[A83] Re: Compression


[Prev][Next][Index][Thread]

[A83] Re: Compression




>That's not true at all. The best sorts of compression involve arithmetic
>compression and some sort of predictive modeling or dynamic contexts. But
>the Z80 isn't fast enough for any of that. Huffman can often be good for
>images. But for data and levelsets, I have found Lite86 to provide nice
>compression, and it requires no extra memory. It will work for any
>calculator, not just 86. It sometimes works well for images and sprites
>also.
>
>http://www.ticalc.org/pub/win/asm/lite86.zip

Thanks, you all.

It works well, I guess, but I don't know where to store the data before
continuing to do something with it. I've come this far:

.NOLIST
#define equ .equ
#define EQU .equ
#define end .end
;#include "ti83plus.inc"
;#include "tokens.inc"
.LIST
#define bcall(xxxx) rst 28h \ .dw xxxx
#define bcallz(xxxx) jr nz,$+5 \ rst 28h \ .dw xxxx
#define bcallnz(xxxx) jr z,$+5 \ rst 28h \ .dw xxxx
#define bcallc(xxxx) jr nc,$+5 \ rst 28h \ .dw xxxx
#define bcallnc(xxxx) jr c,$+5 \ rst 28h \ .dw xxxx
#define bjump(xxxx) call 50h \ .dw xxxx
 .addinstr BCALL *       EF   3 NOP 1
saferam1 =9872h ;Ion-
progstart =9327h ;headers
_PutS  =450Ah
 .org    progstart-2
        .db     $BB,$6D

 ld hl,Data
 ld b,0
 ld de,Dataout    ;it just stores the data after the program. Not very
nice...
DeComp:
 ld   a, (hl)            ; b should already be 0
 inc  hl
 cp   00111111b
 jr   nc, DoDeComp

 or   a
 jp  z,Read              ; EOF
 ld   c, a
 ldir              ; Simply dump the data
 jr   DeComp

DoDeComp:
 push af

 and  00011111b
 add  a, 2
 cp   33
 jr   nz, NotMax

 add  a, (hl)
 rl   b
 inc  hl

NotMax:
 ld   c, a             ; Here, bc = Length
 pop  af
 push hl
 ld   l, (hl)
 rlca
 rlca
 rlca
 or   11111000b
 ld   h, a

 add  hl, de
 ldir
 pop  hl
 inc  hl
 jr   DeComp
 ret
Read:
 ld hl,Dataout
 bcall(_puts)
 ret
Data:
   .db 011h, 02Eh, 04Eh, 04Fh, 04Ch, 049h, 053h, 054h, 00Dh, 00Ah, 023h,
064h
   .db 065h, 066h, 069h, 06Eh, 065h, 020h, 0E2h, 0FFh, 004h, 065h, 071h,
075h
   .db 020h, 0EAh, 0FFh, 001h, 02Eh, 0E1h, 0EFh, 0ECh, 0DEh, 003h, 045h,
051h
   .db 055h, 0FEh, 0DEh, 002h, 04Eh, 044h, 0EDh, 0BCh, 005h, 06Eh, 064h,
00Dh
   .db 00Ah, 02Eh, 0E4h, 093h, 00Ch, 05Fh, 063h, 068h, 065h, 063h, 06Bh,
053h
   .db 074h, 061h, 072h, 074h, 020h, 0EEh, 0FFh, 0E6h, 083h, 008h, 030h,
044h
   .db 037h, 034h, 038h, 068h, 00Dh, 00Ah, 0E1h, 0CBh, 003h, 06Fh, 072h,
067h
   .db 0E6h, 070h, 0E7h, 0EBh, 0E3h, 0F6h, 0E1h, 052h, 004h, 033h, 045h,
034h
   .db 031h, 0E4h, 053h, 002h, 06Ch, 064h, 0E1h, 043h, 005h, 061h, 02Ch,
020h
   .db 034h, 031h, 0E1h, 0CAh, 0E2h, 0D7h, 001h, 041h, 0E2h, 0D0h, 003h,
033h
   .db 030h, 036h, 0E4h, 034h, 002h, 06Fh, 075h, 0E1h, 094h, 00Ah, 028h,
030h
   .db 036h, 068h, 029h, 02Ch, 020h, 061h, 020h, 020h, 0E4h, 0BEh, 001h,
043h
   .db 0E1h, 010h, 006h, 032h, 031h, 036h, 031h, 044h, 037h, 0E7h, 0BEh,
00Ah
   .db 068h, 06Ch, 02Ch, 020h, 04Ch, 061h, 062h, 065h, 06Ch, 031h, 0E4h,
09Bh
   .db 001h, 046h, 0C1h, 0EDh, 006h, 031h, 031h, 030h, 030h, 038h, 032h,
0E7h
   .db 09Bh, 0C0h, 0D5h, 0E0h, 09Ah, 0E1h, 0F0h, 0E0h, 0ECh, 0E4h, 097h,
001h
   .db 035h, 0E2h, 0E6h, 006h, 030h, 031h, 035h, 046h, 030h, 030h, 0E7h,
078h
   .db 002h, 062h, 063h, 0E1h, 0DDh, 003h, 030h, 035h, 046h, 0E5h, 0DEh,
001h
   .db 035h, 0C2h, 0CCh, 002h, 044h, 042h, 0E3h, 0E0h, 0E2h, 056h, 002h,
069h
   .db 072h, 0C7h, 09Fh, 0E4h, 0BDh, 0E2h, 080h, 0E0h, 09Ah, 0E0h, 00Fh,
0E9h
   .db 077h, 0E2h, 09Ah, 0C9h, 0D7h, 0E4h, 095h, 0E3h, 02Ch, 0E2h, 0B2h,
0C3h
   .db 057h, 004h, 070h, 075h, 073h, 068h, 0E1h, 072h, 0EAh, 0B7h, 001h,
042h
   .db 0E3h, 02Eh, 002h, 032h, 042h, 0E9h, 051h, 0E2h, 02Eh, 0E1h, 041h,
0E0h
   .db 0ECh, 0E5h, 051h, 001h, 045h, 0C1h, 01Bh, 002h, 043h, 033h, 0E6h,
02Eh
   .db 002h, 06Ah, 070h, 0C2h, 093h, 0E5h, 032h, 0A0h, 0F8h, 0E4h, 005h,
001h
   .db 03Ah, 0C3h, 09Fh, 0C0h, 0E8h, 0A1h, 0F1h, 001h, 037h, 0E2h, 0D1h,
0CBh
   .db 09Fh, 004h, 028h, 068h, 06Ch, 029h, 0C4h, 0C0h, 001h, 036h, 0C2h,
0ECh
   .db 002h, 032h, 033h, 0A6h, 0D3h, 0A0h, 0C0h, 001h, 063h, 0C2h, 0C0h,
0E9h
   .db 028h, 001h, 036h, 0E2h, 0E4h, 003h, 046h, 045h, 033h, 0C2h, 0BBh,
0A1h
   .db 0A5h, 001h, 063h, 0E2h, 094h, 0E0h, 0F3h, 0C4h, 060h, 001h, 036h,
0C2h
   .db 0EBh, 0E1h, 079h, 0C3h, 085h, 0E1h, 078h, 0C2h, 0EDh, 0E0h, 0BFh,
0C5h
   .db 083h, 001h, 032h, 0E4h, 07Fh, 0C2h, 069h, 001h, 042h, 0E5h, 0DFh,
0C1h
   .db 03Dh, 0C2h, 0CAh, 0C1h, 044h, 0E9h, 0A0h, 0A2h, 0FDh, 001h, 043h,
0A2h
   .db 0F8h, 0A3h, 047h, 002h, 072h, 065h, 0A1h, 0B0h, 001h, 07Ah, 0EBh,
0DFh
   .db 001h, 039h, 0A1h, 02Eh, 0C3h, 03Ch, 0A8h, 0DCh, 0C1h, 065h, 0E3h,
0BBh
   .db 0E4h, 01Ch, 0A2h, 0DAh, 0DAh, 065h, 001h, 036h, 0A2h, 0DCh, 003h,
031h
   .db 038h, 046h, 0E5h, 01Ah, 0E3h, 059h, 0A6h, 0E0h, 0C5h, 0D1h, 001h,
032h
   .db 0C5h, 0D1h, 0C2h, 0A7h, 001h, 046h, 0CCh, 063h, 002h, 061h, 066h,
0CAh
   .db 0F2h, 0A2h, 0B4h, 003h, 045h, 036h, 031h, 0C5h, 0F2h, 002h, 061h,
06Eh
   .db 0A1h, 04Eh, 0E0h, 0F3h, 0A4h, 052h, 001h, 037h, 0A2h, 03Ah, 003h,
043h
   .db 036h, 030h, 0A3h, 09Ah, 0A1h, 038h, 001h, 064h, 0A1h, 032h, 0A1h,
033h
   .db 0E0h, 0F0h, 0E5h, 0E1h, 0C4h, 0B7h, 0A0h, 054h, 0C9h, 0B7h, 0A0h,
047h
   .db 0C8h, 04Eh, 001h, 034h, 0C4h, 04Eh, 0A0h, 074h, 0A2h, 02Fh, 0A0h,
053h
   .db 001h, 034h, 0CAh, 0ACh, 001h, 07Ah, 0A5h, 02Fh, 001h, 033h, 0E4h,
097h
   .db 0A2h, 015h, 001h, 038h, 085h, 0EBh, 0E8h, 097h, 0C8h, 02Bh, 001h,
