Get rid of mednafen.cpp

This commit is contained in:
twinaphex 2014-06-17 00:54:33 +02:00
parent 6e114f5acc
commit 4ffa3950de
8 changed files with 40 additions and 156 deletions

View File

@ -522,8 +522,7 @@ ifeq ($(NEED_TREMOR), 1)
endif
MEDNAFEN_SOURCES := $(MEDNAFEN_DIR)/mednafen.cpp \
$(MEDNAFEN_DIR)/error.cpp \
MEDNAFEN_SOURCES := $(MEDNAFEN_DIR)/error.cpp \
$(MEDNAFEN_DIR)/math_ops.cpp \
$(MEDNAFEN_DIR)/settings.cpp \
$(MEDNAFEN_DIR)/general.cpp \

View File

@ -337,8 +337,7 @@ FLAGS += -DNEED_TREMOR
endif
MEDNAFEN_SOURCES := $(MEDNAFEN_DIR)/mednafen.cpp \
$(MEDNAFEN_DIR)/error.cpp \
MEDNAFEN_SOURCES := $(MEDNAFEN_DIR)/error.cpp \
$(MEDNAFEN_DIR)/math_ops.cpp \
$(MEDNAFEN_DIR)/settings.cpp \
$(MEDNAFEN_DIR)/general.cpp \

View File

