Start removing most of MDFNGameInfo

This commit is contained in:
twinaphex 2016-08-09 07:38:20 +02:00
parent 604c2a2e28
commit 7657a5cfbb
4 changed files with 34 additions and 109 deletions

View File

@ -275,7 +275,9 @@ static int LoadCommon(void)
PCE_Power(); PCE_Power();
#if 0
MDFNGameInfo->LayerNames = "Background\0Sprites\0"; MDFNGameInfo->LayerNames = "Background\0Sprites\0";
#endif
MDFNGameInfo->fps = (uint32)((double)7159090.90909090 / 455 / 263 * 65536 * 256); MDFNGameInfo->fps = (uint32)((double)7159090.90909090 / 455 / 263 * 65536 * 256);
// Clean this up: // Clean this up:
@ -449,7 +451,7 @@ static void Emulate(EmulateSpecStruct *espec)
PCECD_ResetTS(); PCECD_ResetTS();
} }
static int StateAction(StateMem *sm, int load, int data_only) int StateAction(StateMem *sm, int load, int data_only)
{ {
SFORMAT StateRegs[] = SFORMAT StateRegs[] =
{ {
@ -528,7 +530,7 @@ static MDFNSetting PCESettings[] =
{ NULL } { NULL }
}; };
static uint8 MemRead(uint32 addr) uint8 MemRead(uint32 addr)
{ {
return(PCERead[(addr / 8192) & 0xFF](addr)); return(PCERead[(addr / 8192) & 0xFF](addr));
} }
@ -844,30 +846,6 @@ void HuC_Power(void)
MDFNGI EmulatedPCE_Fast = MDFNGI EmulatedPCE_Fast =
{ {
"pce_fast",
"PC Engine (CD)/TurboGrafx 16 (CD)/SuperGrafx",
KnownExtensions,
MODPRIO_INTERNAL_LOW,
NULL,
&PCEInputInfo,
Load,
TestMagic,
LoadCD,
TestMagicCD,
CloseGame,
VDC_SetLayerEnableMask,
NULL,
NULL,
NULL,
NULL,
NULL,
MemRead,
NULL,
false,
StateAction,
Emulate,
PCEINPUT_SetInput,
DoSimpleCommand,
PCESettings, PCESettings,
MDFN_MASTERCLOCK_FIXED(PCE_MASTER_CLOCK), MDFN_MASTERCLOCK_FIXED(PCE_MASTER_CLOCK),
0, 0,
@ -988,16 +966,9 @@ MDFNGI *MDFNI_LoadCD(const char *force_module, const char *devicename)
} }
MDFN_indent(-1); MDFN_indent(-1);
// This if statement will be true if force_module references a system without CDROM support. MDFN_printf("Using module: pce_fast.\n");
if(!MDFNGameInfo->LoadCD)
{
MDFN_PrintError(_("Specified system \"%s\" doesn't support CDs!"), force_module);
return(0);
}
MDFN_printf(_("Using module: %s(%s)\n\n"), MDFNGameInfo->shortname, MDFNGameInfo->fullname); if(!(LoadCD(&CDInterfaces)))
if(!(MDFNGameInfo->LoadCD(&CDInterfaces)))
{ {
for(unsigned i = 0; i < CDInterfaces.size(); i++) for(unsigned i = 0; i < CDInterfaces.size(); i++)
delete CDInterfaces[i]; delete CDInterfaces[i];
@ -1032,7 +1003,7 @@ MDFNGI *MDFNI_LoadGame(const char *force_module, const char *name)
MDFN_indent(1); MDFN_indent(1);
// Construct a NULL-delimited list of known file extensions for MDFN_fopen() // Construct a NULL-delimited list of known file extensions for MDFN_fopen()
const FileExtensionSpecStruct *curexts = MDFNGameInfo->FileExtensions; const FileExtensionSpecStruct *curexts = KnownExtensions;
while(curexts->extension && curexts->description) while(curexts->extension && curexts->description)
{ {
@ -1045,7 +1016,7 @@ MDFNGI *MDFNI_LoadGame(const char *force_module, const char *name)
if(!GameFile) if(!GameFile)
goto error; goto error;
MDFN_printf(_("Using module: %s(%s)\n\n"), MDFNGameInfo->shortname, MDFNGameInfo->fullname); MDFN_printf(_("Using module: pce_fast.\n\n"));
MDFN_indent(1); MDFN_indent(1);
// //
@ -1055,7 +1026,7 @@ MDFNGI *MDFNI_LoadGame(const char *force_module, const char *name)
// End load per-game settings // End load per-game settings
// //
if(MDFNGameInfo->Load(name, GameFile) <= 0) if(Load(name, GameFile) <= 0)
goto error; goto error;
MDFN_LoadGameCheats(NULL); MDFN_LoadGameCheats(NULL);
@ -1569,7 +1540,7 @@ void retro_unload_game(void)
MDFN_FlushGameCheats(0); MDFN_FlushGameCheats(0);
MDFNGameInfo->CloseGame(); CloseGame();
if(MDFNGameInfo->name) if(MDFNGameInfo->name)
free(MDFNGameInfo->name); free(MDFNGameInfo->name);

View File

@ -276,70 +276,13 @@ typedef enum
class CDIF; class CDIF;
#define MDFN_MASTERCLOCK_FIXED(n) ((int64)((double)(n) * (1LL << 32)))
typedef struct typedef struct
{ {
/* Private functions to Mednafen. Do not call directly
from the driver code, or else bad things shall happen. Maybe. Probably not, but don't
do it(yet)!
*/
// Short system name, lowercase a-z, 0-9, and _ are the only allowable characters!
const char *shortname;
// Full system name. Preferably English letters, but can be UTF8
const char *fullname;
// Pointer to an array of FileExtensionSpecStruct, with the last entry being { NULL, NULL } to terminate the list.
// This list is used to make best-guess choices, when calling the TestMagic*() functions would be unreasonable, such
// as when scanning a ZIP archive for a file to load. The list may also be used in the future for GUI file open windows.
const FileExtensionSpecStruct *FileExtensions;
ModPrio ModulePriority;
void *Debugger;
InputInfoStruct *InputInfo;
// Returns 1 on successful load, 0 on fatal error(deprecated: -1 on unrecognized format)
int (*Load)(const char *name, MDFNFILE *fp);
// Return TRUE if the file is a recognized type, FALSE if not.
bool (*TestMagic)(const char *name, MDFNFILE *fp);
//
// (*CDInterfaces).size() is guaranteed to be >= 1.
int (*LoadCD)(std::vector<CDIF *> *CDInterfaces);
bool (*TestMagicCD)(std::vector<CDIF *> *CDInterfaces);
void (*CloseGame)(void);
void (*SetLayerEnableMask)(uint64 mask); // Video
const char *LayerNames;
void (*SetChanEnableMask)(uint64 mask); // Audio(TODO, placeholder)
const char *ChanNames;
void (*InstallReadPatch)(uint32 address);
void (*RemoveReadPatches)(void);
uint8 (*MemRead)(uint32 addr);
#ifdef WANT_NEW_API
CheatFormatInfoStruct *CheatFormatInfo;
#endif
bool SaveStateAltersState; // true for bsnes and some libco-style emulators, false otherwise.
// Main save state routine, called by the save state code in state.cpp.
// When saving, load is set to 0. When loading, load is set to the version field of the save state being loaded.
// data_only is true when the save state data is temporary, such as being saved into memory for state rewinding.
int (*StateAction)(StateMem *sm, int load, int data_only);
void (*Emulate)(EmulateSpecStruct *espec);
void (*SetInput)(int port, const char *type, void *ptr);
void (*DoSimpleCommand)(int cmd);
const MDFNSetting *Settings; const MDFNSetting *Settings;
// Time base for EmulateSpecStruct::MasterCycles // Time base for EmulateSpecStruct::MasterCycles
#define MDFN_MASTERCLOCK_FIXED(n) ((int64)((double)(n) * (1LL << 32)))
int64 MasterClock; int64 MasterClock;
uint32 fps; // frames per second * 65536 * 256, truncated uint32 fps; // frames per second * 65536 * 256, truncated
@ -389,4 +332,8 @@ typedef struct
double mouse_sensitivity; double mouse_sensitivity;
} MDFNGI; } MDFNGI;
int StateAction(StateMem *sm, int load, int data_only);
uint8 MemRead(uint32 addr);
#endif #endif

View File

@ -132,22 +132,29 @@ void MDFNMP_AddRAM(uint32 size, uint32 A, uint8 *RAM)
void MDFNMP_InstallReadPatches(void) void MDFNMP_InstallReadPatches(void)
{ {
if(!CheatsActive) return; unsigned x;
std::vector<SUBCHEAT>::iterator chit;
if(!CheatsActive) return;
std::vector<SUBCHEAT>::iterator chit;
for(unsigned int x = 0; x < 8; x++) #if 0
for(chit = SubCheats[x].begin(); chit != SubCheats[x].end(); chit++) for(x = 0; x < 8; x++)
{ {
if(MDFNGameInfo->InstallReadPatch) for(chit = SubCheats[x].begin(); chit != SubCheats[x].end(); chit++)
MDFNGameInfo->InstallReadPatch(chit->addr); {
} if(MDFNGameInfo->InstallReadPatch)
MDFNGameInfo->InstallReadPatch(chit->addr);
}
}
#endif
} }
void MDFNMP_RemoveReadPatches(void) void MDFNMP_RemoveReadPatches(void)
{ {
#if 0
if(MDFNGameInfo->RemoveReadPatches) if(MDFNGameInfo->RemoveReadPatches)
MDFNGameInfo->RemoveReadPatches(); MDFNGameInfo->RemoveReadPatches();
#endif
} }
static void CheatMemErr(void) static void CheatMemErr(void)
@ -299,7 +306,7 @@ static bool TestConditions(const char *string)
shiftie = (bytelen - 1 - x) * 8; shiftie = (bytelen - 1 - x) * 8;
else else
shiftie = x * 8; shiftie = x * 8;
value_at_address |= MDFNGameInfo->MemRead(v_address + x) << shiftie; value_at_address |= MemRead(v_address + x) << shiftie;
} }
//printf("A: %08x, V: %08llx, VA: %08llx, OP: %s\n", v_address, v_value, value_at_address, operation); //printf("A: %08x, V: %08llx, VA: %08llx, OP: %s\n", v_address, v_value, value_at_address, operation);

View File

@ -467,7 +467,7 @@ int MDFNSS_SaveSM(void *st_p, int, int, const void*, const void*, const void*)
MDFN_en32lsb(header + 28, neoheight); MDFN_en32lsb(header + 28, neoheight);
smem_write(st, header, 32); smem_write(st, header, 32);
if(!MDFNGameInfo->StateAction(st, 0, 0)) if(!StateAction(st, 0, 0))
return(0); return(0);
uint32_t sizy = st->loc; uint32_t sizy = st->loc;
@ -490,5 +490,5 @@ int MDFNSS_LoadSM(void *st_p, int, int)
stateversion = MDFN_de32lsb(header + 16); stateversion = MDFN_de32lsb(header + 16);
return(MDFNGameInfo->StateAction(st, stateversion, 0)); return StateAction(st, stateversion, 0);
} }