Skip to content

Commit

Permalink
Update Mednafen to 1.25.0
Browse files Browse the repository at this point in the history
  • Loading branch information
clobber committed Aug 19, 2020
1 parent 899bdce commit 3fdb22a
Show file tree
Hide file tree
Showing 29 changed files with 1,249 additions and 602 deletions.
2 changes: 1 addition & 1 deletion Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.24.3</string>
<string>1.25.0</string>
<key>NSPrincipalClass</key>
<string>OEGameCoreController</string>
<key>OEGameCoreClass</key>
Expand Down
8 changes: 4 additions & 4 deletions Mednafen.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -4752,9 +4752,9 @@
OTHER_CFLAGS = (
"-fwrapv",
"-DHAVE_MKDIR",
"-DMEDNAFEN_VERSION=\\\"1.24.3\\\"",
"-DMEDNAFEN_VERSION=\\\"1.25.0-UNSTABLE\\\"",
"-DPACKAGE=\\\"mednafen\\\"",
"-DMEDNAFEN_VERSION_NUMERIC=0x00102403",
"-DMEDNAFEN_VERSION_NUMERIC=0x00102500",
"-DPSS_STYLE=1",
"-DMPC_FIXED_POINT",
"-DARCH_X86",
Expand Down Expand Up @@ -4818,9 +4818,9 @@
OTHER_CFLAGS = (
"-fwrapv",
"-DHAVE_MKDIR",
"-DMEDNAFEN_VERSION=\\\"1.24.3\\\"",
"-DMEDNAFEN_VERSION=\\\"1.25.0-UNSTABLE\\\"",
"-DPACKAGE=\\\"mednafen\\\"",
"-DMEDNAFEN_VERSION_NUMERIC=0x00102403",
"-DMEDNAFEN_VERSION_NUMERIC=0x00102500",
"-DPSS_STYLE=1",
"-DMPC_FIXED_POINT",
"-DARCH_X86",
Expand Down
1 change: 1 addition & 0 deletions mednafen/apple2/debug.inc
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ static const RegGroupType CPURegsGroup =

static DebuggerInfoStruct DBGInfo =
{
true,
"cp437",
3,
1, // Instruction alignment(bytes)
Expand Down
2 changes: 1 addition & 1 deletion mednafen/apple2/kbio.inc
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ static const IDIISG IODevice_Keyboard_Twopiece_IDII =
/* X8 */ IDIIS_Padding<1>(),

/* Y4 */
/* X0 */ IDIIS_Button("7", "7'", -1),
/* X0 */ IDIIS_Button("7", "7", -1),
/* X1 */ IDIIS_Button("t", "T", -1),
/* X2 */ IDIIS_Button("j", "J", -1),
/* X3 */ IDIIS_Button("b", "B", -1),
Expand Down
5 changes: 3 additions & 2 deletions mednafen/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ struct DGD_Source
};
#endif

typedef struct
struct DebuggerInfoStruct
{
bool SuppressDoc; // Suppress auto-generated documentation for this system's debugger.
const char *DefaultCharEnc; // Default(or most common) internal character encoding for text for the system.

uint32 MaxInstructionSize; // Maximum instruction size in bytes
Expand Down Expand Up @@ -180,7 +181,7 @@ typedef struct
// Game emulation code shouldn't touch these directly.
std::vector<AddressSpaceType> *AddressSpaces;
std::vector<const RegGroupType*> *RegGroups;
} DebuggerInfoStruct;
};

// ASpace_Add() functions return an ID that should be used with with MDFNDBG_ASpace_Read()
// and ASpace_Write() functions. The ID is guaranteed to be 0 for the first address space,
Expand Down
10 changes: 6 additions & 4 deletions mednafen/drivers/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ static const MDFNSetting DriverSettings[] =
void BuildSystemSetting(MDFNSetting *setting, const char *system_name, const char *name, const char *description, const char *description_extra, MDFNSettingType type,
const char *default_value, const char *minimum, const char *maximum,
bool (*validate_func)(const char *name, const char *value), void (*ChangeNotification)(const char *name),
const MDFNSetting_EnumList *enum_list)
const MDFNSetting_EnumList *enum_list, uint32 extra_flags)
{
char setting_name[256];

Expand All @@ -204,7 +204,7 @@ void BuildSystemSetting(MDFNSetting *setting, const char *system_name, const cha
trio_snprintf(setting_name, 256, "%s.%s", system_name, name);

setting->name = strdup(setting_name);
setting->flags = MDFNSF_COMMON_TEMPLATE;
setting->flags = MDFNSF_COMMON_TEMPLATE | extra_flags;
setting->description = description;
setting->description_extra = description_extra;
setting->type = type;
Expand All @@ -227,11 +227,13 @@ void MakeDebugSettings(std::vector <MDFNSetting> &settings)

if(!dbg)
continue;
//
const uint32 extra_flags = dbg->SuppressDoc ? MDFNSF_SUPPRESS_DOC : 0;

BuildSystemSetting(&setting, sysname, "debugger.disfontsize", gettext_noop("Disassembly font size."), gettext_noop("Note: Setting the font size to larger than the default may cause text overlap in the debugger."), MDFNST_ENUM, "5x7", NULL, NULL, NULL, NULL, FontSize_List);
BuildSystemSetting(&setting, sysname, "debugger.disfontsize", gettext_noop("Disassembly font size."), gettext_noop("Note: Setting the font size to larger than the default may cause text overlap in the debugger."), MDFNST_ENUM, "5x7", NULL, NULL, NULL, NULL, FontSize_List, extra_flags);
settings.push_back(setting);

BuildSystemSetting(&setting, sysname, "debugger.memcharenc", gettext_noop("Character encoding for the debugger's memory editor."), NULL, MDFNST_STRING, dbg->DefaultCharEnc);
BuildSystemSetting(&setting, sysname, "debugger.memcharenc", gettext_noop("Character encoding for the debugger's memory editor."), NULL, MDFNST_STRING, dbg->DefaultCharEnc, NULL, NULL, NULL, NULL, NULL, extra_flags);
settings.push_back(setting);
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion mednafen/drivers/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,5 @@ bool GT_ReinitSound(void);
void BuildSystemSetting(MDFNSetting *setting, const char *system_name, const char *name, const char *description, const char *description_extra, MDFNSettingType type,
const char *default_value, const char *minimum = NULL, const char *maximum = NULL,
bool (*validate_func)(const char *name, const char *value) = NULL, void (*ChangeNotification)(const char *name) = NULL,
const MDFNSetting_EnumList *enum_list = NULL);
const MDFNSetting_EnumList *enum_list = NULL, uint32 extra_flags = 0);
#endif
12 changes: 11 additions & 1 deletion mednafen/hw_cpu/m68k/m68k.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
//
// TODO: Fix instruction timings(currently execute too fast).
//
// TODO: Fix multiplication and division timing, and make sure flags are ok for divide by zero.
// TODO: Fix division timing, and make sure flags are ok for divide by zero.
//
// FIXME: Handle NMI differently; how to test? Maybe MOVEM to interrupt control registers...
//
Expand Down Expand Up @@ -1123,6 +1123,11 @@ INLINE void M68K::MULU(HAM<T, SAM> &src, const unsigned dr)
T const src_data = src.read();
uint32 const result = (uint32)(uint16)D[dr] * (uint32)src_data;

timestamp += 34;

for(uint32 tmp = src_data; tmp; tmp &= tmp - 1)
timestamp += 2;

CalcZN<uint32>(result);
SetC(false);
SetV(false);
Expand All @@ -1143,6 +1148,11 @@ INLINE void M68K::MULS(HAM<T, SAM> &src, const unsigned dr)
T const src_data = src.read();
uint32 const result = (int16)D[dr] * (int16)src_data;

timestamp += 34;

for(uint32 tmp = src_data << 1, i = 0; i < 16; tmp >>= 1, i++)
timestamp += (tmp ^ (tmp << 1)) & 2;

CalcZN<uint32>(result);
SetC(false);
SetV(false);
Expand Down
1 change: 1 addition & 0 deletions mednafen/md/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ void MDDBG_Init(void)

DebuggerInfoStruct DBGInfo =
{
false,
"shift_jis",
10, // Max instruction size(bytes)
2, // Instruction alignment(bytes)
Expand Down
1 change: 1 addition & 0 deletions mednafen/nes/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ static const RegGroupType NESPPURegsGroup =

DebuggerInfoStruct NESDBGInfo =
{
false,
"cp437",
3,
1, // Instruction alignment(bytes)
Expand Down
1 change: 1 addition & 0 deletions mednafen/pce/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,7 @@ static void SetGraphicsDecode(MDFN_Surface *surface, int line, int which, int xs

DebuggerInfoStruct PCEDBGInfo =
{
false,
"shift_jis",
7,
1, // Instruction alignment(bytes)
Expand Down
1 change: 1 addition & 0 deletions mednafen/pcfx/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,7 @@ static void ForceIRQ(int level)

DebuggerInfoStruct PCFXDBGInfo =
{
false,
"shift_jis",
4,
2, // Instruction alignment(bytes)
Expand Down
1 change: 1 addition & 0 deletions mednafen/psx/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ static void SetGraphicsDecode(MDFN_Surface *surface, int line, int which, int xs

DebuggerInfoStruct PSX_DBGInfo =
{
false,
"shift_jis",
4, // Max instruction byte size
4, // Instruction alignment(bytes)
Expand Down
1 change: 1 addition & 0 deletions mednafen/snes_faust/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,7 @@ void DBG_Kill(void)

DebuggerInfoStruct DBG_DBGInfo
{
true,
"cp437",

4,
Expand Down
16 changes: 16 additions & 0 deletions mednafen/ss/db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,21 @@ static const struct
{ "T-7664G", CPUCACHE_EMUMODE_FULL, "Nobunaga no Yabou Shouseiroku (Japan)", gettext_noop("Fixes game hang.") },
{ "T-9510G", CPUCACHE_EMUMODE_FULL, "Policenauts (Japan)", gettext_noop("Fixes screen flickering on disc 2.") },
{ "T-25416H50", CPUCACHE_EMUMODE_FULL, "Rampage - World Tour (Europe)", gettext_noop("Fixes game hang.") },
{ "T-37401G", CPUCACHE_EMUMODE_FULL, "Senken Kigyouden (Japan)", gettext_noop("Fixes dialogue text truncation.") },
{ "T-37401H", CPUCACHE_EMUMODE_FULL, "Xian Jian Qi Xia Zhuan (Taiwan)", gettext_noop("Fixes dialogue text truncation.") },
{ "T-159056", CPUCACHE_EMUMODE_FULL, "Slam 'n Jam 96 (Japan)", gettext_noop("Fixes minor FMV glitches.") },
{ "T-159028H", CPUCACHE_EMUMODE_FULL, "Slam 'n Jam 96 (USA)", gettext_noop("Fixes minor FMV glitches.") },
{ "T-15902H50", CPUCACHE_EMUMODE_FULL, "Slam 'n Jam 96 (Europe)", gettext_noop("Fixes minor FMV glitches.") },
{ "T-8119G", CPUCACHE_EMUMODE_FULL, "Space Jam (Japan)", gettext_noop("Fixes game crash.") },
{ "T-8125H", CPUCACHE_EMUMODE_FULL, "Space Jam (USA)", gettext_noop("Fixes game crash.") },
{ "T-8125H-50", CPUCACHE_EMUMODE_FULL, "Space Jam (Europe)", gettext_noop("Fixes game crash.") },
{ "GS-9001", CPUCACHE_EMUMODE_FULL, "Virtua Fighter (Japan)", gettext_noop("Fixes graphical glitches.") },
{ "MK-81005", CPUCACHE_EMUMODE_FULL, "Virtua Fighter (USA)", gettext_noop("Fixes graphical glitches.") },
{ "MK_8100550", CPUCACHE_EMUMODE_FULL, "Virtua Fighter (Europe)", gettext_noop("Fixes graphical glitches.") },
{ "GS-9039", CPUCACHE_EMUMODE_FULL, "Virtua Fighter Remix (Japan)", gettext_noop("Fixes graphical glitches.") },
{ "MK-81023", CPUCACHE_EMUMODE_FULL, "Virtua Fighter Remix (USA)", gettext_noop("Fixes graphical glitches.") },
{ "MK-8102350", CPUCACHE_EMUMODE_FULL, "Virtua Fighter Remix (Europe)", gettext_noop("Fixes graphical glitches.") },
{ "SG-7103", CPUCACHE_EMUMODE_FULL, "Virtua Fighter Remix (SegaNet)", gettext_noop("Fixes graphical glitches.") },
{ "T-36102G", CPUCACHE_EMUMODE_FULL, "Whizz (Japan)", gettext_noop("Fixes quasi-random hangs during startup.") },
{ "T-9515H-50", CPUCACHE_EMUMODE_FULL, "Whizz (Europe)", gettext_noop("Fixes quasi-random hangs during startup.") },
};
Expand Down Expand Up @@ -356,6 +365,13 @@ static const struct
{ "T-8138H", HORRIBLEHACK_VDP1RWDRAWSLOWDOWN, "Frank Thomas Big Hurt Baseball (USA)", gettext_noop("Reduces graphical glitches.") }, // Probably need more-accurate VDP1 draw timings to fix the glitches completely.
{ "T-36102G", HORRIBLEHACK_VDP1RWDRAWSLOWDOWN, "Whizz (Japan)", gettext_noop("Fixes major graphical issues during gameplay.") },
{ "T-9515H-50", HORRIBLEHACK_VDP1RWDRAWSLOWDOWN,"Whizz (Europe)", gettext_noop("Fixes major graphical issues during gameplay.") },
{ "GS-9001", HORRIBLEHACK_VDP1RWDRAWSLOWDOWN, "Virtua Fighter (Japan)", gettext_noop("Fixes graphical glitches.") },
{ "MK-81005", HORRIBLEHACK_VDP1RWDRAWSLOWDOWN, "Virtua Fighter (USA)", gettext_noop("Fixes graphical glitches.") },
{ "MK_8100550", HORRIBLEHACK_VDP1RWDRAWSLOWDOWN,"Virtua Fighter (Europe)", gettext_noop("Fixes graphical glitches.") },
{ "GS-9039", HORRIBLEHACK_VDP1RWDRAWSLOWDOWN, "Virtua Fighter Remix (Japan)", gettext_noop("Fixes graphical glitches.") },
{ "MK-81023", HORRIBLEHACK_VDP1RWDRAWSLOWDOWN, "Virtua Fighter Remix (USA)", gettext_noop("Fixes graphical glitches.") },
{ "MK-8102350", HORRIBLEHACK_VDP1RWDRAWSLOWDOWN,"Virtua Fighter Remix (Europe)", gettext_noop("Fixes graphical glitches.") },
{ "SG-7103", HORRIBLEHACK_VDP1RWDRAWSLOWDOWN, "Virtua Fighter Remix (SegaNet)", gettext_noop("Fixes graphical glitches.") },

// Still random hangs...wtf is this game doing...
{ "T-6006G", HORRIBLEHACK_NOSH2DMALINE106 | HORRIBLEHACK_VDP1INSTANT, "Thunderhawk II (Japan)", gettext_noop("Fixes hangs just before and during gameplay.") },
Expand Down
1 change: 1 addition & 0 deletions mednafen/ss/debug.inc
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,7 @@ static void DBG_Kill(void)

static DebuggerInfoStruct DBGInfo
{
false,
"SJIS",

2,
Expand Down
77 changes: 47 additions & 30 deletions mednafen/ss/scsp.inc
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ INLINE void SS_SCSP::RW(uint32 A, T& DBV)
if(!shift)
t->Reload = DBV & 0xFF;

//printf("Timer(%zu-byte) %u: %04x\n", sizeof(T), ((A >> 1) & 0x1F) - 0x0C, DBV);
//printf("Timer(%zu-byte) %u: %04x --- %02x\n", sizeof(T), ((A >> 1) & 0x1F) - 0x0C, DBV, t->Counter);
}
else
DBV = 0;
Expand Down Expand Up @@ -1313,7 +1313,6 @@ INLINE void SS_SCSP::RunSample(int16* outlr)
//
for(unsigned slot = 0; slot < 32; slot++)
{
uint32 mdata = 0;
auto* s = &Slots[slot];
unsigned key_eg_scale;

Expand Down Expand Up @@ -1343,16 +1342,8 @@ INLINE void SS_SCSP::RunSample(int16* outlr)
else
s->EnvPhase = ENV_PHASE_RELEASE;
}

//
//
uint16 sample = 0;

if(s->SourceControl == 1)
sample = LFSR << 8;

sample ^= s->SBXOR; // For zero and noise case only; waveform playback needs it to occur before linear interpolation.

if(!s->InLoop)
{
if((uint16)(s->CurrentAddr + 1) > s->LoopStart)
Expand Down Expand Up @@ -1393,57 +1384,83 @@ INLINE void SS_SCSP::RunSample(int16* outlr)
}
}
}
}

for(unsigned slot = 0; slot < 32; slot++)
{
auto* s = &Slots[slot];
uint32 mdata = 0;
uint16 sample = 0;

if(s->SourceControl == 1)
sample = LFSR << 8;

sample ^= s->SBXOR; // For zero and noise case only; waveform playback needs it to occur before linear interpolation.
//
//
if(s->WFAllowAccess)
{
uint32 modalizer;
uint32 modalizer_int;
uint32 modalizer_int[2];
uint32 tmppw = s->PhaseWhacker;
uint16 tmpa = s->CurrentAddr;
int16 s0, s1;

//
//
modalizer = (int16)SoundStack[(GlobalCounter + s->ModInputX) & 0x3F];
modalizer += (int16)SoundStack[(GlobalCounter + s->ModInputY) & 0x3F];
modalizer = (modalizer << 6) >> (0x10 - s->ModLevel);

if(s->ModLevel <= 0x04)
modalizer = 0;

modalizer_int = sign_x_to_s32(11, modalizer >> 6);
//
//

if(s->LoopSub)
{
tmppw = ~tmppw;
tmpa = ~tmpa;
}

mdata |= ((tmpa >> 12) << 7);
//
//
uint32 sia;
int16 s0, s1;

{
//
// TODO/FIXME: Proper handling of the slot 31->0 buggy FM interpolation case with respect to reverse looping(ns->LoopSub)
// requires sub-sample timing emulation.
//
auto* ns = &Slots[(slot + 1) & 0x1F];
uint32 modalizer;
uint32 ns_sia;

modalizer = (int16)SoundStack[(GlobalCounter + s->ModInputX) & 0x3F];
modalizer += (int16)SoundStack[(GlobalCounter + s->ModInputY) & 0x3F];
modalizer = ((modalizer << 6) >> (0x10 - s->ModLevel)) & ~1;

if(s->ModLevel <= 0x04)
modalizer = 0;

sia = modalizer + ((tmppw >> (14 - 6)) & 0x3F);
ns_sia = modalizer + (((ns->PhaseWhacker >> (14 - 6)) ^ (ns->LoopSub ? 0x3F : 0x00)) & 0x3F);

modalizer_int[0] = sign_x_to_s32(11, sia >> 6);
modalizer_int[1] = sign_x_to_s32(11, ns_sia >> 6);
//
sia &= 0x3F;
}

if(s->WF8Bit)
{
const uint32 addr0 = (s->StartAddr + ((modalizer_int + (uint16)(tmpa + 0)) & s->ShortWaveMask)) & 0xFFFFF;
const uint32 addr1 = (s->StartAddr + ((modalizer_int + (uint16)(tmpa + 1)) & s->ShortWaveMask)) & 0xFFFFF;
const uint32 addr0 = (s->StartAddr + ((modalizer_int[0] + (uint16)(tmpa + 0)) & s->ShortWaveMask)) & 0xFFFFF;
const uint32 addr1 = (s->StartAddr + ((modalizer_int[1] + (uint16)(tmpa + 1)) & s->ShortWaveMask)) & 0xFFFFF;

s0 = ne16_rbo_be<uint8>(RAM, addr0) << 8;
s1 = ne16_rbo_be<uint8>(RAM, addr1) << 8;
}
else
{
s0 = RAM[((s->StartAddr >> 1) + ((modalizer_int + (uint16)(tmpa + 0)) & s->ShortWaveMask)) & 0x7FFFF];
s1 = RAM[((s->StartAddr >> 1) + ((modalizer_int + (uint16)(tmpa + 1)) & s->ShortWaveMask)) & 0x7FFFF];
s0 = RAM[((s->StartAddr >> 1) + ((modalizer_int[0] + (uint16)(tmpa + 0)) & s->ShortWaveMask)) & 0x7FFFF];
s1 = RAM[((s->StartAddr >> 1) + ((modalizer_int[1] + (uint16)(tmpa + 1)) & s->ShortWaveMask)) & 0x7FFFF];
}

s0 ^= s->SBXOR;
s1 ^= s->SBXOR;

if(s->SourceControl == 0)
{
const unsigned sia = std::min<unsigned>(0x40, ((tmppw >> (14 - 6)) & 0x3F) + (modalizer & 0x3E));
sample = ((s0 * (0x40 - sia)) + (s1 * sia)) >> 6;
}

Expand Down
8 changes: 8 additions & 0 deletions mednafen/ss/sh7095.h
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,14 @@ class SH7095 final
const char* const cpu_name;
bool CBH_Setting;
uint32 PC_IF, PC_ID; // Debug-related variables.

#ifdef MDFN_ENABLE_DEV_BUILD
void CheckDMARace(uint32 addr, uint32 size, bool write);
struct
{
uint32 rw[2][2];
} DMADebug[2];
#endif
};

#endif
Loading

0 comments on commit 3fdb22a

Please sign in to comment.