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 interrupts interfere
- ;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;
- ; set up the key port. Reset the low bit to poll for arrows and next bit for
- ; Enter through Clear
- ;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;
- ld a,%11111100
- out (1),a
- ;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;
- ; 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:
- ; read from the key port
- in a,(1)
- inc a ; no key presses ==> 0xFF, adding 1 makes it 0 and sets the z flag
- jr z,main_loop
- dec a
- bit 6,a ; check if clear is pressed
- ret z
- ld bc,(coords)
- ; We'll need A, so store it in H
- rra
- ld h,a
- call nc,move_down
- rr h
- call nc,move_left
- rr h
- call nc,move_right
- rr h
- call nc,move_up
- jr draw_sprite
- move_up:
- ld a,c
- or a ; make sure C isn't 0
- ret z
- dec c
- ret
- move_down:
- ld a,c
- cp 56
- ret z
- inc c
- ret
- move_right:
- ld a,b
- cp 88
- ret z
- inc b
- ret
- move_left:
- ld a,b
- or b
- ret z
- dec b
- ret
- ;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;:;;
- ; 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