From 0c62d901d2eda443ebc25b29102fb1e9d39cebd2 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Wed, 19 Jan 2022 00:51:08 -0500 Subject: [PATCH] tiny_tracker: a few more bytes --- demos/l/music_256/Makefile | 4 +- .../{apple2_80_zp.inc => apple2_60_zp.inc} | 2 +- demos/l/music_256/ay3_write_regs.s | 7 +-- demos/l/music_256/d2.s | 9 +++- demos/l/music_256/mockingboard_init.s | 30 ++++++++++--- demos/l/music_256/text_to_tiny.c | 45 +++++++++++-------- demos/l/music_256/zp.inc | 3 +- 7 files changed, 63 insertions(+), 37 deletions(-) rename demos/l/music_256/{apple2_80_zp.inc => apple2_60_zp.inc} (83%) diff --git a/demos/l/music_256/Makefile b/demos/l/music_256/Makefile index 8b94c027..71976def 100644 --- a/demos/l/music_256/Makefile +++ b/demos/l/music_256/Makefile @@ -15,7 +15,7 @@ submit: hgr_d2_1k.zip hgr_d2.dsk: HELLO D2 cp $(EMPTY_DISK)/empty.dsk ./hgr_d2.dsk $(DOS33) -y hgr_d2.dsk SAVE A HELLO - $(DOS33) -y hgr_d2.dsk -t BIN -a 0x80 BSAVE D2 + $(DOS33) -y hgr_d2.dsk -t BIN -a 0x60 BSAVE D2 #### @@ -37,7 +37,7 @@ mA2E_2.s: mA2E_2.txt text_to_tiny #### D2: d2.o - ld65 -o D2 d2.o -C ./apple2_80_zp.inc + ld65 -o D2 d2.o -C ./apple2_60_zp.inc d2.o: d2.s \ zp.inc hardware.inc \ diff --git a/demos/l/music_256/apple2_80_zp.inc b/demos/l/music_256/apple2_60_zp.inc similarity index 83% rename from demos/l/music_256/apple2_80_zp.inc rename to demos/l/music_256/apple2_60_zp.inc index a911b240..35f4313d 100644 --- a/demos/l/music_256/apple2_80_zp.inc +++ b/demos/l/music_256/apple2_60_zp.inc @@ -1,5 +1,5 @@ MEMORY { - ZP: start = $80, size = $120, type = rw; + ZP: start = $60, size = $120, type = rw; RAM: start = $100, size = $8E00, file = %O; } diff --git a/demos/l/music_256/ay3_write_regs.s b/demos/l/music_256/ay3_write_regs.s index 63eee339..09e90adf 100644 --- a/demos/l/music_256/ay3_write_regs.s +++ b/demos/l/music_256/ay3_write_regs.s @@ -5,11 +5,11 @@ ;===================== ;===================== ;===================== - ; write all 14 registers at AY_REGS + ; write all 13 registers at AY_REGS ay3_write_regs: - ldx #13 + ldx #12 ay3_write_reg_loop: lda #MOCK_AY_LATCH_ADDR ; latch_address for PB1 ; 2 @@ -29,6 +29,3 @@ ay3_write_reg_loop: dex bpl ay3_write_reg_loop -; rts - - diff --git a/demos/l/music_256/d2.s b/demos/l/music_256/d2.s index 8eda7f6c..db4f209a 100644 --- a/demos/l/music_256/d2.s +++ b/demos/l/music_256/d2.s @@ -32,9 +32,12 @@ ; 241 bytes -- forgot we didn't need to init volume in play_frame anymore ; 238 bytes -- can use Y to save note value in play_frame now ; 237 bytes -- make song terminator #$FF so we don't have to load it +; 235 bytes -- note X is $FF on entry to mockingboard entry .zeropage -;.globalzp rot_smc +.globalzp frequencies_low +.globalzp frequencies_high + d2: ; this is also the start of AY_REGS @@ -51,6 +54,8 @@ d2: .byte $38,$e,$e,$e ; mixer, A, B, C volume +.include "notes.inc" + skip_const: txs ; write 0 to stack pointer @@ -101,7 +106,7 @@ inner_wait: .byte $00,$00,$00,$00 .byte $00,$00,$00,$00,$00 .byte $00,$00,$00 -.byte $00 +.byte $00,$00,$00 ; music .include "mA2E_2.s" diff --git a/demos/l/music_256/mockingboard_init.s b/demos/l/music_256/mockingboard_init.s index dfe014a6..505097ce 100644 --- a/demos/l/music_256/mockingboard_init.s +++ b/demos/l/music_256/mockingboard_init.s @@ -65,13 +65,29 @@ mockingboard_init: ; Initialize the 6522s ; Reset Left AY-3-8910 ;=========================== + ; 15 bytes - ldx #$FF - stx MOCK_6522_DDRB1 - stx MOCK_6522_DDRA1 + ; X is FF on entry? - inx ; #MOCK_AY_RESET $0 - stx MOCK_6522_ORB1 - ldx #MOCK_AY_INACTIVE ; $4 - stx MOCK_6522_ORB1 +; ldx #$FF ; 2 + stx MOCK_6522_DDRB1 ; 3 $C402 + stx MOCK_6522_DDRA1 ; 3 $C403 + inx ; 1 #MOCK_AY_RESET $0 + stx MOCK_6522_ORB1 ; 3 $C400 + ldx #MOCK_AY_INACTIVE ; 2 $4 + stx MOCK_6522_ORB1 ; 3 $C400 + + +; lda #$FF ; 2 +; ldy #$2 ; 2 +; sta ($44),Y ; 2 +; iny ; 1 +; sta ($44),Y ; 2 + +; lda #0 ; 2 +; ldy #$0 ; 2 +; blah: +; sta $C400,Y ; 3 +; lda #$4 ; 2 +; sta (blah+1),Y ; 2 diff --git a/demos/l/music_256/text_to_tiny.c b/demos/l/music_256/text_to_tiny.c index 8c393164..231c4f9a 100644 --- a/demos/l/music_256/text_to_tiny.c +++ b/demos/l/music_256/text_to_tiny.c @@ -461,46 +461,55 @@ printf("\n"); printf("\t.byte $FF ; end\n"); total_len++; + + FILE *fff; + int o,n; + fff=fopen("notes.inc","w"); + if (fff==NULL) { + fprintf(stderr,"Oh no!\n"); + exit(1); + } + for(o=0;o<4;o++) { - printf("; Octave %d : ",o); + fprintf(fff,"; Octave %d : ",o); for(n=0;n<12;n++) { - printf("%d ",notes_used[(o*12)+n]); + fprintf(fff,"%d ",notes_used[(o*12)+n]); } - printf("\n"); + fprintf(fff,"\n"); } - printf("; %d notes allocated\n",notes_allocated); + fprintf(fff,"; %d notes allocated\n",notes_allocated); - printf(";.byte "); + fprintf(fff,";.byte "); for(n=0;n>8)); - if (n!=(notes_allocated-1)) printf(","); + fprintf(fff,"$%02X",(frequencies[allocated_notes[n]]>>8)); + if (n!=(notes_allocated-1)) fprintf(fff,","); total_len++; } - printf("\n"); + fprintf(fff,"\n"); - printf("; total len=%d\n",total_len); + fprintf(fff,"; total len=%d\n",total_len); (void) irq; (void) loop; diff --git a/demos/l/music_256/zp.inc b/demos/l/music_256/zp.inc index 86c412d5..91b010bb 100644 --- a/demos/l/music_256/zp.inc +++ b/demos/l/music_256/zp.inc @@ -9,8 +9,7 @@ GBASH = $27 BASL = $28 BASH = $29 -AY_REGS = $80 -SAVE = $60 +AY_REGS = $60 HGR_Y = $E2 HGR_COLOR = $E4