mirror of
https://github.com/deater/dos33fsprogs.git
synced 2025-01-12 15:30:55 +00:00
chiptune: works if rasterbars turned off
This commit is contained in:
parent
f6e6bad974
commit
4e2e314fbc
@ -32,7 +32,7 @@ CHIPTUNE_PLAYER: chiptune_player.o
|
||||
chiptune_player.o: chiptune_player.s \
|
||||
../asm_routines/mockingboard.s \
|
||||
../asm_routines/dos33_routines.s \
|
||||
../asm_routines/lz4_decode_step.s \
|
||||
../asm_routines/lz4_decode.s \
|
||||
rasterbars.s volume_bars.s interrupt_handler.s \
|
||||
chip_title.inc zp.inc
|
||||
ca65 -o chiptune_player.o chiptune_player.s -l chiptune_player.lst
|
||||
|
@ -320,3 +320,24 @@ Interesting bugs that were hard to debug:
|
||||
Turns out I was padding the filename buffer with A0 but going
|
||||
one too far and it was writing A0 to the first byte of the
|
||||
hlin routine, and A0 is a LDY # instruction.
|
||||
|
||||
|
||||
|
||||
|
||||
Know the current problem, taking longer than 5s to decode file.
|
||||
Thought it only took 1s max? Not in face of interrupts.
|
||||
|
||||
Every 20,000 an interrupt
|
||||
1,500 for music
|
||||
7,500 for volume bars
|
||||
1,794 for raster bars
|
||||
2,000 for misc rest
|
||||
Roughly 13,000 cycles, leaving only 7000 to userspace
|
||||
|
||||
If takes 700,000 cycles to decode a block, will take 100
|
||||
Hz cycles, or 2s to finish? that should be doable.
|
||||
why does it instead take 15?
|
||||
Can play fine if I turn the raster bars off.
|
||||
|
||||
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
|
||||
|
Binary file not shown.
@ -22,6 +22,7 @@ UNPACK_BUFFER EQU $5E00 ; $5E00 - $9600, 14k, $3800
|
||||
sta DONE_PLAYING
|
||||
sta XPOS
|
||||
sta MB_CHUNK_OFFSET
|
||||
sta DECODE_ERROR
|
||||
|
||||
; print detection message
|
||||
|
||||
@ -151,21 +152,50 @@ mockingboard_found:
|
||||
; Loop forever
|
||||
;============================
|
||||
main_loop:
|
||||
lda DECODE_ERROR
|
||||
beq check_copy
|
||||
sei
|
||||
brk
|
||||
|
||||
check_copy:
|
||||
lda COPY_TIME
|
||||
beq check_decompress ; if zero, skip
|
||||
|
||||
lda #0
|
||||
sta COPY_OFFSET
|
||||
check_copy_loop:
|
||||
jsr page_copy ;6+3621
|
||||
|
||||
inc COPY_OFFSET ; (opt: make subtract?) ; 5
|
||||
|
||||
lda #$14
|
||||
cmp COPY_OFFSET
|
||||
bne check_copy_loop
|
||||
|
||||
lda #0 ; we are done
|
||||
sta COPY_TIME
|
||||
|
||||
check_decompress:
|
||||
lda DECOMPRESS_TIME
|
||||
beq check_done ; if zero, skip
|
||||
|
||||
jsr setup_next_subsong ; decompress
|
||||
|
||||
lda MB_CHUNK_OFFSET
|
||||
sta TIME_TAKEN
|
||||
|
||||
lda #0
|
||||
sta DECOMPRESS_TIME
|
||||
|
||||
;============================
|
||||
; rasters
|
||||
; visualization
|
||||
;============================
|
||||
|
||||
; jsr clear_top
|
||||
|
||||
; jsr draw_rasters
|
||||
|
||||
; jsr volume_bars
|
||||
|
||||
; jsr page_flip
|
||||
|
||||
|
||||
check_done:
|
||||
lda DONE_PLAYING
|
||||
beq main_loop
|
||||
|
||||
@ -298,18 +328,16 @@ read_size EQU $4000
|
||||
|
||||
lda #$0
|
||||
sta COPY_OFFSET
|
||||
sta DECOMPRESS_TIME
|
||||
lda #$3
|
||||
sta CHUNKSIZE
|
||||
lda #$20
|
||||
sta DECODER_STATE
|
||||
sta COPY_TIME
|
||||
|
||||
jsr setup_next_subsong
|
||||
|
||||
jsr lz4_decode_setup
|
||||
|
||||
our_lz4_loop:
|
||||
jsr lz4_decode_step
|
||||
bcc our_lz4_loop
|
||||
|
||||
rts
|
||||
|
||||
@ -317,12 +345,6 @@ our_lz4_loop:
|
||||
; next sub-song
|
||||
;=================
|
||||
setup_next_subsong:
|
||||
; lda #$0
|
||||
; sta COPY_OFFSET
|
||||
; lda #$3
|
||||
; sta CHUNKSIZE
|
||||
; lda #$20
|
||||
; sta DECODER_STATE
|
||||
|
||||
ldy #0
|
||||
|
||||
@ -340,7 +362,7 @@ setup_next_subsong:
|
||||
adc #0
|
||||
sta LZ4_SRC+1
|
||||
|
||||
; jsr lz4_decode ; decode
|
||||
jsr lz4_decode ; decode
|
||||
|
||||
; tail-call?
|
||||
|
||||
@ -448,7 +470,7 @@ krw_file:
|
||||
.include "../asm_routines/gr_setpage.s"
|
||||
.include "../asm_routines/dos33_routines.s"
|
||||
.include "../asm_routines/gr_hlin.s"
|
||||
.include "../asm_routines/lz4_decode_step.s"
|
||||
.include "../asm_routines/lz4_decode.s"
|
||||
.include "rasterbars.s"
|
||||
.include "volume_bars.s"
|
||||
.include "interrupt_handler.s"
|
||||
|
@ -145,33 +145,33 @@ mb_not_13:
|
||||
|
||||
phase_specific:
|
||||
|
||||
lda #$20 ; 2
|
||||
bit DECODER_STATE ; V=B, N=C else A ; 3
|
||||
bvs increment_offset ; 2nt/3
|
||||
bmi decompress_step ; 2nt/3
|
||||
; lda #$20 ; 2
|
||||
; bit DECODER_STATE ; V=B, N=C else A ; 3
|
||||
; bvs increment_offset ; 2nt/3
|
||||
; bmi decompress_step ; 2nt/3
|
||||
|
||||
handle_copy:
|
||||
lda MB_CHUNK_OFFSET ; 3
|
||||
and #$0f ; 2
|
||||
bne increment_offset ; 2nt/3
|
||||
;handle_copy:
|
||||
; lda MB_CHUNK_OFFSET ; 3
|
||||
; and #$0f ; 2
|
||||
; bne increment_offset ; 2nt/3
|
||||
|
||||
lda COPY_OFFSET ; 3
|
||||
cmp #$14 ; 2
|
||||
beq increment_offset ; 2nt/3
|
||||
; lda COPY_OFFSET ; 3
|
||||
; cmp #$14 ; 2
|
||||
; beq increment_offset ; 2nt/3
|
||||
|
||||
jsr page_copy ;6+3621
|
||||
; jsr page_copy ;6+3621
|
||||
|
||||
inc COPY_OFFSET ; (opt: make subtract?) ; 5
|
||||
; inc COPY_OFFSET ; (opt: make subtract?) ; 5
|
||||
|
||||
jmp increment_offset ; 3
|
||||
; jmp increment_offset ; 3
|
||||
|
||||
decompress_step:
|
||||
lda LZ4_DONE
|
||||
bne increment_offset
|
||||
;decompress_step:
|
||||
; lda LZ4_DONE
|
||||
; bne increment_offset
|
||||
|
||||
jsr lz4_decode_step
|
||||
bcc increment_offset
|
||||
inc LZ4_DONE
|
||||
; jsr lz4_decode_step
|
||||
; bcc increment_offset
|
||||
; inc LZ4_DONE
|
||||
|
||||
;==============================================
|
||||
; incremement offset. If 0 move to next chunk
|
||||
@ -192,7 +192,7 @@ increment_offset:
|
||||
; 20 -> 40 -> 80 -> c+00
|
||||
bcs wraparound_to_a ; 3/2nt
|
||||
|
||||
bit DECODER_STATE
|
||||
bit DECODER_STATE ;bit7->N bit6->V
|
||||
bvs back_to_first_reg ; do nothing on B ; 3/2nt
|
||||
|
||||
start_c:
|
||||
@ -200,21 +200,24 @@ start_c:
|
||||
sta CHUNKSIZE
|
||||
|
||||
; setup next three chunks of song
|
||||
jsr setup_next_subsong ; and decompress next ; 6
|
||||
jsr lz4_decode_setup
|
||||
lda #0
|
||||
sta LZ4_DONE
|
||||
|
||||
lda #1 ; start decompressing
|
||||
sta DECOMPRESS_TIME ; outside of handler
|
||||
|
||||
jmp back_to_first_reg
|
||||
|
||||
wraparound_to_a:
|
||||
lda #$0
|
||||
sta COPY_OFFSET
|
||||
lda #$3
|
||||
sta CHUNKSIZE
|
||||
lda #$20
|
||||
sta DECODER_STATE
|
||||
sta COPY_TIME ; start copying
|
||||
|
||||
lda DECOMPRESS_TIME
|
||||
beq blah
|
||||
lda #1
|
||||
sta DECODE_ERROR
|
||||
blah:
|
||||
;==============================
|
||||
; After 14th reg, reset back to
|
||||
; read R0 data
|
||||
@ -236,7 +239,7 @@ back_to_first_reg_a:
|
||||
jmp update_r0_pointer ; 3
|
||||
|
||||
back_to_first_reg_c:
|
||||
lda #>(UNPACK_BUFFER+$2A00) ; in proper chunk (1 of 3) ; 2
|
||||
lda #>(UNPACK_BUFFER+$2A00) ; in linear C area ; 2
|
||||
|
||||
update_r0_pointer:
|
||||
sta INH ; update r0 pointer ; 3
|
||||
@ -260,7 +263,7 @@ done_interrupt:
|
||||
;============================
|
||||
|
||||
jsr clear_top
|
||||
jsr draw_rasters
|
||||
; jsr draw_rasters
|
||||
jsr volume_bars
|
||||
jsr page_flip
|
||||
|
||||
|
@ -20,41 +20,41 @@ draw_rasters:
|
||||
|
||||
; clear rows
|
||||
|
||||
ldy #(NUM_ROWS-1) ; 2
|
||||
lda #0 ; 2
|
||||
ldy #(NUM_ROWS-1) ; 2
|
||||
lda #0 ; 2
|
||||
|
||||
init_rows:
|
||||
sta row_color,Y ; 5
|
||||
dey ; 2
|
||||
bpl init_rows ; 2nt/3
|
||||
sta row_color,Y ; 5
|
||||
dey ; 2
|
||||
bpl init_rows ; 2nt/3
|
||||
|
||||
;================
|
||||
; set colors
|
||||
|
||||
lda #COLOR_BOTH_AQUA ; aqua
|
||||
ldy SCREEN_Y
|
||||
jsr set_row_color
|
||||
lda #COLOR_BOTH_AQUA ; aqua ; 2
|
||||
ldy SCREEN_Y ; 3
|
||||
jsr set_row_color ; 6+136
|
||||
|
||||
lda #COLOR_BOTH_MEDIUMBLUE ; medium blue
|
||||
jsr set_row_color
|
||||
lda #COLOR_BOTH_MEDIUMBLUE ; medium blue ; 2
|
||||
jsr set_row_color ; 6+136
|
||||
|
||||
lda #COLOR_BOTH_LIGHTGREEN ; light green
|
||||
jsr set_row_color
|
||||
lda #COLOR_BOTH_LIGHTGREEN ; light green ; 2
|
||||
jsr set_row_color ; 6+136
|
||||
|
||||
lda #COLOR_BOTH_DARKGREEN ; green
|
||||
jsr set_row_color
|
||||
lda #COLOR_BOTH_DARKGREEN ; green ; 2
|
||||
jsr set_row_color ; 6+136
|
||||
|
||||
lda #COLOR_BOTH_YELLOW ; yellow
|
||||
jsr set_row_color
|
||||
lda #COLOR_BOTH_YELLOW ; yellow ; 2
|
||||
jsr set_row_color ; 6+136
|
||||
|
||||
lda #COLOR_BOTH_ORANGE ; orange
|
||||
jsr set_row_color
|
||||
lda #COLOR_BOTH_ORANGE ; orange ; 2
|
||||
jsr set_row_color ; 6+136
|
||||
|
||||
lda #COLOR_BOTH_PINK ; pink
|
||||
jsr set_row_color
|
||||
lda #COLOR_BOTH_PINK ; pink ; 2
|
||||
jsr set_row_color ; 6+136
|
||||
|
||||
lda #COLOR_BOTH_RED ; red
|
||||
jsr set_row_color
|
||||
lda #COLOR_BOTH_RED ; red ; 2
|
||||
jsr set_row_color ; 6+136
|
||||
|
||||
;=================
|
||||
; draw rows
|
||||
@ -74,27 +74,27 @@ draw_rows_loop:
|
||||
ldy #39 ; 2
|
||||
sty V2 ; 3
|
||||
ldy #0 ; 2
|
||||
jsr hlin_double ; hlin y,V2 at A ; 63+(X*16)
|
||||
jsr hlin_double ; hlin y,V2 at A ; 63+(40*16)
|
||||
pla ; 4
|
||||
tay ; 2
|
||||
draw_rows_skip:
|
||||
dey ; 2
|
||||
bpl draw_rows_loop ; 2
|
||||
bpl draw_rows_loop ; 3/2nt
|
||||
|
||||
;==================
|
||||
; update y pointer
|
||||
;==================
|
||||
ldy SCREEN_Y
|
||||
iny
|
||||
cpy #ELEMENTS
|
||||
bne not_there
|
||||
ldy #0
|
||||
ldy SCREEN_Y ; 3
|
||||
iny ; 2
|
||||
cpy #ELEMENTS ; 2
|
||||
bne not_there ; 3/2nt
|
||||
ldy #0 ; 2
|
||||
not_there:
|
||||
sty SCREEN_Y
|
||||
|
||||
|
||||
rts
|
||||
sty SCREEN_Y ; 3
|
||||
|
||||
rts ; 6
|
||||
;===========
|
||||
; 1794
|
||||
;===================
|
||||
;===================
|
||||
; set_row_color
|
||||
@ -106,31 +106,33 @@ not_there:
|
||||
; A, X trashed
|
||||
|
||||
set_row_color:
|
||||
sta COLOR
|
||||
tya ; wrap y offset
|
||||
and #(ELEMENTS-1)
|
||||
tax
|
||||
sta COLOR ; 3
|
||||
tya ; wrap y offset ; 2
|
||||
and #(ELEMENTS-1) ; 2
|
||||
tax ; 2
|
||||
|
||||
lda fine_sine,X ; lookup sine value
|
||||
lda fine_sine,X ; lookup sine value ; 4
|
||||
; pre-shifted right by 4, sign-extended
|
||||
|
||||
clc
|
||||
adc #18 ; add in 18 to center on screen
|
||||
clc ; 2
|
||||
adc #18 ; add in 18 to center on screen ; 2
|
||||
|
||||
sin_no_more:
|
||||
|
||||
pha ; save row value
|
||||
jsr put_color ; put color at row
|
||||
pla ; restore row value
|
||||
pha ; save row value ; 3
|
||||
jsr put_color ; put color at row ; 6+44
|
||||
pla ; restore row value ; 4
|
||||
|
||||
clc ; increment row value
|
||||
adc #1
|
||||
clc ; increment row value ; 2
|
||||
adc #1 ; 2
|
||||
|
||||
jsr put_color ; put color at row
|
||||
jsr put_color ; put color at row ; 6+44
|
||||
|
||||
iny ; increment for next time
|
||||
iny ; increment for next time ; 2
|
||||
|
||||
rts
|
||||
rts ; 6
|
||||
;=============
|
||||
; 136
|
||||
|
||||
;==================
|
||||
; put_color
|
||||
@ -138,31 +140,33 @@ sin_no_more:
|
||||
; A = row to set color of
|
||||
; A trashed
|
||||
put_color:
|
||||
clc
|
||||
ror ; row/2, with even/odd in carry
|
||||
tax ; put row/2 in X
|
||||
clc ; 2
|
||||
ror ; row/2, with even/odd in carry ; 2
|
||||
tax ; put row/2 in X ; 2
|
||||
|
||||
bcc even_line ; if even, skip to even
|
||||
bcc even_line ; if even, skip to even ; 2nt/3
|
||||
odd_line:
|
||||
lda #$f0 ; load mask for odd
|
||||
bcs finish_line
|
||||
lda #$f0 ; load mask for odd ; 2
|
||||
bcs finish_line ; 2nt/3
|
||||
even_line:
|
||||
lda #$0f ; load mask for even
|
||||
lda #$0f ; load mask for even ; 2
|
||||
finish_line:
|
||||
sta MASK
|
||||
sta MASK ; 3
|
||||
|
||||
and COLOR ; mask off color
|
||||
sta COLOR2 ; store for later
|
||||
and COLOR ; mask off color ; 3
|
||||
sta COLOR2 ; store for later ; 3
|
||||
|
||||
lda MASK
|
||||
eor #$ff ; invert mask
|
||||
and row_color,X ; load existing color
|
||||
lda MASK ; 3
|
||||
eor #$ff ; invert mask ; 2
|
||||
and row_color,X ; load existing color ; 4
|
||||
|
||||
ora COLOR2 ; combine
|
||||
sta row_color,X ; store back
|
||||
ora COLOR2 ; combine ; 3
|
||||
sta row_color,X ; store back ; 5
|
||||
|
||||
rts
|
||||
rts ; 6
|
||||
|
||||
;===========
|
||||
; 44
|
||||
;======================
|
||||
; some arrays
|
||||
;======================
|
||||
|
@ -85,10 +85,14 @@ DECODER_STATE EQU $7F
|
||||
;NUM1H EQU $7F
|
||||
CHUNKSIZE EQU $80
|
||||
LZ4_DONE EQU $81
|
||||
DECODE_ERROR EQU $82
|
||||
|
||||
A_COLOR EQU $83
|
||||
B_COLOR EQU $84
|
||||
C_COLOR EQU $85
|
||||
COPY_TIME EQU $86
|
||||
DECOMPRESS_TIME EQU $87
|
||||
TIME_TAKEN EQU $88
|
||||
;NUM2L EQU $80
|
||||
;NUM2H EQU $81
|
||||
;RESULT EQU $82 ; 83,84,85
|
||||
|
Loading…
x
Reference in New Issue
Block a user