All avaliable (/unavaliable) options for creating tilemaps?

Discussion of hardware and software development for Super NES and Super Famicom. See the SNESdev wiki for more information.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: All avaliable (/unavaliable) options for creating tilema

Post by tepples »

Use ASCII, render the map to a buffer in main memory, and then DMA the map to VRAM.

While rendering the map to a buffer in main memory, you can interpret control characters such as newline and form feed. Thwaite, RHDE, the Action 53 menu, Haunted: Halloween '85, and The Curse of Possum Hollow all respond to the newline character (0x0A); some also do something special with form feed (0x0C).
93143
Posts: 1718
Joined: Fri Jul 04, 2014 9:31 pm

Re: All avaliable (/unavaliable) options for creating tilema

Post by 93143 »

Espozo wrote:I thought I heard there was a way to skip every other byte when using DMA to upload data to VRAM. Is this true, and what do you have to do if so?
The top bit of VMAIN ($2115) tells the PPU whether to increment the word address on a write to VMDATAL or VMDATAH.

Normally you set it to 1 (increment on VMDATAH/$2119) and DMA in a word pattern to $2118-$2119. But if you set it to 0 and DMA single bytes to $2118, you can write to just the low byte of a region in VRAM, and if you set it to 1 and DMA single bytes to $2119, you can write to just the high byte.

This is useful for Mode 7, since the low byte is map data and the high byte is pixel data. You can load either map data or tiles separately, without having to interleave them in software and perhaps waste time overwriting something that doesn't need changing.

I've also used this to display the OAM on screen, by setting up character tiles from 00 to FF and simply dumping the contents of OAM (loaded into WRAM from $2138) directly into VRAM via $2118.
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: All avaliable (/unavaliable) options for creating tilema

Post by dougeff »

The top bit of VMAIN ($2115) tells the PPU whether to increment the word address on a write to VMDATAL or VMDATAH.

Normally you set it to 1 (increment on VMDATAH/$2119) and DMA in a word pattern to $2118-$2119. But if you set it to 0 and DMA single bytes to $2118, you can write to just the low byte of a region in VRAM, and if you set it to 1 and DMA single bytes to $2119, you can write to just the high byte.

This is useful for Mode 7, since the low byte is map data and the high byte is pixel data. You can load either map data or tiles separately, without having to interleave them in software and perhaps waste time overwriting something that doesn't need changing.

I've also used this to display the OAM on screen, by setting up character tiles from 00 to FF and simply dumping the contents of OAM (loaded into WRAM from $2138) directly into VRAM via $2118.
Interesting. Is the source of the DMA an array of single bytes, or word sized.

That is to say. If I unpack compressed tiles, of just the low bytes, will I have to unpack it to a buffer of every other byte being filled?
nesdoug.com -- blog/tutorial on programming for the NES
93143
Posts: 1718
Joined: Fri Jul 04, 2014 9:31 pm

Re: All avaliable (/unavaliable) options for creating tilema

Post by 93143 »

As far as the DMA unit is concerned, data is 8-bit. MDMA source options are pretty barebones: a stream of consecutive bytes, a stream of consecutive bytes in reverse order, or the same byte over and over. You can't skip bytes. It's the combination of DMAPx and VMAIN settings - how the DMA unit writes to the B bus and how the PPU distributes the received data, respectively - that allows you to send the whole byte stream to just one of the 32 KB VRAM chips instead of alternating between them.

In short, no. You don't have to leave spaces in your WRAM buffer.

...your post kinda sounds like you're talking about using NES format for sprites, or something like that. What exactly is the use case here?
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: All avaliable (/unavaliable) options for creating tilema

Post by dougeff »

I found this today...

(source, MIT)

https://github.com/Optiroc/SuperFamiconv

(binary)

http://www.romhacking.net/utilities/1293/

It appears to convert a PNG image to a 'palette', 'tiles', or 'map' for SNES.

I have absolutely no idea how it works, but it may be useful.
nesdoug.com -- blog/tutorial on programming for the NES
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: All avaliable (/unavaliable) options for creating tilema

Post by calima »

Yes, that was posted a page ago :P
User avatar
Drew Sebastino
Formerly Espozo
Posts: 3496
Joined: Mon Sep 15, 2014 4:35 pm
Location: Richmond, Virginia

