chiptune: working on being able to auto-switch to next file

This commit is contained in:
Vince Weaver 2018-02-25 19:02:00 -05:00
parent 4e2e314fbc
commit 2f4e90f4ab
4 changed files with 132 additions and 25 deletions

View File

@ -330,8 +330,9 @@ Thought it only took 1s max? Not in face of interrupts.
Every 20,000 an interrupt Every 20,000 an interrupt
1,500 for music 1,500 for music
7,500 for volume bars 7,500 for volume bars
1,794 for raster bars 16,200 (!)for raster bars
2,000 for misc rest 2,000 for misc rest
Roughly 13,000 cycles, leaving only 7000 to userspace Roughly 13,000 cycles, leaving only 7000 to userspace
If takes 700,000 cycles to decode a block, will take 100 If takes 700,000 cycles to decode a block, will take 100

View File

@ -7,6 +7,8 @@ UNPACK_BUFFER EQU $5E00 ; $5E00 - $9600, 14k, $3800
; trying not to hit DOS at $9600 ; trying not to hit DOS at $9600
; Reserve 3 chunks plus spare (14k) ; Reserve 3 chunks plus spare (14k)
NUM_FILES EQU 15
;============================= ;=============================
; Setup ; Setup
;============================= ;=============================
@ -24,6 +26,9 @@ UNPACK_BUFFER EQU $5E00 ; $5E00 - $9600, 14k, $3800
sta MB_CHUNK_OFFSET sta MB_CHUNK_OFFSET
sta DECODE_ERROR sta DECODE_ERROR
lda #1
sta WHICH_FILE
; print detection message ; print detection message
lda #<mocking_message ; load loading message lda #<mocking_message ; load loading message
@ -76,6 +81,8 @@ mockingboard_found:
; Enable 50Hz clock on 6522 ; Enable 50Hz clock on 6522
;============================ ;============================
sei ; disable interrupts just in case
lda #$40 ; Continuous interrupts, don't touch PB7 lda #$40 ; Continuous interrupts, don't touch PB7
sta $C40B ; ACR register sta $C40B ; ACR register
lda #$7F ; clear all interrupt flags lda #$7F ; clear all interrupt flags
@ -136,7 +143,7 @@ mockingboard_found:
; Enable 6502 interrupts ; Enable 6502 interrupts
;============================ ;============================
cli ; clear interrupt mask ;cli ; clear interrupt mask
;============================ ;============================
@ -201,33 +208,37 @@ check_done:
done_play: done_play:
; FIXME: disable timer on 6522 ; ; FIXME: disable timer on 6522
; FIXME: unhook interrupt handler ; ; FIXME: unhook interrupt handler
;
sei ; disable interrupts sei ; disable interrupts
;
jsr clear_ay_both jsr clear_ay_both
lda #0 lda #0
sta CH sta CH
jsr clear_bottoms jsr clear_bottoms
;
; lda #21
; sta CV
; lda #<done_message
; sta OUTL
; lda #>done_message
; sta OUTH
lda #21 ; jsr print_both_pages
sta CV
lda #<done_message
sta OUTL
lda #>done_message
sta OUTH
jsr print_both_pages jsr increment_file
jsr new_song
jmp main_loop
forever_loop: forever_loop:
jmp forever_loop jmp forever_loop
;================= ;=================
; load a new song ; load a new song
;================= ;=================
@ -271,10 +282,23 @@ new_song:
; Load in KRW file ; Load in KRW file
;=========================== ;===========================
lda #<krw_file ; point to filename jsr get_filename
sta INL
lda #>krw_file lda #8
sta INH sta CH
lda #21
sta CV
lda INL
sta OUTL
lda INH
sta OUTH
jsr print_both_pages
; lda #<krw_file ; point to filename
; sta INL
; lda #>krw_file
; sta INH
disk_buff EQU LZ4_BUFFER disk_buff EQU LZ4_BUFFER
read_size EQU $4000 read_size EQU $4000
@ -337,7 +361,7 @@ read_size EQU $4000
jsr setup_next_subsong jsr setup_next_subsong
cli ; start playing
rts rts
@ -437,11 +461,79 @@ page_copy_loop:
;====================== ;======================
; 2+14*256+6+29= 3621 ; 2+14*256+6+29= 3621
;==================
; Get filename
;==================
; WHICH_FILE holds number
; MAX_FILES has max
; Scroll through until find
; point INH:INL to it
get_filename:
ldy #0
ldx WHICH_FILE
lda #<krw_file ; point to filename
sta INL
lda #>krw_file
sta INH
get_filename_loop:
cpx #0
beq filename_found
inner_loop:
iny
lda (INL),Y
bne inner_loop
iny
dex
jmp get_filename_loop
filename_found:
tya
clc
adc INL
sta INL
lda INH
adc #0
sta INH
rts
;===============================
; Increment file we want to load
;===============================
increment_file:
inc WHICH_FILE
lda WHICH_FILE
cmp NUM_FILES
bne done_increment
lda #0
sta WHICH_FILE
done_increment:
rts
;===============================
; Decrement file we want to load
;===============================
decrement_file:
dec WHICH_FILE
bpl done_decrement
lda #(NUM_FILES-1)
sta WHICH_FILE
done_decrement:
rts
;========== ;==========
; filenames ; filenames
;========== ;==========
krw_file: krw_file:
.asciiz "INTRO2.KRW" .asciiz "INTRO2.KRW"
.asciiz "KORO.KRW"
.asciiz "DEATH2.KRW" .asciiz "DEATH2.KRW"
.asciiz "DEMO4.KRW" .asciiz "DEMO4.KRW"
.asciiz "WAVE.KRW" .asciiz "WAVE.KRW"
@ -482,7 +574,7 @@ mocking_message: .asciiz "LOOKING FOR MOCKINGBOARD IN SLOT #4"
not_message: .byte "NOT " not_message: .byte "NOT "
found_message: .asciiz "FOUND" found_message: .asciiz "FOUND"
done_message: .asciiz "DONE PLAYING" done_message: .asciiz "DONE PLAYING"
loading_message: .asciiz "LOADING..." loading_message: .asciiz "LOADING"
;============ ;============
; graphics ; graphics

