It is currently Fri Nov 17, 2017 12:38 pm

All times are UTC - 7 hours



Forum rules


Related:



Post new topic Reply to topic  [ 50 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
 Post subject: getting started on SNES
PostPosted: Sun Sep 27, 2015 5:21 am 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1823
Location: DIGDUG
I'm having trouble finding good source material for the SNES to start learning from. I found 1 Hello World on github (in German). But, there's no nerdy nights equivalent for the SNES.

I was thinking about using a debugger and going step by step through an actual game, to see how it initializes things and sets everything up. Does anyone have any suggestions for a simple game I can start looking at, or should I just start with SMW since it's so well documented? Did anyone make a Pac-man or Galaga port to the SNES that I can look at (examples of simple games).

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Sun Sep 27, 2015 5:37 am 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1823
Location: DIGDUG
Oh, I see that Frogger, Space Invaders, and Ms. Pacman were. Space invaders might be the easier of them to figure out.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Sun Sep 27, 2015 6:09 am 
Offline
User avatar

Joined: Mon Sep 15, 2014 4:35 pm
Posts: 3100
Location: Nacogdoches, Texas
Superfamicom.org is your friend: http://wiki.superfamicom.org/snes/show/HomePage

You could try looking at bazz's tutorials just like I did, but I'm sure you already know most of that stuff, and they're using WLA... I started off fiddling with the Walker demo in "Neviksti's Starter Kit" under this: http://wiki.superfamicom.org/snes/show/ ... nvironment


Top
 Profile  
 
PostPosted: Sun Sep 27, 2015 6:54 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19220
Location: NE Indiana, USA (NTSC)
I've got a walker demo for Super NES in ca65 if you're interested.


Top
 Profile  
 
PostPosted: Sun Sep 27, 2015 7:11 am 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1823
Location: DIGDUG
Thanks guys.

I don't know if I'm going to make any SNES homebrews, but I've had a few people ask me if I can mod SNES games, and I'd really like to learn it, since SNES was the system I played through high school.

Dumb question... what's the difference between HiROM and LoROM?

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Sun Sep 27, 2015 7:15 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19220
Location: NE Indiana, USA (NTSC)
In LoROM (mode $20), CPU A15 isn't connected to the ROM. In HiROM (mode $21), it is. This means in LoROM, data occupies the upper half of each 64 KiB bank, while in HiROM, ROM data occupies the whole bank. LoROM is intended to be accessed through $808000-$80FFFF, $818000-$81FFFF, $828000-$82FFFF, etc., while HiROM just starts at $C00000 and goes up. The reason for LoROM's existence is related to the mirroring of the first 8 KiB of RAM and MMIO registers throughout banks $00-$3F and $80-$BF so that you don't always have to use (slower) long addressing modes to reach MMIO. However, the second half of each bank of HiROM is also mirrored down into $80-$BF, letting you do MMIO with 2-byte addresses from pseudo-LoROM routines stored there.

View more definitions


Top
 Profile  
 
PostPosted: Sun Sep 27, 2015 8:12 am 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1823
Location: DIGDUG
Just so I understand...

In either mode, LoROM or HiROM, can I access all banks?

Edit. Oh wait, there are 2 different types of cartridges... One mapped with LoROM and one mapped with HiROM. Do I have that right? And so, its not like switching from Native mode to Emulator mode, or something like that.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Sun Sep 27, 2015 9:06 am 
Offline

Joined: Mon Nov 10, 2008 3:09 pm
Posts: 431
dougeff wrote:
Just so I understand...

In either mode, LoROM or HiROM, can I access all banks?

Edit. Oh wait, there are 2 different types of cartridges... One mapped with LoROM and one mapped with HiROM. Do I have that right? And so, its not like switching from Native mode to Emulator mode, or something like that.


Yeah, it's two types of cartridges that are physically wired differently--a bit like horizontal/vertical CIRAM mirroring on the NES.

There are actually a lot more than two cartridge types, with subtle differences involving which address ranges are mirrored in cartridges with SRAM and/or with multiple physical ROM chips, but you really don't have to worry about them unless you're an emulator developer.


Top
 Profile  
 
PostPosted: Sun Oct 11, 2015 8:01 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1823
Location: DIGDUG
Ive read every document on SNES that I could find. I have a few questions...just so I know I have it right.

1. The SNES has a VRAM that is divided into 3 parts...Color palette, OAM (sprite attributes), and tilemap...each accessible though different registers...
2121/2122 for palette, 2102-4 OAM, 2116-9 tilemap. Do I have that right?
2. How do I write tile data then (CHR)?
3. Do you usually write to the VRAM with a DMA?
4. Do you have to write to VRAM during V-blank?
5. In mode 1, there are 3 BG layers? If an upper one is mostly color 0, does that work as a mostly transparent layer?

Edit...
6. I'm also slightly confused with joypad reads. There seems to be 2 ways to read the joypads (auto and manual) with a warning somewhere about getting incorrect reads if done at the wrong time. Is there a 'standard' way of doing this?

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Sun Oct 11, 2015 8:12 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19220
Location: NE Indiana, USA (NTSC)
dougeff wrote:
1. The SNES has a VRAM that is divided into 3 parts...Color palette, OAM (sprite attributes), and tilemap...each accessible though different registers...

Yes, much as with the NES, except the palette doesn't overlay the last 256 words of VRAM addresses anymore.

Quote:
2. How do I write tile data then (CHR)?

It should be familiar if you've ever used CHR RAM on the NES: write the address, then write the data. Tiles and tile map both go in the main 32 Kword (64 KiB) VRAM.

Quote:
3. Do you usually write to the VRAM with a DMA?

Yes. "Blast Processing" is one advantage the Genesis and Super NES have over the third-gen systems.

Quote:
4. Do you have to write to VRAM during V-blank?

Yes, just as on the NES. Unlike on the Genesis, there's no VRAM write FIFO. Or if you're willing to do a little letterboxing, you can also write during forced blank. This is a lot easier to pull off on the Super NES than on the NES.

Quote:
5. In mode 1, there are 3 BG layers? If an upper one is mostly color 0, does that work as a mostly transparent layer?

Correct.


Top
 Profile  
 
PostPosted: Sun Oct 11, 2015 8:26 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1823
Location: DIGDUG
Thanks. I was editing (adding another question) while you were typing. Any thoughts on button reads?

And...
7. Do sprites use the same tileset that BGs do in the same area of the VRAM?

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Sun Oct 11, 2015 8:39 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19220
Location: NE Indiana, USA (NTSC)
The base address for sprite tiles, each background's tiles, and each background's tile map can be set independently. A 16-color background can address 32K of tiles, but the sprite system can address only 16K at once. You might be able to get away with a layout like this in mode 1:

$0000-$3FFF (32K): 1024 tiles for BG1 and BG2
$4000-$5FFF (16K): 512 sprite tiles
$6000-$67FF (4K): BG1 map
$6800-$6FFF (4K): BG2 map
$7000-$77FF (4K): BG3 map
$6000-$7FFF ($7800-$7FFF used): 256 HUD tiles for BG3

These are word addresses, where $0000 refers to 16 bits, $0001 refers to the next 16 bits, etc.


Top
 Profile  
 
PostPosted: Sun Oct 11, 2015 9:19 pm 
Offline

Joined: Mon Nov 10, 2008 3:09 pm
Posts: 431
dougeff wrote:
Ive read every document on SNES that I could find. I have a few questions...just so I know I have it right.

1. The SNES has a VRAM that is divided into 3 parts...Color palette, OAM (sprite attributes), and tilemap...each accessible though different registers...
2121/2122 for palette, 2102-4 OAM, 2116-9 tilemap. Do I have that right?
2. How do I write tile data then (CHR)?
3. Do you usually write to the VRAM with a DMA?
4. Do you have to write to VRAM during V-blank?
5. In mode 1, there are 3 BG layers? If an upper one is mostly color 0, does that work as a mostly transparent layer?


1. Mostly correct, but CGRAM (the palette) and OAM aren't normally referred to as VRAM.

2. VRAM contains both the name tables (tilemaps) and the pattern tables (CHR data). Unlike the NES, which has the name tables and pattern tables at fixed addresses in the PPU address space, the SNES has registers to specify the addresses where the name table and the pattern table for each layer are located (including the pattern table for sprites).

3. Yes, uploading data to the PPU is almost always done via DMA. Even writing to the scroll registers may be done via DMA.

4. Yes. VRAM can only be accessed during VBlank or forced blank. Unlike the NES, accessing VRAM outside VBlank simply fails (writes go nowhere, reads return 0) with no side effects on the display. CGRAM can be accessed normally during either VBlank or HBlank; some games write to CGRAM during HBlank to produce a color gradient. You can "sort of" access OAM outside VBlank but what you can do with it is very limited; Uniracers is the only game that intentionally does so.

5. Typically the 2bpp layer (BG3) is used as the score/status display and is therefore mostly blank (transparent) tiles. Or it may be multiplexed as both a score/status display and a far BG, using a raster effect to change its scroll position and priority partway down the screen (see e.g. Super Castlevania) Note that doing raster effects on the SNES is much, much easier than on the NES. Both a beam-position IRQ (a real one, not fake like MMC3) and beam-triggered DMA (HDMA) are built into the base system, and there's no voodoo needed for midscreen scroll changes, you just write the new vertical and horizontal positions exactly the same way you would during VBlank.

Quote:
Edit...
6. I'm also slightly confused with joypad reads. There seems to be 2 ways to read the joypads (auto and manual) with a warning somewhere about getting incorrect reads if done at the wrong time. Is there a 'standard' way of doing this?


The standard way to read normal SNES controllers is using the auto read. In VBlank, after doing all the OAM/VRAM/CGRAM uploads you're going to do, wait for bit 0 of $4212 to go to 0 and then read $4218-$421B. Manual reading is only needed for special controllers: mouse, multitap, light guns, etc.


Top
 Profile  
 
PostPosted: Sun Oct 11, 2015 9:22 pm 
Offline

Joined: Mon Nov 10, 2008 3:09 pm
Posts: 431
tepples wrote:
The base address for sprite tiles, each background's tiles, and each background's tile map can be set independently. A 16-color background can address 32K of tiles, but the sprite system can address only 16K at once. You might be able to get away with a layout like this in mode 1:

$0000-$3FFF (32K): 1024 tiles for BG1 and BG2
$4000-$5FFF (16K): 512 sprite tiles
$6000-$67FF (4K): BG1 map
$6800-$6FFF (4K): BG2 map
$7000-$77FF (4K): BG3 map
$6000-$7FFF ($7800-$7FFF used): 256 HUD tiles for BG3

These are word addresses, where $0000 refers to 16 bits, $0001 refers to the next 16 bits, etc.


BGxxNBA have granularity of $1000 words, so I don't see the need to locate the BG3 tiles in such a weird way...


Top
 Profile  
 
PostPosted: Mon Oct 12, 2015 8:39 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19220
Location: NE Indiana, USA (NTSC)
AWJ wrote:
BGxxNBA have granularity of $1000 words, so I don't see the need to locate the BG3 tiles in such a weird way...

Also possible:
$7000-$77FF (4K): 256 HUD tiles for BG3
$7800-$7FFF (4K): BG3 map

Or
$7000-$7BFF (6K): 384 HUD tiles for BG3
$7C00-$7FFF (2K): BG3 map (not scrolling)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 50 posts ]  Go to page 1, 2, 3, 4  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: LuigiBlood and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group