;Most of my programs/games are just helping me learn. so dont expect much :) im learning alot from making this! ;this is as close to a real game as i have gotten yet. its not fun, but it helped me with learning collision detection ;(my formula still sucks real bad, but it worked.) and so there isnt much to this game yet. dont think i will even add on (maybe) ;just because its coded bad and will be hard to expand. i commented some of the first lines, but got lazy and stopped ;hope this can help anyone. but dont try to take my code as a good example, im just learning. so my code is quite rough ;and for lack of better words, a piece of shit. but hey :P oh well. ill get better! ;comments/questions -- doomsday2001@hotmail.com include "doorsos.h" ; general ROM calls include "graphlib.h" ; clr_scr function include "userlib.h" ; idle_loop xdef _main ; define program entry point xdef _comment ; define program comment xdef _ti89 ; compile for TI-89 xdef _exit ; mask0 equ %11111110 ;(up\2nd\donw...) mask1 equ %11111101 ;(Enter\clear...) mask2 equ %11111011 ;( <- ) mask3 equ %11110111 ;(catalog...) mask4 equ %11101111 ;(Mode...) mask5 equ %11011111 ;(Home...) mask6 equ %10111111 ;(ESC...) DrawSpr Macro ;macro i made for putting sprites move.w \1,d0 ;use "DrawSpr #,#,sprite name" to draw it at x,y move.w \2,d1 move.l #\3,a0 jsr graphlib::put_sprite ENDM delay: ;loop to delay the game, so it doesnt go to fast. move.w #0,d0 delay_repeat: add.w #1,d0 cmp delay_len,d0 ;delay_len is speed, higher the number, the slower the game goes bne delay_repeat rts _main: ;start of program move.w #0,nme_boom move.w #150,exp_timer jsr graphlib::clr_scr ;clears the screen WriteStr #1,#1,#2,enter jsr userlib::idle_loop jsr graphlib::clr_scr ;clears the screen keyloop: bra getkey ;goto getkey nextloop: bsr getpos ;gets enemies position bsr display bsr test_collision cmp.w #1,keytag beq change_speed move.w #2000,delay_len bra game_speed change_speed: move.w #750,delay_len move.w #0,keytag game_speed: bsr delay ;goto delay (delays the program for amount of time) bra keyloop ;go back to mainloop getkey: move.w #mask0,d0 ;move key mask 0 into d0 (keys 2nd, left, right, up, down, etc.) bsr get_key ;goes to get_key, which will put the key that was pushed into d0 btst.b #0,d0 ;test to see if up was pressed beq keyup ;up was pressed, goto keyup, else goto next line btst.b #2,d0 ;test to see if down was pressed beq keydown ;down was pressed, goto keydown, else goto next line btst.b #1,d0 ;check left beq keyleft ;left pressed btst.b #3,d0 ;check right beq keyright ;right pressed btst.b #4,d0 ;check 2nd beq key2nd ;2nd pressed move.b #mask6,d0 ;put key mask 6 into d0, thats the esc key mask bsr get_key btst.b #0,d0 ;check esc. beq _exit ;esc pressed, else goto next line tst2nd: move.w #mask0,d0 ;move key mask 0 into d0 (keys 2nd, left, right, up, down, etc.) bsr get_key ;goes to get_key, which will put the key that was pushed into d0 btst.b #4,d0 ;check 2nd beq key2nd ;2nd pressed endgetkey: bra nextloop ;go back to mainloop get_key: move.b d0,($600019) ;keypad located at $600019 (wr) $60001b (re). move.w #50,d0 ;give 89 time to store key press, about 50 loops delay_c: dbra d0,delay_c ;loop 50 times move.b $60001b,d0 ;gives bit stored into d0 i.e. bit 1-7 rts keyup: ;put instructions for when user presses up move.w #1,keytag sub.w #1,y cmp.w #1,y beq endup bra tst2nd endup: move.w #2,y bra tst2nd keydown: ;put instructions for when user presses down move.w #1,keytag add.w #1,y cmp.w #84,y beq enddown bra tst2nd enddown: move.w #83,y bra tst2nd keyleft: ;put instructions for when user presses left bra tst2nd keyright: ;put instructions for when user presses right bra tst2nd key2nd: ;put instructions for when user presses 2nd move.w #1,keytag cmp.w #2,bullet beq endgetkey move.w y,bullety add.w #5,bullety move.w #2,bullet bra endgetkey test_collision: cmp.w #27,bulletx bcc _exit cmp.w #5,bulletx bls _exit move.w bullety,d0 move.w enemyy,d1 cmp.w d0,d1 bcc _exit add.w #16,d1 cmp.w d0,d1 bls _exit bra ithit rts ithit: move.w #2,nme_boom rts getpos: cmp.w #0,nme_boom bne _exit cmp.w #1,nmedir beq nmedown bra nmeup nmedown: add.w #1,enemyy cmp.w #84,enemyy bne _exit move.w #2,nmedir rts nmeup: sub.w #1,enemyy cmp.w #1,enemyy bne _exit move.w #1,nmedir rts display: DrawSpr #144,y,gun cmp.w #0,nme_boom bne draw_boom DrawSpr enemyx,enemyy,enemys bulletst: cmp.w #1,bullet beq _exit DrawSpr bulletx,bullety,bullets sub.w #1,bulletx cmp.w #1,bulletx beq endbullet rts draw_boom: cmp.w #150,exp_timer beq erase_nme finish_boom: sub.w #1,exp_timer cmp.w #1,exp_timer beq boomfinish cmp.w #125,exp_timer beq erase_boom finish_boom2: cmp.w #100,exp_timer bcs erase_boom2 cmp.w #125,exp_timer bcc dboom1 cmp.w #125,exp_timer bcs dboom2 erase_nme: DrawSpr enemyx,enemyy,enemysd bra finish_boom erase_boom: DrawSpr enemyx,enemyy,enemysd bra finish_boom2 erase_boom2: DrawSpr enemyx,enemyy,enemysd bra bulletst dboom1: DrawSpr enemyx,enemyy,explode bra bulletst dboom2: DrawSpr enemyx,enemyy,explode2 bra bulletst boomfinish: move.w #0,nme_boom move.w #50,exp_timer move.w #30,enemyy bra bulletst endbullet: DrawSpr bulletx,bullety,dbullets move.w #1,bullet move.w #136,bulletx rts _exit: rts ; end of program ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; variable declaration section enter dc.b "Press Enter",0 _comment dc.b "comment",0 ; program comment delay_len dc.w 2000 ;delay (game speed) lower number = faster speed y dc.w 40 bullet dc.w 1 ;tag to see if bullet has been shot (1 no, 2 yes) bullety dc.w 40 bulletx dc.w 136 enemyy dc.w 30 enemyx dc.w 10 nmedir dc.w 1 ;direction of enemy 1=down, 2=up keytag dc.w 0 ;sees if a key is being pressed or was pressed (0=no,1=yes) nme_boom dc.w 0 ;sees if an enemy has died (plays anim) 0=no 1=yes exp_timer dc.w 150 ;timer for explosion of nme gun: dc.w 16 dc.w 2 dc.b %00000000,%00000000 dc.b %00000000,%00000111 dc.b %00000000,%00001111 dc.b %00000000,%00111010 dc.b %00000000,%11111000 dc.b %11100001,%11010101 dc.b %10011111,%10001011 dc.b %11111111,%11111111 dc.b %11111101,%10111111 dc.b %11111111,%01010111 dc.b %11100001,%11101011 dc.b %00000000,%11111010 dc.b %00000000,%00111101 dc.b %00000000,%00001111 dc.b %00000000,%00000111 dc.b %00000000,%00000000 gun_mask dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 bullets: dc.w 6 dc.w 1 dc.b %00000000 dc.b %00110000 dc.b %11111110 dc.b %11111100 dc.b %00110000 dc.b %00000000 bullets_mask dc.b %11111111 dc.b %11111111 dc.b %11111111 dc.b %11111111 dc.b %11111111 dc.b %11111111 dbullets: dc.w 6 dc.w 1 dc.b %00000000 dc.b %00000000 dc.b %00000000 dc.b %00000000 dc.b %00000000 dc.b %00000000 dbullets_mask dc.b %11111111 dc.b %11111111 dc.b %11111111 dc.b %11111111 dc.b %11111111 dc.b %11111111 enemys: dc.w 16 dc.w 2 dc.b %00000000,%00000000 dc.b %00001110,%00000000 dc.b %00111001,%10000000 dc.b %01111100,%11110000 dc.b %01111111,%11111000 dc.b %01111110,%11101100 dc.b %01111110,%11000010 dc.b %01111111,%10000000 dc.b %01111111,%10000000 dc.b %01111110,%11000010 dc.b %01111110,%11101100 dc.b %01011111,%11111000 dc.b %01101111,%11110000 dc.b %00110111,%10000000 dc.b %00001110,%00000000 dc.b %00000000,%00000000 enemys_mask: dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 explode: dc.w 16 dc.w 2 dc.b %00000000,%00000000 dc.b %00000001,%00000000 dc.b %00000001,%10000000 dc.b %00011011,%10000000 dc.b %00011011,%11000000 dc.b %00010111,%11110000 dc.b %00111111,%11111100 dc.b %00111111,%11101110 dc.b %01111111,%10110000 dc.b %00001110,%11010000 dc.b %00101111,%11010000 dc.b %00111111,%11110000 dc.b %00011111,%10000000 dc.b %00001111,%10000000 dc.b %00000000,%00000000 dc.b %00000000,%00000000 explode_mask: dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 explode2: dc.w 16 dc.w 2 dc.b %00000000,%00000000 dc.b %00000000,%00000000 dc.b %00000000,%10000000 dc.b %00000010,%10000000 dc.b %00000000,%10000000 dc.b %00000110,%10010000 dc.b %00100111,%00010000 dc.b %00110111,%11101000 dc.b %01111111,%10110000 dc.b %00001110,%11010000 dc.b %00101111,%11010000 dc.b %00111110,%11110000 dc.b %00000110,%00000000 dc.b %00001111,%00000000 dc.b %00000000,%00000000 dc.b %00000000,%00000000 explode2_mask: dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 enemysd: dc.w 16 dc.w 2 dc.b %00000000,%00000000 dc.b %00000000,%00000000 dc.b %00000000,%00000000 dc.b %00000000,%00000000 dc.b %00000000,%00000000 dc.b %00000000,%00000000 dc.b %00000000,%00000000 dc.b %00000000,%00000000 dc.b %00000000,%00000000 dc.b %00000000,%00000000 dc.b %00000000,%00000000 dc.b %00000000,%00000000 dc.b %00000000,%00000000 dc.b %00000000,%00000000 dc.b %00000000,%00000000 dc.b %00000000,%00000000 enemysd_mask: dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 dc.b %11111111,%11111111 end ; end of the source code