changeset 930:f33e8d88ab6f

Add yt debug command for printing YM-2612 timer info. Fix AMS shift values.
author Michael Pavone <pavone@retrodev.com>
date Sat, 13 Feb 2016 22:20:37 -0800
parents 0ee8cfcc06d1
children 126c0294c1e4
files debug.c ym2612.c ym2612.h
diffstat 3 files changed, 38 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/debug.c	Wed Feb 10 20:05:39 2016 -0800
+++ b/debug.c	Sat Feb 13 22:20:37 2016 -0800
@@ -775,6 +775,10 @@
 						ym_print_channel_info(gen->ym, i);
 					}
 				}
+				break;
+			case 't':
+				ym_print_timer_info(gen->ym);
+				break;
 			}
 			break;
 		}
--- a/ym2612.c	Wed Feb 10 20:05:39 2016 -0800
+++ b/ym2612.c	Sat Feb 13 22:20:37 2016 -0800
@@ -86,7 +86,7 @@
 };
 int16_t lfo_pm_table[128 * 32 * 8];
 
-uint16_t ams_shift[] = {8, 3, 1, 0};
+int16_t ams_shift[] = {8, 1, -1, -2};
 
 #define MAX_ENVELOPE 0xFFC
 #define YM_DIVIDER 2
@@ -439,7 +439,11 @@
 			uint16_t env = operator->envelope + operator->total_level;
 			if (operator->am) {
 				uint16_t base_am = (context->lfo_am_step & 0x80 ? context->lfo_am_step : ~context->lfo_am_step) & 0x7E;
-				env += base_am >> ams_shift[chan->ams];
+				if (ams_shift[chan->ams] >= 0) {
+					env += base_am >> ams_shift[chan->ams];
+				} else {
+					env += base_am << (-ams_shift[chan->ams]);
+				}
 			}
 			if (env > MAX_ENVELOPE) {
 				env = MAX_ENVELOPE;
@@ -856,6 +860,11 @@
 		   channel+1, chan->algorithm, chan->feedback,
 		   chan->lr == 0xC0 ? "LR" : chan->lr == 0x80 ? "L" : chan->lr == 0x40 ? "R" : "",
 		   chan->ams, chan->pms);
+	if (channel == 2) {
+		printf(
+		   "Mode:      %X: %s\n",
+		   context->ch3_mode, context->ch3_mode ? "special" : "normal");
+	}
 	for (int operator = channel * 4; operator < channel * 4+4; operator++)
 	{
 		int dispnum = operator - channel * 4 + 1;
@@ -883,3 +892,25 @@
 	}
 }
 
+void ym_print_timer_info(ym2612_context *context)
+{
+	printf("***Timer A***\n"
+	       "Current Value: %d\n"
+		   "Load Value:    %d\n"
+		   "Triggered:     %s\n"
+		   "Enabled:       %s\n\n",
+		   context->timer_a,
+		   context->timer_a_load,
+		   context->status & BIT_STATUS_TIMERA ? "yes" : "no",
+		   context->timer_control & BIT_TIMERA_ENABLE ? "yes" : "no");
+	printf("***Timer B***\n"
+	       "Current Value: %d\n"
+		   "Load Value:    %d\n"
+		   "Triggered:     %s\n"
+		   "Enabled:       %s\n\n",
+		   context->timer_b,
+		   context->timer_b_load,
+		   context->status & BIT_STATUS_TIMERB ? "yes" : "no",
+		   context->timer_control & BIT_TIMERB_ENABLE ? "yes" : "no");
+}
+
--- a/ym2612.h	Wed Feb 10 20:05:39 2016 -0800
+++ b/ym2612.h	Sat Feb 13 22:20:37 2016 -0800
@@ -134,6 +134,7 @@
 uint8_t ym_load_gst(ym2612_context * context, FILE * gstfile);
 uint8_t ym_save_gst(ym2612_context * context, FILE * gstfile);
 void ym_print_channel_info(ym2612_context *context, int channel);
+void ym_print_timer_info(ym2612_context *context);
 
 #endif //YM2612_H_