home *** CD-ROM | disk | FTP | other *** search
- #include "ti86asm.inc"
- #include "asm86.h"
-
- .org _asm_exec_ram
-
- begin:
- call _clrLCD
- ld a,0
- ld (p1_pos),a
- call dispp1
- ld a,7
- ld (p2_pos),a
- call dispp2
- ld a,0
- ld (shot1),a
- ld (shot2),a
- ld a,10
- ld (hit1),a
- ld (hit2),a
- call _runindicoff
- ld hl,menu_table
-
- ;===========================================================
- ; DoMenu -- Bar menu routine
- ; Clears the screen and displays a table driven bar menu
- ;
- ; A CCCC ZZZZZ
- ; A A C ZZ
- ; AAAAA C ZZ
- ; A A CCCC ZZZZZ
- ;
- ; Welcom fellow coder to the routines of the ACZ...
- ; Assembly Coders Zenith is a new group that will further TI
- ; assembly programming on all platforms. This is the first
- ; released routine from one of their up comming games and it
- ; will not be the last. Be ready for us, here we come...
- ; CLEM, Dux Gregis, Dave Scheltema, David Phillips, and Jbrett.
- ;
- ;
- ; Coded by:
- : David Phillips <electrum@tfs.net> aka Electrum
- ; David Scheltema <scheltem@aaps.k12.mi.us> aka zoomBlock
- ;
- ; input: HL = menu table
- ; output: chosen table address jumped to
- ;
- ; example table:
- ; .db 2 ; num entries
- ; .dw "My menu",0 ; title text (at the top)
- ; .dw "First thing",0 ; text for each entry
- ; .dw "Second one",0 ; ...
- ; .dw Option1 ; pointers (labels) to jump
- ; .dw Option2 ; to for each entry in menu
- ;
- ; Note: routine must be jumped to!
- ;===========================================================
- DoMenu:
- push hl ; _clrLCD destroys hl
- call _clrLCD ; clears the screen
- pop hl ; now restore it
- ld c,(hl) ; get number of entries
- inc hl ; move to menu title text
- ld de,$0001 ; draw at top, one char right
- ld (_penCol),de ; set the small font coords
- call _vputs ; print the title text
- push hl ; save pointer
- ld hl,$fc00 ; point to video ram
- call DoMenuInv ; invert the top line
- pop hl ; restore our pointer
- ld b,c ; load num entries for loop
- ld de,$0729 ; start printing at middle of second line
- DoMenuDTL:
- ld (_penCol),de ; set the font coords
- call _vputs ; print the menu text
- ld a,d ; get the vertical coord
- add a,7 ; move to next line
- ld d,a ; save new coord
- djnz DoMenuDTL ; draw all the text
- push hl ; save pointer
- ld b,1 ; start menu at first entry
- call DoMenuInvBar ; invert it
- DoMenuL:
- push bc ; save entries and current entry
- call _getky ; same as GET_KEY
- pop bc ; restore it
- cp K_UP ; did they press up?
- jr z,DoMenuUp ; move menu bar up
- cp K_DOWN ; or was it down?
- jr z,DoMenuDown ; then move the bar down
- cp K_SECOND ; did they hit 2nd?
- jr z,DoMenuSelect ; then they want it
- cp K_ENTER ; some people like enter
- jr z,DoMenuSelect ; so check it too
- jr DoMenuL ; they're just sitting there, loop again
- DoMenuUp:
- call DoMenuInvBar ; invert current selection back to normal
- dec b ; move up
- jr nz,DoMenuBar ; if it's zero, we're at the top
- ld b,c ; so move to the bottom
- jr DoMenuBar ; handle menu bar
- DoMenuDown:
- call DoMenuInvBar ; same as up, go back to normal text
- ld a,c ; get current entry for check
- cp b ; at the bottom?
- jr z,DoMenuDownT ; the move to the top
- inc b ; move down
- jr DoMenuBar ; handle menu bar
- DoMenuDownT:
- ld b,1 ; move to the top
- DoMenuBar:
- call DoMenuInvBar ; invert the new selection
- jr DoMenuL ; now it's time to loop
- DoMenuInvBar:
- push hl ; save pointer
- push bc ; save position and entries
- ld h,b ; get position
- ld l,112 ; there are 7 lines of 16 bytes each (7*16 = 112)
- call MUL_HL ; do the multiply
- ld de,$fc00 ; we need to add to video memory
- add hl,de ; do the add
- call DoMenuInv ; invert the line
- pop bc ; restore position and entries
- pop hl ; restore pointer
- ret ; done inverting
- DoMenuInv:
- ld b,7*16 ; each row is 16 bytes wide and text is 7 rows high
- DoMenuIL:
- ld a,(hl) ; get the byte
- cpl ; NOT the byte--flips all the bits
- ld (hl),a ; save the new byte
- inc hl ; next byte
- djnz DoMenuIL ; loop for all bytes
- ret ; we're done with the invert loop
- DoMenuSelect:
- pop hl ; restore the pointer
- ld d,0 ; clear upper byte
- ld e,b ; load lower byte with current selection
- dec e ; decrease, starting at 0 instead of 1
- sla e ; multiply by 2, pointers are 16-bit (2 bytes)
- add hl,de ; add to get correct address in the jump table
- ld a,(hl) ; get lower byte of pointer
- inc hl ; next byte
- ld h,(hl) ; get upper byte of pointer
- ld l,a ; complete pointer with lower byte
- jp (hl) ; jump to the address from the table--hl, not (hl
-
- loop1:
- call _clrScrn
- ld b,0
- ld c,10
- ld (_penCol),bc
- ld a,(hit1)
- call dispa
- ld c,106
- ld (_penCol),bc
- ld a,(hit2)
- call dispa
- loop:
- call dispp1
- call dispp2
- call GET_KEY
- cp K_GRAPH
- jr z,down1
- cp K_SECOND
- jr z,up1
- cp K_STO
- jp z,shoot1
- cp K_PLUS
- jp z,down2
- cp K_STAR
- jp z,up2
- cp K_F5
- jp z,shoot2
- cp K_EXIT
- jp z,begin
- ld a,(shot1)
- cp 1
- jp z,inc_shot_1
- loop2:
- ld a,(shot2)
- cp 1
- jp z,inc_shot_2
- jr loop
-
- dispa:
- ld l,a
- ld h,0
- xor a
- ld de,-1
- ld (_curRow),de
- call 4A33h
- dec hl
- jp _vputs
-
- dispp1:
- ld e,0
- ld a,(p1_pos)
- ld d,a
- ld hl,$fc00
- ld bc,player1
- call GridPutSprite
- ret
- dispp2:
- ld e,15
- ld a,(p2_pos)
- ld d,a
- ld hl,$fc00
- ld bc,player2
- call GridPutSprite
- ret
-
- down1:
- ld a,(p1_pos)
- cp 7
- jp z,loop
- ld e,0
- call draw_blank1
- ld a,(p1_pos)
- inc a
- ld (p1_pos),a
- call dispp1
- jp loop
- up1:
- ld a,(p1_pos)
- cp 0
- jp z,loop
- ld e,0
- call draw_blank1
- ld a,(p1_pos)
- dec a
- ld (p1_pos),a
- call dispp1
- jp loop
-
- draw_blank1:
- ld d,a
- ld bc,blank
- ld hl,$fc00
- call GridPutSprite
- ret
-
- down2:
- ld a,(p2_pos)
- cp 7
- jp z,loop
- ld e,15
- call draw_blank1
- ld a,(p2_pos)
- inc a
- ld (p2_pos),a
- call dispp2
- jp loop
- up2:
- ld a,(p2_pos)
- cp 0
- jp z,loop
- ld e,15
- call draw_blank1
- ld a,(p2_pos)
- dec a
- ld (p2_pos),a
- call dispp2
- jp loop
-
- shoot1:
- ld a,(shot1)
- cp 1
- jp z,loop
- ld a,1
- ld (shot1),a
- ld a,(p1_pos)
- ld (shot1v),a
- ld d,a
- ld a,1
- ld (shot1h),a
- ld e,a
- ld bc,fire1
- ld hl,$fc00
- call GridPutSprite
- ld a,0
- ld (s1),a
- jp loop2
- inc_shot_1:
- ld a,(s1)
- cp 150
- jr c,inc1
- ld a,0
- ld (s1),a
- ld a,(shot1h)
- cp 15
- jr z,no_shot1
- ld a,(shot1v)
- ld d,a
- ld a,(shot1h)
- ld e,a
- ld bc,blank
- ld hl,$fc00
- call GridPutSprite
- ld a,(shot1v)
- ld d,a
- ld a,(shot1h)
- inc a
- ld (shot1h),a
- ld e,a
- ld bc,fire1
- ld hl,$fc00
- call GridPutSprite
- jp loop2
- no_shot1:
- ld a,(shot1v)
- ld b,a
- ld a,(p2_pos)
- cp b
- jp z,one_hit_2
- ld a,(shot1v)
- ld d,a
- ld a,(shot1h)
- ld e,a
- ld bc,blank
- ld hl,$fc00
- call GridPutSprite
- ld a,0
- ld (shot1),a
- jp loop2
- inc1:
- inc a
- ld (s1),a
- jp loop2
-
- shoot2:
- ld a,(shot2)
- cp 1
- jp z,loop
- ld a,1
- ld (shot2),a
- ld a,(p2_pos)
- ld (shot2v),a
- ld d,a
- ld a,14
- ld (shot2h),a
- ld e,a
- ld bc,fire1
- ld hl,$fc00
- call GridPutSprite
- ld a,0
- ld (s2),a
- jp loop
- inc_shot_2:
- ld a,(s2)
- cp 150
- jr c,inc2
- ld a,0
- ld (s2),a
- ld a,(shot2h)
- cp 0
- jr z,no_shot2
- ld a,(shot2v)
- ld d,a
- ld a,(shot2h)
- ld e,a
- ld bc,blank
- ld hl,$fc00
- call GridPutSprite
- ld a,(shot2v)
- ld d,a
- ld a,(shot2h)
- dec a
- ld (shot2h),a
- ld e,a
- ld bc,fire1
- ld hl,$fc00
- call GridPutSprite
- jp loop
- no_shot2:
- ld a,(shot2v)
- ld b,a
- ld a,(p1_pos)
- cp b
- jp z,two_hit_1
- ld a,(shot2v)
- ld d,a
- ld a,(shot2h)
- ld e,a
- ld bc,blank
- ld hl,$fc00
- call GridPutSprite
- ld a,0
- ld (shot2),a
- jp loop
- inc2:
- inc a
- ld (s2),a
- jp loop
-
- two_hit_1:
- ld a,(hit1)
- dec a
- ld (hit1),a
- cp 0
- jr z,fight_over
- ld a,0
- ld (shot2),a
- jp loop1
- one_hit_2:
- ld a,(hit2)
- dec a
- ld (hit2),a
- cp 0
- jr z,fight_over
- ld a,0
- ld (shot1),a
- jp loop1
-
- fight_over:
- ld a,(hit2)
- cp 0
- jr z,fo1
- ld a,(hit1)
- cp 0
- jr z,fo2
- fo1:
- ld hl,p1_wins
- jr over
- fo2:
- ld hl,p2_wins
- over:
- call _homeup
- call _puts
- call $4d43
- jp begin
- exit:
- call _clrLCD
- call _homeup
- ret
-
- keys:
- call _clrScrn
- call _flushallmenus
- call _homeup
- ld hl,keys_text
- call _puts
- ld a,01ch
- call _putc
- call $4d43
- call _clrLCD
- call _homeup
- ld hl,keys_text2
- call _puts
- call $4d43
- jp begin
-
- ;=====================================================================
- ; GridPutSprite:
- ; Puts an aligned sprite at (E, D), where BC -> Sprite
- ;=====================================================================
- ; IN : D = y (0-7 inclusive)
- ; E = x (0-15 inclusive)
- ; BC -> sprite
- ; HL -> screen buffer to draw to ($fc00)
- ;
- ; OUT: AF, BC, DE, HL modified
- ; Current total : 44b/289t (not counting ret)
- ;=====================================================================
- GridPutSprite:
- srl d ; de = 128y+x (16 bytes/row, 8 rows)
- rra
- and $80
- or e ; add x offset (remember x <= 15)
- ld e,a
- add hl,de ; hl-> address + offset
- ld de,$10 ; initialize line increment
- ld a,(bc) ; get byte from sprite
- ld (hl),a ; put byte on screen
- inc bc ; move to next byte in sprite
- add hl,de ; move to next line on screen
- ld a,(bc) ; {2}
- ld (hl),a ; ...
- inc bc ; ..
- add hl,de ; .
- ld a,(bc) ; {3}
- ld (hl),a ; ...
- inc bc ; ..
- add hl,de ; .
- ld a,(bc) ; {4}
- ld (hl),a ; ...
- inc bc ; ..
- add hl,de ; .
- ld a,(bc) ; {5}
- ld (hl),a ; ...
- inc bc ; ..
- add hl,de ; .
- ld a,(bc) ; {6}
- ld (hl),a ; ...
- inc bc ; ..
- add hl,de ; .
- ld a,(bc) ; {7}
- ld (hl),a ; ...
- inc bc ; ..
- add hl,de ; .
- ld a,(bc) ; {8}
- ld (hl),a ; ...
- ret
-
- p1_wins: .db "Player 1 wins!",0
- p2_wins: .db "Player 2 wins!",0
-
- keys_text:
- .db "Player 1: "
- .db " "
- .db "UP................2ND"
- .db "DOWN.............GRPH"
- .db "SHOOT...............",0
- keys_text2:
- .db "Player 2: "
- .db " "
- .db "UP..................*"
- .db "DOWN................+"
- .db "SHOOT..............F5",0
-
- p1_pos: .db 0
- p2_pos: .db 0
- shot1: .db 0
- shot1v: .db 0
- shot1h: .db 0
- s1: .db 0
- shot2: .db 0
- shot2v: .db 0
- shot2h: .db 0
- s2: .db 0
- hit1: .db 0
- hit2: .db 0
-
- menu_table:
- .db 3
- .db " WAR86!",0
- .db "Play",0
- .db "Keys",0
- .db "Exit",0
- .dw loop1
- .dw keys
- .dw exit
-
- player1:
- .db %10011000
- .db %11011000
- .db %11111100
- .db %11111011
- .db %11111011
- .db %11111100
- .db %11011000
- .db %10011000
-
- player2:
- .db %00011001
- .db %00011011
- .db %00111111
- .db %11011111
- .db %11011111
- .db %00111111
- .db %00011011
- .db %00011001
-
- blank:
- .db %00000000
- .db %00000000
- .db %00000000
- .db %00000000
- .db %00000000
- .db %00000000
- .db %00000000
- .db %00000000
-
- fire1:
- .db %00000000
- .db %00000000
- .db %00000000
- .db %11111111
- .db %00000000
- .db %00000000
- .db %00000000
- .db %00000000
-
- .end
-