How to simply write tile datas into PPU?

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

Post Reply
User avatar
MartsINY
Posts: 66
Joined: Sun Jun 11, 2017 5:39 pm

How to simply write tile datas into PPU?

Post by MartsINY »

Is there any easy tutorial to learn how to write tiles on the PPU?

I know this one : https://wiki.nesdev.com/w/index.php/PPU_registers

It's kinda hard but I can do with it if I don't have the choice.

However, I wondered if there were more easy tutorial that would guide a step-by-step? Something like a tutorial which indicates step by step how to just change 1 tile on the PPU?

What I'm trying to say is that I would be looking for something more basic.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: How to simply write tile datas into PPU?

Post by tepples »

To overwrite all tiles, use the CHR ROM to CHR RAM conversion example in this article.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: How to simply write tile datas into PPU?

Post by tokumaru »

When you say "change one tile", do you mean modifying the graphics of one of the 512 tiles available for drawing sprites and backgrounds, causing all instances of that tile to reflect the change, or do you mean changing which tile one single sprite or background position is using so that only that spot changes?
User avatar
MartsINY
Posts: 66
Joined: Sun Jun 11, 2017 5:39 pm

Re: How to simply write tile datas into PPU?

Post by MartsINY »

tokumaru wrote:When you say "change one tile", do you mean modifying the graphics of one of the 512 tiles available for drawing sprites and backgrounds, causing all instances of that tile to reflect the change, or do you mean changing which tile one single sprite or background position is using so that only that spot changes?

The first one, the tile to be changed in the ppu so every instance of that tile in the screen is changed.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: How to simply write tile datas into PPU?

Post by tokumaru »

Then the article tepples linked to is a good place to start. It's a simple routine that fills the pattern tables with tile data copied from PRG-ROM. This will only work in a CHR-RAM cartridge.
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: How to simply write tile datas into PPU?

Post by rainwarrior »

If you're using CHR-RAM you're going to need to be able to write a full set of tiles into that RAM anyway, not just one tile. (Unless your whole game has only one tile?) RAM does not start up with any contents already in it. So... tepples' article is a thing you will need to learn first, before you can get to modifying a single tile.

If you're using CHR-ROM you can't change just one tile. That can only be banked in pages (or sometimes not at all), depending on the mapper used. The more advanced mappers can page them in 1k (64 tile) sets.
kuja killer
Posts: 130
Joined: Mon May 25, 2009 2:20 pm

Re: How to simply write tile datas into PPU?

Post by kuja killer »

It's megaman 4, which is CHR-RAM
User avatar
MartsINY
Posts: 66
Joined: Sun Jun 11, 2017 5:39 pm

Re: How to simply write tile datas into PPU?

Post by MartsINY »

rainwarrior wrote:If you're using CHR-RAM you're going to need to be able to write a full set of tiles into that RAM anyway, not just one tile. (Unless your whole game has only one tile?) RAM does not start up with any contents already in it. So... tepples' article is a thing you will need to learn first, before you can get to modifying a single tile.

If you're using CHR-ROM you can't change just one tile. That can only be banked in pages (or sometimes not at all), depending on the mapper used. The more advanced mappers can page them in 1k (64 tile) sets.
thanks I'll check it!! And kujakiller is correct, it's mega man 4 and CHR-RAM
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: How to simply write tile datas into PPU?

Post by tokumaru »

Hacking an existing game is more complex, because you can't easily tell if you have enough time to do the extra stuff you want. The game may very well have been "tuned" to use all of the vblank time (which is the only time you're allowed to write to VRAM if rendering is on) under certain conditions, and if you try to put the extra 140 to 200 cycles that updating 16 bytes takes, you might extrapolate the allowed time for updates an end up with corrupted graphics/scroll, even though the copy procedure by itself is correct.

To hack a game you need more than just the knowledge of how to perform a certain task, you need to know how that task and the time it takes will affect the existing game engine, in order to avoid any conflicts and timing issues.
User avatar
MartsINY
Posts: 66
Joined: Sun Jun 11, 2017 5:39 pm

Re: How to simply write tile datas into PPU?

Post by MartsINY »

tokumaru wrote:Hacking an existing game is more complex, because you can't easily tell if you have enough time to do the extra stuff you want. The game may very well have been "tuned" to use all of the vblank time (which is the only time you're allowed to write to VRAM if rendering is on) under certain conditions, and if you try to put the extra 140 to 200 cycles that updating 16 bytes takes, you might extrapolate the allowed time for updates an end up with corrupted graphics/scroll, even though the copy procedure by itself is correct.

To hack a game you need more than just the knowledge of how to perform a certain task, you need to know how that task and the time it takes will affect the existing game engine, in order to avoid any conflicts and timing issues.

Thanks I read about VBlank. I'm pretty sure I know some function which will check that and I will be able to use this

I'm glad you mentionned it I forgot about this.
Post Reply