mirror of
https://github.com/deater/dos33fsprogs.git
synced 2024-06-16 07:29:29 +00:00
tiny_tracker: working on smaller
This commit is contained in:
parent
081ddabaf6
commit
307a8ec58b
|
@ -6,11 +6,10 @@
|
||||||
.include "zp.inc"
|
.include "zp.inc"
|
||||||
.include "hardware.inc"
|
.include "hardware.inc"
|
||||||
|
|
||||||
; goal is 332 bytes
|
; aiming for under 256
|
||||||
|
|
||||||
|
; 309 bytes -- first try
|
||||||
|
|
||||||
; 319 bytes -- switch songs to mA2E_3
|
|
||||||
; 415 bytes -- double length of song
|
|
||||||
; 334 bytes -- merge length into value
|
|
||||||
|
|
||||||
; if can straddle interrupt vector, save 10 bytes
|
; if can straddle interrupt vector, save 10 bytes
|
||||||
; if can guarantee Y is 0 on entry, save 2 bytes
|
; if can guarantee Y is 0 on entry, save 2 bytes
|
||||||
|
@ -48,7 +47,7 @@ end:
|
||||||
|
|
||||||
|
|
||||||
; music
|
; music
|
||||||
.include "mA2E_3.s"
|
.include "mA2E_2.s"
|
||||||
.include "interrupt_handler.s"
|
.include "interrupt_handler.s"
|
||||||
; must be last
|
; must be last
|
||||||
.include "mockingboard_constants.s"
|
.include "mockingboard_constants.s"
|
||||||
|
|
|
@ -41,15 +41,16 @@ ay3_irq_handler:
|
||||||
bit MOCK_6522_T1CL
|
bit MOCK_6522_T1CL
|
||||||
|
|
||||||
; drop note down after first
|
; drop note down after first
|
||||||
lda #$C
|
; lda #$C
|
||||||
sta AY_REGS+8
|
; sta AY_REGS+8
|
||||||
sta AY_REGS+10
|
; sta AY_REGS+9
|
||||||
|
; sta AY_REGS+10
|
||||||
|
|
||||||
; lda #$0E
|
lda #$0E
|
||||||
; sta AY_REGS+8 ; $08 volume A
|
sta AY_REGS+8 ; $08 volume A
|
||||||
; lda #$0C
|
lda #$0C
|
||||||
; sta AY_REGS+9 ; $09 volume B
|
sta AY_REGS+9 ; $09 volume B
|
||||||
; sta AY_REGS+10 ; $0A volume C
|
sta AY_REGS+10 ; $0A volume C
|
||||||
|
|
||||||
|
|
||||||
;============================
|
;============================
|
||||||
|
@ -90,30 +91,22 @@ all_ok:
|
||||||
|
|
||||||
note_only:
|
note_only:
|
||||||
; tya
|
; tya
|
||||||
; NNNNNLLC -- c=channel, n=note
|
; NNNNNECC -- c=channel, n=note
|
||||||
|
|
||||||
tay
|
tay ; save note in Y
|
||||||
|
|
||||||
ldx #0
|
and #3
|
||||||
lsr
|
asl
|
||||||
bcc channel_a
|
tax ; put channel offset in X
|
||||||
ldx #4 ; skip to C
|
|
||||||
channel_a:
|
|
||||||
|
|
||||||
and #$3
|
lda #$2 ; always 4 lines long
|
||||||
sta SONG_COUNTDOWN
|
sta SONG_COUNTDOWN
|
||||||
; inc SONG_COUNTDOWN
|
|
||||||
|
|
||||||
tya
|
tya
|
||||||
lsr
|
lsr
|
||||||
lsr
|
lsr
|
||||||
lsr
|
lsr ; get note in A
|
||||||
|
|
||||||
; and #$FE ; fine register value, want in X
|
|
||||||
; tax
|
|
||||||
|
|
||||||
; tya ; get note
|
|
||||||
; and #$1F
|
|
||||||
tay ; lookup in table
|
tay ; lookup in table
|
||||||
lda frequencies_low,Y
|
lda frequencies_low,Y
|
||||||
|
|
||||||
|
|
|
@ -208,6 +208,45 @@ static void print_help(int just_version, char *exec_name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int write_note(int *a_last,int *b_last,int *c_last,int *total_len) {
|
||||||
|
|
||||||
|
unsigned char temp_value;
|
||||||
|
|
||||||
|
if (*a_last>=0) {
|
||||||
|
temp_value=(*a_last<<3)|0;
|
||||||
|
if ((*b_last<0) || (*c_last<0)) {
|
||||||
|
temp_value|=4;
|
||||||
|
}
|
||||||
|
printf("\t.byte $%02X ; A=%d L=%d\n",
|
||||||
|
temp_value,
|
||||||
|
*a_last,(*b_last<0)||(*c_last<0));
|
||||||
|
(*total_len)++;
|
||||||
|
*a_last=-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*b_last>=0) {
|
||||||
|
temp_value=(*b_last<<3)|1;
|
||||||
|
if (*c_last<0) temp_value|=4;
|
||||||
|
|
||||||
|
printf("\t.byte $%02X ; B=%d L=%d\n",
|
||||||
|
temp_value,
|
||||||
|
*b_last,(*c_last<0));
|
||||||
|
(*total_len)++;
|
||||||
|
*b_last=-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*c_last>=0) {
|
||||||
|
printf("\t.byte $%02X ; C=%d L=%d\n",
|
||||||
|
(unsigned char)(*c_last<<3)|4|2,
|
||||||
|
*c_last,1);
|
||||||
|
(*total_len)++;
|
||||||
|
*c_last=-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
|
||||||
char string[BUFSIZ];
|
char string[BUFSIZ];
|
||||||
|
@ -226,7 +265,7 @@ int main(int argc, char **argv) {
|
||||||
char comments[BUFSIZ];
|
char comments[BUFSIZ];
|
||||||
char *comments_ptr=comments;
|
char *comments_ptr=comments;
|
||||||
|
|
||||||
unsigned char sharp_char[]=" #-=";
|
// unsigned char sharp_char[]=" #-=";
|
||||||
|
|
||||||
/* Parse command line arguments */
|
/* Parse command line arguments */
|
||||||
while ((copt = getopt(argc, argv, "dhvo:i:"))!=-1) {
|
while ((copt = getopt(argc, argv, "dhvo:i:"))!=-1) {
|
||||||
|
@ -320,8 +359,7 @@ int main(int argc, char **argv) {
|
||||||
// int a_len=0,b_len=0,a_freq=0,b_freq=0;
|
// int a_len=0,b_len=0,a_freq=0,b_freq=0;
|
||||||
int current_length=0;
|
int current_length=0;
|
||||||
int first=1;
|
int first=1;
|
||||||
int a_last=-1,c_last=-1;
|
int a_last=-1,b_last=-1,c_last=-1;
|
||||||
unsigned char temp_value;
|
|
||||||
|
|
||||||
printf("peasant_song:\n");
|
printf("peasant_song:\n");
|
||||||
printf("; register init\n");
|
printf("; register init\n");
|
||||||
|
@ -376,29 +414,12 @@ printf("\n");
|
||||||
|
|
||||||
if ((a.ed_freq>=0)||(b.ed_freq>=0)||(c.ed_freq>=0)) {
|
if ((a.ed_freq>=0)||(b.ed_freq>=0)||(c.ed_freq>=0)) {
|
||||||
printf("; none: a=%d c=%d len=%d\n",a_last,c_last,current_length);
|
printf("; none: a=%d c=%d len=%d\n",a_last,c_last,current_length);
|
||||||
//NNNNNLLC
|
//(old) NNNNNLLC
|
||||||
|
//(new) NNNNNLCC
|
||||||
|
// L=Last
|
||||||
|
|
||||||
if (!first) {
|
if (!first) {
|
||||||
if (a_last>=0) {
|
write_note(&a_last,&b_last,&c_last,&total_len);
|
||||||
temp_value=(a_last<<3)|0;
|
|
||||||
if (c_last<0) temp_value|=(current_length<<1);
|
|
||||||
|
|
||||||
printf("\t.byte $%02X ; A=%d L=%d\n",
|
|
||||||
temp_value,
|
|
||||||
a_last,c_last>=0?0:current_length);
|
|
||||||
total_len++;
|
|
||||||
a_last=-1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (c_last>=0) {
|
|
||||||
printf("\t.byte $%02X ; C=%d L=%d\n",
|
|
||||||
(unsigned char)(c_last<<3)|((current_length)<<1)|1,
|
|
||||||
c_last,current_length);
|
|
||||||
total_len++;
|
|
||||||
c_last=-1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
current_length=0;
|
current_length=0;
|
||||||
|
|
||||||
|
@ -419,38 +440,12 @@ printf("\n");
|
||||||
a_last=a.offset;
|
a_last=a.offset;
|
||||||
}
|
}
|
||||||
if (b.ed_freq>=0) {
|
if (b.ed_freq>=0) {
|
||||||
|
b_last=b.offset;
|
||||||
}
|
}
|
||||||
if (c.ed_freq>=0) {
|
if (c.ed_freq>=0) {
|
||||||
c_last=c.offset;
|
c_last=c.offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (a.ed_freq>=0) {
|
|
||||||
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.ed_freq,a.offset);
|
|
||||||
total_len++;
|
|
||||||
}
|
|
||||||
if (b.ed_freq>=0) {
|
|
||||||
printf("\t.byte $%02X ; B = %c%c%d\n",
|
|
||||||
b.offset|0x40,
|
|
||||||
b.note,sharp_char[b.sharp+2*b.flat],
|
|
||||||
b.octave);
|
|
||||||
total_len++;
|
|
||||||
}
|
|
||||||
if (c.ed_freq>=0) {
|
|
||||||
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.ed_freq,c.offset);
|
|
||||||
total_len++;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
current_length++;
|
current_length++;
|
||||||
|
|
||||||
|
|
||||||
|
@ -458,28 +453,7 @@ printf("\n");
|
||||||
|
|
||||||
|
|
||||||
printf("; last: a=%d c=%d len=%d\n",a_last,c_last,current_length);
|
printf("; last: a=%d c=%d len=%d\n",a_last,c_last,current_length);
|
||||||
if (a_last>=0) {
|
write_note(&a_last,&b_last,&c_last,&total_len);
|
||||||
temp_value=(a_last<<3)|0;
|
|
||||||
if (c_last<0) temp_value|=(current_length<<1);
|
|
||||||
printf("\t.byte $%02X ; A=%d L=%d\n",
|
|
||||||
temp_value,
|
|
||||||
a_last,c_last>=0?0:current_length);
|
|
||||||
total_len++;
|
|
||||||
a_last=-1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (c_last>=0) {
|
|
||||||
printf("\t.byte $%02X ; C=%d L=%d\n",
|
|
||||||
(unsigned char)(c_last<<3)|((current_length)<<1)|1,
|
|
||||||
c_last,current_length);
|
|
||||||
total_len++;
|
|
||||||
c_last=-1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// printf("\t.byte $%02X ; L = %d\n",
|
|
||||||
// current_length|0xc0,current_length);
|
|
||||||
// printf("\n");
|
|
||||||
|
|
||||||
printf("\t.byte $FF ; end\n");
|
printf("\t.byte $FF ; end\n");
|
||||||
total_len++;
|
total_len++;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user