pipe bottom working..

This commit is contained in:
Dagen Brock
2014-04-25 19:38:57 -05:00
parent 2a82bda46c
commit ecbf63d8ee
2 changed files with 144 additions and 32 deletions

View File

@@ -38,7 +38,7 @@ GameLoop
jsr UpdatePipes
jsr UpdateGrass
jsr VBlank
*jsr WaitKey
jsr WaitKey
@@ -82,16 +82,6 @@ BotPipes hex 00,00,00,00
BotPipeMin equ 3
BotPipeMax equ 8
PipeSpr_Main
hex 55,e5,e5,c5,e5,c5,c5,c5,c5,45,c5,45,45,55,77
hex 55,5e,5e,5c,5e,5c,5c,5c,5c,54,5c,54,54,55,77
hex 77,55,ee,ee,cc,ee,cc,cc,44,cc,44,44,55,77,77
PipeSpr_Aux
hex aa,7a,7a,6a,7a,6a,6a,6a,6a,2a,6a,2a,2a,aa,bb
hex aa,a7,a7,a6,a7,a6,a6,a6,a6,a2,a6,a2,a2,aa,bb
hex bb,aa,77,77,66,77,66,66,22,66,22,22,aa,bb,bb
* pipe min = 15x6 pixels = 15x3 bytes
* playfield = 80x48 pixels = 80x24 bytes

View File

