Author Topic: Hudson tile compression format: Has anyone made a decoder?  (Read 628 times)

ccovell

  • Hero Member
  • *****
  • Posts: 2245
Hudson tile compression format: Has anyone made a decoder?
« on: October 17, 2015, 12:52:02 PM »
Hi, folks.  As the title says, I'm wondering if anyone has made detection/decoding/display software for the tile format in Hudson Soft's HuCard games.  It'd be cool to have (nudge, wink) like the excellent one that the SMS world has:


http://www.smspower.org/maxim/Software/TileDecoder

MooZ

  • Newbie
  • *
  • Posts: 34
Re: Hudson tile compression format: Has anyone made a decoder?
« Reply #1 on: October 19, 2015, 01:11:45 AM »
I have coded a command line tile extractor for Pack-In-Video/Namcot games (zipang, marchen maze, obocchama kun, World Jockey). I don't known if all Hudson Soft games are using the same tile encoding scheme.

Unfortunately,  I'm not an expert in (and not very found of) GUI coding but I can help on the encoding/decoding part.

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: Hudson tile compression format: Has anyone made a decoder?
« Reply #2 on: October 19, 2015, 06:06:56 AM »
I documented Bonk's tile compression scheme, but I don't think I've seen it else where. I've seen similar compression schemes on hucards, but not exactly the same.

spenoza

  • Hero Member
  • *****
  • Posts: 2751
Re: Hudson tile compression format: Has anyone made a decoder?
« Reply #3 on: October 19, 2015, 06:30:31 AM »
I documented Bonk's tile compression scheme, but I don't think I've seen it else where. I've seen similar compression schemes on hucards, but not exactly the same.

Not even the other Atlas-programmed games use it?
<a href="http://www.pcedaisakusen.net/2/34/103/show-collection.htm" class="bbc_link" target="_blank">My meager PC Engine Collection so far.</a><br><a href="https://www.pcenginefx.com/forums/" class="bbc_link" target="_blank">PC Engine Software Bible</a><br><a href="http://www.racketboy.com/forum/" c

ccovell

  • Hero Member
  • *****
  • Posts: 2245
Re: Hudson tile compression format: Has anyone made a decoder?
« Reply #4 on: November 30, 2017, 02:54:51 PM »
A little update:  I decided to look into a couple Hudson games so far to see how they uncompressed their graphics data.  So, I'll post some notes here.  If anybody has any questions or wants to make contributions, please do.

In Bomberman, anyway, BAT maps, Palette data, and BG & SPR tiles all are compressed the same way (but written into VRAM in slightly different ways)

A pic of my Hudson compression decoder inside of PCEmon:


Some notes:
Code: [Select]
Bomberman & Neutopia use the same compression method

Neutopia analysis:

The game maps stuff in at ROM bank $4C, $4D, which are invalid, but...
Game mapping: bank $00-1F. Then 20-2F, repeating.
So banks $4C/$4D are really $2C / $2D.


Bomberman analysis:

$01:A4C0 starts loading tile graphics...

lda #$16, JSR $E377 (BG tiles...)
lda #$0C, JSR $E427 (SPR tiles...)

 Clear BG below:
lda #$20, STA $22BB, JSR $E6A4 (clear MAP with char #$20)

 Decompress BG MAP below:
lda #$03, STA $B4, CLX, LDA #$01, JSR $F5F3...
($B4 appears to be a title Gfx page offset.)
(Acc chooses MAP #)

-$F5F3
 + X -> $8D, #$03 -> $23BC, JSR $E704
 +-- $E704, A*2->X, $23BC -> MPR2
 +-- $E6EC, map in 2 banks pointed to
 | retrieve X->$8D->A
 | STZ $2213, $2215
 +-- $E750 (mangle address write value), write to VRAM
 | both X and Y set to #$1F
 +-- $F63F, decompress, write to VRAM. High byte added with $B4 before write.
 |   in a BPL loop with Y, then VRAM add. inc'ed by $80, then a BPL loop with X
 RTS





-$E377
  +-- $E397
  |    +-- A*2->X, lda $F03E-F,X -> $36-7
  |    <-- sheets 1,2
  |
  +-- $E400
  |
  |
  +-- $E4DC if $2210 is nonzero
  |
  |
  SMB0 $1A (update palette flag)
  RTS

ldx 0/1, lda 1/0, JSR $F5F3... BG MAPs?


$F03E: Master Gfx file pointer table - $23 entries

F0B6,F0BE,F0C6,F0CE,F0D6,F0DE,F0E6,F0EE
F0F6,F0FE,F106,F10E,F116,F11E,F126,F12E
F136,F13E,F146,F14E,F156,F15E,F166,F16E
F176,F17E,F186,F18E,F196,F19E,F1A6,F1AE
F1B6,F1BE,F1C6

$F084: same table, for sprites - $19 entries

F1CE,F1D6,F1DE,F1E6,F1EE,F1F6,F1FE,F206
F20E,F216,F21E,F226,F22E,F236,F23E,F246
F24E,F256,F25E,F266,F26E,F276,F27E,F286
F28E

$F0B6-F295: Master Gfx file data table (8 bytes each)

byte layout
0: Data source table entry # (in bank #$18)
1: X = VRAM Destination: $2000+$X000 (8k boundaries)
2 & 3: VRAM offset to add to Destination above
4: # of 8x8 tiles to write. "00" = 256 tiles.
5: Palette Data source table entry # (in bank #$0F)
6: Start palette # (0-F?)  ?
7: # of palettes to write to RAM buffer.

00,00,00,02,C5, 00,0C,04,
01,00,00,06,3C, 01,0B,01,
02,00,00,06,40, 02,0B,01,
03,01,00,00,60, 03,00,08,
04,01,00,06,20, 05,0A,01,
05,01,00,00,60, 06,00,08,
06,01,00,06,20, 08,0A,01,
07,01,00,00,60, 09,00,08,
08,01,00,06,20, 0B,0A,01,
09,01,00,00,60, 0C,00,08,
0A,01,00,06,20, 0E,0A,01,
0B,01,00,00,60, 0F,00,08,
0C,01,00,06,20, 11,0A,01,
0D,01,00,00,60, 12,00,08,
0E,01,00,06,20, 14,0A,01,
0F,01,00,00,60, 15,00,08,
10,01,00,06,20, 17,0A,01,
11,01,00,00,60, 18,00,08,
12,01,00,06,20, 1A,0A,01,
13,01,00,00,60, 1B,00,08,
14,01,00,06,20, 1D,0A,01,
15,02,00,00,40, 1E,0C,03,
17,01,00,00,9D, 1F,00,05,
16,02,00,00,A9, 1F,00,00,
18,01,00,00,00, 20,00,06,
19,01,00,00,6D, 21,00,03,
1A,00,00,04,7B, 22,0E,02,
1B,01,00,00,00, 23,00,04,
1C,02,00,00,40, 23,00,00,
1D,02,00,04,94, 24,07,01,
1E,01,00,00,A0, 25,00,02,
1F,01,00,00,DF, 26,00,0E,
20,02,00,00,7B, 26,00,00,
21,02,00,00,93, 26,00,00,
22,02,00,00,9D, 26,00,00,

notice 16 and 17 are swapped above...




Sprite data table byte layout
0: Data source table entry # (in bank #$10)
1: X = VRAM Destination: $2000+$X000 (8k boundaries)
2 & 3: VRAM offset to add to Destination above
4: # of 16x16 tiles to write. "00" = NOTHING!
5: Palette Data source table entry # (in bank #$0E)
6: Start palette # (0-F?)  ?
7: # of palettes to write to RAM buffer.


00,03,00,00,40, 00,1C,04,
01,05,00,00,3F, 01,18,04,
02,04,00,00,1F, 02,10,07,
03,04,00,00,1F, 03,10,07,
04,04,00,00,26, 04,10,07,
05,04,00,00,2A, 05,10,07,
06,04,00,00,21, 06,10,07,
07,04,00,00,3A, 07,10,07,
08,04,00,00,1C, 08,10,07,
09,04,00,00,20, 09,10,07,
0A,04,00,00,40, 0A,10,07,
0B,05,00,00,20, 0A,18,00,
0C,04,00,00,31, 0B,13,02,
0D,05,00,00,40, 0C,11,02,
0E,04,00,00,40, 0D,11,06,
0F,05,00,00,40, 0D,11,00,
10,04,00,00,11, 0E,10,03,
11,04,00,00,30, 0F,10,03,
12,05,00,00,40, 10,17,05,
13,04,00,00,39, 11,10,0B,
14,02,00,04,10, 00,1C,00,
15,02,00,08,20, 12,17,01,
16,04,00,04,15, 13,10,02,
17,04,00,00,08, 14,10,06,
18,05,00,00,12, 15,10,03



$18:4000: BG Gfx data pointer table - $23 entries
Offset is from $4000 in bank $18 (to $1F).

4046,45E7,48E0,4C74,526E,554B,5DED,606E,
67FC,6A98,75A1,7874,7FF9,8329,88E7,8BE5,
909B,9317,996E,9D32,9E8C,9FF1,A749,B3F5,
C091,CFF4,D811,DB50,F37E,FA02,FFC6,09F4,
1C0A,2318,2FBD

Offset of $4000 is removed from data pointers
before handling their banks, so apparent overflow doesn't matter.


$10:4000: SPR Gfx data pointer table - $19 entries
Offset is from $4000 in bank $10 (to $17).

4032,4DBD,5E92,684D,7167,7E63,8BAE,94F8,
A1CC,A967,B0AB,BFE1,C799,D453,DD7C,EC2E,
FDAA,004B,0CAF,19E2,299E,2B04,3162,3799,
393B


Palette offset table for the BG, bank $0F

404E,406D,408F,40B0,4127,4154,4172,4209,
423A,425C,42D3,4303,4320,4391,43BE,43D4,
4455,4484,449C,4527,4554,4575,45F1,461E,
4637,46AE,46DB,46FC,4736,4763,4785,47D8,
4861,48EE,492A,4954,49C4,49DF,4A15


Palette offset table for SPR, bank $0E

402C,407C,40E6,4145,41BF,4227,4286,42D9,
4339,437D,43C5,4455,448B,44C4,4545,458A,
45D2,4622,46E0,46F4,472F,47AF

BAT (MAP) offset table, bank $03

4020,4255,44A7,479E,4906,4AFA,4DB0,5177,
5296,53B5,5554,56CB,5816,5A27,5B66,5CF9

esteban

  • Hero Member
  • *****
  • Posts: 24063
Re: Hudson tile compression format: Has anyone made a decoder?
« Reply #5 on: December 08, 2017, 12:14:00 PM »
:)

  |    |