# Romhacking.net

## Romhacking => Newcomer's Board => Topic started by: Millertime2325 on September 02, 2013, 11:27:14 pm

Title: Trying to hack SNES rom: Need help with Palettes and ImPalEd (Latest Post)
Post by: Millertime2325 on September 02, 2013, 11:27:14 pm
I've been reading up on this for a while now and I think I'm ready to jump into editing. I can't, however, find anything about what the \$ and : or / symbols mean when talking about values. For example, in another thread about NBA Jam (the game I'm looking to edit) a user posted:

\$3F/B8CF-\$3F/C9F8 Player definition data (0x1A bytes per player)

Where and how do I find this in my hex editor? I've been searching for the last few hours and can't seem to find any information on it. Thanks in advance for the help!
Title: Re: Trying to hack SNES rom: Confused about \$ and : symbols
Post by: KingMike on September 03, 2013, 12:56:09 am
\$ means we're talking in hexadecimal numbers. If you don't know what hexadecimal means, you need to learn that first.

First, you need to know the memory map of the game you're hacking (typically, just knowing if it's a "LoROM" or "HiROM" is good enough, ZSNES and SNES9x will tell you when you boot the game.)
Since HiROM typically starts at address \$C0/0000, I'll guess NBA Jam is LoROM.

\$3F/ indicates bank \$3F is CPU memory. For LoROM, each bank is mapped to 32KB (\$8000 bytes) of the ROM in addresses \$8000-FFFF of that bank.
So, again assuming LoROM, do 3F x 8000 = \$1F8000, that means CPU bank 3F can map to ROM addresses \$1F8000-1FFFFF.
So, then take the second part, B8CF, and subtract 8000 (well, for this purpose) because 3F/8000 maps to byte 0 of that ROM \$1F8000 bank, you get 38CF.
Now add 1F8000 + 38CF to get 1FB8CF, the ROM address that CPU address 3F/B8CF represents (again, going on the assumption NBA Jam is a "LoROM" game.)
Title: Re: Trying to hack SNES rom: Confused about \$ and : symbols
Post by: puzzledude on September 03, 2013, 04:54:36 am
\$ tells the machine that the address is in hex, it also defines the location, rather then a value on that location. The / is just a formality. It simply defines the global 8000 bank. This separation is essentially not necessary to be defined. If someone would write 3FB8CF, we would know what the deal is. It is, however, more important if we are talking about SNES or PC address. The upper seems like a Snes one, which can be converted into PC address as seen in the upper post, or using Lunar address, specifying, what kind of rom it is (probably Lorom). So you would be looking at 1FB8CF in a hex editor (pc address).
Title: Re: Trying to hack SNES rom: Confused about \$ and : symbols
Post by: Millertime2325 on September 03, 2013, 11:10:51 am
Yes, I'm familiar with hex. I did some work on NHL 94 for the genesis trying to get my feet wet, and I decided to use the SNES version of NBA Jam because there's a lot more information out there, I'd be completely on my own if I decided to use the genesis version.

Also, the SNES version of NBA Jam is indeed lo rom.

I appreciate the explanation of this, I haven't found any sort of information about it in my searches, so this should help me a lot. Is there a hex calculator so I don't have to do the math in my head? I'm still a hex novice, I understand the basic concepts of it but I think the adding is a little over my head at this point.

:edit: Oh, I just looked into that Lunar Address program. Exactly what I was looking for. Thanks! But I'm glad I understand the principles of what's going on now. Thanks a lot guys.

September 03, 2013, 01:37:37 pm - (Auto Merged - Double Posts are not allowed before 7 days.)
Quick question about editing images (never really gone down this road before)

