Author Topic: Cyber Knight translation  (Read 10354 times)

megatron-uk

  • Full Member
  • ***
  • Posts: 219
Cyber Knight translation
« on: February 05, 2014, 05:03:24 AM »
Can anyone confirm what I believe to be the case with Cyber Knight? That it, its script and artwork assets are stored as compressed in the rom?
I'm having no luck with Tile Layer Pro, TMOD2 or YY-CHR when trying to viewing any sprite or font data.


This thread started out in early 2014 as an attempt to find any English text or assets in the RPG/Strategy game Cyber Knight, it has now turned into a full English translation project.

Translation tools, patches and other assets will be continuously updated on my github page and anyone can download and use them. The project now has a 99% complete Ascii/Hiragana/Katakana translation table, a 99% complete Kanji translation table, working extractor and injector scripts and work has started on writing patches for the game text. These take the form of individual JSON that correspond to a particular section of the rom file. This way we can extract and re-insert seperate sections of text and not have to create a single, giant all-encompassing patch.
The patch files mostly correspond to certain, common sections of the text - all the ship menu structures, all the item names, battle screen dialogue, dialogue for each world/town etc.

https://github.com/megatron-uk/cyberknight-pce



Edit (April 18th, 2014):
The battle interface is almost 100% complete - all menu options, status text, messages from the computer etc and all translated. There are some minor spacing and linebreaks to test visually, but the text itself is all done. Unfortunately a side effect of doing more translating of the main game dialogue has broken the scrolling intro - it will need work again (possibly someone to adjust it's location in the rom). Here's a video of several battles on the way to the first main quest in the game (the crashed ship 'Europa'):

Edit (March 30th, 2014):
Lots more translations done, virtually all weapons/items, character names and now in-game text too. Here's the full English menu structure for the ship:

Edit (March 3nd, 2014):
Scrolling 'the story so far' text that appears after the intro cinema is now translated. Updated patch files now on github.

Edit (March 2nd, 2014):
Intro cinema now fully translated!

Edit (Febrary 28th, 2014):
Quick example showing some of the translated menu and dialogue:

Edit (Febrary 26th, 2014):
Updated player character name entry screen, started translating npc name lists (incomplete).

Edit (Febrary 25th, 2014):
Main menu screen is now translated (patches/test.json on github) as a test of the extractor and injector utilities.

Edit (Febrary 23rd, 2014):
All code and assets I've produced to extract/inject script data will be available on github here: https://github.com/megatron-uk/cyberknight-pce
For now this includes a 99% complete translation table and a 'mostly' working script extractor; which we need more text dialogue location information for!
« Last Edit: April 17, 2014, 08:29:09 PM by megatron-uk »

megatron-uk

  • Full Member
  • ***
  • Posts: 219
Re: Cyber Knight assets (tiles/text)
« Reply #1 on: February 05, 2014, 05:44:27 AM »
Hold on, I think I can see partial font data in TLP if I switch to 1BPP format (why?), but it doesn't look right - the fonts are all offset and corrupted, different to any of the other hucard games I've looked at so far.

One good thing about this is that it does have a full western character set (both upper and lower-case) in there though.

Tried Nana too - it also seems to show the font not being byte-aligned.

« Last Edit: February 05, 2014, 07:22:33 AM by megatron-uk »

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: Cyber Knight assets (tiles/text)
« Reply #2 on: February 05, 2014, 08:00:02 AM »
Looks like data(a byte or two) is interleaved between some of the font graphics. Look at "C" and "D", appear to be corrupt. Some of the others, while not corrupt looking, are probably offset because of header bytes or control codes (for sequencing through the font?).

Edit:
 Actually, just looking at it - it appear to be compressed via RLE variant. Look at the "C", and look right at the first break. See that pattern of pixel? You see the same thing on the number "1". And the same thing for "D". The byte is probably something unique that doesn't exist in the whole font (graphically) and thus is a control code. When encountered, the following bytes are probably the paramenters for the control code (run length). Pretty poor compression method. They would have been better off using a mask 1bit repeat method. Typical lousy compression schemes uses on hucard games (ugh).

 Anyway, that's my guess.
« Last Edit: February 05, 2014, 08:06:31 AM by Bonknuts »

megatron-uk

  • Full Member
  • ***
  • Posts: 219
Re: Cyber Knight assets (tiles/text)
« Reply #3 on: February 05, 2014, 10:05:42 AM »
That makes sense Tom.

I'm following some of MooZ's postings here where he describes looking for writes to the vram at the locations where the font ends up in order to find out what  code is doing the decompression. According the bg/sprite viewer the font occupies 0x1210 to 0x2ff0 in vram.

I'll see if I can trace what is decompressing and loading the font.

megatron-uk

  • Full Member
  • ***
  • Posts: 219
Re: Cyber Knight assets (tiles/text)
« Reply #4 on: February 05, 2014, 10:45:43 AM »
Well I think I found the code thats clearing vram before the copy:

Code: [Select]
EAD3    SEI
EAD4    STX $0002
EAD7    STX $0003
EADA    CLI
EADB    DEC $34
EADD    BNE $EAD3

This seems to be running for the entire vram region, so I presume it's clearing it before writing sprite/tile/font data. Still looking for the font decompressor, off to peeps now though.

John

megatron-uk

  • Full Member
  • ***
  • Posts: 219
Re: Cyber Knight assets (tiles/text)
« Reply #5 on: February 05, 2014, 09:33:39 PM »
So it appears as though the ASCII used in the game is stored clear in the rom - the phrases I've found in English so-far:

"CYBER KNIGHT" - In the title bar of the (dreadful!) blue start screen (seriously? could they not do a better effort than that?) appears three times in the rom (once in the header, once misspelled as 'CYBER NIGHT' and once more for the title screen) and when edited to other ASCII codes represented by the included font is reflected in that screen.

"MAX!" - Appears in one of the dialogue boxes from the crew during the intro while the ship is under attack and is present in the rom exactly once; having briefly played the SNES translation I think it refers to 'Hyperdrive now charged at MAX!' or something similar.

Judging from the control codes embedded in some of the text strings I'm also guessing that 043c is the flashing 'more text' graphic that appears at the end of dialogue boxes a that sequence is very heavily used.

There's also the name of the ships computer "Mica", which occurs quite regularly throught the rom.

Also another point - when you create a new character the name of the player you create is stored as a plain ASCII or single-char Japanese representation at 0x2400 in main memory.

With that, although we don't have a font to extract (yet) because of the encoding (and, actually as it already has full upper and lower case western characters with punctuation, we wouldn't necessarily need to replace it), I should at least be able to make a start doing a table of characters to font tiles (as at least the western font tiles are sequential).

