;Pong 83Z v1.5 ;Copyright (C) 1996-1997 Bill Nagel ;DO NOT MAKE ANY MODIFICATIONS OF THIS PROGRAM ;FOR OTHER REASONS THAN PERSONAL USE ;This code is outdated, but a good start for beginners .NOLIST #DEFINE x 8265h #DEFINE y 8266h #DEFINE score1 8267h #DEFINE score2 8268h #DEFINE py1 8269h #DEFINE py2 826Ah #DEFINE bxs 826Bh #DEFINE bys 826Ch #DEFINE ball 826Dh #DEFINE mcountc 826Eh #DEFINE mcount 826Fh #DEFINE bxcount 8270h #DEFINE x2 8271h #DEFINE y2 8272h #DEFINE x3 8273h #DEFINE y3 8274h #DEFINE bycount 8275h #DEFINE x4 8276h #DEFINE y4 8277h #DEFINE x5 8278h #DEFINE y5 8279h #DEFINE tx 827Ah #DEFINE tx2 827Bh #DEFINE tx3 827Ch #DEFINE tx4 827Dh #DEFINE tx5 827Eh #DEFINE ty 827Fh #DEFINE ty2 8280h #DEFINE ty3 8281h #DEFINE ty4 8282h #DEFINE ty5 8283h #DEFINE txs 8284h #DEFINE tys 8285h #DEFINE done 8286h #DEFINE padupd 8287h #DEFINE cpadupd 8288h #DEFINE ballupd 8289h #DEFINE speed 828Ah #DEFINE index 828Bh #define equ .equ #define EQU .equ #define end .end #include "ti83asm.inc" #include "tokens.inc" #DEFINE SCANKEY(keymasked,keypressed) ld a,keymasked #DEFCONT \ out (1),a #DEFCONT \ in a,(1) #DEFCONT \ bit keypressed,a M6 = %10111111 M5 = %11011111 M4 = %11101111 M3 = %11110111 M2 = %11111011 M1 = %11111101 M0 = %11111110 .LIST .org 9327h nop jr prog_start .dw $0000 .dw Description .dw $0000 .dw $0000 prog_start: 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,18*256+1 ld (PENCOL),hl ld hl,str_balls call _vputs ld hl,27*256+1 ld (PENCOL),hl ld hl,str_speed call _vputs ld hl,57*256+29 ld (PENCOL),hl ld hl,press_clear call _vputs xor a ld (ball),a ld a,1 ld (speed),a call normball jp oneball options: call _GetK ld a,21 call _SETXXOP1 call _CPOP1OP2 jp z,nballs ld a,31 call _SETXXOP1 call _CPOP1OP2 jp z,aspeed ld a,45 call _SETXXOP1 call _CPOP1OP2 jp z,startgame jp options startgame: xor a ld (score1),a ld (score2),a call _GRBUFCLR call _clrlcdfull call draw_screen call restart call scoreboard Start: ld a,(mcount) inc a ld (mcount),a ld hl,padupd cp (hl) call Z,movepad ld a,(mcountc) inc a ld (mcountc),a ld hl,cpadupd cp (hl) call Z,movepadc ld a,(bxcount) inc a ld (bxcount),a ld hl,ballupd cp (hl) call Z,moveballx ld a,(bycount) inc a ld (bycount),a ld hl,ballupd cp (hl) call Z,movebally SCANKEY(M6,6) jp z,pause ld a,(done) or a jp Z,Start jp exit nballs: ld a,(ball) ld b,a ld a,1 sub b ld (ball),a or a jp Z,oneball jp twoball oneball: ld hl,18*256+91 ld (PENCOL),hl ld hl,str_1 call _vputs jp options twoball: ld hl,18*256+91 ld (PENCOL),hl ld hl,str_2 call _vputs jp options aspeed: ld a,(speed) inc a cp 3 call Z,toofast ld (speed),a or a jp Z,slowball cp 2 jp Z,fastball call normball jp options toofast: xor a ret slowball: ld hl,27*256+79 ld (PENCOL),hl ld hl,str_slow call _vputs jp options normball: ld hl,27*256+79 ld (PENCOL),hl ld hl,str_norm call _vputs ret fastball: ld hl,27*256+79 ld (PENCOL),hl ld hl,str_fast call _vputs jp options moveballx: xor a ld (bxcount),a ld a,(ball) cp 1 call Z,tmoveballx call erase_ball ld a,(bxs) ld b,a ld a,(x) add a,b sub 4 ld (x),a cp 94 jp P,rightmiss cp 0 jp M,leftmiss cp 91 jp P,righthit cp 3 jp M,lefthit padmiss: call draw_ball ret movebally: xor a ld (bycount),a ld a,(ball) cp 1 call Z,tmovebally call erase_ball ld a,(bys) ld b,a ld a,(y) add a,b sub 4 cp 62 jp P,tophit cp 10 jp M,bothit ld (y),a call draw_ball ret erase_ball: ld a,(x5) ld b,a ld a,(y5) ld c,a ld d,0 call _IPoint inc b call _IPoint dec c call _IPoint dec b call _IPoint ld a,(x) cp 6 call Z,drawpaddle1 ld a,(x) cp 5 call Z,drawpaddle1 ld a,(x) cp 89 call Z,drawpaddle2 ld a,(x) cp 88 call Z,drawpaddle2 ld a,(x4) ld (x5),a ld a,(y4) ld (y5),a ld a,(x3) ld (x4),a ld a,(y3) ld (y4),a ld a,(x2) ld (x3),a ld a,(y2) ld (y3),a ld a,(x) ld (x2),a ld a,(y) ld (y2),a ret draw_ball: ld a,(x) ld b,a ld a,(y) ld c,a ld d,1 call _IPoint inc b call _IPoint dec c call _IPoint dec b call _IPoint ret lefthit: ld a,(y) add a,13 ld b,a ld a,(py1) cp b jp P,padmiss ld a,(y) dec a ld b,a ld a,(py1) cp b jp M,padmiss ld a,(bxs) cp 5 call M,switch ; ld a,(ball) ; cp 0 call random jp padmiss righthit: ld a,(y) add a,13 ld b,a ld a,(py2) cp b jp P,padmiss ld a,(y) dec a ld b,a ld a,(py2) cp b jp M,padmiss ld a,(bxs) cp 5 call P,switch ; ld a,(ball) ; cp 0 call random jp padmiss leftmiss: call switch ld hl,score2 inc (hl) call scoreboard jp padmiss rightmiss: call switch ld hl,score1 inc (hl) call scoreboard jp padmiss tophit: ld a,(bys) sub 4 ld b,a ld a,4 sub b ld (bys),a jp movebally bothit: ld a,(bys) ld b,a ld a,4 sub b add a,4 ld (bys),a jp movebally switch: ld a,(bxs) ld b,a ld a,8 sub b ld (bxs),a ret random: call _RANDOM call _OP2SET8 call _FPMULT call _CONVOP1 ld a,e cp 6 jp Z,bysfast ld a,(bys) cp 4 jp P,upslow ld a,3 ld (bys),a ret upslow: ld a,5 ld (bys),a ret bysfast: ld a,(bys) cp 4 jp P,upfast ld a,2 ld (bys),a ret upfast: ld a,6 ld (bys),a ret ;*******************Ball Two*************************** tmoveballx: ; ld a,0 ; ld (bxcount),a call terase_ball ld a,(txs) ld b,a ld a,(tx) add a,b sub 4 ld (tx),a cp 94 jp P,trightmiss cp 0 jp M,tleftmiss cp 91 jp P,trighthit cp 3 jp M,tlefthit tpadmiss: call tdraw_ball ret tmovebally: ; ld a,0 ; ld (bycount),a call terase_ball ld a,(tys) ld b,a ld a,(ty) add a,b sub 4 cp 62 jp P,ttophit cp 10 jp M,tbothit ld (ty),a call tdraw_ball ret terase_ball: ld a,(tx5) ld b,a ld a,(ty5) ld c,a ld d,0 call _IPoint inc b call _IPoint dec c call _IPoint dec b call _IPoint ld a,(tx) cp 5 call Z,drawpaddle1 ld a,(tx) cp 89 call Z,drawpaddle2 ld a,(tx4) ld (tx5),a ld a,(ty4) ld (ty5),a ld a,(tx3) ld (tx4),a ld a,(ty3) ld (ty4),a ld a,(tx2) ld (tx3),a ld a,(ty2) ld (ty3),a ld a,(tx) ld (tx2),a ld a,(ty) ld (ty2),a ret tdraw_ball: ld a,(tx) ld b,a ld a,(ty) ld c,a ld d,1 call _IPoint inc b call _IPoint dec c call _IPoint dec b call _IPoint ret tlefthit: ld a,(ty) add a,13 ld b,a ld a,(py1) cp b jp P,tpadmiss ld a,(ty) dec a ld b,a ld a,(py1) cp b jp M,tpadmiss ld a,5 ld (txs),a jp tpadmiss trighthit: ld a,(ty) add a,13 ld b,a ld a,(py2) cp b jp P,tpadmiss ld a,(ty) dec a ld b,a ld a,(py2) cp b jp M,tpadmiss ld a,3 ld (txs),a jp tpadmiss tleftmiss: ld a,5 ld (txs),a ld hl,score2 inc (hl) call scoreboard jp tpadmiss trightmiss: ld a,3 ld (txs),a ld hl,score1 inc (hl) call scoreboard jp tpadmiss ttophit: ld a,(tys) sub 4 ld b,a ld a,4 sub b ld (tys),a jp tmovebally tbothit: ld a,(tys) ld b,a ld a,4 sub b add a,4 ld (tys),a jp tmovebally ;**************************End Ball Two***************** movepad: xor a ld (mcount),a SCANKEY(M0,0) call z,movedown SCANKEY(M0,3) call z,moveup ret movepadc: xor a ld (mcountc),a ld a,(bxs) cp 3 ret Z ld a,(py2) sub 6 ld hl,y cp (hl) jp P,compdown jp M,compup ret moveup: ld a,(py1) inc a cp 62 ret Z ld (py1),a ld c,a ld b,0 ld d,1 call _IPoint inc b call _IPoint ld a,(py1) sub 12 ld c,a ld d,0 call _IPoint dec b call _IPoint ret movedown: ld a,(py1) dec a cp 19 ret Z ld (py1),a sub 11 ld c,a ld d,1 ld b,0 call _IPoint inc b call _IPoint ld a,(py1) inc a ld c,a ld d,0 call _IPoint dec b call _IPoint ret compup: ld a,(py2) inc a ld c,a ld b,93 ld d,1 call _IPoint inc b call _IPoint ld a,(py2) inc a cp 62 ret Z ld (py2),a sub 12 ld c,a ld d,0 call _IPoint dec b call _IPoint ret compdown: ld a,(py2) sub 12 ld c,a ld d,1 ld b,93 call _IPoint inc b call _IPoint ld a,(py2) dec a cp 19 ret Z ld (py2),a inc a ld c,a ld d,0 call _IPoint dec b call _IPoint ret pause: call _clrlcdfull call _homeup ld hl,str_paused call _puts ;dloop: call _GetK ; ld a,22 ; call _SETXXOP1 ; call _CPOP1OP2 ; jp z,pquit ; jr ploop ploop: call _GetK ld a,23 call _SETXXOP1 call _CPOP1OP2 jp z,pquit ld a,22 call _SETXXOP1 call _CPOP1OP2 jp z,pcont jr ploop pret: call _GRBUFCPY_V call draw_screen call scoreboard ret pcont: call pret jp Start pquit: call pret jp exit scoreboard: ld hl,57*256+8 ld (PENCOL),hl ld a,(score1) call _setxxop1 ld a,2 call _dispop1a ld hl,57*256+82 ld (PENCOL),hl ld a,(score2) call _setxxop1 ld a,2 call _dispop1a ld a,(score1) cp 21 call Z,uwin ld a,(score2) cp 21 call Z,compwin ret compwin: ld hl,18*256+26 ld (PENCOL),hl ld hl,comp_wins call _vputs ld hl,24*256+31 ld (PENCOL),hl ld hl,press_clear call _vputs call wait_for_enter ld a,1 ld (done),a ret uwin: ld hl,18*256+36 ld (PENCOL),hl ld hl,you_win call _vputs ld hl,24*256+31 ld (PENCOL),hl ld hl,press_clear call _vputs call wait_for_enter ld a,1 ld (done),a ret drawpaddle1: ld b,0 ld a,(py1) ld c,a ld d,0 sub 11 ld e,a ld h,1 call _ILine inc b inc d call _ILine ret drawpaddle2: ld b,93 ld a,(py2) ld c,a ld d,93 sub 11 ld e,a ld h,1 call _ILine inc b inc d call _ILine ret restart: xor a ld (mcountc),a ld (mcount),a ld (bxcount),a ld (bycount),a ld (done),a ld a,42 ld (py1),a ld (py2),a ld a,6 ld (bxs),a ld a,5 ld (bys),a ld a,5 ld (txs),a ld a,6 ld (tys),a ld a,46 ld (x),a ld (x2),a ld (x3),a ld (x4),a ld (x5),a ld (tx),a ld (tx2),a ld (tx3),a ld (tx4),a ld (tx5),a ld a,28 ld (y),a ld (y2),a ld (y3),a ld (y4),a ld (y5),a ld (ty),a ld (ty2),a ld (ty3),a ld (ty4),a ld (ty5),a ld a,150 ld (ballupd),a ld a,100 ld (padupd),a ld a,180 ld (cpadupd),a ld a,(speed) cp 1 call Z,setnorm ld a,(speed) cp 2 call Z,setfast ld a,(ball) cp 1 call Z,fastcomp call drawpaddle1 call drawpaddle2 ret fastcomp: ld a,17 ld (cpadupd),a ret setfast: ld a,15 ld (ballupd),a ld a,10 ld (padupd),a ld a,18 ld (cpadupd),a ret setnorm: ld a,75 ld (ballupd),a ld a,50 ld (padupd),a ld a,90 ld (cpadupd),a ret draw_screen: ld b,0 ld d,94 ld c,63 ld e,63 ld h,1 call _ILine dec c dec e call _ILine ld e,8 ld c,8 call _ILine dec c dec e call _ILine ld hl,57*256+30 ld (PENCOL),hl ld hl,title call _vputs ret wait_for_enter: call _GetK ld a,45 call _SETXXOP1 call _CPOP1OP2 jp nz,wait_for_enter ret exit: call _GRBUFCLR call _clrlcdfull call _clrtxtshd call _homeup ret Description: .db "Pong 83Z v1.5",0 str_norm: .db "NORM",0 str_slow: .db "SLOW",0 title: .db " Pong 83Z",0 credits: .db "Copyright (C) 1997 Bill Nagel",0 press_clear: .db "Press Clear",0 str_paused: .db "Paused",0 game_over: .db "Game Over",0 you_win: .db "You Win!",0 comp_wins: .db "Computer Wins.",0 str_balls: .db "2nd: Balls",0 str_1: .db "1",0 str_2: .db "2",0 str_speed: .db "Alpha: Speed",0 str_fast: .db "FAST",0 .END