Skip to content

Commit

Permalink
axe wchar
Browse files Browse the repository at this point in the history
  • Loading branch information
flyinghead committed Jan 31, 2020
1 parent d476b79 commit b79c074
Show file tree
Hide file tree
Showing 24 changed files with 75 additions and 94 deletions.
18 changes: 9 additions & 9 deletions core/cfg/cfg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void savecfgf()
fclose(cfgfile);
}
}
void cfgSaveStr(const wchar * Section, const wchar * Key, const wchar * String)
void cfgSaveStr(const char * Section, const char * Key, const char * String)
{
const std::string section(Section);
const std::string key(Key);
Expand Down Expand Up @@ -116,7 +116,7 @@ bool cfgOpen()
//0 : not found
//1 : found section , key was 0
//2 : found section & key
s32 cfgExists(const wchar * Section, const wchar * Key)
s32 cfgExists(const char * Section, const char * Key)
{
if(cfgdb.has_entry(string(Section), string(Key)))
{
Expand All @@ -128,14 +128,14 @@ s32 cfgExists(const wchar * Section, const wchar * Key)
}
}

void cfgLoadStr(const wchar * Section, const wchar * Key, wchar * Return,const wchar* Default)
void cfgLoadStr(const char * Section, const char * Key, char * Return,const char* Default)
{
string value = cfgdb.get(Section, Key, Default);
// FIXME: Buffer overflow possible
strcpy(Return, value.c_str());
}

string cfgLoadStr(const wchar * Section, const wchar * Key, const wchar* Default)
string cfgLoadStr(const char * Section, const char * Key, const char* Default)
{
std::string v = cfgdb.get(string(Section), string(Key), string(Default));
if (cfgHasGameSpecificConfig())
Expand All @@ -145,14 +145,14 @@ string cfgLoadStr(const wchar * Section, const wchar * Key, const wchar* Defaul
}

//These are helpers , mainly :)
void cfgSaveInt(const wchar * Section, const wchar * Key, s32 Int)
void cfgSaveInt(const char * Section, const char * Key, s32 Int)
{
char str[32];
sprintf(str, "%d", Int);
cfgSaveStr(Section, Key, str);
}

s32 cfgLoadInt(const wchar * Section, const wchar * Key,s32 Default)
s32 cfgLoadInt(const char * Section, const char * Key,s32 Default)
{
s32 v = cfgdb.get_int(string(Section), string(Key), Default);
if (cfgHasGameSpecificConfig())
Expand All @@ -161,12 +161,12 @@ s32 cfgLoadInt(const wchar * Section, const wchar * Key,s32 Default)
return v;
}

void cfgSaveBool(const wchar * Section, const wchar * Key, bool BoolValue)
void cfgSaveBool(const char * Section, const char * Key, bool BoolValue)
{
cfgSaveStr(Section, Key, BoolValue ? "yes" : "no");
}

bool cfgLoadBool(const wchar * Section, const wchar * Key,bool Default)
bool cfgLoadBool(const char * Section, const char * Key,bool Default)
{
bool v = cfgdb.get_bool(string(Section), string(Key), Default);
if (cfgHasGameSpecificConfig())
Expand All @@ -175,7 +175,7 @@ bool cfgLoadBool(const wchar * Section, const wchar * Key,bool Default)
return v;
}

void cfgSetVirtual(const wchar * Section, const wchar * Key, const wchar * String)
void cfgSetVirtual(const char * Section, const char * Key, const char * String)
{
cfgdb.set(string(Section), string(Key), string(String), true);
}
Expand Down
20 changes: 10 additions & 10 deletions core/cfg/cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
*/

bool cfgOpen();
s32 cfgLoadInt(const wchar * lpSection, const wchar * lpKey,s32 Default);
void cfgSaveInt(const wchar * lpSection, const wchar * lpKey, s32 Int);
void cfgLoadStr(const wchar * lpSection, const wchar * lpKey, wchar * lpReturn,const wchar* lpDefault);
string cfgLoadStr(const wchar * Section, const wchar * Key, const wchar* Default);
void cfgSaveStr(const wchar * lpSection, const wchar * lpKey, const wchar * lpString);
void cfgSaveBool(const wchar * Section, const wchar * Key, bool BoolValue);
bool cfgLoadBool(const wchar * Section, const wchar * Key,bool Default);
s32 cfgExists(const wchar * Section, const wchar * Key);
void cfgSetVirtual(const wchar * lpSection, const wchar * lpKey, const wchar * lpString);
s32 cfgLoadInt(const char * lpSection, const char * lpKey,s32 Default);
void cfgSaveInt(const char * lpSection, const char * lpKey, s32 Int);
void cfgLoadStr(const char * lpSection, const char * lpKey, char * lpReturn,const char* lpDefault);
string cfgLoadStr(const char * Section, const char * Key, const char* Default);
void cfgSaveStr(const char * lpSection, const char * lpKey, const char * lpString);
void cfgSaveBool(const char * Section, const char * Key, bool BoolValue);
bool cfgLoadBool(const char * Section, const char * Key,bool Default);
s32 cfgExists(const char * Section, const char * Key);
void cfgSetVirtual(const char * lpSection, const char * lpKey, const char * lpString);

bool ParseCommandLine(int argc,wchar* argv[]);
bool ParseCommandLine(int argc,char* argv[]);

void cfgSetGameId(const char *id);
const char *cfgGetGameId();
Expand Down
20 changes: 10 additions & 10 deletions core/cfg/cl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include "cfg/cfg.h"

wchar* trim_ws(wchar* str)
char* trim_ws(char* str)
{
if (str==0 || strlen(str)==0)
return 0;
Expand Down Expand Up @@ -42,7 +42,7 @@ wchar* trim_ws(wchar* str)
return str;
}

int setconfig(wchar** arg,int cl)
int setconfig(char** arg,int cl)
{
int rv=0;
for(;;)
Expand All @@ -52,13 +52,13 @@ int setconfig(wchar** arg,int cl)
WARN_LOG(COMMON, "-config : invalid number of parameters, format is section:key=value");
return rv;
}
wchar* sep=strstr(arg[1],":");
char* sep=strstr(arg[1],":");
if (sep==0)
{
WARN_LOG(COMMON, "-config : invalid parameter %s, format is section:key=value", arg[1]);
return rv;
}
wchar* value=strstr(sep+1,"=");
char* value=strstr(sep+1,"=");
if (value==0)
{
WARN_LOG(COMMON, "-config : invalid parameter %s, format is section:key=value", arg[1]);
Expand All @@ -68,8 +68,8 @@ int setconfig(wchar** arg,int cl)
*sep++=0;
*value++=0;

wchar* sect=trim_ws(arg[1]);
wchar* key=trim_ws(sep);
char* sect=trim_ws(arg[1]);
char* key=trim_ws(sep);
value=trim_ws(value);

if (sect==0 || key==0)
Expand All @@ -78,7 +78,7 @@ int setconfig(wchar** arg,int cl)
return rv;
}

const wchar* constval = value;
const char* constval = value;
if (constval==0)
constval="";
INFO_LOG(COMMON, "Virtual cfg %s:%s=%s", sect, key, value);
Expand All @@ -99,7 +99,7 @@ int setconfig(wchar** arg,int cl)
return rv;
}

int showhelp(wchar** arg,int cl)
int showhelp(char** arg,int cl)
{
NOTICE_LOG(COMMON, "Available commands:");

Expand All @@ -109,11 +109,11 @@ int showhelp(wchar** arg,int cl)
return 0;
}

bool ParseCommandLine(int argc,wchar* argv[])
bool ParseCommandLine(int argc,char* argv[])
{
settings.imgread.ImagePath[0] = '\0';
int cl=argc-2;
wchar** arg=argv+1;
char** arg=argv+1;
while(cl>=0)
{
if (stricmp(*arg,"-help")==0 || stricmp(*arg,"--help")==0)
Expand Down
2 changes: 1 addition & 1 deletion core/cfg/ini.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "ini.h"
#include <sstream>

wchar* trim_ws(wchar* str);
char* trim_ws(char* str);

namespace emucfg {

Expand Down
12 changes: 6 additions & 6 deletions core/hw/flashrom/flashrom.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,18 @@ struct MemChip

bool Load(const string& root,const string& prefix,const string& names_ro,const string& title)
{
wchar base[512];
wchar temp[512];
wchar names[512];
char base[512];
char temp[512];
char names[512];

// FIXME: Data loss if buffer is too small
strncpy(names,names_ro.c_str(), sizeof(names));
names[sizeof(names) - 1] = '\0';

sprintf(base,"%s",root.c_str());

wchar* curr=names;
wchar* next;
char* curr=names;
char* next;
do
{
next=strstr(curr,";");
Expand Down Expand Up @@ -116,7 +116,7 @@ struct MemChip
}
void Save(const string& root,const string& prefix,const string& name_ro,const string& title)
{
wchar path[512];
char path[512];

sprintf(path,"%s%s%s",root.c_str(),prefix.c_str(),name_ro.c_str());
Save(path);
Expand Down
2 changes: 1 addition & 1 deletion core/hw/maple/maple_devs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ struct maple_sega_vmu: maple_base
{
memset(flash_data, 0, sizeof(flash_data));
memset(lcd_data, 0, sizeof(lcd_data));
wchar tempy[512];
char tempy[512];
sprintf(tempy, "/vmu_save_%s.bin", logical_port);
string apath = get_writable_data_path(tempy);

Expand Down
2 changes: 1 addition & 1 deletion core/hw/maple/maple_devs.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ struct maple_device
u8 maple_port; //raw maple port
u8 bus_port; //0 .. 5
u8 bus_id; //0 .. 3
wchar logical_port[3]; //A0, etc
char logical_port[3]; //A0, etc
IMapleConfigMap* config;

//fill in the info
Expand Down
16 changes: 0 additions & 16 deletions core/hw/sh4/dyna/driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,6 @@ std::unordered_set<u32> smc_hotspots;

void* emit_GetCCPtr() { return emit_ptr==0?(void*)&CodeCache[LastAddr]:(void*)emit_ptr; }
void emit_SetBaseAddr() { LastAddr_min = LastAddr; }
void emit_WriteCodeCache()
{
wchar path[512];
sprintf(path,"/code_cache_%8p.bin",CodeCache);
string pt2=get_writable_data_path(path);
INFO_LOG(DYNAREC, "Writing code cache to %s",pt2.c_str());
FILE*f=fopen(pt2.c_str(),"wb");
if (f)
{
fwrite(CodeCache,LastAddr,1,f);
fclose(f);
INFO_LOG(DYNAREC, "Written!");
}

bm_WriteBlockMap(pt2+".map");
}

void clear_temp_cache(bool full)
{
Expand Down
2 changes: 1 addition & 1 deletion core/imgread/cdi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "deps/chdpsr/cdipsr.h"

Disc* cdi_parse(const wchar* file)
Disc* cdi_parse(const char* file)
{
// Only try to open .cdi files
size_t len = strlen(file);
Expand Down
6 changes: 3 additions & 3 deletions core/imgread/chd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct CHDDisc : Disc
hunk_mem=0;
}

bool TryOpen(const wchar* file);
bool TryOpen(const char* file);

~CHDDisc()
{
Expand Down Expand Up @@ -79,7 +79,7 @@ struct CHDTrack : TrackFile
}
};

bool CHDDisc::TryOpen(const wchar* file)
bool CHDDisc::TryOpen(const char* file)
{
chd_error err=chd_open(file,CHD_OPEN_READ,0,&chd);

Expand Down Expand Up @@ -180,7 +180,7 @@ bool CHDDisc::TryOpen(const wchar* file)
}


Disc* chd_parse(const wchar* file)
Disc* chd_parse(const char* file)
{
// Only try to open .chd files
size_t len = strlen(file);
Expand Down
18 changes: 9 additions & 9 deletions core/imgread/common.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#include "common.h"

Disc* chd_parse(const wchar* file);
Disc* gdi_parse(const wchar* file);
Disc* cdi_parse(const wchar* file);
Disc* cue_parse(const wchar* file);
Disc* chd_parse(const char* file);
Disc* gdi_parse(const char* file);
Disc* cdi_parse(const char* file);
Disc* cue_parse(const char* file);
#ifdef _WIN32
Disc* ioctl_parse(const wchar* file);
Disc* ioctl_parse(const char* file);
#endif

u32 NullDriveDiscType;
Disc* disc;

Disc*(*drivers[])(const wchar* path)=
Disc*(*drivers[])(const char* path)=
{
chd_parse,
gdi_parse,
Expand Down Expand Up @@ -112,15 +112,15 @@ bool ConvertSector(u8* in_buff , u8* out_buff , int from , int to,int sector)
return true;
}

Disc* OpenDisc(const wchar* fn)
Disc* OpenDisc(const char* fn)
{
Disc* rv = NULL;

for (unat i=0; drivers[i] && !rv; i++) { // ;drivers[i] && !(rv=drivers[i](fn));
rv = drivers[i](fn);

if (rv && cdi_parse == drivers[i]) {
const wchar warn_str[] = "Warning: CDI Image Loaded! Many CDI images are known to be defective, GDI, CUE or CHD format is preferred. "
const char warn_str[] = "Warning: CDI Image Loaded! Many CDI images are known to be defective, GDI, CUE or CHD format is preferred. "
"Please only file bug reports when using images known to be good (GDI, CUE or CHD).";
WARN_LOG(GDROM, "%s", warn_str);

Expand All @@ -131,7 +131,7 @@ Disc* OpenDisc(const wchar* fn)
return rv;
}

bool InitDrive_(wchar* fn)
bool InitDrive_(char* fn)
{
TermDrive();

Expand Down
4 changes: 2 additions & 2 deletions core/imgread/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void GetDriveSector(u8 * buff,u32 StartSector,u32 SectorCount,u32 secsz);

void GetDriveSessionInfo(u8* to,u8 session);
int GetFile(char *szFileName, char *szParse=0,u32 flags=0);
int msgboxf(wchar* text,unsigned int type,...);
int msgboxf(char* text,unsigned int type,...);
void printtoc(TocInfo* toc,SessionInfo* ses);
extern u8 q_subchannel[96];

Expand Down Expand Up @@ -263,7 +263,7 @@ struct Disc

extern Disc* disc;

Disc* OpenDisc(const wchar* fn);
Disc* OpenDisc(const char* fn);

struct RawTrackFile : TrackFile
{
Expand Down
2 changes: 1 addition & 1 deletion core/imgread/cue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static u32 getSectorSize(const string& type) {
return 0;
}

Disc* cue_parse(const wchar* file)
Disc* cue_parse(const char* file)
{
// Only try to open .cue files
size_t len = strlen(file);
Expand Down
Loading

0 comments on commit b79c074

Please sign in to comment.