tepples wrote:
Ideally, your main program, be it in C or assembly language or whatever, fills a buffer of addresses and data values in otherwise unused memory, such as $0100-$01BF in the stack page. Then during vblank, your program calls a subroutine written in assembly language that reads the buffer, copying addresses and data from the buffer to the PPU's ports. There's one such subroutine in neslib; I wrote my own called
Popslide that uses pointer arithmetic and (ab)use of the stack pointer to allow a fast unrolled loop that C on a 6502 can't practically match.
Yeah, I think I use this technique! I'm going to take a look at Popslide.
dougeff wrote:
Looking at the distribution of incorrect tiles on that NTSC picture, I would guess that there is a lot more to your update code than just
LDA byte
STA 2006
LDA byte
STA 2006
LDA byte
STA 2007
I would have to guess that it is inside a loop that is calculating each PPU address in real time.
loops can be MUCH more efficient in ASM [edit, autocorrect]
Addresses should be calculated beforehand (buffered), or selected from a table of precalculated addresses.
EDIT, also, in my latest blog posts, I DO use neslib, and I prefer that sort of approach. I have abandoned my earlier code, and plan to rewrite all the example code some day.
Of course, this is just an example of how I draw ONE tile ^^
Indeed I will use the buffer technique using the unused part in the stack!
-------------------
Thank you all for your responses !
Edit: It's good ! I used stack's buffer technique, push data in stack during rendering, and pop stack data to vram during vblank. It works very well, I no longer exceed 20 scanlines!