Vector demo problems

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Post Reply
CartCollector
Posts: 122
Joined: Mon Oct 30, 2006 8:32 pm

Vector demo problems

Post by CartCollector »

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.
User avatar
Quietust
Posts: 1786
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Post by Quietust »

Could you post an assembled binary? Some of us don't have NESASM (and would rather not taint our systems with its presence).
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.
CartCollector
Posts: 122
Joined: Mon Oct 30, 2006 8:32 pm

Post by CartCollector »

Okay, file updated! See my above post.
User avatar
Quietust
Posts: 1786
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Post by Quietust »

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).
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.
CartCollector
Posts: 122
Joined: Mon Oct 30, 2006 8:32 pm

Post by CartCollector »

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.
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

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).
CaH4e3
Posts: 72
Joined: Thu Oct 13, 2005 10:39 am

Post by CaH4e3 »

Use "<" modif. to make assembler compile code in zero page.

Code: Select all

sta <$01
sta <$00	
All offsets less than 256 will be compiled as zero page offsets.

Code: Select all

	.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. ;)
CartCollector
Posts: 122
Joined: Mon Oct 30, 2006 8:32 pm

Post by CartCollector »

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.
User avatar
Disch
Posts: 1848
Joined: Wed Nov 10, 2004 6:47 pm

Post by Disch »

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.
CartCollector
Posts: 122
Joined: Mon Oct 30, 2006 8:32 pm

Post by CartCollector »

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.
CartCollector
Posts: 122
Joined: Mon Oct 30, 2006 8:32 pm

Post by CartCollector »

I've tried everything I can think of. Does anyone know why the line isn't being rendered?
Post Reply