mirror of
https://github.com/deater/dos33fsprogs.git
synced 2024-06-07 08:30:20 +00:00
tiny_tracker3: room for 140 byte program
This commit is contained in:
parent
36fcc72dde
commit
b7cd2f386a
|
@ -17,6 +17,7 @@
|
|||
; 393 bytes -- don't keep song offset in Y
|
||||
; 390 bytes -- use Y instead of X
|
||||
; 388 bytes -- optimizing octave selection
|
||||
; 373 bytes -- completely redo file format to avoid freq table
|
||||
|
||||
d2:
|
||||
|
||||
|
|
|
@ -78,41 +78,25 @@ all_ok:
|
|||
|
||||
note_only:
|
||||
tya
|
||||
; CCOONNNN -- c=channel, o=octave, n=note
|
||||
; TODO: OONNNNCC instead?
|
||||
; CCXNNNNN -- c=channel, n=note
|
||||
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
sta OCTAVE ; save octave for later
|
||||
lsr
|
||||
and #$FE ; fine register value, want in X
|
||||
tax
|
||||
|
||||
tya ; get note
|
||||
and #$3F
|
||||
and #$1F
|
||||
tay ; lookup in table
|
||||
lda frequency_lookup_low,Y
|
||||
lda frequencies_low,Y
|
||||
|
||||
sta AY_REGS,X ; set proper register value
|
||||
|
||||
; set coarse note A
|
||||
; hack: if octave=0 (C2) then coarse=1
|
||||
; else coarse=0
|
||||
|
||||
inx ; point to corase register
|
||||
|
||||
lda OCTAVE
|
||||
and #$3 ; if 0 then 1
|
||||
; if 1,2,3 then 0
|
||||
beq invert
|
||||
|
||||
lda #1
|
||||
invert:
|
||||
eor #$1
|
||||
|
||||
sta AY_REGS,X
|
||||
lda frequencies_high,Y
|
||||
sta AY_REGS+1,X
|
||||
|
||||
jsr ay3_write_regs ; trashes A/X/Y
|
||||
|
||||
|
|
|
@ -35,15 +35,6 @@ ay3_write_reg_loop:
|
|||
rts
|
||||
|
||||
|
||||
; starts at C4
|
||||
frequency_lookup_low:
|
||||
.byte $E8,$CD,$B3,$9B,$83,$6E,$59,$46,$33,$22,$12,$02
|
||||
|
||||
;$1E8,$1CD,$1B3,$19B,$183,$16E,$159,$146,$133,$122,$112,$102,
|
||||
;.byte $F4,$E6,$D9,$CD,$C1,$B7,$AC,$A3,$99,$91,$89,$81,$00,$00,$00,$00
|
||||
;.byte $7A,$73,$6C,$66,$60,$5B,$56,$51,$4C,$48,$44,$40,$00,$00,$00,$00
|
||||
;.byte $3D,$39,$36,$33,$30,$2D,$2B,$28,$26,$24,$22,$20,$00,$00,$00,$00
|
||||
|
||||
|
||||
init_addresses:
|
||||
.byte <MOCK_6522_DDRB1,<MOCK_6522_DDRA1 ; set the data direction for all pins of PortA/PortB to be output
|
||||
|
|
|
@ -19,6 +19,15 @@ static int notes_used[64];
|
|||
static int allocated_notes[64];
|
||||
static int notes_allocated=0;
|
||||
|
||||
|
||||
unsigned short frequencies[]={
|
||||
//C C# D D# E F F# G G# A A# B
|
||||
0x1E8,0x1CD,0x1B3,0x19B,0x183,0x16E,0x159,0x146,0x133,0x122,0x112,0x102, //3
|
||||
0x0F4,0x0E6,0x0D9,0x0CD,0x0C1,0x0B7,0x0AC,0x0A3,0x099,0x091,0x089,0x081, //4
|
||||
0x07A,0x073,0x06C,0x066,0x060,0x05B,0x056,0x051,0x04C,0x048,0x044,0x040, //5
|
||||
0x03D,0x039,0x036,0x033,0x030,0x02D,0x02B,0x028,0x026,0x024,0x022,0x020, //6
|
||||
};
|
||||
|
||||
// CCOONNNN -- c=channel, o=octave, n=note
|
||||
|
||||
int note_to_ed(char note, int flat, int sharp, int octave) {
|
||||
|
@ -45,7 +54,8 @@ int note_to_ed(char note, int flat, int sharp, int octave) {
|
|||
if (sharp==2) offset+=2;
|
||||
|
||||
|
||||
offset=((((octave+octave_adjust)-3)&0x3)<<4)|offset;
|
||||
offset=((((octave+octave_adjust)-3)&0x3)*12)+offset;
|
||||
// offset=((((octave+octave_adjust)-3)&0x3)<<4)|offset;
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
@ -371,10 +381,11 @@ printf("\n");
|
|||
|
||||
|
||||
if (a.ed_freq>=0) {
|
||||
printf("\t.byte $%02X ; A = %c%c%d\n",
|
||||
printf("\t.byte $%02X ; A = %c%c%d freq=%d offset=%d\n",
|
||||
a.offset,
|
||||
a.note,sharp_char[a.sharp+2*a.flat],
|
||||
a.octave);
|
||||
a.octave,
|
||||
a.ed_freq,a.offset);
|
||||
}
|
||||
if (b.ed_freq>=0) {
|
||||
printf("\t.byte $%02X ; B = %c%c%d\n",
|
||||
|
@ -383,10 +394,11 @@ printf("\n");
|
|||
b.octave);
|
||||
}
|
||||
if (c.ed_freq>=0) {
|
||||
printf("\t.byte $%02X ; C = %c%c%d\n",
|
||||
printf("\t.byte $%02X ; C = %c%c%d freq=%d offset=%d\n",
|
||||
c.offset|0x80,
|
||||
c.note,sharp_char[c.sharp+2*c.flat],
|
||||
c.octave);
|
||||
c.octave,
|
||||
c.ed_freq,c.offset);
|
||||
}
|
||||
|
||||
current_length++;
|
||||
|
@ -414,6 +426,23 @@ printf("\n");
|
|||
}
|
||||
printf("\n");
|
||||
|
||||
printf("frequencies_high:\n");
|
||||
printf(".byte ");
|
||||
for(n=0;n<notes_allocated;n++) {
|
||||
printf("$%02X",(frequencies[allocated_notes[n]]>>8));
|
||||
if (n!=(notes_allocated-1)) printf(",");
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
|
||||
printf("frequencies_low:\n");
|
||||
printf(".byte ");
|
||||
for(n=0;n<notes_allocated;n++) {
|
||||
printf("$%02X",(frequencies[allocated_notes[n]])&0xff);
|
||||
if (n!=(notes_allocated-1)) printf(",");
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
(void) irq;
|
||||
(void) loop;
|
||||
(void) external_frequency;
|
||||
|
|
|
@ -1,24 +1,6 @@
|
|||
|
||||
tracker_init:
|
||||
|
||||
; create Frequency Table
|
||||
ldx #11
|
||||
make_freq_loop:
|
||||
sec
|
||||
lda frequency_lookup_low,X
|
||||
ror
|
||||
sta frequency_lookup_low+16,X
|
||||
lsr
|
||||
sta frequency_lookup_low+32,X
|
||||
lsr
|
||||
sta frequency_lookup_low+48,X
|
||||
|
||||
dex
|
||||
bpl make_freq_loop
|
||||
|
||||
inx
|
||||
stx frequency_lookup_low+28
|
||||
|
||||
; setup initial ay-3-8910 values (this depends on song)
|
||||
|
||||
lda #$38
|
||||
|
|
Loading…
Reference in New Issue
Block a user