037h
   .db 0C3h, 0ACh, 002h, 042h, 031h, 0A5h, 053h, 001h, 072h, 0C2h, 030h,
001h
   .db 062h, 0AAh, 053h, 001h, 037h, 082h, 0A7h, 0D7h, 00Ah, 0A5h, 0BDh,
001h
   .db 033h, 0E5h, 06Fh, 0A2h, 070h, 0DAh, 080h, 001h, 037h, 082h, 07Dh,
001h
   .db 046h, 085h, 03Dh, 0A1h, 02Eh, 001h, 06Fh, 0A1h, 071h, 0CBh, 0CBh,
001h
   .db 037h, 062h, 0B8h, 001h, 045h, 0ACh, 00Dh, 0ABh, 09Ch, 0A3h, 05Fh,
0C3h
   .db 084h, 068h, 0F9h, 081h, 03Ch, 0E9h, 02Fh, 082h, 03Dh, 0A6h, 099h,
0E2h
   .db 02Fh, 001h, 063h, 0A6h, 0BCh, 065h, 0F9h, 001h, 038h, 082h, 048h,
0FBh
   .db 0DFh, 062h, 09Dh, 0FBh, 0BEh, 062h, 0E3h, 003h, 046h, 036h, 046h,
0A5h
   .db 076h, 0A3h, 057h, 002h, 030h, 046h, 062h, 041h, 0E2h, 0A1h, 0C2h,
072h
   .db 0A3h, 035h, 068h, 058h, 001h, 068h, 0AAh, 07Ch, 001h, 038h, 062h,
0E1h
   .db 001h, 031h, 0A2h, 056h, 0C8h, 004h, 062h, 079h, 082h, 026h, 0E4h,
05Fh
   .db 062h, 03Ch, 07Ah, 0C0h, 001h, 038h, 042h, 0F5h, 001h, 045h, 0CCh,
0BAh
   .db 08Bh, 077h, 001h, 038h, 082h, 0F8h, 09Ah, 056h, 001h, 038h, 042h,
0D2h
   .db 0A0h, 019h, 066h, 0A4h, 0ABh, 019h, 0C2h, 0DDh, 042h, 0D6h, 040h,
0B5h
   .db 083h, 090h, 067h, 01Ch, 040h, 094h, 080h, 080h, 0E5h, 01Dh, 0C3h,
07Ch
   .db 0C7h, 03Ah, 0E6h, 01Dh, 061h, 0F1h, 0C6h, 09Dh, 042h, 0B9h, 083h,
0B5h
   .db 0CBh, 05Bh, 060h, 042h, 046h, 0FEh, 001h, 039h, 042h, 0C4h, 0FBh,
0DFh
   .db 042h, 019h, 083h, 0BEh, 0CBh, 019h, 088h, 036h, 001h, 039h, 063h,
073h
   .db 001h, 030h, 0C6h, 0FAh, 0ACh, 004h, 001h, 034h, 0E4h, 09Bh, 082h,
0E8h
   .db 001h, 046h, 042h, 0DDh, 043h, 077h, 003h, 065h, 069h, 020h, 0E8h,
0FFh
   .db 0E4h, 07Ah, 083h, 0C0h, 080h, 0E2h, 0CAh, 0FAh, 081h, 0C1h, 0E0h,
007h
   .db 001h, 035h, 044h, 015h, 001h, 039h, 042h, 058h, 001h, 036h, 0A2h,
06Eh
   .db 0ABh, 094h, 063h, 00Dh, 0E4h, 039h, 062h, 06Fh, 0DAh, 0F7h, 001h,
039h
   .db 062h, 06Fh, 0FBh, 0DFh, 042h, 01Dh, 0DBh, 0D6h, 043h, 01Dh, 0C0h,
074h
   .db 08Eh, 01Ch, 0E1h, 0EEh, 0E5h, 05Bh, 082h, 0CEh, 063h, 007h, 08Bh,
0EFh
   .db 0E9h, 07Ch, 042h, 02Dh, 001h, 037h, 065h, 0DCh, 045h, 028h, 042h,
02Bh
   .db 0C2h, 070h, 0C4h, 073h, 042h, 050h, 0E1h, 09Dh, 0A5h, 06Dh, 0E9h,
09Dh
   .db 001h, 039h, 044h, 044h, 001h, 041h, 062h, 052h, 063h, 06Ch, 0EEh,
0BEh
   .db 0A0h, 04Dh, 0E4h, 0DFh, 0C4h, 073h, 0CBh, 0B7h, 0E4h, 05Bh, 0C5h,
0B6h
   .db 001h, 041h, 083h, 0EBh, 047h, 0D3h, 086h, 0EBh, 0C8h, 0B6h, 001h,
