From d2f2d97ff1e60565dddd08758c250f4e4dd09f6d Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Sat, 15 Jan 2022 20:51:35 -0500 Subject: [PATCH] tiny_tracker: more optimization --- demos/l/d4/d2.s | 10 ++++++++++ demos/l/d4/play_frame.s | 29 ++++++++++++++++++++--------- demos/l/d4/text_to_tiny.c | 18 ++++++++++-------- demos/l/d4/tracker_init.s | 10 +++++----- 4 files changed, 45 insertions(+), 22 deletions(-) diff --git a/demos/l/d4/d2.s b/demos/l/d4/d2.s index 634f8fc6..74ede716 100644 --- a/demos/l/d4/d2.s +++ b/demos/l/d4/d2.s @@ -17,6 +17,8 @@ ; 250 bytes -- song only has 16 notes so can never be negative ; 249 bytes -- make terminating value $80 instead of $FF ; 247 bytes -- combine note loop. makes song a bit faster +; 245 bytes -- try to optimize writing out volume +; 255 bytes -- add in some visualization d2: @@ -33,7 +35,15 @@ tracker_song = peasant_song .include "tracker_init.s" + jsr SETGR + game_loop: + ; typically A=0, X=FF, Y=0 + +; lda $70 +;blah_smc: +; sta $400 +; inc blah_smc+1 ; start the music playing diff --git a/demos/l/d4/play_frame.s b/demos/l/d4/play_frame.s index 78637639..9be4ecf9 100644 --- a/demos/l/d4/play_frame.s +++ b/demos/l/d4/play_frame.s @@ -19,7 +19,7 @@ set_notes_loop: ; this song only 16 notes so valid notes always positive ; cmp #$80 - bpl all_ok + bpl not_end ;==================================== ; if at end, loop back to beginning @@ -27,20 +27,24 @@ set_notes_loop: asl ; reset song offset to 0 sta SONG_OFFSET beq set_notes_loop -all_ok: - -note_only: +not_end: ; NNNNNECC -- c=channel, e=end, n=note - tay ; save note in Y + pha ; save note and #3 + tax + ldy #$0E + sty AY_REGS+8,X ; $08 set volume A,B,C + asl tax ; put channel offset in X - tya + + pla ; restore note + tay and #$4 sta SONG_COUNTDOWN ; always 4 long? @@ -50,12 +54,19 @@ note_only: 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 +; sta $500,X + + lda frequencies_low,Y + sta AY_REGS,X ; set proper register value + + ; visualization +blah_urgh: + sta $400,Y + inc blah_urgh+1 + ;============================ ; point to next diff --git a/demos/l/d4/text_to_tiny.c b/demos/l/d4/text_to_tiny.c index f5f0450e..e06c41e5 100644 --- a/demos/l/d4/text_to_tiny.c +++ b/demos/l/d4/text_to_tiny.c @@ -479,6 +479,16 @@ printf("\n"); } printf("\n"); + /* put these first as we use the high bit to end things? */ + printf("frequencies_low:\n"); + printf(".byte "); + for(n=0;n