Added option to swap bytes in charge of duty cycles, a bug present on some Dendy models.

This commit is contained in:
feos-tas 2015-04-26 23:16:31 +00:00
parent 36e1b07c19
commit 21d94f7f27
8 changed files with 91 additions and 71 deletions

View File

@ -226,6 +226,7 @@ static CFGSTRUCT fceuconfig[] =
AC(soundNoisevol), AC(soundNoisevol),
AC(soundPCMvol), AC(soundPCMvol),
AC(muteTurbo), AC(muteTurbo),
AC(swapDuty),
AC(goptions), AC(goptions),
NAC("eoptions",eoptions), NAC("eoptions",eoptions),

View File

@ -147,6 +147,7 @@ int genie = 0;
int pal_emulation = 0; int pal_emulation = 0;
int pal_setting_specified = 0; int pal_setting_specified = 0;
int dendy = 0; int dendy = 0;
bool swapDuty = 0; // some dendy models had duty cycle bits swapped
int ntsccol = 0, ntsctint, ntschue; int ntsccol = 0, ntsctint, ntschue;
std::string BaseDirectory; std::string BaseDirectory;
int PauseAfterLoad; int PauseAfterLoad;

View File

@ -104,6 +104,7 @@ extern int soundPCMvol; //Sound channel PCM - volume control
extern int soundquality; extern int soundquality;
extern bool muteTurbo; extern bool muteTurbo;
extern bool swapDuty;
extern uint8 cpalette[192]; extern uint8 cpalette[192];
extern int srendlinen; extern int srendlinen;

View File

@ -422,8 +422,8 @@ BEGIN
COMBOBOX COMBO_SOUND_RATE,50,78,53,46,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP COMBOBOX COMBO_SOUND_RATE,50,78,53,46,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
COMBOBOX COMBO_SOUND_QUALITY,50,54,67,46,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP COMBOBOX COMBO_SOUND_QUALITY,50,54,67,46,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "Quality:",65455,17,54,27,10 LTEXT "Quality:",65455,17,54,27,10
CONTROL "Mute frame advance.",CHECK_SOUND_MUTEFA,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,110,87,11 CONTROL "Mute frame advance",CHECK_SOUND_MUTEFA,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,110,87,11
CONTROL "Mute Turbo.",CHECK_SOUND_MUTETURBO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,150,111,55,10 CONTROL "Mute Turbo",CHECK_SOUND_MUTETURBO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,138,111,53,10
GROUPBOX "Triangle",131,70,142,44,93,WS_GROUP GROUPBOX "Triangle",131,70,142,44,93,WS_GROUP
CONTROL "",CTL_VOLUME_TRACKBAR_TRIANGLE,"msctls_trackbar32",TBS_AUTOTICKS | TBS_VERT | TBS_BOTH | WS_TABSTOP,78,150,28,83 CONTROL "",CTL_VOLUME_TRACKBAR_TRIANGLE,"msctls_trackbar32",TBS_AUTOTICKS | TBS_VERT | TBS_BOTH | WS_TABSTOP,78,150,28,83
GROUPBOX "Square1",132,121,142,44,93,WS_GROUP GROUPBOX "Square1",132,121,142,44,93,WS_GROUP
@ -438,6 +438,7 @@ BEGIN
PUSHBUTTON "Restore defaults",IDC_SOUND_RESTOREDEFAULTVOL,19,238,56,11 PUSHBUTTON "Restore defaults",IDC_SOUND_RESTOREDEFAULTVOL,19,238,56,11
LTEXT "",ID_SOUND_TRITOP,76,135,38,8 LTEXT "",ID_SOUND_TRITOP,76,135,38,8
LTEXT "",ID_SOUND_QUALITYNOTIFY,170,133,144,8 LTEXT "",ID_SOUND_QUALITYNOTIFY,170,133,144,8
CONTROL "Swap Duty Cycles",CHECK_SOUND_SWAPDUTY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,239,110,74,10
END END
SUBORKBDIALOG DIALOGEX 13, 72, 478, 171 SUBORKBDIALOG DIALOGEX 13, 72, 478, 171

View File