I guess what I'm trying to say is that although the graphic assets appear encoded in some fashion, the text itself now doesn't appear to be.
« Last Edit: February 05, 2014, 09:54:30 PM by megatron-uk »

megatron-uk

  • Full Member
  • ***
  • Posts: 219
Re: Cyber Knight assets (tiles/text)
« Reply #6 on: February 05, 2014, 10:41:26 PM »
... and I think that that the code 0x52 switches between character sets - as it occurs right before and right after any ASCII text (when that text has Japanese characters before or after it), so it must be interpreted as a char mode toggle.

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: Cyber Knight assets (tiles/text)
« Reply #7 on: February 06, 2014, 03:33:21 AM »
Yeah, if the font has everything you need - you could leave it as is. But you will need a vram dump of it, and need to identify all those japanese characters, so when you dump the game script you'll now what char is one is referring to (I usually do a small table to convert the game JP chars to SJIS and write them to a doc/txt file). JWPCE will read plain text files with SJIS chars (and ascii as well). Just use the .SJIS extension instead of the .TXT

megatron-uk

  • Full Member
  • ***
  • Posts: 219
Re: Cyber Knight assets (tiles/text)
« Reply #8 on: February 06, 2014, 03:59:03 AM »
Well I've got the vram screenshot of all the western and single tile Japanese characters and have now divided into a grid so that I can (slowly) go through it and identify all the characters and recheck that key phrases I've been looking at in Windhex start to look correct with the new table added. This bit is going to be slow...

I think the some of the control codes in the text strings are to switch to/from double width/byte characters as the second screen dump from Mednafen, further down the vram memory map, shows some Kanji and 'large' fonts. But it's not sequential like the first font set. You can see that you get the top half of one set of characters in one row, then the top half of the next, then the bottom of the first half, then the bottom of the second set.
« Last Edit: February 06, 2014, 04:03:09 AM by megatron-uk »

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: Cyber Knight assets (tiles/text)
« Reply #9 on: February 06, 2014, 04:22:22 AM »
Ahh, I see. There's another approach I've seen over at RHDN. First, you have to find the main print routine and figured out the smallest and largest character values. Then you take that vram dump and write an app that goes through the entire valid character range, and spit out the vram assembled graphics to a bitmap file. Then present the file to RHDN or whatever translation site, and request an identification of said chars.

 Of course, you can do this without writing an app, but it's slower. You save state the emulator, over-write the corresponding text string with sequential values, and take visual snap shots of each set of sequential output to the text box.


 As far as the font itself, assuming you want to change it, you can always expand the rom and write a hook to monitor font decompression routine (because it could be used for more than just the font) and jump to alt code that updates vram with your new font. No need to decompress the old one and re-compress a new one.
« Last Edit: February 06, 2014, 04:24:24 AM by Bonknuts »

megatron-uk

  • Full Member
  • ***
  • Posts: 219
Re: Cyber Knight assets (tiles/text)
« Reply #10 on: February 06, 2014, 04:41:59 AM »
I would probably just keep the font as-is, but expanding the rom image is a good idea. It would be nice to jazz up that main menu screen and some of the dialogue box bezel images.

To be honest, about 50% of what you've just said is probably over my head :mrgreen: but I'll keep plugging away to create this table in the first instance :)

Edit: actually, just looking at that second set of fonts, I bet it's only used in the in-game menus as it certainly matches the menu options I've seen in the game so-far.
« Last Edit: February 06, 2014, 04:53:55 AM by megatron-uk »

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: Cyber Knight assets (tiles/text)
« Reply #11 on: February 06, 2014, 04:52:08 AM »
Have you done this type of translation hacking before? If this is your first project, it just takes a little bit of time to get used to all of this. Lol - after your first project is done, you feel like you can translate any game at that point - haha.

 If the script is uncompressed, then that makes this twice or three times as easy as a compressed script game. I really hate Huffman compression :P Necro-whatever PCE game uses it. I took a look at it for a hacker over at RHDN, because they're trying to translate the game. I really didn't want to write the decompressor... ugh. Dunno - something about huffman (binary trees) that I never liked/clicked with me (LZSS for me alllll day). If you talk to MooZ, see if he's interested in dumping the script to Necro-whatever for PCE. There's already a group waiting on the script. I have my notes, somewhere around here...

 That aside, have you thought about upgrading any of the graphics? They're probably in 2bit/3bit format. If you expand the rom, you could hook the character/sprite upload routine to upload upgraded 4bit versions of the graphics. A LOT of early hucard games used simple 1/2/3bit graphic formats, because there is no decompression resource penalty (planar graphics) and can be uploaded to vram on the fly without decompressing to a buffer first.

megatron-uk

  • Full Member
  • ***
  • Posts: 219
Re: Cyber Knight assets (tiles/text)
« Reply #12 on: February 06, 2014, 05:05:39 AM »
Have you done this type of translation hacking before? If this is your first project, it just takes a little bit of time to get used to all of this. Lol - after your first project is done, you feel like you can translate any game at that point - haha.

I haven't done any hacking before :D

I did a lot of Unix systems programming (C, Posix threads, OS design, that kind of stuff) about 15 years ago at University, but the last proper C/systems-programming was probably about 10 years ago.

The everdrive-fat code is the first bit of decent coding I've done for a long time (and I'm enjoying it again!); I'm a Unix systems manager in my day-job so the kind of stuff I do on a daily basis tends to be shell scripting, Python, Ruby, maybe a bit of Java. But the programming side of it is just a tiny bit (just enough to keep my skills from going rusty) it's mainly managing virtual machines, doing dba work, designing middleware libraries etc. Nothing as low level as this! :lol:

I think this is one that's definitely worth persevering with - the script is already translated via the SNES and everyone really rates the game.

Graphical upgrades would be the icing on the cake - the SNES version already has some better in-game sprites (although the ship navigation screens look nicer on the PCE, imo) and I would oh-so-love to put a snazzy mecha background on that menu screen 8)

Xak

  • Hero Member
  • *****
  • Posts: 720
Re: Cyber Knight assets (tiles/text)
« Reply #13 on: February 06, 2014, 05:57:10 AM »
Very very interesting topic. thank you for posting and keep us updated.
Im a real life Sadler, just take me to the nearest item shop.

I have aspergers, and am a recovering Tonicholic

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: Cyber Knight assets (tiles/text)
« Reply #14 on: February 06, 2014, 06:23:21 AM »
Quote
I haven't done any hacking before :D

 Well, looks like you have a knack for it then.

 Both MooZ and I have a few PCE translation works under our belt. Feel free to ask questions if you get stuck.

Quote
Nothing as low level as this! :lol:

It's not so bad. PCE arch' is fairly straight forward/clean compared to some other systems. Mednafen is a pretty powerful debugger, once you get the hang of it.

Quote
Graphical upgrades would be the icing on the cake - the SNES version already has some better in-game sprites (although the ship navigation screens look nicer on the PCE, imo) and I would oh-so-love to put a snazzy mecha background on that menu screen 8)

Let me know when you get to that point. I can definitely help out there (I have a lot of experience with writing hook code for loading alternate stuffs, for PCE related games).