chiptune: lz4 decode

doesn't work :(

problem seems to be in lz4 code
This commit is contained in:
Vince Weaver 2018-02-20 00:01:15 -05:00
parent 345efc18bb
commit e0946b1bdf
4 changed files with 28 additions and 18 deletions

View File

@ -3,8 +3,11 @@
; FIXME: make these a parameter
; filename
disk_buff EQU $6000
read_size EQU $2A00 ; (3*256*14)
;disk_buff EQU $6000
;read_size EQU $2A00 ; (3*256*14)
disk_buff EQU $4000
read_size EQU $1000 ; 4kB
;; For the disk-read code
;RWTSL EQU $F0
@ -240,8 +243,8 @@ dos33_read:
filename:
; OUT.0
.byte 'O'+$80,'U'+$80,'T'+$80,'.'+$80,'0'+$80
.byte $A0,$A0,$A0,$A0,$A0
.byte 'O'+$80,'U'+$80,'T'+$80,'.'+$80,'L'+$80
.byte 'Z'+$80,'4'+$80,$A0,$A0,$A0
.byte $A0,$A0,$A0,$A0,$A0
.byte $A0,$A0,$A0,$A0,$A0
.byte $A0,$A0,$A0,$A0,$A0

View File

@ -17,16 +17,17 @@ A4L EQU $42
A4H EQU $43
size EQU 794
orgoff EQU $8000 ; offset of first unpacked byte
paksize EQU size-$b-8 ; minus 4 for checksum at end
orgoff EQU $6000 ; offset of first unpacked byte
paksize EQU size-$b-8
; size of packed data
; minus 4 for checksum at end
; not sure what other 4 is from?
; block checksum? though had that disabled?
; size of packed data
pakoff EQU $200b ; 11 byte offset to data?
pakoff EQU $400b ; 11 byte offset to data?
lz4_unpack:
lz4_decode:
lda #<pakoff ; packed data offset
sta src
lda #<(pakoff+paksize) ; packed data size

View File

@ -203,6 +203,9 @@ interrupt_handler:
bit $C404 ; can clear 6522 interrupt by reading T1C-L
;=====================
; Update time counter
;=====================
inc FRAME_COUNT
lda FRAME_COUNT
@ -320,6 +323,8 @@ new_song:
jsr read_file
jsr lz4_decode
lda #>CHUNK_BUFFER
sta INH
lda #<CHUNK_BUFFER
@ -400,6 +405,7 @@ bloop3:
jsr print_both_pages
rts
;=========
;routines
;=========

View File

@ -83,8 +83,8 @@ docopy_label:
}
#define ORGOFFSET 0x6000
#define PAKOFFSET 0x4000
int main(int argc, char **argv) {
@ -111,7 +111,7 @@ int main(int argc, char **argv) {
fclose(fff);
memcpy(&ram[0x2000],input,size);
memcpy(&ram[PAKOFFSET],input,size);
//LZ4 data decompressor for Apple II
//Peter Ferrie (peter.ferrie@gmail.com)
@ -121,14 +121,14 @@ int main(int argc, char **argv) {
//hipak = 0 ;packed data entirely in high memory (requires hiunp)
//oep = 0; //first unpacked byte to run, you must set this by yourself
orgoff = 0x8000; //offset of first unpacked byte, you must set this by yourself
paksize = size-0xb-8;
orgoff = ORGOFFSET; //offset of first unpacked byte, you must set this by yourself
paksize = size-0xb-8;
// minus 4 for checksum at end
// not sure what other 4 is from?
// block checksum? though had that disabled?
//size of packed data, you must set this by yourself if hiunp=0
pakoff = 0x200b; // 11 byte offset to data?
pakoff = PAKOFFSET+11; // 11 byte offset to data?
//LCBANK2 = $c083
@ -236,12 +236,12 @@ done:
int out_size=(ram[dst+1]<<8)+ram[dst];
out_size-=0x8000;
out_size-=ORGOFFSET;
printf("dest addr : %02X%02X\n",ram[dst+1],ram[dst]);
int i,j,addr,temp;
addr=0x8000;
addr=ORGOFFSET;
printf("\n");
for(i=0;i<256;i++) {
@ -268,7 +268,7 @@ done:
printf("Out size=%d\n",out_size);
fwrite(&ram[0x8000],1,out_size,fff);
fwrite(&ram[ORGOFFSET],1,out_size,fff);
fclose(fff);