diff options
author | Rangi <remy.oukaour+rangi42@gmail.com> | 2020-09-13 21:07:34 -0400 |
---|---|---|
committer | Rangi <remy.oukaour+rangi42@gmail.com> | 2020-09-13 21:08:19 -0400 |
commit | 21fd7b8e92234b80cba34a9f6d8924e81a7ed313 (patch) | |
tree | 03240e6f2b78df2f477b940cc829dda3e39bb9ac | |
parent | 9917c84446978af1604599d66916eecc81008b9f (diff) |
Start decompressing data (to do: implement a compressor)
-rw-r--r-- | gfx/copyright/copyright.bin.xor | bin | 0 -> 715 bytes | |||
-rw-r--r-- | gfx/copyright/copyright.png | bin | 0 -> 477 bytes | |||
-rw-r--r-- | gfx/copyright/copyright.tilemap | bin | 0 -> 1024 bytes | |||
-rw-r--r-- | gfx/copyright/copyright.tilemap.xor | bin | 0 -> 234 bytes | |||
-rw-r--r-- | shim.sym | 4 | ||||
-rw-r--r-- | source/bank_28.asm | 12 | ||||
-rw-r--r-- | source/bank_6c.asm | 4 | ||||
-rw-r--r-- | source/bank_75.asm | 5 | ||||
-rw-r--r-- | tools/dump_decompress.py | 33 |
9 files changed, 48 insertions, 10 deletions
diff --git a/gfx/copyright/copyright.bin.xor b/gfx/copyright/copyright.bin.xor Binary files differnew file mode 100644 index 0000000..463037b --- /dev/null +++ b/gfx/copyright/copyright.bin.xor diff --git a/gfx/copyright/copyright.png b/gfx/copyright/copyright.png Binary files differnew file mode 100644 index 0000000..d18739b --- /dev/null +++ b/gfx/copyright/copyright.png diff --git a/gfx/copyright/copyright.tilemap b/gfx/copyright/copyright.tilemap Binary files differnew file mode 100644 index 0000000..4e41767 --- /dev/null +++ b/gfx/copyright/copyright.tilemap diff --git a/gfx/copyright/copyright.tilemap.xor b/gfx/copyright/copyright.tilemap.xor Binary files differnew file mode 100644 index 0000000..1156fd6 --- /dev/null +++ b/gfx/copyright/copyright.tilemap.xor @@ -59,10 +59,6 @@ 3c:4377 function_3c_4377 -6c:7eec compressed_tilemap_6c_7eec - -75:7d35 compressed_gfx_75_7d35 - 7b:41e0 gfx_blank_char 00:a03e s_a03e diff --git a/source/bank_28.asm b/source/bank_28.asm index d798744..e5d96fe 100644 --- a/source/bank_28.asm +++ b/source/bank_28.asm @@ -6,15 +6,15 @@ SECTION "function_28_426a", ROMX[$426a], BANK[$28] function_28_426a:: ld a, $01 ld [w_d6b5], a - ld a, BANK(compressed_gfx_75_7d35) - ld hl, compressed_gfx_75_7d35 + ld a, BANK(compressed_gfx_copyright) + ld hl, compressed_gfx_copyright ld de, _VRAM8800 - ld bc, 182 + ld bc, $b6 call decompress - ld a, BANK(compressed_tilemap_6c_7eec) - ld hl, compressed_tilemap_6c_7eec + ld a, BANK(compressed_tilemap_copyright) + ld hl, compressed_tilemap_copyright ld de, _SCRN0 - ld bc, 82 + ld bc, $52 call decompress call function_00_1085 ; TBC diff --git a/source/bank_6c.asm b/source/bank_6c.asm new file mode 100644 index 0000000..d6f5816 --- /dev/null +++ b/source/bank_6c.asm @@ -0,0 +1,4 @@ +SECTION "compressed_tilemap_copyright", ROMX[$7eec], BANK[$6c] +compressed_tilemap_copyright:: +INCBIN "gfx/copyright/copyright.tilemap.xor" +.end:: diff --git a/source/bank_75.asm b/source/bank_75.asm index 0862024..a23a85e 100644 --- a/source/bank_75.asm +++ b/source/bank_75.asm @@ -23,3 +23,8 @@ INCBIN "gfx/levels/lv_5_pokemon_tower_sgb.bin" gfx_lv_5_pokemon_tower_duplicate:: INCBIN "gfx/levels/lv_5_pokemon_tower.bin" .end:: + +SECTION "compressed_gfx_copyright", ROMX[$7d35], BANK[$75] +compressed_gfx_copyright:: +INCBIN "gfx/copyright/copyright.bin.xor" +.end:: diff --git a/tools/dump_decompress.py b/tools/dump_decompress.py new file mode 100644 index 0000000..2776c2b --- /dev/null +++ b/tools/dump_decompress.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 + +# Usage: ./dump_decompress.py 75:7d35 00b6 >compressed.bin 2>decompressed.bin + +from sys import argv, stdout, stderr + +file = open("DMGAKVJ0.1", "rb").read() + +bank_addr = argv[1].split(':') +bank = int(bank_addr[0], 16) +addr = int(bank_addr[1], 16) +length = int(argv[2], 16) +offset = bank * 0x4000 + addr - (0x4000 if bank else 0) + +output = [] +i = offset +v = 0x00 +for _1 in range(length): + byte = file[i] + i += 1 + if byte < 0x80: + for _2 in range(byte + 1): + v ^= file[i] + output.append(v) + i += 1 + else: + for _2 in range(byte - 0x7e): + v ^= file[i] + output.append(v) + i += 1 + +stdout.buffer.write(bytes(file[offset:i])) # compressed +stderr.buffer.write(bytes(output)) # decompressed |