+  RHDN Forum Archive
|-+  Romhacking
| |-+  ROM Hacking Discussion
| | |-+  ASM Help Needed with Shi Kin Jou (Compressed Graphics)
Pages: [1]
Author Topic: ASM Help Needed with Shi Kin Jou (Compressed Graphics)  (Read 2 times)
InVerse
Guest
« on: December 17, 2007, 01:18:25 pm »

I finally sat down and played through all 150 stages of Shi Kin Jou and discovered that there is are a couple of untranslated THE END type graphics. I would like to translate these, as well as the title screen, but there's a bit of a problem with the graphics being compressed. Here's a snippet from the original readme that explains the problems I had dealing with the font:

Quote
The font in this game is oddly compressed. It shows up clearly in Nesticle but
there's no VRAM so I couldn't hack it that way. When you look at it in a tile
editor, the font is hopelessly scrambled in NES mode and in 1Bpp mode there are
duplicates of each tile. I also tried viewing the font in 2Bpp on someone's
suggestion but it was still scrambled.
   What I eventually figured out was that by moving the alignment around in
Tile Layer, I could isolate individual characters and then edit the character
as long as the new tile didn't use anymore color 1 "dots" than the original
tile did. Also, for some odd reason, the font would become corrupt if I
inserted any tiles that had exactly 5 "dots" on both the right and left sides.
More or less on either side and it was fine but 5 on each caused a problem.
     Well, as you can see, I eventually got all of the tiles I needed inserted.
This was possibly the most frustrating hack I've ever done but I'm proud to say
that I managed to do it on my own and you can see the results for yourself.

Now, all the text is translated, so there's no need to deal with it, but I would like to translate the aforementioned title/ending graphics. If anyone is interested in looking into this, I can provide a save state (FCE Ultra) that will allow you to access the ending graphics.

I would really like to include an update to this translation as part of the relaunch of my site (which will be, at least, several weeks away) so if anyone would be willing to tackle this issue, I would greatly appreciate it.
Disch
Guest
« Reply #1 on: December 17, 2007, 05:40:11 pm »

I'm not very busy today -- and I think I may be in the mood to take a gander at this.

A savestate for the ending would be nice.  In the meantime I'll look at the font's compression in the likely event that the game uses the same compression scheme for the graphics in question.

*me takes a piss, then opens the ROM*

EDIT --

The graphics compression routine I found (looks like it starts at offset 0x1D855) looks like it is a form of basic RLE with various control codes.  $99, $AA, $BB, $CC, $DD and $EE are control codes indicating the decompressor to do something special (like output a run of bytes).  Other bytes are stored normally.

This is probably why you were having trouble before -- you probably had one of those control codes in your image and it was borking the works.  I've deciphered what all the control codes do but one of them still puzzles me so I'm going to look at it further before giving details.

More to come.


EDIT 2 --

I couldn't figure this last bit out from the intro sequence, so it doesn't look like it applies to text decompression.  I find it unlikely that it applies to ending graphic questions -- but you never know.  Anyway here's what I have so far:

$99, $AA, $BB, $CC, $DD, $EE are control codes.  Following the control code is one or more bytes indicating additional info for the control.  Other bytes not part of the control code are output normally (not compressed).

$99:  output a byte normally.  "99 63"  would output "63".  This is so you can output bytes that are normally control codes.

$AA:  run of byte at address $93.  I don't know what is put at $93 (this is what I couldn't figure out).  At any rate, "AA 05" will output the byte at $93 five times (so if $93 contained, say, $11, this would output 11 11 11 11 11)

$BB:  run of $00.  "BB 05" would output five 00's

$CC:  run of $FF.  As you'd expect

$DD:  run of specified value.  "DD 43 05" outputs $43 five times

$EE:  termination marker.  Marks end of compressed data (decompression routine exits upon reaching this byte).


A run length of 00 would actually be a run of 256


I did not bother locating any actual compressed text or pointer tables, so I don't know how they're constructed.


Other misc notes you probably don't care about:

Looks like the routine starts at 0x1D81C.  X and Y are backed up on routine entry and restored on routine exit.  If $1A is nonzero, the game seems to jump to a seperate routine which does something pretty weird instead of the normal decompression routine.

Input for routine is:
$0010,$0011 -> source address (CPU address) -- ie:  pointer to start of text graphics placed here
$0012,$0013 -> destination address (PPU address) -- ie:  where to put decompressed graphics in PPU space
$001A -> determines whether to do the RLE routine or the wacky routine


Wacky routine ($1A nonzero) skips over the usual RLE decompression and simply reads exactly $60 bytes from the given source pointer.  It outputs the first $20 at the dest address, the next $20 at dest address + $0100, and the last $20 at dest+$0200.  Data is a straight copy -- no compression involved.  I have no idea what this routine would be for -- it seems kind of ridiculous.  It might be for some nametable drawing crap or something.
« Last Edit: December 17, 2007, 06:52:26 pm by Disch »
KingMike
Guest
« Reply #2 on: December 17, 2007, 11:09:25 pm »

That compression is EXACTLY like Dungeon Kid (a first-person-RPG maker by Quest), of which there is a compression kit (with C source) I wrote already posted here. I didn't include $AA, since it was RAM-dependant.
Disch
Guest
« Reply #3 on: December 18, 2007, 12:19:48 pm »

This?  Awesome.  Saves me the trouble of writing a compressor.  :thumbsup:

In that event I'm going to stop putting time into this.  InVerse -- if you want that titlescreen arrangement and that other stuff you talked about you'll have to find it yourself.  Now that the compression issues are solved I lack the interest to do any more fiddling.
KingMike
Guest
« Reply #4 on: December 18, 2007, 01:56:30 pm »

Now that I look at the compression code, it could use some cleanup.
There is a bunch of hardcoded data.
(the decompressor expects the ROM to be named "dunkidj.nes", and the compressor used hard-coded filenames as input/output, and offsets)
So, it's probably not as useful.
Not sure how I could add support for the $AA control code (IIRC, DK never actually used it in the graphics I ripped.)
Perhaps a prompt asking the user which value to use, leaving it to the user to find out what it should be (since of course, RAM is determined while the game runs)?


Alright, here is an updated version, with the hard-coded parts changed, and I changed the offset prompts to take hex input. See if this helps.
« Last Edit: December 18, 2007, 10:52:11 pm by KingMike »
Neil
Guest
« Reply #5 on: January 02, 2009, 08:45:36 am »

-necrobump to save a thread from the great board prune of 2009-
Pages: [1]  


Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC