mirror of
https://github.com/deater/dos33fsprogs.git
synced 2024-10-10 08:23:49 +00:00
chiptune_player: get the file format/loader working
This commit is contained in:
parent
7423b1d3ee
commit
3829a921bb
@ -30,47 +30,37 @@
|
|||||||
; 4 added to it. As with the literal length, if it is 15 then
|
; 4 added to it. As with the literal length, if it is 15 then
|
||||||
; you read a byte and add (and if that byte is 255, keep adding)
|
; you read a byte and add (and if that byte is 255, keep adding)
|
||||||
|
|
||||||
src EQU $00
|
src EQU $FC
|
||||||
dst EQU $02
|
dst EQU $02
|
||||||
end EQU $04
|
end EQU $04
|
||||||
count EQU $06
|
count EQU $06
|
||||||
delta EQU $08
|
delta EQU $08
|
||||||
A1L EQU $3c
|
|
||||||
A1H EQU $3d
|
|
||||||
A2L EQU $3e
|
|
||||||
A2H EQU $3f
|
|
||||||
A4L EQU $42
|
|
||||||
A4H EQU $43
|
|
||||||
|
|
||||||
size EQU 794
|
|
||||||
orgoff EQU $6000 ; offset of first unpacked byte
|
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?
|
|
||||||
|
|
||||||
pakoff EQU $400b ; 11 byte offset to data?
|
|
||||||
|
|
||||||
|
;======================
|
||||||
|
; LZ4 decode
|
||||||
|
;======================
|
||||||
|
; input buffer in INH:INL
|
||||||
|
; output buffer hardcoded still
|
||||||
|
; size in ENDH:ENDL
|
||||||
|
|
||||||
lz4_decode:
|
lz4_decode:
|
||||||
lda #<pakoff ; packed data offset
|
lda INL ; packed data offset
|
||||||
sta src
|
; sta src
|
||||||
lda #<(pakoff+paksize) ; packed data size
|
clc
|
||||||
|
adc end
|
||||||
sta end
|
sta end
|
||||||
lda #>pakoff
|
lda INH
|
||||||
sta src+1
|
; sta src+1
|
||||||
lda #>(pakoff+paksize)
|
adc end+1
|
||||||
sta end+1
|
sta end+1
|
||||||
|
|
||||||
lda #>orgoff ; original unpacked data offset
|
lda #>orgoff ; original unpacked data offset
|
||||||
sta dst+1
|
sta dst+1
|
||||||
lda #<orgoff
|
lda #<orgoff
|
||||||
sta dst
|
sta dst
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
unpmain:
|
unpmain:
|
||||||
ldy #0 ; used to index, always zero
|
ldy #0 ; used to index, always zero
|
||||||
|
|
||||||
|
Binary file not shown.
@ -197,9 +197,13 @@ forever_loop:
|
|||||||
|
|
||||||
interrupt_handler:
|
interrupt_handler:
|
||||||
pha ; save A
|
pha ; save A
|
||||||
|
; tya
|
||||||
|
; pha
|
||||||
|
; txa
|
||||||
|
; pha
|
||||||
; Should we save X and Y too?
|
; Should we save X and Y too?
|
||||||
|
|
||||||
inc $0404 ; debug
|
; inc $0404 ; debug
|
||||||
|
|
||||||
bit $C404 ; can clear 6522 interrupt by reading T1C-L
|
bit $C404 ; can clear 6522 interrupt by reading T1C-L
|
||||||
|
|
||||||
@ -216,26 +220,26 @@ interrupt_handler:
|
|||||||
sta FRAME_COUNT
|
sta FRAME_COUNT
|
||||||
|
|
||||||
update_second_ones:
|
update_second_ones:
|
||||||
inc $7d0+18
|
|
||||||
inc $bd0+18
|
|
||||||
lda $bd0+18
|
|
||||||
cmp #$ba ; one past '9'
|
|
||||||
bne frame_good
|
|
||||||
lda #'0'+$80
|
|
||||||
sta $7d0+18
|
|
||||||
sta $bd0+18
|
|
||||||
update_second_tens:
|
|
||||||
inc $7d0+17
|
inc $7d0+17
|
||||||
inc $bd0+17
|
inc $bd0+17
|
||||||
lda $bd0+17
|
lda $bd0+17
|
||||||
cmp #$b6 ; 6
|
cmp #$ba ; one past '9'
|
||||||
bne frame_good
|
bne frame_good
|
||||||
lda #'0'+$80
|
lda #'0'+$80
|
||||||
sta $7d0+17
|
sta $7d0+17
|
||||||
sta $bd0+17
|
sta $bd0+17
|
||||||
|
update_second_tens:
|
||||||
|
inc $7d0+16
|
||||||
|
inc $bd0+16
|
||||||
|
lda $bd0+16
|
||||||
|
cmp #$b6 ; 6
|
||||||
|
bne frame_good
|
||||||
|
lda #'0'+$80
|
||||||
|
sta $7d0+16
|
||||||
|
sta $bd0+16
|
||||||
update_minutes:
|
update_minutes:
|
||||||
inc $7d0+15
|
inc $7d0+14
|
||||||
inc $bd0+15
|
inc $bd0+14
|
||||||
; we don't handle > 9:59 songs yet
|
; we don't handle > 9:59 songs yet
|
||||||
|
|
||||||
frame_good:
|
frame_good:
|
||||||
@ -301,6 +305,10 @@ chunk_good:
|
|||||||
|
|
||||||
done_interrupt:
|
done_interrupt:
|
||||||
pla
|
pla
|
||||||
|
; tax
|
||||||
|
; pla
|
||||||
|
; tay
|
||||||
|
; pla
|
||||||
rti
|
rti
|
||||||
|
|
||||||
|
|
||||||
@ -309,11 +317,16 @@ done_interrupt:
|
|||||||
;=================
|
;=================
|
||||||
|
|
||||||
new_song:
|
new_song:
|
||||||
lda #0
|
|
||||||
|
;=========================
|
||||||
|
; Init Variables
|
||||||
|
;=========================
|
||||||
|
|
||||||
|
lda #$0
|
||||||
|
sta MB_CHUNK
|
||||||
|
sta FRAME_COUNT
|
||||||
sta A_VOLUME
|
sta A_VOLUME
|
||||||
lda #0
|
|
||||||
sta B_VOLUME
|
sta B_VOLUME
|
||||||
lda #0
|
|
||||||
sta C_VOLUME
|
sta C_VOLUME
|
||||||
|
|
||||||
;===========================
|
;===========================
|
||||||
@ -335,38 +348,30 @@ new_song:
|
|||||||
|
|
||||||
|
|
||||||
;===========================
|
;===========================
|
||||||
; init pointer to the music
|
; Load in KRW file
|
||||||
;===========================
|
;===========================
|
||||||
|
|
||||||
lda #<krw_file
|
lda #<krw_file ; point to filename
|
||||||
sta INL
|
sta INL
|
||||||
lda #>krw_file
|
lda #>krw_file
|
||||||
sta INH
|
sta INH
|
||||||
|
|
||||||
jsr read_file
|
jsr read_file ; read KRW file from disk
|
||||||
|
|
||||||
jsr lz4_decode
|
|
||||||
|
|
||||||
lda #>CHUNK_BUFFER
|
|
||||||
sta INH
|
|
||||||
lda #<CHUNK_BUFFER
|
|
||||||
sta INL
|
|
||||||
|
|
||||||
lda #$0
|
|
||||||
sta MB_CHUNK
|
|
||||||
sta FRAME_COUNT
|
|
||||||
|
|
||||||
;=========================
|
;=========================
|
||||||
; Print Title/Author info
|
; Print Info
|
||||||
;=========================
|
;=========================
|
||||||
|
|
||||||
jsr clear_bottoms ; clear bottom of page 0/1
|
jsr clear_bottoms ; clear bottom of page 0/1
|
||||||
|
|
||||||
; lda #<file_info
|
lda #>LZ4_BUFFER
|
||||||
; sta OUTL
|
sta OUTH
|
||||||
; lda #>file_info
|
lda #<LZ4_BUFFER
|
||||||
; sta OUTH
|
sta OUTL
|
||||||
; ldy #0
|
|
||||||
|
ldy #4 ; skip KRW at front
|
||||||
|
|
||||||
|
|
||||||
; FIXME: optimize
|
; FIXME: optimize
|
||||||
|
|
||||||
@ -375,10 +380,13 @@ new_song:
|
|||||||
lda (OUTL),Y
|
lda (OUTL),Y
|
||||||
sta CH
|
sta CH
|
||||||
|
|
||||||
inc OUTL
|
lda OUTL
|
||||||
bne bloop1
|
clc
|
||||||
inc OUTH
|
adc #5 ; point past header stuff
|
||||||
bloop1:
|
sta OUTL
|
||||||
|
lda OUTH
|
||||||
|
adc #0
|
||||||
|
sta OUTH
|
||||||
|
|
||||||
jsr print_both_pages
|
jsr print_both_pages
|
||||||
|
|
||||||
@ -423,9 +431,47 @@ bloop2:
|
|||||||
bne bloop3
|
bne bloop3
|
||||||
inc OUTH
|
inc OUTH
|
||||||
bloop3:
|
bloop3:
|
||||||
|
|
||||||
jsr print_both_pages
|
jsr print_both_pages
|
||||||
|
|
||||||
|
|
||||||
|
SIZEL EQU $04
|
||||||
|
SIZEH EQU $05
|
||||||
|
|
||||||
|
ldy #0
|
||||||
|
lda #>(LZ4_BUFFER+3)
|
||||||
|
sta INH
|
||||||
|
lda #<(LZ4_BUFFER+3)
|
||||||
|
sta INL
|
||||||
|
|
||||||
|
lda (INL),Y ; get header skip
|
||||||
|
clc
|
||||||
|
adc INL
|
||||||
|
sta INL
|
||||||
|
lda INH
|
||||||
|
adc #0
|
||||||
|
sta INH
|
||||||
|
|
||||||
|
lda (INL),Y
|
||||||
|
sta SIZEL
|
||||||
|
iny
|
||||||
|
lda (INL),Y
|
||||||
|
sta SIZEH
|
||||||
|
|
||||||
|
lda #2
|
||||||
|
clc
|
||||||
|
adc INL
|
||||||
|
sta INL
|
||||||
|
lda INH
|
||||||
|
adc #0
|
||||||
|
sta INH
|
||||||
|
|
||||||
|
jsr lz4_decode
|
||||||
|
|
||||||
|
lda #<CHUNK_BUFFER
|
||||||
|
sta INL
|
||||||
|
lda #>CHUNK_BUFFER
|
||||||
|
sta INH
|
||||||
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
;==========
|
;==========
|
||||||
|
Loading…
Reference in New Issue
Block a user