-set main dol optimize level back to -O2

-set optimize level of booter from -Os to -O1
-added back name addition for gamecube game disc 2
-made gprintf, fmt and sfmt a bit more safe
-removed unneeded char for list check, just wastes memory
This commit is contained in:
fix94.1 2012-10-10 14:03:04 +00:00
parent fb7cdc4d75
commit 3d2363bd78
6 changed files with 41 additions and 27 deletions

View File

@ -55,7 +55,7 @@ ios := 249
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
CFLAGS = -g -O1 -Wall -Wextra -Wno-multichar $(MACHDEP) $(INCLUDE) -DHAVE_CONFIG_H
CFLAGS = -g -O2 -Wall -Wextra -Wno-multichar $(MACHDEP) $(INCLUDE) -DHAVE_CONFIG_H
CXXFLAGS = $(CFLAGS)
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map,--section-start,.init=0x80620000,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,malloc_usable_size

View File

@ -23,7 +23,7 @@ INCLUDES := source
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
CFLAGS = -g -Os -Wall -Wextra -Wno-multichar $(MACHDEP) $(INCLUDE) -DHAVE_CONFIG_H
CFLAGS = -g -O1 -Wall -Wextra -Wno-multichar $(MACHDEP) $(INCLUDE) -DHAVE_CONFIG_H
CXXFLAGS = $(CFLAGS)
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map,--section-start,.init=0x80A00000

View File

@ -17,7 +17,8 @@ bool geckoinit = false;
bool textVideoInit = false;
bool bufferMessages = true;
bool WriteToSD = false;
char tmpfilebuffer[1024];
#define SDWRITE_SIZE 1024
char sdwritebuffer[SDWRITE_SIZE];
static ssize_t __out_write(struct _reent *r __attribute__((unused)), int fd __attribute__((unused)), const char *ptr, size_t len)
{
@ -65,36 +66,39 @@ static void USBGeckoOutput()
devoptab_list[STD_ERR] = &gecko_out;
}
static void WriteToFile(char* tmp, int len)
static void WriteToFile(const char* tmp, size_t len)
{
if(!bufferMessages)
return;
if((strlen(tmpfilebuffer) + len) < 1024)
strcat(tmpfilebuffer, tmp);
if((strlen(sdwritebuffer) + len) < SDWRITE_SIZE)
strcat(sdwritebuffer, tmp);
if(WriteToSD)
{
FILE *outfile = fopen("sd:/wiiflow.log", "a");
if(outfile)
{
fwrite(tmpfilebuffer, 1, strlen(tmpfilebuffer), outfile);
memset(tmpfilebuffer, 0, 1024);
fwrite(sdwritebuffer, 1, strlen(sdwritebuffer), outfile);
memset(sdwritebuffer, 0, SDWRITE_SIZE);
fclose(outfile);
}
}
}
char gprintfBuffer[256];
#define GPRINTF_SIZE 256
static char gprintfBuffer[GPRINTF_SIZE];
void gprintf(const char *format, ...)
{
va_list va;
va_start(va, format);
int len = vsnprintf(gprintfBuffer, 255, format, va);
size_t len = vsnprintf(gprintfBuffer, GPRINTF_SIZE - 1, format, va);
gprintfBuffer[GPRINTF_SIZE - 1] = '\0';
va_end(va);
__out_write(NULL, 0, gprintfBuffer, len);
WifiGecko_Send(gprintfBuffer, len);
WriteToFile(gprintfBuffer, len);
va_end(va);
}
char ascii(char s)
@ -137,14 +141,15 @@ void ghexdump(void *d, int len)
}
}
const char *initstr = "USB Gecko inited.\n";
static const char *initstr = "USB Gecko inited.\n";
bool InitGecko()
{
if(geckoinit)
return geckoinit;
USBGeckoOutput();
memset(tmpfilebuffer, 0, 1024);
memset(sdwritebuffer, 0, SDWRITE_SIZE);
memset(gprintfBuffer, 0, GPRINTF_SIZE);
#ifdef sd_write_log
WriteToSD = true;

View File

@ -1,16 +1,18 @@
#include "text.hpp"
int currentStr = 0;
char fmt_buffer[MAX_USES][MAX_MSG_SIZE];
char general_buffer[MAX_MSG_SIZE];
static char fmt_buffer[MAX_USES][MAX_MSG_SIZE];
static char general_buffer[MAX_MSG_SIZE];
// Simplified use of sprintf
const char *fmt(const char *format, ...)
char *fmt(const char *format, ...)
{
va_list va;
va_start(va, format);
currentStr = (currentStr + 1) % MAX_USES;
vsnprintf(fmt_buffer[currentStr], MAX_MSG_SIZE - 1, format, va);
fmt_buffer[currentStr][MAX_MSG_SIZE - 1] = '\0';
va_end(va);
return fmt_buffer[currentStr];
}
@ -19,7 +21,8 @@ string sfmt(const char *format, ...)
{
va_list va;
va_start(va, format);
int len = vsnprintf(general_buffer, MAX_MSG_SIZE - 1, format, va);
size_t len = vsnprintf(general_buffer, MAX_MSG_SIZE - 1, format, va);
general_buffer[MAX_MSG_SIZE - 1] = '\0';
va_end(va);
return string(general_buffer, len);
}
@ -80,6 +83,7 @@ wstringEx wfmt(const wstringEx &format, ...)
va_list va;
va_start(va, format);
vsnprintf(general_buffer, MAX_MSG_SIZE - 1, format.toUTF8().c_str(), va);
general_buffer[MAX_MSG_SIZE - 1] = '\0';
va_end(va);
wstringEx wide_buffer;
wide_buffer.fromUTF8(general_buffer);

View File

@ -61,7 +61,7 @@ enum {
MAX_USES = 8,
};
const char *fmt(const char *format, ...);
char *fmt(const char *format, ...);
std::string sfmt(const char *format, ...);
wstringEx wfmt(const wstringEx &format, ...);
bool checkFmt(const wstringEx &ref, const wstringEx &format);

View File

@ -68,7 +68,7 @@ static void AddISO(const char *GameID, const char *GameTitle, const char *GamePa
memset((void*)&ListElement, 0, sizeof(dir_discHdr));
ListElement.index = m_gameList.size();
if(GameID != NULL) strncpy(ListElement.id, GameID, 6);
if(GamePath != NULL) strncpy(ListElement.path, GamePath, sizeof(ListElement.path));
if(GamePath != NULL) strncpy(ListElement.path, GamePath, sizeof(ListElement.path) - 1);
ListElement.casecolor = CustomTitles.getColor("COVERS", ListElement.id, GameColor).intVal();
string CustomTitle = CustomTitles.getString("TITLES", ListElement.id);
if(gameTDB.IsLoaded())
@ -116,6 +116,7 @@ static void Create_Wii_EXT_List(char *FullPath)
}
}
static u8 gc_disc[1];
static const char *FST_APPEND = "sys/boot.bin";
static const u8 FST_APPEND_SIZE = strlen(FST_APPEND);
static void Create_GC_List(char *FullPath)
@ -124,15 +125,22 @@ static void Create_GC_List(char *FullPath)
if(!fp && strstr(FullPath, "/root") != NULL) //fst folder
{
*(strstr(FullPath, "/root") + 1) = '\0';
if(strlen(FullPath) + FST_APPEND_SIZE < 256) strcat(FullPath, FST_APPEND);
if(strlen(FullPath) + FST_APPEND_SIZE < MAX_MSG_SIZE) strcat(FullPath, FST_APPEND);
fp = fopen(FullPath, "rb");
}
if(fp)
{
fread((void*)&GCGameHeader, 1, sizeof(gc_discHdr), fp);
if(GCGameHeader.magic == GC_MAGIC)
{
AddISO((const char*)GCGameHeader.id, (const char*)GCGameHeader.title,
FullPath, 0, TYPE_GC_GAME);
/* Check for disc 2 */
fseek(fp, 6, SEEK_SET);
fread(gc_disc, 1, 1, fp);
if(gc_disc[0])
wcslcat(m_gameList.back().title, L" disc 2", 63);
}
fclose(fp);
}
}
@ -141,7 +149,7 @@ static void Create_Plugin_List(char *FullPath)
{
memset((void*)&ListElement, 0, sizeof(dir_discHdr));
strncpy(ListElement.path, FullPath, sizeof(ListElement.path));
strncpy(ListElement.path, FullPath, sizeof(ListElement.path) - 1);
strncpy(ListElement.id, "PLUGIN", 6);
*strchr(FullPath, '.') = '\0';
mbstowcs(ListElement.title, strrchr(FullPath, '/') + 1, 63);
@ -160,7 +168,7 @@ static void Create_Homebrew_List(char *FullPath)
memset((void*)&ListElement, 0, sizeof(dir_discHdr));
ListElement.index = m_gameList.size();
*strrchr(FullPath, '/') = '\0';
strncpy(ListElement.path, FullPath, sizeof(ListElement.path));
strncpy(ListElement.path, FullPath, sizeof(ListElement.path) - 1);
strncpy(ListElement.id, "HB_APP", 6);
static const char *FolderTitle = strrchr(FullPath, '/') + 1;
@ -267,6 +275,7 @@ void GetFiles(const char *Path, const vector<string>& FileTypes,
FileAdder AddFile, bool CompareFolders, u32 max_depth, u32 depth)
{
static const char *NewFileName = NULL;
static char *FullPathChar = NULL;
static dirent *pent = NULL;
static DIR *pdir = NULL;
vector<string> SubPaths;
@ -274,15 +283,11 @@ void GetFiles(const char *Path, const vector<string>& FileTypes,
pdir = opendir(Path);
if(pdir == NULL)
return;
char FullPathChar[256];
if(FullPathChar == NULL)
return;
memset(FullPathChar, 0, 256);
while((pent = readdir(pdir)) != NULL)
{
if(pent->d_name[0] == '.')
continue;
strncpy(FullPathChar, fmt("%s/%s", Path, pent->d_name), 255);
FullPathChar = fmt("%s/%s", Path, pent->d_name);
if(pent->d_type == DT_DIR)
{
if(CompareFolders && IsFileSupported(pent->d_name, FileTypes))