diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -114,7 +114,7 @@ screen_talk(Device *d, u8 b0, u8 w) { | |||
114 | 114 | ||
115 | static void | 115 | static void |
116 | audio_talk(Device *d, u8 b0, u8 w) { | 116 | audio_talk(Device *d, u8 b0, u8 w) { |
117 | AudioChannel *c = &channels[0]; | 117 | AudioChannel *c = &channels[d - devaudio]; |
118 | if(!w) { | 118 | if(!w) { |
119 | if(b0 == 0x2) { | 119 | if(b0 == 0x2) { |
120 | mempoke16(d->dat, 0x2, c->pos); | 120 | mempoke16(d->dat, 0x2, c->pos); |
@@ -123,12 +123,14 @@ audio_talk(Device *d, u8 b0, u8 w) { | |||
123 | // d->dat[0x4] = apu_get_vu(c); | 123 | // d->dat[0x4] = apu_get_vu(c); |
124 | } | 124 | } |
125 | } else if(b0 == 0xf) { | 125 | } else if(b0 == 0xf) { |
126 | u16 length = mempeek16(d->dat, 0xa); | ||
127 | |||
126 | // Disable the channel before updating. | 128 | // Disable the channel before updating. |
127 | c->data = NULL; | 129 | c->data = NULL; |
128 | 130 | ||
129 | // Data. | 131 | // Data. |
130 | c->pos = 0; | 132 | c->pos = 0; |
131 | c->length = mempeek16(d->dat, 0xa); | 133 | c->length = length; |
132 | c->length <<= 12; // fixed point. | 134 | c->length <<= 12; // fixed point. |
133 | c->data = &d->mem[mempeek16(d->dat, 0xc)]; | 135 | c->data = &d->mem[mempeek16(d->dat, 0xc)]; |
134 | 136 | ||
@@ -148,7 +150,11 @@ audio_talk(Device *d, u8 b0, u8 w) { | |||
148 | c->pitch = d->dat[0xf] & 0x7f; | 150 | c->pitch = d->dat[0xf] & 0x7f; |
149 | 151 | ||
150 | // Initialization. | 152 | // Initialization. |
151 | c->inc = pitch_table_44100[c->pitch]; | 153 | if (length > 256) { |
154 | c->inc = pitch_table_44100[c->pitch]; | ||
155 | } else { | ||
156 | c->inc = pitch_table_variable[c->pitch] * length / AUDIO_FREQ; | ||
157 | } | ||
152 | 158 | ||
153 | txt_position(0, 0); | 159 | txt_position(0, 0); |
154 | txt_printf("note: %d \n", c->pitch); | 160 | txt_printf("note: %d \n", c->pitch); |