; last modif 08/23/98 02:11pm EST .NOLIST #define equ .equ #define EQU .equ #define end .end #include "ti83asm.inc" #include "sos.inc" .LIST ; see comment below GET_KEY = $4014 K_DEL = $38 ballx = $8265 bally = $8266 blockcnt = $8267 score = $8268 tmpx = $826A ; used in movelt/rt .org 9327h xor a ; reset that dang carry flag for a sbc hl,hl jr z,main .dw libraries-$9327 .dw ttl ;------------------------------------------- main: ; call _runIndicOff ; SOS already did this ; call _clrLCDFull ; lemme explain : ; or a ; 1 byte ; sbc hl,hl ; 2 bytes ; 3 bytes, and 19 cpu cycle ! ; let's do this : ; ld hl, 0 ; 3 bytes, 10 cpu cycles ! ; lemme explain sbc hl,hl ; 2 bytes, who cares how many cycles here ld (score),hl ; Title Screen ; set 3,(iy+$05) ld de,2 ld hl,name call DispText res 3,(iy+$05) ld de,30*256+4 ld hl,AuthorStr call vDispText ld de,37*256+7 ; ld hl,AuthorWeb call vDispText ld de,57*256+0 ld hl,HighScr call vDispText ld de,57*256+45 ld hl,(HighS) call SdispHL ld de,57*256+62 ld hl,HighName call vDispText call _getkey ; not exacly a good idea.... ;------------- ; call _GRBUFclr ld hl,0*256+44 ld (ballx),hl Initialize: call RandomBlocks ld hl, (score) add hl, hl ; hl=score*2 ld a, 24 sub h ; a=0 if sc<128, 1 if 128<=sc<256, ... ld b, a ScrollDLoop: ; ld a, b ; 4 c, 1 b ; ld (blockcnt), a ; 7 c, 3 b push bc ; 11 c, 1 b call Scroll_U call check_coll ; check collisions & gravity stuff call put_ball ; put ball (xor) call fastcopy ei call put_ball ; remove ball (xor) HALT ; one halt, try to go always at same speed Continue: ld a,$BF out ($01),a in a,($01) cp 191 jr nz,nopause call _GetK pause: call _GetK or a jr z,pause nopause: ; check clear : ld a, $fd ; clear row out (1), a in a, (1) and $40 pop bc ; 10 c, 1 b jp z, show_sc ld a, $fe out (1), a in a, (1) bit 1,a jr z, moveleft bit 2,a jr z, moveright donemv: ; ld a, (blockcnt) ; 7 c, 3 b ; ld b, a ; 4 c, 1 b djnz ScrollDLoop jr Initialize moveleft: ld a, (ballx) sub 2 jr c, donemv ; exit if we're already at left side ld (tmpx), a jr x_check moveright: ld hl, ballx ld a, (hl) add a,2 cp 96-4 jr nc, donemv ; exit if we're already at right side ld (tmpx), a add a, 5 ; we check right side x_check: push af ld a, (bally) ld e, a pop af call getphysaddr ld a, (hl) or a jr nz, donemv ; don't move if there is something in the way ld de, 5*12 add hl, de ; same stuff if there's something a bit lower ld a, (hl) or a jr nz, donemv ld a, (tmpx) ld (ballx), a ; else move the ball jr donemv RandomBlocks: ld b, 12 ; 12 blocks max to put ld hl, $8e29+(60*12) ; where to put blocks rb_loop: push bc push hl ld b, 5 call vector1 ; one luck on 5 to have a hole pop hl or a ; put a space ? jr z, rb_djnz ; yeah, so skip it ; else put the brick ld ix, block ld de, 12 ld b, 4 ; 4 lines to put push hl rb_putloop: ld a, (ix+0) ld (hl), a inc ix add hl, de djnz rb_putloop pop hl rb_djnz: inc hl pop bc djnz rb_loop ; now, check there is at least one hole ;; ld hl, $8e29+(60*12) ; not needed : works as well with second row ld b, 12 xor a ; c used as number of bricks counter rb_cloop: ; check loop ld c,(hl) rrc c adc a, 0 djnz rb_cloop cp 12 ; if less than 12 brick ( so at least one hole) ret c ; then exit ld b, a ; a was 12 if we didn't exit call vector1 ; put a hole somewhere ld hl, $8e29+(60*12) ld d, 0 ld e, a add hl, de ; find where to put the hole ld b, 4 ; 4 rows to clear ld e, 12 ; d = 0 rb_cl_loop: ; clear loop ld (hl), d ; d = 0 add hl, de ; next row djnz rb_cl_loop ret Scroll_U: ; [?16228? Clock Cycles] LD HL, $8e29+12 ; Copy from one row below top LD DE, $8e29 ; to top row LD BC, 756 ; 756 bytes LDIR LD H, D ; Fill Blanks LD L, E INC E LD (HL), B LD C, 11 LDIR RET check_coll: ; gravity and collision stuff : ld a, (bally) add a, 6 ld e,a ld a, (ballx) call getphysaddr ; check left ld a, (hl) or a ; can move down ? jr nz, cc_downno ; no ==> move it up ld a, (ballx) and 7 cp 3 ; if < 3, then same block lt&rt jr c, cc_movedn ; so skip this check inc hl ; check right ld a, (hl) dec hl or a ; can move down ? jr nz, cc_downno ; no ==> move it up cc_movedn: ld hl,(score) ; increase the score inc hl ld (score),hl ld hl, bally ; move the ball down inc (hl) ld a, (hl) cp 60-5 ; is it too far down ? ret c ; no : ok dec (hl) ; else stay where it was ret cc_downno: ; if the ball can't move down ; a short check to see it it must really go up, or if it can stay where it is ld de, -12 add hl, de ; go one line upper ld a, (hl) ; check left or a ; something down ? jr nz, cc_mvup ; yeah ==> move up ld a, (ballx) and 7 cp 3 ; if < 3, then same block lt&rt ret c ; so skip this check inc hl ; check right ld a, (hl) ret z cc_mvup: ld hl, bally dec (hl) ld a, (hl) and $80 ; check if y<0 ret z ; if ball is out of the screen, you've loose loose: call _clrLCDFull ld hl, loostxt pop de ; don't return to the main loop pop de ; bc has been pushed in the main loop ld de,$0202 call DispText show_sc: ld de,$0003 ld hl,scoretxt call DispText ld hl,(score) call _disphl call GET_KEY ; flush keypress buffer CheckHigh: ld de,(HighS) ld hl,(score) call ScoreChk or a jp nz,EndLoop ld (HighS),hl ld hl,4 ld (curRow),hl ld hl,NHSMsg call _puts jp NameEnter EndLoop: call _getkey cp $05 ; wait 4 a key except arrows jr c,EndLoop ret NameEnter: ld hl,6 ld (currow),hl ld hl,HighName push hl ld b,9 space_loop: ld (hl), ' ' inc hl djnz space_loop pop ix enter_name_loop: call GET_KEY or A jr z,enter_name_loop cp K_DEL jr z,backup sub 9 ret z dec a jp m,enter_name_loop ld hl,chartable ld e,a ld d,0 add hl,de ld a,9 cp b jr z,enter_name_loop ld a,(hl) or a jr z,enter_name_loop ld (ix),a call _putc inc b inc ix jr enter_name_loop backup: xor a cp b jr z,enter_name_loop dec b dec ix ld a,' ' ld (ix),a ld hl,curcol dec (hl) call _putc dec (hl) jr enter_name_loop getphysaddr: ; get physic address from x/y ; input : e=y, a=x ; output : hl = addr ld hl,0 ; Do y*12 ld d,h add hl,de add hl,de add hl,de add hl,hl add hl,hl ld e,a ; do x/8 srl e srl e srl e add hl,de ; d was already 0 ld de, $8e29 add hl, de ret vDispText: ld (pencol),de jp _vputs DispText: ld ($800c), de jp _puts SdispHL: ld (penCol),de ld a, h or l jr z,Disp0 call _setxxxxop2 call _op2toop1 jp _dispop1a Disp0: ld a,'0' jp _vputmap chartable: .db ":WRMH." .DB "..0VQLG!..ZUPKFC" .DB ". YTOJEBX.>SNIDA" .DB ".12345.." put_ball: ld a, (bally) ld l, a ld a, (ballx) ld ix, ballspr ld b,8 jp vector0 name: .db $f1," " ttl: .db "FallDown 1.3 ",$f1,0 loostxt: .db "* Game Over *",0 HighScr: .db "High " scoretxt: .db "Score: ",0 AuthorStr: .db "By Ahmed E. and Florent Dh.",0 AuthorWeb: .db "Idea: Thomas FERNIQUE ",0 NHSMsg: .db "New High! Name?",0 HighName: .db "Ahmed E. ",0 Block: .db %11111111 .db %10000001 .db %10111111 .db %11111111 ballspr: .db %01111000 .db %10110100 .db %11001100 .db %11001100 .db %10110100 .db %01111000 .db %00000000 .db %00000000 libraries: .db "ZLIB",0 HighS: .db 0,0 .db 0,lib1,vec0 .db "ZLIB",0,0,0,0,lib2,vec1 .db "ZLIB",0,0,0,0,libD,vec2 .db "ZGFXL",0,0,0,lib2,vec3 .db $FF scorechk = vector2 fastCopy =vector3 .end END