Post by flow on Dec 4, 2011 17:04:57 GMT -5
Hey Mop, still remember me?
A) Boss gfx decrompression:
What the game does
1) read pointers for compressed tiles.
2) write compressed data from ROM via blockmove to WRAM
3) decompress and directly write them with $2118/$2119 in VRAM
get boss tile data:
Decompression starts at $C2/2636
Some ugly java code for decrompression:
Examples:
First block compressed:
5B (length)
Uncompressed:
More Examples:
If I have more time, I will add more to this thread.
Cheers ;D
A) Boss gfx decrompression:
What the game does
1) read pointers for compressed tiles.
2) write compressed data from ROM via blockmove to WRAM
3) decompress and directly write them with $2118/$2119 in VRAM
get boss tile data:
$C2/260C BF 52 BC D0 LDA $D0BC52,x[$D0:BC8A] A:0038 X:0038 Y:001A P:envmxdIzc
$C2/2610 85 95 STA $95 [$00:0295] A:00DB X:0038 Y:001A P:envmxdIzc
$C2/2612 85 9D STA $9D [$00:029D] A:00DB X:0038 Y:001A P:envmxdIzc
$C2/2614 BF 54 BC D0 LDA $D0BC54,x[$D0:BC8C] A:00DB X:0038 Y:001A P:envmxdIzc
$C2/2618 85 97 STA $97 [$00:0297] A:8E86 X:0038 Y:001A P:eNvmxdIzc
$C2/261A BF 56 BC D0 LDA $D0BC56,x[$D0:BC8E] A:8E86 X:0038 Y:001A P:eNvmxdIzc
$C2/261E 85 99 STA $99 [$00:0299] A:6200 X:0038 Y:001A P:envmxdIzc
$C2/2620 BF 58 BC D0 LDA $D0BC58,x[$D0:BC90] A:6200 X:0038 Y:001A P:envmxdIzc
$C2/2624 85 9B STA $9B [$00:029B] A:1400 X:0038 Y:001A P:envmxdIzc
$C2/2626 A0 00 60 LDY #$6000 A:1400 X:0038 Y:001A P:envmxdIzc
$C2/2629 A6 97 LDX $97 [$00:0297] A:1400 X:0038 Y:6000 P:envmxdIzc
$C2/262B A9 7F 00 LDA #$007F A:1400 X:8E86 Y:6000 P:eNvmxdIzc
Decompression starts at $C2/2636
Some ugly java code for decrompression:
public class DecompBoss {
int now, last, code, decompByte;
int[] data;
int[] decomp;
public void setData(int[] data){
this.data = data;
}
public void decomp(int length){
decomp = new int[length];
now = 0;
last = 0;
decompByte = 0;
for(int dataByte=0; data.length > dataByte; dataByte++) {
code = data[dataByte];
System.out.println("Decompress code:"+code);
for(int counter = 0;counter < 8; counter++) {
code = code * 2;
if (code > 255) {
dataByte++;
code = code-256;
decomp[decompByte] = data[dataByte];
last = now;
now = data[dataByte];
} else {
decomp[decompByte] = last;
last = now;
now = decomp[decompByte];
}
decompByte++;
}
}
}
public void out(){
System.out.println(" ");
for(int x=0; decomp.length > x; x++) {
if(x % 16 == 0){
System.out.println(" ");
}
System.out.print(Integer.toHexString(decomp[x])+" ");
}
System.out.println(" ");
}
}
Examples:
First block compressed:
5B (length)
0B 01 03 01 FF 06 02 0D 04 1B 08 16 01 C2 00 00
01 FF 02 01 04 03 08 07 00 0F FF 1E 00 F3 12 86
84 26 04 8F F6 16 E4 12 E0 FF 00 00 12 0C 84 78
04 F8 03 00 FC 4B 00 0F 11 07 FF 33 0F 79 39 63
20 EF 6F C3 00 00 0E 0F F9 1F 1F 07 3F 1F 7F CA
00 00 E0 58 F7 14 A0 CA F0 D0 E6 68
Uncompressed:
00 00 00 00 01 00 03 01 06 02 0D 04 1B 08 16 01
00 00 00 00 00 00 01 00 02 01 04 03 08 07 00 0F
1E 00 F3 12 86 84 26 04 F6 04 F6 04 16 E4 12 E0
00 00 12 0C 84 78 04 F8 04 F8 04 F8 04 F8 00 FC
00 00 00 00 0F 00 11 07 33 0F 79 39 63 20 EF 6F
00 00 00 00 00 00 0E 0F 1F 1F 07 3F 1F 3F 1F 7F
00 00 00 00 E0 00 58 00 14 A0 CA F0 CA D0 E6 68
More Examples:
2B
( ) E0E0 (F0) F8F8FCFC
(EF) 0F0073801FFF03 (E0) 030000
(17) 0F7F0303 (C0) 0000
(BF) FCC70419E1C6F8 (FF)E37C791E190E0906
000000000000E0E0 F8F8FCFCFCFCFCFC
0F007300801FFF03 0300000000000000
0000000F007F0303 0000000000000000
FC00C70419E1C6F8 E37C791E190E0906
---------------------------------
2C
( ) 04F801FEC0FF (FF) 607F181F080F0007
(6F) 0080C0806040 (FE) 30209810CC0084
(8B) 00804080 (FD) 20C010E000F0F8
000004F801FEC0FF 607F181F080F0007
00008000C0806040 30209810CC008400
0000000080004080 20C010E000F000F8
---------------------------------
05
(2F) 183E182706
0000000000000000 0000000000000000
0000000000000000 0000000000000000
0000000000000000 000018003E182706
If I have more time, I will add more to this thread.
Cheers ;D