Can I change the palette for each 8x8 tile in SMB?

Started by skrubbed, August 12, 2020, 08:09:23 PM

Previous topic - Next topic

skrubbed

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

#1
Edit: Doh! Didnt see that it said palette, but I will warn you that editing palletes can be difficult.
Mega Man 7 > 3 > 2 > 9 > Wily Wars > 10 > 5 > 6 > 4 > Powered Up > V(GB) > 1 > The Power Fighters > The Power Battle > IV(GB) > III(GB) > II(GB) > Dr. Wily's Revenge(GB) > 8 > Mega Man and Bass > Mega Man (Game Gear) > Mega Man and Bass - Challengers from the Future

Cyneprepou4uk

#2
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

skrubbed

Quote from: Cyneprepou4uk 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.
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

#4
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.

Cyneprepou4uk

#5
Quote from: skrubbed on August 13, 2020, 02:00:31 PM
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

frantik

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

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