Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Compile this with:
- ; spasm <blah>.z80 <blah>.8xp -I path/to/Z80-Optimized-Routines
- ; Z80-Optimized-Routines can be found at https://github.com/Zeda/Z80-Optimized-Routines
- ;
- ;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;
- ; Define some vars
- ;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;
- #define spritetmp 8000h ; needed for the bigsprite routine. 8000h has 256 bytes of scrap ram, we use 4
- #define db .db ; syntax comaptibility
- #define dw .dw ; syntax comaptibility
- plotSScreen = 9340h ; a.k.a. the graph screen
- gbuf = plotSScreen ; using plotSScreen as our gbuf
- _GetCSC = 4018h ; TI-OS bcall
- coords = 8004h ;we'll store our coords here
- ;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;
- ; TI Program header
- ;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;
- .db $BB, $6D
- .org $9D95
- di ; don't let the OS interfere
- ;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;
- ; clear the gbuf
- ;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;
- ld hl,gbuf
- xor a ; shortcut to set A to 0
- ld b,a ; now B is 0, but because we are DJNZing, this is basically 256
- clr_loop:
- ld (hl),a
- inc hl
- ld (hl),a
- inc hl
- ld (hl),a
- inc hl
- djnz clr_loop
- ; init our coords
- ; note that B is already 0
- ld c,b
- draw_sprite:
- ld (coords),bc
- ; we'll draw the sprite XORed, copy the buffer to the LCD, then re-XOR it
- ; XORing twice basically does nothing to the screen, but by displaying
- ; after the first XOR, the LCD shows the sprite.
- ld hl, 0808h ; (H,L) = (height, width)
- ld de,sprite ; pointer to the sprite
- call bigsprite_XOR
- call gbuf_to_lcd_6MHz ; show the screen before we remove the sprite
- ld bc,(coords)
- ld hl, 0808h ; (H,L) = (height, width)
- ld de,sprite ; pointer to the sprite
- call bigsprite_XOR
- main_loop:
- call getKey
- or a ; shortcut to check if A is 0
- jr z,main_loop
- cp 15 ; clear button
- ret z
- cp 5 ; arrows are 1-4, so make sure it isn't bigger then 4
- jr nc,main_loop
- ld bc,(coords) ; restore coords
- dec a ; down = 1, so this would set it to 0
- jr z,move_down
- dec a ; left = 2, so this would set it to 0
- jr z,move_left
- dec a ; right = 3, so this would set it to 0
- jr z,move_right
- dec a ; up = 0, so this would set it to 0
- ; jr z,move_right
- move_up:
- or c ; make sure C isn't 0. A is already 0, so this is a cheat
- jr z,main_loop
- dec c
- jr draw_sprite
- move_down:
- ld a,c
- cp 56
- jr z,main_loop
- inc c
- jr draw_sprite
- move_right:
- ld a,b
- cp 88
- jr z,main_loop
- inc b
- jr draw_sprite
- move_left:
- or b ; make sure B isn't 0. A is already 0, so this is a cheat
- jr z,main_loop
- dec b
- jr draw_sprite
- ;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;
- ; This is a common subroutine that is required for the bigsprite routines.
- ;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;
- call_ix:
- jp (ix)
- ;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;
- ; Our sprite data
- ;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;
- sprite:
- .db %00111100
- .db %01000010
- .db %10000001
- .db %10000001
- .db %10000001
- .db %10000001
- .db %01000010
- .db %00111100
- ;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;
- ; Includes
- ;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;
- #include "ti8x/gfx/bigsprite_XOR.z80"
- #include "ti8x/gfx/gbuf_to_lcd_6MHz.z80"
- #include "ti8x/utility/getKey.z80"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement