Permalink
Browse files

Fully construct options nametable before re-enabling PPU drawing

Should fix vblank overflow on options screen.
  • Loading branch information...
Sylvain Gadrat
Sylvain Gadrat committed Apr 15, 2017
1 parent b64142b commit 62cdf8b54ba4accfd964472789854d9469a88298
Showing with 8,178 additions and 40 deletions.
  1. +4 −0 prg_rom/config_screen.asm
  2. +8 −40 prg_rom/prg_rom.asm
  3. +45 −0 prg_rom/utils.asm
  4. +8,121 −0 tilt.nes.0.nl
@@ -169,6 +169,10 @@ sta config_selected_option
; Adapt to configuration's state
jsr config_update_screen
; Process the batch of nt buffers immediately (while the PPU is disabled)
jsr process_nt_buffers
jsr reset_nt_buffers
rts
sprites:
View
@@ -13,52 +13,18 @@ pha
tya
pha
; Do not draw anything if not ready
lda nmi_processing
beq end
; reload PPU OAM (Objects Attributes Memory) with fresh data from cpu memory
lda #$00
sta OAMADDR
lda #$02
sta OAMDMA
; Copy nametable buffers to PPU nametable
; A nametable buffer has the following pattern:
; continuation (1 byte), address (2 bytes), number of tiles (1 byte), tiles (N bytes)
; continuation - 1 there is a buffer, 0 work done
; address - address where to write in PPU address space (big endian)
; number of tiles - Number of tiles in this buffer
; tiles - One byte per tile, representing the tile number
.(
ldx #$00
handle_nt_buffer:
lda nametable_buffers, x ; Check continuation byte
beq end_buffers ;
inx ;
lda PPUSTATUS ; Set PPU destination address
lda nametable_buffers, x ;
sta PPUADDR ;
inx ;
lda nametable_buffers, x ;
sta PPUADDR ;
inx ;
lda nametable_buffers, x ; Save tiles counter to tmpfield1
sta tmpfield1 ;
inx ;
write_one_tile:
lda tmpfield1 ; Check if there is still a tile to write
beq handle_nt_buffer ;
lda nametable_buffers, x ; Write current tile to PPU
sta PPUDATA ;
dec tmpfield1 ; Next tile
inx ;
jmp write_one_tile ;
end_buffers:
.)
; Rewrite nametable based on nt_buffers
jsr process_nt_buffers
; Scroll
lda ppuctrl_val
@@ -73,6 +39,8 @@ sta PPUSCROLL
lda #$00
sta nmi_processing
end:
; Restore CPU registers
pla
tay
View
@@ -330,6 +330,51 @@ sta nametable_buffers
rts
.)
; Copy nametable buffers to PPU nametable
; A nametable buffer has the following pattern:
; continuation (1 byte), address (2 bytes), number of tiles (1 byte), tiles (N bytes)
; continuation - 1 there is a buffer, 0 work done
; address - address where to write in PPU address space (big endian)
; number of tiles - Number of tiles in this buffer
; tiles - One byte per tile, representing the tile number
;
; Overwrites register X
process_nt_buffers:
.(
ldx #$00
handle_nt_buffer:
lda nametable_buffers, x ; Check continuation byte
beq end_buffers ;
inx ;
lda PPUSTATUS ; Set PPU destination address
lda nametable_buffers, x ;
sta PPUADDR ;
inx ;
lda nametable_buffers, x ;
sta PPUADDR ;
inx ;
lda nametable_buffers, x ; Save tiles counter to tmpfield1
sta tmpfield1 ;
inx ;
write_one_tile:
lda tmpfield1 ; Check if there is still a tile to write
beq handle_nt_buffer ;
lda nametable_buffers, x ; Write current tile to PPU
sta PPUDATA ;
dec tmpfield1 ; Next tile
inx ;
jmp write_one_tile ;
end_buffers:
rts
.)
; Produce a list of three tile indexes representing a number
; tmpfield1 - Number to represent
; tmpfield2 - Destination address LSB
Oops, something went wrong.

0 comments on commit 62cdf8b

Please sign in to comment.