pipe cap sprite optimization

This commit is contained in:
Dagen Brock 2014-05-06 20:50:31 -05:00
parent ea2c27f1e9
commit efc076e425

View File

@ -139,24 +139,39 @@ MovePipes
DrawPipes
lda BotPipes
lda BotPipes ;BotPipes[0]
beq :noP1
sta PIPE_X_FULL
ldx #PIPE_BOT
stx PIPE_T_B
ldy BotPipes+1
sty PIPE_Y
jsr DrawPipe
lda TopPipes ;TopPipes[0]
sta PIPE_X_FULL
ldx #PIPE_TOP
lda TopPipes
stx PIPE_T_B
ldy TopPipes+1
sty PIPE_Y
jsr DrawPipe
:noP1
lda BotPipes+2
lda BotPipes+2 ;BotPipes[1]
beq :noP2
ldx #PIPE_BOT
stx PIPE_T_B
sta PIPE_X_FULL
ldy BotPipes+3
sty PIPE_Y
jsr DrawPipe
ldx #PIPE_TOP
stx PIPE_T_B
lda TopPipes+2
sta PIPE_X_FULL
ldy TopPipes+3
sty PIPE_Y
jsr DrawPipe
:noP2
rts
@ -178,11 +193,8 @@ SetPipeCapPtrs
* A=x Y=(byte)y X=pipe top/bottom
DrawPipe
stx PIPE_T_B
sta PIPE_X_FULL
sty PIPE_Y
tya
lda PIPE_Y
asl ; *2
sta PIPE_Y_IDX
@ -529,29 +541,108 @@ DrawPipeEvenBL
DrawPipeEven jsr SetPipeCapPtrs
sta TXTPAGE2
ldy PIPE_X_IDX ; y= the x offset... yay dp indexing on 6502
ldx #0
:l1_loop lda PipeSpr_Aux,x
; optimized by hand, not perfect, but big help
;col 0
cpy #PIPE_RCLIP
bcs :RCLIP
lda #$AA
sta (PIPE_DP),y
lda PipeSpr_Aux+PIPE_WIDTH,x
sta (PIPE_DP2),y
iny ; can check this for clipping?
inx
inx ;\_ skip a col
cpx #PIPE_WIDTH
bcc :l1_loop
iny ;col 2
cpy #PIPE_RCLIP
bcs :RCLIP
lda #$7A
sta (PIPE_DP),y
lda #$A7
sta (PIPE_DP2),y
iny ;col 4
cpy #PIPE_RCLIP
bcs :RCLIP
sta (PIPE_DP2),y
lda #$7A
sta (PIPE_DP),y
iny ;col 6
cpy #PIPE_RCLIP
bcs :RCLIP
lda #$6A
sta (PIPE_DP),y
lda #$A6
sta (PIPE_DP2),y
iny ;col 8
cpy #PIPE_RCLIP
bcs :RCLIP
sta (PIPE_DP2),y
lda #$6A
sta (PIPE_DP),y
iny ;col 10
cpy #PIPE_RCLIP
bcs :RCLIP
sta (PIPE_DP),y
lda #$A6
sta (PIPE_DP2),y
iny ;col 12
cpy #PIPE_RCLIP
bcs :RCLIP
lda #$2A
sta (PIPE_DP),y
lda #$A2
sta (PIPE_DP2),y
iny ;col 14 (final!)
cpy #PIPE_RCLIP
bcs :RCLIP
lda #$BB
sta (PIPE_DP),y
sta (PIPE_DP2),y
:RCLIP
sta TXTPAGE1
ldy PIPE_X_IDX
ldx #1
:l2_loop lda PipeSpr_Main,x
ldy PIPE_X_IDX ; y= the x offset... yay dp indexing on 6502
;col 1
cpy #PIPE_RCLIP
bcs :RCLIP2
lda #$E5
sta (PIPE_DP),y
lda PipeSpr_Main+PIPE_WIDTH,x
lda #$5E
sta (PIPE_DP2),y
iny ; can check this for clipping?
inx
inx ;\_ skip a col
cpx #PIPE_WIDTH
bcc :l2_loop
iny ;col 3
cpy #PIPE_RCLIP
bcs :RCLIP2
lda #$C5
sta (PIPE_DP),y
lda #$5C
sta (PIPE_DP2),y
iny ;col 5
cpy #PIPE_RCLIP
bcs :RCLIP2
sta (PIPE_DP2),y
lda #$C5
sta (PIPE_DP),y
iny ;col 7
cpy #PIPE_RCLIP
bcs :RCLIP2
sta (PIPE_DP),y
lda #$5C
sta (PIPE_DP2),y
iny ;col 9
cpy #PIPE_RCLIP
bcs :RCLIP2
lda #$45
sta (PIPE_DP),y
lda #$54
sta (PIPE_DP2),y
iny ;col 11
cpy #PIPE_RCLIP
bcs :RCLIP2
sta (PIPE_DP2),y
lda #$45
sta (PIPE_DP),y
iny ;col 13
cpy #PIPE_RCLIP
bcs :RCLIP2
lda #$55
sta (PIPE_DP),y
sta (PIPE_DP2),y
:RCLIP2
* Handle body
lda PIPE_T_B ; TOP or BOTTOM ?
bne :doBottom