Skip to content

Commit

Permalink
Use uncap decompressor
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperDisk committed Feb 6, 2022
1 parent c85e2ca commit e505b26
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 233 deletions.
11 changes: 7 additions & 4 deletions hUGEDriver.asm
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,7 @@ ENDC
pop de
ld hl, order4
ld bc, pattern4_buf
call .load_pattern

ret
;; fallthrough

.load_pattern:
ld a, [hl+]
Expand All @@ -272,7 +270,12 @@ ENDC
inc hl
ld d, [hl]

call UNAPACK
ld h, d
ld l, e
ld d, b
ld e, c

call uncap

ret

Expand Down
229 changes: 0 additions & 229 deletions unapack.asm

This file was deleted.

36 changes: 36 additions & 0 deletions uncap.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
; resourced by tmk
; visit Game Boy Compression Playground at https://github.com/gitendo/gbcp for more
; Mega Man Xtreme 2 (USA, Europe).gbc uses exactly the same routine

SECTION "Uncap Decompressor", ROM0

uncap::
ld a,[hl+] ; start with token
and a ; 0 marks the end of packed data
ret z
bit 7,a ; next byte is offset if 7th bit is set
jr z,_literals ; literals come next otherwise
and $7F ; bits 0 - 6 define reference length
ld c,a ; move length to c(ounter)
ld a,[hl+] ; load offset
push hl ; store packed data address
ld l,a ; offset is negative because game boy cpu lacks
ld h,$FF ; sub hl,de :)
add hl,de ; locate reference
_1:
ld a,[hl+] ; and copy it
ld [de],a
inc de
dec c
jr nz,_1
pop hl ; restore packed data address
jr uncap ; continue
_literals:
ld c,a ; move length to c(ounter)
_2:
ld a,[hl+] ; and copy c literals
ld [de],a
inc de
dec c
jr nz,_2
jr uncap ; continue

0 comments on commit e505b26

Please sign in to comment.