@ -634,6 +634,7 @@
#define IDC_COPY_INPUT 1203 #define IDC_COPY_INPUT 1203
#define IDC_AUTORESUMECDLOGGING 1203 #define IDC_AUTORESUMECDLOGGING 1203
#define IDC_MASK_UNUSED_GRAPHICS 1203 #define IDC_MASK_UNUSED_GRAPHICS 1203
#define CHECK_SOUND_SWAPDUTY 1203
#define IDC_VOLUMEGROUP 1204 #define IDC_VOLUMEGROUP 1204
#define IDC_OMITBLANK 1204 #define IDC_OMITBLANK 1204
#define IDC_CHECK3 1204 #define IDC_CHECK3 1204

View File

@ -400,6 +400,7 @@ static void UpdateSD(HWND hwndDlg)
CheckDlgButton(hwndDlg,CHECK_SOUND_GLOBAL_FOCUS,(soundoptions&SO_GFOCUS)?BST_CHECKED:BST_UNCHECKED); CheckDlgButton(hwndDlg,CHECK_SOUND_GLOBAL_FOCUS,(soundoptions&SO_GFOCUS)?BST_CHECKED:BST_UNCHECKED);
CheckDlgButton(hwndDlg,CHECK_SOUND_MUTEFA,(soundoptions&SO_MUTEFA)?BST_CHECKED:BST_UNCHECKED); CheckDlgButton(hwndDlg,CHECK_SOUND_MUTEFA,(soundoptions&SO_MUTEFA)?BST_CHECKED:BST_UNCHECKED);
CheckDlgButton(hwndDlg,CHECK_SOUND_MUTETURBO,(muteTurbo)?BST_CHECKED:BST_UNCHECKED); CheckDlgButton(hwndDlg,CHECK_SOUND_MUTETURBO,(muteTurbo)?BST_CHECKED:BST_UNCHECKED);
CheckDlgButton(hwndDlg,CHECK_SOUND_SWAPDUTY,(swapDuty)?BST_CHECKED:BST_UNCHECKED);
// The option formerly flagged by SO_OLDUP can no longer be enabled. // The option formerly flagged by SO_OLDUP can no longer be enabled.
// CheckDlgButton(hwndDlg,131,(soundoptions&SO_OLDUP)?BST_CHECKED:BST_UNCHECKED); // CheckDlgButton(hwndDlg,131,(soundoptions&SO_OLDUP)?BST_CHECKED:BST_UNCHECKED);
SendDlgItemMessage(hwndDlg,COMBO_SOUND_QUALITY,CB_SETCURSEL,soundquality,(LPARAM)(LPSTR)0); SendDlgItemMessage(hwndDlg,COMBO_SOUND_QUALITY,CB_SETCURSEL,soundquality,(LPARAM)(LPSTR)0);
@ -412,6 +413,7 @@ static void UpdateSD(HWND hwndDlg)
if (!soundo) if (!soundo)
{ {
EnableWindow(GetDlgItem(hwndDlg,CHECK_SOUND_SWAPDUTY),FALSE);
EnableWindow(GetDlgItem(hwndDlg,CHECK_SOUND_MUTETURBO),FALSE); EnableWindow(GetDlgItem(hwndDlg,CHECK_SOUND_MUTETURBO),FALSE);
EnableWindow(GetDlgItem(hwndDlg,CHECK_SOUND_MUTEFA),FALSE); EnableWindow(GetDlgItem(hwndDlg,CHECK_SOUND_MUTEFA),FALSE);
EnableWindow(GetDlgItem(hwndDlg,CHECK_SOUND_8BIT),FALSE); EnableWindow(GetDlgItem(hwndDlg,CHECK_SOUND_8BIT),FALSE);
@ -692,7 +694,10 @@ case WM_COMMAND:
#endif #endif
case CHECK_SOUND_MUTETURBO: case CHECK_SOUND_MUTETURBO:
muteTurbo ^= 1; muteTurbo ^= 1;
break; break;
case CHECK_SOUND_SWAPDUTY:
swapDuty ^=1;
break;
case CHECK_SOUND_ENABLED:soundo=!soundo; case CHECK_SOUND_ENABLED:soundo=!soundo;
if(!soundo) TrashSound(); if(!soundo) TrashSound();
else soundo=InitSound(); else soundo=InitSound();

View File

@ -226,74 +226,83 @@ static void SQReload(int x, uint8 V)
static DECLFW(Write_PSG) static DECLFW(Write_PSG)
{ {
A&=0x1F; A&=0x1F;
switch(A) switch(A)
{ {
case 0x0:DoSQ1(); case 0x0:
EnvUnits[0].Mode=(V&0x30)>>4; DoSQ1();
EnvUnits[0].Speed=(V&0xF); EnvUnits[0].Mode=(V&0x30)>>4;
break; EnvUnits[0].Speed=(V&0xF);
case 0x1: if (swapDuty)
sweepon[0]=V&0x80; V = (V&0x3F)|((V&0x80)>>1)|((V&0x40)<<1);
break; break;
case 0x2: case 0x1:
DoSQ1(); sweepon[0]=V&0x80;
curfreq[0]&=0xFF00; break;
curfreq[0]|=V; case 0x2:
break; DoSQ1();
case 0x3: curfreq[0]&=0xFF00;
SQReload(0,V); curfreq[0]|=V;
break; break;
case 0x4: case 0x3:
DoSQ2(); SQReload(0,V);
EnvUnits[1].Mode=(V&0x30)>>4; break;
EnvUnits[1].Speed=(V&0xF); case 0x4:
break; DoSQ2();
case 0x5: EnvUnits[1].Mode=(V&0x30)>>4;
sweepon[1]=V&0x80; EnvUnits[1].Speed=(V&0xF);
break; if (swapDuty)
case 0x6:DoSQ2(); V = (V&0x3F)|((V&0x80)>>1)|((V&0x40)<<1);
curfreq[1]&=0xFF00; break;
curfreq[1]|=V; case 0x5:
break; sweepon[1]=V&0x80;
case 0x7: break;
SQReload(1,V); case 0x6:
break; DoSQ2();
case 0xa:DoTriangle(); curfreq[1]&=0xFF00;
break; curfreq[1]|=V;
case 0xb: break;
DoTriangle(); case 0x7:
if(EnabledChannels&0x4) SQReload(1,V);
lengthcount[2]=lengthtable[(V>>3)&0x1f]; break;
TriMode=1; // Load mode case 0xa:
break; DoTriangle();
case 0xC:DoNoise(); break;
EnvUnits[2].Mode=(V&0x30)>>4; case 0xb:
EnvUnits[2].Speed=(V&0xF); DoTriangle();
break; if(EnabledChannels&0x4)
case 0xE:DoNoise(); lengthcount[2]=lengthtable[(V>>3)&0x1f];
break; TriMode=1; // Load mode
case 0xF: break;
DoNoise(); case 0xC:
if(EnabledChannels&0x8) DoNoise();
lengthcount[3]=lengthtable[(V>>3)&0x1f]; EnvUnits[2].Mode=(V&0x30)>>4;
EnvUnits[2].reloaddec=1; EnvUnits[2].Speed=(V&0xF);
break; break;
case 0x10:DoPCM(); case 0xE:
LoadDMCPeriod(V&0xF); DoNoise();
break;
if(SIRQStat&0x80) case 0xF:
{ DoNoise();
if(!(V&0x80)) if(EnabledChannels&0x8)
{ lengthcount[3]=lengthtable[(V>>3)&0x1f];
X6502_IRQEnd(FCEU_IQDPCM); EnvUnits[2].reloaddec=1;
SIRQStat&=~0x80; break;
} case 0x10:
else X6502_IRQBegin(FCEU_IQDPCM); DoPCM();
} LoadDMCPeriod(V&0xF);
break; if(SIRQStat&0x80)
} {
PSG[A]=V; if(!(V&0x80))
{
X6502_IRQEnd(FCEU_IQDPCM);
SIRQStat&=~0x80;
}
else X6502_IRQBegin(FCEU_IQDPCM);
}
break;
}
PSG[A]=V;
} }
static DECLFW(Write_DMCRegs) static DECLFW(Write_DMCRegs)

View File

@ -58,6 +58,7 @@ extern unsigned char *cdloggerdata;
#endif #endif
extern uint32 soundtsoffs; extern uint32 soundtsoffs;
extern bool swapDuty;
#define SOUNDTS (timestamp + soundtsoffs) #define SOUNDTS (timestamp + soundtsoffs)
void SetNESSoundMap(void); void SetNESSoundMap(void);