From 53f9fc0bc2127f9f650afbc3a950be9ad49ab355 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Sat, 15 Jan 2022 15:07:13 -0500 Subject: [PATCH] tiny_tracker: get it working --- demos/l/d4/Makefile | 2 +- demos/l/d4/d2.s | 2 +- demos/l/d4/interrupt_handler.s | 110 +-------------------------------- demos/l/d4/play_frame.s | 96 ++++++++++++++++++++++++++++ demos/l/d4/text_to_tiny.c | 2 +- 5 files changed, 100 insertions(+), 112 deletions(-) create mode 100644 demos/l/d4/play_frame.s diff --git a/demos/l/d4/Makefile b/demos/l/d4/Makefile index 774a3759..46bc5cb2 100644 --- a/demos/l/d4/Makefile +++ b/demos/l/d4/Makefile @@ -57,7 +57,7 @@ D2: d2.o d2.o: d2.s \ zp.inc hardware.inc \ mA2E_2.s mA2E_3.s \ - interrupt_handler.s mockingboard_init.s \ + interrupt_handler.s mockingboard_init.s play_frame.s \ tracker_init.s mockingboard_constants.s ay3_write_regs.s ca65 -o d2.o d2.s -l d2.lst diff --git a/demos/l/d4/d2.s b/demos/l/d4/d2.s index 7337e193..47001941 100644 --- a/demos/l/d4/d2.s +++ b/demos/l/d4/d2.s @@ -8,7 +8,7 @@ ; aiming for under 256 -; 309 bytes -- first try +; 310 bytes -- initial ; if can straddle interrupt vector, save 10 bytes diff --git a/demos/l/d4/interrupt_handler.s b/demos/l/d4/interrupt_handler.s index 5db30029..227de2c6 100644 --- a/demos/l/d4/interrupt_handler.s +++ b/demos/l/d4/interrupt_handler.s @@ -40,116 +40,8 @@ ay3_irq_handler: bit MOCK_6522_T1CL - ; drop note down after first -; lda #$C -; sta AY_REGS+8 -; sta AY_REGS+9 -; sta AY_REGS+10 - lda #$0E - sta AY_REGS+8 ; $08 volume A - lda #$0C - sta AY_REGS+9 ; $09 volume B - sta AY_REGS+10 ; $0A volume C - - - ;============================ - ; see if still counting down - - lda SONG_COUNTDOWN - bpl done_update_song - -set_notes_loop: - - ;================== - ; load next byte - - ldy SONG_OFFSET - lda tracker_song,Y - - ;================== - ; see if hit end - - cmp #$FF - bne all_ok - - ;==================================== - ; if at end, loop back to beginning - - lda #0 ; reset song offset - sta SONG_OFFSET - beq set_notes_loop ; bra - -all_ok: - - ; see if note - -; tay -; and #$C0 -; cmp #$C0 -; beq handle_timing - -note_only: -; tya - ; NNNNNECC -- c=channel, n=note - - tay ; save note in Y - - and #3 - asl - tax ; put channel offset in X - - lda #$2 ; always 4 lines long - sta SONG_COUNTDOWN - - tya - lsr - lsr - lsr ; get note in A - - tay ; lookup in table - lda frequencies_low,Y - - sta AY_REGS,X ; set proper register value - - lda frequencies_high,Y - sta AY_REGS+1,X - - lda #$F - sta AY_REGS+8 - - ;============================ - ; point to next - - ; assume less than 256 bytes - inc SONG_OFFSET - - - lda SONG_COUNTDOWN - beq set_notes_loop ; bra - - - -.include "ay3_write_regs.s" - -; jsr ay3_write_regs - - - - - -handle_timing: - ; was timing - -; tya - -; and #$3f -; sta SONG_COUNTDOWN - -; inc SONG_OFFSET - -done_update_song: - dec SONG_COUNTDOWN +.include "play_frame.s" ;================================= diff --git a/demos/l/d4/play_frame.s b/demos/l/d4/play_frame.s new file mode 100644 index 00000000..9c3ec3bd --- /dev/null +++ b/demos/l/d4/play_frame.s @@ -0,0 +1,96 @@ +play_frame: + ; drop note down after first +; lda #$C +; sta AY_REGS+8 +; sta AY_REGS+9 +; sta AY_REGS+10 + + lda #$0E + sta AY_REGS+8 ; $08 volume A + lda #$0C + sta AY_REGS+9 ; $09 volume B + sta AY_REGS+10 ; $0A volume C + + + ;============================ + ; see if still counting down + + lda SONG_COUNTDOWN + bpl done_update_song + +set_notes_loop: + + ;================== + ; load next byte + + ldy SONG_OFFSET + lda tracker_song,Y + + ;================== + ; see if hit end + + cmp #$FF + bne all_ok + + ;==================================== + ; if at end, loop back to beginning + + lda #0 ; reset song offset + sta SONG_OFFSET + beq set_notes_loop ; bra + +all_ok: + +note_only: + + ; NNNNNECC -- c=channel, e=end, n=note + + tay ; save note in Y + + and #3 + asl + tax ; put channel offset in X + + tya + and #$4 + sta SONG_COUNTDOWN ; always 4 long? + + tya + lsr + lsr + lsr ; get note in A + + tay ; lookup in table + lda frequencies_low,Y + + sta AY_REGS,X ; set proper register value + + lda frequencies_high,Y + sta AY_REGS+1,X + + lda #$F + sta AY_REGS+8 + + ;============================ + ; point to next + + ; assume less than 256 bytes + inc SONG_OFFSET + + + lda SONG_COUNTDOWN + beq set_notes_loop ; bra + +.include "ay3_write_regs.s" + +done_update_song: + dec SONG_COUNTDOWN + + + + + + + + + diff --git a/demos/l/d4/text_to_tiny.c b/demos/l/d4/text_to_tiny.c index 0de4d6c8..066d6410 100644 --- a/demos/l/d4/text_to_tiny.c +++ b/demos/l/d4/text_to_tiny.c @@ -214,7 +214,7 @@ static int write_note(int *a_last,int *b_last,int *c_last,int *total_len) { if (*a_last>=0) { temp_value=(*a_last<<3)|0; - if ((*b_last<0) || (*c_last<0)) { + if ((*b_last<0) && (*c_last<0)) { temp_value|=4; } printf("\t.byte $%02X ; A=%d L=%d\n",