Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .proc UpdateScrollColumn
- WhichMetaColumn = 1
- LevelBufIndex = 14
- NewColumn = StatusRow2
- ; calculate PPU address to write the 28 byte buffer to
- ; (repurposed from being a status bar)
- lda #$20
- sta Update28Address+0
- lda ScrollX+1
- lsr
- lsr
- lsr
- sta 0 ; nametable column used to determine what level column to update
- add #64 ; start one block down
- sta Update28Address+1
- ldy #0 ; y will be Update28 index
- sty WhichMetaColumn
- lda 0
- lsr ; get the LevelBuf index
- sta LevelBufIndex
- ; we split the tasks for scrolling into different parts per frame
- ; partly to leave more CPU for other stuff and partly
- ChooseTask:
- lda ScrollX+1
- and #15
- cmp #8
- jeq RenderRight
- bcc :+
- rts
- : asl
- tax
- lda ScrollTasks+1,x
- pha
- lda ScrollTasks+0,x
- pha
- rts
- RenderLeftGenerate:
- ; generate new level stuff here, if left column
- ldx #15
- lda #0
- ldy #SCROLLCOL_MIDGROUND*16
- : lda ScrollColumnTemplates,y
- sta NewColumn,x
- iny
- dex
- bpl :-
- ; just put a random block on here for now
- jsr huge_rand
- and #15
- tax
- lda #METATILE_GRASSM
- sta NewColumn,x
- ldy #0
- RenderLeft:
- tya
- lsr
- tax
- lda NewColumn,x
- sta TempVal
- lda LevelBufIndex ; step to next metatile
- tax ; but for this iteration, use the previous value
- add #16
- sta LevelBufIndex
- lda TempVal
- sta LevelBuf+16,x ; find index into MetatileData
- asl
- asl
- tax
- lda MetatileTiledata,x
- sta Update28+0,y
- lda MetatileTiledata+2,x
- sta Update28+1,y
- iny
- iny
- cpy #28
- bne RenderLeft
- rts
- RenderRight:
- lda LevelBufIndex ; step to next metatile
- tax ; but for this iteration, use the previous value
- add #16
- sta LevelBufIndex
- lda LevelBuf+16,x ; find index into MetatileData
- asl
- asl
- tax
- lda MetatileTiledata+1,x
- sta Update28+0,y
- lda MetatileTiledata+3,x
- sta Update28+1,y
- iny
- iny
- cpy #28
- bne RenderRight
- rts
- FixColors1:
- ldx #0
- ldy #FixColorSet2-FixColorSet1
- bne FixColors
- FixColors2:
- ldx #FixColorSet2-FixColorSet1
- ldy #FixColorSet3-FixColorSet2
- bne FixColors
- FixColors3:
- ldx #FixColorSet3-FixColorSet1
- ldy #FixColorSetEnd-FixColorSet3
- FixColors:
- ColorSetIndex = 12
- ColorSetLoopCount = 13
- stx ColorSetIndex
- sty ColorSetLoopCount
- FixColorsLoop:
- ldx ColorSetIndex
- inc ColorSetIndex
- lda FixColorSet1,x ; what block to do currently
- add LevelBufIndex
- tay
- sty 0
- lda LevelBuf,y ; get tile we're going to be coloring
- tay
- lda MetatileFlags,y ; get the flags for this tile
- and #3 ; mask off just the palette number
- ldy 0
- jsr ChangeBlockColor ; A = new palette, Y = LevelBuf index
- dec ColorSetLoopCount
- bne FixColorsLoop
- rts
- ; two consecutive rows are going to share the same byte
- ; so I spread it out so we're not rewriting the same byte twice in one NMI
- FixColorSet1: .byt 1*16, 3*16, 5*16, 7*16, 9*16
- FixColorSet2: .byt 11*16, 13*16, 2*16, 4*16
- FixColorSet3: .byt 6*16, 8*16, 10*16, 12*16, 14*16
- FixColorSetEnd:
- ScrollTasks:
- .raddr RenderLeftGenerate
- .raddr FixColors1
- .raddr FixColors2
- .raddr FixColors3
- .raddr EmptyObject
- .raddr EmptyObject
- .raddr EmptyObject
- .raddr EmptyObject
- .endproc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement