sprites: working sprite

This commit is contained in:
Vince Weaver 2019-06-13 12:12:36 -04:00
parent 93e0f4af41
commit 8a21bce3cd
4 changed files with 62 additions and 22 deletions

View File

@ -43,7 +43,7 @@ SPRITES: sprites.o
ld65 -o SPRITES sprites.o -C ../linker_scripts/apple2_1000.inc
sprites.o: sprites.s gr_copy.s \
sprites_screen.s sprites_table.s movement_table.s earth.inc
sprites_screen.s sprites_table.s movement_table.s earth.inc asteroid.inc
ca65 -o sprites.o sprites.s -l sprites.lst

View File

@ -0,0 +1,21 @@
; all hard-coded 3x2
asteroid_p1:
.byte $50,$85,$80
.byte $05,$88,$08
explode0_p1:
.byte $50,$85,$80
.byte $05,$88,$08
explode1_p1:
.byte $50,$85,$80
.byte $05,$88,$08
explode2_p1:
.byte $50,$85,$80
.byte $05,$88,$08
void_p1:
.byte $00,$00,$00
.byte $00,$00,$00

View File

@ -2,37 +2,32 @@
; put_sprite
;=============================================
; Sprite to display in INH,INL
; Assumes sprite size is 3x2
; Location is SPRITE_XPOS,SPRITE_YPOS
; Note, only works if SPRITE_YPOS is multiple of two
; NO TRANSPARENCY
; 28+ Y*(34+17+X*(18+13) + 5
; 33 + Y*(51+31*X)
; 13+ Y*(33+17+X*(18+13) + 5
; 18 + Y*(50+31*X)
; so if 3*2 = 321 cycles??
; so if 3*2 = 304 cycles??
put_sprite:
ldy #0 ; byte 0 is xsize ; 2
lda (INL),Y ; 5
sta CH ; xsize is in CH ; 3
iny ; 2
lda (INL),Y ; byte 1 is ysize ; 5
ldy #0 ; 2
lda #2 ; ysize is 2 ; 2
sta CV ; ysize is in CV ; 3
iny ; 2
lda SPRITE_YPOS ; make a copy of ypos ; 3
lda SPRITE_YPOS ; make a copy of ypos ; 3
sta TEMPY ; as we modify it ; 3
;===========
; 28
; 13
put_sprite_loop:
sty TEMP ; save sprite pointer ; 3
ldy TEMPY ; 3
lda gr_offsets,Y ; lookup low-res memory address ; 4
clc ; 2
adc SPRITE_XPOS ; add in xpos ; 3
adc SPRITE_XPOS ; add in xpos ; 3
sta OUTL ; store out low byte of addy ; 3
lda gr_offsets+1,Y ; look up high byte ; 4
adc DRAW_PAGE ; ; 3
@ -41,9 +36,9 @@ put_sprite_loop:
; OUTH:OUTL now points at right place
ldx CH ; load xsize into x ; 3
ldx #3 ; load xsize into x ; 2
;===========
; 34
; 33
put_sprite_pixel:
lda (INL),Y ; get sprite colors ; 5
iny ; increment sprite pointer ; 2

View File

@ -232,11 +232,12 @@ display_loop:
; -31 -- move ship
; -17 -- move fire
; -436 -- draw fire
; -335 -- draw asteroid
; -61 -- keypress
; -33 -- handle fire press
; -8 -- loop
;=======
; 1147
; 812
;================
; erase old ship
@ -589,6 +590,28 @@ no_draw_fire:
done_draw_fire:
;=====================
; draw the asteroid
lda #$0 ; 2
sta DRAW_PAGE ; 3
lda #<asteroid_p1 ; 2
sta INL ; 3
lda #>asteroid_p1 ; 2
sta INH ; 3
lda #30 ; 2
sta SPRITE_XPOS ; 3
lda #12 ; 2
sta SPRITE_YPOS ; 3
jsr put_sprite ; 6+304
;======
; 335
pad_time:
@ -610,13 +633,12 @@ pad_time:
wait_loop:
; Try X=37 Y=6 cycles=1147
; Try X=161 Y=1 cycles=812
; nop
; nop
ldy #6 ; 2
loop1: ldx #37 ; 2
ldy #1 ; 2
loop1: ldx #161 ; 2
loop2: dex ; 2
bne loop2 ; 2nt/3
dey ; 2
@ -1060,3 +1082,5 @@ ship_sprite:
; l13:
.byte $00,$00,$00,$ff,$ff,$77,$ff
.include "asteroid.inc"