comparison ym2612.c @ 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 01fb50390b27
comparison
equal deleted inserted replaced
929:0ee8cfcc06d1 930:f33e8d88ab6f
84 {0, 0,0x10,0x18,0x20,0x20,0x28,0x30}, 84 {0, 0,0x10,0x18,0x20,0x20,0x28,0x30},
85 {0, 0,0x20,0x30,0x40,0x40,0x50,0x60} 85 {0, 0,0x20,0x30,0x40,0x40,0x50,0x60}
86 }; 86 };
87 int16_t lfo_pm_table[128 * 32 * 8]; 87 int16_t lfo_pm_table[128 * 32 * 8];
88 88
89 uint16_t ams_shift[] = {8, 3, 1, 0}; 89 int16_t ams_shift[] = {8, 1, -1, -2};
90 90
91 #define MAX_ENVELOPE 0xFFC 91 #define MAX_ENVELOPE 0xFFC
92 #define YM_DIVIDER 2 92 #define YM_DIVIDER 2
93 #define CYCLE_NEVER 0xFFFFFFFF 93 #define CYCLE_NEVER 0xFFFFFFFF
94 94
437 break; 437 break;
438 } 438 }
439 uint16_t env = operator->envelope + operator->total_level; 439 uint16_t env = operator->envelope + operator->total_level;
440 if (operator->am) { 440 if (operator->am) {
441 uint16_t base_am = (context->lfo_am_step & 0x80 ? context->lfo_am_step : ~context->lfo_am_step) & 0x7E; 441 uint16_t base_am = (context->lfo_am_step & 0x80 ? context->lfo_am_step : ~context->lfo_am_step) & 0x7E;
442 env += base_am >> ams_shift[chan->ams]; 442 if (ams_shift[chan->ams] >= 0) {
443 env += base_am >> ams_shift[chan->ams];
444 } else {
445 env += base_am << (-ams_shift[chan->ams]);
446 }
443 } 447 }
444 if (env > MAX_ENVELOPE) { 448 if (env > MAX_ENVELOPE) {
445 env = MAX_ENVELOPE; 449 env = MAX_ENVELOPE;
446 } 450 }
447 if (first_key_on) { 451 if (first_key_on) {
854 "AMS: %d\n" 858 "AMS: %d\n"
855 "PMS: %d\n", 859 "PMS: %d\n",
856 channel+1, chan->algorithm, chan->feedback, 860 channel+1, chan->algorithm, chan->feedback,
857 chan->lr == 0xC0 ? "LR" : chan->lr == 0x80 ? "L" : chan->lr == 0x40 ? "R" : "", 861 chan->lr == 0xC0 ? "LR" : chan->lr == 0x80 ? "L" : chan->lr == 0x40 ? "R" : "",
858 chan->ams, chan->pms); 862 chan->ams, chan->pms);
863 if (channel == 2) {
864 printf(
865 "Mode: %X: %s\n",
866 context->ch3_mode, context->ch3_mode ? "special" : "normal");
867 }
859 for (int operator = channel * 4; operator < channel * 4+4; operator++) 868 for (int operator = channel * 4; operator < channel * 4+4; operator++)
860 { 869 {
861 int dispnum = operator - channel * 4 + 1; 870 int dispnum = operator - channel * 4 + 1;
862 if (dispnum == 2) { 871 if (dispnum == 2) {
863 dispnum = 3; 872 dispnum = 3;
881 op->sustain_level, op->rates[PHASE_SUSTAIN], op->rates[PHASE_RELEASE], 890 op->sustain_level, op->rates[PHASE_SUSTAIN], op->rates[PHASE_RELEASE],
882 op->am ? "On" : "Off"); 891 op->am ? "On" : "Off");
883 } 892 }
884 } 893 }
885 894
895 void ym_print_timer_info(ym2612_context *context)
896 {
897 printf("***Timer A***\n"
898 "Current Value: %d\n"
899 "Load Value: %d\n"
900 "Triggered: %s\n"
901 "Enabled: %s\n\n",
902 context->timer_a,
903 context->timer_a_load,
904 context->status & BIT_STATUS_TIMERA ? "yes" : "no",
905 context->timer_control & BIT_TIMERA_ENABLE ? "yes" : "no");
906 printf("***Timer B***\n"
907 "Current Value: %d\n"
908 "Load Value: %d\n"
909 "Triggered: %s\n"
910 "Enabled: %s\n\n",
911 context->timer_b,
912 context->timer_b_load,
913 context->status & BIT_STATUS_TIMERB ? "yes" : "no",
914 context->timer_control & BIT_TIMERB_ENABLE ? "yes" : "no");
915 }
916