Jump to content
IGNORED

Unpacking compressed data from ROM to RAM


mksmith

Recommended Posts

Level compressed ZX0 - 682 bytes

Depacking only 6 frames! ? 

10 bytes on Zero Page (you can move 4 bytes to ram)

ASM tested 100% ? 

Code by @xxl

https://xxl.atari.pl/zx0-decompressor/

 

@mksmith let me know if it works

 

rem unpack compressed data
 asm
    SET_POINTER ZX0_INPUT,Level11CompressedMapData
    SET_POINTER ZX0_OUTPUT,MAPSCREENRAM
    jsr dzx0_standard
end

 

ZX0_OUTPUT      equ a
copysrc         equ ZX0_Output+2
ZX0_INPUT		equ copysrc+2
offsetL			equ	ZX0_INPUT+2
offsetH			equ offsetL+1
LenL			equ offsetH+1
LenH			equ LenL+1


dzx0_standard
              lda   #$ff
              sta   offsetL
              sta   offsetH
              ldy   #$00
              sty   lenL
              sty   lenH
              lda   #$80

dzx0s_literals
              jsr   dzx0s_elias
              pha
cop0          jsr   get_byte
              ldy   #$00
              sta   (ZX0_OUTPUT),y
              inc   ZX0_OUTPUT
              bne	skip
              inc	ZX0_OUTPUT+1
skip
              lda   lenL
              bne   Label1
              dec   lenH
Label1        dec   lenL
              bne   cop0
              lda   lenH
              bne   cop0
              pla
              asl   @
              bcs   dzx0s_new_offset
              jsr   dzx0s_elias
dzx0s_copy    pha
              lda   ZX0_OUTPUT
              clc
              adc   offsetL
              sta   copysrc
              lda   ZX0_OUTPUT+1
              adc   offsetH
              sta   copysrc+1
              ldy   #$00
              ldx   lenH
              beq   Remainder
Page          lda   (copysrc),y
              sta   (ZX0_OUTPUT),y
              iny
              bne   Page
              inc   copysrc+1
              inc   ZX0_OUTPUT+1
              dex
              bne   Page
Remainder     ldx   lenL
              beq   copyDone
copyByte      lda   (copysrc),y
              sta   (ZX0_OUTPUT),y
              iny
              dex
              bne   copyByte
              tya
              clc
              adc   ZX0_OUTPUT
              sta   ZX0_OUTPUT
              bcc   copyDone
              inc   ZX0_OUTPUT+1
copyDone      stx   lenH
              stx   lenL
              pla
              asl   @
              bcc   dzx0s_literals
dzx0s_new_offset
              ldx   #$fe
              stx   lenL
              jsr   dzx0s_elias_loop
              pha
			  php ; stream
              ldx   lenL
              inx
              stx   offsetH
              bne   Label2
 			  plp ; stream
              pla
              rts           ; koniec
Label2        jsr   get_byte
 			  plp ; stream
              sta   offsetL
              ror   offsetH
              ror   offsetL
              ldx   #$00
              stx   lenH
              inx
              stx   lenL
              pla
              bcs   Label3
              jsr   dzx0s_elias_backtrack
Label3        inc   lenL
              bne   Label4
              inc   lenH
Label4             jmp   dzx0s_copy
dzx0s_elias   inc   lenL
dzx0s_elias_loop
              asl   @
              bne   dzx0s_elias_skip
              jsr   get_byte
			  sec ; stream
              rol   @
dzx0s_elias_skip
              bcc   dzx0s_elias_backtrack
              rts
dzx0s_elias_backtrack
              asl   @
              rol   lenL
              rol   lenH
              jmp   dzx0s_elias_loop
              
              
GET_BYTE		ldy #$00
		        lda    (ZX0_INPUT),y
				inc ZX0_INPUT
				bne g_b1
				inc ZX0_INPUT+1
g_b1            rts

 

Level11Map.binary.zx0

Link to comment
Share on other sites

ZX5 also gives very good results (sometimes surprising), also PackFire (tiny) is worth checking - in general it is worth checking different compressors depending on your data.

 

2 hours ago, Eagle said:

Level compressed ZX0 - 682 bytes

ZX5 - 678   ( https://xxl.atari.pl/zx5-decompressor/ )

PackFire - 646 ( https://xxl.atari.pl/packfire-decompressor/ )

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

  • 1 month later...

Heads up that I've released lz4raw, which is essentially a recreation of @playsoft's hacked lz4 encoder. (which skips LZ4 headers and just produces raw compressed data output) I wanted to have OS binaries for each of the OS platforms supported under 7800basic, so I can distribute it in a future release of 7800basic.

  • Like 6
Link to comment
Share on other sites

3 hours ago, RevEng said:

Heads up that I've released lz4raw, which is essentially a recreation of @playsoft's hacked lz4 encoder. (which skips LZ4 headers and just produces raw compressed data output) I wanted to have OS binaries for each of the OS platforms supported under 7800basic, so I can distribute it in a future release of 7800basic.

Awesome thanks Mike ???

  • Like 1
Link to comment
Share on other sites

  • 2 months later...
  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...