diff --git a/desmume/src/NDSSystem.h b/desmume/src/NDSSystem.h index f2af566d4..320ab455f 100644 --- a/desmume/src/NDSSystem.h +++ b/desmume/src/NDSSystem.h @@ -329,42 +329,26 @@ struct RomBanner struct GameInfo { - void *fROM; + void *fROM = nullptr; ROMReader_struct *reader; - u8 *romdataForReader; - u32 romsize; - u32 cardSize; - u32 mask; - u32 crc; + u8 *romdataForReader = nullptr; + u32 romsize = 0; + u32 cardSize = 0; + u32 mask = 0; + u32 crc = 0; u32 crcForCheatsDb; - u32 chipID; - u32 romType; - u32 headerOffset; - char ROMserial[20]; - char ROMname[13]; - bool _isDSiEnhanced; - NDS_header header; + u32 chipID = 0x00000FC2; + u32 romType = ROM_NDS; + u32 headerOffset = 0; + char ROMserial[20] = {}; + char ROMname[13] = {}; + bool _isDSiEnhanced = false; + NDS_header header = {}; //a copy of the pristine secure area from the rom u8 secureArea[0x4000]; RomBanner banner; const RomBanner& getRomBanner(); - GameInfo() : fROM(NULL), - romdataForReader(NULL), - crc(0), - chipID(0x00000FC2), - romsize(0), - cardSize(0), - mask(0), - romType(ROM_NDS), - headerOffset(0), - _isDSiEnhanced(false) - { - memset(&header, 0, sizeof(header)); - memset(&ROMserial[0], 0, sizeof(ROMserial)); - memset(&ROMname[0], 0, sizeof(ROMname)); - } - ~GameInfo() { closeROM(); } bool IsCode(const char* code) const; @@ -497,48 +481,7 @@ extern int lagframecounter; extern struct TCommonSettings { - TCommonSettings() - : GFX3D_HighResolutionInterpolateColor(true) - , GFX3D_EdgeMark(true) - , GFX3D_Fog(true) - , GFX3D_Texture(true) - , GFX3D_LineHack(true) - , GFX3D_Renderer_MultisampleSize(0) - , GFX3D_Renderer_TextureScalingFactor(1) // Possible values: 1, 2, 4 - , GFX3D_Renderer_TextureDeposterize(false) - , GFX3D_Renderer_TextureSmoothing(false) - , GFX3D_TXTHack(false) - , OpenGL_Emulation_ShadowPolygon(true) - , OpenGL_Emulation_SpecialZeroAlphaBlending(true) - , OpenGL_Emulation_NDSDepthCalculation(true) - , OpenGL_Emulation_DepthLEqualPolygonFacing(false) - , jit_max_block_size(12) - , loadToMemory(false) - , UseExtBIOS(false) - , SWIFromBIOS(false) - , PatchSWI3(false) - , UseExtFirmware(false) - , UseExtFirmwareSettings(false) - , RetailCardProtection8000(true) - , BootFromFirmware(false) - , DebugConsole(false) - , EnsataEmulation(false) - , cheatsDisable(false) - , rigorous_timing(false) - , advanced_timing(true) - , micMode(InternalNoise) - , spuInterpolationMode(2) - , manualBackupType(0) - , autodetectBackupMethod(0) - , spu_captureMuted(false) - , spu_advanced(true) - , StylusPressure(50) - , ConsoleType(NDS_CONSOLE_TYPE_FAT) - , backupSave(false) - , SPU_sync_mode(1) - , SPU_sync_method(0) - , WifiBridgeDeviceID(0) - { + TCommonSettings() { strcpy(ARM9BIOS, "biosnds9.bin"); strcpy(ARM7BIOS, "biosnds7.bin"); strcpy(ExtFirmwarePath, "firmware.bin"); @@ -560,55 +503,53 @@ extern struct TCommonSettings num_cores = NDS_GetCPUCoreCount(); NDS_SetupDefaultFirmware(); } - bool GFX3D_HighResolutionInterpolateColor; - bool GFX3D_EdgeMark; - bool GFX3D_Fog; - bool GFX3D_Texture; - bool GFX3D_LineHack; - int GFX3D_Renderer_MultisampleSize; - int GFX3D_Renderer_TextureScalingFactor; //must be one of {1,2,4} - bool GFX3D_Renderer_TextureDeposterize; - bool GFX3D_Renderer_TextureSmoothing; - bool GFX3D_TXTHack; + bool GFX3D_HighResolutionInterpolateColor = true; + bool GFX3D_EdgeMark = true; + bool GFX3D_Fog = true; + bool GFX3D_Texture = true; + bool GFX3D_LineHack = true; + int GFX3D_Renderer_MultisampleSize = 0; + int GFX3D_Renderer_TextureScalingFactor = 1; //must be one of {1,2,4} + bool GFX3D_Renderer_TextureDeposterize = false; + bool GFX3D_Renderer_TextureSmoothing = false; + bool GFX3D_TXTHack = false; - bool OpenGL_Emulation_ShadowPolygon; - bool OpenGL_Emulation_SpecialZeroAlphaBlending; - bool OpenGL_Emulation_NDSDepthCalculation; - bool OpenGL_Emulation_DepthLEqualPolygonFacing; + bool OpenGL_Emulation_ShadowPolygon = true; + bool OpenGL_Emulation_SpecialZeroAlphaBlending = true; + bool OpenGL_Emulation_NDSDepthCalculation = true; + bool OpenGL_Emulation_DepthLEqualPolygonFacing = false; - bool loadToMemory; + bool loadToMemory = false; - bool UseExtBIOS; + bool UseExtBIOS = false; char ARM9BIOS[MAX_PATH]; char ARM7BIOS[MAX_PATH]; - bool SWIFromBIOS; - bool PatchSWI3; + bool SWIFromBIOS = false; + bool PatchSWI3 = false; - bool RetailCardProtection8000; - bool UseExtFirmware; - bool UseExtFirmwareSettings; + bool RetailCardProtection8000 = true; + bool UseExtFirmware = false; + bool UseExtFirmwareSettings = false; char ExtFirmwarePath[MAX_PATH]; char ExtFirmwareUserSettingsPath[MAX_PATH]; - bool BootFromFirmware; + bool BootFromFirmware = false; FirmwareConfig fwConfig; - NDS_CONSOLE_TYPE ConsoleType; - bool DebugConsole; - bool EnsataEmulation; + NDS_CONSOLE_TYPE ConsoleType = NDS_CONSOLE_TYPE_FAT; + bool DebugConsole = false; + bool EnsataEmulation = false; - bool cheatsDisable; + bool cheatsDisable = false; int num_cores; bool single_core() { return num_cores==1; } - bool rigorous_timing; + bool rigorous_timing = false; struct GameHacks { - GameHacks() - : en(true) - { + GameHacks() { clear(); } - bool en; + bool en = true; struct { bool overclock; @@ -619,16 +560,16 @@ extern struct TCommonSettings void clear(); } gamehacks; - int StylusPressure; + int StylusPressure = 50; bool dispLayers[2][5]; - FAST_ALIGN bool advanced_timing; + FAST_ALIGN bool advanced_timing = true; bool use_jit; - u32 jit_max_block_size; + u32 jit_max_block_size = 12; - int WifiBridgeDeviceID; + int WifiBridgeDeviceID = 0; enum MicMode { @@ -636,45 +577,44 @@ extern struct TCommonSettings Sample = 1, Random = 2, Physical = 3 - } micMode; + } micMode = InternalNoise; - int spuInterpolationMode; + int spuInterpolationMode = 2; //this is a temporary hack until we straighten out the flushing logic and/or gxfifo //int gfx3d_flushMode; - int autodetectBackupMethod; + int autodetectBackupMethod = 0; //this is the user's choice of manual backup type, for cases when the autodetection can't be trusted - int manualBackupType; - bool backupSave; + int manualBackupType = 0; + bool backupSave = false; - int SPU_sync_mode; - int SPU_sync_method; + int SPU_sync_mode = 1; + int SPU_sync_method = 0; bool spu_muteChannels[16]; - bool spu_captureMuted; - bool spu_advanced; + bool spu_captureMuted = false; + bool spu_advanced = true; struct _ShowGpu { - _ShowGpu() : main(true), sub(true) {} union { - struct { bool main,sub; }; + struct { + bool main = true; + bool sub = true; + }; bool screens[2]; }; } showGpu; struct _Hud { - _Hud() - : ShowInputDisplay(false) - , ShowGraphicalInputDisplay(false) - , FpsDisplay(false) - , FrameCounterDisplay(false) - , ShowLagFrameCounter(false) - , ShowMicrophone(false) - , ShowRTC(false) - {} - bool ShowInputDisplay, ShowGraphicalInputDisplay, FpsDisplay, FrameCounterDisplay, ShowLagFrameCounter, ShowMicrophone, ShowRTC; + bool ShowInputDisplay = false; + bool ShowGraphicalInputDisplay = false; + bool FpsDisplay = false; + bool FrameCounterDisplay = false; + bool ShowLagFrameCounter = false; + bool ShowMicrophone = false; + bool ShowRTC = false; } hud; std::string run_advanscene_import; diff --git a/desmume/src/commandline.cpp b/desmume/src/commandline.cpp index d1a25987e..d26e5527d 100644 --- a/desmume/src/commandline.cpp +++ b/desmume/src/commandline.cpp @@ -36,62 +36,6 @@ int _scanline_filter_a = 0, _scanline_filter_b = 2, _scanline_filter_c = 2, _scanline_filter_d = 4; int _commandline_linux_nojoy = 0; -CommandLine::CommandLine() -: is_cflash_configured(false) -, _load_to_memory(-1) -, _play_movie_file(0) -, _record_movie_file(0) -, _cflash_image(0) -, _cflash_path(0) -, _gbaslot_rom(0) -, _bios_arm9(NULL) -, _bios_arm7(NULL) -, _bios_swi(0) -, _fw_path(NULL) -, _fw_boot(0) -, _spu_sync_mode(-1) -, _spu_sync_method(-1) -, _spu_advanced(0) -, _num_cores(-1) -, _rigorous_timing(0) -, _advanced_timing(-1) -, _gamehacks(-1) -, _texture_deposterize(-1) -, _texture_smooth(-1) -, _slot1(NULL) -, _slot1_fat_dir(NULL) -, _slot1_fat_dir_type(false) -, _slot1_no8000prot(0) -#ifdef HAVE_JIT -, _cpu_mode(-1) -, _jit_size(-1) -#endif -, _console_type(NULL) -, _advanscene_import(NULL) -, load_slot(-1) -, arm9_gdb_port(0) -, arm7_gdb_port(0) -, start_paused(FALSE) -, autodetect_method(-1) -, render3d(COMMANDLINE_RENDER3D_DEFAULT) -, texture_upscale(-1) -, gpu_resolution_multiplier(-1) -, language(1) //english by default -, disable_sound(0) -, disable_limiter(0) -, windowed_fullscreen(0) -, frameskip(0) -, horizontal(0) -, scale(1.0) -, _rtc_day(-1) -, _rtc_hour(-1) -{ -} - -CommandLine::~CommandLine() -{ -} - static char mytoupper(char c) { return ::toupper(c); } static std::string strtoupper(const std::string& str) diff --git a/desmume/src/commandline.h b/desmume/src/commandline.h index 47a28aca6..07c371182 100644 --- a/desmume/src/commandline.h +++ b/desmume/src/commandline.h @@ -43,31 +43,32 @@ class CommandLine { public: //actual options: these may move to another struct - int load_slot; - int autodetect_method; - int render3d; - int texture_upscale; - int gpu_resolution_multiplier; - int language; - float scale; + int load_slot = -1; + int autodetect_method = -1; + int render3d = COMMANDLINE_RENDER3D_DEFAULT; + int texture_upscale = -1; + int gpu_resolution_multiplier = -1; + int language = 1; // English by default + float scale = 1.0; std::string nds_file; std::string play_movie_file; std::string record_movie_file; - int arm9_gdb_port, arm7_gdb_port; - int start_paused; + int arm9_gdb_port = 0; + int arm7_gdb_port = 0; + int start_paused = FALSE; std::string cflash_image; std::string cflash_path; std::string gbaslot_rom; std::string slot1; std::string console_type; std::string slot1_fat_dir; - bool _slot1_fat_dir_type; - int _slot1_no8000prot; - int disable_sound; - int disable_limiter; - int windowed_fullscreen; - int frameskip; - int horizontal; + bool _slot1_fat_dir_type = false; + int _slot1_no8000prot = 0; + int disable_sound = 0; + int disable_limiter = 0; + int windowed_fullscreen = 0; + int frameskip = 0; + int horizontal = 0; bool parse(int argc,char **argv); @@ -78,44 +79,42 @@ public: void process_movieCommands(); //etc. void process_addonCommands(); - bool is_cflash_configured; + bool is_cflash_configured = false; //print a little help message for cases when erroneous commandlines are entered void errorHelp(const char* binName); - CommandLine(); - ~CommandLine(); - - int _spu_sync_mode; - int _spu_sync_method; + int _spu_sync_mode = -1; + int _spu_sync_method = -1; private: - char* _play_movie_file; - char* _record_movie_file; - char* _cflash_image; - char* _cflash_path; - char* _gbaslot_rom; - char* _bios_arm9, *_bios_arm7; - char* _fw_path; - int _fw_boot; - int _load_to_memory; - int _bios_swi; - int _spu_advanced; - int _num_cores; - int _rigorous_timing; - int _advanced_timing; - int _gamehacks; - int _texture_deposterize; - int _texture_smooth; + char* _play_movie_file = 0; + char* _record_movie_file = 0; + char* _cflash_image = 0; + char* _cflash_path = 0; + char* _gbaslot_rom = 0; + char* _bios_arm9 = nullptr; + char* _bios_arm7 = nullptr; + char* _fw_path = nullptr; + int _fw_boot = 0; + int _load_to_memory = -1; + int _bios_swi = 0; + int _spu_advanced = 0; + int _num_cores = -1; + int _rigorous_timing = 0; + int _advanced_timing = -1; + int _gamehacks = -1; + int _texture_deposterize = -1; + int _texture_smooth = -1; #ifdef HAVE_JIT - int _cpu_mode; - int _jit_size; + int _cpu_mode = -1; + int _jit_size = -1; #endif - char* _slot1; - char *_slot1_fat_dir; - char* _console_type; - char* _advanscene_import; - int _rtc_day; - int _rtc_hour; + char* _slot1 = nullptr; + char* _slot1_fat_dir = nullptr; + char* _console_type = nullptr; + char* _advanscene_import = nullptr; + int _rtc_day = -1; + int _rtc_hour = -1; }; #endif diff --git a/desmume/src/firmware.h b/desmume/src/firmware.h index 232a0dc14..75fb5fc36 100644 --- a/desmume/src/firmware.h +++ b/desmume/src/firmware.h @@ -425,16 +425,14 @@ class CFIRMWARE private: FWHeader _header; std::string _fwFilePath; - bool _isLoaded; - u32 _userDataAddr; + bool _isLoaded = false; + u32 _userDataAddr = 0x3FE00; u16 _getBootCodeCRC16(const u8 *arm9Data, const u32 arm9Size, const u8 *arm7Data, const u32 arm7Size); u32 _decrypt(const u8 *in, u8* &out); u32 _decompress(const u8 *in, u8* &out); public: - CFIRMWARE(): _userDataAddr(0x3FE00), _isLoaded(false) {}; - bool load(const char *firmwareFilePath); bool unpack(); bool loadSettings(const char *firmwareUserSettingsFilePath); diff --git a/desmume/src/utils/advanscene.h b/desmume/src/utils/advanscene.h index 4abeaefb6..6cfb3e458 100644 --- a/desmume/src/utils/advanscene.h +++ b/desmume/src/utils/advanscene.h @@ -25,13 +25,13 @@ class ADVANsCEne private: std::string database_path; time_t createTime; - u32 crc32; - char serial[6]; - char version[4]; - u8 versionBase[2]; - u8 saveType; + u32 crc32 = 0; + char serial[6] = {}; + char version[4] = {}; + u8 versionBase[2] = {}; + u8 saveType = 0xFF; - bool loaded; + bool loaded = false; bool foundAsCrc, foundAsSerial; // XML @@ -42,15 +42,6 @@ private: bool getXMLConfig(const char *in_filename); public: - ADVANsCEne() - : saveType(0xFF), - crc32(0), - loaded(false) - { - memset(versionBase, 0, sizeof(versionBase)); - memset(version, 0, sizeof(version)); - memset(serial, 0, sizeof(serial)); - } void setDatabase(const char *path); std::string getDatabase() const { return database_path; } u32 convertDB(const char *in_filename, EMUFILE &output);