@@ -21,7 +21,15 @@
* >:(
*
**************************************************
PipeSpr_Main
hex 55,e5,e5,c5,e5,c5,c5,c5,c5,45,c5,45,45,55,77
hex 55,5e,5e,5c,5e,5c,5c,5c,5c,54,5c,54,54,55,77
hex 77,55,ee,ee,cc,ee,cc,cc,44,cc,44,44,55,77,77
PipeSpr_Aux
hex aa,7a,7a,6a,7a,6a,6a,6a,6a,2a,6a,2a,2a,aa,bb
hex aa,a7,a7,a6,a7,a6,a6,a6,a6,a2,a6,a2,a2,aa,bb
hex bb,aa,77,77,66,77,66,66,22,66,22,22,aa,bb,bb
SRCPTR equz $00
DSTPTR equz $02
@@ -38,6 +46,20 @@ PIPE_T_B db 0 ; TOP = 0, BOTTOM = 1 (non-zero)
PIPE_TOP equ 0 ; enum for top pipe type
PIPE_BOT equ 1 ; enum for bottom pipe type
* Used by all of the routines that draw the pipe caps
SetPipeCapPtrs
ldy PIPE_Y_IDX
lda LoLineTable,y
sta DSTPTR
lda LoLineTable+1,y
sta DSTPTR+1 ; pointer to line on screen
lda LoLineTable+2,y
sta DSTPTR2
lda LoLineTable+3,y
sta DSTPTR2+1 ; pointer to line on screen
rts
* A=x Y=(byte)y
DrawPipe
sta PIPE_X_FULL
@@ -126,7 +148,61 @@ DrawPipeOdd jsr SetPipeCapPtrs
inx ;\_ skip a col
cpx #PIPE_WIDTH
bcc :l2_loop
* Handle body
lda PIPE_T_B ; TOP or BOTTOM ?
bne :doBottom
rts ; @TODO!!! starting with bottom
:doTop jsr DrawPipeOddT
rts
:doBottom jsr DrawPipeOddB
rts
DrawPipeOddB
inc PIPE_Y_IDX ; set to advance to 3rd line (2) of sprite pos
inc PIPE_Y_IDX ;
:loop inc PIPE_Y_IDX ; remember this is the *2 table lookup
inc PIPE_Y_IDX
ldy PIPE_Y_IDX
cpy #44 ; make sure we haven't hit bottom... pun intended
beq :done
lda LoLineTable,y
sta DSTPTR
lda LoLineTable+1,y
sta DSTPTR+1 ; pointer to line on screen
sta TXTPAGE1
ldy PIPE_X_IDX
ldx #1
:l1_loop cpy #PIPE_RCLIP
beq :l1_clip_break
lda 2*PIPE_WIDTH+PipeSpr_Main,x ; line 2
sta (DSTPTR),y
iny
inx
inx
cpx #PIPE_WIDTH
bcc :l1_loop
:l1_clip_break
sta TXTPAGE2
ldy PIPE_X_IDX
ldx #0
:l2_loop cpy #PIPE_RCLIP
beq :l2_clip_break
lda 2*PIPE_WIDTH+PipeSpr_Aux,x ; line 2
sta (DSTPTR),y
iny
inx
inx
cpx #PIPE_WIDTH
bcc :l2_loop
:l2_clip_break sec
bcs :loop
:done rts
DrawPipeOddT rts
DrawPipeEven jsr SetPipeCapPtrs
sta TXTPAGE2
@@ -156,35 +232,21 @@ DrawPipeEven jsr SetPipeCapPtrs
bcc :l2_loop
rts
SetPipeCapPtrs
ldy PIPE_Y_IDX
lda LoLineTable,y
sta DSTPTR
lda LoLineTable+1,y
sta DSTPTR+1 ; pointer to line on screen
lda LoLineTable+2,y
sta DSTPTR2
lda LoLineTable+3,y
sta DSTPTR2+1 ; pointer to line on screen
rts
* A=x(screenmemX) x=x(full96) Y=(byte)y
DrawPipeOddR
DrawPipeOddR
jsr SetPipeCapPtrs
sta TXTPAGE1
ldy PIPE_X_IDX ; y= the x offset... yay dp indexing on 6502
ldy PIPE_X_IDX ; y= x offset... yay dp indexing on 6502
ldx #0
:l1_loop
cpy #PIPE_RCLIP ;this works for underflow too (?) i think
bcs :l1_break
lda PipeSpr_Main,x
sta (DSTPTR),y
lda PipeSpr_Main+PIPE_WIDTH,x
sta (DSTPTR2),y
iny ; can check this for clipping?
inx
inx ;\_ skip a col
@@ -196,7 +258,7 @@ DrawPipeOddR
ldy PIPE_X_IDX
iny ;-- pixel after - fun mapping
ldx #1
:l1a_loop
:l2_loop
cpy #PIPE_RCLIP
bcs :l2_break
@@ -209,13 +271,21 @@ DrawPipeOddR
inx
inx ;\_ skip a col
cpx #PIPE_WIDTH
bcc :l1a_loop
bcc :l2_loop
:l2_break
*** Handle body
lda PIPE_T_B ; TOP or BOTTOM ?
bne :doBottom
rts ; @TODO!!! starting with bottom
:doTop jsr DrawPipeOddT
rts
:doBottom jsr DrawPipeOddB
rts
DrawPipeEvenR
DrawPipeEvenR
jsr SetPipeCapPtrs
sta TXTPAGE1
sta TXTPAGE2
ldy PIPE_X_IDX ; y= the x offset... yay dp indexing on 6502
ldx #0
:l1_loop lda PipeSpr_Aux,x
@@ -247,7 +317,6 @@ DrawPipeEvenR
bcc :l1a_loop
:l2_break rts
* A=x(screenmemX) x=x(full96) Y=(byte)y
DrawPipeOddL
jsr SetPipeCapPtrs
sta TXTPAGE1
@@ -281,7 +350,60 @@ DrawPipeOddL
inx ;\_ skip a col
cpx #PIPE_WIDTH
bcc :l2_loop
*** Handle body
lda PIPE_T_B ; TOP or BOTTOM ?
bne :doBottom
rts ; @TODO!!! starting with bottom
:doTop jsr DrawPipeOddT
rts
:doBottom jsr DrawPipeOddBL
rts
DrawPipeOddBL
inc PIPE_Y_IDX ; set to advance to 3rd line (2) of sprite pos
inc PIPE_Y_IDX ;
:loop inc PIPE_Y_IDX ; remember this is the *2 table lookup
inc PIPE_Y_IDX
ldy PIPE_Y_IDX
cpy #44 ; make sure we haven't hit bottom... pun intended
beq :done
lda LoLineTable,y
sta DSTPTR
lda LoLineTable+1,y
sta DSTPTR+1 ; pointer to line on screen
sta TXTPAGE1
ldy PIPE_X_IDX
ldx #1
:l1_loop cpy #PIPE_RCLIP
bcs :l1_clip_skip
lda 2*PIPE_WIDTH+PipeSpr_Main,x ; line 2
sta (DSTPTR),y
:l1_clip_skip iny
inx
inx
cpx #PIPE_WIDTH
bcc :l1_loop
:l1_clip_break
sta TXTPAGE2
ldy PIPE_X_IDX
ldx #0
:l2_loop cpy #PIPE_RCLIP
bcs :l2_clip_skip
lda 2*PIPE_WIDTH+PipeSpr_Aux,x ; line 2
sta (DSTPTR),y
:l2_clip_skip iny
inx
inx
cpx #PIPE_WIDTH
bcc :l2_loop
:l2_clip_break sec
bcs :loop
:done rts
DrawPipeEvenL
jsr SetPipeCapPtrs