diff --git a/desmume/src/NDSSystem.cpp b/desmume/src/NDSSystem.cpp index bbc998d0b..898208e30 100644 --- a/desmume/src/NDSSystem.cpp +++ b/desmume/src/NDSSystem.cpp @@ -379,9 +379,7 @@ void GameInfo::populate() }; - memset(ROMserial, 0, sizeof(ROMserial)); - memset(ROMname, 0, sizeof(ROMname)); - + //set or build as appropriate ROMserial if(isHomebrew()) { //we can't really make a serial for a homebrew game that hasnt set a game code @@ -405,9 +403,8 @@ void GameInfo::populate() } //rom name is probably set even in homebrew, so do it regardless - memset(ROMname, 0, sizeof(ROMname)); memcpy(ROMname, header.gameTile, 12); - trim(ROMname,20); + ROMname[12] = 0; /*if(header.IconOff < romsize) { diff --git a/desmume/src/NDSSystem.h b/desmume/src/NDSSystem.h index 657449eb9..3baa29b39 100644 --- a/desmume/src/NDSSystem.h +++ b/desmume/src/NDSSystem.h @@ -325,7 +325,7 @@ struct GameInfo u32 romType; u32 headerOffset; char ROMserial[20]; - char ROMname[20]; + char ROMname[13]; bool _isDSiEnhanced; NDS_header header; //a copy of the pristine secure area from the rom diff --git a/desmume/src/cheatSystem.cpp b/desmume/src/cheatSystem.cpp index e62ef9b62..266488de1 100644 --- a/desmume/src/cheatSystem.cpp +++ b/desmume/src/cheatSystem.cpp @@ -561,6 +561,22 @@ void CHEATS::setDescription(const char *description, u32 pos) list[pos].description[sizeof(list[pos].description) - 1] = '\0'; } + +static char *trim(char *s, int len = -1) +{ + char *ptr = NULL; + if (!s) return NULL; + if (!*s) return s; + + if(len==-1) + ptr = s + strlen(s) - 1; + else ptr = s+len - 1; + for (; (ptr >= s) && (!*ptr || isspace((u8)*ptr)) ; ptr--); + ptr[1] = '\0'; + return s; +} + + BOOL CHEATS::save() { const char *types[] = {"DS", "AR", "CB"}; @@ -722,7 +738,7 @@ BOOL CHEATS::load() char tmp_buf[9] = {0}; strncpy(tmp_buf, &codeStr[i * 16], 8); - sscanf_s(tmp_buf, "%x", &tmp_cht.code[i][0]); + sscanf(tmp_buf, "%x", &tmp_cht.code[i][0]); if (tmp_cht.type == 0) { @@ -731,7 +747,7 @@ BOOL CHEATS::load() } strncpy(tmp_buf, &codeStr[(i * 16) + 8], 8); - sscanf_s(tmp_buf, "%x", &tmp_cht.code[i][1]); + sscanf(tmp_buf, "%x", &tmp_cht.code[i][1]); } list.push_back(tmp_cht); diff --git a/desmume/src/common.cpp b/desmume/src/common.cpp index a47728d27..985425bdd 100644 --- a/desmume/src/common.cpp +++ b/desmume/src/common.cpp @@ -32,38 +32,6 @@ static std::map _alignedPtrList; // Key: Aligned pointer / Value: Original pointer -char *trim(char *s, int len) -{ - char *ptr = NULL; - if (!s) return NULL; - if (!*s) return s; - - if(len==-1) - ptr = s + strlen(s) - 1; - else ptr = s+len - 1; - for (; (ptr >= s) && (!*ptr || isspace((u8)*ptr)) ; ptr--); - ptr[1] = '\0'; - return s; -} - -char *removeSpecialChars(char *s) -{ - char *buf = s; - if (!s) return NULL; - if (!*s) return s; - - for (u32 i = 0; i < strlen(s); i++) - { - if (isspace((u8)s[i]) && (s[i] != 0x20)) - *buf = 0x20; - else - *buf = s[i]; - buf++; - } - *buf = 0; - return s; -} - static MAKER makerCodes[] = { { 0x3130, "Nintendo" }, { 0x3230, "Rocket Games, Ajinomoto" }, diff --git a/desmume/src/common.h b/desmume/src/common.h index 4542f1e7a..ea23baed3 100644 --- a/desmume/src/common.h +++ b/desmume/src/common.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2008-2015 DeSmuME team + Copyright (C) 2008-2016 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,30 +25,6 @@ #include #include "types.h" -#if defined(WIN32) - #define CLASSNAME "DeSmuME" -#else // non Windows - #define sscanf_s sscanf -#endif - -template -T reverseBits(T x) -{ - T h = 0; - T i = 0; - - for (i = 0; i < sizeof(T)*8; i++) - { - h = (h << 1) + (x & 1); - x >>= 1; - } - - return h; -} - -extern char *trim(char *s, int len=-1); -extern char *removeSpecialChars(char *s); - // =============================================================================== // Message dialogs // =============================================================================== diff --git a/desmume/src/utils/advanscene.cpp b/desmume/src/utils/advanscene.cpp index 8d8f37005..50a63da0f 100644 --- a/desmume/src/utils/advanscene.cpp +++ b/desmume/src/utils/advanscene.cpp @@ -202,7 +202,7 @@ u32 ADVANsCEne::convertDB(const char *in_filename, EMUFILE* output) // CRC32 el_crc32 = el->FirstChildElement("files"); - sscanf_s(el_crc32->FirstChildElement("romCRC")->GetText(), "%x", &crc32); + sscanf(el_crc32->FirstChildElement("romCRC")->GetText(), "%x", &crc32); output->fwrite(&crc32, sizeof(u32)); // Save type