Mercurial > repos > blastem
comparison ym2612.c @ 371:0f8a759f1ff4
Use signed ints for things that represent signed values in YM2612 core
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 02 Jun 2013 13:42:33 -0700 |
parents | 5f215603d001 |
children | d42a8a3e4894 |
comparison
equal
deleted
inserted
replaced
370:5f215603d001 | 371:0f8a759f1ff4 |
---|---|
259 ym_operator * operator = context->operators + op; | 259 ym_operator * operator = context->operators + op; |
260 ym_channel * chan = context->channels + channel; | 260 ym_channel * chan = context->channels + channel; |
261 //TODO: Modulate phase by LFO if necessary | 261 //TODO: Modulate phase by LFO if necessary |
262 operator->phase_counter += operator->phase_inc; | 262 operator->phase_counter += operator->phase_inc; |
263 uint16_t phase = operator->phase_counter >> 10 & 0x3FF; | 263 uint16_t phase = operator->phase_counter >> 10 & 0x3FF; |
264 uint16_t mod = 0; | 264 int16_t mod = 0; |
265 switch (op % 4) | 265 switch (op % 4) |
266 { | 266 { |
267 case 0://Operator 1 | 267 case 0://Operator 1 |
268 //TODO: Feedback | 268 //TODO: Feedback |
269 break; | 269 break; |
321 if (first_key_on) { | 321 if (first_key_on) { |
322 dfprintf(debug_file, "op %d, base phase: %d, mod: %d, sine: %d, out: %d\n", op, phase, mod, sine_table[(phase+mod) & 0x1FF], pow_table[sine_table[phase & 0x1FF] + env]); | 322 dfprintf(debug_file, "op %d, base phase: %d, mod: %d, sine: %d, out: %d\n", op, phase, mod, sine_table[(phase+mod) & 0x1FF], pow_table[sine_table[phase & 0x1FF] + env]); |
323 } | 323 } |
324 phase += mod; | 324 phase += mod; |
325 | 325 |
326 uint16_t output = pow_table[sine_table[phase & 0x1FF] + env]; | 326 int16_t output = pow_table[sine_table[phase & 0x1FF] + env]; |
327 if (phase & 0x200) { | 327 if (phase & 0x200) { |
328 output = -output; | 328 output = -output; |
329 } | 329 } |
330 operator->output = output; | 330 operator->output = output; |
331 //Update the channel output if we've updated all operators | 331 //Update the channel output if we've updated all operators |
339 for (uint32_t op = ((chan->algorithm == 7) ? 0 : 1) + channel*4; op < (channel+1)*4; op++) { | 339 for (uint32_t op = ((chan->algorithm == 7) ? 0 : 1) + channel*4; op < (channel+1)*4; op++) { |
340 output += context->operators[op].output; | 340 output += context->operators[op].output; |
341 } | 341 } |
342 chan->output = output; | 342 chan->output = output; |
343 } | 343 } |
344 int16_t value = context->channels[channel].output & 0x3FE0; | |
345 if (value & 0x2000) { | |
346 value |= 0xC000; | |
347 } | |
348 if (first_key_on) { | 344 if (first_key_on) { |
349 dfprintf(debug_file, "channel %d output: %d\n", channel, value / 2); | 345 int16_t value = context->channels[channel].output & 0x3FE0; |
346 if (value & 0x2000) { | |
347 value |= 0xC000; | |
348 } | |
349 dfprintf(debug_file, "channel %d output: %d\n", channel, value / YM_VOLUME_DIVIDER); | |
350 } | 350 } |
351 } | 351 } |
352 //puts("operator update done"); | 352 //puts("operator update done"); |
353 } | 353 } |
354 context->current_op++; | 354 context->current_op++; |