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(soundPCMvol),
AC(muteTurbo),
AC(swapDuty),
AC(goptions),
NAC("eoptions",eoptions),

View File

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

View File

@ -104,6 +104,7 @@ extern int soundPCMvol; //Sound channel PCM - volume control
extern int soundquality;
extern bool muteTurbo;
extern bool swapDuty;
extern uint8 cpalette[192];
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_QUALITY,50,54,67,46,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
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 Turbo.",CHECK_SOUND_MUTETURBO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,150,111,55,10
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,138,111,53,10
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
GROUPBOX "Square1",132,121,142,44,93,WS_GROUP
@ -438,6 +438,7 @@ BEGIN
PUSHBUTTON "Restore defaults",IDC_SOUND_RESTOREDEFAULTVOL,19,238,56,11
LTEXT "",ID_SOUND_TRITOP,76,135,38,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
SUBORKBDIALOG DIALOGEX 13, 72, 478, 171

View File

@ -634,6 +634,7 @@
#define IDC_COPY_INPUT 1203
#define IDC_AUTORESUMECDLOGGING 1203
#define IDC_MASK_UNUSED_GRAPHICS 1203
#define CHECK_SOUND_SWAPDUTY 1203
#define IDC_VOLUMEGROUP 1204
#define IDC_OMITBLANK 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_MUTEFA,(soundoptions&SO_MUTEFA)?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.
// CheckDlgButton(hwndDlg,131,(soundoptions&SO_OLDUP)?BST_CHECKED:BST_UNCHECKED);
SendDlgItemMessage(hwndDlg,COMBO_SOUND_QUALITY,CB_SETCURSEL,soundquality,(LPARAM)(LPSTR)0);
@ -412,6 +413,7 @@ static void UpdateSD(HWND hwndDlg)
if (!soundo)
{
EnableWindow(GetDlgItem(hwndDlg,CHECK_SOUND_SWAPDUTY),FALSE);
EnableWindow(GetDlgItem(hwndDlg,CHECK_SOUND_MUTETURBO),FALSE);
EnableWindow(GetDlgItem(hwndDlg,CHECK_SOUND_MUTEFA),FALSE);
EnableWindow(GetDlgItem(hwndDlg,CHECK_SOUND_8BIT),FALSE);
@ -693,6 +695,9 @@ case WM_COMMAND:
case CHECK_SOUND_MUTETURBO:
muteTurbo ^= 1;
break;
case CHECK_SOUND_SWAPDUTY:
swapDuty ^=1;
break;
case CHECK_SOUND_ENABLED:soundo=!soundo;
if(!soundo) TrashSound();
else soundo=InitSound();

View File

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

View File

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