DKC Stage Name Editor

Share and discuss all facets of DKC ROM hacking...

DKC Stage Name Editor

Postby rainbowsprinklez » September 1st, 2019, 9:58 pm

This is the DKC Stage Name Editor which can be used to edit the stage names of Donkey Kong Country. The way I edit stage names doesn't use any extra space so this also works with hacks. A 1.0 U Rom will be required for this program to work. Once done, the editor will create a new copy of your ROM (your original file will be left untouched)!

FEATURES:
Smart saving - This program can tell when a change has been made. Therefore, it warns you if you try to exit with unsaved changes. Also, you are only allowed to save when a change has been made.
Smart ROM reading - This program recognizes when it is viewing a ROM that was previously edited by this program. For this reason, no repeat work is necessary.
Minimal Editing - This program modifies a very small amount of the game's code, and the edited part is the stage name part. Therefore, this program is 100% safe to use on various hacks.
Quick edit - Minor, but you can press Enter in any textbox to get the same effect as clicking the associated button.

Download here
http://download1324.mediafire.com/jpymv ... +Editor.7z

A stage name hex editing tutorial: viewtopic.php?f=38&t=2500
Veteran Venturer
Bananas received 110
Posts: 596
Joined: 2016

Re: DKC Stage Name Editor

Postby Cyclone » September 7th, 2020, 11:31 am

How do you specify the end of the text string? In the hex editor the last character is gibberish with a symbol on top.
Expedition Leader
Bananas received 559
Posts: 1253
Joined: 2008

Re: DKC Stage Name Editor

Postby Kingizor » September 7th, 2020, 1:32 pm

The encoding is similar to ASCII which is usually seven bits. DKC and DKC2 use the spare high bit to indicate that a certain character is the last character in a string.

Code: Select all
Jungle Hijinxs = 4A 75 6E 67 6C 65 20 48 69 6A 69 6E 78 F3

01110011 = 0x73 = 's' (normal ASCII value)
11110011 = 0xF3 = 's' (high bit set to indicate last character)

The idea is that they can save a tiny bit of space by doing it this way. Just iterate through the string until a character has the high bit set.
Trailblazer
Bananas received 77
Posts: 248
Joined: 2010

Re: DKC Stage Name Editor

Postby Cyclone » September 7th, 2020, 2:19 pm

Thank you so much Kingizor.

How do you set a high bit of a ASCII character? Is there a calculator? I'm looking on google... Using C++

Something like this?

Thanks again.

Code: Select all

// constructing bitsets
#include <iostream>       // std::cout
#include <string>         // std::string
#include <bitset>         // std::bitset

int main ()
{
  std::bitset<7> bar (0x73);
 
  std::cout << "bar: " << bar << '\n';
 
  return 0;
}



Expedition Leader
Bananas received 559
Posts: 1253
Joined: 2008

Re: DKC Stage Name Editor

Postby Kingizor » September 7th, 2020, 2:46 pm

We have numbers.

In binary, a bit is either 1 (set) or 0 (not set).

A single bit can therefore represent the numbers 0 or 1.

We can represent bigger numbers by using multiple bits at once.

If we have two bits, we have:

00 = 0
01 = 1
10 = 2
11 = 3

Here the bit on the right represents 1, while the one on the left represents 2. If we set both bits, we're basically combining those together to get 3.

Every time we add an extra bit on the left, we're adding a possible power of two to the sum.

A byte is eight bits, so it can represent values from 0 to 255.

11111111 = 255 = 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1

And that's more or less it.

I bookmarked this stackoverflow answer a long time ago which should go over the basic operators (OR |, XOR ^, AND &, NOT ~) and why you might need each one.

Another thing we can do is "shift" bits to the left (<<) or to the right (>>), which is quite similar to multiplying or dividing by two.

Being comfortable with hexadecimal numbers is helpful too. The idea is that you can look at a byte in a hex editor and quickly realise which bits are set.

Bitwise operations are very useful and very fun. Many branches of programming don't use them very much, but in this area they're quite important. There are more topics, but it's easy to be overwhelmed early on with this.

edit:

Setting the high bit of a byte is as simple as:

val |= 128; // decimal
or
val |= 0x80; // hexadecimal
Trailblazer
Bananas received 77
Posts: 248
Joined: 2010

Re: DKC Stage Name Editor

Postby Cyclone » September 8th, 2020, 4:32 pm

Kingizor. Your explanation was great. very easy to understand. I would have never known about the high bit thing without your help.

I can now edit the stage names easily. So what is next? How can I edit a stage name without overwriting the other stage names?

hmm
Expedition Leader
Bananas received 559
Posts: 1253
Joined: 2008

Re: DKC Stage Name Editor

Postby Kingizor » September 8th, 2020, 5:11 pm

Well this is where it starts getting tricky. The best way to tackle it depends on how the game handles it.

Usually when data is stored sequentially like that, there can be something called a pointer table. This would contain a list of addresses that point to the start of each string. The idea is that if we made say, Jungle Hijinxs, a few characters longer, we would have to change the subsequent addresses in the table.

If we have a few strings and addresses:

Code: Select all
0000 = "Dog"
0003 = "Cat"
0006 = "Gorilla"
000D = "Shark"

If we wanted to change "Cat" to "Tiger" which is two characters longer, we would have to adjust the addresses of the subsequent entries as well:

Code: Select all
0000 = "Dog"
0003 = "Tiger"
0008 = "Gorilla"
000F = "Shark"

There are other potential problems too. When we shift the data like that there is also a chance we're overwriting something important that occurs later on, and it's very important not to do that.

DKC3 in particular doesn't use this technique for text. The non-JP versions store the majority of their text in a compressed format (details omitted), and use a nul separator to generate the required addresses during decompression. Even if the text isn't compressed it would still be possible to do that by starting at the first entry and using that high bit to tell where different entries start and end.

I'm not sure exactly what DKC does though. Perhaps RainbowSprinklez or some other kind person could give us some additional insight?

It's great that you're taking an interest in all this though. You might find getting a bit familiar with the SNES assembly language and different kinds of debugging tools helpful.
Trailblazer
Bananas received 77
Posts: 248
Joined: 2010

Re: DKC Stage Name Editor

Postby rainbowsprinklez » September 9th, 2020, 1:52 am

Cyclone wrote:
How do you set a high bit of a ASCII character? Is there a calculator? I'm looking on google... Using C++



A neat shortcut that you can do is open up windows calculator. Go to programming mode, hex, then type in the ASCII code. Now click on bit toggler, and set the max bit. This shows you what the value would be if you set the highest bit. Windows calculator should not be underestimated. It really is something special. If you are not on windows, just download an app. There's tons.
Veteran Venturer
Bananas received 110
Posts: 596
Joined: 2016

Re: DKC Stage Name Editor

Postby rainbowsprinklez » September 9th, 2020, 1:57 am

Not to plug myself, but here viewtopic.php?f=38&t=2500 :D


Also, this got deleted?

If you're using this editor, there is no loss of data. (EDIT - I was very careful to make sure you can't break things. ) In the ROM, the German language is used, so I overwrote that for space. I could have dynamically set names, but I didn't :funky: It is like Kingizor said. In a rom, there exists a pointer table. That table specifies where a string starts. The game finds where a string ends by looking for the high bit. Both of those together allow you to fully customize names (well, mostly :bleak: )

I'm afraid I'm not as well spoken as Kingizor, so let me know if you need more clarification!
Veteran Venturer
Bananas received 110
Posts: 596
Joined: 2016

Re: DKC Stage Name Editor

Postby Cyclone » September 9th, 2020, 3:52 pm

Cool!
Could you provide an example on how to change the Kongo Jungle Text using your method?

I know how to change it now, my code works but it overwrites the next text block if the string is too long.

The only way I can think of is to re-write all the text... or something like that.
Expedition Leader
Bananas received 559
Posts: 1253
Joined: 2008

Re: DKC Stage Name Editor

Postby rainbowsprinklez » September 9th, 2020, 9:38 pm

I would put it in all the german names. Please see the post I linked for a tutorial and example. Nvm! You did! :thumbs:
Veteran Venturer
Bananas received 110
Posts: 596
Joined: 2016

Re: DKC Stage Name Editor

Postby Cyclone » September 12th, 2020, 1:01 pm

I need some advice. My code works and all and I can write the changed text to the German text in the ROM. I started the game and it works great.

My question is how do I change multiple names at a time so that they don't overlap? I'm trying to understand the logic. Maybe I have to load every byte/character into an array? An re-write it to the ROM some how?
Expedition Leader
Bananas received 559
Posts: 1253
Joined: 2008

Re: DKC Stage Name Editor

Postby rainbowsprinklez » September 13th, 2020, 3:08 am

Cyclone wrote:I need some advice. My code works and all and I can write the changed text to the German text in the ROM. I started the game and it works great.

My question is how do I change multiple names at a time so that they don't overlap? I'm trying to understand the logic. Maybe I have to load every byte/character into an array? An re-write it to the ROM some how?


Reread that tutorial we were talking on :P

Big hint:
Spoiler!
You want to load the array of pointers into your program. Loading characters is a waste of space and efficiency.
Veteran Venturer
Bananas received 110
Posts: 596
Joined: 2016


Return to ROM Hacking

Who is online

Users browsing this forum: No registered users and 5 guests