diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 19 |
1 files changed, 9 insertions, 10 deletions
@@ -134,10 +134,9 @@ audio_talk(Device *d, u8 b0, u8 w) { | |||
134 | c->length <<= 12; // fixed point. | 134 | c->length <<= 12; // fixed point. |
135 | c->data = &d->mem[mempeek16(d->dat, 0xc)]; | 135 | c->data = &d->mem[mempeek16(d->dat, 0xc)]; |
136 | 136 | ||
137 | // TODO: Volume. | 137 | // Volume (Mono only for now). |
138 | c->vol = 12; // 0-64 | 138 | c->vol = MAX(d->dat[0xe] >> 4, d->dat[0xe] & 0xf); // 0-64 |
139 | // c->volume[0] = d->dat[0xe] >> 4; | 139 | c->vol *= 4 / 3; |
140 | // c->volume[1] = d->dat[0xe] & 0xf; | ||
141 | 140 | ||
142 | // Looping. | 141 | // Looping. |
143 | if (!(d->dat[0xf] & 0x80)) { | 142 | if (!(d->dat[0xf] & 0x80)) { |
@@ -150,16 +149,16 @@ audio_talk(Device *d, u8 b0, u8 w) { | |||
150 | c->pitch = d->dat[0xf] & 0x7f; | 149 | c->pitch = d->dat[0xf] & 0x7f; |
151 | 150 | ||
152 | // Initialization. | 151 | // Initialization. |
152 | u32 sampling_rate = length; | ||
153 | if (length > 256) { | 153 | if (length > 256) { |
154 | c->inc = pitch_table_44100[c->pitch]; | 154 | sampling_rate = 44100; |
155 | } else { | ||
156 | c->inc = pitch_table_variable[c->pitch] * length / AUDIO_FREQ; | ||
157 | } | 155 | } |
156 | c->inc = (pitch_table[c->pitch] * sampling_rate) >> 5; | ||
158 | 157 | ||
159 | txt_position(0, 0); | 158 | txt_position(0, 0); |
160 | txt_printf("note: %d \n", c->pitch); | 159 | txt_printf("note: %d \n", c->pitch); |
161 | txt_printf("inc: %ld \n", c->inc); | 160 | txt_printf("inc: %ld \n", c->inc); |
162 | txt_printf("length: %ld \n", c->length >> 12); | 161 | txt_printf("length: %ld \n", c->length >> 12); |
163 | } | 162 | } |
164 | } | 163 | } |
165 | 164 | ||