From eded3c090853ff60add76713bb669875e4071527 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Fri, 17 May 2019 13:19:04 -0400 Subject: [PATCH] pt3: add looping support --- pt3_player/README.pt3_player | 3 ++- pt3_player/interrupt_handler.s | 46 +++++++++++++++++++++++++++++++++- pt3_player/pt3_lib.s | 9 ++++++- pt3_player/pt3_player.s | 1 + pt3_player/zp.inc | 2 +- 5 files changed, 57 insertions(+), 4 deletions(-) diff --git a/pt3_player/README.pt3_player b/pt3_player/README.pt3_player index 45c69d56..c7554d35 100644 --- a/pt3_player/README.pt3_player +++ b/pt3_player/README.pt3_player @@ -51,11 +51,12 @@ Using the PT3_PLAYER Right/Left arrow Switch songs Spacebar Pause playback. M Switch from 1MHz to 1.77MHz mode + L Enables looping in the song FUTURE FEATURES: Key to disable visualization Key to skip ahead/back in pattern list - L to enable looping in the song + ZX Compatability: ~~~~~~~~~~~~~~~~~ diff --git a/pt3_player/interrupt_handler.s b/pt3_player/interrupt_handler.s index 83bb854c..c89ce970 100644 --- a/pt3_player/interrupt_handler.s +++ b/pt3_player/interrupt_handler.s @@ -42,6 +42,19 @@ pt3_play_music: lda DONE_SONG beq mb_write_frame + lda LOOP ; see if looping + beq move_to_next + + lda pt3_loop + sta current_pattern + lda #$0 + sta current_line + sta current_subframe + sta DONE_SONG + + jmp done_interrupt + +move_to_next: ; same as "press right" lda #$40 jmp quiet_exit @@ -197,7 +210,7 @@ lowbar: key_M: cmp #'M' - bne key_left + bne key_L lda convert_177 eor #$1 @@ -218,6 +231,34 @@ at_1MHz: jmp done_key + + ;=========================== + ; L enables loop mode + +key_L: + cmp #'L' + bne key_left + + lda LOOP + eor #$1 + sta LOOP + beq music_looping + + ; update text on screen + + lda #'L'+$80 + sta $7D0+18 + sta $BD0+18 + jmp done_key + +music_looping: + lda #'/'+$80 + sta $7D0+18 + sta $BD0+18 + + jmp done_key + + ;====================== ; left key, to next song @@ -250,6 +291,9 @@ quiet_exit: sta DONE_PLAYING jsr clear_ay_both + lda #$ff ; also mute the channel + sta REGISTER_DUMP+7 ; just in case + exit_interrupt: ; pla ; restore a ; 4 diff --git a/pt3_player/pt3_lib.s b/pt3_player/pt3_lib.s index 8937ca89..4a6d27e2 100644 --- a/pt3_player/pt3_lib.s +++ b/pt3_player/pt3_lib.s @@ -192,7 +192,7 @@ note_c: pt3_version: .byte $0 pt3_frequency_table: .byte $0 pt3_speed: .byte $0 -pt3_num_patterns: .byte $0 +;pt3_num_patterns: .byte $0 pt3_loop: .byte $0 pt3_noise_period: .byte $0 @@ -227,6 +227,7 @@ convert_177: .byte $1 PT3_VERSION = $D PT3_HEADER_FREQUENCY = $63 PT3_SPEED = $64 +PT3_LOOP = $66 PT3_PATTERN_LOC_L = $67 PT3_PATTERN_LOC_H = $68 PT3_SAMPLE_LOC_L = $69 @@ -444,6 +445,12 @@ not_ascii_number: lda PT3_LOC+PT3_SPEED sta pt3_speed + ;======================= + ; load default speed + + lda PT3_LOC+PT3_LOOP + sta pt3_loop + rts diff --git a/pt3_player/pt3_player.s b/pt3_player/pt3_player.s index 381f4e33..87124bae 100644 --- a/pt3_player/pt3_player.s +++ b/pt3_player/pt3_player.s @@ -54,6 +54,7 @@ apple_iie: sta DRAW_PAGE sta DONE_PLAYING sta WHICH_FILE + sta LOOP ;======================= ; Detect mockingboard diff --git a/pt3_player/zp.inc b/pt3_player/zp.inc index 6ec04b5b..72c2f620 100644 --- a/pt3_player/zp.inc +++ b/pt3_player/zp.inc @@ -110,7 +110,7 @@ WHICH_FILE EQU $98 COLOR_MASK EQU $99 RASTERBARS_ON EQU $9A RANDOM_POINTER EQU $9B -;FRAME_COUNT EQU $9C +LOOP EQU $9C MB_VALUE EQU $9D ;MB_CHUNK EQU $9E MB_ADDRL EQU $9F