This commit is contained in:
twinaphex 2015-07-23 17:57:44 +02:00
parent 5d3cbae300
commit 33776fe17c
4 changed files with 118 additions and 242 deletions

View File

@ -202,7 +202,7 @@ static int Load(const char *name, MDFNFILE *fp)
if(GET_FSIZE_PTR(fp) < 65536)
{
MDFN_PrintError(_("%s ROM image is too small."), MDFNGameInfo->fullname);
/* ROM image is too small. */
return(0);
}
@ -219,12 +219,12 @@ static int Load(const char *name, MDFNFILE *fp)
memcpy(wsCartROM + (rom_size - real_rom_size), GET_FDATA_PTR(fp), GET_FSIZE_PTR(fp));
MDFN_printf(_("ROM: %dKiB\n"), real_rom_size / 1024);
printf(_("ROM: %dKiB\n"), real_rom_size / 1024);
md5_context md5;
md5.starts();
md5.update(wsCartROM, rom_size);
md5.finish(MDFNGameInfo->MD5);
MDFN_printf(_("ROM MD5: 0x%s\n"), md5_context::asciistr(MDFNGameInfo->MD5, 0).c_str());
printf(_("ROM MD5: 0x%s\n"), md5_context::asciistr(MDFNGameInfo->MD5, 0).c_str());
uint8 header[10];
memcpy(header, wsCartROM + rom_size - 10, 10);
@ -239,7 +239,7 @@ static int Load(const char *name, MDFNFILE *fp)
break;
}
}
MDFN_printf(_("Developer: %s (0x%02x)\n"), developer_name, header[0]);
printf(_("Developer: %s (0x%02x)\n"), developer_name, header[0]);
}
uint32 SRAMSize = 0;
@ -260,17 +260,17 @@ static int Load(const char *name, MDFNFILE *fp)
//printf("%02x\n", header[5]);
if(eeprom_size)
MDFN_printf(_("EEPROM: %d bytes\n"), eeprom_size);
printf(_("EEPROM: %d bytes\n"), eeprom_size);
if(SRAMSize)
MDFN_printf(_("Battery-backed RAM: %d bytes\n"), SRAMSize);
printf(_("Battery-backed RAM: %d bytes\n"), SRAMSize);
MDFN_printf(_("Recorded Checksum: 0x%04x\n"), header[8] | (header[9] << 8));
printf(_("Recorded Checksum: 0x%04x\n"), header[8] | (header[9] << 8));
{
uint16 real_crc = 0;
for(unsigned int i = 0; i < rom_size - 2; i++)
real_crc += wsCartROM[i];
MDFN_printf(_("Real Checksum: 0x%04x\n"), real_crc);
printf(_("Real Checksum: 0x%04x\n"), real_crc);
}
if((header[8] | (header[9] << 8)) == 0x8de1 && (header[0]==0x01)&&(header[2]==0x27)) /* Detective Conan */

View File

