Wikifang:Telefang 1 Translation Patch/NatsumeGB compression/ASM: Difference between revisions
Jump to navigation
Jump to search
(Created page with "<pre>; MALIAS DECOMPRESSION ROUTINE START ; bc = index of graphics to load ROM0:0C39 C5 push bc ; \ ROM0:0C3A D1 pop de ; | ROM0:0C...") |
m (Sanky moved page Wikifang:Telefang 1 Translation Patch/Malias compression/ASM to Wikifang:Telefang 1 Translation Patch/NatsumeGB compression/ASM: naming a compression algorithm after the person who first cracked it is passé) |
||
(No difference)
|
Latest revision as of 08:10, 16 November 2020
; MALIAS DECOMPRESSION ROUTINE START ; bc = index of graphics to load ROM0:0C39 C5 push bc ; \ ROM0:0C3A D1 pop de ; | ROM0:0C3B 21 00 40 ld hl,4000 ; | Get pointer offset ROM0:0C3E CB 23 sla e ; | ROM0:0C40 CB 12 rl d ; | ROM0:0C42 CB 23 sla e ; | ROM0:0C44 CB 12 rl d ; | ROM0:0C46 19 add hl,de ; / ROM0:0C47 2A ldi a,(hl) ; \ Bank ROM0:0C48 EA 4E C4 ld (C44E),a ; / ROM0:0C4B 2A ldi a,(hl) ; \ ROM0:0C4C EA 50 C4 ld (C450),a ; | Offset to decompress *to* ROM0:0C4F 7E ld a,(hl) ; | ROM0:0C50 EA 51 C4 ld (C451),a ; / ROM0:0C53 FA 4E C4 ld a,(C44E) ; \ Bankswitch ROM0:0C56 D7 rst 10 ; / ROM0:0C57 21 E1 1D ld hl,1DE1 ; \ ROM0:0C5A CB 21 sla c ; | de = (1DE1+bc*2) ROM0:0C5C CB 10 rl b ; | (the compressed graphics ROM0:0C5E 09 add hl,bc ; | offset) ROM0:0C5F 2A ldi a,(hl) ; | ROM0:0C60 66 ld h,(hl) ; | ROM0:0C61 6F ld l,a ; | ROM0:0C62 E5 push hl ; | ROM0:0C63 D1 pop de ; / ROM0:0C64 FA 51 C4 ld a,(C451) ; \ ROM0:0C67 67 ld h,a ; | hl = offset to write to ROM0:0C68 FA 50 C4 ld a,(C450) ; | ROM0:0C6B 6F ld l,a ; / ROM0:0C6C 1A ld a,(de) ; \ ROM0:0C6D 13 inc de ; | If first byte is 0, ROM0:0C6E C3 71 0C jp 0C71 ; [What.] ROM0:0C71 FE 00 cp a,00 ; | skip decompression, it's raw ROM0:0C73 CA 33 0D jp z,0D33 ; * ROM0:0C76 7C ld a,h ; \ ROM0:0C77 EA 06 C4 ld (C406),a ; | ROM0:0C7A 7D ld a,l ; | ROM0:0C7B EA 07 C4 ld (C407),a ; / ROM0:0C7E 1A ld a,(de) ; \ ROM0:0C7F 4F ld c,a ; | Load the total size ROM0:0C80 13 inc de ; | ROM0:0C81 1A ld a,(de) ; | ROM0:0C82 47 ld b,a ; | ROM0:0C83 13 inc de ; | ROM0:0C84 78 ld a,b ; | ROM0:0C85 B1 or c ; | ret if decompressed all bytes ROM0:0C86 CA 4D 0D jp z,0D4D ; * ROM0:0C89 1A ld a,(de) ; \ ROM0:0C8A EA 05 C4 ld (C405),a ; | ROM0:0C8D 13 inc de ; | ROM0:0C8E 1A ld a,(de) ; | ROM0:0C8F EA 04 C4 ld (C404),a ; | ROM0:0C92 13 inc de ; | ROM0:0C93 3E 11 ld a,11 ; | ROM0:0C95 EA 03 C4 ld (C403),a ; / ROM0:0C98 78 ld a,b ; \ ROM0:0C99 B1 or c ; | ret if decompressed all bytes ROM0:0C9A CA 4D 0D jp z,0D4D ; * ROM0:0C9D FA 03 C4 ld a,(C403) ; \ ROM0:0CA0 3D dec a ; | Jump back if read 11 bytes ROM0:0CA1 CA 84 0C jp z,0C84 ; * ROM0:0CA4 EA 03 C4 ld (C403),a ; / ROM0:0CA7 D5 push de ; \ ROM0:0CA8 FA 04 C4 ld a,(C404) ; | \ ROM0:0CAB 57 ld d,a ; | | Is this of de set? ROM0:0CAC FA 05 C4 ld a,(C405) ; | | ROM0:0CAF 5F ld e,a ; | | ROM0:0CB0 CB 3A slr d ; | | ROM0:0CB2 7A ld a,d ; | | ROM0:0CB3 EA 04 C4 ld (C404),a ; | | ROM0:0CB6 CB 1B rr e ; | | ROM0:0CB8 7B ld a,e ; | | ROM0:0CB9 EA 05 C4 ld (C405),a ; | / ROM0:0CBC DA DF 0C jp c,0CDF ; * Jump to mode 1 ROM0:0CBF D1 pop de ; / ROM0:0CC0 FA 06 C4 ld a,(C406) ; \ ROM0:0CC3 67 ld h,a ; | Mode 0: ROM0:0CC4 FA 07 C4 ld a,(C407) ; | Simply copy the next byte. ROM0:0CC7 6F ld l,a ; | ROM0:0CC8 F3 di ; | ROM0:0CC9 CD AA 09 call 09AA ; | ROM0:0CCC 1A ld a,(de) ; | ROM0:0CCD CD AA 09 call 09AA ; | ROM0:0CD0 22 ldi (hl),a ; | ROM0:0CD1 FB ei ; | ROM0:0CD2 7C ld a,h ; | ROM0:0CD3 EA 06 C4 ld (C406),a ; | Write down hl ROM0:0CD6 7D ld a,l ; | ROM0:0CD7 EA 07 C4 ld (C407),a ; | ROM0:0CDA 0B dec bc ; | ROM0:0CDB 13 inc de ; | ROM0:0CDC C3 98 0C jp 0C98 ; * ROM0:0CDF D1 pop de ; * ROM0:0CE0 D5 push de ; | ROM0:0CE1 1A ld a,(de) ; | \ ROM0:0CE2 6F ld l,a ; | | ROM0:0CE3 13 inc de ; | | Get the location ROM0:0CE4 1A ld a,(de) ; | | ROM0:0CE5 E6 07 and a,07 ; | | ROM0:0CE7 67 ld h,a ; | / ROM0:0CE8 1A ld a,(de) ; | \ ROM0:0CE9 CB 3F slr a ; | | ROM0:0CEB CB 3F slr a ; | | Get the number of bytes ROM0:0CED CB 3F slr a ; | | ROM0:0CEF E6 1F and a,1F ; | | ROM0:0CF1 C6 03 add a,03 ; | | ROM0:0CF3 EA 02 C4 ld (C402),a ; | / ROM0:0CF6 7C ld a,h ; | \ ROM0:0CF7 2F cpl ; | | ROM0:0CF8 57 ld d,a ; | | Make the location ROM0:0CF9 7D ld a,l ; | | negative ROM0:0CFA 2F cpl ; | | ROM0:0CFB 5F ld e,a ; | | ROM0:0CFC FA 06 C4 ld a,(C406) ; | | ROM0:0CFF 67 ld h,a ; | | ROM0:0D00 FA 07 C4 ld a,(C407) ; | | ROM0:0D03 6F ld l,a ; | | ROM0:0D04 19 add hl,de ; | | ROM0:0D05 E5 push hl ; | | ROM0:0D06 D1 pop de ; | / ROM0:0D07 FA 06 C4 ld a,(C406) ; | \ ROM0:0D0A 67 ld h,a ; | | ROM0:0D0B FA 07 C4 ld a,(C407) ; | | ROM0:0D0E 6F ld l,a ; | | ROM0:0D0F F3 di ; | | \ ROM0:0D10 CD AA 09 call 09AA ; | | | ROM0:0D13 1A ld a,(de) ; | | | Copy a bytes fro de to hl ROM0:0D14 CD AA 09 call 09AA ; | | | ROM0:0D17 22 ldi (hl),a ; | | | ROM0:0D18 FB ei ; | | | ROM0:0D19 0B dec bc ; | | | ROM0:0D1A 13 inc de ; | | | ROM0:0D1B FA 02 C4 ld a,(C402) ; | | | ROM0:0D1E 3D dec a ; | | | ROM0:0D1F EA 02 C4 ld (C402),a ; | | | ROM0:0D22 C2 0F 0D jp nz 0D0F ; | | / ROM0:0D25 7C ld a,h ; | | ROM0:0D26 EA 06 C4 ld (C406),a ; | | ROM0:0D29 7D ld a,l ; | | ROM0:0D2A EA 07 C4 ld (C407),a ; | / ROM0:0D2D D1 pop de ; | ROM0:0D2E 13 inc de ; | ROM0:0D2F 13 inc de ; | ROM0:0D30 C3 98 0C jp 0C98 ; * ROM0:0D33 1A ld a,(de) ; * \ Uncompressed: ROM0:0D34 4F ld c,a ; | | ROM0:0D35 13 inc de ; | | Load the size in bc ROM0:0D36 1A ld a,(de) ; | | ROM0:0D37 47 ld b,a ; | | ROM0:0D38 13 inc de ; | / ROM0:0D39 78 ld a,b ; | \ ROM0:0D3A B1 or c ; | | Copy bc bytes from de to hl ROM0:0D3B CA 4D 0D jp z,0D4D ; | * ROM0:0D3E F3 di ; | | ROM0:0D3F CD AA 09 call 09AA ; | | ROM0:0D42 1A ld a,(de) ; | | ROM0:0D43 CD AA 09 call 09AA ; | | ROM0:0D46 22 ldi (hl),a ; | | ROM0:0D47 FB ei ; | | ROM0:0D48 13 inc de ; | | ROM0:0D49 0B dec bc ; | | ROM0:0D4A C3 39 0D jp 0D39 ; / / ROM0:0D4D C9 ret ; ***