Remove some dead code and streamline some addressing. Fix bug in dispatch macro

This commit is contained in:
Lucas Scharenbroich 2022-06-02 12:28:49 -05:00
parent 83ec527b06
commit 4f557230c6
5 changed files with 18 additions and 20 deletions

View File

@ -245,3 +245,4 @@ ScreenModeHeight EXT
_SpriteBits EXT
_SpriteBitsNot EXT
VBuffArray EXT
_stamp_step EXT

View File

@ -575,20 +575,17 @@ _CacheSpriteBanks
; it's tile information, or changing its position.
;
; X = sprite index
_stamp_step dw 0,12,24,36
_PrecalcAllSpriteInfo
lda _Sprites+SPRITE_ID,x
; and #$3E00
xba
and #$0006
txy ; swap X/Y for this...
tax
lda _Sprites+VBUFF_ADDR,y
tay
lda _Sprites+VBUFF_ADDR,x
clc
adcl _stamp_step,x
adc _stamp_step,y
sta _Sprites+SPRITE_DISP,y
tyx
; Set the sprite's width and height
lda #4
@ -604,7 +601,7 @@ _PrecalcAllSpriteInfo
:width_4
lda _Sprites+SPRITE_ID,x
bit #$0800 ; width select
bit #$0800 ; height select
beq :height_8
lda #16
sta _Sprites+SPRITE_HEIGHT,x
@ -734,7 +731,7 @@ _UpdateSprite
; Move a sprite to a new location. If the tile ID of the sprite needs to be changed, then
; a full remove/add cycle needs to happen
;
; A = sprite ID
; A = sprite slot
; X = x position
; Y = y position
_MoveSprite
@ -750,7 +747,6 @@ _MoveSprite
cmp _Sprites+SPRITE_X,x
bne :changed1
sta _Sprites+SPRITE_X,x ; Update the X coordinate
tya
cmp _Sprites+SPRITE_Y,x
bne :changed2

View File

@ -128,10 +128,6 @@ _CalcDirtySprite
lda _Sprites+VBUFF_ARRAY_ADDR,y
sec
sbc TileStoreLookup,x
; eor #$FFFF
; sec
; adc _Sprites+VBUFF_ARRAY_ADDR,y
sta tmp1 ; Spill this value to direct page temp space
; Calculate the final address of the sprite data in the stamp buffer. We have to move earlier

View File

@ -268,11 +268,11 @@ dobit mac
bcc next_bit
beq last_bit
tax
lda (SPRITE_VBUFF_PTR+{]2*2}),y
lda (SPRITE_VBUFF_PTR+{]1*2}),y
sta sprite_ptr0+{]2*4}
txa
jmp ]3
last_bit lda (SPRITE_VBUFF_PTR+{]2*2}),y
last_bit lda (SPRITE_VBUFF_PTR+{]1*2}),y
sta sprite_ptr0+{]2*4}
jmp ]4
next_bit
@ -280,16 +280,17 @@ next_bit
; Specialization for the first sprite which can just return the vbuff address
; in a register if there is only one sprite intersecting the tile
; dobit bit_position,dest;next;exit
dobit1 mac
lsr
bcc next_bit
beq last_bit
tax
lda (SPRITE_VBUFF_PTR+{]2*2}),y
lda (SPRITE_VBUFF_PTR+{]1*2}),y
sta sprite_ptr0+{]2*4}
txa
jmp ]3
last_bit lda (SPRITE_VBUFF_PTR+{]2*2}),y
last_bit lda (SPRITE_VBUFF_PTR+{]1*2}),y
jmp ]4
next_bit
<<<
@ -366,7 +367,7 @@ next_bit
stpbit mac
lsr
bcc next_bit
lda (SPRITE_VBUFF_PTR+{]2*2}),y
lda (SPRITE_VBUFF_PTR+{]1*2}),y
sta sprite_ptr0+{]2*4}
jmp ]3
next_bit
@ -374,7 +375,7 @@ next_bit
; Last bit test which *must* be set
endbit mac
lda (SPRITE_VBUFF_PTR+{]2*2}),y
lda (SPRITE_VBUFF_PTR+{]1*2}),y
sta sprite_ptr0+{]2*4}
jmp ]3
<<<
@ -421,7 +422,7 @@ SpriteBitsToVBuffAddrs mac
dobit1 12;0;b_13_1;]1
dobit1 13;0;b_14_1;]1
dobit1 14;0;b_15_1;]1
endbit 15;0;]1
endbit 15;0;]1
b_1_1 dobit 1;1;b_2_2;]2
b_2_1 dobit 2;1;b_3_2;]2

View File

@ -423,5 +423,9 @@ _SpriteBits ENT
_SpriteBitsNot ENT
dw $FFFE,$FFFD,$FFFB,$FFF7,$FFEF,$FFDF,$FFBF,$FF7F,$FEFF,$FDFF,$FBFF,$F7FF,$EFFF,$DFFF,$BFFF,$7FFF
; Steps to the different sprite stamps
_stamp_step ENT
dw 0,12,24,36
blt_return
stk_save