;Turbo Breakout 1.0 ;Copyright (C) 1996-1997 Bill Nagel ;This was my first ever Z80 assembly program and I've received a countless ;number of letters asking for the source code, so I finally decided to ;release it. I'm releasing it because people out there really want to learn ;83ASM and viewing source code is the best way to learn. All that I'm asking ;in return is that you do not use this code without identify me as the author. ;If you use parts of this code in your own program, please be sure to give me ;credit somewhere. Also, since this was my first z80 program, it was written ;very poorly and there are some things (like input) that I could have done ;better. If you have any specific questions, email me at penguinb@geocities.com. .NOLIST #DEFINE padx 8265h #DEFINE ballx 8266h #DEFINE bally 8267h #DEFINE bxs 8268h #DEFINE bys 8269h #DEFINE counter 826Ah #DEFINE tailx 826Ch #DEFINE taily 826Dh #DEFINE parx 826Eh #DEFINE pary 826Fh #DEFINE counterx 8270h #DEFINE countery 8271h #DEFINE bcx 8272h #DEFINE bcy 8273h #DEFINE tailxx 8274h #DEFINE tailyy 8275h #DEFINE tailxxx 8276h #DEFINE tailyyy 8277h #DEFINE tx 8278h #DEFINE ty 8279h #DEFINE level 827Ah #DEFINE collision 827Bh #DEFINE lives 827Ch #DEFINE nblocks 827Dh #DEFINE blocks 827Eh #DEFINE i1 827Fh #DEFINE i2 8280h #DEFINE i3 8281h #DEFINE in 8282h #DEFINE inix 8283h #DEFINE map 8500h #define equ .equ #define EQU .equ #define end .end #include "ti83asm.inc" #include "tokens.inc" .LIST .org 9327h call _runIndicOff call _clrlcdfull call _homeup ld hl,title call _puts ld b,0 ld c,55 ld d,94 ld e,55 ld h,1 call _ILine ld hl,9*256+1 ld (PENCOL),hl ld hl,credits call _vputs ld hl,16*256+1 ld (PENCOL),hl ld hl,high_score call _vputs call _RCLY ld hl,16*256+38 ld (PENCOL),hl ld a,6 call _DISPOP1A ld hl,16*256+83 ld (PENCOL),hl CALL _ZEROOOP1 LD HL,'A' LD (OP1+1),HL call _RCLVARSYM call _CONVOP1 ld a,e call _vputmap ld hl,16*256+87 ld (PENCOL),hl CALL _ZEROOOP1 LD HL,'B' LD (OP1+1),HL call _RCLVARSYM call _CONVOP1 ld a,e call _vputmap ld hl,16*256+91 ld (PENCOL),hl CALL _ZEROOOP1 LD HL,'C' LD (OP1+1),HL call _RCLVARSYM call _CONVOP1 ld a,e call _vputmap ld hl,57*256+29 ld (PENCOL),hl ld hl,press_clear call _vputs call wait_for_enter ld a,0 ld (in),a ld (blocks),a call _OP1SET0 call _STOX ld a,9 ld (lives),a ld a,1 ld (level),a call clear_board call set_up_board Restart: ld a,0 ld (counterx),a ld (countery),a ld a,42 ld (padx),a ld a,46 ld (ballx),a ld (tailx),a ld (tailxx),a ld (tailxxx),a ld a,13 ld (bally),a ld (taily),a ld (tailyy),a ld (tailyyy),a ld a,2 ld (bxs),a ld (bys),a ld a,14 ld (bcx),a ld (bcy),a call _GRBUFCLR call _clrlcdfull ld h,1 ld bc,7 ld de,94*256+7 call _ILine ld hl,57*256 ld (PENCOL),hl ld hl,str_lives call _vputs ld a,25 ld (PENCOL),a ld hl,str_level call _vputs ld a,53 ld (PENCOL),a ld hl,str_score call _vputs call draw_paddle call draw_board call draw_scoreboard Start: jp Ball Player: call _GetK ;This was really stupid ld a,22 ;I should have use _GetK only once call _SETXXOP1 ;and then _CONVOP1 call _CPOP1OP2 jp z,exit ld a,24 call _SETXXOP1 call _CPOP1OP2 jr z,left ld a,26 call _SETXXOP1 call _CPOP1OP2 jr z,right jr Start left: ld hl,padx dec (hl) dec (hl) dec (hl) ld d,1 ld a,(padx) ld b,a ld c,10 call _IPoint dec c call _IPoint inc b call _IPoint inc c call _IPoint inc b call _IPoint dec c call _IPoint ld a,b ;Increase b by 9 add a,10 ld b,a ld d,0 inc c call _IPoint dec c call _IPoint inc b call _IPoint inc c call _IPoint inc b call _IPoint dec c call _IPoint jr Start right: ld a,(padx) ld b,a ld d,0 ld c,10 call _IPoint dec c call _IPoint inc b call _IPoint inc c call _IPoint inc b call _IPoint dec c call _IPoint ld hl,padx ;Increase paddle position inc (hl) inc (hl) inc (hl) ld d,1 ;Draw right side of paddle ld a,b ;Increase b by 9 add a,10 ld b,a inc c call _IPoint dec c call _IPoint inc b call _IPoint inc c call _IPoint inc b call _IPoint dec c call _IPoint jp Start Ball: ld a,0 ld (parx),a ld a,(counterx) inc a ld (counterx),a ld b,a ld a,(bcx) cp b jp Z,XBall XRet: ld a,(countery) inc a ld (countery),a ld b,a ld a,(bcy) cp b jp Z,YBall YRet: ld a,(parx) cp 0 call nz,draw_ball jp Player XBall: ld a,0 ld (counterx),a ld a,1 ld (parx),a call erase_ball ld a,(bxs) cp 0 jp Z,XLeft ld a,(ballx) inc a ld (ballx),a cp 92 call P,righthit ld a,(bally) dec a ld (ty),a ld a,(ballx) add a,3 ld (tx),a call check_point ld a,(collision) cp 1 call P,block_right ld a,(collision) cp 2 jp Z,Restart jp XRet XLeft: ld a,(ballx) dec a ld (ballx),a cp 1 call M,lefthit ld a,(bally) dec a ld (ty),a ld a,(ballx) dec a ld (tx),a call check_point ld a,(collision) cp 1 call P,block_left ld a,(collision) cp 2 jp Z,Restart jp XRet YBall: ld a,0 ld (countery),a ld a,(parx) cp 0 call Z,erase_ball ld a,1 ld (parx),a ld a,(bys) cp 0 jp Z,YDown ld a,(bally) inc a ld (bally),a cp 63 call P,tophit ld a,(bally) inc a ld (ty),a ld a,(ballx) inc a ld (tx),a call check_point ld a,(collision) cp 1 call P,block_above ld a,(collision) cp 2 jp Z,Restart jp YRet YDown: ld a,(bally) dec a ld (bally),a cp 13 call Z,check_paddle cp 12 jp Z,bothit ld a,(bally) sub 3 ld (ty),a ld a,(ballx) inc a ld (tx),a call check_point ld a,(collision) cp 1 call P,block_bellow ld a,(collision) cp 2 jp Z,Restart jp YRet block_above: ld a,0 ld (bys),a ret block_bellow: ld a,2 ld (bys),a ret block_left: ld a,2 ld (bxs),a ret block_right: ld a,0 ld (bxs),a ret check_paddle: ld a,(padx) ld b,a ld a,(ballx) inc a cp b jp P,cptwo ret cptwo: ld a,(padx) add a,11 ld b,a ld a,(ballx) cp b ret P ld a,13 ld (bally),a ld a,2 ld (bys),a ld a,(padx) ld b,a ld a,(ballx) inc a sub b ld c,a cp 6 jp M,leftpad ld a,2 ld (bxs),a ld a,c sub 6 ld c,a add a,c add a,4 ld (bcy),a dec a ld (countery),a ld a,14 sub c sub c ld (bcx),a dec a ld (counterx),a ret leftpad: ld a,0 ld (bxs),a ld a,c add a,c add a,4 ld (bcx),a dec a ld (counterx),a ld a,14 sub c sub c ld (bcy),a dec a ld (countery),a ret tophit: ld a,63 ld (bally),a ld a,0 ld (bys),a ret bothit: call draw_ball ld hl,lives dec (hl) call draw_scoreboard ld a,(lives) cp 0 jp Z,exit ld hl,44*256+31 ld (PENCOL),hl ld hl,press_clear call _vputs call wait_for_enter jp Restart lefthit: ld a,0 ld (ballx),a ld a,2 ld (bxs),a ret righthit: ld a,92 ld (ballx),a ld a,0 ld (bxs),a ret erase_ball: ld d,0 ld a,(tailxxx) ld b,a ld a,(tailyyy) ld c,a dec c call _IPoint inc b dec c call _IPoint inc c call _IPoint inc c call _IPoint dec c inc b call _IPoint ld a,(tailxx) ld (tailxxx),a ld a,(tailyy) ld (tailyyy),a ld a,(tailx) ld (tailxx),a ld a,(taily) ld (tailyy),a ld a,(ballx) ld (tailx),a ld a,(bally) ld (taily),a ret draw_ball: ld a,(bally) ld c,a ld a,(ballx) ld b,a ld d,1 dec c call _IPoint inc b dec c call _IPoint inc c call _IPoint inc c call _IPoint dec c inc b call _IPoint ret check_point: ld a,0 ld (collision),a ld a,(tx) cp 0 ret M cp 95 ret P ld a,(tx) ;divide ty by 6 call _setxxop1 ld a,6 call _setxxop2 call _FPDIV call _CONVOP1 ld a,e ld (tx),a ld a,(ty) ;divide tx by 6 ld b,a ld a,63 sub b call _setxxop1 ld a,6 call _setxxop2 call _FPDIV call _CONVOP1 ld a,e ld (ty),a cp 6 ret P call get_map ;check map ld a,1 cp (hl) ret NZ ld a,0 ld (hl),a ld a,(tx) ;I should have use _htimesl here but call _setxxop1 ;I didn't know about that command when ld a,6 ;I wrote this call _setxxop2 call _FPMULT call _CONVOP1 ld a,e ld (parx),a ld a,(ty) call _setxxop1 ld a,6 call _setxxop2 call _FPMULT call _CONVOP1 ld a,e ld b,a ld a,63 sub b ld (pary),a ld d,0 call draw_block ld hl,blocks inc (hl) call _RCLX call _PLUS1 call _STOX call draw_scoreboard ld a,1 ld (collision),a ld a,(blocks) ld hl,nblocks cp (hl) call Z,Next_Level ret Next_Level: ld a,0 ld (blocks),a call _RCLX ld a,96 call _setxxop2 call _FPADD call _STOX ld a,2 ld (collision),a ld hl,level inc (hl) ld a,10 cp (hl) call Z,reslevs call draw_scoreboard ld hl,38*256+22 ld (PENCOL),hl ld hl,level_comp call _vputs ld hl,44*256+31 ld (PENCOL),hl ld hl,press_clear call _vputs call wait_for_enter call set_up_board ret reslevs: ld (hl),1 ret get_map: ld a,(tx) ld b,a ld a,(ty) sla a sla a sla a sla a add a,b ld h,0 ld l,a ld bc,map add hl,bc ret draw_paddle: ld a,0 ld (counter),a ld d,1 dploop: ld a,(padx) ld b,a ld a,(counter) add a,b ld b,a ld c,10 call _IPoint dec c call _IPoint ld a,(counter) inc a ld (counter),a cp 12 jr NZ,dploop ret draw_block: ld a,(parx) add a,5 ld b,a ld a,(pary) ld c,a call _IPoint ld h,d ld a,(parx) inc a ld b,a add a,4 ld d,a dec c ld e,c call _ILine dec c dec e call _ILine dec c dec e call _ILine dec c dec e call _ILine dec b dec c dec e call _ILine ret setblock: call get_map ld a,1 ld (hl),a ld hl,nblocks inc (hl) ret set_up_board: ld a,0 ld (nblocks),a ld (counter),a ld (ty),a ld de,level1-12 addlevel: inc de ;this could have been done a lot easier by inc de ;loading 12 into de and adding it to hl inc de ;and swapping de & hl inc de inc de inc de inc de inc de inc de inc de inc de inc de ld hl,counter inc (hl) ld a,(level) cp (hl) jp NZ,addlevel cyloop: ld a,0 ld (tx),a cxloop: ld a,(de) bit 0,a call NZ,setblock ld hl,tx inc (hl) ld a,(de) bit 1,a call NZ,setblock ld hl,tx inc (hl) ld a,(de) bit 2,a call NZ,setblock ld hl,tx inc (hl) ld a,(de) bit 3,a call NZ,setblock ld hl,tx inc (hl) ld a,(de) bit 4,a call NZ,setblock ld hl,tx inc (hl) ld a,(de) bit 5,a call NZ,setblock ld hl,tx inc (hl) ld a,(de) bit 6,a call NZ,setblock ld hl,tx inc (hl) ld a,(de) bit 7,a call NZ,setblock inc de ld hl,tx inc (hl) ld a,(tx) cp 8 jp Z,cxloop ld a,(ty) inc a ld (ty),a cp 6 jp NZ,cyloop ret draw_board: ld a,0 ld (tx),a cxloop2: ld a,(tx) call _setxxop1 ld a,6 call _setxxop2 call _FPMULT call _CONVOP1 ld a,e ld (parx),a ld a,0 ld (ty),a cyloop2: ld a,(ty) call _setxxop1 ld a,6 call _setxxop2 call _FPMULT call _CONVOP1 ld a,63 sub e ld (pary),a call get_map ;check map ld d,1 ;Make Block Appear ld a,1 cp (hl) call Z,draw_block ld hl,ty ;increase y loop counter inc (hl) ld a,(ty) cp 6 jp M,cyloop2 ld hl,tx ;increase x loop counter inc (hl) ld a,(tx) cp 16 ret Z jp cxloop2 clear_board: ld a,0 ld (tx),a cxloop3: ld a,0 ld (ty),a cyloop3: call get_map ld (hl),0 ld hl,ty inc (hl) ld a,(ty) cp 6 jp M,cyloop3 ld hl,tx inc (hl) ld a,(tx) cp 16 ret Z jp cxloop3 draw_scoreboard: call _RCLX ld hl,57*256+75 ld (PENCOL),hl ld a,5 call _DISPOP1A ld a,(lives) call _setxxop1 ld hl,57*256+19 ld (PENCOL),hl ld a,1 call _DISPOP1A ld a,(level) call _setxxop1 ld hl,57*256+46 ld (PENCOL),hl ld a,2 call _DISPOP1A ret wait_for_enter: call _GetK ld a,45 call _SETXXOP1 call _CPOP1OP2 jp nz,wait_for_enter ret draw_letter: ld a,12 ld (PENROW),a ld a,(inix) ld (PENCOL),a ld a,(in) call _vputmap ret iniup: ld a,(in) inc a cp 91 call Z,toohigh ld (in),a jp draw_letter toohigh: ld a,65 ret inidown: ld a,(in) dec a cp 64 call Z,toolow ld (in),a jp draw_letter toolow: ld a,90 ret getinitial: ld (inix),a ld a,65 ld (in),a call draw_letter iniloop: call _getk ld a,25 call _SETXXOP1 call _CPOP1OP2 call z,iniup ld a,34 call _SETXXOP1 call _CPOP1OP2 call z,inidown ld a,45 call _SETXXOP1 call _CPOP1OP2 ret Z jp iniloop newhs: call _RCLX call _STOY ld hl,0 ld (PENCOL),hl ld hl,nhs call _vputs ld hl,6*256 ld (PENCOL),hl ld hl,enter_ini call _vputs ld a,6 call getinitial ld a,(in) call _setxxop1 CALL _PUSHREALO1 CALL _ZEROOOP1 LD HL,'A' LD (OP1+1),HL CALL _STOOTHER ld a,10 call getinitial ld a,(in) call _setxxop1 CALL _PUSHREALO1 CALL _ZEROOOP1 LD HL,'B' LD (OP1+1),HL CALL _STOOTHER ld a,14 call getinitial ld a,(in) call _setxxop1 CALL _PUSHREALO1 CALL _ZEROOOP1 LD HL,'C' LD (OP1+1),HL CALL _STOOTHER ret exit: ld hl,38*256+32 ld (PENCOL),hl ld hl,game_over call _vputs ld hl,44*256+31 ld (PENCOL),hl ld hl,press_clear call _vputs call wait_for_enter call _clrlcdfull call _clrtxtshd call _homeup call _RCLX call _OP1TOOP2 call _RCLY call _CPOP1OP2 jp C,newhs ret title: .db " Turbo Breakout",0 credits: .db "Copyright (C) 1996 Bill Nagel",0 press_clear: .db "Press Clear",0 str_score: .db "Score:",0 str_lives: .db "Lives:",0 str_level: .db "Level:",0 game_over: .db "Game Over",0 level_comp: .db "Level Complete!",0 high_score: .db "High Score:",0 enter_ini: .db "Enter Initials:",0 nhs: .db "New High Score!",0 level1: .db 0,0,131,193,15,240,60,60,48,12,0,0 ;\ - / .db 96,136,240,136,98,136,7,248,6,32,1,32 ;Football .db 223,251,68,138,196,137,68,138,68,138,196,251 ;TBO .db 15,240,67,194,1,128,17,136,33,132,193,131 ;Smiley Face .db 153,153,204,204,102,102,51,51,153,153,0,0 ;/ / / / .db 15,242,35,198,193,131,193,134,67,194,15,240 ;Dog .db 17,136,162,69,36,36,136,17,17,136,2,64 ;\\-// .db 119,238,84,42,87,234,209,139,29,184,7,224 ;Snake .db 142,113,218,91,186,93,226,39,130,65,0,0 ;Spider .END