2018-02-16 05:12:53 +00:00
|
|
|
; VMW Chiptune Player
|
|
|
|
|
|
|
|
.include "zp.inc"
|
2018-02-24 21:57:20 +00:00
|
|
|
; program is ~4k, so from 0xc00 to 0x1C00
|
|
|
|
LZ4_BUFFER EQU $1C00 ; $1C00 - $5C00, 16k for now
|
2018-11-19 19:25:04 +00:00
|
|
|
DISK_BUFFER EQU $5D00 ; for disk loading
|
|
|
|
UNPACK_BUFFER EQU $6000 ; $6000 - $9800, 14k, $3800
|
|
|
|
|
|
|
|
; by using qkumba's RTS code
|
|
|
|
; no need for DOS, so we actually
|
|
|
|
; are free the whole way to $C000
|
|
|
|
; instead of stopping at $9600
|
|
|
|
; $6000 - $C000 = 24k
|
|
|
|
|
2018-02-24 22:28:10 +00:00
|
|
|
|
2018-02-26 00:02:00 +00:00
|
|
|
NUM_FILES EQU 15
|
|
|
|
|
2018-11-19 21:06:00 +00:00
|
|
|
|
|
|
|
jmp chiptune_setup
|
|
|
|
|
|
|
|
.include "chip_title_uncompressed.inc"
|
|
|
|
|
|
|
|
.align $400
|
|
|
|
|
2018-02-16 05:12:53 +00:00
|
|
|
;=============================
|
2018-02-18 05:13:30 +00:00
|
|
|
; Setup
|
2018-02-16 05:12:53 +00:00
|
|
|
;=============================
|
2018-11-19 21:06:00 +00:00
|
|
|
chiptune_setup:
|
|
|
|
; jsr HOME
|
|
|
|
; jsr TEXT
|
2018-02-16 05:12:53 +00:00
|
|
|
|
2018-11-19 19:25:04 +00:00
|
|
|
; Init disk code
|
|
|
|
|
|
|
|
jsr rts_init
|
|
|
|
|
2018-02-18 05:13:30 +00:00
|
|
|
; init variables
|
|
|
|
|
2018-02-16 05:12:53 +00:00
|
|
|
lda #0
|
|
|
|
sta DRAW_PAGE
|
|
|
|
sta CH
|
|
|
|
sta CV
|
|
|
|
sta DONE_PLAYING
|
2018-02-25 02:26:54 +00:00
|
|
|
sta MB_CHUNK_OFFSET
|
2018-02-25 21:01:01 +00:00
|
|
|
sta DECODE_ERROR
|
2018-02-16 05:12:53 +00:00
|
|
|
|
2018-11-19 21:06:00 +00:00
|
|
|
; lda #0
|
2018-06-11 19:47:40 +00:00
|
|
|
; lda #4 ; start at DEMO4
|
2018-03-12 20:00:40 +00:00
|
|
|
; lda #7 ; start at LYRA
|
2018-11-19 19:25:04 +00:00
|
|
|
; lda #10 ; start at SDEMO
|
2018-02-26 00:02:00 +00:00
|
|
|
sta WHICH_FILE
|
|
|
|
|
2018-11-19 21:06:00 +00:00
|
|
|
|
|
|
|
lda #$ff
|
|
|
|
sta RASTERBARS_ON
|
|
|
|
|
2018-02-18 05:13:30 +00:00
|
|
|
; print detection message
|
|
|
|
|
2018-11-19 21:06:00 +00:00
|
|
|
; lda #<mocking_message ; load loading message
|
|
|
|
; sta OUTL
|
|
|
|
; lda #>mocking_message
|
|
|
|
; sta OUTH
|
|
|
|
; jsr move_and_print ; print it
|
2018-02-16 05:12:53 +00:00
|
|
|
|
2018-02-16 05:13:34 +00:00
|
|
|
jsr mockingboard_detect_slot4 ; call detection routine
|
2018-02-16 05:12:53 +00:00
|
|
|
cpx #$1
|
|
|
|
beq mockingboard_found
|
|
|
|
|
2018-02-16 05:13:34 +00:00
|
|
|
lda #<not_message ; if not found, print that
|
2018-02-16 05:12:53 +00:00
|
|
|
sta OUTL
|
|
|
|
lda #>not_message
|
|
|
|
sta OUTH
|
|
|
|
inc CV
|
|
|
|
jsr move_and_print
|
|
|
|
|
2018-07-19 00:46:05 +00:00
|
|
|
; jmp forever_loop ; and wait forever
|
2018-02-16 05:12:53 +00:00
|
|
|
|
|
|
|
mockingboard_found:
|
2018-02-18 05:13:30 +00:00
|
|
|
; lda #<found_message ; print found message
|
|
|
|
; sta OUTL
|
|
|
|
; lda #>found_message
|
|
|
|
; sta OUTH
|
|
|
|
; inc CV
|
|
|
|
; jsr move_and_print
|
2018-02-16 05:12:53 +00:00
|
|
|
|
|
|
|
;============================
|
|
|
|
; Init the Mockingboard
|
|
|
|
;============================
|
|
|
|
|
|
|
|
jsr mockingboard_init
|
2018-02-17 05:26:58 +00:00
|
|
|
jsr reset_ay_both
|
|
|
|
jsr clear_ay_both
|
2018-02-16 05:12:53 +00:00
|
|
|
|
|
|
|
;=========================
|
|
|
|
; Setup Interrupt Handler
|
|
|
|
;=========================
|
|
|
|
; Vector address goes to 0x3fe/0x3ff
|
|
|
|
; FIXME: should chain any existing handler
|
|
|
|
|
|
|
|
lda #<interrupt_handler
|
|
|
|
sta $03fe
|
|
|
|
lda #>interrupt_handler
|
|
|
|
sta $03ff
|
|
|
|
|
|
|
|
;============================
|
|
|
|
; Enable 50Hz clock on 6522
|
|
|
|
;============================
|
|
|
|
|
2018-02-26 00:02:00 +00:00
|
|
|
sei ; disable interrupts just in case
|
|
|
|
|
2018-02-18 05:13:30 +00:00
|
|
|
lda #$40 ; Continuous interrupts, don't touch PB7
|
2018-02-16 05:12:53 +00:00
|
|
|
sta $C40B ; ACR register
|
|
|
|
lda #$7F ; clear all interrupt flags
|
|
|
|
sta $C40E ; IER register (interrupt enable)
|
|
|
|
|
|
|
|
lda #$C0
|
|
|
|
sta $C40D ; IFR: 1100, enable interrupt on timer one oflow
|
|
|
|
sta $C40E ; IER: 1100, enable timer one interrupt
|
|
|
|
|
|
|
|
lda #$E7
|
|
|
|
sta $C404 ; write into low-order latch
|
|
|
|
lda #$4f
|
|
|
|
sta $C405 ; write into high-order latch,
|
|
|
|
; load both values into counter
|
|
|
|
; clear interrupt and start counting
|
|
|
|
|
|
|
|
; 4fe7 / 1e6 = .020s, 50Hz
|
|
|
|
|
2018-02-16 05:13:34 +00:00
|
|
|
|
|
|
|
;============================
|
2018-02-18 05:13:30 +00:00
|
|
|
; Draw title screen
|
2018-02-16 05:13:34 +00:00
|
|
|
;============================
|
|
|
|
|
2018-11-19 21:06:00 +00:00
|
|
|
; jsr set_gr_page0 ; set page 0
|
2018-02-16 05:13:34 +00:00
|
|
|
|
2018-11-19 21:06:00 +00:00
|
|
|
; lda #$4 ; draw page 1
|
|
|
|
; sta DRAW_PAGE
|
|
|
|
|
|
|
|
; jsr clear_screens ; clear both screens
|
2018-02-16 05:13:34 +00:00
|
|
|
|
2018-11-19 21:06:00 +00:00
|
|
|
; lda #<chip_title ; point to title data
|
|
|
|
; sta GBASL
|
|
|
|
; lda #>chip_title
|
|
|
|
; sta GBASH
|
2018-02-16 05:13:34 +00:00
|
|
|
|
2018-11-19 21:06:00 +00:00
|
|
|
; bit PAGE1
|
2018-02-16 05:12:53 +00:00
|
|
|
|
2018-02-25 18:32:06 +00:00
|
|
|
; Load image ; load the image
|
2018-11-19 21:06:00 +00:00
|
|
|
; lda #<$800
|
|
|
|
; sta BASL
|
|
|
|
; lda #>$800
|
|
|
|
; sta BASH
|
2018-02-16 05:12:53 +00:00
|
|
|
|
2018-11-19 21:06:00 +00:00
|
|
|
; jsr load_rle_gr
|
2018-02-16 05:12:53 +00:00
|
|
|
|
2018-02-25 18:32:06 +00:00
|
|
|
;==================
|
2018-02-19 03:21:09 +00:00
|
|
|
; load first song
|
2018-02-25 18:32:06 +00:00
|
|
|
;==================
|
2018-02-18 03:45:17 +00:00
|
|
|
|
2018-02-19 03:21:09 +00:00
|
|
|
jsr new_song
|
2018-02-18 03:45:17 +00:00
|
|
|
|
2018-02-18 05:13:30 +00:00
|
|
|
;============================
|
|
|
|
; Init Background
|
|
|
|
;============================
|
2018-02-18 17:01:15 +00:00
|
|
|
jsr set_gr_page0
|
2018-02-18 03:45:17 +00:00
|
|
|
|
2018-02-18 17:01:15 +00:00
|
|
|
lda #0
|
|
|
|
sta DRAW_PAGE
|
|
|
|
sta SCREEN_Y
|
2018-02-16 05:12:53 +00:00
|
|
|
|
2018-02-26 06:33:34 +00:00
|
|
|
;============================
|
|
|
|
; Enable 6502 interrupts
|
|
|
|
;============================
|
|
|
|
|
|
|
|
cli ; clear interrupt mask
|
|
|
|
|
|
|
|
|
2018-02-16 05:12:53 +00:00
|
|
|
;============================
|
|
|
|
; Loop forever
|
|
|
|
;============================
|
2018-02-25 18:32:06 +00:00
|
|
|
main_loop:
|
2018-02-25 21:01:01 +00:00
|
|
|
lda DECODE_ERROR
|
|
|
|
beq check_copy
|
|
|
|
sei
|
|
|
|
brk
|
2018-02-18 05:13:30 +00:00
|
|
|
|
2018-02-25 21:01:01 +00:00
|
|
|
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
|
|
|
|
|
2018-02-26 05:47:06 +00:00
|
|
|
lda #14 ; NOT HEX URGH!
|
2018-02-25 21:01:01 +00:00
|
|
|
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
|
2018-02-18 05:13:30 +00:00
|
|
|
|
|
|
|
;============================
|
2018-02-25 21:01:01 +00:00
|
|
|
; visualization
|
2018-02-18 05:13:30 +00:00
|
|
|
;============================
|
2018-02-25 18:32:06 +00:00
|
|
|
; jsr clear_top
|
|
|
|
; jsr draw_rasters
|
|
|
|
; jsr volume_bars
|
|
|
|
; jsr page_flip
|
2018-02-18 17:27:51 +00:00
|
|
|
|
2018-02-25 21:01:01 +00:00
|
|
|
check_done:
|
2018-02-26 15:02:32 +00:00
|
|
|
lda #$ff
|
|
|
|
bit DONE_PLAYING
|
|
|
|
beq main_loop ; if was all zeros, loop
|
|
|
|
bmi main_loop ; if high bit set, paused
|
2018-02-26 16:10:31 +00:00
|
|
|
bvs minus_song ; if bit 6 set, then left pressed
|
2018-02-26 15:02:32 +00:00
|
|
|
|
2018-02-26 16:10:31 +00:00
|
|
|
; else, either song finished or
|
|
|
|
; right pressed
|
2018-02-16 05:12:53 +00:00
|
|
|
|
2018-02-26 16:10:31 +00:00
|
|
|
plus_song:
|
|
|
|
sei ; disable interrupts
|
|
|
|
jsr increment_file
|
|
|
|
jmp done_play
|
2018-02-16 05:12:53 +00:00
|
|
|
|
2018-02-26 16:10:31 +00:00
|
|
|
minus_song:
|
2018-02-16 05:12:53 +00:00
|
|
|
sei ; disable interrupts
|
2018-02-26 16:10:31 +00:00
|
|
|
jsr decrement_file
|
|
|
|
|
|
|
|
done_play:
|
2018-02-26 06:33:34 +00:00
|
|
|
|
|
|
|
lda #0
|
|
|
|
sta DONE_PLAYING
|
|
|
|
|
2018-02-16 05:12:53 +00:00
|
|
|
lda #0
|
|
|
|
sta CH
|
2018-02-22 06:07:02 +00:00
|
|
|
|
|
|
|
jsr clear_bottoms
|
|
|
|
|
2018-02-26 00:02:00 +00:00
|
|
|
jsr new_song
|
|
|
|
|
2018-02-26 06:33:34 +00:00
|
|
|
cli ; re-enable interrupts
|
2018-02-26 05:47:06 +00:00
|
|
|
|
2018-02-26 00:02:00 +00:00
|
|
|
jmp main_loop
|
2018-02-16 05:12:53 +00:00
|
|
|
|
|
|
|
forever_loop:
|
|
|
|
jmp forever_loop
|
|
|
|
|
2018-02-24 03:01:31 +00:00
|
|
|
|
2018-02-16 05:12:53 +00:00
|
|
|
|
2018-02-19 03:21:09 +00:00
|
|
|
;=================
|
|
|
|
; load a new song
|
|
|
|
;=================
|
|
|
|
|
|
|
|
new_song:
|
2018-02-22 03:50:34 +00:00
|
|
|
|
|
|
|
;=========================
|
|
|
|
; Init Variables
|
|
|
|
;=========================
|
|
|
|
|
|
|
|
lda #$0
|
|
|
|
sta FRAME_COUNT
|
2018-02-19 03:21:09 +00:00
|
|
|
sta A_VOLUME
|
|
|
|
sta B_VOLUME
|
|
|
|
sta C_VOLUME
|
2018-02-24 21:57:20 +00:00
|
|
|
sta COPY_OFFSET
|
2018-02-26 06:33:34 +00:00
|
|
|
sta DECOMPRESS_TIME
|
|
|
|
sta COPY_TIME
|
|
|
|
sta MB_CHUNK_OFFSET
|
2018-02-25 05:17:42 +00:00
|
|
|
lda #$20
|
2018-02-24 21:57:20 +00:00
|
|
|
sta DECODER_STATE
|
2018-02-25 05:17:42 +00:00
|
|
|
lda #3
|
|
|
|
sta CHUNKSIZE
|
2018-02-19 03:21:09 +00:00
|
|
|
|
2018-02-21 21:56:56 +00:00
|
|
|
;===========================
|
|
|
|
; Print loading message
|
|
|
|
;===========================
|
|
|
|
|
|
|
|
jsr clear_bottoms ; clear bottom of page 0/1
|
|
|
|
|
2018-02-22 01:32:40 +00:00
|
|
|
lda #0 ; print LOADING message
|
2018-02-21 21:56:56 +00:00
|
|
|
sta CH
|
|
|
|
lda #21
|
|
|
|
sta CV
|
|
|
|
|
|
|
|
lda #<loading_message
|
|
|
|
sta OUTL
|
|
|
|
lda #>loading_message
|
|
|
|
sta OUTH
|
|
|
|
jsr print_both_pages
|
|
|
|
|
|
|
|
|
2018-02-19 03:21:09 +00:00
|
|
|
;===========================
|
2018-02-22 03:50:34 +00:00
|
|
|
; Load in KRW file
|
2018-02-19 03:21:09 +00:00
|
|
|
;===========================
|
|
|
|
|
2018-02-26 00:02:00 +00:00
|
|
|
jsr get_filename
|
|
|
|
|
2018-11-19 19:25:04 +00:00
|
|
|
lda #8 ; print filename to screen
|
2018-02-26 00:02:00 +00:00
|
|
|
sta CH
|
|
|
|
lda #21
|
|
|
|
sta CV
|
|
|
|
|
|
|
|
lda INL
|
|
|
|
sta OUTL
|
|
|
|
lda INH
|
|
|
|
sta OUTH
|
|
|
|
jsr print_both_pages
|
|
|
|
|
2018-02-24 22:28:10 +00:00
|
|
|
|
2018-11-19 19:25:04 +00:00
|
|
|
; needs to be space-padded $A0 30-byte filename
|
2018-11-19 19:39:36 +00:00
|
|
|
|
2018-11-19 19:25:04 +00:00
|
|
|
lda #<readfile_filename
|
|
|
|
sta namlo
|
|
|
|
lda #>readfile_filename
|
|
|
|
sta namhi
|
2018-11-19 19:39:36 +00:00
|
|
|
|
|
|
|
ldy #0
|
|
|
|
ldx #30 ; 30 chars
|
|
|
|
name_loop:
|
|
|
|
lda (INL),Y
|
|
|
|
beq space_loop
|
|
|
|
ora #$80
|
|
|
|
sta (namlo),Y
|
|
|
|
iny
|
|
|
|
dex
|
|
|
|
bne name_loop
|
|
|
|
beq done_name_loop
|
|
|
|
space_loop:
|
|
|
|
lda #$a0 ; pad with ' '
|
|
|
|
sta (namlo),Y
|
|
|
|
iny
|
|
|
|
dex
|
|
|
|
bne space_loop
|
|
|
|
|
|
|
|
done_name_loop:
|
|
|
|
|
|
|
|
; open and read a file
|
|
|
|
; loads to whatever it was BSAVED at (default is $1C00)
|
|
|
|
|
2018-02-22 03:50:34 +00:00
|
|
|
jsr read_file ; read KRW file from disk
|
2018-02-19 03:21:09 +00:00
|
|
|
|
|
|
|
|
2018-02-19 05:08:42 +00:00
|
|
|
;=========================
|
2018-02-22 03:50:34 +00:00
|
|
|
; Print Info
|
2018-02-19 05:08:42 +00:00
|
|
|
;=========================
|
|
|
|
|
2018-02-21 21:56:56 +00:00
|
|
|
jsr clear_bottoms ; clear bottom of page 0/1
|
2018-02-19 05:08:42 +00:00
|
|
|
|
2018-02-23 05:16:43 +00:00
|
|
|
lda #>LZ4_BUFFER ; point to LZ4 data
|
2018-02-22 03:50:34 +00:00
|
|
|
sta OUTH
|
|
|
|
lda #<LZ4_BUFFER
|
|
|
|
sta OUTL
|
|
|
|
|
2018-02-23 05:16:43 +00:00
|
|
|
ldy #3 ; skip KRW magic at front
|
2018-02-22 03:50:34 +00:00
|
|
|
|
2018-02-23 05:16:43 +00:00
|
|
|
; print title
|
|
|
|
lda #20 ; VTAB 20: HTAB from file
|
|
|
|
jsr print_header_info
|
2018-02-19 05:08:42 +00:00
|
|
|
|
2018-02-23 05:16:43 +00:00
|
|
|
; Print Author
|
|
|
|
lda #21 ; VTAB 21: HTAB from file
|
|
|
|
jsr print_header_info
|
2018-02-19 05:08:42 +00:00
|
|
|
|
2018-02-23 05:16:43 +00:00
|
|
|
; Print clock
|
|
|
|
lda #23 ; VTAB 23: HTAB from file
|
|
|
|
jsr print_header_info
|
2018-02-19 05:08:42 +00:00
|
|
|
|
2018-02-26 15:40:03 +00:00
|
|
|
; Print Left Arrow (INVERSE)
|
|
|
|
lda #'<'
|
|
|
|
sta $750
|
|
|
|
sta $B50
|
|
|
|
|
|
|
|
lda #'-'
|
|
|
|
sta $751
|
|
|
|
sta $B51
|
|
|
|
|
|
|
|
; Print Rright Arrow (INVERSE)
|
|
|
|
lda #'-'
|
|
|
|
sta $776
|
|
|
|
sta $B76
|
|
|
|
|
|
|
|
lda #'>'
|
|
|
|
sta $777
|
|
|
|
sta $B77
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-02-23 05:16:43 +00:00
|
|
|
; Point LZ4 src at proper place
|
2018-02-19 05:08:42 +00:00
|
|
|
|
2018-02-22 03:50:34 +00:00
|
|
|
ldy #0
|
|
|
|
lda #>(LZ4_BUFFER+3)
|
2018-02-22 04:01:33 +00:00
|
|
|
sta LZ4_SRC+1
|
2018-02-22 03:50:34 +00:00
|
|
|
lda #<(LZ4_BUFFER+3)
|
2018-02-22 04:01:33 +00:00
|
|
|
sta LZ4_SRC
|
2018-02-22 03:50:34 +00:00
|
|
|
|
2018-02-22 04:01:33 +00:00
|
|
|
lda (LZ4_SRC),Y ; get header skip
|
2018-02-22 03:50:34 +00:00
|
|
|
clc
|
2018-02-22 04:01:33 +00:00
|
|
|
adc LZ4_SRC
|
|
|
|
sta LZ4_SRC
|
|
|
|
lda LZ4_SRC+1
|
2018-02-22 03:50:34 +00:00
|
|
|
adc #0
|
2018-02-22 04:01:33 +00:00
|
|
|
sta LZ4_SRC+1
|
2018-02-22 03:50:34 +00:00
|
|
|
|
2018-02-26 05:47:06 +00:00
|
|
|
lda #<UNPACK_BUFFER ; set input pointer
|
|
|
|
sta INL
|
|
|
|
lda #>UNPACK_BUFFER
|
|
|
|
sta INH
|
2018-02-22 04:06:02 +00:00
|
|
|
|
2018-02-25 06:08:14 +00:00
|
|
|
; Decompress first chunks
|
|
|
|
|
2018-02-25 05:17:42 +00:00
|
|
|
lda #$0
|
|
|
|
sta COPY_OFFSET
|
2018-02-25 21:01:01 +00:00
|
|
|
sta DECOMPRESS_TIME
|
2018-02-25 05:17:42 +00:00
|
|
|
lda #$3
|
|
|
|
sta CHUNKSIZE
|
|
|
|
lda #$20
|
|
|
|
sta DECODER_STATE
|
2018-02-25 21:01:01 +00:00
|
|
|
sta COPY_TIME
|
2018-02-22 04:06:02 +00:00
|
|
|
|
2018-02-25 06:08:14 +00:00
|
|
|
jsr setup_next_subsong
|
|
|
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
;=================
|
|
|
|
; next sub-song
|
|
|
|
;=================
|
|
|
|
setup_next_subsong:
|
|
|
|
|
2018-02-22 04:06:02 +00:00
|
|
|
ldy #0
|
|
|
|
|
|
|
|
lda (LZ4_SRC),Y ; get next size value
|
2018-02-22 04:01:33 +00:00
|
|
|
sta LZ4_END
|
2018-02-22 03:50:34 +00:00
|
|
|
iny
|
2018-02-22 04:01:33 +00:00
|
|
|
lda (LZ4_SRC),Y
|
|
|
|
sta LZ4_END+1
|
2018-02-22 03:50:34 +00:00
|
|
|
|
2018-02-22 04:06:02 +00:00
|
|
|
lda #2 ; increment pointer
|
2018-02-22 03:50:34 +00:00
|
|
|
clc
|
2018-02-22 04:01:33 +00:00
|
|
|
adc LZ4_SRC
|
|
|
|
sta LZ4_SRC
|
|
|
|
lda LZ4_SRC+1
|
2018-02-22 03:50:34 +00:00
|
|
|
adc #0
|
2018-02-22 04:01:33 +00:00
|
|
|
sta LZ4_SRC+1
|
2018-02-22 03:50:34 +00:00
|
|
|
|
2018-02-25 21:01:01 +00:00
|
|
|
jsr lz4_decode ; decode
|
2018-02-19 03:21:09 +00:00
|
|
|
|
2018-02-23 05:16:43 +00:00
|
|
|
; tail-call?
|
|
|
|
|
2018-02-19 03:21:09 +00:00
|
|
|
rts
|
2018-02-20 05:01:15 +00:00
|
|
|
|
2018-02-23 05:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
;===================
|
|
|
|
; print header info
|
|
|
|
;===================
|
|
|
|
; shortcut to print header info
|
|
|
|
; a = VTAB
|
|
|
|
|
|
|
|
print_header_info:
|
|
|
|
|
|
|
|
sta CV
|
|
|
|
|
|
|
|
iny ; adjust pointer
|
|
|
|
tya
|
|
|
|
ldy #0
|
|
|
|
clc
|
|
|
|
adc OUTL
|
|
|
|
sta OUTL
|
|
|
|
lda OUTH
|
|
|
|
adc #$0
|
|
|
|
sta OUTH
|
|
|
|
|
|
|
|
lda (OUTL),Y ; get HTAB value
|
|
|
|
sta CH
|
|
|
|
|
|
|
|
inc OUTL ; increment 16-bits
|
|
|
|
bne bloop22
|
|
|
|
inc OUTH
|
|
|
|
bloop22:
|
|
|
|
|
|
|
|
jmp print_both_pages ; print, tail call
|
|
|
|
|
|
|
|
|
2018-02-24 20:50:10 +00:00
|
|
|
;==============================================
|
|
|
|
; plan: takes 256 50Hz to play a chunk
|
|
|
|
; need to copy 14 256-byte blocks
|
|
|
|
; PLAY A (copying C)
|
|
|
|
; PLAY B (copying C)
|
|
|
|
; PLAY D (decompressing A/B/C)
|
|
|
|
|
2018-02-24 21:57:20 +00:00
|
|
|
|
2018-02-24 20:50:10 +00:00
|
|
|
;========================
|
|
|
|
; page copy
|
|
|
|
;========================
|
2018-02-24 21:57:20 +00:00
|
|
|
; want to copy:
|
|
|
|
; SRC: chunk_buffer+(2*256)+(COPY_OFFSET*3*256)
|
|
|
|
; DST: chunk_buffer+$2A00+(COPY_OFFSET*256)
|
2018-02-24 20:50:10 +00:00
|
|
|
page_copy:
|
2018-02-24 21:57:20 +00:00
|
|
|
clc ; 2
|
2018-02-24 22:23:30 +00:00
|
|
|
lda #>(UNPACK_BUFFER+512) ; 3
|
2018-02-24 21:57:20 +00:00
|
|
|
adc COPY_OFFSET ; 3
|
|
|
|
adc COPY_OFFSET ; 3
|
|
|
|
adc COPY_OFFSET ; 3
|
|
|
|
sta page_copy_loop+2 ; self modify ; 5
|
|
|
|
|
2018-02-24 22:23:30 +00:00
|
|
|
lda #>(UNPACK_BUFFER+$2A00) ; 2
|
2018-02-24 21:57:20 +00:00
|
|
|
adc COPY_OFFSET ; 3
|
|
|
|
sta page_copy_loop+5 ; self modify ; 5
|
2018-02-24 20:50:10 +00:00
|
|
|
|
|
|
|
ldx #$00 ; 2
|
|
|
|
page_copy_loop:
|
|
|
|
lda $1000,x ; 4
|
|
|
|
sta $1000,X ; 5
|
|
|
|
inx ; 2
|
|
|
|
bne page_copy_loop ; 2nt/3
|
|
|
|
rts ; 6
|
|
|
|
;======================
|
2018-02-24 21:57:20 +00:00
|
|
|
; 2+14*256+6+29= 3621
|
2018-02-23 05:16:43 +00:00
|
|
|
|
2018-02-26 00:02:00 +00:00
|
|
|
|
|
|
|
;==================
|
|
|
|
; 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
|
2018-02-26 05:47:06 +00:00
|
|
|
cmp #NUM_FILES
|
2018-02-26 00:02:00 +00:00
|
|
|
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
|
|
|
|
|
2018-02-22 01:32:40 +00:00
|
|
|
;==========
|
|
|
|
; filenames
|
|
|
|
;==========
|
2018-02-26 19:05:30 +00:00
|
|
|
|
2018-11-19 18:35:49 +00:00
|
|
|
krw_file:
|
2018-02-26 19:05:30 +00:00
|
|
|
|
2018-11-19 18:35:49 +00:00
|
|
|
.include "song_list.inc"
|
2018-02-22 01:32:40 +00:00
|
|
|
|
2018-02-16 05:12:53 +00:00
|
|
|
;=========
|
|
|
|
;routines
|
|
|
|
;=========
|
|
|
|
.include "../asm_routines/gr_offsets.s"
|
2018-07-19 00:46:05 +00:00
|
|
|
.include "text_print.s"
|
2018-02-17 05:26:58 +00:00
|
|
|
.include "../asm_routines/mockingboard_a.s"
|
2018-02-16 05:12:53 +00:00
|
|
|
.include "../asm_routines/gr_fast_clear.s"
|
2018-02-16 05:13:34 +00:00
|
|
|
.include "../asm_routines/pageflip.s"
|
2018-11-19 21:06:00 +00:00
|
|
|
;.include "../asm_routines/gr_unrle.s"
|
2018-02-16 05:13:34 +00:00
|
|
|
.include "../asm_routines/gr_setpage.s"
|
2018-11-19 19:25:04 +00:00
|
|
|
.include "qkumba_rts.s"
|
2018-02-18 17:01:15 +00:00
|
|
|
.include "../asm_routines/gr_hlin.s"
|
2018-02-25 21:01:01 +00:00
|
|
|
.include "../asm_routines/lz4_decode.s"
|
2018-02-26 15:02:32 +00:00
|
|
|
.include "../asm_routines/keypress_minimal.s"
|
2018-02-18 17:01:15 +00:00
|
|
|
.include "rasterbars.s"
|
2018-02-20 04:05:02 +00:00
|
|
|
.include "volume_bars.s"
|
2018-04-06 15:36:30 +00:00
|
|
|
.if .def(UNROLLED)
|
|
|
|
.include "interrupt_handler_unrolled.s"
|
|
|
|
.else
|
2018-02-24 22:23:30 +00:00
|
|
|
.include "interrupt_handler.s"
|
2018-04-06 15:36:30 +00:00
|
|
|
.endif
|
2018-02-16 05:12:53 +00:00
|
|
|
;=========
|
|
|
|
; strings
|
|
|
|
;=========
|
2018-11-19 21:06:00 +00:00
|
|
|
;mocking_message: .asciiz "LOOKING FOR MOCKINGBOARD IN SLOT #4"
|
2018-02-16 05:12:53 +00:00
|
|
|
not_message: .byte "NOT "
|
|
|
|
found_message: .asciiz "FOUND"
|
2018-02-26 06:33:34 +00:00
|
|
|
;done_message: .asciiz "DONE PLAYING"
|
2018-02-26 00:02:00 +00:00
|
|
|
loading_message: .asciiz "LOADING"
|
2018-02-16 05:12:53 +00:00
|
|
|
|