From ce17fbd2855032c6e527c38b706c3491b13917c0 Mon Sep 17 00:00:00 2001 From: pkali Date: Thu, 15 Aug 2024 01:53:37 -0400 Subject: [PATCH] wip lzss player...... --- intro/tech_diff.asm | 4 +- intro/tech_diff.lab | 78 ++++++++-------- intro/tech_diff.xex | Bin 27517 -> 27495 bytes music/playlzs16.asm | 98 +++++++++++--------- music/playlzs16.obx | Bin 0 -> 3133 bytes music/playlzs16_original.asm | 171 +++++++++++++++++++++++++++++++++++ 6 files changed, 265 insertions(+), 86 deletions(-) create mode 100644 music/playlzs16.obx create mode 100644 music/playlzs16_original.asm diff --git a/intro/tech_diff.asm b/intro/tech_diff.asm index 77b19b4..c224fd5 100644 --- a/intro/tech_diff.asm +++ b/intro/tech_diff.asm @@ -13,7 +13,7 @@ icl '../lib/MACRO.ASM' ;--------------------------------------------------- ; BASIC off - ORG $2700 + ORG $2c00 mva #$ff portb mwa #DL_pre dlptrs lda #@dmactl(narrow|dma) ; narrow screen width, DL on @@ -119,7 +119,7 @@ leet_speek1 leet_speek2 dta "ABCDEFGHIJKLMNOPQRSTUVWXYZ" leet_speek3 - dta "4&[)eF9-|jk_mn0p@r57uvw*y2" + dta "48[)eF9-|jk_mn0p@r57uvw*y2" leet_speek4 dta "^b(>",$5b,$41,"gh1",$4c+$80,"k",$4b+$80,"M\",$54,$49+$80,"q",$51,"5",$57,"uvwxy/" diff --git a/intro/tech_diff.lab b/intro/tech_diff.lab index e91ec27..ec9b63b 100644 --- a/intro/tech_diff.lab +++ b/intro/tech_diff.lab @@ -577,48 +577,48 @@ FFFD 0000 @KBCODE 00 0082 TEMP_B 00 0083 TEMP_W2 00 0085 TEMP_W3 -00 2724 LEET_ANIM -00 274D 0@ -00 2771 NEXT_LETTER -00 2790 LEET_END -00 2794 WAIT_FOR_RELEASING_KEYZ -00 2794 WAIT_FOR_RELEASING_KEYZ.1@ -00 279B WAIT_FOR_RELEASING_KEYZ.2@ -00 27A6 WAIT_FOR_RELEASING_KEYZ.3@ -00 27AC DL_PRE -00 27CC PRE_SCREEN -00 28EC PRE_SCREEN_END -00 28EC LEET_SPEEK1 -00 2906 LEET_SPEEK2 -00 2920 LEET_SPEEK3 -00 293A LEET_SPEEK4 -00 2954 LEET_SPEEKS_L -00 2958 LEET_SPEEKS_H -00 295C LEET_SCREEN -00 2A7C LEET_SCREEN_END +00 2C24 LEET_ANIM +00 2C4D 0@ +00 2C71 NEXT_LETTER +00 2C90 LEET_END +00 2C94 WAIT_FOR_RELEASING_KEYZ +00 2C94 WAIT_FOR_RELEASING_KEYZ.1@ +00 2C9B WAIT_FOR_RELEASING_KEYZ.2@ +00 2CA6 WAIT_FOR_RELEASING_KEYZ.3@ +00 2CAC DL_PRE +00 2CCC PRE_SCREEN +00 2DEC PRE_SCREEN_END +00 2DEC LEET_SPEEK1 +00 2E06 LEET_SPEEK2 +00 2E20 LEET_SPEEK3 +00 2E3A LEET_SPEEK4 +00 2E54 LEET_SPEEKS_L +00 2E58 LEET_SPEEKS_H +00 2E5C LEET_SCREEN +00 2F7C LEET_SCREEN_END 00 3000 SCREEN 00 3410 DL 00 343C START 00 3482 PLEASE_WAIT_LOOP 00 3498 4@ 00 3499 SAMPLE_LOAD -00 3510 5@ -00 351A EXIT_TECH_DIFF -00 351A 6@ -00 3521 7@ -00 352C 8@ -00 3540 SAMPLE1 -00 48AC SAMPLE_END1 -00 48AC SAMPLE2 -00 6B91 SAMPLE_END2 -00 6B91 SAMPLE3 -00 6E2B SAMPLE_END3 -00 6E2B SAMPLE4 -00 70C5 SAMPLE_END4 -00 70C5 SAMPLE5 -00 98DF SAMPLE_END5 -00 98DF SAMPLES_L -00 98EA SAMPLES_H -00 98F5 SAMPLES_END_L -00 9900 SAMPLES_END_H -00 990B FINITO +00 34FA 5@ +00 3504 EXIT_TECH_DIFF +00 3504 6@ +00 350B 7@ +00 3516 8@ +00 352A SAMPLE1 +00 4896 SAMPLE_END1 +00 4896 SAMPLE2 +00 6B7B SAMPLE_END2 +00 6B7B SAMPLE3 +00 6E15 SAMPLE_END3 +00 6E15 SAMPLE4 +00 70AF SAMPLE_END4 +00 70AF SAMPLE5 +00 98C9 SAMPLE_END5 +00 98C9 SAMPLES_L +00 98D4 SAMPLES_H +00 98DF SAMPLES_END_L +00 98EA SAMPLES_END_H +00 98F5 FINITO diff --git a/intro/tech_diff.xex b/intro/tech_diff.xex index a3b459000afd83b014f9b6c81f0398363199e9f7..e1f68885601e51b15503f6f96647a7c7211d26c1 100644 GIT binary patch delta 317 zcmex+jq&+4My>z<8FZrcR{rm0yu5NvuL09aonAwxm5ROkOe-0Bk1_R1U0BKAdz49G ziq1qW8BU$n#+5Oxtt<5=`pfC)wKngK&}(hk*t~#YV(YVp3rx=%pS1$Xwxx|HbuX|i zZ8-Vn!*m~C9gyak%3^v9Oa)-XzyyPiYjieV3T0%Jn5@BM#;2>Nr}v2IF%yFVgTa>> zn{$|&Swc_F=$&b@_sWdkStfh$&uDGf`)WpOz<8PuaSSN`v1yu5NvuL09a^9$ zZ8-Vn!*m~Cb)e>i$p!4PI%u;`UM(<3My{~5U&NA8ibw+E$UWS>ijcfn^Uty621ig%xdYLcv zvR+!%%XMX~{DqV37gE>qUpo2yL)^*#7otFd0vA36b@d8f>J`4!D|!hiGDDM}Qvjjy z-At1U%XGe{ f=TQJ6*G$x&cy!`@5b2SfmtBxO14M#6V`BmU^Yf!w diff --git a/music/playlzs16.asm b/music/playlzs16.asm index 81b99f9..ba6dddf 100644 --- a/music/playlzs16.asm +++ b/music/playlzs16.asm @@ -20,48 +20,44 @@ ; The plater needs 256 bytes of buffer for each pokey register stored, for a ; full SAP file this is 2304 bytes. ; - org $80 - + org $e0 + +song_start_ptr .ds 2 +song_end_ptr .ds 2 chn_copy .ds 9 chn_pos .ds 9 bptr .ds 2 cur_pos .ds 1 chn_bits .ds 1 -bit_data .byte 1 +bit_data .ds 1 -.proc get_byte - lda song_data+1 - inc song_ptr - bne skip - inc song_ptr+1 -skip - rts -.endp -song_ptr = get_byte + 1 POKEY = $D200 org $2000 -buffers - .ds 256 * 9 - -song_data - ins 'test.lz16' -song_end -start - +player + jmp play_frame ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Song Initialization - this runs in the first tick: ; .proc init_song - ; Example: here initializes song pointer: - ; sta song_ptr - ; stx song_ptr + 1 + ;clear buffers + lda #0 + tax +@ + :9 sta buffers+#*$100,x + inx + bne @- + + mva #1 bit_data + + ; here initializes song pointer: + adw song_start_ptr #1 song_ptr ; Init all channels: ldx #8 @@ -80,18 +76,9 @@ cbuf ; Initialize buffer pointer: sty bptr sty cur_pos + rts .endp -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; Wait for next frame -; -.proc wait_frame - - lda 20 -delay - cmp 20 - beq delay -.endp ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Play one frame of the song @@ -100,7 +87,8 @@ delay lda #>buffers sta bptr+1 - lda song_data + ldy #0 + lda (song_start_ptr),y sta chn_bits ldx #8 @@ -149,22 +137,42 @@ skip_chn: bpl chn_loop ; Next channel inc cur_pos -.endp ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Check for ending of song and jump to the next frame ; -.proc check_end_song - lda song_ptr + 1 - cmp #>song_end - bne wait_frame - lda song_ptr - cmp #x2+l%Gvk=oQM3jY?VIdS2V&-Vy%|;*d)3Cb1^*)ug zvbv%5L}i`KCaNK1cA16v=D@AWarxLH*`>gHrbnhHs~Y9z$2G)>LG$l6k?!~7Gtb=W z3(-C8L;UCs=BNDjc)-EC{O;hbZ*M)id;0E)N3~D*$9(u`@Lb+1y zL-aP831a(R!r9|tjULi7#WSVl`goV&*qu%yy!qj?3qF26eofDv^*hEpY(D3S>l7JB zu@u`bBHP+L*b{VzU?>mHnZ)d>f-w&!%oP&CYA%0v$|M1^(`4#wEi3CPGj@Am1bM(<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3D*jt@qnJ4}=t!NHya@eqHjWXF0WV%0UW}r6@vJbX8V^Eg zaenY5h1WbyAv04kBWi}%yiY?^MtY9QYhGA;Kg|8FdGqETjg_od7kJIf>d*X&I)s;{ zw^6Cd5f>3ZpIR5|HLpI2pHi=R1;fn3Q(BGd^+WKAhBwdTMQ`^5B#sM%-=eH`D?6@n zfeVxbC7;$Qih^XIPD0Z~#2{>dO;vgpO{kZ061GnXV!Z literal 0 HcmV?d00001 diff --git a/music/playlzs16_original.asm b/music/playlzs16_original.asm new file mode 100644 index 0000000..81b99f9 --- /dev/null +++ b/music/playlzs16_original.asm @@ -0,0 +1,171 @@ +; +; LZSS Compressed SAP player for 16 match bits +; -------------------------------------------- +; +; (c) 2020 DMSC +; Code under MIT license, see LICENSE file. +; +; This player uses: +; Match length: 8 bits (1 to 256) +; Match offset: 8 bits (1 to 256) +; Min length: 2 +; Total match bits: 16 bits +; +; Compress using: +; lzss -b 16 -o 8 -m 1 input.rsap test.lz12 +; +; Assemble this file with MADS assembler, the compressed song is expected in +; the `test.lz16` file at assembly time. +; +; The plater needs 256 bytes of buffer for each pokey register stored, for a +; full SAP file this is 2304 bytes. +; + org $80 + +chn_copy .ds 9 +chn_pos .ds 9 +bptr .ds 2 +cur_pos .ds 1 +chn_bits .ds 1 + +bit_data .byte 1 + +.proc get_byte + lda song_data+1 + inc song_ptr + bne skip + inc song_ptr+1 +skip + rts +.endp +song_ptr = get_byte + 1 + + +POKEY = $D200 + + org $2000 +buffers + .ds 256 * 9 + +song_data + ins 'test.lz16' +song_end + + +start + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Song Initialization - this runs in the first tick: +; +.proc init_song + + ; Example: here initializes song pointer: + ; sta song_ptr + ; stx song_ptr + 1 + + ; Init all channels: + ldx #8 + ldy #0 +clear + ; Read just init value and store into buffer and POKEY + jsr get_byte + sta POKEY, x + sty chn_copy, x +cbuf + sta buffers + 255 + inc cbuf + 2 + dex + bpl clear + + ; Initialize buffer pointer: + sty bptr + sty cur_pos +.endp + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Wait for next frame +; +.proc wait_frame + + lda 20 +delay + cmp 20 + beq delay +.endp + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Play one frame of the song +; +.proc play_frame + lda #>buffers + sta bptr+1 + + lda song_data + sta chn_bits + ldx #8 + + ; Loop through all "channels", one for each POKEY register +chn_loop: + lsr chn_bits + bcs skip_chn ; C=1 : skip this channel + + lda chn_copy, x ; Get status of this stream + bne do_copy_byte ; If > 0 we are copying bytes + + ; We are decoding a new match/literal + lsr bit_data ; Get next bit + bne got_bit + jsr get_byte ; Not enough bits, refill! + ror ; Extract a new bit and add a 1 at the high bit (from C set above) + sta bit_data ; +got_bit: + jsr get_byte ; Always read a byte, it could mean "match size/offset" or "literal byte" + bcs store ; Bit = 1 is "literal", bit = 0 is "match" + + sta chn_pos, x ; Store in "copy pos" + + jsr get_byte + sta chn_copy, x ; Store in "copy length" + + ; And start copying first byte +do_copy_byte: + dec chn_copy, x ; Decrease match length, increase match position + inc chn_pos, x + ldy chn_pos, x + + ; Now, read old data, jump to data store + lda (bptr), y + +store: + ldy cur_pos + sta POKEY, x ; Store to output and buffer + sta (bptr), y + +skip_chn: + ; Increment channel buffer pointer + inc bptr+1 + + dex + bpl chn_loop ; Next channel + + inc cur_pos +.endp + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Check for ending of song and jump to the next frame +; +.proc check_end_song + lda song_ptr + 1 + cmp #>song_end + bne wait_frame + lda song_ptr + cmp #