Commit 97721f60 authored by Libretro-Admin's avatar Libretro-Admin
Browse files

Cleanup unneeded code

parent 165bde94
......@@ -704,7 +704,7 @@ MDFN_COLD RETRO_API bool retro_load_game(const retro_game_info* game)
ExtMemStream gs(game->data, game->size);
GameFile gf({&NVFS, dir, &gs, MDFN_strazlower(ext.size() ? ext.substr(1) : ext), fbase, { &NVFS, dir, fbase }});
cgi = MDFNI_LoadGame(/*"snes_faust"*/nullptr, &gf);
cgi = MDFNI_LoadGame(&gf);
//
//
for(size_t i = 0; i < ports_active; i++)
......
......@@ -27,7 +27,6 @@
#include "FileStream.h"
#include <mednafen/mednafen.h>
#include <trio/trio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
......
......@@ -21,7 +21,6 @@
#include "types.h"
#include "Stream.h"
#include <trio/trio.h>
namespace Mednafen
{
......@@ -213,36 +212,6 @@ void Stream::put_line(const char* str)
write(&l, sizeof(l));
}
void Stream::print_format(const char *format, ...)
{
char *str = NULL;
int rc;
va_list ap;
va_start(ap, format);
rc = trio_vasprintf(&str, format, ap);
va_end(ap);
if(rc < 0)
throw MDFN_Error(0, "Error in trio_vasprintf()");
else
{
try // Bleck
{
write(str, rc);
}
catch(...)
{
free(str);
throw;
}
free(str);
}
}
int Stream::get_line(std::string &str)
{
uint8 c;
......
......@@ -219,8 +219,6 @@ class Stream
// Implemented as virtual so that a higher-performance version can be implemented if possible(IE with MemoryStream)
virtual int get_line(std::string &str);
virtual void print_format(const char *format, ...) MDFN_FORMATSTR(gnu_printf, 2, 3);
void put_line(const std::string& str);
void put_line(const char* s);
......
......@@ -22,8 +22,6 @@
#include <mednafen/mednafen.h>
#include <mednafen/mempatcher.h>
#include <trio/trio.h>
#include "snes.h"
namespace Mednafen
......
......@@ -128,42 +128,26 @@ static MDFN_COLD void LoadCommonPost(void)
last_pixel_format = MDFN_PixelFormat();
}
static MDFN_COLD MDFNGI* FindCompatibleModule(const char* force_module, GameFile* gf)
static MDFN_COLD MDFNGI* FindCompatibleModule(GameFile* gf)
{
//for(unsigned pass = 0; pass < 2; pass++)
//{
for(std::list<MDFNGI *>::iterator it = MDFNSystemsPrio.begin(); it != MDFNSystemsPrio.end(); it++) //_unsigned int x = 0; x < MDFNSystems.size(); x++)
{
if(force_module)
{
if(!strcmp(force_module, (*it)->shortname))
{
if(!(*it)->Load)
{
throw MDFN_Error(0, _("Specified system does not support normal file loading."));
}
return(*it);
}
}
else
{
if(!(*it)->Load || !(*it)->TestMagic)
continue;
gf->stream->rewind();
if((*it)->TestMagic(gf))
{
return(*it);
}
}
}
//}
return(NULL);
}
MDFNGI *MDFNI_LoadGame(const char *force_module, GameFile* gf)
MDFNGI *MDFNI_LoadGame(GameFile* gf)
{
MDFNI_CloseGame();
......@@ -171,15 +155,10 @@ MDFNGI *MDFNI_LoadGame(const char *force_module, GameFile* gf)
{
MDFN_AutoIndent aind(1);
MDFNGameInfo = FindCompatibleModule(force_module, gf);
MDFNGameInfo = FindCompatibleModule(gf);
if(!MDFNGameInfo)
{
if(force_module)
throw MDFN_Error(0, _("Unrecognized system \"%s\"!"), force_module);
else
throw MDFN_Error(0, _("Unrecognized file format."));
}
MDFN_printf(_("Using module: %s(%s)\n"), MDFNGameInfo->shortname, MDFNGameInfo->fullname);
{
......
......@@ -88,7 +88,7 @@ void MDFNI_Reset(void);
void MDFNI_Power(void);
//
MDFNGI* MDFNI_LoadGame(const char *force_module, GameFile* gf) MDFN_COLD;
MDFNGI* MDFNI_LoadGame(GameFile* gf) MDFN_COLD;
//
void MDFNI_Initialize(void) MDFN_COLD;
......
......@@ -29,7 +29,6 @@
#include "settings.h"
#include "string/string.h"
#include "MemoryStream.h"
#include <trio/trio.h>
namespace Mednafen
{
......
......@@ -84,125 +84,6 @@ class DSP1Chip
enum : int { ANGLE_HALF_PI = 16384 };
};
#if 0
static void SynthDataROM(void)
{
FileStream fp("datarom-synth.bin", FileStream::MODE_WRITE);
FileStream fph("datarom-synth.h", FileStream::MODE_WRITE);
int16 tmp[0x400];
memset(tmp, 0, sizeof(tmp));
// 0 ... 97
for(int i = 0; i < 98; i++)
{
int v = 0;
if(i == 60) // bug?
v = 1;
else if(i >= 34 && i <= 64)
v = std::min<int>(32767, 32768 >> abs(i - 49));
tmp[i] = v;
}
// TODO: 98 ... 100
// 101...228
//
// Inverse table
for(int i = 0; i < 128; i++)
{
int v = std::min<int>(32767, floor(0.5 + 32768.0 / (1.0 + i / 128.0)));
tmp[101 + i] = v;
}
// 229...277
//
// Square root table
for(int i = 0; i < 49; i++)
{
float fv = 32767.0 / 2.0 * sqrt(1.0 + i / 16.0);
int v = std::min<int>(32767, floor(fv));
tmp[229 + i] = v;
}
// 278...279
for(int i = 0; i < 2; i++)
{
int v = 32 << i;
tmp[278 + i] = v;
}
// 280 ... 407
//
// Sine table
for(int i = 0; i < 128; i++)
{
int v = std::min<int>(32767, floor(32768 * sin(i * M_PI / 128.0)));
tmp[280 + i] = v;
}
// 408 ... 535
//
// Cosine table
for(int i = 0; i < 128; i++)
{
float angle = i * M_PI / 128.0;
float fv = 32768.0 * cos(angle);
int v = std::min<int>(32767, (int)fv);
tmp[408 + i] = v;
}
// TODO: 536 ... 541
// pi, 2**7, (2**10)-1, ?, ?, 2**7
// 542 ... 797
//
// Arc cosine table
for(int i = 0; i < 256; i++)
{
float fv = 32768.0 * acos(i / 256.0) / M_PI;
int v = std::min<int>(32767, floor(0.5 + fv));
tmp[542 + i] = v;
}
// TODO: 798 ... 808
// 809
//
// tasty pie
{
int v = floor(0.5 + M_PI * 8192);
tmp[809] = v;
}
// TODO: 810 ... 816
// 817 ... 1023
for(int i = 817; i < 1024; i++)
{
tmp[i] = -1;
}
for(unsigned i = 0; i < 0x400; i++)
{
fp.put_LE<uint16>(tmp[i]);
fph.print_format("%d, ", tmp[i]);
if((i & 0xF) == 0xF)
fph.print_format("\n");
}
}
#endif
DSP1Chip::DSP1Chip()
{
Revision = 0x0101;
......
......@@ -27,8 +27,6 @@
#include "dis65816.h"
#include <trio/trio.h>
#include <bitset>
#ifdef SNES_DBG_ENABLE
......@@ -275,8 +273,8 @@ static MDFN_COLD std::vector<BranchTraceResult> GetBranchTrace(void)
continue;
tmp.count = bt->branch_count;
trio_snprintf(tmp.from, sizeof(tmp.from), "%06x", bt->from);
trio_snprintf(tmp.to, sizeof(tmp.to), "%06x", bt->to);
snprintf(tmp.from, sizeof(tmp.from), "%06x", bt->from);
snprintf(tmp.to, sizeof(tmp.to), "%06x", bt->to);
switch(bt->iseq)
{
......@@ -301,7 +299,7 @@ static MDFN_COLD std::vector<BranchTraceResult> GetBranchTrace(void)
break;
}
trio_snprintf(tmp.code, sizeof(tmp.code), "%s", estr);
snprintf(tmp.code, sizeof(tmp.code), "%s", estr);
ret.push_back(tmp);
}
......
......@@ -22,8 +22,6 @@
#include <mednafen/types.h>
#include "dis65816.h"
#include <trio/trio.h>
namespace Mednafen
{
......@@ -376,102 +374,102 @@ void Dis65816::Disassemble(uint32& A, uint32 SpecialA, char* buf, bool CurM, boo
case AM_IM_X: bs = 2 - X; break;
}
opbuf_count += bs;
trio_snprintf(buf, 256, "%s #$%0*X", ote->mnemonic, (int)(bs * 2), (opbuf[1] | (((bs == 1) ? 0 : opbuf[2]) << 8)));
snprintf(buf, 256, "%s #$%0*X", ote->mnemonic, (int)(bs * 2), (opbuf[1] | (((bs == 1) ? 0 : opbuf[2]) << 8)));
}
break;
case AM_AB:
opbuf_count += 2;
trio_snprintf(buf, 256, "%s $%04X", ote->mnemonic, MDFN_de16lsb(&opbuf[1]));
snprintf(buf, 256, "%s $%04X", ote->mnemonic, MDFN_de16lsb(&opbuf[1]));
break;
case AM_ABL:
opbuf_count += 3;
trio_snprintf(buf, 256, "%s $%06X", ote->mnemonic, MDFN_de24lsb(&opbuf[1]));
snprintf(buf, 256, "%s $%06X", ote->mnemonic, MDFN_de24lsb(&opbuf[1]));
break;
case AM_ABLX:
opbuf_count += 3;
trio_snprintf(buf, 256, "%s $%06X, X", ote->mnemonic, MDFN_de24lsb(&opbuf[1]));
snprintf(buf, 256, "%s $%06X, X", ote->mnemonic, MDFN_de24lsb(&opbuf[1]));
break;
case AM_ABX:
case AM_ABY:
opbuf_count += 2;
trio_snprintf(buf, 256, "%s $%04X, %c", ote->mnemonic, MDFN_de16lsb(&opbuf[1]), ((ote->address_mode == AM_ABY) ? 'Y' : 'X'));
snprintf(buf, 256, "%s $%04X, %c", ote->mnemonic, MDFN_de16lsb(&opbuf[1]), ((ote->address_mode == AM_ABY) ? 'Y' : 'X'));
break;
case AM_DP: // d
opbuf_count += 1;
trio_snprintf(buf, 256, "%s $%02X", ote->mnemonic, opbuf[1]);
snprintf(buf, 256, "%s $%02X", ote->mnemonic, opbuf[1]);
break;
case AM_DPX: // d, X
case AM_DPY: // d, Y
opbuf_count += 1;
trio_snprintf(buf, 256, "%s $%02X, %c", ote->mnemonic, opbuf[1], ((ote->address_mode == AM_DPY) ? 'Y' : 'X'));
snprintf(buf, 256, "%s $%02X, %c", ote->mnemonic, opbuf[1], ((ote->address_mode == AM_DPY) ? 'Y' : 'X'));
break;
case AM_IND: // (d)
opbuf_count += 1;
trio_snprintf(buf, 256, "%s ($%02X)", ote->mnemonic, opbuf[1]);
snprintf(buf, 256, "%s ($%02X)", ote->mnemonic, opbuf[1]);
break;
case AM_INDL: // [d]
opbuf_count += 1;
trio_snprintf(buf, 256, "%s [$%02X]", ote->mnemonic, opbuf[1]);
snprintf(buf, 256, "%s [$%02X]", ote->mnemonic, opbuf[1]);
break;
case AM_IX: // (d, X)
opbuf_count += 1;
trio_snprintf(buf, 256, "%s ($%02X, X)", ote->mnemonic, opbuf[1]);
snprintf(buf, 256, "%s ($%02X, X)", ote->mnemonic, opbuf[1]);
break;
case AM_IY: // (d), Y
opbuf_count += 1;
trio_snprintf(buf, 256, "%s ($%02X), Y", ote->mnemonic, opbuf[1]);
snprintf(buf, 256, "%s ($%02X), Y", ote->mnemonic, opbuf[1]);
break;
case AM_ILY: // [d], Y
opbuf_count += 1;
trio_snprintf(buf, 256, "%s [$%02X], Y", ote->mnemonic, opbuf[1]);
snprintf(buf, 256, "%s [$%02X], Y", ote->mnemonic, opbuf[1]);
break;
case AM_SR:
opbuf_count += 1;
trio_snprintf(buf, 256, "%s $%02X, S", ote->mnemonic, opbuf[1]);
snprintf(buf, 256, "%s $%02X, S", ote->mnemonic, opbuf[1]);
break;
case AM_SRIY:
opbuf_count += 1;
trio_snprintf(buf, 256, "%s ($%02X, S), Y", ote->mnemonic, opbuf[1]);
snprintf(buf, 256, "%s ($%02X, S), Y", ote->mnemonic, opbuf[1]);
break;
case AM_BLOCK:
opbuf_count += 2;
trio_snprintf(buf, 256, "%s $%02X, $%02X", ote->mnemonic, opbuf[1], opbuf[2]);
snprintf(buf, 256, "%s $%02X, $%02X", ote->mnemonic, opbuf[1], opbuf[2]);
break;
case AM_ABIND:
opbuf_count += 2;
trio_snprintf(buf, 256, "%s ($%04X)", ote->mnemonic, MDFN_de16lsb(&opbuf[1]));
snprintf(buf, 256, "%s ($%04X)", ote->mnemonic, MDFN_de16lsb(&opbuf[1]));
break;
case AM_ABIX:
opbuf_count += 2;
trio_snprintf(buf, 256, "%s ($%04X, X)", ote->mnemonic, MDFN_de16lsb(&opbuf[1]));
snprintf(buf, 256, "%s ($%04X, X)", ote->mnemonic, MDFN_de16lsb(&opbuf[1]));
break;
//
//
//
case AM_R:
opbuf_count += 1;
trio_snprintf(buf, 256, "%s $%06X", ote->mnemonic, (A & 0xFF0000) | ((A + 2 + (int8)opbuf[1]) & 0xFFFF) );
snprintf(buf, 256, "%s $%06X", ote->mnemonic, (A & 0xFF0000) | ((A + 2 + (int8)opbuf[1]) & 0xFFFF) );
break;
case AM_RL:
opbuf_count += 2;
trio_snprintf(buf, 256, "%s $%06X", ote->mnemonic, (A & 0xFF0000) | ((A + 2 + (int16)MDFN_de16lsb(&opbuf[1])) & 0xFFFF) );
snprintf(buf, 256, "%s $%06X", ote->mnemonic, (A & 0xFF0000) | ((A + 2 + (int16)MDFN_de16lsb(&opbuf[1])) & 0xFFFF) );
break;
}
......@@ -479,7 +477,7 @@ void Dis65816::Disassemble(uint32& A, uint32 SpecialA, char* buf, bool CurM, boo
{
if((!imxhsa && IsMXHintSet(TestA)) || TestA == SpecialA)
{
trio_snprintf(buf, 256, ".db $%02X", opbuf[0]);
snprintf(buf, 256, ".db $%02X", opbuf[0]);
A = (A + 1) & 0xFFFFFF;
return;
}
......@@ -492,7 +490,7 @@ void Dis65816::Disassemble(uint32& A, uint32 SpecialA, char* buf, bool CurM, boo
{
buf[i] = ' ';
}
trio_snprintf(buf + tp, 256 - tp, "; .M=%s%d%s, .X=%s%d%s", qstring, M, qstring, qstring, X, qstring);
snprintf(buf + tp, 256 - tp, "; .M=%s%d%s, .X=%s%d%s", qstring, M, qstring, qstring, X, qstring);
}
//
//
......
......@@ -27,35 +27,9 @@
#include <mednafen/mednafen.h>
#include "string.h"
#include <trio/trio.h>
namespace Mednafen
{
/*
static int AppendSS(void* data, int c)
{
std::string* ss = (std::string*)data;
ss->push_back(c);
return 1;
}
std::string MDFN_sprintf(const char* format, ...)
{
std::string ret;
va_list ap;
ret.reserve(64);
va_start(ap, format);
trio_vcprintf(AppendSS, &ret, format, ap);
va_end(ap);
return ret;
}
*/
// Remove whitespace from beginning of s
void MDFN_ltrim(char* s)
......@@ -183,36 +157,6 @@ std::string MDFN_trim(const std::string& s)
return ret;
}
void MDFN_zapctrlchars(char* s)
{
if(!s)
return;
while(*s)
{
if((unsigned char)*s < 0x20)
*s = ' ';
s++;
}
}
void MDFN_zapctrlchars(std::string* s)
{
for(auto& c : *s)
if((unsigned char)c < 0x20)
c = ' ';
}
std::string MDFN_zapctrlchars(const std::string& s)
{
std::string ret = s;
MDFN_zapctrlchars(&ret);
return ret;
}
void MDFN_strazlower(char* s)
{
while(*s)
......@@ -463,57 +407,6 @@ std::string MDFN_strescape(const std::string& str)
return ret;
}
std::vector<std::string> MDFN_strargssplit(const std::string& str)
{
std::vector<std::string> ret;
std::string tmp;
bool tmp_valid = false;
bool in_quote = false;
bool in_ws = true;
int last_c = 0;
for(size_t i = 0; i < str.size(); i++)
{
const int new_c = str[i];
const bool is_quote = (new_c == '"' && last_c != '\\');
const bool new_in_quote = in_quote ^ is_quote;
const bool new_in_ws = MDFN_isspace(new_c) & !new_in_quote;
if(!new_in_ws & !is_quote)
{
//printf("KA: %c\n", new_c);
tmp.push_back(new_c);
tmp_valid = true;
}
if((in_quote ^ new_in_quote) & new_in_quote)
tmp_valid = true;
if((in_ws ^ new_in_ws) & new_in_ws)
{
MDFN_strunescape(&tmp);
//printf("borp1: %s\n", tmp.c_str());
ret.push_back(tmp);
tmp.clear();
tmp_valid = false;
}
in_quote = new_in_quote;
in_ws = new_in_ws;
last_c = new_c;
}
if(tmp_valid)
{
MDFN_strunescape(&tmp);
//printf("borp2: %s\n", tmp.c_str());
ret.push_back(tmp);
}
return ret;
}
template<typename T> static void utf_noreplace(T* c) { }
template<int replacement, typename T> static void utf_replace(T* c) { *c = replacement; }
static INLINE void dummy_cp_handler(char32_t) { }
......@@ -944,80 +837,4 @@ std::u32string UTF16_to_UTF32(const char16_t* s, size_t slen, bool* invalid_utf1
}
bool UTF32_to_UTF8(const char32_t* s, size_t slen, char* d, size_t* dlen, bool permit_utf16_surrogates)
{
bool ret = true;
size_t di = 0;
for(size_t i = 0; i < slen; i++)
{
char32_t cp = s[i];
if(cp > 0x10FFFF || (!permit_utf16_surrogates && cp >= 0xD800 && cp <= 0xDFFF))
{
cp = 0xFFFD;
ret = false;
}
di += EncodeCP_UTF8(cp, &d[di], std::max<size_t>(*dlen, di) - di);
}
*dlen = di;
return ret;
}