041h
   .db 042h, 0B7h, 09Ah, 029h, 001h, 041h, 062h, 03Ch, 060h, 014h, 0E6h,
038h
   .db 0C8h, 0F8h, 0E0h, 026h, 0E5h, 05Bh, 0C3h, 074h, 0FAh, 09Dh, 082h,
08Dh
   .db 0FBh, 03Ah, 062h, 016h, 0DAh, 0D7h, 001h, 041h, 0C4h, 074h, 040h,
005h
   .db 0EFh, 07Ch, 001h, 036h, 0C5h, 0D7h, 0C3h, 074h, 099h, 0E7h, 001h,
041h
   .db 07Eh, 042h, 001h, 041h, 0C5h, 074h, 085h, 0C4h, 0C9h, 011h, 001h,
043h
   .db 064h, 0A1h, 040h, 056h, 0DDh, 011h, 001h, 042h, 062h, 063h, 0DAh,
011h
   .db 001h, 042h, 042h, 034h, 0DAh, 074h, 001h, 042h, 062h, 03Eh, 003h,
033h
   .db 038h, 033h, 0EAh, 019h, 041h, 03Ah, 002h, 030h, 033h, 0E5h, 01Ah,
001h
   .db 042h, 062h, 060h, 001h, 036h, 087h, 0A8h, 046h, 07Dh, 061h, 041h,
0E6h
   .db 07Dh, 042h, 082h, 040h, 014h, 0B1h, 08Eh, 040h, 075h, 0E4h, 03Bh,
09Eh
   .db 0C8h, 001h, 042h, 083h, 0C8h, 0ACh, 04Ch, 041h, 0BBh, 068h, 0BFh,
001h
   .db 042h, 0C3h, 054h, 042h, 078h, 0AEh, 02Bh, 040h, 090h, 0C4h, 0D8h,
082h
   .db 008h, 0FBh, 09Dh, 062h, 01Ch, 0FBh, 07Ch, 082h, 007h, 0DBh, 0B7h,
042h
   .db 0F9h, 001h, 030h, 045h, 05Ah, 061h, 082h, 042h, 079h, 04Bh, 058h,
001h
   .db 042h, 042h, 0F9h, 041h, 00Ch, 032h, 03Bh, 020h, 044h, 069h, 073h,
061h
   .db 073h, 073h, 065h, 06Dh, 062h, 06Ch, 065h, 064h, 020h, 062h, 079h,
020h
   .db 04Ah, 069h, 06Dh, 06Dh, 079h, 020h, 043h, 06Fh, 06Eh, 06Eh, 065h,
072h
   .db 020h, 02Dh, 020h, 074h, 069h, 06Dh, 061h, 067h, 069h, 063h, 040h,
079h
   .db 061h, 068h, 06Fh, 06Fh, 02Eh, 063h, 06Fh, 06Dh, 0E3h, 0CBh, 011h,
040h
   .db 020h, 032h, 02Dh, 036h, 02Dh, 030h, 031h, 020h, 031h, 031h, 03Ah,
030h
   .db 033h, 03Ah, 032h, 038h, 0EEh, 0B5h, 040h, 04Ah, 004h, 076h, 031h,
02Eh
   .db 037h, 0E3h, 09Fh, 011h, 054h, 06Fh, 074h, 061h, 06Ch, 020h, 04Fh,
070h
   .db 063h, 06Fh, 064h, 065h, 073h, 03Ah, 020h, 038h, 032h, 0E9h, 0EAh,
007h
   .db 044h, 061h, 074h, 061h, 03Ah, 020h, 030h, 0E3h, 077h, 005h, 05Ah,
038h
   .db 030h, 020h, 041h, 042h, 022h, 0E0h, 08Bh, 060h, 015h, 0E0h, 0F4h,
00Ah
   .db 02Eh, 075h, 073h, 02Eh, 066h, 06Fh, 072h, 06Eh, 061h, 078h, 0E7h,
08Ah
   .db 006h, 050h, 065h, 072h, 073h, 06Fh, 06Eh, 0E1h, 0B3h, 0E1h, 0DEh,
001h
   .db 077h, 0E0h, 0FFh, 001h, 02Eh, 0E5h, 064h, 0E0h, 06Ah, 00Eh, 06Ah,
062h
   .db 02Eh, 06Eh, 065h, 074h, 00Dh, 00Ah, 02Eh, 065h, 06Eh, 064h, 00Dh,
00Ah
   .db 0E3h, 0FBh, 000h
 ret
Dataout:

.end
end

>---- Original Message ----
>
>In compression, the best you can get for all thing(data, sprite, image) is
>huffman but the "negative" of huffman is it need a 1024 byte buffer to
>decompress.... So Hope that help
>
>Paxl
>
>
>




Follow-Ups: