;************************************************************************************************ ; ; Mat's Drop V1.2 - tunnel-type game for ION on the TI-83/TI-83+ ; ; V1.2 ; -Added High Scores ; -More optimizing ; ; V1.1 ; -Did some rearranging and optimizing ; -Add filled in tunnel walls ; ; By - Mathew Brenaman 5/1/03 ; MBrenaman@msn.com ; http://www.geocities.com/mbrenaman1982/index.html ; ;************************************************************************************************ .nolist ;remember, first we need the ION Header #include "ion.inc" .list storage =sram shipx =storage ;one byte for ships x position leftwallx =storage+1 ;Left walls current position (one byte) rightwallx =storage+2 ;Right walls current position (one byte) score =storage+3 ;Score (two bytes) #ifdef TI83P .org progstart-2 .db $BB,6D #else .org progstart #endif ;Variables ret jr nc,begin ;where to go to start the program .db "Mats Drop V1.2",0 ;the title begin: ;Do splash screen ld bc,64*256+12 ;b = the sprite is 64 high ;it is 96 wide overall. c = Divide by 8 and we get 12 xor a ;lets just display this sprite at (0,0) ld l,a ld ix,splash_sprite ;load the sprite into register ix call ionLargeSprite ;call the library bcall(_grbufcpy) ;copy the graph buffer to the screen--displaying the sprite ;Wait for enter titleloop: bcall(_GetCSC) cp 09h ;If enter was not pressed jr nz,titleloop ;Clr sceen and INIT stuff bcall(_grbufclr) ;clr the gr buffer ld a,44 ;Set shipx to middle of screen ld (shipx),a ld a,22 ;INIT left and right wall x positions ld (leftwallx),a ld a,74 ld (rightwallx),a ld hl,0000h ;set hl =0 ld (score),hl ;Set score to 0 ;Init Draw of shipship call drawship mainloop: ;Erase ship sprite by drawing onto it call drawship ;Direct Key input ld a,0FFh out (1),a ld a,0FEh out (1),a in a,(1) cp 253 ;If not LEFT then dont move left no clip jr nz,checkrightk ld a,(shipx) ;Store shipx and move left (dec) dec a ld (shipx),a checkrightk: cp 251 ;If not RIGHT then dont move right no clip jr nz,checkcleark ld a,(shipx) ;Store shipx and move right (inc) inc a ld (shipx),a checkcleark: bcall(_getCSC) cp 0Fh ;If not hit clear then continue to loop jr z,quit dodraws: ;Randomize wall sides and clip jp wallshaper wallsdone: ;Draw walls ld b,0 ;set b=x,c=y ld a,(leftwallx) ld c,a call drawline ld a,(rightwallx) ld b,a ;set b=x,c=y ld c,95 call drawline ;Scroll screen down ld hl,grbuf+743 ld de,grbuf+767 ld bc,744 lddr ld hl,grbuf+35 ld c,12 lddr ld hl,grbuf+10 ; clear top row ex de,hl ld c,11 ld (hl),b lddr ;draw ship call drawship call ionFastCopy ;Collision Detection ;Left Side ld e,57 ;load the pixel coordinates here, ;where e=y and a=x in (x,y). ld a,(shipx) ;shipx-1 dec a call ionGetPixel ;call the routine to get pixel and (hl) ;check to see if new dot place on screen is on jr nz,quit ;if so then quit game :( ;Right Side ld e,57 ;load the pixel coordinates here, ;where e=y and a=x in (x,y). ld a,(shipx) ;shipx+8 add a,8 call ionGetPixel ;call the routine to get pixel and (hl) ;check to see if new dot place on screen is on jr nz,quit ;if so then quit game :( ;INC score ld hl,(score) inc hl ld (score),hl ;Do a little delay ld hl,1500 delayloop: dec hl ld a, h or l jr nz, delayloop jp mainloop quit: ;draw ship to erase ship call drawship ;draw explosion ld b,8 ;the sprite is 8 high ld a,(shipx) ;set x,y ld l,53 ; ld ix,explosion_sprite ;load the sprite into register ix call ionPutSprite ;call the library call ionFastCopy ;Show grp buffer quitloop: bcall(_GetCSC) cp 09h ;If enter was not pressed jr nz,quitloop ;Show score bcall(_ClrLCDFull) ld hl,3*256+0 ;Write u died string ld (CurRow),hl ld hl,death_text bcall(_PutS) ld hl,5*256+3 ;Write score string ld (CurRow),hl ld hl,score_text bcall(_PutS) ld hl,4*256+4 ;Write score ld (CurRow),hl ld hl,(score) bcall(_DispHL) ;write high score ld hl,5*256+5 ;text then str ld (CurRow),hl ld hl,high_score_text bcall(_PutS) ld hl,4*256+6 ;Write hight score ld (CurRow),hl ld hl,(highscore) bcall(_DispHL) ld hl,(score) ;ld hl=score ex de,hl ;swap de,hl de=score ld hl,(highscore) ;put hl=highscore bcall(_cphlde) ;if new high write high score to mem jr nc,lookingatscore ex de,hl ;save new high ld (highscore),hl ld hl,4*256+1 ;text then str ld (CurRow),hl ld hl,new_high_score bcall(_PutS) lookingatscore: bcall(_GetCSC) ;Wait for Enter key press (Loop) cp 09h jr nz,lookingatscore ret ;End of main program ;Randomizes the walls and clip wallshaper: ld b,3 call ionRandom ;Load a with either 0,1,2 ld b,a ;save a and a ;If 0 then move left wall over 1 to the left jr nz,checkmoveright ld a,(leftwallx) dec a ld (leftwallx),a checkmoveright: ld a,b ;Restore a cp 2 ;If 0 then move left wall over 1 to the left jr nz,checkmoveleftdone ld a,(leftwallx) inc a ld (leftwallx),a checkmoveleftdone: ld b,3 call ionRandom ;Load a with either 0,1,2 ld b,a ;save a and a ;If 0 then move right wall over 1 to the left jr nz,checkmoveleft ld a,(rightwallx) dec a ld (rightwallx),a checkmoveleft: ld a,b ;Restore a cp 2 ;If 0 then move right wall over 1 to the left jr nz,checkmoverightdone ld a,(rightwallx) inc a ld (rightwallx),a checkmoverightdone: ;Clip walls right,left x ;Clip left wall ld a,(leftwallx) cp 17 ;If wall is >= 17 then dont clip else... jr nc,leftwallclipmax ld a,17 ld (leftwallx),a leftwallclipmax: ld a,(leftwallx) cp 45 ;If wall is < 45 then dont clip else... jr c,leftwallclipdone ld a,45 ld (leftwallx),a leftwallclipdone: ;Clip right wall ld a,(rightwallx) cp 53 ;If wall is >= 53 then dont clip else... jr nc,rightwallclipmax ld a,53 ld (rightwallx),a rightwallclipmax: ld a,(rightwallx) cp 79 ;If wall is < 79 then dont clip else... jr c,rightwallclipdone ld a,79 ld (rightwallx),a rightwallclipdone: jp wallsdone drawship: ld b,8 ;the sprite is 8 high ld a,(shipx) ;set x,y ld l,53 ; ld ix,ship_sprite ;load the sprite into register ix call ionPutSprite ;call the library ret ;draws a line were b=x c=y drawline: ld d,0 ld e,b srl e ; x/8 srl e srl e ld hl,grbuf ; set hl to grbuff at 0,0 add hl,de ; add offset ld a,c sub b inc a ld c,a ld a,b and %00000111 ld b,a ld d,%10000000 ; mask ld a,(hl) jr z,linel2 linel1: srl d djnz linel1 linel2: or d ; draw pixel dec c jr z,linefinish rrc d ; shift mask jr nc,linel2 ld (hl),a inc hl ld a,(hl) jr linel2 linefinish: ld (hl),a ret .end .end ;highscore highscore: .dw 0 ;Strings score_text: .db "Score-",0 high_score_text: .db "High-",0 new_high_score: .db "New High!",0 death_text: .db "You Died :(",0 ;Sprites ship_sprite: .db %00011000 .db %00011000 .db %00111100 .db %10100101 .db %10100101 .db %10111101 .db %11111111 .db %11111111 explosion_sprite: .db %10010001 .db %00000000 .db %01010100 .db %00011000 .db %10011010 .db %00010000 .db %01000100 .db %00010001 ;Spalsh screen Width:96 Height:64 (768 bytes) splash_sprite: .db 0,0,0,0,0,0,0,0,0,0,0,0 .db 0,0,0,0,0,0,0,0,0,0,0,0 .db 0,0,2,32,16,56,0,10,0,0,0,0 .db 0,0,3,96,144,36,0,10,67,0,0,0 .db 0,0,3,111,215,37,221,202,64,128,0,0 .db 0,0,3,106,149,37,85,74,192,128,0,0 .db 0,0,3,166,132,37,85,74,65,0,0,0 .db 0,0,2,170,130,37,21,68,66,0,0,0 .db 0,0,2,170,129,37,21,68,66,0,0,0 .db 0,0,2,170,133,37,21,68,74,0,0,0 .db 0,0,2,174,199,57,29,196,75,128,0,0 .db 0,0,0,0,0,0,1,0,0,0,0,0 .db 0,0,0,0,0,0,1,0,0,0,0,0 .db 0,0,0,0,0,0,0,0,0,0,0,0 .db 0,0,0,0,0,0,0,0,0,0,0,0 .db 0,3,1,65,32,0,96,0,0,0,0,0 .db 0,2,169,205,177,34,85,38,54,141,128,0 .db 0,3,41,213,42,170,102,85,85,85,64,0 .db 0,2,145,85,43,42,84,101,85,85,64,0 .db 0,3,33,76,169,148,100,53,52,77,64,0 .db 0,0,0,0,0,0,0,0,0,0,0,0 .db 0,0,0,0,0,0,0,0,0,0,0,0 .db 0,0,0,0,0,0,0,0,0,0,0,0 .db 0,0,0,0,0,0,0,0,0,16,0,0 .db 0,0,0,0,0,0,0,0,0,48,0,0 .db 0,0,0,8,0,0,0,0,0,48,0,0 .db 0,0,0,24,0,0,0,0,0,112,0,7 .db 0,0,0,20,0,0,0,0,0,120,0,60 .db 0,0,0,20,0,0,0,0,0,252,63,224 .db 0,0,0,52,4,0,0,0,1,255,224,8 .db 0,0,0,34,12,0,0,0,3,254,0,0 .db 0,0,0,34,12,0,0,0,7,224,0,66 .db 0,0,0,66,28,0,0,0,30,144,132,0 .db 0,0,0,69,30,15,128,0,58,2,0,5 .db 0,0,0,67,62,56,224,0,232,64,32,18 .db 224,0,224,133,127,96,184,3,213,20,1,5 .db 92,1,255,10,255,193,94,14,168,64,128,42 .db 42,3,255,5,255,130,171,187,85,20,16,149 .db 5,239,254,10,255,1,87,244,170,170,130,42 .db 2,95,254,21,254,10,175,255,255,255,255,245 .db 8,43,252,75,248,31,255,255,255,255,255,255 .db 18,213,125,191,255,255,255,255,255,255,255,255 .db 86,8,175,255,255,255,255,255,255,255,255,255 .db 42,12,87,255,255,255,255,255,255,255,255,255 .db 124,6,11,255,255,255,255,255,255,255,255,255 .db 22,0,5,127,255,255,255,255,255,255,255,255 .db 0,5,64,147,255,255,255,255,255,255,255,255 .db 16,88,0,5,63,255,255,255,255,255,255,255 .db 160,0,4,0,83,255,255,255,255,255,255,254 .db 2,139,128,8,4,255,255,255,255,255,255,254 .db 192,28,225,74,33,79,255,255,255,255,255,245 .db 5,100,16,5,18,21,95,255,255,255,255,234 .db 64,162,130,0,48,128,163,255,255,255,255,81 .db 160,134,40,66,131,0,84,255,255,255,250,132 .db 241,136,53,14,128,96,133,147,255,249,84,8 .db 70,16,134,76,66,16,128,36,127,164,128,33 .db 184,64,172,3,80,234,90,10,188,144,1,4 .db 7,44,65,148,34,172,0,13,2,0,0,0 .db 185,136,144,162,252,22,0,4,0,71,0,33 .db 160,160,4,72,168,64,33,54,0,40,32,4 .db 123,132,65,225,159,224,4,8,225,200,0,0 .db 122,72,10,164,132,78,136,3,134,0,1,1 .db 183,152,150,172,75,180,32,80,32,32,0,8 .db 116,165,1,4,128,44,20,128,1,0,136,68 ;EOF