Vector demo problems

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Vector demo problems
by on (#20958)
I started work on what I call the "vector demo." It's a program that draws a line in a 6 by 5 tile box (48 by 40 pixels) in CHR-RAM. The line can be moved around with the d-pad, and can only go down and right on a slope less than 1 (for now). The only problem is, I get a grey screen of nothingness! What is wrong with my code? I'm gong to guess the initialization, but it's worked fine in my other programs. Maybe it's the CHR-RAM writes during VBLANK - if NESASM compiled my zero-page instructions as $00xx the timing's probably off. So what's wrong? Download it here.

by on (#20959)
Could you post an assembled binary? Some of us don't have NESASM (and would rather not taint our systems with its presence).

by on (#20960)
Okay, file updated! See my above post.

by on (#20961)
I see two problems already:

1. NESASM is indeed assembling your zero-page instructions as $00xx.
2. Something went horribly wrong during assembly - after VWait4, the "sta $2000" only has the first 1 (or 2) bytes stored, making it execute "STA $0000" followed by a string of BRKs lasting until $C000 (at which point the ROM repeats).

by on (#20962)
Number 1 is okay, I can just run the program as PAL until I put in the ZPs necessary. 240 ZPs... woohoo what fun! But what's causing number 2, I wonder? Stupid assembler? I'd use CA65 - I just don't know how to set it up for NES programming. And I hear the file needed to do it doesn't work right or something.

by on (#20963)
CartCollector wrote:
Number 1 is okay, I can just run the program as PAL until I put in the ZPs necessary. 240 ZPs... woohoo what fun! But what's causing number 2, I wonder? Stupid assembler? I'd use CA65 - I just don't know how to set it up for NES programming. And I hear the file needed to do it doesn't work right or something.

You can use Tetramino's source code as an example of how to use CA65 and LD65 to produce an iNES binary for NROM-128 (mapper 0). But you'll need to leave off the CHR ROM if you're going to be configuring it as an undersize UNROM (mapper 2).

by on (#20964)
Use "<" modif. to make assembler compile code in zero page.

Code:
sta <$01
sta <$00   


All offsets less than 256 will be compiled as zero page offsets.

Code:
   .org $A0A0


Causing assembling error, your NameTable with zeroes overwrite most compiled earlier code. If you really need NameTable data (4K? huh?), then let it be without "org" directive or use .bank directive with banks different from 0. ;)

by on (#21651)
Okay, I got it working (sort of). I added all of the <s to all of the zero page locations (including the VBlank rendering), the nametable is set up right, and it compiles. But, the scrolling is off (even though I set it to #$00 every frame) and only two pixels of the line are rendered. It behaves the same way whether it's run on an emulator in NTSC or PAL mode. So now what's wrong? The updated file is available in the same place as the last one, or you can just click here.

by on (#21653)
CartCollector wrote:
(even though I set it to #$00 every frame)


Where? I never see you touch the scroll after your extremely large unrolled drawing loop.

Remember that "the scroll" is just the PPU Address. The same address set by $2006... the same one auto-incremented by writes to $2007.... that's the address that determines where the screen is scrolled to.

If you want to reset the scroll, you must do so AFTER all your drawing is complete. Once you touch $2006 or $2007, you've essentially "broken" the scroll you previously set.

by on (#21657)
Okay, I was resetting the scroll before the unrolled loop. So I moved it to the end of the loop, and the scroll is where I want it. Now all that's left is the line rendering and input. Updated file available here.

by on (#21830)
I've tried everything I can think of. Does anyone know why the line isn't being rendered?