(http://img262.imageshack.us/img262/7374/teamnames.jpg)

How do I edit these team names when they're displayed like this? I tried to do it by hand but it looked like crap haha, is there a more precise way to do it?
Title: Re: Trying to hack SNES rom: How to modify images? (See latest post)
Post by: puzzledude on September 03, 2013, 01:51:34 pm
Here are the tools I'm using

-freeware hex editor HxD (ignore the Zelda title of the zip)

-address calculator and rom expander plus patcher (asm inserting function not recommended with this tool, use xkas directly)
http://www.romhacking.net/utilities/841/

---------------------

regarding the gfx edit

this is how the gfx looks like (mixed). You can edit this directly (knowing how letters fit together). See those "Lakers" in two lines, the lower one being shifted. It must remain like this to be ok in-game. Or extract the gfx (not sure how to do this with your game). If the gfx is not compressed, you can open it directly in yy-chr and copy paste the parts of letters correctly together in a separate rom (opened with yy-chr)= "assembled" gfx. Make the edit and disassemble the gfx back as it was.

I agree gfx editing is problematic, since it is (as you can see) packed "tight", or "disassembled", to fit into horizontal gfx tile sets (this is why it is "shifted" or "scattered").

EDIT
I've just realized this editor has a built-in gfx editor, so you don't need yy-chr or gfx decompression. You can edit it directly. You might want to make a copy of the rom, to be used with "assembled" gfx. For instance in a separate rom you can make the "Lakers" a whole (correctly matching), edit it, and copy paste it to a regular rom by small squares (so that it remains scattered-edited in the original, since it must be so).
Title: Re: Trying to hack SNES rom: How to modify images? (See latest post)
Post by: Millertime2325 on September 03, 2013, 05:20:52 pm
Okay, it sort of makes sense now. So you're saying match them up, make the edits, and scatter them out again. Let's say for example I want to edit Seattle into Oklahoma City? How can I make a smaller team name into a bigger one, and vice versa?

I also don't understand how to make it look the same as it originally did. Do I just copy each individual letter of the name I'm trying to edit it to, and paste them all up? Like, take the C I from Clippers, T from Golden State, etc? Confused about that with the player names as well. Like I said, when I tried to do it free hand it just looked like crap, and I'm trying to keep it looking as close to the original text and font as possible, with just different names.

I wish you could just edit a few strings of code in the hex editor to change names -- I tried that and it only changed the names on the intro screen.

Thanks again for the help. I'm really excited to get started on this project.
Title: Re: Trying to hack SNES rom: How to modify images? (See latest post)
Post by: puzzledude on September 03, 2013, 06:29:29 pm
Seattle into Oklahoma city is not happening if the letters are as big as in the original. You are space-limited with gfx. Gfx is packed-up + compressed to take as less space as possible. Original authors even had calculators to fit it into a tileset, by using as much as repeated small tiles as possible.

The gfx is formed with unique squares only.

Lets take an example. Lets say a one small square is one letter. And you want to write: Seattle, you would only need S, E, A, T, L. (the T and E would be double used). But you have big letters with shadow, making all small 16x16 squares unique, to be able to see correct letters at all.

But a long name into short one is possible, by blanking the rest out (the blank will remain).

Quote
I also don't understand how to make it look the same as it originally did. Do I just copy each individual letter of the name I'm trying to edit it to, and paste them all up? Like, take the C I from Clippers, T from Golden State, etc?
Not in this case, the text is "continuing". Changing the name means redrawing the entire name pixel-wise (or with partial copy-paste help). As you can see in STATE, the second T goes into E on one square. But if T goes into L, the same square is used. So you have some small help here.

I would start with the Golden State. You can write anything here which fits, editing it pixel-wise. You can use your own letters, no shadow for instance etc.

You could change the "continuing" text by making custom letters, one letter in two vertical squares (but, as can you can see, you would have less space with that, so the original authors made it continuing to fit more in with shadow).
Title: Re: Trying to hack SNES rom: How to modify images? (See latest post)
Post by: KingMike on September 03, 2013, 09:06:07 pm
You'd probably have to do tilemap changes as well.

You can see SACRAMENTO is missing the bottom corner of the outline of the O, probably reusing another tile. See SAN ANTONIO as well. Clearly tiles are being reused.
Title: Re: Trying to hack SNES rom: How to modify images? (See latest post)
Post by: Millertime2325 on September 09, 2013, 10:44:32 am
Alright, I'm giving up on trying to change the team names. Just going to keep them original and modify the roster. So far so good. I can modify the names, attributes, and player models, but what I'm having a tough time with is the portraits in the game. I'm using this tutorial here:

http://mattrizzle.pac.am/docs/nbajamte/nbajamte_portrait_tutorial.htm

What I'm having trouble with is exporting the palette. I tried to download a few programs and google some information about how to do this, but I couldn't find the specific program listed in the tutorial. I downloaded a later version of it, and I can't figure out where that option is or if it is available. Is there some other program which allows this? Other than that, I think I'm headed in the right direction with the project, thanks in large part to the help I've received here.
Title: Re: Trying to hack SNES rom: How to modify images? (See latest post)
Post by: FAST6191 on September 09, 2013, 02:32:23 pm
When you say exporting the palette do you mean from your image editor so you can stick it back into the game or originally from the game itself?

It sounds like the latter and in that case I have to ask whether you intend to change the colours or just use existing ones and tweak the image. Either way it is a fairly fundamental part of graphics hacking. The tutorial actually tells you what you need to do (the palettes are stored in plaintext at 690 hex after the start of the portrait in question) but I will cover basic palette extraction anyway.

The SNES is not like some older systems and can have a selection of colours that make up a given colour palette (you can even change them during runtime as a type of animation). It does this by having the developer choose a selection of colours (they are anything in the 15 bit range for 555 BGR which is also the same as the GBA and DS in case you find other tools aimed more at them, or some 32768 colours) but you can only have 256 of those loaded at once*. Actually I say 256 but there is http://en.wikibooks.org/wiki/Super_NES_Programming/Graphics_tutorial#Bit_Depths to consider which basically says there are real and virtual modes that it can be carved into and oddities beyond that so you may end up a bit more restricted (though it does not look to be the case here).

*it looks like you are not having it happen here but there are blending options which up this number a bit further.

By necessity the game will have to have this loaded into memory so if you get to the point in the game where the image is displayed then you can probably export it directly from the emulator and various tile editors will be able to pull them from savestates (and from there you can export it to more general formats for more exotic image editors).

If you just want to mod using existing colours this works well. You will have to enforce tile editing discipline and thus you will not be as able to do things like gradients, noise functions, colour blending, anti aliasing and everything else that works but changing/blending colours according to a mathematical function. This is not as bad as it might seem as you can still be sharply limited when you have though importing "real" images can be tricky.

If you want to change what colours you have available then you get to find the palette within the ROM. The obvious start is to search for the relevant fragment in the ROM -- palettes are small and thus not often compressed so they can be sitting there plain as day in the ROM.
Alternatively with the virtual modes, animation (you can change colours, maybe do a bit of contrast adjustment and more*), simple palette construction and more the above might not work and you will have to trace it like you when finding another image.

*I have not hacked a wide enough selection of SNES ROMs to call it but the GBA, which is basically SNES junior/little SNES, it is quite common and on the DS, which is basically SNES junior plus, then it is very common indeed.

If those pictures are used as an animation (losing face, injured face....) then it might be a different palette for every one (SNES coders were usually a bit tighter than that but I am not going to put money on it not happening) and it may also be a different palette for every
Title: Re: Trying to hack SNES rom: How to modify images? (See latest post)
Post by: Millertime2325 on September 09, 2013, 03:28:39 pm
I'm sorry, but I'm a little confused by your post lol.

I am stuck on the part where it says "2. More editing, exporting the palette (Paint Shop Pro): Go to the Colors Menu and select Save Palette."

I downloaded Paint Shop Pro 5x but the tutorial recommends Paint Shop Pro 4.15, so I can't find that option in my version of the software. I just need to export the palette from a modified image to place into the game. Is there any software that can easily do this?

:edit: I think I just saved the palette using GIMP, but it's in .gpl format. How do I change it to .pal? Is there any way to do that, or is there a better program to use all together?

:edit2: Okay, I definitely figured out how to save a palette. My latest issue is that when I try to load it in ImPalEd, the colors don't change. Not sure what I'm doing wrong here.
Title: Re: Trying to hack SNES rom: Need help with Palettes and ImPalEd (Latest Post)
Post by: eskayelle on May 25, 2017, 08:18:01 am
Based on that nice NBA Jam 2k17 ROM that hit the web in January, I know that Millertime solved his ImPalEd dilemma, but for those of you who (like me) had the same problem, I wanted to pay it forward and provide one workaround.

If you're using Matrizzle's tutorial on how to edit NBA Jam TE portraits (and if you aren't, and you're just starting on your project, you should consider it), note the APP_A.PAL and APP_B.PAL files (I may have the names slightly off) that you're asked to download to use after you import your portrait via TileMolester.  These PAL files are plain-text-readable in WordPad.  So...

1) Copy/paste one of those PAL files and rename the copy.  This renamed PAL is the file you're going to use to import into ImPalEd (after you edit it).  I use APP_B.PAL, since there's less palette data to overwrite (and less chance I screw up the palette I'm recording).
2) In that PAL file, note there are 256 rows of R G B data (space delimited, which is why I spaced them out here).  You're going to overwrite the first 32 with your portrait's palette info.
3) Open your portrait .png file in Paint Shop Pro (or whatever tool you've been using that will allow you to view the palette).
4) One by one, starting from palette ID 0 and ending at ID 31, record the 3 RGB values per palette ID in the PAL file you created.
5) Double check your work for typos, fat-fingering, etc.
6) Save that PAL file.
7) Import that manually written PAL file into ImPalEd.
8) Via ImPalEd, save that imported PAL to BGR, jump back into Matrizzle's tutorial (I can't recommend it enough!), and get cracking on that portrait!