summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRangi <remy.oukaour+rangi42@gmail.com>2020-09-13 19:56:55 -0400
committerRangi <remy.oukaour+rangi42@gmail.com>2020-09-13 19:56:55 -0400
commit24efa227b1f3934660d29ab5c930ec167079f5f1 (patch)
tree684a892dfdecd00560a9045e19ddef476a574150
parent8e7d7737aba30506c2689d3ba422c5c8c5785b44 (diff)
Disassemble the decompression routine
-rw-r--r--shim.sym5
-rw-r--r--source/bank_00.asm65
-rw-r--r--source/bank_28.asm20
3 files changed, 90 insertions, 0 deletions
diff --git a/shim.sym b/shim.sym
index c7960a2..57a56fd 100644
--- a/shim.sym
+++ b/shim.sym
@@ -59,6 +59,10 @@
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
@@ -88,6 +92,7 @@
00:c318 w_farcall_target_high
00:c31e w_bank_temp ; db
+00:c300 w_c300
00:c301 w_c301
00:c314 w_c314
00:c316 w_c316
diff --git a/source/bank_00.asm b/source/bank_00.asm
index ae4a7cb..21d3160 100644
--- a/source/bank_00.asm
+++ b/source/bank_00.asm
@@ -1472,6 +1472,71 @@ text_draw_char:
ld a, e
ret
+SECTION "decompress", ROM0[$20cf]
+decompress::
+; Parameters:
+; hl - source
+; de - dest
+; bc - length (not the actual source or dest length)
+ ld [w_bank_temp], a
+ ld a, [w_bank_rom]
+ push af
+ ld a, [w_bank_temp]
+ ld [w_bank_rom], a
+ ld [rROMB0], a
+
+ xor a
+ ld [w_c300], a
+
+.main_loop
+ push bc
+ ld a, [hl+]
+ bit 7, a
+ jr nz, .alternating
+
+; uses the next a + 1 bytes of compressed data
+; to output a + 1 bytes of decompressed data
+ inc a
+ ld c, a
+ ld a, [w_c300]
+.seq_loop
+ xor [hl]
+ ld [de], a
+ inc hl
+ inc de
+ dec c
+ jr nz, .seq_loop
+ ld [w_c300], a
+ jr .next
+
+; uses the next one byte of compressed data
+; to output a - $7e bytes of decompressed data,
+; alternating between two different values
+.alternating
+ sub $7e
+ ld c, a
+ ld a, [w_c300]
+.alt_loop
+ xor [hl]
+ ld [de], a
+ inc de
+ dec c
+ jr nz, .alt_loop
+ ld [w_c300], a
+ inc hl
+
+.next
+ pop bc
+ dec bc
+ ld a, c
+ or b
+ jr nz, .main_loop
+
+ pop af
+ ld [w_bank_rom], a
+ ld [rROMB0], a
+ ret
+
SECTION "function_00_24b7", ROM0[$24b7]
function_00_24b7::
xor a
diff --git a/source/bank_28.asm b/source/bank_28.asm
new file mode 100644
index 0000000..d798744
--- /dev/null
+++ b/source/bank_28.asm
@@ -0,0 +1,20 @@
+INCLUDE "hardware.inc"
+INCLUDE "macros.inc"
+
+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 de, _VRAM8800
+ ld bc, 182
+ call decompress
+ ld a, BANK(compressed_tilemap_6c_7eec)
+ ld hl, compressed_tilemap_6c_7eec
+ ld de, _SCRN0
+ ld bc, 82
+ call decompress
+ call function_00_1085
+ ; TBC