varous bugfixes, xstring trimming functions logic bugs, etc
some refactoring, some wtfs... ;)
This commit is contained in:
parent
125173107b
commit
565f063fa5
|
@ -15,8 +15,8 @@ int Assemble(unsigned char *output, int addr, char *str) {
|
|||
//unsigned char opcode[3] = { 0,0,0 };
|
||||
output[0] = output[1] = output[2] = 0;
|
||||
char astr[128],ins[4];
|
||||
|
||||
if ((!strlen(str)) || (strlen(str) > 0x127)) return 1;
|
||||
int len = strlen(str);
|
||||
if ((!len) || (len > 0x127)) return 1;
|
||||
|
||||
strcpy(astr,str);
|
||||
str_ucase(astr);
|
||||
|
@ -211,7 +211,7 @@ int Assemble(unsigned char *output, int addr, char *str) {
|
|||
output[2] = (tmpint >> 8);
|
||||
}
|
||||
else { //Zero Page
|
||||
if ((output[0] != 0x86) || (output[0] != 0xA2)) return 1; //only STX and LDX Absolute,Y!
|
||||
if ((output[0] != 0x86) && (output[0] != 0xA2)) return 1; //only STX and LDX Absolute,Y!
|
||||
output[0] |= 0x10;
|
||||
output[1] = (tmpint & 0xFF);
|
||||
}
|
||||
|
|
|
@ -608,7 +608,7 @@ int FCEUI_SetCheat(uint32 which, const char *name, int32 a, int32 v, int compare
|
|||
{
|
||||
char *t;
|
||||
|
||||
if((t=(char *)realloc(next->name,strlen(name+1))))
|
||||
if((t=(char *)realloc(next->name,strlen(name)+1)))
|
||||
{
|
||||
next->name=t;
|
||||
strcpy(next->name,name);
|
||||
|
|
|
@ -228,7 +228,7 @@ int getBank(int offs)
|
|||
}
|
||||
|
||||
int GetNesFileAddress(int A){
|
||||
unsigned int result;
|
||||
int result;
|
||||
if((A < 0x8000) || (A > 0xFFFF))return -1;
|
||||
result = &Page[A>>11][A]-PRGptr[0];
|
||||
if((result > PRGsize[0]) || (result < 0))return -1;
|
||||
|
|
|
@ -478,7 +478,7 @@ int *GetEditHexData(HWND hwndDlg, int id){
|
|||
int i,j, k;
|
||||
|
||||
GetDlgItemText(hwndDlg,id,str,60);
|
||||
memset(data,0,30*sizeof(int));
|
||||
memset(data,0,31*sizeof(int));
|
||||
j=0;
|
||||
for(i = 0;i < 60;i++){
|
||||
if(str[i] == 0)break;
|
||||
|
|
|
@ -19,14 +19,14 @@ void CenterWindow(HWND hwndDlg)
|
|||
GetWindowRect(hwndDlg, &rect);
|
||||
GetWindowRect(hwndParent, &rectP);
|
||||
|
||||
unsigned int width = rect.right - rect.left;
|
||||
unsigned height = rect.bottom - rect.top;
|
||||
int width = rect.right - rect.left;
|
||||
int height = rect.bottom - rect.top;
|
||||
|
||||
unsigned x = ((rectP.right-rectP.left) - width) / 2 + rectP.left;
|
||||
unsigned y = ((rectP.bottom-rectP.top) - height) / 2 + rectP.top;
|
||||
int x = ((rectP.right-rectP.left) - width) / 2 + rectP.left;
|
||||
int y = ((rectP.bottom-rectP.top) - height) / 2 + rectP.top;
|
||||
|
||||
unsigned int screenwidth = GetSystemMetrics(SM_CXSCREEN);
|
||||
unsigned int screenheight = GetSystemMetrics(SM_CYSCREEN);
|
||||
int screenwidth = GetSystemMetrics(SM_CXSCREEN);
|
||||
int screenheight = GetSystemMetrics(SM_CYSCREEN);
|
||||
|
||||
//make sure that the dialog box never moves outside of the screen
|
||||
if(x < 0) x = 0;
|
||||
|
|
|
@ -1690,7 +1690,6 @@ static void PresetImport(int preset)
|
|||
if(GetOpenFileName(&ofn))
|
||||
{
|
||||
//Save the directory
|
||||
if(ofn.nFileOffset < 1024)
|
||||
if(ofn.nFileOffset < 1024)
|
||||
{
|
||||
free(InputPresetDir);
|
||||
|
|
|
@ -608,7 +608,7 @@ int main(int argc,char *argv[])
|
|||
|
||||
SetThreadAffinityMask(GetCurrentThread(),1);
|
||||
|
||||
printf("%08x",opsize);
|
||||
//printf("%08x",opsize); //AGAIN?!
|
||||
|
||||
char *t;
|
||||
|
||||
|
@ -832,7 +832,7 @@ doloopy:
|
|||
if(closeGame)
|
||||
{
|
||||
FCEUI_CloseGame();
|
||||
GameInfo = 0;
|
||||
GameInfo = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -683,7 +683,7 @@ void UnfreezeAllRam() {
|
|||
// would be added by the freeze command. Manual unfreeze should let them
|
||||
// make that mistake once or twice, in case they like it that way.
|
||||
FCEUI_GetCheat(i,&Cname,&Caddr,NULL,NULL,NULL,&Ctype);
|
||||
if ((Cname[0] == '\0') && (((Caddr >= 0) && (Caddr < 0x2000)) || ((Caddr >= 0x6000) && (Caddr < 0x8000))) && (Ctype == 1)) {
|
||||
if ((Cname[0] == '\0') && ((Caddr < 0x2000) || ((Caddr >= 0x6000) && (Caddr < 0x8000))) && (Ctype == 1)) {
|
||||
// Already Added, so consider it a success
|
||||
FreezeRam(Caddr,-1,1);
|
||||
|
||||
|
|
|
@ -708,7 +708,7 @@ static BOOL CALLBACK MemWatchCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
|
|||
switch(uMsg)
|
||||
{
|
||||
case WM_ENTERMENULOOP:
|
||||
EnableMenuItem(memwmenu,MEMW_FILE_SAVE,MF_BYCOMMAND | fileChanged ? MF_ENABLED:MF_GRAYED);
|
||||
EnableMenuItem(memwmenu,MEMW_FILE_SAVE,MF_BYCOMMAND | (fileChanged ? MF_ENABLED : MF_GRAYED));
|
||||
break;
|
||||
case WM_MOVE: {
|
||||
if (!IsIconic(hwndDlg)) {
|
||||
|
|
|
@ -114,7 +114,7 @@ BOOL updateResults(HWND hwndDlg, int rule)
|
|||
|
||||
if ( chosen_rules[i] == RULE_EXACT || chosen_rules[i] == RULE_EXACT_NOT )
|
||||
{
|
||||
SendDlgItemMessage( hwndDlg, RULE_INPUT_1 + i, WM_GETTEXT, sizeof(buff - 1), (LPARAM) input_buff );
|
||||
SendDlgItemMessage( hwndDlg, RULE_INPUT_1 + i, WM_GETTEXT, sizeof(buff) - 1, (LPARAM) input_buff );
|
||||
|
||||
unsigned int len = strlen(input_buff);
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ bool IsHardwareAddressValid(HWAddressType address)
|
|||
if (!GameInfo)
|
||||
return false;
|
||||
|
||||
if ((address >= 0x0000 && address <= 0x07ff) || (address >= 0x6000 && address <= 0x7FFF))
|
||||
if ((address <= 0x07ff) || (address >= 0x6000 && address <= 0x7FFF))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
@ -874,10 +874,10 @@ bool Set_RS_Val()
|
|||
appliedSize = 'w', appliedSign = 'u';
|
||||
if(rs_c == 'a')
|
||||
appliedSize = 'd', appliedSign = 'u';
|
||||
if((appliedSize == 'b' && appliedSize == 's' && (rs_param < -128 || rs_param > 127)) ||
|
||||
(appliedSize == 'b' && appliedSize != 's' && (rs_param < 0 || rs_param > 255)) ||
|
||||
(appliedSize == 'w' && appliedSize == 's' && (rs_param < -32768 || rs_param > 32767)) ||
|
||||
(appliedSize == 'w' && appliedSize != 's' && (rs_param < 0 || rs_param > 65535)))
|
||||
if((appliedSize == 'b' && appliedSign == 's' && (rs_param < -128 || rs_param > 127)) ||
|
||||
(appliedSize == 'b' && appliedSign != 's' && (rs_param < 0 || rs_param > 255)) ||
|
||||
(appliedSize == 'w' && appliedSign == 's' && (rs_param < -32768 || rs_param > 32767)) ||
|
||||
(appliedSize == 'w' && appliedSign != 's' && (rs_param < 0 || rs_param > 65535)))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,11 +21,11 @@ extern bool RWfileChanged;
|
|||
struct AddressWatcher
|
||||
{
|
||||
unsigned int Address; // hardware address
|
||||
char Size; //'d' = 4 bytes, 'w' = 2 bytes, 'b' = 1 byte, and 'S' means it's a separator.
|
||||
char Type;//'s' = signed integer, 'u' = unsigned, 'h' = hex, 'S' = separator
|
||||
unsigned int CurValue;
|
||||
char* comment; // NULL means no comment, non-NULL means allocated comment
|
||||
bool WrongEndian;
|
||||
unsigned int CurValue;
|
||||
char Size; //'d' = 4 bytes, 'w' = 2 bytes, 'b' = 1 byte, and 'S' means it's a separator.
|
||||
char Type;//'s' = signed integer, 'u' = unsigned, 'h' = hex, 'S' = separator
|
||||
};
|
||||
#define MAX_WATCH_COUNT 256
|
||||
extern AddressWatcher rswatches[MAX_WATCH_COUNT];
|
||||
|
|
|
@ -965,7 +965,7 @@ void FCEUD_MovieRecordTo()
|
|||
if(loadStateFailed)
|
||||
{
|
||||
char str [1024];
|
||||
sprintf(str, "Failed to load save state \"%s\".\nRecording from current state instead...", p.szSavestateFilename);
|
||||
sprintf(str, "Failed to load save state \"%s\".\nRecording from current state instead...", p.szSavestateFilename.c_str());
|
||||
FCEUD_PrintError(str);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -333,7 +333,6 @@ void SELECTION::saveSelection(SelectionFrames& selection, EMUFILE *os)
|
|||
bool SELECTION::loadSelection(SelectionFrames& selection, EMUFILE *is)
|
||||
{
|
||||
int temp_int, temp_size;
|
||||
selection.clear();
|
||||
if (!read32le(&temp_size, is)) return true;
|
||||
selection.clear();
|
||||
for(; temp_size > 0; temp_size--)
|
||||
|
|
|
@ -345,8 +345,8 @@ void TextHookerUnloadTableFile(){
|
|||
|
||||
//clear the selections hash holder
|
||||
if ( hashholder != NULL ) {
|
||||
memset( hashholder, 0, sizeof( hashholder ) );
|
||||
free( hashholder );
|
||||
hashholder = NULL;
|
||||
}
|
||||
|
||||
//if there are words...
|
||||
|
@ -739,7 +739,7 @@ int TextHookerSaveTableFile(){
|
|||
|
||||
//write the selection hashes to the file
|
||||
for ( i = 0; i < numselections; i++ ) {
|
||||
memset( str, 0, 365 ); //init str
|
||||
memset( str, 0, sizeof( str ) ); //init str
|
||||
SendDlgItemMessage(hTextHooker,109,CB_GETLBTEXT,i,(LPARAM)(LPTSTR)str); //get the selection name
|
||||
fputs( str, FP ); //write the name
|
||||
fputs( "=", FP ); //write the =
|
||||
|
@ -797,8 +797,8 @@ BOOL CALLBACK TextHookerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
|||
int si;
|
||||
int saveFileErrorCheck = 0; //used to display error message that may have arised from saving a file
|
||||
|
||||
memset( str, 0, sizeof( char ) * 2048 );
|
||||
memset( bufferstr, 0, sizeof( char ) * 10240 );
|
||||
memset( str, 0, sizeof( str ) );
|
||||
memset( bufferstr, 0, sizeof( bufferstr ));
|
||||
|
||||
switch(uMsg) {
|
||||
case WM_INITDIALOG:
|
||||
|
@ -854,7 +854,7 @@ BOOL CALLBACK TextHookerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
|||
else
|
||||
sprintf( str, "Table is not Loaded!\r\nError on line: %d", result );
|
||||
//store the current text into the buffer
|
||||
GetDlgItemText(hwndDlg,102,bufferstr,10240);
|
||||
GetDlgItemText(hwndDlg,102,bufferstr,sizeof( bufferstr ));
|
||||
strcat( bufferstr, "\r\n" ); //add a newline
|
||||
strcat( bufferstr, str ); //add the status message to the buffer
|
||||
SetDlgItemText(hwndDlg,102,bufferstr); //display the buffer
|
||||
|
@ -995,7 +995,7 @@ BOOL CALLBACK TextHookerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
|||
}
|
||||
|
||||
//store the current text into the buffer
|
||||
GetDlgItemText(hwndDlg,102,bufferstr,10240);
|
||||
GetDlgItemText(hwndDlg,102,bufferstr,sizeof( bufferstr ));
|
||||
strcat( bufferstr, "\r\n" ); //add a newline
|
||||
strcat( bufferstr, str ); //add the status message to the buffer
|
||||
SetDlgItemText(hwndDlg,102,bufferstr); //display the buffer
|
||||
|
@ -1103,7 +1103,7 @@ BOOL CALLBACK TextHookerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
|||
current = words->next; //get the first word
|
||||
while ( current != NULL ) { //while there's still words to check
|
||||
found = strstr( str, current->ja ); //search the buffer for the word
|
||||
memset( bufferstrtemp, 0, sizeof( str ) ); //init the temp buffer
|
||||
memset( bufferstrtemp, 0, sizeof( bufferstrtemp ) ); //init the temp buffer
|
||||
if ( found ) { //if we found it, replace it
|
||||
//add a null byte after the first half
|
||||
strcpy( (char*)found, "\0" );
|
||||
|
@ -1130,7 +1130,7 @@ BOOL CALLBACK TextHookerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
|||
|
||||
|
||||
//store the current text into the buffer
|
||||
GetDlgItemText(hwndDlg,102,bufferstr,10240);
|
||||
GetDlgItemText(hwndDlg,102,bufferstr,sizeof( bufferstr ));
|
||||
strcat( bufferstr, "\r\n" ); //add a newline
|
||||
strcat( bufferstr, str ); //add the hooked text to the buffer
|
||||
SetDlgItemText(hwndDlg,102,bufferstr); //display the buffer
|
||||
|
@ -1175,7 +1175,7 @@ BOOL CALLBACK TextHookerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
|||
if ( !found ) {
|
||||
found = strstr( str, "\r\n" ); //and also for newlines
|
||||
}
|
||||
memset( bufferstrtemp, 0, sizeof( str ) ); //init the temp buffer
|
||||
memset( bufferstrtemp, 0, sizeof( bufferstrtemp ) ); //init the temp buffer
|
||||
if ( found ) { //found something to replace!
|
||||
//add a null byte after the first half
|
||||
strcpy( (char*)found, "\0" );
|
||||
|
|
|
@ -462,7 +462,7 @@ void UpdateContextMenuItems(HMENU context, int whichContext)
|
|||
string undoSavestate = "Undo savestate";
|
||||
string redoSavestate = "Redo savestate";
|
||||
|
||||
CheckMenuItem(context,ID_CONTEXT_FULLSAVESTATES,MF_BYCOMMAND | fullSaveStateLoads?MF_CHECKED:MF_UNCHECKED);
|
||||
CheckMenuItem(context,ID_CONTEXT_FULLSAVESTATES,MF_BYCOMMAND | (fullSaveStateLoads ? MF_CHECKED : MF_UNCHECKED));
|
||||
|
||||
//Undo Loadstate
|
||||
if (CheckBackupSaveStateExist() && (undoLS || redoLS))
|
||||
|
@ -1005,8 +1005,8 @@ void CloseGame()
|
|||
{
|
||||
FCEUI_CloseGame();
|
||||
KillMemView();
|
||||
updateGameDependentMenus(GameInfo != 0);
|
||||
updateGameDependentMenusDebugger(GameInfo != 0);
|
||||
updateGameDependentMenus(1);
|
||||
updateGameDependentMenusDebugger(1);
|
||||
SetMainWindowText();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ FCEUGI::FCEUGI()
|
|||
: filename(0)
|
||||
, archiveFilename(0)
|
||||
{
|
||||
printf("%08x",opsize);
|
||||
//printf("%08x",opsize); // WTF?!
|
||||
}
|
||||
|
||||
FCEUGI::~FCEUGI()
|
||||
|
@ -177,7 +177,7 @@ static void FCEU_CloseGame(void)
|
|||
CloseGenie();
|
||||
|
||||
delete GameInfo;
|
||||
GameInfo = 0;
|
||||
GameInfo = NULL;
|
||||
|
||||
currFrameCounter = 0;
|
||||
|
||||
|
@ -196,7 +196,7 @@ static void FCEU_CloseGame(void)
|
|||
uint64 timestampbase;
|
||||
|
||||
|
||||
FCEUGI *GameInfo = 0;
|
||||
FCEUGI *GameInfo = NULL;
|
||||
|
||||
void (*GameInterface)(GI h);
|
||||
void (*GameStateRestore)(int version);
|
||||
|
|
|
@ -81,7 +81,7 @@ static uint8 *diskdata[8]={0,0,0,0,0,0,0,0};
|
|||
static int TotalSides; //mbg merge 7/17/06 - unsignedectomy
|
||||
static uint8 DiskWritten=0; /* Set to 1 if disk was written to. */
|
||||
static uint8 writeskip;
|
||||
static uint32 DiskPtr;
|
||||
static int32 DiskPtr;
|
||||
static int32 DiskSeekIRQ;
|
||||
static uint8 SelectDisk,InDisk;
|
||||
|
||||
|
|
|
@ -881,12 +881,10 @@ int iNesSaveAs(char* name)
|
|||
FILE *fp;
|
||||
|
||||
if(GameInfo->type != GIT_CART)return 0;
|
||||
if(GameInterface!=iNESGI)return 0;
|
||||
if(GameInterface != iNESGI)return 0;
|
||||
|
||||
fp = fopen(name,"wb");
|
||||
int x = 0;
|
||||
if (!fp)
|
||||
int x = 1;
|
||||
|
||||
if(fwrite(&head,1,16,fp)!=16)
|
||||
{
|
||||
fclose(fp);
|
||||
|
|
|
@ -62,24 +62,20 @@ int str_ltrim(char *str, int flags) {
|
|||
unsigned int i=0; //mbg merge 7/17/06 changed to unsigned int
|
||||
|
||||
while (str[0]) {
|
||||
if ((str[0] != ' ') || (str[0] != '\t') || (str[0] != '\r') || (str[0] != '\n')) break;
|
||||
|
||||
if ((flags & STRIP_SP) && (str[0] == ' ')) {
|
||||
i++;
|
||||
strcpy(str,str+1);
|
||||
}
|
||||
if ((flags & STRIP_TAB) && (str[0] == '\t')) {
|
||||
} else if ((flags & STRIP_TAB) && (str[0] == '\t')) {
|
||||
i++;
|
||||
strcpy(str,str+1);
|
||||
}
|
||||
if ((flags & STRIP_CR) && (str[0] == '\r')) {
|
||||
} else if ((flags & STRIP_CR) && (str[0] == '\r')) {
|
||||
i++;
|
||||
strcpy(str,str+1);
|
||||
}
|
||||
if ((flags & STRIP_LF) && (str[0] == '\n')) {
|
||||
} else if ((flags & STRIP_LF) && (str[0] == '\n')) {
|
||||
i++;
|
||||
strcpy(str,str+1);
|
||||
}
|
||||
} else
|
||||
break;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
@ -90,30 +86,23 @@ int str_ltrim(char *str, int flags) {
|
|||
///Removes whitespace from right side of string, depending on the flags set (See STRIP_x definitions in xstring.h)
|
||||
///Returns number of characters removed
|
||||
int str_rtrim(char *str, int flags) {
|
||||
unsigned int i=0; //mbg merge 7/17/06 changed to unsigned int
|
||||
|
||||
while (strlen(str)) {
|
||||
if ((str[strlen(str)-1] != ' ') ||
|
||||
(str[strlen(str)-1] != '\t') ||
|
||||
(str[strlen(str)-1] != '\r') ||
|
||||
(str[strlen(str)-1] != '\n')) break;
|
||||
unsigned int i=0, strl; //mbg merge 7/17/06 changed to unsigned int
|
||||
|
||||
while (strl = strlen(str)) {
|
||||
if ((flags & STRIP_SP) && (str[0] == ' ')) {
|
||||
i++;
|
||||
str[strlen(str)-1] = 0;
|
||||
}
|
||||
if ((flags & STRIP_TAB) && (str[0] == '\t')) {
|
||||
str[str] = 0;
|
||||
} else if ((flags & STRIP_TAB) && (str[0] == '\t')) {
|
||||
i++;
|
||||
str[strlen(str)-1] = 0;
|
||||
}
|
||||
if ((flags & STRIP_CR) && (str[0] == '\r')) {
|
||||
str[strl] = 0;
|
||||
} else if ((flags & STRIP_CR) && (str[0] == '\r')) {
|
||||
i++;
|
||||
str[strlen(str)-1] = 0;
|
||||
}
|
||||
if ((flags & STRIP_LF) && (str[0] == '\n')) {
|
||||
str[strl] = 0;
|
||||
} else if ((flags & STRIP_LF) && (str[0] == '\n')) {
|
||||
i++;
|
||||
str[strlen(str)-1] = 0;
|
||||
}
|
||||
str[strl] = 0;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
@ -441,7 +430,7 @@ void splitpath(const char* path, char* drv, char* dir, char* name, char* ext)
|
|||
*name = '\0';
|
||||
} else
|
||||
for(s=p; s<end; )
|
||||
*s++;
|
||||
s++;
|
||||
|
||||
if (dir) {
|
||||
for(s=path; s<p; )
|
||||
|
|
Loading…
Reference in New Issue