how to make a tilemap's background

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.
Post Reply
fritzzz
Posts: 32
Joined: Sat Apr 08, 2023 11:41 am

how to make a tilemap's background

Post by fritzzz »

Hi,

I don't understand how to make a tilmap :?:


For example I have 2 tiles named T0 and T1, of 16x16 pixels , stored at $8000 in vram (snes in mode 1)


What is the code for renseign the tilemap, by example if I would like to have the background0 with:
-the tile T0, positioned in X16 Y32, palette 4
-the tile T1, positioned in X48 Y64, palette 7, vertical flip


THANKS
Last edited by fritzzz on Wed Jun 07, 2023 6:08 am, edited 2 times in total.
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: how to make a tileset's background

Post by dougeff »

Are you trying to put tiles on a tile map (display on a background layer)?

And you want to calculate the position of a specific X/Y coordinate?

Y64... makes me think you mean 64 pixels from the top.

If tiles are set to 16x16 mode, then divide each number by 16. Your first example gives X=1, Y=2.

The map has rows 32 tiles wide, so the next row down is +32. So multiply the Y by 32, then add the X

32x2 + 1 = 33 (in hex that's $21)

So, add $21 to the map base address to get the address of that tile. Then write the tile there.

The data is 16 bits. The bits are
15 V flip
14 H flip
13 Priority
10-12 Palette
0-9 Tile Number

Your first example, Tile=0, Palette=4
000 100 00000000 or $1000

So, if the map for BG1 starts at VRAM $2000, you would set a VRAM address for $2021, then write the value $1000 here to make the tile appear.
nesdoug.com -- blog/tutorial on programming for the NES
fritzzz
Posts: 32
Joined: Sat Apr 08, 2023 11:41 am

Re: how to make a tileset's background

Post by fritzzz »

Yes it's that, I want make a tilemap (not a tileset , I go change the title)

Thank you, now I understand better
Last edited by fritzzz on Wed Jun 07, 2023 6:07 am, edited 1 time in total.
fritzzz
Posts: 32
Joined: Sat Apr 08, 2023 11:41 am

Re: how to make a tileset's background

Post by fritzzz »

A question for mode 3,

In mode 3, we can have 16 palettes of 16 colors for Background 0 ? If it's right, how to choose from 0 to 15, because here there is just 3bit to choose the palette
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: how to make a tilemap's background

Post by calima »

No, 8 palettes. Fullsnes.htm has all the details.
93143
Posts: 1717
Joined: Fri Jul 04, 2014 9:31 pm

Re: how to make a tilemap's background

Post by 93143 »

In Mode 3, BG1 has unfettered access to all of CGRAM. The pixel data is 8-bit, and the palette selector bits are not used unless you're in direct-colour mode, which doesn't use CGRAM at all.

BG2 (again, speaking of Mode 3) has access to the 8 4-bit palettes in the bottom half of CGRAM, and you select which one with those three bits. The top half of CGRAM is for sprites (and 8bpp layers).
fritzzz
Posts: 32
Joined: Sat Apr 08, 2023 11:41 am

Re: how to make a tilemap's background

Post by fritzzz »

Thanks

So I'm going to stay in mode 1, I'll see that another time the color system of mode 3
Post Reply