getting started on SNES

Discussion of hardware and software development for Super NES and Super Famicom.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
93143
Posts: 1310
Joined: Fri Jul 04, 2014 9:31 pm

Re: getting started on SNES

Post by 93143 » Mon Oct 12, 2015 1:06 pm

You can, of course, overlap OBJ tables and BG tile data, and use literally the same tiles for both. But only for 4bpp BG layers; otherwise you get a format mismatch. And of course both sprite tables combined would only cover half of the valid BG data range.

User avatar
dougeff
Posts: 2817
Joined: Fri May 08, 2015 7:17 pm
Location: DIGDUG
Contact:

Re: getting started on SNES

Post by dougeff » Thu Oct 15, 2015 7:15 am

I need some help. I've been trying to write a "Hello World" SNES program, but so far it's been a total failure. I've modified it to just fill all BG tilemaps with tiles and display 2 sprites (and turn the background green)...

Except I'm getting nothing. Nothing but a blank green screen.

Here's the source files and snes file...I just want it to show ANYTHING at all on the screen. Can anyone explain to me what I'm doing wrong? I want to understand this, but the documents for SNES are hard to understand...especially VRAM writes / registers.

http://dl.dropboxusercontent.com/s/bsl0 ... /Hello.zip

EDIT: DON'T USE THIS CODE. BROKEN. LEFT HERE FOR REFERENCE.

Compiles with ca65.
Last edited by dougeff on Thu Mar 02, 2017 10:01 pm, edited 1 time in total.
nesdoug.com -- blog/tutorial on programming for the NES

User avatar
dougeff
Posts: 2817
Joined: Fri May 08, 2015 7:17 pm
Location: DIGDUG
Contact:

Re: getting started on SNES

Post by dougeff » Thu Oct 15, 2015 12:59 pm

Solved...

Apparently I needed to add this at the end...

Code: Select all

lda #$1f
sta $212C ;enable main screen!!!
It only took me about 3 hours to figure out that :P
nesdoug.com -- blog/tutorial on programming for the NES

User avatar
dougeff
Posts: 2817
Joined: Fri May 08, 2015 7:17 pm
Location: DIGDUG
Contact:

Re: getting started on SNES

Post by dougeff » Thu Oct 15, 2015 1:07 pm

There's my lovely little sprites. Yay!
Attachments
sprites1.gif
sprites1.gif (6.71 KiB) Viewed 4185 times
nesdoug.com -- blog/tutorial on programming for the NES

User avatar
dougeff
Posts: 2817
Joined: Fri May 08, 2015 7:17 pm
Location: DIGDUG
Contact:

Re: getting started on SNES

Post by dougeff » Thu Oct 15, 2015 2:10 pm

I'd say I have success. The above link has been updated, if anyone wants to see source code for a working "Hello World" for the SNES.
Attachments
sprites2.gif
sprites2.gif (25.86 KiB) Viewed 4176 times
nesdoug.com -- blog/tutorial on programming for the NES

User avatar
dougeff
Posts: 2817
Joined: Fri May 08, 2015 7:17 pm
Location: DIGDUG
Contact:

Re: getting started on SNES

Post by dougeff » Tue Feb 28, 2017 10:23 am

I got a Super Everdrive yesterday, tried this file, and none of the sprites appear on screen. (Sprites are letters, BG is numbers). Any ideas?

BTW, my loop is this...

Forever:
Jmp Forever

And my NMI/IRQ is...
Rti

Am I supposed to do something each frame to get sprites to work? I know you have to continually send sprite data on NES. (Or else they all jump to the corner of the screen)
nesdoug.com -- blog/tutorial on programming for the NES

adam_smasher
Posts: 272
Joined: Sun Mar 27, 2011 10:49 am
Location: Victoria, BC

Re: getting started on SNES

Post by adam_smasher » Tue Feb 28, 2017 11:23 am

You should use bsnes(-plus) for testing, rather than Snes9X. It's more accurate, so if it works on there it'll be more likely to work on hardware.

