Calculating the size of 16x16 tile data.

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.
Post Reply
DashEightMate
Posts: 3
Joined: Wed Aug 05, 2020 3:36 pm

Calculating the size of 16x16 tile data.

Post by DashEightMate » Wed Aug 05, 2020 7:22 pm

I'm brand new to SNES programming. I"ve been following bazz's tutorials on the SuperFamicom wiki, and I've displayed 8x8 tiles using the tutorial. But, I'd also want to display 16x16 tiles in a background. I've modified bazz's equation for finding out tile data size using what I've figured out about how the tile data is stored. But, calculating it for a 4-bit color depth and a 64x64 map gives $8000 bytes - huge! especially considering this is only for a simple test with only 4 distinct tiles. Am I just discovering a big limitation with the snes, or am I calculating this wrong? Thanks.

lidnariq
Posts: 9659
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: Calculating the size of 16x16 tile data.

Post by lidnariq » Wed Aug 05, 2020 8:22 pm

It's intended that each tile is used more than once. You're not supposed to think of it as an awkward bitmap. For example, Super Mario Bros. relies on reusing each tile many times, as pipes or clouds or bushes.

SNES tilemaps only support addressing 1024 unique 8x8px tiles simultaneously (Except mode 7; that only supports addressing 256). Switching to 16x16px tiles doesn't allow you to address more tiles; it only allows spending less memory on the tilemaps.

DashEightMate
Posts: 3
Joined: Wed Aug 05, 2020 3:36 pm

Re: Calculating the size of 16x16 tile data.

Post by DashEightMate » Wed Aug 05, 2020 11:57 pm

Ok, that makes much more sense with what I was reading. For some reason, the tutorial I followed made the size of the tile map dependent on the size of the characters. Thanks for the help.

Oziphantom
Posts: 913
Joined: Tue Feb 07, 2017 2:03 am

Re: Calculating the size of 16x16 tile data.

Post by Oziphantom » Thu Aug 06, 2020 1:06 am

Well it is dependent on the size of the tiles.

for example if you have 8x8 tiles and you want a map that is 4 screens by 4 screens

so (32*4)*(28*4)*2 = 28,672 bytes to hold the tile map

or if each tile is 16x16 then you need

(16*4)*(14*4)*2 = 7,168 bytes to hold the tile map

as you can probably imagine this is 1/4 the size because each tile now covers 4 times the size.

lidnariq
Posts: 9659
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: Calculating the size of 16x16 tile data.

Post by lidnariq » Thu Aug 06, 2020 1:55 am

Oziphantom wrote:
Thu Aug 06, 2020 1:06 am
for example if you have 8x8 tiles and you want a map that is 4 screens by 4 screens
SNES doesn't let you hold a tilemap that is 4 screens wide or tall unless it's made of 16x16 tiles... it only lets you specify whether the tilemap itself has 32 or 64 rows and columns, and then you can tell it whether to interpret the tilemap contents as meaning 8x8¹ tiles or 16x16 tiles.

¹ in the 512px modes 5 and 6, tiles are always 16px wide and the same toggle only sets tile height.
so (32*4)*(28*4)*2 = 28,672 bytes to hold the tile map
Also, tilemaps are always a multiple of 32 rows tall.

Do any systems use 28-row tilemaps? Not just visible window, but explicitly the tilemap itself. Not the NES - that's 30-row. Not the SMS2 - that's the visible window, the tilemap is still 32 rows.

Oziphantom
Posts: 913
Joined: Tue Feb 07, 2017 2:03 am

Re: Calculating the size of 16x16 tile data.

Post by Oziphantom » Thu Aug 06, 2020 2:25 am

In VRAM then yes, however in WRAM or ROM you can store the tile map however you want and that has a cost which changes depending upon the size of tiles as well.
VRAM has a mostly fixed cost, in you tend to store a map 32 or 64 wide/high depending upon your scrolling needs and size needs which boils down to a simple table

32x32 = 2K
32x64 = 4K
64x32 = 4K
64x64 = 8K

pick one.

if you are using 8x8 and doing 4 way scrolling then you will probably want to use the 64x64 for convenience if you can afford it. However the VRAM cost doesn't change if you have 8x8 or 16x16 tiles but your storage costs do, as that is the size of the tile map. If you choose a 32x32 VRAM size if you are using 8x8 tiles it's 2K if you are using 16x16 tiles it's 2K.
If you want a map to cover 4x4 screens at 8x8 tiles that is 28K, if you using 16x16 its 7K

The SNES (NTSC) is 256x224 right? so if you were designing something to be 4 screens tall, say a Legend of Zelda like "room based" map, you would only design the rooms 224 pixels high, if the internal VRAM is 256 high and the last few rows go unused oh well.

DashEightMate
Posts: 3
Joined: Wed Aug 05, 2020 3:36 pm

Re: Calculating the size of 16x16 tile data.

Post by DashEightMate » Thu Aug 06, 2020 6:24 pm

Thank you all for the help. I ran into an issue initially where the bottom half of my tiles wasn't displaying, but apparently the tiles are $200 bytes per row. Increasing the size of the char data to over $0200 bytes fixed this. Again, thank you - I've never done any programming so rewarding as this!

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

Re: Calculating the size of 16x16 tile data.

Post by tepples » Fri Aug 07, 2020 4:29 pm

lidnariq wrote:
Thu Aug 06, 2020 1:55 am
Do any systems use 28-row tilemaps? Not just visible window, but explicitly the tilemap itself. Not the NES - that's 30-row. Not the SMS2 - that's the visible window, the tilemap is still 32 rows.
SMS in 192-line mode uses 256x224-pixel tilemaps, as does the Game Gear. It's common to stash the sprite table in the unused 256 bytes after a 1792-byte tilemap on that platform.

Post Reply