@ -1456,9 +1456,15 @@ static void LoadEXE(const uint8_t *data, const uint32_t size, bool ignore_pcsp =
TextSize = MDFN_de32lsb(&data[0x1C]);
if(ignore_pcsp)
MDFN_printf("TextStart=0x%08x\nTextSize=0x%08x\n", TextStart, TextSize);
{
if (log_cb)
log_cb(RETRO_LOG_INFO, "TextStart=0x%08x\nTextSize=0x%08x\n", TextStart, TextSize);
}
else
MDFN_printf("PC=0x%08x\nSP=0x%08x\nTextStart=0x%08x\nTextSize=0x%08x\n", PC, SP, TextStart, TextSize);
{
if (log_cb)
log_cb(RETRO_LOG_INFO, "PC=0x%08x\nSP=0x%08x\nTextStart=0x%08x\nTextSize=0x%08x\n", PC, SP, TextStart, TextSize);
}
TextStart &= 0x1FFFFF;
@ -2482,9 +2488,8 @@ static MDFNGI *MDFNI_LoadGame(const char *force_module, const char *name)
return(MDFNI_LoadCD(force_module, name));
#endif
MDFN_printf(_("Loading %s...\n"),name);
MDFN_indent(1);
if (log_cb)
log_cb(RETRO_LOG_INFO, "Loading %s...\n", name);
// Construct a NULL-delimited list of known file extensions for MDFN_fopen()
const FileExtensionSpecStruct *curexts = MDFNGameInfo->FileExtensions;
@ -2521,8 +2526,6 @@ static MDFNGI *MDFNI_LoadGame(const char *force_module, const char *name)
MDFN_LoadGameCheats(NULL);
MDFNMP_InstallReadPatches();
MDFN_indent(-2);
if(!MDFNGameInfo->name)
{
unsigned int x;
@ -3183,6 +3186,18 @@ void MDFND_DispMessage(unsigned char *str)
log_cb(RETRO_LOG_INFO, "%s\n", str);
}
void MDFN_DispMessage(const char *format, ...)
{
va_list ap;
va_start(ap,format);
char *msg = NULL;
trio_vasprintf(&msg, format,ap);
va_end(ap);
MDFND_DispMessage((UTF8*)msg);
}
void MDFND_Message(const char *str)
{
if (log_cb)

View File

@ -356,7 +356,8 @@ void CDAccess_Image::ImageOpen(const char *path, bool image_memcache)
if(!strcasecmp(file_ext.c_str(), ".toc"))
{
MDFN_printf(_("TOC file detected.\n"));
if (log_cb)
log_cb(RETRO_LOG_INFO, "TOC file detected.\n");
IsTOC = true;
}
@ -747,7 +748,8 @@ void CDAccess_Image::ImageOpen(const char *path, bool image_memcache)
else if(cmdbuf == "CDTEXTFILE" || cmdbuf == "CATALOG" || cmdbuf == "ISRC" ||
cmdbuf == "TITLE" || cmdbuf == "PERFORMER" || cmdbuf == "SONGWRITER")
{
MDFN_printf(_("Unsupported CUE sheet directive: \"%s\".\n"), cmdbuf.c_str()); // FIXME, generic logger passed by pointer to constructor
if (log_cb)
log_cb(RETRO_LOG_ERROR, "Unsupported CUE sheet directive: \"%s\".\n", cmdbuf.c_str());
}
else
{

View File

@ -9,10 +9,6 @@
extern std::vector<MDFNGI *>MDFNSystems;
/* Indent stdout newlines +- "indent" amount */
void MDFN_indent(int indent);
void MDFN_printf(const char *format, ...);
/* Displays an error. Can block or not. */
void MDFND_Message(const char *s);

View File

@ -1,124 +0,0 @@
/* Mednafen - Multi-system Emulator
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mednafen.h"
#include <string.h>
#include <stdarg.h>
#include <errno.h>
#include <trio/trio.h>
#include <list>
#include <algorithm>
#include "general.h"
#include "state.h"
#include "video.h"
#include "file.h"
#include "FileWrapper.h"
#ifdef NEED_CD
#include "cdrom/cdromif.h"
#include "cdrom/CDUtility.h"
#endif
#include "mempatcher.h"
#include "md5.h"
#include "clamp.h"
#ifdef _MSC_VER
#include "msvc_compat.h"
#endif
/* forward declarations */
extern void MDFND_DispMessage(unsigned char *str);
void MDFN_DispMessage(const char *format, ...)
{
va_list ap;
va_start(ap,format);
char *msg = NULL;
trio_vasprintf(&msg, format,ap);
va_end(ap);
MDFND_DispMessage((UTF8*)msg);
}
void MDFN_ResetMessages(void)
{
}
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);
}

View File

@ -47,7 +47,6 @@ extern MDFNGI *MDFNGameInfo;
#include "settings.h"
void MDFN_printf(const char *format, ...);
void MDFN_DispMessage(const char *format, ...);
void MDFN_LoadGameCheats(void *override);

View File

@ -236,19 +236,16 @@ void MDFN_LoadGameCheats(void *override_ptr)
fp = override;
else
{
std::string fn = MDFN_MakeFName(MDFNMKF_CHEAT,0,0).c_str();
const char *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 (log_cb && fn)
log_cb(RETRO_LOG_INFO, "Loading cheats from %s...\n", fn);
if(!(fp = fopen(fn.c_str(),"rb")))
if(!(fp = fopen(fn,"rb")))
{
ErrnoHolder ene(errno);
MDFN_printf(_("Error opening file: %s\n"), ene.StrError());
MDFN_indent(-1);
return;
if (log_cb)
log_cb(RETRO_LOG_ERROR, "Error opening file.\n");
return;
}
}
@ -273,8 +270,9 @@ 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]);
break;
if (log_cb)
log_cb(RETRO_LOG_ERROR, "Invalid cheat type: %c\n", tbuf[0]);
break;
}
type = tbuf[0];
namebuf[0] = 0;
@ -321,8 +319,8 @@ void MDFN_LoadGameCheats(void *override_ptr)
if(!override)
{
MDFN_printf(_("%lu cheats loaded.\n"), (unsigned long)cheats.size());
MDFN_indent(-1);
if (log_cb)
log_cb(RETRO_LOG_INFO, "%lu cheats loaded.\n", (unsigned long)cheats.size());
fclose(fp);
}
}