Re: All avaliable (/unavaliable) options for creating tilema

Post by Drew Sebastino »

Well, this isn't very related to this, but how do you put BG3 in front of BG1 and BG2 in mode 1? It looks like setting bit $08 (so writing $09) on $2105 should do it, but I've had no success. I'm only referencing $2105 once outside of the initialization routine, so overwriting the register isn't the problem. Is there any other register that influences this?
93143
Posts: 1718
Joined: Fri Jul 04, 2014 9:31 pm

Re: All avaliable (/unavaliable) options for creating tilema

Post by 93143 »

You have to set the tile priority bit.
User avatar
Drew Sebastino
Formerly Espozo
Posts: 3496
Joined: Mon Sep 15, 2014 4:35 pm
Location: Richmond, Virginia

Re: All avaliable (/unavaliable) options for creating tilema

Post by Drew Sebastino »

For each entry on BG3's tilemap? :( (I have to manually go through it again if so.)
93143
Posts: 1718
Joined: Fri Jul 04, 2014 9:31 pm

Re: All avaliable (/unavaliable) options for creating tilema

Post by 93143 »

I'm afraid so. Priority 0 just ends up behind everything regardless.
creaothceann
Posts: 611
Joined: Mon Jan 23, 2006 7:47 am
Location: Germany
Contact:

Re: All avaliable (/unavaliable) options for creating tilema

Post by creaothceann »

It can also still end up behind other layers if you put it on the subscreen.
My current setup:
Super Famicom ("2/1/3" SNS-CPU-GPM-02) → SCART → OSSC → StarTech USB3HDCAP → AmaRecTV 3.10
User avatar
HihiDanni
Posts: 186
Joined: Tue Apr 05, 2016 5:25 pm

Re: All avaliable (/unavaliable) options for creating tilema

Post by HihiDanni »

The priority bit thing is likely so that you can have both a far BG and a HUD providing that the two never overlap the same vertical space.
SNES NTSC 2/1/3 1CHIP | serial number UN318588627
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: All avaliable (/unavaliable) options for creating tilema

Post by dougeff »

It can also still end up behind other layers if you put it on the subscreen.
Ok, this is completely different from my understanding of main screen / sub screen.

Can someone else confirm this info? I thought main/sub was independent of priority layers.
nesdoug.com -- blog/tutorial on programming for the NES
niconii
Posts: 219
Joined: Sun Mar 27, 2016 7:56 pm

Re: All avaliable (/unavaliable) options for creating tilema

Post by niconii »

dougeff wrote:Can someone else confirm this info? I thought main/sub was independent of priority layers.
It is, but you can add the subscreen to just the backdrop layer of the main screen, and that gives the appearance of the subscreen being behind the layers on the main screen.
User avatar
Drew Sebastino
Formerly Espozo
Posts: 3496
Joined: Mon Sep 15, 2014 4:35 pm
Location: Richmond, Virginia

Re: All avaliable (/unavaliable) options for creating tilema

Post by Drew Sebastino »

What (I think) Nicole is talking about is most notably (only example I can think of) done in Donkey Kong Country 3, where they actually get BG3 to render between BG1 and BG2 in the canyon and factory level archetypes.

Anyway, the reason I wanted to know all of this information is that I made a rudimentary slideshow for my high school history class where we are supposed to give a summary of a person's life and determine whether or not they are a "hero or a zero". It's a bullshit end of the year project, and as such, my teacher was emphasizing creativity, with one example he showed us being a scrapbook someone made last year. I said screw that and decided to make this, which ended up being exponentially more work than I would have thought, and I never even ended up making the ability to display pictures in the slides, but there's so few words you can write in a 32x32 grid that pictures is all it would be anyway. The code is also really sloppy because I had to get this done in time.

I just realized that this is my first fully completed code of anything... Man, that's sad... :lol:
Slideshow.zip
(1.07 MiB) Downloaded 108 times
Oh yeah, what does the "Address Remapping" in $2115 (described here: https://wiki.superfamicom.org/snes/show/Registers) actually do? Their description really confused me. I'm asking because I had to use it sometimes and othertimes I didn't to get everything to display properly.
Last edited by Drew Sebastino on Thu May 18, 2017 8:13 pm, edited 1 time in total.
Post Reply