;fix 2nd and hold ;Tetris Attack by Brandon Sterner ;This is a TCPA game ;#define TI83P #include "ion.inc" #define equ .equ #define EQU .equ #define end .end #define x 8265h-$8265+apdram ;1 \miscellaneous purpose #define y 8266h-$8265+apdram ;1 /x and y coors #define time 8267h-$8265+apdram ;1 #define deltime 8268h-$8265+apdram ;1 #define scrollx 8269h-$8265+apdram ;1 how much scrolling has occurred since new pieces #define sx 826ah-$8265+apdram ;1 \these #define sy 826bh-$8265+apdram ;1 /are the x and y of the selector #define curloc 826ch-$8265+apdram ;2 \used at 2 are used ;miscellaneous loc of things #define textloc 826ch-$8265+apdram ;2 /at different times ;location of inverse text #define mode 826eh-$8265+apdram ;1 endless(1) puzzle(0) #define curworld 826fh-$8265+apdram ;2 pointer to decompressed levels #define message 8271h-$8265+apdram ;1 box uses this and decides what to say #define sloc 8272h-$8265+apdram ;2 location of the selector in boardbuff #define dx 8274h-$8265+apdram ;1 x and #define dy 8275h-$8265+apdram ;1 y coors for dissappear becuae dissappear uses sprites too which use x and y #define fmatch 8276h-$8265+apdram ;1 found match (0 if nothing 1 if found) #define keywait 8277h-$8265+apdram ;1 counter for keys avoids multiple keypresses quickly (a little like _getkey but times are different) #define remhl 8278h-$8265+apdram ;2 for storing hl when push/pop aren't a good idea #define remhl2 827ah-$8265+apdram ;2 " #define level 827ch-$8265+apdram ;1 this is where the level# is stored #define movelim 827dh-$8265+apdram ;1 this is the move limit for puzzle mode #define lev 827eh-$8265+apdram ;2 this curworld-31 (the current level's data) #define menmode 8280h-$8265+apdram ;1 this is so we know if to use inverse or not #define score 8282h-$8265+apdram ;2 this is the score counter in endless mode #define textxy 8284h-$8265+apdram ;2 this is the x and y of the inverse text #define option 8286h-$8265+apdram ;1 this the option number that is selected #define options 8287h-$8265+apdram ;1 # of options #define sets 8288h-$8265+apdram ;1 # of times the dissapppear routine is gone through #define page 8289h-$8265+apdram ;1 page # for text #define pointer 828ah-$8265+apdram ;2 location for final password #define second 828ch-$8265+apdram ;1 if 1 then second is being held if 0 then second is pressed for the first time ;*delete* ;#define fpass 828dh ;6 the coors of swaps #define floop 8294h-$8265+apdram ;1 boolean for looping fall *new* #define exbuffer 82f7h-$8265+apdram ;9 bytes for falling? #define lsc 8300h-$8265+apdram ;64 Left Side Column for clipping #define boardbuff 8300h+64-$8265+apdram ;50 everything o #define firstlast 8300h+64+9-$8265+apdram ; part of boardbuff but the last column of the first row on the screen this is so you don't have to compute it #define lastlast 8300h+64+49-$8265+apdram ; " last row " #define boardbuff2 8300h+64+60-$8265+apdram ;50 this is for checking in dissappear and changes are made in boardbuff #define boxtemp 8300h+64+60+60-$8265+apdram ;? red in while box is running #define data op6 .list GET_KEY = _getcsc vidmem .equ plotsscreen #ifdef TI83P .org progstart-2 .db $BB,$6D #else .org progstart #endif ;-----------= Beginning of ASM code =----------- ret jr nc,start description: .db " Tetris Attack ",0 start: prog_start: xor a ld (sets),a ld HL,title ld DE,plotsscreen call DispRLE bcall _grbufcpy ld a,1 ld (keywait),a ld b,60 ld hl,boardbuff del: ld (hl),0 inc hl djnz del ld a,9 ld (scrollx),a ld a,30 ld (deltime),a ld (time),a ld hl,boardbuff ld (sloc),hl ld a,32 ;for text y ld (y),a ;delete anything in lsc del1: ld b,114 ld hl,lsc del2: ld (hl),0 inc hl djnz del2 ;/delete ;title screen drawselecttext: ld a,1 ld (menmode),a ld hl,endtxt ld de,57*256+5 ld a,4 call choosemode xor a ld (menmode),a ;/title ;find what was selected ld a,(option) cp 4 ;endless was picked jp z,loadendless cp 3 ;puzzle picked jp z,loadpuzzle cp 2 ;help picked jr z,loadhelp ret ;by now i know that exit was picked ;/find slowdown: ld b,20 slowdown2: halt djnz slowdown2 ret loadhelp: bcall _grbufclr ;clear graph buffer bcall _grbufcpy ld hl,instructions ld a,1 ld (page),a loadhelp2: xor a ld (x),a ld (y),a ld b,10 loadhelp3: push bc ld de,(x) ld (pencol),de bcall _vputs ld a,(y) add a,6 ld (y),a pop bc djnz loadhelp3 push hl call wait bcall _grbufcpy pop hl ld a,(page) inc a ld (page),a cp 3 jr nz,loadhelp2 ;*deleted some here jp prog_start checkpassword: call message7 ld hl,levels-1 ld ix,passbuff-1 ld b,3 checkp2: push bc inc ix inc hl ld a,(hl) ld d,a ld a,(ix) pop bc cp d jr nz,checkp3 djnz checkp2 jp loadpuzzle2 checkp3: ld a,(level) inc a ld (level),a cp 61 ;stop checking after 50 levels jr z,checkp4 ld hl,(curworld) ld de,3 add hl,de call decomp inc hl ld (curworld),hl dec hl ld b,3 ld ix,passbuff-1 jr checkp2 checkp4: xor a ld (level),a ld hl,levels ld (curworld),hl jp loadpuzzle2 loadpuzzle: xor a ld (mode),a ld (scrollx),a ld (sx),a ld (sy),a ld (level),a ld hl,boardbuff ld (sloc),hl ld hl,levels ld (curworld),hl call message6 ld a,(option) cp 2 jp z,checkpassword loadpuzzle2: ld a,(level) ;increment level cp 60 jr z,puzend inc a ld (level),a ;*delete ; cp 60 ; call z,clearfpass bcall _grbufclr ;clear graph buffer call drbottombar call loadworld bcall _grbufcpy call message3 call drawselector jp puzmain ;*delete* ;clearfpass: ; ld hl,fpass ; ld (pointer),hl ; ld b,6 ;clearfpass2: ; ld (hl),0 ; inc hl ; djnz clearfpass2 ; ret puzend: call box ld hl,wininst ld de,31*256+35 ;*fix* ld (pencol),de bcall _vputs ;*delete* ; ld hl,fpass ; ld (pointer),hl ; ld de,31*256+27 ; ld (pencol),de ; ld b,3 puzend2: ; push bc ; ld hl,(pointer) ; ld a,(hl) ; inc hl ; ld d,a ; ld a,(hl) ; ld e,a ; inc hl ; ld (pointer),hl ; ex de,hl ; call disphl ; ld de,(pencol) ; dec de ; ld (pencol),de ; pop bc ; djnz puzend2 ; ld hl,wininst2 ; ld de,38*256+33 ; ld (pencol),de ; call _vputs call wait jp prog_start decomp: ld ix,boardbuff ld bc,256*1 ld de,60 ;expanded bytes check: ld a,(hl) and b cp b call z,match inc c ld a,128 cp b jr z,nextbyte rl b jr check nextbyte: inc hl ld b,1 jr check match: ld a,c ld (ix),a inc ix ld c,-1 dec de xor a cp e jr z,endexp ret endexp: pop ix inc hl ret loadworld: ld hl,(curworld) ;compressed data ld (lev),hl ld de,passbuff ld bc,3 ldir call decomp ;decompress routine ld a,(hl) ;last byte in level is ld (movelim),a ;the move limit inc hl ld (curworld),hl ;output was next compressed byte in level now i'm storing it ld hl,boardbuff ld (curloc),hl ld a,1 ld (x),a ld (y),a loadworld2: ;draw everything in boardbuff ld hl,(curloc) ld a,(hl) inc hl ld (curloc),hl call interpret2 inc hl ld a,(x) add a,9 ld (x),a cp 91 jr nz,loadworld2 ld a,1 ld (x),a ld a,(y) add a,9 ld (y),a cp 55 jr nz,loadworld2 ret drbottombar: ld HL,bottombar ld DE,plotsscreen jp DispRLE loadendless: bcall _grbufclr ld de,5 ld (score),de call drbottombar ld a,1 ld (mode),a dec a ld (sy),a ld (sx),a call drawselector main: call _scrollright bcall _grbufcpy ;set up checks ld b,0FEh ;loads the proper key column call Direct_Input ;goes to a simple rountine so you have to only use it once. ;check if up was pressed cp %11110111 call z, up ;check if down was pressed cp %11111110 call z, down ;check if left was pressed cp %11111101 call z, left ;check if right was pressed cp %11111011 call z, right ld b,0dfh call Direct_Input ;check if alpha was pressed cp %01111111 call z, fast ;check if clear was pressed ld b,0fdh call Direct_Input cp %10111111 call z,message8 ld b,0bfh call Direct_Input ;check if mode was pressed cp %10111111 call z,message1 ;check if 2nd was pressed cp %11011111 call nz,noswap call z, swap jp main puzmain: bcall _grbufcpy ld a,(movelim) cp 0 jp z,message5 ;set up checks ld b,0FEh ;loads the proper key column call Direct_Input ;check if up was pressed cp %11110111 call z, up ;check if down was pressed cp %11111110 call z, down ;check if left was pressed cp %11111101 call z, left ;check if right was pressed cp %11111011 call z, right ;check if clear was pressed ld b,0fdh call Direct_Input cp %10111111 call z,message4 ld b,0bfh call Direct_Input ;check if mode was pressed cp %10111111 call z,message4 ;check if 2nd was pressed cp %11011111 call nz,noswap call z,swap jp puzmain noswap: ld a,0 ld (second),a cp 1 ret keywaiter: ld a,(keywait) dec a ld (keywait),a or a ret nz ld a,3 ld (keywait),a ret left: call keywaiter ret nz ld a,(sx) cp 9 jr z,left2 ret c left2: ld hl,(sloc) dec hl ld (sloc),hl call drawselector ld a,(sx) add a,-9 ld (sx),a jp drawselector right: call keywaiter ret nz ld a,(sx) cp 74 ret nc ld hl,(sloc) inc hl ld (sloc),hl call drawselector ld a,(sx) add a,9 ld (sx),a jp drawselector up: call keywaiter ret nz ld a,(sy) or a ret z ld hl,(sloc) ld bc,-10 add hl,bc ld (sloc),hl call drawselector ld a,(sy) add a,-9 ld (sy),a jp drawselector down: call keywaiter ret nz ld a,(sy) cp 36 ret z ld hl,(sloc) ld bc,10 add hl,bc ld (sloc),hl call drawselector ld a,(sy) add a,9 ld (sy),a jp drawselector swap: ld hl,(sloc) ld a,(hl) ;this right here checks if ld b,a ;you tried to swap blank spaces or two of the same ld de,10 ;this only is really useful in puzzle add hl,de ;mode so that you don't accidentally ld a,(hl) ;loose swaps cp b ret z ld a,(second) cp 1 ret z ld a,1 ld (second),a ld (keywait),a ld a,(level) cp 60 jr nz,swap2 ;here is where we make the final password ld a,(sx) ld hl,(pointer) ld (hl),a inc hl ld a,(sy) ld (hl),a inc hl ld (pointer),hl ;/password swap2: ld a,(movelim) dec a ld (movelim),a call doublexor ld hl,(sloc) ld a,(hl) push af ld bc,10 ld de,-10 add hl,bc ld a,(hl) add hl,de ld (hl),a add hl,bc pop af ld (hl),a call doublexor bcall _grbufcpy ld hl,(sloc) ;we know that 2 empty spaces were not swapped ld a,1 ld (fmatch),a ld a,(hl) ;so if one location has empty space or a ;we know the other didn't and there might jp z,fall1 ;be a piece that falls. If not then there ld bc,10 ;cannot be a fall unless something disappears add hl,bc ; and that will be dealt with from the dissappear ld a,(hl) ;routine. If there was no fall we will check or a ;for a dissappear. After fall we will call jp z,fall1 ld a,0 ld (fmatch),a jp dissappear ;dissappear. The two may jump back and forth till ;nothing changes. Then if mode=1 (puzzle mode) ;we will check if the screen is empty if so next level ;double xor sprite doublexor: ld a,(sx) inc a ld (x),a ld a,(sy) inc a ld (y),a ld hl,(sloc) ld a,(hl) call interpret2 ld a,(sx) inc a ld (x),a ld a,(sy) add a,10 ;inc a and add a,9 ld (y),a ld hl,(sloc) ld bc,10 add hl,bc ld a,(hl) jp interpret2 ;/sprite ;input: c, b ;output: a=b*c, b=0 ;------------------------ ctimesb: ; xor a ; ctimesb2: ; add a,c ; djnz ctimesb2 ; ret ; ;------------------------ ;input: (dx), (dy) ;output: hl=loc in boardbuff ; ix=loc in boardbuff2 ; (x) and (y) coors of square ;------------------------ getloc: ; ld a,(dy) ; inc a ; ld b,a ; ld c,10 ; call ctimesb ; add a,-10 ; ld c,a ; ld a,(dx) ; add a,c ; ld c,a ; ld hl,boardbuff ; add hl,bc ; ld ix,boardbuff2 ; add ix,bc ; ; ld a,(dy) ; inc a ; ld b,a ; ld c,9 ; call ctimesb ; add a,-8 ; ld (y),a ; ld a,(dx) ; inc a ; ld b,a ; ld c,9 ; call ctimesb ; add a,-8 ; push af ; ld a,(mode) ;is it puzzle or endless? or a ; jp z,getloc2 ;if puzzle goto getloc2 pop af ; ld b,a ;if endless we calculate the offsets ld a,(scrollx) ; add a,b ; add a,-9 ; ld (x),a ; ret ; getloc2: ; pop af ; ld (x),a ; ret ; ;------------------------ dissappear: ld hl,boardbuff ld de,boardbuff2 ld bc,60 ldir ld a,-1 ld (dy),a xor a ld (fmatch),a dissappear2: ld a,(mode) ld (dx),a dissappear21: ld a,(dy) inc a ld (dy),a cp 6 ;number of lines to check jp z,dissappear7 ;vertical check dissappear3: ;horiz check ld a,(dx) cp 8 jr nc,dissappear2 call getloc ld a,(hl) or a jr z,dissappear2 ld b,a inc hl ld a,(dx) inc a ld (dx),a ld a,(hl) ld c,a inc hl ld a,(hl) cp b jr nz,dissappear3 ld a,(dx) inc a ld (dx),a ld a,(hl) cp c jr nz,dissappear3 ld a,(dx) add a,-2 ld (dx),a ld a,1 ld (fmatch),a ;match found ;we now know we have 3 of a kind across ;dx was set back to beginning of matches ;we need to go back and blacked and change nums in boardbuff2 to 6 ld b,3 dissappear4: push bc call getloc ld a,(ix) cp 6 jr z,dissappear41 ld a,6 ld (ix),a ld a,(hl) call interpret2 call drawsquare dissappear41: ld a,(dx) inc a ld (dx),a pop bc djnz dissappear4 ;now that is taken care of. lets check for extended matches ld a,(dx) dec a ld (dx),a call getloc ex de,hl ld a,(dx) inc a ld (dx),a ;de points to one of the nums of the matches dissappear5: ld hl,(score) ld bc,5 add hl,bc ld (score),hl ld a,(dx) cp 10 jp z,dissappear2 push de call getloc push ix ld a,(ix) cp 6 jr z,dissappear51 ld a,(hl) ld b,a ex de,hl ld a,(hl) cp b jr nz,dissappear6 call interpret2 call drawsquare dissappear51: pop ix ld a,6 ld (ix),a ld a,(dx) inc a ld (dx),a pop de jr dissappear5 dissappear6: pop ix pop de jp dissappear3 dissappear7: ld a,(mode) dec a ld (dx),a dissappear8: xor a ld (dy),a ld a,(dx) inc a ld (dx),a cp 10 jp z,dissappear13 dissappear9: ld a,(dy) cp 4 jr nc,dissappear8 call getloc ld a,(dy) inc a ld (dy),a ld a,(hl) cp 0 jr z,dissappear9 ld b,a ld de,10 add hl,de ld a,(hl) ld c,a add hl,de ld a,(hl) cp b Jr nz,dissappear9 ld a,(dy) inc a ld (dy),a ld a,(hl) cp c jr nz,dissappear9 ;now go back 2 ld a,(dy) add a,-2 ld (dy),a ld a,1 ld (fmatch),a ;match found ;then change and blacken ld b,3 dissappear10: push bc call getloc ld a,(ix) cp 6 jr z,dissappear101 ld a,6 ld (ix),a ld a,(hl) call interpret2 call drawsquare dissappear101: ld a,(dy) inc a ld (dy),a pop bc djnz dissappear10 ;check for extended matches ;now that is taken care of. lets check for extended matches ld a,(dy) dec a ld (dy),a call getloc ex de,hl ld a,(dy) inc a ld (dy),a ;de points to one of the nums of the matches dissappear11: ld hl,(score) ld bc,5 add hl,bc ld (score),hl ld a,(dy) cp 6 jp z,dissappear8 push de call getloc push ix ld a,(ix) cp 6 jr z,dissappear111 ld a,(hl) ld b,a ex de,hl ld a,(hl) cp b jr nz,dissappear12 call interpret2 call drawsquare pop ix ld a,6 ld (ix),a jr dissappear1111 dissappear111: ld hl,(score) ld bc,10 add hl,bc ld (score),hl pop ix dissappear1111: ld a,(dy) inc a ld (dy),a pop de jr dissappear11 dissappear12: pop ix pop de ld a,(dy) dec a ld (dy),a jp dissappear9 dissappear13: ;chech if any peices did dissappear ;if no then no need to check fall again so we return ld a,(fmatch) or a ret z ;need to copy graphbuffer and pause for a short while ;to show what peices are being deleted! Call waitshow ld a,-1 ld (dx),a dissappear14: xor a ld (dy),a ld a,(dx) inc a ld (dx),a cp 10 jr z,dissappear16 dissappear15: call getloc ld a,(ix) cp 6 call z,dissappear17 ld a,(dy) inc a ld (dy),a cp 6 jr z,dissappear14 jr dissappear15 dissappear16: ld hl,(score) ld bc,10 add hl,bc ld (score),hl ;now that everything is taken care of lets update boardbuff (the first one) ld hl,boardbuff2 ld de,boardbuff ld bc,60 ldir jr allgone ;check if all pieces are gone in puzzle mode if not puzzle or if not all gone then go to fall ;this routine here deletes 6s (this is only called when 6 is found) ; from the graph buffer and boarbuff dissappear17: call z,drawsquare call getloc xor a ld (ix),a ret allgone: ;check if level is complete ld a,(mode) cp 1 jr z,setscount ld b,60 ld hl,boardbuff allgone2: ld a,(hl) cp 0 jr nz,fall inc hl djnz allgone2 pop hl ;remove swap from stack jp loadpuzzle2 setscount: ld a,(sets) inc a ld (sets),a cp 10 jr nz,fall ld a,0 ld (sets),a ld a,(deltime) dec a ld (deltime),a ;this whole routine makes pieces fall left if there are pieces to the right of empty spaces fall: xor a ld (fmatch),a fall1: ld a,0 ;***** ld (floop),a ;*NEW* set to zero if in the end it is still zero this will not loop ;***** ld a,-1 ld (dy),a fall2: xor a ld (dx),a ld a,(dy) inc a ld (dy),a cp 6 jp z,fall12 fall3: ;now lets find the open space in this column if there are any call getloc ld a,(hl) or a jr z,fall4 ld a,(dx) inc a ld (dx),a cp 9 jr z,fall2 jr fall3 fall4: ;we know there is an open space at hl, dx,dy, y,x ;now we need to find the actual piece ld hl,(dx) ld (remhl),hl ;it doesn't make sense but i can't push hl here ;if i do then later in the game, ld a,(hl) (which isn't relying on this hl) ;crashes the calc. I later pop hl but still it crashes ld a,(dx) cp 10 ;if space is at the end then there is nothing to do jr z,fall2 fall5: ld a,(dx) inc a ld (dx),a cp 10 jp z,fall2 call getloc ld a,(hl) cp 0 jr nz,fall6 jr fall5 fall6: ld hl,(dx) ld (remhl2),hl fall7: call getloc ld a,(hl) call interpret2 ld a,(dx) inc a ld (dx),a cp 10 jr z,fall8 jr fall7 fall8: ld hl,(remhl) ld (dx),hl call getloc push hl ld hl,(remhl2) ld (dx),hl call getloc pop ix ;ix=first blank hl=first block after spaces fall9: ld a,(hl) ld (ix),a ;this makes the piece if not covered up by another ld (hl),0 ;dissappear from the boardbuff inc ix inc hl ld a,(dx) inc a ld (dx),a cp 10 jr z,fall10 jr fall9 fall10: ;this displays all blocks after (remhl) ld hl,(remhl) ld (dx),hl ld a,1 ld (fmatch),a ld (floop),a ;*new* fall11: call getloc ld a,(hl) call interpret2 ld a,(dx) inc a ld (dx),a cp 9 jp z,fall2 jr fall11 fall12: ld a,(floop) ;***** cp 0 ;*new* loop if something fell jp nz,fall1 ;***** ld a,(fmatch) cp 0 ret z call waitshow jp dissappear fast: ld a,1 ld (time),a ret delay: ld a,(time) dec a ld (time),a nop ret waitshow: bcall _grbufcpy ld b,40 waitshow2: halt djnz waitshow2 ret _Scrollright: call delay ld a,(time) or a ret nz ld a,(deltime) ld (time),a ld a,(scrollx) cp 9 jp z,loadline _scrollright2: ld a,(scrollx) inc a ld (scrollx),a ld a,(sx) inc a ld (sx),a ld hl,plotsscreen ld b,55 ; 55*12 bytes to rotate ld de,lsc _loop1: ex de,hl rr (hl) inc hl ex de,hl rr (hl) inc hl rr (hl) inc hl rr (hl) inc hl rr (hl) inc hl rr (hl) inc hl rr (hl) inc hl rr (hl) inc hl rr (hl) inc hl rr (hl) inc hl rr (hl) inc hl rr (hl) inc hl rr (hl) inc hl ld a,1 or a djnz _loop1 ld a,(sx) cp 82 call nc,left ret ;input: hl(to be displayed) ;------------------------ disphl: ; bcall _setxxxxop2 ; bcall _op2toop1 ; bcall _dispop1a ret ; ;------------------------ ;-----Menu Routine------; ;as it is now, this is ; ;a sideways menu routine; ;to move use right and ; ;left. Use del to select; ;an option ; ;required vars: ; ;textloc ;2 bytes; ;textxy ;2 bytes; ;option ;1 byte ; ;options ;1 byte ; ;be sure to put option ; ;right before the the ; ;var options in memory ; ; ; ;input for menu: ; ;hl=start of text ; ;de=coors of menu ; ;a=options ; ; ; ;output: ; ;option= # of options-1st or 2nd or...; ;--------Code-----------; choosemode: ; ld (textloc),hl ;store the variables ld (textxy),de ; ld (options),a ; ld (option),a ;a=the num of options. If there were 5 then five would point to the first option call writemenu ;display the menu fot the first time ;the first option will alwas be selected writemenu4: ;main loop for selecting bcall get_key ; cp $36 ;2nd? jp z,wait2 ;then wait till 2nd is up and then return cp $02 ;left? jr z,leftmen ;then move left cp $03 ;right? jr z,rightmen ;then move right jr writemenu4 ;otherwise go back to top of loop leftmen: ;move left in the menu ld de,(option) ;compare ld a,e ;option to cp d ;options jr z,writemenu4 ;if = then go back inc a ;increase the option pointer ld (option),a ; call writemenu ;rewrite the menu jr writemenu4 ;go back to loop rightmen: ; ld a,(option) ;compare cp 1 ;option # to 1 jr z,writemenu4 ;if = then go back dec a ;else decrease the option # ld (option),a ; call writemenu ;rewrite menu jr writemenu4 ;go back to loop writemenu: ;display all the options w/ one highlighted ld hl,(textloc) ;load hl with the text loaction of the menu texts ld de,(textxy) ;load de with the coors of the menu ld (pencol),de ;set pencol accordingly ld a,(options) ;load a and b with the ld b,a ;number of option writemenu2: ; push bc ;save bc ld a,(option) ;see if option(the one that sould be highlighted) cp b ;= b(the current option being written jr z,ivputs ;if yes then make it inverse text call vputs ;if no then make it regular text writemenu3: ; pop bc ;recall bc djnz writemenu2 ; ret ; ivputs: ;text w/ underline ld a,(menmode) cp 0 jr z,ivputs2 call ivputs3 jr writemenu3 ; ivputs2: call vputs3 jr writemenu3 ivputs3: set 1,(iy+$05) ; bcall _vputs ; res 1,(iy+$05) ; ret vputs: ;inverse text routine w/ underline ld a,(menmode) cp 0 jr z,ivputs3 vputs3: set textInverse,(iy+textflags); set 1,(iy+$05) ; bcall _vputs ; res textInverse,(iy+textflags); res 1,(iy+$05) ; ret ; ;-----------------------; wait: bcall get_key cp $36 jr z,wait2 jr wait wait2: bcall get_key cp $36 jr z,wait ret loadline: ;check if last column contains a piece ld hl,firstlast ld b,6 loadline11: ld a,(hl) or a jp nz,message2 ld de,10 add hl,de djnz loadline11 ;/end of check ld hl,(sloc) inc hl ld (sloc),hl ld hl,boardbuff ld (curloc),hl ld b,6 loadline15: ;15 as in 1.5 not 15 push bc ld hl,(curloc) ld de,exbuffer ld bc,9 ldir ld hl,(curloc) inc hl ex de,hl ld hl,exbuffer ld bc,9 ldir ld hl,(curloc) ld bc,10 add hl,bc ld (curloc),hl pop bc djnz loadline15 ld hl,boardbuff ld (curloc),hl xor a ld (lsc),a ld b,5 ld a,1 ld (y),a ld b,6 loadline2: push bc ld b,5 call vector1 inc a ;now 1-5 not 0-4 ;save the piece to boardbuff and increment pointer by 10 ;must save register a ;destroyed hl,bc ld hl,(curloc) ld (hl),a ld bc,10 add hl,bc ld (curloc),hl ;/save call interpret1 ld a,(y) add a,9 ld (y),a pop bc djnz loadline2 xor a ld (scrollx),a call dissappear jp _scrollright2 interpret1: cp 1 jr z,copyblock1 cp 2 jr z,copyblock2 cp 3 jr z,copyblock3 cp 4 jr z,copyblock4 cp 5 jr z,copyblock5 ret copyblock1: call copyblock ld hl,block1 jr copyblockdone copyblock2: call copyblock ld hl,block2 jr copyblockdone copyblock3: call copyblock ld hl,block3 jr copyblockdone copyblock4: call copyblock ld hl,block4 jr copyblockdone copyblock5: call copyblock ld hl,block5 copyblockdone: ldir ret copyblock: ld hl,lsc ld b,0 ld a,(y) ld c,a add hl,bc ex de,hl ld bc,8 ret interpret2: cp 1 jr z,drawblock1 cp 2 jr z,drawblock2 cp 3 jr z,drawblock3 cp 4 jr z,drawblock4 cp 5 jr z,drawblock5 ret drawblock1: ld ix,block1 jr drawblock drawblock2: ld ix,block2 jr drawblock drawblock3: ld ix,block3 jr drawblock drawblock4: ld ix,block4 jr drawblock drawblock5: ld ix,block5 drawblock: ld b,8 ld a,(y) ld l,a ld a,(x) jp vector0 drawsquare: ld ix,square jr drawblock drawselector: ld ix,selector ld b,19 ;height ld a,(sy) ld l,a ld a,(sx) call vector0 ld b,19 ld a,(sy) ld l,a ld a,(sx) add a,8 jp vector0 #include levels.h Direct_Input: ;This little routine is the correct syntax ; ld a,0ffh ;for Direct Input that all of you know, ; out (1),a ;but this Subroutine is so the steps can be ld a,b ;written once and called as much as needed out (1),a ;with just the Keyport that you want, loaded in a,(1) ;into B. Use this if you check for keys ret ;being pressed in More than One Row... =) displayline: ld c,a ld b,0 displayline2: ;display text[hl] and number[bc] at de push bc ld (pencol),de bcall _vputs pop hl jp dispHL vputter: ld (pencol),de bcall _vputs ret dispgover: ld hl,Govertxt ld de,24*256+31 jp vputter dispagain: ld hl,againtxt ld de,31*256+29 jp vputter displevel: ld hl,leveltxt ld de,24*256+26 ld a,(level) jr displayline dispmoves: ld hl,moves ld de,31*256+26 ld a,(movelim) jr displayline disppass: ld de,38*256+26 ld hl,passtxt call vputter ld hl,passbuff bcall _vputs ret disphigh: ld hl,(highscore) push hl pop bc ld de,38*256+26 ld hl,highname jp displayline2 dispscore: ld hl,(score) push hl pop bc ld de,31*256+26 ld hl,scoretxt jp displayline2 dispgoverall: call dispgover call dispagain dispyesno: ld hl,yestxt ld de,38*256+36 ld a,2 jp choosemode disppause: ld hl,pausetxt ld de,24*256+26 jp vputter dispnewgame: ld hl,newgametxt ld de,28*256+30 jp vputter hiscore: ld hl,(score) ld (highscore),hl ld hl,newtxt ld de,24*256+26 call vputter call dispscore ld hl,initials ld de,38*256+26 call vputter ld a,3 ld hl,highname ld de,alphabet ld bc,(pencol) call input pop hl ;delete a call jp prog_start ;input: ;hl= were you want the text/nums ;de= set of chars ;bc= coors ;a= options input: ld (remhl),hl ld (textloc),de ld (options),a ld (textxy),bc ld (pencol),bc xor a ld (option),a jp placechar inputmain: bcall get_key ; cp $04 ;up? jr z,inputup cp $01 ;down? jr z,inputdown cp $36 ;2nd? jr z,nextchar ; jr inputmain nextchar: ld hl,(textloc) ld a,(hl) ld hl,(remhl) ld (hl),a inc hl ld (remhl),hl ld a,(options) ld b,a ld a,(option) inc a ld (option),a cp b jr nz,nextchar2 ret nextchar2: ld hl,(pencol) ld (textxy),hl jr placechar inputup: ld hl,(textloc) dec hl ld a,(hl) or a ;if 0 then jr z,inputup2 ;we can't go higher jr overwrite inputup2: ld hl,alphend ld (textloc),hl jr overwrite inputdown: ld hl,(textloc) inc hl ld a,(hl) or a ;if 0 then jr z,inputdown2 ;we're at lower end jr overwrite inputdown2: ld hl,alphabet ld (textloc),hl jr overwrite overwrite: ld (textloc),hl ld hl,(textxy) ;***** ld (pencol),hl ;*new* ld hl,blanks ;***** bcall _vputs ;***** ld a,(hl) ld hl,(textxy) ld (pencol),hl placechar: ld hl,(textloc) ld a,(hl) bcall _vputmap jp inputmain message1: call box ;you see this when you pause in endless ;score ;highscore and players name(or initials) call disppause call dispscore call disphigh call wait ;wait for 2nd to be pressed call slowdown jp messdone message2: call box ;you see this when you loose endless ;score ;highscore and players name(or initials) ;if high score then goto that routine ld de,(highscore) ld hl,(score) call vector4 or a jp z,hiscore call dispgover call dispscore call disphigh call wait ;wait for 2nd to be pressed pop hl jp prog_start message3: call box ;you see this when you begin a level in puzzle ;says "PUZZLE" and "LEVEL X" and move limit call displevel call dispmoves call disppass call wait call slowdown jp messdone message4: call box ;message when paused in puzzle or when clear pressed ;see the number of moves left ;menu for choosing continue ;or restart ;"Cont. Retry Quit" call displevel call dispmoves ;menu ld hl,mess4txt ld de,38*256+25 ld a,3 call choosemode ;/menu ;1=quit 2=retry 3=Cont. ld a,(option) cp 1 jr z,message40 cp 2 jr z,message42 call slowdown jp messdone message40: pop hl jp prog_start message42: ;retry pop hl jr retry message5: call box ;message when movelim=0 in puzzle ;menu for choosing restart ;or quit call dispgoverall call slowdown ld a,(option) cp 1 ;if no was pressed go back to main menu jp z,prog_start retry: ld a,(level) dec a ld (level),a ld hl,(lev) ld (curworld),hl jp loadpuzzle2 message6: call box ;message when starting puzzle mode ;menu for choosing new game ;yes=new no=password call dispnewgame call dispyesno jp messdone message7: call box ;you see this when you begin to enter a password ld hl,please ld de,256*24+28 call vputter ld de,256*31+26 call vputter ld de,alphabet ld hl,passbuff ld bc,256*38+42 ld a,3 call input jp messdone message8: call box ;in endless "Are you sure?" you want to quit ld hl,dywtq ld de,256*27+26 ld (pencol),de bcall _vputs call dispyesno ;0=no 1=yes ld a,(option) cp 1 ;***fix*** jp z,messdone call box ld de,(highscore) ld hl,(score) call vector4 cp 0 jp z,hiscore pop hl jp prog_start box: ; START OF CODE By Chris Hiszpanski (Man in the Moon) ld a,31 ; Height + 1 ld hl,plotsscreen+195 ; Top left corner ld de,boxtemp ; copyline: ; Save section to overwrite ld bc,6 ; ldir ; inc hl ; Move to next line ; inc hl ; inc hl ; Move to next line inc hl ; inc hl ; inc hl ; dec a ; Count lines or a ; jr nz,copyline ; ld a,31 ; Height + 1 again ld de,$plotsscreen+195 ; Top left corner clearline: ; Clear the section saved ld hl,byte ; ld bc,6 ; ldir ; call deplus4 dec a ; or a ; jr nz,clearline ; bcall _grbufcpy ; END OF CODE ;draw first line ld bc,18223 ld de,6191 ld h,1 bcall _ILINE ;draw second line ld b,24 ld e,17 bcall _ILINE ;draw third line ld b,71 ld c,17 bcall _ILINE ;draw fourth line ld d,71 ld e,47 bcall _ILINE ;vortexx15 ;put title in ld hl,description ld de,17*256+25 set 1,(iy+$05) set textInverse,(iy+textflags) call vputter res textInverse,(iy+textflags) res 1,(iy+$05) ;end of title ;/vortexx15 ret deplus4: inc de ; Skip last four bytes inc de ; inc de ; Skip last four bytes inc de ; inc de ; inc de ; ret messdone: ld hl,boxtemp ; START OF CODE ld de,$plotsscreen+195 ; By Chris Hiszpanski (Man in the Moon) ld a,31 ; Height + 1 recoverline: ; Recover protion of data covered by window ld bc,6 ; ldir ; call deplus4 dec a ; or a ; jr nz,recoverline ; END OF CODE bcall _grbufcpy ret byte: .db 0,0,0,0,0,0 ; Clearing buffer blanks: ;*new* .db " ",0 ;***** leveltxt: .db "Level: ",0 moves: .db "Moves: ",0 passtxt: .db "Pass: ",0 scoretxt: .db "Score: ",0 endtxt: .db " Endless ",0 puztxt: .db " Puzzle ",0 helptxt: .db " Help ",0 exittxt: .db " Exit ",0 GOvertxt: .db "GAME OVER",0 againtxt: .db "Play Again?",0 yestxt: .db " Yes ",0 notxt: .db " No ",0 alphabet: .db "ABCDEFGHIJKLMNOP" ;***** .db "QRSTUVWXYZabcdef" ;*fix* .db "ghijklmnopqrstuv" ;* * .db "wxyz012345678" ;***** alphend: .db "9",0 highname: .db "BMS: ",0 highscore: .db 5,0 pausetxt: .db "Paused",0 newtxt: .db "NEW HIGH!",0 initials: .db "Initials: ",0 newgametxt: .db "Password?",0 dywtq: .db "Are you sure?",0 please: .db "Please Enter",0 .db "The Password",0 mess4txt: .db "Cont",0 .db "Again",0 .db "Quit",0 wininst: .db "YOU WON!",0 ;*fix* ;*deleted ;wininst2: ; .db "to Dim-Ti",0 passbuff: .db 0,0,0,0 ;the password you enter goes here i needed a 0 terminated string so i used 4 bytes instructions: .db "The object of the game is to",0 ;*fixed these* .db "align 3 or more like pieces ",0 .db "horizontally or vertically.",0 .db "To do this you must use the",0 .db "selector. You can move it up,",0 .db "down, right, and left but you",0 .db "can not rotate it. When you",0 .db "find a pair of pieces which",0 .db "you wish to swap press 2nd.",0 .db "If you wish to speed up the",0 .db "pieces appearing in endless",0 .db "mode then press ALPHA. To",0 .db "pause in either mode press",0 .db "MODE. To exit press CLEAR.",0 .db "Please visit our web site at",0 .db "tcpa.calc.org. I would like",0 .db "to thank Tim Anders, Chris",0 .db "Hiszpanski, and Nukem for",0 .db "their help with routines and",0 .db "graphics.",0 titletxt: .db "TETRIS ATTACK v1.1",0 vector0 = ionputsprite vector1 = ionrandom vector4: hiscr: push hl xor a sbc hl,de pop hl jr z,nnhs jr nc,nhs nnhs: ex de,hl inc a ret nhs: or a ret #define gbuf plotsscreen .end END