@ -46,10 +46,6 @@ MDFNGI *MDFNI_LoadGame(const char *force_module, const char *name)
std::vector<FileExtensionSpecStruct> valid_iae;
MDFNGameInfo = &EmulatedWSwan;
MDFN_printf(_("Loading %s...\n"),name);
MDFN_indent(1);
// Construct a NULL-delimited list of known file extensions for MDFN_fopen()
const FileExtensionSpecStruct *curexts = MDFNGameInfo->FileExtensions;
@ -65,20 +61,9 @@ MDFNGI *MDFNI_LoadGame(const char *force_module, const char *name)
return 0;
}
MDFN_printf(_("Using module: %s(%s)\n\n"), MDFNGameInfo->shortname, MDFNGameInfo->fullname);
MDFN_indent(1);
//
// Load per-game settings
//
// Maybe we should make a "pgcfg" subdir, and automatically load all files in it?
// End load per-game settings
//
if(MDFNGameInfo->Load(name, &GameFile) <= 0)
{
GameFile.Close();
MDFN_indent(-2);
MDFNGameInfo = NULL;
return(0);
}
@ -86,8 +71,6 @@ MDFNGI *MDFNI_LoadGame(const char *force_module, const char *name)
MDFN_LoadGameCheats(NULL);
MDFNMP_InstallReadPatches();
MDFN_indent(-2);
if(!MDFNGameInfo->name)
{
unsigned int x;
@ -135,93 +118,3 @@ int MDFNI_Initialize(const char *basedir)
{
return(1);
}
static int curindent = 0;
void MDFN_indent(int indent)
{
curindent += indent;
}
static uint8 lastchar = 0;
void MDFN_printf(const char *format, ...)
{
char *format_temp;
char *temp;
unsigned int x, newlen;
va_list ap;
va_start(ap,format);
// First, determine how large our format_temp buffer needs to be.
uint8 lastchar_backup = lastchar; // Save lastchar!
for(newlen=x=0;x<strlen(format);x++)
{
if(lastchar == '\n' && format[x] != '\n')
{
int y;
for(y=0;y<curindent;y++)
newlen++;
}
newlen++;
lastchar = format[x];
}
format_temp = (char *)malloc(newlen + 1); // Length + NULL character, duh
// Now, construct our format_temp string
lastchar = lastchar_backup; // Restore lastchar
for(newlen=x=0;x<strlen(format);x++)
{
if(lastchar == '\n' && format[x] != '\n')
{
int y;
for(y=0;y<curindent;y++)
format_temp[newlen++] = ' ';
}
format_temp[newlen++] = format[x];
lastchar = format[x];
}
format_temp[newlen] = 0;
temp = trio_vaprintf(format_temp, ap);
free(format_temp);
MDFND_Message(temp);
free(temp);
va_end(ap);
}
void MDFN_PrintError(const char *format, ...)
{
char *temp;
va_list ap;
va_start(ap, format);
temp = trio_vaprintf(format, ap);
MDFND_PrintError(temp);
free(temp);
va_end(ap);
}
void MDFN_DebugPrintReal(const char *file, const int line, const char *format, ...)
{
char *temp;
va_list ap;
va_start(ap, format);
temp = trio_vaprintf(format, ap);
fprintf(stderr, "%s:%d %s\n", file, line, temp);
free(temp);
va_end(ap);
}

View File

@ -35,12 +35,6 @@ extern MDFNGI *MDFNGameInfo;
#include "settings.h"
void MDFN_PrintError(const char *format, ...);
void MDFN_printf(const char *format, ...);
void MDFN_DispMessage(const char *format, ...);
void MDFN_DebugPrintReal(const char *file, const int line, const char *format, ...);
void MDFN_LoadGameCheats(void *override);
void MDFN_FlushGameCheats(int nosave);

View File

@ -165,11 +165,6 @@ void MDFNMP_RemoveReadPatches(void)
MDFNGameInfo->RemoveReadPatches();
}
static void CheatMemErr(void)
{
MDFN_PrintError(_("Error allocating memory for cheat data."));
}
/* This function doesn't allocate any memory for "name" */
static int AddCheatEntry(char *name, char *conditions, uint32 addr, uint64 val, uint64 compare, int status, char type, unsigned int length, bool bigendian)
{
@ -231,18 +226,13 @@ void MDFN_LoadGameCheats(void *override_ptr)
fp = override;
else
{
/* Loading cheats */
std::string fn = MDFN_MakeFName(MDFNMKF_CHEAT,0,0).c_str();
MDFN_printf("\n");
MDFN_printf(_("Loading cheats from %s...\n"), fn.c_str());
MDFN_indent(1);
if(!(fp = fopen(fn.c_str(),"rb")))
{
/* Error opening file. */
ErrnoHolder ene(errno);
MDFN_printf(_("Error opening file: %s\n"), ene.StrError());
MDFN_indent(-1);
return;
}
}
@ -268,7 +258,7 @@ void MDFN_LoadGameCheats(void *override_ptr)
if(tbuf[0] != 'R' && tbuf[0] != 'C' && tbuf[0] != 'S')
{
MDFN_printf(_("Invalid cheat type: %c\n"), tbuf[0]);
/* Invalid cheat type */
break;
}
type = tbuf[0];
@ -316,8 +306,7 @@ void MDFN_LoadGameCheats(void *override_ptr)
if(!override)
{
MDFN_printf(_("%lu cheats loaded.\n"), (unsigned long)cheats.size());
MDFN_indent(-1);
/* Cheats loaded. */
fclose(fp);
}
}
@ -453,7 +442,7 @@ int MDFNI_AddCheat(const char *name, uint32 addr, uint64 val, uint64 compare, ch
if(!(t = strdup(name)))
{
CheatMemErr();
/* Error allocating memory for cheat data */
return(0);
}