View File

@ -22,11 +22,13 @@ draw_rasters:
ldy #(NUM_ROWS-1) ; 2 ldy #(NUM_ROWS-1) ; 2
lda #0 ; 2 lda #0 ; 2
init_rows: init_rows:
sta row_color,Y ; 5 sta row_color,Y ; 5
dey ; 2 dey ; 2
bpl init_rows ; 2nt/3 bpl init_rows ; 2nt/3
;==============
; 4+20*10 = 204
;================ ;================
; set colors ; set colors
@ -55,6 +57,9 @@ init_rows:
lda #COLOR_BOTH_RED ; red ; 2 lda #COLOR_BOTH_RED ; red ; 2
jsr set_row_color ; 6+136 jsr set_row_color ; 6+136
;==============
; 8 * 144
; 1152
;================= ;=================
; draw rows ; draw rows
@ -80,7 +85,9 @@ draw_rows_loop:
draw_rows_skip: draw_rows_skip:
dey ; 2 dey ; 2
bpl draw_rows_loop ; 3/2nt bpl draw_rows_loop ; 3/2nt
;=============
; 20 * 741
; 14,820
;================== ;==================
; update y pointer ; update y pointer
;================== ;==================
@ -93,8 +100,13 @@ not_there:
sty SCREEN_Y ; 3 sty SCREEN_Y ; 3
rts ; 6 rts ; 6
;=========== ;===========
; 1794 ; 24
;=============================
; total= 16,200
;=================== ;===================
;=================== ;===================
; set_row_color ; set_row_color

View File

@ -35,7 +35,9 @@ FILEML EQU $64
FILEMH EQU $65 FILEMH EQU $65
;TURNING EQU $60 ;TURNING EQU $60
;SCREEN_X EQU $61 ; not used? ;SCREEN_X EQU $61 ; not used?
SCREEN_Y EQU $62 SCREEN_Y EQU $67
WHICH_FILE EQU $68
;ANGLE EQU $63 ;ANGLE EQU $63
;HORIZ_SCALE_I EQU $64 ;HORIZ_SCALE_I EQU $64
;HORIZ_SCALE_F EQU $65 ;HORIZ_SCALE_F EQU $65