diff --git a/asm_routines/lz4_decode.s b/asm_routines/lz4_decode.s index 98cde179..840fe1d8 100644 --- a/asm_routines/lz4_decode.s +++ b/asm_routines/lz4_decode.s @@ -3,7 +3,9 @@ ; Code by Peter Ferrie (qkumba) (peter.ferrie@gmail.com) ; "LZ4 unpacker in 143 bytes (6502 version) (2013)" ; http://pferrie.host22.com/misc/appleii.htm -; I found a bug, and also added comments to clarify a bit what's going on +; This is that code, but with comments and labels added for clarity. +; I also found a bug when decoding with runs of multiples of 256 +; which has since been fixed upstream. ; For LZ4 reference see ; https://github.com/lz4/lz4/wiki/lz4_Frame_format.md @@ -107,7 +109,9 @@ copymatches: adc #4 ; adjust count by 4 (minmatch) tax + beq copy_skip ; BUGFIX bcc copy_skip + inc count+1 copy_skip: lda src+1 @@ -193,19 +197,11 @@ putdst_end: ; copies ram[count+1]-1:X bytes ; from src to dst docopy: - ; working around bug in original code that would loop 256 too - ; many times if incoming X was equal to 0 - cpx #$0 - bne docopy_loop - jsr getput - dex - bne docopy_hack docopy_loop: jsr getput ; get/put byte dex ; decrement count bne docopy_loop ; if not zero, loop -docopy_hack: dec count+1 ; if zero, decrement high byte bne docopy_loop ; if not zero, loop diff --git a/chiptune_player/TODO b/chiptune_player/TODO index 41ba9bd6..7f683706 100644 --- a/chiptune_player/TODO +++ b/chiptune_player/TODO @@ -1,6 +1,5 @@ -+ Starfield -- takes too much ram (3k+) -+ Volume Bars -+ Print Descriptive Text + Print time + LZ4 decompression + Loop support ++ Right/Left arrows on screen ++ "LOADING..." message while loading from disk diff --git a/gr-sim/lz4d_verbose.c b/gr-sim/lz4d_verbose.c index 248901de..fbd9ce59 100644 --- a/gr-sim/lz4d_verbose.c +++ b/gr-sim/lz4d_verbose.c @@ -89,18 +89,11 @@ static void getput(void) { static void docopy(void) { printf("\tDOCOPY ENTRY: %02X%02X\n",ram[count+1],x); // docopy: - if (x==0) { - getput(); - x--; - goto dc_hack; - } - docopy_label: printf("\tDOCOPY %02X%02X: ",ram[count+1],x); getput(); // jsr getput x--; // dex if (x!=0) goto docopy_label; // bne docopy -dc_hack: ram[count+1]--; // dec count+1 if (ram[count+1]!=0) goto docopy_label; //bne docopy //rts @@ -234,6 +227,7 @@ copymatches: c=0; // clc adc(4); // adc #4 x=a; // tax + if (x==0) goto copy_skip; //BUGFIX // beq + if (c==0) goto copy_skip; // bcc + ram[count+1]++; // inc count+1 copy_skip: