summaryrefslogtreecommitdiff
path: root/ym2612.c
diff options
context:
space:
mode:
Diffstat (limited to 'ym2612.c')
-rw-r--r--ym2612.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/ym2612.c b/ym2612.c
index cc2fd01..2e273c0 100644
--- a/ym2612.c
+++ b/ym2612.c
@@ -605,7 +605,7 @@ void ym_update_phase_inc(ym2612_context * context, ym_operator * operator, uint3
//detune
detune = detune_table[channel->keycode][operator->detune & 0x3];
}
- if (operator->detune & 0x40) {
+ if (operator->detune & 0x4) {
inc -= detune;
//this can underflow, mask to 17-bit result
inc &= 0x1FFFF;
@@ -615,6 +615,7 @@ void ym_update_phase_inc(ym2612_context * context, ym_operator * operator, uint3
//multiple
if (operator->multiple) {
inc *= operator->multiple;
+ inc &= 0xFFFFF;
} else {
//0.5
inc >>= 1;
@@ -748,6 +749,7 @@ void ym_data_write(ym2612_context * context, uint8_t value)
break;
case REG_DECAY_AM:
//TODO: AM flag for LFO
+ operator->am = value & 0x80;
operator->rates[PHASE_DECAY] = value & 0x1F;
break;
case REG_SUSTAIN_RATE:
@@ -821,3 +823,42 @@ uint8_t ym_read_status(ym2612_context * context)
return context->status;
}
+void ym_print_channel_info(ym2612_context *context, int channel)
+{
+ ym_channel *chan = context->channels + channel;
+ printf("\n***Channel %d***\n"
+ "Algorithm: %d\n"
+ "Feedback: %d\n"
+ "Pan: %s\n"
+ "AMS: %d\n"
+ "PMS: %d\n",
+ channel+1, chan->algorithm, chan->feedback,
+ chan->lr == 0xC0 ? "LR" : chan->lr == 0x80 ? "L" : chan->lr == 0x40 ? "R" : "",
+ chan->ams, chan->pms);
+ for (int operator = channel * 4; operator < channel * 4+4; operator++)
+ {
+ int dispnum = operator - channel * 4 + 1;
+ if (dispnum == 2) {
+ dispnum = 3;
+ } else if (dispnum == 3) {
+ dispnum = 2;
+ }
+ ym_operator *op = context->operators + operator;
+ printf("\nOperator %d:\n"
+ " Multiple: %d\n"
+ " Detune: %d\n"
+ " Total Level: %d\n"
+ " Attack Rate: %d\n"
+ " Key Scaling: %d\n"
+ " Decay Rate: %d\n"
+ " Sustain Level: %d\n"
+ " Sustain Rate: %d\n"
+ " Release Rate: %d\n"
+ " Amplitude Modulation %s\n",
+ dispnum, op->multiple, op->detune, op->total_level,
+ op->rates[PHASE_ATTACK], op->key_scaling, op->rates[PHASE_DECAY],
+ op->sustain_level, op->rates[PHASE_SUSTAIN], op->rates[PHASE_RELEASE],
+ op->am ? "On" : "Off");
+ }
+}
+