chiptune: try to add support for loading multiple files

hours of debugging, traced to a stray $.  Urgh.
This commit is contained in:
Vince Weaver 2018-02-26 00:47:06 -05:00
parent 2f4e90f4ab
commit 0a5ee09b92
4 changed files with 56 additions and 15 deletions

View File

@ -72,6 +72,7 @@ filename_pad_spaces:
cpy #30 ; fill 30 bytes
bne filename_pad_spaces
filename_pad_done:
ldy #8 ; filename ptr offset = 8
lda #<filename
@ -83,15 +84,39 @@ filename_pad_spaces:
ldx #1 ; open existing file
jsr dos33_open ; open file
bcs error_open
jsr dos33_read ; read buffer
bcc now_close
; got an error
; error 05 is OK (OUT OF DATA)
; because we try to read too much
ldy #$a
lda (FILEML),Y
cmp #5
beq now_close
jmp error_read
now_close:
jsr dos33_close ; close file
clc
bcs error_close
rts
error_open:
lda #$f5
brk
error_read:
ldy #$a
lda (FILEML),y
tay
lda #$f6
brk
error_close:
lda #$f7
brk
;=================================
; get_dos_buffer
;=================================
@ -224,6 +249,7 @@ dos33_close:
sta (FILEML),y
jsr filemanager_interface
bcs error_close
ldy #0 ; mark dos buffer as free again
tya
@ -246,7 +272,7 @@ dos33_read:
ldy #6 ; point to number of bytes to read
lda #<read_size
sta (FILEML),y ; we want to read 255 bytes
sta (FILEML),y ; we want to read read_size bytes
iny
lda #>read_size
sta (FILEML),y
@ -258,7 +284,7 @@ dos33_read:
lda #>disk_buff
sta (FILEML),y
bne filemanager_interface ; same as JMP
jmp filemanager_interface
filename:
; OUT.0

View File

@ -342,3 +342,8 @@ Thought it only took 1s max? Not in face of interrupts.
TIME_TAKEN ($88) stores how long took to decode
INTRO2: 60@19, 60@36, 62@50 61@1:03 61@1:32 60@2:05 61@2:32
+ Our old friend, forget the # so we're comparing against some random
zero page value rather than a constsant
+ Related, the accidentally put in a $ when I meant for it to be decimal.

View File

@ -132,18 +132,19 @@ mockingboard_found:
jsr new_song
; jsr increment_file ; debug
; jsr new_song
; cli
lda #<UNPACK_BUFFER ; set input pointer
sta INL
lda #>UNPACK_BUFFER
sta INH
;============================
; Enable 6502 interrupts
;============================
;cli ; clear interrupt mask
cli ; clear interrupt mask
;============================
@ -175,7 +176,7 @@ check_copy_loop:
inc COPY_OFFSET ; (opt: make subtract?) ; 5
lda #$14
lda #14 ; NOT HEX URGH!
cmp COPY_OFFSET
bne check_copy_loop
@ -232,6 +233,8 @@ done_play:
jsr increment_file
jsr new_song
cli
jmp main_loop
forever_loop:
@ -347,6 +350,10 @@ read_size EQU $4000
adc #0
sta LZ4_SRC+1
lda #<UNPACK_BUFFER ; set input pointer
sta INL
lda #>UNPACK_BUFFER
sta INH
; Decompress first chunks
@ -361,8 +368,6 @@ read_size EQU $4000
jsr setup_next_subsong
cli ; start playing
rts
;=================
@ -510,7 +515,7 @@ filename_found:
increment_file:
inc WHICH_FILE
lda WHICH_FILE
cmp NUM_FILES
cmp #NUM_FILES
bne done_increment
lda #0
sta WHICH_FILE

View File

@ -27,6 +27,9 @@ COLOR EQU $30
; dos33 zero page = 26-2f, 35-38, 3e 3f 40-4d
; overlap applesoft 67-6a,6f,70,af,b0,ca-cd,d8
; DOS33: Confirmed kills $68
RWTSL EQU $60
RWTSH EQU $61
DOSBUFL EQU $62
@ -35,8 +38,8 @@ FILEML EQU $64
FILEMH EQU $65
;TURNING EQU $60
;SCREEN_X EQU $61 ; not used?
SCREEN_Y EQU $67
WHICH_FILE EQU $68
;SCREEN_Y EQU $62
;ANGLE EQU $63
;HORIZ_SCALE_I EQU $64
@ -95,6 +98,8 @@ C_COLOR EQU $85
COPY_TIME EQU $86
DECOMPRESS_TIME EQU $87
TIME_TAKEN EQU $88
SCREEN_Y EQU $89
WHICH_FILE EQU $8A
;NUM2L EQU $80
;NUM2H EQU $81
;RESULT EQU $82 ; 83,84,85