home *** CD-ROM | disk | FTP | other *** search
- ;Dijpupon 1998
- ;Bouncy Ball v1.0
- ;June 17, 1998
-
- .NOLIST
-
- #define equ .EQU
- #define EQU .equ
- #define end .end
-
- #include "ti83asm.inc"
- #include "tokens.inc"
- #include "sos.inc"
-
- .LIST
-
- ;~~~~~~~~~~ vars ~~~~~~~~~~
- #define xc 8265h ;x coordinate
- #define yc 8266h ;y coordinate
- #define vert 8267h ;vertical direction (0=up 1=down)
- #define horiz 8268h ;horizontal direction (0=left 1=right)
-
- .org 9327h
-
- ;~~~~~~~~~~ THIS IS AN SOS PROGRAM! ~~~~~~~~~~
- ccf ; SOS program
- jr z,start_of_program ; not detectable until INSTALL is run
- .dw sos_libraries-$9327 ; libraries
- .dw title ; title to be displayed
-
- ;~~~~~~~~~~ begin ~~~~~~~~~~
- start_of_program:
- ld b,80 ;upper bound
- call vector1 ;random
- ld (xc),a ;store x-coord value
- ld b,49
- call vector1 ;random
- ld (yc),a ;y-coord
- ld b,2
- call vector1 ;random
- ld (vert),a ;vertical direction
- ld b,2
- call vector1 ;random
- ld (horiz),a ;horizontal direction
-
- ;~~~~~~~~~~ move ~~~~~~~~~~
- move:
- call draw_b ;draw the ball
- move_l:
- call _grbufcpy_v ;copy the buffer to the screen
- call _getK ;\
- call _op2toop1 ; }get a key
- call _convop1 ;/
- cp 22 ;[MODE]
- call z,waitkey ;pressed?... pause
- cp 45 ;[CLEAR]
- ret z ;exit and return to SOS
- call draw_b ;take away the ball
- call u_d ;move up or down
- call l_r ;move left or right
- call draw_b ;draw the ball
- jr move_l ;loop back
-
- ;~~~~~~~~~~ up/down ~~~~~~~~~
- u_d:
- ld a,(yc)
- ld b,a ;store y-coord in b
- ld a,(vert)
- cp 0 ;up
- jr nz,down ;jump to "down:"
- up:
- ld a,b
- cp 0 ;at the edge of the screen (graph buffer)
- jr nz,up_nch
- inc a ;yc=yc+1
- ld (yc),a
- ld a,1 ;reverse direction (down)
- ld (vert),a
- ret ;return
- up_nch:
- dec a ;yc=yc-1
- ld (yc),a
- ret ;return
- down:
- ld a,b
- cp 48 ;edge (this is determined by the dimensions of the sprite)
- jr nz,dw_nch
- dec a ;yc=yc-1
- ld (yc),a
- ld a,0 ;reverse direction (up)
- ld (vert),a
- ret ;return
- dw_nch:
- inc a
- ld (yc),a ;yc=yc+1
- ret ;return
-
- ;~~~~~~~~~~ left/right ~~~~~~~~~~~
- l_r:
- ld a,(xc)
- ld b,a ;store x-coord in b
- ld a,(horiz)
- cp 0 ;left
- jr nz,right ;right
- left:
- ld a,b
- cp 0 ;edge
- jr nz,l_nch
- inc a ;xc=xc+1
- ld (xc),a
- ld a,1 ;reverse direction (right)
- ld (horiz),a
- ret ;return
- l_nch:
- dec a ;xc=xc-1
- ld (xc),a
- ret ;return
- right:
- ld a,b
- cp 79 ;edge
- jr nz,r_nch
- dec a ;xc=xc-1
- ld (xc),a
- ld a,0 ;reverse direction (left)
- ld (horiz),a
- ret ;return
- r_nch:
- inc a ;xc=xc+1
- ld (xc),a
- ret ;return
-
- ;~~~~~~~~~~ draw ball ~~~~~~~~~~
- draw_b:
- ld b,16 ;b = height
- ld a,(yc)
- ld l,a ;l = y-coord
- ld a,(xc) ;a = x-coord
- ld ix,ball_l ;ix = upper left portion of ball
- call vector0 ;ZLIB XOR sprite routine
- ld b,16 ;b = height
- ld a,(yc)
- ld l,a ;l = y-coord
- ld a,(xc) ;a = x-coord
- ld c,8
- add a,c ;this sprite is 8 pixels right from x-coord
- ld ix,ball_r ;ix = upper right portion of ball
- call vector0 ;ZLIB XOR sprite routine
- ret ;return
-
- ;~~~~~~~~~~ wait for a key ~~~~~~~~~~
- waitkey:
- call _getK ;value returned in op2
- call _op2toop1 ;store op2 in op1
- call _convop1 ;a = op1
- cp 0 ;no key pressed
- jr z,waitkey ;keep looping until a key is pressed
- ret ;return
-
- ;~~~~~~~~~~ text ~~~~~~~~~~
- title: .db "Bouncy Ball v1.0 by Dijpupon"
- .db 0
-
- ;~~~~~~~~~~ sprites ~~~~~~~~~~
- ball_l:
- .db %00000111 ;left side of ball
- .db %00011111
- .db %00111111
- .db %01111111
- .db %01111111
- .db %11111111
- .db %11111111
- .db %11111111
- .db %11111111
- .db %11111111
- .db %11111111
- .db %01111111
- .db %01111111
- .db %00111111
- .db %00011111
- .db %00000111
- ball_r
- .db %11100000 ;right side
- .db %11111000
- .db %11111100
- .db %11111110
- .db %11111110
- .db %11111111
- .db %11111111
- .db %11111111
- .db %11111111
- .db %11111111
- .db %11111111
- .db %11111110
- .db %11111110
- .db %11111100
- .db %11111000
- .db %11100000
-
- ;~~~~~~~~~~ (libraries) ~~~~~~~~~~
- sos_libraries:
- .db "ZLIB",0,0,0,0,lib1,vec0 ; sprite
- .db "ZLIB",0,0,0,0,lib2,vec1 ; random
- .db $FF
-
- .end
- END