News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: Can I change the palette for each 8x8 tile in SMB?  (Read 2451 times)

skrubbed

  • Newbie
  • *
  • Posts: 2
    • View Profile
Can I change the palette for each 8x8 tile in SMB?
« on: August 12, 2020, 08:09:23 pm »
Hey, so I am working on this hack, and it basically replaces the SMB visuals with the SMB3 visuals, and if you didn't know, the shell in SMB3 uses a different palette than the rest of the turtle. So, I was wondering if it was possible to change the palette for each and every 8x8 tile that makes up an enemy, and if so, how? Thanks! :P
(Each line separates every 8x8 chunk btw. It's a bit cropped so it doesn't look exactly square.)

Supergamerguy

  • Full Member
  • ***
  • Posts: 140
  • Retro game fanatic; loves platformers, hates jrpgs
    • View Profile
Re: Can I change the palette for each 8x8 tile in SMB?
« Reply #1 on: August 13, 2020, 07:36:37 am »
Edit: Doh! Didnt see that it said palette, but I will warn you that editing palletes can be difficult.
« Last Edit: August 13, 2020, 08:48:43 am by Supergamerguy »
Dah-nuh-nuh-nah! Super fighting robot! Dah-nuh-nah-nah! MEGA MAN! Fighting.......to save.......the world!!!!!

Cyneprepou4uk

  • Sr. Member
  • ****
  • Posts: 475
  • I am the baldest romhacker
    • View Profile
Re: Can I change the palette for each 8x8 tile in SMB?
« Reply #2 on: August 13, 2020, 07:50:09 am »
NES sets 1 of 4 palette to each tile that is used as a sprite. So yes, it's possible. In theory your tutrle can use up to 12 unique colors in total.

https://wiki.nesdev.com/w/index.php/PPU_OAM
https://wiki.nesdev.com/w/index.php/PPU_palettes
« Last Edit: August 13, 2020, 10:26:17 am by Cyneprepou4uk »
iromhacker.ru - NES ROM hacking tutorials for beginners. Please use Google Translate browser extension

skrubbed

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Can I change the palette for each 8x8 tile in SMB?
« Reply #3 on: August 13, 2020, 02:00:31 pm »
NES sets 1 of 4 palette to each tile that is used as a sprite. So yes, it's possible. In theory your tutrle can use up to 12 unique colors in total.
Any tools that can help me out with that? Or do I have to use a hex editor? If I have to use a hex editor, are there any tutorials I could follow to help me?

Chicken Knife

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
Re: Can I change the palette for each 8x8 tile in SMB?
« Reply #4 on: August 14, 2020, 08:02:50 am »
I've had success changing sprite palettes by using the code logger function on FCEUX to narrow down the potential places in the rom where the arrangement of the sprites get referenced. One by one, I would alter the data in each of those sections until I found the one that altered the sprite I was looking for. (You're looking for big chunks of bytes that turn blue which means they are read) Be aware that it took a lot of playing around with the numbers for me to figure out the pattern of exactly how the tile addresses and palette selections were stored. Each game I've worked on handled the scheme a little bit differently. I'm most cases, there would be something like 3 bytes that handled the palette selection and the address in memory being referenced for each quadrant of the sprite. I was dealing with four tile sprites so the arrangement would something like A885D3 901920 A89890 14A520. The The first 3 bytes would handle the upper left tile, the 2nd set would handle the upper right, the third would handle the lower left, and the fourth the lower right. Within each of those sets, one of the nybbles (half of the byte) would alter the palette. You are dealing with a 6 tile sprite arrangement, so you would probably have 6 more additional bytes with each sprite arrangement.
« Last Edit: August 14, 2020, 08:11:20 am by Chicken Knife »
The final challenge of a game is the game itself.

Cyneprepou4uk

  • Sr. Member
  • ****
  • Posts: 475
  • I am the baldest romhacker
    • View Profile
Re: Can I change the palette for each 8x8 tile in SMB?
« Reply #5 on: August 14, 2020, 08:54:07 am »
Any tools that can help me out with that? Or do I have to use a hex editor? If I have to use a hex editor, are there any tutorials I could follow to help me?

Don't know any particular tutorials.

If you're using fceux emulator, find in ram where sprite data is and set a write breakpoint to one of turtle's palette number address. Which can be tricky because this address is most likely dynamic, but usually it is the same each 2 frames if you stand still and don't move. Then trace where this number is coming from, trace logger tool can be useful.

Another way is to log a couple of frames with a turtle on the screen with code/data logger, then pause it, go to rom file tab in hex editor and try to change blue bytes until you find it.



Palette colors can be found with a write breakpoint at ppu address with palette, or by changing blue bytes after you log a moment when this palette was written into ppu. Sometimes simply searching in rom file several bytes from palette also works, 2nd + 3rd + 4th for example
« Last Edit: August 14, 2020, 09:04:00 am by Cyneprepou4uk »
iromhacker.ru - NES ROM hacking tutorials for beginners. Please use Google Translate browser extension

frantik

  • Hero Member
  • *****
  • Posts: 546
    • View Profile
Re: Can I change the palette for each 8x8 tile in SMB?
« Reply #6 on: August 22, 2020, 03:37:33 pm »
The green shell in your graphic is 10 pixels tall and not aligned with the 8x8 grid.  SMB sprites can only be 24 pixels tall (3x8)

bogaabogaa

  • Full Member
  • ***
  • Posts: 155
    • View Profile
Re: Can I change the palette for each 8x8 tile in SMB?
« Reply #7 on: August 29, 2020, 10:40:15 pm »
Here you see where the assembly for the turtle sprite is stored. I put some Mario Tiles and they are indeed 8x8 and not 8x16 as for most other Nes Games.



When you look for the colors you will find that the palette will get copied from RAM $16,x (This means 16 is the base of the table and will be offset by x register)



When I change the value that will get copied there other things change to.. but I did not spend time to really figure it out. But on this point I can tell that you need to write some custom routines to make this work. There are routines in place that will make a whole enemy the same palette.

Do you look forward to learn to code for the 6502? When yes http://nesdev.com/ does have resources to study and programming tutorials. There are also many other places with tutorials.
CV ROM DiscordServer
https://discord.gg/PvFgxRg