Scrollin'
Moderator: Moderators
Scrollin'
I have scrolling implemented now. Though it is a tad buggy I have the core engine in place. Let me know what you think.
Source: http://www.yibbleware.com/nes/cartlemmy-test-0.2.zip
NES: http://www.yibbleware.com/nes/cartlemmy-test-0.2.nes
(use UDLR on controller to scroll)
Also, I want to make it so that the background initialization is done all in one pass... The problem is there is not enough vBlank time for that. Is there a way I can black the screen out and keep rendering without the PPU interfering?
Source: http://www.yibbleware.com/nes/cartlemmy-test-0.2.zip
NES: http://www.yibbleware.com/nes/cartlemmy-test-0.2.nes
(use UDLR on controller to scroll)
Also, I want to make it so that the background initialization is done all in one pass... The problem is there is not enough vBlank time for that. Is there a way I can black the screen out and keep rendering without the PPU interfering?
PPUMASK register ($2001)
Set to 0 and the screen becomes blank (uses the background color from the palette), and you can draw as much as you want.
Make sure to wait for vblank (NMI) before you turn the screen back on.
By the way, I tend to use stack tricks to do PPU writes, so your draw code can look something like:
PLA
STA $2007
PLA
STA $2007
PLA
STA $2007
PLA
STA $2007
...
It's probably not the "best way" for newcomers to do it though, but it sure is fast. You need to absolutely make sure there is no way for that code to be interrupted.
Here's a snippet of code I was using to draw columns onto the screen in my own scrolling demo. (thread) (File)
It's designed for vertical mirroring, so it assumes that columns will be drawn in two parts, one for the 'top half' and one for the 'bottom half'.
Set to 0 and the screen becomes blank (uses the background color from the palette), and you can draw as much as you want.
Make sure to wait for vblank (NMI) before you turn the screen back on.
By the way, I tend to use stack tricks to do PPU writes, so your draw code can look something like:
PLA
STA $2007
PLA
STA $2007
PLA
STA $2007
PLA
STA $2007
...
It's probably not the "best way" for newcomers to do it though, but it sure is fast. You need to absolutely make sure there is no way for that code to be interrupted.
Here's a snippet of code I was using to draw columns onto the screen in my own scrolling demo. (thread) (File)
It's designed for vertical mirroring, so it assumes that columns will be drawn in two parts, one for the 'top half' and one for the 'bottom half'.
Code: Select all
DrawColumn:
lda #$04 ;disable NMI, inc by 32
sta PPUCTRL
tsx
txa ;save old stack pointer to register A
ldx #(NameTableBufferColumn-1)&$FF
txs
tax ;copy old stack pointer to register X
lda ntColAddress1+1
sta PPUADDR
lda ntColAddress1
sta PPUADDR
ldy ntColBlocksRemaining1
-
pla
sta PPUDATA
pla
sta PPUDATA
dey
bne -
ldy ntColBlocksRemaining2
beq +
lda ntColAddress2+1
sta PPUADDR
lda ntColAddress2
sta PPUADDR
-
pla
sta PPUDATA
pla
sta PPUDATA
dey
bne -
+
txs
rts
Last edited by Dwedit on Fri Oct 15, 2010 10:15 am, edited 1 time in total.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
Or using the .repeat command (automatic unrolling) in ca65:Dwedit wrote:By the way, I tend to use stack tricks to do PPU writes, so your draw code can look something like:
Code: Select all
.repeat 16, I
pla ; 4
sta $2007 ; 4
.endrepeat
Code: Select all
.repeat 16, I
lda xferBufBase+I,x ; 4
sta $2007 ; 4
.endrepeat
The other way to do it, used by ca65, is : labels that can be accessed with :- and :+.cartlemmy wrote:Also, is that ASM6? Because those + and - labels look really useful
So that's a 'yes, those + and - labels can be used in ASM6'? Sorry, I'm a n00b to this stufftepples wrote:The other way to do it, used by ca65, is : labels that can be accessed with :- and :+.cartlemmy wrote:Also, is that ASM6? Because those + and - labels look really useful
That's a yes. We recently had a discussion over the merits of these - and + labels.cartlemmy wrote:So that's a 'yes, those + and - labels can be used in ASM6'?
Ah, ok cool. I remember that thread, I just didn't realize what the + and - were at the time, so I didn't notice :/tepples wrote:That's a yes. We recently had a discussion over the merits of these - and + labels.cartlemmy wrote:So that's a 'yes, those + and - labels can be used in ASM6'?