Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .proc VBlankUpdates
- jsr WaitVblank
- lda #2
- sta OAM_DMA
- bit PPUSTATUS
- lda IsScrollUpdate ; update the side if needed, also use vertical writes for it since it's vertical
- jeq NotScrollUpdate
- lda #VBLANK_NMI | NT_2000 | OBJ_8X8 | BG_0000 | OBJ_1000 | VRAM_DOWN
- sta PPUCTRL
- lda ThirtyUpdateAddr+0
- sta PPUADDR
- lda ThirtyUpdateAddr+1
- sta PPUADDR
- .repeat 30, I
- lda ThirtyUpdateTile+I
- sta PPUDATA
- .endrep
- ; do attribute updates if needed
- ; note: vertical writes are still on!
- lda IsScrollUpdate
- cmp #4
- bne Not4
- .repeat 4, I
- lda AttributeWriteA1
- sta PPUADDR
- lda AttributeWriteA2+I
- sta PPUADDR
- lda AttributeWriteD+I
- sta PPUDATA
- lda AttributeWriteD+I+4
- sta PPUDATA
- .endrep
- Not4:
- NotScrollUpdate:
- lda #VBLANK_NMI | NT_2000 | OBJ_8X8 | BG_0000 | OBJ_1000
- sta PPUCTRL
- lda UploadTileAddress+1
- jeq NoUploadTile
- sta PPUADDR
- lda UploadTileAddress+0
- sta PPUADDR
- .repeat 64, I
- lda UploadTileSpace+I
- sta PPUDATA
- .endrep
- lda #0
- sta UploadTileAddress+1
- NoUploadTile:
- .repeat 4, I ; change if the max number of tile changes per frame is changed
- lda TileUpdateA1+I
- beq :+
- sta PPUADDR
- lda TileUpdateA2+I
- sta PPUADDR
- lda TileUpdateT+I
- sta PPUDATA
- lda #0
- sta TileUpdateA1+I
- :
- .endrep
- .repeat 3, I
- lda BlockUpdateA1+I
- beq :+
- sta PPUADDR
- lda BlockUpdateA2+I
- sta PPUADDR
- lda BlockUpdateT1+I
- sta PPUDATA
- lda BlockUpdateT2+I
- sta PPUDATA
- lda BlockUpdateB1+I
- sta PPUADDR
- lda BlockUpdateB2+I
- sta PPUADDR
- lda BlockUpdateT3+I
- sta PPUDATA
- lda BlockUpdateT4+I
- sta PPUDATA
- lda #0
- sta BlockUpdateA1+I
- :
- .endrep
- ; set the scroll
- lda ScrollX+1
- sta 0
- lda ScrollX
- .repeat 4
- lsr 0
- ror
- .endrep
- sta PPUSCROLL
- lda #0
- sta PPUSCROLL
- lda 0
- and #1 ; bit 0 is most significant bit of scroll
- ora #VBLANK_NMI | NT_2000 | OBJ_8X8 | BG_0000 | OBJ_1000
- sta PPUCTRL
- .endproc
- ; don't put anything else here
- .proc MainLoop
- lda #OBJ_CLIP | BG_CLIP | 1 ; turn grayscale on for CPU usage meter
- sta PPUMASK
- lda IsScrollUpdate ; decrease scroll update stage
- beq :+
- dec IsScrollUpdate
- : jsr ReadJoy
- jsr ClearOAM
- lda #MAINLOOP_BANK
- jsr SetPRG
- jsr RunPlayer
- jsr AdjustCamera
- jsr DisplayPlayer
- jsr RunObjects
- jsr FlickerEnemies
- lda #SOUND_BANK
- jsr SetPRG
- jsr FamiToneUpdate
- lda NeedSFX
- bpl :+
- and #63
- ldx #FT_SFX_CH0
- jsr FamiToneSfxPlay
- lda #0
- sta NeedSFX
- :
- lda #OBJ_CLIP | BG_CLIP
- sta PPUMASK
- jmp VBlankUpdates
- .endproc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement