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

Author Topic: Lets make Zelda2 for GB!  (Read 7169 times)

dACE

  • Sr. Member
  • ****
  • Posts: 346
    • View Profile
Lets make Zelda2 for GB!
« on: September 05, 2014, 11:17:38 am »
Hi,

I know that it is pretty pointless to try to recruit people for a joint-venture hack...
BUT who knows - maybe someone out there have share the very same dream as I:

To bring a Zelda2 type game to the GameBoy system!

Now, the easiest way of achieving this would of course be to modify a already existing game for GB - that plays almost exactly like Zelda2 anyway - namely Battle of Olympus.

The minimum requirement for such a hack would be to:

- Alter the gfx of all the characters and bosses to that of the Zelda(2) universe
- Alter the script so it suits a Zelda story-line

The first part I think I can manage all by myself - take a look at the below 'Proof of Concept' image:



The above is a screen-shot of a modified rom running in VirtualBoy (not a montage made in MS Paint :-)
And yes - I have borrowed/stolen (but meant to ask) the design for link from Thanatos-Zero http://www.romhacking.net/forum/index.php/topic,12330.60.html

The second part, adapting the script - turned out to be a real bi*ch though.

It seems as if the developers have used some kind of 'look-up' table for both single letters, groups of letters and entire words (probably those used a lot throughout the game).

The first dialog takes place in the very first house directly when walking right from the start.
This dialog is located at address:2 C727

The hex-values and the equivalent in characters/words are:

79,
40[space]
0E 72FIRST
C8 08YOU
0C F0MUST
01G
04O
16[return]
15T
20O[space]
02 00THE[space]
02 34TEMPLE
B0O
80F
70[space]
00A
89R
84C
04AD
14I
50A
20[space]
05T
48O
2C F3MEET
00[space]
A6 29ZEUS
5A.

As you can see above - the same character-tile can be represented by different hex-values!

Take for instance the letter 'T' tile:
- the first time it is referenced in the dialog, the hex-value is 15
- the second time  it is referenced in the dialog, the hex-value is 05

In short - this project would require a experienced rom-hacker/rom-translator for guidance of how to tweak the script to fit a Zelda story-line.

If anybody feel up to the task - comment in this thread and maybe we can make this hack a reality (maybe we can convince Thanatos-Zero to join in too).

/dACE


Thanatos-Zero

  • Full Member
  • ***
  • Posts: 217
  • NES Graphic Designer
    • View Profile
Re: Lets make Zelda2 for GB!
« Reply #1 on: September 05, 2014, 04:05:39 pm »
Okay, since I have nothing better to do, let us give it a shot.
But remember, unlike Infidelity's hack, I have but one request as a condition to work.
Make it so that my designed sprites work within the game. As such I hope you are not a beginner of romhacking.

I had some great designs in mind, but was forced due the rediculous size limits to resize them.
The original fairy in LoZ was 8x16, but I went for 16x16 to make the fairy look much more appealing.
It couldn't be done and so I had to create somehow a new fairy in 8x16.


Tiles for the background however are never a problem for me. ;)

And before I forget, you will have to account in my mood and creativity. I might not being able to create a sprite sheet for months, if both things are down. Keep this in mind dACE.
« Last Edit: September 05, 2014, 04:11:03 pm by Thanatos-Zero »

dACE

  • Sr. Member
  • ****
  • Posts: 346
    • View Profile
Re: Lets make Zelda2 for GB!
« Reply #2 on: September 05, 2014, 05:09:45 pm »
Although I managed to rearrange tiles when i hacked kid icarus:retold on the NES - I would say what you require is quite cumbersome. If this project is takes off - my idea was that I would do all the 'ridiculous' size adaptions and insertions - but you would of course have final say regarding any 'compromises' made.

I'm not a gfx-wiz BUT I can deliver hacks like the above mentioned kid icarus one - where all enemies are custom or adaptions of GB enemies.

Anyway - there is no project at all unless someone can at least provide help with understanding the way that the script and dialogs can be altered.

/d-ace

dACE

  • Sr. Member
  • ****
  • Posts: 346
    • View Profile
Re: Lets make Zelda2 for GB!
« Reply #3 on: January 28, 2015, 11:09:21 am »
NecroPost!

Is there really nobody that can offer ANY help to understand how the script of 'Battle of Olympus' can be altered?

I'm seriously loosing faith in this 'forum'....

/dACE

Dr. Floppy

  • Restricted Access
  • Hero Member
  • *
  • Posts: 972
  • Make America GREAT Again!
    • View Profile
    • BaddestHacks.net
Re: Lets make Zelda2 for GB!
« Reply #4 on: January 28, 2015, 10:20:38 pm »
I've worked with various scripting engines and have experience in adapting scripts to Zelda games. I'm willing to throw my weight behind this project, although I won't be fully-available until Late April.

dACE

  • Sr. Member
  • ****
  • Posts: 346
    • View Profile
Re: Lets make Zelda2 for GB!
« Reply #5 on: January 29, 2015, 04:22:12 am »
If you want to join in - thats great!

But the main issue right now is that I don't understand how to decifer the way the script is arranged in the rom.

Any insight in this matter would be appriciated - are we dealing with some kind of compression? What are common compression methods for text in regular gameboy games?

As soon as I know how to properly alter the script, I would then build a application for viewing all dialogs and replacing them. This would make localization to the other languages this rom supports a trivial matter.

/dACE

Seihen

  • Sr. Member
  • ****
  • Posts: 405
    • View Profile
Re: Lets make Zelda2 for GB!
« Reply #6 on: January 29, 2015, 06:55:27 am »
As soon as I know how to properly alter the script, I would then build a application for viewing all dialogs and replacing them. This would make localization to the other languages this rom supports a trivial matter.

Let me get this straight... you can't figure out the compression used in the ROM yourself and don't even know where to start, nor have you bothered starting to use a debugger and try to debug the compression itself (assuming that's what's being used), and yet you are able to build a script to view all dialogues, replace them, and "make localization... a trivial matter"?

Onto a more constructive post:

It would be a lot more helpful if you could explain what you've tried, and how you've come to the conclusion that the string you've posted is, indeed, the text that you've asserted. Have you tried replacing the second instance of 'T' with a 15 instead of a 05 to see what would happen? It seems really weird and out of place that several values would be the same letter, and I have a feeling if you replace even one of the values in the string, it'd probably break the whole sentence. Which means that one letter is not represented by two values, but rather than there's some sort of basic compression going on and neither of those numbers 'represent' the letter in question.

Again, the less info you supply, the less people can help. What have you done so far?

dACE

  • Sr. Member
  • ****
  • Posts: 346
    • View Profile
Re: Lets make Zelda2 for GB!
« Reply #7 on: January 29, 2015, 11:56:29 am »
What I have tried so far - well lets see:

- I was able to locate the entire first dialog within the rom-file
- I have (of course) tried to replace single and sequenced hex-characters to get a predetermied result - but failed
- I have considered that the rom might contain a look-up table for entire words (FIRST, YOU, ZEUS etc)
- I have considered that the script might be compressed/encoded in some way (maybe in conjuction with a look-up table)

Below is an example of what I have tried..... and failed at.

Here is the screen-shot of the first dialog (only the sprite of the character have been altered in the rom):



Here is the untouched original hex-sequence for the first dialog:
Code: [Select]
79 40 0E 72 C8 08 0C F0 01 04 16 15 20 02 00 02 34 B0 80 70 00 89 84 04 14 50 20 05 48 2C F3 00 A6 29 5A
Then, I try to modify the hex-sequence - by making the word FIRST appear twice (at the cost of loosing the word YOU).

Code: [Select]
79 40 0E 72 0E 72 0C F0 01 04 16 15 20 02 00 02 34 B0 80 70 00 89 84 04 14 50 20 05 48 2C F3 00 A6 29 5A
The modified scentence should now start with '[Name], FIRST FIRST MUST GO..', since the hex chars 'C8 08' have been replaced with '0E 72'. Instead - I get the following result:



So now I have doubled the word FIRST, but also replaced space with the number 3.
I have also lost 'MUST GO' - I can't make any sense out of that...

The thing is, I newer hacked 'complex-text' in a game before - only tile-replacing according to a table-file.
I simply don't know how to proceed and the debugger of VisualBoy has always been a mystery to me.

If I knew the compression/look-up table, I'm pretty confident I could wip together a .NET application to properly compress
scentences and insert them into the rom (as long as the new hex-array was no longer than the old one (and shorter ones could be padded with spaces)). The real hard work would of course be to pin-point each and every hex-address of all the different scentenses in all the different languages - but it could be done...

/dACE
« Last Edit: January 29, 2015, 12:42:50 pm by dACE »

Dr. Floppy

  • Restricted Access
  • Hero Member
  • *
  • Posts: 972
  • Make America GREAT Again!
    • View Profile
    • BaddestHacks.net
Re: Lets make Zelda2 for GB!
« Reply #8 on: January 29, 2015, 06:22:30 pm »
This looks like a groovy mystery to solve!  :D

Depending on when/how well my Adderallâ„¢ kicks in today, I just might take a stab or three at it...

dACE

  • Sr. Member
  • ****
  • Posts: 346
    • View Profile
Re: Lets make Zelda2 for GB!
« Reply #9 on: February 03, 2015, 11:40:57 am »
UPDATE:

So I tried some more switching around of the hex-values of the first dialog - and stumbled upon this:

The two words below are fully interchangable in the first dialog!

02 00   THE
02 34   TEMPLE

Here is the untouched original hex-sequence for the first dialog:

Code: [Select]
79 40 0E 72 C8 08 0C F0 01 04 16 15 20 02 00 02 34 B0 80 70 00 89 84 04 14 50 20 05 48 2C F3 00 A6 29 5A
Here it is - with the above two words swapped:

Code: [Select]
79 40 0E 72 C8 08 0C F0 01 04 16 15 20 02 34 02 00 B0 80 70 00 89 84 04 14 50 20 05 48 2C F3 00 A6 29 5A
And here is the resulting screen-shot:



I don't know if this is a step foward or not...just though I should share...

EDIT:

So - it seems I stumbled upon the look-up table!

By using the interchangable known hex-pairs for THE and TEMPLE - I extrapolated (through guessing :-) and verifyed the following table (so far...):

02 00   THE
02 02   YOU
02 04   THIS
02 06   THERE
02 08   HADES
02 0A   THAT
02 0C   HAVE
02 0E   PLEASE
02 10   TARTARUS
02 12   ARGOLIS
02 14   SALAMANDER
02 16   YOU'VE
02 18   POWER
02 1A   I'LL
02 1C   AND
02 1E   FROM
02 20   COME
02 22   PELOPONNESUS
02 24   SOMETHING
02 26   FOR
02 28   CRETE
02 2A   STAFF
02 2C   HERE
02 2E   OLIVES
02 30   HAS
02 32   LACONIA
02 34   TEMPLE
02 36   I'VE
02 38   GIVE
02 3A   HEARD
02 3C   PROMETHEUS
02 3E   SHIELD
02 40   YOU'LL
02 42   HELP
02 44   SOMEWHERE
02 46   WELCOME
02 48   DON'T
02 4A   USE
02 4C   SALAMANDERS
02 4E   CAN
02 50   WITH
02 52   WILL
02 54   SWORD
02 56   HEPHAESTOS
02 58   HESPERIDES
02 5A   FOREST
02 5C   YOUR
02 5E   CRYSTAL
02 60   PROTECT
02 62   WITHOUT
02 64   WAS
02 66   APHRODITE
02 68   ARE
02 6A   SEA
02 6C   TAKEN
02 6E   NYMPH
02 70   KNOW
02 72   POSEIDON
02 74   NECTAR
02 76   I'M
02 78   TAKE
02 7A   LOVE
02 7C   POWERS
02 7E   ENTRANCE
02 80   FIRE
02 82   MONSTERS
02 84   PHTHIA
02 86   APHRODITE'S
02 88   CAREFUL
02 8A   THROUGH
02 8C   MONSTER
02 8E   BENEATH
02 90   PHRYGIA
02 92   ELEUSIS
02 94   HOWEVER
02 96   GODDESS
02 98   ZEUS
02 9A   BEING
02 9C   IT'S
02 9E   WELL
02 A0   MOON
02 A2   GONE
02 A4   AFTER
02 A6   BEEN
02 A8   COULD
02 AA   CAVE
02 AC   MYSTERIOUS
02 AE   AGAIN
02 B0   GARDEN
02 B2   LITTLE
02 B4   INVISIBLE
02 B6   GRAEAE
02 B8   GRATITUDE
02 BA   THORNS
02 BC   ACCEPT
02 BE   BEFORE
02 C0   DIRECTION
02 C2   FENNEL
02 C4   SEE
02 C6   RETURN
02 C8   IMPORTANT
02 CA   SPIRIT
02 CC   FRAGMENT
02 CE   INTO
02 D0   SUMMONED
02 D2   SOME
02 D4   WHAT
02 D6   EXCHANGE
02 D8   WANT
02 DA   SERVANTS
02 DC   STRENGTH
02 DE   MAKE
02 E0   LEFT
02 E2   AMBROSIA
02 E4   LIKE
02 E6   RETURNED
02 E8   BRACELET
02 EA   DOLPHINS
02 EC   ENTERING
02 EE   FLASK
02 F0   THOSE
02 F2   CROSS
02 F4   WITCH
02 F6   WAY
02 F8   HOW
02 FA   FOUND
02 FC   CAN'T
02 FE   WHO

03 00   SKINS
...
03 FE   HOLDS

What's left to research is the words encoded between 03 00 AND 03 FE.

When I have those - I'll try to find where the look-up table is defined. Maybe it would be enough to exchange certain words - to a Zelda equivalent to make an acceptable script-transition....who knows...

EDIT:

Where the h*ll is the look-up table specified?

Maybe it is encoded/compressed somehow?

One technique of compression is apparently to string bytes together and use only a couple of bits to identify each tile. If this is true, then I should be able to find the below sequence of words encoded somewhere in the rom:

THE YOU THIS THERE

Anyone that feels like helping with finding this string?

/dACE
« Last Edit: February 03, 2015, 06:13:27 pm by dACE »

bailli

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Re: Lets make Zelda2 for GB!
« Reply #10 on: February 04, 2015, 07:53:39 am »
I only had a very quick look at this game, but with my very basic Z80 asm knowledge it feels like this game uses an (overly?) complicated text engine. It seems a word is not written in one loop directly to VRAM but more like one letter at time - this might be a clue that there is additional compression besides the look-up table involved.

THE YOU THIS THERE

Anyone that feels like helping with finding this string?

Remember there has to be a terminator between these strings or the length of each indexed string has to be hardcoded - which I do not believe...
Also what about the odd table indices like 0201?



So now I have doubled the word FIRST, but also replaced space with the number 3.
I have also lost 'MUST GO' - I can't make any sense out of that...

You do not loose the words "MUST GO", but the "carriage return" from the script is missing. If you look at your screen(shot) in VRAM you can see the words...

I do not want to make any promises but I *might* take another look at the game this weekend... maybe this motivates me enough to pick up my DK editor again...

dACE

  • Sr. Member
  • ****
  • Posts: 346
    • View Profile
Re: Lets make Zelda2 for GB!
« Reply #11 on: February 04, 2015, 01:44:52 pm »
Good point bailli. I skipped the 'odd' hex increments since they added some extra 'character' (to the left of the word, if i'm not mistaken) - could that be the 'separator'?

I will investigate this further tomorrow - I'll post if I succeed (with anything...:-)

EDIT:

Yepp - the values in between the words in the look-up table (listed above) are the word with a trailing space.
This is probably the delimiter char for the look-up table.

/dACE
« Last Edit: February 05, 2015, 11:17:12 am by dACE »

bailli

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Re: Lets make Zelda2 for GB!
« Reply #12 on: February 05, 2015, 04:34:33 pm »
Okay I did some more debugging - even though it isn't the weekend yet ;)

I think I found the look-up table in bank 3. But this game uses every single bit it can get its hands on...
... meaning the look-up table consists of something like 5bit word length + 6bits per letter...
Bank 3 has some pointers at the beginning - (mostly?) to the same bank.
From the pointer location starts a word list (5bit+N*6bit) which the game needs to walk through till the requested word - very efficient...

I *think* the dialogue at 0x2C727 you found is also a "bit stream" but this needs more debugging... but not today.

EDIT:
The dialogue around 0x2C727 (I am not quite sure about its starting position) is indeed a "bit stream":
bit == 0 a single letter (again 6bit) follows; bit == 1 table index (8bit) follows (see above).
There is one table for every language.

I didn't mention yet that the 6bit letters do not match the tile number and get converted in a small subroutine...

I guess what is left to do is to locate the pointers to the different text strings...
« Last Edit: February 06, 2015, 02:08:30 pm by bailli »

dACE

  • Sr. Member
  • ****
  • Posts: 346
    • View Profile
Re: Lets make Zelda2 for GB!
« Reply #13 on: February 06, 2015, 02:45:22 pm »
Thanks bailli!

With your info and Excel! I have finally located the look-up table for the English translation.

Tomorrow I will try to build a .Net executable that lets me extract, modify and reinsert a modified look-up table.

/dACE

bailli

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Re: Lets make Zelda2 for GB!
« Reply #14 on: February 07, 2015, 08:53:05 am »
ENG word list: http://pastebin.com/4juit1vi

WIP: Python script which dumps all 5 tables: http://pastebin.com/BhczNMC2

EDIT2
I was too lazy to debug whether there are more tables with string pointers, but this script does a primitive dump of the pointer table at the start of bank 0x0B in all 5 languages. There first few strings (unimportant) are broken except for English and French...
What makes me think there might be more tables is that there are only 139 indices for every language - is the game/story that short?

If anybody is curious here is the English dump (after a little cleanup to make it more readable): http://pastebin.com/iuiDeCch
« Last Edit: February 07, 2015, 03:58:19 pm by bailli »

dACE

  • Sr. Member
  • ****
  • Posts: 346
    • View Profile
Re: Lets make Zelda2 for GB!
« Reply #15 on: February 07, 2015, 05:04:49 pm »
Thanks a lot bailli.

That is about how far I got myself with my .NET executable. I can read the look-up table in English (but I have prepared the executable for the other languages as well).

What's disappointing is that not all 'localization' words are in the look-up table. For instance, the word ARCADIA must be 'assembled' tile by tile.

I was hoping the look-up table editor I am building would solve the whole matter of altering the script...

/dACE

bailli

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Re: Lets make Zelda2 for GB!
« Reply #16 on: February 07, 2015, 05:28:56 pm »
Hm I forget the link to the python script in my last post... http://pastebin.com/mQNFFvck
This is the script that dumps the full pointer table from rom bank 0x0B.

Have played that game? Is it really as short as the 139 string indices suggest? And the little I saw from the game feels kinda sluggish...

dACE

  • Sr. Member
  • ****
  • Posts: 346
    • View Profile
Re: Lets make Zelda2 for GB!
« Reply #17 on: February 08, 2015, 06:57:30 am »
So today I finished up my look-up table editor - it turned out pretty nice!



(If you still doubt my skills, Seihen - I can upload the actual executable so you can verify it  ;D)

It is not perfect and there are bound to be some issues BUT you should be able to edit each and every of the 5 sets (one for each language) of the 256 predefined words!

The editor does not currently write directly to the ROM - you have to use a Hex-editor and copy-paste the generated table manually.
The limitation is that you can not expand the table and I have assumed that you can 'pad' a shorter table with '00' entries.

...

The ONE problem left for me to solve is to address the words NOT in the look-up table (for instance, the word ARCADIA).

I'll dig around today and see what I can find - as always - any help is greatly appriciated...
(bailli has already secured his spot in the credits ;))


/dACE

bailli

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Re: Lets make Zelda2 for GB!
« Reply #18 on: February 08, 2015, 07:40:41 am »
You realized I dumped the full dialogue not just the look up table in the last version of the python script?

dACE

  • Sr. Member
  • ****
  • Posts: 346
    • View Profile
Re: Lets make Zelda2 for GB!
« Reply #19 on: February 08, 2015, 08:21:05 am »
Actually...no...I don't really know how to run Python scripts.

So - are the dialogs encoded the same way as the look-up table then - with n bits for the sentence length and 6 bits per tile-index? If so - how are the pointers to the look-up table encoded?

EDIT:

So I was checking your Python-script and from what I can gather you have it all pretty much figured out already?

I haven't calculated/debugged my rom-offsets for parsing the look-up tables - I found them by trial and error:

Code: [Select]
private const long ENG_TABLE_POS = 0xC3BC;
private const long FRE_TABLE_POS = 0xC85C;
private const long GER_TABLE_POS = 0xCD66;
private const long ITA_TABLE_POS = 0xD266;
private const long ESP_TABLE_POS = 0x3367D;

private const int ENG_TABLE_LEN = 1184;
private const int FRE_TABLE_LEN = 1290;
private const int GER_TABLE_LEN = 1280;
private const int ITA_TABLE_LEN = 1281;
private const int ESP_TABLE_LEN = 1249;


So I have a couple of questions to get me started with adding sentence editing into my editor:

- What are the offsets to the first scentence, for each language?
- How do I know when to look-up a word and when to parse a word - when parsing a sentence?
- When parsing non look-up word in a sentence, does the first 5bits still determine the length and then every tile-index is 6bits?


/dACE
« Last Edit: February 08, 2015, 09:03:55 am by dACE »