From de13cf692798ea88e6625deda86093f718026bf0 Mon Sep 17 00:00:00 2001 From: dborth Date: Sat, 28 Mar 2009 19:03:35 +0000 Subject: [PATCH] update comments --- source/ngc/audio.cpp | 11 +++ source/ngc/button_mapping.c | 1 + source/ngc/button_mapping.h | 1 + source/ngc/dvd.cpp | 8 +- source/ngc/dvd.h | 3 +- source/ngc/filebrowser.cpp | 23 +++-- source/ngc/filebrowser.h | 6 +- source/ngc/gui/gui_text.cpp | 2 - source/ngc/input.cpp | 166 ++++++++++++++++++------------------ source/ngc/memcardop.h | 4 +- source/ngc/menu.cpp | 12 ++- source/ngc/menu.h | 1 - source/ngc/networkop.cpp | 45 ++++++++-- source/ngc/preferences.cpp | 23 ++++- source/ngc/s9xconfig.cpp | 17 ++-- source/ngc/s9xconfig.h | 3 +- source/ngc/snes9xGX.cpp | 8 +- source/ngc/snes9xGX.h | 6 +- source/ngc/video.cpp | 34 ++++++-- source/ngc/video.h | 1 - 20 files changed, 228 insertions(+), 147 deletions(-) diff --git a/source/ngc/audio.cpp b/source/ngc/audio.cpp index 74edfa9..a70c543 100644 --- a/source/ngc/audio.cpp +++ b/source/ngc/audio.cpp @@ -94,6 +94,11 @@ InitAudio () LWP_CreateThread (&athread, AudioThread, NULL, astack, AUDIOSTACK, 150); } +/**************************************************************************** + * SwitchAudioMode + * + * Switches between menu sound and emulator sound + ***************************************************************************/ void SwitchAudioMode(int mode) { @@ -117,6 +122,12 @@ SwitchAudioMode(int mode) } } +/**************************************************************************** + * ShutdownAudio + * + * Shuts down audio subsystem. Useful to avoid unpleasant sounds if a + * crash occurs during shutdown. + ***************************************************************************/ void ShutdownAudio() { #ifndef NO_SOUND diff --git a/source/ngc/button_mapping.c b/source/ngc/button_mapping.c index b44bdb1..da7b191 100644 --- a/source/ngc/button_mapping.c +++ b/source/ngc/button_mapping.c @@ -2,6 +2,7 @@ * Snes9x 1.51 Nintendo Wii/Gamecube Port * * michniewski August 2008 + * Tantric 2008-2009 * * button_mapping.c * diff --git a/source/ngc/button_mapping.h b/source/ngc/button_mapping.h index 1f0621f..16e117b 100644 --- a/source/ngc/button_mapping.h +++ b/source/ngc/button_mapping.h @@ -2,6 +2,7 @@ * Snes9x 1.51 Nintendo Wii/Gamecube Port * * michniewski August 2008 + * Tantric 2008-2009 * * button_mapping.h * diff --git a/source/ngc/dvd.cpp b/source/ngc/dvd.cpp index d29f69c..fe877e3 100644 --- a/source/ngc/dvd.cpp +++ b/source/ngc/dvd.cpp @@ -3,7 +3,7 @@ * * softdev July 2006 * svpe & crunchy2 June 2007 - * Tantric September 2008 + * Tantric 2008-2009 * * dvd.cpp * @@ -144,7 +144,6 @@ static int dvd_buffered_read(void *dst, u32 len, u64 offset) * This function relies on dvddir (file offset) being prepopulated! * returns: 1 - ok ; 0 - error ***************************************************************************/ - int dvd_safe_read(void *dst_v, u32 len, u64 fileoffset) { u64 offset = dvddir + fileoffset; @@ -321,7 +320,6 @@ getpvd () * * Tests if a ISO9660 DVD is inserted and available, and mounts it ***************************************************************************/ - bool MountDVD(bool silent) { bool res = false; @@ -364,7 +362,6 @@ bool MountDVD(bool silent) * Support function to return the next file entry, if any * Declared static to avoid accidental external entry. ***************************************************************************/ - static int getentry (int entrycount, unsigned char dvdbuffer[]) { @@ -548,7 +545,6 @@ ParseDVDdirectory () * SetDVDdirectory * Set the current DVD file offset ***************************************************************************/ - void SetDVDdirectory(u64 dir, int length) { dvddir = dir; @@ -647,7 +643,6 @@ bool SwitchDVDFolder(char origdir[]) * This function will load a file from DVD * It assumes dvddir and dvddirlength are prepopulated ***************************************************************************/ - int LoadDVDFileOffset (unsigned char *buffer, int length) { @@ -719,7 +714,6 @@ done: * It will attempt to find the offset of the file, and if successful it * will populate dvddir and dvddirlength, and load the file ***************************************************************************/ - int LoadDVDFile(char * buffer, char *filepath, int datasize, bool silent) { diff --git a/source/ngc/dvd.h b/source/ngc/dvd.h index d21dc36..ab4ff71 100644 --- a/source/ngc/dvd.h +++ b/source/ngc/dvd.h @@ -3,7 +3,7 @@ * * softdev July 2006 * svpe & crunchy2 June 2007 - * Tantric September 2008 + * Tantric 2008-2009 * * dvd.h * @@ -25,7 +25,6 @@ int dvd_safe_read (void *dst, unsigned int len, u64 offset); void SetDVDDriveType(); #ifdef HW_DOL void dvd_motor_off (); -void uselessinquiry (); #endif #endif diff --git a/source/ngc/filebrowser.cpp b/source/ngc/filebrowser.cpp index f350e36..40f324e 100644 --- a/source/ngc/filebrowser.cpp +++ b/source/ngc/filebrowser.cpp @@ -7,7 +7,7 @@ * Michniewski 2008 * Tantric 2008-2009 * - * filesel.cpp + * filebrowser.cpp * * Generic file routines - reading, writing, browsing ***************************************************************************/ @@ -306,7 +306,6 @@ int FileSortCallback(const void *f1, const void *f2) * If the file is a zip, we will check the file extension / file size of the * first file inside ***************************************************************************/ - static bool IsValidROM(int method) { // file size should be between 96K and 8MB @@ -357,7 +356,6 @@ static bool IsValidROM(int method) * * Checks if the specified file is a 7z ***************************************************************************/ - bool IsSz() { if (strlen(browserList[browser.selIndex].filename) > 4) @@ -376,7 +374,6 @@ bool IsSz() * * Strips an extension from a filename ***************************************************************************/ - void StripExt(char* returnstring, char * inputstring) { char* loc_dot; @@ -391,7 +388,11 @@ void StripExt(char* returnstring, char * inputstring) *loc_dot = 0; // strip file extension } -// 7z file - let's open it up to select a file inside +/**************************************************************************** + * BrowserLoadSz + * + * Opens the selected 7z file, and parses a listing of the files within + ***************************************************************************/ int BrowserLoadSz(int method) { char filepath[MAXPATHLEN]; @@ -417,6 +418,11 @@ int BrowserLoadSz(int method) return szfiles; } +/**************************************************************************** + * BrowserLoadFile + * + * Loads the selected ROM + ***************************************************************************/ int BrowserLoadFile(int method) { char filepath[1024]; @@ -483,7 +489,11 @@ done: return loaded; } -/* update current directory and set new entry list if directory has changed */ +/**************************************************************************** + * BrowserChangeFolder + * + * Update current directory and set new entry list if directory has changed + ***************************************************************************/ int BrowserChangeFolder(int method) { if(inSz && browser.selIndex == 0) // inside a 7z, requesting to leave @@ -521,7 +531,6 @@ int BrowserChangeFolder(int method) * OpenROM * Displays a list of ROMS on load device ***************************************************************************/ - int OpenGameList () { diff --git a/source/ngc/filebrowser.h b/source/ngc/filebrowser.h index 9d3d35c..15169cc 100644 --- a/source/ngc/filebrowser.h +++ b/source/ngc/filebrowser.h @@ -6,13 +6,13 @@ * Michniewski 2008 * Tantric 2008-2009 * - * filesel.h + * filebrowser.h * * Generic file routines - reading, writing, browsing ****************************************************************************/ -#ifndef _NGCFILESEL_ -#define _NGCFILESEL_ +#ifndef _FILEBROWSER_H_ +#define _FILEBROWSER_H_ #include #include diff --git a/source/ngc/gui/gui_text.cpp b/source/ngc/gui/gui_text.cpp index 88414c5..6caaf10 100644 --- a/source/ngc/gui/gui_text.cpp +++ b/source/ngc/gui/gui_text.cpp @@ -9,8 +9,6 @@ ***************************************************************************/ #include "gui.h" -#include "snes9xGX.h" -#include "filelist.h" static int currentSize = 0; static int presetSize = 0; diff --git a/source/ngc/input.cpp b/source/ngc/input.cpp index 0ee3297..b099e05 100644 --- a/source/ngc/input.cpp +++ b/source/ngc/input.cpp @@ -602,7 +602,7 @@ void NGCReportButtons () } } -void SetControllers () +void SetControllers() { if (Settings.MultiPlayer5Master == true) { @@ -637,104 +637,102 @@ void SetControllers () ***************************************************************************/ void SetDefaultButtonMap () { - int maxcode = 0x10; - s9xcommand_t cmd; + int maxcode = 0x10; + s9xcommand_t cmd; /*** Joypad 1 ***/ - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 A"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 B"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 X"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 Y"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 L"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 R"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 Start"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 Select"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 Up"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 Down"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 Left"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 Right"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 A"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 B"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 X"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 Y"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 L"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 R"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 Start"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 Select"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 Up"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 Down"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 Left"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 Right"); - maxcode = 0x20; + maxcode = 0x20; /*** Joypad 2 ***/ - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 A"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 B"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 X"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 Y"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 L"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 R"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 Start"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 Select"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 Up"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 Down"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 Left"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 Right"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 A"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 B"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 X"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 Y"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 L"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 R"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 Start"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 Select"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 Up"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 Down"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 Left"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 Right"); - maxcode = 0x30; + maxcode = 0x30; /*** Joypad 3 ***/ - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 A"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 B"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 X"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 Y"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 L"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 R"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 Start"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 Select"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 Up"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 Down"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 Left"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 Right"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 A"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 B"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 X"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 Y"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 L"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 R"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 Start"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 Select"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 Up"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 Down"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 Left"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 Right"); - maxcode = 0x40; + maxcode = 0x40; /*** Joypad 4 ***/ - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 A"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 B"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 X"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 Y"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 L"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 R"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 Start"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 Select"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 Up"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 Down"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 Left"); - ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 Right"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 A"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 B"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 X"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 Y"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 L"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 R"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 Start"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 Select"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 Up"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 Down"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 Left"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 Right"); - maxcode = 0x50; + maxcode = 0x50; /*** Superscope ***/ - ASSIGN_BUTTON_FALSE (maxcode++, "Superscope Fire"); - ASSIGN_BUTTON_FALSE (maxcode++, "Superscope AimOffscreen"); - ASSIGN_BUTTON_FALSE (maxcode++, "Superscope Cursor"); - ASSIGN_BUTTON_FALSE (maxcode++, "Superscope ToggleTurbo"); - ASSIGN_BUTTON_FALSE (maxcode++, "Superscope ToggleTurbo"); - ASSIGN_BUTTON_FALSE (maxcode++, "Superscope Pause"); + ASSIGN_BUTTON_FALSE (maxcode++, "Superscope Fire"); + ASSIGN_BUTTON_FALSE (maxcode++, "Superscope AimOffscreen"); + ASSIGN_BUTTON_FALSE (maxcode++, "Superscope Cursor"); + ASSIGN_BUTTON_FALSE (maxcode++, "Superscope ToggleTurbo"); + ASSIGN_BUTTON_FALSE (maxcode++, "Superscope ToggleTurbo"); + ASSIGN_BUTTON_FALSE (maxcode++, "Superscope Pause"); - maxcode = 0x60; + maxcode = 0x60; /*** Mouse ***/ - ASSIGN_BUTTON_FALSE (maxcode++, "Mouse1 L"); - ASSIGN_BUTTON_FALSE (maxcode++, "Mouse1 R"); - ASSIGN_BUTTON_FALSE (maxcode++, "Mouse2 L"); - ASSIGN_BUTTON_FALSE (maxcode++, "Mouse2 R"); + ASSIGN_BUTTON_FALSE (maxcode++, "Mouse1 L"); + ASSIGN_BUTTON_FALSE (maxcode++, "Mouse1 R"); + ASSIGN_BUTTON_FALSE (maxcode++, "Mouse2 L"); + ASSIGN_BUTTON_FALSE (maxcode++, "Mouse2 R"); - maxcode = 0x70; + maxcode = 0x70; /*** Justifier ***/ - ASSIGN_BUTTON_FALSE (maxcode++, "Justifier1 Trigger"); - ASSIGN_BUTTON_FALSE (maxcode++, "Justifier1 AimOffscreen"); - ASSIGN_BUTTON_FALSE (maxcode++, "Justifier1 Start"); - ASSIGN_BUTTON_FALSE (maxcode++, "Justifier2 Trigger"); - ASSIGN_BUTTON_FALSE (maxcode++, "Justifier2 AimOffscreen"); - ASSIGN_BUTTON_FALSE (maxcode++, "Justifier2 Start"); + ASSIGN_BUTTON_FALSE (maxcode++, "Justifier1 Trigger"); + ASSIGN_BUTTON_FALSE (maxcode++, "Justifier1 AimOffscreen"); + ASSIGN_BUTTON_FALSE (maxcode++, "Justifier1 Start"); + ASSIGN_BUTTON_FALSE (maxcode++, "Justifier2 Trigger"); + ASSIGN_BUTTON_FALSE (maxcode++, "Justifier2 AimOffscreen"); + ASSIGN_BUTTON_FALSE (maxcode++, "Justifier2 Start"); - maxcode = 0x80; - S9xMapPointer( maxcode++, S9xGetCommandT("Pointer Superscope"), false); - S9xMapPointer( maxcode++, S9xGetCommandT("Pointer Mouse1"), false); - S9xMapPointer( maxcode++, S9xGetCommandT("Pointer Mouse2"), false); - S9xMapPointer( maxcode++, S9xGetCommandT("Pointer Justifier1"), false); - S9xMapPointer( maxcode++, S9xGetCommandT("Pointer Justifier2"), false); + maxcode = 0x80; + S9xMapPointer(maxcode++, S9xGetCommandT("Pointer Superscope"), false); + S9xMapPointer(maxcode++, S9xGetCommandT("Pointer Mouse1"), false); + S9xMapPointer(maxcode++, S9xGetCommandT("Pointer Mouse2"), false); + S9xMapPointer(maxcode++, S9xGetCommandT("Pointer Justifier1"), false); + S9xMapPointer(maxcode++, S9xGetCommandT("Pointer Justifier2"), false); - maxcode = 0x90; - ASSIGN_BUTTON_FALSE (maxcode++, "Screenshot"); - - SetControllers (); + maxcode = 0x90; + ASSIGN_BUTTON_FALSE (maxcode++, "Screenshot"); + SetControllers(); } - diff --git a/source/ngc/memcardop.h b/source/ngc/memcardop.h index f417c7a..1b36f28 100644 --- a/source/ngc/memcardop.h +++ b/source/ngc/memcardop.h @@ -10,8 +10,8 @@ * Memory Card routines ***************************************************************************/ -#ifndef _NGCMCSAVE_ -#define _NGCMCSAVE_ +#ifndef _MEMCARDOP_ +#define _MEMCARDOP_ int ParseMCDirectory (int slot); int LoadMCFile (char *buf, int slot, char *filename, bool silent); diff --git a/source/ngc/menu.cpp b/source/ngc/menu.cpp index fbf310c..7f834e7 100644 --- a/source/ngc/menu.cpp +++ b/source/ngc/menu.cpp @@ -42,7 +42,6 @@ extern "C" { #include "networkop.h" #include "memcardop.h" #include "fileop.h" - #include "dvd.h" #include "s9xconfig.h" #include "sram.h" @@ -53,7 +52,6 @@ extern "C" { #include "input.h" #include "patch.h" #include "filter.h" - #include "filelist.h" #include "gui/gui.h" #include "menu.h" @@ -947,10 +945,10 @@ static void ControllerWindowUpdate(void * ptr, int dir) { GCSettings.Controller += dir; - if(GCSettings.Controller > CTRL_LENGTH-1) - GCSettings.Controller = 0; - else if(GCSettings.Controller < 0) - GCSettings.Controller = CTRL_LENGTH-1; + if(GCSettings.Controller > CTRL_PAD4) + GCSettings.Controller = CTRL_MOUSE; + if(GCSettings.Controller < CTRL_MOUSE) + GCSettings.Controller = CTRL_PAD4; settingText->SetText(ctrlName[GCSettings.Controller]); b->ResetState(); @@ -962,7 +960,7 @@ static void ControllerWindowRightClick(void * ptr) { ControllerWindowUpdate(ptr, static void ControllerWindow() { - GuiWindow * w = new GuiWindow(250,250); + GuiWindow * w = new GuiWindow(300,250); w->SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); GuiTrigger trigA; diff --git a/source/ngc/menu.h b/source/ngc/menu.h index 527116e..d29cf79 100644 --- a/source/ngc/menu.h +++ b/source/ngc/menu.h @@ -21,7 +21,6 @@ void InfoPrompt(const char * msg); void ShowAction (const char *msg); void CancelAction(); void ShowProgress (const char *msg, int done, int total); -void ShutoffRumble(); enum { diff --git a/source/ngc/networkop.cpp b/source/ngc/networkop.cpp index 7899672..5e1b567 100644 --- a/source/ngc/networkop.cpp +++ b/source/ngc/networkop.cpp @@ -65,20 +65,51 @@ void UpdateCheck() item = mxmlFindElement(xml, xml, "app", "version", NULL, MXML_DESCEND); if(item) // a version entry exists { - const char * versionstr = mxmlElementGetAttr(item, "version"); + const char * version = mxmlElementGetAttr(item, "version"); - if(versionstr) + if(version && strlen(version) == 5) { - int version = atoi(versionstr); - int currVersion = atoi(APPVERSION); + int verMajor = version[0] - '0'; + int verMinor = version[2] - '0'; + int verPoint = version[4] - '0'; + int curMajor = APPVERSION[0] - '0'; + int curMinor = APPVERSION[2] - '0'; + int curPoint = APPVERSION[4] - '0'; - if(version > currVersion) // a new version is available + // check that the versioning is valid and is a newer version + if((verMajor >= 0 && verMajor <= 9 && + verMinor >= 0 && verMinor <= 9 && + verPoint >= 0 && verPoint <= 9) && + (verMajor > curMajor || + verMinor > curMinor || + verPoint > curPoint)) { item = mxmlFindElement(xml, xml, "file", NULL, NULL, MXML_DESCEND); if(item) { - snprintf(updateURL, 128, "%s", mxmlElementGetAttr(item, "url")); - updateFound = true; + const char * tmp = mxmlElementGetAttr(item, "url"); + if(tmp) + { + snprintf(updateURL, 128, "%s", tmp); + updateFound = true; + } + } + } + } + else // temporary, for compatibility + { + int versionnum = atoi(version); + if(versionnum > 10) // 010 + { + item = mxmlFindElement(xml, xml, "file", NULL, NULL, MXML_DESCEND); + if(item) + { + const char * tmp = mxmlElementGetAttr(item, "url"); + if(tmp) + { + snprintf(updateURL, 128, "%s", tmp); + updateFound = true; + } } } } diff --git a/source/ngc/preferences.cpp b/source/ngc/preferences.cpp index 550a4a0..105151b 100644 --- a/source/ngc/preferences.cpp +++ b/source/ngc/preferences.cpp @@ -256,9 +256,28 @@ decodePrefsData (int method) { const char * version = mxmlElementGetAttr(item, "version"); - if(version) + if(version && strlen(version) == 5) { - result = true; // assume version is valid + // this code assumes version in format X.X.X + // XX.X.X, X.XX.X, or X.X.XX will NOT work + int verMajor = version[0] - '0'; + int verMinor = version[2] - '0'; + int verPoint = version[4] - '0'; + int curMajor = APPVERSION[0] - '0'; + int curMinor = APPVERSION[2] - '0'; + int curPoint = APPVERSION[4] - '0'; + + // first we'll check that the versioning is valid + if(!(verMajor >= 0 && verMajor <= 9 && + verMinor >= 0 && verMinor <= 9 && + verPoint >= 0 && verPoint <= 9)) + result = false; + else if(verPoint < 8 && verMajor == 1) // less than version 1.0.8 + result = false; // reset settings (sorry, should update settings instead) + else if(verMajor > curMajor || verMinor > curMinor || verPoint > curPoint) // some future version + result = false; // reset settings + else + result = true; } } diff --git a/source/ngc/s9xconfig.cpp b/source/ngc/s9xconfig.cpp index fe36d7d..6fe01a7 100644 --- a/source/ngc/s9xconfig.cpp +++ b/source/ngc/s9xconfig.cpp @@ -22,10 +22,11 @@ struct SGCSettings GCSettings; /**************************************************************************** + * FixInvalidSettings + * * Attempts to correct at least some invalid settings - the ones that * might cause crashes ***************************************************************************/ - void FixInvalidSettings() { if(!(GCSettings.ZoomLevel > 0.5 && GCSettings.ZoomLevel < 1.5)) @@ -38,8 +39,15 @@ void FixInvalidSettings() GCSettings.MusicVolume = 40; if(!(GCSettings.SFXVolume >= 0 && GCSettings.SFXVolume <= 100)) GCSettings.SFXVolume = 40; + if(GCSettings.Controller > CTRL_PAD4 || GCSettings.Controller < CTRL_MOUSE) + GCSettings.Controller = CTRL_PAD2; } +/**************************************************************************** + * DefaultSettings + * + * Sets all the defaults! + ***************************************************************************/ void DefaultSettings () { @@ -67,15 +75,15 @@ DefaultSettings () GCSettings.smbpwd[19] = 0; GCSettings.smbshare[19] = 0; - GCSettings.Controller = 0; + GCSettings.Controller = CTRL_PAD2; GCSettings.ZoomLevel = 1.0; // zoom level GCSettings.render = 2; // Unfiltered GCSettings.widescreen = 0; // no aspect ratio correction GCSettings.FilterMethod = FILTER_NONE; // no hq2x - GCSettings.xshift = 0; // video shift - GCSettings.yshift = 0; + GCSettings.xshift = 0; // horizontal video shift + GCSettings.yshift = 0; // vertical video shift GCSettings.WiimoteOrientation = 0; GCSettings.ExitAction = 0; @@ -144,4 +152,3 @@ DefaultSettings () Settings.ForceDSP1 = 0; Settings.ForceNoDSP1 = 0; } - diff --git a/source/ngc/s9xconfig.h b/source/ngc/s9xconfig.h index 21ed97b..d255108 100644 --- a/source/ngc/s9xconfig.h +++ b/source/ngc/s9xconfig.h @@ -14,10 +14,9 @@ ***************************************************************************/ #ifndef _S9XCONFIG_ - #define _S9XCONFIG_ void FixInvalidSettings(); -void DefaultSettings (); +void DefaultSettings(); #endif diff --git a/source/ngc/snes9xGX.cpp b/source/ngc/snes9xGX.cpp index a365464..10a045e 100644 --- a/source/ngc/snes9xGX.cpp +++ b/source/ngc/snes9xGX.cpp @@ -303,11 +303,11 @@ static void * InitThread (void *arg) // Allocate SNES Memory if (!Memory.Init ()) - while (1); + ExitApp(); // Allocate APU if (!S9xInitAPU ()) - while (1); + ExitApp(); // Set Pixel Renderer to match 565 S9xSetRenderPixelFormat (RGB565); @@ -318,7 +318,7 @@ static void * InitThread (void *arg) // Initialise Graphics setGFX (); if (!S9xGraphicsInit ()) - while (1); + ExitApp(); // Check if DVD drive belongs to a Wii SetDVDDriveType(); @@ -374,7 +374,7 @@ main(int argc, char *argv[]) #ifdef HW_RVL // read wiimote accelerometer and IR data WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR); - WPAD_SetVRes(WPAD_CHAN_ALL,screenwidth, screenheight); + WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight); // Wii Power/Reset buttons WPAD_SetPowerButtonCallback((WPADShutdownCallback)ShutdownCB); diff --git a/source/ngc/snes9xGX.h b/source/ngc/snes9xGX.h index 3aaaf88..aee84a1 100644 --- a/source/ngc/snes9xGX.h +++ b/source/ngc/snes9xGX.h @@ -20,7 +20,7 @@ #include "filelist.h" #define APPNAME "Snes9x GX" -#define APPVERSION "009" +#define APPVERSION "4.0.0" #define PREF_FILE_NAME "settings.xml" #define NOTSILENT 0 @@ -58,8 +58,8 @@ enum CTRL_LENGTH }; -const char ctrlName[6][20] = -{ "SNES Controller", "SNES Mouse", "Superscope", "Justifier", "SNES Pad (2)", "SNES Pad (4)" }; +const char ctrlName[6][24] = +{ "SNES Controller", "SNES Mouse", "Superscope", "Justifier", "SNES Controllers (2)", "SNES Controllers (4)" }; struct SGCSettings{ int AutoLoad; diff --git a/source/ngc/video.cpp b/source/ngc/video.cpp index 9f933c5..68ed503 100644 --- a/source/ngc/video.cpp +++ b/source/ngc/video.cpp @@ -388,7 +388,7 @@ draw_square (Mtx v) /**************************************************************************** * StartGX * - * This function initialises the GX. + * Initialises GX and sets it up for use ***************************************************************************/ static void StartGX () @@ -409,6 +409,11 @@ StartGX () vheight = 100; } +/**************************************************************************** + * StopGX + * + * Stops GX (when exiting) + ***************************************************************************/ void StopGX() { GX_AbortFrame(); @@ -859,13 +864,10 @@ setGFX () } /**************************************************************************** - * GX Menu drawing routines + * TakeScreenshot + * + * Copies the current screen into a GX texture ***************************************************************************/ - -/** - * Make a snapshot of the screen in a texture. - * @return A pointer to a texture representing the screen or NULL if an error occurs. - */ void TakeScreenshot() { int texSize = vmode->fbWidth * vmode->efbHeight * 4; @@ -960,6 +962,11 @@ ResetVideo_Menu () GX_SetAlphaUpdate(GX_TRUE); } +/**************************************************************************** + * Menu_Render + * + * Renders everything current sent to GX, and flushes video + ***************************************************************************/ void Menu_Render() { GX_DrawDone (); @@ -973,7 +980,13 @@ void Menu_Render() VIDEO_WaitVSync(); } -void Menu_DrawImg(f32 xpos, f32 ypos, u16 width, u16 height, u8 data[], f32 degrees, f32 scaleX, f32 scaleY, u8 alpha) +/**************************************************************************** + * Menu_DrawImg + * + * Draws the specified image on screen using GX + ***************************************************************************/ +void Menu_DrawImg(f32 xpos, f32 ypos, u16 width, u16 height, u8 data[], + f32 degrees, f32 scaleX, f32 scaleY, u8 alpha) { if(data == NULL) return; @@ -1023,6 +1036,11 @@ void Menu_DrawImg(f32 xpos, f32 ypos, u16 width, u16 height, u8 data[], f32 degr GX_SetVtxDesc (GX_VA_TEX0, GX_NONE); } +/**************************************************************************** + * Menu_DrawRectangle + * + * Draws a rectangle at the specified coordinates using GX + ***************************************************************************/ void Menu_DrawRectangle(f32 x, f32 y, f32 width, f32 height, GXColor color, u8 filled) { u8 fmt; diff --git a/source/ngc/video.h b/source/ngc/video.h index 189c8bb..769d6ab 100644 --- a/source/ngc/video.h +++ b/source/ngc/video.h @@ -10,7 +10,6 @@ ***************************************************************************/ #ifndef _GCVIDEOH_ - #define _GCVIDEOH_ #include