Three guesses (in order from most to least likely):

You're writing data to VRAM during not-vblank

OR

You're relying on uninitialized RAM somehow

OR

Your header data is invalid somehow, causing the Super Everdrive to map it improperly

User avatar
dougeff
Posts: 2817
Joined: Fri May 08, 2015 7:17 pm
Location: DIGDUG
Contact:

Re: getting started on SNES

Post by dougeff » Tue Feb 28, 2017 1:45 pm

I did test with higan/bsnes accuracy. It looks fine.

On hardware, Bg is fine. No sprites.

Tried pushing sprites every frame. No difference.
nesdoug.com -- blog/tutorial on programming for the NES

93143
Posts: 1310
Joined: Fri Jul 04, 2014 9:31 pm

Re: getting started on SNES

Post by 93143 » Tue Feb 28, 2017 4:40 pm

OAM persists on SNES. You don't need to resend it.

Also, if you're actually using an interrupt, you need to clear the IRQ flag by reading $4211, or it will keep firing ad infinitum. According to fullsnes you don't actually have to read $4210 in an NMI, but it's good practice anyway (and I'm not sure I'm impressed by his excuse).

Do games work properly on your SNES?

tepples
Posts: 22280
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: getting started on SNES

Post by tepples » Tue Feb 28, 2017 6:35 pm

93143 wrote:According to fullsnes you don't actually have to read $4210 in an NMI, but it's good practice anyway (and I'm not sure I'm impressed by his excuse).
I'd say that reading $4210 on Super NES is approximately as required as reading $2002 on NES, but at least $2002 clears the PPU's first/second write latch.

93143
Posts: 1310
Joined: Fri Jul 04, 2014 9:31 pm

Re: getting started on SNES

Post by 93143 » Wed Mar 01, 2017 1:20 am

93143 wrote:and I'm not sure I'm impressed by his excuse
...that sounded really rude, didn't it?

His explanation was that the NMI flag is cleared at the end of VBlank, so unless you're disabling and re-enabling NMI, you shouldn't have to clear it yourself. I'm pretty sure nocash knows more about the SNES than I do, but it's not obvious to me what happens if your NMI routine ends before the flag is cleared.

User avatar
dougeff
Posts: 2817
Joined: Fri May 08, 2015 7:17 pm
Location: DIGDUG
Contact:

Re: getting started on SNES

Post by dougeff » Wed Mar 01, 2017 1:25 am

Do games work properly on your SNES?
Yes.
No problems with games, nor with the Everdrive.

It's a code problem. I just don't know enough SNES programming to understand, or fix.
nesdoug.com -- blog/tutorial on programming for the NES

adam_smasher
Posts: 272
Joined: Sun Mar 27, 2011 10:49 am
Location: Victoria, BC

Re: getting started on SNES

Post by adam_smasher » Wed Mar 01, 2017 8:30 am

Mind posting your code so that we can take a look?

zkip
Posts: 67
Joined: Tue Nov 20, 2012 1:59 pm

Re: getting started on SNES

Post by zkip » Wed Mar 01, 2017 1:28 pm

Are you writing correctly to the second OAM table? It's been a while since my SNES days, but I do seem to recall having a similar problem and it was caused by (IIRC) not correctly writing to the second OAM table that contains the X coordinates MSB and the sprite size.

Also, the way OAM works on the SNES seems weird to me. IIRC, you have the set the sprite number multiplied by either 2 or 4 when you write the OAM address low.

User avatar
dougeff
Posts: 2817
Joined: Fri May 08, 2015 7:17 pm
Location: DIGDUG
Contact:

Re: getting started on SNES

Post by dougeff » Wed Mar 01, 2017 1:51 pm

Mind posting your code so that we can take a look?
It's the Dropbox link above...the only thing I've changed from that is the Vectors.
Writing to the second OAM table
I don't think so.
CORRECTION - I think I'm filling it with zeros.
nesdoug.com -- blog/tutorial on programming for the NES

Post Reply