diff --git a/Source/Android/Bridge/JavaBridge.cpp b/Source/Android/Bridge/JavaBridge.cpp index a80d37634..3c6d2b1b7 100644 --- a/Source/Android/Bridge/JavaBridge.cpp +++ b/Source/Android/Bridge/JavaBridge.cpp @@ -40,7 +40,7 @@ void JavaBridge::GfxThreadDone() JNIEnv *env = Android_JNI_GetEnv(); if (g_GLThread != NULL && env != NULL) { - WriteTrace(TraceUserInterface, TraceDebug, "calling java GLThread::ThreadExiting"); + WriteTrace(TraceUserInterface, TraceDebug, "Calling java GLThread::ThreadExiting"); jclass GLThreadClass = env->GetObjectClass(g_GLThread); jmethodID midThreadExiting = env->GetMethodID(GLThreadClass, "ThreadExiting", "()V"); env->CallVoidMethod(g_GLThread, midThreadExiting); diff --git a/Source/Android/Bridge/JavaBridge.h b/Source/Android/Bridge/JavaBridge.h index f0c2d18b0..903c21d21 100644 --- a/Source/Android/Bridge/JavaBridge.h +++ b/Source/Android/Bridge/JavaBridge.h @@ -16,7 +16,7 @@ public: void GfxThreadDone(); void SwapWindow(); - // ROM List + // ROM list void RomListReset(void); void RomListAddItem(const char * FullFileName, const char * FileName, const char * GoodName, uint32_t TextColor); void RomListLoaded(void); diff --git a/Source/Android/Bridge/Notification.cpp b/Source/Android/Bridge/Notification.cpp index e1e4846bb..41ff1547e 100644 --- a/Source/Android/Bridge/Notification.cpp +++ b/Source/Android/Bridge/Notification.cpp @@ -125,7 +125,7 @@ void CNotificationImp::BreakPoint(const char * FileName, int32_t LineNumber) } else { - FatalError("Fatal Error: Emulation stopped"); + FatalError("Fatal error: emulation stopped"); } } diff --git a/Source/Android/Bridge/jniBridge.cpp b/Source/Android/Bridge/jniBridge.cpp index f76e9ab2d..d9a6112ef 100644 --- a/Source/Android/Bridge/jniBridge.cpp +++ b/Source/Android/Bridge/jniBridge.cpp @@ -210,7 +210,7 @@ void AddRecentRom(const char * ImagePath) if (g_JavaBridge) { - WriteTrace(TraceUserInterface, TraceDebug, "calling RecentRomsUpdated"); + WriteTrace(TraceUserInterface, TraceDebug, "Calling RecentRomsUpdated"); g_JavaBridge->RecentRomsUpdated(); } WriteTrace(TraceUserInterface, TraceDebug, "Done"); @@ -220,7 +220,7 @@ void GameCpuRunning(void * /*NotUsed*/) { WriteTrace(TraceUserInterface, TraceDebug, "Start"); bool Running = g_Settings->LoadBool(GameRunning_CPU_Running); - WriteTrace(TraceUserInterface, TraceDebug, Running ? "Game Started" : "Game Stopped"); + WriteTrace(TraceUserInterface, TraceDebug, Running ? "Game started" : "Game stopped"); JNIEnv *env = Android_JNI_GetEnv(); if (Running) { @@ -232,7 +232,7 @@ void GameCpuRunning(void * /*NotUsed*/) g_System->RefreshGameSettings(); int RunCount = UISettingsLoadDword(Game_RunCount); - WriteTrace(TraceUserInterface, TraceDebug, "Setting Run Count to %d", RunCount + 1); + WriteTrace(TraceUserInterface, TraceDebug, "Setting run count to %d", RunCount + 1); UISettingsSaveDword(Game_RunCount, RunCount + 1); if (env != NULL) { @@ -265,12 +265,12 @@ void GameCpuRunning(void * /*NotUsed*/) WriteTrace(TraceUserInterface, TraceError, "No Java bridge"); } - // call in to java that emulation done + // Call in to java that emulation done WriteTrace(TraceUserInterface, TraceDebug, "Clean up global activity"); env->DeleteGlobalRef(g_Activity); g_Activity = NULL; - WriteTrace(TraceUserInterface, TraceDebug, "Clean up global gl thread"); + WriteTrace(TraceUserInterface, TraceDebug, "Clean up global GL thread"); if (g_JavaBridge) { g_JavaBridge->GfxThreadDone(); @@ -300,7 +300,7 @@ EXPORT jboolean CALL Java_emu_project64_jni_NativeExports_appInit(JNIEnv* env, j Notify().DisplayMessage(10, " / ____/ / / /_/ / / / __/ /__/ /_/ /_/ /__ __/"); Notify().DisplayMessage(10, "/_/ /_/ \\____/_/ /\\___/\\___/\\__/\\____/ /_/"); Notify().DisplayMessage(10, " /___/"); - Notify().DisplayMessage(10, "http://www.pj64-emu.com/"); + Notify().DisplayMessage(10, "https://www.pj64-emu.com/"); Notify().DisplayMessage(10, stdstr_f("%s Version %s", VER_FILE_DESCRIPTION_STR, VER_FILE_VERSION_STR).c_str()); Notify().DisplayMessage(10, ""); diff --git a/Source/Android/PluginInput/Controller_1.1.h b/Source/Android/PluginInput/Controller_1.1.h index 7014110e4..5aa4159b9 100644 --- a/Source/Android/PluginInput/Controller_1.1.h +++ b/Source/Android/PluginInput/Controller_1.1.h @@ -89,8 +89,8 @@ typedef struct Function: CloseDLL Purpose: This function is called when the emulator is closing down allowing the DLL to de-initialize. -input: none -output: none +Input: None +Output: None */ EXPORT void CALL CloseDLL(void); @@ -99,15 +99,15 @@ EXPORT void CALL CloseDLL(void); Function: ControllerCommand Purpose: To process the raw data that has just been sent to a specific controller. -input: - Controller Number (0 to 3) and -1 signaling end of +Input: Controller Number (0 to 3) and -1 signaling end of processing the PIF RAM. - Pointer of data to be processed. -output: none +Output: None -note: This function is only needed if the DLL is allowing raw +Note: This function is only needed if the DLL is allowing raw data, or the plugin is set to raw -the data that is being processed looks like this: +The data that is being processed looks like this: initialize controller: 01 03 00 FF FF FF read controller: 01 04 01 FF FF FF FF */ @@ -118,8 +118,8 @@ EXPORT void CALL ControllerCommand(int Control, uint8_t * Command); Function: DllAbout Purpose: This function is optional function that is provided to give further information about the DLL. -input: a handle to the window that calls this function -output: none +Input: A handle to the window that calls this function +Output: None */ EXPORT void CALL DllAbout(void * hParent); @@ -128,8 +128,8 @@ EXPORT void CALL DllAbout(void * hParent); Function: DllConfig Purpose: This function is optional function that is provided to allow the user to configure the DLL -input: a handle to the window that calls this function -output: none +Input: A handle to the window that calls this function +Output: None */ EXPORT void CALL DllConfig(void * hParent); @@ -138,8 +138,8 @@ EXPORT void CALL DllConfig(void * hParent); Function: DllTest Purpose: This function is optional function that is provided to allow the user to test the DLL -input: a handle to the window that calls this function -output: none +Input: A handle to the window that calls this function +Output: None */ EXPORT void CALL DllTest(void * hParent); @@ -148,9 +148,9 @@ EXPORT void CALL DllTest(void * hParent); Function: GetDllInfo Purpose: This function allows the emulator to gather information about the DLL by filling in the PluginInfo structure. -input: a pointer to a PLUGIN_INFO structure that needs to be -filled by the function. (see def above) -output: none +Input: A pointer to a PLUGIN_INFO structure that needs to be +filled by the function (see def above) +Output: None */ EXPORT void CALL GetDllInfo(PLUGIN_INFO * PluginInfo); @@ -158,10 +158,10 @@ EXPORT void CALL GetDllInfo(PLUGIN_INFO * PluginInfo); /* Function: GetKeys Purpose: To get the current state of the controllers buttons. -input: - Controller Number (0 to 3) +Input: Controller Number (0 to 3) - A pointer to a BUTTONS structure to be filled with the controller state. -output: none +Output: None */ EXPORT void CALL GetKeys(int32_t Control, BUTTONS * Keys); @@ -170,10 +170,10 @@ EXPORT void CALL GetKeys(int32_t Control, BUTTONS * Keys); Function: InitiateControllers Purpose: This function initializes how each of the controllers should be handled. -input: - The handle to the main window. +Input: - The handle to the main window. - A controller structure that needs to be filled for the emulator to know how to handle each controller. -output: none +Output: None */ EXPORT void CALL InitiateControllers(CONTROL_INFO ControlInfo); @@ -182,11 +182,11 @@ EXPORT void CALL InitiateControllers(CONTROL_INFO ControlInfo); Function: ReadController Purpose: To process the raw data in the PIF RAM that is about to be read. -input: - Controller Number (0 to 3) and -1 signaling end of +Input: Controller Number (0 to 3) and -1 signaling end of processing the PIF RAM. - Pointer of data to be processed. -output: none -note: This function is only needed if the DLL is allowing raw +Output: None +Note: This function is only needed if the DLL is allowing raw data. */ @@ -195,18 +195,18 @@ EXPORT void CALL ReadController(int Control, uint8_t * Command); /* Function: RomClosed Purpose: This function is called when a ROM is closed. -input: none -output: none +Input: None +Output: None */ EXPORT void CALL RomClosed(void); /* Function: RomOpen -Purpose: This function is called when a ROM is open. (from the +Purpose: This function is called when a ROM is open (from the emulation thread) -input: none -output: none +Input: None +Output: None */ EXPORT void CALL RomOpen(void); @@ -215,8 +215,8 @@ EXPORT void CALL RomOpen(void); Function: WM_KeyDown Purpose: To pass the WM_KeyDown message from the emulator to the plugin. -input: wParam and lParam of the WM_KEYDOWN message. -output: none +Input: wParam and lParam of the WM_KEYDOWN message. +Output: None */ EXPORT void CALL WM_KeyDown(uint32_t wParam, uint32_t lParam); @@ -225,8 +225,8 @@ EXPORT void CALL WM_KeyDown(uint32_t wParam, uint32_t lParam); Function: WM_KeyUp Purpose: To pass the WM_KEYUP message from the emulator to the plugin. -input: wParam and lParam of the WM_KEYDOWN message. -output: none +Input: wParam and lParam of the WM_KEYDOWN message. +Output: None */ EXPORT void CALL WM_KeyUp(uint32_t wParam, uint32_t lParam); diff --git a/Source/Android/PluginInput/Main.cpp b/Source/Android/PluginInput/Main.cpp index bc25fd25e..51cfde70f 100644 --- a/Source/Android/PluginInput/Main.cpp +++ b/Source/Android/PluginInput/Main.cpp @@ -12,46 +12,46 @@ BUTTONS g_buttons; void ShowAboutWindow (void * hParent); -/****************************************************************** +/* Function: CloseDLL Purpose: This function is called when the emulator is closing down allowing the DLL to de-initialize. -input: none -output: none -*******************************************************************/ +Input: None +Output: None +*/ EXPORT void CALL CloseDLL (void) { } -/****************************************************************** +/* Function: ControllerCommand Purpose: To process the raw data that has just been sent to a specific controller. -input: - Controller Number (0 to 3) and -1 signaling end of +Input: Controller Number (0 to 3) and -1 signaling end of processing the PIF RAM. - Pointer of data to be processed. -output: none +Output: None -note: This function is only needed if the DLL is allowing raw +Note: This function is only needed if the DLL is allowing raw data, or the plugin is set to raw -the data that is being processed looks like this: -initialize controller: 01 03 00 FF FF FF -read controller: 01 04 01 FF FF FF FF -*******************************************************************/ +The data that is being processed looks like this: +Initialize controller: 01 03 00 FF FF FF +Read controller: 01 04 01 FF FF FF FF +*/ EXPORT void CALL ControllerCommand ( int /*Control*/, uint8_t * /*Command*/) { } -/****************************************************************** +/* Function: DllAbout Purpose: This function is optional function that is provided to give further information about the DLL. -input: a handle to the window that calls this function -output: none -*******************************************************************/ +Input: A handle to the window that calls this function +Output: None +*/ EXPORT void CALL DllAbout ( void * hParent ) { @@ -60,38 +60,38 @@ EXPORT void CALL DllAbout ( void * hParent ) #endif } -/****************************************************************** +/* Function: DllConfig Purpose: This function is optional function that is provided to allow the user to configure the DLL -input: a handle to the window that calls this function -output: none -*******************************************************************/ +Input: A handle to the window that calls this function +Output: None +*/ EXPORT void CALL DllConfig ( void * /*hParent*/ ) { } -/****************************************************************** +/* Function: DllTest Purpose: This function is optional function that is provided to allow the user to test the DLL -input: a handle to the window that calls this function -output: none -*******************************************************************/ +Input: A handle to the window that calls this function +Output: None +*/ EXPORT void CALL DllTest ( void * /*hParent*/ ) { } -/****************************************************************** +/* Function: GetDllInfo Purpose: This function allows the emulator to gather information about the DLL by filling in the PluginInfo structure. -input: a pointer to a PLUGIN_INFO structure that needs to be +Input: A pointer to a PLUGIN_INFO structure that needs to be filled by the function. (see def above) -output: none -*******************************************************************/ +Output: None +*/ EXPORT void CALL GetDllInfo ( PLUGIN_INFO * PluginInfo ) { @@ -104,14 +104,14 @@ EXPORT void CALL GetDllInfo ( PLUGIN_INFO * PluginInfo ) #endif } -/****************************************************************** +/* Function: GetKeys Purpose: To get the current state of the controllers buttons. -input: - Controller Number (0 to 3) +Input: Controller Number (0 to 3) - A pointer to a BUTTONS structure to be filled with the controller state. -output: none -*******************************************************************/ +Output: None +*/ EXPORT void CALL GetKeys(int Control, BUTTONS * Keys ) { @@ -121,15 +121,15 @@ EXPORT void CALL GetKeys(int Control, BUTTONS * Keys ) } } -/****************************************************************** +/* Function: InitiateControllers Purpose: This function initializes how each of the controllers should be handled. -input: - The handle to the main window. +Input: The handle to the main window. - A controller structure that needs to be filled for the emulator to know how to handle each controller. -output: none -*******************************************************************/ +Output: None +*/ EXPORT void CALL InitiateControllers (CONTROL_INFO ControlInfo) { @@ -138,65 +138,65 @@ EXPORT void CALL InitiateControllers (CONTROL_INFO ControlInfo) g_control_info.Controls[0].Plugin = PLUGIN_MEMPAK; } -/****************************************************************** +/* Function: ReadController Purpose: To process the raw data in the PIF RAM that is about to be read. -input: - Controller Number (0 to 3) and -1 signaling end of +Input: Controller Number (0 to 3) and -1 signaling end of processing the PIF RAM. - Pointer of data to be processed. -output: none -note: This function is only needed if the DLL is allowing raw +Output: None +Note: This function is only needed if the DLL is allowing raw data. -*******************************************************************/ +*/ EXPORT void CALL ReadController ( int /*Control*/, uint8_t * /*Command*/ ) { } -/****************************************************************** +/* Function: RomClosed Purpose: This function is called when a ROM is closed. -input: none -output: none -*******************************************************************/ +Input: None +Output: None +*/ EXPORT void CALL RomClosed (void) { } -/****************************************************************** +/* Function: RomOpen -Purpose: This function is called when a ROM is open. (from the +Purpose: This function is called when a ROM is open (from the emulation thread) -input: none -output: none -*******************************************************************/ +Input: None +Output: None +*/ EXPORT void CALL RomOpen (void) { memset(&g_buttons, 0, sizeof(g_buttons)); } -/****************************************************************** +/* Function: WM_KeyDown Purpose: To pass the WM_KeyDown message from the emulator to the plugin. -input: wParam and lParam of the WM_KEYDOWN message. -output: none -*******************************************************************/ +Input: wParam and lParam of the WM_KEYDOWN message. +Output: None +*/ EXPORT void CALL WM_KeyDown( uint32_t /*wParam*/, uint32_t /*lParam*/ ) { } -/****************************************************************** +/* Function: WM_KeyUp Purpose: To pass the WM_KEYUP message from the emulator to the plugin. -input: wParam and lParam of the WM_KEYDOWN message. -output: none -*******************************************************************/ +Input: wParam and lParam of the WM_KEYDOWN message. +Output: None +*/ EXPORT void CALL WM_KeyUp( uint32_t /*wParam*/, uint32_t /*lParam*/ ) { diff --git a/Source/Android/PluginInput/about.cpp b/Source/Android/PluginInput/about.cpp index d41733a57..a65589dd6 100644 --- a/Source/Android/PluginInput/about.cpp +++ b/Source/Android/PluginInput/about.cpp @@ -5,6 +5,6 @@ void ShowAboutWindow (void * hParent) { #ifdef _WIN32 - MessageBox((HWND)hParent,L"Android Input Plugin",L"Dll About",MB_OK); + MessageBox((HWND)hParent,L"Android input plugin",L"Dll About",MB_OK); #endif } diff --git a/Source/Android/PluginRSP/alist.cpp b/Source/Android/PluginRSP/alist.cpp index 63802628d..311f0a1d8 100644 --- a/Source/Android/PluginRSP/alist.cpp +++ b/Source/Android/PluginRSP/alist.cpp @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2014 Bobby Smiles // Copyright(C) 2009 Richard Goedeken @@ -286,7 +286,7 @@ void alist_envmix_exp( CHle * hle, bool init, bool aux, uint16_t dmem_dl, uint16 ramps[1].value = *(int32_t *)(save_buffer + 18); // 14-15 } - // init which ensure ramp.step != 0 iff ramp.value == ramp.target + // Initialize which ensure ramp.step != 0 iff ramp.value == ramp.target ramps[0].step = ramps[0].target - ramps[0].value; ramps[1].step = ramps[1].target - ramps[1].value; diff --git a/Source/Android/PluginRSP/alist.h b/Source/Android/PluginRSP/alist.h index 67410f215..daaf2c005 100644 --- a/Source/Android/PluginRSP/alist.h +++ b/Source/Android/PluginRSP/alist.h @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2014 Bobby Smiles // GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html diff --git a/Source/Android/PluginRSP/alist_audio.cpp b/Source/Android/PluginRSP/alist_audio.cpp index 77694b272..e6347c6f0 100644 --- a/Source/Android/PluginRSP/alist_audio.cpp +++ b/Source/Android/PluginRSP/alist_audio.cpp @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2014 Bobby Smiles // Copyright(C) 2009 Richard Goedeken diff --git a/Source/Android/PluginRSP/alist_naudio.cpp b/Source/Android/PluginRSP/alist_naudio.cpp index 66dc8a0d7..0f1ad5b17 100644 --- a/Source/Android/PluginRSP/alist_naudio.cpp +++ b/Source/Android/PluginRSP/alist_naudio.cpp @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2014 Bobby Smiles // Copyright(C) 2009 Richard Goedeken diff --git a/Source/Android/PluginRSP/alist_nead.cpp b/Source/Android/PluginRSP/alist_nead.cpp index 68240814c..d3530b842 100644 --- a/Source/Android/PluginRSP/alist_nead.cpp +++ b/Source/Android/PluginRSP/alist_nead.cpp @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2014 Bobby Smiles // Copyright(C) 2009 Richard Goedeken @@ -284,12 +284,12 @@ static void FILTER(CHle * hle, uint32_t w1, uint32_t w2) if (flags > 1) { hle->alist_nead().filter_count = w1; - hle->alist_nead().filter_lut_address[0] = address; // t6 + hle->alist_nead().filter_lut_address[0] = address; // T6 } else { uint16_t dmem = w1; - hle->alist_nead().filter_lut_address[1] = address + 0x10; // t5 + hle->alist_nead().filter_lut_address[1] = address + 0x10; // T5 alist_filter(hle, dmem, hle->alist_nead().filter_count, address, hle->alist_nead().filter_lut_address); } } diff --git a/Source/Android/PluginRSP/arithmetics.h b/Source/Android/PluginRSP/arithmetics.h index 9ddd4e565..27eeb385d 100644 --- a/Source/Android/PluginRSP/arithmetics.h +++ b/Source/Android/PluginRSP/arithmetics.h @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2014 Bobby Smiles // GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html diff --git a/Source/Android/PluginRSP/audio.cpp b/Source/Android/PluginRSP/audio.cpp index afd5da4d6..6f88df073 100644 --- a/Source/Android/PluginRSP/audio.cpp +++ b/Source/Android/PluginRSP/audio.cpp @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2014 Bobby Smiles // GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html diff --git a/Source/Android/PluginRSP/audio.h b/Source/Android/PluginRSP/audio.h index 6dfe6cdb8..ffa229c67 100644 --- a/Source/Android/PluginRSP/audio.h +++ b/Source/Android/PluginRSP/audio.h @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2014 Bobby Smiles // GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html @@ -14,7 +14,7 @@ static inline int16_t adpcm_predict_sample(uint8_t byte, uint8_t mask, unsigned lshift, unsigned rshift) { int16_t sample = (uint16_t)(byte & mask) << lshift; - sample >>= rshift; // signed + sample >>= rshift; // Signed return sample; } diff --git a/Source/Android/PluginRSP/cicx105.cpp b/Source/Android/PluginRSP/cicx105.cpp index 12e543483..4d093565b 100644 --- a/Source/Android/PluginRSP/cicx105.cpp +++ b/Source/Android/PluginRSP/cicx105.cpp @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2012 Bobby Smiles // Copyright(C) 2009 Richard Goedeken diff --git a/Source/Android/PluginRSP/common.h b/Source/Android/PluginRSP/common.h index 67dd04b55..82167c42b 100644 --- a/Source/Android/PluginRSP/common.h +++ b/Source/Android/PluginRSP/common.h @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2014 Bobby Smiles // Copyright(C) 2009 Richard Goedeken diff --git a/Source/Android/PluginRSP/hle.cpp b/Source/Android/PluginRSP/hle.cpp index e603b8449..4657a7c20 100644 --- a/Source/Android/PluginRSP/hle.cpp +++ b/Source/Android/PluginRSP/hle.cpp @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2012 Bobby Smiles // Copyright(C) 2009 Richard Goedeken @@ -294,7 +294,7 @@ void CHle::normal_task_dispatching(void) return; } - WarnMessage("unknown OSTask: sum: %x PC:%x", sum, *m_sp_pc); + WarnMessage("Unknown OSTask: sum: %x PC:%x", sum, *m_sp_pc); #ifdef ENABLE_TASK_DUMP dump_unknown_task(this, sum); #endif @@ -311,7 +311,7 @@ void CHle::non_task_dispatching(void) return; } - WarnMessage("unknown RSP code: sum: %x PC:%x", sum, *m_sp_pc); + WarnMessage("Unknown RSP code: sum: %x PC:%x", sum, *m_sp_pc); #ifdef ENABLE_TASK_DUMP dump_unknown_non_task(hle, sum); #endif @@ -324,7 +324,7 @@ void CHle::non_task_dispatching(void) void CHle::VerboseMessage(const char *message, ...) { #if defined(_WIN32) && defined(_DEBUG) - // These can get annoying. + // These can get annoying #if 0 MessageBox(NULL, message, "HLE verbose message", MB_OK); #endif diff --git a/Source/Android/PluginRSP/hle.h b/Source/Android/PluginRSP/hle.h index 4af3e2e65..964a68d5f 100644 --- a/Source/Android/PluginRSP/hle.h +++ b/Source/Android/PluginRSP/hle.h @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2014 Bobby Smiles // GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html @@ -13,59 +13,59 @@ enum { - SP_CLR_HALT = 0x00001, /* Bit 0: Clear halt */ - SP_SET_HALT = 0x00002, /* Bit 1: Set halt */ - SP_CLR_BROKE = 0x00004, /* Bit 2: Clear broke */ - SP_CLR_INTR = 0x00008, /* Bit 3: Clear INTR */ - SP_SET_INTR = 0x00010, /* Bit 4: Set INTR */ - SP_CLR_SSTEP = 0x00020, /* Bit 5: Clear SSTEP */ - SP_SET_SSTEP = 0x00040, /* Bit 6: Set SSTEP */ - SP_CLR_INTR_BREAK = 0x00080, /* Bit 7: Clear INTR on break */ - SP_SET_INTR_BREAK = 0x00100, /* Bit 8: Set INTR on break */ - SP_CLR_SIG0 = 0x00200, /* Bit 9: Clear signal 0 */ - SP_SET_SIG0 = 0x00400, /* Bit 10: Set signal 0 */ - SP_CLR_SIG1 = 0x00800, /* Bit 11: Clear signal 1 */ - SP_SET_SIG1 = 0x01000, /* Bit 12: Set signal 1 */ - SP_CLR_SIG2 = 0x02000, /* Bit 13: Clear signal 2 */ - SP_SET_SIG2 = 0x04000, /* Bit 14: Set signal 2 */ - SP_CLR_SIG3 = 0x08000, /* Bit 15: Clear signal 3 */ - SP_SET_SIG3 = 0x10000, /* Bit 16: Set signal 3 */ - SP_CLR_SIG4 = 0x20000, /* Bit 17: Clear signal 4 */ - SP_SET_SIG4 = 0x40000, /* Bit 18: Set signal 4 */ - SP_CLR_SIG5 = 0x80000, /* Bit 19: Clear signal 5 */ - SP_SET_SIG5 = 0x100000, /* Bit 20: Set signal 5 */ - SP_CLR_SIG6 = 0x200000, /* Bit 21: Clear signal 6 */ - SP_SET_SIG6 = 0x400000, /* Bit 22: Set signal 6 */ - SP_CLR_SIG7 = 0x800000, /* Bit 23: Clear signal 7 */ - SP_SET_SIG7 = 0x1000000, /* Bit 24: Set signal 7 */ + SP_CLR_HALT = 0x00001, // Bit 0: Clear halt + SP_SET_HALT = 0x00002, // Bit 1: Set halt + SP_CLR_BROKE = 0x00004, // Bit 2: Clear broke + SP_CLR_INTR = 0x00008, // Bit 3: Clear INTR + SP_SET_INTR = 0x00010, // Bit 4: Set INTR + SP_CLR_SSTEP = 0x00020, // Bit 5: Clear SSTEP + SP_SET_SSTEP = 0x00040, // Bit 6: Set SSTEP + SP_CLR_INTR_BREAK = 0x00080, // Bit 7: Clear INTR on break + SP_SET_INTR_BREAK = 0x00100, // Bit 8: Set INTR on break + SP_CLR_SIG0 = 0x00200, // Bit 9: Clear signal 0 + SP_SET_SIG0 = 0x00400, // Bit 10: Set signal 0 + SP_CLR_SIG1 = 0x00800, // Bit 11: Clear signal 1 + SP_SET_SIG1 = 0x01000, // Bit 12: Set signal 1 + SP_CLR_SIG2 = 0x02000, // Bit 13: Clear signal 2 + SP_SET_SIG2 = 0x04000, // Bit 14: Set signal 2 + SP_CLR_SIG3 = 0x08000, // Bit 15: Clear signal 3 + SP_SET_SIG3 = 0x10000, // Bit 16: Set signal 3 + SP_CLR_SIG4 = 0x20000, // Bit 17: Clear signal 4 + SP_SET_SIG4 = 0x40000, // Bit 18: Set signal 4 + SP_CLR_SIG5 = 0x80000, // Bit 19: Clear signal 5 + SP_SET_SIG5 = 0x100000, // Bit 20: Set signal 5 + SP_CLR_SIG6 = 0x200000, // Bit 21: Clear signal 6 + SP_SET_SIG6 = 0x400000, // Bit 22: Set signal 6 + SP_CLR_SIG7 = 0x800000, // Bit 23: Clear signal 7 + SP_SET_SIG7 = 0x1000000, // Bit 24: Set signal 7 - SP_STATUS_HALT = 0x001, /* Bit 0: Halt */ - SP_STATUS_BROKE = 0x002, /* Bit 1: Broke */ - SP_STATUS_DMA_BUSY = 0x004, /* Bit 2: DMA busy */ - SP_STATUS_DMA_FULL = 0x008, /* Bit 3: DMA full */ - SP_STATUS_IO_FULL = 0x010, /* Bit 4: IO full */ - SP_STATUS_SSTEP = 0x020, /* Bit 5: Single step */ - SP_STATUS_INTR_BREAK = 0x040, /* Bit 6: Interrupt on break */ - SP_STATUS_SIG0 = 0x080, /* Bit 7: Signal 0 set */ - SP_STATUS_SIG1 = 0x100, /* Bit 8: Signal 1 set */ - SP_STATUS_SIG2 = 0x200, /* Bit 9: Signal 2 set */ - SP_STATUS_SIG3 = 0x400, /* Bit 10: Signal 3 set */ - SP_STATUS_SIG4 = 0x800, /* Bit 11: Signal 4 set */ - SP_STATUS_SIG5 = 0x1000, /* Bit 12: Signal 5 set */ - SP_STATUS_SIG6 = 0x2000, /* Bit 13: Signal 6 set */ - SP_STATUS_SIG7 = 0x4000, /* Bit 14: Signal 7 set */ + SP_STATUS_HALT = 0x001, // Bit 0: Halt + SP_STATUS_BROKE = 0x002, // Bit 1: Broke + SP_STATUS_DMA_BUSY = 0x004, // Bit 2: DMA busy + SP_STATUS_DMA_FULL = 0x008, // Bit 3: DMA full + SP_STATUS_IO_FULL = 0x010, // Bit 4: IO full + SP_STATUS_SSTEP = 0x020, // Bit 5: Single step + SP_STATUS_INTR_BREAK = 0x040, // Bit 6: Interrupt on break + SP_STATUS_SIG0 = 0x080, // Bit 7: Signal 0 set + SP_STATUS_SIG1 = 0x100, // Bit 8: Signal 1 set + SP_STATUS_SIG2 = 0x200, // Bit 9: Signal 2 set + SP_STATUS_SIG3 = 0x400, // Bit 10: Signal 3 set + SP_STATUS_SIG4 = 0x800, // Bit 11: Signal 4 set + SP_STATUS_SIG5 = 0x1000, // Bit 12: Signal 5 set + SP_STATUS_SIG6 = 0x2000, // Bit 13: Signal 6 set + SP_STATUS_SIG7 = 0x4000, // Bit 14: Signal 7 set }; // MIPS interface flags enum { - MI_INTR_SP = 0x01, /* Bit 0: SP INTR */ - MI_INTR_SI = 0x02, /* Bit 1: SI INTR */ - MI_INTR_AI = 0x04, /* Bit 2: AI INTR */ - MI_INTR_VI = 0x08, /* Bit 3: VI INTR */ - MI_INTR_PI = 0x10, /* Bit 4: PI INTR */ - MI_INTR_DP = 0x20, /* Bit 5: DP INTR */ + MI_INTR_SP = 0x01, // Bit 0: SP INTR + MI_INTR_SI = 0x02, // Bit 1: SI INTR + MI_INTR_AI = 0x04, // Bit 2: AI INTR + MI_INTR_VI = 0x08, // Bit 3: VI INTR + MI_INTR_PI = 0x10, // Bit 4: PI INTR + MI_INTR_DP = 0x20, // Bit 5: DP INTR }; class CHle diff --git a/Source/Android/PluginRSP/jpeg.cpp b/Source/Android/PluginRSP/jpeg.cpp index 2ca29b430..1b1b4dd4d 100644 --- a/Source/Android/PluginRSP/jpeg.cpp +++ b/Source/Android/PluginRSP/jpeg.cpp @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2012 Bobby Smiles // Copyright(C) 2009 Richard Goedeken @@ -373,7 +373,7 @@ static void decode_macroblock_ob(int16_t *macroblock, int32_t *y_dc, int32_t *u_ for (sb = 0; sb < 6; ++sb) { int16_t tmp_sb[SUBBLOCK_SIZE]; - // Update DC + // Update decode int32_t dc = (int32_t)macroblock[0]; switch (sb) { case 0: diff --git a/Source/Android/PluginRSP/main.cpp b/Source/Android/PluginRSP/main.cpp index 5234d0b48..f31bc1d88 100644 --- a/Source/Android/PluginRSP/main.cpp +++ b/Source/Android/PluginRSP/main.cpp @@ -19,8 +19,8 @@ BOOL WINAPI DllMain(void * hinst, DWORD /*fdwReason*/, LPVOID /*lpvReserved*/) Function: CloseDLL Purpose: This function is called when the emulator is closing down allowing the DLL to de-initialize. -input: none -output: none +Input: None +Output: None */ void CloseDLL(void) @@ -36,8 +36,8 @@ void CloseDLL(void) Function: DllAbout Purpose: This function is optional function that is provided to give further information about the DLL. -input: a handle to the window that calls this function -output: none +Input: A handle to the window that calls this function +Output: None */ void DllAbout(void * hParent) @@ -52,8 +52,8 @@ Function: DoRspCycles Purpose: This function is to allow the RSP to run in parallel with the r4300 switching control back to the r4300 once the function ends. -input: The number of cycles that is meant to be executed -output: The number of cycles that was executed. This value can +Input: The number of cycles that is meant to be executed +Output: The number of cycles that was executed. This value can be greater than the number of cycles that the RSP should have performed. (this value is ignored if the RSP is stopped) @@ -72,9 +72,9 @@ uint32_t DoRspCycles(uint32_t Cycles) Function: GetDllInfo Purpose: This function allows the emulator to gather information about the DLL by filling in the PluginInfo structure. -input: a pointer to a PLUGIN_INFO structure that needs to be +Input: A pointer to a PLUGIN_INFO structure that needs to be filled by the function. (see def above) -output: none +Output: None */ void GetDllInfo(PLUGIN_INFO * PluginInfo) @@ -95,11 +95,11 @@ Function: InitiateRSP Purpose: This function is called when the DLL is started to give information from the emulator that the N64 RSP interface needs -input: Rsp_Info is passed to this function which is defined +Input: Rsp_Info is passed to this function which is defined above. CycleCount is the number of cycles between switching control between the RSP and r4300i core. -output: none +Output: None */ void InitiateRSP(RSP_INFO Rsp_Info, uint32_t * /*CycleCount*/) @@ -114,9 +114,9 @@ void InitiateRSP(RSP_INFO Rsp_Info, uint32_t * /*CycleCount*/) /* Function: RomOpen -Purpose: This function is called when a ROM is opened. -input: none -output: none +Purpose: This function is called when a ROM is opened +Input: None +Output: None */ void RomOpen(void) @@ -125,9 +125,9 @@ void RomOpen(void) /* Function: RomClosed -Purpose: This function is called when a ROM is closed. -input: none -output: none +Purpose: This function is called when a ROM is closed +Input: None +Output: None */ void RomClosed(void) diff --git a/Source/Android/PluginRSP/mem.cpp b/Source/Android/PluginRSP/mem.cpp index ac67e6cda..4b8087fd0 100644 --- a/Source/Android/PluginRSP/mem.cpp +++ b/Source/Android/PluginRSP/mem.cpp @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2012 Bobby Smiles // GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html diff --git a/Source/Android/PluginRSP/mem.h b/Source/Android/PluginRSP/mem.h index 553775acd..6b7aeb586 100644 --- a/Source/Android/PluginRSP/mem.h +++ b/Source/Android/PluginRSP/mem.h @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2014 Bobby Smiles // GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html diff --git a/Source/Android/PluginRSP/mp3.cpp b/Source/Android/PluginRSP/mp3.cpp index f51a221ac..7072d6516 100644 --- a/Source/Android/PluginRSP/mp3.cpp +++ b/Source/Android/PluginRSP/mp3.cpp @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2014 Bobby Smiles // Copyright(C) 2009 Richard Goedeken @@ -197,8 +197,8 @@ void mp3_task(CHle * hle, unsigned int index, uint32_t address) uint32_t t4;// = (w1 & 0x1E); // Initialization code - uint32_t readPtr; // s5 - uint32_t writePtr; // s6 + uint32_t readPtr; // S5 + uint32_t writePtr; // S6 uint32_t tmp; int cnt, cnt2; @@ -210,16 +210,16 @@ void mp3_task(CHle * hle, unsigned int index, uint32_t address) writePtr = readPtr = address; // TODO: Just do that for efficiency...may remove and use directly later anyway memcpy(hle->mp3_buffer() + 0xCE8, hle->dram() + readPtr, 8); - // This must be a header byte or whatnot + // This must be a header byte or what not readPtr += 8; for (cnt = 0; cnt < 0x480; cnt += 0x180) { // DMA: 0xCF0 <- RDRAM[s5] : 0x180 memcpy(hle->mp3_buffer() + 0xCF0, hle->dram() + readPtr, 0x180); - inPtr = 0xCF0; // s7 - outPtr = 0xE70; // s3 - // --------------- Inner Loop Start -------------------- + inPtr = 0xCF0; // S7 + outPtr = 0xE70; // S3 + // Inner loop start for (cnt2 = 0; cnt2 < 0x180; cnt2 += 0x40) { t6 &= 0xFFE0; @@ -234,7 +234,7 @@ void mp3_task(CHle * hle, unsigned int index, uint32_t address) inPtr += 0x40; outPtr += 0x40; } - // --------------- Inner Loop End -------------------- + // Inner loop end memcpy(hle->dram() + writePtr, hle->mp3_buffer() + 0xe70, 0x180); writePtr += 0x180; readPtr += 0x180; @@ -326,7 +326,7 @@ static void InnerLoop(CHle * hle, uint32_t outPtr, uint32_t inPtr, uint32_t t6, MP3AB0(v); - // Part 5 - 1-Wide Butterflies - 100% accurate but need SSVs! + // Part 5 - 1-wide butterflies - 100% accurate but need SSVs! t0 = t6 + 0x100; t1 = t6 + 0x200; @@ -485,7 +485,7 @@ static void InnerLoop(CHle * hle, uint32_t outPtr, uint32_t inPtr, uint32_t t6, MP3AB0(v); - // Part 7: - 100% accurate + SSV - Unoptimized + // Part 7: - 100% accurate + SSV - unoptimized (TODO: optimize?) v[0] = (v[17] + v[16]) >> 1; v[1] = ((v[17] * (int)((short)0xA57E * 2)) + (v[16] * 0xB504)) >> 0x10; @@ -582,7 +582,7 @@ static void InnerLoop(CHle * hle, uint32_t outPtr, uint32_t inPtr, uint32_t t6, v18 = v6 + v8; // Clamp(v0); // Clamp(v18); - // clamp??? + // Clamp? *(int16_t *)(hle->mp3_buffer() + (outPtr ^ S16)) = v0; *(int16_t *)(hle->mp3_buffer() + ((outPtr + 2)^S16)) = v18; outPtr += 4; @@ -643,7 +643,7 @@ static void InnerLoop(CHle * hle, uint32_t outPtr, uint32_t inPtr, uint32_t t6, v18 = v6 + v8; // Clamp(v0); // Clamp(v18); - // clamp??? + // Clamp? *(int16_t *)(hle->mp3_buffer() + ((outPtr + 2)^S16)) = v0; *(int16_t *)(hle->mp3_buffer() + ((outPtr + 4)^S16)) = v18; outPtr += 4; diff --git a/Source/Android/PluginRSP/musyx.cpp b/Source/Android/PluginRSP/musyx.cpp index caea2554c..e78488b85 100644 --- a/Source/Android/PluginRSP/musyx.cpp +++ b/Source/Android/PluginRSP/musyx.cpp @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2013 Bobby Smiles // GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html @@ -252,7 +252,6 @@ void musyx_v2_task(CHle * hle) if (ptr_10) { - // TODO: hle->WarnMessage("ptr_10=%08x mask_14=%02x ptr_24=%08x", ptr_10, mask_14, ptr_24); } @@ -320,7 +319,7 @@ static void update_base_vol(CHle * hle, int32_t *base_vol, hle->VerboseMessage("base_vol voice_mask = %08x", voice_mask); hle->VerboseMessage("BEFORE: base_vol = %08x %08x %08x %08x", base_vol[0], base_vol[1], base_vol[2], base_vol[3]); - // optimization: skip voices contributions entirely if voice_mask is empty + // Optimization: skip voices contributions entirely if voice_mask is empty if (voice_mask != 0) { for (i = 0, mask = 1; i < MAX_VOICES; ++i, mask <<= 1, last_sample_ptr += 8) @@ -337,7 +336,7 @@ static void update_base_vol(CHle * hle, int32_t *base_vol, } } - // optimization: skip contributions entirely if mask_15 is empty + // Optimization: skip contributions entirely if mask_15 is empty if (mask_15 != 0) { for(i = 0, mask = 1; i < 4; ++i, mask <<= 1, ptr_24 += 8) @@ -846,7 +845,7 @@ static void interleave_stage_v1(CHle * hle, musyx_t *musyx, uint32_t output_ptr) int16_t *right; uint32_t *dst; - hle->VerboseMessage("interleave: %08x", output_ptr); + hle->VerboseMessage("Interleave: %08x", output_ptr); base_left = clamp_s16(musyx->base_vol[0]); base_right = clamp_s16(musyx->base_vol[1]); diff --git a/Source/Android/PluginRSP/ucodes.h b/Source/Android/PluginRSP/ucodes.h index 4b3a5788f..41fce0d3a 100644 --- a/Source/Android/PluginRSP/ucodes.h +++ b/Source/Android/PluginRSP/ucodes.h @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2014 Bobby Smiles // GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html diff --git a/Source/Common/IniFile.h b/Source/Common/IniFile.h index e8140095b..81005950f 100644 --- a/Source/Common/IniFile.h +++ b/Source/Common/IniFile.h @@ -72,10 +72,10 @@ private: std::string m_CurrentSection; bool m_CurrentSectionDirty; - int m_CurrentSectionFilePos; // Where in the file is the current section + int m_CurrentSectionFilePos; KeyValueList m_CurrentSectionData; - long m_lastSectionSearch; // When scanning for a section, what was the last scanned POS + long m_lastSectionSearch; bool m_ReadOnly; bool m_InstantFlush; diff --git a/Source/Common/Thread.cpp b/Source/Common/Thread.cpp index c492c0058..7b9f41b62 100644 --- a/Source/Common/Thread.cpp +++ b/Source/Common/Thread.cpp @@ -141,7 +141,7 @@ uint32_t CThread::GetCurrentThreadId(void) #ifdef _WIN32 return ::GetCurrentThreadId(); #elif defined(SYS_gettid) || defined(__NR_gettid) - return syscall(__NR_gettid); /* GLIBC has no implementation of gettid(). */ + return syscall(__NR_gettid); // GLIBC has no implementation of gettid() #else return gettid(); #endif diff --git a/Source/Common/Trace.cpp b/Source/Common/Trace.cpp index f434011fb..44bd23060 100644 --- a/Source/Common/Trace.cpp +++ b/Source/Common/Trace.cpp @@ -207,7 +207,7 @@ CTraceFileLog::CTraceFileLog(const char * FileName, bool FlushFile, CLog::LOG_OP m_hLogFile.SetTruncateFile(true); if (dwMaxFileSize < 3 || dwMaxFileSize > 2047) - { /* Clamp file size to 5 MB if it exceeds 2047 or falls short of 3. */ + { // Clamp file size to 5MB if it exceeds 2047 or falls short of 3 dwMaxFileSize = 5; } m_hLogFile.SetMaxFileSize((uint32_t)(dwMaxFileSize * MB)); diff --git a/Source/Common/Util.cpp b/Source/Common/Util.cpp index 2f60e5f93..169f001df 100644 --- a/Source/Common/Util.cpp +++ b/Source/Common/Util.cpp @@ -53,7 +53,7 @@ bool pjutil::TerminatedExistingExe() } if (!AskedUser) { - stdstr_f Message("%s currently running\n\nTerminate pid %d now?", ModuleName.c_str(), lppe.th32ProcessID); + stdstr_f Message("%s currently running\n\nTerminate PID %d now?", ModuleName.c_str(), lppe.th32ProcessID); stdstr_f Caption("Terminate %s", ModuleName.c_str()); AskedUser = true; @@ -73,7 +73,7 @@ bool pjutil::TerminatedExistingExe() } else { - stdstr_f Message("Failed to terminate pid %d", lppe.th32ProcessID); + stdstr_f Message("Failed to terminate PID %d", lppe.th32ProcessID); stdstr_f Caption("Terminate %s failed!", ModuleName.c_str()); MessageBox(nullptr, Message.ToUTF16().c_str(), Caption.ToUTF16().c_str(), MB_YESNO | MB_ICONEXCLAMATION); } diff --git a/Source/Common/md5.cpp b/Source/Common/md5.cpp index 9a9f368eb..0e1fe32d4 100644 --- a/Source/Common/md5.cpp +++ b/Source/Common/md5.cpp @@ -9,15 +9,15 @@ implied warranty of any kind. The translator/ modifier does not claim (1) that MD5 will do what you think it does; (2) that this translation/ modification is accurate; or (3) that -this software is "merchantable." (Language for this disclaimer partially -copied from the disclaimer below). +this software is "merchantable." (language for this disclaimer partially +copied from the disclaimer below) based on: MD5.H - header file for MD5C.C MDDRIVER.C - test driver for MD2, MD4 and MD5 -Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All rights reserved. +Copyright (C) 1991-1992, RSA Data Security, Inc. Created 1991. All rights reserved. License to copy and use this software is granted provided that it is identified as the "RSA Data Security, Inc. MD5 Message-Digest @@ -59,7 +59,7 @@ MD5::~MD5() void MD5::update(const uint1 *input, uint4 input_length) { uint4 input_index, buffer_index; - uint4 buffer_space; // How much space is left in the buffer + uint4 buffer_space; if (finalized) // So we can't update! { @@ -78,7 +78,7 @@ void MD5::update(const uint1 *input, uint4 input_length) count[1] += ((uint4)input_length >> 29); - buffer_space = 64 - buffer_index; // How much space is left in the buffer + buffer_space = 64 - buffer_index; // Transform as many times as possible if (input_length >= buffer_space) // i.e. we have enough to fill the buffer @@ -93,11 +93,11 @@ void MD5::update(const uint1 *input, uint4 input_length) transform((unsigned char *)(input + input_index)); } - buffer_index = 0; // So we can buffer remaining + buffer_index = 0; } else { - input_index = 0; // So we can buffer the whole input + input_index = 0; } // Here we do the buffering: @@ -246,7 +246,7 @@ const char *MD5::hex_digest() return m_hex_digest.c_str(); } -// PRIVATE METHODS: +// Private methods: void MD5::init() { diff --git a/Source/Common/md5.h b/Source/Common/md5.h index 55b0343b9..94e23cdd7 100644 --- a/Source/Common/md5.h +++ b/Source/Common/md5.h @@ -9,15 +9,15 @@ implied warranty of any kind. The translator/ modifier does not claim (1) that MD5 will do what you think it does; (2) that this translation/ modification is accurate; or (3) that -this software is "merchantable." (Language for this disclaimer partially -copied from the disclaimer below). +this software is "merchantable." (language for this disclaimer partially +copied from the disclaimer below) based on: MD5.H - header file for MD5C.C MDDRIVER.C - test driver for MD2, MD4 and MD5 -Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All rights reserved. +Copyright (C) 1991-1992, RSA Data Security, Inc. Created 1991. All rights reserved. License to copy and use this software is granted provided that it is identified as the "RSA Data Security, Inc. MD5 Message-Digest diff --git a/Source/Common/path.cpp b/Source/Common/path.cpp index 70042b9ce..3175851d8 100644 --- a/Source/Common/path.cpp +++ b/Source/Common/path.cpp @@ -233,7 +233,7 @@ CPath& CPath::operator =(const std::string& strPath) /* Post: Converts path to string Task: Convert path to string -Warning: because this pointer to string point in the data +Warning: Because this pointer to string point in the data of this class, it is possible to cast the result of this function in any non-constant pointer and alter the data. Very dangerous! @@ -281,7 +281,7 @@ Task: Return the individual components of this path. For any given argument, you can pass nullptr if you are not interested in that component. Do not rely on pNames being <= 8 characters, extensions -being <= 3 characters, or drives being 1 character +being <= 3 characters, or drives being 1 character. */ #ifdef _WIN32 @@ -922,7 +922,7 @@ Task: To determine if the directory exists, we need to create a test path with a wildcard (*.*) extension and see if FindFirstFile returns anything. We don't use CPath::FindFirst() because that routine parses out -'.' and '..', which fails for empty directories +'.' and '..', which fails for empty directories. */ bool CPath::DirectoryExists() const @@ -1041,10 +1041,10 @@ bool CPath::Delete(bool bEvenIfReadOnly) const /* Post: Return TRUE on success, false if there is such a target file -and we weren't granted permission to overwrite file or if we get an error +and we weren't granted permission to overwrite file or if we get an error. Task: Copy file Since ::CopyFile will not overwrite read-only files -we will make sure the target file is writable first +we will make sure the target file is writable first. */ bool CPath::CopyTo(const char * lpcszTargetFile, bool bOverwrite) @@ -1053,7 +1053,7 @@ bool CPath::CopyTo(const char * lpcszTargetFile, bool bOverwrite) { return false; } - WriteTrace(TracePath, TraceDebug, "copy \"%s\" to \"%s\"",m_strPath.c_str(),lpcszTargetFile); + WriteTrace(TracePath, TraceDebug, "Copy \"%s\" to \"%s\"",m_strPath.c_str(),lpcszTargetFile); #ifdef _WIN32 // Check if the target file exists CPath TargetFile(lpcszTargetFile); @@ -1164,7 +1164,7 @@ bool CPath::CopyTo(const char * lpcszTargetFile, bool bOverwrite) } // Post: Return TRUE on success, false if there is such a target file -// and we weren't granted permission to overwrite file or get an error +// and we weren't granted permission to overwrite file or get an error. // Task: Move file bool CPath::MoveTo(const char * lpcszTargetFile, bool bOverwrite) @@ -1228,7 +1228,7 @@ These attributes do not follow a simple additive logic. Note that FIND_ATTRIBUTE_FILES is 0x00, so it effectively cannot be removed from the attribute set. You will therefore always get normal files, and may also get Archive, Hidden, etc. -if you specify those attributes +if you specify those attributes. See also: FindFirstFile, FindNextFile */ @@ -1287,8 +1287,8 @@ bool CPath::FindFirst(uint32_t dwAttributes /*= FIND_ATTRIBUTE_FILES*/) return false; } -// Post : Return TRUE if a new match found -// Task : Find the next file that meets the conditions specified in the last FindFirst call +// Post: Return TRUE if a new match found +// Task: Find the next file that meets the conditions specified in the last FindFirst call bool CPath::FindNext() { @@ -1347,12 +1347,12 @@ bool CPath::FindNext() strcmp(pEntry->d_name,"..") == 0 || !wildcmp(m_FindWildcard.c_str(),pEntry->d_name)) { - WriteTrace(TracePath, TraceVerbose, "continue, d_name = %s",pEntry->d_name); + WriteTrace(TracePath, TraceVerbose, "Continue, d_name = %s",pEntry->d_name); continue; } if ((FIND_ATTRIBUTE_SUBDIR & dwFileAttributes) == FIND_ATTRIBUTE_SUBDIR) { - WriteTrace(TracePath, TraceVerbose, "is dir"); + WriteTrace(TracePath, TraceVerbose, "is a directory"); if (IsDirectory()) { // Found a directory @@ -1366,7 +1366,7 @@ bool CPath::FindNext() } else { - WriteTrace(TracePath, TraceVerbose, "is file"); + WriteTrace(TracePath, TraceVerbose, "is a file"); // Found a file if (IsDirectory()) { diff --git a/Source/Project64-audio/AudioMain.cpp b/Source/Project64-audio/AudioMain.cpp index 6b99c5598..b919b931d 100644 --- a/Source/Project64-audio/AudioMain.cpp +++ b/Source/Project64-audio/AudioMain.cpp @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64. // Copyright(C) 2015 Gilles Siberlin // Copyright(C) 2007-2009 Richard Goedeken diff --git a/Source/Project64-audio/Audio_1.1.h b/Source/Project64-audio/Audio_1.1.h index c7e9f45fa..e66fadfc6 100644 --- a/Source/Project64-audio/Audio_1.1.h +++ b/Source/Project64-audio/Audio_1.1.h @@ -56,7 +56,7 @@ typedef struct int32_t MemoryBswaped; // If this is set to TRUE, then the memory has been pre-bswap'd on a DWORD (32-bit) boundary // eg. the first 8 bytes are stored like this: - // 4 3 2 1 8 7 6 5 + // 4 3 2 1 8 7 6 5 uint8_t * HEADER; // This is the ROM header (first 40h bytes of the ROM) // This will be in the same memory format as the rest of the memory. uint8_t * RDRAM; @@ -77,99 +77,99 @@ typedef struct /* Function: AiDacrateChanged -Purpose: This function is called to notify the DLL that the +Purpose: This function is called to notify the DLL that the AiDacrate registers value has been changed. -input: The System type: +Input: The system type: SYSTEM_NTSC 0 SYSTEM_PAL 1 SYSTEM_MPAL 2 -output: none +Output: None */ EXPORT void CALL AiDacrateChanged(int32_t SystemType); /* Function: AiLenChanged -Purpose: This function is called to notify the DLL that the +Purpose: This function is called to notify the DLL that the AiLen registers value has been changed. -input: none -output: none +Input: None +Output: None */ EXPORT void CALL AiLenChanged(void); /* Function: AiReadLength -Purpose: This function is called to allow the DLL to return the +Purpose: This function is called to allow the DLL to return the value that AI_LEN_REG should equal -input: none -output: The amount of bytes still left to play. +Input: None +Output: The amount of bytes still left to play. */ EXPORT uint32_t CALL AiReadLength(void); /* Function: AiUpdate -Purpose: This function is called to allow the DLL to update +Purpose: This function is called to allow the DLL to update things on a regular basis (check how long to sound to go, copy more stuff to the buffer, anything you like). The function is designed to go in to the message loop of the main window...but can be placed anywhere you like. -input: if Wait is set to true, then this function should wait +Input: If wait is set to true, then this function should wait till there is a message in its message queue. -output: none +Output: None */ EXPORT void CALL AiUpdate(int32_t Wait); /* Function: CloseDLL -Purpose: This function is called when the emulator is closing +Purpose: This function is called when the emulator is closing down allowing the DLL to de-initialize. -input: none -output: none +Input: None +Output: None */ EXPORT void CALL CloseDLL(void); /* Function: DllAbout -Purpose: This function is optional function that is provided +Purpose: This function is optional function that is provided to give further information about the DLL. -input: a handle to the window that calls this function -output: none +Input: A handle to the window that calls this function. +Output: None */ EXPORT void CALL DllAbout(void * hParent); /* Function: DllConfig -Purpose: This function is optional function that is provided +Purpose: This function is optional function that is provided to allow the user to configure the DLL -input: a handle to the window that calls this function -output: none +Input: A handle to the window that calls this function +Output: None */ EXPORT void CALL DllConfig(void * hParent); /* Function: DllTest -Purpose: This function is optional function that is provided +Purpose: This function is optional function that is provided to allow the user to test the DLL -input: a handle to the window that calls this function -output: none +Input: A handle to the window that calls this function +Output: None */ EXPORT void CALL DllTest(void * hParent); /* Function: GetDllInfo -Purpose: This function allows the emulator to gather information +Purpose: This function allows the emulator to gather information about the DLL by filling in the PluginInfo structure. -input: a pointer to a PLUGIN_INFO structure that needs to be +Input: A pointer to a PLUGIN_INFO structure that needs to be filled by the function. (see def above) -output: none +Output: None */ EXPORT void CALL GetDllInfo(PLUGIN_INFO * PluginInfo); @@ -179,12 +179,11 @@ Function: InitiateSound Purpose: This function is called when the DLL is started to give information from the emulator that the N64 audio interface needs -Input: Audio_Info is passed to this function which is defined +Input: Audio_Info is passed to this function which is defined above. -Output: TRUE on success +Output: True on success FALSE on failure to initialize - -** Note on interrupts **: +Note on interrupts: To generate an interrupt set the appropriate bit in MI_INTR_REG and then call the function CheckInterrupts to tell the emulator that there is a waiting interrupt. @@ -194,20 +193,20 @@ EXPORT int32_t CALL InitiateAudio(AUDIO_INFO Audio_Info); /* Function: ProcessAList -Purpose: This function is called when there is a Alist to be +Purpose: This function is called when there is a Alist to be processed. The DLL will have to work out all the info about the AList itself. -input: none -output: none +Input: None +Output: None */ EXPORT void CALL ProcessAList(void); /* Function: RomClosed -Purpose: This function is called when a ROM is closed. -input: none -output: none +Purpose: This function is called when a ROM is closed. +Input: None +Output: None */ EXPORT void CALL RomClosed(void); diff --git a/Source/Project64-audio/Driver/DirectSound.cpp b/Source/Project64-audio/Driver/DirectSound.cpp index 013a530f0..f5a6e2214 100644 --- a/Source/Project64-audio/Driver/DirectSound.cpp +++ b/Source/Project64-audio/Driver/DirectSound.cpp @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64. // Copyright(C) 2000-2015 Azimer // GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html @@ -88,7 +88,7 @@ void DirectSoundDriver::StopAudio() m_AudioIsDone = true; if (WaitForSingleObject((HANDLE)m_handleAudioThread, 5000) == WAIT_TIMEOUT) { - WriteTrace(TraceAudioDriver, TraceError, "Time out on close"); + WriteTrace(TraceAudioDriver, TraceError, "Timeout on close"); TerminateThread((HANDLE)m_handleAudioThread, 1); } diff --git a/Source/Project64-audio/Driver/OpenSLES.cpp b/Source/Project64-audio/Driver/OpenSLES.cpp index 67454ba6e..772174800 100644 --- a/Source/Project64-audio/Driver/OpenSLES.cpp +++ b/Source/Project64-audio/Driver/OpenSLES.cpp @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64. // Copyright(C) 2015 Gilles Siberlin // Copyright(C) 2007 - 2009 Richard Goedeken @@ -45,7 +45,7 @@ enum { SECONDARY_BUFFER_NBR = 2 }; // This sets default frequency what is used if ROM doesn't want to change it. // Probably only game that needs this is Zelda: Ocarina Of Time Master Quest // TODO: We should try to find out why Demos' frequencies are always wrong -// They tend to rely on a default frequency, but apparently never the same one ;) +// They tend to rely on a default frequency, but apparently never the same one enum { DEFAULT_FREQUENCY = 33600 }; @@ -87,7 +87,7 @@ int g_OutputFreq = 44100; bool g_critical_failure = false; #ifdef ANDROID -// Thread Lock +// Thread lock threadLock g_lock; // Engine interfaces @@ -192,7 +192,7 @@ static void CloseAudio(void) g_engineEngine = nullptr; } - // Destroy thread Locks + // Destroy thread locks pthread_cond_signal(&(g_lock.cond)); pthread_mutex_unlock(&(g_lock.mutex)); pthread_cond_destroy(&(g_lock.cond)); @@ -379,7 +379,7 @@ void OpenSLESDriver::AI_SetFrequency(uint32_t freq, uint32_t BufferSize) if (g_critical_failure) { - WriteTrace(TraceAudioInitShutdown, TraceInfo, "Critical failure in setting up plugin, ignoring init..."); + WriteTrace(TraceAudioInitShutdown, TraceInfo, "Critical failure in setting up plugin, ignoring initialization..."); WriteTrace(TraceAudioInitShutdown, TraceDebug, "Done"); return; } @@ -437,7 +437,7 @@ void OpenSLESDriver::AI_SetFrequency(uint32_t freq, uint32_t BufferSize) } #ifdef ANDROID - // Create thread Locks to ensure synchronization between callback and processing code + // Create thread locks to ensure synchronization between callback and processing code if (pthread_mutex_init(&(g_lock.mutex), (pthread_mutexattr_t*)nullptr) != 0) { WriteTrace(TraceAudioInitShutdown, TraceError, "pthread_mutex_init failed"); diff --git a/Source/Project64-audio/Driver/OpenSLES.h b/Source/Project64-audio/Driver/OpenSLES.h index 274e5716a..8609aa499 100644 --- a/Source/Project64-audio/Driver/OpenSLES.h +++ b/Source/Project64-audio/Driver/OpenSLES.h @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64. // Copyright(C) 2015 Gilles Siberlin // Copyright(C) 2007 - 2009 Richard Goedeken diff --git a/Source/Project64-audio/Driver/SoundBase.cpp b/Source/Project64-audio/Driver/SoundBase.cpp index d2fb00a54..4f00e7234 100644 --- a/Source/Project64-audio/Driver/SoundBase.cpp +++ b/Source/Project64-audio/Driver/SoundBase.cpp @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2000-2015 Azimer // GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html @@ -119,7 +119,7 @@ void SoundDriverBase::LoadAiBuffer(uint8_t *start, uint32_t length) bool DMAEnabled = (*g_AudioInfo.AI_CONTROL_REG & AI_CONTROL_DMA_ON) == AI_CONTROL_DMA_ON; if (!DMAEnabled) { - WriteTrace(TraceAudioDriver, TraceVerbose, "Return silence -- DMA is disabled"); + WriteTrace(TraceAudioDriver, TraceVerbose, "Return silence - DMA is disabled"); memset(ptrStart, 0, bytesToMove); return; } diff --git a/Source/Project64-audio/Driver/SoundBase.h b/Source/Project64-audio/Driver/SoundBase.h index b6de81ede..5a8cc36a5 100644 --- a/Source/Project64-audio/Driver/SoundBase.h +++ b/Source/Project64-audio/Driver/SoundBase.h @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2000-2015 Azimer // GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html diff --git a/Source/Project64-core/AppInit.cpp b/Source/Project64-core/AppInit.cpp index dd46e319e..15612c6d6 100644 --- a/Source/Project64-core/AppInit.cpp +++ b/Source/Project64-core/AppInit.cpp @@ -196,7 +196,7 @@ static bool ParseCommand(int32_t argc, char **argv) } else { - WriteTrace(TraceAppInit, TraceError, "not enough parameters for '%d: %s'", i, argv[i]); + WriteTrace(TraceAppInit, TraceError, "Not enough parameters for '%d: %s'", i, argv[i]); return false; } } @@ -207,7 +207,7 @@ static bool ParseCommand(int32_t argc, char **argv) } else { - WriteTrace(TraceAppInit, TraceError, "unrecognized command-line parameter '%d: %s'", i, argv[i]); + WriteTrace(TraceAppInit, TraceError, "Unrecognized command-line parameter '%d: %s'", i, argv[i]); } } return false; @@ -222,17 +222,17 @@ bool AppInit(CNotification * Notify, const char * BaseDirectory, int argc, char WriteTrace(TraceAppInit, TraceDebug, "Starting (BaseDirectory: %s)", BaseDirectory ? BaseDirectory : "null"); if (Notify == nullptr) { - WriteTrace(TraceAppInit, TraceError, "No Notification class passed"); + WriteTrace(TraceAppInit, TraceError, "No notification class passed"); return false; } - WriteTrace(TraceAppInit, TraceDebug, "Settings up settings"); + WriteTrace(TraceAppInit, TraceDebug, "Setting up settings"); g_Settings = new CSettings; g_Settings->Initialize(BaseDirectory, AppName()); - WriteTrace(TraceAppInit, TraceDebug, "Parse Commands"); + WriteTrace(TraceAppInit, TraceDebug, "Parse commands"); if (!ParseCommand(argc, argv)) { - WriteTrace(TraceAppInit, TraceError, "Failed to Parse Commands, exiting now"); + WriteTrace(TraceAppInit, TraceError, "Failed to parse commands, exiting now"); return false; } @@ -254,33 +254,33 @@ bool AppInit(CNotification * Notify, const char * BaseDirectory, int argc, char #else if (!CMipsMemoryVM::SetupSegvHandler()) { - WriteTrace(TraceAppInit, TraceDebug, "Setup Segv Handler Failed"); + WriteTrace(TraceAppInit, TraceDebug, "Setup SEGV handler failed"); return false; } #endif g_Enhancements = new CEnhancements(); //Create the plugin container - WriteTrace(TraceAppInit, TraceInfo, "Create Plugins"); + WriteTrace(TraceAppInit, TraceInfo, "Create plugins"); g_Plugins = new CPlugins(Directory_Plugin, false); g_Lang = new CLanguage(); g_Lang->LoadCurrentStrings(); g_Notify->AppInitDone(); - WriteTrace(TraceAppInit, TraceDebug, "Initialized Successfully"); + WriteTrace(TraceAppInit, TraceDebug, "Initialized successfully"); return true; } catch (...) { g_Notify->DisplayError(stdstr_f("Exception caught\nFile: %s\nLine: %d", __FILE__, __LINE__).c_str()); - WriteTrace(TraceAppInit, TraceError, "Exception caught, Init was not successfull"); + WriteTrace(TraceAppInit, TraceError, "Exception caught, initialization was not successful"); return false; } } void AppCleanup(void) { - WriteTrace(TraceAppCleanup, TraceDebug, "cleaning up global objects"); + WriteTrace(TraceAppCleanup, TraceDebug, "Cleaning up global objects"); CleanupTrace(); if (g_Enhancements) { delete g_Enhancements; g_Enhancements = nullptr; } diff --git a/Source/Project64-core/MemoryExceptionFilter.cpp b/Source/Project64-core/MemoryExceptionFilter.cpp index 71b5d4dc6..0bcf878a8 100644 --- a/Source/Project64-core/MemoryExceptionFilter.cpp +++ b/Source/Project64-core/MemoryExceptionFilter.cpp @@ -188,7 +188,7 @@ bool CMipsMemoryVM::FilterX86Exception(uint32_t MemAddress, X86_CONTEXT & contex { if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("Failed to load byte\n\nMIPS Address: %08X\nX86 Address: %08X", MemAddress, (uint8_t *)*context.Eip).c_str()); + g_Notify->DisplayError(stdstr_f("Failed to load byte\n\nMIPS address: %08X\nX86 address: %08X", MemAddress, (uint8_t *)*context.Eip).c_str()); } } *context.Eip = (uint32_t)ReadPos; @@ -198,7 +198,7 @@ bool CMipsMemoryVM::FilterX86Exception(uint32_t MemAddress, X86_CONTEXT & contex { if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("Failed to load half word\n\nMIPS Address: %08X\nX86 Address: %08X", MemAddress, (uint8_t *)*context.Eip).c_str()); + g_Notify->DisplayError(stdstr_f("Failed to load half word\n\nMIPS address: %08X\nX86 address: %08X", MemAddress, (uint8_t *)*context.Eip).c_str()); } } *context.Eip = (uint32_t)ReadPos; @@ -208,7 +208,7 @@ bool CMipsMemoryVM::FilterX86Exception(uint32_t MemAddress, X86_CONTEXT & contex { if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("Failed to load byte\n\nMIPS Address: %08X\nX86 Address: %08X", MemAddress, (uint8_t *)*context.Eip).c_str()); + g_Notify->DisplayError(stdstr_f("Failed to load byte\n\nMIPS address: %08X\nX86 address: %08X", MemAddress, (uint8_t *)*context.Eip).c_str()); } } *context.Eip = (uint32_t)ReadPos; @@ -218,7 +218,7 @@ bool CMipsMemoryVM::FilterX86Exception(uint32_t MemAddress, X86_CONTEXT & contex { if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("Failed to load half word\n\nMIPS Address: %08X\nX86 Address: %08X", MemAddress, (uint8_t *)*context.Eip).c_str()); + g_Notify->DisplayError(stdstr_f("Failed to load half word\n\nMIPS address: %08X\nX86 address: %08X", MemAddress, (uint8_t *)*context.Eip).c_str()); } } *context.Eip = (uint32_t)ReadPos; @@ -239,7 +239,7 @@ bool CMipsMemoryVM::FilterX86Exception(uint32_t MemAddress, X86_CONTEXT & contex { if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("Failed to half word\n\nMIPS Address: %08X\nX86 Address: %08X", MemAddress, (uint8_t *)*context.Eip).c_str()); + g_Notify->DisplayError(stdstr_f("Failed to half word\n\nMIPS address: %08X\nX86 address: %08X", MemAddress, (uint8_t *)*context.Eip).c_str()); } } *context.Eip = (uint32_t)ReadPos; @@ -249,7 +249,7 @@ bool CMipsMemoryVM::FilterX86Exception(uint32_t MemAddress, X86_CONTEXT & contex { if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("Failed to store half word\n\nMIPS Address: %08X\nX86 Address: %08X", MemAddress, + g_Notify->DisplayError(stdstr_f("Failed to store half word\n\nMIPS address: %08X\nX86 address: %08X", MemAddress, (uint8_t *)*context.Eip).c_str()); } } @@ -268,7 +268,7 @@ bool CMipsMemoryVM::FilterX86Exception(uint32_t MemAddress, X86_CONTEXT & contex { if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("Failed to store half word\n\nMIPS Address: %08X\nX86 Address: %08X", MemAddress, (uint8_t *)*context.Eip).c_str()); + g_Notify->DisplayError(stdstr_f("Failed to store half word\n\nMIPS address: %08X\nX86 address: %08X", MemAddress, (uint8_t *)*context.Eip).c_str()); } } *context.Eip = (uint32_t)(ReadPos + 2); @@ -286,7 +286,7 @@ bool CMipsMemoryVM::FilterX86Exception(uint32_t MemAddress, X86_CONTEXT & contex { if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("Failed to store byte\n\nMIPS Address: %08X\nX86 Address: %08X", MemAddress, (uint8_t *)*context.Eip).c_str()); + g_Notify->DisplayError(stdstr_f("Failed to store byte\n\nMIPS address: %08X\nX86 address: %08X", MemAddress, (uint8_t *)*context.Eip).c_str()); } } *context.Eip = (uint32_t)ReadPos; @@ -296,7 +296,7 @@ bool CMipsMemoryVM::FilterX86Exception(uint32_t MemAddress, X86_CONTEXT & contex { if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("Failed to load byte\n\nMIPS Address: %08X\nX86 Address: %08X", MemAddress, (uint8_t *)*context.Eip).c_str()); + g_Notify->DisplayError(stdstr_f("Failed to load byte\n\nMIPS address: %08X\nX86 address: %08X", MemAddress, (uint8_t *)*context.Eip).c_str()); } } *context.Eip = (uint32_t)ReadPos; @@ -306,7 +306,7 @@ bool CMipsMemoryVM::FilterX86Exception(uint32_t MemAddress, X86_CONTEXT & contex { if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("Failed to load word\n\nMIPS Address: %08X\nX86 Address: %08X", MemAddress, (uint8_t *)*context.Eip).c_str()); + g_Notify->DisplayError(stdstr_f("Failed to load word\n\nMIPS address: %08X\nX86 address: %08X", MemAddress, (uint8_t *)*context.Eip).c_str()); } } *context.Eip = (uint32_t)ReadPos; @@ -316,7 +316,7 @@ bool CMipsMemoryVM::FilterX86Exception(uint32_t MemAddress, X86_CONTEXT & contex { if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("Failed to store word\n\nMIPS Address: %08X\nX86 Address: %08X", MemAddress, (uint8_t *)*context.Eip).c_str()); + g_Notify->DisplayError(stdstr_f("Failed to store word\n\nMIPS address: %08X\nX86 address: %08X", MemAddress, (uint8_t *)*context.Eip).c_str()); } } *context.Eip = (uint32_t)ReadPos; @@ -334,7 +334,7 @@ bool CMipsMemoryVM::FilterX86Exception(uint32_t MemAddress, X86_CONTEXT & contex { if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("Failed to store byte\n\nMIPS Address: %08X\nX86 Address: %08X", MemAddress, (uint8_t *)*context.Eip).c_str()); + g_Notify->DisplayError(stdstr_f("Failed to store byte\n\nMIPS address: %08X\nX86 address: %08X", MemAddress, (uint8_t *)*context.Eip).c_str()); } } *context.Eip = (uint32_t)(ReadPos + 1); @@ -352,7 +352,7 @@ bool CMipsMemoryVM::FilterX86Exception(uint32_t MemAddress, X86_CONTEXT & contex { if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("Failed to store word\n\nMIPS Address: %08X\nX86 Address: %08X", MemAddress, (uint8_t *)*context.Eip).c_str()); + g_Notify->DisplayError(stdstr_f("Failed to store word\n\nMIPS address: %08X\nX86 address: %08X", MemAddress, (uint8_t *)*context.Eip).c_str()); } } *context.Eip = (uint32_t)(ReadPos + 4); @@ -371,7 +371,7 @@ void CMipsMemoryVM::DumpArmExceptionInfo(uint32_t MemAddress, mcontext_t & conte { ArmThumbOpcode * OpCode = (ArmThumbOpcode *)context.arm_pc; Arm32Opcode * OpCode32 = (Arm32Opcode *)context.arm_pc; - WriteTrace(TraceExceptionHandler, TraceError, "Program Counter 0x%lx", g_Reg->m_PROGRAM_COUNTER); + WriteTrace(TraceExceptionHandler, TraceError, "Program counter 0x%lx", g_Reg->m_PROGRAM_COUNTER); for (int i = 0, n = (sizeof(g_BaseSystem->m_LastSuccessSyncPC) / sizeof(g_BaseSystem->m_LastSuccessSyncPC[0])); i < n; i++) { WriteTrace(TraceExceptionHandler, TraceError, "m_LastSuccessSyncPC[%d] = 0x%lx", i, g_BaseSystem->m_LastSuccessSyncPC[i]); @@ -467,7 +467,7 @@ bool CMipsMemoryVM::FilterArmException(uint32_t MemAddress, mcontext_t & context { if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("Failed to load word\n\nMIPS Address: %08X\nPC Address: %08X", MemAddress, context.arm_pc).c_str()); + g_Notify->DisplayError(stdstr_f("Failed to load word\n\nMIPS address: %08X\nPC address: %08X", MemAddress, context.arm_pc).c_str()); } } context.arm_pc = context.arm_pc + 2; @@ -479,7 +479,7 @@ bool CMipsMemoryVM::FilterArmException(uint32_t MemAddress, mcontext_t & context { if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("Failed to store word\n\nMIPS Address: %08X\nPC Address: %08X", MemAddress, context.arm_pc).c_str()); + g_Notify->DisplayError(stdstr_f("Failed to store word\n\nMIPS address: %08X\nPC address: %08X", MemAddress, context.arm_pc).c_str()); } } context.arm_pc = context.arm_pc + 2; @@ -493,7 +493,7 @@ bool CMipsMemoryVM::FilterArmException(uint32_t MemAddress, mcontext_t & context { if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("Failed to store word\n\nMIPS Address: %08X\nPC Address: %08X", MemAddress, context.arm_pc).c_str()); + g_Notify->DisplayError(stdstr_f("Failed to store word\n\nMIPS address: %08X\nPC address: %08X", MemAddress, context.arm_pc).c_str()); } } context.arm_pc = context.arm_pc + 4; @@ -507,7 +507,7 @@ bool CMipsMemoryVM::FilterArmException(uint32_t MemAddress, mcontext_t & context { if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("Failed to store word\n\nMIPS Address: %08X\nPC Address: %08X", MemAddress, context.arm_pc).c_str()); + g_Notify->DisplayError(stdstr_f("Failed to store word\n\nMIPS address: %08X\nPC address: %08X", MemAddress, context.arm_pc).c_str()); } } context.arm_pc = context.arm_pc + 4; @@ -521,7 +521,7 @@ bool CMipsMemoryVM::FilterArmException(uint32_t MemAddress, mcontext_t & context { if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("Failed to load word\n\nMIPS Address: %08X\nPC Address: %08X", MemAddress, context.arm_pc).c_str()); + g_Notify->DisplayError(stdstr_f("Failed to load word\n\nMIPS address: %08X\nPC address: %08X", MemAddress, context.arm_pc).c_str()); } } context.arm_pc = context.arm_pc + 4; @@ -536,7 +536,7 @@ bool CMipsMemoryVM::FilterArmException(uint32_t MemAddress, mcontext_t & context { if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("Failed to store word\n\nMIPS Address: %08X\nPC Address: %08X", MemAddress, context.arm_pc).c_str()); + g_Notify->DisplayError(stdstr_f("Failed to store word\n\nMIPS address: %08X\nPC address: %08X", MemAddress, context.arm_pc).c_str()); } } context.arm_pc = context.arm_pc + 4; @@ -549,7 +549,7 @@ bool CMipsMemoryVM::FilterArmException(uint32_t MemAddress, mcontext_t & context { if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("Failed to store byte\n\nMIPS Address: %08X\nPC Address: %08X", MemAddress, context.arm_pc).c_str()); + g_Notify->DisplayError(stdstr_f("Failed to store byte\n\nMIPS address: %08X\nPC address: %08X", MemAddress, context.arm_pc).c_str()); } } context.arm_pc = context.arm_pc + 2; @@ -563,7 +563,7 @@ bool CMipsMemoryVM::FilterArmException(uint32_t MemAddress, mcontext_t & context { if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("Failed to store byte\n\nMIPS Address: %08X\nPC Address: %08X", MemAddress, context.arm_pc).c_str()); + g_Notify->DisplayError(stdstr_f("Failed to store byte\n\nMIPS address: %08X\nPC address: %08X", MemAddress, context.arm_pc).c_str()); } } context.arm_pc = context.arm_pc + 4; @@ -577,7 +577,7 @@ bool CMipsMemoryVM::FilterArmException(uint32_t MemAddress, mcontext_t & context { if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("Failed to store half word\n\nMIPS Address: %08X\nPC Address: %08X", MemAddress, context.arm_pc).c_str()); + g_Notify->DisplayError(stdstr_f("Failed to store half word\n\nMIPS address: %08X\nPC address: %08X", MemAddress, context.arm_pc).c_str()); } } context.arm_pc = context.arm_pc + 4; @@ -591,7 +591,7 @@ bool CMipsMemoryVM::FilterArmException(uint32_t MemAddress, mcontext_t & context { if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("Failed to store half word\n\nMIPS Address: %08X\nPC Address: %08X", MemAddress, context.arm_pc).c_str()); + g_Notify->DisplayError(stdstr_f("Failed to store half word\n\nMIPS address: %08X\nPC address: %08X", MemAddress, context.arm_pc).c_str()); } } context.arm_pc = context.arm_pc + 2; @@ -605,7 +605,7 @@ bool CMipsMemoryVM::FilterArmException(uint32_t MemAddress, mcontext_t & context { if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("Failed to store half word\n\nMIPS Address: %08X\nPC Address: %08X", MemAddress, context.arm_pc).c_str()); + g_Notify->DisplayError(stdstr_f("Failed to store half word\n\nMIPS address: %08X\nPC address: %08X", MemAddress, context.arm_pc).c_str()); } } context.arm_pc = context.arm_pc + 2; @@ -619,7 +619,7 @@ bool CMipsMemoryVM::FilterArmException(uint32_t MemAddress, mcontext_t & context { if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("Failed to store word\n\nMIPS Address: %08X\nPC Address: %08X", MemAddress, context.arm_pc).c_str()); + g_Notify->DisplayError(stdstr_f("Failed to store word\n\nMIPS address: %08X\nPC address: %08X", MemAddress, context.arm_pc).c_str()); } } context.arm_pc = context.arm_pc + 2; @@ -633,7 +633,7 @@ bool CMipsMemoryVM::FilterArmException(uint32_t MemAddress, mcontext_t & context { if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("Failed to load word\n\nMIPS Address: %08X\nPC Address: %08X", MemAddress, context.arm_pc).c_str()); + g_Notify->DisplayError(stdstr_f("Failed to load word\n\nMIPS address: %08X\nPC address: %08X", MemAddress, context.arm_pc).c_str()); } } context.arm_pc = context.arm_pc + 2; @@ -647,7 +647,7 @@ bool CMipsMemoryVM::FilterArmException(uint32_t MemAddress, mcontext_t & context { if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("Failed to store byte\n\nMIPS Address: %08X\nPC Address: %08X", MemAddress, context.arm_pc).c_str()); + g_Notify->DisplayError(stdstr_f("Failed to store byte\n\nMIPS address: %08X\nPC address: %08X", MemAddress, context.arm_pc).c_str()); } } context.arm_pc = context.arm_pc + 2; @@ -661,7 +661,7 @@ bool CMipsMemoryVM::FilterArmException(uint32_t MemAddress, mcontext_t & context { if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("Failed to store half word\n\nMIPS Address: %08X\nPC Address: %08X", MemAddress, context.arm_pc).c_str()); + g_Notify->DisplayError(stdstr_f("Failed to store half word\n\nMIPS address: %08X\nPC address: %08X", MemAddress, context.arm_pc).c_str()); } } context.arm_pc = context.arm_pc + 4; @@ -675,7 +675,7 @@ bool CMipsMemoryVM::FilterArmException(uint32_t MemAddress, mcontext_t & context { if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("Failed to store word\n\nMIPS Address: %08X\nPC Address: %08X", MemAddress, context.arm_pc).c_str()); + g_Notify->DisplayError(stdstr_f("Failed to store word\n\nMIPS address: %08X\nPC address: %08X", MemAddress, context.arm_pc).c_str()); } } context.arm_pc = context.arm_pc + 4; @@ -689,7 +689,7 @@ bool CMipsMemoryVM::FilterArmException(uint32_t MemAddress, mcontext_t & context { if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("Failed to load half word\n\nMIPS Address: %08X\nPC Address: %08X", MemAddress, context.arm_pc).c_str()); + g_Notify->DisplayError(stdstr_f("Failed to load half word\n\nMIPS address: %08X\nPC address: %08X", MemAddress, context.arm_pc).c_str()); } } context.arm_pc = context.arm_pc + 4; @@ -703,7 +703,7 @@ bool CMipsMemoryVM::FilterArmException(uint32_t MemAddress, mcontext_t & context { if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("Failed to load half word\n\nMIPS Address: %08X\nPC Address: %08X", MemAddress, context.arm_pc).c_str()); + g_Notify->DisplayError(stdstr_f("Failed to load half word\n\nMIPS address: %08X\nPC address: %08X", MemAddress, context.arm_pc).c_str()); } } context.arm_pc = context.arm_pc + 4; @@ -718,7 +718,7 @@ bool CMipsMemoryVM::FilterArmException(uint32_t MemAddress, mcontext_t & context { if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("Failed to load half word\n\nMIPS Address: %08X\nPC Address: %08X", MemAddress, context.arm_pc).c_str()); + g_Notify->DisplayError(stdstr_f("Failed to load half word\n\nMIPS address: %08X\nPC address: %08X", MemAddress, context.arm_pc).c_str()); } } context.arm_pc = context.arm_pc + 4; @@ -732,7 +732,7 @@ bool CMipsMemoryVM::FilterArmException(uint32_t MemAddress, mcontext_t & context { if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("Failed to load word\n\nMIPS Address: %08X\nPC Address: %08X", MemAddress, context.arm_pc).c_str()); + g_Notify->DisplayError(stdstr_f("Failed to load word\n\nMIPS address: %08X\nPC address: %08X", MemAddress, context.arm_pc).c_str()); } } context.arm_pc = context.arm_pc + 4; @@ -746,7 +746,7 @@ bool CMipsMemoryVM::FilterArmException(uint32_t MemAddress, mcontext_t & context { if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("Failed to load word\n\nMIPS Address: %08X\nPC Address: %08X", MemAddress, context.arm_pc).c_str()); + g_Notify->DisplayError(stdstr_f("Failed to load word\n\nMIPS address: %08X\nPC address: %08X", MemAddress, context.arm_pc).c_str()); } } context.arm_pc = context.arm_pc + 4; diff --git a/Source/Project64-core/Multilanguage.h b/Source/Project64-core/Multilanguage.h index 6a0ec58e5..80eec5f32 100644 --- a/Source/Project64-core/Multilanguage.h +++ b/Source/Project64-core/Multilanguage.h @@ -4,7 +4,7 @@ enum LanguageStringID { EMPTY_STRING = 0, - // Meta Information + // Meta information // About DLL LANGUAGE_NAME = 1, @@ -110,7 +110,7 @@ enum LanguageStringID MENU_SLOT_10 = 200, MENU_SLOT_SAVE = 201, - // Pop up menu + // Pop-up menu POPUP_PLAY = 210, POPUP_INFO = 211, POPUP_SETTINGS = 212, @@ -171,7 +171,6 @@ enum LanguageStringID MENUDES_GAME_SETTINGS = 285, MENUDES_GAME_CHEATS = 286, - // ROM browser // ROM browser fields @@ -197,7 +196,6 @@ enum LanguageStringID RB_FILE_FORMAT = 319, RB_NAME = 321, - // Select ROM SELECT_ROM_DIR = 320, diff --git a/Source/Project64-core/Multilanguage/Language.cpp b/Source/Project64-core/Multilanguage/Language.cpp index b6ef06215..69fe7dac9 100644 --- a/Source/Project64-core/Multilanguage/Language.cpp +++ b/Source/Project64-core/Multilanguage/Language.cpp @@ -373,7 +373,7 @@ void CLanguage::LoadDefaultStrings(void) DEF_STR(DISKSAVE_SHADOW, "Full Disk Copy"); DEF_STR(DISKSAVE_RAM, "Save Area Only"); - // ROM Information + // ROM information // ROM info title DEF_STR(INFO_TITLE, "ROM Information"); @@ -434,7 +434,7 @@ void CLanguage::LoadDefaultStrings(void) DEF_STR(CHEAT_CHANGED_MSG, "Cheat has been changed.\n\nDo you want to update?"); DEF_STR(CHEAT_CHANGED_TITLE, "Cheat updated"); - // Cheat Pop-up menu + // Cheat pop-up menu DEF_STR(CHEAT_ADDNEW, "Add New Cheat..."); DEF_STR(CHEAT_EDIT, "Edit"); DEF_STR(CHEAT_DELETE, "Delete"); diff --git a/Source/Project64-core/N64System/EmulationThread.cpp b/Source/Project64-core/N64System/EmulationThread.cpp index bc6fdcbc0..8348e3045 100644 --- a/Source/Project64-core/N64System/EmulationThread.cpp +++ b/Source/Project64-core/N64System/EmulationThread.cpp @@ -44,7 +44,7 @@ void CN64System::CloseCpu() m_EndEmulation = true; if (g_Settings->LoadBool(GameRunning_CPU_Paused)) { - WriteTrace(TraceN64System, TraceDebug, "Resume cpu"); + WriteTrace(TraceN64System, TraceDebug, "Resume CPU"); m_hPauseEvent.Trigger(); } diff --git a/Source/Project64-core/N64System/Enhancement/Enhancement.cpp b/Source/Project64-core/N64System/Enhancement/Enhancement.cpp index 21e642ca9..2277154b4 100644 --- a/Source/Project64-core/N64System/Enhancement/Enhancement.cpp +++ b/Source/Project64-core/N64System/Enhancement/Enhancement.cpp @@ -145,7 +145,7 @@ CEnhancement::CEnhancement(const char * Ident, const char * Entry) : m_Name = &(Lines[0][CurrentLine]); m_NameAndExtension = m_Name; - //key=value + // Key=value while (CurrentLine < Lines.size()) { const char * Pos = strchr(Lines[CurrentLine].c_str(), '='); @@ -189,7 +189,7 @@ CEnhancement::CEnhancement(const char * Ident, const char * Entry) : } } - //Gameshark Code + // Gameshark code while (CurrentLine < Lines.size()) { char TempFormat[128] = { 0 }; @@ -231,7 +231,7 @@ CEnhancement::CEnhancement(const char * Ident, const char * Entry) : m_Entries.push_back(GSEntry); } - //Options + // Options uint32_t OptionSize = 0; while (CurrentLine < Lines.size()) { diff --git a/Source/Project64-core/N64System/Enhancement/EnhancementFile.cpp b/Source/Project64-core/N64System/Enhancement/EnhancementFile.cpp index d812dd5cc..a56246cd6 100644 --- a/Source/Project64-core/N64System/Enhancement/EnhancementFile.cpp +++ b/Source/Project64-core/N64System/Enhancement/EnhancementFile.cpp @@ -164,7 +164,7 @@ bool CEnhancmentFile::MoveToSection(const char * Section, bool ChangeCurrentSect } std::unique_ptr Data; - char *Input = nullptr; + char * Input = nullptr; int MaxDataSize = 0, DataSize = 0, ReadPos = 0, result; FILELOC_ITR iter = m_SectionsPos.find(std::string(Section)); @@ -183,7 +183,7 @@ bool CEnhancmentFile::MoveToSection(const char * Section, bool ChangeCurrentSect { m_File.Seek(m_lastSectionSearch, CFileBase::begin); - //long Fpos; + // Long Fpos; uint8_t pUTF8[3]; pUTF8[0] = 0xef; pUTF8[1] = 0xbb; @@ -195,7 +195,7 @@ bool CEnhancmentFile::MoveToSection(const char * Section, bool ChangeCurrentSect if (result <= 1) { continue; } if (strlen(CleanLine(Input)) <= 1) { continue; } - //We Only care about sections + // We only care about sections char * CurrentSection = Input; if (m_lastSectionSearch == 0 && !memcmp(CurrentSection, pUTF8, 3)) @@ -206,7 +206,7 @@ bool CEnhancmentFile::MoveToSection(const char * Section, bool ChangeCurrentSect if (CurrentSection[0] != '[') { continue; } int lineEndPos = (int)strlen(CurrentSection) - 1; if (CurrentSection[lineEndPos] != ']') { continue; } - //take off the ']' from the end of the string + // Take off the ']' from the end of the string CurrentSection[lineEndPos] = 0; CurrentSection += 1; m_lastSectionSearch = (m_File.GetPosition() - DataSize) + ReadPos; @@ -385,9 +385,9 @@ void CEnhancmentFile::SaveCurrentSection(void) int MaxDataSize = 0, DataSize = 0, ReadPos = 0, result; std::unique_ptr Data; - char *Input = nullptr; + char * Input = nullptr; - //Skip first line as it is the section name + // Skip first line as it is the section name int StartPos = m_CurrentSectionFilePos; int EndPos = StartPos; do @@ -457,7 +457,7 @@ int CEnhancmentFile::GetStringFromFile(char * & String, std::unique_ptr & } else { - //Increase buffer size + // Increase buffer size int NewMaxDataSize = MaxDataSize + BufferIncrease; char * NewBuffer = new char[NewMaxDataSize]; if (NewBuffer == nullptr) @@ -491,7 +491,7 @@ const char * CEnhancmentFile::CleanLine(char * Line) { char * Pos = Line; - //Remove any comment from the line + // Remove any comment from the line while (Pos != nullptr) { Pos = strchr(Pos, '/'); @@ -524,7 +524,7 @@ const char * CEnhancmentFile::CleanLine(char * Line) } } - //strip any spaces or line feeds from the end of the line + // Strip any spaces or line feeds from the end of the line for (int32_t i = (int32_t)strlen(&Line[0]) - 1; i >= 0; i--) { if (Line[i] != ' ' && Line[i] != '\r') @@ -620,4 +620,3 @@ void CEnhancmentFile::ClearSectionPosList(long FilePos) m_lastSectionSearch = FilePos; } } - diff --git a/Source/Project64-core/N64System/Enhancement/Enhancements.cpp b/Source/Project64-core/N64System/Enhancement/Enhancements.cpp index 918c00983..c1b971ccb 100644 --- a/Source/Project64-core/N64System/Enhancement/Enhancements.cpp +++ b/Source/Project64-core/N64System/Enhancement/Enhancements.cpp @@ -411,7 +411,7 @@ void CEnhancements::ApplyGameSharkCodes(CMipsMemoryVM & MMU, CODES & CodeEntry, switch (Code.Command() & 0xFF000000) { - case 0x50000000: // Gameshark / AR + case 0x50000000: // Gameshark / Action Replay if ((CurrentEntry + 1) >= (int)CodeEntry.size()) { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -532,7 +532,7 @@ void CEnhancements::ApplyGameSharkCodes(CMipsMemoryVM & MMU, CODES & CodeEntry, case 0x89000000: case 0xA8000000: case 0xA9000000: - //Ignore - GS Button + // Ignore - Gameshark (GS) button break; default: g_Notify->BreakPoint(__FILE__, __LINE__); @@ -681,7 +681,7 @@ void CEnhancements::ScanFileThread(void) { do { - CEnhancmentFile EnhancmentFile(File, "Enhancment"); + CEnhancmentFile EnhancmentFile(File, CEnhancement::EnhancementIdent); CEnhancmentFile::SectionList Sections; EnhancmentFile.GetSections(Sections); for (CEnhancmentFile::SectionList::const_iterator itr = Sections.begin(); itr != Sections.end(); itr++) @@ -699,7 +699,7 @@ void CEnhancements::ScanFileThread(void) { do { - CEnhancmentFile EnhancmentFile(File, "Enhancment"); + CEnhancmentFile EnhancmentFile(File, CEnhancement::EnhancementIdent); CEnhancmentFile::SectionList Sections; EnhancmentFile.GetSections(Sections); for (CEnhancmentFile::SectionList::const_iterator itr = Sections.begin(); itr != Sections.end(); itr++) diff --git a/Source/Project64-core/N64System/FramePerSecond.h b/Source/Project64-core/N64System/FramePerSecond.h index 1d815b40e..2c3d26df1 100644 --- a/Source/Project64-core/N64System/FramePerSecond.h +++ b/Source/Project64-core/N64System/FramePerSecond.h @@ -32,7 +32,7 @@ private: int32_t m_ViFrameRateWhole; uint32_t m_ViFrameRateFraction; - //Dlist + // Dlist HighResTimeStamp m_LastDlistFrame; uint64_t m_FramesDlist[NoOfFrames]; uint32_t m_CurrentDlistFrame; diff --git a/Source/Project64-core/N64System/Interpreter/InterpreterCPU.cpp b/Source/Project64-core/N64System/Interpreter/InterpreterCPU.cpp index 950649cb5..6c18014f4 100644 --- a/Source/Project64-core/N64System/Interpreter/InterpreterCPU.cpp +++ b/Source/Project64-core/N64System/Interpreter/InterpreterCPU.cpp @@ -88,7 +88,7 @@ bool DelaySlotEffectsCompare(uint32_t PC, uint32_t Reg1, uint32_t Reg2) default: if (CDebugSettings::HaveDebugger()) { - g_Notify->DisplayError(stdstr_f("Does %s effect Delay slot at %X?", R4300iOpcodeName(Command.Hex, PC + 4), PC).c_str()); + g_Notify->DisplayError(stdstr_f("Does %s effect delay slot at %X?", R4300iOpcodeName(Command.Hex, PC + 4), PC).c_str()); } return true; } @@ -119,7 +119,7 @@ bool DelaySlotEffectsCompare(uint32_t PC, uint32_t Reg1, uint32_t Reg2) default: if (CDebugSettings::HaveDebugger()) { - g_Notify->DisplayError(stdstr_f("Does %s effect Delay slot at %X?\n6", R4300iOpcodeName(Command.Hex, PC + 4), PC).c_str()); + g_Notify->DisplayError(stdstr_f("Does %s effect delay slot at %X?\n6", R4300iOpcodeName(Command.Hex, PC + 4), PC).c_str()); } return true; } @@ -128,7 +128,7 @@ bool DelaySlotEffectsCompare(uint32_t PC, uint32_t Reg1, uint32_t Reg2) { if (CDebugSettings::HaveDebugger()) { - g_Notify->DisplayError(stdstr_f("Does %s effect Delay slot at %X?\n7", R4300iOpcodeName(Command.Hex, PC + 4), PC).c_str()); + g_Notify->DisplayError(stdstr_f("Does %s effect delay slot at %X?\n7", R4300iOpcodeName(Command.Hex, PC + 4), PC).c_str()); } return true; } @@ -157,7 +157,7 @@ bool DelaySlotEffectsCompare(uint32_t PC, uint32_t Reg1, uint32_t Reg2) default: if (CDebugSettings::HaveDebugger()) { - g_Notify->DisplayError(stdstr_f("Does %s effect Delay slot at %X?", R4300iOpcodeName(Command.Hex, PC + 4), PC).c_str()); + g_Notify->DisplayError(stdstr_f("Does %s effect delay slot at %X?", R4300iOpcodeName(Command.Hex, PC + 4), PC).c_str()); } return true; } @@ -205,7 +205,7 @@ bool DelaySlotEffectsCompare(uint32_t PC, uint32_t Reg1, uint32_t Reg2) default: if (CDebugSettings::HaveDebugger()) { - g_Notify->DisplayError(stdstr_f("Does %s effect Delay slot at %X?", R4300iOpcodeName(Command.Hex, PC + 4), PC).c_str()); + g_Notify->DisplayError(stdstr_f("Does %s effect delay slot at %X?", R4300iOpcodeName(Command.Hex, PC + 4), PC).c_str()); } return true; } @@ -230,13 +230,13 @@ void CInterpreterCPU::BuildCPU() void CInterpreterCPU::InPermLoop() { - // *** Changed ***/ + // Changed //if (CPU_Type == CPU_SyncCores) //{ // SyncRegisters.CP0[9] +=5; //} - /* Interrupts enabled */ + // Interrupts enabled if ((g_Reg->STATUS_REGISTER & STATUS_IE) == 0 || (g_Reg->STATUS_REGISTER & STATUS_EXL) != 0 || (g_Reg->STATUS_REGISTER & STATUS_ERL) != 0 || @@ -294,7 +294,7 @@ void CInterpreterCPU::ExecuteCPU() g_Settings->SaveBool(Debugger_SteppingOps, true); } - g_Debugger->CPUStepStarted(); // may set stepping ops/skip op + g_Debugger->CPUStepStarted(); // May set stepping ops/skip op if (isStepping()) { @@ -320,7 +320,7 @@ void CInterpreterCPU::ExecuteCPU() } */ m_R4300i_Opcode[Opcode.op](); - _GPR[0].DW = 0; /* MIPS $zero hard-wired to 0 */ + _GPR[0].DW = 0; // MIPS $zero hard-wired to 0 NextTimer -= CountPerOp; if (CDebugSettings::HaveDebugger()) { g_Debugger->CPUStepEnded(); } diff --git a/Source/Project64-core/N64System/Interpreter/InterpreterOps.cpp b/Source/Project64-core/N64System/Interpreter/InterpreterOps.cpp index db91b1b83..637f8a500 100644 --- a/Source/Project64-core/N64System/Interpreter/InterpreterOps.cpp +++ b/Source/Project64-core/N64System/Interpreter/InterpreterOps.cpp @@ -739,7 +739,8 @@ void TestInterpreterJump(uint32_t PC, uint32_t TargetPC, int32_t Reg1, int32_t R R4300iOp::m_TestTimer = true; } -/************************* Opcode functions *************************/ +// Opcode functions + void R4300iOp::J() { m_NextInstruction = DELAY_SLOT; @@ -1686,7 +1687,9 @@ void R4300iOp::SD() TLB_WRITE_EXCEPTION(Address); } } -/********************** R4300i OpCodes: Special **********************/ + +// R4300i opcodes: Special + void R4300iOp::SPECIAL_SLL() { _GPR[m_Opcode.rd].DW = (_GPR[m_Opcode.rt].W[0] << m_Opcode.sa); @@ -1810,7 +1813,7 @@ void R4300iOp::SPECIAL_DIV() { if (bShowDivByZero()) { - g_Notify->DisplayError("DIV by 0 ???"); + g_Notify->DisplayError("DIV by 0"); } _RegLO->DW = 0; _RegHI->DW = 0; @@ -1828,7 +1831,7 @@ void R4300iOp::SPECIAL_DIVU() { if (bShowDivByZero()) { - g_Notify->DisplayError("DIVU by 0 ???"); + g_Notify->DisplayError("DIVU by 0"); } _RegLO->DW = 0; _RegHI->DW = 0; @@ -1874,7 +1877,7 @@ void R4300iOp::SPECIAL_DDIV() { if (HaveDebugger()) { - g_Notify->DisplayError("DDIV by 0 ???"); + g_Notify->DisplayError("DDIV by 0"); } } } @@ -1890,7 +1893,7 @@ void R4300iOp::SPECIAL_DDIVU() { if (HaveDebugger()) { - g_Notify->DisplayError("DDIVU by 0 ???"); + g_Notify->DisplayError("DDIVU by 0"); } } } @@ -2063,7 +2066,8 @@ void R4300iOp::SPECIAL_DSRA32() _GPR[m_Opcode.rd].DW = (_GPR[m_Opcode.rt].DW >> (m_Opcode.sa + 32)); } -/********************** R4300i OpCodes: RegImm **********************/ +// R4300i opcodes: RegImm + void R4300iOp::REGIMM_BLTZ() { m_NextInstruction = DELAY_SLOT; @@ -2256,12 +2260,13 @@ void R4300iOp::REGIMM_TNEI() } } -/************************** COP0 functions **************************/ +// COP0 functions + void R4300iOp::COP0_MF() { if (LogCP0reads()) { - LogMessage("%08X: R4300i Read from %s (0x%08X)", (*_PROGRAM_COUNTER), CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); + LogMessage("%08X: R4300i read from %s (0x%08X)", (*_PROGRAM_COUNTER), CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); } if (m_Opcode.rd == 9) @@ -2275,8 +2280,8 @@ void R4300iOp::COP0_MT() { if (LogCP0changes()) { - LogMessage("%08X: Writing 0x%X to %s register (Originally: 0x%08X)", (*_PROGRAM_COUNTER), _GPR[m_Opcode.rt].UW[0], CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); - if (m_Opcode.rd == 11) //Compare + LogMessage("%08X: Writing 0x%X to %s register (originally: 0x%08X)", (*_PROGRAM_COUNTER), _GPR[m_Opcode.rt].UW[0], CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); + if (m_Opcode.rd == 11) // Compare { LogMessage("%08X: Cause register changed from %08X to %08X", (*_PROGRAM_COUNTER), g_Reg->CAUSE_REGISTER, (g_Reg->CAUSE_REGISTER & ~CAUSE_IP7)); } @@ -2284,39 +2289,39 @@ void R4300iOp::COP0_MT() switch (m_Opcode.rd) { - case 0: //Index - case 2: //EntryLo0 - case 3: //EntryLo1 - case 5: //PageMask - case 10: //Entry Hi - case 14: //EPC - case 16: //Config - case 18: //WatchLo - case 19: //WatchHi - case 28: //Tag lo - case 29: //Tag Hi - case 30: //ErrEPC + case 0: // Index + case 2: // EntryLo0 + case 3: // EntryLo1 + case 5: // PageMask + case 10: // Entry Hi + case 14: // EPC + case 16: // Config + case 18: // WatchLo + case 19: // WatchHi + case 28: // Tag lo + case 29: // Tag Hi + case 30: // ErrEPC _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0]; break; - case 6: //Wired + case 6: // Wired g_SystemTimer->UpdateTimers(); _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0]; break; - case 4: //Context + case 4: // Context _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0] & 0xFF800000; break; - case 9: //Count + case 9: // Count g_SystemTimer->UpdateTimers(); _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0]; g_SystemTimer->UpdateCompareTimer(); break; - case 11: //Compare + case 11: // Compare g_SystemTimer->UpdateTimers(); _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0]; g_Reg->FAKE_CAUSE_REGISTER &= ~CAUSE_IP7; g_SystemTimer->UpdateCompareTimer(); break; - case 12: //Status + case 12: // Status if ((_CP0[m_Opcode.rd] & STATUS_FR) != (_GPR[m_Opcode.rt].UW[0] & STATUS_FR)) { _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0]; @@ -2332,7 +2337,7 @@ void R4300iOp::COP0_MT() } g_Reg->CheckInterrupts(); break; - case 13: //cause + case 13: // Cause _CP0[m_Opcode.rd] &= 0xFFFFCFF; if ((_GPR[m_Opcode.rt].UW[0] & 0x300) != 0 && HaveDebugger()) { @@ -2344,7 +2349,8 @@ void R4300iOp::COP0_MT() } } -/************************** COP0 CO functions ***********************/ +// COP0 CO functions + void R4300iOp::COP0_CO_TLBR() { if (!g_System->bUseTlb()) @@ -2399,7 +2405,8 @@ void R4300iOp::COP0_CO_ERET() m_TestTimer = true; } -/************************** COP1 functions **************************/ +// COP1 functions + void R4300iOp::COP1_MF() { TEST_COP1_USABLE_EXCEPTION(); @@ -2419,7 +2426,7 @@ void R4300iOp::COP1_CF() { if (HaveDebugger()) { - g_Notify->DisplayError("CFC1 what register are you writing to ?"); + g_Notify->DisplayError("CFC1: what register are you writing to?"); } return; } @@ -2455,11 +2462,12 @@ void R4300iOp::COP1_CT() } if (HaveDebugger()) { - g_Notify->DisplayError("CTC1 what register are you writing to ?"); + g_Notify->DisplayError("CTC1: what register are you writing to?"); } } -/************************* COP1: BC1 functions ***********************/ +// COP1: BC1 functions + void R4300iOp::COP1_BCF() { TEST_COP1_USABLE_EXCEPTION(); @@ -2517,18 +2525,20 @@ void R4300iOp::COP1_BCTL() m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; } } -/************************** COP1: S functions ************************/ + +// COP1: S functions + __inline void Float_RoundToInteger32(int32_t * Dest, const float * Source, int RoundType) { #pragma warning(push) -#pragma warning(disable:4244) //warning C4244: disabe conversion from 'float' to 'int32_t', possible loss of data +#pragma warning(disable:4244) // warning C4244: disable conversion from 'float' to 'int32_t', possible loss of data if (RoundType == FE_TONEAREST) { float reminder = *Source - floorf(*Source); if (reminder == 0.5) { - //make any decimal point in even to go to odd and any decimal point in odd stay as odd + // Make any decimal point that is even odd, and any decimal point that is odd stay odd if (*Source < 0) { *Dest = (int)truncf(*Source) % 2 != 0 ? floorf(*Source) : ceilf(*Source); @@ -2553,14 +2563,14 @@ __inline void Float_RoundToInteger32(int32_t * Dest, const float * Source, int R __inline void Float_RoundToInteger64(int64_t * Dest, const float * Source, int RoundType) { #pragma warning(push) -#pragma warning(disable:4244) //warning C4244: disabe conversion from 'float' to 'int64_t', possible loss of data +#pragma warning(disable:4244) // warning C4244: disable conversion from 'float' to 'int64_t', possible loss of data if (RoundType == FE_TONEAREST) { float reminder = *Source - floorf(*Source); if (reminder == 0.5) { - //make any decimal point in even to go to odd and any decimal point in odd stay as odd + // Make any decimal point that is even odd, and any decimal point that is odd stay odd if (*Source < 0) { *Dest = (int)truncf(*Source) % 2 != 0 ? floorf(*Source) : ceilf(*Source); @@ -2753,18 +2763,19 @@ void R4300iOp::COP1_S_CMP() } } -/************************** COP1: D functions ************************/ +// COP1: D functions + __inline void Double_RoundToInteger32(int32_t * Dest, const double * Source, int RoundType) { #pragma warning(push) -#pragma warning(disable:4244) //warning C4244: disabe conversion from 'double' to 'uint32_t', possible loss of data +#pragma warning(disable:4244) // warning C4244: disable conversion from 'double' to 'uint32_t', possible loss of data if (RoundType == FE_TONEAREST) { double reminder = *Source - floor(*Source); if (reminder == 0.5) { - //make any decimal point in even to go to odd and any decimal point in odd stay as odd + // Make any decimal point that is even odd, and any decimal point that is odd stay odd if (*Source < 0) { *Dest = (int)truncf(*Source) % 2 != 0 ? floor(*Source) : ceil(*Source); @@ -2793,14 +2804,14 @@ __inline void Double_RoundToInteger32(int32_t * Dest, const double * Source, int __inline void Double_RoundToInteger64(int64_t * Dest, const double * Source, int RoundType) { #pragma warning(push) -#pragma warning(disable:4244) //warning C4244: disabe conversion from 'double' to 'uint64_t', possible loss of data +#pragma warning(disable:4244) // warning C4244: disable conversion from 'double' to 'uint64_t', possible loss of data if (RoundType == FE_TONEAREST) { double reminder = *Source - floor(*Source); if (reminder == 0.5) { - //make any decimal point in even to go to odd and any decimal point in odd stay as odd + // Make any decimal point that is even odd, and any decimal point that is odd stay odd if (*Source < 0) { *Dest = (int)truncf(*Source) % 2 != 0 ? floor(*Source) : ceil(*Source); @@ -2997,7 +3008,8 @@ void R4300iOp::COP1_D_CMP() } } -/************************** COP1: W functions ************************/ +// COP1: W functions + void R4300iOp::COP1_W_CVT_S() { TEST_COP1_USABLE_EXCEPTION(); @@ -3012,7 +3024,8 @@ void R4300iOp::COP1_W_CVT_D() *(double *)_FPR_D[m_Opcode.fd] = (double)*(int32_t *)_FPR_S[m_Opcode.fs]; } -/************************** COP1: L functions ************************/ +// COP1: L functions + void R4300iOp::COP1_L_CVT_S() { TEST_COP1_USABLE_EXCEPTION(); @@ -3027,10 +3040,11 @@ void R4300iOp::COP1_L_CVT_D() *(double *)_FPR_D[m_Opcode.fd] = (double)*(int64_t *)_FPR_D[m_Opcode.fs]; } -/************************** Other functions **************************/ +// Other functions + void R4300iOp::UnknownOpcode() { - g_Notify->DisplayError(stdstr_f("%s: %08X\n%s\n\nStopping Emulation !", GS(MSG_UNHANDLED_OP), (*_PROGRAM_COUNTER), + g_Notify->DisplayError(stdstr_f("%s: %08X\n%s\n\nStopping emulation", GS(MSG_UNHANDLED_OP), (*_PROGRAM_COUNTER), R4300iOpcodeName(m_Opcode.Hex, (*_PROGRAM_COUNTER))).c_str()); g_System->m_EndEmulation = true; @@ -3040,7 +3054,7 @@ void R4300iOp::UnknownOpcode() { int32_t response; - strcat(Message, "\n\nDo you wish to enter the debugger ?"); + strcat(Message, "\n\nDo you wish to enter the debugger?"); response = MessageBox(nullptr, Message, GS(MSG_MSGBOX_ERROR_TITLE), MB_YESNO | MB_ICONERROR); if (response == IDYES) diff --git a/Source/Project64-core/N64System/Interpreter/InterpreterOps.h b/Source/Project64-core/N64System/Interpreter/InterpreterOps.h index 133ce9c6c..a140525ce 100644 --- a/Source/Project64-core/N64System/Interpreter/InterpreterOps.h +++ b/Source/Project64-core/N64System/Interpreter/InterpreterOps.h @@ -12,7 +12,7 @@ class R4300iOp : public: typedef void(*Func)(); - /************************* OpCode functions *************************/ + // Opcode functions static void J(); static void JAL(); static void BNE(); @@ -59,7 +59,7 @@ public: static void SDC1(); static void SD(); - /********************** R4300i OpCodes: Special **********************/ + // R4300i opcodes: Special static void SPECIAL_SLL(); static void SPECIAL_SRL(); static void SPECIAL_SRA(); @@ -113,7 +113,7 @@ public: static void SPECIAL_DSRL32(); static void SPECIAL_DSRA32(); - /********************** R4300i OpCodes: RegImm **********************/ + // R4300i opcodes: RegImm static void REGIMM_BLTZ(); static void REGIMM_BGEZ(); static void REGIMM_BLTZL(); @@ -127,18 +127,18 @@ public: static void REGIMM_TLTIU(); static void REGIMM_TNEI(); - /************************** COP0 functions **************************/ + // COP0 functions static void COP0_MF(); static void COP0_MT(); - /************************** COP0 CO functions ***********************/ + // COP0 CO functions static void COP0_CO_TLBR(); static void COP0_CO_TLBWI(); static void COP0_CO_TLBWR(); static void COP0_CO_TLBP(); static void COP0_CO_ERET(); - /************************** COP1 functions **************************/ + // COP1 functions static void COP1_MF(); static void COP1_DMF(); static void COP1_CF(); @@ -146,13 +146,13 @@ public: static void COP1_DMT(); static void COP1_CT(); - /************************* COP1: BC1 functions ***********************/ + // COP1: BC1 functions static void COP1_BCF(); static void COP1_BCT(); static void COP1_BCFL(); static void COP1_BCTL(); - /************************** COP1: S functions ************************/ + // COP1: S functions static void COP1_S_ADD(); static void COP1_S_SUB(); static void COP1_S_MUL(); @@ -174,7 +174,7 @@ public: static void COP1_S_CVT_L(); static void COP1_S_CMP(); - /************************** COP1: D functions ************************/ + // COP1: D functions static void COP1_D_ADD(); static void COP1_D_SUB(); static void COP1_D_MUL(); @@ -196,15 +196,15 @@ public: static void COP1_D_CVT_L(); static void COP1_D_CMP(); - /************************** COP1: W functions ************************/ + // COP1: W functions static void COP1_W_CVT_S(); static void COP1_W_CVT_D(); - /************************** COP1: L functions ************************/ + // COP1: L functions static void COP1_L_CVT_S(); static void COP1_L_CVT_D(); - /************************** Other functions **************************/ + // Other functions static void UnknownOpcode(); static Func* BuildInterpreter(); diff --git a/Source/Project64-core/N64System/Interpreter/InterpreterOps32.cpp b/Source/Project64-core/N64System/Interpreter/InterpreterOps32.cpp index 1ac51a9ee..aad21bee4 100644 --- a/Source/Project64-core/N64System/Interpreter/InterpreterOps32.cpp +++ b/Source/Project64-core/N64System/Interpreter/InterpreterOps32.cpp @@ -622,7 +622,8 @@ R4300iOp32::Func * R4300iOp32::BuildInterpreter() return Jump_Opcode; } -/************************* Opcode functions *************************/ +// Opcode functions + void R4300iOp32::JAL() { m_NextInstruction = DELAY_SLOT; @@ -1103,7 +1104,8 @@ void R4300iOp32::LL() } } -/********************** R4300i OpCodes: Special **********************/ +// R4300i opcodes: Special + void R4300iOp32::SPECIAL_SLL() { _GPR[m_Opcode.rd].W[0] = (_GPR[m_Opcode.rt].W[0] << m_Opcode.sa); @@ -1211,11 +1213,12 @@ void R4300iOp32::SPECIAL_TEQ() { if (_GPR[m_Opcode.rs].W[0] == _GPR[m_Opcode.rt].W[0] && CDebugSettings::HaveDebugger()) { - g_Notify->DisplayError("Should trap this ???"); + g_Notify->DisplayError("Should we trap this?"); } } -/********************** R4300i OpCodes: RegImm **********************/ +// R4300i opcodes: RegImm + void R4300iOp32::REGIMM_BLTZ() { m_NextInstruction = DELAY_SLOT; @@ -1352,12 +1355,13 @@ void R4300iOp32::REGIMM_BGEZAL() _GPR[31].W[0] = (int32_t)((*_PROGRAM_COUNTER) + 8); } -/************************** COP0 functions **************************/ +// COP0 functions + void R4300iOp32::COP0_MF() { if (LogCP0reads()) { - LogMessage("%08X: R4300i Read from %s (0x%08X)", (*_PROGRAM_COUNTER), CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); + LogMessage("%08X: R4300i read from %s (0x%08X)", (*_PROGRAM_COUNTER), CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); } if (m_Opcode.rd == 9) @@ -1372,7 +1376,7 @@ void R4300iOp32::COP0_MT() if (LogCP0changes()) { LogMessage("%08X: Writing 0x%X to %s register (Originally: 0x%08X)", (*_PROGRAM_COUNTER), _GPR[m_Opcode.rt].UW[0], CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); - if (m_Opcode.rd == 11) //Compare + if (m_Opcode.rd == 11) // Compare { LogMessage("%08X: Cause register changed from %08X to %08X", (*_PROGRAM_COUNTER), g_Reg->CAUSE_REGISTER, (g_Reg->CAUSE_REGISTER & ~CAUSE_IP7)); } @@ -1380,39 +1384,39 @@ void R4300iOp32::COP0_MT() switch (m_Opcode.rd) { - case 0: //Index - case 2: //EntryLo0 - case 3: //EntryLo1 - case 5: //PageMask - case 10: //Entry Hi - case 14: //EPC - case 16: //Config - case 18: //WatchLo - case 19: //WatchHi - case 28: //Tag lo - case 29: //Tag Hi - case 30: //ErrEPC + case 0: // Index + case 2: // EntryLo0 + case 3: // EntryLo1 + case 5: // PageMask + case 10: // Entry Hi + case 14: // EPC + case 16: // Config + case 18: // WatchLo + case 19: // WatchHi + case 28: // Tag Lo + case 29: // Tag Hi + case 30: // ErrEPC _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0]; break; - case 6: //Wired + case 6: // Wired g_SystemTimer->UpdateTimers(); _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0]; break; - case 4: //Context + case 4: // Context _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0] & 0xFF800000; break; - case 9: //Count + case 9: // Count g_SystemTimer->UpdateTimers(); _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0]; g_SystemTimer->UpdateCompareTimer(); break; - case 11: //Compare + case 11: // Compare g_SystemTimer->UpdateTimers(); _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0]; g_Reg->FAKE_CAUSE_REGISTER &= ~CAUSE_IP7; g_SystemTimer->UpdateCompareTimer(); break; - case 12: //Status + case 12: // Status if ((_CP0[m_Opcode.rd] & STATUS_FR) != (_GPR[m_Opcode.rt].UW[0] & STATUS_FR)) { _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0]; @@ -1424,11 +1428,11 @@ void R4300iOp32::COP0_MT() } if ((_CP0[m_Opcode.rd] & 0x18) != 0 && CDebugSettings::HaveDebugger()) { - g_Notify->DisplayError("Left kernel mode ??"); + g_Notify->DisplayError("Left kernel mode?"); } g_Reg->CheckInterrupts(); break; - case 13: //cause + case 13: // Cause _CP0[m_Opcode.rd] &= 0xFFFFCFF; if ((_GPR[m_Opcode.rt].UW[0] & 0x300) != 0 && CDebugSettings::HaveDebugger()) { @@ -1440,7 +1444,8 @@ void R4300iOp32::COP0_MT() } } -/************************** COP1 functions **************************/ +// COP1 functions + void R4300iOp32::COP1_MF() { TEST_COP1_USABLE_EXCEPTION @@ -1452,7 +1457,7 @@ void R4300iOp32::COP1_CF() TEST_COP1_USABLE_EXCEPTION if (m_Opcode.fs != 31 && m_Opcode.fs != 0) { - if (CDebugSettings::HaveDebugger()) { g_Notify->DisplayError("CFC1 what register are you writing to ?"); } + if (CDebugSettings::HaveDebugger()) { g_Notify->DisplayError("CFC1: what register are you writing to?"); } return; } _GPR[m_Opcode.rt].W[0] = (int32_t)_FPCR[m_Opcode.fs]; diff --git a/Source/Project64-core/N64System/Interpreter/InterpreterOps32.h b/Source/Project64-core/N64System/Interpreter/InterpreterOps32.h index fd4faf4a7..42038bf50 100644 --- a/Source/Project64-core/N64System/Interpreter/InterpreterOps32.h +++ b/Source/Project64-core/N64System/Interpreter/InterpreterOps32.h @@ -6,7 +6,7 @@ class R4300iOp32 : public R4300iOp { public: - /************************* OpCode functions *************************/ + // Opcode functions static void JAL(); static void BEQ(); static void BNE(); @@ -34,7 +34,7 @@ public: static void LWU(); static void LL(); - /********************** R4300i OpCodes: Special **********************/ + // R4300i opcodes: Special static void SPECIAL_SLL(); static void SPECIAL_SRL(); static void SPECIAL_SRA(); @@ -53,7 +53,7 @@ public: static void SPECIAL_SLTU(); static void SPECIAL_TEQ(); - /********************** R4300i OpCodes: RegImm **********************/ + // R4300i opcodes: RegImm static void REGIMM_BLTZ(); static void REGIMM_BGEZ(); static void REGIMM_BLTZL(); @@ -61,11 +61,11 @@ public: static void REGIMM_BLTZAL(); static void REGIMM_BGEZAL(); - /************************** COP0 functions **************************/ + // COP0 functions static void COP0_MF(); static void COP0_MT(); - /************************** COP1 functions **************************/ + // COP1 functions static void COP1_MF(); static void COP1_CF(); static void COP1_DMT(); diff --git a/Source/Project64-core/N64System/Mips/Audio.cpp b/Source/Project64-core/N64System/Mips/Audio.cpp index 14be8ef05..a0d2ada9f 100644 --- a/Source/Project64-core/N64System/Mips/Audio.cpp +++ b/Source/Project64-core/N64System/Mips/Audio.cpp @@ -17,7 +17,7 @@ void CAudio::Reset() m_SecondBuff = 0; m_Status = 0; m_BytesPerSecond = 0; - m_CountsPerByte = g_System->AiCountPerBytes(); // should be calculated ... see below, instead allow from user settings + m_CountsPerByte = g_System->AiCountPerBytes(); // Should be calculated, see below, instead allow from user settings if (m_CountsPerByte == 0) m_CountsPerByte = 500; // If the user has no defined value, grant a default and we will calculate m_FramesPerSecond = 60; } @@ -47,7 +47,7 @@ void CAudio::LenChanged() { if (g_Reg->AI_LEN_REG >= 0x40000) { - WriteTrace(TraceAudio, TraceDebug, "*** Ignoring Write, To Large (%X)", g_Reg->AI_LEN_REG); + WriteTrace(TraceAudio, TraceDebug, "Ignoring write, to large (%X)", g_Reg->AI_LEN_REG); } else { @@ -57,12 +57,12 @@ void CAudio::LenChanged() { if (AudioLeft == 0) { - WriteTrace(TraceAudio, TraceDebug, "Set Timer AI_LEN_REG: %d m_CountsPerByte: %d", g_Reg->AI_LEN_REG, m_CountsPerByte); + WriteTrace(TraceAudio, TraceDebug, "Set timer AI_LEN_REG: %d m_CountsPerByte: %d", g_Reg->AI_LEN_REG, m_CountsPerByte); g_SystemTimer->SetTimer(CSystemTimer::AiTimerInterrupt, g_Reg->AI_LEN_REG * m_CountsPerByte, false); } else { - WriteTrace(TraceAudio, TraceDebug, "Increasing Second Buffer (m_SecondBuff %d Increase: %d)", m_SecondBuff, g_Reg->AI_LEN_REG); + WriteTrace(TraceAudio, TraceDebug, "Increasing second buffer (m_SecondBuff %d Increase: %d)", m_SecondBuff, g_Reg->AI_LEN_REG); m_SecondBuff += g_Reg->AI_LEN_REG; m_Status |= ai_full; } @@ -75,7 +75,7 @@ void CAudio::LenChanged() } else { - WriteTrace(TraceAudio, TraceDebug, "*** Reset Timer to 0"); + WriteTrace(TraceAudio, TraceDebug, "Reset timer to 0"); g_SystemTimer->StopTimer(CSystemTimer::AiTimerBusy); g_SystemTimer->StopTimer(CSystemTimer::AiTimerInterrupt); m_SecondBuff = 0; @@ -86,7 +86,7 @@ void CAudio::LenChanged() { WriteTrace(TraceAudio, TraceDebug, "Calling plugin AiLenChanged"); g_Plugins->Audio()->AiLenChanged(); - WriteTrace(TraceAudio, TraceDebug, "plugin AiLenChanged Done"); + WriteTrace(TraceAudio, TraceDebug, "Plugin AiLenChanged Done"); } WriteTrace(TraceAudio, TraceDebug, "Done"); } diff --git a/Source/Project64-core/N64System/Mips/Disk.cpp b/Source/Project64-core/N64System/Mips/Disk.cpp index d3d45a089..a3cd0f4ce 100644 --- a/Source/Project64-core/N64System/Mips/Disk.cpp +++ b/Source/Project64-core/N64System/Mips/Disk.cpp @@ -1,4 +1,4 @@ -// Based from MAME's N64DD driver code by Happy_ +// Based on MAME's N64DD driver code by Happy_ #include "stdafx.h" #include "Disk.h" #include @@ -24,13 +24,13 @@ void DiskCommand() { //ASIC_CMD_STATUS - Commands uint32_t cmd = g_Reg->ASIC_CMD; - WriteTrace(TraceN64System, TraceDebug, "DD CMD %08X - DATA %08X", cmd, g_Reg->ASIC_DATA); + WriteTrace(TraceN64System, TraceDebug, "N64DD CMD %08X - DATA %08X", cmd, g_Reg->ASIC_DATA); #ifdef _WIN32 SYSTEMTIME sysTime; ::GetLocalTime(&sysTime); - //BCD format needed for 64DD RTC + // BCD format needed for 64DD RTC uint8_t year = (uint8_t)(((sysTime.wYear / 10 % 10) << 4) | (sysTime.wYear % 10)); uint8_t month = (uint8_t)(((sysTime.wMonth / 10) << 4) | (sysTime.wMonth % 10)); uint8_t day = (uint8_t)(((sysTime.wDay / 10) << 4) | (sysTime.wDay % 10)); @@ -44,7 +44,7 @@ void DiskCommand() struct tm result = { 0 }; localtime_r(<ime, &result); - //BCD format needed for 64DD RTC + // BCD format needed for 64DD RTC uint8_t year = (uint8_t)(((result.tm_year / 10 % 10) << 4) | (result.tm_year % 10)); uint8_t month = (uint8_t)((((result.tm_mon + 1) / 10) << 4) | ((result.tm_mon + 1) % 10)); uint8_t day = (uint8_t)(((result.tm_mday / 10) << 4) | (result.tm_mday % 10)); @@ -53,46 +53,46 @@ void DiskCommand() uint8_t second = (uint8_t)(((result.tm_sec / 10) << 4) | (result.tm_sec % 10)); #endif - //Used for seek times + // Used for seek times bool isSeek = false; switch (cmd & 0xFFFF0000) { case 0x00010000: - //Seek Read + // Seek read g_Reg->ASIC_CUR_TK = g_Reg->ASIC_DATA | 0x60000000; dd_write = false; isSeek = true; break; case 0x00020000: - //Seek Write + // Seek write g_Reg->ASIC_CUR_TK = g_Reg->ASIC_DATA | 0x60000000; dd_write = true; isSeek = true; break; case 0x00080000: - //Unset Disk Changed Bit + // Unset disk changed bit g_Reg->ASIC_STATUS &= ~DD_STATUS_DISK_CHNG; break; case 0x00090000: - //Unset Reset & Disk Changed bit Bit + // Unset reset and disk changed bit bit g_Reg->ASIC_STATUS &= ~DD_STATUS_RST_STATE; g_Reg->ASIC_STATUS &= ~DD_STATUS_DISK_CHNG; - //F-Zero X + Expansion Kit fix so it doesn't enable "swapping" at boot + // F-Zero X + Expansion Kit fix so it doesn't enable "swapping" at boot dd_swapdelay = 0; if (g_Disk != nullptr) g_Reg->ASIC_STATUS |= DD_STATUS_DISK_PRES; break; case 0x00120000: - //RTC Get Year & Month + // RTC get year and month g_Reg->ASIC_DATA = (year << 24) | (month << 16); break; case 0x00130000: - //RTC Get Day & Hour + // RTC get day and hour g_Reg->ASIC_DATA = (day << 24) | (hour << 16); break; case 0x00140000: - //RTC Get Minute & Second + // RTC get minute and second g_Reg->ASIC_DATA = (minute << 24) | (second << 16); break; case 0x001B0000: - //Disk Inquiry + // Disk inquiry g_Reg->ASIC_DATA = 0x00000000; break; } @@ -100,27 +100,27 @@ void DiskCommand() { if (g_System->DiskSeekTimingType() == DiskSeek_Turbo) { - //Instant Response for Turbo + // Instant response for turbo - //Set timer for seek response + // Set timer for seek response g_SystemTimer->SetTimer(g_SystemTimer->DDSeekTimer, 0, false); - //Set timer for motor + // Set timer for motor g_SystemTimer->SetTimer(g_SystemTimer->DDMotorTimer, 0, false); } else /* if (g_System->DiskSeekTimingType() == DiskSeek_Slow) */ { - //Emulate Seek Times, send interrupt later + // Emulate seek times, send interrupt later uint32_t seektime = 0; - //Start Motor, can take half a second, delay the response + // Start motor, can take half a second, delay the response if (g_Reg->ASIC_STATUS & DD_STATUS_MTR_N_SPIN) { seektime += (0x5A00000 / 2); g_Reg->ASIC_STATUS &= ~DD_STATUS_MTR_N_SPIN; } - //Get Zone to calculate seek times + // Get zone to calculate seek times uint32_t track = g_Reg->ASIC_CUR_TK >> 16 & 0x0FFF; uint32_t zone = 0; uint32_t zonebound = 0; @@ -136,7 +136,7 @@ void DiskCommand() } } - //Add seek delay depending on the zone (this is inaccurate timing, but close enough) + // Add seek delay depending on the zone (this is inaccurate timing, but close enough) seektime += 0x179200; switch (zone) @@ -159,16 +159,16 @@ void DiskCommand() break; } - //Set timer for seek response + // Set timer for seek response g_SystemTimer->SetTimer(g_SystemTimer->DDSeekTimer, seektime, false); - //Set timer for motor to shutdown in 5 seconds, reset the timer if other seek commands were sent + // Set timer for motor to shutdown in 5 seconds, reset the timer if other seek commands were sent g_SystemTimer->SetTimer(g_SystemTimer->DDMotorTimer, 0x5A00000 * 5, false); } } else { - //Other commands are basically instant + // Other commands are basically instant g_Reg->ASIC_STATUS |= DD_STATUS_MECHA_INT; g_Reg->FAKE_CAUSE_REGISTER |= CAUSE_IP3; g_Reg->CheckInterrupts(); @@ -178,7 +178,7 @@ void DiskCommand() void DiskReset(void) { //ASIC_HARD_RESET 0xAAAA0000 - WriteTrace(TraceN64System, TraceDebug, "DD RESET"); + WriteTrace(TraceN64System, TraceDebug, "N64DD reset"); g_Reg->ASIC_STATUS |= DD_STATUS_RST_STATE; dd_swapdelay = 0; if (g_Disk != nullptr) @@ -231,9 +231,9 @@ void DiskBMControl(void) void DiskGapSectorCheck() { - //On 64DD Status Register Read + // On 64DD status register read - //Buffer Manager Interrupt, Gap Sector Check + // Buffer manager interrupt, gap sector check if (g_Reg->ASIC_STATUS & DD_STATUS_BM_INT) { if (SECTORS_PER_BLOCK < dd_current) @@ -245,7 +245,7 @@ void DiskGapSectorCheck() } } - //Delay Disk Swapping by removing the disk for a certain amount of time, then insert the newly loaded disk (after 50 Status Register reads, here). + // Delay disk swapping by removing the disk for a certain amount of time, then insert the newly loaded disk (after 50 status register reads, here) if (!(g_Reg->ASIC_STATUS & DD_STATUS_DISK_PRES) && g_Disk != nullptr && g_Settings->LoadBool(GameRunning_LoadingInProgress) == false) { dd_swapdelay++; @@ -253,7 +253,7 @@ void DiskGapSectorCheck() { g_Reg->ASIC_STATUS |= (DD_STATUS_DISK_PRES | DD_STATUS_DISK_CHNG); dd_swapdelay = 0; - WriteTrace(TraceN64System, TraceDebug, "DD SWAP DONE"); + WriteTrace(TraceN64System, TraceDebug, "N64DD swap done"); } } } @@ -277,7 +277,7 @@ void DiskBMUpdate() } else if (dd_current < SECTORS_PER_BLOCK + 1) { - //C2 Sector + // C2 sector if (g_Reg->ASIC_BM_STATUS & DD_BM_STATUS_BLOCK) { dd_start_block = 1 - dd_start_block; @@ -303,16 +303,16 @@ void DiskBMUpdate() } else { - //Read Data + // Read data if (((g_Reg->ASIC_CUR_TK >> 16) & 0x1FFF) == 6 && g_Reg->ASIC_CUR_SECTOR == 0 && g_Disk->GetCountry() != Country_Unknown) { - //Copy Protection if Retail Disk + // Copy protection if retail disk g_Reg->ASIC_STATUS &= ~DD_STATUS_DATA_RQ; g_Reg->ASIC_BM_STATUS |= DD_BM_STATUS_MICRO; } else if (dd_current < SECTORS_PER_BLOCK) { - //User Sector + // User sector if (!DiskBMReadWrite(false)) g_Reg->ASIC_STATUS |= DD_STATUS_DATA_RQ; else @@ -321,14 +321,14 @@ void DiskBMUpdate() } else if (dd_current < SECTORS_PER_BLOCK + 4) { - //C2 sectors (All 00s) + // C2 sectors (all 00s) dd_current += 1; if (dd_current == SECTORS_PER_BLOCK + 4) g_Reg->ASIC_STATUS |= DD_STATUS_C2_XFER; } else if (dd_current == SECTORS_PER_BLOCK + 4) { - //Gap Sector + // Gap sector if (g_Reg->ASIC_BM_STATUS & DD_BM_STATUS_BLOCK) { dd_start_block = 1 - dd_start_block; @@ -349,7 +349,7 @@ void DiskBMUpdate() bool DiskBMReadWrite(bool /*write*/) { - //Returns true if error + // Returns true if error uint16_t head = ((g_Reg->ASIC_CUR_TK >> 16) / 0x1000) & 1; uint16_t track = (g_Reg->ASIC_CUR_TK >> 16) & 0xFFF; uint16_t block = (uint16_t)dd_start_block; @@ -360,7 +360,7 @@ bool DiskBMReadWrite(bool /*write*/) if (addr == 0xFFFFFFFF) { - //Error + // Error return true; } else diff --git a/Source/Project64-core/N64System/Mips/Disk.h b/Source/Project64-core/N64System/Mips/Disk.h index 5b8403d17..d9ce3482b 100644 --- a/Source/Project64-core/N64System/Mips/Disk.h +++ b/Source/Project64-core/N64System/Mips/Disk.h @@ -1,4 +1,4 @@ -// Based from MAME's N64DD driver code by Happy_ +// Based on MAME's N64DD driver code by Happy_ #pragma once #include diff --git a/Source/Project64-core/N64System/Mips/Dma.cpp b/Source/Project64-core/N64System/Mips/Dma.cpp index 720bb98fe..a82150033 100644 --- a/Source/Project64-core/N64System/Mips/Dma.cpp +++ b/Source/Project64-core/N64System/Mips/Dma.cpp @@ -63,17 +63,17 @@ void CDMA::PI_DMA_READ() return; } - //64DD Buffers Write + // 64DD buffers write if (g_Reg->PI_CART_ADDR_REG >= 0x05000000 && g_Reg->PI_CART_ADDR_REG <= 0x050003FF) { - //64DD C2 Sectors (don't care) + // 64DD C2 sectors (don't care) g_SystemTimer->SetTimer(g_SystemTimer->DDPiTimer, (PI_RD_LEN_REG * 63) / 25, false); return; } if (g_Reg->PI_CART_ADDR_REG >= 0x05000400 && g_Reg->PI_CART_ADDR_REG <= 0x050004FF) { - //64DD User Sector + // 64DD user sector uint32_t i; uint8_t * RDRAM = g_MMU->Rdram(); uint8_t * DISK = g_Disk->GetDiskAddressBuffer(); @@ -87,14 +87,14 @@ void CDMA::PI_DMA_READ() if (g_Reg->PI_CART_ADDR_REG >= 0x05000580 && g_Reg->PI_CART_ADDR_REG <= 0x050005BF) { - //64DD MSEQ (don't care) + // 64DD MSEQ (don't care) g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY; g_Reg->MI_INTR_REG |= MI_INTR_PI; g_Reg->CheckInterrupts(); return; } - //Write ROM Area (for 64DD Convert) + // Write ROM area (for 64DD conversion) if (g_Reg->PI_CART_ADDR_REG >= 0x10000000 && g_Reg->PI_CART_ADDR_REG <= 0x1FBFFFFF && g_Settings->LoadBool(Game_AllowROMWrites)) { uint32_t i; @@ -172,7 +172,7 @@ void CDMA::PI_DMA_READ() } if (g_System->m_SaveUsing == SaveChip_FlashRam) { - g_Notify->DisplayError(stdstr_f("**** FLashRam DMA Read address %08X *****", g_Reg->PI_CART_ADDR_REG).c_str()); + g_Notify->DisplayError(stdstr_f("**** FlashRAM DMA read address %08X ****", g_Reg->PI_CART_ADDR_REG).c_str()); g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY; g_Reg->MI_INTR_REG |= MI_INTR_PI; g_Reg->CheckInterrupts(); @@ -180,7 +180,7 @@ void CDMA::PI_DMA_READ() } if (HaveDebugger()) { - g_Notify->DisplayError(stdstr_f("PI_DMA_READ where are you dmaing to ? : %08X", g_Reg->PI_CART_ADDR_REG).c_str()); + g_Notify->DisplayError(stdstr_f("PI_DMA_READ where are you DMAing to? : %08X", g_Reg->PI_CART_ADDR_REG).c_str()); } g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY; g_Reg->MI_INTR_REG |= MI_INTR_PI; @@ -190,24 +190,24 @@ void CDMA::PI_DMA_READ() void CDMA::PI_DMA_WRITE() { - /* rounding PI_WR_LEN_REG up to the nearest even number fixes AI Shougi 3, Doraemon 3, etc. */ + // Rounding PI_WR_LEN_REG up to the nearest even number fixes AI Shougi 3, Doraemon 3, etc. uint32_t PI_WR_LEN_REG = ((g_Reg->PI_WR_LEN_REG) & 0x00FFFFFEul) + 2; uint32_t PI_CART_ADDR_REG = !g_Settings->LoadBool(Game_UnalignedDMA) ? g_Reg->PI_CART_ADDR_REG & ~1 : g_Reg->PI_CART_ADDR_REG; g_Reg->PI_STATUS_REG |= PI_STATUS_DMA_BUSY; if (g_Reg->PI_DRAM_ADDR_REG + PI_WR_LEN_REG > g_MMU->RdramSize()) { - if (ShowUnhandledMemory()) { g_Notify->DisplayError(stdstr_f("PI_DMA_WRITE not in Memory: %08X", g_Reg->PI_DRAM_ADDR_REG + PI_WR_LEN_REG).c_str()); } + if (ShowUnhandledMemory()) { g_Notify->DisplayError(stdstr_f("PI_DMA_WRITE not in memory: %08X", g_Reg->PI_DRAM_ADDR_REG + PI_WR_LEN_REG).c_str()); } g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY; g_Reg->MI_INTR_REG |= MI_INTR_PI; g_Reg->CheckInterrupts(); return; } - //64DD Buffers Read + // 64DD buffers read if (PI_CART_ADDR_REG >= 0x05000000 && PI_CART_ADDR_REG <= 0x050003FF) { - //64DD C2 Sectors (just read 0) + // 64DD C2 sectors (just read 0) uint32_t i; uint8_t * RDRAM = g_MMU->Rdram(); for (i = 0; i < PI_WR_LEN_REG; i++) @@ -215,14 +215,14 @@ void CDMA::PI_DMA_WRITE() *(RDRAM + ((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = 0; } - //Timer is needed for Track Read + // Timer is needed for track read g_SystemTimer->SetTimer(g_SystemTimer->DDPiTimer, (PI_WR_LEN_REG * 63) / 25, false); return; } if (PI_CART_ADDR_REG >= 0x05000400 && PI_CART_ADDR_REG <= 0x050004FF) { - //64DD User Sector + // 64DD user sector uint32_t i; uint8_t * RDRAM = g_MMU->Rdram(); uint8_t * DISK = g_Disk->GetDiskAddressBuffer(); @@ -231,21 +231,21 @@ void CDMA::PI_DMA_WRITE() *(RDRAM + ((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = *(DISK + (i ^ 3)); } - //Timer is needed for Track Read + // Timer is needed for track read g_SystemTimer->SetTimer(g_SystemTimer->DDPiTimer, (PI_WR_LEN_REG * 63) / 25, false); return; } if (PI_CART_ADDR_REG >= 0x05000580 && PI_CART_ADDR_REG <= 0x050005BF) { - //64DD MSEQ (don't care) + // 64DD MSEQ (don't care) g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY; g_Reg->MI_INTR_REG |= MI_INTR_PI; g_Reg->CheckInterrupts(); return; } - //64DD IPL ROM + // 64DD IPL ROM if (PI_CART_ADDR_REG >= 0x06000000 && PI_CART_ADDR_REG <= 0x063FFFFF) { uint32_t i; @@ -483,7 +483,7 @@ void CDMA::SP_DMA_READ() { if (HaveDebugger()) { - g_Notify->DisplayError(stdstr_f("%s\nSP_DRAM_ADDR_REG not in RDRam space : % 08X", __FUNCTION__, g_Reg->SP_DRAM_ADDR_REG).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nSP_DRAM_ADDR_REG not in RDRAM space: % 08X", __FUNCTION__, g_Reg->SP_DRAM_ADDR_REG).c_str()); } g_Reg->SP_DMA_BUSY_REG = 0; g_Reg->SP_STATUS_REG &= ~SP_STATUS_DMA_BUSY; @@ -525,7 +525,7 @@ void CDMA::SP_DMA_WRITE() { if (HaveDebugger()) { - g_Notify->DisplayError(stdstr_f("%s\nSP_DRAM_ADDR_REG not in RDRam space : %08X", __FUNCTION__, g_Reg->SP_DRAM_ADDR_REG).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nSP_DRAM_ADDR_REG not in RDRAM space: %08X", __FUNCTION__, g_Reg->SP_DRAM_ADDR_REG).c_str()); } return; } @@ -534,7 +534,7 @@ void CDMA::SP_DMA_WRITE() { if (HaveDebugger()) { - g_Notify->DisplayError("SP DMA WRITE\ncould not fit copy in memory segement"); + g_Notify->DisplayError("SP DMA WRITE\nCould not fit copy in memory segment"); } return; } diff --git a/Source/Project64-core/N64System/Mips/Eeprom.cpp b/Source/Project64-core/N64System/Mips/Eeprom.cpp index 08034572a..eea35c3fb 100644 --- a/Source/Project64-core/N64System/Mips/Eeprom.cpp +++ b/Source/Project64-core/N64System/Mips/Eeprom.cpp @@ -32,7 +32,7 @@ void CEeprom::EepromCommand(uint8_t * Command) switch (Command[2]) { - case 0: // check + case 0: // Check if (g_System->m_SaveUsing != SaveChip_Eeprom_4K && g_System->m_SaveUsing != SaveChip_Eeprom_16K) { Command[1] |= 0x80; @@ -61,7 +61,7 @@ void CEeprom::EepromCommand(uint8_t * Command) Command[5] = 0x00; } break; - case 4: // Read from Eeprom + case 4: // Read from EEPROM if (Command[0] != 2 && HaveDebugger()) { ProcessingError(Command); @@ -72,7 +72,7 @@ void CEeprom::EepromCommand(uint8_t * Command) } ReadFrom(&Command[4], Command[3]); break; - case 5: //Write to Eeprom + case 5: // Write to EEPROM if (Command[0] != 10 && HaveDebugger()) { ProcessingError(Command); @@ -83,25 +83,25 @@ void CEeprom::EepromCommand(uint8_t * Command) } WriteTo(&Command[4], Command[3]); break; - case 6: //RTC Status query + case 6: // RTC status query Command[3] = 0x00; Command[4] = 0x10; Command[5] = 0x00; break; - case 7: //Read RTC block + case 7: // Read RTC block switch (Command[3]) { - case 0: //Block number + case 0: // Block number Command[4] = 0x00; Command[5] = 0x02; Command[12] = 0x00; break; case 1: - //read block, Command[2], Unimplemented + // Read block, Command[2], unimplemented break; - case 2: //Set RTC Time + case 2: // Set RTC time time(&curtime_time); - memcpy(&curtime, localtime(&curtime_time), sizeof(curtime)); // fd's fix + memcpy(&curtime, localtime(&curtime_time), sizeof(curtime)); Command[4] = byte2bcd(curtime.tm_sec); Command[5] = byte2bcd(curtime.tm_min); Command[6] = 0x80 + byte2bcd(curtime.tm_hour); @@ -110,12 +110,12 @@ void CEeprom::EepromCommand(uint8_t * Command) Command[9] = byte2bcd(curtime.tm_mon + 1); Command[10] = byte2bcd(curtime.tm_year); Command[11] = byte2bcd(curtime.tm_year / 100); - Command[12] = 0x00; // status + Command[12] = 0x00; // Status break; } break; case 8: - //Write RTC, unimplemented + // Write RTC, unimplemented if (bShowPifRamErrors()) { g_Notify->DisplayError("Write RTC, unimplemented"); @@ -199,6 +199,6 @@ void CEeprom::ProcessingError(uint8_t * /*Command*/) { if (bShowPifRamErrors()) { - g_Notify->DisplayError("What am I meant to do with this Eeprom Command"); + g_Notify->DisplayError("What am I meant to do with this EEPROM command?"); } } diff --git a/Source/Project64-core/N64System/Mips/FlashRam.cpp b/Source/Project64-core/N64System/Mips/FlashRam.cpp index 15c3398a9..53d16af65 100644 --- a/Source/Project64-core/N64System/Mips/FlashRam.cpp +++ b/Source/Project64-core/N64System/Mips/FlashRam.cpp @@ -40,7 +40,7 @@ void CFlashram::DmaFromFlashram(uint8_t * dest, int32_t StartOffset, int32_t len { if (HaveDebugger()) { - g_Notify->DisplayError(stdstr_f("%s: Unaligned flash ram read ???", __FUNCTION__).c_str()); + g_Notify->DisplayError(stdstr_f("%s: Unaligned flash RAM read?", __FUNCTION__).c_str()); } return; } @@ -178,7 +178,7 @@ void CFlashram::WriteToFlashCommand(uint32_t FlashRAM_Command) } break; default: - g_Notify->DisplayError(stdstr_f("Writing %X to flash ram command register\nm_FlashFlag: %d", FlashRAM_Command, m_FlashFlag).c_str()); + g_Notify->DisplayError(stdstr_f("Writing %X to flash RAM command register\nm_FlashFlag: %d", FlashRAM_Command, m_FlashFlag).c_str()); } m_FlashFlag = FLASHRAM_MODE_NOPES; break; @@ -199,7 +199,7 @@ void CFlashram::WriteToFlashCommand(uint32_t FlashRAM_Command) m_FlashStatus = 0x1111800800C2001E; break; case 0xB4000000: - m_FlashFlag = FLASHRAM_MODE_WRITE; //???? + m_FlashFlag = FLASHRAM_MODE_WRITE; break; case 0xA5000000: m_FlashRAM_Offset = (FlashRAM_Command & 0xFFFF) * sizeof(EmptyBlock); @@ -208,7 +208,7 @@ void CFlashram::WriteToFlashCommand(uint32_t FlashRAM_Command) default: if (HaveDebugger()) { - g_Notify->DisplayError(stdstr_f("Writing %X to flash ram command register", FlashRAM_Command).c_str()); + g_Notify->DisplayError(stdstr_f("Writing %X to flash RAM command register", FlashRAM_Command).c_str()); } } } \ No newline at end of file diff --git a/Source/Project64-core/N64System/Mips/GBCart.cpp b/Source/Project64-core/N64System/Mips/GBCart.cpp index a47b0670f..df4558a31 100644 --- a/Source/Project64-core/N64System/Mips/GBCart.cpp +++ b/Source/Project64-core/N64System/Mips/GBCart.cpp @@ -1,8 +1,9 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2015 Bobby Smiles // GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html + #include "stdafx.h" #include "GBCart.h" @@ -15,27 +16,27 @@ static void read_gb_cart_normal(struct gb_cart* gb_cart, uint16_t address, uint8 if ((address >= 0x0000) && (address <= 0x7FFF)) { - //Read GB Cart + // Read Game Boy cart if (address >= gb_cart->rom_size) { - //If address is larger then our rome size, bail out + // If address is larger then our ROM size, bail out return; } memcpy(data, &gb_cart->rom[address], 0x20); } else if ((address >= 0xA000) && (address <= 0xBFFF)) { - //Read from RAM + // Read from RAM if (gb_cart->ram == nullptr) { - //No RAM to write to + // No RAM to write to return; } offset = address - 0xA000; if (offset >= gb_cart->ram_size) { - //Offset is larger then our ram size + // Offset is larger then our RAM size return; } @@ -49,17 +50,17 @@ static void write_gb_cart_normal(struct gb_cart* gb_cart, uint16_t address, cons uint16_t offset; if ((address >= 0xA000) && (address <= 0xBFFF)) { - //Write to RAM + // Write to RAM if (gb_cart->ram == nullptr) { - //No RAM to write to + // No RAM to write to return; } offset = address - 0xa000; if (offset >= gb_cart->ram_size) { - //Offset is larger then our ram size + // Offset is larger then our RAM size return; } @@ -71,11 +72,11 @@ static void read_gb_cart_mbc1(struct gb_cart* gb_cart, uint16_t address, uint8_t { size_t offset; - if ((address >= 0x0000) && (address <= 0x3FFF)) //No nbanked memory + if ((address >= 0x0000) && (address <= 0x3FFF)) // No unbanked memory { memcpy(data, &gb_cart->rom[address], 0x20); } - else if ((address >= 0x4000) && (address <= 0x7FFF)) //Read from ROM + else if ((address >= 0x4000) && (address <= 0x7FFF)) // Read from ROM { offset = (address - 0x4000) + (gb_cart->rom_bank * 0x4000); if (offset < gb_cart->rom_size) @@ -83,7 +84,7 @@ static void read_gb_cart_mbc1(struct gb_cart* gb_cart, uint16_t address, uint8_t memcpy(data, &gb_cart->rom[offset], 0x20); } } - else if ((address >= 0xA000) && (address <= 0xBFFF)) //Read from RAM + else if ((address >= 0xA000) && (address <= 0xBFFF)) // Read from RAM { if (gb_cart->ram != nullptr) { @@ -102,15 +103,15 @@ static void write_gb_cart_mbc1(struct gb_cart* gb_cart, uint16_t address, const if ((address >= 0x0000) && (address <= 0x1FFF)) // RAM enable { - //Enable/disable RAM + // Enable/disable RAM gb_cart->ram_enabled = (data[0] & 0x0F) == 0x0A; } else if ((address >= 0x2000) && (address <= 0x3FFF)) // ROM bank select { - gb_cart->rom_bank &= 0x60; // keep MSB + gb_cart->rom_bank &= 0x60; // Keep MSB gb_cart->rom_bank |= data[0] & 0x1F; - // emulate quirk: 0x00 -> 0x01, 0x20 -> 0x21, 0x40->0x41, 0x60 -> 0x61 + // Emulate quirk: 0x00 -> 0x01, 0x20 -> 0x21, 0x40->0x41, 0x60 -> 0x61 if ((gb_cart->rom_bank & 0x1F) == 0) { gb_cart->rom_bank |= 0x01; @@ -125,27 +126,27 @@ static void write_gb_cart_mbc1(struct gb_cart* gb_cart, uint16_t address, const else { gb_cart->rom_bank &= 0x1F; - gb_cart->rom_bank |= ((data[0] & 0x03) << 5); // set bits 5 and 6 of ROM bank + gb_cart->rom_bank |= ((data[0] & 0x03) << 5); // Set bits 5 and 6 of ROM bank } } else if ((address >= 0x6000) && (address <= 0x7FFF)) // MBC1 mode select { - // this is overly complicated, but it keeps us from having to do bitwise math later - // Basically we shuffle the 2 "magic bits" between rom_bank and ram_bank as necessary. + // This is overly complicated, but it keeps us from having to do bitwise math later + // Basically we shuffle the 2 "magic bits" between rom_bank and ram_bank as necessary if (gb_cart->ram_bank_mode != (data[0] & 0x01)) { - // we should only alter the ROM and RAM bank numbers if we have changed modes + // We should only alter the ROM and RAM bank numbers if we have changed modes gb_cart->ram_bank_mode = data[0] & 0x01; if (gb_cart->ram_bank_mode) { - gb_cart->ram_bank = gb_cart->rom_bank >> 5; // set the ram bank to the "magic bits" - gb_cart->rom_bank &= 0x1F; // zero out bits 5 and 6 to keep consistency + gb_cart->ram_bank = gb_cart->rom_bank >> 5; // Set the RAM bank to the "magic bits" + gb_cart->rom_bank &= 0x1F; // Zero out bits 5 and 6 to keep consistency } else { gb_cart->rom_bank &= 0x1F; gb_cart->rom_bank |= (gb_cart->ram_bank << 5); - gb_cart->ram_bank = 0x00; // we can only reach RAM page 0 + gb_cart->ram_bank = 0x00; // We can only reach RAM page 0 } } } @@ -166,11 +167,11 @@ static void read_gb_cart_mbc2(struct gb_cart* gb_cart, uint16_t address, uint8_t { size_t offset; - if ((address < 0x4000)) //Rom Bank 0 + if ((address < 0x4000)) // ROM bank 0 { memcpy(data, &gb_cart->rom[address], 0x20); } - else if ((address >= 0x4000) && (address < 0x8000)) //Switchable Rom Bank + else if ((address >= 0x4000) && (address < 0x8000)) // Switchable ROM bank { offset = (address - 0x4000) + (gb_cart->rom_bank * 0x4000); if (offset < gb_cart->rom_size) @@ -178,7 +179,7 @@ static void read_gb_cart_mbc2(struct gb_cart* gb_cart, uint16_t address, uint8_t memcpy(data, &gb_cart->rom[offset], 0x20); } } - else if ((address >= 0xA000) && (address <= 0xC000)) //Upper Bounds of memory map + else if ((address >= 0xA000) && (address <= 0xC000)) // Upper bounds of memory map { if (gb_cart->ram != nullptr) { @@ -232,7 +233,7 @@ void memoryUpdateMBC3Clock(struct gb_cart* gb_cart) time_t now = time(nullptr); time_t diff = now - gb_cart->rtc_last_time; if (diff > 0) { - // update the clock according to the last update time + // Update the clock according to the last update time gb_cart->rtc_data[0] += (int)(diff % 60); if (gb_cart->rtc_data[0] > 59) { gb_cart->rtc_data[0] -= 60; @@ -270,11 +271,11 @@ static void read_gb_cart_mbc3(struct gb_cart* gb_cart, uint16_t address, uint8_t { size_t offset; - if ((address < 0x4000)) //Rom Bank 0 + if ((address < 0x4000)) // ROM bank 0 { memcpy(data, &gb_cart->rom[address], 0x20); } - else if ((address >= 0x4000) && (address < 0x8000)) //Switchable Rom Bank + else if ((address >= 0x4000) && (address < 0x8000)) // Switchable ROM bank { offset = (address - 0x4000) + (gb_cart->rom_bank * 0x4000); if (offset < gb_cart->rom_size) @@ -282,7 +283,7 @@ static void read_gb_cart_mbc3(struct gb_cart* gb_cart, uint16_t address, uint8_t memcpy(data, &gb_cart->rom[offset], 0x20); } } - else if ((address >= 0xA000) && (address <= 0xC000)) //Upper Bounds of memory map + else if ((address >= 0xA000) && (address <= 0xC000)) // Upper bounds of memory map { if (gb_cart->ram != nullptr) { @@ -323,7 +324,7 @@ static void write_gb_cart_mbc3(struct gb_cart* gb_cart, uint16_t address, const if ((address >= 0x0000) && (address <= 0x1FFF)) // We shouldn't be able to read/write to RAM unless this is toggled on { - //Enable / Disable RAM -- NOT WORKING -- FIXME + // Enable / Disable RAM -- NOT WORKING -- gb_cart->ram_enabled = (data[0] & 0x0F) == 0x0A; } else if ((address >= 0x2000) && (address <= 0x3FFF)) // ROM bank select @@ -331,14 +332,14 @@ static void write_gb_cart_mbc3(struct gb_cart* gb_cart, uint16_t address, const bank = data[0] & 0x7F; gb_cart->rom_bank = (bank == 0) ? 1 : bank; } - else if ((address >= 0x4000) && (address <= 0x5FFF)) // RAM/Clock bank select + else if ((address >= 0x4000) && (address <= 0x5FFF)) // RAM/clock bank select { if (gb_cart->ram != nullptr) { bank = data[0]; if (gb_cart->has_rtc && (bank >= 0x8 && bank <= 0xc)) { - //Set the bank for the timer + // Set the bank for the timer gb_cart->ram_bank = bank; } else @@ -349,10 +350,10 @@ static void write_gb_cart_mbc3(struct gb_cart* gb_cart, uint16_t address, const } else if ((address >= 0x6000) && (address <= 0x7FFF)) // Latch timer data { - //Implement RTC timer / latch + // Implement RTC timer / latch if (gb_cart->rtc_latch == 0 && data[0] == 1) { - //Update time + // Update time memoryUpdateMBC3Clock(gb_cart); for (int i = 0; i < 4; i++) { @@ -375,7 +376,7 @@ static void write_gb_cart_mbc3(struct gb_cart* gb_cart, uint16_t address, const } else if (gb_cart->has_rtc) { - /* RTC write */ + // RTC write gb_cart->rtc_data[gb_cart->ram_bank - 0x08] = data[0]; } } @@ -396,11 +397,11 @@ static void read_gb_cart_mbc5(struct gb_cart * gb_cart, uint16_t address, uint8_ { size_t offset; - if ((address < 0x4000)) //Rom Bank 0 + if ((address < 0x4000)) // ROM bank 0 { memcpy(data, &gb_cart->rom[address], 0x20); } - else if ((address >= 0x4000) && (address < 0x8000)) //Switchable ROM BANK + else if ((address >= 0x4000) && (address < 0x8000)) // Switchable ROM bank { offset = (address - 0x4000) + (gb_cart->rom_bank * 0x4000); if (offset < gb_cart->rom_size) @@ -408,7 +409,7 @@ static void read_gb_cart_mbc5(struct gb_cart * gb_cart, uint16_t address, uint8_ memcpy(data, &gb_cart->rom[offset], 0x20); } } - else if ((address >= 0xA000) && (address <= 0xC000)) //Upper bounds of memory map + else if ((address >= 0xA000) && (address <= 0xC000)) // Upper bounds of memory map { if (gb_cart->ram != nullptr) { @@ -427,7 +428,7 @@ static void write_gb_cart_mbc5(struct gb_cart* gb_cart, uint16_t address, const if ((address >= 0x0000) && (address <= 0x1FFF)) // We shouldn't be able to read/write to RAM unless this is toggled on { - //Enable / Disable RAM -- NOT WORKING -- CHECK ME + // Enable / Disable RAM -- NOT WORKING -- gb_cart->ram_enabled = (data[0] & 0x0F) == 0x0A; } else if ((address >= 0x2000) && (address <= 0x2FFF)) // ROM bank select, low bits @@ -474,11 +475,11 @@ static void read_gb_cart_pocket_cam(struct gb_cart * gb_cart, uint16_t address, { size_t offset; - if ((address < 0x4000)) //Rom Bank 0 + if ((address < 0x4000)) // ROM bank 0 { memcpy(data, &gb_cart->rom[address], 0x20); } - else if ((address >= 0x4000) && (address < 0x8000)) //Switchable ROM BANK + else if ((address >= 0x4000) && (address < 0x8000)) // Switchable ROM bank { offset = (address - 0x4000) + (gb_cart->rom_bank * 0x4000); if (offset < gb_cart->rom_size) @@ -486,20 +487,20 @@ static void read_gb_cart_pocket_cam(struct gb_cart * gb_cart, uint16_t address, memcpy(data, &gb_cart->rom[offset], 0x20); } } - else if ((address >= 0xA000) && (address <= 0xC000)) //Upper bounds of memory map + else if ((address >= 0xA000) && (address <= 0xC000)) // Upper bounds of memory map { - //Check to see if where currently in register mode + // Check to see if where currently in register mode if (gb_cart->ram != nullptr) { if (gb_cart->ram_bank & 0x10) { - //Where in register mode, based off NRAGE we just fill the memory with Zeroes. - //Seems to be incorrect behaviour but need to find more doccumentation + // When in register mode, based off of N-Rage code we just fill the memory with zeroes + // Seems to be incorrect behavior, but need to find more documentation memset(data, 0x00, 0x20); } else { - //Read RAM normally + // Read RAM normally offset = (address - 0xA000) + (gb_cart->ram_bank * 0x2000); if (offset < gb_cart->ram_size) { @@ -516,7 +517,7 @@ static void write_gb_cart_pocket_cam(struct gb_cart* gb_cart, uint16_t address, if ((address >= 0x0000) && (address <= 0x1FFF)) // We shouldn't be able to read/write to RAM unless this is toggled on { - //Enable / Disable RAM + // Enable / Disable RAM gb_cart->ram_enabled = (data[0] & 0x0F) == 0x0A; } else if ((address >= 0x2000) && (address <= 0x2FFF)) // ROM bank select, low bits @@ -524,18 +525,18 @@ static void write_gb_cart_pocket_cam(struct gb_cart* gb_cart, uint16_t address, gb_cart->rom_bank &= 0xFF00; gb_cart->rom_bank |= data[0]; } - else if ((address >= 0x4000) && (address <= 0x4FFF)) // Camera Register & RAM bank select + else if ((address >= 0x4000) && (address <= 0x4FFF)) // Camera register and RAM bank select { if (gb_cart->ram != nullptr) { if (data[0] & 0x10) { - //REGISTER MODE + // Register mode gb_cart->ram_bank = data[0]; } else { - //RAM MODE + // RAM mode gb_cart->ram_bank = data[0] & 0x0F; } } @@ -546,11 +547,11 @@ static void write_gb_cart_pocket_cam(struct gb_cart* gb_cart, uint16_t address, { if (gb_cart->ram_bank & 0x10) { - //REGISTER MODE (DO NOTHING) + // Register mode (do nothing) } else { - //RAM MODE + // RAM mode offset = (address - 0xA000) + (gb_cart->ram_bank * 0x2000); if (offset < gb_cart->ram_size) { @@ -688,10 +689,10 @@ bool GBCart::init_gb_cart(struct gb_cart* gb_cart, const char* gb_file) size_t ram_size = 0; CFile tempFile; - /* load GB cart ROM */ + // Load Game Boy cart ROM if (!tempFile.Open(gb_file, CFileBase::modeRead)) { - g_Notify->DisplayError("Failed to open Transferpak ROM"); + g_Notify->DisplayError("Failed to open Transfer Pak ROM"); return false; } @@ -706,7 +707,7 @@ bool GBCart::init_gb_cart(struct gb_cart* gb_cart, const char* gb_file) return false; } - /* get and parse cart type */ + // Get and parse cart type uint8_t cart_type = rom.get()[0x147]; type = parse_cart_type(cart_type); if (type == nullptr) @@ -714,7 +715,7 @@ bool GBCart::init_gb_cart(struct gb_cart* gb_cart, const char* gb_file) return false; } - /* load ram (if present) */ + // Load RAM (if present) if (type->extra_devices & GED_RAM) { ram_size = 0; @@ -737,14 +738,14 @@ bool GBCart::init_gb_cart(struct gb_cart* gb_cart, const char* gb_file) if (!tempFile.Open(g_Settings->LoadStringVal(Game_Transferpak_Sav).c_str(), CFileBase::modeRead)) { - g_Notify->DisplayError("Failed to open Transferpak SAV File"); + g_Notify->DisplayError("Failed to open Transfer Pak SAV file"); return false; } tempFile.Read(ram.get(), ram_size); } - //If we have RTC we need to load in the data, we assume the save will use the VBA-M format + // If we have RTC we need to load in the data, we assume the save will use the VBA-M format if (type->extra_devices & GED_RTC) { tempFile.Read(&gb_cart->rtc_data[0], 4); @@ -763,7 +764,7 @@ bool GBCart::init_gb_cart(struct gb_cart* gb_cart, const char* gb_file) tempFile.Close(); } - /* update gb_cart */ + // Update gb_cart gb_cart->rom = rom.release(); gb_cart->ram = ram.release(); gb_cart->rom_size = rom_size; diff --git a/Source/Project64-core/N64System/Mips/GBCart.h b/Source/Project64-core/N64System/Mips/GBCart.h index 108cfe2d5..da1cc006d 100644 --- a/Source/Project64-core/N64System/Mips/GBCart.h +++ b/Source/Project64-core/N64System/Mips/GBCart.h @@ -38,6 +38,3 @@ public: static void read_gb_cart(struct gb_cart* gb_cart, uint16_t address, uint8_t* data); static void write_gb_cart(struct gb_cart* gb_cart, uint16_t address, const uint8_t* data); }; - - - diff --git a/Source/Project64-core/N64System/Mips/MemoryVirtualMem.cpp b/Source/Project64-core/N64System/Mips/MemoryVirtualMem.cpp index cc1c967e3..3e070a5cc 100755 --- a/Source/Project64-core/N64System/Mips/MemoryVirtualMem.cpp +++ b/Source/Project64-core/N64System/Mips/MemoryVirtualMem.cpp @@ -141,7 +141,7 @@ bool CMipsMemoryVM::Initialize(bool SyncSystem) } if (m_RDRAM == nullptr) { - WriteTrace(TraceN64System, TraceError, "Failed to Reserve RDRAM (Size: 0x%X)", 0x20000000); + WriteTrace(TraceN64System, TraceError, "Failed to reserve RDRAM (Size: 0x%X)", 0x20000000); FreeMemory(); return false; } @@ -149,14 +149,14 @@ bool CMipsMemoryVM::Initialize(bool SyncSystem) m_AllocatedRdramSize = g_Settings->LoadDword(Game_RDRamSize); if (CommitMemory(m_RDRAM, m_AllocatedRdramSize, MEM_READWRITE) == nullptr) { - WriteTrace(TraceN64System, TraceError, "Failed to Allocate RDRAM (Size: 0x%X)", m_AllocatedRdramSize); + WriteTrace(TraceN64System, TraceError, "Failed to allocate RDRAM (Size: 0x%X)", m_AllocatedRdramSize); FreeMemory(); return false; } if (CommitMemory(m_RDRAM + 0x04000000, 0x2000, MEM_READWRITE) == nullptr) { - WriteTrace(TraceN64System, TraceError, "Failed to Allocate DMEM/IMEM (Size: 0x%X)", 0x2000); + WriteTrace(TraceN64System, TraceError, "Failed to allocate DMEM/IMEM (Size: 0x%X)", 0x2000); FreeMemory(); return false; } @@ -171,7 +171,7 @@ bool CMipsMemoryVM::Initialize(bool SyncSystem) m_RomSize = g_Rom->GetRomSize(); if (CommitMemory(m_Rom, g_Rom->GetRomSize(), MEM_READWRITE) == nullptr) { - WriteTrace(TraceN64System, TraceError, "Failed to Allocate Rom (Size: 0x%X)", g_Rom->GetRomSize()); + WriteTrace(TraceN64System, TraceError, "Failed to allocate ROM (Size: 0x%X)", g_Rom->GetRomSize()); FreeMemory(); return false; } @@ -186,7 +186,7 @@ bool CMipsMemoryVM::Initialize(bool SyncSystem) m_RomSize = g_Rom->GetRomSize(); } - //64DD IPL + // 64DD IPL if (g_DDRom != nullptr) { if (g_Settings->LoadBool(Game_LoadRomToMemory)) @@ -196,7 +196,7 @@ bool CMipsMemoryVM::Initialize(bool SyncSystem) m_DDRomSize = g_DDRom->GetRomSize(); if (CommitMemory(m_DDRom, g_DDRom->GetRomSize(), MEM_READWRITE) == nullptr) { - WriteTrace(TraceN64System, TraceError, "Failed to Allocate Rom (Size: 0x%X)", g_DDRom->GetRomSize()); + WriteTrace(TraceN64System, TraceError, "Failed to allocate ROM (Size: 0x%X)", g_DDRom->GetRomSize()); FreeMemory(); return false; } @@ -217,7 +217,7 @@ bool CMipsMemoryVM::Initialize(bool SyncSystem) m_TLB_ReadMap = new size_t[0x100000]; if (m_TLB_ReadMap == nullptr) { - WriteTrace(TraceN64System, TraceError, "Failed to Allocate m_TLB_ReadMap (Size: 0x%X)", 0x100000 * sizeof(size_t)); + WriteTrace(TraceN64System, TraceError, "Failed to allocate m_TLB_ReadMap (Size: 0x%X)", 0x100000 * sizeof(size_t)); FreeMemory(); return false; } @@ -225,7 +225,7 @@ bool CMipsMemoryVM::Initialize(bool SyncSystem) m_TLB_WriteMap = new size_t[0x100000]; if (m_TLB_WriteMap == nullptr) { - WriteTrace(TraceN64System, TraceError, "Failed to Allocate m_TLB_WriteMap (Size: 0x%X)", 0xFFFFF * sizeof(size_t)); + WriteTrace(TraceN64System, TraceError, "Failed to allocate m_TLB_WriteMap (Size: 0x%X)", 0xFFFFF * sizeof(size_t)); FreeMemory(); return false; } @@ -583,7 +583,7 @@ bool CMipsMemoryVM::VAddrToRealAddr(uint32_t VAddr, void * &RealAddress) const bool CMipsMemoryVM::TranslateVaddr(uint32_t VAddr, uint32_t &PAddr) const { - //Change the Virtual address to a Physical Address + // Change the virtual address to a physical address if (m_TLB_ReadMap[VAddr >> 12] == 0) { return false; @@ -807,7 +807,7 @@ bool CMipsMemoryVM::SW_NonMemory(uint32_t PAddr, uint32_t Value) VirtualProtect(ROM, RomFileSize, PAGE_NOACCESS, &OldProtect); } #endif - //LogMessage("%X: Wrote To Rom %08X from %08X",PROGRAM_COUNTER,Value,PAddr); + //LogMessage("%X: Wrote To ROM %08X from %08X",PROGRAM_COUNTER,Value,PAddr); } else { @@ -916,7 +916,7 @@ void CMipsMemoryVM::ProtectMemory(uint32_t StartVaddr, uint32_t EndVaddr) return; } - //Get Physical Addresses passed + // Get physical addresses passed uint32_t StartPAddr, EndPAddr; if (!TranslateVaddr(StartVaddr, StartPAddr)) { @@ -927,14 +927,14 @@ void CMipsMemoryVM::ProtectMemory(uint32_t StartVaddr, uint32_t EndVaddr) g_Notify->BreakPoint(__FILE__, __LINE__); } - //Get Length of memory being protected + // Get length of memory being protected int32_t Length = ((EndPAddr + 3) - StartPAddr) & ~3; if (Length < 0) { g_Notify->BreakPoint(__FILE__, __LINE__); } - //Protect that memory address space + // Protect that memory address space uint8_t * MemLoc = Rdram() + StartPAddr; WriteTrace(TraceProtectedMem, TraceDebug, "Paddr: %08X Length: %X", StartPAddr, Length); @@ -946,7 +946,7 @@ void CMipsMemoryVM::UnProtectMemory(uint32_t StartVaddr, uint32_t EndVaddr) WriteTrace(TraceProtectedMem, TraceDebug, "StartVaddr: %08X EndVaddr: %08X", StartVaddr, EndVaddr); if (!ValidVaddr(StartVaddr) || !ValidVaddr(EndVaddr)) { return; } - //Get Physical Addresses passed + // Get physical addresses passed uint32_t StartPAddr, EndPAddr; if (!TranslateVaddr(StartVaddr, StartPAddr)) { @@ -957,7 +957,7 @@ void CMipsMemoryVM::UnProtectMemory(uint32_t StartVaddr, uint32_t EndVaddr) g_Notify->BreakPoint(__FILE__, __LINE__); } - //Get Length of memory being protected + // Get length of memory being protected int32_t Length = ((EndPAddr + 3) - StartPAddr) & ~3; if (Length < 0) { @@ -1028,15 +1028,15 @@ void CMipsMemoryVM::RdramChanged(CMipsMemoryVM * _this) void * result = CommitMemory(_this->m_RDRAM + old_size, new_size - old_size, MEM_READWRITE); if (result == nullptr) { - WriteTrace(TraceN64System, TraceError, "failed to allocate extended memory"); + WriteTrace(TraceN64System, TraceError, "Failed to allocate extended memory"); g_Notify->FatalError(GS(MSG_MEM_ALLOC_ERROR)); } } if (new_size > 0xFFFFFFFFul) - { // should be unreachable because: size_t new_size = g_Settings->(uint32_t) + { // Should be unreachable because: size_t new_size = g_Settings->(uint32_t) g_Notify->BreakPoint(__FILE__, __LINE__); - } // ...However, FFFFFFFF also is a limit to RCP addressing, so we care. + } // However, FFFFFFFF also is a limit to RCP addressing, so we care _this->m_AllocatedRdramSize = (uint32_t)new_size; } @@ -1432,7 +1432,7 @@ void CMipsMemoryVM::Load32SerialInterface(void) void CMipsMemoryVM::Load32CartridgeDomain1Address1(void) { - //64DD IPL ROM + // 64DD IPL ROM if (g_DDRom != nullptr && (m_MemLookupAddress & 0xFFFFFF) < g_MMU->m_DDRomSize) { m_MemLookupValue.UW[0] = *(uint32_t *)&g_MMU->m_DDRom[(m_MemLookupAddress & 0xFFFFFF)]; @@ -1452,7 +1452,7 @@ void CMipsMemoryVM::Load32CartridgeDomain1Address3(void) void CMipsMemoryVM::Load32CartridgeDomain2Address1(void) { - //64DD REGISTERS + // 64DD registers if (g_Settings->LoadBool(Setting_EnableDisk)) { switch (m_MemLookupAddress & 0x1FFFFFFF) @@ -1509,7 +1509,7 @@ void CMipsMemoryVM::Load32CartridgeDomain2Address2(void) } if (g_System->m_SaveUsing == SaveChip_Sram) { - //Load Sram + // Load SRAM uint8_t tmp[4] = ""; g_MMU->DmaFromSram(tmp, offset, 4); m_MemLookupValue.UW[0] = tmp[3] << 24 | tmp[2] << 16 | tmp[1] << 8 | tmp[0]; @@ -1561,7 +1561,7 @@ void CMipsMemoryVM::Load32Rom(void) if (g_MMU->m_RomWrittenTo) { m_MemLookupValue.UW[0] = g_MMU->m_RomWroteValue; - //LogMessage("%X: Read crap from Rom %08X from %08X",PROGRAM_COUNTER,*Value,PAddr); + //LogMessage("%X: Read crap from ROM %08X from %08X",PROGRAM_COUNTER,*Value,PAddr); g_MMU->m_RomWrittenTo = false; #ifdef ROM_IN_MAPSPACE { @@ -2021,7 +2021,7 @@ void CMipsMemoryVM::Write32AudioInterface(void) break; case 0x04500008: g_Reg->AI_CONTROL_REG = (m_MemLookupValue.UW[0] & 1); break; case 0x0450000C: - /* Clear Interrupt */; + // Clear interrupt g_Reg->MI_INTR_REG &= ~MI_INTR_AI; g_Reg->m_AudioIntrReg &= ~MI_INTR_AI; g_Reg->CheckInterrupts(); @@ -2138,7 +2138,7 @@ void CMipsMemoryVM::Write32SerialInterface(void) void CMipsMemoryVM::Write32CartridgeDomain2Address1(void) { - //64DD Registers + // 64DD registers if (g_Settings->LoadBool(Setting_EnableDisk)) { switch (m_MemLookupAddress & 0xFFFFFFF) @@ -2174,7 +2174,7 @@ void CMipsMemoryVM::Write32CartridgeDomain2Address2(void) uint32_t offset = (m_MemLookupAddress & 0x1FFFFFFF) - 0x08000000; if (g_System->m_SaveUsing == SaveChip_Sram && offset < 0x8000) { - //Store Sram + // Store SRAM uint8_t tmp[4] = ""; tmp[0] = 0xFF & (m_MemLookupValue.UW[0]); tmp[1] = 0xFF & (m_MemLookupValue.UW[0] >> 8); diff --git a/Source/Project64-core/N64System/Mips/MemoryVirtualMem.h b/Source/Project64-core/N64System/Mips/MemoryVirtualMem.h index f7d295a94..28ed13da0 100644 --- a/Source/Project64-core/N64System/Mips/MemoryVirtualMem.h +++ b/Source/Project64-core/N64System/Mips/MemoryVirtualMem.h @@ -14,14 +14,14 @@ #ifndef _WIN32 #include -/* siginfo_t */ +// siginfo_t #endif /* -* To do: Have address translation functions here? +* TODO: Have address translation functions here? * `return` either the translated address or the mask to XOR by? * -* This will help us gradually be able to port Project64 for big-endian CPUs. +* This will help us gradually be able to port Project64 to big-endian CPUs. * Currently it is written to assume 32-bit little-endian, like so: * * 0xAABBCCDD EEFFGGHH --> 0xDDCCBBAA HHGGFFEE @@ -88,11 +88,11 @@ public: static void segv_handler(int signal, siginfo_t *siginfo, void *sigcontext); #endif - //Protect the Memory from being written to + // Protect the memory from being written to void ProtectMemory(uint32_t StartVaddr, uint32_t EndVaddr); void UnProtectMemory(uint32_t StartVaddr, uint32_t EndVaddr); - //Functions for TLB notification + // Functions for TLB notification void TLB_Mapped(uint32_t VAddr, uint32_t Len, uint32_t PAddr, bool bReadOnly); void TLB_Unmaped(uint32_t Vaddr, uint32_t Len); @@ -179,35 +179,35 @@ private: static bool FilterArmException(uint32_t MemAddress, mcontext_t & context); #endif - //Memory Locations + // Memory locations static uint8_t * m_Reserve1, *m_Reserve2; uint8_t * m_RDRAM, *m_DMEM, *m_IMEM; uint32_t m_AllocatedRdramSize; - //Rom Information + // ROM information bool m_RomMapped; uint8_t * m_Rom; uint32_t m_RomSize; bool m_RomWrittenTo; uint32_t m_RomWroteValue; - //DDRom Information + // DDRom information bool m_DDRomMapped; uint8_t * m_DDRom; uint32_t m_DDRomSize; - //Current Half line + //Current half line void UpdateHalfLine(); uint32_t m_HalfLine; uint32_t m_HalfLineCheck; uint32_t m_FieldSerration; - //Initializing and resetting information about the memory system + // Initializing and resetting information about the memory system void FreeMemory(); mutable char m_strLabelName[100]; - //BIG look up table to quickly translate the tlb to real mem address + // Big look up table to quickly translate the TLB to real memory addresses size_t * m_TLB_ReadMap; size_t * m_TLB_WriteMap; diff --git a/Source/Project64-core/N64System/Mips/Mempak.cpp b/Source/Project64-core/N64System/Mips/Mempak.cpp index c29bd1199..a3a016671 100644 --- a/Source/Project64-core/N64System/Mips/Mempak.cpp +++ b/Source/Project64-core/N64System/Mips/Mempak.cpp @@ -165,7 +165,7 @@ void CMempak::ReadFrom(int32_t Control, uint32_t address, uint8_t * data) else { memset(data, 0x00, 0x20); - /* Rumble pack area */ + // Rumble pack area } } @@ -192,6 +192,6 @@ void CMempak::WriteTo(int32_t Control, uint32_t address, uint8_t * data) } else { - /* Rumble pack area */ + // Rumble pack area } } \ No newline at end of file diff --git a/Source/Project64-core/N64System/Mips/OpcodeName.cpp b/Source/Project64-core/N64System/Mips/OpcodeName.cpp index 96d63fd37..be2a1bc99 100644 --- a/Source/Project64-core/N64System/Mips/OpcodeName.cpp +++ b/Source/Project64-core/N64System/Mips/OpcodeName.cpp @@ -557,7 +557,7 @@ const char * R4300iOpcodeName(uint32_t OpCode, uint32_t PC) sprintf(CommandName, "ADDI\t%s, %s, 0x%04X", CRegName::GPR[command.rt], CRegName::GPR[command.rs], command.immediate); break; case R4300i_ADDIU: - // special case for stack + // Special case for stack if (command.rt == 29) { short imm = (short)command.immediate; diff --git a/Source/Project64-core/N64System/Mips/PifRam.cpp b/Source/Project64-core/N64System/Mips/PifRam.cpp index 7987d02d9..6e9a7696a 100644 --- a/Source/Project64-core/N64System/Mips/PifRam.cpp +++ b/Source/Project64-core/N64System/Mips/PifRam.cpp @@ -84,7 +84,7 @@ void CPifRam::PifRamRead() case 0xFD: CurPos = 0x40; break; case 0xFE: CurPos = 0x40; break; case 0xFF: break; - case 0xB4: case 0x56: case 0xB8: break; /* ??? */ + case 0xB4: case 0x56: case 0xB8: break; default: if ((m_PifRam[CurPos] & 0xC0) == 0) { @@ -109,7 +109,7 @@ void CPifRam::PifRamRead() { if (CurPos != 0x27 && bShowPifRamErrors()) { - g_Notify->DisplayError(stdstr_f("Unknown Command in PifRamRead(%X)", m_PifRam[CurPos]).c_str()); + g_Notify->DisplayError(stdstr_f("Unknown command in PifRamRead(%X)", m_PifRam[CurPos]).c_str()); } CurPos = 0x40; } @@ -132,7 +132,7 @@ void CPifRam::PifRamWrite() switch (m_PifRam[0x3F]) { case 0x02: - // format the 'challenge' message into 30 nibbles for X-Scale's CIC code + // Format the 'challenge' message into 30 nibbles for X-Scale's CIC code { char Challenge[30], Response[30]; for (int32_t i = 0; i < 15; i++) @@ -174,7 +174,7 @@ void CPifRam::PifRamWrite() default: if (bShowPifRamErrors()) { - g_Notify->DisplayError(stdstr_f("Unkown PifRam control: %d", m_PifRam[0x3F]).c_str()); + g_Notify->DisplayError(stdstr_f("Unknown PifRam control: %d", m_PifRam[0x3F]).c_str()); } } return; @@ -194,7 +194,7 @@ void CPifRam::PifRamWrite() case 0xFD: CurPos = 0x40; break; case 0xFE: CurPos = 0x40; break; case 0xFF: break; - case 0xB4: case 0x56: case 0xB8: break; /* ??? */ + case 0xB4: case 0x56: case 0xB8: break; // ??? default: if ((m_PifRam[CurPos] & 0xC0) == 0) { @@ -254,7 +254,7 @@ void CPifRam::SI_DMA_READ() { if (bShowPifRamErrors()) { - g_Notify->DisplayError(stdstr_f("%s\nSI_DRAM_ADDR_REG not in RDRam space", __FUNCTION__).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nSI_DRAM_ADDR_REG not in RDRAM space", __FUNCTION__).c_str()); } return; } @@ -354,7 +354,7 @@ void CPifRam::SI_DMA_WRITE() { if (bShowPifRamErrors()) { - g_Notify->DisplayError("SI DMA\nSI_DRAM_ADDR_REG not in RDRam space"); + g_Notify->DisplayError("SI DMA\nSI_DRAM_ADDR_REG not in RDRAM space"); } return; } @@ -388,7 +388,7 @@ void CPifRam::SI_DMA_WRITE() int32_t count; char HexData[100], AsciiData[100], Addon[20]; LogMessage(""); - LogMessage("\tData DMAed to the Pif Ram:"); + LogMessage("\tData DMAed to the PIF RAM:"); LogMessage("\t--------------------------"); for (count = 0; count < 16; count++) { @@ -440,8 +440,8 @@ void CPifRam::ProcessControllerCommand(int32_t Control, uint8_t * Command) switch (Command[2]) { - case 0x00: // check - case 0xFF: // reset & check ? + case 0x00: // Check + case 0xFF: // Reset and check? if ((Command[1] & 0x80) != 0) { break; @@ -450,7 +450,7 @@ void CPifRam::ProcessControllerCommand(int32_t Control, uint8_t * Command) { if (Command[0] != 1 || Command[1] != 3) { - g_Notify->DisplayError("What am I meant to do with this Controller Command"); + g_Notify->DisplayError("What am I meant to do with this controller command?"); } } if (Controllers[Control].Present != 0) @@ -472,12 +472,12 @@ void CPifRam::ProcessControllerCommand(int32_t Control, uint8_t * Command) Command[1] |= 0x80; } break; - case 0x01: // read controller + case 0x01: // Read controller if (bShowPifRamErrors()) { if (Command[0] != 1 || Command[1] != 4) { - g_Notify->DisplayError("What am I meant to do with this Controller Command"); + g_Notify->DisplayError("What am I meant to do with this controller command?"); } } if (Controllers[Control].Present == false) @@ -485,16 +485,16 @@ void CPifRam::ProcessControllerCommand(int32_t Control, uint8_t * Command) Command[1] |= 0x80; } break; - case 0x02: //read from controller pack + case 0x02: // Read from controller pak if (LogControllerPak()) { - LogControllerPakData("Read: Before Gettting Results"); + LogControllerPakData("Read: before getting results"); } if (bShowPifRamErrors()) { if (Command[0] != 3 || Command[1] != 33) { - g_Notify->DisplayError("What am I meant to do with this Controller Command"); + g_Notify->DisplayError("What am I meant to do with this controller command?"); } } if (Controllers[Control].Present != 0) @@ -523,19 +523,19 @@ void CPifRam::ProcessControllerCommand(int32_t Control, uint8_t * Command) } if (LogControllerPak()) { - LogControllerPakData("Read: After Gettting Results"); + LogControllerPakData("Read: after getting results"); } break; - case 0x03: //write controller pak + case 0x03: // Write controller pak if (LogControllerPak()) { - LogControllerPakData("Write: Before Processing"); + LogControllerPakData("Write: before processing"); } if (bShowPifRamErrors()) { if (Command[0] != 35 || Command[1] != 1) { - g_Notify->DisplayError("What am I meant to do with this Controller Command"); + g_Notify->DisplayError("What am I meant to do with this controller command?"); } } if (Controllers[Control].Present != 0) @@ -562,7 +562,7 @@ void CPifRam::ProcessControllerCommand(int32_t Control, uint8_t * Command) } if (LogControllerPak()) { - LogControllerPakData("Write: After Processing"); + LogControllerPakData("Write: after processing"); } break; default: @@ -579,19 +579,19 @@ void CPifRam::ReadControllerCommand(int32_t Control, uint8_t * Command) switch (Command[2]) { - case 0x01: // read controller + case 0x01: // Read controller if (Controllers[Control].Present != 0) { if (bShowPifRamErrors()) { - if (Command[0] != 1 || Command[1] != 4) { g_Notify->DisplayError("What am I meant to do with this Controller Command"); } + if (Command[0] != 1 || Command[1] != 4) { g_Notify->DisplayError("What am I meant to do with this controller command?"); } } const uint32_t buttons = g_BaseSystem->GetButtons(Control); memcpy(&Command[3], &buttons, sizeof(uint32_t)); } break; - case 0x02: //read from controller pack + case 0x02: // Read from controller pak if (Controllers[Control].Present != 0) { switch (Controllers[Control].Plugin) @@ -600,7 +600,7 @@ void CPifRam::ReadControllerCommand(int32_t Control, uint8_t * Command) } } break; - case 0x03: //write controller pak + case 0x03: // Write controller pak if (Controllers[Control].Present != 0) { switch (Controllers[Control].Plugin) diff --git a/Source/Project64-core/N64System/Mips/Register.cpp b/Source/Project64-core/N64System/Mips/Register.cpp index 36efb5f0b..06830331c 100644 --- a/Source/Project64-core/N64System/Mips/Register.cpp +++ b/Source/Project64-core/N64System/Mips/Register.cpp @@ -261,7 +261,7 @@ void CRegisters::Reset() m_LLBit = 0; - //Reset System Registers + // Reset system registers memset(m_RDRAM_Interface, 0, sizeof(m_RDRAM_Interface)); memset(m_RDRAM_Registers, 0, sizeof(m_RDRAM_Registers)); memset(m_Mips_Interface, 0, sizeof(m_Mips_Interface)); @@ -350,11 +350,11 @@ void CRegisters::DoAddressError(bool DelaySlot, uint32_t BadVaddr, bool FromRead g_Notify->DisplayError(stdstr_f("AddressError %s Vaddr: %X", FromRead ? "reading" : "writing", BadVaddr).c_str()); if ((STATUS_REGISTER & STATUS_EXL) != 0) { - g_Notify->DisplayError("EXL set in AddressError Exception"); + g_Notify->DisplayError("EXL set in AddressError exception"); } if ((STATUS_REGISTER & STATUS_ERL) != 0) { - g_Notify->DisplayError("ERL set in AddressError Exception"); + g_Notify->DisplayError("ERL set in AddressError exception"); } } @@ -406,11 +406,11 @@ void CRegisters::DoBreakException(bool DelaySlot) { if ((STATUS_REGISTER & STATUS_EXL) != 0) { - g_Notify->DisplayError("EXL set in Break Exception"); + g_Notify->DisplayError("EXL set in break exception"); } if ((STATUS_REGISTER & STATUS_ERL) != 0) { - g_Notify->DisplayError("ERL set in Break Exception"); + g_Notify->DisplayError("ERL set in break exception"); } } @@ -450,11 +450,11 @@ void CRegisters::DoCopUnusableException(bool DelaySlot, int32_t Coprocessor) { if ((STATUS_REGISTER & STATUS_EXL) != 0) { - g_Notify->DisplayError("EXL set in Break Exception"); + g_Notify->DisplayError("EXL set in break exception"); } if ((STATUS_REGISTER & STATUS_ERL) != 0) { - g_Notify->DisplayError("ERL set in Break Exception"); + g_Notify->DisplayError("ERL set in break exception"); } } @@ -495,7 +495,7 @@ bool CRegisters::DoIntrException(bool DelaySlot) if (GenerateLog() && LogExceptions() && !LogNoInterrupts()) { - LogMessage("%08X: Interrupt Generated", m_PROGRAM_COUNTER); + LogMessage("%08X: Interrupt generated", m_PROGRAM_COUNTER); } CAUSE_REGISTER = FAKE_CAUSE_REGISTER; @@ -548,7 +548,7 @@ void CRegisters::DoTLBReadMiss(bool DelaySlot, uint32_t BadVaddr) { if (HaveDebugger()) { - g_Notify->DisplayError(stdstr_f("TLBMiss - EXL Set\nBadVaddr = %X\nAddress Defined: %s", BadVaddr, g_TLB->AddressDefined(BadVaddr) ? "true" : "false").c_str()); + g_Notify->DisplayError(stdstr_f("TLBMiss - EXL set\nBadVaddr = %X\nAddress defined: %s", BadVaddr, g_TLB->AddressDefined(BadVaddr) ? "true" : "false").c_str()); } m_PROGRAM_COUNTER = 0x80000180; } @@ -586,7 +586,7 @@ void CRegisters::DoTLBWriteMiss(bool DelaySlot, uint32_t BadVaddr) { if (HaveDebugger()) { - g_Notify->DisplayError(stdstr_f("TLBMiss - EXL Set\nBadVaddr = %X\nAddress Defined: %s", BadVaddr, g_TLB->AddressDefined(BadVaddr) ? "true" : "false").c_str()); + g_Notify->DisplayError(stdstr_f("TLBMiss - EXL set\nBadVaddr = %X\nAddress defined: %s", BadVaddr, g_TLB->AddressDefined(BadVaddr) ? "true" : "false").c_str()); } m_PROGRAM_COUNTER = 0x80000180; } @@ -598,11 +598,11 @@ void CRegisters::DoSysCallException(bool DelaySlot) { if ((STATUS_REGISTER & STATUS_EXL) != 0) { - g_Notify->DisplayError("EXL set in SysCall Exception"); + g_Notify->DisplayError("EXL set in syscall exception"); } if ((STATUS_REGISTER & STATUS_ERL) != 0) { - g_Notify->DisplayError("ERL set in SysCall Exception"); + g_Notify->DisplayError("ERL set in syscall exception"); } } diff --git a/Source/Project64-core/N64System/Mips/Register.h b/Source/Project64-core/N64System/Mips/Register.h index 4a35496fa..b5591b0a5 100644 --- a/Source/Project64-core/N64System/Mips/Register.h +++ b/Source/Project64-core/N64System/Mips/Register.h @@ -6,7 +6,7 @@ #include #include -//CPO registers by name +// CPO registers by name class CP0registers { protected: @@ -39,17 +39,17 @@ private: CP0registers& operator=(const CP0registers&); }; -//CPO register flags +// CPO register flags enum { - //Status Register + // Status register STATUS_IE = 0x00000001, STATUS_EXL = 0x00000002, STATUS_ERL = 0x00000004, STATUS_IP0 = 0x00000100, STATUS_IP1 = 0x00000200, STATUS_IP2 = 0x00000400, STATUS_IP3 = 0x00000800, STATUS_IP4 = 0x00001000, STATUS_IP5 = 0x00002000, STATUS_IP6 = 0x00004000, STATUS_IP7 = 0x00008000, STATUS_BEV = 0x00400000, STATUS_FR = 0x04000000, STATUS_CU0 = 0x10000000, STATUS_CU1 = 0x20000000, - //Cause Flags + // Cause flags CAUSE_EXC_CODE = 0xFF, CAUSE_IP0 = 0x100, CAUSE_IP1 = 0x200, @@ -61,56 +61,56 @@ enum CAUSE_IP7 = 0x8000, CAUSE_BD = 0x80000000, - //Cause exception ID's - EXC_INT = 0, /* interrupt */ - EXC_MOD = 4, /* TLB mod */ - EXC_RMISS = 8, /* Read TLB Miss */ - EXC_WMISS = 12, /* Write TLB Miss */ - EXC_RADE = 16, /* Read Address Error */ - EXC_WADE = 20, /* Write Address Error */ - EXC_IBE = 24, /* Instruction Bus Error */ - EXC_DBE = 28, /* Data Bus Error */ - EXC_SYSCALL = 32, /* SYSCALL */ - EXC_BREAK = 36, /* BREAKpoint */ - EXC_II = 40, /* Illegal Instruction */ - EXC_CPU = 44, /* CoProcessor Unusable */ - EXC_OV = 48, /* OVerflow */ - EXC_TRAP = 52, /* Trap exception */ - EXC_VCEI = 56, /* Virt. Coherency on Inst. fetch */ - EXC_FPE = 60, /* Floating Point Exception */ - EXC_WATCH = 92, /* Watchpoint reference */ - EXC_VCED = 124,/* Virt. Coherency on data read */ + // Cause exception ID's + EXC_INT = 0, // Interrupt + EXC_MOD = 4, // TLB mod + EXC_RMISS = 8, // Read TLB miss + EXC_WMISS = 12, // Write TLB miss + EXC_RADE = 16, // Read address error + EXC_WADE = 20, // Write address error + EXC_IBE = 24, // Instruction bus error + EXC_DBE = 28, // Data bus error + EXC_SYSCALL = 32, // Syscall + EXC_BREAK = 36, // Breakpoint + EXC_II = 40, // Illegal instruction + EXC_CPU = 44, // Co-processor unusable + EXC_OV = 48, // Overflow + EXC_TRAP = 52, // Trap exception + EXC_VCEI = 56, // Virtual coherency on instruction fetch + EXC_FPE = 60, // Floating point exception + EXC_WATCH = 92, // Watchpoint reference + EXC_VCED = 124, // Virtual coherency on data read }; -//Float point control status register flags +// Float point control status register flags enum { - FPCSR_FS = 0x01000000, /* flush denorm to zero */ - FPCSR_C = 0x00800000, /* condition bit */ - FPCSR_CE = 0x00020000, /* cause: unimplemented operation */ - FPCSR_CV = 0x00010000, /* cause: invalid operation */ - FPCSR_CZ = 0x00008000, /* cause: division by zero */ - FPCSR_CO = 0x00004000, /* cause: overflow */ - FPCSR_CU = 0x00002000, /* cause: underflow */ - FPCSR_CI = 0x00001000, /* cause: inexact operation */ - FPCSR_EV = 0x00000800, /* enable: invalid operation */ - FPCSR_EZ = 0x00000400, /* enable: division by zero */ - FPCSR_EO = 0x00000200, /* enable: overflow */ - FPCSR_EU = 0x00000100, /* enable: underflow */ - FPCSR_EI = 0x00000080, /* enable: inexact operation */ - FPCSR_FV = 0x00000040, /* flag: invalid operation */ - FPCSR_FZ = 0x00000020, /* flag: division by zero */ - FPCSR_FO = 0x00000010, /* flag: overflow */ - FPCSR_FU = 0x00000008, /* flag: underflow */ - FPCSR_FI = 0x00000004, /* flag: inexact operation */ - FPCSR_RM_MASK = 0x00000003, /* rounding mode mask */ - FPCSR_RM_RN = 0x00000000, /* round to nearest */ - FPCSR_RM_RZ = 0x00000001, /* round to zero */ - FPCSR_RM_RP = 0x00000002, /* round to positive infinity */ - FPCSR_RM_RM = 0x00000003, /* round to negative infinity */ + FPCSR_FS = 0x01000000, // Flush denormalization to zero + FPCSR_C = 0x00800000, // Condition bit + FPCSR_CE = 0x00020000, // Cause: unimplemented operation + FPCSR_CV = 0x00010000, // Cause: invalid operation + FPCSR_CZ = 0x00008000, // Cause: division by zero + FPCSR_CO = 0x00004000, // Cause: overflow + FPCSR_CU = 0x00002000, // Cause: underflow + FPCSR_CI = 0x00001000, // Cause: inexact operation + FPCSR_EV = 0x00000800, // Enable: invalid operation + FPCSR_EZ = 0x00000400, // Enable: division by zero + FPCSR_EO = 0x00000200, // Enable: overflow + FPCSR_EU = 0x00000100, // Enable: underflow + FPCSR_EI = 0x00000080, // Enable: inexact operation + FPCSR_FV = 0x00000040, // Flag: invalid operation + FPCSR_FZ = 0x00000020, // Flag: division by zero + FPCSR_FO = 0x00000010, // Flag: overflow + FPCSR_FU = 0x00000008, // Flag: underflow + FPCSR_FI = 0x00000004, // Flag: inexact operation + FPCSR_RM_MASK = 0x00000003, // Rounding mode mask + FPCSR_RM_RN = 0x00000000, // Round to nearest + FPCSR_RM_RZ = 0x00000001, // Round to zero + FPCSR_RM_RP = 0x00000002, // Round to positive infinity + FPCSR_RM_RM = 0x00000003, // Round to negative infinity }; -//Rdram Registers +// RDRAM registers class Rdram_InterfaceReg { protected: @@ -135,7 +135,7 @@ private: Rdram_InterfaceReg& operator=(const Rdram_InterfaceReg&); }; -//Mips interface registers +// MIPS interface registers class Mips_InterfaceReg { protected: @@ -155,52 +155,52 @@ private: Mips_InterfaceReg& operator=(const Mips_InterfaceReg&); }; -//Mips interface flags +// MIPS interface flags enum { - MI_MODE_INIT = 0x0080, /* Bit 7: init mode */ - MI_MODE_EBUS = 0x0100, /* Bit 8: ebus test mode */ - MI_MODE_RDRAM = 0x0200, /* Bit 9: RDRAM reg mode */ + MI_MODE_INIT = 0x0080, // Bit 7: Initialization mode + MI_MODE_EBUS = 0x0100, // Bit 8: EBUS test mode + MI_MODE_RDRAM = 0x0200, // Bit 9: RDRAM register mode - MI_CLR_INIT = 0x0080, /* Bit 7: clear init mode */ - MI_SET_INIT = 0x0100, /* Bit 8: set init mode */ - MI_CLR_EBUS = 0x0200, /* Bit 9: clear ebus test */ - MI_SET_EBUS = 0x0400, /* Bit 10: set ebus test mode */ - MI_CLR_DP_INTR = 0x0800, /* Bit 11: clear dp interrupt */ - MI_CLR_RDRAM = 0x1000, /* Bit 12: clear RDRAM reg */ - MI_SET_RDRAM = 0x2000, /* Bit 13: set RDRAM reg mode */ + MI_CLR_INIT = 0x0080, // Bit 7: Clear initialization mode + MI_SET_INIT = 0x0100, // Bit 8: Set initialization mode + MI_CLR_EBUS = 0x0200, // Bit 9: Clear EBUS test + MI_SET_EBUS = 0x0400, // Bit 10: Set EBUS test mode + MI_CLR_DP_INTR = 0x0800, // Bit 11: Clear DP interrupt + MI_CLR_RDRAM = 0x1000, // Bit 12: Clear RDRAM register + MI_SET_RDRAM = 0x2000, // Bit 13: Set RDRAM register mode - //Flags for writing to MI_INTR_MASK_REG - MI_INTR_MASK_CLR_SP = 0x0001, /* Bit 0: clear SP mask */ - MI_INTR_MASK_SET_SP = 0x0002, /* Bit 1: set SP mask */ - MI_INTR_MASK_CLR_SI = 0x0004, /* Bit 2: clear SI mask */ - MI_INTR_MASK_SET_SI = 0x0008, /* Bit 3: set SI mask */ - MI_INTR_MASK_CLR_AI = 0x0010, /* Bit 4: clear AI mask */ - MI_INTR_MASK_SET_AI = 0x0020, /* Bit 5: set AI mask */ - MI_INTR_MASK_CLR_VI = 0x0040, /* Bit 6: clear VI mask */ - MI_INTR_MASK_SET_VI = 0x0080, /* Bit 7: set VI mask */ - MI_INTR_MASK_CLR_PI = 0x0100, /* Bit 8: clear PI mask */ - MI_INTR_MASK_SET_PI = 0x0200, /* Bit 9: set PI mask */ - MI_INTR_MASK_CLR_DP = 0x0400, /* Bit 10: clear DP mask */ - MI_INTR_MASK_SET_DP = 0x0800, /* Bit 11: set DP mask */ + // Flags for writing to MI_INTR_MASK_REG + MI_INTR_MASK_CLR_SP = 0x0001, // Bit 0: Clear SP mask + MI_INTR_MASK_SET_SP = 0x0002, // Bit 1: Set SP mask + MI_INTR_MASK_CLR_SI = 0x0004, // Bit 2: Clear SI mask + MI_INTR_MASK_SET_SI = 0x0008, // Bit 3: Set SI mask + MI_INTR_MASK_CLR_AI = 0x0010, // Bit 4: Clear AI mask + MI_INTR_MASK_SET_AI = 0x0020, // Bit 5: Set AI mask + MI_INTR_MASK_CLR_VI = 0x0040, // Bit 6: Clear VI mask + MI_INTR_MASK_SET_VI = 0x0080, // Bit 7: Set VI mask + MI_INTR_MASK_CLR_PI = 0x0100, // Bit 8: Clear PI mask + MI_INTR_MASK_SET_PI = 0x0200, // Bit 9: Set PI mask + MI_INTR_MASK_CLR_DP = 0x0400, // Bit 10: Clear DP mask + MI_INTR_MASK_SET_DP = 0x0800, // Bit 11: Set DP mask - //Flags for reading from MI_INTR_MASK_REG - MI_INTR_MASK_SP = 0x01, /* Bit 0: SP intr mask */ - MI_INTR_MASK_SI = 0x02, /* Bit 1: SI intr mask */ - MI_INTR_MASK_AI = 0x04, /* Bit 2: AI intr mask */ - MI_INTR_MASK_VI = 0x08, /* Bit 3: VI intr mask */ - MI_INTR_MASK_PI = 0x10, /* Bit 4: PI intr mask */ - MI_INTR_MASK_DP = 0x20, /* Bit 5: DP intr mask */ + // Flags for reading from MI_INTR_MASK_REG + MI_INTR_MASK_SP = 0x01, // Bit 0: SP INTR mask + MI_INTR_MASK_SI = 0x02, // Bit 1: SI INTR mask + MI_INTR_MASK_AI = 0x04, // Bit 2: AI INTR mask + MI_INTR_MASK_VI = 0x08, // Bit 3: VI INTR mask + MI_INTR_MASK_PI = 0x10, // Bit 4: PI INTR mask + MI_INTR_MASK_DP = 0x20, // Bit 5: DP INTR mask - MI_INTR_SP = 0x01, /* Bit 0: SP intr */ - MI_INTR_SI = 0x02, /* Bit 1: SI intr */ - MI_INTR_AI = 0x04, /* Bit 2: AI intr */ - MI_INTR_VI = 0x08, /* Bit 3: VI intr */ - MI_INTR_PI = 0x10, /* Bit 4: PI intr */ - MI_INTR_DP = 0x20, /* Bit 5: DP intr */ + MI_INTR_SP = 0x01, // Bit 0: SP INTR + MI_INTR_SI = 0x02, // Bit 1: SI INTR + MI_INTR_AI = 0x04, // Bit 2: AI INTR + MI_INTR_VI = 0x08, // Bit 3: VI INTR + MI_INTR_PI = 0x10, // Bit 4: PI INTR + MI_INTR_DP = 0x20, // Bit 5: DP INTR }; -//Mips interface registers +// MIPS interface registers class Video_InterfaceReg { protected: @@ -237,7 +237,7 @@ private: Video_InterfaceReg& operator=(const Video_InterfaceReg&); }; -//Display Processor Control Registers +// Display processor control registers class DisplayControlReg { protected: @@ -261,33 +261,31 @@ private: enum { - DPC_CLR_XBUS_DMEM_DMA = 0x0001, /* Bit 0: clear xbus_dmem_dma */ - DPC_SET_XBUS_DMEM_DMA = 0x0002, /* Bit 1: set xbus_dmem_dma */ - DPC_CLR_FREEZE = 0x0004, /* Bit 2: clear freeze */ - DPC_SET_FREEZE = 0x0008, /* Bit 3: set freeze */ - DPC_CLR_FLUSH = 0x0010, /* Bit 4: clear flush */ - DPC_SET_FLUSH = 0x0020, /* Bit 5: set flush */ - DPC_CLR_TMEM_CTR = 0x0040, /* Bit 6: clear tmem ctr */ - DPC_CLR_PIPE_CTR = 0x0080, /* Bit 7: clear pipe ctr */ - DPC_CLR_CMD_CTR = 0x0100, /* Bit 8: clear cmd ctr */ - DPC_CLR_CLOCK_CTR = 0x0200, /* Bit 9: clear clock ctr */ + DPC_CLR_XBUS_DMEM_DMA = 0x0001, // Bit 0: Clear xbus_dmem_dma + DPC_SET_XBUS_DMEM_DMA = 0x0002, // Bit 1: Set xbus_dmem_dma + DPC_CLR_FREEZE = 0x0004, // Bit 2: Clear freeze + DPC_SET_FREEZE = 0x0008, // Bit 3: Set freeze + DPC_CLR_FLUSH = 0x0010, // Bit 4: Clear flush + DPC_SET_FLUSH = 0x0020, // Bit 5: Set flush + DPC_CLR_TMEM_CTR = 0x0040, // Bit 6: Clear TMEM CTR + DPC_CLR_PIPE_CTR = 0x0080, // Bit 7: Clear pipe CTR + DPC_CLR_CMD_CTR = 0x0100, // Bit 8: Clear CMD CTR + DPC_CLR_CLOCK_CTR = 0x0200, // Bit 9: Clear clock CTR - DPC_STATUS_XBUS_DMEM_DMA = 0x001, /* Bit 0: xbus_dmem_dma */ - DPC_STATUS_FREEZE = 0x002, /* Bit 1: freeze */ - DPC_STATUS_FLUSH = 0x004, /* Bit 2: flush */ - DPC_STATUS_START_GCLK = 0x008, /* Bit 3: start gclk */ - DPC_STATUS_TMEM_BUSY = 0x010, /* Bit 4: tmem busy */ - DPC_STATUS_PIPE_BUSY = 0x020, /* Bit 5: pipe busy */ - DPC_STATUS_CMD_BUSY = 0x040, /* Bit 6: cmd busy */ - DPC_STATUS_CBUF_READY = 0x080, /* Bit 7: cbuf ready */ - DPC_STATUS_DMA_BUSY = 0x100, /* Bit 8: dma busy */ - DPC_STATUS_END_VALID = 0x200, /* Bit 9: end valid */ - DPC_STATUS_START_VALID = 0x400, /* Bit 10: start valid */ + DPC_STATUS_XBUS_DMEM_DMA = 0x001, // Bit 0: xbus_dmem_dma + DPC_STATUS_FREEZE = 0x002, // Bit 1: Freeze + DPC_STATUS_FLUSH = 0x004, // Bit 2: Flush + DPC_STATUS_START_GCLK = 0x008, // Bit 3: Start GCLK + DPC_STATUS_TMEM_BUSY = 0x010, // Bit 4: TMEM busy + DPC_STATUS_PIPE_BUSY = 0x020, // Bit 5: Pipe busy + DPC_STATUS_CMD_BUSY = 0x040, // Bit 6: CMD busy + DPC_STATUS_CBUF_READY = 0x080, // Bit 7: CBUF ready + DPC_STATUS_DMA_BUSY = 0x100, // Bit 8: DMA busy + DPC_STATUS_END_VALID = 0x200, // Bit 9: End valid + DPC_STATUS_START_VALID = 0x400, // Bit 10: Start valid }; -/* -//Audio Interface registers; -*/ +// Audio interface registers class AudioInterfaceReg { protected: @@ -309,11 +307,11 @@ private: enum { - AI_STATUS_FIFO_FULL = 0x80000000, /* Bit 31: full */ - AI_STATUS_DMA_BUSY = 0x40000000, /* Bit 30: busy */ + AI_STATUS_FIFO_FULL = 0x80000000, // Bit 31: Full + AI_STATUS_DMA_BUSY = 0x40000000, // Bit 30: Busy }; -//Audio Interface registers; +// Audio interface registers class PeripheralInterfaceReg { @@ -365,7 +363,7 @@ private: RDRAMInt_InterfaceReg& operator=(const RDRAMInt_InterfaceReg&); }; -//Signal Processor Interface; +// Signal processor interface class SigProcessor_InterfaceReg { protected: @@ -389,53 +387,53 @@ private: SigProcessor_InterfaceReg& operator=(const SigProcessor_InterfaceReg&); }; -//Signal Processor interface flags +// Signal processor interface flags enum { - SP_CLR_HALT = 0x00001, /* Bit 0: clear halt */ - SP_SET_HALT = 0x00002, /* Bit 1: set halt */ - SP_CLR_BROKE = 0x00004, /* Bit 2: clear broke */ - SP_CLR_INTR = 0x00008, /* Bit 3: clear intr */ - SP_SET_INTR = 0x00010, /* Bit 4: set intr */ - SP_CLR_SSTEP = 0x00020, /* Bit 5: clear sstep */ - SP_SET_SSTEP = 0x00040, /* Bit 6: set sstep */ - SP_CLR_INTR_BREAK = 0x00080, /* Bit 7: clear intr on break */ - SP_SET_INTR_BREAK = 0x00100, /* Bit 8: set intr on break */ - SP_CLR_SIG0 = 0x00200, /* Bit 9: clear signal 0 */ - SP_SET_SIG0 = 0x00400, /* Bit 10: set signal 0 */ - SP_CLR_SIG1 = 0x00800, /* Bit 11: clear signal 1 */ - SP_SET_SIG1 = 0x01000, /* Bit 12: set signal 1 */ - SP_CLR_SIG2 = 0x02000, /* Bit 13: clear signal 2 */ - SP_SET_SIG2 = 0x04000, /* Bit 14: set signal 2 */ - SP_CLR_SIG3 = 0x08000, /* Bit 15: clear signal 3 */ - SP_SET_SIG3 = 0x10000, /* Bit 16: set signal 3 */ - SP_CLR_SIG4 = 0x20000, /* Bit 17: clear signal 4 */ - SP_SET_SIG4 = 0x40000, /* Bit 18: set signal 4 */ - SP_CLR_SIG5 = 0x80000, /* Bit 19: clear signal 5 */ - SP_SET_SIG5 = 0x100000, /* Bit 20: set signal 5 */ - SP_CLR_SIG6 = 0x200000, /* Bit 21: clear signal 6 */ - SP_SET_SIG6 = 0x400000, /* Bit 22: set signal 6 */ - SP_CLR_SIG7 = 0x800000, /* Bit 23: clear signal 7 */ - SP_SET_SIG7 = 0x1000000, /* Bit 24: set signal 7 */ + SP_CLR_HALT = 0x00001, // Bit 0: Clear halt + SP_SET_HALT = 0x00002, // Bit 1: Set halt + SP_CLR_BROKE = 0x00004, // Bit 2: Clear broke + SP_CLR_INTR = 0x00008, // Bit 3: Clear INTR + SP_SET_INTR = 0x00010, // Bit 4: Set INTR + SP_CLR_SSTEP = 0x00020, // Bit 5: Clear SSTEP + SP_SET_SSTEP = 0x00040, // Bit 6: Set SSTEP + SP_CLR_INTR_BREAK = 0x00080, // Bit 7: Clear INTR on break + SP_SET_INTR_BREAK = 0x00100, // Bit 8: Set INTR on break + SP_CLR_SIG0 = 0x00200, // Bit 9: Clear signal 0 + SP_SET_SIG0 = 0x00400, // Bit 10: Set signal 0 + SP_CLR_SIG1 = 0x00800, // Bit 11: Clear signal 1 + SP_SET_SIG1 = 0x01000, // Bit 12: Set signal 1 + SP_CLR_SIG2 = 0x02000, // Bit 13: Clear signal 2 + SP_SET_SIG2 = 0x04000, // Bit 14: Set signal 2 + SP_CLR_SIG3 = 0x08000, // Bit 15: Clear signal 3 + SP_SET_SIG3 = 0x10000, // Bit 16: Set signal 3 + SP_CLR_SIG4 = 0x20000, // Bit 17: Clear signal 4 + SP_SET_SIG4 = 0x40000, // Bit 18: Set signal 4 + SP_CLR_SIG5 = 0x80000, // Bit 19: Clear signal 5 + SP_SET_SIG5 = 0x100000, // Bit 20: Set signal 5 + SP_CLR_SIG6 = 0x200000, // Bit 21: Clear signal 6 + SP_SET_SIG6 = 0x400000, // Bit 22: Set signal 6 + SP_CLR_SIG7 = 0x800000, // Bit 23: Clear signal 7 + SP_SET_SIG7 = 0x1000000, // Bit 24: Set signal 7 - SP_STATUS_HALT = 0x001, /* Bit 0: halt */ - SP_STATUS_BROKE = 0x002, /* Bit 1: broke */ - SP_STATUS_DMA_BUSY = 0x004, /* Bit 2: dma busy */ - SP_STATUS_DMA_FULL = 0x008, /* Bit 3: dma full */ - SP_STATUS_IO_FULL = 0x010, /* Bit 4: io full */ - SP_STATUS_SSTEP = 0x020, /* Bit 5: single step */ - SP_STATUS_INTR_BREAK = 0x040, /* Bit 6: interrupt on break */ - SP_STATUS_SIG0 = 0x080, /* Bit 7: signal 0 set */ - SP_STATUS_SIG1 = 0x100, /* Bit 8: signal 1 set */ - SP_STATUS_SIG2 = 0x200, /* Bit 9: signal 2 set */ - SP_STATUS_SIG3 = 0x400, /* Bit 10: signal 3 set */ - SP_STATUS_SIG4 = 0x800, /* Bit 11: signal 4 set */ - SP_STATUS_SIG5 = 0x1000, /* Bit 12: signal 5 set */ - SP_STATUS_SIG6 = 0x2000, /* Bit 13: signal 6 set */ - SP_STATUS_SIG7 = 0x4000, /* Bit 14: signal 7 set */ + SP_STATUS_HALT = 0x001, // Bit 0: Halt + SP_STATUS_BROKE = 0x002, // Bit 1: Broke + SP_STATUS_DMA_BUSY = 0x004, // Bit 2: DMA busy + SP_STATUS_DMA_FULL = 0x008, // Bit 3: DMA full + SP_STATUS_IO_FULL = 0x010, // Bit 4: IO full + SP_STATUS_SSTEP = 0x020, // Bit 5: Single step + SP_STATUS_INTR_BREAK = 0x040, // Bit 6: Interrupt on break + SP_STATUS_SIG0 = 0x080, // Bit 7: Signal 0 set + SP_STATUS_SIG1 = 0x100, // Bit 8: Signal 1 set + SP_STATUS_SIG2 = 0x200, // Bit 9: Signal 2 set + SP_STATUS_SIG3 = 0x400, // Bit 10: Signal 3 set + SP_STATUS_SIG4 = 0x800, // Bit 11: Signal 4 set + SP_STATUS_SIG5 = 0x1000, // Bit 12: Signal 5 set + SP_STATUS_SIG6 = 0x2000, // Bit 13: Signal 6 set + SP_STATUS_SIG7 = 0x4000, // Bit 14: Signal 7 set }; -//Peripheral Interface flags +// Peripheral interface flags enum { PI_STATUS_DMA_BUSY = 0x01, @@ -463,7 +461,7 @@ private: Serial_InterfaceReg& operator=(const Serial_InterfaceReg&); }; -//Serial Interface flags +// Serial interface flags enum { SI_STATUS_DMA_BUSY = 0x0001, @@ -472,7 +470,7 @@ enum SI_STATUS_INTERRUPT = 0x1000, }; -//Disk Interface +// Disk interface class Disk_InterfaceReg { protected: @@ -508,7 +506,7 @@ private: Disk_InterfaceReg& operator=(const Disk_InterfaceReg&); }; -//Disk Interface Flags +// Disk interface flags enum { DD_STATUS_DATA_RQ = 0x40000000, @@ -588,7 +586,7 @@ class CRegisters : public: CRegisters(CN64System * System, CSystemEvents * SystemEvents); - //General Registers + // General registers uint32_t m_PROGRAM_COUNTER; MIPS_DWORD m_GPR[32]; uint32_t m_CP0[33]; @@ -596,14 +594,14 @@ public: MIPS_DWORD m_LO; uint32_t m_LLBit; - //Floating point registers/information + // Floating point registers/information uint32_t m_FPCR[32]; int32_t m_RoundingModel; MIPS_DWORD m_FPR[32]; float * m_FPR_S[32]; double * m_FPR_D[32]; - //Memory Mapped N64 registers + // Memory-mapped N64 registers uint32_t m_RDRAM_Registers[10]; uint32_t m_SigProcessor_Interface[10]; uint32_t m_Display_ControlReg[10]; diff --git a/Source/Project64-core/N64System/Mips/SystemEvents.cpp b/Source/Project64-core/N64System/Mips/SystemEvents.cpp index 1a4d8fa84..32a99905f 100644 --- a/Source/Project64-core/N64System/Mips/SystemEvents.cpp +++ b/Source/Project64-core/N64System/Mips/SystemEvents.cpp @@ -50,7 +50,7 @@ const char * SystemEventName(SystemEvent event) case SysEvent_ResetRecompilerCode: return "SysEvent_ResetRecompilerCode"; } static char unknown[100]; - sprintf(unknown, "unknown(%d)", event); + sprintf(unknown, "Unknown(%d)", event); return unknown; } diff --git a/Source/Project64-core/N64System/Mips/SystemTiming.cpp b/Source/Project64-core/N64System/Mips/SystemTiming.cpp index 7744cc35e..42d2bb01a 100644 --- a/Source/Project64-core/N64System/Mips/SystemTiming.cpp +++ b/Source/Project64-core/N64System/Mips/SystemTiming.cpp @@ -18,7 +18,7 @@ CSystemTimer::CSystemTimer(CRegisters &Reg, int32_t & NextTimer) : void CSystemTimer::Reset() { - //initialise Structure + // Initialize structure for (int i = 0; i < MaxTimer; i++) { m_TimerDetatils[i].Active = false; @@ -47,16 +47,16 @@ void CSystemTimer::SetTimer(TimerType Type, uint32_t Cycles, bool bRelative) { if (m_TimerDetatils[Type].Active) { - m_TimerDetatils[Type].CyclesToTimer += Cycles; //Add to the timer + m_TimerDetatils[Type].CyclesToTimer += Cycles; // Add to the timer } else { - m_TimerDetatils[Type].CyclesToTimer = (int64_t)Cycles - (int64_t)m_NextTimer; //replace the new cycles + m_TimerDetatils[Type].CyclesToTimer = (int64_t)Cycles - (int64_t)m_NextTimer; // Replace the new cycles } } else { - m_TimerDetatils[Type].CyclesToTimer = (int64_t)Cycles - (int64_t)m_NextTimer; //replace the new cycles + m_TimerDetatils[Type].CyclesToTimer = (int64_t)Cycles - (int64_t)m_NextTimer; // Replace the new cycles } FixTimers(); } @@ -109,7 +109,7 @@ void CSystemTimer::FixTimers() SetCompareTimer(); } - //Update the cycles for the remaining number of cycles to timer + // Update the cycles for the remaining number of cycles to timer int count; for (count = 0; count < MaxTimer; count++) { @@ -120,10 +120,10 @@ void CSystemTimer::FixTimers() m_TimerDetatils[count].CyclesToTimer += m_NextTimer; } - //Set Max timer + // Set max timer m_NextTimer = 0x7FFFFFFF; - //Find the smallest timer left to go + // Find the smallest timer left to go for (count = 0; count < MaxTimer; count++) { if (!m_TimerDetatils[count].Active) @@ -138,7 +138,7 @@ void CSystemTimer::FixTimers() m_Current = (TimerType)count; } - //Move the timer back this value + // Move the timer back this value for (count = 0; count < MaxTimer; count++) { if (!m_TimerDetatils[count].Active) diff --git a/Source/Project64-core/N64System/Mips/TLB.cpp b/Source/Project64-core/N64System/Mips/TLB.cpp index 230535837..cc8a6053d 100644 --- a/Source/Project64-core/N64System/Mips/TLB.cpp +++ b/Source/Project64-core/N64System/Mips/TLB.cpp @@ -85,8 +85,8 @@ void CTLB::Probe() if (TlbValueMasked == EntryHiMasked) { - if ((TlbEntryHiValue & 0x100) != 0 || //Global - ((TlbEntryHiValue & 0xFF) == (g_Reg->ENTRYHI_REGISTER & 0xFF))) //SameAsid + if ((TlbEntryHiValue & 0x100) != 0 || // Global + ((TlbEntryHiValue & 0xFF) == (g_Reg->ENTRYHI_REGISTER & 0xFF))) // SameAsid { g_Reg->INDEX_REGISTER = Counter; int FastIndx = Counter << 1; @@ -115,7 +115,7 @@ void CTLB::WriteEntry(int index, bool Random) WriteTrace(TraceTLB, TraceDebug, "%02d %d %08X %08X %08X %08X ", index, Random, g_Reg->PAGE_MASK_REGISTER, g_Reg->ENTRYHI_REGISTER, g_Reg->ENTRYLO0_REGISTER, g_Reg->ENTRYLO1_REGISTER); - //Check to see if entry is unmapping it self + // Check to see if entry is unmapping itself if (m_tlb[index].EntryDefined) { FastIndx = index << 1; @@ -135,7 +135,7 @@ void CTLB::WriteEntry(int index, bool Random) } } - //Reset old addresses + // Reset old addresses if (m_tlb[index].EntryDefined) { for (FastIndx = index << 1; FastIndx <= (index << 1) + 1; FastIndx++) @@ -164,7 +164,7 @@ void CTLB::WriteEntry(int index, bool Random) } } - //fill in m_tlb entry + // Fill in m_tlb entry m_tlb[index].PageMask.Value = g_Reg->PAGE_MASK_REGISTER; m_tlb[index].EntryHi.Value = g_Reg->ENTRYHI_REGISTER; m_tlb[index].EntryLo0.Value = g_Reg->ENTRYLO0_REGISTER; @@ -176,7 +176,7 @@ void CTLB::WriteEntry(int index, bool Random) void CTLB::SetupTLB_Entry(int index, bool Random) { - //Fix up Fast TLB entries + // Fix up fast TLB entries if (!m_tlb[index].EntryDefined) { return; @@ -216,7 +216,7 @@ void CTLB::SetupTLB_Entry(int index, bool Random) m_FastTlb[FastIndx].Random = Random; m_FastTlb[FastIndx].Probed = false; - //Test both entries to see if they are valid + // Test both entries to see if they are valid for (FastIndx = index << 1; FastIndx <= (index << 1) + 1; FastIndx++) { if (!m_FastTlb[FastIndx].VALID) @@ -238,7 +238,7 @@ void CTLB::SetupTLB_Entry(int index, bool Random) continue; } - //MAP the new m_tlb entry for reading and writing + // Map the new m_tlb entry for reading and writing m_FastTlb[FastIndx].ValidEntry = true; m_CB->TLB_Mapped(m_FastTlb[FastIndx].VSTART, m_FastTlb[FastIndx].Length, m_FastTlb[FastIndx].PHYSSTART, !m_FastTlb[FastIndx].DIRTY); } diff --git a/Source/Project64-core/N64System/Mips/TLB.h b/Source/Project64-core/N64System/Mips/TLB.h index c265a1bf7..8ca36f6bf 100644 --- a/Source/Project64-core/N64System/Mips/TLB.h +++ b/Source/Project64-core/N64System/Mips/TLB.h @@ -88,12 +88,12 @@ public: void Reset(bool InvalidateTLB); - //Used by opcodes of the same name to manipulate the tlb (reads the registers) + // Used by opcodes of the same name to manipulate the TLB (reads the registers) void Probe(); void ReadEntry(); void WriteEntry(int32_t index, bool Random); - //See if a VAddr has an entry to translate to a PAddr + // See if a VAddr has an entry to translate to a PAddr bool AddressDefined(uint32_t VAddr); const TLB_ENTRY & TlbEntry(int32_t Entry) const @@ -124,7 +124,7 @@ private: bool Probed; }; - friend class CDebugTlb; // enable debug window to read class + friend class CDebugTlb; // Enable debug window to read class CTLB_CB * const m_CB; diff --git a/Source/Project64-core/N64System/Mips/Transferpak.cpp b/Source/Project64-core/N64System/Mips/Transferpak.cpp index f73c1342d..531f34248 100644 --- a/Source/Project64-core/N64System/Mips/Transferpak.cpp +++ b/Source/Project64-core/N64System/Mips/Transferpak.cpp @@ -1,9 +1,9 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2015 Bobby Smiles - // GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html + #include "stdafx.h" #include "GBCart.h" #include "Transferpak.h" @@ -17,7 +17,7 @@ uint16_t gb_cart_address(unsigned int bank, uint16_t address) void Transferpak::Init() { - //Quick check to ensure we dont have a ROM already + // Quick check to ensure we don't have a ROM already if (tpak.gb_cart.rom == nullptr) { memset(&tpak, 0, sizeof(tpak)); @@ -38,20 +38,20 @@ void Transferpak::ReadFrom(uint16_t address, uint8_t * data) { if ((address >= 0x8000) && (address <= 0x8FFF)) { - //Ensure we actually have a ROM loaded in first. + // Ensure we actually have a ROM loaded in first if (tpak.gb_cart.rom == nullptr) { Init(); } - //Get whether the GB cart is enabled or disabled + // Get whether the Game Boy cart is enabled or disabled uint8_t value = (tpak.enabled) ? 0x84 : 0x00; memset(data, value, 0x20); } else if ((address >= 0xB000) && (address <= 0xBFFF)) { - // Get the GB Cart access mode + // Get the Game Boy cart access mode if (tpak.enabled) { memset(data, tpak.access_mode, 0x20); @@ -65,7 +65,7 @@ void Transferpak::ReadFrom(uint16_t address, uint8_t * data) } else if (address >= 0xC000) { - // Read the GB Cart + // Read the Game Boy cart if (tpak.enabled) { GBCart::read_gb_cart(&tpak.gb_cart, gb_cart_address(tpak.bank, address), data); @@ -79,13 +79,13 @@ void Transferpak::WriteTo(uint16_t address, uint8_t * data) if ((address >= 0x8000) && (address <= 0x8FFF)) { - //Ensure we actually have a ROM loaded in first. + // Ensure we actually have a ROM loaded in first if (tpak.gb_cart.rom == nullptr) { Init(); } - //Set whether the gb cart is enabled or disabled. + // Set whether the Game Boy cart is enabled or disabled switch (*data) { case 0xFE: @@ -95,13 +95,13 @@ void Transferpak::WriteTo(uint16_t address, uint8_t * data) tpak.enabled = true; break; default: - //Do nothing + // Do nothing break; } } else if ((address >= 0xA000) && (address <= 0xAFFF)) { - //Set the bank for the GB Cart + // Set the bank for the Game Boy cart if (tpak.enabled) { tpak.bank = *data; @@ -109,7 +109,7 @@ void Transferpak::WriteTo(uint16_t address, uint8_t * data) } else if ((address >= 0xB000) && (address <= 0xBFFF)) { - // Get the GB Cart access mode + // Get the Game Boy cart access mode if (tpak.enabled) { tpak.access_mode_changed = 0x04; @@ -118,13 +118,13 @@ void Transferpak::WriteTo(uint16_t address, uint8_t * data) if ((*data & 0xFE) != 0) { - //Unkown tpak write + // Unknown Transfer Pak write } } } else if (address >= 0xC000) { - // Write to the GB Cart + // Write to the Game Boy cart if (tpak.enabled) { GBCart::write_gb_cart(&tpak.gb_cart, gb_cart_address(tpak.bank, address), data); diff --git a/Source/Project64-core/N64System/N64Disk.cpp b/Source/Project64-core/N64System/N64Disk.cpp index 7f4fb0d0a..e2b48f545 100644 --- a/Source/Project64-core/N64System/N64Disk.cpp +++ b/Source/Project64-core/N64System/N64Disk.cpp @@ -31,16 +31,16 @@ bool CN64Disk::LoadDiskImage(const char * FileLoc) UnallocateDiskImage(); m_ErrorMsg = EMPTY_STRING; - //Assume the file extension is *.ndd or *.d64 + // Assume the file extension is *.ndd or *.d64 stdstr ext = CPath(FileLoc).GetExtension(); stdstr ShadowFile = FileLoc; ShadowFile[ShadowFile.length() - 1] = 'r'; - WriteTrace(TraceN64System, TraceDebug, "Attempt to load shadow file."); + WriteTrace(TraceN64System, TraceDebug, "Attempting to load shadow file"); if (!AllocateAndLoadDiskImage(ShadowFile.c_str())) { m_isShadowDisk = false; - WriteTrace(TraceN64System, TraceDebug, "Loading Shadow file failed"); + WriteTrace(TraceN64System, TraceDebug, "Loading shadow file failed"); UnallocateDiskImage(); if (!AllocateAndLoadDiskImage(FileLoc)) { @@ -57,10 +57,10 @@ bool CN64Disk::LoadDiskImage(const char * FileLoc) uint32_t crc1 = CalculateCrc(); uint32_t crc2 = ~crc1; m_DiskIdent.Format("%08X-%08X-C:%X", crc1, crc2, GetDiskAddressID()[0]); - //Get the disk ID from the disk image + // Get the disk ID from the disk image if (*(uint32_t *)(&GetDiskAddressID()[0]) != 0) { - //if not 0x00000000 + // If not 0x00000000 RomName[0] = (char)*(GetDiskAddressID() + 3); RomName[1] = (char)*(GetDiskAddressID() + 2); RomName[2] = (char)*(GetDiskAddressID() + 1); @@ -69,7 +69,7 @@ bool CN64Disk::LoadDiskImage(const char * FileLoc) } else { - //if 0x00000000 then use a made up one + // If 0x00000000 then use a made up one RomName[0] = m_DiskIdent[12]; RomName[1] = m_DiskIdent[11]; RomName[2] = m_DiskIdent[10]; @@ -102,26 +102,26 @@ bool CN64Disk::SaveDiskImage() { DeinitSysDataD64(); - //NO NEED TO SAVE IF DISK TYPE IS 6 + // No need to save if disk type is 6 if (m_DiskType == 6) { m_DiskFile.Close(); - WriteTrace(TraceN64System, TraceDebug, "Loaded Disk Type is 6. No RAM area. Shadow file is not needed."); + WriteTrace(TraceN64System, TraceDebug, "Loaded disk type is 6. No RAM area. Shadow file is not needed."); return true; } - //Assume the file extension is *.ndd / *.d64 + // Assume the file extension is *.ndd / *.d64 if (m_DiskFormat == DiskFormatMAME || m_isShadowDisk || g_Settings->LoadDword(Setting_DiskSaveType) == SaveDisk_ShadowFile) { - //Shadow File + // Shadow file stdstr ShadowFile = m_FileName; ShadowFile[ShadowFile.length() - 1] = 'r'; - WriteTrace(TraceN64System, TraceDebug, "Trying to open %s (Shadow File)", ShadowFile.c_str()); + WriteTrace(TraceN64System, TraceDebug, "Trying to open %s (shadow file)", ShadowFile.c_str()); m_DiskFile.Close(); if (!m_DiskFile.Open(ShadowFile.c_str(), CFileBase::modeWrite | CFileBase::modeCreate | CFileBase::modeNoTruncate)) { - WriteTrace(TraceN64System, TraceError, "Failed to open %s (Shadow File)", ShadowFile.c_str()); + WriteTrace(TraceN64System, TraceError, "Failed to open %s (shadow file)", ShadowFile.c_str()); return false; } @@ -137,7 +137,7 @@ bool CN64Disk::SaveDiskImage() } else { - //RAM File + // RAM file if (m_DiskFileSize <= m_DiskRamAddress || m_DiskRamAddress == 0) { m_DiskFile.Close(); @@ -149,11 +149,11 @@ bool CN64Disk::SaveDiskImage() ShadowFile[ShadowFile.length() - 2] = 'a'; ShadowFile[ShadowFile.length() - 3] = 'r'; - WriteTrace(TraceN64System, TraceDebug, "Trying to open %s (RAM File)", ShadowFile.c_str()); + WriteTrace(TraceN64System, TraceDebug, "Trying to open %s (RAM file)", ShadowFile.c_str()); m_DiskFile.Close(); if (!m_DiskFile.Open(ShadowFile.c_str(), CFileBase::modeWrite | CFileBase::modeCreate | CFileBase::modeNoTruncate)) { - WriteTrace(TraceN64System, TraceError, "Failed to open %s (RAM File)", ShadowFile.c_str()); + WriteTrace(TraceN64System, TraceError, "Failed to open %s (RAM file)", ShadowFile.c_str()); return false; } @@ -180,27 +180,27 @@ void CN64Disk::SwapDiskImage(const char * FileLoc) bool CN64Disk::IsValidDiskImage(uint8_t Test[0x20]) { - //Basic System Data Check (first 0x20 bytes is enough) - //Disk Type + // Basic system data check (first 0x20 bytes is enough) + // Disk type if ((Test[0x05] & 0xEF) > 6) return false; - //IPL Load Block + // IPL load block uint16_t ipl_load_blk = ((Test[0x06] << 8) | Test[0x07]); if (ipl_load_blk > 0x10C3 || ipl_load_blk == 0x0000) return false; - //IPL Load Address + // IPL load address uint32_t ipl_load_addr = (Test[0x1C] << 24) | (Test[0x1D] << 16) | (Test[0x1E] << 8) | Test[0x1F]; if (ipl_load_addr < 0x80000000 && ipl_load_addr >= 0x80800000) return false; - //Country Code + // Country code if (*((uint32_t *)&Test[0]) == 0x16D348E8) { return true; } else if (*((uint32_t *)&Test[0]) == 0x56EE6322) { return true; } else if (*((uint32_t *)&Test[0]) == 0x00000000) { return true; } return false; } -//Save the settings of the loaded rom, so all loaded settings about rom will be identified with -//this rom +// Save the settings of the loaded ROM, so all loaded settings about ROM will be identified with this ROM + void CN64Disk::SaveDiskSettingID(bool temp) { g_Settings->SaveBool(Game_TempLoaded, temp); @@ -242,10 +242,10 @@ bool CN64Disk::AllocateDiskImage(uint32_t DiskFileSize) WriteTrace(TraceN64System, TraceError, "Failed to allocate memory for disk (size: 0x%X)", DiskFileSize); return false; } - uint8_t * Image = (uint8_t *)(((uint64_t)ImageBase.get() + 0xFFF) & ~0xFFF); // start at begining of memory page + uint8_t * Image = (uint8_t *)(((uint64_t)ImageBase.get() + 0xFFF) & ~0xFFF); // Start at beginning of memory page WriteTrace(TraceN64System, TraceDebug, "Allocated disk memory (%p)", Image); - //save information about the disk loaded + // Save information about the disk loaded m_DiskImageBase = ImageBase.release(); m_DiskImage = Image; m_DiskFileSize = DiskFileSize; @@ -262,10 +262,10 @@ bool CN64Disk::AllocateDiskHeader() WriteTrace(TraceN64System, TraceError, "Failed to allocate memory for disk header forge (size: 0x40)"); return false; } - uint8_t * Header = (uint8_t *)(((uint64_t)HeaderBase.get() + 0xFFF) & ~0xFFF); // start at begining of memory page + uint8_t * Header = (uint8_t *)(((uint64_t)HeaderBase.get() + 0xFFF) & ~0xFFF); // Start at beginning of memory page WriteTrace(TraceN64System, TraceDebug, "Allocated disk memory (%p)", Header); - //save information about the disk loaded + // Save information about the disk loaded m_DiskHeaderBase = HeaderBase.release(); m_DiskHeader = Header; return true; @@ -280,7 +280,7 @@ bool CN64Disk::AllocateAndLoadDiskImage(const char * FileLoc) return false; } - //Make sure it is a valid disk image + // Make sure it is a valid disk image uint8_t Test[0x100]; bool isValidDisk = false; @@ -302,27 +302,27 @@ bool CN64Disk::AllocateAndLoadDiskImage(const char * FileLoc) if (!isValidDisk) { m_DiskFile.Close(); - WriteTrace(TraceN64System, TraceError, "invalid disk image file"); + WriteTrace(TraceN64System, TraceError, "Invalid disk image file"); return false; } uint32_t DiskFileSize = m_DiskFile.GetLength(); stdstr ext = CPath(FileLoc).GetExtension(); - WriteTrace(TraceN64System, TraceDebug, "Successfully Opened, size: 0x%X", DiskFileSize); + WriteTrace(TraceN64System, TraceDebug, "Successfully opened, size: 0x%X", DiskFileSize); - //Check Disk File Format + // Check disk file format if (((DiskFileSize == MameFormatSize) || (DiskFileSize == SDKFormatSize)) && (ext.compare("ndr") || ext.compare("ndd"))) { if (DiskFileSize == MameFormatSize) { - //If Disk is MAME Format (size is constant, it should be the same for every file), then continue + // If disk is MAME Format (size is constant, it should be the same for every file), then continue m_DiskFormat = DiskFormatMAME; - WriteTrace(TraceN64System, TraceDebug, "Disk File is MAME Format"); + WriteTrace(TraceN64System, TraceDebug, "Disk file is MAME format"); } else { - //If Disk is SDK format (made with SDK based dumpers like LuigiBlood's, or Nintendo's, size is also constant) + // If disk is SDK format (made with SDK-based dumpers like LuigiBlood's, or Nintendo's, size is also constant) m_DiskFormat = DiskFormatSDK; - WriteTrace(TraceN64System, TraceDebug, "Disk File is SDK Format"); + WriteTrace(TraceN64System, TraceDebug, "Disk file is SDK format"); } if (!AllocateDiskImage(DiskFileSize)) @@ -331,7 +331,7 @@ bool CN64Disk::AllocateAndLoadDiskImage(const char * FileLoc) return false; } - //Load the n64 disk to the allocated memory + // Load the N64 disk to the allocated memory g_Notify->DisplayMessage(5, MSG_LOADING); m_DiskFile.SeekToBegin(); @@ -350,7 +350,7 @@ bool CN64Disk::AllocateAndLoadDiskImage(const char * FileLoc) } TotalRead += dwToRead; - //Show Message of how much % wise of the rom has been loaded + // Show message of how much of the ROM has been loaded (as a percentage) g_Notify->DisplayMessage(0, stdstr_f("%s: %.2f%c", GS(MSG_LOADED), ((float)TotalRead / (float)DiskFileSize) * 100.0f, '%').c_str()); } @@ -370,7 +370,7 @@ bool CN64Disk::AllocateAndLoadDiskImage(const char * FileLoc) else if ((DiskFileSize > 0x4F08) && (ext.compare("d6r") || ext.compare("d64"))) { m_DiskFormat = DiskFormatD64; - WriteTrace(TraceN64System, TraceDebug, "Disk File is D64 Format"); + WriteTrace(TraceN64System, TraceDebug, "Disk file is D64 format"); m_DiskType = Test[5]; uint16_t ROM_LBA_END = (Test[0xE0] << 8) | Test[0xE1]; @@ -396,11 +396,11 @@ bool CN64Disk::AllocateAndLoadDiskImage(const char * FileLoc) { m_DiskFile.Close(); SetError(MSG_FAIL_IMAGE); - WriteTrace(TraceN64System, TraceError, "Malformed D64 disk image, expected filesize of 0x200 + 0x%X + 0x%X = %08X, actual filesize: %08X", ROM_SIZE, RAM_SIZE, (0x200 + ROM_SIZE + RAM_SIZE), DiskFileSize); + WriteTrace(TraceN64System, TraceError, "Malformed D64 disk image, expected file size of 0x200 + 0x%X + 0x%X = %08X, actual file size: %08X", ROM_SIZE, RAM_SIZE, (0x200 + ROM_SIZE + RAM_SIZE), DiskFileSize); return false; } - //Allocate File with Max RAM Area size + // Allocate file with maximum size RAM area WriteTrace(TraceN64System, TraceError, "Allocate D64 ROM %08X + RAM %08X", ROM_SIZE, FULL_RAM_SIZE); if (!AllocateDiskImage(0x200 + ROM_SIZE + FULL_RAM_SIZE)) { @@ -408,7 +408,7 @@ bool CN64Disk::AllocateAndLoadDiskImage(const char * FileLoc) return false; } - //Load the n64 disk to the allocated memory + // Load the N64 disk to the allocated memory g_Notify->DisplayMessage(5, MSG_LOADING); m_DiskFile.SeekToBegin(); @@ -427,7 +427,7 @@ bool CN64Disk::AllocateAndLoadDiskImage(const char * FileLoc) } TotalRead += dwToRead; - //Show Message of how much % wise of the rom has been loaded + // Show message of how much of the ROM has been loaded (as a percentage) g_Notify->DisplayMessage(0, stdstr_f("%s: %.2f%c", GS(MSG_LOADED), ((float)TotalRead / (float)DiskFileSize) * 100.0f, '%').c_str()); } @@ -446,9 +446,9 @@ bool CN64Disk::AllocateAndLoadDiskImage(const char * FileLoc) } else { - //Else the disk file is invalid + // Otherwise the disk file is invalid m_DiskFile.Close(); - WriteTrace(TraceN64System, TraceError, "Disk File is invalid, unexpected size"); + WriteTrace(TraceN64System, TraceError, "Disk file is invalid, unexpected size"); return false; } @@ -571,7 +571,7 @@ void CN64Disk::UnallocateDiskImage() uint32_t CN64Disk::CalculateCrc() { - //Custom CRC + // Custom CRC int crc = 0; for (int i = 0; i < 0x200; i += 4) { @@ -585,7 +585,7 @@ uint32_t CN64Disk::GetDiskAddressBlock(uint16_t head, uint16_t track, uint16_t b uint32_t offset = 0; if (m_DiskFormat == DiskFormatMAME) { - //MAME + // MAME uint32_t tr_off = 0; uint16_t dd_zone = 0; @@ -650,7 +650,7 @@ uint32_t CN64Disk::GetDiskAddressBlock(uint16_t head, uint16_t track, uint16_t b } else if (m_DiskFormat == DiskFormatSDK) { - //SDK + // SDK offset = LBAToByte(0, PhysToLBA(head, track, block)) + sector * sectorsize; if (offset < (BLOCKSIZE(0) * SYSTEM_LBAS) && sector == 0) @@ -671,7 +671,7 @@ uint32_t CN64Disk::GetDiskAddressBlock(uint16_t head, uint16_t track, uint16_t b } else { - //D64 + // D64 uint16_t ROM_LBA_END = *(uint16_t*)(&GetDiskAddressSys()[0xE2]); uint16_t RAM_LBA_START = *(uint16_t*)(&GetDiskAddressSys()[0xE0]); uint16_t RAM_LBA_END = *(uint16_t*)(&GetDiskAddressSys()[0xE6]); @@ -714,14 +714,14 @@ void CN64Disk::DetectSystemArea() { if ((m_DiskFormat == DiskFormatMAME) || (m_DiskFormat == DiskFormatSDK)) { - //MAME / SDK (System Area can be handled identically) + // MAME / SDK (system area can be handled identically) m_DiskSysAddress = 0; m_DiskIDAddress = DISKID_LBA * 0x4D08; m_DiskRomAddress = SYSTEM_LBAS * 0x4D08; - //Handle System Data + // Handle system data const uint16_t sysblocks[4] = { 9, 8, 1, 0 }; - //Check if Disk is development disk + // Check if disk is development disk bool isDevDisk = false; for (int i = 0; i < 4; i++) @@ -744,10 +744,10 @@ void CN64Disk::DetectSystemArea() } } - //Handle Disk ID + // Handle disk ID for (int i = 2; i > 0; i--) { - //There are two Disk ID Blocks + // There are two disk ID blocks if (IsSysSectorGood(DISKID_LBA + i, 0xE8)) { m_DiskIDAddress = ((DISKID_LBA + i) * 0x4D08); @@ -756,7 +756,7 @@ void CN64Disk::DetectSystemArea() } else //if (m_DiskFormat == DiskFormatD64) { - //D64 (uses fixed addresses) + // D64 (uses fixed addresses) m_DiskSysAddress = 0x000; m_DiskIDAddress = 0x100; m_DiskRomAddress = 0x200; @@ -765,7 +765,7 @@ void CN64Disk::DetectSystemArea() bool CN64Disk::IsSysSectorGood(uint32_t block, uint32_t sectorsize) { - //Checks if all sectors are identical (meant only to be used for System Area for MAME and SDK formats) + // Checks if all sectors are identical (meant only to be used for system area for MAME and SDK formats) for (int j = 1; j < SECTORS_PER_BLOCK; j++) { for (uint32_t k = 0; k < sectorsize; k++) @@ -779,25 +779,25 @@ bool CN64Disk::IsSysSectorGood(uint32_t block, uint32_t sectorsize) if (block < DISKID_LBA) { - //Check System Data + // Check system data - //System Format + // System format if (m_DiskImage[(block * 0x4D08) + 4] != 0x10) return false; - //Disk Format + // Disk format if ((m_DiskImage[(block * 0x4D08) + 5] & 0xF0) != 0x10) return false; - //Always 0xFFFFFFFF + // Always 0xFFFFFFFF if (*(uint32_t*)&m_DiskImage[(block * 0x4D08) + 0x18] != 0xFFFFFFFF) return false; - uint8_t alt = 0xC; //Retail + uint8_t alt = 0xC; // Retail if ((block & 2) != 0) - alt = 0xA; //Development + alt = 0xA; // Development - //Alternate Tracks Offsets (always the same) + // Alternate tracks offsets (always the same) for (int i = 0; i < 16; i++) { if (m_DiskImage[(block * 0x4D08) + 8 + i] != ((i + 1) * alt)) @@ -824,14 +824,14 @@ Country CN64Disk::GetDiskCountryCode() void CN64Disk::InitSysDataD64() { - //Else the disk will not work properly. + // Otherwise the disk will not work properly if (m_DiskFormat != DiskFormatD64) return; GetDiskAddressSys()[4 ^ 3] = 0x10; GetDiskAddressSys()[5 ^ 3] |= 0x10; - //Expand RAM Area for file format consistency + // Expand RAM area for file format consistency if (m_DiskType < 6) { *(uint16_t*)&GetDiskAddressSys()[0xE2 ^ 2] = RAM_START_LBA[m_DiskType] - SYSTEM_LBAS; @@ -846,7 +846,7 @@ void CN64Disk::InitSysDataD64() void CN64Disk::DeinitSysDataD64() { - //Restore the data + // Restore the data if (m_DiskFormat != DiskFormatD64) return; @@ -866,7 +866,7 @@ void CN64Disk::DetectRamAddress() { if (m_DiskFormat == DiskFormatMAME) { - //Not supported + // Not supported m_DiskRamAddress = 0; } else if (m_DiskFormat == DiskFormatSDK) @@ -927,50 +927,50 @@ uint16_t CN64Disk::LBAToPhys(uint32_t lba) { uint8_t * sys_data = GetDiskAddressSys(); - //Get Block 0/1 on Disk Track + // Get block 0/1 on disk track uint8_t block = 1; if (((lba & 3) == 0) || ((lba & 3) == 3)) block = 0; - //Get Virtual & Physical Disk Zones + // Get virtual and physical disk zones uint16_t vzone = (uint16_t)LBAToVZone(lba); uint16_t pzone = VZoneToPZone(vzone, m_DiskType); - //Get Disk Head + // Get disk head uint16_t head = (7 < pzone); - //Get Disk Zone + // Get disk zone uint16_t disk_zone = pzone; if (disk_zone != 0) disk_zone = pzone - 7; - //Get Virtual Zone LBA start, if Zone 0, it's LBA 0 + // Get virtual zone LBA start, if zone 0, it's LBA 0 uint16_t vzone_lba = 0; if (vzone != 0) vzone_lba = VZONE_LBA_TBL[m_DiskType][vzone - 1]; - //Calculate Physical Track + // Calculate physical track uint16_t track = (uint16_t)((lba - vzone_lba) >> 1); - //Get the start track from current zone + // Get the start track from current zone uint16_t track_zone_start = SCYL_ZONE_TBL[0][pzone]; if (head != 0) { - //If Head 1, count from the other way around + // If head 1, count from the other way around track = -track; track_zone_start = OUTERCYL_TBL[disk_zone - 1]; } track += SCYL_ZONE_TBL[0][pzone]; - //Get the relative offset to defect tracks for the current zone (if Zone 0, then it's 0) + // Get the relative offset to defect tracks for the current zone (if zone 0, then it's 0) uint16_t defect_offset = 0; if (pzone != 0) defect_offset = sys_data[(8 + pzone - 1) ^ 3]; - //Get amount of defect tracks for the current zone + // Get amount of defect tracks for the current zone uint16_t defect_amount = sys_data[(8 + pzone) ^ 3] - defect_offset; - //Skip defect tracks + // Skip defect tracks while ((defect_amount != 0) && ((sys_data[(0x20 + defect_offset) ^ 3] + track_zone_start) <= track)) { track++; diff --git a/Source/Project64-core/N64System/N64Disk.h b/Source/Project64-core/N64System/N64Disk.h index 6ba241e5e..5ccfd2d4b 100644 --- a/Source/Project64-core/N64System/N64Disk.h +++ b/Source/Project64-core/N64System/N64Disk.h @@ -54,11 +54,11 @@ private: uint16_t LBAToPhys(uint32_t lba); uint16_t PhysToLBA(uint16_t head, uint16_t track, uint16_t block); - //constant values + // Constant values enum { ReadFromRomSection = 0x400000, MameFormatSize = 0x0435B0C0, SDKFormatSize = 0x03DEC800, DiskFormatMAME = 0x0, DiskFormatSDK = 0x1, DiskFormatD64 = 0x2 }; - //class variables + // Class variables CFile m_DiskFile; uint8_t * m_DiskImage; uint8_t * m_DiskImageBase; @@ -73,11 +73,11 @@ private: LanguageStringID m_ErrorMsg; Country m_Country; stdstr m_RomName, m_FileName, m_DiskIdent; - uint8_t m_DiskFormat; //0 = MAME, 1 = SDK, 2 = D64 + uint8_t m_DiskFormat; // 0 = MAME, 1 = SDK, 2 = D64 uint8_t m_DiskType; bool m_isShadowDisk; - //Disk Defines + // Disk defines #define MAX_LBA 0x10DB #define SIZE_LBA MAX_LBA+1 #define SYSTEM_LBAS 24 @@ -134,11 +134,11 @@ private: #define VZoneToPZone(x, y) VZONE_PZONE_TBL[y][x] - //Used for MAME format + // Used for MAME format const uint32_t MAMEStartOffset[16] = { 0x0, 0x5F15E0, 0xB79D00, 0x10801A0, 0x1523720, 0x1963D80, 0x1D414C0, 0x20BBCE0, 0x23196E0, 0x28A1E00, 0x2DF5DC0, 0x3299340, 0x36D99A0, 0x3AB70E0, 0x3E31900, 0x4149200 }; - //Used for SDK and D64 format + // Used for SDK and D64 format uint16_t LBAToPhysTable[SIZE_LBA]; }; \ No newline at end of file diff --git a/Source/Project64-core/N64System/N64Rom.cpp b/Source/Project64-core/N64System/N64Rom.cpp index ea01fc745..5ed111351 100644 --- a/Source/Project64-core/N64System/N64Rom.cpp +++ b/Source/Project64-core/N64System/N64Rom.cpp @@ -29,18 +29,18 @@ CN64Rom::~CN64Rom() bool CN64Rom::AllocateRomImage(uint32_t RomFileSize) { - WriteTrace(TraceN64System, TraceDebug, "Allocating memory for rom"); + WriteTrace(TraceN64System, TraceDebug, "Allocating memory for ROM"); std::unique_ptr ImageBase(new uint8_t[RomFileSize + 0x2000]); if (ImageBase.get() == nullptr) { SetError(MSG_MEM_ALLOC_ERROR); - WriteTrace(TraceN64System, TraceError, "Failed to allocate memory for rom (size: 0x%X)", RomFileSize); + WriteTrace(TraceN64System, TraceError, "Failed to allocate memory for ROM (size: 0x%X)", RomFileSize); return false; } - uint8_t * Image = (uint8_t *)(((uint64_t)ImageBase.get() + 0xFFF) & ~0xFFF); // start at begining of memory page - WriteTrace(TraceN64System, TraceDebug, "Allocated rom memory (%p)", Image); + uint8_t * Image = (uint8_t *)(((uint64_t)ImageBase.get() + 0xFFF) & ~0xFFF); // Start at beginning of memory page + WriteTrace(TraceN64System, TraceDebug, "Allocated ROM memory (%p)", Image); - //save information about the rom loaded + // Save information about the ROM loaded m_ROMImageBase = ImageBase.release(); m_ROMImage = Image; m_RomFileSize = RomFileSize; @@ -56,7 +56,7 @@ bool CN64Rom::AllocateAndLoadN64Image(const char * FileLoc, bool LoadBootCodeOnl return false; } - //Read the first 4 bytes and make sure it is a valid n64 image + // Read the first 4 bytes and make sure it is a valid N64 image uint8_t Test[4]; m_RomFile.SeekToBegin(); if (m_RomFile.Read(Test, sizeof(Test)) != sizeof(Test)) @@ -68,16 +68,16 @@ bool CN64Rom::AllocateAndLoadN64Image(const char * FileLoc, bool LoadBootCodeOnl if (!IsValidRomImage(Test)) { m_RomFile.Close(); - WriteTrace(TraceN64System, TraceError, "invalid image file %X %X %X %X", Test[0], Test[1], Test[2], Test[3]); + WriteTrace(TraceN64System, TraceError, "Invalid image file %X %X %X %X", Test[0], Test[1], Test[2], Test[3]); return false; } uint32_t RomFileSize = m_RomFile.GetLength(); - WriteTrace(TraceN64System, TraceDebug, "Successfully Opened, size: 0x%X", RomFileSize); + WriteTrace(TraceN64System, TraceDebug, "Successfully opened, size: 0x%X", RomFileSize); - //if loading boot code then just load the first 0x1000 bytes + // If loading boot code then just load the first 0x1000 bytes if (LoadBootCodeOnly) { - WriteTrace(TraceN64System, TraceDebug, "loading boot code, so loading the first 0x1000 bytes", RomFileSize); + WriteTrace(TraceN64System, TraceDebug, "Loading boot code, so loading the first 0x1000 bytes", RomFileSize); RomFileSize = 0x1000; } @@ -87,7 +87,7 @@ bool CN64Rom::AllocateAndLoadN64Image(const char * FileLoc, bool LoadBootCodeOnl return false; } - //Load the n64 rom to the allocated memory + // Load the N64 ROM into the allocated memory g_Notify->DisplayMessage(5, MSG_LOADING); m_RomFile.SeekToBegin(); @@ -106,7 +106,7 @@ bool CN64Rom::AllocateAndLoadN64Image(const char * FileLoc, bool LoadBootCodeOnl } TotalRead += dwToRead; - //Show Message of how much % wise of the rom has been loaded + // Show message of how much of the ROM has been loaded (as a percent) g_Notify->DisplayMessage(0, stdstr_f("%s: %.2f%c", GS(MSG_LOADED), ((float)TotalRead / (float)RomFileSize) * 100.0f, '%').c_str()); } @@ -121,7 +121,7 @@ bool CN64Rom::AllocateAndLoadN64Image(const char * FileLoc, bool LoadBootCodeOnl g_Notify->DisplayMessage(5, MSG_BYTESWAP); ByteSwapRom(); - //Protect the memory so that it can not be written to. + // Protect the memory so that it can't be written to ProtectMemory(m_ROMImage, m_RomFileSize, MEM_READONLY); return true; } @@ -137,7 +137,7 @@ bool CN64Rom::AllocateAndLoadZipImage(const char * FileLoc, bool LoadBootCodeOnl int port = unzGoToFirstFile(file); bool FoundRom = false; - //scan through all files in zip to a suitable file is found + // Scan through all files in zip until a suitable file is found while (port == UNZ_OK && !FoundRom) { unz_file_info info; @@ -155,12 +155,12 @@ bool CN64Rom::AllocateAndLoadZipImage(const char * FileLoc, bool LoadBootCodeOnl break; } - //Read the first 4 bytes to check magic number + // Read the first 4 bytes to check magic number uint8_t Test[4]; unzReadCurrentFile(file, Test, sizeof(Test)); if (IsValidRomImage(Test)) { - //Get the size of the rom and try to allocate the memory needed. + // Get the size of the ROM and try to allocate the memory needed uint32_t RomFileSize = info.uncompressed_size; if (LoadBootCodeOnly) { @@ -173,7 +173,7 @@ bool CN64Rom::AllocateAndLoadZipImage(const char * FileLoc, bool LoadBootCodeOnl return false; } - //Load the n64 rom to the allocated memory + // Load the N64 ROM into the allocated memory g_Notify->DisplayMessage(5, MSG_LOADING); memcpy(m_ROMImage, Test, 4); @@ -192,7 +192,7 @@ bool CN64Rom::AllocateAndLoadZipImage(const char * FileLoc, bool LoadBootCodeOnl } TotalRead += dwRead; - //Show Message of how much % wise of the rom has been loaded + // Show message of how much of the ROM has been loaded (as a percent) g_Notify->DisplayMessage(5, stdstr_f("%s: %.2f%c", GS(MSG_LOADED), ((float)TotalRead / (float)RomFileSize) * 100.0f, '%').c_str()); } dwRead = TotalRead + 4; @@ -209,7 +209,7 @@ bool CN64Rom::AllocateAndLoadZipImage(const char * FileLoc, bool LoadBootCodeOnl g_Notify->DisplayMessage(5, MSG_BYTESWAP); ByteSwapRom(); - //Protect the memory so that it can not be written to. + // Protect the memory so that it can't be written to ProtectMemory(m_ROMImage, m_RomFileSize, MEM_READONLY); } unzCloseCurrentFile(file); @@ -241,7 +241,7 @@ void CN64Rom::ByteSwapRom() m_ROMImage[count + 1] ^= m_ROMImage[count + 3]; } break; - case 0x40072780: //64DD IPL + case 0x40072780: // 64DD IPL case 0x40123780: for (count = 0; count < m_RomFileSize; count += 4) { @@ -278,10 +278,10 @@ CICChip CN64Rom::GetCicChipID(uint8_t * RomData, uint64_t * CRC) case 0x000000D6497E414B: return CIC_NUS_6103; case 0x0000011A49F60E96: return CIC_NUS_6105; case 0x000000D6D5BE5580: return CIC_NUS_6106; - case 0x000001053BC19870: return CIC_NUS_5167; //64DD CONVERSION CIC - case 0x000000D2E53EF008: return CIC_NUS_8303; //64DD IPL - case 0x000000D2E53EF39F: return CIC_NUS_DDTL; //64DD IPL TOOL - case 0x000000D2E53E5DDA: return CIC_NUS_DDUS; //64DD IPL US (different CIC) + case 0x000001053BC19870: return CIC_NUS_5167; // 64DD conversion CIC + case 0x000000D2E53EF008: return CIC_NUS_8303; // 64DD IPL + case 0x000000D2E53EF39F: return CIC_NUS_DDTL; // 64DD IPL tool + case 0x000000D2E53E5DDA: return CIC_NUS_DDUS; // 64DD IPL US (different CIC) default: return CIC_UNKNOWN; } @@ -427,7 +427,7 @@ bool CN64Rom::IsValidRomImage(uint8_t Test[4]) if (*((uint32_t *)&Test[0]) == 0x40123780) { return true; } if (*((uint32_t *)&Test[0]) == 0x12408037) { return true; } if (*((uint32_t *)&Test[0]) == 0x80371240) { return true; } - if (*((uint32_t *)&Test[0]) == 0x40072780) { return true; } //64DD IPL + if (*((uint32_t *)&Test[0]) == 0x40072780) { return true; } // 64DD IPL return false; } @@ -459,7 +459,7 @@ void CN64Rom::CleanRomName(char * RomName, bool byteswap) } } - //truncate all the spaces at the end of the string + // Truncate all the spaces at the end of the string for (int count = 19; count >= 0; count--) { if (RomName[count] == ' ') @@ -476,7 +476,7 @@ void CN64Rom::CleanRomName(char * RomName, bool byteswap) } RomName[20] = '\0'; - //remove all /,\,: from the string + // Remove all special characters from the string for (int count = 0; count < (int)strlen(RomName); count++) { switch (RomName[count]) @@ -507,7 +507,7 @@ bool CN64Rom::LoadN64Image(const char * FileLoc, bool LoadBootCodeOnly) { stdstr FullPath = FileLoc; - //this should be a 7zip file + // This should be a 7-zip file char * SubFile = strstr(const_cast(FullPath.c_str()), "?"); if (SubFile != nullptr) { @@ -516,8 +516,8 @@ bool CN64Rom::LoadN64Image(const char * FileLoc, bool LoadBootCodeOnly) } //else load first found file until dialog is implemented //{ - //Pop up a dialog and select file - //allocate memory for sub name and copy selected file name to var + // Pop up a dialog and select file + // Allocate memory for sub name and copy selected file name to variable //} C7zip ZipFile(FullPath.c_str()); @@ -540,9 +540,9 @@ bool CN64Rom::LoadN64Image(const char * FileLoc, bool LoadBootCodeOnly) } } - //Get the size of the rom and try to allocate the memory needed. + // Get the size of the ROM and try to allocate the memory needed uint32_t RomFileSize = (uint32_t)f->Size; - //if loading boot code then just load the first 0x1000 bytes + // If loading boot code then just load the first 0x1000 bytes if (LoadBootCodeOnly) { RomFileSize = 0x1000; } if (!AllocateRomImage(RomFileSize)) @@ -551,7 +551,7 @@ bool CN64Rom::LoadN64Image(const char * FileLoc, bool LoadBootCodeOnly) return false; } - //Load the n64 rom to the allocated memory + // Load the N64 ROM to the allocated memory g_Notify->DisplayMessage(5, MSG_LOADING); if (!ZipFile.GetFile(i, m_ROMImage, RomFileSize)) { @@ -574,7 +574,7 @@ bool CN64Rom::LoadN64Image(const char * FileLoc, bool LoadBootCodeOnly) g_Notify->DisplayMessage(5, MSG_BYTESWAP); ByteSwapRom(); - //Protect the memory so that it can not be written to. + // Protect the memory so that it can't be written to ProtectMemory(m_ROMImage, m_RomFileSize, MEM_READONLY); Loaded7zFile = true; break; @@ -588,7 +588,7 @@ bool CN64Rom::LoadN64Image(const char * FileLoc, bool LoadBootCodeOnly) } #endif - //Try to open the file as a zip file + // Try to open the file as a zip file if (!Loaded7zFile) { if (!AllocateAndLoadZipImage(FileLoc, LoadBootCodeOnly)) @@ -607,7 +607,7 @@ bool CN64Rom::LoadN64Image(const char * FileLoc, bool LoadBootCodeOnly) } char RomName[260]; - //Get the header from the rom image + // Get the header from the ROM image memcpy(&RomName[0], (void *)(m_ROMImage + 0x20), 20); CN64Rom::CleanRomName(RomName); @@ -625,7 +625,7 @@ bool CN64Rom::LoadN64Image(const char * FileLoc, bool LoadBootCodeOnly) if (!LoadBootCodeOnly) { - //Calculate files MD5 + // Calculate files MD5 checksum m_MD5 = MD5((const unsigned char *)m_ROMImage, m_RomFileSize).hex_digest(); WriteTrace(TraceN64System, TraceDebug, "MD5: %s", m_MD5.c_str()); } @@ -636,7 +636,7 @@ bool CN64Rom::LoadN64Image(const char * FileLoc, bool LoadBootCodeOnly) if (IsLoadedRomDDIPL()) { - //Handle CRC differently if 64DD IPL + // Handle CRC differently if it is a 64DD IPL CRC1 = (*(uint16_t *)(&m_ROMImage[0x608]) << 16) | *(uint16_t *)(&m_ROMImage[0x60C]); CRC2 = (*(uint16_t *)(&m_ROMImage[0x638]) << 16) | *(uint16_t *)(&m_ROMImage[0x63C]); } @@ -677,13 +677,13 @@ bool CN64Rom::LoadN64Image(const char * FileLoc, bool LoadBootCodeOnly) } else if (!IsLoadedRomDDIPL()) { - g_Settings->SaveString(Game_GameName, m_RomName.c_str()); //Use Base Game's Save File if loaded in combo + g_Settings->SaveString(Game_GameName, m_RomName.c_str()); // Use base games save file if loaded in combo } } if (g_Settings->LoadBool(Game_CRC_Recalc)) { - //Calculate ROM Header CRC + // Calculate ROM header CRC CalculateRomCrc(); } @@ -703,7 +703,7 @@ bool CN64Rom::LoadN64ImageIPL(const char * FileLoc, bool LoadBootCodeOnly) { stdstr FullPath = FileLoc; - //this should be a 7zip file + // This should be a 7-zip file char * SubFile = strstr(const_cast(FullPath.c_str()), "?"); if (SubFile != nullptr) { @@ -712,8 +712,8 @@ bool CN64Rom::LoadN64ImageIPL(const char * FileLoc, bool LoadBootCodeOnly) } //else load first found file until dialog is implemented //{ - //Pop up a dialog and select file - //allocate memory for sub name and copy selected file name to var + // Pop up a dialog and select file + // Allocate memory for sub name and copy selected file name to variable //} C7zip ZipFile(FullPath.c_str()); @@ -736,9 +736,9 @@ bool CN64Rom::LoadN64ImageIPL(const char * FileLoc, bool LoadBootCodeOnly) } } - //Get the size of the rom and try to allocate the memory needed. + // Get the size of the ROM and try to allocate the memory needed uint32_t RomFileSize = (uint32_t)f->Size; - //if loading boot code then just load the first 0x1000 bytes + // If loading boot code then just load the first 0x1000 bytes if (LoadBootCodeOnly) { RomFileSize = 0x1000; } if (!AllocateRomImage(RomFileSize)) @@ -747,7 +747,7 @@ bool CN64Rom::LoadN64ImageIPL(const char * FileLoc, bool LoadBootCodeOnly) return false; } - //Load the n64 rom to the allocated memory + // Load the N64 ROM to the allocated memory g_Notify->DisplayMessage(5, MSG_LOADING); if (!ZipFile.GetFile(i, m_ROMImage, RomFileSize)) { @@ -770,7 +770,7 @@ bool CN64Rom::LoadN64ImageIPL(const char * FileLoc, bool LoadBootCodeOnly) g_Notify->DisplayMessage(5, MSG_BYTESWAP); ByteSwapRom(); - //Protect the memory so that it can not be written to. + // Protect the memory so that it can't be written to ProtectMemory(m_ROMImage, m_RomFileSize, MEM_READONLY); Loaded7zFile = true; break; @@ -784,7 +784,7 @@ bool CN64Rom::LoadN64ImageIPL(const char * FileLoc, bool LoadBootCodeOnly) } #endif - //Try to open the file as a zip file + // Try to open the file as a zip file if (!Loaded7zFile) { if (!AllocateAndLoadZipImage(FileLoc, LoadBootCodeOnly)) @@ -801,7 +801,7 @@ bool CN64Rom::LoadN64ImageIPL(const char * FileLoc, bool LoadBootCodeOnly) } char RomName[260]; - //Get the header from the rom image + // Get the header from the ROM image memcpy(&RomName[0], (void *)(m_ROMImage + 0x20), 20); CN64Rom::CleanRomName(RomName); if (strlen(RomName) == 0) @@ -817,7 +817,7 @@ bool CN64Rom::LoadN64ImageIPL(const char * FileLoc, bool LoadBootCodeOnly) if (!LoadBootCodeOnly) { - //Calculate files MD5 + // Calculate files MD5 checksum m_MD5 = MD5((const unsigned char *)m_ROMImage, m_RomFileSize).hex_digest(); WriteTrace(TraceN64System, TraceDebug, "MD5: %s", m_MD5.c_str()); } @@ -828,7 +828,7 @@ bool CN64Rom::LoadN64ImageIPL(const char * FileLoc, bool LoadBootCodeOnly) if (IsLoadedRomDDIPL()) { - //Handle CRC differently if 64DD IPL + // Handle CRC differently if it is a 64DD IPL CRC1 = (*(uint16_t *)(&m_ROMImage[0x608]) << 16) | *(uint16_t *)(&m_ROMImage[0x60C]); CRC2 = (*(uint16_t *)(&m_ROMImage[0x638]) << 16) | *(uint16_t *)(&m_ROMImage[0x63C]); } @@ -854,15 +854,15 @@ bool CN64Rom::LoadN64ImageIPL(const char * FileLoc, bool LoadBootCodeOnly) if (g_Settings->LoadBool(Game_CRC_Recalc)) { - //Calculate ROM Header CRC + // Calculate ROM header CRC CalculateRomCrc(); } return true; } -//Save the settings of the loaded rom, so all loaded settings about rom will be identified with -//this rom +// Save the settings of the loaded ROM, so all loaded settings about ROM will be identified with this ROM + void CN64Rom::SaveRomSettingID(bool temp) { g_Settings->SaveBool(Game_TempLoaded, temp); diff --git a/Source/Project64-core/N64System/N64Rom.h b/Source/Project64-core/N64System/N64Rom.h index 78df16621..c7f5761e9 100644 --- a/Source/Project64-core/N64System/N64Rom.h +++ b/Source/Project64-core/N64System/N64Rom.h @@ -27,7 +27,7 @@ public: bool IsPal(); void UnallocateRomImage(); - //Get a message id for the reason that you failed to load the rom + // Get a message ID for the reason that you failed to load the ROM LanguageStringID GetError() const { return m_ErrorMsg; } static CICChip GetCicChipID(uint8_t * RomData, uint64_t * CRC = nullptr); static void CleanRomName(char * RomName, bool byteswap = true); @@ -43,10 +43,10 @@ private: static void NotificationCB(const char * Status, CN64Rom * _this); - //constant values + // Constant values enum { ReadFromRomSection = 0x400000 }; - //class variables + // Class variables CFile m_RomFile; uint8_t * m_ROMImage; uint8_t * m_ROMImageBase; diff --git a/Source/Project64-core/N64System/N64System.cpp b/Source/Project64-core/N64System/N64System.cpp index 298583093..1b97b1dea 100644 --- a/Source/Project64-core/N64System/N64System.cpp +++ b/Source/Project64-core/N64System/N64System.cpp @@ -67,12 +67,12 @@ CN64System::CN64System(CPlugins * Plugins, uint32_t randomizer_seed, bool SavesR if (!m_MMU_VM.Initialize(SyncSystem)) { - WriteTrace(TraceN64System, TraceWarning, "MMU failed to Initialize"); + WriteTrace(TraceN64System, TraceWarning, "MMU failed to initialize"); WriteTrace(TraceN64System, TraceDebug, "Done"); return; } - WriteTrace(TraceN64System, TraceDebug, "Reseting Plugins"); + WriteTrace(TraceN64System, TraceDebug, "Resetting plugins"); g_Notify->DisplayMessage(5, MSG_PLUGIN_INIT); m_Plugins->CreatePlugins(); bool bRes = m_Plugins->Initiate(this); @@ -98,7 +98,7 @@ CN64System::CN64System(CPlugins * Plugins, uint32_t randomizer_seed, bool SavesR { g_Notify->BreakPoint(__FILE__, __LINE__); } - g_Notify->DisplayMessage(5, "Copy Plugins"); + g_Notify->DisplayMessage(5, "Copy plugins"); g_Plugins->CopyPlugins(g_Settings->LoadStringVal(Directory_PluginSync)); m_SyncPlugins = new CPlugins(Directory_PluginSync, true); m_SyncPlugins->SetRenderWindows(g_Plugins->SyncWindow(), nullptr); @@ -154,14 +154,14 @@ CN64System::~CN64System() void CN64System::ExternalEvent(SystemEvent action) { - WriteTrace(TraceN64System, TraceDebug, "action: %s", SystemEventName(action)); + WriteTrace(TraceN64System, TraceDebug, "Action: %s", SystemEventName(action)); if (action == SysEvent_LoadMachineState && !g_Settings->LoadBool(GameRunning_CPU_Running) && g_BaseSystem != nullptr && g_BaseSystem->LoadState()) { - WriteTrace(TraceN64System, TraceDebug, "ignore event, manualy loaded save"); + WriteTrace(TraceN64System, TraceDebug, "Ignore event, manually loaded save"); return; } @@ -170,7 +170,7 @@ void CN64System::ExternalEvent(SystemEvent action) g_BaseSystem != nullptr && g_BaseSystem->SaveState()) { - WriteTrace(TraceN64System, TraceDebug, "ignore event, manualy saved event"); + WriteTrace(TraceN64System, TraceDebug, "Ignore event, manually saved event"); return; } @@ -228,7 +228,7 @@ void CN64System::ExternalEvent(SystemEvent action) } break; case SysEvent_ResumeCPU_FromMenu: - // always resume if from menu + // Always resume if from menu m_hPauseEvent.Trigger(); break; case SysEvent_ResumeCPU_AppGainedFocus: @@ -305,24 +305,24 @@ bool CN64System::LoadFileImage(const char * FileLoc) g_Settings->SaveDword(Game_CurrentSaveState, g_Settings->LoadDefaultDword(Game_CurrentSaveState)); if (g_Settings->LoadBool(GameRunning_LoadingInProgress)) { - WriteTrace(TraceN64System, TraceError, "game loading is in progress, can not load new file"); + WriteTrace(TraceN64System, TraceError, "Game loading is in progress, cannot load new file"); return false; } - //Mark the rom as loading - WriteTrace(TraceN64System, TraceDebug, "Mark Rom as loading"); + // Mark the ROM as loading + WriteTrace(TraceN64System, TraceDebug, "Mark ROM as loading"); g_Settings->SaveString(Game_File, ""); g_Settings->SaveBool(GameRunning_LoadingInProgress, true); - //Try to load the passed N64 rom + // Try to load the passed N64 ROM if (g_Rom == nullptr) { - WriteTrace(TraceN64System, TraceDebug, "Allocating global rom object"); + WriteTrace(TraceN64System, TraceDebug, "Allocating global ROM object"); g_Rom = new CN64Rom(); } else { - WriteTrace(TraceN64System, TraceDebug, "Use existing global rom object"); + WriteTrace(TraceN64System, TraceDebug, "Use existing global ROM object"); } WriteTrace(TraceN64System, TraceDebug, "Loading \"%s\"", FileLoc); @@ -330,7 +330,7 @@ bool CN64System::LoadFileImage(const char * FileLoc) { if (g_Rom->IsLoadedRomDDIPL()) { - //64DD IPL + // 64DD IPL if (g_DDRom == nullptr) { g_DDRom = new CN64Rom(); @@ -351,7 +351,7 @@ bool CN64System::LoadFileImage(const char * FileLoc) g_Settings->SaveString(Game_File, FileLoc); } g_Settings->SaveBool(GameRunning_LoadingInProgress, false); - WriteTrace(TraceN64System, TraceDebug, "Finished Loading (GoodName: %s)", g_Settings->LoadStringVal(Rdb_GoodName).c_str()); + WriteTrace(TraceN64System, TraceDebug, "Finished loading (GoodName: %s)", g_Settings->LoadStringVal(Rdb_GoodName).c_str()); } else { @@ -375,20 +375,20 @@ bool CN64System::LoadFileImageIPL(const char * FileLoc) return false; } - //Mark the rom as loading - WriteTrace(TraceN64System, TraceDebug, "Mark DDRom as loading"); + // Mark the N64DD IPL as loading + WriteTrace(TraceN64System, TraceDebug, "Mark N64DD IPL as loading"); //g_Settings->SaveString(Game_File, ""); g_Settings->SaveBool(GameRunning_LoadingInProgress, true); - //Try to load the passed N64 DDrom + // Try to load the passed N64DD IPL if (g_DDRom == nullptr) { - WriteTrace(TraceN64System, TraceDebug, "Allocating global DDrom object"); + WriteTrace(TraceN64System, TraceDebug, "Allocating global N64DD IPL object"); g_DDRom = new CN64Rom(); } else { - WriteTrace(TraceN64System, TraceDebug, "Use existing global DDrom object"); + WriteTrace(TraceN64System, TraceDebug, "Use existing global N64DD IPL object"); } WriteTrace(TraceN64System, TraceDebug, "Loading \"%s\"", FileLoc); @@ -396,7 +396,7 @@ bool CN64System::LoadFileImageIPL(const char * FileLoc) { if (!g_DDRom->IsLoadedRomDDIPL()) { - //If not 64DD IPL then it's wrong + // If not 64DD IPL then it's wrong WriteTrace(TraceN64System, TraceError, "LoadN64ImageIPL failed (\"%s\")", FileLoc); g_Notify->DisplayError(g_DDRom->GetError()); delete g_DDRom; @@ -437,20 +437,20 @@ bool CN64System::LoadDiskImage(const char * FileLoc, const bool Expansion) return false; } - //Mark the rom as loading - WriteTrace(TraceN64System, TraceDebug, "Mark Disk as loading"); + // Mark the disk as loading + WriteTrace(TraceN64System, TraceDebug, "Mark disk as loading"); //g_Settings->SaveString(Game_File, ""); g_Settings->SaveBool(GameRunning_LoadingInProgress, true); - //Try to load the passed N64 Disk + // Try to load the passed N64 disk if (g_Disk == nullptr) { - WriteTrace(TraceN64System, TraceDebug, "Allocating global Disk object"); + WriteTrace(TraceN64System, TraceDebug, "Allocating global disk object"); g_Disk = new CN64Disk(); } else { - WriteTrace(TraceN64System, TraceDebug, "Use existing global Disk object"); + WriteTrace(TraceN64System, TraceDebug, "Use existing global disk object"); } WriteTrace(TraceN64System, TraceDebug, "Loading \"%s\"", FileLoc); @@ -478,7 +478,7 @@ bool CN64System::LoadDiskImage(const char * FileLoc, const bool Expansion) bool CN64System::RunFileImage(const char * FileLoc) { - //Uninitialize g_Disk and g_DDRom to prevent exception when ending emulation of a regular ROM after playing 64DD content previously. + // Uninitialize g_Disk and g_DDRom to prevent exception when ending emulation of a regular ROM after playing 64DD content previously if (g_Disk != nullptr) { g_Disk->UnallocateDiskImage(); @@ -517,7 +517,7 @@ bool CN64System::RunDiskImage(const char * FileLoc) return false; } - //Select IPL ROM depending on Disk Country Code + // Select IPL ROM depending on disk country code if (!SelectAndLoadFileImageIPL(g_Disk->GetCountry(), false)) { return false; @@ -539,7 +539,7 @@ bool CN64System::RunDiskComboImage(const char * FileLoc, const char * FileLocDis return false; } - //Select IPL ROM depending on Disk Country Code + // Select IPL ROM depending on disk country code if (!SelectAndLoadFileImageIPL(g_Disk->GetCountry(), true)) { return false; @@ -558,7 +558,7 @@ void CN64System::RunLoadedImage(void) { if (g_Settings->LoadBool(Setting_AutoStart) != 0) { - WriteTrace(TraceN64System, TraceDebug, "Automattically starting rom"); + WriteTrace(TraceN64System, TraceDebug, "Automatically starting ROM"); g_BaseSystem->StartEmulation(true); } } @@ -605,7 +605,7 @@ bool CN64System::SelectAndLoadFileImageIPL(Country country, bool combo) IPLROMError = MSG_TOOL_IPL_REQUIRED; if (combo && !CPath(g_Settings->LoadStringVal(File_DiskIPLTOOLPath).c_str()).Exists()) { - //Development IPL is not needed for combo ROM + Disk loading + // Development IPL is not needed for combo ROM + disk loading if (CPath(g_Settings->LoadStringVal(File_DiskIPLPath).c_str()).Exists()) IPLROMPathSetting = File_DiskIPLPath; else if (CPath(g_Settings->LoadStringVal(File_DiskIPLUSAPath).c_str()).Exists()) @@ -660,14 +660,14 @@ bool CN64System::EmulationStarting(CThread * thread) if (g_BaseSystem->SetActiveSystem(true)) { g_BaseSystem->m_thread = thread; - WriteTrace(TraceN64System, TraceDebug, "Setting up N64 system done"); + WriteTrace(TraceN64System, TraceDebug, "Setting up N64 system is done"); g_Settings->SaveBool(GameRunning_LoadingInProgress, false); try { WriteTrace(TraceN64System, TraceDebug, "Game starting"); g_BaseSystem->StartEmulation2(false); - WriteTrace(TraceN64System, TraceDebug, "Game Done"); - //PLACE TO ADD 64DD SAVING CODE + WriteTrace(TraceN64System, TraceDebug, "Game done"); + // TODO: Add 64DD saving code? if (g_Disk != nullptr) { g_Disk->SaveDiskImage(); @@ -715,7 +715,7 @@ void CN64System::StartEmulation2(bool NewThread) WriteTrace(TraceN64System, TraceDebug, "Setting system as active"); if (!m_Plugins->Reset(this) || !m_Plugins->initilized()) { - WriteTrace(TraceN64System, TraceWarning, "can not run, plugins not initlized"); + WriteTrace(TraceN64System, TraceWarning, "Can't run, plugins not initialized"); g_Settings->SaveBool(GameRunning_LoadingInProgress, false); g_Notify->DisplayError(MSG_PLUGIN_NOT_INIT); } @@ -732,9 +732,9 @@ void CN64System::StartEmulation2(bool NewThread) } else { - //mark the emulation as starting and fix up menus + // Mark the emulation as starting and fix up menus g_Notify->DisplayMessage(2, MSG_EMULATION_STARTED); - WriteTrace(TraceN64System, TraceDebug, "Start Executing CPU"); + WriteTrace(TraceN64System, TraceDebug, "Start executing CPU"); ExecuteCPU(); } WriteTrace(TraceN64System, TraceDebug, "Done"); @@ -969,7 +969,7 @@ void CN64System::InitRegisters(bool bPostPif, CMipsMemoryVM & MMU) { m_Reg.Reset(); - //COP0 Registers + // COP0 registers m_Reg.RANDOM_REGISTER = 0x1F; m_Reg.COUNT_REGISTER = 0x5000; m_Reg.MI_VERSION_REG = 0x02020102; @@ -982,9 +982,9 @@ void CN64System::InitRegisters(bool bPostPif, CMipsMemoryVM & MMU) m_Reg.CONFIG_REGISTER = 0x0006E463; m_Reg.STATUS_REGISTER = 0x34000000; - //64DD Registers + // N64DD registers - //Start 64DD in Reset State and Motor Not Spinning + // Start N64DD in reset state and motor not spinning m_Reg.ASIC_STATUS = DD_STATUS_RST_STATE | DD_STATUS_MTR_N_SPIN; m_Reg.ASIC_ID_REG = 0x00030000; if (g_DDRom && (g_DDRom->CicChipID() == CIC_NUS_DDTL || (g_Disk && g_Disk->GetCountry() == Country_Unknown))) @@ -1074,7 +1074,7 @@ void CN64System::InitRegisters(bool bPostPif, CMipsMemoryVM & MMU) case CIC_NUS_DDUS: case CIC_NUS_DDTL: default: - //no specific values + // No specific values break; } m_Reg.m_GPR[20].DW = 0x0000000000000001; @@ -1088,12 +1088,12 @@ void CN64System::InitRegisters(bool bPostPif, CMipsMemoryVM & MMU) case CIC_NUS_6101: m_Reg.m_GPR[22].DW = 0x000000000000003F; break; - case CIC_NUS_8303: //64DD IPL CIC - case CIC_NUS_DDTL: //64DD IPL TOOL CIC - case CIC_NUS_5167: //64DD CONVERSION CIC + case CIC_NUS_8303: // 64DD IPL CIC + case CIC_NUS_DDTL: // 64DD IPL tool CIC + case CIC_NUS_5167: // 64DD conversion CIC m_Reg.m_GPR[22].DW = 0x00000000000000DD; break; - case CIC_NUS_DDUS: //64DD US IPL CIC + case CIC_NUS_DDUS: // 64DD US IPL CIC m_Reg.m_GPR[22].DW = 0x00000000000000DE; break; case CIC_UNKNOWN: @@ -1153,7 +1153,7 @@ void CN64System::InitRegisters(bool bPostPif, CMipsMemoryVM & MMU) else { m_Reg.m_PROGRAM_COUNTER = 0xBFC00000; - /* PIF_Ram[36] = 0x00; PIF_Ram[39] = 0x3F; //common pif ram start values + /* PIF_Ram[36] = 0x00; PIF_Ram[39] = 0x3F; // Common PIF RAM start values switch (g_Rom->CicChipID()) { case CIC_NUS_6101: PIF_Ram[37] = 0x06; PIF_Ram[38] = 0x3F; break; @@ -1170,7 +1170,7 @@ void CN64System::ExecuteCPU() { WriteTrace(TraceN64System, TraceDebug, "Start"); - //reset code + // Reset code g_Settings->SaveBool(GameRunning_CPU_Paused, false); g_Settings->SaveBool(GameRunning_CPU_Running, true); g_Notify->DisplayMessage(2, MSG_EMULATION_STARTED); @@ -1205,7 +1205,7 @@ void CN64System::ExecuteCPU() } WriteTrace(TraceN64System, TraceDebug, "CPU finished executing"); CpuStopped(); - WriteTrace(TraceN64System, TraceDebug, "Notifing plugins rom is done"); + WriteTrace(TraceN64System, TraceDebug, "Notifying plugins ROM is done"); m_Plugins->RomClosed(); if (m_SyncCPU) { @@ -1249,11 +1249,11 @@ void CN64System::UpdateSyncCPU(CN64System * const SecondCPU, uint32_t const Cycl { int CyclesToExecute = Cycles - m_CyclesToSkip; - //Update the number of cycles to skip + // Update the number of cycles to skip m_CyclesToSkip -= Cycles; if (m_CyclesToSkip < 0) { m_CyclesToSkip = 0; } - //Run the other CPU For the same amount of cycles + // Run the other CPU For the same amount of cycles if (CyclesToExecute < 0) { return; } SecondCPU->SetActiveSystem(true); @@ -1438,7 +1438,7 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU) CLog Error; Error.Open(ErrorFile); Error.Log("Errors:\r\n"); - Error.Log("Register, Recompiler, Interpter\r\n"); + Error.Log("Register, Recompiler, Interpreter\r\n"); #ifdef TEST_SP_TRACKING if (m_CurrentSP != GPR[29].UW[0]) { @@ -1552,7 +1552,7 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU) { if (Rdram[z] != Rdram2[z]) { - Error.LogF("Rdram[%X]: %X %X\r\n", z << 2, Rdram[z], Rdram2[z]); + Error.LogF("RDRAM[%X]: %X %X\r\n", z << 2, Rdram[z], Rdram2[z]); } } @@ -1561,7 +1561,7 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU) { if (Imem[z] != Imem2[z]) { - Error.LogF("Imem[%X]: %X %X\r\n", z << 2, Imem[z], Imem2[z]); + Error.LogF("IMEM[%X]: %X %X\r\n", z << 2, Imem[z], Imem2[z]); } } uint32_t * Dmem = (uint32_t *)m_MMU_VM.Dmem(), *Dmem2 = (uint32_t *)SecondCPU->m_MMU_VM.Dmem(); @@ -1569,15 +1569,15 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU) { if (Dmem[z] != Dmem2[z]) { - Error.LogF("Dmem[%X]: %X %X\r\n", z << 2, Dmem[z], Dmem2[z]); + Error.LogF("DMEM[%X]: %X %X\r\n", z << 2, Dmem[z], Dmem2[z]); } } Error.Log("\r\n"); Error.Log("Information:\r\n"); Error.Log("\r\n"); Error.LogF("PROGRAM_COUNTER,0x%X\r\n", m_Reg.m_PROGRAM_COUNTER); - Error.LogF("Current Timer,0x%X\r\n", m_NextTimer); - Error.LogF("Timer Type,0x%X\r\n", m_SystemTimer.CurrentType()); + Error.LogF("Current timer,0x%X\r\n", m_NextTimer); + Error.LogF("Timer type,0x%X\r\n", m_SystemTimer.CurrentType()); Error.Log("\r\n"); for (int i = 0; i < (sizeof(m_LastSuccessSyncPC) / sizeof(m_LastSuccessSyncPC[0])); i++) { @@ -1610,7 +1610,7 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU) count < 10 ? 7 : 6, " ", *(m_Reg.m_FPR_D[count]), *(SecondCPU->m_Reg.m_FPR_D[count])); } Error.Log("\r\n"); - Error.LogF("Rounding Model, 0x%08X, 0x%08X\r\n", m_Reg.m_RoundingModel, SecondCPU->m_Reg.m_RoundingModel); + Error.LogF("Rounding model, 0x%08X, 0x%08X\r\n", m_Reg.m_RoundingModel, SecondCPU->m_Reg.m_RoundingModel); Error.Log("\r\n"); for (count = 0; count < 32; count++) { @@ -1661,7 +1661,7 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU) } } Error.Log("\r\n"); - Error.Log("Code at Last Sync PC:\r\n"); + Error.Log("Code at last sync PC:\r\n"); for (count = 0; count < 50; count++) { uint32_t OpcodeValue, Addr = m_LastSuccessSyncPC[0] + (count << 2); @@ -1672,7 +1672,7 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU) } } - g_Notify->DisplayError("Sync Error"); + g_Notify->DisplayError("Sync error"); g_Notify->BreakPoint(__FILE__, __LINE__); } @@ -1683,7 +1683,7 @@ bool CN64System::SaveState() // if (!m_SystemTimer.SaveAllowed()) { return false; } if ((m_Reg.STATUS_REGISTER & STATUS_EXL) != 0) { - WriteTrace(TraceN64System, TraceDebug, "Done - STATUS_EXL set, can not save"); + WriteTrace(TraceN64System, TraceDebug, "Done - STATUS_EXL set, can't save"); return false; } @@ -1715,13 +1715,13 @@ bool CN64System::SaveState() CPath ZipFile(SaveFile); ZipFile.SetNameExtension(stdstr_f("%s.zip", ZipFile.GetNameExtension().c_str()).c_str()); - //Make sure the target dir exists + // Make sure the target directory exists if (!SaveFile.DirectoryExists()) { SaveFile.DirectoryCreate(); } - //Open the file + // Open the file if (g_Settings->LoadDword(Game_FuncLookupMode) == FuncFind_ChangeMemory) { if (m_Recomp) @@ -1742,7 +1742,7 @@ bool CN64System::SaveState() zipWriteInFileInZip(file, &RdramSize, sizeof(uint32_t)); if (g_Settings->LoadBool(Setting_EnableDisk) && g_Disk) { - //Keep Base ROM Information (64DD IPL / Compatible Game ROM) + // Keep base ROM information (64DD IPL / compatible game ROM) zipWriteInFileInZip(file, &g_Rom->GetRomAddress()[0x10], 0x20); zipWriteInFileInZip(file, g_Disk->GetDiskAddressID(), 0x20); } @@ -1776,13 +1776,13 @@ bool CN64System::SaveState() zipOpenNewFileInZip(file, ExtraInfo.GetNameExtension().c_str(), nullptr, nullptr, 0, nullptr, 0, nullptr, Z_DEFLATED, Z_DEFAULT_COMPRESSION); - //Extra Info v2 + // Extra info v2 zipWriteInFileInZip(file, &SaveID_2, sizeof(SaveID_2)); - //Disk Interface Info + // Disk interface info zipWriteInFileInZip(file, m_Reg.m_DiskInterface, sizeof(uint32_t) * 22); - //System Timers Info + // System timers info m_SystemTimer.SaveData(file); zipCloseFileInZip(file); @@ -1806,13 +1806,13 @@ bool CN64System::SaveState() return true; } - //Write info to file + // Write info to file hSaveFile.SeekToBegin(); hSaveFile.Write(&SaveID_0, sizeof(uint32_t)); hSaveFile.Write(&RdramSize, sizeof(uint32_t)); if (g_Settings->LoadBool(Setting_EnableDisk) && g_Disk) { - //Keep Base ROM Information (64DD IPL / Compatible Game ROM) + // Keep base ROM information (64DD IPL / compatible game ROM) hSaveFile.Write(&g_Rom->GetRomAddress()[0x10], 0x20); hSaveFile.Write(g_Disk->GetDiskAddressID(), 0x20); } @@ -1847,13 +1847,13 @@ bool CN64System::SaveState() CFile hExtraInfo(ExtraInfo, CFileBase::modeWrite | CFileBase::modeCreate); if (hExtraInfo.IsOpen()) { - //Extra Info v2 + // Extra info v2 hExtraInfo.Write(&SaveID_2, sizeof(uint32_t)); - //Disk Interface Info + // Disk interface info hExtraInfo.Write(m_Reg.m_DiskInterface, sizeof(uint32_t) * 22); - //System Timers Info + // System timers info m_SystemTimer.SaveData(hExtraInfo); hExtraInfo.Close(); } @@ -1915,7 +1915,7 @@ bool CN64System::LoadState() } CPath NewFileName = FileName; - //Use old file Name + // Use old file Name if (g_Settings->LoadDword(Game_CurrentSaveState) != 0) { FileName.SetNameExtension(stdstr_f("%s.pj%d", g_Settings->LoadStringVal(Game_GameName).c_str(), g_Settings->LoadDword(Game_CurrentSaveState)).c_str()); @@ -1954,7 +1954,7 @@ bool CN64System::LoadState(const char * FileName) if (g_Settings->LoadDword(Setting_AutoZipInstantSave) || _stricmp(SaveFile.GetExtension().c_str(), ".zip") == 0) { - //If ziping save add .zip on the end + // If zipping save add .zip on the end if (!SaveFile.Exists() && _stricmp(SaveFile.GetExtension().c_str(), ".zip") != 0) { SaveFile.SetNameExtension(stdstr_f("%s.zip", SaveFile.GetNameExtension().c_str()).c_str()); @@ -1987,13 +1987,13 @@ bool CN64System::LoadState(const char * FileName) if (!LoadedZipFile && Value == SaveID_0 && port == UNZ_OK) { unzReadCurrentFile(file, &SaveRDRAMSize, sizeof(SaveRDRAMSize)); - //Check header + // Check header uint8_t LoadHeader[64]; unzReadCurrentFile(file, LoadHeader, 0x40); if (g_Settings->LoadBool(Setting_EnableDisk) && g_Disk) { - //Base ROM Information (64DD IPL / Compatible Game ROM) & Disk Info Check + // Base ROM information (64DD IPL / compatible game ROM) and disk info check if ((memcmp(LoadHeader, &g_Rom->GetRomAddress()[0x10], 0x20) != 0 || memcmp(&LoadHeader[0x20], g_Disk->GetDiskAddressID(), 0x20) != 0) && !g_Notify->AskYesNoQuestion(g_Lang->GetString(MSG_SAVE_STATE_HEADER).c_str())) @@ -2043,21 +2043,21 @@ bool CN64System::LoadState(const char * FileName) } if (LoadedZipFile && Value == SaveID_1 && port == UNZ_OK) { - //Extra Info v1 - //System Timers Info + // Extra info v1 + // System timers info m_SystemTimer.LoadData(file); } if (LoadedZipFile && Value == SaveID_2 && port == UNZ_OK) { - //Extra Info v2 (Project64 2.4) - //Disk Interface Info + // Extra info v2 (Project64 2.4) + // Disk interface info unzReadCurrentFile(file, m_Reg.m_DiskInterface, sizeof(uint32_t) * 22); - //Recover Disk Seek Address (if the save state is done while loading/saving data) + // Recover disk seek address (if the save state is done while loading/saving data) if (g_Disk) DiskBMReadWrite(false); - //System Timers Info + // System timers info m_SystemTimer.LoadData(file); } unzCloseCurrentFile(file); @@ -2083,12 +2083,12 @@ bool CN64System::LoadState(const char * FileName) hSaveFile.Read(&SaveRDRAMSize, sizeof(SaveRDRAMSize)); - //Check header + // Check header uint8_t LoadHeader[64]; hSaveFile.Read(LoadHeader, 0x40); if (g_Settings->LoadBool(Setting_EnableDisk) && g_Disk) { - //Base ROM Information (64DD IPL / Compatible Game ROM) & Disk Info Check + // Base ROM information (64DD IPL / compatible game ROM) and disk info check if ((memcmp(LoadHeader, &g_Rom->GetRomAddress()[0x10], 0x20) != 0 || memcmp(&LoadHeader[0x20], g_Disk->GetDiskAddressID(), 0x20) != 0) && !g_Notify->AskYesNoQuestion(g_Lang->GetString(MSG_SAVE_STATE_HEADER).c_str())) @@ -2138,29 +2138,29 @@ bool CN64System::LoadState(const char * FileName) CFile hExtraInfo(ExtraInfo, CFileBase::modeRead); if (hExtraInfo.IsOpen()) { - //Extra Info version check + // Extra info version check hExtraInfo.Read(&Value, sizeof(Value)); if (Value != SaveID_1 && Value != SaveID_2) hExtraInfo.SeekToBegin(); - //Disk Interface Info + // Disk interface info if (Value == SaveID_2) { hExtraInfo.Read(m_Reg.m_DiskInterface, sizeof(uint32_t) * 22); - //Recover Disk Seek Address (if the save state is done while loading/saving data) + // Recover disk seek address (if the save state is done while loading/saving data) if (g_Disk) DiskBMReadWrite(false); } - //System Timers Info + // System timers info m_SystemTimer.LoadData(hExtraInfo); hExtraInfo.Close(); } } - //Fix losing audio in certain games with certain plugins + // Fix losing audio in certain games with certain plugins AudioResetOnLoad = g_Settings->LoadBool(Game_AudioResetOnLoad); if (AudioResetOnLoad) { @@ -2185,12 +2185,12 @@ bool CN64System::LoadState(const char * FileName) } g_Plugins->Audio()->DacrateChanged(SystemType()); - //Fix Random Register + // Fix random register while ((int)m_Reg.RANDOM_REGISTER < (int)m_Reg.WIRED_REGISTER) { m_Reg.RANDOM_REGISTER += 32 - m_Reg.WIRED_REGISTER; } - //Fix up timer + // Fix up timer m_SystemTimer.SetTimer(CSystemTimer::CompareTimer, m_Reg.COMPARE_REGISTER - m_Reg.COUNT_REGISTER, false); m_SystemTimer.SetTimer(CSystemTimer::ViTimer, NextVITimer, false); m_Reg.FixFpuLocations(); @@ -2288,14 +2288,14 @@ void CN64System::RunRSP() __except_try() { - WriteTrace(TraceRSP, TraceDebug, "do cycles - starting"); + WriteTrace(TraceRSP, TraceDebug, "Do cycles - starting"); g_Plugins->RSP()->DoRspCycles(100); - WriteTrace(TraceRSP, TraceDebug, "do cycles - Done"); + WriteTrace(TraceRSP, TraceDebug, "Do cycles - done"); } __except_catch() { - WriteTrace(TraceRSP, TraceError, "exception generated"); - g_Notify->FatalError("CN64System::RunRSP()\nUnknown memory action\n\nEmulation stop"); + WriteTrace(TraceRSP, TraceError, "Exception generated"); + g_Notify->FatalError("CN64System::RunRSP()\nUnknown memory action\n\nEmulation stopping"); } if (Task == 1 && bDelayDP() && ((m_Reg.m_GfxIntrReg & MI_INTR_DP) != 0)) @@ -2328,7 +2328,7 @@ void CN64System::RunRSP() { m_RspBroke = true; } - WriteTrace(TraceRSP, TraceDebug, "check interrupts"); + WriteTrace(TraceRSP, TraceDebug, "Check interrupts"); g_Reg->CheckInterrupts(); } } @@ -2347,7 +2347,7 @@ void CN64System::RefreshScreen() if (bShowCPUPer()) { CPU_UsageAddr = m_CPU_Usage.StartTimer(Timer_RefreshScreen); } - //Calculate how many cycles to next refresh + // Calculate how many cycles to next refresh if (m_Reg.VI_V_SYNC_REG == 0) { VI_INTR_TIME = 500000; @@ -2381,13 +2381,13 @@ void CN64System::RefreshScreen() __except_try() { - WriteTrace(TraceGFXPlugin, TraceDebug, "UpdateScreen Starting"); + WriteTrace(TraceGFXPlugin, TraceDebug, "UpdateScreen starting"); g_Plugins->Gfx()->UpdateScreen(); if (g_Debugger != nullptr && HaveDebugger()) { g_Debugger->FrameDrawn(); } - WriteTrace(TraceGFXPlugin, TraceDebug, "UpdateScreen Done"); + WriteTrace(TraceGFXPlugin, TraceDebug, "UpdateScreen done"); } __except_catch() { diff --git a/Source/Project64-core/N64System/N64System.h b/Source/Project64-core/N64System/N64System.h index 9e2c8eaa3..ed4527dc3 100644 --- a/Source/Project64-core/N64System/N64System.h +++ b/Source/Project64-core/N64System/N64System.h @@ -27,7 +27,7 @@ class CPlugins; class CRSP_Plugin; class CRecompiler; -//#define TEST_SP_TRACKING //track the SP to make sure all ops pick it up fine +//#define TEST_SP_TRACKING // Track the SP to make sure all ops pick it up fine class CN64System : public CLogging, @@ -44,7 +44,7 @@ public: bool m_EndEmulation; SAVE_CHIP_TYPE m_SaveUsing; - //Methods + // Methods static bool LoadFileImage(const char * FileLoc); static bool LoadFileImageIPL(const char * FileLoc); static bool LoadDiskImage(const char * FileLoc, const bool Expansion); @@ -56,7 +56,7 @@ public: static void CloseSystem(void); void CloseCpu(); - void ExternalEvent(SystemEvent action); //covers gui interacting and timers etc.. + void ExternalEvent(SystemEvent action); // Covers GUI interactions and timers etc. void StartEmulation(bool NewThread); void EndEmulation(); void AlterSpeed(const CSpeedLimiter::ESpeedChange SpeedChange) { m_Limiter.AlterSpeed(SpeedChange); } @@ -79,29 +79,29 @@ public: uint32_t GetButtons(int32_t Control) const { return m_Buttons[Control]; } CPlugins * GetPlugins() { return m_Plugins; } - //Variable used to track that the SP is being handled and stays the same as the real SP in sync core + // Variable used to track that the SP is being handled and stays the same as the real SP in sync core #ifdef TEST_SP_TRACKING uint32_t m_CurrentSP; #endif - //For Sync CPU + // For sync CPU void UpdateSyncCPU(CN64System * const SecondCPU, uint32_t const Cycles); void SyncCPU(CN64System * const SecondCPU); void SyncCPUPC(CN64System * const SecondCPU); void SyncSystem(); void SyncSystemPC(); private: - //Make sure plugins can directly access this information + // Make sure plugins can directly access this information friend class CGfxPlugin; friend class CAudioPlugin; friend class CRSP_Plugin; friend class CControl_Plugin; - //Recompiler has access to manipulate and call functions + // Recompiler has access to manipulate and call functions friend class CSystemTimer; friend class CRecompiler; friend class CMipsMemoryVM; - //Used for loading and potentially executing the CPU in its own thread. + // Used for loading and potentially executing the CPU in its own thread static void StartEmulationThread(CThread * thread); static bool EmulationStarting(CThread * thread); static void StartEmulationThead(); @@ -114,28 +114,28 @@ private: void InitRegisters(bool bPostPif, CMipsMemoryVM & MMU); void DisplayRSPListCount(); - //CPU Methods + // CPU methods void ExecuteRecompiler(); void ExecuteInterpret(); void ExecuteSyncCPU(); - //Mark information saying that the CPU has stopped + // Mark information saying that the CPU has stopped void CpuStopped(); - //Functions in CTLB_CB + // Functions in CTLB_CB void TLB_Mapped(uint32_t VAddr, uint32_t Len, uint32_t PAddr, bool bReadOnly); void TLB_Unmaped(uint32_t VAddr, uint32_t Len); void TLB_Changed(); - CPlugins * const m_Plugins; //The plugin container + CPlugins * const m_Plugins; // The plugin container CPlugins * m_SyncPlugins; CN64System * m_SyncCPU; - CMipsMemoryVM m_MMU_VM; //Memory of the n64 + CMipsMemoryVM m_MMU_VM; // Memory of the N64 CTLB m_TLB; CRegisters m_Reg; CMempak m_Mempak; CFramePerSecond m_FPS; - CProfiling m_CPU_Usage; //used to track the cpu usage + CProfiling m_CPU_Usage; // Used to track the CPU usage CRecompiler * m_Recomp; CAudio m_Audio; CSpeedLimiter m_Limiter; @@ -155,24 +155,24 @@ private: bool m_SyncSystem; CRandom m_Random; - //When Syncing cores this is the PC where it last Sync'ed correctly + // When syncing cores this is the PC where it last synced correctly uint32_t m_LastSuccessSyncPC[10]; int32_t m_CyclesToSkip; - //Handle to the cpu thread + // Handle to the CPU thread CThread * m_thread; - //Handle to pause mutex + // Handle to pause mutex SyncEvent m_hPauseEvent; - //No of Alist and Dlist sent to the RSP + // Number of Alist and Dlist sent to the RSP uint32_t m_AlistCount, m_DlistCount, m_UnknownCount; - //list of function that have been called .. used in profiling + // List of function that have been called (used in profiling) FUNC_CALLS m_FunctionCalls; - //list of Save State File IDs - const uint32_t SaveID_0 = 0x23D8A6C8; //Main Save State Info (*.pj) - const uint32_t SaveID_1 = 0x56D2CD23; //Extra Data v1 (System Timing) Info (*.dat) - const uint32_t SaveID_2 = 0x750A6BEB; //Extra Data v2 (Timing + Disk Registers) (*.dat) + // List of save state file IDs + const uint32_t SaveID_0 = 0x23D8A6C8; // Main save state info (*.pj) + const uint32_t SaveID_1 = 0x56D2CD23; // Extra data v1 (system timing) info (*.dat) + const uint32_t SaveID_2 = 0x750A6BEB; // Extra data v2 (timing + disk registers) (*.dat) }; diff --git a/Source/Project64-core/N64System/N64Types.h b/Source/Project64-core/N64System/N64Types.h index c2fb206a4..cea38122b 100644 --- a/Source/Project64-core/N64System/N64Types.h +++ b/Source/Project64-core/N64System/N64Types.h @@ -2,12 +2,13 @@ #include /* - * The limits of COP1 extend to native SSE2 register capabilities, but for - * now this is only being included to dodge the MSVC inline asm for x86. - * - * As better cross-platform methods of handling FP precision are implemented - * for non-Intel-architecture builds, this #include may become obsolete. - */ +The limits of COP1 extend to native SSE2 register capabilities, but for +now this is only being included to dodge the MSVC inline assembler for x86. + +As better cross-platform methods of handling floating point precision are implemented +for non-Intel-architecture builds, this #include may become obsolete. +*/ + #if defined(__i386) || defined(__x86_64__) || defined(_M_X64) #include #endif diff --git a/Source/Project64-core/N64System/Profiling.h b/Source/Project64-core/N64System/Profiling.h index e221e23b2..6f8e0e693 100644 --- a/Source/Project64-core/N64System/Profiling.h +++ b/Source/Project64-core/N64System/Profiling.h @@ -10,11 +10,11 @@ public: void RecordTime(PROFILE_TIMERS timer, uint32_t time); uint64_t NonCPUTime(void); - //recording timing against current timer, returns the address of the timer stopped + // Recording timing against the current timer, returns the address of the timer stopped PROFILE_TIMERS StartTimer(PROFILE_TIMERS TimerType); PROFILE_TIMERS StopTimer(); - //Display the CPU Usage + // Display the CPU usage void ShowCPU_Usage(); void ResetTimers(void); diff --git a/Source/Project64-core/N64System/Recompiler/Arm/ArmOpCode.h b/Source/Project64-core/N64System/Recompiler/Arm/ArmOpCode.h index 78e0a67ac..bf465cdbe 100644 --- a/Source/Project64-core/N64System/Recompiler/Arm/ArmOpCode.h +++ b/Source/Project64-core/N64System/Recompiler/Arm/ArmOpCode.h @@ -94,7 +94,7 @@ union Arm32Opcode uint32_t Hex; uint8_t Ascii[4]; - // uint16 + uint16 type instuction + // uint16 + uint16 type instruction struct { unsigned rn : 4; diff --git a/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.cpp b/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.cpp index ce26c8dc9..905c317ea 100644 --- a/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.cpp +++ b/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.cpp @@ -16,9 +16,8 @@ CArmOps::ArmReg CArmOps::m_LastStoreReg; uint16_t CArmOps::m_PopRegisters = 0; uint16_t CArmOps::m_PushRegisters = 0; -/************************************************************************** -* Logging Functions * -**************************************************************************/ +// Logging functions + void CArmOps::WriteArmComment(const char * Comment) { CPU_Message(""); @@ -126,7 +125,7 @@ void CArmOps::AddConstToArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t Const) if (DestReg == SourceReg && Const == 0) { - //ignore + // Ignore } else if ((Const & 0xFFFFFFF8) == 0 && DestReg <= 7 && SourceReg <= 7) { @@ -836,7 +835,7 @@ void CArmOps::PushArmReg(uint16_t Registers) { if (Registers == m_PopRegisters) { - CPU_Message("%s: Ignoring Push/Pop", __FUNCTION__); + CPU_Message("%s: Ignoring push/pop", __FUNCTION__); m_PopRegisters = 0; PreOpCheck(Arm_Unknown, false, __FILE__, __LINE__); return; @@ -1373,7 +1372,7 @@ void CArmOps::XorConstToArmReg(ArmReg DestReg, uint32_t value) if (value == 0) { - //ignore + // Ignore } else if (CanThumbCompressConst(value)) { diff --git a/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.h b/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.h index 47c8e90f3..6dbc0a550 100644 --- a/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.h +++ b/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.h @@ -115,13 +115,13 @@ public: enum ArmCompareType { - ArmBranch_Equal = 0, //Code = 0000 - ArmBranch_Notequal = 1, //Code = 0001 - ArmBranch_GreaterThanOrEqual = 10, //Code = 1010 - ArmBranch_LessThan = 11, //Code = 1011 - ArmBranch_GreaterThan = 12, //Code = 1100 - ArmBranch_LessThanOrEqual = 13, //Code = 1101 - ArmBranch_Always = 14, //Code = 1110 + ArmBranch_Equal = 0, // Code = 0000 + ArmBranch_Notequal = 1, // Code = 0001 + ArmBranch_GreaterThanOrEqual = 10, // Code = 1010 + ArmBranch_LessThan = 11, // Code = 1011 + ArmBranch_GreaterThan = 12, // Code = 1100 + ArmBranch_LessThanOrEqual = 13, // Code = 1101 + ArmBranch_Always = 14, // Code = 1110 }; enum ArmItMask @@ -144,7 +144,7 @@ public: }; protected: - //Logging Functions + // Logging functions static void WriteArmComment(const char * Comment); static void WriteArmLabel(const char * Label); diff --git a/Source/Project64-core/N64System/Recompiler/Arm/ArmRecompilerOps.cpp b/Source/Project64-core/N64System/Recompiler/Arm/ArmRecompilerOps.cpp index 920478643..a2d1ac346 100644 --- a/Source/Project64-core/N64System/Recompiler/Arm/ArmRecompilerOps.cpp +++ b/Source/Project64-core/N64System/Recompiler/Arm/ArmRecompilerOps.cpp @@ -166,7 +166,8 @@ void CArmRecompilerOps::Compile_TrapCompare(TRAP_COMPARE CompareType) } } -/************************** Branch functions ************************/ +// Branch functions + void CArmRecompilerOps::Compile_BranchCompare(BRANCH_COMPARE CompareType) { switch (CompareType) @@ -643,7 +644,7 @@ void CArmRecompilerOps::BNE_Compare() if (m_Section->m_Jump.FallThrough) { Jump = *g_RecompPos; - BranchLabel8(ArmBranch_Notequal, "continue"); + BranchLabel8(ArmBranch_Notequal, "Continue"); } else { @@ -721,7 +722,7 @@ void CArmRecompilerOps::BNE_Compare() if (m_Section->m_Jump.FallThrough) { Jump = *g_RecompPos; - BranchLabel8(ArmBranch_Notequal, "continue"); + BranchLabel8(ArmBranch_Notequal, "Continue"); } else { @@ -810,7 +811,7 @@ void CArmRecompilerOps::BNE_Compare() if (m_Section->m_Jump.FallThrough) { Jump = *g_RecompPos; - BranchLabel8(ArmBranch_Notequal, "continue"); + BranchLabel8(ArmBranch_Notequal, "Continue"); } else { @@ -885,7 +886,7 @@ void CArmRecompilerOps::BNE_Compare() if (m_Section->m_Jump.FallThrough) { Jump = *g_RecompPos; - BranchLabel8(ArmBranch_Notequal, "continue"); + BranchLabel8(ArmBranch_Notequal, "Continue"); } else { @@ -980,7 +981,7 @@ void CArmRecompilerOps::BEQ_Compare() if (m_Section->m_Cont.FallThrough) { Jump = *g_RecompPos; - BranchLabel8(ArmBranch_Notequal, "continue"); + BranchLabel8(ArmBranch_Notequal, "Continue"); } else { @@ -1057,7 +1058,7 @@ void CArmRecompilerOps::BEQ_Compare() if (m_Section->m_Cont.FallThrough) { Jump = *g_RecompPos; - BranchLabel8(ArmBranch_Notequal, "continue"); + BranchLabel8(ArmBranch_Notequal, "Continue"); } else { @@ -1141,7 +1142,7 @@ void CArmRecompilerOps::BEQ_Compare() if (m_Section->m_Cont.FallThrough) { Jump = *g_RecompPos; - BranchLabel8(ArmBranch_Notequal, "continue"); + BranchLabel8(ArmBranch_Notequal, "Continue"); } else { @@ -1204,7 +1205,7 @@ void CArmRecompilerOps::BEQ_Compare() if (m_Section->m_Cont.FallThrough) { Jump = *g_RecompPos; - BranchLabel8(ArmBranch_Notequal, "continue"); + BranchLabel8(ArmBranch_Notequal, "Continue"); } else { @@ -1328,12 +1329,12 @@ void CArmRecompilerOps::BGTZ_Compare() BranchLabel20(ArmBranch_LessThan, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); Jump = *g_RecompPos; - BranchLabel8(ArmBranch_GreaterThan, "continue"); + BranchLabel8(ArmBranch_GreaterThan, "Continue"); } else if (m_Section->m_Cont.FallThrough) { Jump = *g_RecompPos; - BranchLabel8(ArmBranch_LessThan, "continue"); + BranchLabel8(ArmBranch_LessThan, "Continue"); BranchLabel20(ArmBranch_GreaterThan, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } @@ -1829,7 +1830,8 @@ void CArmRecompilerOps::COP1_BCT_Compare() } } -/************************* OpCode functions *************************/ +// Opcode functions + void CArmRecompilerOps::J() { if (m_NextInstruction == NORMAL) @@ -2335,8 +2337,8 @@ void CArmRecompilerOps::LW(bool ResultSigned, bool bRecordLLBit) if (g_System->bFastSP() && m_Opcode.rt == 29) { g_Notify->BreakPoint(__FILE__, __LINE__); - /*ResetX86Protection(); - ResetMemoryStack();*/ + //ResetX86Protection(); + //ResetMemoryStack(); } } @@ -3671,7 +3673,7 @@ void CArmRecompilerOps::SPECIAL_SLT() MoveConstToArmReg(useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : UnknownArmReg, (uint16_t)0); CPU_Message(""); - CPU_Message(" Continue:"); + CPU_Message(" continue:"); SetJump8(JumpContinue, *g_RecompPos); if (!useRdReg) { @@ -3754,7 +3756,7 @@ void CArmRecompilerOps::SPECIAL_SLT() MoveConstToArmReg(useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : TempRegRt, (uint16_t)1); MoveConstToArmReg(useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : TempRegRt, (uint16_t)0); CPU_Message(""); - CPU_Message(" Continue:"); + CPU_Message(" continue:"); SetJump8(JumpContinue, *g_RecompPos); if (!useRdReg) { @@ -3923,14 +3925,15 @@ void CArmRecompilerOps::SPECIAL_DSRA32() } } -/************************** COP0 functions **************************/ +// COP0 functions + void CArmRecompilerOps::COP0_MF() { if (m_Opcode.rt != 0) { UnMap_GPR(m_Opcode.rt, true); } switch (m_Opcode.rd) { - case 9: //Count + case 9: // Count m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); UpdateCounters(m_RegWorkingSet, false, true); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); @@ -3952,21 +3955,21 @@ void CArmRecompilerOps::COP0_MT() switch (m_Opcode.rd) { - case 0: //Index - case 2: //EntryLo0 - case 3: //EntryLo1 - case 4: //Context - case 5: //PageMask - case 10: //Entry Hi - case 12: //Status - case 13: //cause - case 14: //EPC - case 16: //Config - case 18: //WatchLo - case 19: //WatchHi - case 28: //Tag lo - case 29: //Tag Hi - case 30: //ErrEPC + case 0: // Index + case 2: // EntryLo0 + case 3: // EntryLo1 + case 4: // Context + case 5: // PageMask + case 10: // Entry Hi + case 12: // Status + case 13: // Cause + case 14: // EPC + case 16: // Config + case 18: // WatchLo + case 19: // WatchHi + case 28: // Tag Lo + case 29: // Tag Hi + case 30: // ErrEPC if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::COP0_MT, "R4300iOp32::COP0_MT"); @@ -3976,9 +3979,9 @@ void CArmRecompilerOps::COP0_MT() CompileInterpterCall((void *)R4300iOp::COP0_MT, "R4300iOp::COP0_MT"); } break; - case 6: //Wired - case 9: //Count - case 11: //Compare + case 6: // Wired + case 9: // Count + case 11: // Compare m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); UpdateCounters(m_RegWorkingSet, false, true); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); @@ -4080,7 +4083,8 @@ void CArmRecompilerOps::COP0_CO_ERET() m_NextInstruction = END_BLOCK; } -/************************** COP1 functions **************************/ +// COP1 functions + void CArmRecompilerOps::COP1_MF() { CompileCop1Test(); @@ -4952,7 +4956,7 @@ void CArmRecompilerOps::SyncRegState(const CRegInfo & SyncTo) if (m_RegWorkingSet.GetArmRegMapped((ArmReg)i) == CArmRegInfo::GPR_Mapped) { bool moved_gpr_mapping = false; - //See if mapped, if so move it + // See if mapped, if so move it for (uint32_t z = 0; z < 16; z++) { if (SyncTo.GetArmRegMapped((ArmReg)z) != CArmRegInfo::GPR_Mapped) @@ -4984,7 +4988,7 @@ void CArmRecompilerOps::SyncRegState(const CRegInfo & SyncTo) } } bool moved = false; - //See if mapped, if so move it + // See if mapped, if so move it for (uint32_t z = i + 1; z < 16; z++) { if (m_RegWorkingSet.GetArmRegMapped((ArmReg)z) == CArmRegInfo::Variable_Mapped && @@ -5010,7 +5014,7 @@ void CArmRecompilerOps::SyncRegState(const CRegInfo & SyncTo) if (m_RegWorkingSet.GetArmRegMapped((ArmReg)i) == CArmRegInfo::Variable_Mapped && m_RegWorkingSet.GetVariableMappedTo((ArmReg)i) != SyncTo.GetVariableMappedTo((ArmReg)i)) { - //See if mapped, if so move it + // See if mapped, if so move it for (uint32_t z = i + 1; z < 16; z++) { if (SyncTo.GetArmRegMapped((ArmReg)z) != CArmRegInfo::Variable_Mapped || @@ -5053,14 +5057,14 @@ void CArmRecompilerOps::SyncRegState(const CRegInfo & SyncTo) else if (MemStackReg == x86_Unknown) { UnMap_X86reg(TargetStackReg); - CPU_Message(" regcache: allocate %s as Memory Stack", x86_Name(TargetStackReg)); + CPU_Message(" regcache: allocate %s as memory stack", x86_Name(TargetStackReg)); m_RegWorkingSet.SetX86Mapped(TargetStackReg, CRegInfo::Stack_Mapped); MoveVariableToX86reg(&g_Recompiler->MemoryStackPos(), "MemoryStack", TargetStackReg); } else { UnMap_X86reg(TargetStackReg); - CPU_Message(" regcache: change allocation of Memory Stack from %s to %s", x86_Name(MemStackReg), x86_Name(TargetStackReg)); + CPU_Message(" regcache: change allocation of memory stack from %s to %s", x86_Name(MemStackReg), x86_Name(TargetStackReg)); m_RegWorkingSet.SetX86Mapped(TargetStackReg, CRegInfo::Stack_Mapped); m_RegWorkingSet.SetX86Mapped(MemStackReg, CRegInfo::NotMapped); MoveX86RegToX86Reg(MemStackReg, TargetStackReg); @@ -5103,12 +5107,12 @@ void CArmRecompilerOps::SyncRegState(const CRegInfo & SyncTo) case CRegInfo::STATE_CONST_32_SIGN: if (GetMipsRegLo(i) != SyncTo.GetMipsRegLo(i)) { - CPU_Message("Value of const is different Reg %d (%s) Value: 0x%08X to 0x%08X", i, CRegName::GPR[i], GetMipsRegLo(i), SyncTo.GetMipsRegLo(i)); + CPU_Message("Value of constant is different register %d (%s) Value: 0x%08X to 0x%08X", i, CRegName::GPR[i], GetMipsRegLo(i), SyncTo.GetMipsRegLo(i)); g_Notify->BreakPoint(__FILE__, __LINE__); } continue; default: - CPU_Message("Unhandled Reg state %d\nin SyncRegState", GetMipsRegState(i)); + CPU_Message("Unhandled register state %d\nin SyncRegState", GetMipsRegState(i)); g_Notify->BreakPoint(__FILE__, __LINE__); } } @@ -5258,7 +5262,7 @@ void CArmRecompilerOps::SyncRegState(const CRegInfo & SyncTo) case CRegInfo::STATE_CONST_32_SIGN: if (!g_System->b32BitCore() && GetMipsRegLo_S(i) < 0) { - CPU_Message("Sign Problems in SyncRegState\nSTATE_MAPPED_32_ZERO"); + CPU_Message("Sign problems in SyncRegState\nSTATE_MAPPED_32_ZERO"); CPU_Message("%s: %X", CRegName::GPR[i], GetMipsRegLo_S(i)); g_Notify->BreakPoint(__FILE__, __LINE__); } @@ -5503,7 +5507,7 @@ bool CArmRecompilerOps::InheritParentInfo() return true; } - //Multiple Parents + // Multiple parents BLOCK_PARENT_LIST ParentList; CCodeSection::SECTION_LIST::iterator iter; for (iter = m_Section->m_ParentSection.begin(); iter != m_Section->m_ParentSection.end(); iter++) @@ -5576,7 +5580,7 @@ bool CArmRecompilerOps::InheritParentInfo() FirstParent = 0; } - //Link First Parent to start + // Link first parent to start CCodeSection * Parent = ParentList[FirstParent].Parent; CJumpInfo * JumpInfo = ParentList[FirstParent].JumpInfo; @@ -5610,7 +5614,7 @@ bool CArmRecompilerOps::InheritParentInfo() } JumpInfo->FallThrough = false; - //determine loop reg usage + // Determine loop register usage if (m_Section->m_InLoop && ParentList.size() > 1) { if (!SetupRegisterForLoop(m_Section->m_BlockInfo, m_Section->m_RegEnter)) { return false; } @@ -5632,7 +5636,7 @@ bool CArmRecompilerOps::InheritParentInfo() if (m_RegWorkingSet.GetRoundingModel() != RegSet->GetRoundingModel()) { m_RegWorkingSet.SetRoundingModel(CRegInfo::RoundUnknown); } - //Find Parent MapRegState + // Find parent MapRegState /*MemoryStackPos = x86_Unknown; for (i2 = 0; i2 < sizeof(x86_Registers) / sizeof(x86_Registers[0]); i2++) { @@ -5644,7 +5648,7 @@ bool CArmRecompilerOps::InheritParentInfo() } if (MemoryStackPos == x86_Unknown) { - // if the memory stack position is not mapped then unmap it + // If the memory stack position is not mapped then unmap it x86Reg MemStackReg = Get_MemoryStack(); if (MemStackReg != x86_Unknown) { @@ -5686,7 +5690,7 @@ bool CArmRecompilerOps::InheritParentInfo() } break; default: - CPU_Message("Unknown CPU State(%d) in InheritParentInfo", GetMipsRegState(i2)); + CPU_Message("Unknown CPU state(%d) in InheritParentInfo", GetMipsRegState(i2)); g_Notify->BreakPoint(__FILE__, __LINE__); } } @@ -5729,7 +5733,7 @@ bool CArmRecompilerOps::InheritParentInfo() } break; default: - CPU_Message("Unknown CPU State(%d) in InheritParentInfo", RegSet->GetMipsRegState(i2)); + CPU_Message("Unknown CPU state(%d) in InheritParentInfo", RegSet->GetMipsRegState(i2)); g_Notify->BreakPoint(__FILE__, __LINE__); break; } @@ -5755,7 +5759,7 @@ bool CArmRecompilerOps::InheritParentInfo() } m_Section->m_RegEnter = m_RegWorkingSet; - //Sync registers for different blocks + // Sync registers for different blocks stdstr_f Label("Section_%d", m_Section->m_SectionID); int CurrentParent = FirstParent; bool NeedSync = false; @@ -5828,7 +5832,7 @@ bool CArmRecompilerOps::InheritParentInfo() } break; default: - WriteTrace(TraceRecompiler, TraceError, "Unhandled Reg state %d\nin InheritParentInfo", GetMipsRegState(i2)); + WriteTrace(TraceRecompiler, TraceError, "Unhandled register state %d\nin InheritParentInfo", GetMipsRegState(i2)); g_Notify->BreakPoint(__FILE__, __LINE__); } } @@ -5865,7 +5869,7 @@ bool CArmRecompilerOps::InheritParentInfo() { UpdateCounters(m_RegWorkingSet, false, true); } - SyncRegState(m_Section->m_RegEnter); //Sync + SyncRegState(m_Section->m_RegEnter); // Sync m_Section->m_RegEnter = m_RegWorkingSet; } @@ -5966,7 +5970,7 @@ void CArmRecompilerOps::UpdateSyncCPU(CRegInfo & RegSet, uint32_t Cycles) { return; } - WriteArmComment("Updating Sync CPU"); + WriteArmComment("Updating sync CPU"); RegSet.BeforeCallDirect(); MoveConstToArmReg(Arm_R2, Cycles); MoveConstToArmReg(Arm_R1, (uint32_t)g_SyncSystem, "g_SyncSystem"); @@ -5980,7 +5984,7 @@ void CArmRecompilerOps::UpdateCounters(CRegInfo & RegSet, bool CheckTimer, bool if (RegSet.GetBlockCycleCount() != 0) { UpdateSyncCPU(RegSet, RegSet.GetBlockCycleCount()); - WriteArmComment("Update Counter"); + WriteArmComment("Update counter"); ArmReg NextTimerReg = RegSet.Map_Variable(CArmRegInfo::VARIABLE_NEXT_TIMER); ArmReg TempReg = RegSet.Map_TempReg(Arm_Any, -1, false); @@ -6133,7 +6137,7 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) default: if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } } break; @@ -6169,10 +6173,10 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) case 0x0404001C: MoveConstToVariable(0, &g_Reg->SP_SEMAPHORE_REG, "SP_SEMAPHORE_REG"); break; case 0x04080000: MoveConstToVariable(Value & 0xFFC, &g_Reg->SP_PC_REG, "SP_PC_REG"); break; default: - CPU_Message(" Should be moving %X in to %08X ?!?", Value, VAddr); + CPU_Message(" should be moving %X in to %08X ?", Value, VAddr); if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } } @@ -6191,7 +6195,7 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) default: if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } } @@ -6303,10 +6307,10 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) } break; default: - CPU_Message(" Should be moving %X in to %08X ?!?", Value, VAddr); + CPU_Message(" should be moving %X in to %08X ?", Value, VAddr); if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } } @@ -6324,7 +6328,7 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) CompareArmRegToArmReg(TempReg, TempValueReg); uint8_t * Jump = *g_RecompPos; - BranchLabel8(ArmBranch_Equal, "continue"); + BranchLabel8(ArmBranch_Equal, "Continue"); m_RegWorkingSet.BeforeCallDirect(); ArmReg VariableReg = TempValueReg != Arm_R1 ? Arm_R1 : Arm_R2; @@ -6349,7 +6353,7 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) CompareArmRegToArmReg(TempReg, TempValueReg); uint8_t * Jump = *g_RecompPos; - BranchLabel8(ArmBranch_Equal, "continue"); + BranchLabel8(ArmBranch_Equal, "Continue"); MoveArmRegToVariable(TempValueReg, &g_Reg->VI_WIDTH_REG, "VI_WIDTH_REG"); m_RegWorkingSet.BeforeCallDirect(); @@ -6357,7 +6361,7 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) m_RegWorkingSet.AfterCallDirect(); FlushPopArmReg(); CPU_Message(""); - CPU_Message(" Continue:"); + CPU_Message(" continue:"); SetJump8(Jump, *g_RecompPos); } break; @@ -6379,15 +6383,15 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) case 0x04400030: MoveConstToVariable(Value, &g_Reg->VI_X_SCALE_REG, "VI_X_SCALE_REG"); break; case 0x04400034: MoveConstToVariable(Value, &g_Reg->VI_Y_SCALE_REG, "VI_Y_SCALE_REG"); break; default: - CPU_Message(" Should be moving %X in to %08X ?!?", Value, VAddr); + CPU_Message(" should be moving %X in to %08X ?", Value, VAddr); if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } } break; - case 0x04500000: /* AI registers */ + case 0x04500000: // AI registers switch (PAddr) { case 0x04500000: MoveConstToVariable(Value, &g_Reg->AI_DRAM_ADDR_REG, "AI_DRAM_ADDR_REG"); break; @@ -6408,7 +6412,7 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) break; case 0x04500008: MoveConstToVariable((Value & 1), &g_Reg->AI_CONTROL_REG, "AI_CONTROL_REG"); break; case 0x0450000C: - /* Clear Interrupt */; + // Clear interrupt AndConstToVariable(&g_Reg->MI_INTR_REG, "MI_INTR_REG", (uint32_t)~MI_INTR_AI); AndConstToVariable(&g_Reg->m_AudioIntrReg, "m_AudioIntrReg", (uint32_t)~MI_INTR_AI); m_RegWorkingSet.BeforeCallDirect(); @@ -6426,10 +6430,10 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) break; case 0x04500014: MoveConstToVariable(Value, &g_Reg->AI_BITRATE_REG, "AI_BITRATE_REG"); break; default: - CPU_Message(" Should be moving %X in to %08X ?!?", Value, VAddr); + CPU_Message(" should be moving %X in to %08X ?", Value, VAddr); if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } } @@ -6475,10 +6479,10 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) case 0x0460002C: MoveConstToVariable((Value & 0xFF), &g_Reg->PI_BSD_DOM2_PGS_REG, "PI_BSD_DOM2_PGS_REG"); break; case 0x04600030: MoveConstToVariable((Value & 0xFF), &g_Reg->PI_BSD_DOM2_RLS_REG, "PI_BSD_DOM2_RLS_REG"); break; default: - CPU_Message(" Should be moving %X in to %08X ?!?", Value, VAddr); + CPU_Message(" should be moving %X in to %08X ?", Value, VAddr); if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } } @@ -6491,10 +6495,10 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) case 0x04700008: MoveConstToVariable(Value, &g_Reg->RI_CURRENT_LOAD_REG, "RI_CURRENT_LOAD_REG"); break; case 0x0470000C: MoveConstToVariable(Value, &g_Reg->RI_SELECT_REG, "RI_SELECT_REG"); break; default: - CPU_Message(" Should be moving %X in to %08X ?!?", Value, VAddr); + CPU_Message(" should be moving %X in to %08X ?", Value, VAddr); if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } } @@ -6532,16 +6536,16 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) m_RegWorkingSet.AfterCallDirect(); break; default: - CPU_Message(" Should be moving %X in to %08X ?!?", Value, VAddr); + CPU_Message(" should be moving %X in to %08X ?", Value, VAddr); if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } } break; case 0x05000000: - //64DD Registers + // 64DD registers if (g_Settings->LoadBool(Setting_EnableDisk)) { switch (PAddr) @@ -6552,10 +6556,10 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) m_RegWorkingSet.AfterCallDirect(); break; default: - CPU_Message(" Should be moving %X in to %08X ?!?", Value, VAddr); + CPU_Message(" should be moving %X in to %08X ?", Value, VAddr); if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } } @@ -6574,10 +6578,10 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) m_RegWorkingSet.AfterCallDirect(); break; default: - CPU_Message(" Should be moving %X in to %08X ?!?", Value, VAddr); + CPU_Message(" should be moving %X in to %08X ?", Value, VAddr); if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } } @@ -6641,10 +6645,10 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) case 0x03F8000C: break; case 0x03F80014: break; default: - CPU_Message(" Should be moving %s in to %08X ?!?", ArmRegName(Reg), VAddr); + CPU_Message(" should be moving %s in to %08X ?", ArmRegName(Reg), VAddr); if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store in %08X?", __FUNCTION__, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store in %08X?", __FUNCTION__, VAddr).c_str()); } if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } } @@ -6689,10 +6693,10 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) } else { - CPU_Message(" Should be moving %s in to %08X ?!?", ArmRegName(Reg), VAddr); + CPU_Message(" should be moving %s in to %08X ?", ArmRegName(Reg), VAddr); if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store in %08X?", __FUNCTION__, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store in %08X?", __FUNCTION__, VAddr).c_str()); } if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } } @@ -6732,10 +6736,10 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) m_RegWorkingSet.AfterCallDirect(); break; default: - CPU_Message(" Should be moving %s in to %08X ?!?", ArmRegName(Reg), VAddr); + CPU_Message(" should be moving %s in to %08X ?", ArmRegName(Reg), VAddr); if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store in %08X?", __FUNCTION__, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store in %08X?", __FUNCTION__, VAddr).c_str()); } if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } } @@ -6750,7 +6754,7 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) CompareArmRegToArmReg(TempReg, Reg); uint8_t * Jump = *g_RecompPos; - BranchLabel8(ArmBranch_Equal, "continue"); + BranchLabel8(ArmBranch_Equal, "Continue"); MoveArmRegToVariable(Reg, &g_Reg->VI_STATUS_REG, "VI_STATUS_REG"); m_RegWorkingSet.BeforeCallDirect(); @@ -6758,7 +6762,7 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) m_RegWorkingSet.AfterCallDirect(); FlushPopArmReg(); CPU_Message(""); - CPU_Message(" Continue:"); + CPU_Message(" continue:"); SetJump8(Jump, *g_RecompPos); } break; @@ -6782,7 +6786,7 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) m_RegWorkingSet.AfterCallDirect(); FlushPopArmReg(); CPU_Message(""); - CPU_Message(" Continue:"); + CPU_Message(" continue:"); SetJump8(Jump, *g_RecompPos); } break; @@ -6804,14 +6808,14 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) case 0x04400030: MoveArmRegToVariable(Reg, &g_Reg->VI_X_SCALE_REG, "VI_X_SCALE_REG"); break; case 0x04400034: MoveArmRegToVariable(Reg, &g_Reg->VI_Y_SCALE_REG, "VI_Y_SCALE_REG"); break; default: - CPU_Message(" Should be moving %s in to %08X ?!?", ArmRegName(Reg), VAddr); + CPU_Message(" should be moving %s in to %08X ?", ArmRegName(Reg), VAddr); if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store in %08X?", __FUNCTION__, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store in %08X?", __FUNCTION__, VAddr).c_str()); } } break; - case 0x04500000: /* AI registers */ + case 0x04500000: // AI registers switch (PAddr) { case 0x04500000: MoveArmRegToVariable(Reg, &g_Reg->AI_DRAM_ADDR_REG, "AI_DRAM_ADDR_REG"); break; case 0x04500004: @@ -6835,7 +6839,7 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) MoveArmRegToVariable(Reg, &g_Reg->AI_CONTROL_REG, "AI_CONTROL_REG"); AndConstToVariable(&g_Reg->AI_CONTROL_REG, "AI_CONTROL_REG", 1); case 0x0450000C: - /* Clear Interrupt */; + // Clear interrupt AndConstToVariable(&g_Reg->MI_INTR_REG, "MI_INTR_REG", (uint32_t)~MI_INTR_AI); AndConstToVariable(&g_Reg->m_AudioIntrReg, "m_AudioIntrReg", (uint32_t)~MI_INTR_AI); m_RegWorkingSet.BeforeCallDirect(); @@ -6859,7 +6863,7 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) MoveArmRegToVariable(Reg, PAddr + g_MMU->Rdram(), stdstr_f("RDRAM + %X", PAddr).c_str()); if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store in %08X?", __FUNCTION__, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store in %08X?", __FUNCTION__, VAddr).c_str()); } } break; @@ -6896,7 +6900,7 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) case 0x04600010: if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store in %08X?", __FUNCTION__, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store in %08X?", __FUNCTION__, VAddr).c_str()); } AndConstToVariable(&g_Reg->MI_INTR_REG, "MI_INTR_REG", (uint32_t)~MI_INTR_PI); m_RegWorkingSet.BeforeCallDirect(); @@ -6937,10 +6941,10 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) AndConstToVariable(&g_Reg->PI_BSD_DOM2_RLS_REG, "PI_BSD_DOM2_RLS_REG", 0xFF); break; default: - CPU_Message(" Should be moving %s in to %08X ?!?", ArmRegName(Reg), VAddr); + CPU_Message(" should be moving %s in to %08X ?", ArmRegName(Reg), VAddr); if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store in %08X?", __FUNCTION__, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store in %08X?", __FUNCTION__, VAddr).c_str()); } if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } } @@ -6953,10 +6957,10 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) case 0x0470000C: MoveArmRegToVariable(Reg, &g_Reg->RI_SELECT_REG, "RI_SELECT_REG"); break; case 0x04700010: MoveArmRegToVariable(Reg, &g_Reg->RI_REFRESH_REG, "RI_REFRESH_REG"); break; default: - CPU_Message(" Should be moving %s in to %08X ?!?", ArmRegName(Reg), VAddr); + CPU_Message(" should be moving %s in to %08X ?", ArmRegName(Reg), VAddr); if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store in %08X?", __FUNCTION__, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store in %08X?", __FUNCTION__, VAddr).c_str()); } if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } } @@ -6988,23 +6992,23 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) m_RegWorkingSet.AfterCallDirect(); break; default: - CPU_Message(" Should be moving %s in to %08X ?!?", ArmRegName(Reg), VAddr); + CPU_Message(" should be moving %s in to %08X ?", ArmRegName(Reg), VAddr); if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store in %08X?", __FUNCTION__, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store in %08X?", __FUNCTION__, VAddr).c_str()); } if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } } break; case 0x05000000: - //64DD Registers + // 64DD registers if (g_Settings->LoadBool(Setting_EnableDisk)) { switch (PAddr) { case 0x05000500: MoveArmRegToVariable(Reg, &g_Reg->ASIC_DATA, "ASIC_DATA"); break; case 0x05000508: - //ASIC_CMD + // ASIC_CMD MoveArmRegToVariable(Reg, &g_Reg->ASIC_CMD, "ASIC_CMD"); m_RegWorkingSet.BeforeCallDirect(); CallFunction(AddressOf(&DiskCommand), "DiskCommand"); @@ -7017,7 +7021,7 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) m_RegWorkingSet.AfterCallDirect(); break; case 0x05000510: - //ASIC_BM_CTL + // ASIC_BM_CTL MoveArmRegToVariable(Reg, &g_Reg->ASIC_BM_CTL, "ASIC_BM_CTL"); m_RegWorkingSet.BeforeCallDirect(); CallFunction(AddressOf(&DiskBMControl), "DiskBMControl"); @@ -7040,10 +7044,10 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) MoveArmRegToVariable(Reg, PAddr + g_MMU->Rdram(), stdstr_f("RDRAM + %X", PAddr).c_str()); break; default: - CPU_Message(" Should be moving %s in to %08X ?!?", ArmRegName(Reg), VAddr); + CPU_Message(" should be moving %s in to %08X ?", ArmRegName(Reg), VAddr); if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store in %08X?", __FUNCTION__, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store in %08X?", __FUNCTION__, VAddr).c_str()); } if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } } @@ -7084,7 +7088,7 @@ void CArmRecompilerOps::LB_KnownAddress(ArmReg Reg, uint32_t VAddr, bool SignExt SignExtendByte(Reg); break; default: - CPU_Message(" Should be loading from %08X ?!?", VAddr); + CPU_Message(" should be loading from %08X ?", VAddr); if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } } } @@ -7157,7 +7161,7 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr) { g_Notify->DisplayError(stdstr_f("%s\nFailed to translate address: %08X", __FUNCTION__, VAddr).c_str()); } - CPU_Message(" Should be loading from %08X ?!?", VAddr); + CPU_Message(" should be loading from %08X ?", VAddr); if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } } break; @@ -7180,7 +7184,7 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr) default: MoveConstToArmReg(Reg, (uint32_t)0); if (ShowUnhandledMemory()) { g_Notify->DisplayError(stdstr_f("%s\nFailed to translate address: %08X", __FUNCTION__, VAddr).c_str()); } - CPU_Message(" Should be loading from %08X ?!?", VAddr); + CPU_Message(" should be loading from %08X ?", VAddr); if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } } break; @@ -7200,11 +7204,11 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr) default: MoveConstToArmReg(Reg, (uint32_t)0); if (ShowUnhandledMemory()) { g_Notify->DisplayError(stdstr_f("%s\nFailed to translate address: %08X", __FUNCTION__, VAddr).c_str()); } - CPU_Message(" Should be loading from %08X ?!?", VAddr); + CPU_Message(" should be loading from %08X ?", VAddr); if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } } break; - case 0x04500000: /* AI registers */ + case 0x04500000: // AI registers switch (PAddr) { case 0x04500004: @@ -7257,7 +7261,7 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr) default: MoveConstToArmReg(Reg, (uint32_t)0); if (ShowUnhandledMemory()) { g_Notify->DisplayError(stdstr_f("%s\nFailed to translate address: %08X", __FUNCTION__, VAddr).c_str()); } - CPU_Message(" Should be loading from %08X ?!?", VAddr); + CPU_Message(" should be loading from %08X ?", VAddr); if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } } break; @@ -7283,7 +7287,7 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr) { g_Notify->DisplayError(stdstr_f("%s\nFailed to translate address: %08X", __FUNCTION__, VAddr).c_str()); } - CPU_Message(" Should be loading from %08X ?!?", VAddr); + CPU_Message(" should be loading from %08X ?", VAddr); if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } } break; @@ -7298,7 +7302,7 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr) { g_Notify->DisplayError(stdstr_f("%s\nFailed to translate address: %08X", __FUNCTION__, VAddr).c_str()); } - CPU_Message(" Should be loading from %08X ?!?", VAddr); + CPU_Message(" should be loading from %08X ?", VAddr); if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } } break; @@ -7313,12 +7317,12 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr) { g_Notify->DisplayError(stdstr_f("%s\nFailed to translate address: %08X", __FUNCTION__, VAddr).c_str()); } - CPU_Message(" Should be loading from %08X ?!?", VAddr); + CPU_Message(" should be loading from %08X ?", VAddr); if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } } break; case 0x05000000: - //64DD Registers + // 64DD registers if (g_Settings->LoadBool(Setting_EnableDisk)) { switch (PAddr) @@ -7353,7 +7357,7 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr) { g_Notify->DisplayError(stdstr_f("%s\nFailed to translate address: %08X", __FUNCTION__, VAddr).c_str()); } - CPU_Message(" Should be loading from %08X ?!?", VAddr); + CPU_Message(" should be loading from %08X ?", VAddr); if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } } } @@ -7375,11 +7379,11 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr) if ((PAddr & 0xF0000000) == 0x10000000 && (PAddr - 0x10000000) < g_Rom->GetRomSize()) { uint32_t RomOffset = PAddr - 0x10000000; - MoveVariableToArmReg(RomOffset + g_Rom->GetRomAddress(), stdstr_f("ROM + %X", RomOffset).c_str(), Reg); // read from rom + MoveVariableToArmReg(RomOffset + g_Rom->GetRomAddress(), stdstr_f("ROM + %X", RomOffset).c_str(), Reg); // Read from ROM } else { - CPU_Message(" Should be loading from %08X ?!?", VAddr); + CPU_Message(" should be loading from %08X ?", VAddr); if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } } } diff --git a/Source/Project64-core/N64System/Recompiler/Arm/ArmRecompilerOps.h b/Source/Project64-core/N64System/Recompiler/Arm/ArmRecompilerOps.h index 8ec947a51..2b3aa02e8 100644 --- a/Source/Project64-core/N64System/Recompiler/Arm/ArmRecompilerOps.h +++ b/Source/Project64-core/N64System/Recompiler/Arm/ArmRecompilerOps.h @@ -12,10 +12,10 @@ class CArmRecompilerOps : public: CArmRecompilerOps(); - /*************************** Trap functions *************************/ + // Trap functions void Compile_TrapCompare(TRAP_COMPARE CompareType); - /************************** Branch functions ************************/ + // Branch functions void Compile_BranchCompare(BRANCH_COMPARE CompareType); void Compile_Branch(BRANCH_COMPARE CompareType, BRANCH_TYPE BranchType, bool Link); void Compile_BranchLikely(BRANCH_COMPARE CompareType, bool Link); @@ -28,7 +28,7 @@ public: void COP1_BCF_Compare(); void COP1_BCT_Compare(); - /************************* OpCode functions *************************/ + // Opcode functions void J (); void JAL (); void ADDI (); @@ -67,7 +67,7 @@ public: void SDC1 (); void SD (); - /********************** R4300i OpCodes: Special **********************/ + // R4300i opcodes: Special void SPECIAL_SLL (); void SPECIAL_SRL (); void SPECIAL_SRA (); @@ -113,18 +113,18 @@ public: void SPECIAL_DSRL32 (); void SPECIAL_DSRA32 (); - /************************** COP0 functions **************************/ + // COP0 functions void COP0_MF (); void COP0_MT (); - /************************** COP0 CO functions ***********************/ + // COP0 CO functions void COP0_CO_TLBR (); void COP0_CO_TLBWI (); void COP0_CO_TLBWR (); void COP0_CO_TLBP (); void COP0_CO_ERET (); - /************************** COP1 functions **************************/ + // COP1 functions void COP1_MF (); void COP1_DMF (); void COP1_CF (); @@ -132,7 +132,7 @@ public: void COP1_DMT (); void COP1_CT (); - /************************** COP1: S functions ************************/ + // COP1: S functions void COP1_S_ADD (); void COP1_S_SUB (); void COP1_S_MUL (); @@ -154,7 +154,7 @@ public: void COP1_S_CVT_L (); void COP1_S_CMP (); - /************************** COP1: D functions ************************/ + // COP1: D functions void COP1_D_ADD (); void COP1_D_SUB (); void COP1_D_MUL (); @@ -176,15 +176,15 @@ public: void COP1_D_CVT_L (); void COP1_D_CMP (); - /************************** COP1: W functions ************************/ + // COP1: W functions void COP1_W_CVT_S (); void COP1_W_CVT_D (); - /************************** COP1: L functions ************************/ + // COP1: L functions void COP1_L_CVT_S (); void COP1_L_CVT_D (); - /************************** Other functions **************************/ + // Other functions void UnknownOpcode (); private: @@ -220,7 +220,7 @@ private: void CompileExecuteBP(void); void CompileExecuteDelaySlotBP(void); - /********* Helper Functions *********/ + // Helper functions typedef CRegInfo::REG_STATE REG_STATE; static inline REG_STATE GetMipsRegState(int32_t Reg) { return m_RegWorkingSet.GetMipsRegState(Reg); } diff --git a/Source/Project64-core/N64System/Recompiler/Arm/ArmRegInfo.cpp b/Source/Project64-core/N64System/Recompiler/Arm/ArmRegInfo.cpp index da9542940..ca12615ee 100644 --- a/Source/Project64-core/N64System/Recompiler/Arm/ArmRegInfo.cpp +++ b/Source/Project64-core/N64System/Recompiler/Arm/ArmRegInfo.cpp @@ -265,7 +265,7 @@ void CArmRegInfo::Map_GPR_32bit(int32_t MipsReg, bool SignValue, int32_t MipsReg { if (Is64Bit(MipsReg)) { - CPU_Message(" regcache: unallocate %s from high 32bit of %s", ArmRegName(GetMipsRegMapHi(MipsReg)), CRegName::GPR_Hi[MipsReg]); + CPU_Message(" regcache: unallocate %s from high 32-bit of %s", ArmRegName(GetMipsRegMapHi(MipsReg)), CRegName::GPR_Hi[MipsReg]); SetArmRegMapOrder(GetMipsRegMapHi(MipsReg), 0); SetArmRegMapped(GetMipsRegMapHi(MipsReg), NotMapped); SetArmRegProtected(GetMipsRegMapHi(MipsReg), false); @@ -327,7 +327,7 @@ void CArmRegInfo::Map_GPR_64bit(int32_t MipsReg, int32_t MipsRegToLoad) if (MipsReg == 0) { - if (HaveDebugger()) { g_Notify->DisplayError("Map_GPR_64bit\n\nWhy are you trying to map reg 0"); } + if (HaveDebugger()) { g_Notify->DisplayError("Map_GPR_64bit\n\nWhy are you trying to map register 0?"); } g_Notify->BreakPoint(__FILE__, __LINE__); return; } @@ -466,7 +466,7 @@ void CArmRegInfo::UnMap_GPR(uint32_t MipsReg, bool WriteBackValue) { if (HaveDebugger()) { - g_Notify->DisplayError(stdstr_f("%s\n\nWhy are you trying to unmap reg 0", __FUNCTION__).c_str()); + g_Notify->DisplayError(stdstr_f("%s\n\nWhy are you trying to unmap register 0?", __FUNCTION__).c_str()); } return; } @@ -502,7 +502,7 @@ void CArmRegInfo::WriteBack_GPR(uint32_t MipsReg, bool Unmapping) { if (HaveDebugger()) { - g_Notify->DisplayError(stdstr_f("%s\n\nWhy are you trying to unmap reg 0", __FUNCTION__).c_str()); + g_Notify->DisplayError(stdstr_f("%s\n\nWhy are you trying to unmap register 0?", __FUNCTION__).c_str()); } return; } @@ -597,7 +597,7 @@ void CArmRegInfo::WriteBackRegisters() g_Notify->BreakPoint(__FILE__, __LINE__); break; default: - CPU_Message("%s: Unknown State: %d reg %d (%s)", __FUNCTION__, GetMipsRegState(count), count, CRegName::GPR[count]); + CPU_Message("%s: Unknown state: %d reg %d (%s)", __FUNCTION__, GetMipsRegState(count), count, CRegName::GPR[count]); g_Notify->BreakPoint(__FILE__, __LINE__); } } @@ -701,7 +701,7 @@ bool CArmRegInfo::UnMap_ArmReg(ArmReg Reg) } else if (GetArmRegMapped(Reg) == Temp_Mapped) { - CPU_Message(" regcache: unallocate %s from temp storage", ArmRegName(Reg)); + CPU_Message(" regcache: unallocate %s from temporary storage", ArmRegName(Reg)); SetArmRegMapped(Reg, NotMapped); return true; } @@ -901,11 +901,11 @@ CArmOps::ArmReg CArmRegInfo::Map_TempReg(ArmReg Reg, int32_t MipsReg, bool LoadH } if (MipsReg < 0) { - CPU_Message(" regcache: allocate %s as temp storage", ArmRegName(Reg)); + CPU_Message(" regcache: allocate %s as temporary storage", ArmRegName(Reg)); } else { - CPU_Message(" regcache: allocate %s as temp storage (%s)", ArmRegName(Reg), LoadHiWord ? CRegName::GPR_Hi[MipsReg] : CRegName::GPR_Lo[MipsReg]); + CPU_Message(" regcache: allocate %s as temporary storage (%s)", ArmRegName(Reg), LoadHiWord ? CRegName::GPR_Hi[MipsReg] : CRegName::GPR_Lo[MipsReg]); if (GprReg == Arm_Unknown) { g_Notify->BreakPoint(__FILE__, __LINE__); diff --git a/Source/Project64-core/N64System/Recompiler/Arm/ArmRegInfo.h b/Source/Project64-core/N64System/Recompiler/Arm/ArmRegInfo.h index 809100bf3..3f2a4b94f 100644 --- a/Source/Project64-core/N64System/Recompiler/Arm/ArmRegInfo.h +++ b/Source/Project64-core/N64System/Recompiler/Arm/ArmRegInfo.h @@ -10,7 +10,7 @@ class CArmRegInfo : private CSystemRegisters { public: - //enums + // Enums enum REG_MAPPED { NotMapped = 0, diff --git a/Source/Project64-core/N64System/Recompiler/Arm/asm_functions.S b/Source/Project64-core/N64System/Recompiler/Arm/asm_functions.S index f2fa72245..0e1a4db2e 100644 --- a/Source/Project64-core/N64System/Recompiler/Arm/asm_functions.S +++ b/Source/Project64-core/N64System/Recompiler/Arm/asm_functions.S @@ -1,17 +1,14 @@ -/**************************************************************************** -* * -* Project64 - A Nintendo 64 emulator. * -* http://www.pj64-emu.com/ * -* Copyright (C) 2012 Project64. All rights reserved. * -* * -* License: * -* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * -* * -****************************************************************************/ +/* +Project64 - A Nintendo 64 emulator +https://www.pj64-emu.com/ +Copyright (C) 2012-2021 Project64. All rights reserved. +License: +GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html +*/ #define GLOBAL_FUNCTION(name) \ .align 2; \ - .globl name; \ + .global name; \ .hidden name; \ .type name, %function; \ name @@ -25,7 +22,7 @@ TEXT_SECTION GLOBAL_FUNCTION(__clear_cache_android): - /* The following bug-fix implements __clear_cache (missing in Android) */ + /* The following bug-fix implements __clear_cache (missing in Android) */ push {r7, lr} mov r2, #0 mov r7, #0x2 diff --git a/Source/Project64-core/N64System/Recompiler/CodeBlock.cpp b/Source/Project64-core/N64System/Recompiler/CodeBlock.cpp index fd60c8ea5..7c0c1d8b6 100644 --- a/Source/Project64-core/N64System/Recompiler/CodeBlock.cpp +++ b/Source/Project64-core/N64System/Recompiler/CodeBlock.cpp @@ -26,7 +26,7 @@ m_RecompilerOps(nullptr), m_Test(1) { #if defined(__arm__) || defined(_M_ARM) - // make sure function starts at odd address so that the system knows it is thumb mode + // Make sure function starts at an odd address so that the system knows it is in thumb mode if (((uint32_t)m_CompiledLocation % 2) == 0) { m_CompiledLocation+=1; @@ -264,7 +264,7 @@ bool CCodeBlock::CreateBlockLinkage(CCodeSection * EnterSection) { CPU_Message("%s: End Block", __FUNCTION__); CurrentSection->m_EndSection = true; - // find other sections that need compiling + // Find other sections that need compiling break; } @@ -334,7 +334,7 @@ bool CCodeBlock::CreateBlockLinkage(CCodeSection * EnterSection) TestPC += IncludeDelaySlot ? 8 : 4; - //Find the next section + // Find the next section CCodeSection * NewSection = nullptr; for (SectionMap::const_iterator itr = m_SectionMap.begin(); itr != m_SectionMap.end(); itr++) { @@ -745,11 +745,11 @@ bool CCodeBlock::AnalyzeInstruction(uint32_t PC, uint32_t & TargetPC, uint32_t & bool CCodeBlock::Compile() { - CPU_Message("====== Code Block ======"); + CPU_Message("====== Code block ======"); CPU_Message("Native entry point: %X", CompiledLocation()); - CPU_Message("Start of Block: %X", VAddrEnter()); - CPU_Message("No of Sections: %d", NoOfSections()); - CPU_Message("====== recompiled code ======"); + CPU_Message("Start of block: %X", VAddrEnter()); + CPU_Message("Number of sections: %d", NoOfSections()); + CPU_Message("====== Recompiled code ======"); m_RecompilerOps->EnterCodeBlock(); if (g_System->bLinkBlocks()) diff --git a/Source/Project64-core/N64System/Recompiler/CodeBlock.h b/Source/Project64-core/N64System/Recompiler/CodeBlock.h index f6016e8d0..4a5bc2dc9 100644 --- a/Source/Project64-core/N64System/Recompiler/CodeBlock.h +++ b/Source/Project64-core/N64System/Recompiler/CodeBlock.h @@ -46,10 +46,10 @@ private: bool & EndBlock, bool & PermLoop); uint32_t m_VAddrEnter; - uint32_t m_VAddrFirst; // the address of the first opcode in the block - uint32_t m_VAddrLast; // the address of the first opcode in the block - uint8_t* m_CompiledLocation; // What address is this compiled at - uint8_t* m_CompiledLocationEnd; // What address is this compiled at + uint32_t m_VAddrFirst; // The address of the first opcode in the block + uint32_t m_VAddrLast; // The address of the first opcode in the block + uint8_t* m_CompiledLocation; // What address is this compiled at? + uint8_t* m_CompiledLocationEnd; // What address is this compiled at? typedef std::map SectionMap; typedef std::list SectionList; diff --git a/Source/Project64-core/N64System/Recompiler/CodeSection.cpp b/Source/Project64-core/N64System/Recompiler/CodeSection.cpp index 3f3e66d56..9b0bb4870 100644 --- a/Source/Project64-core/N64System/Recompiler/CodeSection.cpp +++ b/Source/Project64-core/N64System/Recompiler/CodeSection.cpp @@ -187,7 +187,7 @@ void CCodeSection::GenerateSectionLinkage() { g_Notify->BreakPoint(__FILE__, __LINE__); #ifdef legacycode - //Handle Fall througth + // Handle fall-through uint8_t * Jump = nullptr; for (i = 0; i < 2; i ++) { @@ -243,7 +243,7 @@ void CCodeSection::GenerateSectionLinkage() // MoveConstToVariable(DELAY_SLOT,&m_NextInstruction,"m_NextInstruction"); PushImm32(stdstr_f("0x%08X",m_RecompilerOps->GetCurrentPC() + 4).c_str(),m_RecompilerOps->GetCurrentPC() + 4); - // check if there is an existing section + // Check if there is an existing section MoveConstToX86reg((uint32_t)g_Recompiler,x86_ECX); Call_Direct(AddressOf(&CRecompiler::CompileDelaySlot), "CRecompiler::CompileDelaySlot"); @@ -253,7 +253,7 @@ void CCodeSection::GenerateSectionLinkage() #endif } - // Handle Perm Loop + // Handle permanent loop if (m_RecompilerOps->GetCurrentPC() == m_Jump.TargetPC && (m_Cont.FallThrough == false)) { if (!DelaySlotEffectsJump(m_RecompilerOps->GetCurrentPC())) @@ -826,7 +826,7 @@ bool CCodeSection::GenerateNativeCode(uint32_t Test) break; case JUMP: case END_BLOCK: - // Do nothing, block will end + // Do nothing, the block will end break; default: CPU_Message("m_RecompilerOps->GetNextStepType() = %d", m_RecompilerOps->GetNextStepType()); @@ -874,7 +874,7 @@ void CCodeSection::AddParent(CCodeSection * Parent) return; } - // check to see if we already have the parent in the list + // Check to see if we already have the parent in the list for (SECTION_LIST::iterator iter = m_ParentSection.begin(); iter != m_ParentSection.end(); iter++) { if (*iter == Parent) @@ -896,7 +896,7 @@ void CCodeSection::AddParent(CCodeSection * Parent) } else { - g_Notify->DisplayError("How are these sections joined?????"); + g_Notify->DisplayError("How are these sections joined?"); } } else @@ -1192,26 +1192,27 @@ void CCodeSection::DisplaySectionInformation() if (g_System->bLinkBlocks()) { - CPU_Message("Jump Address: 0x%08X", m_Jump.JumpPC); - CPU_Message("Jump Target Address: 0x%08X", m_Jump.TargetPC); + CPU_Message("Jump address: 0x%08X", m_Jump.JumpPC); + CPU_Message("Jump target address: 0x%08X", m_Jump.TargetPC); if (m_JumpSection != nullptr) { - CPU_Message("Jump Section: %d", m_JumpSection->m_SectionID); + CPU_Message("Jump section: %d", m_JumpSection->m_SectionID); } else { - CPU_Message("Jump Section: None"); + CPU_Message("Jump section: None"); } - CPU_Message("Continue Address: 0x%08X", m_Cont.JumpPC); - CPU_Message("Continue Target Address: 0x%08X", m_Cont.TargetPC); - if (m_ContinueSection != nullptr) { - CPU_Message("Continue Section: %d", m_ContinueSection->m_SectionID); + CPU_Message("Continue address: 0x%08X", m_Cont.JumpPC); + CPU_Message("Continue target address: 0x%08X", m_Cont.TargetPC); + if (m_ContinueSection != nullptr) + { + CPU_Message("Continue section: %d", m_ContinueSection->m_SectionID); } else { - CPU_Message("Continue Section: None"); + CPU_Message("Continue section: None"); } - CPU_Message("In Loop: %s", m_InLoop ? "Yes" : "No"); + CPU_Message("In loop: %s", m_InLoop ? "Yes" : "No"); } CPU_Message("======================="); } \ No newline at end of file diff --git a/Source/Project64-core/N64System/Recompiler/CodeSection.h b/Source/Project64-core/N64System/Recompiler/CodeSection.h index 9c22fbdeb..2adcea322 100644 --- a/Source/Project64-core/N64System/Recompiler/CodeSection.h +++ b/Source/Project64-core/N64System/Recompiler/CodeSection.h @@ -27,7 +27,7 @@ public: void AddParent(CCodeSection * Parent); void SwitchParent(CCodeSection * OldParent, CCodeSection * NewParent); - /* Block Connection info */ + // Block connection info SECTION_LIST m_ParentSection; CCodeBlock * const m_BlockInfo; const uint32_t m_SectionID; @@ -35,8 +35,8 @@ public: uint32_t m_EndPC; CCodeSection * m_ContinueSection; CCodeSection * m_JumpSection; - bool m_EndSection; // if this section does not link - bool m_LinkAllowed; // are other sections allowed to find block to link to it + bool m_EndSection; // If this section does not link, are other sections allowed to find block to link to it? + bool m_LinkAllowed; uint32_t m_Test; uint32_t m_Test2; uint8_t * m_CompiledLocation; @@ -44,10 +44,10 @@ public: bool m_DelaySlot; CRecompilerOps * & m_RecompilerOps; - /* Register Info */ + // Register info CRegInfo m_RegEnter; - /* Jump Info */ + // Jump info CJumpInfo m_Jump; CJumpInfo m_Cont; diff --git a/Source/Project64-core/N64System/Recompiler/ExitInfo.h b/Source/Project64-core/N64System/Recompiler/ExitInfo.h index 822262ebf..44cfa264d 100644 --- a/Source/Project64-core/N64System/Recompiler/ExitInfo.h +++ b/Source/Project64-core/N64System/Recompiler/ExitInfo.h @@ -23,7 +23,7 @@ struct CExitInfo CRegInfo ExitRegSet; EXIT_REASON reason; STEP_TYPE NextInstruction; - uint32_t * JumpLoc; //32bit jump + uint32_t * JumpLoc; // 32-bit jump }; typedef std::list EXIT_LIST; diff --git a/Source/Project64-core/N64System/Recompiler/FunctionInfo.cpp b/Source/Project64-core/N64System/Recompiler/FunctionInfo.cpp index 87ef17ba7..6a7ff283c 100644 --- a/Source/Project64-core/N64System/Recompiler/FunctionInfo.cpp +++ b/Source/Project64-core/N64System/Recompiler/FunctionInfo.cpp @@ -16,7 +16,7 @@ CCompiledFunc::CCompiledFunc( const CCodeBlock & CodeBlock ) : m_MemLocation[1] = CodeBlock.MemLocation(1); #if defined(__arm__) || defined(_M_ARM) - // make sure function starts at odd address so that the system knows it is thumb mode + // Make sure function starts at an odd address so that the system knows it is in thumb mode if ((((uint32_t)m_Function) % 2) == 0) { m_Function = (Func)(((uint32_t)m_Function) + 1); diff --git a/Source/Project64-core/N64System/Recompiler/FunctionInfo.h b/Source/Project64-core/N64System/Recompiler/FunctionInfo.h index 7e60732e7..61ece2af2 100644 --- a/Source/Project64-core/N64System/Recompiler/FunctionInfo.h +++ b/Source/Project64-core/N64System/Recompiler/FunctionInfo.h @@ -8,7 +8,6 @@ public: typedef void (*Func)(); - //Get Private Information const uint32_t EnterPC () const { return m_EnterPC; } const uint32_t MinPC () const { return m_MinPC; } const uint32_t MaxPC () const { return m_MaxPC; } diff --git a/Source/Project64-core/N64System/Recompiler/FunctionMap.cpp b/Source/Project64-core/N64System/Recompiler/FunctionMap.cpp index 0f442a1b0..533832d8f 100644 --- a/Source/Project64-core/N64System/Recompiler/FunctionMap.cpp +++ b/Source/Project64-core/N64System/Recompiler/FunctionMap.cpp @@ -16,13 +16,13 @@ CFunctionMap::~CFunctionMap() bool CFunctionMap::AllocateMemory() { - WriteTrace(TraceRecompiler, TraceDebug, "start"); + WriteTrace(TraceRecompiler, TraceDebug, "Start"); if (LookUpMode() == FuncFind_VirtualLookup && m_FunctionTable == nullptr) { m_FunctionTable = new PCCompiledFunc_TABLE[0x100000]; if (m_FunctionTable == nullptr) { - WriteTrace(TraceRecompiler, TraceError, "failed to allocate function table"); + WriteTrace(TraceRecompiler, TraceError, "Failed to allocate function table"); g_Notify->FatalError(MSG_MEM_ALLOC_ERROR); return false; } @@ -33,7 +33,7 @@ bool CFunctionMap::AllocateMemory() m_JumpTable = new PCCompiledFunc[RdramSize() >> 2]; if (m_JumpTable == nullptr) { - WriteTrace(TraceRecompiler, TraceError, "failed to allocate jump table"); + WriteTrace(TraceRecompiler, TraceError, "Failed to allocate jump table"); g_Notify->FatalError(MSG_MEM_ALLOC_ERROR); return false; } @@ -66,7 +66,7 @@ void CFunctionMap::CleanBuffers() void CFunctionMap::Reset(bool bAllocate) { - WriteTrace(TraceRecompiler, TraceDebug, "start (bAllocate: %s)", bAllocate ? "true" : "false"); + WriteTrace(TraceRecompiler, TraceDebug, "Start (bAllocate: %s)", bAllocate ? "true" : "false"); CleanBuffers(); if (bAllocate && (g_System->LookUpMode() == FuncFind_VirtualLookup || g_System->LookUpMode() == FuncFind_PhysicalLookup)) { diff --git a/Source/Project64-core/N64System/Recompiler/JumpInfo.h b/Source/Project64-core/N64System/Recompiler/JumpInfo.h index 4ecabb3cd..f45a512e0 100644 --- a/Source/Project64-core/N64System/Recompiler/JumpInfo.h +++ b/Source/Project64-core/N64System/Recompiler/JumpInfo.h @@ -14,7 +14,7 @@ struct CJumpInfo uint32_t * LinkLocation2; bool FallThrough; bool PermLoop; - bool DoneDelaySlot; //maybe deletable + bool DoneDelaySlot; CRegInfo RegSet; EXIT_REASON ExitReason; }; diff --git a/Source/Project64-core/N64System/Recompiler/LoopAnalysis.cpp b/Source/Project64-core/N64System/Recompiler/LoopAnalysis.cpp index 1914d0084..f56cd86ef 100644 --- a/Source/Project64-core/N64System/Recompiler/LoopAnalysis.cpp +++ b/Source/Project64-core/N64System/Recompiler/LoopAnalysis.cpp @@ -235,7 +235,7 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section) g_Notify->BreakPoint(__FILE__, __LINE__); #ifdef legacycode if (m_Command.Hex == 0x00000001) { break; } - g_Notify->DisplayError("Unhandled R4300i OpCode in FillSectionInfo 5\n%s", + g_Notify->DisplayError("Unhandled R4300i opcode in FillSectionInfo 5\n%s", R4300iOpcodeName(m_Command.Hex, m_PC)); #endif m_NextInstruction = END_BLOCK; @@ -366,7 +366,7 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section) g_Notify->BreakPoint(__FILE__, __LINE__); #ifdef legacycode if (m_Command.Hex == 0x0407000D) { break; } - g_Notify->DisplayError("Unhandled R4300i OpCode in FillSectionInfo 4\n%s", + g_Notify->DisplayError("Unhandled R4300i opcode in FillSectionInfo 4\n%s", R4300iOpcodeName(m_Command.Hex, m_PC)); m_NextInstruction = END_BLOCK; m_PC -= 4; @@ -542,14 +542,14 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section) case R4300i_COP0_CO_TLBP: break; case R4300i_COP0_CO_ERET: m_NextInstruction = END_BLOCK; break; default: - g_Notify->DisplayError(stdstr_f("Unhandled R4300i OpCode in FillSectionInfo\n%s", R4300iOpcodeName(m_Command.Hex, m_PC)).c_str()); + g_Notify->DisplayError(stdstr_f("Unhandled R4300i opcode in FillSectionInfo\n%s", R4300iOpcodeName(m_Command.Hex, m_PC)).c_str()); m_NextInstruction = END_BLOCK; m_PC -= 4; } } else { - g_Notify->DisplayError(stdstr_f("Unhandled R4300i OpCode in FillSectionInfo 3\n%s", R4300iOpcodeName(m_Command.Hex, m_PC)).c_str()); + g_Notify->DisplayError(stdstr_f("Unhandled R4300i opcode in FillSectionInfo 3\n%s", R4300iOpcodeName(m_Command.Hex, m_PC)).c_str()); m_NextInstruction = END_BLOCK; m_PC -= 4; } @@ -627,7 +627,7 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section) case R4300i_COP1_W: break; case R4300i_COP1_L: break; default: - g_Notify->DisplayError(stdstr_f("Unhandled R4300i OpCode in FillSectionInfo 2\n%s", R4300iOpcodeName(m_Command.Hex, m_PC)).c_str()); + g_Notify->DisplayError(stdstr_f("Unhandled R4300i opcode in FillSectionInfo 2\n%s", R4300iOpcodeName(m_Command.Hex, m_PC)).c_str()); m_NextInstruction = END_BLOCK; m_PC -= 4; } @@ -727,7 +727,7 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section) if (m_Command.Hex == 0xF1F3F5F7) { break; } if (m_Command.Hex == 0xC1200000) { break; } if (m_Command.Hex == 0x4C5A5353) { break; } - g_Notify->DisplayError(stdstr_f("Unhandled R4300i OpCode in FillSectionInfo 1\n%s\n%X", R4300iOpcodeName(m_Command.Hex, m_PC), m_Command.Hex).c_str()); + g_Notify->DisplayError(stdstr_f("Unhandled R4300i opcode in FillSectionInfo 1\n%s\n%X", R4300iOpcodeName(m_Command.Hex, m_PC), m_Command.Hex).c_str()); } CPU_Message(" %s state: %X value: %X", CRegName::GPR[5], m_Reg.GetMipsRegState(5), m_Reg.GetMipsRegLo(5)); diff --git a/Source/Project64-core/N64System/Recompiler/LoopAnalysis.h b/Source/Project64-core/N64System/Recompiler/LoopAnalysis.h index 7aa580cc8..d4636a0ce 100644 --- a/Source/Project64-core/N64System/Recompiler/LoopAnalysis.h +++ b/Source/Project64-core/N64System/Recompiler/LoopAnalysis.h @@ -26,7 +26,7 @@ private: void SetJumpRegSet(CCodeSection * Section, const CRegInfo &Reg); void SetContinueRegSet(CCodeSection * Section, const CRegInfo &Reg); - /********************** R4300i OpCodes: Special **********************/ + // R4300i opcodes: Special void SPECIAL_SLL(); void SPECIAL_SRL(); void SPECIAL_SRA(); diff --git a/Source/Project64-core/N64System/Recompiler/Recompiler.cpp b/Source/Project64-core/N64System/Recompiler/Recompiler.cpp index dcf3b97d0..7f20c0e4d 100644 --- a/Source/Project64-core/N64System/Recompiler/Recompiler.cpp +++ b/Source/Project64-core/N64System/Recompiler/Recompiler.cpp @@ -137,7 +137,7 @@ void CRecompiler::RecompilerMain_VirtualTable() table = new PCCompiledFunc[(0x1000 >> 2)]; if (table == nullptr) { - WriteTrace(TraceRecompiler, TraceError, "failed to allocate PCCompiledFunc"); + WriteTrace(TraceRecompiler, TraceError, "Failed to allocate PCCompiledFunc"); g_Notify->FatalError(MSG_MEM_ALLOC_ERROR); } memset(table, 0, sizeof(PCCompiledFunc)* (0x1000 >> 2)); @@ -164,7 +164,7 @@ void CRecompiler::RecompilerMain_VirtualTable_validate() if (NextInstruction == DELAY_SLOT) { CCompiledFunc * Info = m_FunctionsDelaySlot.FindFunction(PROGRAM_COUNTER); - //Find Block on hash table + // Find block on hash table if (Info == nullptr) { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -181,7 +181,7 @@ void CRecompiler::RecompilerMain_VirtualTable_validate() continue; } #endif - //Find Block on hash table + // Find block on hash table Info = CompileDelaySlot(PROGRAM_COUNTER); if (Info == nullptr || EndEmulation()) @@ -264,7 +264,7 @@ void CRecompiler::RecompilerMain_VirtualTable_validate() { CCompiledFunc * Info = m_FunctionsDelaySlot.FindFunction(PROGRAM_COUNTER); - //Find Block on hash table + // Find block on hash table if (Info == nullptr) { Info = CompileDelaySlot(PROGRAM_COUNTER); @@ -296,7 +296,7 @@ void CRecompiler::RecompilerMain_VirtualTable_validate() CCompiledFunc * Info = m_Functions.FindFunction(PROGRAM_COUNTER); - //Find Block on hash table + // Find block on hash table if (Info == nullptr) { Info = CompileCode(); @@ -431,7 +431,7 @@ void CRecompiler::RecompilerMain_Lookup() { if (Addr > 0x20000000) { - WriteTraceF(TraceDebug,"Executing from non mapped space .1 PC: %X Addr: %X",PROGRAM_COUNTER, Addr); + WriteTraceF(TraceDebug,"Executing from non-mapped space .1 PC: %X Addr: %X",PROGRAM_COUNTER, Addr); g_Notify->DisplayError(GS(MSG_NONMAPPED_SPACE)); break; } @@ -443,7 +443,7 @@ void CRecompiler::RecompilerMain_Lookup() } continue; } else { - WriteTraceF(TraceDebug,"Executing from non mapped space .1 PC: %X Addr: %X",PROGRAM_COUNTER, Addr); + WriteTraceF(TraceDebug,"Executing from non-mapped space .1 PC: %X Addr: %X",PROGRAM_COUNTER, Addr); g_Notify->DisplayError(GS(MSG_NONMAPPED_SPACE)); break; } @@ -458,7 +458,7 @@ void CRecompiler::RecompilerMain_Lookup() } continue; } else { - WriteTraceF(TraceDebug,"Executing from non mapped space .2 PC: %X Addr: %X",PROGRAM_COUNTER, Addr); + WriteTraceF(TraceDebug,"Executing from non-mapped space .2 PC: %X Addr: %X",PROGRAM_COUNTER, Addr); g_Notify->DisplayError(GS(MSG_NONMAPPED_SPACE)); return; } @@ -739,7 +739,7 @@ void CRecompiler::RecompilerMain_Lookup_validate_TLB() void CRecompiler::Reset() { - WriteTrace(TraceRecompiler, TraceDebug, "start"); + WriteTrace(TraceRecompiler, TraceDebug, "Start"); ResetRecompCode(true); ResetMemoryStackPos(); WriteTrace(TraceRecompiler, TraceDebug, "Done"); @@ -747,7 +747,7 @@ void CRecompiler::Reset() void CRecompiler::ResetRecompCode(bool bAllocate) { - WriteTrace(TraceRecompiler, TraceDebug, "start"); + WriteTrace(TraceRecompiler, TraceDebug, "Start"); CRecompMemory::Reset(); CFunctionMap::Reset(bAllocate); @@ -801,7 +801,7 @@ void CRecompiler::RecompilerMain_ChangeMemory() } __except (EXCEPTION_EXECUTE_HANDLER) { - g_Notify->DisplayError("Executing Delay Slot from non maped space\nPROGRAM_COUNTER = 0x%X", PROGRAM_COUNTER); + g_Notify->DisplayError("Executing delay slot from non-mapped space\nPROGRAM_COUNTER = 0x%X", PROGRAM_COUNTER); ExitThread(0); } if ((Value >> 16) == 0x7C7C) @@ -949,7 +949,7 @@ CCompiledFunc * CRecompiler::CompileCode() CCompiledFuncList::iterator iter = m_Functions.find(PROGRAM_COUNTER); if (iter != m_Functions.end()) { - WriteTrace(TraceRecompiler, TraceInfo, "exisiting functions for address (Program Counter: %X pAddr: %X)", PROGRAM_COUNTER, pAddr); + WriteTrace(TraceRecompiler, TraceInfo, "Existing functions for address (Program Counter: %X pAddr: %X)", PROGRAM_COUNTER, pAddr); for (CCompiledFunc * Func = iter->second; Func != nullptr; Func = Func->Next()) { uint32_t PAddr; @@ -959,7 +959,7 @@ CCompiledFunc * CRecompiler::CompileCode() MD5(m_MMU.Rdram() + PAddr, (Func->MaxPC() - Func->MinPC()) + 4).get_digest(Hash); if (memcmp(Hash.digest, Func->Hash().digest, sizeof(Hash.digest)) == 0) { - WriteTrace(TraceRecompiler, TraceInfo, "Using extisting compiled code (Program Counter: %X pAddr: %X)", PROGRAM_COUNTER, pAddr); + WriteTrace(TraceRecompiler, TraceInfo, "Using existing compiled code (Program Counter: %X pAddr: %X)", PROGRAM_COUNTER, pAddr); return Func; } } @@ -992,7 +992,7 @@ CCompiledFunc * CRecompiler::CompileCode() if (g_ModuleLogLevel[TraceRecompiler] >= TraceDebug) { - WriteTrace(TraceRecompiler, TraceDebug, "info->Function() = %X", Func->Function()); + WriteTrace(TraceRecompiler, TraceDebug, "Info->Function() = %X", Func->Function()); std::string dumpline; uint32_t start_address = (uint32_t)(Func->Function()) & ~1; for (uint8_t * ptr = (uint8_t *)start_address; ptr < CodeBlock.CompiledLocationEnd(); ptr++) @@ -1045,7 +1045,7 @@ void CRecompiler::ClearRecompCode_Phys(uint32_t Address, int length, REMOVE_REAS g_Notify->BreakPoint(__FILE__, __LINE__); ClearLen = g_System->RdramSize() - Address; } - WriteTrace(TraceRecompiler, TraceInfo, "Reseting Jump Table, Addr: %X len: %d", Address, ClearLen); + WriteTrace(TraceRecompiler, TraceInfo, "Resetting jump table, Addr: %X len: %d", Address, ClearLen); memset((uint8_t *)JumpTable() + Address, 0, ClearLen); if (g_System->bSMM_Protect()) { @@ -1054,7 +1054,7 @@ void CRecompiler::ClearRecompCode_Phys(uint32_t Address, int length, REMOVE_REAS } else { - WriteTrace(TraceRecompiler, TraceInfo, "Ignoring reset of Jump Table, Addr: %X len: %d", Address, ((length + 3) & ~3)); + WriteTrace(TraceRecompiler, TraceInfo, "Ignoring reset of jump table, Addr: %X len: %d", Address, ((length + 3) & ~3)); } } } @@ -1079,7 +1079,7 @@ void CRecompiler::ClearRecompCode_Virt(uint32_t Address, int length, REMOVE_REAS PCCompiledFunc_TABLE & table = FunctionTable()[AddressIndex]; if (table) { - WriteTrace(TraceRecompiler, TraceError, "Delete Table (%X): Index = %d", table, AddressIndex); + WriteTrace(TraceRecompiler, TraceError, "Delete table (%X): Index = %d", table, AddressIndex); delete table; table = nullptr; m_MMU.UnProtectMemory(Address, Address + length); diff --git a/Source/Project64-core/N64System/Recompiler/Recompiler.h b/Source/Project64-core/N64System/Recompiler/Recompiler.h index 27ea1a1a0..30a693e4b 100644 --- a/Source/Project64-core/N64System/Recompiler/Recompiler.h +++ b/Source/Project64-core/N64System/Recompiler/Recompiler.h @@ -40,7 +40,7 @@ public: void Reset(); void ResetRecompCode(bool bAllocate); - //Self modifying code methods + // Self-modifying code methods void ClearRecompCode_Virt(uint32_t VirtualAddress, int32_t length, REMOVE_REASON Reason); void ClearRecompCode_Phys(uint32_t PhysicalAddress, int32_t length, REMOVE_REASON Reason); @@ -81,6 +81,6 @@ private: uint32_t m_MemoryStack; FUNCTION_PROFILE m_BlockProfile; - //Quick access to registers + // Quick access to registers uint32_t & PROGRAM_COUNTER; }; diff --git a/Source/Project64-core/N64System/Recompiler/RecompilerCodeLog.cpp b/Source/Project64-core/N64System/Recompiler/RecompilerCodeLog.cpp index 0677c3015..fc02be57e 100644 --- a/Source/Project64-core/N64System/Recompiler/RecompilerCodeLog.cpp +++ b/Source/Project64-core/N64System/Recompiler/RecompilerCodeLog.cpp @@ -3,7 +3,7 @@ #include #include -/* vsprintf() */ +// vsprintf() #include #include diff --git a/Source/Project64-core/N64System/Recompiler/RecompilerMemory.cpp b/Source/Project64-core/N64System/Recompiler/RecompilerMemory.cpp index 99ad857f8..8e4d74a32 100644 --- a/Source/Project64-core/N64System/Recompiler/RecompilerMemory.cpp +++ b/Source/Project64-core/N64System/Recompiler/RecompilerMemory.cpp @@ -28,7 +28,7 @@ bool CRecompMemory::AllocateMemory() WriteTrace(TraceRecompiler, TraceDebug, "RecompCodeBase = %X", RecompCodeBase); if (RecompCodeBase == nullptr) { - WriteTrace(TraceRecompiler, TraceError, "failed to allocate RecompCodeBase"); + WriteTrace(TraceRecompiler, TraceError, "Failed to allocate RecompCodeBase"); g_Notify->DisplayError(MSG_MEM_ALLOC_ERROR); return false; } @@ -36,7 +36,7 @@ bool CRecompMemory::AllocateMemory() m_RecompCode = (uint8_t *)CommitMemory(RecompCodeBase, InitialCompileBufferSize, MEM_EXECUTE_READWRITE); if (m_RecompCode == nullptr) { - WriteTrace(TraceRecompiler, TraceError, "failed to commit initial buffer"); + WriteTrace(TraceRecompiler, TraceError, "Failed to commit initial buffer"); FreeAddressSpace(RecompCodeBase,MaxCompileBufferSize + 4); g_Notify->DisplayError(MSG_MEM_ALLOC_ERROR); return false; @@ -63,7 +63,7 @@ void CRecompMemory::CheckRecompMem() void * MemAddr = CommitMemory(m_RecompCode + m_RecompSize, IncreaseCompileBufferSize, MEM_EXECUTE_READWRITE); if (MemAddr == nullptr) { - WriteTrace(TraceRecompiler, TraceError, "failed to increase buffer"); + WriteTrace(TraceRecompiler, TraceError, "Failed to increase buffer"); g_Notify->FatalError(MSG_MEM_ALLOC_ERROR); } m_RecompSize += IncreaseCompileBufferSize; diff --git a/Source/Project64-core/N64System/Recompiler/RecompilerOps.h b/Source/Project64-core/N64System/Recompiler/RecompilerOps.h index 17c999f1c..93843a4d8 100644 --- a/Source/Project64-core/N64System/Recompiler/RecompilerOps.h +++ b/Source/Project64-core/N64System/Recompiler/RecompilerOps.h @@ -41,14 +41,14 @@ public: CompareTypeTLTIU, }; - /*************************** Trap functions *************************/ + // Trap functions virtual void Compile_TrapCompare(TRAP_COMPARE CompareType) = 0; - /************************** Branch functions ************************/ + // Branch functions virtual void Compile_Branch(BRANCH_COMPARE CompareType, BRANCH_TYPE BranchType, bool Link) = 0; virtual void Compile_BranchLikely(BRANCH_COMPARE CompareType, bool Link) = 0; - /************************* OpCode functions *************************/ + // Opcode functions virtual void J() = 0; virtual void JAL() = 0; virtual void ADDI() = 0; @@ -87,7 +87,7 @@ public: virtual void SDC1() = 0; virtual void SD() = 0; - /********************** R4300i OpCodes: Special **********************/ + // R4300i opcodes: Special virtual void SPECIAL_SLL() = 0; virtual void SPECIAL_SRL() = 0; virtual void SPECIAL_SRA() = 0; @@ -133,18 +133,18 @@ public: virtual void SPECIAL_DSRL32() = 0; virtual void SPECIAL_DSRA32() = 0; - /************************** COP0 functions **************************/ + // COP0 functions virtual void COP0_MF() = 0; virtual void COP0_MT() = 0; - /************************** COP0 CO functions ***********************/ + // COP0 CO functions virtual void COP0_CO_TLBR() = 0; virtual void COP0_CO_TLBWI() = 0; virtual void COP0_CO_TLBWR() = 0; virtual void COP0_CO_TLBP() = 0; virtual void COP0_CO_ERET() = 0; - /************************** COP1 functions **************************/ + // COP1 functions virtual void COP1_MF() = 0; virtual void COP1_DMF() = 0; virtual void COP1_CF() = 0; @@ -152,7 +152,7 @@ public: virtual void COP1_DMT() = 0; virtual void COP1_CT() = 0; - /************************** COP1: S functions ************************/ + // COP1: S functions virtual void COP1_S_ADD() = 0; virtual void COP1_S_SUB() = 0; virtual void COP1_S_MUL() = 0; @@ -174,7 +174,7 @@ public: virtual void COP1_S_CVT_L() = 0; virtual void COP1_S_CMP() = 0; - /************************** COP1: D functions ************************/ + // COP1: D functions virtual void COP1_D_ADD() = 0; virtual void COP1_D_SUB() = 0; virtual void COP1_D_MUL() = 0; @@ -196,15 +196,15 @@ public: virtual void COP1_D_CVT_L() = 0; virtual void COP1_D_CMP() = 0; - /************************** COP1: W functions ************************/ + // COP1: W functions virtual void COP1_W_CVT_S() = 0; virtual void COP1_W_CVT_D() = 0; - /************************** COP1: L functions ************************/ + // COP1: L functions virtual void COP1_L_CVT_S() = 0; virtual void COP1_L_CVT_D() = 0; - /************************** Other functions **************************/ + // Other functions virtual void UnknownOpcode() = 0; virtual void EnterCodeBlock() = 0; diff --git a/Source/Project64-core/N64System/Recompiler/RegBase.h b/Source/Project64-core/N64System/Recompiler/RegBase.h index b9d8a86d6..f6ad943e6 100644 --- a/Source/Project64-core/N64System/Recompiler/RegBase.h +++ b/Source/Project64-core/N64System/Recompiler/RegBase.h @@ -6,7 +6,7 @@ class CRegBase public: CRegBase(); - //enums + // Enums enum REG_STATE { STATE_UNKNOWN = 0x00, diff --git a/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp b/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp index 2b5d458e6..2d0e24e72 100644 --- a/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp +++ b/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp @@ -352,7 +352,7 @@ void CX86RecompilerOps::CompileWriteTLBMiss(x86Reg AddressReg, x86Reg LookUpReg) bool DelaySlotEffectsCompare(uint32_t PC, uint32_t Reg1, uint32_t Reg2); -/*************************** Trap functions *************************/ +// Trap functions void CX86RecompilerOps::Compile_TrapCompare(TRAP_COMPARE CompareType) { void *FunctAddress = nullptr; @@ -430,7 +430,7 @@ void CX86RecompilerOps::Compile_TrapCompare(TRAP_COMPARE CompareType) } } -/************************** Branch functions ************************/ +// Branch functions void CX86RecompilerOps::Compile_BranchCompare(BRANCH_COMPARE CompareType) { switch (CompareType) @@ -900,7 +900,7 @@ void CX86RecompilerOps::BNE_Compare() if (m_Section->m_Jump.FallThrough) { - JneLabel8("continue", 0); + JneLabel8("Continue", 0); Jump = *g_RecompPos - 1; } else @@ -977,7 +977,7 @@ void CX86RecompilerOps::BNE_Compare() } if (m_Section->m_Jump.FallThrough) { - JneLabel8("continue", 0); + JneLabel8("Continue", 0); Jump = *g_RecompPos - 1; } else @@ -1070,7 +1070,7 @@ void CX86RecompilerOps::BNE_Compare() } if (m_Section->m_Jump.FallThrough) { - JneLabel8("continue", 0); + JneLabel8("Continue", 0); Jump = *g_RecompPos - 1; } else @@ -1137,7 +1137,7 @@ void CX86RecompilerOps::BNE_Compare() CompX86regToVariable(Reg, &_GPR[m_Opcode.rs].W[1], CRegName::GPR_Hi[m_Opcode.rs]); if (m_Section->m_Jump.FallThrough) { - JneLabel8("continue", 0); + JneLabel8("Continue", 0); Jump = *g_RecompPos - 1; } else @@ -1225,7 +1225,7 @@ void CX86RecompilerOps::BEQ_Compare() ); if (m_Section->m_Cont.FallThrough) { - JneLabel8("continue", 0); + JneLabel8("Continue", 0); Jump = *g_RecompPos - 1; } else @@ -1301,7 +1301,7 @@ void CX86RecompilerOps::BEQ_Compare() CompConstToX86reg(GetMipsRegMapHi(MappedReg), GetMipsRegHi(ConstReg)); } if (m_Section->m_Cont.FallThrough) { - JneLabel8("continue", 0); + JneLabel8("Continue", 0); Jump = *g_RecompPos - 1; } else @@ -1394,7 +1394,7 @@ void CX86RecompilerOps::BEQ_Compare() } if (m_Section->m_Cont.FallThrough) { - JneLabel8("continue", 0); + JneLabel8("Continue", 0); Jump = *g_RecompPos - 1; } else @@ -1451,7 +1451,7 @@ void CX86RecompilerOps::BEQ_Compare() CompX86regToVariable(Reg, &_GPR[m_Opcode.rt].W[1], CRegName::GPR_Hi[m_Opcode.rt]); if (m_Section->m_Cont.FallThrough) { - JneLabel8("continue", 0); + JneLabel8("Continue", 0); Jump = *g_RecompPos - 1; } else @@ -1590,12 +1590,12 @@ void CX86RecompilerOps::BGTZ_Compare() { JlLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); - JgLabel8("continue", 0); + JgLabel8("Continue", 0); Jump = *g_RecompPos - 1; } else if (m_Section->m_Cont.FallThrough) { - JlLabel8("continue", 0); + JlLabel8("Continue", 0); Jump = *g_RecompPos - 1; JgLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); @@ -2127,7 +2127,7 @@ void CX86RecompilerOps::COP1_BCT_Compare() } } -/************************* OpCode functions *************************/ +// Opcode functions void CX86RecompilerOps::J() { if (m_NextInstruction == NORMAL) @@ -3325,7 +3325,7 @@ void CX86RecompilerOps::LW_KnownAddress(x86Reg Reg, uint32_t VAddr) } } break; - case 0x04500000: /* AI registers */ + case 0x04500000: // AI registers switch (PAddr) { case 0x04500004: @@ -3442,7 +3442,7 @@ void CX86RecompilerOps::LW_KnownAddress(x86Reg Reg, uint32_t VAddr) } break; case 0x05000000: - //64DD Registers + // 64DD registers if (g_Settings->LoadBool(Setting_EnableDisk)) { switch (PAddr) @@ -3491,13 +3491,13 @@ void CX86RecompilerOps::LW_KnownAddress(x86Reg Reg, uint32_t VAddr) default: if ((PAddr & 0xF0000000) == 0x10000000 && (PAddr - 0x10000000) < g_Rom->GetRomSize()) { - // read from rom + // Read from ROM sprintf(VarName, "RDRAM + %X", PAddr); MoveVariableToX86reg(PAddr + g_MMU->Rdram(), VarName, Reg); } else if (g_DDRom != nullptr && ((PAddr & 0xFF000000) == 0x06000000 && (PAddr - 0x06000000) < g_DDRom->GetRomSize())) { - // read from ddrom + // Read from DDROM (TODO: Is DDROM a disk image or the IPL?) sprintf(VarName, "RDRAM + %X", PAddr); MoveVariableToX86reg(PAddr + g_MMU->Rdram(), VarName, Reg); } @@ -4949,7 +4949,7 @@ void CX86RecompilerOps::SD() } } -/********************** R4300i OpCodes: Special **********************/ +// R4300i opcodes: Special void CX86RecompilerOps::SPECIAL_SLL() { if (m_Opcode.rd == 0) @@ -5432,10 +5432,10 @@ void CX86RecompilerOps::SPECIAL_DSLLV() Jump[0] = *g_RecompPos - 1; ShiftLeftDouble(GetMipsRegMapHi(m_Opcode.rd), GetMipsRegMapLo(m_Opcode.rd)); ShiftLeftSign(GetMipsRegMapLo(m_Opcode.rd)); - JmpLabel8("continue", 0); + JmpLabel8("Continue", 0); Jump[1] = *g_RecompPos - 1; - //MORE32: + // MORE32: CPU_Message(""); CPU_Message(" MORE32:"); SetJump8(Jump[0], *g_RecompPos); @@ -5444,7 +5444,7 @@ void CX86RecompilerOps::SPECIAL_DSLLV() AndConstToX86Reg(x86_ECX, 0x1F); ShiftLeftSign(GetMipsRegMapHi(m_Opcode.rd)); - //continue: + // Continue: CPU_Message(""); CPU_Message(" continue:"); SetJump8(Jump[1], *g_RecompPos); @@ -5517,10 +5517,10 @@ void CX86RecompilerOps::SPECIAL_DSRLV() Jump[0] = *g_RecompPos - 1; ShiftRightDouble(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapHi(m_Opcode.rd)); ShiftRightUnsign(GetMipsRegMapHi(m_Opcode.rd)); - JmpLabel8("continue", 0); + JmpLabel8("Continue", 0); Jump[1] = *g_RecompPos - 1; - //MORE32: + // MORE32: CPU_Message(""); CPU_Message(" MORE32:"); SetJump8(Jump[0], *g_RecompPos); @@ -5529,7 +5529,7 @@ void CX86RecompilerOps::SPECIAL_DSRLV() AndConstToX86Reg(x86_ECX, 0x1F); ShiftRightUnsign(GetMipsRegMapLo(m_Opcode.rd)); - //continue: + // Continue: CPU_Message(""); CPU_Message(" continue:"); SetJump8(Jump[1], *g_RecompPos); @@ -5559,10 +5559,10 @@ void CX86RecompilerOps::SPECIAL_DSRAV() Jump[0] = *g_RecompPos - 1; ShiftRightDouble(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapHi(m_Opcode.rd)); ShiftRightSign(GetMipsRegMapHi(m_Opcode.rd)); - JmpLabel8("continue", 0); + JmpLabel8("Continue", 0); Jump[1] = *g_RecompPos - 1; - //MORE32: + // MORE32: CPU_Message(""); CPU_Message(" MORE32:"); SetJump8(Jump[0], *g_RecompPos); @@ -5571,7 +5571,7 @@ void CX86RecompilerOps::SPECIAL_DSRAV() AndConstToX86Reg(x86_ECX, 0x1F); ShiftRightSign(GetMipsRegMapLo(m_Opcode.rd)); - //continue: + // Continue: CPU_Message(""); CPU_Message(" continue:"); SetJump8(Jump[1], *g_RecompPos); @@ -5588,7 +5588,7 @@ void CX86RecompilerOps::SPECIAL_MULT() MoveX86regToVariable(x86_EAX, &_RegLO->UW[0], "_RegLO->UW[0]"); MoveX86regToVariable(x86_EDX, &_RegHI->UW[0], "_RegHI->UW[0]"); - ShiftRightSignImmed(x86_EAX, 31); /* paired */ + ShiftRightSignImmed(x86_EAX, 31); // Paired ShiftRightSignImmed(x86_EDX, 31); MoveX86regToVariable(x86_EAX, &_RegLO->UW[1], "_RegLO->UW[1]"); MoveX86regToVariable(x86_EDX, &_RegHI->UW[1], "_RegHI->UW[1]"); @@ -5605,7 +5605,7 @@ void CX86RecompilerOps::SPECIAL_MULTU() MoveX86regToVariable(x86_EAX, &_RegLO->UW[0], "_RegLO->UW[0]"); MoveX86regToVariable(x86_EDX, &_RegHI->UW[0], "_RegHI->UW[0]"); - ShiftRightSignImmed(x86_EAX, 31); /* paired */ + ShiftRightSignImmed(x86_EAX, 31); // Paired ShiftRightSignImmed(x86_EDX, 31); MoveX86regToVariable(x86_EAX, &_RegLO->UW[1], "_RegLO->UW[1]"); MoveX86regToVariable(x86_EDX, &_RegHI->UW[1], "_RegHI->UW[1]"); @@ -5642,7 +5642,7 @@ void CX86RecompilerOps::SPECIAL_DIV() m_RegWorkingSet.SetX86Protected(x86_EDX, true); Map_TempReg(x86_EAX, m_Opcode.rs, false); - /* edx is the signed portion to eax */ + // EDX is the signed portion to EAX m_RegWorkingSet.SetX86Protected(x86_EDX, false); Map_TempReg(x86_EDX, -1, false); @@ -5660,7 +5660,7 @@ void CX86RecompilerOps::SPECIAL_DIV() MoveX86regToVariable(x86_EAX, &_RegLO->UW[0], "_RegLO->UW[0]"); MoveX86regToVariable(x86_EDX, &_RegHI->UW[0], "_RegHI->UW[0]"); - ShiftRightSignImmed(x86_EAX, 31); /* paired */ + ShiftRightSignImmed(x86_EAX, 31); // Paired ShiftRightSignImmed(x86_EDX, 31); MoveX86regToVariable(x86_EAX, &_RegLO->UW[1], "_RegLO->UW[1]"); MoveX86regToVariable(x86_EDX, &_RegHI->UW[1], "_RegHI->UW[1]"); @@ -5724,9 +5724,9 @@ void CX86RecompilerOps::SPECIAL_DIVU() MoveX86regToVariable(x86_EAX, &_RegLO->UW[0], "_RegLO->UW[0]"); MoveX86regToVariable(x86_EDX, &_RegHI->UW[0], "_RegHI->UW[0]"); - /* wouldnt these be zero (???) */ + // Wouldn't these be zero? - ShiftRightSignImmed(x86_EAX, 31); /* paired */ + ShiftRightSignImmed(x86_EAX, 31); // Paired ShiftRightSignImmed(x86_EDX, 31); MoveX86regToVariable(x86_EAX, &_RegLO->UW[1], "_RegLO->UW[1]"); MoveX86regToVariable(x86_EDX, &_RegHI->UW[1], "_RegHI->UW[1]"); @@ -5793,7 +5793,7 @@ void CX86RecompilerOps::SPECIAL_DMULTU() Map_TempReg(x86_ECX, -1, false); MulX86reg(x86_EDX); - MoveX86RegToX86Reg(x86_EAX, x86_EBX); /* EDX:EAX -> ECX:EBX */ + MoveX86RegToX86Reg(x86_EAX, x86_EBX); // EDX:EAX -> ECX:EBX MoveX86RegToX86Reg(x86_EDX, x86_ECX); /* Tmp[1].UDW = (uint64)_GPR[m_Opcode.rs].UW[0] * (uint64)_GPR[m_Opcode.rt].UW[1]; */ @@ -5803,7 +5803,7 @@ void CX86RecompilerOps::SPECIAL_DMULTU() MulX86reg(x86_EDX); Map_TempReg(x86_ESI, -1, false); Map_TempReg(x86_EDI, -1, false); - MoveX86RegToX86Reg(x86_EAX, x86_ESI); /* EDX:EAX -> EDI:ESI */ + MoveX86RegToX86Reg(x86_EAX, x86_ESI); // EDX:EAX -> EDI:ESI MoveX86RegToX86Reg(x86_EDX, x86_EDI); /* Tmp[2].UDW = (uint64)_RegLO->UW[1] + (uint64)Tmp[0].UW[0] + (uint64)Tmp[1].UW[0]; */ @@ -5812,7 +5812,7 @@ void CX86RecompilerOps::SPECIAL_DMULTU() AddX86RegToX86Reg(x86_EAX, x86_EBX); AddConstToX86Reg(x86_EDX, 0); AddX86RegToX86Reg(x86_EAX, x86_ESI); - AddConstToX86Reg(x86_EDX, 0); /* EDX:EAX */ + AddConstToX86Reg(x86_EDX, 0); // EDX:EAX /* _RegLO->UDW += ((uint64)Tmp[0].UW[0] + (uint64)Tmp[1].UW[0]) << 32; */ /* [low+4] += ebx + esi */ @@ -7837,12 +7837,12 @@ void CX86RecompilerOps::SPECIAL_DSRA32() } } -/************************** COP0 functions **************************/ +// COP0 functions void CX86RecompilerOps::COP0_MF() { switch (m_Opcode.rd) { - case 9: //Count + case 9: // Count m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); UpdateCounters(m_RegWorkingSet, false, true); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); @@ -7867,19 +7867,19 @@ void CX86RecompilerOps::COP0_MT() switch (m_Opcode.rd) { - case 0: //Index - case 2: //EntryLo0 - case 3: //EntryLo1 - case 4: //Context - case 5: //PageMask - case 10: //Entry Hi - case 14: //EPC - case 16: //Config - case 18: //WatchLo - case 19: //WatchHi - case 28: //Tag lo - case 29: //Tag Hi - case 30: //ErrEPC + case 0: // Index + case 2: // EntryLo0 + case 3: // EntryLo1 + case 4: // Context + case 5: // PageMask + case 10: // Entry Hi + case 14: // EPC + case 16: // Config + case 18: // WatchLo + case 19: // WatchHi + case 28: // Tag Lo + case 29: // Tag Hi + case 30: // ErrEPC if (IsConst(m_Opcode.rt)) { MoveConstToVariable(GetMipsRegLo(m_Opcode.rt), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); @@ -7892,12 +7892,12 @@ void CX86RecompilerOps::COP0_MT() { MoveX86regToVariable(Map_TempReg(x86_Any, m_Opcode.rt, false), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); } - if (m_Opcode.rd == 4) //Context + if (m_Opcode.rd == 4) // Context { AndConstToVariable(0xFF800000, &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); } break; - case 11: //Compare + case 11: // Compare m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); UpdateCounters(m_RegWorkingSet, false, true); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); @@ -7935,7 +7935,7 @@ void CX86RecompilerOps::COP0_MT() #endif m_RegWorkingSet.AfterCallDirect(); break; - case 9: //Count + case 9: // Count m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); UpdateCounters(m_RegWorkingSet, false, true); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); @@ -7966,7 +7966,7 @@ void CX86RecompilerOps::COP0_MT() Call_Direct(AddressOf(&CSystemTimer::UpdateCompareTimer), "CSystemTimer::UpdateCompareTimer"); m_RegWorkingSet.AfterCallDirect(); break; - case 12: //Status + case 12: // Status { x86Reg OldStatusReg = Map_TempReg(x86_Any, -1, false); MoveVariableToX86reg(&_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd], OldStatusReg); @@ -8009,7 +8009,7 @@ void CX86RecompilerOps::COP0_MT() m_RegWorkingSet.AfterCallDirect(); } break; - case 6: //Wired + case 6: // Wired m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); UpdateCounters(m_RegWorkingSet, false, true); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); @@ -8037,7 +8037,7 @@ void CX86RecompilerOps::COP0_MT() MoveX86regToVariable(Map_TempReg(x86_Any, m_Opcode.rt, false), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); } break; - case 13: //cause + case 13: // Cause AndConstToVariable(0xFFFFCFF, &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); if (IsConst(m_Opcode.rt)) { @@ -8067,7 +8067,7 @@ void CX86RecompilerOps::COP0_MT() } } -/************************** COP0 CO functions ***********************/ +// COP0 CO functions void CX86RecompilerOps::COP0_CO_TLBR(void) { if (!g_System->bUseTlb()) { return; } @@ -8175,7 +8175,7 @@ void CX86RecompilerOps::COP0_CO_ERET(void) m_NextInstruction = END_BLOCK; } -/************************** FPU Options **************************/ +// FPU options void CX86RecompilerOps::ChangeDefaultRoundingModel() { switch ((_FPCR[31] & 3)) @@ -8187,7 +8187,7 @@ void CX86RecompilerOps::ChangeDefaultRoundingModel() } } -/************************** COP1 functions **************************/ +// COP1 functions void CX86RecompilerOps::COP1_MF() { CompileCop1Test(); @@ -8346,7 +8346,7 @@ void CX86RecompilerOps::COP1_CT() m_RegWorkingSet.SetRoundingModel(CRegInfo::RoundUnknown); } -/************************** COP1: S functions ************************/ +// COP1: S functions void CX86RecompilerOps::COP1_S_ADD() { uint32_t Reg1 = m_Opcode.ft == m_Opcode.fd ? m_Opcode.ft : m_Opcode.fs; @@ -8693,7 +8693,7 @@ void CX86RecompilerOps::COP1_S_CMP() OrX86RegToVariable(&_FPCR[31], "_FPCR[31]", Reg); } -/************************** COP1: D functions ************************/ +// COP1: D functions void CX86RecompilerOps::COP1_D_ADD() { uint32_t Reg1 = m_Opcode.ft == m_Opcode.fd ? m_Opcode.ft : m_Opcode.fs; @@ -9066,7 +9066,7 @@ void CX86RecompilerOps::COP1_D_CMP() OrX86RegToVariable(&_FPCR[31], "_FPCR[31]", Reg); } -/************************** COP1: W functions ************************/ +// COP1: W functions void CX86RecompilerOps::COP1_W_CVT_S() { CompileCop1Test(); @@ -9087,7 +9087,7 @@ void CX86RecompilerOps::COP1_W_CVT_D() ChangeFPURegFormat(m_Opcode.fd, CRegInfo::FPU_Dword, CRegInfo::FPU_Double, CRegInfo::RoundDefault); } -/************************** COP1: L functions ************************/ +// COP1: L functions void CX86RecompilerOps::COP1_L_CVT_S() { CompileCop1Test(); @@ -9108,10 +9108,10 @@ void CX86RecompilerOps::COP1_L_CVT_D() ChangeFPURegFormat(m_Opcode.fd, CRegInfo::FPU_Qword, CRegInfo::FPU_Double, CRegInfo::RoundDefault); } -/************************** Other functions **************************/ +// Other functions void CX86RecompilerOps::UnknownOpcode() { - CPU_Message(" %X Unhandled Opcode: %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + CPU_Message(" %X Unhandled opcode: %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); m_RegWorkingSet.WriteBackRegisters(); UpdateCounters(m_RegWorkingSet, false, true); @@ -9341,14 +9341,14 @@ void CX86RecompilerOps::SyncRegState(const CRegInfo & SyncTo) else if (MemStackReg == x86_Unknown) { UnMap_X86reg(TargetStackReg); - CPU_Message(" regcache: allocate %s as Memory Stack", x86_Name(TargetStackReg)); + CPU_Message(" regcache: allocate %s as memory stack", x86_Name(TargetStackReg)); m_RegWorkingSet.SetX86Mapped(TargetStackReg, CRegInfo::Stack_Mapped); MoveVariableToX86reg(&g_Recompiler->MemoryStackPos(), "MemoryStack", TargetStackReg); } else { UnMap_X86reg(TargetStackReg); - CPU_Message(" regcache: change allocation of Memory Stack from %s to %s", x86_Name(MemStackReg), x86_Name(TargetStackReg)); + CPU_Message(" regcache: change allocation of memory stack from %s to %s", x86_Name(MemStackReg), x86_Name(TargetStackReg)); m_RegWorkingSet.SetX86Mapped(TargetStackReg, CRegInfo::Stack_Mapped); m_RegWorkingSet.SetX86Mapped(MemStackReg, CRegInfo::NotMapped); MoveX86RegToX86Reg(MemStackReg, TargetStackReg); @@ -9386,12 +9386,12 @@ void CX86RecompilerOps::SyncRegState(const CRegInfo & SyncTo) case CRegInfo::STATE_CONST_32_SIGN: if (GetMipsRegLo(i) != SyncTo.GetMipsRegLo(i)) { - CPU_Message("Value of const is different Reg %d (%s) Value: 0x%08X to 0x%08X", i, CRegName::GPR[i], GetMipsRegLo(i), SyncTo.GetMipsRegLo(i)); + CPU_Message("Value of constant is different register %d (%s) Value: 0x%08X to 0x%08X", i, CRegName::GPR[i], GetMipsRegLo(i), SyncTo.GetMipsRegLo(i)); g_Notify->BreakPoint(__FILE__, __LINE__); } continue; default: - CPU_Message("Unhandled Reg state %d\nin SyncRegState", GetMipsRegState(i)); + CPU_Message("Unhandled register state %d\nin SyncRegState", GetMipsRegState(i)); g_Notify->BreakPoint(__FILE__, __LINE__); } } @@ -9516,7 +9516,7 @@ void CX86RecompilerOps::SyncRegState(const CRegInfo & SyncTo) case CRegInfo::STATE_CONST_32_SIGN: if (!g_System->b32BitCore() && GetMipsRegLo_S(i) < 0) { - CPU_Message("Sign Problems in SyncRegState\nSTATE_MAPPED_32_ZERO"); + CPU_Message("Sign problems in SyncRegState\nSTATE_MAPPED_32_ZERO"); CPU_Message("%s: %X", CRegName::GPR[i], GetMipsRegLo_S(i)); g_Notify->BreakPoint(__FILE__, __LINE__); } @@ -9584,7 +9584,7 @@ bool CX86RecompilerOps::InheritParentInfo() return true; } - //Multiple Parents + // Multiple parents BLOCK_PARENT_LIST ParentList; CCodeSection::SECTION_LIST::iterator iter; for (iter = m_Section->m_ParentSection.begin(); iter != m_Section->m_ParentSection.end(); iter++) @@ -9657,7 +9657,7 @@ bool CX86RecompilerOps::InheritParentInfo() FirstParent = 0; } - //Link First Parent to start + // Link first parent to start CCodeSection * Parent = ParentList[FirstParent].Parent; CJumpInfo * JumpInfo = ParentList[FirstParent].JumpInfo; @@ -9691,10 +9691,10 @@ bool CX86RecompilerOps::InheritParentInfo() } JumpInfo->FallThrough = false; - //Fix up initial state + // Fix up initial state UnMap_AllFPRs(); - //determine loop reg usage + // Determine loop registry usage if (m_Section->m_InLoop && ParentList.size() > 1) { if (!SetupRegisterForLoop(m_Section->m_BlockInfo, m_Section->m_RegEnter)) { return false; } @@ -9716,7 +9716,7 @@ bool CX86RecompilerOps::InheritParentInfo() if (m_RegWorkingSet.GetRoundingModel() != RegSet->GetRoundingModel()) { m_RegWorkingSet.SetRoundingModel(CRegInfo::RoundUnknown); } - //Find Parent MapRegState + // Find parent MapRegState MemoryStackPos = x86_Unknown; for (i2 = 0; i2 < sizeof(x86_Registers) / sizeof(x86_Registers[0]); i2++) { @@ -9728,7 +9728,7 @@ bool CX86RecompilerOps::InheritParentInfo() } if (MemoryStackPos == x86_Unknown) { - // if the memory stack position is not mapped then unmap it + // If the memory stack position is not mapped then unmap it x86Reg MemStackReg = Get_MemoryStack(); if (MemStackReg != x86_Unknown) { @@ -9770,7 +9770,7 @@ bool CX86RecompilerOps::InheritParentInfo() } break; default: - CPU_Message("Unknown CPU State(%d) in InheritParentInfo", GetMipsRegState(i2)); + CPU_Message("Unknown CPU state(%d) in InheritParentInfo", GetMipsRegState(i2)); g_Notify->BreakPoint(__FILE__, __LINE__); } } @@ -9813,7 +9813,7 @@ bool CX86RecompilerOps::InheritParentInfo() } break; default: - CPU_Message("Unknown CPU State(%d) in InheritParentInfo", RegSet->GetMipsRegState(i2)); + CPU_Message("Unknown CPU state(%d) in InheritParentInfo", RegSet->GetMipsRegState(i2)); g_Notify->BreakPoint(__FILE__, __LINE__); break; } @@ -9837,7 +9837,7 @@ bool CX86RecompilerOps::InheritParentInfo() } m_Section->m_RegEnter = m_RegWorkingSet; - //Sync registers for different blocks + // Sync registers for different blocks stdstr_f Label("Section_%d", m_Section->m_SectionID); int CurrentParent = FirstParent; bool NeedSync = false; @@ -9906,7 +9906,7 @@ bool CX86RecompilerOps::InheritParentInfo() } break; default: - WriteTrace(TraceRecompiler, TraceError, "Unhandled Reg state %d\nin InheritParentInfo", GetMipsRegState(i2)); + WriteTrace(TraceRecompiler, TraceError, "Unhandled register state %d\nin InheritParentInfo", GetMipsRegState(i2)); g_Notify->BreakPoint(__FILE__, __LINE__); } } @@ -9943,7 +9943,7 @@ bool CX86RecompilerOps::InheritParentInfo() { UpdateCounters(m_RegWorkingSet, false, true); } - SyncRegState(m_Section->m_RegEnter); //Sync + SyncRegState(m_Section->m_RegEnter); // Sync m_Section->m_RegEnter = m_RegWorkingSet; } @@ -10046,7 +10046,7 @@ void CX86RecompilerOps::UpdateSyncCPU(CRegInfo & RegSet, uint32_t Cycles) return; } - WriteX86Comment("Updating Sync CPU"); + WriteX86Comment("Updating sync CPU"); RegSet.BeforeCallDirect(); PushImm32(stdstr_f("%d", Cycles).c_str(), Cycles); PushImm32("g_SyncSystem", (uint32_t)g_SyncSystem); @@ -10066,8 +10066,8 @@ void CX86RecompilerOps::UpdateCounters(CRegInfo & RegSet, bool CheckTimer, bool if (RegSet.GetBlockCycleCount() != 0) { UpdateSyncCPU(RegSet, RegSet.GetBlockCycleCount()); - WriteX86Comment("Update Counter"); - SubConstFromVariable(RegSet.GetBlockCycleCount(), g_NextTimer, "g_NextTimer"); // updates compare flag + WriteX86Comment("Update counter"); + SubConstFromVariable(RegSet.GetBlockCycleCount(), g_NextTimer, "g_NextTimer"); // Updates compare flag if (ClearValues) { RegSet.SetBlockCycleCount(0); @@ -10487,7 +10487,7 @@ void CX86RecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo ExitCodeBlock(); break; default: - WriteTrace(TraceRecompiler, TraceError, "how did you want to exit on reason (%d) ???", reason); + WriteTrace(TraceRecompiler, TraceError, "How did you want to exit on reason (%d) ???", reason); g_Notify->BreakPoint(__FILE__, __LINE__); } } @@ -10591,7 +10591,7 @@ void CX86RecompilerOps::SB_Const(uint8_t Value, uint32_t VAddr) default: if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store %02X in %08X?", __FUNCTION__, Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store %02X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } } } @@ -10642,7 +10642,7 @@ void CX86RecompilerOps::SB_Register(x86Reg Reg, uint32_t VAddr) default: if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store in %08X?", __FUNCTION__, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store in %08X?", __FUNCTION__, VAddr).c_str()); } } } @@ -10691,7 +10691,7 @@ void CX86RecompilerOps::SH_Const(uint16_t Value, uint32_t VAddr) default: if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store %04X in %08X?", __FUNCTION__, Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store %04X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } } } @@ -10742,7 +10742,7 @@ void CX86RecompilerOps::SH_Register(x86Reg Reg, uint32_t VAddr) default: if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store in %08X?", __FUNCTION__, PAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store in %08X?", __FUNCTION__, PAddr).c_str()); } } } @@ -10811,7 +10811,7 @@ void CX86RecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) default: if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } } break; @@ -10864,7 +10864,7 @@ void CX86RecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) default: if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } } break; @@ -10888,7 +10888,7 @@ void CX86RecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) default: if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } } break; @@ -11006,7 +11006,7 @@ void CX86RecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) default: if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } } break; @@ -11070,11 +11070,11 @@ void CX86RecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) default: if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } } break; - case 0x04500000: /* AI registers */ + case 0x04500000: // AI registers switch (PAddr) { case 0x04500000: MoveConstToVariable(Value, &g_Reg->AI_DRAM_ADDR_REG, "AI_DRAM_ADDR_REG"); break; @@ -11095,7 +11095,7 @@ void CX86RecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) break; case 0x04500008: MoveConstToVariable((Value & 1), &g_Reg->AI_CONTROL_REG, "AI_CONTROL_REG"); break; case 0x0450000C: - /* Clear Interrupt */; + // Clear interrupt AndConstToVariable((uint32_t)~MI_INTR_AI, &g_Reg->MI_INTR_REG, "MI_INTR_REG"); AndConstToVariable((uint32_t)~MI_INTR_AI, &g_Reg->m_AudioIntrReg, "m_AudioIntrReg"); m_RegWorkingSet.BeforeCallDirect(); @@ -11119,7 +11119,7 @@ void CX86RecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) MoveConstToVariable(Value, PAddr + g_MMU->Rdram(), VarName); if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } } break; @@ -11184,7 +11184,7 @@ void CX86RecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) default: if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } } break; @@ -11198,7 +11198,7 @@ void CX86RecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) default: if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } } break; @@ -11255,12 +11255,12 @@ void CX86RecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) default: if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } } break; case 0x05000000: - //64DD Registers + // 64DD registers if (g_Settings->LoadBool(Setting_EnableDisk)) { switch (PAddr) @@ -11273,7 +11273,7 @@ void CX86RecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) default: if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } } break; @@ -11301,7 +11301,7 @@ void CX86RecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) default: if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store %08X in %08X?", __FUNCTION__, Value, VAddr).c_str()); } m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); UpdateCounters(m_RegWorkingSet, false, true); @@ -11418,10 +11418,10 @@ void CX86RecompilerOps::SW_Register(x86Reg Reg, uint32_t VAddr) } else { - CPU_Message(" Should be moving %s in to %08X ?!?", x86_Name(Reg), VAddr); + CPU_Message(" should be moving %s in to %08X ?", x86_Name(Reg), VAddr); if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store in %08X?", __FUNCTION__, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store in %08X?", __FUNCTION__, VAddr).c_str()); } } } @@ -11463,10 +11463,10 @@ void CX86RecompilerOps::SW_Register(x86Reg Reg, uint32_t VAddr) m_RegWorkingSet.AfterCallDirect(); break; default: - CPU_Message(" Should be moving %s in to %08X ?!?", x86_Name(Reg), VAddr); + CPU_Message(" should be moving %s in to %08X ?", x86_Name(Reg), VAddr); if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store in %08X?", __FUNCTION__, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store in %08X?", __FUNCTION__, VAddr).c_str()); } } break; @@ -11532,14 +11532,14 @@ void CX86RecompilerOps::SW_Register(x86Reg Reg, uint32_t VAddr) case 0x04400030: MoveX86regToVariable(Reg, &g_Reg->VI_X_SCALE_REG, "VI_X_SCALE_REG"); break; case 0x04400034: MoveX86regToVariable(Reg, &g_Reg->VI_Y_SCALE_REG, "VI_Y_SCALE_REG"); break; default: - CPU_Message(" Should be moving %s in to %08X ?!?", x86_Name(Reg), VAddr); + CPU_Message(" should be moving %s in to %08X ?", x86_Name(Reg), VAddr); if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store in %08X?", __FUNCTION__, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store in %08X?", __FUNCTION__, VAddr).c_str()); } } break; - case 0x04500000: /* AI registers */ + case 0x04500000: // AI registers switch (PAddr) { case 0x04500000: MoveX86regToVariable(Reg, &g_Reg->AI_DRAM_ADDR_REG, "AI_DRAM_ADDR_REG"); break; case 0x04500004: @@ -11569,7 +11569,7 @@ void CX86RecompilerOps::SW_Register(x86Reg Reg, uint32_t VAddr) MoveX86regToVariable(Reg, &g_Reg->AI_CONTROL_REG, "AI_CONTROL_REG"); AndConstToVariable(1, &g_Reg->AI_CONTROL_REG, "AI_CONTROL_REG"); case 0x0450000C: - /* Clear Interrupt */; + // Clear interrupt AndConstToVariable((uint32_t)~MI_INTR_AI, &g_Reg->MI_INTR_REG, "MI_INTR_REG"); AndConstToVariable((uint32_t)~MI_INTR_AI, &g_Reg->m_AudioIntrReg, "m_AudioIntrReg"); m_RegWorkingSet.BeforeCallDirect(); @@ -11593,7 +11593,7 @@ void CX86RecompilerOps::SW_Register(x86Reg Reg, uint32_t VAddr) MoveX86regToVariable(Reg, PAddr + g_MMU->Rdram(), VarName); if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store in %08X?", __FUNCTION__, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store in %08X?", __FUNCTION__, VAddr).c_str()); } } break; @@ -11642,7 +11642,7 @@ void CX86RecompilerOps::SW_Register(x86Reg Reg, uint32_t VAddr) case 0x04600010: if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store in %08X?", __FUNCTION__, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store in %08X?", __FUNCTION__, VAddr).c_str()); } AndConstToVariable((uint32_t)~MI_INTR_PI, &g_Reg->MI_INTR_REG, "MI_INTR_REG"); m_RegWorkingSet.BeforeCallDirect(); @@ -11689,10 +11689,10 @@ void CX86RecompilerOps::SW_Register(x86Reg Reg, uint32_t VAddr) AndConstToVariable(0xFF, &g_Reg->PI_BSD_DOM2_RLS_REG, "PI_BSD_DOM2_RLS_REG"); break; default: - CPU_Message(" Should be moving %s in to %08X ?!?", x86_Name(Reg), VAddr); + CPU_Message(" should be moving %s in to %08X ?", x86_Name(Reg), VAddr); if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store in %08X?", __FUNCTION__, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store in %08X?", __FUNCTION__, VAddr).c_str()); } } break; @@ -11706,7 +11706,7 @@ void CX86RecompilerOps::SW_Register(x86Reg Reg, uint32_t VAddr) default: if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store in %08X?", __FUNCTION__, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store in %08X?", __FUNCTION__, VAddr).c_str()); } } break; @@ -11757,12 +11757,12 @@ void CX86RecompilerOps::SW_Register(x86Reg Reg, uint32_t VAddr) default: if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store in %08X?", __FUNCTION__, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store in %08X?", __FUNCTION__, VAddr).c_str()); } } break; case 0x05000000: - //64DD Registers + // 64DD registers if (g_Settings->LoadBool(Setting_EnableDisk)) { switch (PAddr) @@ -11770,7 +11770,7 @@ void CX86RecompilerOps::SW_Register(x86Reg Reg, uint32_t VAddr) case 0x05000500: MoveX86regToVariable(Reg, &g_Reg->ASIC_DATA, "ASIC_DATA"); break; case 0x05000508: { - //ASIC_CMD + // ASIC_CMD MoveX86regToVariable(Reg, &g_Reg->ASIC_CMD, "ASIC_CMD"); m_RegWorkingSet.BeforeCallDirect(); Call_Direct(AddressOf(&DiskCommand), "DiskCommand"); @@ -11779,7 +11779,7 @@ void CX86RecompilerOps::SW_Register(x86Reg Reg, uint32_t VAddr) } case 0x05000510: { - //ASIC_BM_CTL + // ASIC_BM_CTL MoveX86regToVariable(Reg, &g_Reg->ASIC_BM_CTL, "ASIC_BM_CTL"); m_RegWorkingSet.BeforeCallDirect(); Call_Direct(AddressOf(&DiskBMControl), "DiskBMControl"); @@ -11804,10 +11804,10 @@ void CX86RecompilerOps::SW_Register(x86Reg Reg, uint32_t VAddr) MoveX86regToVariable(Reg, PAddr + g_MMU->Rdram(), VarName); break; default: - CPU_Message(" Should be moving %s in to %08X ?!?", x86_Name(Reg), VAddr); + CPU_Message(" should be moving %s in to %08X ?", x86_Name(Reg), VAddr); if (ShowUnhandledMemory()) { - g_Notify->DisplayError(stdstr_f("%s\ntrying to store in %08X?", __FUNCTION__, VAddr).c_str()); + g_Notify->DisplayError(stdstr_f("%s\nTrying to store in %08X?", __FUNCTION__, VAddr).c_str()); } } } diff --git a/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.h b/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.h index f84e36361..4c0e90681 100644 --- a/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.h +++ b/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.h @@ -23,10 +23,10 @@ class CX86RecompilerOps : protected CRecompilerSettings { public: - /*************************** Trap functions *************************/ + // Trap functions void Compile_TrapCompare(TRAP_COMPARE CompareType); - /************************** Branch functions ************************/ + // Branch functions void Compile_BranchCompare(BRANCH_COMPARE CompareType); void Compile_Branch(BRANCH_COMPARE CompareType, BRANCH_TYPE BranchType, bool Link); void Compile_BranchLikely(BRANCH_COMPARE CompareType, bool Link); @@ -39,7 +39,7 @@ public: void COP1_BCF_Compare(); void COP1_BCT_Compare(); - /************************* OpCode functions *************************/ + // Opcode functions void J(); void JAL(); void ADDI(); @@ -78,7 +78,7 @@ public: void SDC1(); void SD(); - /********************** R4300i OpCodes: Special **********************/ + // R4300i opcodes: Special void SPECIAL_SLL(); void SPECIAL_SRL(); void SPECIAL_SRA(); @@ -124,18 +124,18 @@ public: void SPECIAL_DSRL32(); void SPECIAL_DSRA32(); - /************************** COP0 functions **************************/ + // COP0 functions void COP0_MF(); void COP0_MT(); - /************************** COP0 CO functions ***********************/ + // COP0 CO functions void COP0_CO_TLBR(); void COP0_CO_TLBWI(); void COP0_CO_TLBWR(); void COP0_CO_TLBP(); void COP0_CO_ERET(); - /************************** COP1 functions **************************/ + // COP1 functions void COP1_MF(); void COP1_DMF(); void COP1_CF(); @@ -143,7 +143,7 @@ public: void COP1_DMT(); void COP1_CT(); - /************************** COP1: S functions ************************/ + // COP1: S functions void COP1_S_ADD(); void COP1_S_SUB(); void COP1_S_MUL(); @@ -165,7 +165,7 @@ public: void COP1_S_CVT_L(); void COP1_S_CMP(); - /************************** COP1: D functions ************************/ + // COP1: D functions void COP1_D_ADD(); void COP1_D_SUB(); void COP1_D_MUL(); @@ -187,15 +187,15 @@ public: void COP1_D_CVT_L(); void COP1_D_CMP(); - /************************** COP1: W functions ************************/ + // COP1: W functions void COP1_W_CVT_S(); void COP1_W_CVT_D(); - /************************** COP1: L functions ************************/ + // COP1: L functions void COP1_L_CVT_S(); void COP1_L_CVT_D(); - /************************** Other functions **************************/ + // Other functions void UnknownOpcode(); void ClearCachedInstructionInfo(); @@ -239,7 +239,7 @@ public: static void ChangeDefaultRoundingModel(); void OverflowDelaySlot(bool TestTimer); - /********* Helper Functions *********/ + // Helper functions typedef CRegInfo::REG_STATE REG_STATE; static REG_STATE GetMipsRegState(int32_t Reg) { return m_RegWorkingSet.GetMipsRegState(Reg); } diff --git a/Source/Project64-core/N64System/Recompiler/x86/x86RegInfo.cpp b/Source/Project64-core/N64System/Recompiler/x86/x86RegInfo.cpp index fa8da8640..82fef66d5 100644 --- a/Source/Project64-core/N64System/Recompiler/x86/x86RegInfo.cpp +++ b/Source/Project64-core/N64System/Recompiler/x86/x86RegInfo.cpp @@ -169,7 +169,7 @@ void CX86RegInfo::FixRoundModel(FPU_ROUND RoundMethod) case RoundDown: OrConstToX86Reg(0x0400, reg); break; case RoundUp: OrConstToX86Reg(0x0800, reg); break; default: - g_Notify->DisplayError("Unknown Rounding model"); + g_Notify->DisplayError("Unknown rounding model"); } } MoveX86regToVariable(reg, &m_fpuControl, "m_fpuControl"); @@ -203,7 +203,7 @@ void CX86RegInfo::ChangeFPURegFormat(int32_t Reg, FPU_STATE OldFormat, FPU_STATE if (HaveDebugger()) { - g_Notify->DisplayError("ChangeFormat: Register not on stack!!"); + g_Notify->DisplayError("ChangeFormat: Register not on stack!"); } } @@ -258,7 +258,7 @@ void CX86RegInfo::Load_FPR_ToTop(int32_t Reg, int32_t RegToLoad, FPU_STATE Forma if (Reg == RegToLoad) { - //if different format then unmap original reg from stack + // If different format then unmap original register from stack for (i = 0; i < 8; i++) { if (m_x86fpu_MappedTo[i] != Reg) @@ -274,7 +274,7 @@ void CX86RegInfo::Load_FPR_ToTop(int32_t Reg, int32_t RegToLoad, FPU_STATE Forma } else { - //if different format then unmap original reg from stack + // If different format then unmap original register from stack for (i = 0; i < 8; i++) { if (m_x86fpu_MappedTo[i] != Reg) @@ -550,16 +550,16 @@ CX86RegInfo::x86Reg CX86RegInfo::Map_MemoryStack(x86Reg Reg, bool bMapRegister, x86Reg CurrentMap = Get_MemoryStack(); if (!bMapRegister) { - //if not mapping then just return what the current mapping is + // If not mapping then just return what the current mapping is return CurrentMap; } if (CurrentMap != x86_Unknown && CurrentMap == Reg) { - //already mapped to correct reg + // Already mapped to correct register return CurrentMap; } - // map a register + // Map a register if (Reg == x86_Any) { if (CurrentMap != x86_Unknown) @@ -581,11 +581,11 @@ CX86RegInfo::x86Reg CX86RegInfo::Map_MemoryStack(x86Reg Reg, bool bMapRegister, return Reg; } - //move to a register/allocate register + // Move to a register/allocate register UnMap_X86reg(Reg); if (CurrentMap != x86_Unknown) { - CPU_Message(" regcache: change allocation of Memory Stack from %s to %s", x86_Name(CurrentMap), x86_Name(Reg)); + CPU_Message(" regcache: change allocation of memory stack from %s to %s", x86_Name(CurrentMap), x86_Name(Reg)); SetX86Mapped(Reg, CX86RegInfo::Stack_Mapped); SetX86Mapped(CurrentMap, CX86RegInfo::NotMapped); MoveX86RegToX86Reg(CurrentMap, Reg); @@ -593,7 +593,7 @@ CX86RegInfo::x86Reg CX86RegInfo::Map_MemoryStack(x86Reg Reg, bool bMapRegister, else { SetX86Mapped(Reg, CX86RegInfo::Stack_Mapped); - CPU_Message(" regcache: allocate %s as Memory Stack", x86_Name(Reg)); + CPU_Message(" regcache: allocate %s as memory stack", x86_Name(Reg)); if (LoadValue) { MoveVariableToX86reg(&g_Recompiler->MemoryStackPos(), "MemoryStack", Reg); @@ -628,7 +628,7 @@ void CX86RegInfo::Map_GPR_32bit(int32_t MipsReg, bool SignValue, int32_t MipsReg { if (Is64Bit(MipsReg)) { - CPU_Message(" regcache: unallocate %s from high 32bit of %s", x86_Name(GetMipsRegMapHi(MipsReg)), CRegName::GPR_Hi[MipsReg]); + CPU_Message(" regcache: unallocate %s from high 32-bit of %s", x86_Name(GetMipsRegMapHi(MipsReg)), CRegName::GPR_Hi[MipsReg]); SetX86MapOrder(GetMipsRegMapHi(MipsReg), 0); SetX86Mapped(GetMipsRegMapHi(MipsReg), NotMapped); SetX86Protected(GetMipsRegMapHi(MipsReg), false); @@ -681,7 +681,7 @@ void CX86RegInfo::Map_GPR_64bit(int32_t MipsReg, int32_t MipsRegToLoad) if (MipsReg == 0) { - if (HaveDebugger()) { g_Notify->DisplayError("Map_GPR_32bit\n\nWhy are you trying to map reg 0"); } + if (HaveDebugger()) { g_Notify->DisplayError("Map_GPR_32bit\n\nWhy are you trying to map register 0?"); } return; } @@ -841,7 +841,7 @@ CX86Ops::x86Reg CX86RegInfo::Map_TempReg(CX86Ops::x86Reg Reg, int32_t MipsReg, b Reg = Free8BitX86Reg(); if (Reg < 0) { - WriteTrace(TraceRegisterCache, TraceError, "Failed to find a free 8 bit register"); + WriteTrace(TraceRegisterCache, TraceError, "Failed to find a free 8-bit register"); g_Notify->BreakPoint(__FILE__, __LINE__); return x86_Unknown; } @@ -1034,7 +1034,7 @@ void CX86RegInfo::UnMap_AllFPRs() UnMap_FPR(m_x86fpu_MappedTo[StackPos], true); continue; } - //see if any more registers mapped + // See if any more registers mapped int32_t StartPos = StackTopPos(); for (int32_t i = 0; i < 8; i++) { @@ -1139,7 +1139,7 @@ void CX86RegInfo::UnMap_GPR(uint32_t Reg, bool WriteBackValue) { if (HaveDebugger()) { - g_Notify->DisplayError(stdstr_f("%s\n\nWhy are you trying to unmap reg 0", __FUNCTION__).c_str()); + g_Notify->DisplayError(stdstr_f("%s\n\nWhy are you trying to unmap register 0?", __FUNCTION__).c_str()); } return; } @@ -1287,7 +1287,7 @@ bool CX86RegInfo::UnMap_X86reg(CX86Ops::x86Reg Reg) } else if (GetX86Mapped(Reg) == CX86RegInfo::Stack_Mapped) { - CPU_Message(" regcache: unallocate %s from Memory Stack", x86_Name(Reg)); + CPU_Message(" regcache: unallocate %s from memory stack", x86_Name(Reg)); MoveX86regToVariable(Reg, &(g_Recompiler->MemoryStackPos()), "MemoryStack"); SetX86Mapped(Reg, NotMapped); return true; @@ -1308,8 +1308,6 @@ void CX86RegInfo::WriteBackRegisters() for (int32_t i = 0; i < X86RegCount; i++) { SetX86Protected(x86_Registers[i], false); } for (int32_t i = 0; i < X86RegCount; i++) { UnMap_X86reg(x86_Registers[i]); } - /*************************************/ - for (count = 1; count < 32; count++) { switch (GetMipsRegState(count)) diff --git a/Source/Project64-core/N64System/Recompiler/x86/x86RegInfo.h b/Source/Project64-core/N64System/Recompiler/x86/x86RegInfo.h index 3f7e15d04..446db7f59 100644 --- a/Source/Project64-core/N64System/Recompiler/x86/x86RegInfo.h +++ b/Source/Project64-core/N64System/Recompiler/x86/x86RegInfo.h @@ -13,7 +13,7 @@ class CX86RegInfo : private CSystemRegisters { public: - //enums + // Enums enum REG_MAPPED { NotMapped = 0, @@ -92,7 +92,7 @@ public: private: x86Reg UnMap_8BitTempReg(); - //r4k + // r4k x86Reg m_RegMapHi[32]; x86Reg m_RegMapLo[32]; @@ -100,7 +100,7 @@ private: uint32_t m_x86reg_MapOrder[10]; bool m_x86reg_Protected[10]; - //FPU + // FPU int32_t m_Stack_TopPos; int32_t m_x86fpu_MappedTo[8]; FPU_STATE m_x86fpu_State[8]; diff --git a/Source/Project64-core/N64System/Recompiler/x86/x86ops.cpp b/Source/Project64-core/N64System/Recompiler/x86/x86ops.cpp index b52d6edb6..034a1d80a 100644 --- a/Source/Project64-core/N64System/Recompiler/x86/x86ops.cpp +++ b/Source/Project64-core/N64System/Recompiler/x86/x86ops.cpp @@ -23,9 +23,7 @@ CX86Ops::x86Reg CX86Ops::x86_Registers[8] = x86_ESP }; -/************************************************************************** -* Logging Functions * -**************************************************************************/ +// Logging functions void CX86Ops::WriteX86Comment(const char * Comment) { CPU_Message(""); @@ -551,12 +549,12 @@ void CX86Ops::JmpIndirectReg(x86Reg reg) case x86_ESP: AddCode8(0xff); AddCode16(0x2434); - /* g_Notify->BreakPoint(__FILEW__,__LINE__); */ + // g_Notify->BreakPoint(__FILEW__,__LINE__); break; case x86_EBP: AddCode8(0xff); AddCode16(0x0065); - /* g_Notify->BreakPoint(__FILEW__,__LINE__); */ + // g_Notify->BreakPoint(__FILEW__,__LINE__); break; } } @@ -1087,9 +1085,9 @@ void CX86Ops::MoveN64MemToX86regByte(x86Reg reg, x86Reg AddrReg) case x86_EBX: x86Command += 0x9800; break; case x86_ECX: x86Command += 0x8800; break; case x86_EDX: x86Command += 0x9000; break; - /* case x86_ESI: x86Command += 0xB000; break; */ - /* case x86_EDI: x86Command += 0xB800; break; */ - /* case x86_ESP: case x86_EBP: */ + // case x86_ESI: x86Command += 0xB000; break; + // case x86_EDI: x86Command += 0xB800; break; + // case x86_ESP: case x86_EBP: default: g_Notify->BreakPoint(__FILE__, __LINE__); break; @@ -1388,7 +1386,7 @@ void CX86Ops::MoveVariableDispToX86Reg(void *Variable, const char * VariableName g_Notify->BreakPoint(__FILE__, __LINE__); } - /* put in shifter 2(01), 4(10), 8(11) */ + // Put in shifter 2(01), 4(10), 8(11) switch (Multiplier) { case 1: x = 0; break; @@ -1399,7 +1397,7 @@ void CX86Ops::MoveVariableDispToX86Reg(void *Variable, const char * VariableName g_Notify->BreakPoint(__FILE__, __LINE__); } - /* format xx|000000 */ + // Format xx|000000 switch (AddrReg) { case x86_EAX: AddCode8((uint8_t)(0x05 | x)); break; diff --git a/Source/Project64-core/N64System/Recompiler/x86/x86ops.h b/Source/Project64-core/N64System/Recompiler/x86/x86ops.h index e72c432ce..e7e2d9838 100644 --- a/Source/Project64-core/N64System/Recompiler/x86/x86ops.h +++ b/Source/Project64-core/N64System/Recompiler/x86/x86ops.h @@ -50,7 +50,7 @@ public: static const char * fpu_Name(x86FpuValues Reg); protected: - //Logging Functions + // Logging functions static void WriteX86Comment(const char * Comment); static void WriteX86Label(const char * Label); diff --git a/Source/Project64-core/N64System/SpeedLimiter.cpp b/Source/Project64-core/N64System/SpeedLimiter.cpp index 06e8b013f..154a5e338 100644 --- a/Source/Project64-core/N64System/SpeedLimiter.cpp +++ b/Source/Project64-core/N64System/SpeedLimiter.cpp @@ -3,12 +3,8 @@ #include -// --------------------------------------------------- - const uint32_t CSpeedLimiter::m_DefaultSpeed = 60; -// --------------------------------------------------- - CSpeedLimiter::CSpeedLimiter() : m_Frames(0), m_Speed(m_DefaultSpeed), @@ -39,7 +35,7 @@ bool CSpeedLimiter::Timer_Process(uint32_t * FrameRate) HighResTimeStamp CurrentTime; CurrentTime.SetToNow(); - /* Calculate time that should of elapsed for this frame */ + // Calculate time that should have elapsed for this frame uint64_t LastTime = m_LastTime.GetMicroSeconds(), CurrentTimeValue = CurrentTime.GetMicroSeconds(); if (LastTime == 0) { @@ -55,13 +51,13 @@ bool CSpeedLimiter::Timer_Process(uint32_t * FrameRate) { pjutil::Sleep((time / 1000) + 1); } - /* Refresh current time */ + // Refresh current time CurrentTime.SetToNow(); CurrentTimeValue = CurrentTime.GetMicroSeconds(); } if (CurrentTimeValue - LastTime >= 1000000) { - /* Output FPS */ + // Output FPS if (FrameRate != nullptr) { *FrameRate = m_Frames; } m_Frames = 0; m_LastTime = CurrentTime; diff --git a/Source/Project64-core/N64System/SystemGlobals.cpp b/Source/Project64-core/N64System/SystemGlobals.cpp index 1fed8895f..440ada03e 100644 --- a/Source/Project64-core/N64System/SystemGlobals.cpp +++ b/Source/Project64-core/N64System/SystemGlobals.cpp @@ -5,14 +5,14 @@ CN64System * g_System = nullptr; CN64System * g_BaseSystem = nullptr; CN64System * g_SyncSystem = nullptr; CRecompiler * g_Recompiler = nullptr; -CMipsMemoryVM * g_MMU = nullptr; //Memory of the n64 -CTLB * g_TLB = nullptr; //TLB Unit -CRegisters * g_Reg = nullptr; //Current Register Set attacted to the g_MMU +CMipsMemoryVM * g_MMU = nullptr; // Memory of the N64 +CTLB * g_TLB = nullptr; // TLB unit +CRegisters * g_Reg = nullptr; // Current register set attached to the g_MMU CNotification * g_Notify = nullptr; CPlugins * g_Plugins = nullptr; -CN64Rom * g_Rom = nullptr; //The current rom that this system is executing.. it can only execute one file at the time -CN64Rom * g_DDRom = nullptr; //64DD IPL ROM -CN64Disk * g_Disk = nullptr; //64DD DISK +CN64Rom * g_Rom = nullptr; // The current ROM that this system is executing, it can only execute one file at the time +CN64Rom * g_DDRom = nullptr; // 64DD IPL ROM +CN64Disk * g_Disk = nullptr; // 64DD disk CAudio * g_Audio = nullptr; CSystemTimer * g_SystemTimer = nullptr; CTransVaddr * g_TransVaddr = nullptr; diff --git a/Source/Project64-core/N64System/SystemGlobals.h b/Source/Project64-core/N64System/SystemGlobals.h index d5af47f3d..c4e4fc0b7 100644 --- a/Source/Project64-core/N64System/SystemGlobals.h +++ b/Source/Project64-core/N64System/SystemGlobals.h @@ -12,23 +12,23 @@ class CRecompiler; extern CRecompiler * g_Recompiler; class CMipsMemoryVM; -extern CMipsMemoryVM * g_MMU; //Memory of the n64 +extern CMipsMemoryVM * g_MMU; // Memory of the N64 class CTLB; -extern CTLB * g_TLB; //TLB Unit +extern CTLB * g_TLB; // TLB unit class CRegisters; -extern CRegisters * g_Reg; //Current Register Set attached to the g_MMU +extern CRegisters * g_Reg; // Current register set attached to the g_MMU class CPlugins; extern CPlugins * g_Plugins; class CN64Rom; -extern CN64Rom * g_Rom; //The current rom that this system is executing.. it can only execute one file at the time -extern CN64Rom * g_DDRom; //64DD IPL ROM +extern CN64Rom * g_Rom; // The current ROM that this system is executing, it can only execute one file at the time +extern CN64Rom * g_DDRom; // 64DD IPL ROM class CN64Disk; -extern CN64Disk * g_Disk; //64DD DISK +extern CN64Disk * g_Disk; // 64DD disk class CAudio; extern CAudio * g_Audio; diff --git a/Source/Project64-core/Plugins/AudioPlugin.cpp b/Source/Project64-core/Plugins/AudioPlugin.cpp index 01016e09a..f34e899df 100644 --- a/Source/Project64-core/Plugins/AudioPlugin.cpp +++ b/Source/Project64-core/Plugins/AudioPlugin.cpp @@ -39,7 +39,7 @@ bool CAudioPlugin::LoadFunctions(void) LoadFunction(AiUpdate); LoadFunction(ProcessAList); - // Make sure dll has all needed functions + // Make sure DLL has all needed functions if (AiDacrateChanged == nullptr) { UnloadPlugin(); return false; } if (AiLenChanged == nullptr) { UnloadPlugin(); return false; } if (AiReadLength == nullptr) { UnloadPlugin(); return false; } @@ -60,13 +60,11 @@ bool CAudioPlugin::Initiate(CN64System * System, RenderWindow * Window) void * hwnd; void * hinst; - int32_t MemoryBswaped; // If this is set to TRUE, then the memory has been pre - - // bswap on a dword (32 bits) boundry + int32_t MemoryBswaped; // If this is set to TRUE, then the memory has been pre-bswap'd on a DWORD (32-bit) boundary // eg. the first 8 bytes are stored like this: - // 4 3 2 1 8 7 6 5 - uint8_t * HEADER; // This is the rom header (first 40h bytes of the rom - // This will be in the same memory format as the rest of the memory. + // 4 3 2 1 8 7 6 5 + uint8_t * HEADER; // This is the ROM header (first 40h bytes of the ROM) + // This will be in the same memory format as the rest of the memory uint8_t * RDRAM; uint8_t * DMEM; uint8_t * IMEM; @@ -83,7 +81,7 @@ bool CAudioPlugin::Initiate(CN64System * System, RenderWindow * Window) void(CALL *CheckInterrupts)(void); }; - //Get Function from DLL + // Get function from DLL int32_t(CALL *InitiateAudio)(AUDIO_INFO Audio_Info); LoadFunction(InitiateAudio); if (InitiateAudio == nullptr) { return false; } @@ -100,8 +98,8 @@ bool CAudioPlugin::Initiate(CN64System * System, RenderWindow * Window) Info.MemoryBswaped = true; Info.CheckInterrupts = DummyCheckInterrupts; - // We are initializing the plugin before any rom is loaded so we do not have any correct - // parameters here.. just needed to we can config the DLL. + // We are initializing the plugin before any ROM is loaded so we do not have any correct + // parameters here, just needed to we can config the DLL if (System == nullptr) { static uint8_t Buffer[100]; @@ -171,7 +169,7 @@ void CAudioPlugin::UnloadPluginDetails(void) #ifdef _WIN32 if (m_hAudioThread) { - WriteTrace(TraceAudioPlugin, TraceDebug, "Terminate Audio Thread"); + WriteTrace(TraceAudioPlugin, TraceDebug, "Terminate audio thread"); TerminateThread(m_hAudioThread, 0); m_hAudioThread = nullptr; } diff --git a/Source/Project64-core/Plugins/ControllerPlugin.cpp b/Source/Project64-core/Plugins/ControllerPlugin.cpp index ff18eac89..23ed078a7 100644 --- a/Source/Project64-core/Plugins/ControllerPlugin.cpp +++ b/Source/Project64-core/Plugins/ControllerPlugin.cpp @@ -35,7 +35,7 @@ bool CControl_Plugin::LoadFunctions(void) LoadFunction(WM_KeyUp); LoadFunction(RumbleCommand); - //Make sure dll had all needed functions + // Make sure DLL had all needed functions if (InitiateControllers == nullptr) { UnloadPlugin(); return false; } if (m_PluginInfo.Version >= 0x0102) @@ -63,10 +63,10 @@ bool CControl_Plugin::Initiate(CN64System * System, RenderWindow * Window) m_PluginControllers[i].Plugin = PLUGIN_NONE; } - // Test Plugin version + // Test plugin version if (m_PluginInfo.Version == 0x0100) { - //Get Function from DLL + // Get function from DLL void(CALL *InitiateControllers_1_0)(void * hMainWindow, CONTROL Controls[4]); _LoadFunction("InitiateControllers", InitiateControllers_1_0); if (InitiateControllers_1_0 == nullptr) { return false; } @@ -93,7 +93,7 @@ bool CControl_Plugin::Initiate(CN64System * System, RenderWindow * Window) if (m_PluginInfo.Version == 0x0101) { - //Get Function from DLL + // Get function from DLL void(CALL *InitiateControllers_1_1)(CONTROL_INFO ControlInfo); _LoadFunction("InitiateControllers", InitiateControllers_1_1); if (InitiateControllers_1_1 == nullptr) { return false; } @@ -103,7 +103,7 @@ bool CControl_Plugin::Initiate(CN64System * System, RenderWindow * Window) } else if (m_PluginInfo.Version >= 0x0102) { - //Get Function from DLL + // Get function from DLL void(CALL *InitiateControllers_1_2)(CONTROL_INFO * ControlInfo); _LoadFunction("InitiateControllers", InitiateControllers_1_2); if (InitiateControllers_1_2 == nullptr) { return false; } diff --git a/Source/Project64-core/Plugins/ControllerPlugin.h b/Source/Project64-core/Plugins/ControllerPlugin.h index d5cfa7096..0efdf8552 100644 --- a/Source/Project64-core/Plugins/ControllerPlugin.h +++ b/Source/Project64-core/Plugins/ControllerPlugin.h @@ -46,9 +46,9 @@ typedef struct void * hMainWindow; void * hinst; - int32_t MemoryBswaped; // memory in client- or server-native endian - uint8_t * HEADER; // the ROM header (first 40h bytes of the ROM) - CONTROL * Controls; // pointer to array of 4 controllers, i.e.: CONTROL Controls[4]; + int32_t MemoryBswaped; // Memory in client or server-native endian + uint8_t * HEADER; // The ROM header (first 40h bytes of the ROM) + CONTROL * Controls; // Pointer to array of 4 controllers, i.e.: CONTROL Controls[4]; } CONTROL_INFO; enum PluginType @@ -56,8 +56,8 @@ enum PluginType PLUGIN_NONE = 1, PLUGIN_MEMPAK = 2, PLUGIN_RUMBLE_PAK = 3, - PLUGIN_TANSFER_PAK = 4, // not implemeted for non raw data - PLUGIN_RAW = 5, // the controller plugin is passed in raw data + PLUGIN_TANSFER_PAK = 4, // Not implemented for non-raw data + PLUGIN_RAW = 5, // The controller plugin is passed in raw data }; class CControl_Plugin; diff --git a/Source/Project64-core/Plugins/GFXPlugin.cpp b/Source/Project64-core/Plugins/GFXPlugin.cpp index e228d6b0b..2b12e3933 100644 --- a/Source/Project64-core/Plugins/GFXPlugin.cpp +++ b/Source/Project64-core/Plugins/GFXPlugin.cpp @@ -54,14 +54,14 @@ bool CGfxPlugin::LoadFunctions(void) LoadFunction(SurfaceChanged); #endif - // version 0x104 functions + // Version 0x104 functions _LoadFunction("DrawFullScreenStatus", DrawStatus); - // Rom Browser + // ROM browser LoadFunction(GetRomBrowserMenu); LoadFunction(OnRomBrowserMenuItem); - //Make sure dll had all needed functions + // Make sure DLL had all needed functions if (ChangeWindow == nullptr) { UnloadPlugin(); return false; } if (DrawScreen == nullptr) { DrawScreen = DummyDrawScreen; } if (InitiateGFX == nullptr) { UnloadPlugin(); return false; } @@ -105,24 +105,23 @@ bool CGfxPlugin::Initiate(CN64System * System, RenderWindow * Window) Close(Window); if (PluginOpened) { - WriteTrace(PluginTraceType(), TraceDebug, "Before Plugin Opened"); + WriteTrace(PluginTraceType(), TraceDebug, "Before plugin opened"); PluginOpened(); - WriteTrace(PluginTraceType(), TraceDebug, "After Plugin Opened"); + WriteTrace(PluginTraceType(), TraceDebug, "After plugin opened"); } } typedef struct { - void * hWnd; /* Render window */ - void * hStatusBar; /* if render window does not have a status bar then this is nullptr */ + void * hWnd; // Render window + void * hStatusBar; // If render window does not have a status bar then this is NULL - int32_t MemoryBswaped; // If this is set to TRUE, then the memory has been pre - // bswap on a dword (32 bits) boundry + int32_t MemoryBswaped; // If this is set to TRUE, then the memory has been pre-bswap'd on a DWORD (32-bit) boundary // eg. the first 8 bytes are stored like this: - // 4 3 2 1 8 7 6 5 + // 4 3 2 1 8 7 6 5 - uint8_t * HEADER; // This is the rom header (first 40h bytes of the rom - // This will be in the same memory format as the rest of the memory. + uint8_t * HEADER; // This is the ROM header (first 40h bytes of the ROM) + // This will be in the same memory format as the rest of the memory uint8_t * RDRAM; uint8_t * DMEM; uint8_t * IMEM; @@ -159,7 +158,7 @@ bool CGfxPlugin::Initiate(CN64System * System, RenderWindow * Window) #endif } GFX_INFO; - //Get Function from DLL + // Get function from DLL int32_t(CALL *InitiateGFX)(GFX_INFO Gfx_Info); _LoadFunction("InitiateGFX", InitiateGFX); if (InitiateGFX == nullptr) @@ -185,8 +184,8 @@ bool CGfxPlugin::Initiate(CN64System * System, RenderWindow * Window) #endif Info.CheckInterrupts = DummyCheckInterrupts; - // We are initializing the plugin before any rom is loaded so we do not have any correct - // parameters here.. it's just needed so we can config the DLL. + // We are initializing the plugin before any ROM is loaded so we do not have any correct + // parameters here, it's just needed so we can config the DLL WriteTrace(TraceGFXPlugin, TraceDebug, "System = %X", System); if (System == nullptr) { @@ -260,7 +259,7 @@ bool CGfxPlugin::Initiate(CN64System * System, RenderWindow * Window) void CGfxPlugin::UnloadPluginDetails(void) { - WriteTrace(TraceGFXPlugin, TraceDebug, "start"); + WriteTrace(TraceGFXPlugin, TraceDebug, "Start"); if (m_LibHandle != nullptr) { DynamicLibraryClose(m_LibHandle); diff --git a/Source/Project64-core/Plugins/GFXPlugin.h b/Source/Project64-core/Plugins/GFXPlugin.h index a5b46a941..8922ace24 100644 --- a/Source/Project64-core/Plugins/GFXPlugin.h +++ b/Source/Project64-core/Plugins/GFXPlugin.h @@ -5,12 +5,12 @@ class CGfxPlugin : public CPlugin { typedef struct { - /* Menu */ - /* Items should have an ID between 5101 and 5200 */ + // Menu + // Items should have an ID between 5101 and 5200 void * hGFXMenu; void(CALL *ProcessMenuItem)(int32_t ID); - /* Break Points */ + // Breakpoints int32_t UseBPoints; char BPPanelName[20]; void(CALL *Add_BPoint) (void); @@ -22,7 +22,7 @@ class CGfxPlugin : public CPlugin void(CALL *RemoveBpoint) (void * hList, int32_t index); void(CALL *RemoveAllBpoint) (void); - /* GFX command Window */ + // GFX command window void(CALL *Enter_GFX_Commands_Window)(void); } GFXDEBUG_INFO; @@ -62,8 +62,8 @@ public: void(CALL *SurfaceChanged) (int w, int h); #endif - //Rom Browser - void *(CALL * GetRomBrowserMenu)(void); /* Items should have an ID between 4101 and 4200 */ + // ROM browser + void *(CALL * GetRomBrowserMenu)(void); // Items should have an ID between 4101 and 4200 void(CALL * OnRomBrowserMenuItem)(int32_t MenuID, void * hParent, uint8_t * HEADER); void * GetDebugMenu(void) { return m_GFXDebug.hGFXMenu; } diff --git a/Source/Project64-core/Plugins/Plugin.cpp b/Source/Project64-core/Plugins/Plugin.cpp index d2a5d2fa3..b3f27bec3 100644 --- a/Source/Project64-core/Plugins/Plugin.cpp +++ b/Source/Project64-core/Plugins/Plugin.cpp @@ -71,7 +71,7 @@ void CPlugins::PluginChanged(CPlugins * _this) WriteTrace(TracePlugins, TraceVerbose, "m_PluginDir: \"%s\" m_PluginDirSetting: \"%s\" changed: %s", _this->m_PluginDir.c_str(), g_Settings->LoadStringVal(_this->m_PluginDirSetting).c_str(), bDirChange ? "true" : "false"); if (bDirChange) { - WriteTrace(TracePlugins, TraceDebug, "plugin directory changed"); + WriteTrace(TracePlugins, TraceDebug, "Plugin directory changed"); bGfxChange = true; bAudioChange = true; bRspChange = true; @@ -81,13 +81,13 @@ void CPlugins::PluginChanged(CPlugins * _this) if (bGfxChange || bAudioChange || bRspChange || bContChange) { - if (bGfxChange) { WriteTrace(TracePlugins, TraceDebug, "Gfx plugin changed"); } + if (bGfxChange) { WriteTrace(TracePlugins, TraceDebug, "GFX plugin changed"); } if (bAudioChange) { WriteTrace(TracePlugins, TraceDebug, "Audio plugin changed"); } if (bRspChange) { WriteTrace(TracePlugins, TraceDebug, "RSP plugin changed"); } if (bContChange) { WriteTrace(TracePlugins, TraceDebug, "Controller plugin changed"); } if (g_Settings->LoadBool(GameRunning_CPU_Running)) { - //Ensure that base system actually exists before we go triggering the event + // Ensure that base system actually exists before we go triggering the event if (g_BaseSystem) { g_BaseSystem->ExternalEvent(SysEvent_ChangePlugins); @@ -129,7 +129,7 @@ static void LoadPlugin(SettingID PluginSettingID, SettingID PluginVerSettingID, delete plugin; plugin = nullptr; } - WriteTrace(TraceLevel, TraceDebug, "%s Loading Done", type); + WriteTrace(TraceLevel, TraceDebug, "%s Loading done", type); } else { @@ -146,7 +146,7 @@ void CPlugins::CreatePlugins(void) LoadPlugin(Game_Plugin_RSP, Plugin_RSP_CurVer, m_RSP, m_PluginDir.c_str(), m_RSPFile, TraceRSPPlugin, "RSP", m_SyncPlugins); LoadPlugin(Game_Plugin_Controller, Plugin_CONT_CurVer, m_Control, m_PluginDir.c_str(), m_ControlFile, TraceControllerPlugin, "Control", m_SyncPlugins); - //Enable debugger + // Enable debugger if (m_RSP != nullptr && m_RSP->EnableDebugging) { WriteTrace(TraceRSPPlugin, TraceInfo, "EnableDebugging starting"); @@ -182,9 +182,9 @@ void CPlugins::DestroyGfxPlugin(void) { return; } - WriteTrace(TraceGFXPlugin, TraceDebug, "before close"); + WriteTrace(TraceGFXPlugin, TraceDebug, "Before close"); m_Gfx->Close(m_MainWindow); - WriteTrace(TraceGFXPlugin, TraceInfo, "deleting"); + WriteTrace(TraceGFXPlugin, TraceInfo, "Deleting"); delete m_Gfx; WriteTrace(TraceGFXPlugin, TraceInfo, "m_Gfx deleted"); m_Gfx = nullptr; @@ -199,16 +199,16 @@ void CPlugins::DestroyAudioPlugin(void) { return; } - WriteTrace(TraceAudioPlugin, TraceDebug, "before close"); + WriteTrace(TraceAudioPlugin, TraceDebug, "Before close"); m_Audio->Close(m_MainWindow); - WriteTrace(TraceAudioPlugin, TraceDebug, "before delete"); + WriteTrace(TraceAudioPlugin, TraceDebug, "Before delete"); delete m_Audio; - WriteTrace(TraceAudioPlugin, TraceDebug, "after delete"); + WriteTrace(TraceAudioPlugin, TraceDebug, "After delete"); m_Audio = nullptr; - WriteTrace(TraceAudioPlugin, TraceDebug, "before DestroyRspPlugin"); + WriteTrace(TraceAudioPlugin, TraceDebug, "Before DestroyRspPlugin"); // g_Settings->UnknownSetting_AUDIO = nullptr; DestroyRspPlugin(); - WriteTrace(TraceAudioPlugin, TraceDebug, "after DestroyRspPlugin"); + WriteTrace(TraceAudioPlugin, TraceDebug, "After DestroyRspPlugin"); } void CPlugins::DestroyRspPlugin(void) @@ -217,12 +217,12 @@ void CPlugins::DestroyRspPlugin(void) { return; } - WriteTrace(TraceRSPPlugin, TraceDebug, "before close"); + WriteTrace(TraceRSPPlugin, TraceDebug, "Before close"); m_RSP->Close(m_MainWindow); - WriteTrace(TraceRSPPlugin, TraceDebug, "before delete"); + WriteTrace(TraceRSPPlugin, TraceDebug, "Before delete"); delete m_RSP; m_RSP = nullptr; - WriteTrace(TraceRSPPlugin, TraceDebug, "after delete"); + WriteTrace(TraceRSPPlugin, TraceDebug, "After delete"); // g_Settings->UnknownSetting_RSP = nullptr; } @@ -232,12 +232,12 @@ void CPlugins::DestroyControlPlugin(void) { return; } - WriteTrace(TraceControllerPlugin, TraceDebug, "before close"); + WriteTrace(TraceControllerPlugin, TraceDebug, "Before close"); m_Control->Close(m_MainWindow); - WriteTrace(TraceControllerPlugin, TraceDebug, "before delete"); + WriteTrace(TraceControllerPlugin, TraceDebug, "Before delete"); delete m_Control; m_Control = nullptr; - WriteTrace(TraceControllerPlugin, TraceDebug, "after delete"); + WriteTrace(TraceControllerPlugin, TraceDebug, "After delete"); // g_Settings->UnknownSetting_CTRL = nullptr; } @@ -275,24 +275,24 @@ void CPlugins::RomClosed(void) bool CPlugins::Initiate(CN64System * System) { WriteTrace(TracePlugins, TraceDebug, "Start"); - //Check to make sure we have the plugin available to be used + // Check to make sure we have the plugin available to be used if (m_Gfx == nullptr) { return false; } if (m_Audio == nullptr) { return false; } if (m_RSP == nullptr) { return false; } if (m_Control == nullptr) { return false; } - WriteTrace(TraceGFXPlugin, TraceDebug, "Gfx Initiate Starting"); + WriteTrace(TraceGFXPlugin, TraceDebug, "GFX initiate starting"); if (!m_Gfx->Initiate(System, m_MainWindow)) { return false; } - WriteTrace(TraceGFXPlugin, TraceDebug, "Gfx Initiate Done"); - WriteTrace(TraceAudioPlugin, TraceDebug, "Audio Initiate Starting"); + WriteTrace(TraceGFXPlugin, TraceDebug, "GFX initiate done"); + WriteTrace(TraceAudioPlugin, TraceDebug, "Audio initiate starting"); if (!m_Audio->Initiate(System, m_MainWindow)) { return false; } - WriteTrace(TraceAudioPlugin, TraceDebug, "Audio Initiate Done"); - WriteTrace(TraceControllerPlugin, TraceDebug, "Control Initiate Starting"); + WriteTrace(TraceAudioPlugin, TraceDebug, "Audio initiate done"); + WriteTrace(TraceControllerPlugin, TraceDebug, "Control initiate starting"); if (!m_Control->Initiate(System, m_MainWindow)) { return false; } - WriteTrace(TraceControllerPlugin, TraceDebug, "Control Initiate Done"); - WriteTrace(TraceRSPPlugin, TraceDebug, "RSP Initiate Starting"); + WriteTrace(TraceControllerPlugin, TraceDebug, "Control initiate done"); + WriteTrace(TraceRSPPlugin, TraceDebug, "RSP initiate starting"); if (!m_RSP->Initiate(this, System)) { return false; } - WriteTrace(TraceRSPPlugin, TraceDebug, "RSP Initiate Done"); + WriteTrace(TraceRSPPlugin, TraceDebug, "RSP initiate done"); WriteTrace(TracePlugins, TraceDebug, "Done"); m_initilized = true; return true; @@ -316,7 +316,7 @@ bool CPlugins::Reset(CN64System * System) bool bRspChange = _stricmp(m_RSPFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_RSP).c_str()) != 0; bool bContChange = _stricmp(m_ControlFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Controller).c_str()) != 0; - //if GFX and Audio has changed we also need to force reset of RSP + // If GFX and audio has changed we also need to force reset of RSP if (bGfxChange || bAudioChange) { bRspChange = true; @@ -331,27 +331,27 @@ bool CPlugins::Reset(CN64System * System) if (m_Gfx && bGfxChange) { - WriteTrace(TraceGFXPlugin, TraceDebug, "Gfx Initiate Starting"); + WriteTrace(TraceGFXPlugin, TraceDebug, "GFX initiate starting"); if (!m_Gfx->Initiate(System, m_MainWindow)) { return false; } - WriteTrace(TraceGFXPlugin, TraceDebug, "Gfx Initiate Done"); + WriteTrace(TraceGFXPlugin, TraceDebug, "GFX initiate done"); } if (m_Audio && bAudioChange) { - WriteTrace(TraceAudioPlugin, TraceDebug, "Audio Initiate Starting"); + WriteTrace(TraceAudioPlugin, TraceDebug, "Audio initiate starting"); if (!m_Audio->Initiate(System, m_MainWindow)) { return false; } - WriteTrace(TraceAudioPlugin, TraceDebug, "Audio Initiate Done"); + WriteTrace(TraceAudioPlugin, TraceDebug, "Audio initiate done"); } if (m_Control && bContChange) { - WriteTrace(TraceControllerPlugin, TraceDebug, "Control Initiate Starting"); + WriteTrace(TraceControllerPlugin, TraceDebug, "Control initiate starting"); if (!m_Control->Initiate(System, m_MainWindow)) { return false; } - WriteTrace(TraceControllerPlugin, TraceDebug, "Control Initiate Done"); + WriteTrace(TraceControllerPlugin, TraceDebug, "Control initiate done"); } if (m_RSP && bRspChange) { - WriteTrace(TraceRSPPlugin, TraceDebug, "RSP Initiate Starting"); + WriteTrace(TraceRSPPlugin, TraceDebug, "RSP initiate starting"); if (!m_RSP->Initiate(this, System)) { return false; } - WriteTrace(TraceRSPPlugin, TraceDebug, "RSP Initiate Done"); + WriteTrace(TraceRSPPlugin, TraceDebug, "RSP initiate done"); } if (System) @@ -440,7 +440,7 @@ void DummyFunction(void) bool CPlugins::CopyPlugins(const stdstr & DstDir) const { - //Copy GFX Plugin + // Copy GFX plugin CPath srcGfxPlugin(m_PluginDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str()); CPath dstGfxPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str()); dstGfxPlugin.SetName(stdstr_f("%s-copy", dstGfxPlugin.GetName().c_str()).c_str()); @@ -451,11 +451,11 @@ bool CPlugins::CopyPlugins(const stdstr & DstDir) const } if (!srcGfxPlugin.CopyTo(dstGfxPlugin)) { - WriteTrace(TracePlugins, TraceError, "failed to copy %s to %s", (const char *)srcGfxPlugin, (const char *)dstGfxPlugin); + WriteTrace(TracePlugins, TraceError, "Failed to copy %s to %s", (const char *)srcGfxPlugin, (const char *)dstGfxPlugin); return false; } - //Copy m_Audio Plugin + // Copy m_Audio plugin CPath srcAudioPlugin(m_PluginDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Audio).c_str()); CPath dstAudioPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Audio).c_str()); dstAudioPlugin.SetName(stdstr_f("%s-copy", dstAudioPlugin.GetName().c_str()).c_str()); @@ -467,7 +467,7 @@ bool CPlugins::CopyPlugins(const stdstr & DstDir) const { return false; } - //Copy RSP Plugin + // Copy RSP plugin CPath srcRSPPlugin(m_PluginDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_RSP).c_str()); CPath dstRSPPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_RSP).c_str()); dstRSPPlugin.SetName(stdstr_f("%s-copy", dstRSPPlugin.GetName().c_str()).c_str()); @@ -480,7 +480,7 @@ bool CPlugins::CopyPlugins(const stdstr & DstDir) const return false; } - //Copy Controller Plugin + // Copy Controller plugin CPath srcContPlugin(m_PluginDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Controller).c_str()); CPath dstContPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Controller).c_str()); dstContPlugin.SetName(stdstr_f("%s-copy", dstContPlugin.GetName().c_str()).c_str()); diff --git a/Source/Project64-core/Plugins/Plugin.h b/Source/Project64-core/Plugins/Plugin.h index 4a367dfb9..213e429c7 100644 --- a/Source/Project64-core/Plugins/Plugin.h +++ b/Source/Project64-core/Plugins/Plugin.h @@ -8,30 +8,28 @@ typedef struct { - uint16_t Version; /* Should be set to 1 */ - uint16_t Type; /* Set to PLUGIN_TYPE_GFX */ - char Name[100]; /* Name of the DLL */ + uint16_t Version; // Should be set to 1 + uint16_t Type; // Set to PLUGIN_TYPE_GFX + char Name[100]; // Name of the DLL - /* If DLL supports memory these memory options then set them to TRUE or FALSE - if it does not support it */ - int32_t NormalMemory; /* a normal BYTE array */ - int32_t MemoryBswaped; /* a normal BYTE array where the memory has been pre - bswap on a dword (32 bits) boundry */ + // If DLL supports these memory options then set them to TRUE or FALSE if it does not support it + int32_t NormalMemory; // A normal BYTE array + int32_t MemoryBswaped; // A normal BYTE array where the memory has been pre-bswap'd on a DWORD (32-bit) boundary } PLUGIN_INFO; #endif -// enum's +// Enums enum SETTING_DATA_TYPE { Data_DWORD_General = 0, // A uint32_t setting used anywhere Data_String_General = 1, // A string setting used anywhere Data_DWORD_Game = 2, // A uint32_t associated with the current game Data_String_Game = 3, // A string associated with the current game - Data_DWORD_RDB = 4, // A uint32_t associated with the current game in the rom database - Data_String_RDB = 5, // A string associated with the current game in the rom database - Data_DWORD_RDB_Setting = 6, // A uint32_t read from the rom database, with config file - Data_String_RDB_Setting = 7, // A string read from the rom database, with config file + Data_DWORD_RDB = 4, // A uint32_t associated with the current game in the ROM database + Data_String_RDB = 5, // A string associated with the current game in the ROM database + Data_DWORD_RDB_Setting = 6, // A uint32_t read from the ROM database, with config file + Data_String_RDB_Setting = 7, // A string read from the ROM database, with config file }; typedef struct @@ -117,7 +115,7 @@ class CPlugins : private CDebugSettings { public: - //Functions + // Functions CPlugins(SettingID PluginDirSetting, bool SyncPlugins); ~CPlugins(); @@ -160,7 +158,7 @@ private: SettingID m_PluginDirSetting; stdstr m_PluginDir; - //Plugins + // Plugins CGfxPlugin * m_Gfx; CAudioPlugin * m_Audio; CRSP_Plugin * m_RSP; @@ -174,6 +172,6 @@ private: bool m_SyncPlugins; }; -//Dummy Functions +// Dummy Functions void DummyCheckInterrupts(void); void DummyFunction(void); diff --git a/Source/Project64-core/Plugins/PluginBase.cpp b/Source/Project64-core/Plugins/PluginBase.cpp index eafdbe650..65fece0ae 100644 --- a/Source/Project64-core/Plugins/PluginBase.cpp +++ b/Source/Project64-core/Plugins/PluginBase.cpp @@ -30,14 +30,13 @@ bool CPlugin::Load(const char * FileName) { WriteTrace(PluginTraceType(), TraceDebug, "Loading: %s", FileName); - // Already loaded, so unload first. + // Already loaded, so unload first if (m_LibHandle != nullptr) { UnloadPlugin(); } - // Try to load the plugin DLL - //Try to load the DLL library + // Try to load the DLL library m_LibHandle = DynamicLibraryOpen(FileName, HaveDebugger()); WriteTrace(PluginTraceType(), TraceDebug, "Loaded: %s LibHandle: %X", FileName, m_LibHandle); @@ -139,9 +138,9 @@ bool CPlugin::Load(const char * FileName) if (PluginOpened) { - WriteTrace(PluginTraceType(), TraceDebug, "Before Plugin Opened"); + WriteTrace(PluginTraceType(), TraceDebug, "Before plugin opened"); PluginOpened(); - WriteTrace(PluginTraceType(), TraceDebug, "After Plugin Opened"); + WriteTrace(PluginTraceType(), TraceDebug, "After plugin opened"); } WriteTrace(PluginTraceType(), TraceDebug, "Loaded"); return true; @@ -166,14 +165,14 @@ void CPlugin::RomOpened(RenderWindow * Render) } } #else - Render = Render; // used just for andoid + Render = Render; // Used just for the Android port #endif if (RomOpen != nullptr) { - WriteTrace(PluginTraceType(), TraceDebug, "Before Rom Open"); + WriteTrace(PluginTraceType(), TraceDebug, "Before ROM open"); RomOpen(); - WriteTrace(PluginTraceType(), TraceDebug, "After Rom Open"); + WriteTrace(PluginTraceType(), TraceDebug, "After ROM open"); } m_RomOpen = true; @@ -190,7 +189,7 @@ void CPlugin::RomClose(RenderWindow * Render) if (m_PluginInfo.Type == PLUGIN_TYPE_GFX) { WriteTrace(PluginTraceType(), TraceDebug, "Render = %p", Render); - if (Render != nullptr) + if (Render != NULL) { WriteTrace(PluginTraceType(), TraceDebug, "Calling GfxThreadDone"); Render->GfxThreadDone(); @@ -198,13 +197,13 @@ void CPlugin::RomClose(RenderWindow * Render) } } #else - Render = Render; // used just for andoid + Render = Render; // Used just for the Android port #endif - WriteTrace(PluginTraceType(), TraceDebug, "Before Rom Close"); + WriteTrace(PluginTraceType(), TraceDebug, "Before ROM close"); RomClosed(); m_RomOpen = false; - WriteTrace(PluginTraceType(), TraceDebug, "After Rom Close"); + WriteTrace(PluginTraceType(), TraceDebug, "After ROM close"); } void CPlugin::GameReset(RenderWindow * Render) diff --git a/Source/Project64-core/Plugins/RSPPlugin.cpp b/Source/Project64-core/Plugins/RSPPlugin.cpp index 8adb242d6..a3cee4849 100644 --- a/Source/Project64-core/Plugins/RSPPlugin.cpp +++ b/Source/Project64-core/Plugins/RSPPlugin.cpp @@ -38,7 +38,7 @@ bool CRSP_Plugin::LoadFunctions(void) LoadFunction(EnableDebugging); if (EnableDebugging == nullptr) { EnableDebugging = DummyFunc1; } - //Make sure dll had all needed functions + // Make sure DLL had all needed functions if (DoRspCycles == nullptr) { UnloadPlugin(); return false; } if (InitiateRSP == nullptr) { UnloadPlugin(); return false; } if (RomClosed == nullptr) { UnloadPlugin(); return false; } @@ -49,7 +49,7 @@ bool CRSP_Plugin::LoadFunctions(void) if (PluginOpened == nullptr) { UnloadPlugin(); return false; } } - // Get debug info if able + // Get debug info if possible if (GetDebugInfo != nullptr) { GetDebugInfo(&m_RSPDebug); @@ -62,7 +62,7 @@ bool CRSP_Plugin::Initiate(CPlugins * Plugins, CN64System * System) WriteTrace(TraceRSPPlugin, TraceDebug, "Starting"); if (m_PluginInfo.Version == 1 || m_PluginInfo.Version == 0x100) { - WriteTrace(TraceRSPPlugin, TraceDebug, "Invalid Version: %X", m_PluginInfo.Version); + WriteTrace(TraceRSPPlugin, TraceDebug, "Invalid version: %X", m_PluginInfo.Version); WriteTrace(TraceRSPPlugin, TraceDebug, "Done (res: false)"); return false; } @@ -72,10 +72,9 @@ bool CRSP_Plugin::Initiate(CPlugins * Plugins, CN64System * System) typedef struct { void * hInst; - int MemoryBswaped; /* If this is set to TRUE, then the memory has been pre - bswap on a dword (32 bits) boundry */ - uint8_t * HEADER; // This is the rom header (first 40h bytes of the rom - // This will be in the same memory format as the rest of the memory. + int MemoryBswaped; // If this is set to TRUE, then the memory has been pre-bswap'd on a DWORD (32-bit) boundary + uint8_t * HEADER; // This is the ROM header (first 40h bytes of the ROM) + // This will be in the same memory format as the rest of the memory uint8_t * RDRAM; uint8_t * DMEM; uint8_t * IMEM; @@ -116,9 +115,9 @@ bool CRSP_Plugin::Initiate(CPlugins * Plugins, CN64System * System) Info.hInst = nullptr; #endif Info.CheckInterrupts = DummyCheckInterrupts; - Info.MemoryBswaped = (System == nullptr); // only true when the system's not yet loaded + Info.MemoryBswaped = (System == nullptr); // Only true when the system's not yet loaded - //Get Function from DLL + // Get function from DLL void(CALL *InitiateRSP) (RSP_INFO_1_3 RSP_Info, uint32_t * Cycles); LoadFunction(InitiateRSP); if (InitiateRSP == nullptr) @@ -128,8 +127,8 @@ bool CRSP_Plugin::Initiate(CPlugins * Plugins, CN64System * System) return false; } - // We are initializing the plugin before any rom is loaded so we do not have any correct - // parameters here.. just needed to we can config the DLL. + // We are initializing the plugin before any ROM is loaded so we do not have any correct + // parameters here, just needed to we can config the DLL if (System == nullptr) { static uint8_t Buffer[100]; @@ -214,8 +213,7 @@ bool CRSP_Plugin::Initiate(CPlugins * Plugins, CN64System * System) typedef struct { void * hInst; - int MemoryBswaped; /* If this is set to TRUE, then the memory has been pre - bswap on a dword (32 bits) boundry */ + int MemoryBswaped; // If this is set to TRUE, then the memory has been pre-bswap'd on a DWORD (32-bit) boundary uint8_t * RDRAM; uint8_t * DMEM; uint8_t * IMEM; @@ -256,9 +254,9 @@ bool CRSP_Plugin::Initiate(CPlugins * Plugins, CN64System * System) Info.hInst = nullptr; #endif Info.CheckInterrupts = DummyCheckInterrupts; - Info.MemoryBswaped = (System == nullptr); // only true when the system's not yet loaded + Info.MemoryBswaped = (System == nullptr); // Only true when the system's not yet loaded - //Get Function from DLL + // Get function from DLL void(CALL *InitiateRSP) (RSP_INFO_1_1 RSP_Info, uint32_t * Cycles); LoadFunction(InitiateRSP); if (InitiateRSP == nullptr) @@ -268,8 +266,8 @@ bool CRSP_Plugin::Initiate(CPlugins * Plugins, CN64System * System) return false; } - // We are initializing the plugin before any rom is loaded so we do not have any correct - // parameters here.. just needed to we can config the DLL. + // We are initializing the plugin before any ROM is loaded so we do not have any correct + // parameters here, just needed to we can config the DLL if (System == nullptr) { static uint8_t Buffer[100]; diff --git a/Source/Project64-core/Plugins/RSPPlugin.h b/Source/Project64-core/Plugins/RSPPlugin.h index d67c91f84..838376aa9 100644 --- a/Source/Project64-core/Plugins/RSPPlugin.h +++ b/Source/Project64-core/Plugins/RSPPlugin.h @@ -4,12 +4,12 @@ class CRSP_Plugin : public CPlugin { typedef struct { - /* Menu */ - /* Items should have an ID between 5001 and 5100 */ + // Menu + // Items should have an ID between 5001 and 5100 void * hRSPMenu; void(CALL *ProcessMenuItem) (int32_t ID); - /* Break Points */ + // Breakpoints int32_t UseBPoints; char BPPanelName[20]; void(CALL *Add_BPoint) (void); @@ -21,7 +21,7 @@ class CRSP_Plugin : public CPlugin void(CALL *RemoveBpoint) (void * hList, int32_t index); void(CALL *RemoveAllBpoint) (void); - /* RSP command Window */ + // RSP command window void(CALL *Enter_RSP_Commands_Window)(void); } RSPDEBUG_INFO; diff --git a/Source/Project64-core/Settings/GameSettings.h b/Source/Project64-core/Settings/GameSettings.h index a4e6548a9..f9cd485d9 100644 --- a/Source/Project64-core/Settings/GameSettings.h +++ b/Source/Project64-core/Settings/GameSettings.h @@ -44,7 +44,7 @@ protected: static void SpeedChanged(int32_t SpeedLimit); private: - //Settings that can be changed on the fly + // Settings that can be changed on the fly static bool m_UseHleGfx; static bool m_bRomInMemory; static bool m_RegCaching; diff --git a/Source/Project64-core/Settings/LoggingSettings.h b/Source/Project64-core/Settings/LoggingSettings.h index 4aad78949..e4a739e3e 100644 --- a/Source/Project64-core/Settings/LoggingSettings.h +++ b/Source/Project64-core/Settings/LoggingSettings.h @@ -8,7 +8,7 @@ public: inline static bool GenerateLog ( void ) { return m_GenerateLog; } - /* Registers Log */ + // Registers log inline static bool LogRDRamRegisters ( void ) { return m_LogRDRamRegisters; } inline static bool LogSPRegisters ( void ) { return m_LogSPRegisters; } inline static bool LogDPCRegisters ( void ) { return m_LogDPCRegisters; } @@ -20,7 +20,7 @@ public: inline static bool LogRDRAMInterface ( void ) { return m_LogRDRAMInterface; } inline static bool LogSerialInterface ( void ) { return m_LogSerialInterface; } - /* Pif Ram Log */ + // PIF RAM log inline static bool LogPRDMAOperations ( void ) { return m_LogPRDMAOperations; } inline static bool LogPRDirectMemLoads ( void ) { return m_LogPRDirectMemLoads; } inline static bool LogPRDMAMemLoads ( void ) { return m_LogPRDMAMemLoads; } @@ -28,7 +28,7 @@ public: inline static bool LogPRDMAMemStores ( void ) { return m_LogPRDMAMemStores; } inline static bool LogControllerPak ( void ) { return m_LogControllerPak; } - /* Special Log */ + // Special log inline static bool LogCP0changes ( void ) { return m_LogCP0changes; } inline static bool LogCP0reads ( void ) { return m_LogCP0reads; } inline static bool LogTLB ( void ) { return m_LogTLB; } @@ -43,7 +43,7 @@ private: static bool m_GenerateLog; - /* Registers Log */ + // Registers log static bool m_LogRDRamRegisters; static bool m_LogSPRegisters; static bool m_LogDPCRegisters; @@ -55,7 +55,7 @@ private: static bool m_LogRDRAMInterface; static bool m_LogSerialInterface; - /* Pif Ram Log */ + // PIF RAM log static bool m_LogPRDMAOperations; static bool m_LogPRDirectMemLoads; static bool m_LogPRDMAMemLoads; @@ -63,7 +63,7 @@ private: static bool m_LogPRDMAMemStores; static bool m_LogControllerPak; - /* Special Log */ + // Special log static bool m_LogCP0changes; static bool m_LogCP0reads; static bool m_LogTLB; diff --git a/Source/Project64-core/Settings/RecompilerSettings.h b/Source/Project64-core/Settings/RecompilerSettings.h index 2da1ef77d..5d2a124da 100644 --- a/Source/Project64-core/Settings/RecompilerSettings.h +++ b/Source/Project64-core/Settings/RecompilerSettings.h @@ -18,7 +18,7 @@ private: void RefreshSettings(void); - //Settings that can be changed on the fly + // Settings that can be changed on the fly static bool m_bShowRecompMemSize; static int32_t m_RefCount; diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-Application.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-Application.cpp index 8bcf404dc..ed31c33b7 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-Application.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-Application.cpp @@ -59,7 +59,7 @@ void CSettingTypeApplication::Initialize(void) CPath BaseDir(g_Settings->LoadStringVal(Cmd_BaseDirectory).c_str(), ""); if (!BaseDir.DirectoryExists()) { - WriteTrace(TraceAppInit, TraceDebug, "BaseDir does not exist. Doing nothing."); + WriteTrace(TraceAppInit, TraceDebug, "BaseDir does not exist. Doing nothing..."); WriteTrace(TraceAppInit, TraceDebug, "Done"); return; } @@ -184,7 +184,7 @@ bool CSettingTypeApplication::Load(uint32_t Index, std::string & Value) const return bRes; } -//return the default values +// Return the default values void CSettingTypeApplication::LoadDefault(uint32_t Index, bool & Value) const { if (m_DefaultSetting != Default_None) @@ -220,7 +220,7 @@ void CSettingTypeApplication::LoadDefault(uint32_t /*Index*/, std::string & Valu } } -//Update the settings +// Update the settings void CSettingTypeApplication::Save(uint32_t Index, bool Value) { bool indexed = g_Settings->IndexBasedSetting(m_DefaultSetting); diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-Application.h b/Source/Project64-core/Settings/SettingType/SettingsType-Application.h index 0728e7b60..bc8061190 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-Application.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-Application.h @@ -17,17 +17,17 @@ public: virtual SettingType GetSettingType(void) const { return SettingType_CfgFile; } virtual bool IsSettingSet(void) const; - //return the values + // Return the values virtual bool Load(uint32_t Index, bool & Value) const; virtual bool Load(uint32_t Index, uint32_t & Value) const; virtual bool Load(uint32_t Index, std::string & Value) const; - //return the default values + // Return the default values virtual void LoadDefault(uint32_t Index, bool & Value) const; virtual void LoadDefault(uint32_t Index, uint32_t & Value) const; virtual void LoadDefault(uint32_t Index, std::string & Value) const; - //Update the settings + // Update the settings virtual void Save(uint32_t Index, bool Value); virtual void Save(uint32_t Index, uint32_t Value); virtual void Save(uint32_t Index, const std::string & Value); @@ -36,7 +36,7 @@ public: // Delete the setting virtual void Delete(uint32_t Index); - // Initialize this class to use ini or registry + // Initialize this class to use the INI file or registry static void Initialize(void); static void CleanUp(void); static void Flush(void); diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-ApplicationIndex.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-ApplicationIndex.cpp index 81945b805..411e6a353 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-ApplicationIndex.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-ApplicationIndex.cpp @@ -44,7 +44,7 @@ bool CSettingTypeApplicationIndex::Load(uint32_t Index, std::string & Value) con return CSettingTypeApplication::Load(0, Value); } -//return the default values +// Return the default values void CSettingTypeApplicationIndex::LoadDefault(uint32_t Index, bool & Value) const { m_KeyNameIdex = stdstr_f("%s %d", m_KeyName.c_str(), Index); @@ -63,7 +63,7 @@ void CSettingTypeApplicationIndex::LoadDefault(uint32_t Index, std::string & Val CSettingTypeApplication::LoadDefault(0, Value); } -//Update the settings +// Update the settings void CSettingTypeApplicationIndex::Save(uint32_t Index, bool Value) { m_KeyNameIdex = stdstr_f("%s %d", m_KeyName.c_str(), Index); diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-ApplicationIndex.h b/Source/Project64-core/Settings/SettingType/SettingsType-ApplicationIndex.h index 6c00d21dc..c0b828e7b 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-ApplicationIndex.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-ApplicationIndex.h @@ -12,17 +12,17 @@ public: virtual bool IndexBasedSetting(void) const { return true; } - //return the values + // Return the values virtual bool Load(uint32_t Index, bool & Value) const; virtual bool Load(uint32_t Index, uint32_t & Value) const; virtual bool Load(uint32_t Index, std::string & Value) const; - //return the default values + // Return the default values virtual void LoadDefault(uint32_t Index, bool & Value) const; virtual void LoadDefault(uint32_t Index, uint32_t & Value) const; virtual void LoadDefault(uint32_t Index, std::string & Value) const; - //Update the settings + // Update the settings virtual void Save(uint32_t Index, bool Value); virtual void Save(uint32_t Index, uint32_t Value); virtual void Save(uint32_t Index, const std::string & Value); diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-ApplicationPath.h b/Source/Project64-core/Settings/SettingType/SettingsType-ApplicationPath.h index cd05486fd..72b8e59fd 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-ApplicationPath.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-ApplicationPath.h @@ -9,7 +9,7 @@ public: CSettingTypeApplicationPath(const char * Section, const char * Name, SettingID DefaultSetting ); bool IsSettingSet(void) const; - //return the values + // Return the values virtual bool Load ( int32_t Index, stdstr & Value ) const; private: diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-Base.h b/Source/Project64-core/Settings/SettingType/SettingsType-Base.h index dd9ca8a84..71cd26d84 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-Base.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-Base.h @@ -33,17 +33,17 @@ public: virtual bool IndexBasedSetting(void) const = 0; virtual bool IsSettingSet(void) const = 0; - //return the values + // Return the values virtual bool Load(uint32_t Index, bool & Value) const = 0; virtual bool Load(uint32_t Index, uint32_t & Value) const = 0; virtual bool Load(uint32_t Index, std::string & Value) const = 0; - //return the default values + // Return the default values virtual void LoadDefault(uint32_t Index, bool & Value) const = 0; virtual void LoadDefault(uint32_t Index, uint32_t & Value) const = 0; virtual void LoadDefault(uint32_t Index, std::string & Value) const = 0; - //Update the settings + // Update the settings virtual void Save(uint32_t Index, bool Value) = 0; virtual void Save(uint32_t Index, uint32_t Value) = 0; virtual void Save(uint32_t Index, const std::string & Value) = 0; diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-GameSetting.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-GameSetting.cpp index adad8ab98..efe46a83b 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-GameSetting.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-GameSetting.cpp @@ -119,7 +119,7 @@ bool CSettingTypeGame::Load(uint32_t Index, std::string & Value) const return CSettingTypeApplication::Load(Index, Value); } -//return the default values +// Return the default values void CSettingTypeGame::LoadDefault(uint32_t Index, bool & Value) const { if (m_RdbEditor && g_Settings->GetSettingType(m_DefaultSetting) == SettingType_RomDatabase) @@ -177,7 +177,7 @@ void CSettingTypeGame::LoadDefault(uint32_t Index, std::string & Value) const } } -//Update the settings +// Update the settings void CSettingTypeGame::Save(uint32_t Index, bool Value) { if (m_EraseDefaults) diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-GameSetting.h b/Source/Project64-core/Settings/SettingType/SettingsType-GameSetting.h index aa0a4b33b..95abb63b4 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-GameSetting.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-GameSetting.h @@ -17,17 +17,17 @@ public: static void Initialize( void ); static void CleanUp ( void ); - //return the values + // Return the values virtual bool Load (uint32_t Index, bool & Value) const; virtual bool Load (uint32_t Index, uint32_t & Value) const; virtual bool Load (uint32_t Index, std::string & Value) const; - //return the default values + // Return the default values virtual void LoadDefault (uint32_t Index, bool & Value) const; virtual void LoadDefault (uint32_t Index, uint32_t & Value) const; virtual void LoadDefault (uint32_t Index, std::string & Value) const; - //Update the settings + // Update the settings virtual void Save (uint32_t Index, bool Value); virtual void Save (uint32_t Index, uint32_t Value); virtual void Save (uint32_t Index, const std::string & Value); diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-GameSettingIndex.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-GameSettingIndex.cpp index 45641aeaa..258e28089 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-GameSettingIndex.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-GameSettingIndex.cpp @@ -53,7 +53,7 @@ bool CSettingTypeGameIndex::Load (uint32_t Index, std::string & Value ) const return CSettingTypeGame::Load(0,Value); } -//return the default values +// Return the default values void CSettingTypeGameIndex::LoadDefault (uint32_t Index, bool & Value ) const { m_KeyNameIdex = stdstr_f("%s%d%s",m_PreIndex.c_str(),Index,m_PostIndex.c_str()); @@ -70,7 +70,7 @@ void CSettingTypeGameIndex::LoadDefault (uint32_t /*Index*/, std::string & /*Val g_Notify->BreakPoint(__FILE__, __LINE__); } -//Update the settings +// Update the settings void CSettingTypeGameIndex::Save (uint32_t Index, bool Value ) { m_KeyNameIdex = stdstr_f("%s%d%s",m_PreIndex.c_str(),Index,m_PostIndex.c_str()); diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-GameSettingIndex.h b/Source/Project64-core/Settings/SettingType/SettingsType-GameSettingIndex.h index d0d67e769..f2c6cf956 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-GameSettingIndex.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-GameSettingIndex.h @@ -13,17 +13,17 @@ public: virtual bool IndexBasedSetting ( void ) const { return true; } virtual SettingType GetSettingType ( void ) const { return SettingType_GameSetting; } - //return the values + // Return the values virtual bool Load ( uint32_t Index, bool & Value ) const; virtual bool Load ( uint32_t Index, uint32_t & Value ) const; virtual bool Load ( uint32_t Index, std::string & Value ) const; - //return the default values + // Return the default values virtual void LoadDefault (uint32_t Index, bool & Value ) const; virtual void LoadDefault (uint32_t Index, uint32_t & Value ) const; virtual void LoadDefault (uint32_t Index, std::string & Value ) const; - //Update the settings + // Update the settings virtual void Save (uint32_t Index, bool Value ); virtual void Save (uint32_t Index, uint32_t Value ); virtual void Save (uint32_t Index, const std::string & Value ); diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RDBCpuType.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-RDBCpuType.cpp index 52a78859a..90b6be924 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RDBCpuType.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RDBCpuType.cpp @@ -37,7 +37,7 @@ bool CSettingTypeRDBCpuType::Load (uint32_t Index, uint32_t & Value ) const if (_stricmp(String,"Interpreter") == 0) { Value = CPU_Interpreter; } else if (_stricmp(String,"Recompiler") == 0) { Value = CPU_Recompiler; } else if (_stricmp(String,"SyncCores") == 0) { Value = CPU_SyncCores; } - else if (_stricmp(String,"default") == 0) + else if (_stricmp(String,"Default") == 0) { LoadDefault(Index,Value); return false; @@ -53,7 +53,7 @@ bool CSettingTypeRDBCpuType::Load (uint32_t /*Index*/, std::string & /*Value*/ ) return false; } -//return the default values +// Return the default values void CSettingTypeRDBCpuType::LoadDefault (uint32_t /*Index*/, bool & /*Value*/ ) const { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -77,7 +77,7 @@ void CSettingTypeRDBCpuType::LoadDefault (uint32_t /*Index*/, std::string & /*Va g_Notify->BreakPoint(__FILE__, __LINE__); } -//Update the settings +// Update the settings void CSettingTypeRDBCpuType::Save (uint32_t /*Index*/, bool /*Value*/ ) { g_Notify->BreakPoint(__FILE__, __LINE__); diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RDBCpuType.h b/Source/Project64-core/Settings/SettingType/SettingsType-RDBCpuType.h index b3befc7c0..7216bcd51 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RDBCpuType.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RDBCpuType.h @@ -8,17 +8,17 @@ public: CSettingTypeRDBCpuType(const char * Name, uint32_t DefaultValue ); ~CSettingTypeRDBCpuType(); - //return the values + // Return the values virtual bool Load (uint32_t Index, bool & Value ) const; virtual bool Load (uint32_t Index, uint32_t & Value ) const; virtual bool Load (uint32_t Index, std::string & Value ) const; - //return the default values + // Return the default values virtual void LoadDefault (uint32_t Index, bool & Value ) const; virtual void LoadDefault (uint32_t Index, uint32_t & Value ) const; virtual void LoadDefault (uint32_t Index, std::string & Value ) const; - //Update the settings + // Update the settings virtual void Save (uint32_t Index, bool Value ); virtual void Save (uint32_t Index, uint32_t Value ); virtual void Save (uint32_t Index, const std::string & Value ); diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RDBOnOff.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-RDBOnOff.cpp index 859bbcb62..1e92a6bc1 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RDBOnOff.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RDBOnOff.cpp @@ -51,7 +51,7 @@ bool CSettingTypeRDBOnOff::Load (uint32_t /*Index*/, std::string & /*Value*/ ) c return false; } -//return the default values +// Return the default values void CSettingTypeRDBOnOff::LoadDefault (uint32_t /*Index*/, bool & Value ) const { if (m_DefaultSetting != Default_None) @@ -75,7 +75,7 @@ void CSettingTypeRDBOnOff::LoadDefault (uint32_t /*Index*/, std::string & /*Valu g_Notify->BreakPoint(__FILE__, __LINE__); } -//Update the settings +// Update the settings void CSettingTypeRDBOnOff::Save (uint32_t /*Index*/, bool Value ) { m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),Value? "On" : "Off"); diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RDBOnOff.h b/Source/Project64-core/Settings/SettingType/SettingsType-RDBOnOff.h index 765805246..7a0b9a65d 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RDBOnOff.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RDBOnOff.h @@ -8,17 +8,17 @@ public: CSettingTypeRDBOnOff(const char * Name, uint32_t DefaultValue); ~CSettingTypeRDBOnOff(); - //return the values + // Return the values virtual bool Load (uint32_t Index, bool & Value) const; virtual bool Load (uint32_t Index, uint32_t & Value) const; virtual bool Load (uint32_t Index, std::string & Value) const; - //return the default values + // Return the default values virtual void LoadDefault (uint32_t Index, bool & Value) const; virtual void LoadDefault (uint32_t Index, uint32_t & Value) const; virtual void LoadDefault (uint32_t Index, std::string & Value) const; - //Update the settings + // Update the settings virtual void Save (uint32_t Index, bool Value ); virtual void Save (uint32_t Index, uint32_t Value ); virtual void Save (uint32_t Index, const std::string & Value ); diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RDBRamSize.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-RDBRamSize.cpp index 3de1b15da..7b7f5b115 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RDBRamSize.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RDBRamSize.cpp @@ -35,7 +35,7 @@ bool CSettingTypeRDBRDRamSize::Load (uint32_t Index, uint32_t & Value ) const LoadDefault(Index,ulValue); } Value = 0x400000; - if (ulValue == 8 || ulValue == 0x800000 || !existsInRdb) //default to 8MB if ROM is not in the RDB + if (ulValue == 8 || ulValue == 0x800000 || !existsInRdb) // Default to 8MB if ROM is not in the RDB { Value = 0x800000; } @@ -48,7 +48,7 @@ bool CSettingTypeRDBRDRamSize::Load (uint32_t /*Index*/, std::string & /*Value*/ return false; } -//return the default values +// Return the default values void CSettingTypeRDBRDRamSize::LoadDefault (uint32_t /*Index*/, bool & /*Value*/ ) const { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -64,7 +64,7 @@ void CSettingTypeRDBRDRamSize::LoadDefault (uint32_t /*Index*/, std::string & /* g_Notify->BreakPoint(__FILE__, __LINE__); } -//Update the settings +// Update the settings void CSettingTypeRDBRDRamSize::Save (uint32_t /*Index*/, bool /*Value*/ ) { g_Notify->BreakPoint(__FILE__, __LINE__); diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RDBRamSize.h b/Source/Project64-core/Settings/SettingType/SettingsType-RDBRamSize.h index a390c0684..09ce60995 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RDBRamSize.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RDBRamSize.h @@ -8,17 +8,17 @@ public: CSettingTypeRDBRDRamSize(const char * Name, uint32_t DefaultValue ); ~CSettingTypeRDBRDRamSize(); - //return the values + // Return the values virtual bool Load (uint32_t Index, bool & Value ) const; virtual bool Load (uint32_t Index, uint32_t & Value ) const; virtual bool Load (uint32_t Index, std::string & Value ) const; - //return the default values + // Return the default values virtual void LoadDefault (uint32_t Index, bool & Value ) const; virtual void LoadDefault (uint32_t Index, uint32_t & Value ) const; virtual void LoadDefault (uint32_t Index, std::string & Value ) const; - //Update the settings + // Update the settings virtual void Save (uint32_t Index, bool Value ); virtual void Save (uint32_t Index, uint32_t Value ); virtual void Save (uint32_t Index, const std::string & Value ); diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RDBSaveChip.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-RDBSaveChip.cpp index 4959a4523..17905fe0c 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RDBSaveChip.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RDBSaveChip.cpp @@ -34,11 +34,11 @@ bool CSettingTypeRDBSaveChip::Load (uint32_t Index, uint32_t & Value ) const } const char * String = strValue.c_str(); - if (_stricmp(String,"First Save Type") == 0) { Value = (uint32_t)SaveChip_Auto; } - else if (_stricmp(String,"4kbit Eeprom") == 0) { Value = SaveChip_Eeprom_4K; } - else if (_stricmp(String,"16kbit Eeprom") == 0) { Value = SaveChip_Eeprom_16K; } - else if (_stricmp(String,"Sram") == 0) { Value = SaveChip_Sram; } - else if (_stricmp(String,"FlashRam") == 0) { Value = SaveChip_FlashRam; } + if (_stricmp(String,"First save type") == 0) { Value = (uint32_t)SaveChip_Auto; } + else if (_stricmp(String,"4kbit EEPROM") == 0) { Value = SaveChip_Eeprom_4K; } + else if (_stricmp(String,"16kbit EEPROM") == 0) { Value = SaveChip_Eeprom_16K; } + else if (_stricmp(String,"SRAM") == 0) { Value = SaveChip_Sram; } + else if (_stricmp(String,"FlashRAM") == 0) { Value = SaveChip_FlashRam; } else if (_stricmp(String,"default") == 0) { LoadDefault(Index,Value); @@ -56,7 +56,7 @@ bool CSettingTypeRDBSaveChip::Load (uint32_t /*Index*/, std::string & /*Value*/ return false; } -//return the default values +// Return the default values void CSettingTypeRDBSaveChip::LoadDefault (uint32_t /*Index*/, bool & /*Value*/ ) const { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -80,7 +80,7 @@ void CSettingTypeRDBSaveChip::LoadDefault (uint32_t /*Index*/, std::string & /*V g_Notify->BreakPoint(__FILE__, __LINE__); } -//Update the settings +// Update the settings void CSettingTypeRDBSaveChip::Save (uint32_t /*Index*/, bool /*Value*/ ) { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -90,11 +90,11 @@ void CSettingTypeRDBSaveChip::Save (uint32_t /*Index*/, uint32_t Value ) { switch ((SAVE_CHIP_TYPE)Value) { - case SaveChip_Auto: m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),"First Save Type"); break; - case SaveChip_Eeprom_4K: m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),"4kbit Eeprom"); break; - case SaveChip_Eeprom_16K: m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),"16kbit Eeprom"); break; - case SaveChip_Sram: m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),"Sram"); break; - case SaveChip_FlashRam: m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),"FlashRam"); break; + case SaveChip_Auto: m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),"First save type"); break; + case SaveChip_Eeprom_4K: m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),"4kbit EEPROM"); break; + case SaveChip_Eeprom_16K: m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),"16kbit EEPROM"); break; + case SaveChip_Sram: m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),"SRAM"); break; + case SaveChip_FlashRam: m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),"FlashRAM"); break; default: g_Notify->BreakPoint(__FILE__, __LINE__); } diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RDBSaveChip.h b/Source/Project64-core/Settings/SettingType/SettingsType-RDBSaveChip.h index a462908a4..52d7b5fad 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RDBSaveChip.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RDBSaveChip.h @@ -8,17 +8,17 @@ public: CSettingTypeRDBSaveChip(const char * Name, uint32_t DefaultValue ); ~CSettingTypeRDBSaveChip(); - //return the values + // Return the values virtual bool Load (uint32_t Index, bool & Value ) const; virtual bool Load (uint32_t Index, uint32_t & Value ) const; virtual bool Load (uint32_t Index, std::string & Value ) const; - //return the default values + // Return the default values virtual void LoadDefault (uint32_t Index, bool & Value ) const; virtual void LoadDefault (uint32_t Index, uint32_t & Value ) const; virtual void LoadDefault (uint32_t Index, std::string & Value ) const; - //Update the settings + // Update the settings virtual void Save (uint32_t Index, bool Value ); virtual void Save (uint32_t Index, uint32_t Value ); virtual void Save (uint32_t Index, const std::string & Value ); diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RDBYesNo.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-RDBYesNo.cpp index 74d6ea8be..110246b6c 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RDBYesNo.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RDBYesNo.cpp @@ -35,14 +35,14 @@ bool CSettingTypeRDBYesNo::Load(uint32_t Index, bool & Value) const { Value = false; } - else if (_stricmp(String, "default") == 0) + else if (_stricmp(String, "Default") == 0) { LoadDefault(Index, Value); return false; } else { - WriteTrace(TraceSettings, TraceError, "Invalid Yes/No setting value (Section: %s Key: %s Value: %s)", m_SectionIdent->c_str(), String, m_KeyName.c_str(), strValue.c_str()); + WriteTrace(TraceSettings, TraceError, "Invalid yes/no setting value (Section: %s Key: %s Value: %s)", m_SectionIdent->c_str(), String, m_KeyName.c_str(), strValue.c_str()); LoadDefault(Index, Value); return false; } @@ -62,7 +62,7 @@ bool CSettingTypeRDBYesNo::Load(uint32_t /*Index*/, std::string & /*Value*/) con return false; } -//return the default values +// Return the default values void CSettingTypeRDBYesNo::LoadDefault(uint32_t /*Index*/, bool & Value) const { if (m_DefaultSetting != Default_None) @@ -87,7 +87,7 @@ void CSettingTypeRDBYesNo::LoadDefault(uint32_t /*Index*/, std::string & /*Value g_Notify->BreakPoint(__FILE__, __LINE__); } -//Update the settings +// Update the settings void CSettingTypeRDBYesNo::Save(uint32_t /*Index*/, bool Value) { m_SettingsIniFile->SaveString(m_SectionIdent->c_str(), m_KeyName.c_str(), Value ? "Yes" : "No"); diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RelativePath.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-RelativePath.cpp index a240386c9..75a213da0 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RelativePath.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RelativePath.cpp @@ -20,7 +20,7 @@ bool CSettingTypeRelativePath::Load(uint32_t /*Index*/, std::string & value) con return true; } -//return the default values +// Return the default values void CSettingTypeRelativePath::LoadDefault(uint32_t /*Index*/, bool & /*Value*/) const { g_Notify->BreakPoint(__FILE__, __LINE__); diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.cpp index 759267ae7..1ed885b19 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.cpp @@ -192,7 +192,7 @@ bool CSettingTypeRomDatabase::Load(uint32_t Index, std::string & Value) const return bRes; } -//return the default values +// Return the default values void CSettingTypeRomDatabase::LoadDefault(uint32_t /*Index*/, bool & Value) const { if (m_DefaultSetting != Default_None) @@ -229,7 +229,7 @@ void CSettingTypeRomDatabase::LoadDefault(uint32_t /*Index*/, std::string & Valu } } -//Update the settings +// Update the settings void CSettingTypeRomDatabase::Save(uint32_t /*Index*/, bool Value) { if (!g_Settings->LoadBool(Setting_RdbEditor)) diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.h b/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.h index 3d948ac1f..1b5752132 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.h @@ -18,17 +18,17 @@ public: virtual SettingType GetSettingType(void) const { return SettingType_RomDatabase; } virtual bool IsSettingSet(void) const { return false; } - //return the values + // Return the values virtual bool Load(uint32_t Index, bool & Value) const; virtual bool Load(uint32_t Index, uint32_t & Value) const; virtual bool Load(uint32_t Index, std::string & Value) const; - //return the default values + // Return the default values virtual void LoadDefault(uint32_t Index, bool & Value) const; virtual void LoadDefault(uint32_t Index, uint32_t & Value) const; virtual void LoadDefault(uint32_t Index, std::string & Value) const; - //Update the settings + // Update the settings virtual void Save(uint32_t Index, bool Value); virtual void Save(uint32_t Index, uint32_t Value); virtual void Save(uint32_t Index, const std::string & Value); diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabaseIndex.h b/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabaseIndex.h index 2f7da8ab8..521a6b40c 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabaseIndex.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabaseIndex.h @@ -13,17 +13,17 @@ public: virtual bool IndexBasedSetting ( void ) const { return true; } - //return the values + // Return the values virtual bool Load (uint32_t Index, bool & Value) const; virtual bool Load (uint32_t Index, uint32_t & Value) const; virtual bool Load (uint32_t Index, std::string & Value) const; - //return the default values + // Return the default values virtual void LoadDefault (uint32_t Index, bool & Value) const; virtual void LoadDefault (uint32_t Index, uint32_t & Value) const; virtual void LoadDefault (uint32_t Index, std::string & Value) const; - //Update the settings + // Update the settings virtual void Save (uint32_t Index, bool Value); virtual void Save (uint32_t Index, uint32_t Value); virtual void Save (uint32_t Index, const std::string & Value); diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RomSetting.h b/Source/Project64-core/Settings/SettingType/SettingsType-RomSetting.h index 147b7afa8..229758a4b 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RomSetting.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RomSetting.h @@ -12,12 +12,12 @@ public: virtual SettingLocation GetSettingsLocation ( void ) const { return SettingLocation_RomDatabase; } - //return the values + // Return the values virtual bool Load (int32_t Index, bool & Value) const; virtual bool Load (int32_t Index, uint32_t & Value) const; virtual bool Load (int32_t Index, stdstr & Value) const; - //Update the settings + // Update the settings virtual void Save (int32_t Index, bool Value); virtual void Save (int32_t Index, uint32_t Value); virtual void Save (int32_t Index, const stdstr & Value); diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-SelectedDirectory.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-SelectedDirectory.cpp index acc6a58e9..026791219 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-SelectedDirectory.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-SelectedDirectory.cpp @@ -44,7 +44,7 @@ bool CSettingTypeSelectedDirectory::Load(uint32_t /*Index*/, std::string & Value return g_Settings->LoadStringVal(DirSettingId, Value); } -//return the default values +// Return the default values void CSettingTypeSelectedDirectory::LoadDefault(uint32_t /*Index*/, bool & /*Value*/) const { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -60,7 +60,7 @@ void CSettingTypeSelectedDirectory::LoadDefault(uint32_t /*Index*/, std::string g_Notify->BreakPoint(__FILE__, __LINE__); } -//Update the settings +// Update the settings void CSettingTypeSelectedDirectory::Save(uint32_t /*Index*/, bool /*Value*/) { g_Notify->BreakPoint(__FILE__, __LINE__); diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-SelectedDirectory.h b/Source/Project64-core/Settings/SettingType/SettingsType-SelectedDirectory.h index 056fbc0e1..f76f3a9c4 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-SelectedDirectory.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-SelectedDirectory.h @@ -15,17 +15,17 @@ public: const char * GetName(void) const { return m_Name.c_str(); } - //return the values + // Return the values virtual bool Load(uint32_t Index, bool & Value) const; virtual bool Load(uint32_t Index, uint32_t & Value) const; virtual bool Load(uint32_t Index, std::string & Value) const; - //return the default values + // Return the default values virtual void LoadDefault(uint32_t Index, bool & Value) const; virtual void LoadDefault(uint32_t Index, uint32_t & Value) const; virtual void LoadDefault(uint32_t Index, std::string & Value) const; - //Update the settings + // Update the settings virtual void Save(uint32_t Index, bool Value); virtual void Save(uint32_t Index, uint32_t Value); virtual void Save(uint32_t Index, const std::string & Value); diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-TempBool.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-TempBool.cpp index 8b791d14b..25a203a15 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-TempBool.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-TempBool.cpp @@ -30,7 +30,7 @@ bool CSettingTypeTempBool::Load(uint32_t /*Index*/, std::string & /*Value*/) con return false; } -//return the default values +// Return the default values void CSettingTypeTempBool::LoadDefault(uint32_t /*Index*/, bool & /*Value*/) const { g_Notify->BreakPoint(__FILE__, __LINE__); diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-TempBool.h b/Source/Project64-core/Settings/SettingType/SettingsType-TempBool.h index 22f30e4f8..078592020 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-TempBool.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-TempBool.h @@ -15,17 +15,17 @@ public: const char * GetName(void) const { return m_Name.c_str(); } - //return the values + // Return the values bool Load(uint32_t Index, bool & Value) const; bool Load(uint32_t Index, uint32_t & Value) const; bool Load(uint32_t Index, std::string & Value) const; - //return the default values + // Return the default values void LoadDefault(uint32_t Index, bool & Value) const; void LoadDefault(uint32_t Index, uint32_t & Value) const; void LoadDefault(uint32_t Index, std::string & Value) const; - //Update the settings + // Update the settings void Save(uint32_t Index, bool Value); void Save(uint32_t Index, uint32_t Value); void Save(uint32_t Index, const std::string & Value); diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-TempNumber.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-TempNumber.cpp index 79c6b4cd8..1bee12c04 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-TempNumber.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-TempNumber.cpp @@ -29,7 +29,7 @@ bool CSettingTypeTempNumber::Load (uint32_t /*Index*/, std::string & /*Value*/ ) return false; } -//return the default values +// Return the default values void CSettingTypeTempNumber::LoadDefault (uint32_t /*Index*/, bool & /*Value*/ ) const { g_Notify->BreakPoint(__FILE__, __LINE__); diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-TempNumber.h b/Source/Project64-core/Settings/SettingType/SettingsType-TempNumber.h index b3b2ab559..11baa3a4f 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-TempNumber.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-TempNumber.h @@ -13,17 +13,17 @@ public: SettingType GetSettingType ( void ) const { return SettingType_NumberVariable; } bool IsSettingSet(void) const { return false; } - //return the values + // Return the values bool Load (uint32_t Index, bool & Value ) const; bool Load (uint32_t Index, uint32_t & Value ) const; bool Load (uint32_t Index, std::string & Value ) const; - //return the default values + // Return the default values void LoadDefault (uint32_t Index, bool & Value ) const; void LoadDefault (uint32_t Index, uint32_t & Value ) const; void LoadDefault (uint32_t Index, std::string & Value ) const; - //Update the settings + // Update the settings void Save (uint32_t Index, bool Value ); void Save (uint32_t Index, uint32_t Value ); void Save (uint32_t Index, const std::string & Value ); diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-TempString.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-TempString.cpp index 8d137588e..7fd2d7646 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-TempString.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-TempString.cpp @@ -28,7 +28,7 @@ bool CSettingTypeTempString::Load (uint32_t /*Index*/, std::string & Value ) con return true; } -//return the default values +// Return the default values void CSettingTypeTempString::LoadDefault (uint32_t /*Index*/, bool & /*Value*/ ) const { g_Notify->BreakPoint(__FILE__, __LINE__); diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-TempString.h b/Source/Project64-core/Settings/SettingType/SettingsType-TempString.h index c3dea1fdc..b99e3dbb9 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-TempString.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-TempString.h @@ -13,17 +13,17 @@ public: SettingType GetSettingType ( void ) const { return SettingType_StringVariable; } bool IsSettingSet(void) const { return false; } - //return the values + // Return the values bool Load (uint32_t Index, bool & Value ) const; bool Load (uint32_t Index, uint32_t & Value ) const; bool Load (uint32_t Index, std::string & Value ) const; - //return the default values + // Return the default values void LoadDefault (uint32_t Index, bool & Value ) const; void LoadDefault (uint32_t Index, uint32_t & Value ) const; void LoadDefault (uint32_t Index, std::string & Value ) const; - //Update the settings + // Update the settings void Save (uint32_t Index, bool Value ); void Save (uint32_t Index, uint32_t Value ); void Save (uint32_t Index, const std::string & Value ); diff --git a/Source/Project64-core/Settings/SettingsID.h b/Source/Project64-core/Settings/SettingsID.h index 4035df767..7962130a5 100644 --- a/Source/Project64-core/Settings/SettingsID.h +++ b/Source/Project64-core/Settings/SettingsID.h @@ -7,17 +7,17 @@ enum enum SettingID { - //Default values + // Default values Default_None, Default_Constant, - //Command Settings + // Command settings Cmd_BaseDirectory, Cmd_RomFile, Cmd_ComboDiskFile, Cmd_ShowHelp, - //Support Files + // Support files SupportFile_Settings, SupportFile_SettingsDefault, SupportFile_RomDatabase, @@ -39,7 +39,7 @@ enum SettingID SupportFile_ExtInfo, SupportFile_ExtInfoDefault, - //Settings + // Settings Setting_ApplicationName, Setting_UseFromRegistry, Setting_RdbEditor, @@ -61,7 +61,7 @@ enum SettingID Setting_Enhancement, Setting_DiskSaveType, - //Default Settings + // Default settings Default_RDRamSize, Default_UseHleGfx, Default_UseTlb, @@ -76,7 +76,7 @@ enum SettingID Default_SMM_Protect_Memory, Default_DiskSeekTiming, - //RDB Settings + // RDB settings Rdb_GoodName, Rdb_SaveChip, Rdb_CpuType, @@ -116,7 +116,7 @@ enum SettingID Rdb_RPCKey, Rdb_DiskSeekTiming, - //Individual Game Settings + // Individual game settings Game_IniKey, Game_File, Game_UniqueSaveDir, @@ -175,7 +175,7 @@ enum SettingID Game_RPCKey, Game_DiskSeekTiming, - // General Game running info + // General game running info GameRunning_LoadingInProgress, GameRunning_CPU_Running, GameRunning_CPU_Paused, @@ -185,13 +185,13 @@ enum SettingID GameRunning_ScreenHertz, GameRunning_InReset, - //User Interface + // User interface UserInterface_BasicMode, UserInterface_ShowCPUPer, UserInterface_DisplayFrameRate, UserInterface_FrameDisplayType, - //Directory Info + // Directory info Directory_Plugin, Directory_PluginInitial, Directory_PluginSelected, @@ -221,7 +221,7 @@ enum SettingID Directory_LogSelected, Directory_LogUseSelected, - //Rom List + // ROM list RomList_RomListCache, RomList_RomListCacheDefault, RomList_GameDir, @@ -233,12 +233,12 @@ enum SettingID RomList_7zipCache, RomList_7zipCacheDefault, - //File Info + // File info File_DiskIPLPath, File_DiskIPLUSAPath, File_DiskIPLTOOLPath, - //Debugger + // Debugger Debugger_Enabled, Debugger_ShowTLBMisses, Debugger_ShowUnhandledMemory, @@ -265,7 +265,7 @@ enum SettingID Debugger_IntrBreakpoints, Debugger_RcpIntrBreakpoints, - //Trace + // Trace Debugger_TraceMD5, Debugger_TraceThread, Debugger_TracePath, @@ -289,7 +289,7 @@ enum SettingID Debugger_TraceRomList, Debugger_TraceExceptionHandler, - //Plugins + // Plugins Plugin_RSP_Current, Plugin_RSP_CurVer, Plugin_GFX_Default, diff --git a/Source/Project64-input/Button.h b/Source/Project64-input/Button.h index 3e2546d86..daf06950e 100644 --- a/Source/Project64-input/Button.h +++ b/Source/Project64-input/Button.h @@ -6,7 +6,7 @@ enum BtnType { BTNTYPE_UNASSIGNED = 0, - // Joystick + // Joystick / controller BTNTYPE_JOYBUTTON = 1, BTNTYPE_JOYAXE = 2, BTNTYPE_JOYPOV = 3, diff --git a/Source/Project64-input/ControllerSpec1.1.h b/Source/Project64-input/ControllerSpec1.1.h index 5753c9141..359c31383 100644 --- a/Source/Project64-input/ControllerSpec1.1.h +++ b/Source/Project64-input/ControllerSpec1.1.h @@ -85,111 +85,109 @@ typedef struct void * hinst; int32_t MemoryBswaped; // Set this to true uint8_t * HEADER; // This is the ROM header (first 40h bytes of the ROM) - CONTROL * Controls; // A pointer to an array of 4 controllers .. eg: + CONTROL * Controls; // A pointer to an array of 4 controllers } CONTROL_INFO; /* Function: CloseDLL -Purpose: This function is called when the emulator is closing +Purpose: This function is called when the emulator is closing down allowing the DLL to de-initialize. -input: none -output: none +Input: None +Output: None */ EXPORT void CALL CloseDLL(void); /* Function: ControllerCommand -Purpose: To process the raw data that has just been sent to a +Purpose: To process the raw data that has just been sent to a specific controller. -input: - Controller Number (0 to 3) and -1 signaling end of +Input: Controller number (0 to 3) and -1 signaling end of processing the PIF RAM. - Pointer of data to be processed. -output: none - -note: This function is only needed if the DLL is allowing raw -data, or the plugin is set to raw - +Output: None +Note: This function is only needed if the DLL is allowing raw +data, or the plugin is set to raw. The data that is being processed looks like this: Initialize controller: 01 03 00 FF FF FF -Read controller: 01 04 01 FF FF FF FF +Read controller: 01 04 01 FF FF FF FF */ EXPORT void CALL ControllerCommand(int32_t Control, uint8_t * Command); /* Function: DllAbout -Purpose: This function is optional function that is provided +Purpose: This function is optional function that is provided to give further information about the DLL. -input: a handle to the window that calls this function -output: none +Input: A handle to the window that calls this function. +Output: None */ EXPORT void CALL DllAbout(void * hParent); /* Function: DllConfig -Purpose: This function is optional function that is provided -to allow the user to configure the DLL -input: a handle to the window that calls this function -output: none +Purpose: This function is optional function that is provided +to allow the user to configure the DLL. +Input: A handle to the window that calls this function. +Output: None */ EXPORT void CALL DllConfig(void * hParent); /* Function: DllTest -Purpose: This function is optional function that is provided -to allow the user to test the DLL -input: a handle to the window that calls this function -output: none +Purpose: This function is optional function that is provided +to allow the user to test the DLL. +Input: A handle to the window that calls this function. +Output: None */ EXPORT void CALL DllTest(void * hParent); /* Function: GetDllInfo -Purpose: This function allows the emulator to gather information +Purpose: This function allows the emulator to gather information about the DLL by filling in the PluginInfo structure. -input: a pointer to a PLUGIN_INFO structure that needs to be +Input: A pointer to a PLUGIN_INFO structure that needs to be filled by the function. (see def above) -output: none +Output: None */ EXPORT void CALL GetDllInfo(PLUGIN_INFO * PluginInfo); /* Function: GetKeys -Purpose: To get the current state of the controllers buttons. -input: - Controller Number (0 to 3) +Purpose: To get the current state of the controllers buttons. +Input: Controller number (0 to 3) - A pointer to a BUTTONS structure to be filled with the controller state. -output: none +Output: None */ EXPORT void CALL GetKeys(int32_t Control, BUTTONS * Keys); /* Function: InitiateControllers -Purpose: This function initializes how each of the controllers +Purpose: This function initializes how each of the controllers should be handled. -input: - The handle to the main window. +Input: The handle to the main window. - A controller structure that needs to be filled for the emulator to know how to handle each controller. -output: none +Output: None */ EXPORT void CALL InitiateControllers(CONTROL_INFO * ControlInfo); /* Function: ReadController -Purpose: To process the raw data in the PIF RAM that is about to +Purpose: To process the raw data in the PIF RAM that is about to be read. -input: - Controller Number (0 to 3) and -1 signaling end of +Input: Controller number (0 to 3) and -1 signaling end of processing the PIF RAM. - Pointer of data to be processed. -output: none -note: This function is only needed if the DLL is allowing raw +Output: None +Note: This function is only needed if the DLL is allowing raw data. */ @@ -197,39 +195,39 @@ EXPORT void CALL ReadController(int Control, uint8_t * Command); /* Function: RomClosed -Purpose: This function is called when a ROM is closed. -input: none -output: none +Purpose: This function is called when a ROM is closed. +Input: None +Output: None */ EXPORT void CALL RomClosed(void); /* Function: RomOpen -Purpose: This function is called when a ROM is open. (from the +Purpose: This function is called when a ROM is open. (from the emulation thread) -input: none -output: none +Input: None +Output: None */ EXPORT void CALL RomOpen(void); /* Function: WM_KeyDown -Purpose: To pass the WM_KeyDown message from the emulator to the +Purpose: To pass the WM_KeyDown message from the emulator to the plugin. -input: wParam and lParam of the WM_KEYDOWN message. -output: none +Input: wParam and lParam of the WM_KEYDOWN message. +Output: None */ EXPORT void CALL WM_KeyDown(uint32_t wParam, uint32_t lParam); /* Function: WM_KeyUp -Purpose: To pass the WM_KEYUP message from the emulator to the +Purpose: To pass the WM_KEYUP message from the emulator to the plugin. -input: wParam and lParam of the WM_KEYDOWN message. -output: none +Input: wParam and lParam of the WM_KEYDOWN message. +Output: None */ EXPORT void CALL WM_KeyUp(uint32_t wParam, uint32_t lParam); diff --git a/Source/Project64-input/InputMain.cpp b/Source/Project64-input/InputMain.cpp index db92d2a1c..90f5b2ab0 100644 --- a/Source/Project64-input/InputMain.cpp +++ b/Source/Project64-input/InputMain.cpp @@ -7,10 +7,10 @@ /* Function: CloseDLL -Purpose: This function is called when the emulator is closing +Purpose: This function is called when the emulator is closing down allowing the DLL to de-initialize. -input: none -output: none +Input: None +Output: None */ EXPORT void CALL CloseDLL(void) @@ -20,19 +20,17 @@ EXPORT void CALL CloseDLL(void) /* Function: ControllerCommand -Purpose: To process the raw data that has just been sent to a +Purpose: To process the raw data that has just been sent to a specific controller. -input: - Controller Number (0 to 3) and -1 signaling end of +Input: Controller number (0 to 3) and -1 signaling end of processing the PIF RAM. - Pointer of data to be processed. -output: none - -note: This function is only needed if the DLL is allowing raw -data, or the plugin is set to raw - -the data that is being processed looks like this: +Output: None +Note: This function is only needed if the DLL is allowing raw +data, or the plugin is set to raw. +The data that is being processed looks like this: Initialize controller: 01 03 00 FF FF FF -Read controller: 01 04 01 FF FF FF FF +Read controller: 01 04 01 FF FF FF FF */ EXPORT void CALL ControllerCommand(int32_t /*Control*/, uint8_t * /*Command*/) @@ -41,21 +39,22 @@ EXPORT void CALL ControllerCommand(int32_t /*Control*/, uint8_t * /*Command*/) /* Function: DllAbout -Purpose: This function is optional function that is provided +Purpose: This function is optional function that is provided to give further information about the DLL. -input: a handle to the window that calls this function -output: none -*******************************************************************/ -/*EXPORT void CALL DllAbout(void * hParent) -{ -}*/ +Input: A handle to the window that calls this function. +Output: None +*/ -/****************************************************************** +//EXPORT void CALL DllAbout(void * hParent) +//{ +//} + +/* Function: DllConfig -Purpose: This function is optional function that is provided -to allow the user to configure the DLL -input: a handle to the window that calls this function -output: none +Purpose: This function is optional function that is provided +to allow the user to configure the DLL. +Input: A handle to the window that calls this function. +Output: None */ #ifdef _WIN32 @@ -67,10 +66,10 @@ EXPORT void CALL DllConfig(void * hParent) /* Function: DllTest -Purpose: This function is optional function that is provided -to allow the user to test the DLL -input: a handle to the window that calls this function -output: none +Purpose: This function is optional function that is provided +to allow the user to test the DLL. +Input: A handle to the window that calls this function. +Output: None */ EXPORT void CALL DllTest(void * /*hParent*/) @@ -79,11 +78,11 @@ EXPORT void CALL DllTest(void * /*hParent*/) /* Function: GetDllInfo -Purpose: This function allows the emulator to gather information +Purpose: This function allows the emulator to gather information about the DLL by filling in the PluginInfo structure. -input: a pointer to a PLUGIN_INFO structure that needs to be +Input: A pointer to a PLUGIN_INFO structure that needs to be filled by the function. (see def above) -output: none +Output: None */ EXPORT void CALL GetDllInfo(PLUGIN_INFO * PluginInfo) @@ -101,11 +100,11 @@ EXPORT void CALL GetDllInfo(PLUGIN_INFO * PluginInfo) /* Function: GetKeys -Purpose: To get the current state of the controllers buttons. -input: - Controller Number (0 to 3) +Purpose: To get the current state of the controllers buttons. +Input: Controller number (0 to 3) - A pointer to a BUTTONS structure to be filled with the controller state. -output: none +Output: None */ EXPORT void CALL GetKeys(int32_t Control, BUTTONS * Keys) @@ -114,12 +113,12 @@ EXPORT void CALL GetKeys(int32_t Control, BUTTONS * Keys) } /* - Function: InitiateControllers - Purpose: This function initializes how each of the controllers - should be handled. - input: - A controller structure that needs to be filled for - the emulator to know how to handle each controller. - output: none +Function: InitiateControllers +Purpose: This function initializes how each of the controllers +should be handled. +Input: A controller structure that needs to be filled for +the emulator to know how to handle each controller. +Output: None */ EXPORT void CALL InitiateControllers(CONTROL_INFO * ControlInfo) @@ -132,13 +131,13 @@ EXPORT void CALL InitiateControllers(CONTROL_INFO * ControlInfo) /* Function: ReadController -Purpose: To process the raw data in the PIF RAM that is about to +Purpose: To process the raw data in the PIF RAM that is about to be read. -input: - Controller Number (0 to 3) and -1 signaling end of +Input: Controller number (0 to 3) and -1 signaling end of processing the PIF RAM. - Pointer of data to be processed. -output: none -note: This function is only needed if the DLL is allowing raw +Output: None +Note: This function is only needed if the DLL is allowing raw data. */ @@ -148,9 +147,9 @@ EXPORT void CALL ReadController(int /*Control*/, uint8_t * /*Command*/) /* Function: RomClosed -Purpose: This function is called when a ROM is closed. -input: none -output: none +Purpose: This function is called when a ROM is closed. +Input: None +Output: None */ EXPORT void CALL RomClosed(void) @@ -159,10 +158,10 @@ EXPORT void CALL RomClosed(void) /* Function: RomOpen -Purpose: This function is called when a ROM is open. (from the +Purpose: This function is called when a ROM is open. (from the emulation thread) -input: none -output: none +Input: None +Output: None */ EXPORT void CALL RomOpen(void) @@ -171,10 +170,10 @@ EXPORT void CALL RomOpen(void) /* Function: WM_KeyDown -Purpose: To pass the WM_KeyDown message from the emulator to the +Purpose: To pass the WM_KeyDown message from the emulator to the plugin. -input: wParam and lParam of the WM_KEYDOWN message. -output: none +Input: wParam and lParam of the WM_KEYDOWN message. +Output: None */ EXPORT void CALL WM_KeyDown(uint32_t /*wParam*/, uint32_t /*lParam*/) @@ -183,10 +182,10 @@ EXPORT void CALL WM_KeyDown(uint32_t /*wParam*/, uint32_t /*lParam*/) /* Function: WM_KeyUp -Purpose: To pass the WM_KEYUP message from the emulator to the +Purpose: To pass the WM_KEYUP message from the emulator to the plugin. -input: wParam and lParam of the WM_KEYDOWN message. -output: none +Input: wParam and lParam of the WM_KEYDOWN message. +Output: None */ EXPORT void CALL WM_KeyUp(uint32_t /*wParam*/, uint32_t /*lParam*/) diff --git a/Source/Project64-video/Renderer/OGLEScombiner.cpp b/Source/Project64-video/Renderer/OGLEScombiner.cpp index 7a0f52589..419e0e588 100644 --- a/Source/Project64-video/Renderer/OGLEScombiner.cpp +++ b/Source/Project64-video/Renderer/OGLEScombiner.cpp @@ -1,9 +1,10 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2003-2009 Sergey 'Gonetz' Lipski // Copyright(C) 2002 Dave2001 // GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html + #include #ifdef _WIN32 @@ -44,7 +45,7 @@ float fogColor[4]; int need_lambda[2]; float lambda_color[2][4]; -// shaders variables +// Shaders variables int need_to_compile; static GLuint g_program_object_default = 0; @@ -91,7 +92,7 @@ SHADER_VARYING "{ \n" ; -// using gl_FragCoord is terribly slow on ATI and varying variables don't work for some unknown +// TODO: Using gl_FragCoord is terribly slow on ATI and varying variables don't work for some unknown // reason, so we use the unused components of the texture2 coordinates static const char* g_fragment_shader_dither = " float dithx = (vTexCoord[2].b + 1.0)*0.5*1000.0; \n" @@ -150,16 +151,16 @@ SHADER_HEADER "attribute highp vec4 aMultiTexCoord0; \n" "attribute highp vec4 aMultiTexCoord1; \n" "attribute float aFog; \n" -"uniform vec3 vertexOffset; \n" //Moved some calculations from grDrawXXX to shader +"uniform vec3 vertexOffset; \n" // Moved some calculations from grDrawXXX to shaders "uniform vec4 textureSizes; \n" -"uniform vec3 fogModeEndScale; \n" //0 = Mode, 1 = gl_Fog.end, 2 = gl_Fog.scale +"uniform vec3 fogModeEndScale; \n" // 0 = Mode, 1 = gl_Fog.end, 2 = gl_Fog.scale "uniform mat4 rotation_matrix; \n" SHADER_VARYING " \n" "void main() \n" "{ \n" " float q = aPosition.w; \n" -" float invertY = vertexOffset.z; \n" //Usually 1.0 but -1.0 when rendering to a texture (see inverted_culling gfxRenderBuffer) +" float invertY = vertexOffset.z; \n" // Usually 1.0 but -1.0 when rendering to a texture (see inverted_culling gfxRenderBuffer) " gl_Position.x = (aPosition.x - vertexOffset.x) / vertexOffset.x; \n" " gl_Position.y = invertY *-(aPosition.y - vertexOffset.y) / vertexOffset.y;\n" " gl_Position.z = aPosition.z / Z_MAX; \n" @@ -232,12 +233,12 @@ void set_rotation_matrix(GLuint loc, CSettings::ScreenRotate_t rotate) { GLfloat mat[16]; - /* first setup everything which is the same everytime */ - /* (X, X, 0, 0) - * (X, X, 0, 0) - * (0, 0, 1, 0) - * (0, 0, 0, 1) - */ + // First setup everything which is the same every time + /*(X, X, 0, 0) + (X, X, 0, 0) + (0, 0, 1, 0) + (0, 0, 0, 1) + */ mat[0] = 1; mat[1] = 0; @@ -259,7 +260,7 @@ void set_rotation_matrix(GLuint loc, CSettings::ScreenRotate_t rotate) mat[14] = 0; mat[15] = 1; - /* now set the actual rotation */ + // Now set the actual rotation if (rotate == CSettings::Rotate_90) { mat[0] = 0; @@ -290,7 +291,7 @@ void init_combiner() glActiveTexture(GL_TEXTURE0); - // creating a fake texture + // Creating a fake texture glBindTexture(GL_TEXTURE_2D, default_texture); glTexImage2D(GL_TEXTURE_2D, 0, 3, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); @@ -302,7 +303,7 @@ void init_combiner() int texture0_location; int texture1_location; - // default shader + // Default shader std::string fragment_shader = g_fragment_shader_header; fragment_shader += g_fragment_shader_default; fragment_shader += g_fragment_shader_end; @@ -310,7 +311,7 @@ void init_combiner() GLuint fragment_shader_object = CompileShader(GL_FRAGMENT_SHADER, fragment_shader); GLuint vertex_shader_object = CompileShader(GL_VERTEX_SHADER, g_vertex_shader); - // default program + // Default program g_program_object_default = glCreateProgram(); glAttachShader(g_program_object_default, fragment_shader_object); glAttachShader(g_program_object_default, vertex_shader_object); @@ -367,7 +368,7 @@ void compile_chroma_shader() strcat(fragment_shader_chroma, "float alpha = constant_color.a; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "unknown compile_choma_shader_alpha : %x", chroma_other_alpha); + WriteTrace(TraceGlitch, TraceWarning, "Unknown compile_choma_shader_alpha: %x", chroma_other_alpha); } switch (chroma_other_color) @@ -382,7 +383,7 @@ void compile_chroma_shader() strcat(fragment_shader_chroma, "vec4 color = vec4(vec3(constant_color),alpha); \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "unknown compile_choma_shader_alpha : %x", chroma_other_color); + WriteTrace(TraceGlitch, TraceWarning, "Unknown compile_choma_shader_alpha: %x", chroma_other_color); } strcat(fragment_shader_chroma, "if (color.rgb == chroma_color.rgb) discard; \n"); @@ -671,7 +672,7 @@ void set_lambda() void gfxConstantColorValue(gfxColor_t value) { - WriteTrace(TraceGlitch, TraceDebug, "value: %d", value); + WriteTrace(TraceGlitch, TraceDebug, "Value: %d", value); switch (lfb_color_fmt) { case GFX_COLORFORMAT_ARGB: @@ -687,7 +688,7 @@ void gfxConstantColorValue(gfxColor_t value) g_texture_env_color[3] = (value & 0xFF) / 255.0f; break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxConstantColorValue: unknown color format : %x", lfb_color_fmt); + WriteTrace(TraceGlitch, TraceWarning, "gfxConstantColorValue: Unknown color format: %x", lfb_color_fmt); } vbo_draw(); @@ -710,7 +711,7 @@ void writeGLSLColorOther(int other) strcat(fragment_shader_color_combiner, "vec4 color_other = constant_color; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "unknown writeGLSLColorOther : %x", other); + WriteTrace(TraceGlitch, TraceWarning, "Unknown writeGLSLColorOther: %x", other); } } @@ -725,7 +726,7 @@ void writeGLSLColorLocal(int local) strcat(fragment_shader_color_combiner, "vec4 color_local = constant_color; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "unknown writeGLSLColorLocal : %x", local); + WriteTrace(TraceGlitch, TraceWarning, "Unknown writeGLSLColorLocal: %x", local); } } @@ -773,13 +774,13 @@ void writeGLSLColorFactor(int factor, int local, int need_local, int other, int strcat(fragment_shader_color_combiner, "vec4 color_factor = vec4(1.0) - vec4(ctexture1.a); \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "unknown writeGLSLColorFactor : %x", factor); + WriteTrace(TraceGlitch, TraceWarning, "Unknown writeGLSLColorFactor: %x", factor); } } void gfxColorCombine(gfxCombineFunction_t function, gfxCombineFactor_t factor, gfxCombineLocal_t local, gfxCombineOther_t other, bool invert) { - WriteTrace(TraceGlitch, TraceDebug, "function: %d factor: %d local: %d other: %d invert: %d", function, factor, local, other, invert); + WriteTrace(TraceGlitch, TraceDebug, "Function: %d factor: %d local: %d other: %d invert: %d", function, factor, local, other, invert); static int last_function = 0; static int last_factor = 0; static int last_local = 0; @@ -795,7 +796,7 @@ void gfxColorCombine(gfxCombineFunction_t function, gfxCombineFactor_t factor, g last_local = local; last_other = other; - if (invert) WriteTrace(TraceGlitch, TraceWarning, "gfxColorCombine : inverted result"); + if (invert) WriteTrace(TraceGlitch, TraceWarning, "gfxColorCombine: Inverted result"); color_combiner_key = function | (factor << 4) | (local << 8) | (other << 10); chroma_other_color = other; @@ -861,7 +862,7 @@ void gfxColorCombine(gfxCombineFunction_t function, gfxCombineFactor_t factor, g break; default: strcpy(fragment_shader_color_combiner, g_fragment_shader_default); - WriteTrace(TraceGlitch, TraceWarning, "gfxColorCombine : unknown function : %x", function); + WriteTrace(TraceGlitch, TraceWarning, "gfxColorCombine: Unknown function: %x", function); } //compile_shader(); need_to_compile = 1; @@ -882,7 +883,7 @@ case GFX_COMBINE_OTHER_CONSTANT: return GL_CONSTANT_ARB; break; default: -WriteTrace(TraceGlitch, TraceWarning, "unknwown other alpha source : %x", other); +WriteTrace(TraceGlitch, TraceWarning, "Unknown other alpha source: %x", other); } return 0; } @@ -898,7 +899,7 @@ case GFX_COMBINE_LOCAL_CONSTANT: return GL_CONSTANT_ARB; break; default: -WriteTrace(TraceGlitch, TraceWarning, "unknwown local alpha source : %x", local); +WriteTrace(TraceGlitch, TraceWarning, "Unknown local alpha source: %x", local); } return 0; } @@ -918,7 +919,7 @@ void writeGLSLAlphaOther(int other) strcat(fragment_shader_alpha_combiner, "float alpha_other = constant_color.a; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "unknown writeGLSLAlphaOther : %x", other); + WriteTrace(TraceGlitch, TraceWarning, "Unknown writeGLSLAlphaOther: %x", other); } } @@ -933,7 +934,7 @@ void writeGLSLAlphaLocal(int local) strcat(fragment_shader_alpha_combiner, "float alpha_local = constant_color.a; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "unknown writeGLSLAlphaLocal : %x", local); + WriteTrace(TraceGlitch, TraceWarning, "Unknown writeGLSLAlphaLocal: %x", local); } } @@ -978,13 +979,13 @@ void writeGLSLAlphaFactor(int factor, int local, int need_local, int other, int strcat(fragment_shader_alpha_combiner, "float alpha_factor = 1.0 - ctexture1.a; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "unknown writeGLSLAlphaFactor : %x", factor); + WriteTrace(TraceGlitch, TraceWarning, "Unknown writeGLSLAlphaFactor: %x", factor); } } void gfxAlphaCombine(gfxCombineFunction_t function, gfxCombineFactor_t factor, gfxCombineLocal_t local, gfxCombineOther_t other, bool invert) { - WriteTrace(TraceGlitch, TraceDebug, "function: %d factor: %d local: %d other: %d invert: %d", function, factor, local, other, invert); + WriteTrace(TraceGlitch, TraceDebug, "Function: %d factor: %d local: %d other: %d invert: %d", function, factor, local, other, invert); static int last_function = 0; static int last_factor = 0; static int last_local = 0; @@ -1000,7 +1001,7 @@ void gfxAlphaCombine(gfxCombineFunction_t function, gfxCombineFactor_t factor, g last_local = local; last_other = other; - if (invert) WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombine : inverted result"); + if (invert) WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombine: Inverted result"); alpha_combiner_key = function | (factor << 4) | (local << 8) | (other << 10); chroma_other_alpha = other; @@ -1066,7 +1067,7 @@ void gfxAlphaCombine(gfxCombineFunction_t function, gfxCombineFactor_t factor, g strcat(fragment_shader_alpha_combiner, "gl_FragColor.a = alpha_factor * (-alpha_local) + alpha_local; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombine : unknown function : %x", function); + WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombine: Unknown function: %x", function); } //compile_shader(); @@ -1138,7 +1139,7 @@ void writeGLSLTextureColorFactor(int num_tex, int factor) strcat(fragment_shader_texture1, "vec4 texture1_color_factor = vec4(1.0) - vec4(lambda); \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "unknown writeGLSLTextureColorFactor : %x", factor); + WriteTrace(TraceGlitch, TraceWarning, "Unknown writeGLSLTextureColorFactor: %x", factor); } } @@ -1207,7 +1208,7 @@ void writeGLSLTextureAlphaFactor(int num_tex, int factor) strcat(fragment_shader_texture1, "float texture1_alpha_factor = 1.0 - lambda; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "unknown writeGLSLTextureAlphaFactor : %x", factor); + WriteTrace(TraceGlitch, TraceWarning, "Unknown writeGLSLTextureAlphaFactor: %x", factor); } } @@ -1352,7 +1353,7 @@ void gfxTexCombine(gfxChipID_t tmu, gfxCombineFunction_t rgb_function, gfxCombin strcat(fragment_shader_texture0, "vec4 ctexture0 = readtex0; \n"); else strcat(fragment_shader_texture1, "vec4 ctexture1 = readtex1; \n"); - WriteTrace(TraceGlitch, TraceWarning, "grTextCombine : unknown rgb function : %x", rgb_function); + WriteTrace(TraceGlitch, TraceWarning, "grTextCombine: Unknown RGB function: %x", rgb_function); } if (rgb_invert) @@ -1444,7 +1445,7 @@ void gfxTexCombine(gfxChipID_t tmu, gfxCombineFunction_t rgb_function, gfxCombin strcat(fragment_shader_texture0, "ctexture0.a = readtex0.a; \n"); else strcat(fragment_shader_texture1, "ctexture1.a = ctexture0.a; \n"); - WriteTrace(TraceGlitch, TraceWarning, "grTextCombine : unknown alpha function : %x", alpha_function); + WriteTrace(TraceGlitch, TraceWarning, "grTextCombine: Unknown alpha function: %x", alpha_function); } if (alpha_invert) @@ -1477,7 +1478,7 @@ void gfxAlphaBlendFunction(gfxAlphaBlendFnc_t rgb_sf, gfxAlphaBlendFnc_t rgb_df, sfactorRGB = GL_ONE_MINUS_SRC_ALPHA; break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaBlendFunction : rgb_sf = %x", rgb_sf); + WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaBlendFunction: rgb_sf = %x", rgb_sf); } switch (rgb_df) @@ -1495,7 +1496,7 @@ void gfxAlphaBlendFunction(gfxAlphaBlendFnc_t rgb_sf, gfxAlphaBlendFnc_t rgb_df, dfactorRGB = GL_ONE_MINUS_SRC_ALPHA; break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaBlendFunction : rgb_df = %x", rgb_df); + WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaBlendFunction: rgb_df = %x", rgb_df); } switch (alpha_sf) @@ -1507,7 +1508,7 @@ void gfxAlphaBlendFunction(gfxAlphaBlendFnc_t rgb_sf, gfxAlphaBlendFnc_t rgb_df, sfactorAlpha = GL_ONE; break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaBlendFunction : alpha_sf = %x", alpha_sf); + WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaBlendFunction: alpha_sf = %x", alpha_sf); } switch (alpha_df) @@ -1519,7 +1520,7 @@ void gfxAlphaBlendFunction(gfxAlphaBlendFnc_t rgb_sf, gfxAlphaBlendFnc_t rgb_df, dfactorAlpha = GL_ONE; break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaBlendFunction : alpha_df = %x", alpha_df); + WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaBlendFunction: alpha_df = %x", alpha_df); } glEnable(GL_BLEND); glBlendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha); @@ -1527,14 +1528,14 @@ void gfxAlphaBlendFunction(gfxAlphaBlendFnc_t rgb_sf, gfxAlphaBlendFnc_t rgb_df, void gfxAlphaTestReferenceValue(gfxAlpha_t value) { - WriteTrace(TraceGlitch, TraceDebug, "value: %d", value); + WriteTrace(TraceGlitch, TraceDebug, "Value: %d", value); g_alpha_ref = value; gfxAlphaTestFunction(g_alpha_func); } void gfxAlphaTestFunction(gfxCmpFnc_t function) { - WriteTrace(TraceGlitch, TraceDebug, "function: %d", function); + WriteTrace(TraceGlitch, TraceDebug, "Function: %d", function); g_alpha_func = function; switch (function) { @@ -1551,17 +1552,17 @@ void gfxAlphaTestFunction(gfxCmpFnc_t function) return; break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaTestFunction : unknown function : %x", function); + WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaTestFunction: Unknown function: %x", function); } //glEnable(GL_ALPHA_TEST); g_alpha_test = true; } -// fog +// Fog void gfxFogMode(gfxFogMode_t mode) { - WriteTrace(TraceGlitch, TraceDebug, "mode: %d", mode); + WriteTrace(TraceGlitch, TraceDebug, "Mode: %d", mode); switch (mode) { case GFX_FOG_DISABLE: @@ -1579,7 +1580,7 @@ void gfxFogMode(gfxFogMode_t mode) g_fog_enabled = 2; break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxFogMode : unknown mode : %x", mode); + WriteTrace(TraceGlitch, TraceWarning, "gfxFogMode: Unknown mode: %x", mode); } need_to_compile = 1; } @@ -1610,14 +1611,14 @@ void gfxFogColorValue(gfxColor_t fogcolor) fogColor[3] = (fogcolor & 0xFF) / 255.0f; break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxFogColorValue: unknown color format : %x", lfb_color_fmt); + WriteTrace(TraceGlitch, TraceWarning, "gfxFogColorValue: Unknown color format: %x", lfb_color_fmt); } } -// chroma +// Chroma void gfxChromakeyMode(gfxChromakeyMode_t mode) { - WriteTrace(TraceGlitch, TraceDebug, "mode: %d", mode); + WriteTrace(TraceGlitch, TraceDebug, "Mode: %d", mode); switch (mode) { case GFX_CHROMAKEY_DISABLE: @@ -1627,14 +1628,14 @@ void gfxChromakeyMode(gfxChromakeyMode_t mode) g_chroma_enabled = true; break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxChromakeyMode : unknown mode : %x", mode); + WriteTrace(TraceGlitch, TraceWarning, "gfxChromakeyMode: Unknown mode: %x", mode); } need_to_compile = 1; } void gfxChromakeyValue(gfxColor_t value) { - WriteTrace(TraceGlitch, TraceDebug, "value: %d", value); + WriteTrace(TraceGlitch, TraceDebug, "Value: %d", value); int chroma_color_location; switch (lfb_color_fmt) @@ -1652,7 +1653,7 @@ void gfxChromakeyValue(gfxColor_t value) g_chroma_color[3] = 1.0;//(value & 0xFF) / 255.0f; break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxChromakeyValue: unknown color format : %x", lfb_color_fmt); + WriteTrace(TraceGlitch, TraceWarning, "gfxChromakeyValue: Unknown color format: %x", lfb_color_fmt); } vbo_draw(); chroma_color_location = glGetUniformLocation(g_program_object_default, "chroma_color"); @@ -1697,7 +1698,7 @@ void setPattern() void gfxStippleMode(gfxStippleMode_t mode) { - WriteTrace(TraceGlitch, TraceDebug, "mode: %d", mode); + WriteTrace(TraceGlitch, TraceDebug, "Mode: %d", mode); switch (mode) { case GFX_STIPPLE_DISABLE: @@ -1723,8 +1724,8 @@ void gfxStippleMode(gfxStippleMode_t mode) void gfxColorCombineExt(gfxCCUColor_t a, gfxCombineMode_t a_mode, gfxCCUColor_t b, gfxCombineMode_t b_mode, gfxCCUColor_t c, bool c_invert, gfxCCUColor_t d, bool d_invert, uint32_t shift, bool invert) { WriteTrace(TraceGlitch, TraceDebug, "a: %d a_mode: %d b: %d b_mode: %d c: %d c_invert: %d d: %d d_invert: %d shift: %d invert: %d", a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert); - if (invert) WriteTrace(TraceGlitch, TraceWarning, "gfxColorCombineExt : inverted result"); - if (shift) WriteTrace(TraceGlitch, TraceWarning, "gfxColorCombineExt : shift = %d", shift); + if (invert) WriteTrace(TraceGlitch, TraceWarning, "gfxColorCombineExt: Inverted result"); + if (shift) WriteTrace(TraceGlitch, TraceWarning, "gfxColorCombineExt: Shift = %d", shift); color_combiner_key = 0x80000000 | (a & 0x1F) | ((a_mode & 3) << 5) | ((b & 0x1F) << 7) | ((b_mode & 3) << 12) | @@ -1757,7 +1758,7 @@ void gfxColorCombineExt(gfxCCUColor_t a, gfxCombineMode_t a_mode, gfxCCUColor_t strcat(fragment_shader_color_combiner, "vec4 cs_a = ctexture1; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxColorCombineExt : a = %x", a); + WriteTrace(TraceGlitch, TraceWarning, "gfxColorCombineExt: a = %x", a); strcat(fragment_shader_color_combiner, "vec4 cs_a = vec4(0.0); \n"); } @@ -1776,7 +1777,7 @@ void gfxColorCombineExt(gfxCCUColor_t a, gfxCombineMode_t a_mode, gfxCCUColor_t strcat(fragment_shader_color_combiner, "vec4 c_a = -cs_a; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxColorCombineExt : a_mode = %x", a_mode); + WriteTrace(TraceGlitch, TraceWarning, "gfxColorCombineExt: a_mode = %x", a_mode); strcat(fragment_shader_color_combiner, "vec4 c_a = vec4(0.0); \n"); } @@ -1804,7 +1805,7 @@ void gfxColorCombineExt(gfxCCUColor_t a, gfxCombineMode_t a_mode, gfxCCUColor_t strcat(fragment_shader_color_combiner, "vec4 cs_b = ctexture1; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxColorCombineExt : b = %x", b); + WriteTrace(TraceGlitch, TraceWarning, "gfxColorCombineExt: b = %x", b); strcat(fragment_shader_color_combiner, "vec4 cs_b = vec4(0.0); \n"); } @@ -1823,7 +1824,7 @@ void gfxColorCombineExt(gfxCCUColor_t a, gfxCombineMode_t a_mode, gfxCCUColor_t strcat(fragment_shader_color_combiner, "vec4 c_b = -cs_b; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxColorCombineExt : b_mode = %x", b_mode); + WriteTrace(TraceGlitch, TraceWarning, "gfxColorCombineExt: b_mode = %x", b_mode); strcat(fragment_shader_color_combiner, "vec4 c_b = vec4(0.0); \n"); } @@ -1860,7 +1861,7 @@ void gfxColorCombineExt(gfxCCUColor_t a, gfxCombineMode_t a_mode, gfxCCUColor_t strcat(fragment_shader_color_combiner, "vec4 c_c = ctexture1; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxColorCombineExt : c = %x", c); + WriteTrace(TraceGlitch, TraceWarning, "gfxColorCombineExt: c = %x", c); strcat(fragment_shader_color_combiner, "vec4 c_c = vec4(0.0); \n"); } @@ -1885,7 +1886,7 @@ void gfxColorCombineExt(gfxCCUColor_t a, gfxCombineMode_t a_mode, gfxCCUColor_t strcat(fragment_shader_color_combiner, "vec4 c_d = vFrontColor; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxColorCombineExt : d = %x", d); + WriteTrace(TraceGlitch, TraceWarning, "gfxColorCombineExt: d = %x", d); strcat(fragment_shader_color_combiner, "vec4 c_d = vec4(0.0); \n"); } @@ -1900,8 +1901,8 @@ void gfxColorCombineExt(gfxCCUColor_t a, gfxCombineMode_t a_mode, gfxCCUColor_t void gfxAlphaCombineExt(gfxACUColor_t a, gfxCombineMode_t a_mode, gfxACUColor_t b, gfxCombineMode_t b_mode, gfxACUColor_t c, bool c_invert, gfxACUColor_t d, bool d_invert, uint32_t shift, bool invert) { WriteTrace(TraceGlitch, TraceDebug, "a: %d a_mode: %d b: %d b_mode: %d c: %d c_invert: %d d: %d d_invert: %d shift: %d invert: %d", a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert); - if (invert) WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombineExt : inverted result"); - if (shift) WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombineExt : shift = %d", shift); + if (invert) WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombineExt: Inverted result"); + if (shift) WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombineExt: Shift = %d", shift); alpha_combiner_key = 0x80000000 | (a & 0x1F) | ((a_mode & 3) << 5) | ((b & 0x1F) << 7) | ((b_mode & 3) << 12) | @@ -1925,7 +1926,7 @@ void gfxAlphaCombineExt(gfxACUColor_t a, gfxCombineMode_t a_mode, gfxACUColor_t strcat(fragment_shader_alpha_combiner, "float as_a = vFrontColor.a; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombineExt : a = %x", a); + WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombineExt: a = %x", a); strcat(fragment_shader_alpha_combiner, "float as_a = 0.0; \n"); } @@ -1944,7 +1945,7 @@ void gfxAlphaCombineExt(gfxACUColor_t a, gfxCombineMode_t a_mode, gfxACUColor_t strcat(fragment_shader_alpha_combiner, "float a_a = -as_a; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombineExt : a_mode = %x", a_mode); + WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombineExt: a_mode = %x", a_mode); strcat(fragment_shader_alpha_combiner, "float a_a = 0.0; \n"); } @@ -1963,7 +1964,7 @@ void gfxAlphaCombineExt(gfxACUColor_t a, gfxCombineMode_t a_mode, gfxACUColor_t strcat(fragment_shader_alpha_combiner, "float as_b = vFrontColor.a; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombineExt : b = %x", b); + WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombineExt: b = %x", b); strcat(fragment_shader_alpha_combiner, "float as_b = 0.0; \n"); } @@ -1982,7 +1983,7 @@ void gfxAlphaCombineExt(gfxACUColor_t a, gfxCombineMode_t a_mode, gfxACUColor_t strcat(fragment_shader_alpha_combiner, "float a_b = -as_b; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombineExt : b_mode = %x", b_mode); + WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombineExt: b_mode = %x", b_mode); strcat(fragment_shader_alpha_combiner, "float a_b = 0.0; \n"); } @@ -2010,7 +2011,7 @@ void gfxAlphaCombineExt(gfxACUColor_t a, gfxCombineMode_t a_mode, gfxACUColor_t strcat(fragment_shader_alpha_combiner, "float a_c = vFrontColor.a; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombineExt : c = %x", c); + WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombineExt: c = %x", c); strcat(fragment_shader_alpha_combiner, "float a_c = 0.0; \n"); } @@ -2032,7 +2033,7 @@ void gfxAlphaCombineExt(gfxACUColor_t a, gfxCombineMode_t a_mode, gfxACUColor_t strcat(fragment_shader_alpha_combiner, "float a_d = as_b; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombineExt : d = %x", d); + WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombineExt: d = %x", d); strcat(fragment_shader_alpha_combiner, "float a_d = 0.0; \n"); } @@ -2049,8 +2050,8 @@ void gfxTexColorCombineExt(gfxChipID_t tmu, gfxTCCUColor_t a, gfxCombineMode_t a int num_tex; WriteTrace(TraceGlitch, TraceDebug, "tmu: %d a: %d a_mode: %d b: %d b_mode: %d c: %d c_invert: %d d: %d d_invert: %d shift: %d invert: %d", tmu, a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert); - if (invert) WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt : inverted result"); - if (shift) WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt : shift = %d", shift); + if (invert) WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt: Inverted result"); + if (shift) WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt: Shift = %d", shift); if (tmu == GFX_TMU0) num_tex = 1; else num_tex = 0; @@ -2131,7 +2132,7 @@ void gfxTexColorCombineExt(gfxChipID_t tmu, gfxTCCUColor_t a, gfxCombineMode_t a strcat(fragment_shader_texture1, "vec4 ctex1s_a = vec4(ccolor1.a); \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt : a = %x", a); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt: a = %x", a); if (num_tex == 0) strcat(fragment_shader_texture0, "vec4 ctex0s_a = vec4(0.0); \n"); else @@ -2165,7 +2166,7 @@ void gfxTexColorCombineExt(gfxChipID_t tmu, gfxTCCUColor_t a, gfxCombineMode_t a strcat(fragment_shader_texture1, "vec4 ctex1_a = -ctex1s_a; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt : a_mode = %x", a_mode); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt: a_mode = %x", a_mode); if (num_tex == 0) strcat(fragment_shader_texture0, "vec4 ctex0_a = vec4(0.0); \n"); else @@ -2229,7 +2230,7 @@ void gfxTexColorCombineExt(gfxChipID_t tmu, gfxTCCUColor_t a, gfxCombineMode_t a strcat(fragment_shader_texture1, "vec4 ctex1s_b = ccolor1; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt : b = %x", b); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt: b = %x", b); if (num_tex == 0) strcat(fragment_shader_texture0, "vec4 ctex0s_b = vec4(0.0); \n"); else @@ -2263,7 +2264,7 @@ void gfxTexColorCombineExt(gfxChipID_t tmu, gfxTCCUColor_t a, gfxCombineMode_t a strcat(fragment_shader_texture1, "vec4 ctex1_b = -ctex1s_b; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt : b_mode = %x", b_mode); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt: b_mode = %x", b_mode); if (num_tex == 0) strcat(fragment_shader_texture0, "vec4 ctex0_b = vec4(0.0); \n"); else @@ -2339,7 +2340,7 @@ void gfxTexColorCombineExt(gfxChipID_t tmu, gfxTCCUColor_t a, gfxCombineMode_t a strcat(fragment_shader_texture1, "vec4 ctex1_c = ccolor1; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt : c = %x", c); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt: c = %x", c); if (num_tex == 0) strcat(fragment_shader_texture0, "vec4 ctex0_c = vec4(0.0); \n"); else @@ -2381,7 +2382,7 @@ void gfxTexColorCombineExt(gfxChipID_t tmu, gfxTCCUColor_t a, gfxCombineMode_t a strcat(fragment_shader_texture1, "vec4 ctex1_d = vec4(readtex1.a); \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt : d = %x", d); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt: d = %x", d); if (num_tex == 0) strcat(fragment_shader_texture0, "vec4 ctex0_d = vec4(0.0); \n"); else @@ -2408,8 +2409,8 @@ void gfxTexAlphaCombineExt(gfxChipID_t tmu, gfxTACUColor_t a, gfxCombineMode_t a int num_tex; WriteTrace(TraceGlitch, TraceDebug, "tmu: %d a: %d a_mode: %d b: %d b_mode: %d c: %d c_invert: %d d: %d d_invert: %d shift, invert: %d", tmu, a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert); - if (invert) WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt : inverted result"); - if (shift) WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt : shift = %d", shift); + if (invert) WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt: Inverted result"); + if (shift) WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt: Shift = %d", shift); if (tmu == GFX_TMU0) num_tex = 1; else num_tex = 0; @@ -2456,7 +2457,7 @@ void gfxTexAlphaCombineExt(gfxChipID_t tmu, gfxTACUColor_t a, gfxCombineMode_t a strcat(fragment_shader_texture1, "ctex1s_a.a = ccolor1.a; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt : a = %x", a); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt: a = %x", a); if (num_tex == 0) strcat(fragment_shader_texture0, "ctex0s_a.a = 0.0; \n"); else @@ -2490,7 +2491,7 @@ void gfxTexAlphaCombineExt(gfxChipID_t tmu, gfxTACUColor_t a, gfxCombineMode_t a strcat(fragment_shader_texture1, "ctex1_a.a = -ctex1s_a.a; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt : a_mode = %x", a_mode); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt: a_mode = %x", a_mode); if (num_tex == 0) strcat(fragment_shader_texture0, "ctex0_a.a = 0.0; \n"); else @@ -2524,7 +2525,7 @@ void gfxTexAlphaCombineExt(gfxChipID_t tmu, gfxTACUColor_t a, gfxCombineMode_t a strcat(fragment_shader_texture1, "ctex1s_b.a = ccolor1.a; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt : b = %x", b); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt: b = %x", b); if (num_tex == 0) strcat(fragment_shader_texture0, "ctex0s_b.a = 0.0; \n"); else @@ -2558,7 +2559,7 @@ void gfxTexAlphaCombineExt(gfxChipID_t tmu, gfxTACUColor_t a, gfxCombineMode_t a strcat(fragment_shader_texture1, "ctex1_b.a = -ctex1s_b.a; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt : b_mode = %x", b_mode); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt: b_mode = %x", b_mode); if (num_tex == 0) strcat(fragment_shader_texture0, "ctex0_b.a = 0.0; \n"); else @@ -2610,7 +2611,7 @@ void gfxTexAlphaCombineExt(gfxChipID_t tmu, gfxTACUColor_t a, gfxCombineMode_t a strcat(fragment_shader_texture1, "ctex1_c.a = ccolor1.a; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt : c = %x", c); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt: c = %x", c); if (num_tex == 0) strcat(fragment_shader_texture0, "ctex0_c.a = 0.0; \n"); else @@ -2658,7 +2659,7 @@ void gfxTexAlphaCombineExt(gfxChipID_t tmu, gfxTACUColor_t a, gfxCombineMode_t a strcat(fragment_shader_texture1, "ctex1_d.a = readtex1.a; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt : d = %x", d); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt: d = %x", d); if (num_tex == 0) strcat(fragment_shader_texture0, "ctex0_d.a = 0.0; \n"); else @@ -2724,7 +2725,7 @@ void gfxConstantColorValueExt(gfxChipID_t tmu, gfxColor_t value) } break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxConstantColorValue: unknown color format : %x", lfb_color_fmt); + WriteTrace(TraceGlitch, TraceWarning, "gfxConstantColorValue: Unknown color format: %x", lfb_color_fmt); } vbo_draw(); @@ -2738,4 +2739,4 @@ void gfxConstantColorValueExt(gfxChipID_t tmu, gfxColor_t value) ccolor1_location = glGetUniformLocation(g_program_object_default, "ccolor1"); glUniform4f(ccolor1_location, g_ccolor1[0], g_ccolor1[1], g_ccolor1[2], g_ccolor1[3]); } -} \ No newline at end of file +} diff --git a/Source/Project64-video/Renderer/OGLESgeometry.cpp b/Source/Project64-video/Renderer/OGLESgeometry.cpp index d62ffb4f2..137628a14 100644 --- a/Source/Project64-video/Renderer/OGLESgeometry.cpp +++ b/Source/Project64-video/Renderer/OGLESgeometry.cpp @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2003-2009 Sergey 'Gonetz' Lipski // Copyright(C) 2002 Dave2001 @@ -15,13 +15,13 @@ #include #define Z_MAX (65536.0f) -#define VERTEX_SIZE sizeof(gfxVERTEX) //Size of vertex struct +#define VERTEX_SIZE sizeof(gfxVERTEX) // Size of vertex struct int w_buffer_mode; int inverted_culling; gfxCullMode_t culling_mode; -#define VERTEX_BUFFER_SIZE 1500 //Max amount of vertices to buffer, this seems large enough. +#define VERTEX_BUFFER_SIZE 1500 // Max amount of vertices to buffer, this seems large enough static gfxVERTEX vertex_buffer[VERTEX_BUFFER_SIZE]; static int vertex_buffer_count = 0; static GLenum vertex_draw_mode; @@ -31,14 +31,14 @@ void vbo_draw() { if (vertex_buffer_count) { - WriteTrace(TraceGlide64, TraceDebug, "vertex_draw_mode: %d vertex_buffer_count: %d", vertex_draw_mode, vertex_buffer_count); + WriteTrace(TraceGlide64, TraceDebug, "Vertex_draw_mode: %d vertex_buffer_count: %d", vertex_draw_mode, vertex_buffer_count); glDrawArrays(vertex_draw_mode, 0, vertex_buffer_count); vertex_buffer_count = 0; - WriteTrace(TraceGlide64, TraceDebug, "done (glGetError() = %X)", glGetError()); + WriteTrace(TraceGlide64, TraceDebug, "Done (glGetError() = %X)", glGetError()); } } -//Buffer vertices instead of glDrawArrays(...) +// Buffer vertices instead of glDrawArrays(...) void vbo_buffer(GLenum mode, GLint first, GLsizei count, void* pointers) { if ((count != 3 && mode != GL_TRIANGLES) || vertex_buffer_count + count > VERTEX_BUFFER_SIZE) @@ -56,7 +56,7 @@ void vbo_buffer(GLenum mode, GLint first, GLsizei count, void* pointers) else { vertex_draw_mode = mode; - vbo_draw(); //Triangle fans and strips can't be joined as easily, just draw them straight away. + vbo_draw(); // Triangle fans and strips can't be joined as easily, just draw them straight away } } @@ -148,7 +148,7 @@ void gfxCullMode(gfxCullMode_t mode) glEnable(GL_CULL_FACE); break; default: - WriteTrace(TraceGlitch, TraceWarning, "unknown cull mode : %x", mode); + WriteTrace(TraceGlitch, TraceWarning, "Unknown cull mode : %x", mode); } } @@ -174,7 +174,7 @@ void gfxDepthBufferMode(gfxDepthBufferMode_t mode) w_buffer_mode = 0; break; default: - WriteTrace(TraceGlitch, TraceWarning, "unknown depth buffer mode : %x", mode); + WriteTrace(TraceGlitch, TraceWarning, "Unknown depth buffer mode : %x", mode); } } @@ -221,7 +221,7 @@ void gfxDepthBufferFunction(gfxCmpFnc_t function) break; default: - WriteTrace(TraceGlitch, TraceWarning, "unknown depth buffer function : %x", function); + WriteTrace(TraceGlitch, TraceWarning, "Unknown depth buffer function : %x", function); } } @@ -254,10 +254,10 @@ void gfxDepthBiasLevel(int32_t level) } } -// draw +// Draw void gfxDrawTriangle(const gfxVERTEX *a, const gfxVERTEX *b, const gfxVERTEX *c) { - WriteTrace(TraceGlitch, TraceDebug, "start"); + WriteTrace(TraceGlitch, TraceDebug, "Start"); vbo_enable(); if (nvidia_viewport_hack && !render_to_texture) { @@ -303,7 +303,7 @@ void gfxDrawVertexArray(gfxDrawMode_t mode, uint32_t Count, void *pointers2) if (mode != GFX_TRIANGLE_FAN) { - WriteTrace(TraceGlitch, TraceWarning, "gfxDrawVertexArray : unknown mode : %x", mode); + WriteTrace(TraceGlitch, TraceWarning, "gfxDrawVertexArray: Unknown mode : %x", mode); } vbo_enable(); @@ -340,6 +340,6 @@ void gfxDrawVertexArrayContiguous(gfxDrawMode_t mode, uint32_t Count, void *poin vbo_buffer(GL_TRIANGLE_FAN, 0, Count, pointers); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxDrawVertexArrayContiguous : unknown mode : %x", mode); + WriteTrace(TraceGlitch, TraceWarning, "gfxDrawVertexArrayContiguous: Unknown mode : %x", mode); } -} \ No newline at end of file +} diff --git a/Source/Project64-video/Renderer/OGLESglitchmain.cpp b/Source/Project64-video/Renderer/OGLESglitchmain.cpp index 0f6e41fd9..f2ebcc1c2 100644 --- a/Source/Project64-video/Renderer/OGLESglitchmain.cpp +++ b/Source/Project64-video/Renderer/OGLESglitchmain.cpp @@ -1,9 +1,10 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2003-2009 Sergey 'Gonetz' Lipski // Copyright(C) 2002 Dave2001 // GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html + #include #define SAVE_CBUFFER @@ -105,7 +106,7 @@ PFNGLGETINFOLOGARBPROC glGetInfoLogARB; PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB; PFNGLSECONDARYCOLOR3FPROC glSecondaryColor3f; -// FXT1,DXT1,DXT5 support - Hiroshi Morii +// FXT1,DXT1,DXT5 support - Hiroshi Morii // NOTE: Glide64 + GlideHQ use the following formats // GL_COMPRESSED_RGB_S3TC_DXT1_EXT // GL_COMPRESSED_RGBA_S3TC_DXT5_EXT @@ -135,10 +136,10 @@ int render_to_texture = 0; int texture_unit; int use_fbo; int buffer_cleared; -// ZIGGY -// to allocate a new static texture name, take the value (free_texture++) +// Comment by Ziggy +// To allocate a new static texture name, take the value (free_texture++) int free_texture; -int default_texture; // the infamous "32*1024*1024" is now configurable +int default_texture; // The infamous "32*1024*1024" is now configurable int current_texture; int depth_texture, color_texture; int glsl_support = 1; @@ -169,12 +170,12 @@ struct texbuf_t { uint32_t start, end; int fmt; }; -#define NB_TEXBUFS 128 // MUST be a power of two +#define NB_TEXBUFS 128 // Must be a power of two static texbuf_t texbufs[NB_TEXBUFS]; static int texbuf_i; -unsigned short frameBuffer[2048 * 2048 * 2]; // Support 2048x2048 screen resolution at 32 bits (RGBA) per pixel -unsigned short depthBuffer[2048 * 2048]; // Support 2048x2048 screen resolution at 16 bits (depth) per pixel +unsigned short frameBuffer[2048 * 2048 * 2]; // Support 2048x2048 screen resolution at 32-bits (RGBA) per pixel +unsigned short depthBuffer[2048 * 2048]; // Support 2048x2048 screen resolution at 16-bits (depth) per pixel void display_warning(const char *text, ...) { @@ -222,7 +223,7 @@ void gfxClipWindow(uint32_t minx, uint32_t miny, uint32_t maxx, uint32_t maxy) if (maxx < minx) maxx = minx; if (maxy < miny) maxy = miny; glScissor(minx, miny + g_viewport_offset, maxx - minx, maxy - miny); - //printf("gl scissor %d %d %d %d\n", minx, miny, maxx, maxy); + //printf("OpenGL scissor %d %d %d %d\n", minx, miny, maxx, maxy); } else { glScissor(minx, (g_viewport_offset)+g_height - maxy, maxx - minx, maxy - miny); @@ -314,9 +315,9 @@ bool gfxSstWinOpen(gfxColorFormat_t color_format, gfxOriginLocation_t origin_loc GLCache::ResetCache(); - // ZIGGY - // allocate static texture names - // the initial value should be big enough to support the maximal resolution + // Ziggy + // Allocate static texture names + // The initial value should be big enough to support the maximal resolution free_texture = 32 * 2048 * 2048; default_texture = free_texture++; color_texture = free_texture++; @@ -333,9 +334,9 @@ bool gfxSstWinOpen(gfxColorFormat_t color_format, gfxOriginLocation_t origin_loc glViewport(0, g_viewport_offset, g_width, g_height); lfb_color_fmt = color_format; - if (origin_location != GFX_ORIGIN_UPPER_LEFT) WriteTrace(TraceGlitch, TraceWarning, "origin must be in upper left corner"); - if (nColBuffers != 2) WriteTrace(TraceGlitch, TraceWarning, "number of color buffer is not 2"); - if (nAuxBuffers != 1) WriteTrace(TraceGlitch, TraceWarning, "number of auxiliary buffer is not 1"); + if (origin_location != GFX_ORIGIN_UPPER_LEFT) WriteTrace(TraceGlitch, TraceWarning, "Origin must be in upper left corner"); + if (nColBuffers != 2) WriteTrace(TraceGlitch, TraceWarning, "Number of color buffer is not 2"); + if (nAuxBuffers != 1) WriteTrace(TraceGlitch, TraceWarning, "Number of auxiliary buffer is not 1"); if (isExtensionSupported("GL_ARB_texture_env_combine") == 0 && isExtensionSupported("GL_EXT_texture_env_combine") == 0 && @@ -356,7 +357,7 @@ bool gfxSstWinOpen(gfxColorFormat_t color_format, gfxOriginLocation_t origin_loc nbAuxBuffers = 4; //glGetIntegerv(GL_AUX_BUFFERS, &nbAuxBuffers); if (nbAuxBuffers > 0) - printf("Congratulations, you have %d auxilliary buffers, we'll use them wisely !\n", nbAuxBuffers); + printf("Congratulations, you have %d auxiliary buffers, we'll use them wisely!\n", nbAuxBuffers); blend_func_separate_support = 1; packed_pixels_support = 0; @@ -475,7 +476,7 @@ bool gfxSstWinOpen(gfxColorFormat_t color_format, gfxOriginLocation_t origin_loc } if (!use_fbo && nbAuxBuffers == 0) { - // create the framebuffer saving texture + // Create the framebuffer saving texture int w = g_width, h = g_height; glBindTexture(GL_TEXTURE_2D, color_texture); if (!npot_support) { @@ -511,8 +512,8 @@ bool gfxSstWinClose() free_combiners(); #ifndef _WIN32 - try // I don't know why, but opengl can be killed before this function call when emulator is closed (Gonetz). - // ZIGGY : I found the problem : it is a function pointer, when the extension isn't supported , it is then zero, so just need to check the pointer prior to do the call. + try // I don't know why, but OpenGL can be killed before this function call when emulator is closed (Gonetz). + // Comment by Ziggy: I found the problem: It's a function pointer, when the extension isn't supported, it is then zero, so just need to check the pointer prior to do the call. { if (use_fbo) glBindFramebuffer(GL_FRAMEBUFFER, 0); @@ -536,7 +537,7 @@ bool gfxSstWinClose() free_textures(); #ifndef _WIN32 - // ZIGGY for some reasons, Pj64 doesn't like remove_tex on exit + // Ziggy for some reasons, Project64 doesn't like remove_tex on exit remove_tex(0, 0xfffffff); #endif @@ -558,9 +559,9 @@ void gfxTextureBufferExt(gfxChipID_t tmu, uint32_t startAddress, gfxLOD_t lodmin static int fbs_init = 0; WriteTrace(TraceGlitch, TraceDebug, "tmu: %d startAddress: %d lodmin: %d lodmax: %d aspect: %d fmt: %d evenOdd: %d", tmu, startAddress, lodmin, lodmax, aspect, fmt, evenOdd); - if (lodmin != lodmax) WriteTrace(TraceGlitch, TraceWarning, "gfxTextureBufferExt : loading more than one LOD"); + if (lodmin != lodmax) WriteTrace(TraceGlitch, TraceWarning, "gfxTextureBufferExt: Loading more than one LOD"); if (!use_fbo) { - if (!render_to_texture) { //initialization + if (!render_to_texture) { // Initialization return; } @@ -581,7 +582,7 @@ void gfxTextureBufferExt(gfxChipID_t tmu, uint32_t startAddress, gfxLOD_t lodmin updateTexture(); #ifdef SAVE_CBUFFER //printf("saving %dx%d\n", pBufferWidth, pBufferHeight); - // save color buffer + // Save color buffer if (nbAuxBuffers > 0) { //glDrawBuffer(GL_AUX0); //current_buffer = GL_AUX0; @@ -599,7 +600,7 @@ void gfxTextureBufferExt(gfxChipID_t tmu, uint32_t startAddress, gfxLOD_t lodmin //glReadBuffer(GL_BACK); glActiveTexture(texture_unit); glBindTexture(GL_TEXTURE_2D, color_texture); - // save incrementally the framebuffer + // Save incrementally the framebuffer if (save_w) { if (tw > save_w && th > save_h) { glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, save_h, @@ -652,7 +653,7 @@ void gfxTextureBufferExt(gfxChipID_t tmu, uint32_t startAddress, gfxLOD_t lodmin widtho = g_width / 2; heighto = g_height / 2; - // this could be improved, but might be enough as long as the set of + // This could be improved, but might be enough as long as the set of // texture buffer addresses stay small for (i = (texbuf_i - 1)&(NB_TEXBUFS - 1); i != texbuf_i; i = (i - 1)&(NB_TEXBUFS - 1)) if (texbufs[i].start == pBufferAddress) @@ -664,7 +665,7 @@ void gfxTextureBufferExt(gfxChipID_t tmu, uint32_t startAddress, gfxLOD_t lodmin texbuf_i = (texbuf_i + 1)&(NB_TEXBUFS - 1); //printf("texbuf %x fmt %x\n", pBufferAddress, fmt); - // ZIGGY it speeds things up to not delete the buffers + // (Comment by Ziggy) It speeds things up to not delete the buffers // a better thing would be to delete them *sometimes* // remove_tex(pBufferAddress+1, pBufferAddress + size); add_tex(pBufferAddress); @@ -679,7 +680,7 @@ void gfxTextureBufferExt(gfxChipID_t tmu, uint32_t startAddress, gfxLOD_t lodmin glScissor(0, g_viewport_offset, g_width, g_height); } else { - if (!render_to_texture) //initialization + if (!render_to_texture) // Initialization { if (!fbs_init) { @@ -687,7 +688,7 @@ void gfxTextureBufferExt(gfxChipID_t tmu, uint32_t startAddress, gfxLOD_t lodmin fbs_init = 1; nb_fb = 0; } - return; //no need to allocate FBO if render buffer is not texture buffer + return; // No need to allocate FBO if render buffer is not texture buffer } render_to_texture = 2; @@ -714,7 +715,7 @@ void gfxTextureBufferExt(gfxChipID_t tmu, uint32_t startAddress, gfxLOD_t lodmin { if (fbs[i].address == pBufferAddress) { - if (fbs[i].width == g_width && fbs[i].height == g_height) //select already allocated FBO + if (fbs[i].width == g_width && fbs[i].height == g_height) // Select already allocated FBO { glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, fbs[i].fbid); @@ -726,14 +727,14 @@ void gfxTextureBufferExt(gfxChipID_t tmu, uint32_t startAddress, gfxLOD_t lodmin if (fbs[i].buff_clear) { glDepthMask(1); - glClear(GL_DEPTH_BUFFER_BIT); //clear z-buffer only. we may need content, stored in the frame buffer + glClear(GL_DEPTH_BUFFER_BIT); // Clear z-buffer only. we may need content, stored in the frame buffer fbs[i].buff_clear = 0; } CHECK_FRAMEBUFFER_STATUS(); curBufferAddr = pBufferAddress; return; } - else //create new FBO at the same address, delete old one + else // Create new FBO at the same address, delete old one { glDeleteFramebuffers(1, &(fbs[i].fbid)); glDeleteRenderbuffers(1, &(fbs[i].zbid)); @@ -746,7 +747,7 @@ void gfxTextureBufferExt(gfxChipID_t tmu, uint32_t startAddress, gfxLOD_t lodmin } remove_tex(pBufferAddress, pBufferAddress + g_width*g_height * 2/*grTexFormatSize(fmt)*/); - //create new FBO + // Create new FBO glGenFramebuffers(1, &(fbs[nb_fb].fbid)); glGenRenderbuffers(1, &(fbs[nb_fb].zbid)); glBindRenderbuffer(GL_RENDERBUFFER, fbs[nb_fb].zbid); @@ -897,8 +898,8 @@ static void render_rectangle(int texture_number, glDisableVertexAttribArray(TEXCOORD_1_ATTR); glDisableVertexAttribArray(FOG_ATTR); - glVertexAttribPointer(POSITION_ATTR, 2, GL_FLOAT, false, 2, data); //Position - glVertexAttribPointer(TEXCOORD_0_ATTR, 2, GL_FLOAT, false, 2, &data[2]); //Tex + glVertexAttribPointer(POSITION_ATTR, 2, GL_FLOAT, false, 2, data); // Position + glVertexAttribPointer(TEXCOORD_0_ATTR, 2, GL_FLOAT, false, 2, &data[2]); // Tex glEnableVertexAttribArray(COLOUR_ATTR); glEnableVertexAttribArray(TEXCOORD_1_ATTR); @@ -974,20 +975,20 @@ void updateTexture() WriteTrace(TraceGlitch, TraceDebug, "pBufferAddress: %x", pBufferAddress); //printf("update texture %x\n", pBufferAddress); - // nothing changed, don't update the texture + // Nothing changed, don't update the texture if (!buffer_cleared) { - WriteTrace(TraceGlitch, TraceDebug, "update cancelled"); + WriteTrace(TraceGlitch, TraceDebug, "Update cancelled"); return; } //glPushAttrib(GL_ALL_ATTRIB_BITS); - // save result of render to texture into actual texture + // Save result of render to texture into actual texture //glReadBuffer(current_buffer); glActiveTexture(texture_unit); - // ZIGGY - // deleting the texture before resampling it increases speed on certain old - // nvidia cards (geforce 2 for example), unfortunatly it slows down a lot + // Ziggy + // Deleting the texture before resampling it increases speed on certain old + // Nvidia cards (GeForce 2 for example), unfortunately it slows down a lot // on newer cards. //glDeleteTextures( 1, &pBufferAddress ); glBindTexture(GL_TEXTURE_2D, pBufferAddress); @@ -1015,7 +1016,7 @@ void gfxRenderBuffer(gfxBuffer_t buffer) { updateTexture(); - // VP z fix + // VP Z fix //glMatrixMode(GL_MODELVIEW); //glLoadIdentity(); //glTranslatef(0, 0, 1-zscale); @@ -1038,7 +1039,7 @@ void gfxRenderBuffer(gfxBuffer_t buffer) #ifdef SAVE_CBUFFER if (!use_fbo && render_to_texture == 2) { - // restore color buffer + // Restore color buffer if (nbAuxBuffers > 0) { //glDrawBuffer(GL_BACK); current_buffer = GL_BACK; @@ -1079,7 +1080,7 @@ void gfxRenderBuffer(gfxBuffer_t buffer) } //glDrawBuffer(GL_BACK); break; - case 6: // RENDER TO TEXTURE + case 6: // Render to texture if (!render_to_texture) { savedWidth = g_width; @@ -1115,7 +1116,7 @@ void gfxRenderBuffer(gfxBuffer_t buffer) render_to_texture = 1; break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxRenderBuffer : unknown buffer : %x", buffer); + WriteTrace(TraceGlitch, TraceWarning, "gfxRenderBuffer: Unknown buffer : %x", buffer); } } @@ -1162,7 +1163,7 @@ void gfxBufferClear(gfxColor_t color, gfxAlpha_t alpha, uint32_t depth) alpha / 255.0f); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxBufferClear: unknown color format : %x", lfb_color_fmt); + WriteTrace(TraceGlitch, TraceWarning, "gfxBufferClear: Unknown color format : %x", lfb_color_fmt); } glClear(GL_COLOR_BUFFER_BIT); @@ -1173,7 +1174,7 @@ void gfxBufferClear(gfxColor_t color, gfxAlpha_t alpha, uint32_t depth) glClearDepthf(depth / 65535.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - // ZIGGY TODO check that color mask is on + // (Comment by Ziggy) TODO: Check that color mask is on buffer_cleared = 1; } @@ -1208,7 +1209,7 @@ void gfxBufferSwap(uint32_t swap_interval) fbs[i].buff_clear = 1; } -// frame buffer +// Frame buffer bool gfxLfbLock(gfxLock_t type, gfxBuffer_t buffer, gfxLfbWriteMode_t writeMode, gfxOriginLocation_t origin, bool pixelPipeline, gfxLfbInfo_t *info) { WriteTrace(TraceGlitch, TraceDebug, "type: %d buffer: %d writeMode: %d origin: %d pixelPipeline: %d", type, buffer, writeMode, origin, pixelPipeline); @@ -1372,7 +1373,7 @@ bool gfxLfbWriteRegion(gfxBuffer_t dst_buffer, uint32_t dst_x, uint32_t dst_y, g //glDrawBuffer(current_buffer); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxLfbWriteRegion : unknown buffer : %x", dst_buffer); + WriteTrace(TraceGlitch, TraceWarning, "gfxLfbWriteRegion: Unknown buffer : %x", dst_buffer); } if (dst_buffer != GFX_BUFFER_AUXBUFFER) @@ -1425,7 +1426,7 @@ bool gfxLfbWriteRegion(gfxBuffer_t dst_buffer, uint32_t dst_x, uint32_t dst_y, g } break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxLfbWriteRegion : unknown format : %d", src_format); + WriteTrace(TraceGlitch, TraceWarning, "gfxLfbWriteRegion: Unknown format : %d", src_format); } glBindTexture(GL_TEXTURE_2D, default_texture); @@ -1446,7 +1447,7 @@ bool gfxLfbWriteRegion(gfxBuffer_t dst_buffer, uint32_t dst_x, uint32_t dst_y, g float *buf = (float*)malloc(src_width*(src_height + (g_viewport_offset)) * sizeof(float)); if (src_format != GFX_LFBWRITEMODE_ZA16) - WriteTrace(TraceGlitch, TraceWarning, "unknown depth buffer write format:%x", src_format); + WriteTrace(TraceGlitch, TraceWarning, "Unknown depth buffer write format:%x", src_format); if (dst_x || dst_y) WriteTrace(TraceGlitch, TraceWarning, "dst_x:%d, dst_y:%d\n", dst_x, dst_y); @@ -1475,7 +1476,7 @@ bool gfxLfbWriteRegion(gfxBuffer_t dst_buffer, uint32_t dst_x, uint32_t dst_y, g return true; } -/* wrapper-specific glide extensions */ +// Wrapper-specific Glide extensions void gfxLoadGammaTable(uint32_t nentries, uint32_t *red, uint32_t *green, uint32_t *blue) { } @@ -1496,12 +1497,12 @@ void CHECK_FRAMEBUFFER_STATUS(void) WriteTrace(TraceGlitch, TraceDebug, "status: %X", status); switch (status) { case GL_FRAMEBUFFER_COMPLETE: - /*WriteTrace(TraceGlitch, TraceWarning, "framebuffer complete!\n");*/ + //WriteTrace(TraceGlitch, TraceWarning, "Frame buffer complete!\n"); break; case GL_FRAMEBUFFER_UNSUPPORTED: WriteTrace(TraceGlitch, TraceWarning, "framebuffer GL_FRAMEBUFFER_UNSUPPORTED_EXT\n"); - /* you gotta choose different formats */ - /*assert(0);*/ + // You have to choose different formats + //assert(0); break; case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: WriteTrace(TraceGlitch, TraceWarning, "framebuffer INCOMPLETE_ATTACHMENT\n"); @@ -1514,7 +1515,7 @@ void CHECK_FRAMEBUFFER_STATUS(void) break; default: break; - /* programming error; will fail on all hardware */ - /*assert(0);*/ + // Programming error; will fail on all hardware + //assert(0); } -} \ No newline at end of file +} diff --git a/Source/Project64-video/Renderer/OGLEStextures.cpp b/Source/Project64-video/Renderer/OGLEStextures.cpp index dec4bfd48..66ebb91d9 100644 --- a/Source/Project64-video/Renderer/OGLEStextures.cpp +++ b/Source/Project64-video/Renderer/OGLEStextures.cpp @@ -1,9 +1,10 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2003-2009 Sergey 'Gonetz' Lipski // Copyright(C) 2002 Dave2001 // GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html + #ifdef _WIN32 #include #else // _WIN32 @@ -98,7 +99,7 @@ void add_tex(unsigned int id) return; } while (aux->next != nullptr && aux->next->id < id) aux = aux->next; - // ZIGGY added this test so that add_tex now accept re-adding an existing texture + // (Comment by Ziggy) Added this test so that add_tex now accepts re-adding an existing texture if (aux->next != nullptr && aux->next->id == id) return; nbTex++; aux2 = aux->next; @@ -110,9 +111,9 @@ void add_tex(unsigned int id) void init_textures() { tex0_width = tex0_height = tex1_width = tex1_height = 2; - // ZIGGY because remove_tex isn't called (Pj64 doesn't like it), it's better + // TODO: (Comment by Ziggy) Because remove_tex isn't called (Project64 doesn't like it), it's better // to leave these so that they'll be reused (otherwise we have a memory leak) - // list = nullptr; + // list = NULL; // nbTex = 0; if (!texture) texture = (unsigned char*)malloc(2048 * 2048 * 4); @@ -121,7 +122,7 @@ void init_textures() void free_textures() { #ifndef WIN32 - // ZIGGY for some reasons, Pj64 doesn't like remove_tex on exit + // (Comment by Ziggy) For some reasons, Project64 doesn't like remove_tex on exit remove_tex(0x00000000, 0xFFFFFFFF); #endif if (texture != nullptr) { @@ -146,7 +147,7 @@ uint32_t gfxTexTextureMemRequired(uint32_t evenOdd, gfxTexInfo *info) { WriteTrace(TraceGlitch, TraceDebug, "evenOdd = %d", evenOdd); int width, height; - if (info->largeLodLog2 != info->smallLodLog2) WriteTrace(TraceGlitch, TraceWarning, "gfxTexTextureMemRequired : loading more than one LOD"); + if (info->largeLodLog2 != info->smallLodLog2) WriteTrace(TraceGlitch, TraceWarning, "gfxTexTextureMemRequired: Loading more than one LOD"); if (info->aspectRatioLog2 < 0) { @@ -184,7 +185,7 @@ uint32_t gfxTexTextureMemRequired(uint32_t evenOdd, gfxTexInfo *info) case GFX_TEXFMT_ARGB_CMP_FXT1: return ((((width + 0x7)&~0x7)*((height + 0x3)&~0x3)) >> 1); default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexTextureMemRequired : unknown texture format: %x", info->format); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexTextureMemRequired: Unknown texture format: %x", info->format); } return 0; } @@ -193,7 +194,7 @@ uint32_t gfxTexCalcMemRequired(gfxLOD_t lodmin, gfxLOD_t lodmax, gfxAspectRatio_ { WriteTrace(TraceGlitch, TraceDebug, "lodmin = %d, lodmax: %d aspect: %d fmt: %d", lodmin, lodmax, aspect, fmt); int width, height; - if (lodmax != lodmin) WriteTrace(TraceGlitch, TraceWarning, "gfxTexCalcMemRequired : loading more than one LOD"); + if (lodmax != lodmin) WriteTrace(TraceGlitch, TraceWarning, "gfxTexCalcMemRequired: Loading more than one LOD"); if (aspect < 0) { @@ -231,7 +232,7 @@ uint32_t gfxTexCalcMemRequired(gfxLOD_t lodmin, gfxLOD_t lodmax, gfxAspectRatio_ case GFX_TEXFMT_ARGB_CMP_FXT1: return ((((width + 0x7)&~0x7)*((height + 0x3)&~0x3)) >> 1); default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexTextureMemRequired : unknown texture format: %x", fmt); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexTextureMemRequired: Unknown texture format: %x", fmt); } return 0; } @@ -275,7 +276,7 @@ int grTexFormatSize(int fmt) factor = 8; break; default: - WriteTrace(TraceGlitch, TraceWarning, "grTexFormatSize : unknown texture format: %x", fmt); + WriteTrace(TraceGlitch, TraceWarning, "grTexFormatSize: Unknown texture format: %x", fmt); } return factor; } @@ -338,7 +339,7 @@ int grTexFormat2GLPackedFmt(int fmt, int * gltexfmt, int * glpixfmt, int * glpac // HACKALERT: 3Dfx Glide uses GFX_TEXFMT_ARGB_CMP_DXT1 for both opaque DXT1 and DXT1 with 1bit alpha. // GlideHQ compiled with GLIDE64_DXTN option enabled, uses opaqe DXT1 only. factor = 8; // HACKALERT: factor holds block bytes - *gltexfmt = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; // these variables aren't used + *gltexfmt = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; // These variables aren't used *glpixfmt = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; *glpackfmt = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; break; @@ -358,10 +359,10 @@ int grTexFormat2GLPackedFmt(int fmt, int * gltexfmt, int * glpixfmt, int * glpac factor = 8; *gltexfmt = GL_COMPRESSED_RGBA_FXT1_3DFX; *glpixfmt = GL_COMPRESSED_RGBA_FXT1_3DFX; - *glpackfmt = GL_COMPRESSED_RGBA_FXT1_3DFX; // XXX: what should we do about GL_COMPRESSED_RGB_FXT1_3DFX? + *glpackfmt = GL_COMPRESSED_RGBA_FXT1_3DFX; // What should we do about GL_COMPRESSED_RGB_FXT1_3DFX? break; default: - WriteTrace(TraceGlitch, TraceWarning, "grTexFormat2GLPackedFmt : unknown texture format: %x", fmt); + WriteTrace(TraceGlitch, TraceWarning, "grTexFormat2GLPackedFmt: Unknown texture format: %x", fmt); } return factor; */ @@ -374,7 +375,7 @@ void gfxTexDownloadMipMap(gfxChipID_t tmu, uint32_t startAddress, gfxMipMapLevel int factor; int glformat = 0; int gltexfmt, glpixfmt, glpackfmt; - if (info->largeLodLog2 != info->smallLodLog2) WriteTrace(TraceGlitch, TraceWarning, "gfxTexDownloadMipMap : loading more than one LOD"); + if (info->largeLodLog2 != info->smallLodLog2) WriteTrace(TraceGlitch, TraceWarning, "gfxTexDownloadMipMap: Loading more than one LOD"); if (info->aspectRatioLog2 < 0) { @@ -437,7 +438,7 @@ void gfxTexDownloadMipMap(gfxChipID_t tmu, uint32_t startAddress, gfxMipMapLevel { unsigned int texel = (unsigned int)((unsigned char*)info->data)[m]; #if 1 - /* accurate conversion */ + // Accurate conversion unsigned int texel_hi = (texel & 0x000000F0) << 20; unsigned int texel_low = texel & 0x0000000F; texel_low |= (texel_low << 4); @@ -466,7 +467,7 @@ void gfxTexDownloadMipMap(gfxChipID_t tmu, uint32_t startAddress, gfxMipMapLevel unsigned int G = texel & 0x000007E0; unsigned int R = texel & 0x0000001F; #if 0 - /* accurate conversion */ + // Accurate conversion ((unsigned int*)texture)[n] = 0xFF000000 | (R << 19) | ((R >> 2) << 16) | (G << 5) | ((G >> 9) << 8) | (B >> 8) | (B >> 13); #else ((unsigned int*)texture)[n] = 0xFF000000 | (R << 19) | (G << 5) | (B >> 8); @@ -489,7 +490,7 @@ void gfxTexDownloadMipMap(gfxChipID_t tmu, uint32_t startAddress, gfxMipMapLevel unsigned int G = texel & 0x000003E0; unsigned int R = texel & 0x0000001F; #if 0 - /* accurate conversion */ + // Accurate conversion ((unsigned int*)texture)[n] = A | (R << 19) | ((R >> 2) << 16) | (G << 6) | ((G >> 8) << 8) | (B >> 7) | (B >> 12); #else ((unsigned int*)texture)[n] = A | (R << 19) | (G << 6) | (B >> 7); @@ -528,7 +529,7 @@ void gfxTexDownloadMipMap(gfxChipID_t tmu, uint32_t startAddress, gfxMipMapLevel unsigned int G = texel & 0x000000F0; unsigned int R = texel & 0x0000000F; #if 0 - /* accurate conversion */ + // Accurate conversion ((unsigned int*)texture)[n] = (A << 16) | (A << 12) | (R << 20) | (R << 16) | (G << 8) | (G << 4) | (B >> 4) | (B >> 8); #else ((unsigned int*)texture)[n] = (A << 16) | (R << 20) | (G << 8) | (B >> 4); @@ -577,7 +578,7 @@ void gfxTexDownloadMipMap(gfxChipID_t tmu, uint32_t startAddress, gfxMipMapLevel break; */ default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexDownloadMipMap : unknown texture format: %x", info->format); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexDownloadMipMap: Unknown texture format: %x", info->format); factor = 0; } } @@ -693,7 +694,7 @@ void gfxTexDetailControl(gfxChipID_t tmu, int lod_bias, uint8_t detail_scale, fl { if (!lod_bias && !detail_scale && !detail_max) return; else - WriteTrace(TraceGlitch, TraceWarning, "gfxTexDetailControl : %d, %d, %f", lod_bias, detail_scale, detail_max); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexDetailControl: %d, %d, %f", lod_bias, detail_scale, detail_max); } lambda = detail_max; if (lambda > 1.0f) @@ -751,7 +752,7 @@ void gfxTexClampMode(gfxChipID_t tmu, gfxTextureClampMode_t s_clampmode, gfxText wrap_s0 = GL_MIRRORED_REPEAT; break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexClampMode : unknown s_clampmode : %x", s_clampmode); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexClampMode: Unknown s_clampmode : %x", s_clampmode); } switch (t_clampmode) { @@ -765,7 +766,7 @@ void gfxTexClampMode(gfxChipID_t tmu, gfxTextureClampMode_t s_clampmode, gfxText wrap_t0 = GL_MIRRORED_REPEAT; break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexClampMode : unknown t_clampmode : %x", t_clampmode); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexClampMode: Unknown t_clampmode : %x", t_clampmode); } glActiveTexture(GL_TEXTURE0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap_s0); @@ -785,7 +786,7 @@ void gfxTexClampMode(gfxChipID_t tmu, gfxTextureClampMode_t s_clampmode, gfxText wrap_s1 = GL_MIRRORED_REPEAT; break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexClampMode : unknown s_clampmode : %x", s_clampmode); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexClampMode: Unknown s_clampmode : %x", s_clampmode); } switch (t_clampmode) { @@ -799,7 +800,7 @@ void gfxTexClampMode(gfxChipID_t tmu, gfxTextureClampMode_t s_clampmode, gfxText wrap_t1 = GL_MIRRORED_REPEAT; break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexClampMode : unknown t_clampmode : %x", t_clampmode); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexClampMode: Unknown t_clampmode : %x", t_clampmode); } glActiveTexture(GL_TEXTURE1); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap_s1); diff --git a/Source/Project64-video/Renderer/OGLESwrappers.cpp b/Source/Project64-video/Renderer/OGLESwrappers.cpp index 303ea1590..1a95bcb5b 100644 --- a/Source/Project64-video/Renderer/OGLESwrappers.cpp +++ b/Source/Project64-video/Renderer/OGLESwrappers.cpp @@ -1,9 +1,10 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2003-2009 Sergey 'Gonetz' Lipski // Copyright(C) 2002 Dave2001 // GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html + #include #include "glitchmain.h" @@ -113,7 +114,7 @@ void GLCache::glActiveTexture(GLenum texture) { if (texture != m_cached_texture) { - WriteTrace(TraceOGLWrapper, TraceDebug, "texture: %d", texture); + WriteTrace(TraceOGLWrapper, TraceDebug, "Texture: %d", texture); vbo_draw(); ::glActiveTexture(texture); m_cached_texture = texture; @@ -126,7 +127,7 @@ void GLCache::glActiveTexture(GLenum texture) void GLCache::glBindTexture(GLenum target, GLuint texture) { - WriteTrace(TraceOGLWrapper, TraceDebug, "target: %d texture: %d", target, texture); + WriteTrace(TraceOGLWrapper, TraceDebug, "Target: %d texture: %d", target, texture); vbo_draw(); ::glBindTexture(target, texture); } @@ -135,7 +136,7 @@ void GLCache::glBlendEquation(GLenum mode) { if (mode != m_cached_mode) { - WriteTrace(TraceOGLWrapper, TraceDebug, "mode: %d", mode); + WriteTrace(TraceOGLWrapper, TraceDebug, "Mode: %d", mode); vbo_draw(); ::glBlendEquation(mode); m_cached_mode = mode; @@ -200,7 +201,7 @@ void GLCache::glClearDepthf(GLclampf depth) { if (depth != m_cached_depth) { - WriteTrace(TraceOGLWrapper, TraceDebug, "depth: %d", depth); + WriteTrace(TraceOGLWrapper, TraceDebug, "Depth: %d", depth); vbo_draw(); ::glClearDepthf(depth); m_cached_depth = depth; @@ -215,7 +216,7 @@ void GLCache::glCullFace(GLenum mode) { if (mode != m_cached_CullFace_mode) { - WriteTrace(TraceOGLWrapper, TraceDebug, "mode: %d", mode); + WriteTrace(TraceOGLWrapper, TraceDebug, "Mode: %d", mode); vbo_draw(); ::glCullFace(mode); m_cached_CullFace_mode = mode; @@ -230,7 +231,7 @@ void GLCache::glDepthFunc(GLenum func) { if (func != m_cached_func) { - WriteTrace(TraceOGLWrapper, TraceDebug, "func: %d", func); + WriteTrace(TraceOGLWrapper, TraceDebug, "Function: %d", func); vbo_draw(); ::glDepthFunc(func); m_cached_func = func; @@ -245,7 +246,7 @@ void GLCache::glDepthMask(GLboolean flag) { if (flag != m_cached_DepthMask_flag) { - WriteTrace(TraceOGLWrapper, TraceDebug, "flag: %d", (int)flag); + WriteTrace(TraceOGLWrapper, TraceDebug, "Flag: %d", (int)flag); vbo_draw(); ::glDepthMask(flag); m_cached_DepthMask_flag = flag; @@ -336,7 +337,7 @@ void GLCache::glFrontFace(GLenum mode) { if (mode != m_cached_FrontFace_mode) { - WriteTrace(TraceOGLWrapper, TraceDebug, "mode: %d", mode); + WriteTrace(TraceOGLWrapper, TraceDebug, "Mode: %d", mode); vbo_draw(); ::glFrontFace(mode); m_cached_FrontFace_mode = mode; @@ -352,7 +353,7 @@ void GLCache::glPolygonOffset(GLfloat factor, GLfloat units) if (factor != m_cached_factor || units != m_cached_units) { vbo_draw(); - WriteTrace(TraceOGLWrapper, TraceDebug, "factor: %f units: %f", factor, units); + WriteTrace(TraceOGLWrapper, TraceDebug, "Factor: %f units: %f", factor, units); ::glPolygonOffset(factor, units); m_cached_factor = factor; m_cached_units = units; @@ -403,7 +404,7 @@ void GLCache::glUseProgram(GLuint program) { if (program != m_cached_program) { - WriteTrace(TraceOGLWrapper, TraceDebug, "program: %d", program); + WriteTrace(TraceOGLWrapper, TraceDebug, "Program: %d", program); vbo_draw(); ::glUseProgram(program); m_cached_program = program; @@ -428,6 +429,6 @@ void GLCache::glViewport(GLint x, GLint y, GLsizei width, GLsizei height) } else { - WriteTrace(TraceOGLWrapper, TraceDebug, "ignored x: %d, y: %d, width: %d, height: %d", x, y, width, height); + WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored x: %d, y: %d, width: %d, height: %d", x, y, width, height); } } diff --git a/Source/Project64-video/Renderer/OGLESwrappers.h b/Source/Project64-video/Renderer/OGLESwrappers.h index bfe0a6b2a..0e42b12e2 100644 --- a/Source/Project64-video/Renderer/OGLESwrappers.h +++ b/Source/Project64-video/Renderer/OGLESwrappers.h @@ -1,9 +1,10 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2003-2009 Sergey 'Gonetz' Lipski // Copyright(C) 2002 Dave2001 // GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html + #pragma once #include #include diff --git a/Source/Project64-video/Renderer/OGLcombiner.cpp b/Source/Project64-video/Renderer/OGLcombiner.cpp index ea21c9e74..5b9db790b 100644 --- a/Source/Project64-video/Renderer/OGLcombiner.cpp +++ b/Source/Project64-video/Renderer/OGLcombiner.cpp @@ -1,9 +1,10 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2003-2009 Sergey 'Gonetz' Lipski // Copyright(C) 2002 Dave2001 // GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html + #include #ifdef _WIN32 @@ -42,7 +43,7 @@ static float nearF; int need_lambda[2]; float lambda_color[2][4]; -// shaders variables +// Shaders variables int need_to_compile; static GLhandleARB fragment_shader_object; @@ -81,7 +82,7 @@ static const char* fragment_shader_header = "{ \n" ; -// using gl_FragCoord is terribly slow on ATI and varying variables don't work for some unknown +// Using gl_FragCoord is terribly slow on ATI and varying variables don't work for some unknown // reason, so we use the unused components of the texture2 coordinates static const char* fragment_shader_dither = " float dithx = (gl_TexCoord[2].b + 1.0)*0.5*1000.0; \n" @@ -139,12 +140,12 @@ static const char* vertex_shader = " gl_FrontColor = gl_Color; \n" " gl_TexCoord[0] = gl_MultiTexCoord0; \n" " gl_TexCoord[1] = gl_MultiTexCoord1; \n" -" float f = (gl_Fog.end - gl_SecondaryColor.r) * gl_Fog.scale; \n" // fog value passed through secondary color (workaround ATI bug) +" float f = (gl_Fog.end - gl_SecondaryColor.r) * gl_Fog.scale; \n" // TODO: Fog value passed through secondary color (workaround ATI bug) " f = clamp(f, 0.0, 1.0); \n" -" gl_TexCoord[0].b = f; \n" // various data passed through -" gl_TexCoord[2].b = gl_Vertex.x; \n" // texture coordinates -" gl_TexCoord[2].a = gl_Vertex.y; \n" // again it is the only way -"} \n" // i've found to get it working fast with ATI drivers +" gl_TexCoord[0].b = f; \n" // Various data passed through +" gl_TexCoord[2].b = gl_Vertex.x; \n" // Texture coordinates +" gl_TexCoord[2].a = gl_Vertex.y; \n" // Again it is the only way +"} \n" // I've found to get it working fast with ATI drivers ; static char fragment_shader_color_combiner[1024]; @@ -189,7 +190,7 @@ void init_combiner() glActiveTextureARB(GL_TEXTURE0_ARB); glEnable(GL_TEXTURE_2D); - // creating a fake texture + // Creating a fake texture glBindTexture(GL_TEXTURE_2D, default_texture); glTexImage2D(GL_TEXTURE_2D, 0, 3, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); @@ -204,11 +205,11 @@ void init_combiner() char *fragment_shader; int log_length; - // depth shader + // Depth shader fragment_depth_shader_object = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB); char s[128]; - // ZIGGY convert a 565 texture into depth component + // (Comment by Ziggy) Convert a 565 texture into depth component sprintf(s, "gl_FragDepth = dot(texture2D(texture0, vec2(gl_TexCoord[0])), vec4(31*64*32, 63*32, 31, 0))*%g + %g; \n", zscale / 2 / 65535.0, 1 - zscale / 2); fragment_shader = (char*)malloc(strlen(fragment_shader_header) + strlen(s) + @@ -221,7 +222,7 @@ void init_combiner() glCompileShaderARB(fragment_depth_shader_object); - // default shader + // Default shader fragment_shader_object = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB); fragment_shader = (char*)malloc(strlen(fragment_shader_header) + @@ -239,7 +240,7 @@ void init_combiner() glShaderSourceARB(vertex_shader_object, 1, &vertex_shader, nullptr); glCompileShaderARB(vertex_shader_object); - // depth program + // Depth program program_object = glCreateProgramObjectARB(); program_object_depth = program_object; glAttachObjectARB(program_object, fragment_depth_shader_object); @@ -263,7 +264,7 @@ void init_combiner() glUniform1iARB(texture0_location, 0); glUniform1iARB(texture1_location, 1); - // default program + // Default program program_object = glCreateProgramObjectARB(); program_object_default = program_object; glAttachObjectARB(program_object, fragment_shader_object); @@ -322,7 +323,7 @@ void compile_chroma_shader() strcat(fragment_shader_chroma, "float alpha = constant_color.a; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "unknown compile_choma_shader_alpha : %x", chroma_other_alpha); + WriteTrace(TraceGlitch, TraceWarning, "Unknown compile_choma_shader_alpha : %x", chroma_other_alpha); } switch (chroma_other_color) @@ -337,7 +338,7 @@ void compile_chroma_shader() strcat(fragment_shader_chroma, "vec4 color = vec4(vec3(constant_color),alpha); \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "unknown compile_choma_shader_alpha : %x", chroma_other_color); + WriteTrace(TraceGlitch, TraceWarning, "Unknown compile_choma_shader_alpha : %x", chroma_other_color); } strcat(fragment_shader_chroma, "if (color.rgb == chroma_color.rgb) discard; \n"); @@ -435,7 +436,7 @@ void compile_shader() shader_programs = (shader_program_key*)realloc(shader_programs, (number_of_programs + 1) * sizeof(shader_program_key)); else shader_programs = (shader_program_key*)malloc(sizeof(shader_program_key)); - //printf("number of shaders %d\n", number_of_programs); + //printf("Number of shaders %d\n", number_of_programs); shader_programs[number_of_programs].color_combiner = color_combiner_key; shader_programs[number_of_programs].alpha_combiner = alpha_combiner_key; @@ -589,7 +590,7 @@ void gfxConstantColorValue(gfxColor_t value) texture_env_color[3] = (value & 0xFF) / 255.0f; break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxConstantColorValue: unknown color format : %x", lfb_color_fmt); + WriteTrace(TraceGlitch, TraceWarning, "gfxConstantColorValue: Unknown color format : %x", lfb_color_fmt); } constant_color_location = glGetUniformLocationARB(program_object, "constant_color"); @@ -613,7 +614,7 @@ int setOtherColorSource(int other) return GL_CONSTANT_ARB; break; default: - WriteTrace(TraceGlitch, TraceWarning, "unknown other color source : %x", other); + WriteTrace(TraceGlitch, TraceWarning, "Unknown other color source : %x", other); } return 0; } @@ -629,7 +630,7 @@ int setLocalColorSource(int local) return GL_CONSTANT_ARB; break; default: - WriteTrace(TraceGlitch, TraceWarning, "unknown local color source : %x", local); + WriteTrace(TraceGlitch, TraceWarning, "Unknown local color source : %x", local); } return 0; } @@ -648,7 +649,7 @@ void writeGLSLColorOther(int other) strcat(fragment_shader_color_combiner, "vec4 color_other = constant_color; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "unknown writeGLSLColorOther : %x", other); + WriteTrace(TraceGlitch, TraceWarning, "Unknown writeGLSLColorOther : %x", other); } } @@ -663,7 +664,7 @@ void writeGLSLColorLocal(int local) strcat(fragment_shader_color_combiner, "vec4 color_local = constant_color; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "unknown writeGLSLColorLocal : %x", local); + WriteTrace(TraceGlitch, TraceWarning, "Unknown writeGLSLColorLocal : %x", local); } } @@ -711,13 +712,13 @@ void writeGLSLColorFactor(int factor, int local, int need_local, int other, int strcat(fragment_shader_color_combiner, "vec4 color_factor = vec4(1.0) - vec4(ctexture1.a); \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "unknown writeGLSLColorFactor : %x", factor); + WriteTrace(TraceGlitch, TraceWarning, "Unknown writeGLSLColorFactor : %x", factor); } } void gfxColorCombine(gfxCombineFunction_t function, gfxCombineFactor_t factor, gfxCombineLocal_t local, gfxCombineOther_t other, bool invert) { - WriteTrace(TraceGlitch, TraceDebug, "function: %d factor: %d local: %d other: %d invert: %d", function, factor, local, other, invert); + WriteTrace(TraceGlitch, TraceDebug, "Function: %d factor: %d local: %d other: %d invert: %d", function, factor, local, other, invert); static int last_function = 0; static int last_factor = 0; @@ -734,7 +735,7 @@ void gfxColorCombine(gfxCombineFunction_t function, gfxCombineFactor_t factor, g last_local = local; last_other = other; - if (invert) WriteTrace(TraceGlitch, TraceWarning, "inverted result"); + if (invert) WriteTrace(TraceGlitch, TraceWarning, "Inverted result"); color_combiner_key = function | (factor << 4) | (local << 8) | (other << 10); chroma_other_color = other; @@ -800,7 +801,7 @@ void gfxColorCombine(gfxCombineFunction_t function, gfxCombineFactor_t factor, g break; default: strcpy(fragment_shader_color_combiner, fragment_shader_default); - WriteTrace(TraceGlitch, TraceWarning, "unknown function : %x", function); + WriteTrace(TraceGlitch, TraceWarning, "Unknown function : %x", function); } //compile_shader(); need_to_compile = 1; @@ -820,7 +821,7 @@ int setOtherAlphaSource(int other) return GL_CONSTANT_ARB; break; default: - WriteTrace(TraceGlitch, TraceWarning, "unknwown other alpha source : %x", other); + WriteTrace(TraceGlitch, TraceWarning, "Unknown other alpha source : %x", other); } return 0; } @@ -836,7 +837,7 @@ int setLocalAlphaSource(int local) return GL_CONSTANT_ARB; break; default: - WriteTrace(TraceGlitch, TraceWarning, "unknwown local alpha source : %x", local); + WriteTrace(TraceGlitch, TraceWarning, "Unknown local alpha source : %x", local); } return 0; } @@ -855,7 +856,7 @@ void writeGLSLAlphaOther(int other) strcat(fragment_shader_alpha_combiner, "float alpha_other = constant_color.a; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "unknown writeGLSLAlphaOther : %x", other); + WriteTrace(TraceGlitch, TraceWarning, "Unknown writeGLSLAlphaOther : %x", other); } } @@ -870,7 +871,7 @@ void writeGLSLAlphaLocal(int local) strcat(fragment_shader_alpha_combiner, "float alpha_local = constant_color.a; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "unknown writeGLSLAlphaLocal : %x", local); + WriteTrace(TraceGlitch, TraceWarning, "Unknown writeGLSLAlphaLocal : %x", local); } } @@ -915,13 +916,13 @@ void writeGLSLAlphaFactor(int factor, int local, int need_local, int other, int strcat(fragment_shader_alpha_combiner, "float alpha_factor = 1.0 - ctexture1.a; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "unknown writeGLSLAlphaFactor : %x", factor); + WriteTrace(TraceGlitch, TraceWarning, "Unknown writeGLSLAlphaFactor : %x", factor); } } void gfxAlphaCombine(gfxCombineFunction_t function, gfxCombineFactor_t factor, gfxCombineLocal_t local, gfxCombineOther_t other, bool invert) { - WriteTrace(TraceGlitch, TraceDebug, "function: %d factor: %d local: %d other: %d invert: %d", function, factor, local, other, invert); + WriteTrace(TraceGlitch, TraceDebug, "Function: %d factor: %d local: %d other: %d invert: %d", function, factor, local, other, invert); static int last_function = 0; static int last_factor = 0; static int last_local = 0; @@ -937,7 +938,7 @@ void gfxAlphaCombine(gfxCombineFunction_t function, gfxCombineFactor_t factor, g last_local = local; last_other = other; - if (invert) WriteTrace(TraceGlitch, TraceWarning, "inverted result"); + if (invert) WriteTrace(TraceGlitch, TraceWarning, "Inverted result"); alpha_combiner_key = function | (factor << 4) | (local << 8) | (other << 10); chroma_other_alpha = other; @@ -1003,7 +1004,7 @@ void gfxAlphaCombine(gfxCombineFunction_t function, gfxCombineFactor_t factor, g strcat(fragment_shader_alpha_combiner, "gl_FragColor.a = alpha_factor * (-alpha_local) + alpha_local; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "unknown function : %x", function); + WriteTrace(TraceGlitch, TraceWarning, "Unknown function : %x", function); } //compile_shader(); @@ -1075,7 +1076,7 @@ void writeGLSLTextureColorFactor(int num_tex, int factor) strcat(fragment_shader_texture1, "vec4 texture1_color_factor = vec4(1.0) - vec4(lambda); \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "unknown writeGLSLTextureColorFactor : %x", factor); + WriteTrace(TraceGlitch, TraceWarning, "Unknown writeGLSLTextureColorFactor : %x", factor); } } @@ -1144,7 +1145,7 @@ void writeGLSLTextureAlphaFactor(int num_tex, int factor) strcat(fragment_shader_texture1, "float texture1_alpha_factor = 1.0 - lambda; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "unknown writeGLSLTextureAlphaFactor : %x", factor); + WriteTrace(TraceGlitch, TraceWarning, "Unknown writeGLSLTextureAlphaFactor : %x", factor); } } @@ -1289,7 +1290,7 @@ void gfxTexCombine(gfxChipID_t tmu, gfxCombineFunction_t rgb_function, gfxCombin strcat(fragment_shader_texture0, "vec4 ctexture0 = readtex0; \n"); else strcat(fragment_shader_texture1, "vec4 ctexture1 = readtex1; \n"); - WriteTrace(TraceGlitch, TraceWarning, "grTextCombine : unknown rgb function : %x", rgb_function); + WriteTrace(TraceGlitch, TraceWarning, "grTextCombine: Unknown RGB function: %x", rgb_function); } if (rgb_invert) @@ -1381,7 +1382,7 @@ void gfxTexCombine(gfxChipID_t tmu, gfxCombineFunction_t rgb_function, gfxCombin strcat(fragment_shader_texture0, "ctexture0.a = readtex0.a; \n"); else strcat(fragment_shader_texture1, "ctexture1.a = ctexture0.a; \n"); - WriteTrace(TraceGlitch, TraceWarning, "grTextCombine : unknown alpha function : %x", alpha_function); + WriteTrace(TraceGlitch, TraceWarning, "grTextCombine: Unknown alpha function: %x", alpha_function); } if (alpha_invert) @@ -1414,7 +1415,7 @@ void gfxAlphaBlendFunction(gfxAlphaBlendFnc_t rgb_sf, gfxAlphaBlendFnc_t rgb_df, sfactorRGB = GL_ONE_MINUS_SRC_ALPHA; break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaBlendFunction : rgb_sf = %x", rgb_sf); + WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaBlendFunction: rgb_sf = %x", rgb_sf); } switch (rgb_df) @@ -1432,7 +1433,7 @@ void gfxAlphaBlendFunction(gfxAlphaBlendFnc_t rgb_sf, gfxAlphaBlendFnc_t rgb_df, dfactorRGB = GL_ONE_MINUS_SRC_ALPHA; break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaBlendFunction : rgb_df = %x", rgb_df); + WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaBlendFunction: rgb_df = %x", rgb_df); } switch (alpha_sf) @@ -1444,7 +1445,7 @@ void gfxAlphaBlendFunction(gfxAlphaBlendFnc_t rgb_sf, gfxAlphaBlendFnc_t rgb_df, sfactorAlpha = GL_ONE; break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaBlendFunction : alpha_sf = %x", alpha_sf); + WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaBlendFunction: alpha_sf = %x", alpha_sf); } switch (alpha_df) @@ -1456,7 +1457,7 @@ void gfxAlphaBlendFunction(gfxAlphaBlendFnc_t rgb_sf, gfxAlphaBlendFnc_t rgb_df, dfactorAlpha = GL_ONE; break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaBlendFunction : alpha_df = %x", alpha_df); + WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaBlendFunction: alpha_df = %x", alpha_df); } glEnable(GL_BLEND); if (blend_func_separate_support) @@ -1469,14 +1470,14 @@ void gfxAlphaBlendFunction(gfxAlphaBlendFnc_t rgb_sf, gfxAlphaBlendFnc_t rgb_df, void gfxAlphaTestReferenceValue(gfxAlpha_t value) { - WriteTrace(TraceGlitch, TraceDebug, "value: %d", value); + WriteTrace(TraceGlitch, TraceDebug, "Value: %d", value); alpha_ref = value; gfxAlphaTestFunction(alpha_func); } void gfxAlphaTestFunction(gfxCmpFnc_t function) { - WriteTrace(TraceGlitch, TraceDebug, "function: %d", function); + WriteTrace(TraceGlitch, TraceDebug, "Function: %d", function); alpha_func = function; switch (function) { @@ -1493,18 +1494,18 @@ void gfxAlphaTestFunction(gfxCmpFnc_t function) return; break; default: - WriteTrace(TraceGlitch, TraceWarning, "unknown function : %x", function); + WriteTrace(TraceGlitch, TraceWarning, "Unknown function: %x", function); } glEnable(GL_ALPHA_TEST); grDisplayGLError("gfxAlphaTestFunction"); } -// fog +// Fog void gfxFogMode(gfxFogMode_t mode) { - WriteTrace(TraceGlitch, TraceDebug, "mode: %d", mode); + WriteTrace(TraceGlitch, TraceDebug, "Mode: %d", mode); switch (mode) { case GFX_FOG_DISABLE: @@ -1522,7 +1523,7 @@ void gfxFogMode(gfxFogMode_t mode) fog_enabled = 2; break; default: - WriteTrace(TraceGlitch, TraceWarning, "unknown mode : %x", mode); + WriteTrace(TraceGlitch, TraceWarning, "Unknown mode: %x", mode); } need_to_compile = 1; @@ -1560,17 +1561,17 @@ void gfxFogColorValue(gfxColor_t fogcolor) color[3] = (fogcolor & 0xFF) / 255.0f; break; default: - WriteTrace(TraceGlitch, TraceWarning, "unknown color format : %x", lfb_color_fmt); + WriteTrace(TraceGlitch, TraceWarning, "Unknown color format : %x", lfb_color_fmt); } glFogfv(GL_FOG_COLOR, color); grDisplayGLError("glFogfv"); } -// chroma +// Chroma void gfxChromakeyMode(gfxChromakeyMode_t mode) { - WriteTrace(TraceGlitch, TraceDebug, "mode: %d", mode); + WriteTrace(TraceGlitch, TraceDebug, "Mode: %d", mode); switch (mode) { case GFX_CHROMAKEY_DISABLE: @@ -1580,14 +1581,14 @@ void gfxChromakeyMode(gfxChromakeyMode_t mode) chroma_enabled = 1; break; default: - WriteTrace(TraceGlitch, TraceWarning, "unknown mode : %x", mode); + WriteTrace(TraceGlitch, TraceWarning, "Unknown mode : %x", mode); } need_to_compile = 1; } void gfxChromakeyValue(gfxColor_t value) { - WriteTrace(TraceGlitch, TraceDebug, "value: %d", value); + WriteTrace(TraceGlitch, TraceDebug, "Value: %d", value); int chroma_color_location; switch (lfb_color_fmt) @@ -1605,7 +1606,7 @@ void gfxChromakeyValue(gfxColor_t value) chroma_color[3] = 1.0;//(value & 0xFF) / 255.0f; break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxChromakeyValue: unknown color format : %x", lfb_color_fmt); + WriteTrace(TraceGlitch, TraceWarning, "gfxChromakeyValue: Unknown color format: %x", lfb_color_fmt); } chroma_color_location = glGetUniformLocationARB(program_object, "chroma_color"); @@ -1655,7 +1656,7 @@ void setPattern() void gfxStippleMode(gfxStippleMode_t mode) { - WriteTrace(TraceGlitch, TraceDebug, "mode: %d", mode); + WriteTrace(TraceGlitch, TraceDebug, "Mode: %d", mode); switch (mode) { case GFX_STIPPLE_DISABLE: @@ -1686,8 +1687,8 @@ void gfxStippleMode(gfxStippleMode_t mode) void gfxColorCombineExt(gfxCCUColor_t a, gfxCombineMode_t a_mode, gfxCCUColor_t b, gfxCombineMode_t b_mode, gfxCCUColor_t c, bool c_invert, gfxCCUColor_t d, bool d_invert, uint32_t shift, bool invert) { WriteTrace(TraceGlitch, TraceDebug, "a: %d a_mode: %d b: %d b_mode: %d c: %d c_invert: %d d: %d d_invert: %d shift: %d invert: %d", a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert); - if (invert) WriteTrace(TraceGlitch, TraceWarning, "gfxColorCombineExt : inverted result"); - if (shift) WriteTrace(TraceGlitch, TraceWarning, "gfxColorCombineExt : shift = %d", shift); + if (invert) WriteTrace(TraceGlitch, TraceWarning, "gfxColorCombineExt: Inverted result"); + if (shift) WriteTrace(TraceGlitch, TraceWarning, "gfxColorCombineExt: Shift = %d", shift); color_combiner_key = 0x80000000 | (a & 0x1F) | ((a_mode & 3) << 5) | ((b & 0x1F) << 7) | ((b_mode & 3) << 12) | @@ -1720,7 +1721,7 @@ void gfxColorCombineExt(gfxCCUColor_t a, gfxCombineMode_t a_mode, gfxCCUColor_t strcat(fragment_shader_color_combiner, "vec4 cs_a = ctexture1; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxColorCombineExt : a = %x", a); + WriteTrace(TraceGlitch, TraceWarning, "gfxColorCombineExt: a = %x", a); strcat(fragment_shader_color_combiner, "vec4 cs_a = vec4(0.0); \n"); } @@ -1767,7 +1768,7 @@ void gfxColorCombineExt(gfxCCUColor_t a, gfxCombineMode_t a_mode, gfxCCUColor_t strcat(fragment_shader_color_combiner, "vec4 cs_b = ctexture1; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxColorCombineExt : b = %x", b); + WriteTrace(TraceGlitch, TraceWarning, "gfxColorCombineExt: b = %x", b); strcat(fragment_shader_color_combiner, "vec4 cs_b = vec4(0.0); \n"); } @@ -1786,7 +1787,7 @@ void gfxColorCombineExt(gfxCCUColor_t a, gfxCombineMode_t a_mode, gfxCCUColor_t strcat(fragment_shader_color_combiner, "vec4 c_b = -cs_b; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxColorCombineExt : b_mode = %x", b_mode); + WriteTrace(TraceGlitch, TraceWarning, "gfxColorCombineExt: b_mode = %x", b_mode); strcat(fragment_shader_color_combiner, "vec4 c_b = vec4(0.0); \n"); } @@ -1848,7 +1849,7 @@ void gfxColorCombineExt(gfxCCUColor_t a, gfxCombineMode_t a_mode, gfxCCUColor_t strcat(fragment_shader_color_combiner, "vec4 c_d = gl_Color; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxColorCombineExt : d = %x", d); + WriteTrace(TraceGlitch, TraceWarning, "gfxColorCombineExt: d = %x", d); strcat(fragment_shader_color_combiner, "vec4 c_d = vec4(0.0); \n"); } @@ -1863,8 +1864,8 @@ void gfxColorCombineExt(gfxCCUColor_t a, gfxCombineMode_t a_mode, gfxCCUColor_t void gfxAlphaCombineExt(gfxACUColor_t a, gfxCombineMode_t a_mode, gfxACUColor_t b, gfxCombineMode_t b_mode, gfxACUColor_t c, bool c_invert, gfxACUColor_t d, bool d_invert, uint32_t shift, bool invert) { WriteTrace(TraceGlitch, TraceDebug, "a: %d a_mode: %d b: %d b_mode: %d c: %d c_invert: %d d: %d d_invert: %d shift: %d invert: %d", a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert); - if (invert) WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombineExt : inverted result"); - if (shift) WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombineExt : shift = %d", shift); + if (invert) WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombineExt: Inverted result"); + if (shift) WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombineExt: Shift = %d", shift); alpha_combiner_key = 0x80000000 | (a & 0x1F) | ((a_mode & 3) << 5) | ((b & 0x1F) << 7) | ((b_mode & 3) << 12) | @@ -1888,7 +1889,7 @@ void gfxAlphaCombineExt(gfxACUColor_t a, gfxCombineMode_t a_mode, gfxACUColor_t strcat(fragment_shader_alpha_combiner, "float as_a = gl_Color.a; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombineExt : a = %x", a); + WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombineExt: a = %x", a); strcat(fragment_shader_alpha_combiner, "float as_a = 0.0; \n"); } @@ -1907,7 +1908,7 @@ void gfxAlphaCombineExt(gfxACUColor_t a, gfxCombineMode_t a_mode, gfxACUColor_t strcat(fragment_shader_alpha_combiner, "float a_a = -as_a; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombineExt : a_mode = %x", a_mode); + WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombineExt: a_mode = %x", a_mode); strcat(fragment_shader_alpha_combiner, "float a_a = 0.0; \n"); } @@ -1926,7 +1927,7 @@ void gfxAlphaCombineExt(gfxACUColor_t a, gfxCombineMode_t a_mode, gfxACUColor_t strcat(fragment_shader_alpha_combiner, "float as_b = gl_Color.a; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombineExt : b = %x", b); + WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombineExt: b = %x", b); strcat(fragment_shader_alpha_combiner, "float as_b = 0.0; \n"); } @@ -1945,7 +1946,7 @@ void gfxAlphaCombineExt(gfxACUColor_t a, gfxCombineMode_t a_mode, gfxACUColor_t strcat(fragment_shader_alpha_combiner, "float a_b = -as_b; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombineExt : b_mode = %x", b_mode); + WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombineExt: b_mode = %x", b_mode); strcat(fragment_shader_alpha_combiner, "float a_b = 0.0; \n"); } @@ -1973,7 +1974,7 @@ void gfxAlphaCombineExt(gfxACUColor_t a, gfxCombineMode_t a_mode, gfxACUColor_t strcat(fragment_shader_alpha_combiner, "float a_c = gl_Color.a; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombineExt : c = %x", c); + WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombineExt: c = %x", c); strcat(fragment_shader_alpha_combiner, "float a_c = 0.0; \n"); } @@ -1995,7 +1996,7 @@ void gfxAlphaCombineExt(gfxACUColor_t a, gfxCombineMode_t a_mode, gfxACUColor_t strcat(fragment_shader_alpha_combiner, "float a_d = as_b; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombineExt : d = %x", d); + WriteTrace(TraceGlitch, TraceWarning, "gfxAlphaCombineExt: d = %x", d); strcat(fragment_shader_alpha_combiner, "float a_d = 0.0; \n"); } @@ -2012,8 +2013,8 @@ void gfxTexColorCombineExt(gfxChipID_t tmu, gfxTCCUColor_t a, gfxCombineMode_t a int num_tex; WriteTrace(TraceGlitch, TraceDebug, "tmu: %d a: %d a_mode: %d b: %d b_mode: %d c: %d c_invert: %d d: %d d_invert: %d shift: %d invert: %d", tmu, a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert); - if (invert) WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt : inverted result"); - if (shift) WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt : shift = %d", shift); + if (invert) WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt: Inverted result"); + if (shift) WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt: Shift = %d", shift); if (tmu == GFX_TMU0) num_tex = 1; else num_tex = 0; @@ -2094,7 +2095,7 @@ void gfxTexColorCombineExt(gfxChipID_t tmu, gfxTCCUColor_t a, gfxCombineMode_t a strcat(fragment_shader_texture1, "vec4 ctex1s_a = vec4(ccolor1.a); \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt : a = %x", a); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt: a = %x", a); if (num_tex == 0) strcat(fragment_shader_texture0, "vec4 ctex0s_a = vec4(0.0); \n"); else @@ -2128,7 +2129,7 @@ void gfxTexColorCombineExt(gfxChipID_t tmu, gfxTCCUColor_t a, gfxCombineMode_t a strcat(fragment_shader_texture1, "vec4 ctex1_a = -ctex1s_a; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt : a_mode = %x", a_mode); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt: a_mode = %x", a_mode); if (num_tex == 0) strcat(fragment_shader_texture0, "vec4 ctex0_a = vec4(0.0); \n"); else @@ -2192,7 +2193,7 @@ void gfxTexColorCombineExt(gfxChipID_t tmu, gfxTCCUColor_t a, gfxCombineMode_t a strcat(fragment_shader_texture1, "vec4 ctex1s_b = ccolor1; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt : b = %x", b); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt: b = %x", b); if (num_tex == 0) strcat(fragment_shader_texture0, "vec4 ctex0s_b = vec4(0.0); \n"); else @@ -2226,7 +2227,7 @@ void gfxTexColorCombineExt(gfxChipID_t tmu, gfxTCCUColor_t a, gfxCombineMode_t a strcat(fragment_shader_texture1, "vec4 ctex1_b = -ctex1s_b; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt : b_mode = %x", b_mode); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt: b_mode = %x", b_mode); if (num_tex == 0) strcat(fragment_shader_texture0, "vec4 ctex0_b = vec4(0.0); \n"); else @@ -2302,7 +2303,7 @@ void gfxTexColorCombineExt(gfxChipID_t tmu, gfxTCCUColor_t a, gfxCombineMode_t a strcat(fragment_shader_texture1, "vec4 ctex1_c = ccolor1; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt : c = %x", c); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt: c = %x", c); if (num_tex == 0) strcat(fragment_shader_texture0, "vec4 ctex0_c = vec4(0.0); \n"); else @@ -2344,7 +2345,7 @@ void gfxTexColorCombineExt(gfxChipID_t tmu, gfxTCCUColor_t a, gfxCombineMode_t a strcat(fragment_shader_texture1, "vec4 ctex1_d = vec4(readtex1.a); \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt : d = %x", d); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexColorCombineExt: d = %x", d); if (num_tex == 0) strcat(fragment_shader_texture0, "vec4 ctex0_d = vec4(0.0); \n"); else @@ -2371,8 +2372,8 @@ void gfxTexAlphaCombineExt(gfxChipID_t tmu, gfxTACUColor_t a, gfxCombineMode_t a int num_tex; WriteTrace(TraceGlitch, TraceDebug, "tmu: %d a: %d a_mode: %d b: %d b_mode: %d c: %d c_invert: %d d: %d d_invert: %d shift, invert: %d", tmu, a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert); - if (invert) WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt : inverted result"); - if (shift) WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt : shift = %d", shift); + if (invert) WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt: Inverted result"); + if (shift) WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt: Shift = %d", shift); if (tmu == GFX_TMU0) num_tex = 1; else num_tex = 0; @@ -2419,7 +2420,7 @@ void gfxTexAlphaCombineExt(gfxChipID_t tmu, gfxTACUColor_t a, gfxCombineMode_t a strcat(fragment_shader_texture1, "ctex1s_a.a = ccolor1.a; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt : a = %x", a); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt: a = %x", a); if (num_tex == 0) strcat(fragment_shader_texture0, "ctex0s_a.a = 0.0; \n"); else @@ -2453,7 +2454,7 @@ void gfxTexAlphaCombineExt(gfxChipID_t tmu, gfxTACUColor_t a, gfxCombineMode_t a strcat(fragment_shader_texture1, "ctex1_a.a = -ctex1s_a.a; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt : a_mode = %x", a_mode); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt: a_mode = %x", a_mode); if (num_tex == 0) strcat(fragment_shader_texture0, "ctex0_a.a = 0.0; \n"); else @@ -2487,7 +2488,7 @@ void gfxTexAlphaCombineExt(gfxChipID_t tmu, gfxTACUColor_t a, gfxCombineMode_t a strcat(fragment_shader_texture1, "ctex1s_b.a = ccolor1.a; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt : b = %x", b); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt: b = %x", b); if (num_tex == 0) strcat(fragment_shader_texture0, "ctex0s_b.a = 0.0; \n"); else @@ -2521,7 +2522,7 @@ void gfxTexAlphaCombineExt(gfxChipID_t tmu, gfxTACUColor_t a, gfxCombineMode_t a strcat(fragment_shader_texture1, "ctex1_b.a = -ctex1s_b.a; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt : b_mode = %x", b_mode); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt: b_mode = %x", b_mode); if (num_tex == 0) strcat(fragment_shader_texture0, "ctex0_b.a = 0.0; \n"); else @@ -2573,7 +2574,7 @@ void gfxTexAlphaCombineExt(gfxChipID_t tmu, gfxTACUColor_t a, gfxCombineMode_t a strcat(fragment_shader_texture1, "ctex1_c.a = ccolor1.a; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt : c = %x", c); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt: c = %x", c); if (num_tex == 0) strcat(fragment_shader_texture0, "ctex0_c.a = 0.0; \n"); else @@ -2621,7 +2622,7 @@ void gfxTexAlphaCombineExt(gfxChipID_t tmu, gfxTACUColor_t a, gfxCombineMode_t a strcat(fragment_shader_texture1, "ctex1_d.a = readtex1.a; \n"); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt : d = %x", d); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexAlphaCombineExt: d = %x", d); if (num_tex == 0) strcat(fragment_shader_texture0, "ctex0_d.a = 0.0; \n"); else @@ -2687,7 +2688,7 @@ void gfxConstantColorValueExt(gfxChipID_t tmu, gfxColor_t value) } break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxConstantColorValue: unknown color format : %x", lfb_color_fmt); + WriteTrace(TraceGlitch, TraceWarning, "gfxConstantColorValue: Unknown color format: %x", lfb_color_fmt); } if (num_tex == 0) @@ -2701,4 +2702,4 @@ void gfxConstantColorValueExt(gfxChipID_t tmu, gfxColor_t value) glUniform4fARB(ccolor1_location, ccolor1[0], ccolor1[1], ccolor1[2], ccolor1[3]); } grDisplayGLError("gfxConstantColorValueExt"); -} \ No newline at end of file +} diff --git a/Source/Project64-video/Renderer/OGLgeometry.cpp b/Source/Project64-video/Renderer/OGLgeometry.cpp index 932960007..a7ebd48c3 100644 --- a/Source/Project64-video/Renderer/OGLgeometry.cpp +++ b/Source/Project64-video/Renderer/OGLgeometry.cpp @@ -1,9 +1,10 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2003-2009 Sergey 'Gonetz' Lipski // Copyright(C) 2002 Dave2001 // GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html + #include #include #include @@ -88,7 +89,7 @@ void gfxCullMode(gfxCullMode_t mode) glEnable(GL_CULL_FACE); break; default: - WriteTrace(TraceGlitch, TraceWarning, "unknown cull mode : %x", mode); + WriteTrace(TraceGlitch, TraceWarning, "Unknown cull mode : %x", mode); } grDisplayGLError("gfxCullMode"); } @@ -114,14 +115,14 @@ void gfxDepthBufferMode(gfxDepthBufferMode_t mode) w_buffer_mode = 0; break; default: - WriteTrace(TraceGlitch, TraceWarning, "unknown depth buffer mode : %x", mode); + WriteTrace(TraceGlitch, TraceWarning, "Unknown depth buffer mode : %x", mode); } grDisplayGLError("gfxDepthBufferMode"); } void gfxDepthBufferFunction(gfxCmpFnc_t function) { - WriteTrace(TraceGlitch, TraceDebug, "function: %d", function); + WriteTrace(TraceGlitch, TraceDebug, "Function: %d", function); switch (function) { case GFX_CMP_GEQUAL: @@ -162,7 +163,7 @@ void gfxDepthBufferFunction(gfxCmpFnc_t function) break; default: - WriteTrace(TraceGlitch, TraceWarning, "unknown depth buffer function : %x", function); + WriteTrace(TraceGlitch, TraceWarning, "Unknown depth buffer function : %x", function); } grDisplayGLError("gfxDepthBufferFunction"); } @@ -184,7 +185,7 @@ void FindBestDepthBias() if (biasFactor) return; - biasFactor = 64.0f; // default value + biasFactor = 64.0f; // Default value glPushAttrib(GL_ALL_ATTRIB_BITS); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_ALWAYS); @@ -253,7 +254,7 @@ void gfxDepthBiasLevel(int32_t level) grDisplayGLError("gfxDepthBiasLevel"); } -// draw +// Draw void gfxDrawTriangle(const gfxVERTEX *a, const gfxVERTEX *b, const gfxVERTEX *c) { float *a_x = (float*)a + xy_off / sizeof(float); @@ -290,7 +291,7 @@ void gfxDrawTriangle(const gfxVERTEX *a, const gfxVERTEX *b, const gfxVERTEX *c) float *c_fog = (float*)c + fog_ext_off / sizeof(float); WriteTrace(TraceGlitch, TraceDebug, "-"); - // ugly ? i know but nvidia drivers are losing the viewport otherwise + // This is ugly, but Nvidia drivers are losing the viewport otherwise. if (nvidia_viewport_hack && !render_to_texture) { @@ -456,7 +457,7 @@ void gfxDrawVertexArray(gfxDrawMode_t mode, uint32_t Count, void *pointers2) float *x, *y, *q, *s0, *t0, *s1, *t1, *z, *fog; unsigned char *pargb; void **pointers = (void**)pointers2; - WriteTrace(TraceGlitch, TraceDebug, "mode: %d Count: %d", mode, Count); + WriteTrace(TraceGlitch, TraceDebug, "Mode: %d Count: %d", mode, Count); if (nvidia_viewport_hack && !render_to_texture) { @@ -474,7 +475,7 @@ void gfxDrawVertexArray(gfxDrawMode_t mode, uint32_t Count, void *pointers2) glBegin(GL_TRIANGLE_FAN); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxDrawVertexArray : unknown mode : %x", mode); + WriteTrace(TraceGlitch, TraceWarning, "gfxDrawVertexArray: Unknown mode : %x", mode); } for (i = 0; i < Count; i++) @@ -520,7 +521,7 @@ void gfxDrawVertexArrayContiguous(gfxDrawMode_t mode, uint32_t Count, void *poin unsigned int i; float *x, *y, *q, *s0, *t0, *s1, *t1, *z, *fog; unsigned char *pargb; - WriteTrace(TraceGlitch, TraceDebug, "mode: %d Count: %d stride: %d", mode, Count, stride); + WriteTrace(TraceGlitch, TraceDebug, "Mode: %d Count: %d stride: %d", mode, Count, stride); if (nvidia_viewport_hack && !render_to_texture) { @@ -541,7 +542,7 @@ void gfxDrawVertexArrayContiguous(gfxDrawMode_t mode, uint32_t Count, void *poin glBegin(GL_TRIANGLE_FAN); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxDrawVertexArrayContiguous : unknown mode : %x", mode); + WriteTrace(TraceGlitch, TraceWarning, "gfxDrawVertexArrayContiguous: Unknown mode : %x", mode); } for (i = 0; i < Count; i++) diff --git a/Source/Project64-video/Renderer/OGLglitchmain.cpp b/Source/Project64-video/Renderer/OGLglitchmain.cpp index 7e6dda588..828b12d77 100644 --- a/Source/Project64-video/Renderer/OGLglitchmain.cpp +++ b/Source/Project64-video/Renderer/OGLglitchmain.cpp @@ -1,9 +1,10 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2003-2009 Sergey 'Gonetz' Lipski // Copyright(C) 2002 Dave2001 // GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html + #include #include @@ -27,9 +28,10 @@ #include /* - * `GetSystemSetting` and `FindSystemSettingId` from Project64 debugger - * used only in g_Notify->DisplayError when OpenGL extension loading fails on WGL - */ +`GetSystemSetting` and `FindSystemSettingId` from Project64 debugger +used only in g_Notify->DisplayError when OpenGL extension loading fails on WGL +*/ + #include int screen_width, screen_height; @@ -72,14 +74,15 @@ static inline void opt_glCopyTexImage2D(GLenum target, #define glCopyTexImage2D opt_glCopyTexImage2D #ifdef _WIN32 + /* - * Some post-1.1 OpenGL functions can fail to be loaded through GL extensions - * when running primitive OpenGL contexts on Microsoft Windows, specifically. - * - * As of the Project64 Glide64 version, Glitch64 now assigns these GL - * functions to dummy functions to prevent access violations, while also - * displaying error information showing the missing OpenGL support. - */ +Some post-1.1 OpenGL functions can fail to be loaded through OpenGL extensions +when running primitive OpenGL contexts on Microsoft Windows, specifically. + +As of the Project64 Glide64 version, Glitch64 now assigns these OpenGL +functions to dummy functions to prevent access violations, while also +displaying error information showing the missing OpenGL support. +*/ PFNGLACTIVETEXTUREARBPROC glActiveTextureARB; PFNGLBLENDFUNCSEPARATEEXTPROC glBlendFuncSeparateEXT; @@ -245,7 +248,7 @@ void APIENTRY dummy_glGetObjectParameteriv(GLhandleARB, GLenum, GLint *) g_Notify->DisplayError("glGetObjectParameteriv"); } -// FXT1,DXT1,DXT5 support - Hiroshi Morii +// FXT1,DXT1,DXT5 support - Hiroshi Morii // NOTE: Glide64 + GlideHQ use the following formats // GL_COMPRESSED_RGB_S3TC_DXT1_EXT // GL_COMPRESSED_RGBA_S3TC_DXT5_EXT @@ -279,10 +282,10 @@ int render_to_texture = 0; int texture_unit; int use_fbo; int buffer_cleared; -// ZIGGY -// to allocate a new static texture name, take the value (free_texture++) +// Comment by Ziggy +// To allocate a new static texture name, take the value (free_texture++) int free_texture; -int default_texture; // the infamous "32*1024*1024" is now configurable +int default_texture; // The infamous "32*1024*1024" is now configurable int current_texture; int depth_texture, color_texture; int glsl_support = 1; @@ -315,7 +318,7 @@ struct texbuf_t { uint32_t start, end; int fmt; }; -#define NB_TEXBUFS 128 // MUST be a power of two +#define NB_TEXBUFS 128 // Must be a power of two static texbuf_t texbufs[NB_TEXBUFS]; static int texbuf_i; @@ -437,9 +440,9 @@ bool gfxSstWinOpen(gfxColorFormat_t color_format, gfxOriginLocation_t origin_loc { static int show_warning = 1; - // ZIGGY - // allocate static texture names - // the initial value should be big enough to support the maximal resolution + // Comment by Ziggy + // Allocate static texture names + // The initial value should be big enough to support the maximal resolution free_texture = 32 * 2048 * 2048; default_texture = free_texture++; color_texture = free_texture++; @@ -459,7 +462,7 @@ bool gfxSstWinOpen(gfxColorFormat_t color_format, gfxOriginLocation_t origin_loc int pfm; #else - fputs("ERROR: No GLX yet to start GL on [Free]BSD, Linux etc.\n", stderr); + fputs("ERROR: No GLX yet to start GL on [Free]BSD, Linux etc.\n", stderr); #endif // _WIN32 WriteTrace(TraceGlitch, TraceDebug, "color_format: %d, origin_location: %d, nColBuffers: %d, nAuxBuffers: %d", color_format, origin_location, nColBuffers, nAuxBuffers); @@ -467,7 +470,7 @@ bool gfxSstWinOpen(gfxColorFormat_t color_format, gfxOriginLocation_t origin_loc #ifdef _WIN32 TMU_SIZE = ((g_settings->wrpVRAM() * 1024 * 1024) - g_width * g_height * 4 * 3) / 2; - // save screen resolution for hwfbe, after resolution enumeration + // Save screen resolution for hwfbe (hardware framebuffer emulation?), after resolution enumeration screen_width = g_width; screen_height = g_height; @@ -482,7 +485,7 @@ bool gfxSstWinOpen(gfxColorFormat_t color_format, gfxOriginLocation_t origin_loc } if ((pfm = ChoosePixelFormat(hDC, &pfd)) == 0) { - //printf("disabling auxiliary buffers\n"); + //printf("Disabling auxiliary buffers\n"); pfd.cAuxBuffers = 0; pfm = ChoosePixelFormat(hDC, &pfd); } @@ -517,9 +520,9 @@ bool gfxSstWinOpen(gfxColorFormat_t color_format, gfxOriginLocation_t origin_loc } #endif // _WIN32 lfb_color_fmt = color_format; - if (origin_location != GFX_ORIGIN_UPPER_LEFT) WriteTrace(TraceGlitch, TraceWarning, "origin must be in upper left corner"); - if (nColBuffers != 2) WriteTrace(TraceGlitch, TraceWarning, "number of color buffer is not 2"); - if (nAuxBuffers != 1) WriteTrace(TraceGlitch, TraceWarning, "number of auxiliary buffer is not 1"); + if (origin_location != GFX_ORIGIN_UPPER_LEFT) WriteTrace(TraceGlitch, TraceWarning, "Origin must be in upper left corner"); + if (nColBuffers != 2) WriteTrace(TraceGlitch, TraceWarning, "Number of color buffer is not 2"); + if (nAuxBuffers != 1) WriteTrace(TraceGlitch, TraceWarning, "Number of auxiliary buffer is not 1"); if (isExtensionSupported("GL_ARB_texture_env_combine") == 0 && isExtensionSupported("GL_EXT_texture_env_combine") == 0 && @@ -548,7 +551,7 @@ bool gfxSstWinOpen(gfxColorFormat_t color_format, gfxOriginLocation_t origin_loc nbAuxBuffers = 0; glGetIntegerv(GL_AUX_BUFFERS, &nbAuxBuffers); if (nbAuxBuffers > 0) - printf("Congratulations, you have %d auxilliary buffers, we'll use them wisely !\n", nbAuxBuffers); + printf("Congratulations, you have %d auxiliary buffers, we'll use them wisely!\n", nbAuxBuffers); if (isExtensionSupported("GL_EXT_blend_func_separate") == 0) blend_func_separate_support = 0; @@ -558,7 +561,7 @@ bool gfxSstWinOpen(gfxColorFormat_t color_format, gfxOriginLocation_t origin_loc if (isExtensionSupported("GL_EXT_packed_pixels") == 0) packed_pixels_support = 0; else { - printf("packed pixels extension used\n"); + printf("Packed pixels extension used\n"); packed_pixels_support = 1; } @@ -717,7 +720,7 @@ bool gfxSstWinOpen(gfxColorFormat_t color_format, gfxOriginLocation_t origin_loc // void do_benchmarks(); // do_benchmarks(); - // VP try to resolve z precision issues + // VP try to resolve Z precision issues glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0, 0, 1 - zscale); @@ -739,7 +742,7 @@ bool gfxSstWinOpen(gfxColorFormat_t color_format, gfxOriginLocation_t origin_loc } if (!use_fbo && nbAuxBuffers == 0) { - // create the framebuffer saving texture + // Create the framebuffer saving texture int w = g_width, h = g_height; glBindTexture(GL_TEXTURE_2D, color_texture); if (!npot_support) { @@ -759,7 +762,7 @@ bool gfxSstWinOpen(gfxColorFormat_t color_format, gfxOriginLocation_t origin_loc init_textures(); init_combiner(); - // Aniso filter check + // Anisotropic filter check if (g_settings->wrpAnisotropic()) { glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &largest_supported_anisotropy); @@ -799,8 +802,8 @@ bool gfxSstWinClose() free_combiners(); #ifndef WIN32 - try // I don't know why, but opengl can be killed before this function call when emulator is closed (Gonetz). - // ZIGGY : I found the problem : it is a function pointer, when the extension isn't supported , it is then zero, so just need to check the pointer prior to do the call. + try // I don't know why, but OpenGL can be killed before this function call when emulator is closed (Gonetz). + // Comment by Ziggy: I found the problem: it is a function pointer, when the extension isn't supported, it is then zero, so just need to check the pointer prior to do the call. { if (use_fbo && glBindFramebufferEXT) glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); @@ -824,11 +827,10 @@ bool gfxSstWinClose() free_textures(); #ifndef WIN32 - // ZIGGY for some reasons, Pj64 doesn't like remove_tex on exit + // (Comment by Ziggy) For some reasons, Project64 doesn't like remove_tex on exit remove_tex(0, 0xfffffff); #endif - //*/ #ifdef _WIN32 if (hGLRC) { @@ -851,9 +853,9 @@ void gfxTextureBufferExt(gfxChipID_t tmu, uint32_t startAddress, gfxLOD_t lodmin static int fbs_init = 0; WriteTrace(TraceGlitch, TraceDebug, "tmu: %d startAddress: %d lodmin: %d lodmax: %d aspect: %d fmt: %d evenOdd: %d", tmu, startAddress, lodmin, lodmax, aspect, fmt, evenOdd); - if (lodmin != lodmax) WriteTrace(TraceGlitch, TraceWarning, "gfxTextureBufferExt : loading more than one LOD"); + if (lodmin != lodmax) WriteTrace(TraceGlitch, TraceWarning, "gfxTextureBufferExt: Loading more than one LOD"); if (!use_fbo) { - if (!render_to_texture) { //initialization + if (!render_to_texture) { // Initialization return; } @@ -874,7 +876,7 @@ void gfxTextureBufferExt(gfxChipID_t tmu, uint32_t startAddress, gfxLOD_t lodmin updateTexture(); #ifdef SAVE_CBUFFER //printf("saving %dx%d\n", pBufferWidth, pBufferHeight); - // save color buffer + // Save color buffer if (nbAuxBuffers > 0) { glDrawBuffer(GL_AUX0); current_buffer = GL_AUX0; @@ -892,7 +894,7 @@ void gfxTextureBufferExt(gfxChipID_t tmu, uint32_t startAddress, gfxLOD_t lodmin glReadBuffer(GL_BACK); glActiveTextureARB(texture_unit); glBindTexture(GL_TEXTURE_2D, color_texture); - // save incrementally the framebuffer + // Save incrementally the framebuffer if (save_w) { if (tw > save_w && th > save_h) { glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, save_h, @@ -945,8 +947,8 @@ void gfxTextureBufferExt(gfxChipID_t tmu, uint32_t startAddress, gfxLOD_t lodmin widtho = g_width / 2; heighto = g_height / 2; - // this could be improved, but might be enough as long as the set of - // texture buffer addresses stay small + // This could be improved, but might be enough as long as the set of + // texture buffer addresses stays small for (i = (texbuf_i - 1)&(NB_TEXBUFS - 1); i != texbuf_i; i = (i - 1)&(NB_TEXBUFS - 1)) if (texbufs[i].start == pBufferAddress) break; @@ -957,8 +959,8 @@ void gfxTextureBufferExt(gfxChipID_t tmu, uint32_t startAddress, gfxLOD_t lodmin texbuf_i = (texbuf_i + 1)&(NB_TEXBUFS - 1); //printf("texbuf %x fmt %x\n", pBufferAddress, fmt); - // ZIGGY it speeds things up to not delete the buffers - // a better thing would be to delete them *sometimes* + // (Comment by Ziggy) It speeds things up to not delete the buffers + // A better thing would be to delete them *sometimes* // remove_tex(pBufferAddress+1, pBufferAddress + size); add_tex(pBufferAddress); @@ -974,7 +976,7 @@ void gfxTextureBufferExt(gfxChipID_t tmu, uint32_t startAddress, gfxLOD_t lodmin grDisplayGLError("gfxTextureBufferExt :: A"); } else { - if (!render_to_texture) //initialization + if (!render_to_texture) // Initialization { if (!fbs_init) { @@ -982,7 +984,7 @@ void gfxTextureBufferExt(gfxChipID_t tmu, uint32_t startAddress, gfxLOD_t lodmin fbs_init = 1; nb_fb = 0; } - return; //no need to allocate FBO if render buffer is not texture buffer + return; // No need to allocate FBO if render buffer is not texture buffer } render_to_texture = 2; @@ -1009,7 +1011,7 @@ void gfxTextureBufferExt(gfxChipID_t tmu, uint32_t startAddress, gfxLOD_t lodmin { if (fbs[i].address == pBufferAddress) { - if (fbs[i].width == g_width && fbs[i].height == g_height) //select already allocated FBO + if (fbs[i].width == g_width && fbs[i].height == g_height) // Select already allocated FBO { glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbs[i].fbid); @@ -1021,7 +1023,7 @@ void gfxTextureBufferExt(gfxChipID_t tmu, uint32_t startAddress, gfxLOD_t lodmin if (fbs[i].buff_clear) { glDepthMask(1); - glClear(GL_DEPTH_BUFFER_BIT); //clear z-buffer only. we may need content, stored in the frame buffer + glClear(GL_DEPTH_BUFFER_BIT); // Clear Z-buffer only. We may need content, stored in the framebuffer fbs[i].buff_clear = 0; } CHECK_FRAMEBUFFER_STATUS(); @@ -1029,7 +1031,7 @@ void gfxTextureBufferExt(gfxChipID_t tmu, uint32_t startAddress, gfxLOD_t lodmin grDisplayGLError("gfxTextureBufferExt :: C"); return; } - else //create new FBO at the same address, delete old one + else // Create new FBO at the same address, delete old one { glDeleteFramebuffersEXT(1, &(fbs[i].fbid)); glDeleteRenderbuffersEXT(1, &(fbs[i].zbid)); @@ -1042,7 +1044,7 @@ void gfxTextureBufferExt(gfxChipID_t tmu, uint32_t startAddress, gfxLOD_t lodmin } remove_tex(pBufferAddress, pBufferAddress + g_width*g_height * 2/*grTexFormatSize(fmt)*/); - //create new FBO + // Create new FBO glGenFramebuffersEXT(1, &(fbs[nb_fb].fbid)); glGenRenderbuffersEXT(1, &(fbs[nb_fb].zbid)); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, fbs[nb_fb].zbid); @@ -1245,20 +1247,20 @@ void updateTexture() WriteTrace(TraceGlitch, TraceDebug, "pBufferAddress: %x", pBufferAddress); //printf("update texture %x\n", pBufferAddress); - // nothing changed, don't update the texture + // Nothing changed, don't update the texture if (!buffer_cleared) { - WriteTrace(TraceGlitch, TraceDebug, "update cancelled"); + WriteTrace(TraceGlitch, TraceDebug, "Update cancelled"); return; } glPushAttrib(GL_ALL_ATTRIB_BITS); - // save result of render to texture into actual texture + // Save result of render to texture into actual texture glReadBuffer(current_buffer); glActiveTextureARB(texture_unit); - // ZIGGY - // deleting the texture before resampling it increases speed on certain old - // nvidia cards (geforce 2 for example), unfortunatly it slows down a lot + // Comment by Ziggy + // Deleting the texture before resampling it increases speed on certain old + // Nvidia cards (GeForce 2 for example), unfortunately it slows down a lot // on newer cards. //glDeleteTextures( 1, &pBufferAddress ); glBindTexture(GL_TEXTURE_2D, pBufferAddress); @@ -1287,7 +1289,7 @@ void gfxRenderBuffer(gfxBuffer_t buffer) { updateTexture(); - // VP z fix + // VP Z fix glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0, 0, 1 - zscale); @@ -1311,7 +1313,7 @@ void gfxRenderBuffer(gfxBuffer_t buffer) #ifdef SAVE_CBUFFER if (!use_fbo && render_to_texture == 2) { - // restore color buffer + // Restore color buffer if (nbAuxBuffers > 0) { glDrawBuffer(GL_BACK); current_buffer = GL_BACK; @@ -1352,7 +1354,7 @@ void gfxRenderBuffer(gfxBuffer_t buffer) } glDrawBuffer(GL_BACK); break; - case 6: // RENDER TO TEXTURE + case 6: // Render to texture if (!render_to_texture) { savedWidth = g_width; @@ -1376,7 +1378,7 @@ void gfxRenderBuffer(gfxBuffer_t buffer) 0.0f, 0.0f, 0.0f, 1.0f }; glMatrixMode(GL_MODELVIEW); glLoadMatrixf(m); - // VP z fix + // VP Z fix glTranslatef(0, 0, 1 - zscale); glScalef(1, 1 * 1, zscale); inverted_culling = 1; @@ -1386,14 +1388,14 @@ void gfxRenderBuffer(gfxBuffer_t buffer) render_to_texture = 1; break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxRenderBuffer : unknown buffer : %x", buffer); + WriteTrace(TraceGlitch, TraceWarning, "gfxRenderBuffer: Unknown buffer : %x", buffer); } grDisplayGLError("gfxRenderBuffer"); } void gfxAuxBufferExt(gfxBuffer_t buffer) { - WriteTrace(TraceGlitch, TraceDebug, "buffer: %d", buffer); + WriteTrace(TraceGlitch, TraceDebug, "Buffer: %d", buffer); if (buffer == GFX_BUFFER_AUXBUFFER) { @@ -1434,7 +1436,7 @@ void gfxBufferClear(gfxColor_t color, gfxAlpha_t alpha, uint32_t depth) alpha / 255.0f); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxBufferClear: unknown color format : %x", lfb_color_fmt); + WriteTrace(TraceGlitch, TraceWarning, "gfxBufferClear: Unknown color format : %x", lfb_color_fmt); } if (w_buffer_mode) @@ -1443,7 +1445,7 @@ void gfxBufferClear(gfxColor_t color, gfxAlpha_t alpha, uint32_t depth) glClearDepth(depth / 65535.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - // ZIGGY TODO check that color mask is on + // (Comment by Ziggy) TODO: Check that color mask is on buffer_cleared = 1; grDisplayGLError("gfxBufferClear"); @@ -1455,7 +1457,7 @@ void gfxBufferSwap(uint32_t swap_interval) WriteTrace(TraceGlitch, TraceDebug, "swap_interval: %d", swap_interval); //printf("swap\n"); if (render_to_texture) { - WriteTrace(TraceGlitch, TraceWarning, "swap while render_to_texture\n"); + WriteTrace(TraceGlitch, TraceWarning, "Swap while render_to_texture\n"); return; } @@ -1469,13 +1471,13 @@ void gfxBufferSwap(uint32_t swap_interval) // VP debugging } -// frame buffer +// Framebuffer bool gfxLfbLock(gfxLock_t type, gfxBuffer_t buffer, gfxLfbWriteMode_t writeMode, gfxOriginLocation_t origin, bool pixelPipeline, gfxLfbInfo_t *info) { - WriteTrace(TraceGlitch, TraceDebug, "type: %d buffer: %d writeMode: %d origin: %d pixelPipeline: %d", type, buffer, writeMode, origin, pixelPipeline); + WriteTrace(TraceGlitch, TraceDebug, "Type: %d buffer: %d writeMode: %d origin: %d pixelPipeline: %d", type, buffer, writeMode, origin, pixelPipeline); if (type == GFX_LFB_WRITE_ONLY) { - WriteTrace(TraceGlitch, TraceWarning, "gfxLfbLock : write only"); + WriteTrace(TraceGlitch, TraceWarning, "gfxLfbLock: Write only"); } else { @@ -1491,7 +1493,7 @@ bool gfxLfbLock(gfxLock_t type, gfxBuffer_t buffer, gfxLfbWriteMode_t writeMode, glReadBuffer(GL_BACK); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxLfbLock : unknown buffer : %x", buffer); + WriteTrace(TraceGlitch, TraceWarning, "gfxLfbLock: Unknown buffer : %x", buffer); } if (buffer != GFX_BUFFER_AUXBUFFER) @@ -1542,10 +1544,10 @@ bool gfxLfbLock(gfxLock_t type, gfxBuffer_t buffer, gfxLfbWriteMode_t writeMode, bool gfxLfbUnlock(gfxLock_t type, gfxBuffer_t buffer) { - WriteTrace(TraceGlitch, TraceDebug, "type: %d, buffer: %d", type, buffer); + WriteTrace(TraceGlitch, TraceDebug, "Type: %d, buffer: %d", type, buffer); if (type == GFX_LFB_WRITE_ONLY) { - WriteTrace(TraceGlitch, TraceWarning, "gfxLfbUnlock : write only"); + WriteTrace(TraceGlitch, TraceWarning, "gfxLfbUnlock: Write only"); } return true; } @@ -1570,7 +1572,7 @@ bool gfxLfbReadRegion(gfxBuffer_t src_buffer, uint32_t src_x, uint32_t src_y, ui glReadBuffer(current_buffer); break;*/ default: - WriteTrace(TraceGlitch, TraceWarning, "grReadRegion : unknown buffer : %x", src_buffer); + WriteTrace(TraceGlitch, TraceWarning, "grReadRegion: Unknown buffer : %x", src_buffer); } if (src_buffer != GFX_BUFFER_AUXBUFFER) @@ -1635,7 +1637,7 @@ bool gfxLfbWriteRegion(gfxBuffer_t dst_buffer, uint32_t dst_x, uint32_t dst_y, g glDrawBuffer(current_buffer); break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxLfbWriteRegion : unknown buffer : %x", dst_buffer); + WriteTrace(TraceGlitch, TraceWarning, "gfxLfbWriteRegion: Unknown buffer : %x", dst_buffer); } if (dst_buffer != GFX_BUFFER_AUXBUFFER) @@ -1688,7 +1690,7 @@ bool gfxLfbWriteRegion(gfxBuffer_t dst_buffer, uint32_t dst_x, uint32_t dst_y, g } break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxLfbWriteRegion : unknown format : %d", src_format); + WriteTrace(TraceGlitch, TraceWarning, "gfxLfbWriteRegion: Unknown format : %d", src_format); } glBindTexture(GL_TEXTURE_2D, default_texture); @@ -1709,7 +1711,7 @@ bool gfxLfbWriteRegion(gfxBuffer_t dst_buffer, uint32_t dst_x, uint32_t dst_y, g float *buf = (float*)malloc(src_width*(src_height + (g_viewport_offset)) * sizeof(float)); if (src_format != GFX_LFBWRITEMODE_ZA16) - WriteTrace(TraceGlitch, TraceWarning, "unknown depth buffer write format:%x", src_format); + WriteTrace(TraceGlitch, TraceWarning, "Unknown depth buffer write format:%x", src_format); if (dst_x || dst_y) WriteTrace(TraceGlitch, TraceWarning, "dst_x:%d, dst_y:%d\n", dst_x, dst_y); @@ -1740,7 +1742,7 @@ bool gfxLfbWriteRegion(gfxBuffer_t dst_buffer, uint32_t dst_x, uint32_t dst_y, g return true; } -/* wrapper-specific glide extensions */ +// Wrapper-specific Glide extensions #ifdef _WIN32 static void CorrectGamma(LPVOID apGammaRamp) { @@ -1757,9 +1759,9 @@ static void CorrectGamma(const uint16_t aGammaRamp[3][256]) { int res; - /* res = SDL_SetGammaRamp(aGammaRamp[0], aGammaRamp[1], aGammaRamp[2]); */ + // res = SDL_SetGammaRamp(aGammaRamp[0], aGammaRamp[1], aGammaRamp[2]); res = -1; - fputs("ERROR: Replacement for SDL_SetGammaRamp unimplemented.\n", stderr); + fputs("Error: Replacement for SDL_SetGammaRamp unimplemented.\n", stderr); WriteTrace(TraceGlitch, TraceDebug, "SDL_SetGammaRamp returned %d\r\n", res); } #endif @@ -1789,8 +1791,8 @@ void gfxGetGammaTableExt(uint32_t /*nentries*/, uint32_t *red, uint32_t *green, { ReleaseDC(nullptr, hdc); #else - fputs("ERROR: Replacement for SDL_GetGammaRamp unimplemented.\n", stderr); - /* if (SDL_GetGammaRamp(aGammaRamp[0], aGammaRamp[1], aGammaRamp[2]) != -1) */ + fputs("Error: Replacement for SDL_GetGammaRamp unimplemented.\n", stderr); + // if (SDL_GetGammaRamp(aGammaRamp[0], aGammaRamp[1], aGammaRamp[2]) != -1) { #endif for (int i = 0; i < 256; i++) @@ -1817,15 +1819,15 @@ void gfxGammaCorrectionRGB(float gammaR, float gammaG, float gammaB) } static const char * GL_errors[7 + 1] = { - "GL_NO_ERROR", /* "There is no current error." */ - "GL_INVALID_ENUM", /* "Invalid parameter." */ - "GL_INVALID_VALUE", /* "Invalid enum parameter value." */ - "GL_INVALID_OPERATION", /* "Illegal call." */ + "GL_NO_ERROR", // "There is no current error." + "GL_INVALID_ENUM", // "Invalid parameter." + "GL_INVALID_VALUE", // "Invalid enum parameter value." + "GL_INVALID_OPERATION", // "Illegal call." "GL_STACK_OVERFLOW", "GL_STACK_UNDERFLOW", - "GL_OUT_OF_MEMORY", /* "Unable to allocate memory." */ + "GL_OUT_OF_MEMORY", // "Unable to allocate memory." - "GL_UNKNOWN_ERROR" /* ??? */ + "GL_UNKNOWN_ERROR" }; #ifndef _DEBUG @@ -1847,18 +1849,16 @@ int grDisplayGLError(const char* message) error_index = failure = 0; else error_index = - (status < GL_INVALID_ENUM) /* to avoid underflow when subtracting */ - ? (7) /* our own, made-up "GL_UNKNOWN_ERROR" error */ + (status < GL_INVALID_ENUM) // To avoid underflow when subtracting + ? (7) // Our own, made-up "GL_UNKNOWN_ERROR" error : (status - GL_INVALID_ENUM) + 1; if (error_index > 7) error_index = 7; #if !0 - /* - * In most cases, we don't want to spam the screen to repeatedly say that - * there were no OpenGL errors yet, though sometimes one may need verbosity. - */ + // In most cases, we don't want to spam the screen to repeatedly say that + // there were no OpenGL errors yet, though sometimes one may need verbosity. if (failure == 0) return (failure); #endif @@ -1876,43 +1876,43 @@ void CHECK_FRAMEBUFFER_STATUS() { GLenum status; status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); - WriteTrace(TraceGlitch, TraceDebug, "status: %X", status); + WriteTrace(TraceGlitch, TraceDebug, "Status: %X", status); switch (status) { case GL_FRAMEBUFFER_COMPLETE_EXT: - /*WriteTrace(TraceGlitch, TraceWarning, "framebuffer complete!\n");*/ + //WriteTrace(TraceGlitch, TraceWarning, "framebuffer complete!\n"); break; case GL_FRAMEBUFFER_UNSUPPORTED_EXT: - WriteTrace(TraceGlitch, TraceWarning, "framebuffer GL_FRAMEBUFFER_UNSUPPORTED_EXT\n"); - /* you gotta choose different formats */ - /*assert(0);*/ + WriteTrace(TraceGlitch, TraceWarning, "Framebuffer GL_FRAMEBUFFER_UNSUPPORTED_EXT\n"); + // You have to choose different formats + //assert(0); break; case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: - WriteTrace(TraceGlitch, TraceWarning, "framebuffer INCOMPLETE_ATTACHMENT\n"); + WriteTrace(TraceGlitch, TraceWarning, "Framebuffer INCOMPLETE_ATTACHMENT\n"); break; case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: - WriteTrace(TraceGlitch, TraceWarning, "framebuffer FRAMEBUFFER_MISSING_ATTACHMENT\n"); + WriteTrace(TraceGlitch, TraceWarning, "Framebuffer FRAMEBUFFER_MISSING_ATTACHMENT\n"); break; case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: - WriteTrace(TraceGlitch, TraceWarning, "framebuffer FRAMEBUFFER_DIMENSIONS\n"); + WriteTrace(TraceGlitch, TraceWarning, "Framebuffer FRAMEBUFFER_DIMENSIONS\n"); break; - /*case GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT: - WriteTrace(TraceGlitch, TraceWarning, "framebuffer INCOMPLETE_DUPLICATE_ATTACHMENT\n"); - break;*/ + //case GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT: + // WriteTrace(TraceGlitch, TraceWarning, "Framebuffer INCOMPLETE_DUPLICATE_ATTACHMENT\n"); + // break; case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT: - WriteTrace(TraceGlitch, TraceWarning, "framebuffer INCOMPLETE_FORMATS\n"); + WriteTrace(TraceGlitch, TraceWarning, "Framebuffer INCOMPLETE_FORMATS\n"); break; case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: - WriteTrace(TraceGlitch, TraceWarning, "framebuffer INCOMPLETE_DRAW_BUFFER\n"); + WriteTrace(TraceGlitch, TraceWarning, "Framebuffer INCOMPLETE_DRAW_BUFFER\n"); break; case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: - WriteTrace(TraceGlitch, TraceWarning, "framebuffer INCOMPLETE_READ_BUFFER\n"); + WriteTrace(TraceGlitch, TraceWarning, "Framebuffer INCOMPLETE_READ_BUFFER\n"); break; case GL_FRAMEBUFFER_BINDING_EXT: - WriteTrace(TraceGlitch, TraceWarning, "framebuffer BINDING_EXT\n"); + WriteTrace(TraceGlitch, TraceWarning, "Framebuffer BINDING_EXT\n"); break; default: break; - /* programming error; will fail on all hardware */ - /*assert(0);*/ + // Programming error; will fail on all hardware + //assert(0); } } \ No newline at end of file diff --git a/Source/Project64-video/Renderer/OGLtextures.cpp b/Source/Project64-video/Renderer/OGLtextures.cpp index d51aaebf1..4341ba2dc 100644 --- a/Source/Project64-video/Renderer/OGLtextures.cpp +++ b/Source/Project64-video/Renderer/OGLtextures.cpp @@ -1,9 +1,10 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2003-2009 Sergey 'Gonetz' Lipski // Copyright(C) 2002 Dave2001 // GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html + #include #ifdef _WIN32 #include @@ -99,7 +100,7 @@ void add_tex(unsigned int id) return; } while (aux->next != nullptr && aux->next->id < id) aux = aux->next; - // ZIGGY added this test so that add_tex now accept re-adding an existing texture + // (Comment by Ziggy) Added this test so that add_tex now accepts re-adding an existing texture if (aux->next != nullptr && aux->next->id == id) return; nbTex++; aux2 = aux->next; @@ -111,7 +112,7 @@ void add_tex(unsigned int id) void init_textures() { tex0_width = tex0_height = tex1_width = tex1_height = 2; - // ZIGGY because remove_tex isn't called (Pj64 doesn't like it), it's better + // (Comment by Ziggy) Because remove_tex isn't called (Project64 doesn't like it), it's better // to leave these so that they'll be reused (otherwise we have a memory leak) // list = nullptr; // nbTex = 0; @@ -122,7 +123,7 @@ void init_textures() void free_textures() { #ifndef WIN32 - // ZIGGY for some reasons, Pj64 doesn't like remove_tex on exit + // (Comment by Ziggy) For some reason, Project64 doesn't like remove_tex on exit remove_tex(0x00000000, 0xFFFFFFFF); #endif if (texture != nullptr) { @@ -147,7 +148,7 @@ uint32_t gfxTexTextureMemRequired(uint32_t evenOdd, gfxTexInfo *info) { WriteTrace(TraceGlitch, TraceDebug, "evenOdd = %d", evenOdd); int width, height; - if (info->largeLodLog2 != info->smallLodLog2) WriteTrace(TraceGlitch, TraceWarning, "gfxTexTextureMemRequired : loading more than one LOD"); + if (info->largeLodLog2 != info->smallLodLog2) WriteTrace(TraceGlitch, TraceWarning, "gfxTexTextureMemRequired: Loading more than one LOD"); if (info->aspectRatioLog2 < 0) { @@ -185,7 +186,7 @@ uint32_t gfxTexTextureMemRequired(uint32_t evenOdd, gfxTexInfo *info) case GFX_TEXFMT_ARGB_CMP_FXT1: return ((((width + 0x7)&~0x7)*((height + 0x3)&~0x3)) >> 1); default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexTextureMemRequired : unknown texture format: %x", info->format); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexTextureMemRequired: Unknown texture format: %x", info->format); } return 0; } @@ -194,7 +195,7 @@ uint32_t gfxTexCalcMemRequired(gfxLOD_t lodmin, gfxLOD_t lodmax, gfxAspectRatio_ { WriteTrace(TraceGlitch, TraceDebug, "lodmin = %d, lodmax: %d aspect: %d fmt: %d", lodmin, lodmax, aspect, fmt); int width, height; - if (lodmax != lodmin) WriteTrace(TraceGlitch, TraceWarning, "gfxTexCalcMemRequired : loading more than one LOD"); + if (lodmax != lodmin) WriteTrace(TraceGlitch, TraceWarning, "gfxTexCalcMemRequired: Loading more than one LOD"); if (aspect < 0) { @@ -232,7 +233,7 @@ uint32_t gfxTexCalcMemRequired(gfxLOD_t lodmin, gfxLOD_t lodmax, gfxAspectRatio_ case GFX_TEXFMT_ARGB_CMP_FXT1: return ((((width + 0x7)&~0x7)*((height + 0x3)&~0x3)) >> 1); default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexTextureMemRequired : unknown texture format: %x", fmt); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexTextureMemRequired: Unknown texture format: %x", fmt); } return 0; } @@ -276,7 +277,7 @@ int grTexFormatSize(int fmt) factor = 8; break; default: - WriteTrace(TraceGlitch, TraceWarning, "grTexFormatSize : unknown texture format: %x", fmt); + WriteTrace(TraceGlitch, TraceWarning, "grTexFormatSize: Unknown texture format: %x", fmt); } return factor; } @@ -334,7 +335,7 @@ int grTexFormat2GLPackedFmt(int fmt, int * gltexfmt, int * glpixfmt, int * glpac // HACKALERT: 3Dfx Glide uses GFX_TEXFMT_ARGB_CMP_DXT1 for both opaque DXT1 and DXT1 with 1bit alpha. // GlideHQ compiled with GLIDE64_DXTN option enabled, uses opaqe DXT1 only. factor = 8; // HACKALERT: factor holds block bytes - *gltexfmt = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; // these variables aren't used + *gltexfmt = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; // These variables aren't used *glpixfmt = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; *glpackfmt = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; break; @@ -354,10 +355,10 @@ int grTexFormat2GLPackedFmt(int fmt, int * gltexfmt, int * glpixfmt, int * glpac factor = 8; *gltexfmt = GL_COMPRESSED_RGBA_FXT1_3DFX; *glpixfmt = GL_COMPRESSED_RGBA_FXT1_3DFX; - *glpackfmt = GL_COMPRESSED_RGBA_FXT1_3DFX; // XXX: what should we do about GL_COMPRESSED_RGB_FXT1_3DFX? + *glpackfmt = GL_COMPRESSED_RGBA_FXT1_3DFX; // what should we do about GL_COMPRESSED_RGB_FXT1_3DFX? break; default: - WriteTrace(TraceGlitch, TraceWarning, "grTexFormat2GLPackedFmt : unknown texture format: %x", fmt); + WriteTrace(TraceGlitch, TraceWarning, "grTexFormat2GLPackedFmt: Unknown texture format: %x", fmt); } return factor; } @@ -370,7 +371,7 @@ void gfxTexDownloadMipMap(gfxChipID_t tmu, uint32_t startAddress, gfxMipMapLevel int factor; int glformat = 0; int gltexfmt = 0, glpixfmt = 0, glpackfmt = 0; - if (info->largeLodLog2 != info->smallLodLog2) WriteTrace(TraceGlitch, TraceWarning, "gfxTexDownloadMipMap : loading more than one LOD"); + if (info->largeLodLog2 != info->smallLodLog2) WriteTrace(TraceGlitch, TraceWarning, "gfxTexDownloadMipMap: Loading more than one LOD"); if (info->aspectRatioLog2 < 0) { @@ -433,7 +434,7 @@ void gfxTexDownloadMipMap(gfxChipID_t tmu, uint32_t startAddress, gfxMipMapLevel { unsigned int texel = (unsigned int)((unsigned char*)info->data)[m]; #if 1 - /* accurate conversion */ + // Accurate conversion unsigned int texel_hi = (texel & 0x000000F0) << 20; unsigned int texel_low = texel & 0x0000000F; texel_low |= (texel_low << 4); @@ -462,7 +463,7 @@ void gfxTexDownloadMipMap(gfxChipID_t tmu, uint32_t startAddress, gfxMipMapLevel unsigned int G = texel & 0x000007E0; unsigned int R = texel & 0x0000001F; #if 0 - /* accurate conversion */ + // Accurate conversion ((unsigned int*)texture)[n] = 0xFF000000 | (R << 19) | ((R >> 2) << 16) | (G << 5) | ((G >> 9) << 8) | (B >> 8) | (B >> 13); #else ((unsigned int*)texture)[n] = 0xFF000000 | (R << 19) | (G << 5) | (B >> 8); @@ -485,7 +486,7 @@ void gfxTexDownloadMipMap(gfxChipID_t tmu, uint32_t startAddress, gfxMipMapLevel unsigned int G = texel & 0x000003E0; unsigned int R = texel & 0x0000001F; #if 0 - /* accurate conversion */ + // Accurate conversion ((unsigned int*)texture)[n] = A | (R << 19) | ((R >> 2) << 16) | (G << 6) | ((G >> 8) << 8) | (B >> 7) | (B >> 12); #else ((unsigned int*)texture)[n] = A | (R << 19) | (G << 6) | (B >> 7); @@ -524,7 +525,7 @@ void gfxTexDownloadMipMap(gfxChipID_t tmu, uint32_t startAddress, gfxMipMapLevel unsigned int G = texel & 0x000000F0; unsigned int R = texel & 0x0000000F; #if 0 - /* accurate conversion */ + // Accurate conversion ((unsigned int*)texture)[n] = (A << 16) | (A << 12) | (R << 20) | (R << 16) | (G << 8) | (G << 4) | (B >> 4) | (B >> 8); #else ((unsigned int*)texture)[n] = (A << 16) | (R << 20) | (G << 8) | (B >> 4); @@ -571,7 +572,7 @@ void gfxTexDownloadMipMap(gfxChipID_t tmu, uint32_t startAddress, gfxMipMapLevel glformat = GL_COMPRESSED_RGBA_FXT1_3DFX; break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexDownloadMipMap : unknown texture format: %x", info->format); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexDownloadMipMap: Unknown texture format: %x", info->format); factor = 0; } } @@ -691,7 +692,7 @@ void gfxTexDetailControl(gfxChipID_t tmu, int lod_bias, uint8_t detail_scale, fl { if (!lod_bias && !detail_scale && !detail_max) return; else - WriteTrace(TraceGlitch, TraceWarning, "gfxTexDetailControl : %d, %d, %f", lod_bias, detail_scale, detail_max); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexDetailControl: %d, %d, %f", lod_bias, detail_scale, detail_max); } lambda = detail_max; if (lambda > 1.0f) @@ -752,7 +753,7 @@ void gfxTexClampMode(gfxChipID_t tmu, gfxTextureClampMode_t s_clampmode, gfxText wrap_s0 = GL_MIRRORED_REPEAT_ARB; break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexClampMode : unknown s_clampmode : %x", s_clampmode); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexClampMode: Unknown s_clampmode : %x", s_clampmode); } switch (t_clampmode) { @@ -766,7 +767,7 @@ void gfxTexClampMode(gfxChipID_t tmu, gfxTextureClampMode_t s_clampmode, gfxText wrap_t0 = GL_MIRRORED_REPEAT_ARB; break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexClampMode : unknown t_clampmode : %x", t_clampmode); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexClampMode: Unknown t_clampmode : %x", t_clampmode); } glActiveTextureARB(GL_TEXTURE0_ARB); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap_s0); @@ -786,7 +787,7 @@ void gfxTexClampMode(gfxChipID_t tmu, gfxTextureClampMode_t s_clampmode, gfxText wrap_s1 = GL_MIRRORED_REPEAT_ARB; break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexClampMode : unknown s_clampmode : %x", s_clampmode); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexClampMode: Unknown s_clampmode : %x", s_clampmode); } switch (t_clampmode) { @@ -800,7 +801,7 @@ void gfxTexClampMode(gfxChipID_t tmu, gfxTextureClampMode_t s_clampmode, gfxText wrap_t1 = GL_MIRRORED_REPEAT_ARB; break; default: - WriteTrace(TraceGlitch, TraceWarning, "gfxTexClampMode : unknown t_clampmode : %x", t_clampmode); + WriteTrace(TraceGlitch, TraceWarning, "gfxTexClampMode: Unknown t_clampmode : %x", t_clampmode); } glActiveTextureARB(GL_TEXTURE1_ARB); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap_s1); diff --git a/Source/Project64-video/Renderer/Renderer.cpp b/Source/Project64-video/Renderer/Renderer.cpp index 87288b608..de44836fe 100644 --- a/Source/Project64-video/Renderer/Renderer.cpp +++ b/Source/Project64-video/Renderer/Renderer.cpp @@ -1,9 +1,10 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2003-2009 Sergey 'Gonetz' Lipski // Copyright(C) 2002 Dave2001 -// GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.htmlfs +// GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html + #include uint32_t nbTextureUnits = 0; diff --git a/Source/Project64-video/Renderer/Renderer.h b/Source/Project64-video/Renderer/Renderer.h index 6b66cb049..d63ff4d8d 100644 --- a/Source/Project64-video/Renderer/Renderer.h +++ b/Source/Project64-video/Renderer/Renderer.h @@ -1,9 +1,10 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2003-2009 Sergey 'Gonetz' Lipski // Copyright(C) 2002 Dave2001 // GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html + #pragma once #include diff --git a/Source/Project64-video/Renderer/glitchmain.h b/Source/Project64-video/Renderer/glitchmain.h index 267e8856b..b39db13c3 100644 --- a/Source/Project64-video/Renderer/glitchmain.h +++ b/Source/Project64-video/Renderer/glitchmain.h @@ -1,9 +1,10 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2003-2009 Sergey 'Gonetz' Lipski // Copyright(C) 2002 Dave2001 // GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html + #pragma once #ifndef _WIN32 @@ -22,22 +23,22 @@ extern int dumping; #define zscale 1.0f // VP added this utility function -// returns the bytes per pixel of a given GR texture format +// Returns the bytes per pixel of a given GR texture format int grTexFormatSize(int fmt); -/* 2015.03.07 cxd4 -- regulated GL state machine debugging using glGetError */ +// 03/07/2015 Comment by cxd4 -- regulated GL state machine debugging using glGetError extern int grDisplayGLError(const char* message); extern int packed_pixels_support; extern int ati_sucks; extern float largest_supported_anisotropy; -extern int default_texture; // the infamous "32*1024*1024" is now configurable +extern int default_texture; // The infamous "32*1024*1024" is now configurable extern int depth_texture; void set_depth_shader(); void set_bw_shader(); extern float invtex[2]; -extern int buffer_cleared; // mark that the buffer has been cleared, used to check if we need to reload the texture buffer content +extern int buffer_cleared; // Mark that the buffer has been cleared, used to check if we need to reload the texture buffer content #ifdef _WIN32 #include @@ -123,7 +124,7 @@ void check_link(GLuint program); void vbo_enable(); void vbo_disable(); -//Vertex Attribute Locations +// Vertex attribute locations #define POSITION_ATTR 0 #define COLOUR_ATTR 1 #define TEXCOORD_0_ATTR 2 diff --git a/Source/Project64-video/Renderer/opengl.h b/Source/Project64-video/Renderer/opengl.h index 0416fc200..781ee247e 100644 --- a/Source/Project64-video/Renderer/opengl.h +++ b/Source/Project64-video/Renderer/opengl.h @@ -11,7 +11,7 @@ extern "C" typedef unsigned int GLenum; #else -#include /* Header File For The OpenGL Library */ +#include // Header file for the OpenGL library #endif #ifndef APIENTRY @@ -21,8 +21,6 @@ typedef unsigned int GLenum; #define APIENTRYP APIENTRY * #endif - /*************************************************************/ - #define GL_UNSIGNED_SHORT_5_6_5 0x8363 #define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 #define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 @@ -67,11 +65,9 @@ typedef unsigned int GLenum; #define GL_RENDERBUFFER_EXT 0x8D41 #endif - /*************************************************************/ - #include #ifndef GL_VERSION_2_0 - /* GL type for program/shader text */ + // OpenGL type for program/shader text typedef char GLchar; #endif @@ -124,7 +120,7 @@ typedef unsigned int GLenum; #endif #ifndef GL_ARB_shader_objects - /* GL types for program/shader text and shader object handles */ + // OpenGL types for program/shader text and shader object handles typedef char GLcharARB; #if defined(__APPLE__) typedef void *GLhandleARB; diff --git a/Source/Project64-video/Renderer/types.h b/Source/Project64-video/Renderer/types.h index 0891d3937..48c21f2d0 100644 --- a/Source/Project64-video/Renderer/types.h +++ b/Source/Project64-video/Renderer/types.h @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2003-2009 Sergey 'Gonetz' Lipski // Copyright(C) 2002 Dave2001 @@ -71,11 +71,11 @@ enum gfxTextureFormat_t GFX_TEXFMT_8BIT = 0x0, GFX_TEXFMT_RGB_332 = GFX_TEXFMT_8BIT, GFX_TEXFMT_YIQ_422 = 0x1, - GFX_TEXFMT_ALPHA_8 = 0x2, /* (0..0xFF) alpha */ - GFX_TEXFMT_INTENSITY_8 = 0x3, /* (0..0xFF) intensity */ + GFX_TEXFMT_ALPHA_8 = 0x2, // (0..0xFF) alpha + GFX_TEXFMT_INTENSITY_8 = 0x3, // (0..0xFF) intensity GFX_TEXFMT_ALPHA_INTENSITY_44 = 0x4, - GFX_TEXFMT_P_8 = 0x5, /* 8-bit palette */ - GFX_TEXFMT_RSVD0 = 0x6, /* GFX_TEXFMT_P_8_RGBA */ + GFX_TEXFMT_P_8 = 0x5, // 8-bit palette + GFX_TEXFMT_RSVD0 = 0x6, // GFX_TEXFMT_P_8_RGBA GFX_TEXFMT_P_8_6666 = GFX_TEXFMT_RSVD0, GFX_TEXFMT_P_8_6666_EXT = GFX_TEXFMT_RSVD0, GFX_TEXFMT_RSVD1 = 0x7, @@ -86,7 +86,7 @@ enum gfxTextureFormat_t GFX_TEXFMT_ARGB_1555 = 0xb, GFX_TEXFMT_ARGB_4444 = 0xc, GFX_TEXFMT_ALPHA_INTENSITY_88 = 0xd, - GFX_TEXFMT_AP_88 = 0xe, /* 8-bit alpha 8-bit palette */ + GFX_TEXFMT_AP_88 = 0xe, // 8-bit alpha, 8-bit palette GFX_TEXFMT_RSVD2 = 0xf, GFX_TEXFMT_RSVD4 = GFX_TEXFMT_RSVD2, GFX_TEXFMT_ARGB_CMP_FXT1 = 0x11, @@ -105,13 +105,13 @@ enum gfxTextureFormat_t enum gfxAspectRatio_t { - GFX_ASPECT_LOG2_8x1 = 3, /* 8W x 1H */ - GFX_ASPECT_LOG2_4x1 = 2, /* 4W x 1H */ - GFX_ASPECT_LOG2_2x1 = 1, /* 2W x 1H */ - GFX_ASPECT_LOG2_1x1 = 0, /* 1W x 1H */ - GFX_ASPECT_LOG2_1x2 = -1, /* 1W x 2H */ - GFX_ASPECT_LOG2_1x4 = -2, /* 1W x 4H */ - GFX_ASPECT_LOG2_1x8 = -3, /* 1W x 8H */ + GFX_ASPECT_LOG2_8x1 = 3, // 8W x 1H + GFX_ASPECT_LOG2_4x1 = 2, // 4W x 1H + GFX_ASPECT_LOG2_2x1 = 1, // 2W x 1H + GFX_ASPECT_LOG2_1x1 = 0, // 1W x 1H + GFX_ASPECT_LOG2_1x2 = -1, // 1W x 2H + GFX_ASPECT_LOG2_1x4 = -2, // 1W x 4H + GFX_ASPECT_LOG2_1x8 = -3, // 1W x 8H }; enum gfxCombineFunction_t @@ -263,22 +263,22 @@ enum gfxDepthBufferMode_t enum gfxLfbWriteMode_t { - GFX_LFBWRITEMODE_565 = 0x0, /* RGB:RGB */ - GFX_LFBWRITEMODE_555 = 0x1, /* RGB:RGB */ - GFX_LFBWRITEMODE_1555 = 0x2, /* ARGB:ARGB */ + GFX_LFBWRITEMODE_565 = 0x0, // RGB:RGB + GFX_LFBWRITEMODE_555 = 0x1, // RGB:RGB + GFX_LFBWRITEMODE_1555 = 0x2, // ARGB:ARGB GFX_LFBWRITEMODE_RESERVED1 = 0x3, - GFX_LFBWRITEMODE_888 = 0x4, /* RGB */ - GFX_LFBWRITEMODE_8888 = 0x5, /* ARGB */ + GFX_LFBWRITEMODE_888 = 0x4, // RGB + GFX_LFBWRITEMODE_8888 = 0x5, // ARGB GFX_LFBWRITEMODE_RESERVED2 = 0x6, GFX_LFBWRITEMODE_RESERVED3 = 0x7, GFX_LFBWRITEMODE_RESERVED4 = 0x8, GFX_LFBWRITEMODE_RESERVED5 = 0x9, GFX_LFBWRITEMODE_RESERVED6 = 0xa, GFX_LFBWRITEMODE_RESERVED7 = 0xb, - GFX_LFBWRITEMODE_565_DEPTH = 0xc, /* RGB:DEPTH */ - GFX_LFBWRITEMODE_555_DEPTH = 0xd, /* RGB:DEPTH */ - GFX_LFBWRITEMODE_1555_DEPTH = 0xe, /* ARGB:DEPTH */ - GFX_LFBWRITEMODE_ZA16 = 0xf, /* DEPTH:DEPTH */ + GFX_LFBWRITEMODE_565_DEPTH = 0xc, // RGB:DEPTH + GFX_LFBWRITEMODE_555_DEPTH = 0xd, // RGB:DEPTH + GFX_LFBWRITEMODE_1555_DEPTH = 0xe, // ARGB:DEPTH + GFX_LFBWRITEMODE_ZA16 = 0xf, // DEPTH:DEPTH GFX_LFBWRITEMODE_ANY = 0xFF, }; @@ -377,25 +377,25 @@ typedef struct uint16_t flags; uint8_t b; // These values are arranged like this so that *(uint32_t*)(gfxVERTEX+?) is - uint8_t g; // ARGB format that glide can use. + uint8_t g; // ARGB format that Glide can use uint8_t r; uint8_t a; - float f; //fog + float f; // Fog - float vec[3]; // normal vector + float vec[3]; // Normal vector float sx, sy, sz; float x_w, y_w, z_w, u0_w, v0_w, u1_w, v1_w, oow; uint8_t not_zclipped; uint8_t screen_translated; uint8_t uv_scaled; - uint32_t uv_calculated; // like crc + uint32_t uv_calculated; // Like CRC uint32_t shade_mod; uint32_t color_backup; float ou, ov; - int number; // way to identify it - int scr_off, z_off; // off the screen? + int number; // Way to identify it + int scr_off, z_off; // Off the screen? } gfxVERTEX; \ No newline at end of file diff --git a/Source/Project64-video/TextureEnhancer/Ext_TxFilter.h b/Source/Project64-video/TextureEnhancer/Ext_TxFilter.h index 21cbde70e..79d23bb22 100644 --- a/Source/Project64-video/TextureEnhancer/Ext_TxFilter.h +++ b/Source/Project64-video/TextureEnhancer/Ext_TxFilter.h @@ -1,9 +1,10 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2003 Rice1964 // GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html + #pragma once #include @@ -54,7 +55,7 @@ #define UNDEFINED_0 0x08000000 #define FORCE16BPP_HIRESTEX 0x10000000 #define FORCE16BPP_TEX 0x20000000 -#define LET_TEXARTISTS_FLY 0x40000000 /* a little freedom for texture artists */ +#define LET_TEXARTISTS_FLY 0x40000000 // A little freedom for texture artists #define DUMP_TEX 0x80000000 struct GHQTexInfo { @@ -74,8 +75,8 @@ struct GHQTexInfo { unsigned char is_hires_tex; }; -/* Callback to display hires texture info. - * Gonetz +/* Callback to display high resolution texture info. + * Gonetz * * void DispInfo(const char *format, ...) * { @@ -94,48 +95,48 @@ struct GHQTexInfo { typedef void(*dispInfoFuncExt)(const char *format, ...); #ifndef TXFILTER_DLL -bool ext_ghq_init(int maxwidth, /* maximum texture width supported by hardware */ - int maxheight,/* maximum texture height supported by hardware */ - int maxbpp, /* maximum texture bpp supported by hardware */ - int options, /* options */ - int cachesize,/* cache textures to system memory */ - const char *path, /* plugin directory. must be smaller than MAX_PATH */ - const char *ident, /* name of ROM. must be no longer than 64 in character. */ - dispInfoFuncExt callback /* callback function to display info */ +bool ext_ghq_init(int maxwidth, // Maximum texture width supported by hardware + int maxheight, // Maximum texture height supported by hardware + int maxbpp, // Maximum texture bpp supported by hardware + int options, // Options + int cachesize, // Cache textures to system memory + const char *path, // Plugin directory, must be smaller than MAX_PATH + const char *ident, // Name of ROM, must be no longer than 64 characters + dispInfoFuncExt callback // Callback function to display info ); void ext_ghq_shutdown(void); -bool ext_ghq_txfilter(unsigned char *src, /* input texture */ - int srcwidth, /* width of input texture */ - int srcheight, /* height of input texture */ - unsigned short srcformat, /* format of input texture */ - uint64_t g64crc, /* glide64 crc */ - GHQTexInfo *info /* output */ +bool ext_ghq_txfilter(unsigned char *src, // Input texture + int srcwidth, // Width of input texture + int srcheight, // Height of input texture + unsigned short srcformat, // Format of input texture + uint64_t g64crc, // Glide64 CRC + GHQTexInfo *info // Output ); -bool ext_ghq_hirestex(uint64_t g64crc, /* glide64 crc */ - uint64_t r_crc64, /* checksum hi:palette low:texture */ - unsigned short *palette, /* palette for CI textures */ - GHQTexInfo *info /* output */ +bool ext_ghq_hirestex(uint64_t g64crc, // Glide64 CRC + uint64_t r_crc64, // Checksum hi:palette low:texture + unsigned short *palette, // Palette for CI textures + GHQTexInfo *info // Output ); -uint64_t ext_ghq_checksum(unsigned char *src, /* input texture */ - int width, /* width of texture */ - int height, /* height of texture */ - int size, /* type of texture pixel */ - int rowStride, /* row stride in bytes */ - unsigned char *palette /* palette */ +uint64_t ext_ghq_checksum(unsigned char *src, // Input texture + int width, // Width of texture + int height, // Height of texture + int size, // Type of texture pixel + int rowStride, // Row stride in bytes + unsigned char *palette // Palette ); -bool ext_ghq_dmptx(unsigned char *src, /* input texture (must be in 3Dfx Glide format) */ - int width, /* width of texture */ - int height, /* height of texture */ - int rowStridePixel, /* row stride of input texture in pixels */ - unsigned short gfmt, /* glide format of input texture */ - unsigned short n64fmt,/* N64 format hi:format low:size */ - uint64_t r_crc64 /* checksum hi:palette low:texture */ +bool ext_ghq_dmptx(unsigned char *src, // Input texture (must be in 3DFX Glide format) + int width, // Width of texture + int height, // Height of texture + int rowStridePixel, // Row stride of input texture in pixels + unsigned short gfmt, // Glide format of input texture + unsigned short n64fmt,// N64 format hi:format low:size + uint64_t r_crc64 // Checksum hi:palette low:texture ); bool ext_ghq_reloadhirestex(); -#endif /* TXFILTER_DLL */ +#endif // TXFILTER_DLL diff --git a/Source/Project64-video/TextureEnhancer/README.txt b/Source/Project64-video/TextureEnhancer/README.txt index c903e5736..0db3e5cda 100644 --- a/Source/Project64-video/TextureEnhancer/README.txt +++ b/Source/Project64-video/TextureEnhancer/README.txt @@ -1,28 +1,26 @@ -/* - * GlideHQ (Texture enhancer library for Glide64) - * Version: 1.5 - * - * Copyright (C) 2007 Hiroshi Morii aka KoolSmoky All Rights Reserved. - * Email koolsmoky(at)users.sourceforge.net - * Web http://www.3dfxzone.it/koolsmoky - * - * this is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * this is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - */ +GlideHQ (Texture enhancer library for Glide64) +Version: 1.5 + +Copyright (C) 2007 Hiroshi Morii aka KoolSmoky All Rights Reserved. +Email: koolsmoky(at)users.sourceforge.net +Website: http://www.3dfxzone.it/koolsmoky + +This is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Make; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. About: -This is a realtime texture enhancer library with hi-resolution texture +This is a real-time texture enhancer library with high-resolution texture pack support for Glide64 (http://glide64.emuxhaven.net). Traditional and non-traditional techniques have been used to achieve speed and high image quality even on a 9 year old 3Dfx Voodoo2. @@ -31,8 +29,8 @@ Although the 3Dfx Glide3x texture format naming conventions are used, the library can be expanded for generic use. Supported: -OS: 32bit Linux and MS Windows -Enhancers: Hq4x, Hq2x, Hq2xS, Lq2x, Lq2xS, Super2xSai, x2 +OS: 32-bit Linux and Microsoft Windows +Enhancers: HQ4X, HQ2X, HQ2XS, LQ2X, LQ2XS, Super2xSai, x2 Filters: Smooth (1,2,3,4), Sharp (1,2) Compressors: FXT1, S3TC Input formats: GR_TEXFMT_ALPHA_8, @@ -42,8 +40,8 @@ Input formats: GR_TEXFMT_ALPHA_8, GR_TEXFMT_ARGB_8888, GR_TEXFMT_ALPHA_INTENSITY_44, GR_TEXFMT_ALPHA_INTENSITY_88 -Output formats: Same as input unless compression or hires packs are used. -Hires texture packs: Rice format (Jabo and GlideHQ format coming later) +Output formats: Same as input unless compression or high resolution packs are used. +High resolution texture packs: Rice format (Jabo and GlideHQ format coming later) Acknowledgments: I hope you enjoy GlideHQ (texture enhancer library for Glide64). Greatest @@ -59,15 +57,15 @@ special thanks to the Glide64 beta testing crew. Without their feedbacks this library would not have seen daylight. Thank you all. The source code for GlideHQ is released in hopes that it will be improved. -I know the coding is not on par after so much late night caffeine boosts. +I know the coding is not on par after so many late night caffeine boosts. If you have suggestions or modifications, please feel free to post them on the Glide64 forum at emuxhaven. Porting the library to other platforms should not be so hard. The coding is done with cross platform compatibility in mind and will build with GCC and -GNU make. Currently supported are 32bit Linux and MS Windows. +GNU make. Currently supported are 32-bit Linux and Microsoft Windows. -If you are looking for driver updates for your 3Dfx Interactive Inc. gfx +If you are looking for driver updates for your 3Dfx Interactive Inc. graphics card, grab them from the forums at http://www.3dfxzone.it/enboard/ Unbelievable as it seems, drivers are still being updated after 6 years from 3Dfx's demise. diff --git a/Source/Project64-video/TextureEnhancer/TextureFilters.cpp b/Source/Project64-video/TextureEnhancer/TextureFilters.cpp index d3d559f57..58d650662 100644 --- a/Source/Project64-video/TextureEnhancer/TextureFilters.cpp +++ b/Source/Project64-video/TextureEnhancer/TextureFilters.cpp @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2003 Rice1964 @@ -8,9 +8,7 @@ #include #include "TextureFilters.h" -/************************************************************************/ -/* 2X filters */ -/************************************************************************/ +/* 2X filters */ #define DWORD_MAKE(r, g, b, a) ((uint32) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))) #define WORD_MAKE(r, g, b, a) ((uint16) (((a) << 12) | ((r) << 8) | ((g) << 4) | (b))) @@ -226,13 +224,14 @@ void Texture2x_16(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch #endif /* !_16BPP_HACK */ /* - * Sharp filters - * Hiroshi Morii - */ +Sharp filters +Hiroshi Morii +*/ + void SharpFilter_8888(uint32 *src, uint32 srcwidth, uint32 srcheight, uint32 *dest, uint32 filter) { - // NOTE: for now we get away with copying the boundaries - // filter the boundaries if we face problems + // NOTE: For now we get away with copying the boundaries + // filter the boundaries if we face problems uint32 mul1, mul2, mul3, shift4; @@ -258,20 +257,20 @@ void SharpFilter_8888(uint32 *src, uint32 srcwidth, uint32 srcheight, uint32 *de break; } - // setup rows + // Setup rows _src1 = src; _src2 = _src1 + srcwidth; _src3 = _src2 + srcwidth; _dest = dest; - // copy the first row + // Copy the first row memcpy(_dest, _src1, (srcwidth << 2)); _dest += srcwidth; - // filter 2nd row to 1 row before the last + // Filter 2nd row to 1 row before the last for (y = 1; y < srcheight - 1; y++) { - // copy the first pixel + // Copy the first pixel _dest[0] = *_src2; - // filter 2nd pixel to 1 pixel before last + // Filter 2nd pixel to 1 pixel before last for (x = 1; x < srcwidth - 1; x++) { for (z = 0; z < 4; z++) { t1 = *((uint8*)(_src1 + x - 1) + z); @@ -294,23 +293,23 @@ void SharpFilter_8888(uint32 *src, uint32 srcwidth, uint32 srcheight, uint32 *de } _dest[x] = val[0] | (val[1] << 8) | (val[2] << 16) | (val[3] << 24); } - // copy the ending pixel + // Copy the ending pixel _dest[srcwidth - 1] = *(_src3 - 1); - // next row + // Next row _src1 += srcwidth; _src2 += srcwidth; _src3 += srcwidth; _dest += srcwidth; } - // copy the last row + // Copy the last row memcpy(_dest, _src2, (srcwidth << 2)); } #if !_16BPP_HACK void SharpFilter_4444(uint16 *src, uint32 srcwidth, uint32 srcheight, uint16 *dest, uint32 filter) { - // NOTE: for now we get away with copying the boundaries - // filter the boundaries if we face problems + // NOTE: For now we get away with copying the boundaries + // filter the boundaries if we face problems uint16 mul1, mul2, mul3, shift4; @@ -335,25 +334,25 @@ void SharpFilter_4444(uint16 *src, uint32 srcwidth, uint32 srcheight, uint16 *de break; } - // setup rows + // Setup rows _src1 = src; _src2 = _src1 + srcwidth; _src3 = _src2 + srcwidth; _dest = dest; - // copy the first row + // Copy the first row memcpy(_dest, _src1, (srcwidth << 1)); _dest += srcwidth; - // filter 2nd row to 1 row before the last + // Filter 2nd row to 1 row before the last for (y = 1; y < srcheight - 1; y++) { - // copy the first pixel + // Copy the first pixel _dest[0] = *_src2; - // filter 2nd pixel to 1 pixel before last + // Filter 2nd pixel to 1 pixel before last for (x = 1; x < srcwidth - 1; x++) { for (z = 0; z < 4; z++) { - /* Hiroshi Morii - * Read the entire 16bit pixel and then extract the A,R,G,B components. - */ + // Hiroshi Morii + // Read the entire 16-bit pixel and then extract the A,R,G,B components. + uint32 shift = z << 2; t1 = ((*((uint16*)(_src1 + x - 1))) >> shift) & 0xF; t2 = ((*((uint16*)(_src1 + x))) >> shift) & 0xF; @@ -375,27 +374,26 @@ void SharpFilter_4444(uint16 *src, uint32 srcwidth, uint32 srcheight, uint16 *de } _dest[x] = val[0] | (val[1] << 4) | (val[2] << 8) | (val[3] << 12); } - // copy the ending pixel + // Copy the ending pixel _dest[srcwidth - 1] = *(_src3 - 1); - // next row + // Next row _src1 += srcwidth; _src2 += srcwidth; _src3 += srcwidth; _dest += srcwidth; } - // copy the last row + // Copy the last row memcpy(_dest, _src2, (srcwidth << 1)); } #endif /* !_16BPP_HACK */ -/* - * Smooth filters - * Hiroshi Morii - */ +// Smooth filters +// Hiroshi Morii + void SmoothFilter_8888(uint32 *src, uint32 srcwidth, uint32 srcheight, uint32 *dest, uint32 filter) { - // NOTE: for now we get away with copying the boundaries - // filter the boundaries if we face problems + // NOTE: For now we get away with copying the boundaries + // filter the boundaries if we face problems uint32 mul1, mul2, mul3, shift4; @@ -435,19 +433,19 @@ void SmoothFilter_8888(uint32 *src, uint32 srcwidth, uint32 srcheight, uint32 *d switch (filter) { case SMOOTH_FILTER_3: case SMOOTH_FILTER_4: - // setup rows + // Setup rows _src1 = src; _src2 = _src1 + srcwidth; _src3 = _src2 + srcwidth; _dest = dest; - // copy the first row + // Copy the first row memcpy(_dest, _src1, (srcwidth << 2)); _dest += srcwidth; - // filter 2nd row to 1 row before the last + // Filter 2nd row to 1 row before the last for (y = 1; y < srcheight - 1; y++) { - // copy the first pixel + // Copy the first pixel _dest[0] = _src2[0]; - // filter 2nd pixel to 1 pixel before last + // Filter 2nd pixel to 1 pixel before last for (x = 1; x < srcwidth - 1; x++) { for (z = 0; z < 4; z++) { t1 = *((uint8*)(_src1 + x - 1) + z); @@ -459,44 +457,44 @@ void SmoothFilter_8888(uint32 *src, uint32 srcwidth, uint32 srcheight, uint32 *d t7 = *((uint8*)(_src3 + x - 1) + z); t8 = *((uint8*)(_src3 + x) + z); t9 = *((uint8*)(_src3 + x + 1) + z); - /* the component value must not overflow 0xFF */ + // The component value must not overflow 0xFF val[z] = ((t1 + t3 + t7 + t9)*mul1 + ((t2 + t4 + t6 + t8)*mul2) + (t5*mul3)) >> shift4; if (val[z] > 0xFF) val[z] = 0xFF; } _dest[x] = val[0] | (val[1] << 8) | (val[2] << 16) | (val[3] << 24); } - // copy the ending pixel + // Copy the ending pixel _dest[srcwidth - 1] = *(_src3 - 1); - // next row + // Next row _src1 += srcwidth; _src2 += srcwidth; _src3 += srcwidth; _dest += srcwidth; } - // copy the last row + // Copy the last row memcpy(_dest, _src2, (srcwidth << 2)); break; case SMOOTH_FILTER_1: case SMOOTH_FILTER_2: default: - // setup rows + // Setup rows _src1 = src; _src2 = _src1 + srcwidth; _src3 = _src2 + srcwidth; _dest = dest; - // copy the first row + // Copy the first row memcpy(_dest, _src1, (srcwidth << 2)); _dest += srcwidth; - // filter 2nd row to 1 row before the last + // Filter 2nd row to 1 row before the last for (y = 1; y < srcheight - 1; y++) { - // filter 1st pixel to the last + // Filter 1st pixel to the last if (y & 1) { for (x = 0; x < srcwidth; x++) { for (z = 0; z < 4; z++) { t2 = *((uint8*)(_src1 + x) + z); t5 = *((uint8*)(_src2 + x) + z); t8 = *((uint8*)(_src3 + x) + z); - /* the component value must not overflow 0xFF */ + // The component value must not overflow 0xFF val[z] = ((t2 + t8)*mul2 + (t5*mul3)) >> shift4; if (val[z] > 0xFF) val[z] = 0xFF; } @@ -506,13 +504,13 @@ void SmoothFilter_8888(uint32 *src, uint32 srcwidth, uint32 srcheight, uint32 *d else { memcpy(_dest, _src2, (srcwidth << 2)); } - // next row + // Next row _src1 += srcwidth; _src2 += srcwidth; _src3 += srcwidth; _dest += srcwidth; } - // copy the last row + // Copy the last row memcpy(_dest, _src2, (srcwidth << 2)); break; } @@ -521,8 +519,8 @@ void SmoothFilter_8888(uint32 *src, uint32 srcwidth, uint32 srcheight, uint32 *d #if !_16BPP_HACK void SmoothFilter_4444(uint16 *src, uint32 srcwidth, uint32 srcheight, uint16 *dest, uint32 filter) { - // NOTE: for now we get away with copying the boundaries - // filter the boundaries if we face problems + // NOTE: For now we get away with copying the boundaries + // filter the boundaries if we face problems uint16 mul1, mul2, mul3, shift4; @@ -562,22 +560,22 @@ void SmoothFilter_4444(uint16 *src, uint32 srcwidth, uint32 srcheight, uint16 *d switch (filter) { case SMOOTH_FILTER_3: case SMOOTH_FILTER_4: - // setup rows + // Setup rows _src1 = src; _src2 = _src1 + srcwidth; _src3 = _src2 + srcwidth; _dest = dest; - // copy the first row + // Copy the first row memcpy(_dest, _src1, (srcwidth << 1)); _dest += srcwidth; - // filter 2nd row to 1 row before the last + // Filter 2nd row to 1 row before the last for (y = 1; y < srcheight - 1; y++) { - // copy the first pixel + // Copy the first pixel _dest[0] = *_src2; - // filter 2nd pixel to 1 pixel before last + // Filter 2nd pixel to 1 pixel before last for (x = 1; x < srcwidth - 1; x++) { for (z = 0; z < 4; z++) { - /* Read the entire 16bit pixel and then extract the A,R,G,B components. */ + // Read the entire 16-bit pixel and then extract the A,R,G,B components. uint32 shift = z << 2; t1 = ((*(uint16*)(_src1 + x - 1)) >> shift) & 0xF; t2 = ((*(uint16*)(_src1 + x)) >> shift) & 0xF; @@ -588,45 +586,45 @@ void SmoothFilter_4444(uint16 *src, uint32 srcwidth, uint32 srcheight, uint16 *d t7 = ((*(uint16*)(_src3 + x - 1)) >> shift) & 0xF; t8 = ((*(uint16*)(_src3 + x)) >> shift) & 0xF; t9 = ((*(uint16*)(_src3 + x + 1)) >> shift) & 0xF; - /* the component value must not overflow 0xF */ + // The component value must not overflow 0xF val[z] = ((t1 + t3 + t7 + t9)*mul1 + ((t2 + t4 + t6 + t8)*mul2) + (t5*mul3)) >> shift4; if (val[z] > 0xF) val[z] = 0xF; } _dest[x] = val[0] | (val[1] << 4) | (val[2] << 8) | (val[3] << 12); } - // copy the ending pixel + // Copy the ending pixel _dest[srcwidth - 1] = *(_src3 - 1); - // next row + // Next row _src1 += srcwidth; _src2 += srcwidth; _src3 += srcwidth; _dest += srcwidth; } - // copy the last row + // Copy the last row memcpy(_dest, _src2, (srcwidth << 1)); break; case SMOOTH_FILTER_1: case SMOOTH_FILTER_2: default: - // setup rows + // Setup rows _src1 = src; _src2 = _src1 + srcwidth; _src3 = _src2 + srcwidth; _dest = dest; - // copy the first row + // Copy the first row memcpy(_dest, _src1, (srcwidth << 1)); _dest += srcwidth; - // filter 2nd row to 1 row before the last + // Filter 2nd row to 1 row before the last for (y = 1; y < srcheight - 1; y++) { if (y & 1) { for (x = 0; x < srcwidth; x++) { for (z = 0; z < 4; z++) { - /* Read the entire 16bit pixel and then extract the A,R,G,B components. */ + // Read the entire 16-bit pixel and then extract the A,R,G,B components. uint32 shift = z << 2; t2 = ((*(uint16*)(_src1 + x)) >> shift) & 0xF; t5 = ((*(uint16*)(_src2 + x)) >> shift) & 0xF; t8 = ((*(uint16*)(_src3 + x)) >> shift) & 0xF; - /* the component value must not overflow 0xF */ + // The component value must not overflow 0xF val[z] = ((t2 + t8)*mul2 + (t5*mul3)) >> shift4; if (val[z] > 0xF) val[z] = 0xF; } @@ -636,13 +634,13 @@ void SmoothFilter_4444(uint16 *src, uint32 srcwidth, uint32 srcheight, uint16 *d else { memcpy(_dest, _src2, (srcwidth << 1)); } - // next row + // Next row _src1 += srcwidth; _src2 += srcwidth; _src3 += srcwidth; _dest += srcwidth; } - // copy the last row + // Copy the last row memcpy(_dest, _src2, (srcwidth << 1)); break; } diff --git a/Source/Project64-video/TextureEnhancer/TextureFilters.h b/Source/Project64-video/TextureEnhancer/TextureFilters.h index 733b7715a..e6db7a4ce 100644 --- a/Source/Project64-video/TextureEnhancer/TextureFilters.h +++ b/Source/Project64-video/TextureEnhancer/TextureFilters.h @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2003 Rice1964 @@ -8,15 +8,18 @@ #ifndef __TEXTUREFILTERS_H__ #define __TEXTUREFILTERS_H__ -/* 16bpp filters are somewhat buggy and output image is not clean. - * Since there's not much time, we'll just convert them to ARGB8888 - * and use 32bpp filters until fixed. - * (1:enable hack, 0:disable hack) */ +/* +16bpp filters are somewhat buggy and output image is not clean. +Since there's not much time, we'll just convert them to ARGB8888 +and use 32bpp filters until fixed. +(1:enable hack, 0:disable hack) +*/ + #define _16BPP_HACK 1 #include "TxInternal.h" - /* enhancers */ +// Enhancers void hq4x_8888(unsigned char * pIn, unsigned char * pOut, int Xres, int Yres, int SrcPPL, int BpL); void hq2x_32(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); @@ -29,12 +32,12 @@ void Super2xSaI_8888(uint32 *srcPtr, uint32 *destPtr, uint32 width, uint32 heigh void Texture2x_32(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); -/* filters */ +// Filters void SharpFilter_8888(uint32 *src, uint32 srcwidth, uint32 srcheight, uint32 *dest, uint32 filter); void SmoothFilter_8888(uint32 *src, uint32 srcwidth, uint32 srcheight, uint32 *dest, uint32 filter); -/* helper */ +// Helper void filter_8888(uint32 *src, uint32 srcwidth, uint32 srcheight, uint32 *dest, uint32 filter); #if !_16BPP_HACK diff --git a/Source/Project64-video/TextureEnhancer/TextureFilters_2xsai.cpp b/Source/Project64-video/TextureEnhancer/TextureFilters_2xsai.cpp index 0624fbf58..6c68c7468 100644 --- a/Source/Project64-video/TextureEnhancer/TextureFilters_2xsai.cpp +++ b/Source/Project64-video/TextureEnhancer/TextureFilters_2xsai.cpp @@ -1,9 +1,10 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2003 Rice1964 // GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html + #include "TextureFilters.h" #define GET_RESULT(A, B, C, D) ((A != C || A != D) - (B != C || B != D)) diff --git a/Source/Project64-video/TextureEnhancer/TextureFilters_2xsai.h b/Source/Project64-video/TextureEnhancer/TextureFilters_2xsai.h index f6696ae06..926632e4f 100644 --- a/Source/Project64-video/TextureEnhancer/TextureFilters_2xsai.h +++ b/Source/Project64-video/TextureEnhancer/TextureFilters_2xsai.h @@ -1,27 +1,26 @@ /* - * Texture Filtering - * Version: 1.0 - * - * Copyright (C) 2007 Hiroshi Morii All Rights Reserved. - * Email koolsmoky(at)users.sourceforge.net - * Web http://www.3dfxzone.it/koolsmoky - * - * this is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * this is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - */ +Texture Filtering +Version: 1.0 -/* Based on Derek Liauw Kie Fa and Rice1964 Super2xSaI code */ +Copyright (C) 2007 Hiroshi Morii All Rights Reserved. +Web http://www.3dfxzone.it/koolsmoky + +This is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Make; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +// Based on Derek Liauw Kie Fa and Rice1964 Super2xSaI code int row0, row1, row2, row3; int col0, col1, col2, col3; @@ -44,7 +43,7 @@ } for (x = 0; x < width; x++) { -//--------------------------------------- B0 B1 B2 B3 +// B0 B1 B2 B3 // 4 5 6 S2 // 1 2 3 S1 // A0 A1 A2 A3 @@ -80,7 +79,6 @@ colorA2 = *(srcPtr + col2 + row3); colorA3 = *(srcPtr + col3 + row3); -//-------------------------------------- if (color2 == color6 && color5 != color3) product2b = product1b = color2; else if (color5 == color3 && color2 != color6) diff --git a/Source/Project64-video/TextureEnhancer/TextureFilters_hq2x.cpp b/Source/Project64-video/TextureEnhancer/TextureFilters_hq2x.cpp index 03d09a806..d113e1724 100644 --- a/Source/Project64-video/TextureEnhancer/TextureFilters_hq2x.cpp +++ b/Source/Project64-video/TextureEnhancer/TextureFilters_hq2x.cpp @@ -1,21 +1,18 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2007 Mudlord // Copyright(C) 2003 Rice1964 // GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html + #include "TextureFilters.h" -/************************************************************************/ -/* hq2x filters */ -/************************************************************************/ +// HQ2X filters -/***************************************************************************/ -/* Basic types */ +// Basic types -/***************************************************************************/ -/* interpolation */ +// Interpolation //static unsigned interp_bits_per_pixel; @@ -185,8 +182,7 @@ static uint32 hq2x_interp_32_97(uint32 p1, uint32 p2) | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1) * 9 + INTERP_32_MASK_SHIFT_2_4(p2) * 7) / 16); } -/***************************************************************************/ -/* diff */ +// Difference #define INTERP_Y_LIMIT (0x30*4) #define INTERP_U_LIMIT (0x07*4) @@ -405,8 +401,8 @@ static void hq2xS_16_def(uint16* dst0, uint16* dst1, const uint16* src0, const u mask = 0; - // hq2xS dynamic edge detection: - // simply comparing the center color against its surroundings will give bad results in many cases, + // HQ2XS dynamic edge detection: + // Simply comparing the center color against its surroundings will give bad results in many cases, // so, instead, compare the center color relative to the max difference in brightness of this 3x3 block int brightArray[9]; int maxBright = 0, minBright = 999999; @@ -658,8 +654,8 @@ static void hq2xS_32_def(uint32* dst0, uint32* dst1, const uint32* src0, const u } mask = 0; - // hq2xS dynamic edge detection: - // simply comparing the center color against its surroundings will give bad results in many cases, + // HQ2XS dynamic edge detection: + // Simply comparing the center color against its surroundings will give bad results in many cases, // so, instead, compare the center color relative to the max difference in brightness of this 3x3 block int brightArray[9]; int maxBright = 0, minBright = 999999; @@ -753,12 +749,9 @@ static void hq2xS_32_def(uint32* dst0, uint32* dst1, const uint32* src0, const u } } -/***************************************************************************/ -/* LQ2x C implementation */ +// LQ2X C implementation -/* -* This effect is derived from the hq2x effect made by Maxim Stepin -*/ +// This effect is derived from the HQ2X effect made by Maxim Stepin #if !_16BPP_HACK static void lq2x_16_def(uint16* dst0, uint16* dst1, const uint16* src0, const uint16* src1, const uint16* src2, unsigned count) @@ -908,8 +901,8 @@ static void lq2xS_16_def(uint16* dst0, uint16* dst1, const uint16* src0, const u c[8] = c[7]; } - // hq2xS dynamic edge detection: - // simply comparing the center color against its surroundings will give bad results in many cases, + // HQ2XS dynamic edge detection: + // Simply comparing the center color against its surroundings will give bad results in many cases, // so, instead, compare the center color relative to the max difference in brightness of this 3x3 block int brightArray[9]; int maxBright = 0, minBright = 999999; @@ -1152,8 +1145,8 @@ static void lq2xS_32_def(uint32* dst0, uint32* dst1, const uint32* src0, const u c[8] = c[7]; } - // hq2xS dynamic edge detection: - // simply comparing the center color against its surroundings will give bad results in many cases, + // HQ2XS dynamic edge detection: + // Simply comparing the center color against its surroundings will give bad results in many cases, // so, instead, compare the center color relative to the max difference in brightness of this 3x3 block int brightArray[9]; int maxBright = 0, minBright = 999999; @@ -1494,14 +1487,8 @@ void lq2xS_32(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, in lq2xS_32_def(dst0, dst1, src0, src1, src1, width); } -/************************************************************************/ -/* hq3x filters */ -/************************************************************************/ +// hq3x filters -/************************************************************************/ -/* scale2x filters */ -/************************************************************************/ +// scale2x filters -/************************************************************************/ -/* scale3x filters */ -/************************************************************************/ \ No newline at end of file +// scale3x filters diff --git a/Source/Project64-video/TextureEnhancer/TextureFilters_hq2x.h b/Source/Project64-video/TextureEnhancer/TextureFilters_hq2x.h index 7ec3af6a2..c15fbd6d8 100644 --- a/Source/Project64-video/TextureEnhancer/TextureFilters_hq2x.h +++ b/Source/Project64-video/TextureEnhancer/TextureFilters_hq2x.h @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2003 Rice1964 diff --git a/Source/Project64-video/TextureEnhancer/TextureFilters_hq4x.cpp b/Source/Project64-video/TextureEnhancer/TextureFilters_hq4x.cpp index 4385e3247..5387e97a3 100644 --- a/Source/Project64-video/TextureEnhancer/TextureFilters_hq4x.cpp +++ b/Source/Project64-video/TextureEnhancer/TextureFilters_hq4x.cpp @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2003 Rice1964 @@ -863,7 +863,7 @@ void hq4x_init(void) g = (j << 4) | j; b = (k << 4) | k; - /* Microsoft's RGB888->YUV conversion */ + // Microsoft's RGB888->YUV conversion /*Y = ((( 66 * r + 129 * g + 25 * b + 128) >> 8) + 16) & 0xFF; u = ((( -38 * r - 74 * g + 112 * b + 128) >> 8) + 128) & 0xFF; v = ((( 112 * r - 94 * g - 18 * b + 128) >> 8) + 128) & 0xFF;*/ diff --git a/Source/Project64-video/TextureEnhancer/TextureFilters_hq4x.h b/Source/Project64-video/TextureEnhancer/TextureFilters_hq4x.h index c5f045bb7..eb95def6e 100644 --- a/Source/Project64-video/TextureEnhancer/TextureFilters_hq4x.h +++ b/Source/Project64-video/TextureEnhancer/TextureFilters_hq4x.h @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2003 Rice1964 diff --git a/Source/Project64-video/TextureEnhancer/TextureFilters_lq2x.h b/Source/Project64-video/TextureEnhancer/TextureFilters_lq2x.h index 6a0af8c85..9c7e9d646 100644 --- a/Source/Project64-video/TextureEnhancer/TextureFilters_lq2x.h +++ b/Source/Project64-video/TextureEnhancer/TextureFilters_lq2x.h @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2003 Rice1964 diff --git a/Source/Project64-video/TextureEnhancer/TxCache.cpp b/Source/Project64-video/TextureEnhancer/TxCache.cpp index 8300f3cc9..d42f041aa 100644 --- a/Source/Project64-video/TextureEnhancer/TxCache.cpp +++ b/Source/Project64-video/TextureEnhancer/TxCache.cpp @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2003 Rice1964 @@ -9,8 +9,8 @@ #pragma warning(disable: 4786) #endif -#include /* memcpy, memset */ -#include /* malloc, free */ +#include // memcpy, memset +#include // malloc, free #include "TxCache.h" #include "TxDbg.h" @@ -21,7 +21,7 @@ TxCache::~TxCache() { - /* free memory, clean up, etc */ + // Free memory, clean up, etc. clear(); delete _txUtil; @@ -37,19 +37,19 @@ TxCache::TxCache(int options, int cachesize, const char *path, const char *ident _callback = callback; _totalSize = 0; - /* save path name */ + // Save path name if (path) { _path.assign(path); } - /* save ROM name */ + // Save ROM name if (ident) { _ident.assign(ident); } - /* zlib memory buffers to (de)compress hires textures */ + // zlib memory buffers to (de)compress high resolution textures if (_options & (GZ_TEXCACHE | GZ_HIRESTEXCACHE)) { _gzdest0 = TxMemBuf::getInstance()->get(0); @@ -70,7 +70,7 @@ TxCache::TxCache(int options, int cachesize, const char *path, const char *ident bool TxCache::add(uint64_t checksum, GHQTexInfo *info, int dataSize) { - /* NOTE: dataSize must be provided if info->data is zlib compressed. */ + // NOTE: dataSize must be provided if info->data is zlib compressed if (!checksum || !info->data) return 0; @@ -85,7 +85,7 @@ TxCache::add(uint64_t checksum, GHQTexInfo *info, int dataSize) if (_options & (GZ_TEXCACHE | GZ_HIRESTEXCACHE)) { - /* zlib compress it. compression level:1 (best speed) */ + // zlib compress it. Compression level:1 (best speed) uLongf destLen = _gzdestLen; dest = (dest == _gzdest0) ? _gzdest1 : _gzdest0; if (compress2(dest, &destLen, info->data, dataSize, 1) != Z_OK) @@ -102,21 +102,21 @@ TxCache::add(uint64_t checksum, GHQTexInfo *info, int dataSize) } } - /* if cache size exceeds limit, remove old cache */ + // If cache size exceeds limit, remove old cache if (_cacheSize > 0) { _totalSize += dataSize; if ((_totalSize > _cacheSize) && !_cachelist.empty()) { - /* _cachelist is arranged so that frequently used textures are in the back */ + // _cachelist is arranged so that frequently used textures are in the back std::list::iterator itList = _cachelist.begin(); while (itList != _cachelist.end()) { - /* find it in _cache */ + // Find it in _cache std::map::iterator itMap = _cache.find(*itList); if (itMap != _cache.end()) { - /* yep we have it. remove it. */ + // Yep we have it, let's remove it _totalSize -= (*itMap).second->size; free((*itMap).second->info.data); delete (*itMap).second; @@ -124,11 +124,11 @@ TxCache::add(uint64_t checksum, GHQTexInfo *info, int dataSize) } itList++; - /* check if memory cache has enough space */ + // Check if memory cache has enough space if (_totalSize <= _cacheSize) break; } - /* remove from _cachelist */ + // Remove from _cachelist _cachelist.erase(_cachelist.begin(), itList); DBG_INFO(80, "+++++++++\n"); @@ -136,35 +136,35 @@ TxCache::add(uint64_t checksum, GHQTexInfo *info, int dataSize) _totalSize -= dataSize; } - /* cache it */ + // Cache it uint8 *tmpdata = (uint8*)malloc(dataSize); if (tmpdata) { TXCACHE *txCache = new TXCACHE; if (txCache) { - /* we can directly write as we filter, but for now we get away - * with doing memcpy after all the filtering is done. - */ + // We can directly write as we filter, but for now we get away + // with doing memcpy after all the filtering is done. + memcpy(tmpdata, dest, dataSize); - /* copy it */ + // Copy it memcpy(&txCache->info, info, sizeof(GHQTexInfo)); txCache->info.data = tmpdata; txCache->info.format = format; txCache->size = dataSize; - /* add to cache */ + // Add to cache if (_cacheSize > 0) { _cachelist.push_back(checksum); txCache->it = --(_cachelist.end()); } - /* _cache[checksum] = txCache; */ + // _cache[checksum] = txCache; _cache.insert(std::map::value_type(checksum, txCache)); #ifdef DEBUG - DBG_INFO(80, "[%5d] added!! crc:%08X %08X %d x %d gfmt:%x total:%.02fmb\n", + DBG_INFO(80, "[%5d] added! CRC:%08X %08X %d x %d gfmt:%x total:%.02fmb\n", _cache.size(), (uint32)(checksum >> 32), (uint32)(checksum & 0xffffffff), info->width, info->height, info->format, (float)_totalSize / 1000000); @@ -178,16 +178,16 @@ TxCache::add(uint64_t checksum, GHQTexInfo *info, int dataSize) if (_cacheSize > 0) { - DBG_INFO(80, "cache max config:%.02fmb\n", (float)_cacheSize / 1000000); + DBG_INFO(80, "Cache max config:%.02fmb\n", (float)_cacheSize / 1000000); if (_cache.size() != _cachelist.size()) { - DBG_INFO(80, "Error: cache/cachelist mismatch! (%d/%d)\n", _cache.size(), _cachelist.size()); + DBG_INFO(80, "Error: Cache/cache list mismatch! (%d/%d)\n", _cache.size(), _cachelist.size()); } } #endif - /* total cache size */ + // Total cache size _totalSize += dataSize; return 1; @@ -203,14 +203,14 @@ TxCache::get(uint64_t checksum, GHQTexInfo *info) { if (!checksum || _cache.empty()) return 0; - /* find a match in cache */ + // Find a match in cache std::map::iterator itMap = _cache.find(checksum); if (itMap != _cache.end()) { - /* yep, we've got it. */ + // Yep, we've got it memcpy(info, &(((*itMap).second)->info), sizeof(GHQTexInfo)); - /* push it to the back of the list */ + // Push it to the back of the list if (_cacheSize > 0) { _cachelist.erase(((*itMap).second)->it); @@ -218,7 +218,7 @@ TxCache::get(uint64_t checksum, GHQTexInfo *info) ((*itMap).second)->it = --(_cachelist.end()); } - /* zlib decompress it */ + // zlib decompress it if (info->format & GFX_TEXFMT_GZ) { uLongf destLen = _gzdestLen; @@ -247,7 +247,7 @@ bool TxCache::save(const char *path, const char *filename, int config) DBG_INFO(80, "gzfp:%x file:%ls\n", gzfp, filename); if (gzfp) { - /* write header to determine config match */ + // Write header to determine config match gzwrite(gzfp, &config, 4); std::map::iterator itMap = _cache.begin(); @@ -257,11 +257,13 @@ bool TxCache::save(const char *path, const char *filename, int config) uint32 destLen = (*itMap).second->size; uint16 format = (*itMap).second->info.format; - /* to keep things simple, we save the texture data in a zlib uncompressed state. */ - /* sigh... for those who cannot wait the extra few seconds. changed to keep - * texture data in a zlib compressed state. if the GZ_TEXCACHE or GZ_HIRESTEXCACHE - * option is toggled, the cache will need to be rebuilt. - */ + /* + To keep things simple, we save the texture data in a zlib uncompressed state + For those who cannot wait the extra few seconds, we changed to keep + texture data in a zlib compressed state. If the GZ_TEXCACHE or GZ_HIRESTEXCACHE + option is toggled, the cache will need to be rebuilt. + */ + /*if (format & GFX_TEXFMT_GZ) { dest = _gzdest0; destLen = _gzdestLen; @@ -276,10 +278,10 @@ bool TxCache::save(const char *path, const char *filename, int config) if (dest && destLen) { - /* texture checksum */ + // Texture checksum gzwrite(gzfp, &((*itMap).first), 8); - /* other texture info */ + // Other texture info gzwrite(gzfp, &((*itMap).second->info.width), 4); gzwrite(gzfp, &((*itMap).second->info.height), 4); gzwrite(gzfp, &format, 2); @@ -300,9 +302,9 @@ bool TxCache::save(const char *path, const char *filename, int config) itMap++; - /* not ready yet */ + // Not ready yet /*if (_callback) - (*_callback)("Total textures saved to HDD: %d\n", std::distance(itMap, _cache.begin()));*/ + (*_callback)("Total textures saved to storage: %d\n", std::distance(itMap, _cache.begin()));*/ } gzclose(gzfp); } @@ -312,19 +314,19 @@ bool TxCache::save(const char *path, const char *filename, int config) bool TxCache::load(const char *path, const char *filename, int config) { - /* find it on disk */ + // Find it on disk CPath cbuf(path, filename); gzFile gzfp = gzopen(cbuf, "rb"); DBG_INFO(80, "gzfp:%x file:%ls\n", gzfp, filename); if (gzfp) { - /* yep, we have it. load it into memory cache. */ + // Yep, we have it, let's load it into memory cache int dataSize; uint64_t checksum; GHQTexInfo tmpInfo; int tmpconfig; - /* read header to determine config match */ + // Read header to determine config match gzread(gzfp, &tmpconfig, 4); if (tmpconfig == config) @@ -356,7 +358,7 @@ bool TxCache::load(const char *path, const char *filename, int config) { gzread(gzfp, tmpInfo.data, dataSize); - /* add to memory cache */ + // Add to memory cache add(checksum, &tmpInfo, (tmpInfo.format & GFX_TEXFMT_GZ) ? dataSize : 0); free(tmpInfo.data); @@ -366,7 +368,7 @@ bool TxCache::load(const char *path, const char *filename, int config) gzseek(gzfp, dataSize, SEEK_CUR); } - /* skip in between to prevent the loop from being tied down to vsync */ + // Skip in between to prevent the loop from being tied down to v-sync if (_callback && (!(_cache.size() % 100) || gzeof(gzfp))) (*_callback)("[%d] total mem:%.02fmb - %ls\n", _cache.size(), (float)_totalSize / 1000000, filename); } while (!gzeof(gzfp)); @@ -383,16 +385,16 @@ bool TxCache::del(uint64_t checksum) std::map::iterator itMap = _cache.find(checksum); if (itMap != _cache.end()) { - /* for texture cache (not hi-res cache) */ + // For texture cache (not high resolution cache) if (!_cachelist.empty()) _cachelist.erase(((*itMap).second)->it); - /* remove from cache */ + // Remove from cache free((*itMap).second->info.data); _totalSize -= (*itMap).second->size; delete (*itMap).second; _cache.erase(itMap); - DBG_INFO(80, "removed from cache: checksum = %08X %08X\n", (uint32)(checksum & 0xffffffff), (uint32)(checksum >> 32)); + DBG_INFO(80, "Removed from cache: checksum = %08X %08X\n", (uint32)(checksum & 0xffffffff), (uint32)(checksum >> 32)); return 1; } diff --git a/Source/Project64-video/TextureEnhancer/TxCache.h b/Source/Project64-video/TextureEnhancer/TxCache.h index 7a9894898..130412be9 100644 --- a/Source/Project64-video/TextureEnhancer/TxCache.h +++ b/Source/Project64-video/TextureEnhancer/TxCache.h @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2003 Rice1964 @@ -37,16 +37,16 @@ protected: std::map _cache; bool save(const char *path, const char *filename, const int config); bool load(const char *path, const char *filename, const int config); - bool del(uint64_t checksum); /* checksum hi:palette low:texture */ - bool is_cached(uint64_t checksum); /* checksum hi:palette low:texture */ + bool del(uint64_t checksum); // Checksum hi:palette low:texture + bool is_cached(uint64_t checksum); // Checksum hi:palette low:texture void clear(); public: ~TxCache(); TxCache(int options, int cachesize, const char *path, const char *ident, dispInfoFuncExt callback); - bool add(uint64_t checksum, /* checksum hi:palette low:texture */ + bool add(uint64_t checksum, // Checksum hi:palette low:texture GHQTexInfo *info, int dataSize = 0); - bool get(uint64_t checksum, /* checksum hi:palette low:texture */ + bool get(uint64_t checksum, // Checksum hi:palette low:texture GHQTexInfo *info); }; diff --git a/Source/Project64-video/TextureEnhancer/TxDbg.cpp b/Source/Project64-video/TextureEnhancer/TxDbg.cpp index c34502e9c..781428383 100644 --- a/Source/Project64-video/TextureEnhancer/TxDbg.cpp +++ b/Source/Project64-video/TextureEnhancer/TxDbg.cpp @@ -1,9 +1,10 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2003 Rice1964 // GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html + #define DBG_LEVEL 80 #include "TxDbg.h" diff --git a/Source/Project64-video/TextureEnhancer/TxDbg.h b/Source/Project64-video/TextureEnhancer/TxDbg.h index 9427952ea..9c864e39e 100644 --- a/Source/Project64-video/TextureEnhancer/TxDbg.h +++ b/Source/Project64-video/TextureEnhancer/TxDbg.h @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2003 Rice1964 diff --git a/Source/Project64-video/TextureEnhancer/TxFilter.cpp b/Source/Project64-video/TextureEnhancer/TxFilter.cpp index 2d080a830..5e5abae94 100644 --- a/Source/Project64-video/TextureEnhancer/TxFilter.cpp +++ b/Source/Project64-video/TextureEnhancer/TxFilter.cpp @@ -1,9 +1,10 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2003 Rice1964 // GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html + #ifdef _WIN32 #pragma warning(disable: 4786) #endif @@ -17,16 +18,16 @@ void TxFilter::clear() { - /* clear hires texture cache */ + // Clear high resolution texture cache delete _txHiResCache; - /* clear texture cache */ + // Clear texture cache delete _txTexCache; - /* free memory */ + // Free memory TxMemBuf::getInstance()->shutdown(); - /* clear other stuff */ + // Clear other stuff delete _txImage; delete _txQuantize; delete _txUtil; @@ -55,28 +56,28 @@ TxFilter::TxFilter(int maxwidth, int maxheight, int maxbpp, int options, _txImage(nullptr), _initialized(false) { - /* HACKALERT: the emulator misbehaves and sometimes forgets to shutdown */ + // HACKALERT: The emulator misbehaves and sometimes forgets to shutdown if ((ident && strcmp(ident, "DEFAULT") != 0 && _ident.compare(ident) == 0) && _maxwidth == maxwidth && _maxheight == maxheight && _maxbpp == maxbpp && _options == options && _cacheSize == cachesize) return; - clear(); /* gcc does not allow the destructor to be called */ + clear(); // GCC does not allow the destructor to be called - /* shamelessness :P this first call to the debug output message creates - * a file in the executable directory. */ + // This first call to the debug output message creates + // a file in the executable directory INFO(0, "------------------------------------------------------------------\n"); #ifdef GHQCHK - INFO(0, " GlideHQ Hires Texture Checker 1.02.00.%d\n", 0); + INFO(0, " GlideHQ High Resolution Texture Checker 1.02.00.%d\n", 0); #else INFO(0, " GlideHQ version 1.02.00.%d\n", 0); #endif - INFO(0, " Copyright (C) 2010 Hiroshi Morii All Rights Reserved\n"); - INFO(0, " email : koolsmoky(at)users.sourceforge.net\n"); - INFO(0, " website : http://www.3dfxzone.it/koolsmoky\n"); + INFO(0, " Copyright (C) 2010 Hiroshi Morii All Rights Reserved\n"); + INFO(0, " Email: koolsmoky(at)users.sourceforge.net\n"); + INFO(0, " Website: http://www.3dfxzone.it/koolsmoky\n"); INFO(0, "\n"); - INFO(0, " Glide64 official website : http://glide64.emuxhaven.net\n"); + INFO(0, " Glide64 official website: http://glide64.emuxhaven.net\n"); INFO(0, "------------------------------------------------------------------\n"); _options = options; @@ -85,7 +86,7 @@ TxFilter::TxFilter(int maxwidth, int maxheight, int maxbpp, int options, _txQuantize = new TxQuantize(); _txUtil = new TxUtil(); - /* get number of CPU cores. */ + // Get number of CPU cores _numcore = _txUtil->getNumberofProcessors(); _initialized = 0; @@ -93,24 +94,24 @@ TxFilter::TxFilter(int maxwidth, int maxheight, int maxbpp, int options, _tex1 = nullptr; _tex2 = nullptr; - /* XXX: anything larger than 1024 * 1024 is overkill */ + // Anything larger than 1024 * 1024 is overkill _maxwidth = maxwidth > 1024 ? 1024 : maxwidth; _maxheight = maxheight > 1024 ? 1024 : maxheight; _maxbpp = maxbpp; _cacheSize = cachesize; - /* TODO: validate options and do overrides here*/ + // TODO: Validate options and do overrides here - /* save path name */ + // Save path name if (path) _path.assign(path); - /* save ROM name */ + // Save ROM name if (ident && strcmp(ident, "DEFAULT") != 0) _ident.assign(ident); - /* check for dxtn extensions */ + // Check for dxtn extensions if (!TxLoadLib::getInstance()->getdxtCompressTexFuncExt()) _options &= ~S3TC_COMPRESSION; @@ -135,14 +136,14 @@ TxFilter::TxFilter(int maxwidth, int maxheight, int maxbpp, int options, } #if !_16BPP_HACK - /* initialize hq4x filter */ + // Initialize HQ4X filter hq4x_init(); #endif - /* initialize texture cache in bytes. 128Mb will do nicely in most cases */ + // Initialize texture cache in bytes. 128MB will do nicely in most cases. _txTexCache = new TxTexCache(_options, _cacheSize, _path.c_str(), _ident.c_str(), callback); - /* hires texture */ + // High resolution texture #if HIRES_TEXTURE _txHiResCache = new TxHiResCache(_maxwidth, _maxheight, _maxbpp, _options, _path.c_str(), _ident.c_str(), callback); @@ -164,42 +165,42 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint uint8 *tmptex = _tex1; uint16 destformat = srcformat; - /* We need to be initialized first! */ + // We need to be initialized first! if (!_initialized) return 0; - /* find cached textures */ + // Find cached textures if (_cacheSize) { - /* calculate checksum of source texture */ + // Calculate checksum of source texture if (!g64crc) g64crc = (uint64_t)(_txUtil->checksumTx(texture, srcwidth, srcheight, srcformat)); - DBG_INFO(80, "filter: crc:%08X %08X %d x %d gfmt:%x\n", + DBG_INFO(80, "Filter: CRC:%08X %08X %d x %d gfmt:%x\n", (uint32)(g64crc >> 32), (uint32)(g64crc & 0xffffffff), srcwidth, srcheight, srcformat); -#if 0 /* use hirestex to retrieve cached textures. */ - /* check if we have it in cache */ - if (!(g64crc & 0xffffffff00000000) && /* we reach here only when there is no hires texture for this crc */ +#if 0 // Use hirestex to retrieve cached textures + // Check if we have it in cache + if (!(g64crc & 0xffffffff00000000) && // We reach here only when there is no high resolution texture for this CRC _txTexCache->get(g64crc, info)) { - DBG_INFO(80, "cache hit: %d x %d gfmt:%x\n", info->width, info->height, info->format); - return 1; /* yep, we've got it */ + DBG_INFO(80, "Cache hit: %d x %d gfmt:%x\n", info->width, info->height, info->format); + return 1; // Yep, we've got it } #endif } - /* Leave small textures alone because filtering makes little difference. - * Moreover, some filters require at least 4 * 4 to work. - * Bypass _options to do ARGB8888->16bpp if _maxbpp=16 or forced color reduction. - */ + // Leave small textures alone because filtering makes little difference. + // Moreover, some filters require at least 4 * 4 to work. + // Bypass _options to do ARGB8888->16bpp if _maxbpp=16 or forced color reduction. + if ((srcwidth >= 4 && srcheight >= 4) && ((_options & (FILTER_MASK | ENHANCEMENT_MASK | COMPRESSION_MASK)) || (srcformat == GFX_TEXFMT_ARGB_8888 && (_maxbpp < 32 || _options & FORCE16BPP_TEX)))) { #if !_16BPP_HACK - /* convert textures to a format that the compressor accepts (ARGB8888) */ + // Convert textures to a format that the compressor accepts (ARGB8888) if (_options & COMPRESSION_MASK) { #endif if (srcformat != GFX_TEXFMT_ARGB_8888) { if (!_txQuantize->quantize(texture, tmptex, srcwidth, srcheight, srcformat, GFX_TEXFMT_ARGB_8888)) { - DBG_INFO(80, "Error: unsupported format! gfmt:%x\n", srcformat); + DBG_INFO(80, "Error: Unsupported format! gfmt:%x\n", srcformat); return 0; } texture = tmptex; @@ -212,9 +213,7 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint switch (destformat) { case GFX_TEXFMT_ARGB_8888: - /* - * prepare texture enhancements (x2, x4 scalers) - */ + // Prepare texture enhancements (x2, x4 scalers) int scale_shift = 0, num_filters = 0; uint32 filter = 0; @@ -238,17 +237,13 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint } } - /* - * prepare texture filters - */ + // Prepare texture filters if (_options & (SMOOTH_FILTER_MASK | SHARP_FILTER_MASK)) { filter |= (_options & (SMOOTH_FILTER_MASK | SHARP_FILTER_MASK)); num_filters++; } - /* - * execute texture enhancements and filters - */ + // Execute texture enhancements and filters while (num_filters > 0) { tmptex = (texture == _tex1) ? _tex2 : _tex1; @@ -275,26 +270,26 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint } /* - * texture compression - */ - /* ignored if we only have texture compression option on. - * only done when texture enhancer is used. see constructor. */ + Texture compression: + Ignored if we only have texture compression option on. + Only done when texture enhancer is used. See constructor. + */ if ((_options & COMPRESSION_MASK) && (srcwidth >= 64 && srcheight >= 64) /* Texture compression is not suitable for low pixel coarse detail * textures. The assumption here is that textures larger than 64x64 * have enough detail to produce decent quality when compressed. The * down side is that narrow stripped textures that the N64 often use * for large background textures are also ignored. It would be more - * reasonable if decisions are made based on fourier-transform + * reasonable if decisions are made based on Fourier-transform * spectrum or RMS error. */ ) { int compressionType = _options & COMPRESSION_MASK; int tmpwidth, tmpheight; uint16 tmpformat; - /* XXX: textures that use 8bit alpha channel look bad with the current - * fxt1 library, so we substitute it with dxtn for now. afaik all gfx - * cards that support fxt1 also support dxtn. (3dfx and Intel) */ + // Textures that use 8-bit alpha channel look bad with the current + // fxt1 library, so we substitute it with dxtn for now. AFAIK all graphics + // cards that support fxt1 also support dxtn. (3DFX and Intel) if ((destformat == GFX_TEXFMT_ALPHA_INTENSITY_88) || (destformat == GFX_TEXFMT_ARGB_8888) || (destformat == GFX_TEXFMT_ALPHA_8)) { @@ -312,15 +307,13 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint } } - /* - * texture (re)conversions - */ + // Texture re-conversions if (destformat == GFX_TEXFMT_ARGB_8888) { if (srcformat == GFX_TEXFMT_ARGB_8888 && (_maxbpp < 32 || _options & FORCE16BPP_TEX)) srcformat = GFX_TEXFMT_ARGB_4444; if (srcformat != GFX_TEXFMT_ARGB_8888) { tmptex = (texture == _tex1) ? _tex2 : _tex1; if (!_txQuantize->quantize(texture, tmptex, srcwidth, srcheight, GFX_TEXFMT_ARGB_8888, srcformat)) { - DBG_INFO(80, "Error: unsupported format! gfmt:%x\n", srcformat); + DBG_INFO(80, "Error: Unsupported format! gfmt:%x\n", srcformat); return 0; } texture = tmptex; @@ -409,7 +402,7 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint } } - /* fill in the texture info. */ + // Fill in the texture info info->data = texture; info->width = srcwidth; info->height = srcheight; @@ -419,10 +412,10 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint info->aspectRatioLog2 = _txUtil->grAspectRatioLog2(srcwidth, srcheight); info->is_hires_tex = 0; - /* cache the texture. */ + // Cache the texture if (_cacheSize) _txTexCache->add(g64crc, info); - DBG_INFO(80, "filtered texture: %d x %d gfmt:%x\n", info->width, info->height, info->format); + DBG_INFO(80, "Filtered texture: %d x %d gfmt:%x\n", info->width, info->height, info->format); return 1; } @@ -430,79 +423,77 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint bool TxFilter::hirestex(uint64_t g64crc, uint64_t r_crc64, uint16 *palette, GHQTexInfo *info) { - /* NOTE: Rice CRC32 sometimes return the same value for different textures. - * As a workaround, Glide64 CRC32 is used for the key for NON-hires - * texture cache. - * - * r_crc64 = hi:palette low:texture - * (separate crc. doesn't necessary have to be rice crc) - * g64crc = texture + palette glide64 crc32 - * (can be any other crc if robust) - */ + // NOTE: Rice CRC32 sometimes return the same value for different textures. + // As a workaround, Glide64 CRC32 is used for the key for textures not using + // the high resolution texture cache. + // r_crc64 = hi:palette low:texture + // (separate CRC, doesn't necessary have to be Rice CRC) + // g64crc = texture + palette Glide64 CRC32 + // (can be any other CRC if robust) DBG_INFO(80, "hirestex: r_crc64:%08X %08X, g64crc:%08X %08X\n", (uint32)(r_crc64 >> 32), (uint32)(r_crc64 & 0xffffffff), (uint32)(g64crc >> 32), (uint32)(g64crc & 0xffffffff)); #if HIRES_TEXTURE - /* check if we have it in hires memory cache. */ + // Check if we have it in high resolution memory cache if ((_options & HIRESTEXTURES_MASK) && r_crc64) { if (_txHiResCache->get(r_crc64, info)) { DBG_INFO(80, "hires hit: %d x %d gfmt:%x\n", info->width, info->height, info->format); - /* TODO: Enable emulation for special N64 combiner modes. There are few ways + /* TODO: Enable emulation for special N64 combiner modes. There are a few ways * to get this done. Also applies for CI textures below. * - * Solution 1. Load the hiresolution textures in ARGB8888 (or A8, IA88) format + * Solution 1. Load the high resolution textures in ARGB8888 (or A8, IA88) format * to cache. When a cache is hit, then we take the modes passed in from Glide64 * (also TODO) and apply the modification. Then we do color reduction or format - * conversion or compression if desired and stuff it into the non-hires texture - * cache. + * conversion or compression if desired and stuff it into the lower resolution + * texture cache. * * Solution 2. When a cache is hit and if the combiner modes are present, * convert the texture to ARGB4444 and pass it back to Glide64 to process. * If a texture is compressed, it needs to be decompressed first. Then add - * the processed texture to the non-hires texture cache. + * the processed texture to the lower resolution texture cache. * * Solution 3. Hybrid of the above 2. Load the textures in ARGB8888 (A8, IA88) * format. Convert the texture to ARGB4444 and pass it back to Glide64 when * the combiner modes are present. Get the processed texture back from Glide64 - * and compress if desired and add it to the non-hires texture cache. + * and compress if desired and add it to the lower resolution texture cache. * * Solution 4. Take the easy way out and forget about this whole thing. */ - return 1; /* yep, got it */ + return 1; // Yes, we've got it } if (_txHiResCache->get((r_crc64 & 0xffffffff), info)) { DBG_INFO(80, "hires hit: %d x %d gfmt:%x\n", info->width, info->height, info->format); - /* for true CI textures, we use the passed in palette to convert to + /* For true CI textures, we use the passed in palette to convert to * ARGB1555 and add it to memory cache. * - * NOTE: we do this AFTER all other texture cache searches because + * NOTE: We do this after all other texture cache searches because * only a few texture packs actually use true CI textures. * - * NOTE: the pre-converted palette from Glide64 is in RGBA5551 format. + * NOTE: The pre-converted palette from Glide64 is in RGBA5551 format. * A comp comes before RGB comp. */ if (palette && info->format == GFX_TEXFMT_P_8) { - DBG_INFO(80, "found GFX_TEXFMT_P_8 format. Need conversion!!\n"); + DBG_INFO(80, "Found GFX_TEXFMT_P_8 format. Need conversion!!\n"); int width = info->width; int height = info->height; uint16 format = info->format; - /* XXX: avoid collision with zlib compression buffer in TxHiResTexture::get */ + // Avoid collision with zlib compression buffer in TxHiResTexture::get uint8 *texture = info->data; uint8 *tmptex = (texture == _tex1) ? _tex2 : _tex1; - /* use palette and convert to 16bit format */ + // Use palette and convert to 16-bit format _txQuantize->P8_16BPP((uint32*)texture, (uint32*)tmptex, info->width, info->height, (uint32*)palette); texture = tmptex; format = GFX_TEXFMT_ARGB_1555; #if 1 - /* XXX: compressed if memory cache compression is ON */ + // Compressed if memory cache compression is ON if (_options & COMPRESSION_MASK) { tmptex = (texture == _tex1) ? _tex2 : _tex1; if (_txQuantize->quantize(texture, tmptex, info->width, info->height, format, GFX_TEXFMT_ARGB_8888)) { @@ -529,7 +520,7 @@ TxFilter::hirestex(uint64_t g64crc, uint64_t r_crc64, uint16 *palette, GHQTexInf } #endif - /* fill in the required info to return */ + // Fill in the required info to return info->data = texture; info->width = width; info->height = height; @@ -539,7 +530,7 @@ TxFilter::hirestex(uint64_t g64crc, uint64_t r_crc64, uint16 *palette, GHQTexInf info->aspectRatioLog2 = _txUtil->grAspectRatioLog2(width, height); info->is_hires_tex = 1; - /* XXX: add to hires texture cache!!! */ + // Add to high resolution texture cache _txHiResCache->add(r_crc64, info); DBG_INFO(80, "GFX_TEXFMT_P_8 loaded as gfmt:%x!\n", format); @@ -550,17 +541,17 @@ TxFilter::hirestex(uint64_t g64crc, uint64_t r_crc64, uint16 *palette, GHQTexInf } #endif - /* check if we have it in memory cache */ + // Check if we have it in memory cache if (_cacheSize && g64crc) { if (_txTexCache->get(g64crc, info)) { - DBG_INFO(80, "cache hit: %d x %d gfmt:%x\n", info->width, info->height, info->format); - return 1; /* yep, we've got it */ + DBG_INFO(80, "Cache hit: %d x %d gfmt:%x\n", info->width, info->height, info->format); + return 1; // Yes, we've got it } } - DBG_INFO(80, "no cache hits.\n"); + DBG_INFO(80, "No cache hits.\n"); return 0; } @@ -599,11 +590,11 @@ TxFilter::dmptx(uint8 *src, int width, int height, int rowStridePixel, uint16 gf if (!_path.empty() && !_ident.empty()) { - /* dump it to disk */ + // Dump it to disk FILE *fp = nullptr; CPath tmpbuf(_path.c_str(), ""); - /* create directories */ + // Create directories tmpbuf.AppendDirectory("texture_dump"); if (!tmpbuf.DirectoryExists() && !tmpbuf.DirectoryCreate()) @@ -644,7 +635,7 @@ TxFilter::dmptx(uint8 *src, int width, int height, int rowStridePixel, uint16 gf bool TxFilter::reloadhirestex() { - DBG_INFO(80, "Reload hires textures from texture pack.\n"); + DBG_INFO(80, "Reload high resolution textures from texture pack.\n"); if (_txHiResCache->load(0)) { if (_txHiResCache->empty()) _options &= ~HIRESTEXTURES_MASK; diff --git a/Source/Project64-video/TextureEnhancer/TxFilter.h b/Source/Project64-video/TextureEnhancer/TxFilter.h index 28e80b496..2ff91b8f0 100644 --- a/Source/Project64-video/TextureEnhancer/TxFilter.h +++ b/Source/Project64-video/TextureEnhancer/TxFilter.h @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2003 Rice1964 @@ -51,10 +51,10 @@ public: int srcwidth, int srcheight, uint16 srcformat, - uint64_t g64crc, /* glide64 crc, 64bit for future use */ + uint64_t g64crc, // Glide64 CRC, 64-bit for future use GHQTexInfo *info); - bool hirestex(uint64_t g64crc, /* glide64 crc, 64bit for future use */ - uint64_t r_crc64, /* checksum hi:palette low:texture */ + bool hirestex(uint64_t g64crc, // Glide64 CRC, 64-bit for future use + uint64_t r_crc64, // Checksum hi:palette low:texture uint16 *palette, GHQTexInfo *info); uint64_t checksum64(uint8 *src, int width, int height, int size, int rowStride, uint8 *palette); diff --git a/Source/Project64-video/TextureEnhancer/TxFilterExport.cpp b/Source/Project64-video/TextureEnhancer/TxFilterExport.cpp index 9836461b9..84b89e557 100644 --- a/Source/Project64-video/TextureEnhancer/TxFilterExport.cpp +++ b/Source/Project64-video/TextureEnhancer/TxFilterExport.cpp @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2003 Rice1964 diff --git a/Source/Project64-video/TextureEnhancer/TxHiResCache.cpp b/Source/Project64-video/TextureEnhancer/TxHiResCache.cpp index 2a17a53ea..ccb1f920e 100644 --- a/Source/Project64-video/TextureEnhancer/TxHiResCache.cpp +++ b/Source/Project64-video/TextureEnhancer/TxHiResCache.cpp @@ -1,26 +1,26 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2003-2009 Sergey 'Gonetz' Lipski // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2003 Rice1964 // GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html + #ifdef _WIN32 #pragma warning(disable: 4786) #endif -/* dump processed hirestextures to disk - * (0:disable, 1:enable) */ +// Dump processed high resolution textures to disk +// (0:disable, 1:enable) #define DUMP_CACHE 1 - /* handle oversized textures by - * 0: minification - * 1: Glide64 style tiling - */ +// Handle oversized textures by: +// 0: Minification +// 1: Glide64 style tiling #define TEXTURE_TILING 1 - /* use power of 2 texture size - * (0:disable, 1:enable, 2:3dfx) */ +// Use power of 2 texture size +// (0:disable, 1:enable, 2:3dfx) #define POW2_TEXTURES 2 #if TEXTURE_TILING @@ -28,13 +28,13 @@ #define POW2_TEXTURES 2 #endif - /* hack to reduce texture footprint to achieve - * better performace on midrange gfx cards. - * (0:disable, 1:enable) */ +// Hack to reduce texture footprint to achieve +// better performance on mid-range graphics cards. +// (0:disable, 1:enable) #define REDUCE_TEXTURE_FOOTPRINT 0 - /* use aggressive format assumption for quantization - * (0:disable, 1:enable, 2:extreme) */ +// Use aggressive format assumption for quantization +// (0:disable, 1:enable, 2:extreme) #define AGGRESSIVE_QUANTIZATION 1 #include "TxHiResCache.h" @@ -53,7 +53,7 @@ TxHiResCache::~TxHiResCache() #if DUMP_CACHE if ((_options & DUMP_HIRESTEXCACHE) && !_haveCache && !_abortLoad) { - /* dump cache to disk */ + // Dump cache to disk std::string filename = _ident + "_HIRESTEXTURES.dat"; CPath cachepath(_path.c_str(), ""); @@ -82,7 +82,7 @@ TxHiResCache::TxHiResCache(int maxwidth, int maxheight, int maxbpp, int options, _abortLoad = 0; _haveCache = 0; - /* assert local options */ + // Assert local options if (!(_options & COMPRESS_HIRESTEX)) { _options &= ~COMPRESSION_MASK; @@ -94,10 +94,10 @@ TxHiResCache::TxHiResCache(int maxwidth, int maxheight, int maxbpp, int options, } #if DUMP_CACHE - /* read in hires texture cache */ + // Read in high resolution texture cache if (_options & DUMP_HIRESTEXCACHE) { - /* find it on disk */ + // Find it on disk std::string filename = _ident + "_HIRESTEXTURES.dat"; CPath cachepath(_path.c_str(), ""); cachepath.AppendDirectory("Cache"); @@ -107,7 +107,7 @@ TxHiResCache::TxHiResCache(int maxwidth, int maxheight, int maxbpp, int options, } #endif - /* read in hires textures */ + // Read in high resolution textures if (!_haveCache) TxHiResCache::load(0); } @@ -118,7 +118,7 @@ TxHiResCache::empty() } bool -TxHiResCache::load(bool replace) /* 0 : reload, 1 : replace partial */ +TxHiResCache::load(bool replace) // 0: Reload, 1: Replace partial { if (!_path.empty() && !_ident.empty()) { @@ -130,15 +130,15 @@ TxHiResCache::load(bool replace) /* 0 : reload, 1 : replace partial */ { case RICE_HIRESTEXTURES: INFO(80, "-----\n"); - INFO(80, "using Rice hires texture format...\n"); - INFO(80, " must be one of the following;\n"); + INFO(80, "Using Rice high resolution texture format...\n"); + INFO(80, " Must be one of the following;\n"); INFO(80, " 1) *_rgb.png + *_a.png\n"); INFO(80, " 2) *_all.png\n"); INFO(80, " 3) *_ciByRGBA.png\n"); INFO(80, " 4) *_allciByRGBA.png\n"); INFO(80, " 5) *_ci.bmp\n"); - INFO(80, " usage of only 2) and 3) highly recommended!\n"); - INFO(80, " folder names must be in US-ASCII characters!\n"); + INFO(80, " Usage of only 2) and 3) highly recommended!\n"); + INFO(80, " Folder names must be in US-ASCII characters!\n"); dir_path.AppendDirectory(_ident.c_str()); loadHiResTextures(dir_path, replace); @@ -158,14 +158,14 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) CPath TextureDir(dir_path, ""); - /* find it on disk */ + // Find it on disk if (!TextureDir.DirectoryExists()) { - INFO(80, "Error: path not found!\n"); + INFO(80, "Error: Path not found!\n"); return 0; } - /* recursive read into sub-directory */ + // Recursive read into sub-directory TextureDir.SetNameExtension("*"); if (TextureDir.FindFirst(CPath::FIND_ATTRIBUTE_SUBDIR)) { @@ -194,17 +194,16 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) int untiled_width = 0, untiled_height = 0; uint16 destformat = 0; - /* Rice hi-res textures: begin - */ + // Rice high resolution textures: begin uint32 chksum = 0, fmt = 0, siz = 0, palchksum = 0; char *pfname = nullptr, fname[260]; std::string ident; FILE *fp = nullptr; strcpy(fname, _ident.c_str()); - /* XXX case sensitivity fiasco! - * files must use _a, _rgb, _all, _allciByRGBA, _ciByRGBA, _ci - * and file extensions must be in lower case letters! */ + // Case sensitivity fiasco! + // Files must use _a, _rgb, _all, _allciByRGBA, _ciByRGBA, _ci + // and file extensions must be in lower case letters! #ifdef _WIN32 { unsigned int i; @@ -213,13 +212,13 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) #endif ident.assign(fname); - /* read in Rice's file naming convention */ + // Read in Rice's file naming convention #define CRCFMTSIZ_LEN 13 #define PALCRC_LEN 9 wcstombs(fname, stdstr(TextureDir.GetNameExtension()).ToUTF16().c_str(), 260); - /* XXX case sensitivity fiasco! - * files must use _a, _rgb, _all, _allciByRGBA, _ciByRGBA, _ci - * and file extensions must be in lower case letters! */ + // Case sensitivity fiasco! + // Files must use _a, _rgb, _all, _allciByRGBA, _ciByRGBA, _ci + // and file extensions must be in lower case letters! #ifdef _WIN32 { unsigned int i; @@ -233,10 +232,10 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) { #if !DEBUG INFO(80, "-----\n"); - INFO(80, "path: %ls\n", stdstr(dir_path).ToUTF16().c_str()); - INFO(80, "file: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str()); + INFO(80, "Path: %ls\n", stdstr(dir_path).ToUTF16().c_str()); + INFO(80, "File: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str()); #endif - INFO(80, "Error: not png or bmp or dds!\n"); + INFO(80, "Error: Not PNG or BMP or DDS!\n"); continue; } pfname = strstr(fname, ident.c_str()); @@ -252,23 +251,23 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) if (!pfname) { #if !DEBUG INFO(80, "-----\n"); - INFO(80, "path: %ls\n", stdstr(dir_path).ToUTF16().c_str()); - INFO(80, "file: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str()); + INFO(80, "Path: %ls\n", stdstr(dir_path).ToUTF16().c_str()); + INFO(80, "File: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str()); #endif - INFO(80, "Error: not Rice texture naming convention!\n"); + INFO(80, "Error: Not Rice texture naming convention!\n"); continue; } if (!chksum) { #if !DEBUG INFO(80, "-----\n"); - INFO(80, "path: %ls\n", stdstr(dir_path).ToUTF16().c_str()); - INFO(80, "file: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str()); + INFO(80, "Path: %ls\n", stdstr(dir_path).ToUTF16().c_str()); + INFO(80, "File: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str()); #endif - INFO(80, "Error: crc32 = 0!\n"); + INFO(80, "Error: CRC32 = 0!\n"); continue; } - /* check if we already have it in hires texture cache */ + // Check if we already have it in high resolution texture cache if (!replace) { uint64_t chksum64 = (uint64_t)palchksum; chksum64 <<= 32; @@ -276,35 +275,32 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) if (TxCache::is_cached(chksum64)) { #if !DEBUG INFO(80, "-----\n"); - INFO(80, "path: %ls\n", stdstr(dir_path).ToUTF16().c_str()); - INFO(80, "file: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str()); + INFO(80, "Path: %ls\n", stdstr(dir_path).ToUTF16().c_str()); + INFO(80, "File: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str()); #endif - INFO(80, "Error: already cached! duplicate texture!\n"); + INFO(80, "Error: Already cached! Duplicate texture!\n"); continue; } } - DBG_INFO(80, "rom: %ls chksum:%08X %08X fmt:%x size:%x\n", _ident.c_str(), chksum, palchksum, fmt, siz); + DBG_INFO(80, "ROM: %ls chksum:%08X %08X fmt:%x size:%x\n", _ident.c_str(), chksum, palchksum, fmt, siz); - /* Deal with the wackiness some texture packs utilize Rice format. + /* Deal with the odd way some texture packs utilize the Rice format. * Read in the following order: _a.* + _rgb.*, _all.png _ciByRGBA.png, - * _allciByRGBA.png, and _ci.bmp. PNG are prefered over BMP. + * _allciByRGBA.png, and _ci.bmp. PNG are preferred over BMP. * * For some reason there are texture packs that include them all. Some * even have RGB textures named as _all.* and ARGB textures named as - * _rgb.*... Someone pleeeez write a GOOD guideline for the texture - * designers!!! - * - * We allow hires textures to have higher bpp than the N64 originals. - */ - /* N64 formats + * _rgb.*. Someone please write a good guideline for the texture + * designers! + * + * We allow high resolution textures to have higher bpp than the N64 original textures. + * N64 formats * Format: 0 - RGBA, 1 - YUV, 2 - CI, 3 - IA, 4 - I - * Size: 0 - 4bit, 1 - 8bit, 2 - 16bit, 3 - 32 bit + * Size: 0 - 4-bit, 1 - 8-bit, 2 - 16-bit, 3 - 32-bit */ - /* - * read in _rgb.* and _a.* - */ + // Read in _rgb.* and _a.* if (pfname == strstr(fname, "_rgb.") || pfname == strstr(fname, "_a.")) { strcpy(pfname, "_rgb.png"); CPath TargetFile(dir_path, fname); @@ -316,14 +312,14 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) { #if !DEBUG INFO(80, "-----\n"); - INFO(80, "path: %ls\n", stdstr(dir_path).ToUTF16().c_str()); - INFO(80, "file: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str()); + INFO(80, "Path: %ls\n", stdstr(dir_path).ToUTF16().c_str()); + INFO(80, "File: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str()); #endif - INFO(80, "Error: missing _rgb.*! _a.* must be paired with _rgb.*!\n"); + INFO(80, "Error: Missing _rgb.*! _a.* must be paired with _rgb.*!\n"); continue; } } - /* _a.png */ + // _a.png strcpy(pfname, "_a.png"); TargetFile = CPath(dir_path, fname); if ((fp = fopen(TargetFile, "rb")) != nullptr) { @@ -331,7 +327,7 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) fclose(fp); } if (!tmptex) { - /* _a.bmp */ + // _a.bmp strcpy(pfname, "_a.bmp"); TargetFile = CPath(dir_path, fname); if ((fp = fopen(TargetFile, "rb")) != nullptr) { @@ -339,7 +335,7 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) fclose(fp); } } - /* _rgb.png */ + // _rgb.png strcpy(pfname, "_rgb.png"); TargetFile = CPath(dir_path, fname); if ((fp = fopen(TargetFile, "rb")) != nullptr) { @@ -347,7 +343,7 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) fclose(fp); } if (!tex) { - /* _rgb.bmp */ + // _rgb.bmp strcpy(pfname, "_rgb.bmp"); TargetFile = CPath(dir_path, fname); if ((fp = fopen(TargetFile, "rb")) != nullptr) { @@ -356,22 +352,22 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) } } if (tmptex) { - /* check if _rgb.* and _a.* have matching size and format. */ + // Check if _rgb.* and _a.* have matching size and format if (!tex || width != tmpwidth || height != tmpheight || format != GFX_TEXFMT_ARGB_8888 || tmpformat != GFX_TEXFMT_ARGB_8888) { #if !DEBUG INFO(80, "-----\n"); - INFO(80, "path: %ls\n", stdstr(dir_path).ToUTF16().c_str()); - INFO(80, "file: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str()); + INFO(80, "Path: %ls\n", stdstr(dir_path).ToUTF16().c_str()); + INFO(80, "File: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str()); #endif if (!tex) { - INFO(80, "Error: missing _rgb.*!\n"); + INFO(80, "Error: Missing _rgb.*!\n"); } else if (width != tmpwidth || height != tmpheight) { INFO(80, "Error: _rgb.* and _a.* have mismatched width or height!\n"); } else if (format != GFX_TEXFMT_ARGB_8888 || tmpformat != GFX_TEXFMT_ARGB_8888) { - INFO(80, "Error: _rgb.* or _a.* not in 32bit color!\n"); + INFO(80, "Error: _rgb.* or _a.* not in 32-bit color!\n"); } if (tex) free(tex); if (tmptex) free(tmptex); @@ -380,20 +376,20 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) continue; } } - /* make adjustments */ + // Make adjustments if (tex) { if (tmptex) { - /* merge (A)RGB and A comp */ - DBG_INFO(80, "merge (A)RGB and A comp\n"); + // Merge (A)RGB and A comp + DBG_INFO(80, "Merge (A)RGB and A comp\n"); int i; for (i = 0; i < height * width; i++) { #if 1 - /* use R comp for alpha. this is what Rice uses. sigh... */ + // Use R comp for alpha. This is what Rice uses. ((uint32*)tex)[i] &= 0x00ffffff; ((uint32*)tex)[i] |= ((((uint32*)tmptex)[i] & 0x00ff0000) << 8); #endif #if 0 - /* use libpng style grayscale conversion */ + // Use libpng style grayscale conversion uint32 texel = ((uint32*)tmptex)[i]; uint32 acomp = (((texel >> 16) & 0xff) * 6969 + ((texel >> 8) & 0xff) * 23434 + @@ -401,7 +397,7 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) ((uint32*)tex)[i] = (acomp << 24) | (((uint32*)tex)[i] & 0x00ffffff); #endif #if 0 - /* use the standard NTSC gray scale conversion */ + // Use the standard NTSC grayscale conversion uint32 texel = ((uint32*)tmptex)[i]; uint32 acomp = (((texel >> 16) & 0xff) * 299 + ((texel >> 8) & 0xff) * 587 + @@ -413,13 +409,13 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) tmptex = nullptr; } else { - /* clobber A comp. never a question of alpha. only RGB used. */ + // Clobber A comp. Never a question of alpha. Only RGB used. #if !DEBUG INFO(80, "-----\n"); - INFO(80, "path: %ls\n", stdstr(dir_path).ToUTF16().c_str()); - INFO(80, "file: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str()); + INFO(80, "Path: %ls\n", stdstr(dir_path).ToUTF16().c_str()); + INFO(80, "File: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str()); #endif - INFO(80, "Warning: missing _a.*! only using _rgb.*. treat as opaque texture.\n"); + INFO(80, "Warning: Missing _a.*! Only using _rgb.*. Treat as opaque texture.\n"); int i; for (i = 0; i < height * width; i++) { ((uint32*)tex)[i] |= 0xff000000; @@ -429,10 +425,8 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) } else - /* - * read in _all.png, _all.dds, _allciByRGBA.png, _allciByRGBA.dds - * _ciByRGBA.png, _ciByRGBA.dds, _ci.bmp - */ + // Read in _all.png, _all.dds, _allciByRGBA.png, _allciByRGBA.dds + // _ciByRGBA.png, _ciByRGBA.dds, _ci.bmp if (pfname == strstr(fname, "_all.png") || pfname == strstr(fname, "_all.dds") || #ifdef _WIN32 @@ -454,7 +448,7 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) else tex = _txImage->readBMP(fp, &width, &height, &format); fclose(fp); } - /* XXX: auto-adjustment of dxt dds textures unsupported for now */ + // Auto-adjustment of dxt DDS textures unsupported for now if (tex && strstr(fname, ".dds")) { const float aspectratio = (width > height) ? (float)width / (float)height : (float)height / (float)width; if (!(aspectratio == 1.0 || @@ -465,8 +459,8 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) tex = nullptr; #if !DEBUG INFO(80, "-----\n"); - INFO(80, "path: %ls\n", stdstr(dir_path).ToUTF16().c_str()); - INFO(80, "file: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str()); + INFO(80, "Path: %ls\n", stdstr(dir_path).ToUTF16().c_str()); + INFO(80, "File: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str()); #endif INFO(80, "Error: W:H aspect ratio range not 8:1 - 1:8!\n"); continue; @@ -477,46 +471,46 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) tex = nullptr; #if !DEBUG INFO(80, "-----\n"); - INFO(80, "path: %ls\n", stdstr(dir_path).ToUTF16().c_str()); - INFO(80, "file: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str()); + INFO(80, "Path: %ls\n", stdstr(dir_path).ToUTF16().c_str()); + INFO(80, "File: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str()); #endif - INFO(80, "Error: not power of 2 size!\n"); + INFO(80, "Error: Not power of 2 size!\n"); continue; } } } - /* if we do not have a texture at this point we are screwed */ + // If we do not have a texture at this point then fail if (!tex) { #if !DEBUG INFO(80, "-----\n"); - INFO(80, "path: %ls\n", stdstr(dir_path).ToUTF16().c_str()); - INFO(80, "file: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str()); + INFO(80, "Path: %ls\n", stdstr(dir_path).ToUTF16().c_str()); + INFO(80, "File: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str()); #endif - INFO(80, "Error: load failed!\n"); + INFO(80, "Error: Load failed!\n"); continue; } - DBG_INFO(80, "read in as %d x %d gfmt:%x\n", tmpwidth, tmpheight, tmpformat); + DBG_INFO(80, "Read in as %d x %d gfmt:%x\n", tmpwidth, tmpheight, tmpformat); - /* check if size and format are OK */ + // Check if size and format are OK if (!(format == GFX_TEXFMT_ARGB_8888 || format == GFX_TEXFMT_P_8 || format == GFX_TEXFMT_ARGB_CMP_DXT1 || format == GFX_TEXFMT_ARGB_CMP_DXT3 || format == GFX_TEXFMT_ARGB_CMP_DXT5) || - (width * height) < 4) { /* TxQuantize requirement: width * height must be 4 or larger. */ + (width * height) < 4) { // TxQuantize requirement: width * height must be 4 or larger. free(tex); tex = nullptr; #if !DEBUG INFO(80, "-----\n"); - INFO(80, "path: %ls\n", stdstr(dir_path).ToUTF16().c_str()); - INFO(80, "file: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str()); + INFO(80, "Path: %ls\n", stdstr(dir_path).ToUTF16().c_str()); + INFO(80, "File: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str()); #endif - INFO(80, "Error: not width * height > 4 or 8bit palette color or 32bpp or dxt1 or dxt3 or dxt5!\n"); + INFO(80, "Error: Not width * height > 4 or 8-bit palette color or 32bpp or dxt1 or dxt3 or dxt5!\n"); continue; } - /* analyze and determine best format to quantize */ + // Analyze and determine best format to quantize if (format == GFX_TEXFMT_ARGB_8888) { int i; int alphabits = 0; @@ -524,7 +518,7 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) bool intensity = 1; if (!(_options & LET_TEXARTISTS_FLY)) { - /* HACK ALERT! */ + // Hack alert! /* Account for Rice's weirdness with fmt:0 siz:2 textures. * Although the conditions are relaxed with other formats, * the D3D RGBA5551 surface is used for this format in certain @@ -532,16 +526,16 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) * meter. The same goes for fmt:2 textures. See Mollymutt's * PaperMario text. */ if ((fmt == 0 && siz == 2) || fmt == 2) { - DBG_INFO(80, "Remove black, white, etc borders along the alpha edges.\n"); - /* round A comp */ + DBG_INFO(80, "Remove black, white, etc. borders along the alpha edges.\n"); + // Round A comp for (i = 0; i < height * width; i++) { uint32 texel = ((uint32*)tex)[i]; ((uint32*)tex)[i] = ((texel & 0xff000000) == 0xff000000 ? 0xff000000 : 0) | (texel & 0x00ffffff); } - /* Substitute texel color with the average of the surrounding - * opaque texels. This removes borders regardless of hardware - * texture filtering (bilinear, etc). */ + // Substitute texel color with the average of the surrounding + // opaque texels. This removes borders regardless of hardware + // texture filtering (bilinear, etc.) int j; for (i = 0; i < height; i++) { for (j = 0; j < width; j++) { @@ -552,17 +546,17 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) numtexel = r = g = b = 0; memset(&tmptexel, 0, sizeof(tmptexel)); if (i > 0) { - tmptexel[0] = ((uint32*)tex)[(i - 1) * width + j]; /* north */ - if (j > 0) tmptexel[1] = ((uint32*)tex)[(i - 1) * width + j - 1]; /* north-west */ - if (j < width - 1) tmptexel[2] = ((uint32*)tex)[(i - 1) * width + j + 1]; /* north-east */ + tmptexel[0] = ((uint32*)tex)[(i - 1) * width + j]; // North + if (j > 0) tmptexel[1] = ((uint32*)tex)[(i - 1) * width + j - 1]; // Northwest + if (j < width - 1) tmptexel[2] = ((uint32*)tex)[(i - 1) * width + j + 1]; // Northeast } if (i < height - 1) { - tmptexel[3] = ((uint32*)tex)[(i + 1) * width + j]; /* south */ - if (j > 0) tmptexel[4] = ((uint32*)tex)[(i + 1) * width + j - 1]; /* south-west */ - if (j < width - 1) tmptexel[5] = ((uint32*)tex)[(i + 1) * width + j + 1]; /* south-east */ + tmptexel[3] = ((uint32*)tex)[(i + 1) * width + j]; // South + if (j > 0) tmptexel[4] = ((uint32*)tex)[(i + 1) * width + j - 1]; // Southwest + if (j < width - 1) tmptexel[5] = ((uint32*)tex)[(i + 1) * width + j + 1]; // Southeast } - if (j > 0) tmptexel[6] = ((uint32*)tex)[i * width + j - 1]; /* west */ - if (j < width - 1) tmptexel[7] = ((uint32*)tex)[i * width + j + 1]; /* east */ + if (j > 0) tmptexel[6] = ((uint32*)tex)[i * width + j - 1]; // West + if (j < width - 1) tmptexel[7] = ((uint32*)tex)[i * width + j + 1]; // East for (k = 0; k < 8; k++) { if ((tmptexel[k] & 0xff000000) == 0xff000000) { r += ((tmptexel[k] & 0x00ff0000) >> 16); @@ -585,7 +579,7 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) } } - /* simple analysis of texture */ + // Simple analysis of texture for (i = 0; i < height * width; i++) { uint32 texel = ((uint32*)tex)[i]; if (alphabits != 8) { @@ -619,9 +613,9 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) } if (!intensity && alphabits == 8) break; } - DBG_INFO(80, "required alpha bits:%d zero acomp texels:%d rgb as intensity:%d\n", alphabits, fullalpha, intensity); + DBG_INFO(80, "Required alpha bits:%d zero acomp texels:%d rgb as intensity:%d\n", alphabits, fullalpha, intensity); - /* preparations based on above analysis */ + // Preparations based on above analysis #if !REDUCE_TEXTURE_FOOTPRINT if (_maxbpp < 32 || _options & (FORCE16BPP_HIRESTEX | COMPRESSION_MASK)) { #endif @@ -636,7 +630,7 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) #endif if (fmt == 4 && alphabits == 0) { destformat = GFX_TEXFMT_ARGB_8888; - /* Rice I format; I = (R + G + B) / 3 */ + // Rice I format; I = (R + G + B) / 3 for (i = 0; i < height * width; i++) { uint32 texel = ((uint32*)tex)[i]; uint32 icomp = (((texel >> 16) & 0xff) + @@ -655,22 +649,20 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) } } - DBG_INFO(80, "best gfmt:%x\n", destformat); + DBG_INFO(80, "Best gfmt:%x\n", destformat); } - /* - * Rice hi-res textures: end */ - - /* XXX: only ARGB8888 for now. comeback to this later... */ + // Rice high resolution textures: end + // Only ARGB8888 for now, we will come back to this later... if (format == GFX_TEXFMT_ARGB_8888) { #if TEXTURE_TILING - /* minification */ + // Minification { int ratio = 1; - /* minification to enable glide64 style texture tiling */ - /* determine the minification ratio to tile the texture into 256x256 size */ + // Minification to enable Glide64 style texture tiling + // Determine the minification ratio to tile the texture into 256x256 size if ((_options & TILE_HIRESTEX) && _maxwidth >= 256 && _maxheight >= 256) { - DBG_INFO(80, "determine minification ratio to tile\n"); + DBG_INFO(80, "Determine minification ratio to tile\n"); tmpwidth = width; tmpheight = height; if (height > 256) { @@ -687,9 +679,9 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) } } else { - /* normal minification to fit max texture size */ + // Normal minification to fit max texture size if (width > _maxwidth || height > _maxheight) { - DBG_INFO(80, "determine minification ratio to fit max texture size\n"); + DBG_INFO(80, "Determine minification ratio to fit max texture size\n"); tmpwidth = width; tmpheight = height; while (tmpwidth > _maxwidth) { @@ -702,7 +694,7 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) tmpwidth >>= 1; ratio <<= 1; } - DBG_INFO(80, "minification ratio:%d %d x %d -> %d x %d\n", + DBG_INFO(80, "Minification ratio:%d %d x %d -> %d x %d\n", ratio, width, height, tmpwidth, tmpheight); } } @@ -711,30 +703,30 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) if (!_txReSample->minify(&tex, &width, &height, ratio)) { free(tex); tex = nullptr; - DBG_INFO(80, "Error: minification failed!\n"); + DBG_INFO(80, "Error: Minification failed!\n"); continue; } } } - /* tiling */ + // Tiling if ((_options & TILE_HIRESTEX) && _maxwidth >= 256 && _maxheight >= 256) { bool usetile = 0; - /* to tile or not to tile, that is the question */ + // To tile or not to tile, that is the question if (width > 256 && height <= 128 && (((width - 1) >> 8) + 1) * height <= 256) { if (width > _maxwidth) usetile = 1; else { - /* tile if the tiled texture memory footprint is smaller */ + // Tile if the tiled texture memory footprint is smaller int tilewidth = 256; int tileheight = _txReSample->nextPow2((((width - 1) >> 8) + 1) * height); tmpwidth = width; tmpheight = height; - /* 3dfx Glide3 tmpheight, W:H aspect ratio range (8:1 - 1:8) */ + // 3DFX Glide3 tmpheight, W:H aspect ratio range (8:1 - 1:8) if (tilewidth > (tileheight << 3)) tileheight = tilewidth >> 3; - /* HACKALERT: see TxReSample::pow2(); */ + // HACKALERT: see TxReSample::pow2(); if (tmpwidth > 64) tmpwidth -= 4; else if (tmpwidth > 16) tmpwidth -= 2; else if (tmpwidth > 4) tmpwidth -= 1; @@ -746,7 +738,7 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) tmpwidth = _txReSample->nextPow2(tmpwidth); tmpheight = _txReSample->nextPow2(tmpheight); - /* 3dfx Glide3 tmpheight, W:H aspect ratio range (8:1 - 1:8) */ + // 3DFX Glide3 tmpheight, W:H aspect ratio range (8:1 - 1:8) if (tmpwidth > tmpheight) { if (tmpwidth > (tmpheight << 3)) tmpheight = tmpwidth >> 3; } @@ -758,7 +750,7 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) } } - /* tile it! do the actual tiling into 256x256 size */ + // Tile it! Do the actual tiling into 256x256 size if (usetile) { DBG_INFO(80, "Glide64 style texture tiling\n"); @@ -794,9 +786,9 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) } } -#else /* TEXTURE_TILING */ +#else // TEXTURE_TILING - /* minification */ + // Minification if (width > _maxwidth || height > _maxheight) { int ratio = 1; if (width / _maxwidth > height / _maxheight) { @@ -808,24 +800,24 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) if (!_txReSample->minify(&tex, &width, &height, ratio)) { free(tex); tex = nullptr; - DBG_INFO(80, "Error: minification failed!\n"); + DBG_INFO(80, "Error: Minification failed!\n"); continue; } } -#endif /* TEXTURE_TILING */ +#endif // TEXTURE_TILING - /* texture compression */ + // Texture compression if ((_options & COMPRESSION_MASK) && (width >= 64 && height >= 64) /* Texture compression is not suitable for low pixel coarse detail * textures. The assumption here is that textures larger than 64x64 * have enough detail to produce decent quality when compressed. The - * down side is that narrow stripped textures that the N64 often use + * down side is that narrow stripped textures that the N64 often uses * for large background textures are also ignored. It would be more - * reasonable if decisions are made based on fourier-transform + * reasonable if decisions are made based on Fourier-transform * spectrum or RMS error. * - * NOTE: texture size must be checked before expanding to pow2 size. + * NOTE: Texture size must be checked before expanding to pow2 size. */ ) { int dataSize = 0; @@ -833,15 +825,15 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) #if POW2_TEXTURES #if (POW2_TEXTURES == 2) - /* 3dfx Glide3x aspect ratio (8:1 - 1:8) */ + // 3DFX Glide3x aspect ratio (8:1 - 1:8) if (!_txReSample->nextPow2(&tex, &width, &height, 32, 1)) { #else - /* normal pow2 expansion */ + // Normal pow2 expansion if (!_txReSample->nextPow2(&tex, &width, &height, 32, 0)) { #endif free(tex); tex = nullptr; - DBG_INFO(80, "Error: aspect ratio adjustment failed!\n"); + DBG_INFO(80, "Error: Aspect ratio adjustment failed!\n"); continue; } #endif @@ -851,7 +843,7 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) switch (destformat) { case GFX_TEXFMT_ARGB_8888: #if GLIDE64_DXTN - case GFX_TEXFMT_ARGB_1555: /* for ARGB1555 use DXT5 instead of DXT1 */ + case GFX_TEXFMT_ARGB_1555: // For ARGB1555 use DXT5 instead of DXT1 #endif case GFX_TEXFMT_ALPHA_INTENSITY_88: dataSize = width * height; @@ -863,7 +855,7 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) case GFX_TEXFMT_INTENSITY_8: dataSize = (width * height) >> 1; break; - case GFX_TEXFMT_ALPHA_8: /* no size benefit with dxtn */ + case GFX_TEXFMT_ALPHA_8: // No size benefit with dxtn ; } break; @@ -874,19 +866,19 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) case GFX_TEXFMT_INTENSITY_8: dataSize = (width * height) >> 1; break; - /* XXX: textures that use 8bit alpha channel look bad with the current - * fxt1 library, so we substitute it with dxtn for now. afaik all gfx - * cards that support fxt1 also support dxtn. (3dfx and Intel) */ + // Textures that use 8-bit alpha channel look bad with the current + // fxt1 library, so we substitute it with dxtn for now. AFAIK all graphics + // cards that support fxt1 also support dxtn. (3DFX and Intel) case GFX_TEXFMT_ALPHA_INTENSITY_88: case GFX_TEXFMT_ARGB_8888: compressionType = S3TC_COMPRESSION; dataSize = width * height; break; - case GFX_TEXFMT_ALPHA_8: /* no size benefit with dxtn */ + case GFX_TEXFMT_ALPHA_8: // No size benefit with dxtn ; } } - /* compress it! */ + // Compress it! if (dataSize) { #if 0 /* TEST: dither before compression for better results with gradients */ tmptex = (uint8 *)malloc(_txUtil->sizeofTx(width, height, destformat)); @@ -917,21 +909,21 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) else { #if POW2_TEXTURES #if (POW2_TEXTURES == 2) - /* 3dfx Glide3x aspect ratio (8:1 - 1:8) */ + // 3DFX Glide3x aspect ratio (8:1 - 1:8) if (!_txReSample->nextPow2(&tex, &width, &height, 32, 1)) { #else - /* normal pow2 expansion */ + // Normal pow2 expansion if (!_txReSample->nextPow2(&tex, &width, &height, 32, 0)) { #endif free(tex); tex = nullptr; - DBG_INFO(80, "Error: aspect ratio adjustment failed!\n"); + DBG_INFO(80, "Error: Aspect ratio adjustment failed!\n"); continue; } #endif } - /* quantize */ + // Quantize { tmptex = (uint8 *)malloc(_txUtil->sizeofTx(width, height, destformat)); if (tmptex) { @@ -964,7 +956,7 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) #endif break; case GFX_TEXFMT_ALPHA_8: - destformat = GFX_TEXFMT_ALPHA_8; /* yes, this is correct. ALPHA_8 instead of INTENSITY_8 */ + destformat = GFX_TEXFMT_ALPHA_8; // Yes, this is correct. ALPHA_8 instead of INTENSITY_8 break; case GFX_TEXFMT_INTENSITY_8: destformat = GFX_TEXFMT_INTENSITY_8; @@ -978,25 +970,25 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) } } - /* last minute validations */ + // Last minute validations if (!tex || !chksum || !width || !height || !format || width > _maxwidth || height > _maxheight) { #if !DEBUG INFO(80, "-----\n"); - INFO(80, "path: %ls\n", stdstr(dir_path).ToUTF16().c_str()); - INFO(80, "file: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str()); + INFO(80, "Path: %ls\n", stdstr(dir_path).ToUTF16().c_str()); + INFO(80, "File: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str()); #endif if (tex) { free(tex); tex = nullptr; - INFO(80, "Error: bad format or size! %d x %d gfmt:%x\n", width, height, format); + INFO(80, "Error: Bad format or size! %d x %d gfmt:%x\n", width, height, format); } else { - INFO(80, "Error: load failed!!\n"); + INFO(80, "Error: Load failed!!\n"); } continue; } - /* load it into hires texture cache. */ + // Load it into high resolution texture cache { uint64_t chksum64 = (uint64_t)palchksum; chksum64 <<= 32; @@ -1015,7 +1007,7 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) tmpInfo.is_hires_tex = 1; #if TEXTURE_TILING - /* Glide64 style texture tiling. */ + // Glide64 style texture tiling if (untiled_width && untiled_height) { tmpInfo.tiles = ((untiled_width - 1) >> 8) + 1; @@ -1024,24 +1016,24 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) } #endif - /* remove redundant in cache */ + // Remove redundant in cache if (replace && TxCache::del(chksum64)) { - DBG_INFO(80, "removed duplicate old cache.\n"); + DBG_INFO(80, "Removed duplicate old cache.\n"); } - /* add to cache */ + // Add to cache if (TxCache::add(chksum64, &tmpInfo)) { - /* Callback to display hires texture info. - * Gonetz */ + // Callback to display high resolution texture info + // Gonetz if (_callback) { wchar_t tmpbuf[260]; mbstowcs(tmpbuf, fname, 260); (*_callback)("[%d] total mem:%.2fmb - %ls\n", _cache.size(), (float)_totalSize / 1000000, tmpbuf); } - DBG_INFO(80, "texture loaded!\n"); + DBG_INFO(80, "Texture loaded!\n"); } free(tex); } diff --git a/Source/Project64-video/TextureEnhancer/TxHiResCache.h b/Source/Project64-video/TextureEnhancer/TxHiResCache.h index a1a73f20f..e47960ea0 100644 --- a/Source/Project64-video/TextureEnhancer/TxHiResCache.h +++ b/Source/Project64-video/TextureEnhancer/TxHiResCache.h @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2003 Rice1964 @@ -8,10 +8,10 @@ #ifndef __TXHIRESCACHE_H__ #define __TXHIRESCACHE_H__ -/* support hires textures - * 0: disable - * 1: enable - */ +// Support high resolution textures +// 0: disable +// 1: enable + #define HIRES_TEXTURE 1 #include "TxCache.h" diff --git a/Source/Project64-video/TextureEnhancer/TxImage.cpp b/Source/Project64-video/TextureEnhancer/TxImage.cpp index 18d145071..9dec61510 100644 --- a/Source/Project64-video/TextureEnhancer/TxImage.cpp +++ b/Source/Project64-video/TextureEnhancer/TxImage.cpp @@ -1,15 +1,15 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2003 Rice1964 // GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html -/* use power of 2 texture size - * (0:disable, 1:enable, 2:3dfx) */ +// use power of 2 texture size +// (0:disable, 1:enable, 2:3dfx) #define POW2_TEXTURES 0 - /* check 8 bytes. use a larger value if needed. */ +// Check 8 bytes. Use a larger value if needed. #define PNG_CHK_BYTES 8 #include "TxImage.h" @@ -22,18 +22,18 @@ bool TxImage::getPNGInfo(FILE *fp, png_structp *png_ptr, png_infop *info_ptr) { unsigned char sig[PNG_CHK_BYTES]; - /* check for valid file pointer */ + // Check for valid file pointer if (!fp) return 0; - /* check if file is PNG */ + // Check if file is PNG if (fread(sig, 1, PNG_CHK_BYTES, fp) != PNG_CHK_BYTES) return 0; if (png_sig_cmp(sig, 0, PNG_CHK_BYTES) != 0) return 0; - /* get PNG file info */ + // Get PNG file info *png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr); if (!*png_ptr) return 0; @@ -45,7 +45,7 @@ bool TxImage::getPNGInfo(FILE *fp, png_structp *png_ptr, png_infop *info_ptr) } if (setjmp(png_jmpbuf(*png_ptr))) { - DBG_INFO(80, "error reading png!\n"); + DBG_INFO(80, "Error reading PNG!\n"); png_destroy_read_struct(png_ptr, info_ptr, nullptr); return 0; } @@ -60,7 +60,7 @@ bool TxImage::getPNGInfo(FILE *fp, png_structp *png_ptr, png_infop *info_ptr) uint8* TxImage::readPNG(FILE* fp, int* width, int* height, uint16* format) { - /* NOTE: returned image format is GFX_TEXFMT_ARGB_8888 */ + // NOTE: Returned image format is GFX_TEXFMT_ARGB_8888 png_structp png_ptr; png_infop info_ptr; @@ -68,18 +68,18 @@ TxImage::readPNG(FILE* fp, int* width, int* height, uint16* format) int bit_depth, color_type, interlace_type, compression_type, filter_type, row_bytes, o_width, o_height, num_pas; - /* initialize */ + // Initialize *width = 0; *height = 0; *format = 0; - /* check if we have a valid png file */ + // Check if we have a valid PNG file if (!fp) return nullptr; if (!getPNGInfo(fp, &png_ptr, &info_ptr)) { - INFO(80, "error reading png file! png image is corrupt.\n"); + INFO(80, "Error reading PNG file! PNG image is corrupt.\n"); return nullptr; } @@ -87,40 +87,39 @@ TxImage::readPNG(FILE* fp, int* width, int* height, uint16* format) (png_uint_32*)&o_width, (png_uint_32*)&o_height, &bit_depth, &color_type, &interlace_type, &compression_type, &filter_type); - DBG_INFO(80, "png format %d x %d bitdepth:%d color:%x interlace:%x compression:%x filter:%x\n", + DBG_INFO(80, "PNG format %d x %d bitdepth:%d color:%x interlace:%x compression:%x filter:%x\n", o_width, o_height, bit_depth, color_type, interlace_type, compression_type, filter_type); - /* transformations */ + // Transformations - /* Rice hi-res textures - * _all.png - * _rgb.png, _a.png - * _ciByRGBA.png - * _allciByRGBA.png - */ + // Rice high resolution textures + // _all.png + // _rgb.png, _a.png + // _ciByRGBA.png + // _allciByRGBA.png - /* strip if color channel is larger than 8 bits */ + // Strip if color channel is larger than 8-bit if (bit_depth > 8) { png_set_strip_16(png_ptr); bit_depth = 8; } #if 1 - /* These are not really required per Rice format spec, - * but is done just in case someone uses them. - */ - /* convert palette color to rgb color */ + // These are not really required as per the Rice format specification, + // but is done just in case someone uses them. + + // Convert palette color to RGB color if (color_type == PNG_COLOR_TYPE_PALETTE) { png_set_palette_to_rgb(png_ptr); color_type = PNG_COLOR_TYPE_RGB; } - /* expand 1,2,4 bit gray scale to 8 bit gray scale */ + // Expand 1,2, and 4-bit grayscale to 8-bit grayscale if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) png_set_expand(png_ptr); - /* convert gray scale or gray scale + alpha to rgb color */ + // Convert grayscale or grayscale + alpha to RGB color if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { png_set_gray_to_rgb(png_ptr); @@ -128,19 +127,19 @@ TxImage::readPNG(FILE* fp, int* width, int* height, uint16* format) } #endif - /* add alpha channel if any */ + // Add alpha channel if any if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) { png_set_tRNS_to_alpha(png_ptr); color_type = PNG_COLOR_TYPE_RGB_ALPHA; } - /* convert rgb to rgba */ + // Convert RGB to RGBA if (color_type == PNG_COLOR_TYPE_RGB) { png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER); color_type = PNG_COLOR_TYPE_RGB_ALPHA; } - /* punt invalid formats */ + // Check for invalid formatting if (color_type != PNG_COLOR_TYPE_RGB_ALPHA) { png_destroy_read_struct(&png_ptr, &info_ptr, nullptr); DBG_INFO(80, "Error: not PNG_COLOR_TYPE_RGB_ALPHA format!\n"); @@ -151,38 +150,38 @@ TxImage::readPNG(FILE* fp, int* width, int* height, uint16* format) if (png_get_sBIT(png_ptr, info_ptr, &sig_bit)) png_set_shift(png_ptr, sig_bit);*/ - /* convert rgba to bgra */ + // Convert RGBA to BGRA png_set_bgr(png_ptr); - /* turn on interlace handling to cope with the weirdness - * of texture authors using interlaced format */ + // Turn on interlace handling to cope with the weirdness + // of texture authors using interlaced format num_pas = png_set_interlace_handling(png_ptr); - /* update info structure */ + // Update info structure png_read_update_info(png_ptr, info_ptr); - /* we only get here if ARGB8888 */ + // We only get here if ARGB8888 row_bytes = png_get_rowbytes(png_ptr, info_ptr); - /* allocate memory to read in image */ + // Allocate memory to read in image image = (uint8*)malloc(row_bytes * o_height); - /* read in image */ + // Read in image if (image) { int pas, i; uint8* tmpimage; - for (pas = 0; pas < num_pas; pas++) { /* deal with interlacing */ + for (pas = 0; pas < num_pas; pas++) { // Deal with interlacing tmpimage = image; for (i = 0; i < o_height; i++) { - /* copy row */ + // Copy row png_read_rows(png_ptr, &tmpimage, nullptr, 1); tmpimage += row_bytes; } } - /* read rest of the info structure */ + // Read rest of the info structure png_read_end(png_ptr, info_ptr); *width = (row_bytes >> 2); @@ -190,12 +189,11 @@ TxImage::readPNG(FILE* fp, int* width, int* height, uint16* format) *format = GFX_TEXFMT_ARGB_8888; #if POW2_TEXTURES - /* next power of 2 size conversions */ - /* NOTE: I can do this in the above loop for faster operations, but some - * texture packs require a workaround. see HACKALERT in nextPow2(). - */ + // Next power of 2 size conversions + // NOTE: I can do this in the above loop for faster operations, but some + // texture packs require a workaround. See HACKALERT in nextPow2(). - TxReSample txReSample = new TxReSample; // XXX: temporary. move to a better place. + TxReSample txReSample = new TxReSample; // Temporary, move to a better place. #if (POW2_TEXTURES == 2) if (!txReSample->nextPow2(&image, width, height, 32, 1)) { @@ -213,15 +211,15 @@ TxImage::readPNG(FILE* fp, int* width, int* height, uint16* format) delete txReSample; -#endif /* POW2_TEXTURES */ +#endif // POW2_TEXTURES } - /* clean up */ + // Clean up png_destroy_read_struct(&png_ptr, &info_ptr, nullptr); #ifdef DEBUG if (!image) { - DBG_INFO(80, "Error: failed to load png image!\n"); + DBG_INFO(80, "Error: Failed to load PNG image!\n"); } #endif @@ -260,18 +258,19 @@ TxImage::writePNG(uint8* src, FILE* fp, int width, int height, int rowStride, ui png_init_io(png_ptr, fp); - /* TODO: images must be converted to RGBA8888 or CI8, - * palettes need to be separated to A and RGB. */ + /* + TODO: Images must be converted to RGBA8888 or CI8, + palettes need to be separated to A and RGB. - /* N64 formats - * Format: 0 - RGBA, 1 - YUV, 2 - CI, 3 - IA, 4 - I - * Size: 0 - 4bit, 1 - 8bit, 2 - 16bit, 3 - 32 bit - * format = (Format << 8 | Size); - */ - - /* each channel is saved in 8bits for consistency */ + N64 formats + Format: 0 - RGBA, 1 - YUV, 2 - CI, 3 - IA, 4 - I + Size: 0 - 4bit, 1 - 8bit, 2 - 16bit, 3 - 32 bit + format = (Format << 8 | Size); + + Each channel is saved in 8-bit for consistency + */ switch (format) { - case 0x0002:/* RGBA5551 */ + case 0x0002:// RGBA5551 bit_depth = 8; sig_bit.red = 5; sig_bit.green = 5; @@ -279,8 +278,8 @@ TxImage::writePNG(uint8* src, FILE* fp, int width, int height, int rowStride, ui sig_bit.alpha = 1; color_type = PNG_COLOR_TYPE_RGB_ALPHA; break; - case 0x0003:/* RGBA8888 */ - case 0x0302:/* IA88 */ + case 0x0003:// RGBA8888 + case 0x0302:// IA88 bit_depth = 8; sig_bit.red = 8; sig_bit.green = 8; @@ -288,7 +287,7 @@ TxImage::writePNG(uint8* src, FILE* fp, int width, int height, int rowStride, ui sig_bit.alpha = 8; color_type = PNG_COLOR_TYPE_RGB_ALPHA; break; - case 0x0300:/* IA31 */ + case 0x0300:// IA31 bit_depth = 8; sig_bit.red = 3; sig_bit.green = 3; @@ -296,7 +295,7 @@ TxImage::writePNG(uint8* src, FILE* fp, int width, int height, int rowStride, ui sig_bit.alpha = 1; color_type = PNG_COLOR_TYPE_RGB_ALPHA; break; - case 0x0301:/* IA44 */ + case 0x0301:// IA44 bit_depth = 8; sig_bit.red = 4; sig_bit.green = 4; @@ -304,35 +303,35 @@ TxImage::writePNG(uint8* src, FILE* fp, int width, int height, int rowStride, ui sig_bit.alpha = 4; color_type = PNG_COLOR_TYPE_RGB_ALPHA; break; - case 0x0400:/* I4 */ + case 0x0400:// I4 bit_depth = 8; sig_bit.red = 4; sig_bit.green = 4; sig_bit.blue = 4; color_type = PNG_COLOR_TYPE_RGB; break; - case 0x0401:/* I8 */ - case 0x0402:/* I16 */ + case 0x0401:// I8 + case 0x0402:// I16 bit_depth = 8; sig_bit.red = 8; sig_bit.green = 8; sig_bit.blue = 8; color_type = PNG_COLOR_TYPE_RGB; break; - case 0x0200:/* CI4 */ + case 0x0200:// CI4 bit_depth = 8; num_palette = 16; color_type = PNG_COLOR_TYPE_PALETTE; break; - case 0x0201:/* CI8 */ + case 0x0201:// CI8 bit_depth = 8; num_palette = 256; color_type = PNG_COLOR_TYPE_PALETTE; break; - case 0x0102:/* YUV ? */ + case 0x0102:// YUV? case 0x0103: default: - /* unsupported format */ + // Unsupported format png_destroy_write_struct(&png_ptr, &info_ptr); return 0; } @@ -383,87 +382,83 @@ TxImage::writePNG(uint8* src, FILE* fp, int width, int height, int rowStride, ui bool TxImage::getBMPInfo(FILE* fp, BITMAPFILEHEADER* bmp_fhdr, BITMAPINFOHEADER* bmp_ihdr) { - /* - * read in BITMAPFILEHEADER - */ + // Read in BITMAPFILEHEADER - /* is this a BMP file? */ + // Is this a BMP file? if (fread(&bmp_fhdr->bfType, 2, 1, fp) != 1) return 0; if (memcmp(&bmp_fhdr->bfType, "BM", 2) != 0) return 0; - /* get file size */ + // Get file size if (fread(&bmp_fhdr->bfSize, 4, 1, fp) != 1) return 0; - /* reserved 1 */ + // Reserved 1 if (fread(&bmp_fhdr->bfReserved1, 2, 1, fp) != 1) return 0; - /* reserved 2 */ + // Reserved 2 if (fread(&bmp_fhdr->bfReserved2, 2, 1, fp) != 1) return 0; - /* offset to the image data */ + // Offset to the image data if (fread(&bmp_fhdr->bfOffBits, 4, 1, fp) != 1) return 0; - /* - * read in BITMAPINFOHEADER - */ + // Read in BITMAPINFOHEADER - /* size of BITMAPINFOHEADER */ + // Size of BITMAPINFOHEADER if (fread(&bmp_ihdr->biSize, 4, 1, fp) != 1) return 0; - /* is this a Windows BMP? */ + // Is this a Windows BMP? if (bmp_ihdr->biSize != 40) return 0; - /* width of the bitmap in pixels */ + // Width of the bitmap in pixels if (fread(&bmp_ihdr->biWidth, 4, 1, fp) != 1) return 0; - /* height of the bitmap in pixels */ + // Height of the bitmap in pixels if (fread(&bmp_ihdr->biHeight, 4, 1, fp) != 1) return 0; - /* number of planes (always 1) */ + // Number of planes (always 1) if (fread(&bmp_ihdr->biPlanes, 2, 1, fp) != 1) return 0; - /* number of bits-per-pixel. (1, 4, 8, 16, 24, 32) */ + // Number of bits-per-pixel (1, 4, 8, 16, 24, 32) if (fread(&bmp_ihdr->biBitCount, 2, 1, fp) != 1) return 0; - /* compression for a compressed bottom-up bitmap - * 0 : uncompressed format - * 1 : run-length encoded 4 bpp format - * 2 : run-length encoded 8 bpp format - * 3 : bitfield + /* Compression for a compressed bottom-up bitmap + * 0: Uncompressed format + * 1: Run-length encoded 4 bpp format + * 2: Run-length encoded 8 bpp format + * 3: Bitfield */ if (fread(&bmp_ihdr->biCompression, 4, 1, fp) != 1) return 0; - /* size of the image in bytes */ + // Size of the image in bytes if (fread(&bmp_ihdr->biSizeImage, 4, 1, fp) != 1) return 0; - /* horizontal resolution in pixels-per-meter */ + // Horizontal resolution in pixels-per-meter if (fread(&bmp_ihdr->biXPelsPerMeter, 4, 1, fp) != 1) return 0; - /* vertical resolution in pixels-per-meter */ + // Vertical resolution in pixels-per-meter if (fread(&bmp_ihdr->biYPelsPerMeter, 4, 1, fp) != 1) return 0; - /* number of color indexes in the color table that are actually used */ + // Number of color indexes in the color table that are actually used if (fread(&bmp_ihdr->biClrUsed, 4, 1, fp) != 1) return 0; - /* the number of color indexes that are required for displaying */ + // The number of color indexes that are required for displaying if (fread(&bmp_ihdr->biClrImportant, 4, 1, fp) != 1) return 0; @@ -473,9 +468,9 @@ TxImage::getBMPInfo(FILE* fp, BITMAPFILEHEADER* bmp_fhdr, BITMAPINFOHEADER* bmp_ uint8* TxImage::readBMP(FILE* fp, int* width, int* height, uint16* format) { - /* NOTE: returned image format; - * 4, 8bit palette bmp -> GFX_TEXFMT_P_8 - * 24, 32bit bmp -> GFX_TEXFMT_ARGB_8888 + /* NOTE: Returned image format; + * 4, 8-bit palette bmp -> GFX_TEXFMT_P_8 + * 24, 32-bit bmp -> GFX_TEXFMT_ARGB_8888 */ uint8 *image = nullptr; @@ -483,50 +478,50 @@ TxImage::readBMP(FILE* fp, int* width, int* height, uint16* format) uint8 *tmpimage = nullptr; unsigned int row_bytes, pos; int i, j; - /* Windows Bitmap */ + /* Windows bitmap */ BITMAPFILEHEADER bmp_fhdr; BITMAPINFOHEADER bmp_ihdr; - /* initialize */ + // Initialize *width = 0; *height = 0; *format = 0; - /* check if we have a valid bmp file */ + // Check if we have a valid BMP file if (!fp) return nullptr; if (!getBMPInfo(fp, &bmp_fhdr, &bmp_ihdr)) { - INFO(80, "error reading bitmap file! bitmap image is corrupt.\n"); + INFO(80, "Error reading bitmap file! Bitmap image is corrupt.\n"); return nullptr; } - DBG_INFO(80, "bmp format %d x %d bitdepth:%d compression:%x offset:%d\n", + DBG_INFO(80, "BMP format %d x %d bitdepth:%d compression:%x offset:%d\n", bmp_ihdr.biWidth, bmp_ihdr.biHeight, bmp_ihdr.biBitCount, bmp_ihdr.biCompression, bmp_fhdr.bfOffBits); - /* rowStride in bytes */ + // rowStride in bytes row_bytes = (bmp_ihdr.biWidth * bmp_ihdr.biBitCount) >> 3; - /* align to 4bytes boundary */ + // Align to 4 bytes boundary row_bytes = (row_bytes + 3) & ~3; - /* Rice hi-res textures */ + // Rice high resolution textures if (!(bmp_ihdr.biBitCount == 8 || bmp_ihdr.biBitCount == 4 || bmp_ihdr.biBitCount == 32 || bmp_ihdr.biBitCount == 24) || bmp_ihdr.biCompression != 0) { - DBG_INFO(80, "Error: incompatible bitmap format!\n"); + DBG_INFO(80, "Error: Incompatible bitmap format!\n"); return nullptr; } switch (bmp_ihdr.biBitCount) { case 8: case 32: - /* 8 bit, 32 bit bitmap */ + // 8-bit, 32-bit bitmap image = (uint8*)malloc(row_bytes * bmp_ihdr.biHeight); if (image) { tmpimage = image; pos = bmp_fhdr.bfOffBits + row_bytes * (bmp_ihdr.biHeight - 1); for (i = 0; i < bmp_ihdr.biHeight; i++) { - /* read in image */ + // Read in image fseek(fp, pos, SEEK_SET); fread(tmpimage, row_bytes, 1, fp); tmpimage += row_bytes; @@ -535,17 +530,17 @@ TxImage::readBMP(FILE* fp, int* width, int* height, uint16* format) } break; case 4: - /* 4bit bitmap */ + // 4-bit bitmap image = (uint8*)malloc((row_bytes * bmp_ihdr.biHeight) << 1); image_row = (uint8*)malloc(row_bytes); if (image && image_row) { tmpimage = image; pos = bmp_fhdr.bfOffBits + row_bytes * (bmp_ihdr.biHeight - 1); for (i = 0; i < bmp_ihdr.biHeight; i++) { - /* read in image */ + // Read in image fseek(fp, pos, SEEK_SET); fread(image_row, row_bytes, 1, fp); - /* expand 4bpp to 8bpp. stuff 4bit values into 8bit comps. */ + // Expand 4bpp to 8bpp, stuff 4-bit values into 8-bit comps for (j = 0; j < (int)row_bytes; j++) { tmpimage[j << 1] = image_row[j] & 0x0f; tmpimage[(j << 1) + 1] = (image_row[j] & 0xf0) >> 4; @@ -562,17 +557,17 @@ TxImage::readBMP(FILE* fp, int* width, int* height, uint16* format) } break; case 24: - /* 24 bit bitmap */ + // 24-bit bitmap image = (uint8*)malloc((bmp_ihdr.biWidth * bmp_ihdr.biHeight) << 2); image_row = (uint8*)malloc(row_bytes); if (image && image_row) { tmpimage = image; pos = bmp_fhdr.bfOffBits + row_bytes * (bmp_ihdr.biHeight - 1); for (i = 0; i < bmp_ihdr.biHeight; i++) { - /* read in image */ + // Read in image fseek(fp, pos, SEEK_SET); fread(image_row, row_bytes, 1, fp); - /* convert 24bpp to 32bpp. */ + // Convert 24bpp to 32bpp for (j = 0; j < bmp_ihdr.biWidth; j++) { tmpimage[(j << 2)] = image_row[j * 3]; tmpimage[(j << 2) + 1] = image_row[j * 3 + 1]; @@ -606,12 +601,11 @@ TxImage::readBMP(FILE* fp, int* width, int* height, uint16* format) } #if POW2_TEXTURES - /* next power of 2 size conversions */ - /* NOTE: I can do this in the above loop for faster operations, but some - * texture packs require a workaround. see HACKALERT in nextPow2(). - */ + // Next power of 2 size conversions + // NOTE: I can do this in the above loop for faster operations, but some + // texture packs require a workaround. See HACKALERT in nextPow2(). - TxReSample txReSample = new TxReSample; // XXX: temporary. move to a better place. + TxReSample txReSample = new TxReSample; // Temporary, move to a better place. #if (POW2_TEXTURES == 2) if (!txReSample->nextPow2(&image, width, height, 8, 1)) { @@ -629,12 +623,12 @@ TxImage::readBMP(FILE* fp, int* width, int* height, uint16* format) delete txReSample; -#endif /* POW2_TEXTURES */ +#endif // POW2_TEXTURES } #ifdef DEBUG if (!image) { - DBG_INFO(80, "Error: failed to load bmp image!\n"); + DBG_INFO(80, "Error: Failed to load BMP image!\n"); } #endif @@ -644,11 +638,9 @@ TxImage::readBMP(FILE* fp, int* width, int* height, uint16* format) bool TxImage::getDDSInfo(FILE *fp, DDSFILEHEADER *dds_fhdr) { - /* - * read in DDSFILEHEADER - */ + // Read in DDSFILEHEADER - /* is this a DDS file? */ + // Is this a DDS file? if (fread(&dds_fhdr->dwMagic, 4, 1, fp) != 1) return 0; @@ -658,15 +650,15 @@ TxImage::getDDSInfo(FILE *fp, DDSFILEHEADER *dds_fhdr) if (fread(&dds_fhdr->dwSize, 4, 1, fp) != 1) return 0; - /* get file flags */ + // Get file flags if (fread(&dds_fhdr->dwFlags, 4, 1, fp) != 1) return 0; - /* height of dds in pixels */ + // Height of DDS in pixels if (fread(&dds_fhdr->dwHeight, 4, 1, fp) != 1) return 0; - /* width of dds in pixels */ + // Width of DDS in pixels if (fread(&dds_fhdr->dwWidth, 4, 1, fp) != 1) return 0; @@ -722,41 +714,41 @@ TxImage::readDDS(FILE* fp, int* width, int* height, uint16* format) DDSFILEHEADER dds_fhdr; uint16 tmpformat = 0; - /* initialize */ + // Initialize *width = 0; *height = 0; *format = 0; - /* check if we have a valid dds file */ + // Check if we have a valid DDS file if (!fp) return nullptr; if (!getDDSInfo(fp, &dds_fhdr)) { - INFO(80, "error reading dds file! dds image is corrupt.\n"); + INFO(80, "Error reading DDS file! DDS image is corrupt.\n"); return nullptr; } - DBG_INFO(80, "dds format %d x %d HeaderSize %d LinearSize %d\n", + DBG_INFO(80, "DDS format %d x %d HeaderSize %d LinearSize %d\n", dds_fhdr.dwWidth, dds_fhdr.dwHeight, dds_fhdr.dwSize, dds_fhdr.dwLinearSize); if (!(dds_fhdr.dwFlags & (DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_LINEARSIZE))) { - DBG_INFO(80, "Error: incompatible dds format!\n"); + DBG_INFO(80, "Error: Incompatible DDS format!\n"); return nullptr; } if ((dds_fhdr.dwFlags & DDSD_MIPMAPCOUNT) && dds_fhdr.dwMipMapCount != 1) { - DBG_INFO(80, "Error: mipmapped dds not supported!\n"); + DBG_INFO(80, "Error: Mipmapped DDS not supported!\n"); return nullptr; } if (!((dds_fhdr.ddpf.dwFlags & DDPF_FOURCC) && dds_fhdr.dwCaps2 == 0)) { - DBG_INFO(80, "Error: not fourcc standard texture!\n"); + DBG_INFO(80, "Error: Not fourcc standard texture!\n"); return nullptr; } if (memcmp(&dds_fhdr.ddpf.dwFourCC, "DXT1", 4) == 0) { DBG_INFO(80, "DXT1 format\n"); - /* compensate for missing LinearSize */ + // Compensate for missing LinearSize dds_fhdr.dwLinearSize = (dds_fhdr.dwWidth * dds_fhdr.dwHeight) >> 1; tmpformat = GFX_TEXFMT_ARGB_CMP_DXT1; } @@ -771,18 +763,18 @@ TxImage::readDDS(FILE* fp, int* width, int* height, uint16* format) tmpformat = GFX_TEXFMT_ARGB_CMP_DXT5; } else { - DBG_INFO(80, "Error: not DXT1 or DXT3 or DXT5 format!\n"); + DBG_INFO(80, "Error: Not DXT1 or DXT3 or DXT5 format!\n"); return nullptr; } - /* read in image */ + // Read in image image = (uint8*)malloc(dds_fhdr.dwLinearSize); if (image) { *width = dds_fhdr.dwWidth; *height = dds_fhdr.dwHeight; *format = tmpformat; - fseek(fp, 128, SEEK_SET); /* size of header is 128 bytes */ + fseek(fp, 128, SEEK_SET); // Size of header is 128 bytes fread(image, dds_fhdr.dwLinearSize, 1, fp); } diff --git a/Source/Project64-video/TextureEnhancer/TxImage.h b/Source/Project64-video/TextureEnhancer/TxImage.h index 84888b903..aa6354e22 100644 --- a/Source/Project64-video/TextureEnhancer/TxImage.h +++ b/Source/Project64-video/TextureEnhancer/TxImage.h @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2003 Rice1964 diff --git a/Source/Project64-video/TextureEnhancer/TxInternal.h b/Source/Project64-video/TextureEnhancer/TxInternal.h index 24ed23d93..b45e483aa 100644 --- a/Source/Project64-video/TextureEnhancer/TxInternal.h +++ b/Source/Project64-video/TextureEnhancer/TxInternal.h @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2003 Rice1964 @@ -10,7 +10,7 @@ #include "Ext_TxFilter.h" -/* dll exports */ +// DLL exports #ifdef TXFILTER_DLL #define TAPI __declspec(dllexport) #define TAPIENTRY @@ -31,18 +31,18 @@ typedef uint32_t uint32; #define KBHIT(key) (0) #endif -/* from OpenGL glext.h */ +// From OpenGL glext.h #define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 #define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 #define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 #define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 -/* for explicit fxt1 compression */ +// For explicit fxt1 compression #define CC_CHROMA 0x0 #define CC_HI 0x1 #define CC_ALPHA 0x2 -/* in-memory zlib texture compression */ +// In-memory zlib texture compression #define GR_TEXFMT_GZ 0x8000 #endif /* __INTERNAL_H__ */ diff --git a/Source/Project64-video/TextureEnhancer/TxQuantize.cpp b/Source/Project64-video/TextureEnhancer/TxQuantize.cpp index 7c251f71a..11c774875 100644 --- a/Source/Project64-video/TextureEnhancer/TxQuantize.cpp +++ b/Source/Project64-video/TextureEnhancer/TxQuantize.cpp @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2003 Rice1964 @@ -9,7 +9,7 @@ #pragma warning(disable: 4786) #endif -/* NOTE: The codes are not optimized. They can be made faster. */ +// NOTE: The code is not optimized. It can be made faster. #include "TxQuantize.h" #include @@ -18,10 +18,10 @@ TxQuantize::TxQuantize() { _txUtil = new TxUtil(); - /* get number of CPU cores. */ + // Get number of CPU cores _numcore = _txUtil->getNumberofProcessors(); - /* get dxtn extensions */ + // Get dxtn extensions _tx_compress_fxt1 = TxLoadLib::getInstance()->getfxtCompressTexFuncExt(); _tx_compress_dxtn = TxLoadLib::getInstance()->getdxtCompressTexFuncExt(); } @@ -939,7 +939,7 @@ TxQuantize::ARGB8888_A8(uint32* src, uint32* dest, int width, int height) add esi, 4; #if 0 - mov edx, eax; // we'll use A comp for every pixel + mov edx, eax; // We'll use A comp for every pixel and edx, 0xFF000000; // aaaaaaaa 00000000 00000000 00000000 shr edx, 24; // 00000000 00000000 00000000 aaaaaaaa @@ -965,7 +965,7 @@ TxQuantize::ARGB8888_A8(uint32* src, uint32* dest, int width, int height) #endif #if 1 - mov edx, eax; // we'll use G comp for every pixel + mov edx, eax; // We'll use G comp for every pixel and edx, 0x0000FF00; // 00000000 00000000 aaaaaaaa 00000000 shr edx, 8; // 00000000 00000000 00000000 aaaaaaaa @@ -1058,7 +1058,7 @@ TxQuantize::ARGB8888_AI44(uint32* src, uint32* dest, int width, int height) mov eax, dword ptr[esi]; add esi, 4; - mov edx, eax; // use A and G comps MSB + mov edx, eax; // Use A and G comps MSB and edx, 0xF0000000; // aaaa0000 00000000 00000000 00000000 mov ebx, eax; shr edx, 24; // 00000000 00000000 00000000 aaaa0000 @@ -1171,18 +1171,18 @@ TxQuantize::ARGB8888_AI88(uint32* src, uint32* dest, int width, int height) #endif } -/* R.W. Floyd and L. Steinberg, An adaptive algorithm - * for spatial grey scale, Proceedings of the Society - * of Information Display 17, pp75-77, 1976 - */ +// R.W. Floyd and L. Steinberg, An adaptive algorithm +// for spatial grey scale, Proceedings of the Society +// of Information Display 17, pp75-77, 1976 + void TxQuantize::ARGB8888_RGB565_ErrD(uint32* src, uint32* dst, int width, int height) { - /* Floyd-Steinberg error-diffusion halftoning */ + // Floyd-Steinberg error-diffusion halftoning int i, x, y; - int qr = 0, qg = 0, qb = 0; /* quantized incoming values */ - int ir, ig, ib; /* incoming values */ + int qr = 0, qg = 0, qb = 0; // Quantized incoming values + int ir, ig, ib; // Incoming values int t; int *errR = new int[width]; int *errG = new int[width]; @@ -1194,25 +1194,25 @@ TxQuantize::ARGB8888_RGB565_ErrD(uint32* src, uint32* dst, int width, int height for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { - /* incoming pixel values */ + // Incoming pixel values ir = ((*src >> 16) & 0xFF) * 10000; ig = ((*src >> 8) & 0xFF) * 10000; ib = ((*src) & 0xFF) * 10000; if (x == 0) qr = qg = qb = 0; - /* quantize pixel values. - * qr * 0.4375 is the error from the pixel to the left, - * errR is the error from the pixel to the top, top left, and top right */ - /* qr * 0.4375 is the error distribution to the EAST in - * the previous loop */ + // Quantize pixel values + // qr * 0.4375 is the error from the pixel to the left, + // errR is the error from the pixel to the top, top left, and top right + // qr * 0.4375 is the error distribution to the East in + // the previous loop ir += errR[x] + qr * 4375 / 10000; ig += errG[x] + qg * 4375 / 10000; ib += errB[x] + qb * 4375 / 10000; - /* error distribution to the SOUTH-EAST in the previous loop - * can't calculate in the previous loop because it steps on - * the above quantization */ + // Error distribution to the Southeast in the previous loop + // can't calculate in the previous loop because it steps on + // the above quantization errR[x] = qr * 625 / 10000; errG[x] = qg * 625 / 10000; errB[x] = qb * 625 / 10000; @@ -1221,20 +1221,20 @@ TxQuantize::ARGB8888_RGB565_ErrD(uint32* src, uint32* dst, int width, int height qg = ig; qb = ib; - /* clamp */ + // Clamp if (qr < 0) qr = 0; else if (qr > 2550000) qr = 2550000; if (qg < 0) qg = 0; else if (qg > 2550000) qg = 2550000; if (qb < 0) qb = 0; else if (qb > 2550000) qb = 2550000; - /* convert to RGB565 */ + // Convert to RGB565 qr = qr * 0x1F / 2550000; qg = qg * 0x3F / 2550000; qb = qb * 0x1F / 2550000; - /* this is the dithered pixel */ + // This is the dithered pixel t = (qr << 11) | (qg << 5) | qb; - /* compute the errors */ + // Compute the errors qr = ((qr << 3) | (qr >> 2)) * 10000; qg = ((qg << 2) | (qg >> 4)) * 10000; qb = ((qb << 3) | (qb >> 2)) * 10000; @@ -1242,24 +1242,22 @@ TxQuantize::ARGB8888_RGB565_ErrD(uint32* src, uint32* dst, int width, int height qg = ig - qg; qb = ib - qb; - /* compute the error distributions */ - /* Floyd-Steinberg filter - * 7/16 (=0.4375) to the EAST - * 5/16 (=0.3125) to the SOUTH - * 1/16 (=0.0625) to the SOUTH-EAST - * 3/16 (=0.1875) to the SOUTH-WEST - * - * x 7/16 - * 3/16 5/16 1/16 - */ - /* SOUTH-WEST */ + // Compute the error distributions + // Floyd-Steinberg filter + // 7/16 (=0.4375) to the East + // 5/16 (=0.3125) to the South + // 1/16 (=0.0625) to the Southeast + // 3/16 (=0.1875) to the Southwest + // x 7/16 + // 3/16 5/16 1/16 + // Southwest if (x > 1) { errR[x - 1] += qr * 1875 / 10000; errG[x - 1] += qg * 1875 / 10000; errB[x - 1] += qb * 1875 / 10000; } - /* SOUTH */ + // South errR[x] += qr * 3125 / 10000; errG[x] += qg * 3125 / 10000; errB[x] += qb * 3125 / 10000; @@ -1279,11 +1277,11 @@ TxQuantize::ARGB8888_RGB565_ErrD(uint32* src, uint32* dst, int width, int height void TxQuantize::ARGB8888_ARGB1555_ErrD(uint32* src, uint32* dst, int width, int height) { - /* Floyd-Steinberg error-diffusion halftoning */ + // Floyd-Steinberg error-diffusion halftoning int i, x, y; - int qr, qg, qb; /* quantized incoming values */ - int ir, ig, ib; /* incoming values */ + int qr, qg, qb; // Quantized incoming values + int ir, ig, ib; // Incoming values int t; int *errR = new int[width]; int *errG = new int[width]; @@ -1295,25 +1293,25 @@ TxQuantize::ARGB8888_ARGB1555_ErrD(uint32* src, uint32* dst, int width, int heig for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { - /* incoming pixel values */ + // Incoming pixel values ir = ((*src >> 16) & 0xFF) * 10000; ig = ((*src >> 8) & 0xFF) * 10000; ib = ((*src) & 0xFF) * 10000; if (x == 0) qr = qg = qb = 0; - /* quantize pixel values. - * qr * 0.4375 is the error from the pixel to the left, - * errR is the error from the pixel to the top, top left, and top right */ - /* qr * 0.4375 is the error distribution to the EAST in - * the previous loop */ + // Quantize pixel values + // qr * 0.4375 is the error from the pixel to the left, + // errR is the error from the pixel to the top, top left, and top right + // qr * 0.4375 is the error distribution to the East in + // the previous loop ir += errR[x] + qr * 4375 / 10000; ig += errG[x] + qg * 4375 / 10000; ib += errB[x] + qb * 4375 / 10000; - /* error distribution to the SOUTH-EAST of the previous loop. - * cannot calculate in the previous loop because it steps on - * the above quantization */ + // Error distribution to the Southeast of the previous loop. + // Cannot calculate in the previous loop because it steps on + // the above quantization. errR[x] = qr * 625 / 10000; errG[x] = qg * 625 / 10000; errB[x] = qb * 625 / 10000; @@ -1322,21 +1320,21 @@ TxQuantize::ARGB8888_ARGB1555_ErrD(uint32* src, uint32* dst, int width, int heig qg = ig; qb = ib; - /* clamp */ + // Clamp if (qr < 0) qr = 0; else if (qr > 2550000) qr = 2550000; if (qg < 0) qg = 0; else if (qg > 2550000) qg = 2550000; if (qb < 0) qb = 0; else if (qb > 2550000) qb = 2550000; - /* convert to RGB555 */ + // Convert to RGB555 qr = qr * 0x1F / 2550000; qg = qg * 0x1F / 2550000; qb = qb * 0x1F / 2550000; - /* this is the dithered pixel */ + // This is the dithered pixel t = (qr << 10) | (qg << 5) | qb; t |= ((*src >> 24) ? 0x8000 : 0); - /* compute the errors */ + // Compute the errors qr = ((qr << 3) | (qr >> 2)) * 10000; qg = ((qg << 3) | (qg >> 2)) * 10000; qb = ((qb << 3) | (qb >> 2)) * 10000; @@ -1344,24 +1342,22 @@ TxQuantize::ARGB8888_ARGB1555_ErrD(uint32* src, uint32* dst, int width, int heig qg = ig - qg; qb = ib - qb; - /* compute the error distributions */ - /* Floyd-Steinberg filter - * 7/16 (=0.4375) to the EAST - * 5/16 (=0.3125) to the SOUTH - * 1/16 (=0.0625) to the SOUTH-EAST - * 3/16 (=0.1875) to the SOUTH-WEST - * - * x 7/16 - * 3/16 5/16 1/16 - */ - /* SOUTH-WEST */ + // Compute the error distributions + // Floyd-Steinberg filter + // 7/16 (=0.4375) to the East + // 5/16 (=0.3125) to the South + // 1/16 (=0.0625) to the Southeast + // 3/16 (=0.1875) to the Southwest + // x 7/16 + // 3/16 5/16 1/16 + // Southwest if (x > 1) { errR[x - 1] += qr * 1875 / 10000; errG[x - 1] += qg * 1875 / 10000; errB[x - 1] += qb * 1875 / 10000; } - /* SOUTH */ + // South errR[x] += qr * 3125 / 10000; errG[x] += qg * 3125 / 10000; errB[x] += qb * 3125 / 10000; @@ -1381,17 +1377,16 @@ TxQuantize::ARGB8888_ARGB1555_ErrD(uint32* src, uint32* dst, int width, int heig void TxQuantize::ARGB8888_ARGB4444_ErrD(uint32* src, uint32* dst, int width, int height) { - /* Floyd-Steinberg error-diffusion halftoning */ + // Floyd-Steinberg error-diffusion halftoning + // NOTE: Alpha dithering looks better for alpha gradients, but are prone + // to producing noisy speckles for constant or step-level alpha. Output + // results should always be checked. - /* NOTE: alpha dithering looks better for alpha gradients, but are prone - * to producing noisy speckles for constant or step level alpha. Output - * results should always be checked. - */ bool ditherAlpha = 0; int i, x, y; - int qr = 0, qg = 0, qb = 0, qa = 0; /* quantized incoming values */ - int ir, ig, ib, ia; /* incoming values */ + int qr = 0, qg = 0, qb = 0, qa = 0; // Quantized incoming values + int ir, ig, ib, ia; // Incoming values int t; int *errR = new int[width]; int *errG = new int[width]; @@ -1404,7 +1399,7 @@ TxQuantize::ARGB8888_ARGB4444_ErrD(uint32* src, uint32* dst, int width, int heig for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { - /* incoming pixel values */ + // Incoming pixel values ir = ((*src >> 16) & 0xFF) * 10000; ig = ((*src >> 8) & 0xFF) * 10000; ib = ((*src) & 0xFF) * 10000; @@ -1412,19 +1407,19 @@ TxQuantize::ARGB8888_ARGB4444_ErrD(uint32* src, uint32* dst, int width, int heig if (x == 0) qr = qg = qb = qa = 0; - /* quantize pixel values. - * qr * 0.4375 is the error from the pixel to the left, - * errR is the error from the pixel to the top, top left, and top right */ - /* qr * 0.4375 is the error distribution to the EAST in - * the previous loop */ + // Quantize pixel values + // qr * 0.4375 is the error from the pixel to the left, + // errR is the error from the pixel to the top, top left, and top right + // qr * 0.4375 is the error distribution to the East in + // the previous loop ir += errR[x] + qr * 4375 / 10000; ig += errG[x] + qg * 4375 / 10000; ib += errB[x] + qb * 4375 / 10000; ia += errA[x] + qa * 4375 / 10000; - /* error distribution to the SOUTH-EAST of the previous loop. - * cannot calculate in the previous loop because it steps on - * the above quantization */ + // Error distribution to the Southeast of the previous loop. + // Cannot calculate in the previous loop because it steps on + // the above quantization. errR[x] = qr * 625 / 10000; errG[x] = qg * 625 / 10000; errB[x] = qb * 625 / 10000; @@ -1435,19 +1430,19 @@ TxQuantize::ARGB8888_ARGB4444_ErrD(uint32* src, uint32* dst, int width, int heig qb = ib; qa = ia; - /* clamp */ + // Clamp if (qr < 0) qr = 0; else if (qr > 2550000) qr = 2550000; if (qg < 0) qg = 0; else if (qg > 2550000) qg = 2550000; if (qb < 0) qb = 0; else if (qb > 2550000) qb = 2550000; if (qa < 0) qa = 0; else if (qa > 2550000) qa = 2550000; - /* convert to RGB444 */ + // Convert to RGB444 qr = qr * 0xF / 2550000; qg = qg * 0xF / 2550000; qb = qb * 0xF / 2550000; qa = qa * 0xF / 2550000; - /* this is the value to be returned */ + // This is the value to be returned if (ditherAlpha) { t = (qa << 12) | (qr << 8) | (qg << 4) | qb; } @@ -1456,7 +1451,7 @@ TxQuantize::ARGB8888_ARGB4444_ErrD(uint32* src, uint32* dst, int width, int heig t |= (*src >> 16) & 0xF000; } - /* compute the errors */ + // Compute the errors qr = ((qr << 4) | qr) * 10000; qg = ((qg << 4) | qg) * 10000; qb = ((qb << 4) | qb) * 10000; @@ -1466,17 +1461,15 @@ TxQuantize::ARGB8888_ARGB4444_ErrD(uint32* src, uint32* dst, int width, int heig qb = ib - qb; qa = ia - qa; - /* compute the error distributions */ - /* Floyd-Steinberg filter - * 7/16 (=0.4375) to the EAST - * 5/16 (=0.3125) to the SOUTH - * 1/16 (=0.0625) to the SOUTH-EAST - * 3/16 (=0.1875) to the SOUTH-WEST - * - * x 7/16 - * 3/16 5/16 1/16 - */ - /* SOUTH-WEST */ + // Compute the error distributions + // Floyd-Steinberg filter + // 7/16 (=0.4375) to the East + // 5/16 (=0.3125) to the South + // 1/16 (=0.0625) to the Southeast + // 3/16 (=0.1875) to the Southwest + // x 7/16 + // 3/16 5/16 1/16 + // Southwest if (x > 1) { errR[x - 1] += qr * 1875 / 10000; errG[x - 1] += qg * 1875 / 10000; @@ -1484,7 +1477,7 @@ TxQuantize::ARGB8888_ARGB4444_ErrD(uint32* src, uint32* dst, int width, int heig errA[x - 1] += qa * 1875 / 10000; } - /* SOUTH */ + // South errR[x] += qr * 3125 / 10000; errG[x] += qg * 3125 / 10000; errB[x] += qb * 3125 / 10000; @@ -1506,17 +1499,16 @@ TxQuantize::ARGB8888_ARGB4444_ErrD(uint32* src, uint32* dst, int width, int heig void TxQuantize::ARGB8888_AI44_ErrD(uint32* src, uint32* dst, int width, int height) { - /* Floyd-Steinberg error-diffusion halftoning */ + // Floyd-Steinberg error-diffusion halftoning + // NOTE: Alpha dithering looks better for alpha gradients, but are prone + // to producing noisy speckles for constant or step-level alpha. Output + // results should always be checked. - /* NOTE: alpha dithering looks better for alpha gradients, but are prone - * to producing noisy speckles for constant or step level alpha. Output - * results should always be checked. - */ bool ditherAlpha = 0; int i, x, y; - int qi, qa; /* quantized incoming values */ - int ii, ia; /* incoming values */ + int qi, qa; // Quantized incoming values + int ii, ia; // Incoming values int t; int *errI = new int[width]; int *errA = new int[width]; @@ -1527,7 +1519,7 @@ TxQuantize::ARGB8888_AI44_ErrD(uint32* src, uint32* dst, int width, int height) for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { - /* 3dfx style Intensity = R * 0.299 + G * 0.587 + B * 0.114 */ + // 3DFX style Intensity = R * 0.299 + G * 0.587 + B * 0.114 ii = ((*src >> 16) & 0xFF) * 2990 + ((*src >> 8) & 0xFF) * 5870 + ((*src) & 0xFF) * 1140; @@ -1535,32 +1527,32 @@ TxQuantize::ARGB8888_AI44_ErrD(uint32* src, uint32* dst, int width, int height) if (x == 0) qi = qa = 0; - /* quantize pixel values. - * qi * 0.4375 is the error from the pixel to the left, - * errI is the error from the pixel to the top, top left, and top right */ - /* qi * 0.4375 is the error distrtibution to the EAST in - * the previous loop */ + // Quantize pixel values + // qi * 0.4375 is the error from the pixel to the left, + // errI is the error from the pixel to the top, top left, and top right + // qi * 0.4375 is the error distribution to the East in + // the previous loop ii += errI[x] + qi * 4375 / 10000; ia += errA[x] + qa * 4375 / 10000; - /* error distribution to the SOUTH-EAST in the previous loop. - * cannot calculate in the previous loop because it steps on - * the above quantization */ + // Error distribution to the Southeast in the previous loop. + // Cannot calculate in the previous loop because it steps on + // the above quantization. errI[x] = qi * 625 / 10000; errA[x] = qa * 625 / 10000; qi = ii; qa = ia; - /* clamp */ + // Clamp if (qi < 0) qi = 0; else if (qi > 2550000) qi = 2550000; if (qa < 0) qa = 0; else if (qa > 2550000) qa = 2550000; - /* convert to I4 */ + // Convert to I4 qi = qi * 0xF / 2550000; qa = qa * 0xF / 2550000; - /* this is the value to be returned */ + // This is the value to be returned if (ditherAlpha) { t = (qa << 4) | qi; } @@ -1569,29 +1561,27 @@ TxQuantize::ARGB8888_AI44_ErrD(uint32* src, uint32* dst, int width, int height) t |= ((*src >> 24) & 0xF0); } - /* compute the errors */ + // Compute the errors qi = ((qi << 4) | qi) * 10000; qa = ((qa << 4) | qa) * 10000; qi = ii - qi; qa = ia - qa; - /* compute the error distributions */ - /* Floyd-Steinberg filter - * 7/16 (=0.4375) to the EAST - * 5/16 (=0.3125) to the SOUTH - * 1/16 (=0.0625) to the SOUTH-EAST - * 3/16 (=0.1875) to the SOUTH-WEST - * - * x 7/16 - * 3/16 5/16 1/16 - */ - /* SOUTH-WEST */ + // Compute the error distributions + // Floyd-Steinberg filter + // 7/16 (=0.4375) to the East + // 5/16 (=0.3125) to the South + // 1/16 (=0.0625) to the Southeast + // 3/16 (=0.1875) to the Southwest + // x 7/16 + // 3/16 5/16 1/16 + // Southwest if (x > 1) { errI[x - 1] += qi * 1875 / 10000; errA[x - 1] += qa * 1875 / 10000; } - /* SOUTH */ + // South errI[x] += qi * 3125 / 10000; errA[x] += qa * 3125 / 10000; @@ -1614,31 +1604,33 @@ TxQuantize::ARGB8888_AI88_Slow(uint32* src, uint32* dst, int width, int height) for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { #if 1 - /* libpng style grayscale conversion. - * Reduce RGB files to grayscale with or without alpha - * using the equation given in Poynton's ColorFAQ at - * - * Copyright (c) 1998-01-04 Charles Poynton poynton at inforamp.net - * - * Y = 0.212671 * R + 0.715160 * G + 0.072169 * B - * - * We approximate this with - * - * Y = 0.21268 * R + 0.7151 * G + 0.07217 * B - * - * which can be expressed with integers as - * - * Y = (6969 * R + 23434 * G + 2365 * B)/32768 - * - * The calculation is to be done in a linear colorspace. - */ + /* + libpng style grayscale conversion + Reduce RGB files to grayscale with or without alpha + using the equation given in Poynton's ColorFAQ at + + Copyright (c) 1998-01-04 Charles Poynton poynton@inforamp.net + + Y = 0.212671 * R + 0.715160 * G + 0.072169 * B + + We approximate this with + + Y = 0.21268 * R + 0.7151 * G + 0.07217 * B + + Which can be expressed with integers as + + Y = (6969 * R + 23434 * G + 2365 * B)/32768 + + The calculation is to be done in a linear color space. + */ + *dest = (((int)((((*src >> 16) & 0xFF) * 6969 + ((*src >> 8) & 0xFF) * 23434 + ((*src) & 0xFF) * 2365) / 32768) & 0xFF) | (uint16)((*src >> 16) & 0xFF00)); #else - /* 3dfx style Intensity = R * 0.299 + G * 0.587 + B * 0.114 - * this is same as the standard NTSC gray scale conversion. */ + // 3DFX style Intensity = R * 0.299 + G * 0.587 + B * 0.114 + // This is same as the standard NTSC grayscale conversion. *dest = (((int)((((*src >> 16) & 0xFF) * 299 + ((*src >> 8) & 0xFF) * 587 + ((*src) & 0xFF) * 114) / 1000) & 0xFF) | @@ -1658,13 +1650,13 @@ TxQuantize::ARGB8888_I8_Slow(uint32* src, uint32* dst, int width, int height) for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { #if 1 - /* libpng style Intensity = (6969 * R + 23434 * G + 2365 * B)/32768 */ + // libpng style Intensity = (6969 * R + 23434 * G + 2365 * B)/32768 * dest = (int)((((*src >> 16) & 0xFF) * 6969 + ((*src >> 8) & 0xFF) * 23434 + ((*src) & 0xFF) * 2365) / 32768) & 0xFF; #else - /* 3dfx style Intensity = R * 0.299 + G * 0.587 + B * 0.114 - * this is same as the standard NTSC gray scale conversion. */ + // 3DFX style Intensity = R * 0.299 + G * 0.587 + B * 0.114 + // This is same as the standard NTSC grayscale conversion. *dest = (int)((((*src >> 16) & 0xFF) * 299 + ((*src >> 8) & 0xFF) * 587 + ((*src) & 0xFF) * 114) / 1000) & 0xFF; @@ -1678,7 +1670,7 @@ TxQuantize::ARGB8888_I8_Slow(uint32* src, uint32* dst, int width, int height) void TxQuantize::P8_16BPP(uint32* src, uint32* dest, int width, int height, uint32* palette) { - /* passed in palette is RGBA5551 format */ + // Passed in palette is RGBA5551 format #if 1 int i; int size = width * height; @@ -1688,7 +1680,7 @@ TxQuantize::P8_16BPP(uint32* src, uint32* dest, int width, int height, uint32* p } #else - /* not finished yet... */ + // Not finished yet... int siz = (width * height) >> 2; @@ -1806,20 +1798,19 @@ TxQuantize::FXT1(uint8 *src, uint8 *dest, int *destwidth, int *destheight, uint16 *destformat) { /* - * NOTE: src must be in ARGB8888 format, srcformat describes - * the closest 16bbp representation of src. - * - * NOTE: I have modified the dxtn library to use ARGB format - * which originaly was ABGR format. - */ + NOTE: Source must be in ARGB8888 format, srcformat describes + the closest 16bbp representation of source. + + NOTE: I have modified the dxtn library to use ARGB format + which originally was ABGR format. + */ bool bRet = 0; if (_tx_compress_fxt1 && srcwidth >= 8 && srcheight >= 4) { - /* compress to fxt1 - * width and height must be larger than 8 and 4 respectively - */ + // Compress to fxt1 + // Width and height must be larger than 8 and 4 respectively int dstRowStride = ((srcwidth + 7) & ~7) << 1; int srcRowStride = (srcwidth << 2); @@ -1829,15 +1820,15 @@ TxQuantize::FXT1(uint8 *src, uint8 *dest, blkrow = (srcheight >> 2) / numcore; numcore--; } - (*_tx_compress_fxt1)(srcwidth, /* width */ - srcheight, /* height */ - 4, /* comps: ARGB8888=4, RGB888=3 */ - src, /* source */ - srcRowStride, /* width*comps */ - dest, /* destination */ - dstRowStride); /* 16 bytes per 8x4 texel */ + (*_tx_compress_fxt1)(srcwidth, // Width + srcheight, // Height + 4, // Comps: ARGB8888=4, RGB888=3 + src, // Source + srcRowStride, // Width * comps + dest, // Destination + dstRowStride); // 16 bytes per 8x4 texel -/* dxtn adjusts width and height to M8 and M4 respectively by replication */ +// dxtn adjusts width and height to M8 and M4 respectively by replication *destwidth = (srcwidth + 7) & ~7; *destheight = (srcheight + 3) & ~3; *destformat = GFX_TEXFMT_ARGB_CMP_FXT1; @@ -1854,25 +1845,24 @@ TxQuantize::DXTn(uint8 *src, uint8 *dest, int *destwidth, int *destheight, uint16 *destformat) { /* - * NOTE: src must be in ARGB8888 format, srcformat describes - * the closest 16bbp representation of src. - * - * NOTE: I have modified the dxtn library to use ARGB format - * which originaly was ABGR format. - */ + NOTE: Source must be in ARGB8888 format, srcformat describes + the closest 16bbp representation of source. + + NOTE: I have modified the dxtn library to use ARGB format + which originally was ABGR format. + */ bool bRet = 0; if (_tx_compress_dxtn && srcwidth >= 4 && srcheight >= 4) { - /* compress to dxtn - * width and height must be larger than 4 - */ + // Compress to dxtn + // Width and height must be larger than 4 - /* skip formats that DXTn won't help in size. */ + // Skip formats that DXTn won't help in size. if (srcformat == GFX_TEXFMT_ALPHA_8 || srcformat == GFX_TEXFMT_ALPHA_INTENSITY_44) { - ; /* shutup compiler */ + ; // Shut the compiler up } else { int dstRowStride = ((srcwidth + 3) & ~3) << 2; @@ -1881,10 +1871,10 @@ TxQuantize::DXTn(uint8 *src, uint8 *dest, *destformat = GFX_TEXFMT_ARGB_CMP_DXT5; #if !GLIDE64_DXTN - /* okay... we are going to disable DXT1 with 1bit alpha - * for Glide64. some textures have all 0 alpha values. - * see "N64 Kobe Bryant in NBA Courtside" - */ + /// Okay...we are going to disable DXT1 with 1-bit alpha + // for Glide64. Some textures have all 0 alpha values. + // See "N64 Kobe Bryant in NBA Courtside"l. + if (srcformat == GFX_TEXFMT_ARGB_1555) { dstRowStride >>= 1; compression = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; @@ -1905,16 +1895,16 @@ TxQuantize::DXTn(uint8 *src, uint8 *dest, blkrow = (srcheight >> 2) / numcore; numcore--; } - (*_tx_compress_dxtn)(4, /* comps: ARGB8888=4, RGB888=3 */ - srcwidth, /* width */ - srcheight, /* height */ - src, /* source */ - compression, /* format */ - dest, /* destination */ - dstRowStride); /* DXT1 = 8 bytes per 4x4 texel - * others = 16 bytes per 4x4 texel */ + (*_tx_compress_dxtn)(4, // Comps: ARGB8888=4, RGB888=3 + srcwidth, // Width + srcheight, // Height + src, // Source + compression, // Format + dest, // Destination + dstRowStride); // DXT1 = 8 bytes per 4x4 texel + // Others = 16 bytes per 4x4 texel - /* dxtn adjusts width and height to M4 by replication */ + // dxtn adjusts width and height to M4 by replication *destwidth = (srcwidth + 3) & ~3; *destheight = (srcheight + 3) & ~3; @@ -1945,14 +1935,14 @@ TxQuantize::compress(uint8 *src, uint8 *dest, destwidth, destheight, destformat); break; case NCC_COMPRESSION: - /* TODO: narrow channel compression */ + // TODO: Narrow channel compression ; } return bRet; } -#if 0 /* unused */ +#if 0 // Unused void TxQuantize::I8_ARGB8888(uint32* src, uint32* dest, int width, int height) { diff --git a/Source/Project64-video/TextureEnhancer/TxQuantize.h b/Source/Project64-video/TextureEnhancer/TxQuantize.h index 732550bd0..6fff5313b 100644 --- a/Source/Project64-video/TextureEnhancer/TxQuantize.h +++ b/Source/Project64-video/TextureEnhancer/TxQuantize.h @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2003 Rice1964 @@ -8,8 +8,8 @@ #ifndef __TXQUANTIZE_H__ #define __TXQUANTIZE_H__ -/* Glide64 DXTn workaround - * (0:disable, 1:enable) */ +// Glide64 DXTn workaround +// (0:disable, 1:enable) #define GLIDE64_DXTN 1 #include "TxInternal.h" @@ -24,7 +24,7 @@ private: fxtCompressTexFuncExt _tx_compress_fxt1; dxtCompressTexFuncExt _tx_compress_dxtn; - /* fast optimized... well, sort of. */ + // Fast optimized...well, sort of void ARGB1555_ARGB8888(uint32* src, uint32* dst, int width, int height); void ARGB4444_ARGB8888(uint32* src, uint32* dst, int width, int height); void RGB565_ARGB8888(uint32* src, uint32* dst, int width, int height); @@ -39,7 +39,7 @@ private: void ARGB8888_AI44(uint32* src, uint32* dst, int width, int height); void ARGB8888_AI88(uint32* src, uint32* dst, int width, int height); - /* quality */ + // Quality void ARGB8888_RGB565_ErrD(uint32* src, uint32* dst, int width, int height); void ARGB8888_ARGB1555_ErrD(uint32* src, uint32* dst, int width, int height); void ARGB8888_ARGB4444_ErrD(uint32* src, uint32* dst, int width, int height); @@ -47,7 +47,7 @@ private: void ARGB8888_AI88_Slow(uint32* src, uint32* dst, int width, int height); void ARGB8888_I8_Slow(uint32* src, uint32* dst, int width, int height); - /* compressors */ + // Compressors bool FXT1(uint8 *src, uint8 *dest, int srcwidth, int srcheight, uint16 srcformat, int *destwidth, int *destheight, uint16 *destformat); @@ -59,7 +59,7 @@ public: TxQuantize(); ~TxQuantize(); - /* others */ + // Others void P8_16BPP(uint32* src, uint32* dst, int width, int height, uint32* palette); bool quantize(uint8* src, uint8* dest, int width, int height, uint16 srcformat, uint16 destformat, bool fastQuantizer = 1); diff --git a/Source/Project64-video/TextureEnhancer/TxReSample.cpp b/Source/Project64-video/TextureEnhancer/TxReSample.cpp index e7f136aaa..2faca7091 100644 --- a/Source/Project64-video/TextureEnhancer/TxReSample.cpp +++ b/Source/Project64-video/TextureEnhancer/TxReSample.cpp @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2003 Rice1964 @@ -26,7 +26,7 @@ TxReSample::nextPow2(int num) num = num | (num >> 4); num = num | (num >> 8); num = num | (num >> 16); - /*num = num | (num >> 32);*//* for 64bit architecture */ + //num = num | (num >> 32); // For 64-bit architecture num = num + 1; return num; @@ -35,7 +35,7 @@ TxReSample::nextPow2(int num) bool TxReSample::nextPow2(uint8** image, int* width, int* height, int bpp, bool use_3dfx = 0) { - /* NOTE: bpp must be one of the follwing: 8, 16, 24, 32 bits per pixel */ + // NOTE: bpp must be one of the following: 8, 16, 24, 32 bits per pixel if (!*image || !*width || !*height || !bpp) return 0; @@ -48,10 +48,11 @@ TxReSample::nextPow2(uint8** image, int* width, int* height, int bpp, bool use_3 int n_height = *height; /* HACKALERT: I have explicitly subtracted (n) from width/height to - * adjust textures that have (n) pixel larger width/height than - * power of 2 size. This is a dirty hack for textures that have - * munged aspect ratio by (n) pixel to the original. - */ + adjust textures that have (n) pixel larger width/height than + power of 2 size. This is a dirty hack for textures that have + munged aspect ratio by (n) pixel to the original. + */ + if (n_width > 64) n_width -= 4; else if (n_width > 16) n_width -= 2; else if (n_width > 4) n_width -= 1; @@ -64,7 +65,7 @@ TxReSample::nextPow2(uint8** image, int* width, int* height, int bpp, bool use_3 n_height = nextPow2(n_height); row_bytes = (n_width * bpp) >> 3; - /* 3dfx Glide3 format, W:H aspect ratio range (8:1 - 1:8) */ + // 3DFX Glide3 format, W:H aspect ratio range (8:1 - 1:8) if (use_3dfx) { if (n_width > n_height) { if (n_width > (n_height << 3)) @@ -76,14 +77,14 @@ TxReSample::nextPow2(uint8** image, int* width, int* height, int bpp, bool use_3 row_bytes = (n_width * bpp) >> 3; } } - DBG_INFO(80, "using 3dfx W:H aspect ratio range (8:1 - 1:8).\n"); + DBG_INFO(80, "Using 3DFX W:H aspect ratio range (8:1 - 1:8).\n"); } - /* do we really need to do this ? */ + // Do we really need to do this? if (o_width == n_width && o_height == n_height) - return 1; /* nope */ + return 1; // Nope - DBG_INFO(80, "expand image to next power of 2 dimensions. %d x %d -> %d x %d\n", o_width, o_height, n_width, n_height); + DBG_INFO(80, "Expand image to next power of 2 dimensions. %d x %d -> %d x %d\n", o_width, o_height, n_width, n_height); if (o_width > n_width) o_width = n_width; @@ -91,26 +92,26 @@ TxReSample::nextPow2(uint8** image, int* width, int* height, int bpp, bool use_3 if (o_height > n_height) o_height = n_height; - /* allocate memory to read in image */ + // Allocate memory to read in image uint8 *pow2image = (uint8*)malloc(row_bytes * n_height); - /* read in image */ + // Read in image if (pow2image) { int i, j; uint8 *tmpimage = *image, *tmppow2image = pow2image; for (i = 0; i < o_height; i++) { - /* copy row */ + // Copy row memcpy(tmppow2image, tmpimage, ((o_width * bpp) >> 3)); - /* expand to pow2 size by replication */ + // Expand to pow2 size by replication for (j = ((o_width * bpp) >> 3); j < row_bytes; j++) tmppow2image[j] = tmppow2image[j - (bpp >> 3)]; tmppow2image += row_bytes; tmpimage += o_row_bytes; } - /* expand to pow2 size by replication */ + // Expand to pow2 size by replication for (i = o_height; i < n_height; i++) memcpy(&pow2image[row_bytes * i], &pow2image[row_bytes * (i - 1)], row_bytes); @@ -126,10 +127,10 @@ TxReSample::nextPow2(uint8** image, int* width, int* height, int bpp, bool use_3 return 0; } -/* Ken Turkowski - * Filters for Common Resampling Tasks - * Apple Computer 1990 - */ +// Ken Turkowski +// Filters for Common Resampling Tasks +// Apple Computer 1990 + double TxReSample::tent(double x) { @@ -162,12 +163,12 @@ TxReSample::lanczos3(double x) return 0.0; } -/* Don P. Mitchell and Arun N. Netravali - * Reconstruction Filters in Computer Graphics - * SIGGRAPH '88 - * Proceedings of the 15th annual conference on Computer - * graphics and interactive techniques, pp221-228, 1988 - */ +// Don P. Mitchell and Arun N. Netravali +// Reconstruction Filters in Computer Graphics +// SIGGRAPH '88 +// Proceedings of the 15th annual conference on Computer +// graphics and interactive techniques, pp221-228, 1988 + double TxReSample::mitchell(double x) { @@ -191,15 +192,15 @@ TxReSample::mitchell(double x) return 0.0; } -/* J. F. Kaiser and W. A. Reed - * Data smoothing using low-pass digital filters - * Rev. Sci. instrum. 48 (11), pp1447-1457, 1977 - */ +// J. F. Kaiser and W. A. Reed +// Data smoothing using low-pass digital filters +// Rev. Sci. instrum. 48 (11), pp1447-1457, 1977 + double TxReSample::besselI0(double x) { - /* zero-order modified bessel function of the first kind */ - const double eps_coeff = 1E-16; /* small enough */ + // Zero-order modified Bessel function of the first kind + const double eps_coeff = 1E-16; // Small enough double xh, sum, pow, ds; xh = 0.5 * x; sum = 1.0; @@ -227,15 +228,14 @@ TxReSample::kaiser(double x) bool TxReSample::minify(uint8 **src, int *width, int *height, int ratio) { - /* NOTE: src must be ARGB8888, ratio is the inverse representation */ + // NOTE: Source must be ARGB8888, ratio is the inverse representation #if 0 if (!*src || ratio < 2) return 0; - /* Box filtering. - * It would be nice to do Kaiser filtering. - * N64 uses narrow strip textures which makes it hard to filter effectively. - */ + // Box filtering + // It would be nice to do Kaiser filtering. + // N64 uses narrow strip textures which makes it hard to filter effectively. int x, y, x2, y2, offset, numtexel; uint32 A, R, G, B, texel; @@ -286,13 +286,11 @@ TxReSample::minify(uint8 **src, int *width, int *height, int ratio) if (!*src || ratio < 2) return 0; - /* Image Resampling */ - - /* half width of filter window. - * NOTE: must be 1.0 or larger. - * - * kaiser-bessel 5, lanczos3 3, mitchell 2, gaussian 1.5, tent 1 - */ + // Image resampling + // Half width of filter window. + // NOTE: Must be 1.0 or larger. + // Kaiser-Bessel 5, lanczos3 3, Mitchell 2, gaussian 1.5, tent 1 + double half_window = 5.0; int x, y, x2, y2, z; @@ -302,18 +300,18 @@ TxReSample::minify(uint8 **src, int *width, int *height, int ratio) int tmpwidth = *width / ratio; int tmpheight = *height / ratio; - /* resampled destination */ + // Resampled destination uint8 *tmptex = (uint8*)malloc((tmpwidth * tmpheight) << 2); if (!tmptex) return 0; - /* work buffer. single row */ + // Work buffer, single row uint8 *workbuf = (uint8*)malloc(*width << 2); if (!workbuf) { free(tmptex); return 0; } - /* prepare filter lookup table. only half width required for symetric filters. */ + // Prepare filter lookup table, only half width required for symmetric filters double *weight = (double*)malloc((int)((half_window * ratio) * sizeof(double))); if (!weight) { free(tmptex); @@ -328,7 +326,7 @@ TxReSample::minify(uint8 **src, int *width, int *height, int ratio) weight[x] = kaiser((double)x / ratio) / ratio; } - /* linear convolution */ + // Linear convolution for (y = 0; y < tmpheight; y++) { for (x = 0; x < *width; x++) { texel = ((uint32*)*src)[y * ratio * *width + x]; @@ -395,7 +393,7 @@ TxReSample::minify(uint8 **src, int *width, int *height, int ratio) *width = tmpwidth; *height = tmpheight; - DBG_INFO(80, "minification ratio:%d -> %d x %d\n", ratio, *width, *height); + DBG_INFO(80, "Minification ratio:%d -> %d x %d\n", ratio, *width, *height); return 1; #endif diff --git a/Source/Project64-video/TextureEnhancer/TxReSample.h b/Source/Project64-video/TextureEnhancer/TxReSample.h index 1355adeb9..95f654394 100644 --- a/Source/Project64-video/TextureEnhancer/TxReSample.h +++ b/Source/Project64-video/TextureEnhancer/TxReSample.h @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2003 Rice1964 diff --git a/Source/Project64-video/TextureEnhancer/TxTexCache.cpp b/Source/Project64-video/TextureEnhancer/TxTexCache.cpp index 53f470f87..005e02309 100644 --- a/Source/Project64-video/TextureEnhancer/TxTexCache.cpp +++ b/Source/Project64-video/TextureEnhancer/TxTexCache.cpp @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2003 Rice1964 @@ -9,7 +9,7 @@ #pragma warning(disable: 4786) #endif -/* dump cache to disk (0:disable, 1:enable) */ +// Dump cache to disk (0:disable, 1:enable) #define DUMP_CACHE 1 #include "TxTexCache.h" @@ -24,7 +24,7 @@ TxTexCache::~TxTexCache() #if DUMP_CACHE if (_options & DUMP_TEXCACHE) { - /* dump cache to disk */ + // Dump cache to disk std::string filename = _ident + "_MEMORYCACHE.dat"; CPath cachepath(_path.c_str(), ""); cachepath.AppendDirectory("Cache"); @@ -39,7 +39,7 @@ TxTexCache::~TxTexCache() TxTexCache::TxTexCache(int options, int cachesize, const char *path, const char *ident, dispInfoFuncExt callback) : TxCache((options & ~GZ_HIRESTEXCACHE), cachesize, path, ident, callback) { - /* assert local options */ + // Assert local options if (_path.empty() || _ident.empty() || !_cacheSize) { _options &= ~DUMP_TEXCACHE; @@ -48,7 +48,7 @@ TxTexCache::TxTexCache(int options, int cachesize, const char *path, const char #if DUMP_CACHE if (_options & DUMP_TEXCACHE) { - /* find it on disk */ + // Find it on disk std::string filename = _ident + "_MEMORYCACHE.dat"; CPath cachepath(_path.c_str(), ""); cachepath.AppendDirectory("Cache"); diff --git a/Source/Project64-video/TextureEnhancer/TxTexCache.h b/Source/Project64-video/TextureEnhancer/TxTexCache.h index 07ff75765..95e9a0a1d 100644 --- a/Source/Project64-video/TextureEnhancer/TxTexCache.h +++ b/Source/Project64-video/TextureEnhancer/TxTexCache.h @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2003 Rice1964 @@ -16,7 +16,7 @@ public: ~TxTexCache(); TxTexCache(int options, int cachesize, const char *path, const char *ident, dispInfoFuncExt callback); - bool add(uint64_t checksum, /* checksum hi:palette low:texture */ + bool add(uint64_t checksum, // checksum hi:palette low:texture GHQTexInfo *info); }; diff --git a/Source/Project64-video/TextureEnhancer/TxUtil.cpp b/Source/Project64-video/TextureEnhancer/TxUtil.cpp index 4456db270..67981a0d2 100644 --- a/Source/Project64-video/TextureEnhancer/TxUtil.cpp +++ b/Source/Project64-video/TextureEnhancer/TxUtil.cpp @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2003 Rice1964 @@ -16,9 +16,7 @@ #include #endif -/* - * External libraries - ******************************************************************************/ +// External libraries TxLoadLib::TxLoadLib() { _tx_compress_dxtn = tx_compress_dxtn; @@ -39,19 +37,16 @@ dxtCompressTexFuncExt TxLoadLib::getdxtCompressTexFuncExt() return _tx_compress_dxtn; } -/* - * Utilities - ******************************************************************************/ +// Utilities uint32 TxUtil::checksumTx(uint8 *src, int width, int height, uint16 format) { int dataSize = sizeofTx(width, height, format); - /* for now we use adler32 if something else is better - * we can simply swtich later - */ - /* return (dataSize ? Adler32(src, dataSize, 1) : 0); */ + // For now we use adler32 if something else is better + // we can simply switch later + // return (dataSize ? Adler32(src, dataSize, 1) : 0); - /* zlib crc32 */ + // zlib crc32 return (dataSize ? crc32(crc32(0L, Z_NULL, 0), src, dataSize) : 0); } @@ -59,7 +54,7 @@ int TxUtil::sizeofTx(int width, int height, uint16 format) { int dataSize = 0; - /* a lookup table for the shifts would be better */ + // TODO: A lookup table for the shifts would be better switch (format) { case GFX_TEXFMT_ARGB_CMP_FXT1: dataSize = (((width + 0x7) & ~0x7) * ((height + 0x3) & ~0x3)) >> 1; @@ -87,8 +82,8 @@ int TxUtil::sizeofTx(int width, int height, uint16 format) dataSize = (width * height) << 2; break; default: - /* unsupported format */ - DBG_INFO(80, "Error: cannot get size. unsupported gfmt:%x\n", format); + // Unsupported format + DBG_INFO(80, "Error: Cannot get size. Unsupported gfmt:%x\n", format); ; } @@ -97,9 +92,9 @@ int TxUtil::sizeofTx(int width, int height, uint16 format) uint32 TxUtil::checksum(uint8 *src, int width, int height, int size, int rowStride) { - /* Rice CRC32 for now. We can switch this to Jabo MD5 or - * any other custom checksum. - * TODO: use *_HIRESTEXTURE option. */ + // Rice CRC32 for now. We can switch this to MD5 or + // any other custom checksum. + // TODO: use *_HIRESTEXTURE option. if (!src) return 0; @@ -108,10 +103,10 @@ uint32 TxUtil::checksum(uint8 *src, int width, int height, int size, int rowStri uint64_t TxUtil::checksum64(uint8 *src, int width, int height, int size, int rowStride, uint8 *palette) { - /* Rice CRC32 for now. We can switch this to Jabo MD5 or - * any other custom checksum. - * TODO: use *_HIRESTEXTURE option. */ - /* Returned value is 64bits: hi=palette crc32 low=texture crc32 */ + // Rice CRC32 for now. We can switch this to MD5 or + // any other custom checksum. + // TODO: use *_HIRESTEXTURE option. + // Returned value is 64bits: hi=palette crc32 low=texture crc32 if (!src) return 0; @@ -148,43 +143,43 @@ uint64_t TxUtil::checksum64(uint8 *src, int width, int height, int size, int row } /* -** Computes Adler32 checksum for a stream of data. -** -** From the specification found in RFC 1950: (ZLIB Compressed Data Format -** Specification version 3.3) -** -** ADLER32 (Adler-32 checksum) This contains a checksum value of the -** uncompressed data (excluding any dictionary data) computed according to -** Adler-32 algorithm. This algorithm is a 32-bit extension and improvement -** of the Fletcher algorithm, used in the ITU-T X.224 / ISO 8073 standard. -** -** Adler-32 is composed of two sums accumulated per byte: s1 is the sum of -** all bytes, s2 is the sum of all s1 values. Both sums are done modulo -** 65521. s1 is initialized to 1, s2 to zero. The Adler-32 checksum is stored -** as s2*65536 + s1 in most-significant-byte first (network) order. -** -** 8.2. The Adler-32 algorithm -** -** The Adler-32 algorithm is much faster than the CRC32 algorithm yet still -** provides an extremely low probability of undetected errors. -** -** The modulo on unsigned long accumulators can be delayed for 5552 bytes, -** so the modulo operation time is negligible. If the bytes are a, b, c, -** the second sum is 3a + 2b + c + 3, and so is position and order sensitive, -** unlike the first sum, which is just a checksum. That 65521 is prime is -** important to avoid a possible large class of two-byte errors that leave -** the check unchanged. (The Fletcher checksum uses 255, which is not prime -** and which also makes the Fletcher check insensitive to single byte -** changes 0 <-> 255.) -** -** The sum s1 is initialized to 1 instead of zero to make the length of -** the sequence part of s2, so that the length does not have to be checked -** separately. (Any sequence of zeroes has a Fletcher checksum of zero.) +Computes Adler32 checksum for a stream of data. + +From the specification found in RFC 1950: (ZLIB Compressed Data Format +Specification version 3.3) + +ADLER32 (Adler-32 checksum) This contains a checksum value of the +uncompressed data (excluding any dictionary data) computed according to +Adler-32 algorithm. This algorithm is a 32-bit extension and improvement +of the Fletcher algorithm, used in the ITU-T X.224 / ISO 8073 standard. + +Adler-32 is composed of two sums accumulated per byte: s1 is the sum of +all bytes, s2 is the sum of all s1 values. Both sums are done modulo +65521. s1 is initialized to 1, s2 to zero. The Adler-32 checksum is stored +as s2*65536 + s1 in most-significant-byte first (network) order. + +8.2. The Adler-32 algorithm + +The Adler-32 algorithm is much faster than the CRC32 algorithm yet still +provides an extremely low probability of undetected errors. + +The modulo on unsigned long accumulators can be delayed for 5552 bytes, +so the modulo operation time is negligible. If the bytes are a, b, c, +the second sum is 3a + 2b + c + 3, and so is position and order sensitive, +unlike the first sum, which is just a checksum. That 65521 is prime is +important to avoid a possible large class of two-byte errors that leave +the check unchanged. (The Fletcher checksum uses 255, which is not prime +and which also makes the Fletcher check insensitive to single byte +changes 0 <-> 255.) + +The sum s1 is initialized to 1 instead of zero to make the length of +the sequence part of s2, so that the length does not have to be checked +separately. (Any sequence of zeroes has a Fletcher checksum of zero.) */ uint32 TxUtil::Adler32(const uint8* data, int Len, uint32 dwAdler32) { - /* zlib adler32 */ + // zlib adler32 return adler32(dwAdler32, data, Len); } @@ -203,7 +198,7 @@ uint32 TxUtil::Adler32(const uint8* src, int width, int height, int size, int ro return ret; } -// rotate left +// Rotate left template static T __ROL__(T value, unsigned int count) { const unsigned int nbits = sizeof(T) * 8; @@ -215,20 +210,19 @@ template static T __ROL__(T value, unsigned int count) return value; } -/* Rice CRC32 for hires texture packs */ -/* NOTE: The following is used in Glide64 to calculate the CRC32 - * for Rice hires texture packs. - * - * BYTE* addr = (BYTE*)(gfx.RDRAM + - * rdp.addr[rdp.tiles(tile).t_mem] + - * (rdp.tiles(tile).ul_t * bpl) + - * (((rdp.tiles(tile).ul_s<>1)); - * RiceCRC32(addr, - * rdp.tiles(tile).width, - * rdp.tiles(tile).height, - * (unsigned short)(rdp.tiles(tile).format << 8 | rdp.tiles(tile).size), - * bpl); - */ +// Rice CRC32 for high resolution texture packs +// NOTE: The following is used in Glide64 to calculate the CRC32 +// for Rice high resolution texture packs. +// BYTE* addr = (BYTE*)(gfx.RDRAM + +// rdp.addr[rdp.tiles(tile).t_mem] + +// (rdp.tiles(tile).ul_t * bpl) + +// (((rdp.tiles(tile).ul_s<>1)); +// RiceCRC32(addr, +// rdp.tiles(tile).width, +// rdp.tiles(tile).height, +// (unsigned short)(rdp.tiles(tile).format << 8 | rdp.tiles(tile).size), +// bpl); + uint32 TxUtil::RiceCRC32(const uint8* src, int width, int height, int size, int rowStride) { const uint8_t *row; @@ -422,9 +416,7 @@ int TxUtil::getNumberofProcessors() return numcore; } -/* - * Memory buffers for texture manipulations - ******************************************************************************/ +// Memory buffers for texture manipulations TxMemBuf::TxMemBuf() { int i; @@ -477,4 +469,4 @@ uint8* TxMemBuf::get(unsigned int num) uint32 TxMemBuf::size_of(unsigned int num) { return ((num < 2) ? _size[num] : 0); -} \ No newline at end of file +} diff --git a/Source/Project64-video/TextureEnhancer/TxUtil.h b/Source/Project64-video/TextureEnhancer/TxUtil.h index 5d7239f6a..16e06de4c 100644 --- a/Source/Project64-video/TextureEnhancer/TxUtil.h +++ b/Source/Project64-video/TextureEnhancer/TxUtil.h @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2003 Rice1964 @@ -8,7 +8,7 @@ #ifndef __TXUTIL_H__ #define __TXUTIL_H__ -/* maximum number of CPU cores allowed */ +// Maximum number of CPU cores allowed #define MAX_NUMCORE 8 #include "TxInternal.h" @@ -97,4 +97,4 @@ public: uint32 size_of(unsigned int num); }; -#endif /* __TXUTIL_H__ */ +#endif // __TXUTIL_H__ diff --git a/Source/Project64-video/TextureEnhancer/tc-1.1+/dxtn.c b/Source/Project64-video/TextureEnhancer/tc-1.1+/dxtn.c index fe1034f47..ce97af4f5 100644 --- a/Source/Project64-video/TextureEnhancer/tc-1.1+/dxtn.c +++ b/Source/Project64-video/TextureEnhancer/tc-1.1+/dxtn.c @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2004 Daniel Borca @@ -16,17 +16,16 @@ #include "internal.h" #include "dxtn.h" -/***************************************************************************\ - * DXTn encoder - * - * The encoder was built by reversing the decoder, - * and is vaguely based on FXT1 codec. Note that this code - * is merely a proof of concept, since it is highly UNoptimized! -\***************************************************************************/ +/* +DXTn encoder +The encoder was built by reversing the decoder, +and is vaguely based on FXT1 codec. Note that this code +is merely a proof of concept, since it is highly unoptimized! +*/ -#define MAX_COMP 4 /* ever needed maximum number of components in texel */ -#define MAX_VECT 4 /* ever needed maximum number of base vectors to find */ -#define N_TEXELS 16 /* number of texels in a block (always 16) */ +#define MAX_COMP 4 // Ever needed maximum number of components in texel +#define MAX_VECT 4 // Ever needed maximum number of base vectors to find +#define N_TEXELS 16 // Number of texels in a block (always 16) #define COLOR565(v) (word)((((v)[RCOMP] & 0xf8) << 8) | (((v)[GCOMP] & 0xfc) << 3) | ((v)[BCOMP] >> 3)) static const int dxtn_color_tlat[2][4] = { @@ -42,30 +41,30 @@ static const int dxtn_alpha_tlat[2][8] = { static void dxt1_rgb_quantize(dword *cc, const byte *lines[], int comps) { - float b, iv[MAX_COMP]; /* interpolation vector */ + float b, iv[MAX_COMP]; // Interpolation vector - dword hi; /* high doubleword */ + dword hi; // High doubleword int color0, color1; int n_vect; const int n_comp = 3; int black = 0; #ifndef YUV - int minSum = 2000; /* big enough */ + int minSum = 2000; // Big enough #else int minSum = 2000000; #endif - int maxSum = -1; /* small enough */ - int minCol = 0; /* phoudoin: silent compiler! */ - int maxCol = 0; /* phoudoin: silent compiler! */ + int maxSum = -1; // Small enough + int minCol = 0; // phoudoin: Silent compiler! + int maxCol = 0; // phoudoin: Silent compiler! byte input[N_TEXELS][MAX_COMP]; int i, k, l; - /* make the whole block opaque */ - /* we will NEVER reference ACOMP of any pixel */ + // Make the whole block opaque + // We will NEVER reference ACOMP of any pixel - /* 4 texels each line */ + // 4 texels each line #ifndef ARGB for (l = 0; l < 4; l++) { for (k = 0; k < 4; k++) { @@ -75,7 +74,7 @@ dxt1_rgb_quantize(dword *cc, const byte *lines[], int comps) } } #else - /* H.Morii - support for ARGB inputs */ + // H.Morii - Support for ARGB inputs for (l = 0; l < 4; l++) { for (k = 0; k < 4; k++) { input[k + l * 4][2] = *lines[l]++; @@ -86,10 +85,12 @@ dxt1_rgb_quantize(dword *cc, const byte *lines[], int comps) } #endif - /* Our solution here is to find the darkest and brightest colors in - * the 4x4 tile and use those as the two representative colors. - * There are probably better algorithms to use (histogram-based). - */ + /* + Our solution here is to find the darkest and brightest colors in + the 4x4 tile and use those as the two representative colors. + There are probably better algorithms to use (histogram-based). + */ + for (k = 0; k < N_TEXELS; k++) { int sum = 0; #ifndef YUV @@ -98,10 +99,11 @@ dxt1_rgb_quantize(dword *cc, const byte *lines[], int comps) } #else /* RGB to YUV conversion according to CCIR 601 specs - * Y = 0.299R+0.587G+0.114B - * U = 0.713(R - Y) = 0.500R-0.419G-0.081B - * V = 0.564(B - Y) = -0.169R-0.331G+0.500B - */ + Y = 0.299R+0.587G+0.114B + U = 0.713(R - Y) = 0.500R-0.419G-0.081B + V = 0.564(B - Y) = -0.169R-0.331G+0.500B + */ + sum = 299 * input[k][RCOMP] + 587 * input[k][GCOMP] + 114 * input[k][BCOMP]; #endif if (minSum > sum) { @@ -121,13 +123,13 @@ dxt1_rgb_quantize(dword *cc, const byte *lines[], int comps) color1 = COLOR565(input[maxCol]); if (color0 == color1) { - /* we'll use 3-vector */ + // We'll use 3-vector cc[0] = color0 | (color1 << 16); hi = black ? -1 : 0; } else { if (black && ((color0 == 0) || (color1 == 0))) { - /* we still can use 4-vector */ + // We still can use 4-vector black = 0; } @@ -144,7 +146,7 @@ dxt1_rgb_quantize(dword *cc, const byte *lines[], int comps) MAKEIVEC(n_vect, n_comp, iv, b, input[minCol], input[maxCol]); - /* add in texels */ + // Add in texels cc[0] = color0 | (color1 << 16); hi = 0; for (k = N_TEXELS - 1; k >= 0; k--) { @@ -156,11 +158,11 @@ dxt1_rgb_quantize(dword *cc, const byte *lines[], int comps) } } if (!black || sum) { - /* interpolate color */ + // Interpolate color CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); texel = dxtn_color_tlat[black][texel]; } - /* add in texel */ + // Add in texel hi <<= 2; hi |= texel; } @@ -171,32 +173,32 @@ dxt1_rgb_quantize(dword *cc, const byte *lines[], int comps) static void dxt1_rgba_quantize(dword *cc, const byte *lines[], int comps) { - float b, iv[MAX_COMP]; /* interpolation vector */ + float b, iv[MAX_COMP]; // Interpolation vector - dword hi; /* high doubleword */ + dword hi; // High doubleword int color0, color1; int n_vect; const int n_comp = 3; int transparent = 0; #ifndef YUV - int minSum = 2000; /* big enough */ + int minSum = 2000; // Big enough #else int minSum = 2000000; #endif - int maxSum = -1; /* small enough */ - int minCol = 0; /* phoudoin: silent compiler! */ - int maxCol = 0; /* phoudoin: silent compiler! */ + int maxSum = -1; // Small enough + int minCol = 0; // phoudoin: Silent compiler! + int maxCol = 0; // phoudoin: Silent compiler! byte input[N_TEXELS][MAX_COMP]; int i, k, l; if (comps == 3) { - /* make the whole block opaque */ + // Make the whole block opaque memset(input, -1, sizeof(input)); } - /* 4 texels each line */ + // 4 texels each line #ifndef ARGB for (l = 0; l < 4; l++) { for (k = 0; k < 4; k++) { @@ -206,7 +208,7 @@ dxt1_rgba_quantize(dword *cc, const byte *lines[], int comps) } } #else - /* H.Morii - support for ARGB inputs */ + // H.Morii - Support for ARGB inputs for (l = 0; l < 4; l++) { for (k = 0; k < 4; k++) { input[k + l * 4][2] = *lines[l]++; @@ -217,10 +219,12 @@ dxt1_rgba_quantize(dword *cc, const byte *lines[], int comps) } #endif - /* Our solution here is to find the darkest and brightest colors in - * the 4x4 tile and use those as the two representative colors. - * There are probably better algorithms to use (histogram-based). - */ + /* + Our solution here is to find the darkest and brightest colors in + the 4x4 tile and use those as the two representative colors. + There are probably better algorithms to use (histogram-based). + */ + for (k = 0; k < N_TEXELS; k++) { int sum = 0; #ifndef YUV @@ -247,7 +251,7 @@ dxt1_rgba_quantize(dword *cc, const byte *lines[], int comps) color1 = COLOR565(input[maxCol]); if (color0 == color1) { - /* we'll use 3-vector */ + // We'll use 3-vector cc[0] = color0 | (color1 << 16); hi = transparent ? -1 : 0; } @@ -265,17 +269,17 @@ dxt1_rgba_quantize(dword *cc, const byte *lines[], int comps) MAKEIVEC(n_vect, n_comp, iv, b, input[minCol], input[maxCol]); - /* add in texels */ + // Add in texels cc[0] = color0 | (color1 << 16); hi = 0; for (k = N_TEXELS - 1; k >= 0; k--) { int texel = 3; if (input[k][ACOMP] >= 128) { - /* interpolate color */ + // Interpolate color CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); texel = dxtn_color_tlat[transparent][texel]; } - /* add in texel */ + // Add in texel hi <<= 2; hi |= texel; } @@ -286,32 +290,32 @@ dxt1_rgba_quantize(dword *cc, const byte *lines[], int comps) static void dxt3_rgba_quantize(dword *cc, const byte *lines[], int comps) { - float b, iv[MAX_COMP]; /* interpolation vector */ + float b, iv[MAX_COMP]; // Interpolation vector - dword lolo, lohi; /* low quadword: lo dword, hi dword */ - dword hihi; /* high quadword: high dword */ + dword lolo, lohi; // Low quadword: lo DWORD, hi DWORD + dword hihi; // High quadword: high DWORD int color0, color1; const int n_vect = 3; const int n_comp = 3; #ifndef YUV - int minSum = 2000; /* big enough */ + int minSum = 2000; // Big enough #else int minSum = 2000000; #endif - int maxSum = -1; /* small enough */ - int minCol = 0; /* phoudoin: silent compiler! */ - int maxCol = 0; /* phoudoin: silent compiler! */ + int maxSum = -1; // Small enough + int minCol = 0; // phoudoin: Silent compiler! + int maxCol = 0; // phoudoin: Silent compiler! byte input[N_TEXELS][MAX_COMP]; int i, k, l; if (comps == 3) { - /* make the whole block opaque */ + // Make the whole block opaque memset(input, -1, sizeof(input)); } - /* 4 texels each line */ + // 4 texels each line #ifndef ARGB for (l = 0; l < 4; l++) { for (k = 0; k < 4; k++) { @@ -321,7 +325,7 @@ dxt3_rgba_quantize(dword *cc, const byte *lines[], int comps) } } #else - /* H.Morii - support for ARGB inputs */ + // H.Morii - Support for ARGB inputs for (l = 0; l < 4; l++) { for (k = 0; k < 4; k++) { input[k + l * 4][2] = *lines[l]++; @@ -332,10 +336,12 @@ dxt3_rgba_quantize(dword *cc, const byte *lines[], int comps) } #endif - /* Our solution here is to find the darkest and brightest colors in - * the 4x4 tile and use those as the two representative colors. - * There are probably better algorithms to use (histogram-based). - */ + /* TODO: + Our solution here is to find the darkest and brightest colors in + the 4x4 tile and use those as the two representative colors. + There are probably better algorithms to use (histogram-based). + */ + for (k = 0; k < N_TEXELS; k++) { int sum = 0; #ifndef YUV @@ -355,16 +361,16 @@ dxt3_rgba_quantize(dword *cc, const byte *lines[], int comps) } } - /* add in alphas */ + // Add in alphas lolo = lohi = 0; for (k = N_TEXELS - 1; k >= N_TEXELS / 2; k--) { - /* add in alpha */ + // Add in alpha lohi <<= 4; lohi |= input[k][ACOMP] >> 4; } cc[1] = lohi; for (; k >= 0; k--) { - /* add in alpha */ + // Add in alpha lolo <<= 4; lolo |= input[k][ACOMP] >> 4; } @@ -399,13 +405,13 @@ dxt3_rgba_quantize(dword *cc, const byte *lines[], int comps) if (color0 != color1) { MAKEIVEC(n_vect, n_comp, iv, b, input[minCol], input[maxCol]); - /* add in texels */ + // Add in texels for (k = N_TEXELS - 1; k >= 0; k--) { int texel; - /* interpolate color */ + // Interpolate color CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); texel = dxtn_color_tlat[0][texel]; - /* add in texel */ + // Add in texel hihi <<= 2; hihi |= texel; } @@ -416,24 +422,24 @@ dxt3_rgba_quantize(dword *cc, const byte *lines[], int comps) static void dxt5_rgba_quantize(dword *cc, const byte *lines[], int comps) { - float b, iv[MAX_COMP]; /* interpolation vector */ + float b, iv[MAX_COMP]; // Interpolation vector - qword lo; /* low quadword */ - dword hihi; /* high quadword: high dword */ + qword lo; // Low quadword + dword hihi; // High quadword: high DWORD int color0, color1; const int n_vect = 3; const int n_comp = 3; #ifndef YUV - int minSum = 2000; /* big enough */ + int minSum = 2000; // Big enough #else int minSum = 2000000; #endif - int maxSum = -1; /* small enough */ - int minCol = 0; /* phoudoin: silent compiler! */ - int maxCol = 0; /* phoudoin: silent compiler! */ - int alpha0 = 2000; /* big enough */ - int alpha1 = -1; /* small enough */ + int maxSum = -1; // Small enough + int minCol = 0; // phoudoin: Silent compiler! + int maxCol = 0; // phoudoin: Silent compiler! + int alpha0 = 2000; // Big enough + int alpha1 = -1; // Small enough int anyZero = 0, anyOne = 0; int a_vect; @@ -441,11 +447,11 @@ dxt5_rgba_quantize(dword *cc, const byte *lines[], int comps) int i, k, l; if (comps == 3) { - /* make the whole block opaque */ + // Make the whole block opaque memset(input, -1, sizeof(input)); } - /* 4 texels each line */ + // 4 texels each line #ifndef ARGB for (l = 0; l < 4; l++) { for (k = 0; k < 4; k++) { @@ -455,7 +461,7 @@ dxt5_rgba_quantize(dword *cc, const byte *lines[], int comps) } } #else - /* H.Morii - support for ARGB inputs */ + // H.Morii - Support for ARGB inputs for (l = 0; l < 4; l++) { for (k = 0; k < 4; k++) { input[k + l * 4][2] = *lines[l]++; @@ -466,10 +472,12 @@ dxt5_rgba_quantize(dword *cc, const byte *lines[], int comps) } #endif - /* Our solution here is to find the darkest and brightest colors in - * the 4x4 tile and use those as the two representative colors. - * There are probably better algorithms to use (histogram-based). - */ + /* + Our solution here is to find the darkest and brightest colors in + the 4x4 tile and use those as the two representative colors. + There are probably better algorithms to use (histogram-based). + */ + for (k = 0; k < N_TEXELS; k++) { int sum = 0; #ifndef YUV @@ -501,19 +509,19 @@ dxt5_rgba_quantize(dword *cc, const byte *lines[], int comps) } } - /* add in alphas */ + // Add in alphas if (alpha0 == alpha1) { - /* we'll use 6-vector */ + // We'll use 6-vector cc[0] = alpha0 | (alpha1 << 8); cc[1] = 0; } else { if (anyZero && ((alpha0 == 0) || (alpha1 == 0))) { - /* we still might use 8-vector */ + // We still might use 8-vector anyZero = 0; } if (anyOne && ((alpha0 == 255) || (alpha1 == 255))) { - /* we still might use 8-vector */ + // We still might use 8-vector anyOne = 0; } if ((anyZero | anyOne) ^ (alpha0 <= alpha1)) { @@ -524,11 +532,11 @@ dxt5_rgba_quantize(dword *cc, const byte *lines[], int comps) } a_vect = (alpha0 <= alpha1) ? 5 : 7; - /* compute interpolation vector */ + // Compute interpolation vector iv[ACOMP] = (float)a_vect / (alpha1 - alpha0); b = -iv[ACOMP] * alpha0 + 0.5F; - /* add in alphas */ + // Add in alphas Q_MOV32(lo, 0); for (k = N_TEXELS - 1; k >= 0; k--) { int texel = -1; @@ -540,7 +548,7 @@ dxt5_rgba_quantize(dword *cc, const byte *lines[], int comps) texel = 7; } } - /* interpolate alpha */ + // Interpolate alpha if (texel == -1) { float dot = input[k][ACOMP] * iv[ACOMP]; texel = (int)(dot + b); @@ -554,7 +562,7 @@ dxt5_rgba_quantize(dword *cc, const byte *lines[], int comps) #endif texel = dxtn_alpha_tlat[anyZero | anyOne][texel]; } - /* add in texel */ + // Add in texel Q_SHL(lo, 3); Q_OR32(lo, texel); } @@ -584,13 +592,13 @@ dxt5_rgba_quantize(dword *cc, const byte *lines[], int comps) if (color0 != color1) { MAKEIVEC(n_vect, n_comp, iv, b, input[minCol], input[maxCol]); - /* add in texels */ + // Add in texels for (k = N_TEXELS - 1; k >= 0; k--) { int texel; - /* interpolate color */ + // Interpolate color CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); texel = dxtn_color_tlat[0][texel]; - /* add in texel */ + // Add in texel hihi <<= 2; hihi |= texel; } @@ -653,20 +661,19 @@ ENCODER(dxt1_rgba, 2) ENCODER(dxt3_rgba, 4) ENCODER(dxt5_rgba, 4) -/***************************************************************************\ - * DXTn decoder - * - * The decoder is based on GL_EXT_texture_compression_s3tc - * specification and serves as a concept for the encoder. -\***************************************************************************/ +/* +DXTn decoder +The decoder is based on GL_EXT_texture_compression_s3tc +specification and serves as a concept for the encoder. +*/ -/* lookup table for scaling 4 bit colors up to 8 bits */ +// Lookup table for scaling 4-bit colors up to 8-bit static const byte _rgb_scale_4[] = { 0, 17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255 }; -/* lookup table for scaling 5 bit colors up to 8 bits */ +// Lookup table for scaling 5-bit colors up to 8-bit static const byte _rgb_scale_5[] = { 0, 8, 16, 25, 33, 41, 49, 58, 66, 74, 82, 90, 99, 107, 115, 123, @@ -674,7 +681,7 @@ static const byte _rgb_scale_5[] = { 197, 206, 214, 222, 230, 239, 247, 255 }; -/* lookup table for scaling 6 bit colors up to 8 bits */ +// Lookup table for scaling 6-bit colors up to 8-bit static const byte _rgb_scale_6[] = { 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 45, 49, 53, 57, 61, @@ -742,7 +749,7 @@ void TAPIENTRY dxt1_rgba_decode_1(const void *texture, int stride, int i, int j, byte *rgba) { - /* Same as rgb_dxt1 above, except alpha=0 if col0<=col1 and code=3. */ + // Same as rgb_dxt1 above, except alpha=0 if col0<=col1 and code=3. const byte *src = (const byte *)texture + ((j / 4) * ((stride + 3) / 4) + i / 4) * 8; const int code = (src[4 + (j & 3)] >> ((i & 3) * 2)) & 0x3; @@ -807,7 +814,7 @@ dxt3_rgba_decode_1(const void *texture, int stride, rgba[BCOMP] = UP5(CC_SEL(cc, 16)); } else if (code == 2) { - /* (col0 * (4 - code) + col1 * (code - 1)) / 3 */ + // (col0 * (4 - code) + col1 * (code - 1)) / 3 rgba[RCOMP] = (UP5(CC_SEL(cc, 11)) * 2 + UP5(CC_SEL(cc, 27))) / 3; rgba[GCOMP] = (UP6(CC_SEL(cc, 5)) * 2 + UP6(CC_SEL(cc, 21))) / 3; rgba[BCOMP] = (UP5(CC_SEL(cc, 0)) * 2 + UP5(CC_SEL(cc, 16))) / 3; @@ -845,7 +852,7 @@ dxt5_rgba_decode_1(const void *texture, int stride, rgba[BCOMP] = UP5(CC_SEL(cc, 16)); } else if (code == 2) { - /* (col0 * (4 - code) + col1 * (code - 1)) / 3 */ + // (col0 * (4 - code) + col1 * (code - 1)) / 3 rgba[RCOMP] = (UP5(CC_SEL(cc, 11)) * 2 + UP5(CC_SEL(cc, 27))) / 3; rgba[GCOMP] = (UP6(CC_SEL(cc, 5)) * 2 + UP6(CC_SEL(cc, 21))) / 3; rgba[BCOMP] = (UP5(CC_SEL(cc, 0)) * 2 + UP5(CC_SEL(cc, 16))) / 3; diff --git a/Source/Project64-video/TextureEnhancer/tc-1.1+/dxtn.h b/Source/Project64-video/TextureEnhancer/tc-1.1+/dxtn.h index 1414f3318..d348b4e5a 100644 --- a/Source/Project64-video/TextureEnhancer/tc-1.1+/dxtn.h +++ b/Source/Project64-video/TextureEnhancer/tc-1.1+/dxtn.h @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2004 Daniel Borca @@ -29,19 +29,19 @@ dxt5_rgba_encode(int width, int height, int comps, void *dest, int destRowStride); TAPI void TAPIENTRY -dxt1_rgb_decode_1(const void *texture, int stride /* in pixels */, +dxt1_rgb_decode_1(const void *texture, int stride, // In pixels int i, int j, byte *rgba); TAPI void TAPIENTRY -dxt1_rgba_decode_1(const void *texture, int stride /* in pixels */, +dxt1_rgba_decode_1(const void *texture, int stride, // In pixels int i, int j, byte *rgba); TAPI void TAPIENTRY -dxt3_rgba_decode_1(const void *texture, int stride /* in pixels */, +dxt3_rgba_decode_1(const void *texture, int stride, // In pixels int i, int j, byte *rgba); TAPI void TAPIENTRY -dxt5_rgba_decode_1(const void *texture, int stride /* in pixels */, +dxt5_rgba_decode_1(const void *texture, int stride, // In pixels int i, int j, byte *rgba); #endif diff --git a/Source/Project64-video/TextureEnhancer/tc-1.1+/fxt1.c b/Source/Project64-video/TextureEnhancer/tc-1.1+/fxt1.c index 4cb69eda9..97dd7c21e 100644 --- a/Source/Project64-video/TextureEnhancer/tc-1.1+/fxt1.c +++ b/Source/Project64-video/TextureEnhancer/tc-1.1+/fxt1.c @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2004 Daniel Borca @@ -12,15 +12,14 @@ #include "internal.h" #include "fxt1.h" -/***************************************************************************\ - * FXT1 encoder - * - * The encoder was built by reversing the decoder, - * and is vaguely based on Texus2 by 3dfx. Note that this code - * is merely a proof of concept, since it is highly UNoptimized; - * moreover, it is sub-optimal due to initial conditions passed - * to Lloyd's algorithm (the interpolation modes are even worse). -\***************************************************************************/ +/* +FXT1 encoder +The encoder was built by reversing the decoder, +and is vaguely based on Texus2 by 3DFX. Note that this code +is merely a proof of concept, since it is highly unoptimized; +Moreover, it is sub-optimal due to initial conditions passed +to Lloyd's algorithm (the interpolation modes are even worse). +*/ #define MAX_COMP 4 /* ever needed maximum number of components in texel */ #define MAX_VECT 4 /* ever needed maximum number of base vectors to find */ @@ -37,7 +36,7 @@ fxt1_bestcol(float vec[][MAX_COMP], int nv, byte input[MAX_COMP], int nc) { int i, j, best = -1; - float err = 1e9; /* big enough */ + float err = 1e9; // Big enough for (j = 0; j < nv; j++) { float e = 0.0F; @@ -58,7 +57,7 @@ fxt1_worst(float vec[MAX_COMP], byte input[N_TEXELS][MAX_COMP], int nc, int n) { int i, k, worst = -1; - float err = -1.0F; /* small enough */ + float err = -1.0F; // Small enough for (k = 0; k < n; k++) { float e = 0.0F; @@ -80,7 +79,7 @@ fxt1_variance(double variance[MAX_COMP], { int i, k, best = 0; dword sx, sx2; - double var, maxvar = -1; /* small enough */ + double var, maxvar = -1; // Small enough double teenth = 1.0 / n; for (i = 0; i < nc; i++) { @@ -108,8 +107,7 @@ fxt1_choose(float vec[][MAX_COMP], int nv, byte input[N_TEXELS][MAX_COMP], int nc, int n) { #if 0 - /* Choose colors from a grid. - */ + // Choose colors from a grid int i, j; for (j = 0; j < nv; j++) { @@ -119,19 +117,20 @@ fxt1_choose(float vec[][MAX_COMP], int nv, } } #else - /* Our solution here is to find the darkest and brightest colors in - * the 8x4 tile and use those as the two representative colors. - * There are probably better algorithms to use (histogram-based). - */ + /* + Our solution here is to find the darkest and brightest colors in + the 8x4 tile and use those as the two representative colors. + There are probably better algorithms to use (histogram-based). + */ int i, j, k; #ifndef YUV - int minSum = 2000; /* big enough */ + int minSum = 2000; // Big enough #else int minSum = 2000000; #endif - int maxSum = -1; /* small enough */ - int minCol = 0; /* phoudoin: silent compiler! */ - int maxCol = 0; /* phoudoin: silent compiler! */ + int maxSum = -1; // Small enough + int minCol = 0; // phoudoin: Silent compiler! + int maxCol = 0; // phoudoin: Silent compiler! struct { int flag; @@ -163,7 +162,7 @@ fxt1_choose(float vec[][MAX_COMP], int nv, } for (l = 0; l < n; l++) { if (!hist[l].flag) { - /* alloc new slot */ + // Allocate new slot hist[l].flag = !0; hist[l].key = key; hist[l].freq = 1; @@ -214,35 +213,36 @@ static int fxt1_lloyd(float vec[][MAX_COMP], int nv, byte input[N_TEXELS][MAX_COMP], int nc, int n) { - /* Use the generalized lloyd's algorithm for VQ: - * find 4 color vectors. - * - * for each sample color - * sort to nearest vector. - * - * replace each vector with the centroid of it's matching colors. - * - * repeat until RMS doesn't improve. - * - * if a color vector has no samples, or becomes the same as another - * vector, replace it with the color which is farthest from a sample. - * - * vec[][MAX_COMP] initial vectors and resulting colors - * nv number of resulting colors required - * input[N_TEXELS][MAX_COMP] input texels - * nc number of components in input / vec - * n number of input samples - */ + /* + Use the generalized Lloyd's algorithm for VQ: + find 4 color vectors. + + For each sample color, + sort to nearest vector. + + Replace each vector with the centroid of it's matching colors. + + Repeat until RMS doesn't improve. + + If a color vector has no samples, or becomes the same as another + vector, replace it with the color which is farthest from a sample. + + vec[][MAX_COMP] Initial vectors and resulting colors + nv Number of resulting colors required + input[N_TEXELS][MAX_COMP] Input texels + nc Number of components in input / vec + n Number of input samples + */ - int sum[MAX_VECT][MAX_COMP]; /* used to accumulate closest texels */ - int cnt[MAX_VECT]; /* how many times a certain vector was chosen */ + int sum[MAX_VECT][MAX_COMP]; // Used to accumulate closest texels + int cnt[MAX_VECT]; // How many times a certain vector was chosen float error, lasterror = 1e9; int i, j, k, rep; - /* the quantizer */ + // The quantizer for (rep = 0; rep < LL_N_REP; rep++) { - /* reset sums & counters */ + // Reset sums and counters for (j = 0; j < nv; j++) { for (i = 0; i < nc; i++) { sum[j][i] = 0; @@ -251,12 +251,12 @@ fxt1_lloyd(float vec[][MAX_COMP], int nv, } error = 0; - /* scan whole block */ + // Scan whole block for (k = 0; k < n; k++) { #if 1 int best = -1; - float err = 1e9; /* big enough */ - /* determine best vector */ + float err = 1e9; // Big enough + // Determine best vector for (j = 0; j < nv; j++) { float e = (vec[j][0] - input[k][0]) * (vec[j][0] - input[k][0]) + (vec[j][1] - input[k][1]) * (vec[j][1] - input[k][1]) + @@ -272,24 +272,24 @@ fxt1_lloyd(float vec[][MAX_COMP], int nv, #else int best = fxt1_bestcol(vec, nv, input[k], nc, &err); #endif - /* add in closest color */ + // Add in closest color for (i = 0; i < nc; i++) { sum[best][i] += input[k][i]; } - /* mark this vector as used */ + // Mark this vector as used cnt[best]++; - /* accumulate error */ + // Accumulate error error += err; } - /* check RMS */ + // Check RMS if ((error < LL_RMS_E) || ((error < lasterror) && ((lasterror - error) < LL_RMS_D))) { - return !0; /* good match */ + return !0; // Good match } lasterror = error; - /* move each vector to the barycenter of its closest colors */ + // Move each vector to the barycenter of its closest colors for (j = 0; j < nv; j++) { if (cnt[j]) { float div = 1.0F / cnt[j]; @@ -298,7 +298,7 @@ fxt1_lloyd(float vec[][MAX_COMP], int nv, } } else { - /* this vec has no samples or is identical with a previous vec */ + // This vector has no samples or is identical with a previous vector int worst = fxt1_worst(vec[j], input, nc, n); for (i = 0; i < nc; i++) { vec[j][i] = input[worst][i]; @@ -307,28 +307,28 @@ fxt1_lloyd(float vec[][MAX_COMP], int nv, } } - return 0; /* could not converge fast enough */ + return 0; // Could not converge fast enough } static void fxt1_quantize_CHROMA(dword *cc, byte input[N_TEXELS][MAX_COMP]) { - const int n_vect = 4; /* 4 base vectors to find */ - const int n_comp = 3; /* 3 components: R, G, B */ + const int n_vect = 4; // 4 base vectors to find + const int n_comp = 3; // 3 components: R, G, B float vec[MAX_VECT][MAX_COMP]; int i, j, k; - qword hi; /* high quadword */ - dword lohi, lolo; /* low quadword: hi dword, lo dword */ + qword hi; // High quadword + dword lohi, lolo; // Low quadword: hi DWORD, lo DWORD if (fxt1_choose(vec, n_vect, input, n_comp, N_TEXELS) != 0) { fxt1_lloyd(vec, n_vect, input, n_comp, N_TEXELS); } - Q_MOV32(hi, 4); /* cc-chroma = "010" + unused bit */ + Q_MOV32(hi, 4); // cc-chroma = "010" + unused bit for (j = n_vect - 1; j >= 0; j--) { for (i = 0; i < n_comp; i++) { - /* add in colors */ + // Add in colors Q_SHL(hi, 5); Q_OR32(hi, (dword)(vec[j][i] / 8.0F)); } @@ -336,12 +336,12 @@ fxt1_quantize_CHROMA(dword *cc, ((qword *)cc)[1] = hi; lohi = lolo = 0; - /* right microtile */ + // Right microtile for (k = N_TEXELS - 1; k >= N_TEXELS / 2; k--) { lohi <<= 2; lohi |= fxt1_bestcol(vec, n_vect, input[k], n_comp); } - /* left microtile */ + // Left microtile for (; k >= 0; k--) { lolo <<= 2; lolo |= fxt1_bestcol(vec, n_vect, input[k], n_comp); @@ -355,32 +355,32 @@ fxt1_quantize_ALPHA0(dword *cc, byte input[N_TEXELS][MAX_COMP], byte reord[N_TEXELS][MAX_COMP], int n) { - const int n_vect = 3; /* 3 base vectors to find */ - const int n_comp = 4; /* 4 components: R, G, B, A */ + const int n_vect = 3; // 3 base vectors to find + const int n_comp = 4; // 4 components: R, G, B, A float vec[MAX_VECT][MAX_COMP]; int i, j, k; - qword hi; /* high quadword */ - dword lohi, lolo; /* low quadword: hi dword, lo dword */ + qword hi; // High quadword + dword lohi, lolo; // Low quadword: hi DWORD, lo DWORD - /* the last vector indicates zero */ + // The last vector indicates zero for (i = 0; i < n_comp; i++) { vec[n_vect][i] = 0; } - /* the first n texels in reord are guaranteed to be non-zero */ + // The first N texels in reord are guaranteed to be non-zero if (fxt1_choose(vec, n_vect, reord, n_comp, n) != 0) { fxt1_lloyd(vec, n_vect, reord, n_comp, n); } - Q_MOV32(hi, 6); /* alpha = "011" + lerp = 0 */ + Q_MOV32(hi, 6); // Alpha = "011" + lerp = 0 for (j = n_vect - 1; j >= 0; j--) { - /* add in alphas */ + // Add in alphas Q_SHL(hi, 5); Q_OR32(hi, (dword)(vec[j][ACOMP] / 8.0F)); } for (j = n_vect - 1; j >= 0; j--) { for (i = 0; i < n_comp - 1; i++) { - /* add in colors */ + // Add in colors Q_SHL(hi, 5); Q_OR32(hi, (dword)(vec[j][i] / 8.0F)); } @@ -388,12 +388,12 @@ fxt1_quantize_ALPHA0(dword *cc, ((qword *)cc)[1] = hi; lohi = lolo = 0; - /* right microtile */ + // Right microtile for (k = N_TEXELS - 1; k >= N_TEXELS / 2; k--) { lohi <<= 2; lohi |= fxt1_bestcol(vec, n_vect + 1, input[k], n_comp); } - /* left microtile */ + // Left microtile for (; k >= 0; k--) { lolo <<= 2; lolo |= fxt1_bestcol(vec, n_vect + 1, input[k], n_comp); @@ -406,13 +406,13 @@ static void fxt1_quantize_ALPHA1(dword *cc, byte input[N_TEXELS][MAX_COMP]) { - const int n_vect = 3; /* highest vector number in each microtile */ - const int n_comp = 4; /* 4 components: R, G, B, A */ - float vec[1 + 1 + 1][MAX_COMP]; /* 1.5 extrema for each sub-block */ - float b, iv[MAX_COMP]; /* interpolation vector */ + const int n_vect = 3; // Highest vector number in each microtile + const int n_comp = 4; // 4 components: R, G, B, A + float vec[1 + 1 + 1][MAX_COMP]; // 1.5 extrema for each sub-block + float b, iv[MAX_COMP]; // Interpolation vector int i, j, k; - qword hi; /* high quadword */ - dword lohi, lolo; /* low quadword: hi dword, lo dword */ + qword hi; // High quadword + dword lohi, lolo; // Low quadword: hi DWORD, lo DWORD int minSum; int maxSum; @@ -420,16 +420,18 @@ fxt1_quantize_ALPHA1(dword *cc, int minColR = 0, maxColR = 0; int sumL = 0, sumR = 0; - /* Our solution here is to find the darkest and brightest colors in - * the 4x4 tile and use those as the two representative colors. - * There are probably better algorithms to use (histogram-based). - */ + /* + TODO: Our solution here is to find the darkest and brightest colors in + the 4x4 tile and use those as the two representative colors. + There are probably better algorithms to use (histogram-based). + */ + #ifndef YUV - minSum = 2000; /* big enough */ + minSum = 2000; // Big enough #else minSum = 2000000; #endif - maxSum = -1; /* small enough */ + maxSum = -1; // Small enough for (k = 0; k < N_TEXELS / 2; k++) { int sum = 0; #ifndef YUV @@ -450,11 +452,11 @@ fxt1_quantize_ALPHA1(dword *cc, sumL += sum; } #ifndef YUV - minSum = 2000; /* big enough */ + minSum = 2000; // Big enough #else minSum = 2000000; #endif - maxSum = -1; /* small enough */ + maxSum = -1; // Small enough for (; k < N_TEXELS; k++) { int sum = 0; #ifndef YUV @@ -475,12 +477,12 @@ fxt1_quantize_ALPHA1(dword *cc, sumR += sum; } - /* choose the common vector (yuck!) */ + // Choose the common vector { int j1, j2; int v1 = 0, v2 = 0; - float err = 1e9; /* big enough */ - float tv[2 * 2][MAX_COMP]; /* 2 extrema for each sub-block */ + float err = 1e9; // Big enough + float tv[2 * 2][MAX_COMP]; // 2 extrema for each sub-block for (i = 0; i < n_comp; i++) { tv[0][i] = input[minColL][i]; tv[1][i] = input[maxColL][i]; @@ -507,19 +509,19 @@ fxt1_quantize_ALPHA1(dword *cc, } } - /* left microtile */ + // Left microtile cc[0] = 0; if (minColL != maxColL) { - /* compute interpolation vector */ + // Compute interpolation vector MAKEIVEC(n_vect, n_comp, iv, b, vec[0], vec[1]); - /* add in texels */ + // Add in texels lolo = 0; for (k = N_TEXELS / 2 - 1; k >= 0; k--) { int texel; - /* interpolate color */ + // Interpolate color CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); - /* add in texel */ + // Add in texel lolo <<= 2; lolo |= texel; } @@ -527,19 +529,19 @@ fxt1_quantize_ALPHA1(dword *cc, cc[0] = lolo; } - /* right microtile */ + // Right microtile cc[1] = 0; if (minColR != maxColR) { - /* compute interpolation vector */ + // Compute interpolation vector MAKEIVEC(n_vect, n_comp, iv, b, vec[2], vec[1]); - /* add in texels */ + // Add in texels lohi = 0; for (k = N_TEXELS - 1; k >= N_TEXELS / 2; k--) { int texel; - /* interpolate color */ + // Interpolate color CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); - /* add in texel */ + // Add in texel lohi <<= 2; lohi |= texel; } @@ -547,15 +549,15 @@ fxt1_quantize_ALPHA1(dword *cc, cc[1] = lohi; } - Q_MOV32(hi, 7); /* alpha = "011" + lerp = 1 */ + Q_MOV32(hi, 7); // Alpha = "011" + lerp = 1 for (j = n_vect - 1; j >= 0; j--) { - /* add in alphas */ + // Add in alphas Q_SHL(hi, 5); Q_OR32(hi, (dword)(vec[j][ACOMP] / 8.0F)); } for (j = n_vect - 1; j >= 0; j--) { for (i = 0; i < n_comp - 1; i++) { - /* add in colors */ + // Add in colors Q_SHL(hi, 5); Q_OR32(hi, (dword)(vec[j][i] / 8.0F)); } @@ -568,26 +570,28 @@ fxt1_quantize_HI(dword *cc, byte input[N_TEXELS][MAX_COMP], byte reord[N_TEXELS][MAX_COMP], int n) { - const int n_vect = 6; /* highest vector number */ - const int n_comp = 3; /* 3 components: R, G, B */ - float b = 0.0F; /* phoudoin: silent compiler! */ - float iv[MAX_COMP]; /* interpolation vector */ + const int n_vect = 6; // Highest vector number + const int n_comp = 3; // 3 components: R, G, B + float b = 0.0F; // phoudoin: Silent compiler! + float iv[MAX_COMP]; // Interpolation vector int i, k; - dword hihi; /* high quadword: hi dword */ + dword hihi; // High quadword: hi DWORD #ifndef YUV - int minSum = 2000; /* big enough */ + int minSum = 2000; // Big enough #else int minSum = 2000000; #endif - int maxSum = -1; /* small enough */ - int minCol = 0; /* phoudoin: silent compiler! */ - int maxCol = 0; /* phoudoin: silent compiler! */ + int maxSum = -1; // Small enough + int minCol = 0; // phoudoin: Silent compiler! + int maxCol = 0; // phoudoin: Silent compiler! - /* Our solution here is to find the darkest and brightest colors in - * the 8x4 tile and use those as the two representative colors. - * There are probably better algorithms to use (histogram-based). - */ + /* + Our solution here is to find the darkest and brightest colors in + the 8x4 tile and use those as the two representative colors. + There are probably better algorithms to use (histogram-based). + */ + for (k = 0; k < n; k++) { int sum = 0; #ifndef YUV @@ -607,41 +611,41 @@ fxt1_quantize_HI(dword *cc, } } - hihi = 0; /* cc-hi = "00" */ + hihi = 0; // cc-hi = "00" for (i = 0; i < n_comp; i++) { - /* add in colors */ + // Add in colors hihi <<= 5; hihi |= reord[maxCol][i] >> 3; } for (i = 0; i < n_comp; i++) { - /* add in colors */ + // Add in colors hihi <<= 5; hihi |= reord[minCol][i] >> 3; } cc[3] = hihi; cc[0] = cc[1] = cc[2] = 0; - /* compute interpolation vector */ + // Compute interpolation vector if (minCol != maxCol) { MAKEIVEC(n_vect, n_comp, iv, b, reord[minCol], reord[maxCol]); } - /* add in texels */ + // Add in texels for (k = N_TEXELS - 1; k >= 0; k--) { int t = k * 3; dword *kk = (dword *)((byte *)cc + t / 8); - int texel = n_vect + 1; /* transparent black */ + int texel = n_vect + 1; // Transparent black if (!ISTBLACK(input[k])) { if (minCol != maxCol) { - /* interpolate color */ + // Interpolate color CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); - /* add in texel */ + // Add in texel kk[0] |= texel << (t & 7); } } else { - /* add in texel */ + // Add in texel kk[0] |= texel << (t & 7); } } @@ -651,29 +655,31 @@ static void fxt1_quantize_MIXED1(dword *cc, byte input[N_TEXELS][MAX_COMP]) { - const int n_vect = 2; /* highest vector number in each microtile */ - const int n_comp = 3; /* 3 components: R, G, B */ - byte vec[2 * 2][MAX_COMP]; /* 2 extrema for each sub-block */ - float b, iv[MAX_COMP]; /* interpolation vector */ + const int n_vect = 2; // Highest vector number in each microtile + const int n_comp = 3; // 3 components: R, G, B + byte vec[2 * 2][MAX_COMP]; // 2 extrema for each sub-block + float b, iv[MAX_COMP]; // Interpolation vector int i, j, k; - qword hi; /* high quadword */ - dword lohi, lolo; /* low quadword: hi dword, lo dword */ + qword hi; // High quadword + dword lohi, lolo; // Low quadword: hi DWORD, lo DWORD int minSum; int maxSum; int minColL = 0, maxColL = -1; int minColR = 0, maxColR = -1; - /* Our solution here is to find the darkest and brightest colors in - * the 4x4 tile and use those as the two representative colors. - * There are probably better algorithms to use (histogram-based). - */ + /* + Our solution here is to find the darkest and brightest colors in + the 4x4 tile and use those as the two representative colors. + There are probably better algorithms to use (histogram-based). + */ + #ifndef YUV - minSum = 2000; /* big enough */ + minSum = 2000; // Big enough #else minSum = 2000000; #endif - maxSum = -1; /* small enough */ + maxSum = -1; // Small enough for (k = 0; k < N_TEXELS / 2; k++) { if (!ISTBLACK(input[k])) { int sum = 0; @@ -695,11 +701,11 @@ fxt1_quantize_MIXED1(dword *cc, } } #ifndef YUV - minSum = 2000; /* big enough */ + minSum = 2000; // Big enough #else minSum = 2000000; #endif - maxSum = -1; /* small enough */ + maxSum = -1; // Small enough for (; k < N_TEXELS; k++) { if (!ISTBLACK(input[k])) { int sum = 0; @@ -721,9 +727,9 @@ fxt1_quantize_MIXED1(dword *cc, } } - /* left microtile */ + // Left microtile if (maxColL == -1) { - /* all transparent black */ + // All transparent black cc[0] = 0xFFFFFFFFUL; for (i = 0; i < n_comp; i++) { vec[0][i] = 0; @@ -737,18 +743,18 @@ fxt1_quantize_MIXED1(dword *cc, vec[1][i] = input[maxColL][i]; } if (minColL != maxColL) { - /* compute interpolation vector */ + // Compute interpolation vector MAKEIVEC(n_vect, n_comp, iv, b, vec[0], vec[1]); - /* add in texels */ + // Add in texels lolo = 0; for (k = N_TEXELS / 2 - 1; k >= 0; k--) { - int texel = n_vect + 1; /* transparent black */ + int texel = n_vect + 1; // Transparent black if (!ISTBLACK(input[k])) { - /* interpolate color */ + // Interpolate color CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); } - /* add in texel */ + // Add in texel lolo <<= 2; lolo |= texel; } @@ -756,9 +762,9 @@ fxt1_quantize_MIXED1(dword *cc, } } - /* right microtile */ + // Right microtile if (maxColR == -1) { - /* all transparent black */ + // All transparent black cc[1] = 0xFFFFFFFFUL; for (i = 0; i < n_comp; i++) { vec[2][i] = 0; @@ -772,18 +778,18 @@ fxt1_quantize_MIXED1(dword *cc, vec[3][i] = input[maxColR][i]; } if (minColR != maxColR) { - /* compute interpolation vector */ + // Compute interpolation vector MAKEIVEC(n_vect, n_comp, iv, b, vec[2], vec[3]); - /* add in texels */ + // Add in texels lohi = 0; for (k = N_TEXELS - 1; k >= N_TEXELS / 2; k--) { - int texel = n_vect + 1; /* transparent black */ + int texel = n_vect + 1; // Transparent black if (!ISTBLACK(input[k])) { - /* interpolate color */ + // Interpolate color CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); } - /* add in texel */ + // Add in texel lohi <<= 2; lohi |= texel; } @@ -791,10 +797,10 @@ fxt1_quantize_MIXED1(dword *cc, } } - Q_MOV32(hi, 9 | (vec[3][GCOMP] & 4) | ((vec[1][GCOMP] >> 1) & 2)); /* chroma = "1" */ + Q_MOV32(hi, 9 | (vec[3][GCOMP] & 4) | ((vec[1][GCOMP] >> 1) & 2)); // Chroma = "1" for (j = 2 * 2 - 1; j >= 0; j--) { for (i = 0; i < n_comp; i++) { - /* add in colors */ + // Add in colors Q_SHL(hi, 5); Q_OR32(hi, vec[j][i] >> 3); } @@ -806,13 +812,13 @@ static void fxt1_quantize_MIXED0(dword *cc, byte input[N_TEXELS][MAX_COMP]) { - const int n_vect = 3; /* highest vector number in each microtile */ - const int n_comp = 3; /* 3 components: R, G, B */ - byte vec[2 * 2][MAX_COMP]; /* 2 extrema for each sub-block */ - float b, iv[MAX_COMP]; /* interpolation vector */ + const int n_vect = 3; // Highest vector number in each microtile + const int n_comp = 3; // 3 components: R, G, B + byte vec[2 * 2][MAX_COMP]; // 2 extrema for each sub-block + float b, iv[MAX_COMP]; // Interpolation vector int i, j, k; - qword hi; /* high quadword */ - dword lohi, lolo; /* low quadword: hi dword, lo dword */ + qword hi; // High quadword + dword lohi, lolo; // Low quadword: hi DWORD, lo DWORD int minColL = 0, maxColL = 0; int minColR = 0, maxColR = 0; @@ -820,16 +826,18 @@ fxt1_quantize_MIXED0(dword *cc, int minSum; int maxSum; - /* Our solution here is to find the darkest and brightest colors in - * the 4x4 tile and use those as the two representative colors. - * There are probably better algorithms to use (histogram-based). - */ + /* + Our solution here is to find the darkest and brightest colors in + the 4x4 tile and use those as the two representative colors. + There are probably better algorithms to use (histogram-based). + */ + #ifndef YUV - minSum = 2000; /* big enough */ + minSum = 2000; // Big enough #else minSum = 2000000; #endif - maxSum = -1; /* small enough */ + maxSum = -1; // Small enough for (k = 0; k < N_TEXELS / 2; k++) { int sum = 0; #ifndef YUV @@ -848,8 +856,8 @@ fxt1_quantize_MIXED0(dword *cc, maxColL = k; } } - minSum = 2000; /* big enough */ - maxSum = -1; /* small enough */ + minSum = 2000; // Big enough + maxSum = -1; // Small enough for (; k < N_TEXELS; k++) { int sum = 0; #ifndef YUV @@ -874,11 +882,13 @@ fxt1_quantize_MIXED0(dword *cc, int maxVarL = fxt1_variance(NULL, input, n_comp, N_TEXELS / 2); int maxVarR = fxt1_variance(NULL, &input[N_TEXELS / 2], n_comp, N_TEXELS / 2); - /* Scan the channel with max variance for lo & hi - * and use those as the two representative colors. - */ - minVal = 2000; /* big enough */ - maxVal = -1; /* small enough */ + /* + Scan the channel with max variance for lo and hi + and use those as the two representative colors. + */ + + minVal = 2000; // Big enough + maxVal = -1; // Small enough for (k = 0; k < N_TEXELS / 2; k++) { int t = input[k][maxVarL]; if (minVal > t) { @@ -890,8 +900,8 @@ fxt1_quantize_MIXED0(dword *cc, maxColL = k; } } - minVal = 2000; /* big enough */ - maxVal = -1; /* small enough */ + minVal = 2000; // Big enough + maxVal = -1; // Small enough for (; k < N_TEXELS; k++) { int t = input[k][maxVarR]; if (minVal > t) { @@ -905,28 +915,28 @@ fxt1_quantize_MIXED0(dword *cc, } #endif - /* left microtile */ + // Left microtile cc[0] = 0; for (i = 0; i < n_comp; i++) { vec[0][i] = input[minColL][i]; vec[1][i] = input[maxColL][i]; } if (minColL != maxColL) { - /* compute interpolation vector */ + // Compute interpolation vector MAKEIVEC(n_vect, n_comp, iv, b, vec[0], vec[1]); - /* add in texels */ + // Add in texels lolo = 0; for (k = N_TEXELS / 2 - 1; k >= 0; k--) { int texel; - /* interpolate color */ + // Interpolate color CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); - /* add in texel */ + // Add in texel lolo <<= 2; lolo |= texel; } - /* funky encoding for LSB of green */ + // Funky encoding for LSB of green if ((int)((lolo >> 1) & 1) != (((vec[1][GCOMP] ^ vec[0][GCOMP]) >> 2) & 1)) { for (i = 0; i < n_comp; i++) { vec[1][i] = input[minColL][i]; @@ -938,28 +948,28 @@ fxt1_quantize_MIXED0(dword *cc, cc[0] = lolo; } - /* right microtile */ + // Right microtile cc[1] = 0; for (i = 0; i < n_comp; i++) { vec[2][i] = input[minColR][i]; vec[3][i] = input[maxColR][i]; } if (minColR != maxColR) { - /* compute interpolation vector */ + // Compute interpolation vector MAKEIVEC(n_vect, n_comp, iv, b, vec[2], vec[3]); - /* add in texels */ + // Add in texels lohi = 0; for (k = N_TEXELS - 1; k >= N_TEXELS / 2; k--) { int texel; - /* interpolate color */ + // Interpolate color CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); - /* add in texel */ + // Add in texel lohi <<= 2; lohi |= texel; } - /* funky encoding for LSB of green */ + // Funky encoding for LSB of green if ((int)((lohi >> 1) & 1) != (((vec[3][GCOMP] ^ vec[2][GCOMP]) >> 2) & 1)) { for (i = 0; i < n_comp; i++) { vec[3][i] = input[minColR][i]; @@ -971,10 +981,10 @@ fxt1_quantize_MIXED0(dword *cc, cc[1] = lohi; } - Q_MOV32(hi, 8 | (vec[3][GCOMP] & 4) | ((vec[1][GCOMP] >> 1) & 2)); /* chroma = "1" */ + Q_MOV32(hi, 8 | (vec[3][GCOMP] & 4) | ((vec[1][GCOMP] >> 1) & 2)); // Chroma = "1" for (j = 2 * 2 - 1; j >= 0; j--) { for (i = 0; i < n_comp; i++) { - /* add in colors */ + // Add in colors Q_SHL(hi, 5); Q_OR32(hi, vec[j][i] >> 3); } @@ -995,11 +1005,11 @@ fxt1_quantize(dword *cc, const byte *lines[], int comps) int k, l; if (comps == 3) { - /* make the whole block opaque */ + // Make the whole block opaque memset(input, -1, sizeof(input)); } - /* 8 texels each line */ + // 8 texels each line #ifndef ARGB for (l = 0; l < 4; l++) { for (k = 0; k < 4; k++) { @@ -1014,7 +1024,7 @@ fxt1_quantize(dword *cc, const byte *lines[], int comps) } } #else - /* H.Morii - support for ARGB inputs */ + // H.Morii - support for ARGB inputs for (l = 0; l < 4; l++) { for (k = 0; k < 4; k++) { input[k + l * 4][2] = *lines[l]++; @@ -1031,28 +1041,29 @@ fxt1_quantize(dword *cc, const byte *lines[], int comps) } #endif - /* block layout: - * 00, 01, 02, 03, 08, 09, 0a, 0b - * 10, 11, 12, 13, 18, 19, 1a, 1b - * 04, 05, 06, 07, 0c, 0d, 0e, 0f - * 14, 15, 16, 17, 1c, 1d, 1e, 1f - */ + /* Block layout: + 00, 01, 02, 03, 08, 09, 0a, 0b + 10, 11, 12, 13, 18, 19, 1a, 1b + 04, 05, 06, 07, 0c, 0d, 0e, 0f + 14, 15, 16, 17, 1c, 1d, 1e, 1f + */ - /* [dBorca] - * stupidity flows forth from this - */ + /* [dBorca] + Stupidity flows forth from this + */ + l = N_TEXELS; trualpha = 0; if (comps == 4) { - /* skip all transparent black texels */ + // Skip all transparent black texels l = 0; for (k = 0; k < N_TEXELS; k++) { - /* test all components against 0 */ + // Test all components against 0 if (!ISTBLACK(input[k])) { - /* texel is not transparent black */ + // Texel is not transparent black COPY_4UBV(reord[l], input[k]); if (reord[l][ACOMP] < (255 - ALPHA_TS)) { - /* non-opaque texel */ + // Non-opaque texel trualpha = !0; } l++; @@ -1107,7 +1118,7 @@ fxt1_encode(int width, int height, int comps, dword *encoded = (dword *)dest; void *newSource = NULL; - /* Replicate image if width is not M8 or height is not M4 */ + // Replicate image if width is not M8 or height is not M4 if ((width & 7) | (height & 3)) { int newWidth = (width + 7) & ~7; int newHeight = (height + 3) & ~3; @@ -1133,7 +1144,7 @@ fxt1_encode(int width, int height, int comps, lines[3] = lines[2] + srcRowStride; offs += 8 * comps; fxt1_quantize(encoded, lines, comps); - /* 128 bits per 8x4 block */ + // 128 bits per 8x4 block encoded += 4; } encoded += destRowStride; @@ -1146,14 +1157,13 @@ fxt1_encode(int width, int height, int comps, return 0; } -/***************************************************************************\ - * FXT1 decoder - * - * The decoder is based on GL_3DFX_texture_compression_FXT1 - * specification and serves as a concept for the encoder. -\***************************************************************************/ +/* +FXT1 decoder +The decoder is based on GL_3DFX_texture_compression_FXT1 +specification and serves as a concept for the encoder. +*/ -/* lookup table for scaling 5 bit colors up to 8 bits */ +// Lookup table for scaling 5-bit color up to 8-bit color static const byte _rgb_scale_5[] = { 0, 8, 16, 25, 33, 41, 49, 58, 66, 74, 82, 90, 99, 107, 115, 123, @@ -1161,7 +1171,7 @@ static const byte _rgb_scale_5[] = { 197, 206, 214, 222, 230, 239, 247, 255 }; -/* lookup table for scaling 6 bit colors up to 8 bits */ +// Lookup table for scaling 6-bit color up to 8-bit color static const byte _rgb_scale_6[] = { 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 45, 49, 53, 57, 61, @@ -1245,11 +1255,11 @@ fxt1_decode_1MIXED(const byte *code, int t, byte *rgba) if (t & 16) { t &= 15; t = (cc[1] >> (t * 2)) & 3; - /* col 2 */ + // Col 2 col[0][BCOMP] = (*(const dword *)(code + 11)) >> 6; col[0][GCOMP] = CC_SEL(cc, 99); col[0][RCOMP] = CC_SEL(cc, 104); - /* col 3 */ + // Col 3 col[1][BCOMP] = CC_SEL(cc, 109); col[1][GCOMP] = CC_SEL(cc, 114); col[1][RCOMP] = CC_SEL(cc, 119); @@ -1258,11 +1268,11 @@ fxt1_decode_1MIXED(const byte *code, int t, byte *rgba) } else { t = (cc[0] >> (t * 2)) & 3; - /* col 0 */ + // Col 0 col[0][BCOMP] = CC_SEL(cc, 64); col[0][GCOMP] = CC_SEL(cc, 69); col[0][RCOMP] = CC_SEL(cc, 74); - /* col 1 */ + // Col 1 col[1][BCOMP] = CC_SEL(cc, 79); col[1][GCOMP] = CC_SEL(cc, 84); col[1][RCOMP] = CC_SEL(cc, 89); @@ -1271,7 +1281,7 @@ fxt1_decode_1MIXED(const byte *code, int t, byte *rgba) } if (CC_SEL(cc, 124) & 1) { - /* alpha[0] == 1 */ + // alpha[0] == 1 if (t == 3) { ZERO_4UBV(rgba); @@ -1296,7 +1306,7 @@ fxt1_decode_1MIXED(const byte *code, int t, byte *rgba) } } else { - /* alpha[0] == 0 */ + // alpha[0] == 0 if (t == 0) { rgba[BCOMP] = UP5(col[0][BCOMP]); @@ -1325,13 +1335,13 @@ fxt1_decode_1ALPHA(const byte *code, int t, byte *rgba) cc = (const dword *)code; if (CC_SEL(cc, 124) & 1) { - /* lerp == 1 */ + // lerp == 1 int col0[4]; if (t & 16) { t &= 15; t = (cc[1] >> (t * 2)) & 3; - /* col 2 */ + // Col 2 col0[BCOMP] = (*(const dword *)(code + 11)) >> 6; col0[GCOMP] = CC_SEL(cc, 99); col0[RCOMP] = CC_SEL(cc, 104); @@ -1339,7 +1349,7 @@ fxt1_decode_1ALPHA(const byte *code, int t, byte *rgba) } else { t = (cc[0] >> (t * 2)) & 3; - /* col 0 */ + // Col 0 col0[BCOMP] = CC_SEL(cc, 64); col0[GCOMP] = CC_SEL(cc, 69); col0[RCOMP] = CC_SEL(cc, 74); @@ -1366,7 +1376,7 @@ fxt1_decode_1ALPHA(const byte *code, int t, byte *rgba) } } else { - /* lerp == 0 */ + // lerp == 0 if (t & 16) { cc++; @@ -1396,14 +1406,14 @@ fxt1_decode_1(const void *texture, int stride, int i, int j, byte *rgba) { static void(*decode_1[]) (const byte *, int, byte *) = { - fxt1_decode_1HI, /* cc-high = "00?" */ - fxt1_decode_1HI, /* cc-high = "00?" */ - fxt1_decode_1CHROMA, /* cc-chroma = "010" */ - fxt1_decode_1ALPHA, /* alpha = "011" */ - fxt1_decode_1MIXED, /* mixed = "1??" */ - fxt1_decode_1MIXED, /* mixed = "1??" */ - fxt1_decode_1MIXED, /* mixed = "1??" */ - fxt1_decode_1MIXED /* mixed = "1??" */ + fxt1_decode_1HI, // cc-high = "00?" + fxt1_decode_1HI, // cc-high = "00?" + fxt1_decode_1CHROMA, // cc-chroma = "010" + fxt1_decode_1ALPHA, // alpha = "011" + fxt1_decode_1MIXED, // mixed = "1??" + fxt1_decode_1MIXED, // mixed = "1??" + fxt1_decode_1MIXED, // mixed = "1??" + fxt1_decode_1MIXED // mixed = "1??" }; const byte *code = (const byte *)texture + @@ -1437,4 +1447,4 @@ fxt1_decode_1(const void *texture, int stride, (*cctype[mode])++; } #endif -} \ No newline at end of file +} diff --git a/Source/Project64-video/TextureEnhancer/tc-1.1+/fxt1.h b/Source/Project64-video/TextureEnhancer/tc-1.1+/fxt1.h index 72426ec22..b67cd4a5e 100644 --- a/Source/Project64-video/TextureEnhancer/tc-1.1+/fxt1.h +++ b/Source/Project64-video/TextureEnhancer/tc-1.1+/fxt1.h @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2004 Daniel Borca diff --git a/Source/Project64-video/TextureEnhancer/tc-1.1+/internal.h b/Source/Project64-video/TextureEnhancer/tc-1.1+/internal.h index 92998b370..9f8b238c3 100644 --- a/Source/Project64-video/TextureEnhancer/tc-1.1+/internal.h +++ b/Source/Project64-video/TextureEnhancer/tc-1.1+/internal.h @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2004 Daniel Borca @@ -8,23 +8,18 @@ #ifndef INTERNAL_H_included #define INTERNAL_H_included -/*****************************************************************************\ -* Texture compression stuff -\*****************************************************************************/ +// Texture compression stuff + #define RADEON #define YUV #define ARGB -/*****************************************************************************\ - * DLL stuff -\*****************************************************************************/ +// DLL stuff #define TAPI #define TAPIENTRY -/*****************************************************************************\ - * 64bit types on 32bit machine -\*****************************************************************************/ +// 64-bit types on 32-bit machine #if (defined(__GNUC__) && !defined(__cplusplus)) || defined(WIN32) @@ -55,25 +50,21 @@ typedef struct { #endif /* !__GNUC__ */ -/*****************************************************************************\ - * Config -\*****************************************************************************/ +// Config #define RCOMP 0 #define GCOMP 1 #define BCOMP 2 #define ACOMP 3 -/*****************************************************************************\ - * Metric -\*****************************************************************************/ +// Metric -#define F(i) (float)1 /* can be used to obtain an oblong metric: 0.30 / 0.59 / 0.11 */ -#define SAFECDOT 1 /* for paranoids */ +#define F(i) (float)1 // Can be used to obtain an oblong metric: 0.30 / 0.59 / 0.11 +#define SAFECDOT 1 // For paranoids +// compute interpolation vector #define MAKEIVEC(NV, NC, IV, B, V0, V1) \ do { \ - /* compute interpolation vector */\ float d2 = 0.0F; \ float rd2; \ \ @@ -107,9 +98,7 @@ typedef struct { } \ } while (0) -/*****************************************************************************\ - * Utility functions -\*****************************************************************************/ +// Utility functions void _mesa_upscale_teximage2d(unsigned int inWidth, unsigned int inHeight, diff --git a/Source/Project64-video/TextureEnhancer/tc-1.1+/texstore.c b/Source/Project64-video/TextureEnhancer/tc-1.1+/texstore.c index e0cf83a9b..fdcfde239 100644 --- a/Source/Project64-video/TextureEnhancer/tc-1.1+/texstore.c +++ b/Source/Project64-video/TextureEnhancer/tc-1.1+/texstore.c @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2004 Daniel Borca @@ -68,4 +68,4 @@ _mesa_upscale_teximage2d(unsigned int inWidth, unsigned int inHeight, } } #endif -} \ No newline at end of file +} diff --git a/Source/Project64-video/TextureEnhancer/tc-1.1+/types.h b/Source/Project64-video/TextureEnhancer/tc-1.1+/types.h index 639ac3e2c..9fea91825 100644 --- a/Source/Project64-video/TextureEnhancer/tc-1.1+/types.h +++ b/Source/Project64-video/TextureEnhancer/tc-1.1+/types.h @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2004 Daniel Borca @@ -8,11 +8,10 @@ #ifndef TYPES_H_included #define TYPES_H_included -/*****************************************************************************\ - * 32bit types -\*****************************************************************************/ -typedef unsigned char byte; /* 8-bit */ -typedef unsigned short word; /* 16-bit */ -typedef unsigned int dword; /* 32-bit */ +// 32-bit types + +typedef unsigned char byte; // 8-bit +typedef unsigned short word; // 16-bit +typedef unsigned int dword; // 32-bit #endif diff --git a/Source/Project64-video/TextureEnhancer/tc-1.1+/wrapper.c b/Source/Project64-video/TextureEnhancer/tc-1.1+/wrapper.c index 29ca7e31e..5211dc02c 100644 --- a/Source/Project64-video/TextureEnhancer/tc-1.1+/wrapper.c +++ b/Source/Project64-video/TextureEnhancer/tc-1.1+/wrapper.c @@ -1,5 +1,5 @@ // Project64 - A Nintendo 64 emulator -// http://www.pj64-emu.com/ +// https://www.pj64-emu.com/ // Copyright(C) 2001-2021 Project64 // Copyright(C) 2007 Hiroshi Morii // Copyright(C) 2004 Daniel Borca @@ -85,5 +85,5 @@ tx_compress_dxtn(int srccomps, int width, int height, assert(0); } - /*return rv;*/ -} \ No newline at end of file + //return rv; +} diff --git a/Source/Project64/Plugins/PluginList.cpp b/Source/Project64/Plugins/PluginList.cpp index 807b31ecb..b6d8b1bc7 100644 --- a/Source/Project64/Plugins/PluginList.cpp +++ b/Source/Project64/Plugins/PluginList.cpp @@ -64,14 +64,14 @@ void CPluginList::AddPluginFromDir(CPath Dir) } //UINT LastErrorMode = SetErrorMode( SEM_FAILCRITICALERRORS ); - WriteTrace(TraceUserInterface, TraceDebug, "loading %s", (LPCSTR)Dir); + WriteTrace(TraceUserInterface, TraceDebug, "Loading %s", (LPCSTR)Dir); hLib = LoadLibrary(stdstr((LPCSTR)Dir).ToUTF16().c_str()); //SetErrorMode(LastErrorMode); if (hLib == nullptr) { DWORD LoadError = GetLastError(); - WriteTrace(TraceUserInterface, TraceDebug, "failed to load %s (error: %d)", (LPCSTR)Dir, LoadError); + WriteTrace(TraceUserInterface, TraceDebug, "Failed to load %s (error: %d)", (LPCSTR)Dir, LoadError); continue; } diff --git a/Source/Project64/UserInterface/API.js b/Source/Project64/UserInterface/API.js index 6cb51a5a9..463c7a996 100644 --- a/Source/Project64/UserInterface/API.js +++ b/Source/Project64/UserInterface/API.js @@ -969,7 +969,7 @@ function Server(settings) if (_native.sockListen(_fd, port || 80)) { _listening = true; } else { - throw new Error("failed to listen"); + throw new Error("Failed to listen"); } if (_queued_accept) { diff --git a/Source/Project64/UserInterface/About.cpp b/Source/Project64/UserInterface/About.cpp index 0b238ce61..184aabb5c 100644 --- a/Source/Project64/UserInterface/About.cpp +++ b/Source/Project64/UserInterface/About.cpp @@ -33,7 +33,7 @@ LRESULT CAboutDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lPara SetWindowDetais(IDC_THANKS_CORE, IDC_ABOUT_PROJECT, L"Special thanks to previous core members:", m_BoldFont); SetWindowDetais(IDC_CORE_THANK_LIST, IDC_THANKS_CORE, L"Jabo, Smiff, Gent", m_TextFont); SetWindowDetais(IDC_THANKYOU, IDC_CORE_THANK_LIST, L"Thanks also goes to:", m_BoldFont); - SetWindowDetais(IDC_THANKYOU_LIST, IDC_THANKYOU, L"Jahra!n, Witten, RadeonUser, Azimer, Shygoo, Frank, LuigiBlood, theboy181, Gonetz, BlueToonYoshi, Kimbjo, Melchior, retroben, AIO, krom", m_TextFont); + SetWindowDetais(IDC_THANKYOU_LIST, IDC_THANKYOU, L"Jahra!n, Witten, RadeonUser, Azimer, Shygoo, Frank, LuigiBlood, theboy181, Gonetz, BlueToonYoshi, Kimbjo, Melchior, retroben, AIO, and krom", m_TextFont); return TRUE; } diff --git a/Source/Project64/UserInterface/Debugger/Assembler.cpp b/Source/Project64/UserInterface/Debugger/Assembler.cpp index 4fa761576..c4b73de9e 100644 --- a/Source/Project64/UserInterface/Debugger/Assembler.cpp +++ b/Source/Project64/UserInterface/Debugger/Assembler.cpp @@ -432,7 +432,7 @@ uint32_t CAssembler::pop_val() //if (isalpha(*v)) //{ - // // todo lookup label value + // // TODO: lookup label value // return 0; //} diff --git a/Source/Project64/UserInterface/Debugger/DebugMMU.cpp b/Source/Project64/UserInterface/Debugger/DebugMMU.cpp index a5ddf2908..cbfe4b84b 100644 --- a/Source/Project64/UserInterface/Debugger/DebugMMU.cpp +++ b/Source/Project64/UserInterface/Debugger/DebugMMU.cpp @@ -29,7 +29,7 @@ uint8_t* CDebugMMU::GetPhysicalPtr(uint32_t paddr, WORD* flags) { // todo } - else if (paddr >= 0x06000000 && paddr <= 0x06FFFFFF) // Cartridge Domain 1 (Address 1) (64DD IPL ROM) + else if (paddr >= 0x06000000 && paddr <= 0x06FFFFFF) // Cartridge domain 1 (address 1) (64DD IPL ROM) { uint32_t iplRomOffset = paddr - 0x06000000; @@ -172,7 +172,7 @@ bool CDebugMMU::GetPhysicalByte(uint32_t paddr, uint8_t* value) int nByte = paddr & 3; - if (paddr >= 0x08000000 && paddr <= 0x08FFFFFF) // Cartridge Domain 2 (Address 2) + if (paddr >= 0x08000000 && paddr <= 0x08FFFFFF) // Cartridge domain 2 (address 2) { uint32_t saveOffset = paddr & 0x000FFFFF; @@ -186,7 +186,7 @@ bool CDebugMMU::GetPhysicalByte(uint32_t paddr, uint8_t* value) *value = data[nByte ^ 3]; return true; } - else if (g_System->m_SaveUsing == SaveChip_FlashRam && saveOffset <= 3) // Flash RAM status + else if (g_System->m_SaveUsing == SaveChip_FlashRam && saveOffset <= 3) // FlashRAM status { CFlashram* flashRam = g_MMU->GetFlashram(); uint32_t flashStatus = flashRam->ReadFromFlashStatus(0x08000000); @@ -246,7 +246,7 @@ bool CDebugMMU::SetPhysicalByte(uint32_t paddr, uint8_t value) int nByte = paddr & 3; - if (paddr >= 0x08000000 && paddr <= 0x08FFFFFF) // Cartridge Domain 2 (Address 2) + if (paddr >= 0x08000000 && paddr <= 0x08FFFFFF) // Cartridge domain 2 (address 2) { uint32_t saveOffset = paddr & 0x000FFFFF; diff --git a/Source/Project64/UserInterface/Debugger/Debugger-Commands.cpp b/Source/Project64/UserInterface/Debugger/Debugger-Commands.cpp index d47edd6c0..8fdf8b5b2 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-Commands.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-Commands.cpp @@ -659,7 +659,7 @@ void CDebugCommandsView::ShowAddress(uint32_t address, bool top, bool bUserInput m_CommandList.SetRedraw(TRUE); } -// Highlight command list items & draw branch arrows +// Highlight command list items and draw branch arrows LRESULT CDebugCommandsView::OnCustomDrawList(NMHDR* pNMHDR) { NMLVCUSTOMDRAW* pLVCD = reinterpret_cast(pNMHDR); @@ -703,7 +703,7 @@ LRESULT CDebugCommandsView::OnCustomDrawList(NMHDR* pNMHDR) // Breakpoint pLVCD->clrTextBk = RGB(0x44, 0x00, 0x00); pLVCD->clrText = (address == pc && isDebugging()) ? - RGB(0xFF, 0xFF, 0x00) : // Breakpoint & current PC + RGB(0xFF, 0xFF, 0x00) : // Breakpoint and current PC RGB(0xFF, 0xCC, 0xCC); } else if (bpState == CBreakpoints::BP_SET_TEMP) @@ -711,7 +711,7 @@ LRESULT CDebugCommandsView::OnCustomDrawList(NMHDR* pNMHDR) // Breakpoint pLVCD->clrTextBk = RGB(0x66, 0x44, 0x00); pLVCD->clrText = (address == pc && isDebugging()) ? - RGB(0xFF, 0xFF, 0x00) : // Breakpoint & current PC + RGB(0xFF, 0xFF, 0x00) : // Breakpoint and current PC RGB(0xFF, 0xEE, 0xCC); } else if (address == pc && isStepping()) @@ -796,7 +796,7 @@ LRESULT CDebugCommandsView::OnCustomDrawList(NMHDR* pNMHDR) } // Color register usage - // TODO: localize to temp register context (don't look before/after jumps and frame shifts) + // TODO: localize to temporary register context (don't look before/after jumps and frame shifts) COLORREF clrUsedRegister = RGB(0xF5, 0xF0, 0xFF); // Light purple COLORREF clrAffectedRegister = RGB(0xFF, 0xF0, 0xFF); // Light pink @@ -1062,7 +1062,7 @@ void CDebugCommandsView::CPUStepOver() if (opInfo.IsJAL()) { - // Put temp BP on return address and resume + // Put temp breakpoints on return address and resume m_Breakpoints->AddExecution(g_Reg->m_PROGRAM_COUNTER + 8, true); CPUResume(); } @@ -1115,7 +1115,7 @@ LRESULT CDebugCommandsView::OnSymbolsButton(WORD /*wNotifyCode*/, WORD /*wID*/, LRESULT CDebugCommandsView::OnPopupmenuRunTo(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) { - // Add temp BP and resume + // Add temp breakpoints and resume m_Breakpoints->AddExecution(m_SelectedAddress, true); return FALSE; } diff --git a/Source/Project64/UserInterface/Debugger/Debugger-RegisterTabs.cpp b/Source/Project64/UserInterface/Debugger/Debugger-RegisterTabs.cpp index 526917f75..486d76755 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-RegisterTabs.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-RegisterTabs.cpp @@ -232,7 +232,7 @@ void CRegisterTabs::RefreshEdits() m_RIEdits[1].SetValue(g_Reg->RI_CONFIG_REG, DisplayMode::ZeroExtend); m_RIEdits[2].SetValue(g_Reg->RI_CURRENT_LOAD_REG, DisplayMode::ZeroExtend); m_RIEdits[3].SetValue(g_Reg->RI_SELECT_REG, DisplayMode::ZeroExtend); - m_RIEdits[4].SetValue(g_Reg->RI_REFRESH_REG, DisplayMode::ZeroExtend); // or ri count + m_RIEdits[4].SetValue(g_Reg->RI_REFRESH_REG, DisplayMode::ZeroExtend); // or RI count m_RIEdits[5].SetValue(g_Reg->RI_LATENCY_REG, DisplayMode::ZeroExtend); m_RIEdits[6].SetValue(g_Reg->RI_RERROR_REG, DisplayMode::ZeroExtend); m_RIEdits[7].SetValue(g_Reg->RI_WERROR_REG, DisplayMode::ZeroExtend); diff --git a/Source/Project64/UserInterface/Debugger/Debugger-TLB.cpp b/Source/Project64/UserInterface/Debugger/Debugger-TLB.cpp index 26e9a1062..f64e5f80c 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-TLB.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-TLB.cpp @@ -26,7 +26,7 @@ LRESULT CDebugTlb::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lPara col.iSubItem = 0; ListView_InsertColumn(GetDlgItem(IDC_LIST), 0, &col); - col.pszText = L"Page Mask"; + col.pszText = L"Page mask"; col.cx = (int)(90 * DPIScale); col.iSubItem = 1; ListView_InsertColumn(GetDlgItem(IDC_LIST), 1, &col); diff --git a/Source/Project64/UserInterface/Debugger/Debugger-ViewMemory.cpp b/Source/Project64/UserInterface/Debugger/Debugger-ViewMemory.cpp index dfc52bf58..c44b73165 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-ViewMemory.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-ViewMemory.cpp @@ -10,20 +10,20 @@ CDebugMemoryView::jump_item_t CDebugMemoryView::JumpItems[] = { { 0x80000000, 0x00000000, 0x0800000, "RDRAM" }, - { 0xA3F00000, 0x03F00000, 0x0000028, "RDRAM Registers" }, + { 0xA3F00000, 0x03F00000, 0x0000028, "RDRAM registers" }, { 0xA4000000, 0x04000000, 0x0001000, "SP DMEM" }, { 0xA4001000, 0x04001000, 0x0001000, "SP IMEM" }, - { 0xA4040000, 0x04040000, 0x0000020, "SP Registers" }, - { 0xA4080000, 0x04080000, 0x0000004, "SP PC Register" }, - { 0xA4100000, 0x04100000, 0x0000020, "DP Control Registers" }, - { 0xA4300000, 0x04300000, 0x0000010, "MI Registers" }, - { 0xA4400000, 0x04400000, 0x0000038, "VI Registers" }, - { 0xA4500000, 0x04500000, 0x0000018, "AI Registers" }, - { 0xA4600000, 0x04600000, 0x0000034, "PI Registers" }, - { 0xA4700000, 0x04700000, 0x0000020, "RI Registers" }, - { 0xA4800000, 0x04800000, 0x0000010, "SI Registers" }, - { 0xA5000500, 0x05000500, 0x000004C, "DD Registers" }, - { 0xA8000000, 0x08000000, 0x1000000, "Cartridge Save Data" }, + { 0xA4040000, 0x04040000, 0x0000020, "SP registers" }, + { 0xA4080000, 0x04080000, 0x0000004, "SP PC register" }, + { 0xA4100000, 0x04100000, 0x0000020, "DP control registers" }, + { 0xA4300000, 0x04300000, 0x0000010, "MI registers" }, + { 0xA4400000, 0x04400000, 0x0000038, "VI registers" }, + { 0xA4500000, 0x04500000, 0x0000018, "AI registers" }, + { 0xA4600000, 0x04600000, 0x0000034, "PI registers" }, + { 0xA4700000, 0x04700000, 0x0000020, "RI registers" }, + { 0xA4800000, 0x04800000, 0x0000010, "SI registers" }, + { 0xA5000500, 0x05000500, 0x000004C, "DD registers" }, + { 0xA8000000, 0x08000000, 0x1000000, "Cartridge save data" }, { 0xB0000000, 0x10000000, 0xFC00000, "Cartridge ROM" }, { 0xBFC00000, 0x1FC00000, 0x00007C0, "PIF ROM" }, { 0xBFC007C0, 0x1FC007C0, 0x0000040, "PIF RAM" }, @@ -1189,7 +1189,7 @@ LRESULT CDebugMemoryView::OnStatusBarClick(LPNMHDR lpNMHDR) return FALSE; } - stdstr strDmaTitle = stdstr_f("DMA Information for 0x%08X", startAddress); + stdstr strDmaTitle = stdstr_f("DMA information for 0x%08X", startAddress); stdstr strDmaInfo = stdstr_f("Block:\nROM 0x%08X -> RAM 0x%08X ( 0x%X bytes )\n\nROM address of byte:\n0x%08X ( 0x%08X + 0x%08X )", entry->romAddr, entry->ramAddr, entry->length, romAddress, entry->romAddr, blockOffset); MessageBox(strDmaInfo.ToUTF16().c_str(), strDmaTitle.ToUTF16().c_str(), MB_OK); diff --git a/Source/Project64/UserInterface/Debugger/Debugger.cpp b/Source/Project64/UserInterface/Debugger/Debugger.cpp index 80f7fdabb..851c64704 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger.cpp @@ -457,7 +457,7 @@ void CDebuggerUI::TLBChanged() Debug_RefreshTLBWindow(); } -// Exception handling - break on exception vector if exception BP is set +// Exception handling - break on exception vector if exception breakpoint is set void CDebuggerUI::HandleCPUException(void) { int exc = (g_Reg->CAUSE_REGISTER >> 2) & 0x1F; diff --git a/Source/Project64/UserInterface/Debugger/ScriptHook.h b/Source/Project64/UserInterface/Debugger/ScriptHook.h index b7cebfa8f..31c7364ef 100644 --- a/Source/Project64/UserInterface/Debugger/ScriptHook.h +++ b/Source/Project64/UserInterface/Debugger/ScriptHook.h @@ -32,9 +32,9 @@ public: void InvokeAll(); void InvokeById(int callbackId); void InvokeByParam(uint32_t param); - // invoke if param >= cb.param && param < cb.param2 + // Invoke if param >= cb.param && param < cb.param2 void InvokeByAddressInRange(uint32_t address); - // invoke if param >= cb.param && param < cb.param2 && (value & cb.param4) == cb.param3 + // Invoke if param >= cb.param && param < cb.param2 && (value & cb.param4) == cb.param3 void InvokeByAddressInRange_MaskedOpcode(uint32_t pc, uint32_t value); void InvokeByAddressInRange_GPRValue(uint32_t pc); void RemoveById(int callbackId); diff --git a/Source/Project64/UserInterface/Debugger/ScriptInstance.cpp b/Source/Project64/UserInterface/Debugger/ScriptInstance.cpp index 375ff3733..47a17e8c0 100644 --- a/Source/Project64/UserInterface/Debugger/ScriptInstance.cpp +++ b/Source/Project64/UserInterface/Debugger/ScriptInstance.cpp @@ -368,7 +368,7 @@ void CScriptInstance::RemoveListenerByIndex(UINT index) m_Listeners.erase(m_Listeners.begin() + index); } -// Free listener & it's buffer, remove from list +// Free listener and its buffer, remove from list void CScriptInstance::RemoveListener(IOLISTENER* lpListener) { for (UINT i = 0; i < m_Listeners.size(); i++) @@ -581,7 +581,7 @@ void CScriptInstance::QueueAPC(PAPCFUNC userProc, ULONG_PTR param) { if (m_hThread != nullptr) { - MessageBox(nullptr, L"apc queued", L"", MB_OK); + MessageBox(nullptr, L"APC queued", L"", MB_OK); QueueUserAPC(userProc, m_hThread, param); } } diff --git a/Source/Project64/UserInterface/Debugger/Symbols.cpp b/Source/Project64/UserInterface/Debugger/Symbols.cpp index 336c19aeb..d0cf240da 100644 --- a/Source/Project64/UserInterface/Debugger/Symbols.cpp +++ b/Source/Project64/UserInterface/Debugger/Symbols.cpp @@ -176,7 +176,7 @@ void CSymbolTable::Load() if (m_ParserToken == nullptr || m_ParserTokenLength == 0) { - // Empty line @EOF + // Empty line at the EOF errorCode = ERR_SUCCESS; break; } diff --git a/Source/Project64/UserInterface/DiscordRPC.cpp b/Source/Project64/UserInterface/DiscordRPC.cpp index 4a89c6ca8..7740d2f0e 100644 --- a/Source/Project64/UserInterface/DiscordRPC.cpp +++ b/Source/Project64/UserInterface/DiscordRPC.cpp @@ -44,7 +44,7 @@ void CDiscord::Update(bool bHaveGame) stdstr title = bHaveGame ? GetTitle() : ""; stdstr artwork = bHaveGame ? g_Settings->LoadStringVal(Rdb_RPCKey) : ""; - //Load game into DiscordRPC + // Load game into DiscordRPC DiscordRichPresence discordPresence = {}; // Activates DiscordRPC if (artwork.empty()) { diff --git a/Source/Project64/UserInterface/MainMenu.cpp b/Source/Project64/UserInterface/MainMenu.cpp index a306a3687..8df2e8d04 100644 --- a/Source/Project64/UserInterface/MainMenu.cpp +++ b/Source/Project64/UserInterface/MainMenu.cpp @@ -98,7 +98,7 @@ int CMainMenu::ProcessAccelerator(HWND hWnd, void * lpMsg) std::string CMainMenu::ChooseFileToOpen(HWND hParent) { CPath FileName; - const char * Filter = "N64 ROMs & Disks (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin, *.ndd, *.d64)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal;*.ndd;*.d64\0All files (*.*)\0*.*\0"; + const char * Filter = "N64 ROMs and disks (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin, *.ndd, *.d64)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal;*.ndd;*.d64\0All files (*.*)\0*.*\0"; if (FileName.SelectFile(hParent, g_Settings->LoadStringVal(RomList_GameDir).c_str(), Filter, true)) { return FileName; @@ -120,7 +120,7 @@ std::string CMainMenu::ChooseROMFileToOpen(HWND hParent) std::string CMainMenu::ChooseDiskFileToOpen(HWND hParent) { CPath FileName; - const char * Filter = "N64DD Disk Image (*.ndd, *.d64)\0*.ndd;*.d64\0All files (*.*)\0*.*\0"; + const char * Filter = "N64DD disk images (*.ndd, *.d64)\0*.ndd;*.d64\0All files (*.*)\0*.*\0"; if (FileName.SelectFile(hParent, g_Settings->LoadStringVal(RomList_GameDir).c_str(), Filter, true)) { return FileName; @@ -228,7 +228,7 @@ void CMainMenu::OnSaveAs(HWND hWnd) openfilename.lStructSize = sizeof(openfilename); openfilename.hwndOwner = (HWND)hWnd; - openfilename.lpstrFilter = "PJ64 Saves (*.zip, *.pj)\0*.pj?;*.pj;*.zip;"; + openfilename.lpstrFilter = "Project64 saves (*.zip, *.pj)\0*.pj?;*.pj;*.zip;"; openfilename.lpstrFile = SaveFile; openfilename.lpstrInitialDir = Directory; openfilename.nMaxFile = MAX_PATH; @@ -265,7 +265,7 @@ void CMainMenu::OnLodState(HWND hWnd) UISettingsLoadStringVal(Directory_LastSave, Directory, sizeof(Directory)); CPath SaveFile; - const char * Filter = "PJ64 Saves (*.zip, *.pj)\0*.pj?;*.pj;*.zip;"; + const char * Filter = "Project64 saves (*.zip, *.pj)\0*.pj?;*.pj;*.zip;"; if (SaveFile.SelectFile(hWnd, Directory, Filter, false)) { g_Settings->SaveString(GameRunning_InstantSaveFile, (const char *)SaveFile); @@ -1043,23 +1043,23 @@ void CMainMenu::FillOutMenu(HMENU hMenu) MenuItemList DebugNotificationMenu; if (HaveDebugger()) { - // Debug - Interrupt - Item.Reset(ID_DEBUGGER_INTERRUPT_SP, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"SP Interrupt"); + // Debug - interrupt + Item.Reset(ID_DEBUGGER_INTERRUPT_SP, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"SP interrupt"); Item.SetItemEnabled(CPURunning); DebugInterrupt.push_back(Item); - Item.Reset(ID_DEBUGGER_INTERRUPT_SI, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"SI Interrupt"); + Item.Reset(ID_DEBUGGER_INTERRUPT_SI, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"SI interrupt"); Item.SetItemEnabled(CPURunning); DebugInterrupt.push_back(Item); - Item.Reset(ID_DEBUGGER_INTERRUPT_AI, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"AI Interrupt"); + Item.Reset(ID_DEBUGGER_INTERRUPT_AI, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"AI interrupt"); Item.SetItemEnabled(CPURunning); DebugInterrupt.push_back(Item); - Item.Reset(ID_DEBUGGER_INTERRUPT_VI, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"VI Interrupt"); + Item.Reset(ID_DEBUGGER_INTERRUPT_VI, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"VI interrupt"); Item.SetItemEnabled(CPURunning); DebugInterrupt.push_back(Item); - Item.Reset(ID_DEBUGGER_INTERRUPT_PI, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"PI Interrupt"); + Item.Reset(ID_DEBUGGER_INTERRUPT_PI, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"PI interrupt"); Item.SetItemEnabled(CPURunning); DebugInterrupt.push_back(Item); - Item.Reset(ID_DEBUGGER_INTERRUPT_DP, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"DP Interrupt"); + Item.Reset(ID_DEBUGGER_INTERRUPT_DP, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"DP interrupt"); Item.SetItemEnabled(CPURunning); DebugInterrupt.push_back(Item); @@ -1068,25 +1068,25 @@ void CMainMenu::FillOutMenu(HMENU hMenu) // ID_DEBUGGER_LOGOPTIONS Item.Reset(ID_DEBUGGER_BREAKPOINTS, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"&Commands..."); DebugR4300Menu.push_back(Item); - Item.Reset(ID_DEBUGGER_CPULOG, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Command Log..."); + Item.Reset(ID_DEBUGGER_CPULOG, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Command log..."); DebugR4300Menu.push_back(Item); Item.Reset(ID_DEBUGGER_EXCBREAKPOINTS, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Exceptions..."); DebugR4300Menu.push_back(Item); Item.Reset(ID_DEBUGGER_STACKVIEW, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Stack..."); DebugR4300Menu.push_back(Item); - Item.Reset(ID_DEBUGGER_STACKTRACE, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Stack Trace..."); + Item.Reset(ID_DEBUGGER_STACKTRACE, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Stack lrace..."); DebugR4300Menu.push_back(Item); - Item.Reset(ID_DEBUG_DISABLE_GAMEFIX, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Disable Game Fixes"); + Item.Reset(ID_DEBUG_DISABLE_GAMEFIX, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Disable game fixes"); if (g_Settings->LoadBool(Debugger_DisableGameFixes)) { Item.SetItemTicked(true); } DebugR4300Menu.push_back(Item); - Item.Reset(SUB_MENU, EMPTY_STRING, EMPTY_STDSTR, &DebugInterrupt, L"&Generate Interrupt"); + Item.Reset(SUB_MENU, EMPTY_STRING, EMPTY_STDSTR, &DebugInterrupt, L"&Generate interrupt"); DebugR4300Menu.push_back(Item); - // Debug - Memory + // Debug - memory Item.Reset(ID_DEBUGGER_MEMORY, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"View..."); DebugMemoryMenu.push_back(Item); Item.Reset(ID_DEBUGGER_SEARCHMEMORY, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Search..."); @@ -1095,12 +1095,12 @@ void CMainMenu::FillOutMenu(HMENU hMenu) DebugMemoryMenu.push_back(Item); Item.Reset(ID_DEBUGGER_DUMPMEMORY, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Dump..."); DebugMemoryMenu.push_back(Item); - Item.Reset(ID_DEBUGGER_TLBENTRIES, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"TLB Entries..."); + Item.Reset(ID_DEBUGGER_TLBENTRIES, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"TLB entries..."); DebugMemoryMenu.push_back(Item); - Item.Reset(ID_DEBUGGER_DMALOG, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"DMA Log..."); + Item.Reset(ID_DEBUGGER_DMALOG, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"DMA log..."); DebugMemoryMenu.push_back(Item); - // Debug - App logging + // Debug - app logging Item.Reset(ID_DEBUGGER_TRACE_MD5, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"MD5"); Item.SetItemTicked(g_Settings->LoadDword(Debugger_TraceMD5) == TraceVerbose); DebugAppLoggingMenu.push_back(Item); @@ -1113,15 +1113,15 @@ void CMainMenu::FillOutMenu(HMENU hMenu) Item.SetItemTicked(g_Settings->LoadDword(Debugger_TraceUnknown) == TraceVerbose); DebugAppLoggingMenu.push_back(Item); - Item.Reset(ID_DEBUGGER_TRACE_APPINIT, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"App Init"); + Item.Reset(ID_DEBUGGER_TRACE_APPINIT, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"App initialization"); Item.SetItemTicked(g_Settings->LoadDword(Debugger_TraceAppInit) == TraceVerbose); DebugAppLoggingMenu.push_back(Item); - Item.Reset(ID_DEBUGGER_TRACE_APPCLEANUP, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"App Cleanup"); + Item.Reset(ID_DEBUGGER_TRACE_APPCLEANUP, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"App cleanup"); Item.SetItemTicked(g_Settings->LoadDword(Debugger_TraceAppCleanup) == TraceVerbose); DebugAppLoggingMenu.push_back(Item); - Item.Reset(ID_DEBUGGER_TRACE_N64SYSTEM, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"N64 System"); + Item.Reset(ID_DEBUGGER_TRACE_N64SYSTEM, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"N64 system"); Item.SetItemTicked(g_Settings->LoadDword(Debugger_TraceN64System) == TraceVerbose); DebugAppLoggingMenu.push_back(Item); @@ -1129,19 +1129,19 @@ void CMainMenu::FillOutMenu(HMENU hMenu) Item.SetItemTicked(g_Settings->LoadDword(Debugger_TracePlugins) == TraceVerbose);; DebugAppLoggingMenu.push_back(Item); - Item.Reset(ID_DEBUGGER_TRACE_GFXPLUGIN, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"GFX Plugin"); + Item.Reset(ID_DEBUGGER_TRACE_GFXPLUGIN, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"GFX plugin"); Item.SetItemTicked(g_Settings->LoadDword(Debugger_TraceGFXPlugin) == TraceVerbose); DebugAppLoggingMenu.push_back(Item); - Item.Reset(ID_DEBUGGER_TRACE_AUDIOPLUGIN, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Audio Plugin"); + Item.Reset(ID_DEBUGGER_TRACE_AUDIOPLUGIN, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Audio plugin"); Item.SetItemTicked(g_Settings->LoadDword(Debugger_TraceAudioPlugin) == TraceVerbose); DebugAppLoggingMenu.push_back(Item); - Item.Reset(ID_DEBUGGER_TRACE_CONTROLLERPLUGIN, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Controller Plugin"); + Item.Reset(ID_DEBUGGER_TRACE_CONTROLLERPLUGIN, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Controller plugin"); Item.SetItemTicked(g_Settings->LoadDword(Debugger_TraceControllerPlugin) == TraceVerbose); DebugAppLoggingMenu.push_back(Item); - Item.Reset(ID_DEBUGGER_TRACE_RSPPLUGIN, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"RSP Plugin"); + Item.Reset(ID_DEBUGGER_TRACE_RSPPLUGIN, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"RSP plugin"); Item.SetItemTicked(g_Settings->LoadDword(Debugger_TraceRSPPlugin) == TraceVerbose);; DebugAppLoggingMenu.push_back(Item); @@ -1153,7 +1153,7 @@ void CMainMenu::FillOutMenu(HMENU hMenu) Item.SetItemTicked(g_Settings->LoadDword(Debugger_TraceAudio) == TraceVerbose); DebugAppLoggingMenu.push_back(Item); - Item.Reset(ID_DEBUGGER_TRACE_REGISTERCACHE, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Register Cache"); + Item.Reset(ID_DEBUGGER_TRACE_REGISTERCACHE, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Register cache"); Item.SetItemTicked(g_Settings->LoadDword(Debugger_TraceRegisterCache) == TraceVerbose); DebugAppLoggingMenu.push_back(Item); @@ -1169,7 +1169,7 @@ void CMainMenu::FillOutMenu(HMENU hMenu) Item.SetItemTicked(g_Settings->LoadDword(Debugger_TraceProtectedMEM) == TraceVerbose); DebugAppLoggingMenu.push_back(Item); - Item.Reset(ID_DEBUGGER_TRACE_USERINTERFACE, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"User Interface"); + Item.Reset(ID_DEBUGGER_TRACE_USERINTERFACE, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"User interface"); Item.SetItemTicked(g_Settings->LoadDword(Debugger_TraceUserInterface) == TraceVerbose); DebugAppLoggingMenu.push_back(Item); @@ -1180,17 +1180,17 @@ void CMainMenu::FillOutMenu(HMENU hMenu) DebugAppLoggingMenu.push_back(Item); // Debug - logging - Item.Reset(ID_DEBUGGER_LOGOPTIONS, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Log Options..."); + Item.Reset(ID_DEBUGGER_LOGOPTIONS, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Log options..."); DebugLoggingMenu.push_back(Item); - Item.Reset(ID_DEBUGGER_GENERATELOG, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Generate Log"); + Item.Reset(ID_DEBUGGER_GENERATELOG, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Generate log"); if (g_Settings->LoadBool(Logging_GenerateLog)) { Item.SetItemTicked(true); } DebugLoggingMenu.push_back(Item); // Debugger main menu Item.Reset(ID_DEBUGGER_BREAKPOINTS, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Commands..."); DebugMenu.push_back(Item); - Item.Reset(ID_DEBUGGER_MEMORY, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"View Memory..."); + Item.Reset(ID_DEBUGGER_MEMORY, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"View memory..."); DebugMenu.push_back(Item); Item.Reset(ID_DEBUGGER_SCRIPTS, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Scripts..."); DebugMenu.push_back(Item); @@ -1220,19 +1220,19 @@ void CMainMenu::FillOutMenu(HMENU hMenu) } // Notification menu - Item.Reset(ID_DEBUG_SHOW_UNHANDLED_MEM, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"On Unhandled Memory Actions"); + Item.Reset(ID_DEBUG_SHOW_UNHANDLED_MEM, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"On unhandled memory actions"); if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { Item.SetItemTicked(true); } DebugNotificationMenu.push_back(Item); - Item.Reset(ID_DEBUG_SHOW_PIF_ERRORS, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"On PIF Errors"); + Item.Reset(ID_DEBUG_SHOW_PIF_ERRORS, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"On PIF errors"); if (g_Settings->LoadBool(Debugger_ShowPifErrors)) { Item.SetItemTicked(true); } DebugNotificationMenu.push_back(Item); - Item.Reset(ID_DEBUG_SHOW_DIV_BY_ZERO, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"On Div By Zero"); + Item.Reset(ID_DEBUG_SHOW_DIV_BY_ZERO, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"On division by zero errors"); if (g_Settings->LoadBool(Debugger_ShowDivByZero)) { Item.SetItemTicked(true); @@ -1242,39 +1242,39 @@ void CMainMenu::FillOutMenu(HMENU hMenu) DebugMenu.push_back(MENU_ITEM(SPLITER)); Item.Reset(SUB_MENU, EMPTY_STRING, EMPTY_STDSTR, &DebugProfileMenu, L"Profile"); DebugMenu.push_back(Item); - Item.Reset(SUB_MENU, EMPTY_STRING, EMPTY_STDSTR, &DebugAppLoggingMenu, L"App Logging"); + Item.Reset(SUB_MENU, EMPTY_STRING, EMPTY_STDSTR, &DebugAppLoggingMenu, L"App logging"); DebugMenu.push_back(Item); Item.Reset(SUB_MENU, EMPTY_STRING, EMPTY_STDSTR, &DebugLoggingMenu, L"Logging"); DebugMenu.push_back(Item); Item.Reset(SUB_MENU, EMPTY_STRING, EMPTY_STDSTR, &DebugNotificationMenu, L"Notification"); DebugMenu.push_back(Item); DebugMenu.push_back(MENU_ITEM(SPLITER)); - Item.Reset(ID_DEBUG_SHOW_TLB_MISSES, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Show TLB Misses"); + Item.Reset(ID_DEBUG_SHOW_TLB_MISSES, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Show TLB misses"); if (g_Settings->LoadBool(Debugger_ShowTLBMisses)) { Item.SetItemTicked(true); } DebugMenu.push_back(Item); - Item.Reset(ID_DEBUG_SHOW_DLIST_COUNT, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Display Alist/Dlist Count"); + Item.Reset(ID_DEBUG_SHOW_DLIST_COUNT, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Display Alist/Dlist count"); if (g_Settings->LoadBool(Debugger_ShowDListAListCount)) { Item.SetItemTicked(true); } DebugMenu.push_back(Item); - Item.Reset(ID_DEBUG_LANGUAGE, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Debug Language"); + Item.Reset(ID_DEBUG_LANGUAGE, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Debug language"); if (g_Settings->LoadBool(Debugger_DebugLanguage)) { Item.SetItemTicked(true); } DebugMenu.push_back(Item); - Item.Reset(ID_DEBUG_SHOW_RECOMP_MEM_SIZE, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Display Recompiler Code Buffer Size"); + Item.Reset(ID_DEBUG_SHOW_RECOMP_MEM_SIZE, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Display recompiler code buffer size"); if (g_Settings->LoadBool(Debugger_ShowRecompMemSize)) { Item.SetItemTicked(true); } DebugMenu.push_back(Item); DebugMenu.push_back(MENU_ITEM(SPLITER)); - Item.Reset(ID_DEBUG_RECORD_RECOMPILER_ASM, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Record Recompiler ASM"); + Item.Reset(ID_DEBUG_RECORD_RECOMPILER_ASM, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Record recompiler ASM"); if (g_Settings->LoadBool(Debugger_RecordRecompilerAsm)) { Item.SetItemTicked(true); @@ -1342,10 +1342,10 @@ void CMainMenu::ResetMenu(void) if (!UISettingsLoadBool(UserInterface_InFullScreen)) { // Create a new window with all the items - WriteTrace(TraceUserInterface, TraceDebug, "Create Menu"); + WriteTrace(TraceUserInterface, TraceDebug, "Create menu"); HMENU hMenu = CreateMenu(); FillOutMenu(hMenu); - WriteTrace(TraceUserInterface, TraceDebug, "Create Menu Done"); + WriteTrace(TraceUserInterface, TraceDebug, "Creating menu done"); // Save old menu to destroy latter HMENU OldMenuHandle; @@ -1354,7 +1354,7 @@ void CMainMenu::ResetMenu(void) OldMenuHandle = m_MenuHandle; // Save handle and re-attach to a window - WriteTrace(TraceUserInterface, TraceDebug, "Attach Menu"); + WriteTrace(TraceUserInterface, TraceDebug, "Attach menu"); m_MenuHandle = hMenu; } m_Gui->SetWindowMenu(this); @@ -1368,7 +1368,7 @@ void CMainMenu::ResetMenu(void) { RemoveMenu((HMENU)OldMenuHandle, (DWORD)g_Plugins->RSP()->GetDebugMenu(), MF_BYCOMMAND); } - WriteTrace(TraceUserInterface, TraceDebug, "Destroy Old Menu"); + WriteTrace(TraceUserInterface, TraceDebug, "Destroy old menu"); // Destroy the old menu DestroyMenu((HMENU)OldMenuHandle); diff --git a/Source/Project64/UserInterface/MainWindow.cpp b/Source/Project64/UserInterface/MainWindow.cpp index 63b906ec2..666cf130e 100644 --- a/Source/Project64/UserInterface/MainWindow.cpp +++ b/Source/Project64/UserInterface/MainWindow.cpp @@ -206,7 +206,7 @@ void CMainGui::GameLoaded(CMainGui * Gui) stdstr FileLoc = g_Settings->LoadStringVal(Game_File); if (FileLoc.length() > 0) { - WriteTrace(TraceUserInterface, TraceDebug, "Add Recent ROM"); + WriteTrace(TraceUserInterface, TraceDebug, "Add recent ROM"); Gui->AddRecentRom(FileLoc.c_str()); Gui->SetWindowCaption(stdstr(g_Settings->LoadStringVal(Rdb_GoodName)).ToUTF16().c_str()); diff --git a/Source/Project64/UserInterface/Notification.cpp b/Source/Project64/UserInterface/Notification.cpp index 0e88207aa..73feb3cab 100644 --- a/Source/Project64/UserInterface/Notification.cpp +++ b/Source/Project64/UserInterface/Notification.cpp @@ -225,7 +225,7 @@ void CNotificationImp::ShowRomBrowser(void) if (m_hWnd == nullptr) { return; } if (UISettingsLoadBool(RomBrowser_Enabled)) { - //Display the ROM browser + // Display the ROM browser m_hWnd->ShowRomList(); m_hWnd->HighLightLastRom(); } diff --git a/Source/Project64/UserInterface/RomBrowser.cpp b/Source/Project64/UserInterface/RomBrowser.cpp index a948d4fcb..4227ec9df 100644 --- a/Source/Project64/UserInterface/RomBrowser.cpp +++ b/Source/Project64/UserInterface/RomBrowser.cpp @@ -395,7 +395,7 @@ void CRomBrowser::ResetRomBrowserColomuns(void) ListView_DeleteColumn(m_hRomList, 0); } - // Add Columns + // Add columns lvColumn.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; lvColumn.fmt = LVCFMT_LEFT; lvColumn.pszText = szString; diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Directories.cpp b/Source/Project64/UserInterface/Settings/SettingsPage-Directories.cpp index e1920b7bc..3287d453a 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-Directories.cpp +++ b/Source/Project64/UserInterface/Settings/SettingsPage-Directories.cpp @@ -50,8 +50,8 @@ int CALLBACK COptionsDirectoriesPage::SelectDirCallBack(HWND hwnd, DWORD uMsg, D switch (uMsg) { case BFFM_INITIALIZED: - // WParam is TRUE since you are passing a path - // It would be FALSE if you were passing a PIDL + // WParam is true since you are passing a path + // It would be false if you were passing a PIDL if (lpData) { SendMessage(hwnd, BFFM_SETSELECTION, TRUE, lpData); diff --git a/Source/Project64/UserInterface/SettingsConfig.cpp b/Source/Project64/UserInterface/SettingsConfig.cpp index e6073a1e0..6d3c2b48a 100644 --- a/Source/Project64/UserInterface/SettingsConfig.cpp +++ b/Source/Project64/UserInterface/SettingsConfig.cpp @@ -103,7 +103,7 @@ LRESULT CSettingConfig::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /* { if (g_Settings->LoadBool(Setting_RdbEditor)) { - SetWindowText(stdstr_f("%s ** RDB edit mode **", ConfigRomTitle.c_str()).ToUTF16().c_str()); + SetWindowText(stdstr_f("%s *** RDB edit mode ***", ConfigRomTitle.c_str()).ToUTF16().c_str()); } else { @@ -114,7 +114,7 @@ LRESULT CSettingConfig::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /* { if (g_Settings->LoadBool(Setting_RdbEditor)) { - SetWindowText(stdstr_f("%s ** RDB edit mode **", GS(OPTIONS_TITLE)).ToUTF16().c_str()); + SetWindowText(stdstr_f("%s *** RDB edit mode ***", GS(OPTIONS_TITLE)).ToUTF16().c_str()); } else { @@ -312,7 +312,7 @@ LRESULT CSettingConfig::OnPageListItemChanged(NMHDR* /*phdr*/) ::EnableWindow(GetDlgItem(IDC_RESET_PAGE), m_CurrentPage->EnableReset()); } - return 0; // retval ignored + return 0; // Return value ignored } // Fallback to using HitTest if TVN_SELCHANGED isn't working @@ -350,7 +350,7 @@ LRESULT CSettingConfig::OnPageListClicked(NMHDR*) m_CurrentPage->ShowPage(); ::EnableWindow(GetDlgItem(IDC_RESET_PAGE), m_CurrentPage->EnableReset()); } - return 0; // retval ignored + return 0; } LRESULT CSettingConfig::OnSettingPageChanged(UINT /*uMsg*/, WPARAM /*wPage*/, LPARAM /*lParam*/) diff --git a/Source/Project64/UserInterface/WTLControls/ClistCtrl/DataArray.h b/Source/Project64/UserInterface/WTLControls/ClistCtrl/DataArray.h index 40ffc4ad7..9a6357488 100644 --- a/Source/Project64/UserInterface/WTLControls/ClistCtrl/DataArray.h +++ b/Source/Project64/UserInterface/WTLControls/ClistCtrl/DataArray.h @@ -26,8 +26,8 @@ #define pop_new #endif -// template class helpers with functions for comparing elements -// override if using complex types without operator== +// Template class helpers with functions for comparing elements +// Override if using complex types without operator== template class CListCtrlArrayEqualHelper @@ -43,7 +43,7 @@ template > class CListCtrlArray { public: - // Construction/destruction + // Construction / destruction CListCtrlArray() : m_aT(nullptr), m_nSize(0), m_nAllocSize(0) { } diff --git a/Source/Project64/UserInterface/WTLControls/ClistCtrl/ListCtrl.h b/Source/Project64/UserInterface/WTLControls/ClistCtrl/ListCtrl.h index 72f9c16c6..93739839a 100644 --- a/Source/Project64/UserInterface/WTLControls/ClistCtrl/ListCtrl.h +++ b/Source/Project64/UserInterface/WTLControls/ClistCtrl/ListCtrl.h @@ -1,5 +1,5 @@ // CListCtrl - A WTL list control with Windows Vista style item selection -// Revision: 1.5 +// Revision: 1.5 // Last modified: 2nd November 2016 #pragma once @@ -41,7 +41,7 @@ public: CListImpl() { m_bSortEnabled = TRUE; // Added by Rowan 05/12/2006 - m_bRightClickSelect = FALSE; // shygoo 2016 Nov 2 + m_bRightClickSelect = FALSE; // Shygoo 11/02/2016 m_bShowHeader = TRUE; m_bSortAscending = TRUE; m_bButtonDown = FALSE; @@ -105,7 +105,7 @@ public: protected: BOOL m_bSortEnabled; // Added by Rowan 05/12/2006 to disable sorting - BOOL m_bRightClickSelect; // shygoo 2016 Nov 2 + BOOL m_bRightClickSelect; // Shygoo 11/02/2016 BOOL m_bShowHeader; BOOL m_bShowSort; BOOL m_bSortAscending; @@ -307,7 +307,7 @@ public: dcClient.SelectFont( hOldFont ); - // Has system font changed + // Has system font changed? if ( m_nItemHeight != sizeExtent.cy + ITEM_HEIGHT_MARGIN ) { m_nItemHeight = sizeExtent.cy + ITEM_HEIGHT_MARGIN; @@ -335,7 +335,7 @@ public: m_bSortEnabled = bSortEnabled; } - // shygoo 2016 Nov 2 + // Shygoo 11/02/2016 void SetRightClickSelect( BOOL bRightClickSelect = TRUE) { m_bRightClickSelect = bRightClickSelect; @@ -629,7 +629,7 @@ public: if ( strItemText.empty() ) return FALSE; - // Get date-time from item text: yyyymmddhhmmss + // Get date and time from item text: yyyymmddhhmmss stItemDate.wYear = (WORD)_ttoi( strItemText.substr(0, 4 ).c_str() ); stItemDate.wMonth = (WORD)_ttoi( strItemText.substr( 4, 2 ).c_str() ); stItemDate.wDay = (WORD)_ttoi( strItemText.substr( 6, 2 ).c_str() ); @@ -699,7 +699,7 @@ public: { T* pT = static_cast(this); - // Set date-time in format (yyyymmddhhmmss) + // Set date and time in format (yyyymmddhhmmss) stdstr strFormatDate; strFormatDate.Format( _T( "%04d%02d%02d%02d%02d%02d" ), stItemDate.wYear, stItemDate.wMonth, stItemDate.wDay, stItemDate.wHour, stItemDate.wMinute, stItemDate.wSecond ); @@ -1105,7 +1105,7 @@ public: BOOL HitTestHeader( CPoint point, int& nColumn, UINT& nFlags ) { - // Reset hittest flags + // Reset hit test flags nFlags = HITTEST_FLAG_NONE; if ( !m_bShowHeader ) @@ -1122,7 +1122,7 @@ public: int nDividerPos = 0; int nColumnCount = GetColumnCount(); - // Get hit-test subitem + // Get hit test subitem for ( nColumn = 0; nColumn < nColumnCount; nColumn++ ) { int nColumnWidth = GetColumnWidth( nColumn ); @@ -1181,7 +1181,7 @@ public: int nTotalWidth = 0; int nColumnCount = GetColumnCount(); - // Get hit-test subitem + // Get hit test subitem for ( nSubItem = 0; nSubItem < nColumnCount; nSubItem++ ) { int nColumnWidth = GetColumnWidth( nSubItem ); @@ -1620,7 +1620,7 @@ public: } } - // Was scrolling performed? + // Was the scrolling performed? return bAutoScroll; } @@ -3735,7 +3735,6 @@ public: return FALSE; m_aItems[ nItem ].m_aSubItems[ nSubItem ].m_strText = lpszText; - // Added by Rowan - 11/12/2006 to fix an updating bug - can add this to the parameter list if needed if (bInvalidateItem) InvalidateItem(nItem, nSubItem); diff --git a/Source/RSP/Cpu.c b/Source/RSP/Cpu.c index 9f073d3b1..415e3efee 100644 --- a/Source/RSP/Cpu.c +++ b/Source/RSP/Cpu.c @@ -151,17 +151,16 @@ void Build_RSP ( void ) PrgCount = RSPInfo.SP_PC_REG; } -/****************************************************************** - Function: DoRspCycles - Purpose: This function is to allow the RSP to run in parallel with - the r4300i switching control back to the r4300i once the - function ends. - input: The number of cycles that is meant to be executed - output: The number of cycles that was executed. This value can - be greater than the number of cycles that the RSP - should have performed. - (this value is ignored if the RSP has been stopped) -*******************************************************************/ +/* +Function: DoRspCycles +Purpose: This function is to allow the RSP to run in parallel with +the r4300i switching control back to the r4300i once the +function ends. +Input: The number of cycles that is meant to be executed. +Output: The number of cycles that was executed. This value can +be greater than the number of cycles that the RSP should have performed. +(this value is ignored if the RSP has been stopped) +*/ DWORD RunInterpreterCPU(DWORD Cycles); DWORD RunRecompilerCPU (DWORD Cycles); diff --git a/Source/RSP/Interpreter Ops.c b/Source/RSP/Interpreter Ops.c index 23136eb5d..ad813506d 100644 --- a/Source/RSP/Interpreter Ops.c +++ b/Source/RSP/Interpreter Ops.c @@ -1676,7 +1676,7 @@ void RSP_Opcode_SWV ( void ) { RSP_SWV_DMEM( Address, RSPOpC.rt, RSPOpC.del); } -/************************** Other functions **************************/ +// Other functions void rsp_UnknownOpcode (void) { char Message[200]; diff --git a/Source/RSP/Main.cpp b/Source/RSP/Main.cpp index ebd2aed5d..5570f256b 100644 --- a/Source/RSP/Main.cpp +++ b/Source/RSP/Main.cpp @@ -76,7 +76,7 @@ const char * AppName ( void ) } const char * AboutMsg ( void ) { - static stdstr_f Msg("RSP emulation plugin\nMade for Project64 (c)\nVersion %s\n\nby Jabo & Zilmar", VER_FILE_VERSION_STR); + static stdstr_f Msg("RSP emulation plugin\nMade for Project64 (c)\nVersion %s\n\nby Jabo and Zilmar", VER_FILE_VERSION_STR); return Msg.c_str(); } @@ -140,26 +140,26 @@ void DisplayError(char* Message, ...) #endif } -/****************************************************************** - Function: CloseDLL - Purpose: This function is called when the emulator is closing - down allowing the DLL to de-initialize. - input: none - output: none -*******************************************************************/ +/* +Function: CloseDLL +Purpose: This function is called when the emulator is closing +down allowing the DLL to de-initialize. +Input: None +Output: None +*/ EXPORT void CloseDLL(void) { FreeMemory(); } -/****************************************************************** - Function: DllAbout - Purpose: This function is optional function that is provided - to give further information about the DLL. - input: a handle to the window that calls this function - output: none -*******************************************************************/ +/* +Function: DllAbout +Purpose: This function is optional function that is provided +to give further information about the DLL. +Input: A handle to the window that calls this function +Output: None +*/ EXPORT void DllAbout(void * hParent) { @@ -198,37 +198,37 @@ void FixMenuState(void) } #endif -/****************************************************************** - Function: GetDllInfo - Purpose: This function allows the emulator to gather information - about the DLL by filling in the PluginInfo structure. - input: a pointer to a PLUGIN_INFO structure that needs to be - filled by the function. (see def above) - output: none -*******************************************************************/ +/* +Function: GetDllInfo +Purpose: This function allows the emulator to gather information +about the DLL by filling in the PluginInfo structure. +Input: A pointer to a PLUGIN_INFO structure that needs to be +filled by the function. (see def above) +Output: None +*/ EXPORT void GetDllInfo(PLUGIN_INFO * PluginInfo) { PluginInfo->Version = 0x0103; PluginInfo->Type = PLUGIN_TYPE_RSP; #ifdef _DEBUG - sprintf(PluginInfo->Name, "RSP Debug Plugin %s", VER_FILE_VERSION_STR); + sprintf(PluginInfo->Name, "RSP debug plugin %s", VER_FILE_VERSION_STR); #else - sprintf(PluginInfo->Name, "RSP Plugin %s", VER_FILE_VERSION_STR); + sprintf(PluginInfo->Name, "RSP plugin %s", VER_FILE_VERSION_STR); #endif PluginInfo->NormalMemory = FALSE; PluginInfo->MemoryBswaped = TRUE; } -/****************************************************************** - Function: GetRspDebugInfo - Purpose: This function allows the emulator to gather information - about the debug capabilities of the DLL by filling in - the DebugInfo structure. - input: a pointer to a RSPDEBUG_INFO structure that needs to be - filled by the function. (see def above) - output: none -*******************************************************************/ +/* +Function: GetRspDebugInfo +Purpose: This function allows the emulator to gather information +about the debug capabilities of the DLL by filling in +the DebugInfo structure. +Input: A pointer to a RSPDEBUG_INFO structure that needs to be +filled by the function. (see def above) +Output: None +*/ EXPORT void GetRspDebugInfo(RSPDEBUG_INFO * DebugInfo) { @@ -256,17 +256,16 @@ EXPORT void GetRspDebugInfo(RSPDEBUG_INFO * DebugInfo) DebugInfo->Enter_RSP_Commands_Window = Enter_RSP_Commands_Window; } -/****************************************************************** - Function: InitiateRSP - Purpose: This function is called when the DLL is started to give - information from the emulator that the n64 RSP - interface needs - input: Rsp_Info is passed to this function which is defined - above. - CycleCount is the number of cycles between switching - control between the RSP and r4300i core. - output: none -*******************************************************************/ +/* +Function: InitiateRSP +Purpose: This function is called when the DLL is started to give +information from the emulator that the N64 RSP interface needs. +Input: Rsp_Info is passed to this function which is defined +above. +CycleCount is the number of cycles between switching +control between the RSP and r4300i core. +Output: None +*/ RSP_COMPILER Compiler; @@ -348,16 +347,16 @@ EXPORT void InitiateRSP(RSP_INFO Rsp_Info, uint32_t * CycleCount) #endif } -/****************************************************************** - Function: InitiateRSPDebugger - Purpose: This function is called when the DLL is started to give - information from the emulator that the N64 RSP - interface needs to integrate the debugger with the - rest of the emulator. - input: DebugInfo is passed to this function which is defined - above. - output: none -*******************************************************************/ +/* +Function: InitiateRSPDebugger +Purpose: This function is called when the DLL is started to give +information from the emulator that the N64 RSP +interface needs to integrate the debugger with the +rest of the emulator. +Input: DebugInfo is passed to this function which is defined +above. +Output: None +*/ EXPORT void InitiateRSPDebugger(DEBUG_INFO Debug_Info) { @@ -527,12 +526,12 @@ void ProcessMenuItem(int ID) } #endif -/****************************************************************** - Function: RomOpen - Purpose: This function is called when a ROM is opened. - input: none - output: none -*******************************************************************/ +/* +Function: RomOpen +Purpose: This function is called when a ROM is opened. +Input: None +Output: None +*/ EXPORT void RomOpen(void) { @@ -546,12 +545,12 @@ EXPORT void RomOpen(void) SemaphoreExit = GetSetting(Set_SemaphoreExit); } -/****************************************************************** - Function: RomClosed - Purpose: This function is called when a ROM is closed. - input: none - output: none -*******************************************************************/ +/* +Function: RomClosed +Purpose: This function is called when a ROM is closed. +Input: None +Output: None +*/ EXPORT void RomClosed(void) { diff --git a/Source/RSP/OpCode.h b/Source/RSP/OpCode.h index 88e587f95..43ff28749 100644 --- a/Source/RSP/OpCode.h +++ b/Source/RSP/OpCode.h @@ -48,7 +48,7 @@ typedef union tagOPCODE { #pragma warning(pop) -//RSP opcodes +// RSP opcodes #define RSP_SPECIAL 0 #define RSP_REGIMM 1 diff --git a/Source/RSP/Profiling.cpp b/Source/RSP/Profiling.cpp index c5b57faa1..12fe9c504 100644 --- a/Source/RSP/Profiling.cpp +++ b/Source/RSP/Profiling.cpp @@ -145,7 +145,7 @@ public: float CpuUsage = (float)(((double)ItemList[count]->second / (double)TotalTime) * 100); if (CpuUsage <= 0.2) { continue; } - sprintf(Buffer, "Func 0x%08X", ItemList[count]->first); + sprintf(Buffer, "Function 0x%08X", ItemList[count]->first); for (int NameID = 0; NameID < (sizeof(TimerNames) / sizeof(TIMER_NAME)); NameID++) { if (ItemList[count]->first == (DWORD)TimerNames[NameID].Timer) diff --git a/Source/RSP/RSP Registers.h b/Source/RSP/RSP Registers.h index b6400538a..0d741308e 100644 --- a/Source/RSP/RSP Registers.h +++ b/Source/RSP/RSP Registers.h @@ -1,69 +1,69 @@ #include "Types.h" -#define SP_STATUS_HALT 0x001 // Bit 0: halt -#define SP_STATUS_BROKE 0x002 // Bit 1: broke +#define SP_STATUS_HALT 0x001 // Bit 0: Halt +#define SP_STATUS_BROKE 0x002 // Bit 1: Broke #define SP_STATUS_DMA_BUSY 0x004 // Bit 2: DMA busy #define SP_STATUS_DMA_FULL 0x008 // Bit 3: DMA full #define SP_STATUS_IO_FULL 0x010 // Bit 4: IO full -#define SP_STATUS_SSTEP 0x020 // Bit 5: single step -#define SP_STATUS_INTR_BREAK 0x040 // Bit 6: interrupt on break -#define SP_STATUS_SIG0 0x080 // Bit 7: signal 0 set -#define SP_STATUS_SIG1 0x100 // Bit 8: signal 1 set -#define SP_STATUS_SIG2 0x200 // Bit 9: signal 2 set -#define SP_STATUS_SIG3 0x400 // Bit 10: signal 3 set -#define SP_STATUS_SIG4 0x800 // Bit 11: signal 4 set -#define SP_STATUS_SIG5 0x1000 // Bit 12: signal 5 set -#define SP_STATUS_SIG6 0x2000 // Bit 13: signal 6 set -#define SP_STATUS_SIG7 0x4000 // Bit 14: signal 7 set +#define SP_STATUS_SSTEP 0x020 // Bit 5: Single step +#define SP_STATUS_INTR_BREAK 0x040 // Bit 6: Interrupt on break +#define SP_STATUS_SIG0 0x080 // Bit 7: Signal 0 set +#define SP_STATUS_SIG1 0x100 // Bit 8: Signal 1 set +#define SP_STATUS_SIG2 0x200 // Bit 9: Signal 2 set +#define SP_STATUS_SIG3 0x400 // Bit 10: Signal 3 set +#define SP_STATUS_SIG4 0x800 // Bit 11: Signal 4 set +#define SP_STATUS_SIG5 0x1000 // Bit 12: Signal 5 set +#define SP_STATUS_SIG6 0x2000 // Bit 13: Signal 6 set +#define SP_STATUS_SIG7 0x4000 // Bit 14: Signal 7 set -#define SP_CLR_HALT 0x00001 // Bit 0: clear halt -#define SP_SET_HALT 0x00002 // Bit 1: set halt -#define SP_CLR_BROKE 0x00004 // Bit 2: clear broke -#define SP_CLR_INTR 0x00008 // Bit 3: clear INTR -#define SP_SET_INTR 0x00010 // Bit 4: set INTR -#define SP_CLR_SSTEP 0x00020 // Bit 5: clear SSTEP -#define SP_SET_SSTEP 0x00040 // Bit 6: set SSTEP -#define SP_CLR_INTR_BREAK 0x00080 // Bit 7: clear INTR on break -#define SP_SET_INTR_BREAK 0x00100 // Bit 8: set INTR on break -#define SP_CLR_SIG0 0x00200 // Bit 9: clear signal 0 -#define SP_SET_SIG0 0x00400 // Bit 10: set signal 0 -#define SP_CLR_SIG1 0x00800 // Bit 11: clear signal 1 -#define SP_SET_SIG1 0x01000 // Bit 12: set signal 1 -#define SP_CLR_SIG2 0x02000 // Bit 13: clear signal 2 -#define SP_SET_SIG2 0x04000 // Bit 14: set signal 2 -#define SP_CLR_SIG3 0x08000 // Bit 15: clear signal 3 -#define SP_SET_SIG3 0x10000 // Bit 16: set signal 3 -#define SP_CLR_SIG4 0x20000 // Bit 17: clear signal 4 -#define SP_SET_SIG4 0x40000 // Bit 18: set signal 4 -#define SP_CLR_SIG5 0x80000 // Bit 19: clear signal 5 -#define SP_SET_SIG5 0x100000 // Bit 20: set signal 5 -#define SP_CLR_SIG6 0x200000 // Bit 21: clear signal 6 -#define SP_SET_SIG6 0x400000 // Bit 22: set signal 6 -#define SP_CLR_SIG7 0x800000 // Bit 23: clear signal 7 -#define SP_SET_SIG7 0x1000000 // Bit 24: set signal 7 +#define SP_CLR_HALT 0x00001 // Bit 0: Clear halt +#define SP_SET_HALT 0x00002 // Bit 1: Set halt +#define SP_CLR_BROKE 0x00004 // Bit 2: Clear broke +#define SP_CLR_INTR 0x00008 // Bit 3: Clear INTR +#define SP_SET_INTR 0x00010 // Bit 4: Set INTR +#define SP_CLR_SSTEP 0x00020 // Bit 5: Clear SSTEP +#define SP_SET_SSTEP 0x00040 // Bit 6: Set SSTEP +#define SP_CLR_INTR_BREAK 0x00080 // Bit 7: Clear INTR on break +#define SP_SET_INTR_BREAK 0x00100 // Bit 8: Set INTR on break +#define SP_CLR_SIG0 0x00200 // Bit 9: Clear signal 0 +#define SP_SET_SIG0 0x00400 // Bit 10: Set signal 0 +#define SP_CLR_SIG1 0x00800 // Bit 11: Clear signal 1 +#define SP_SET_SIG1 0x01000 // Bit 12: Set signal 1 +#define SP_CLR_SIG2 0x02000 // Bit 13: Clear signal 2 +#define SP_SET_SIG2 0x04000 // Bit 14: Set signal 2 +#define SP_CLR_SIG3 0x08000 // Bit 15: Clear signal 3 +#define SP_SET_SIG3 0x10000 // Bit 16: Set signal 3 +#define SP_CLR_SIG4 0x20000 // Bit 17: Clear signal 4 +#define SP_SET_SIG4 0x40000 // Bit 18: Set signal 4 +#define SP_CLR_SIG5 0x80000 // Bit 19: Clear signal 5 +#define SP_SET_SIG5 0x100000 // Bit 20: Set signal 5 +#define SP_CLR_SIG6 0x200000 // Bit 21: Clear signal 6 +#define SP_SET_SIG6 0x400000 // Bit 22: Set signal 6 +#define SP_CLR_SIG7 0x800000 // Bit 23: Clear signal 7 +#define SP_SET_SIG7 0x1000000 // Bit 24: Set signal 7 -#define DPC_CLR_XBUS_DMEM_DMA 0x0001 // Bit 0: clear xbus_dmem_dma -#define DPC_SET_XBUS_DMEM_DMA 0x0002 // Bit 1: set xbus_dmem_dma -#define DPC_CLR_FREEZE 0x0004 // Bit 2: clear freeze -#define DPC_SET_FREEZE 0x0008 // Bit 3: set freeze -#define DPC_CLR_FLUSH 0x0010 // Bit 4: clear flush -#define DPC_SET_FLUSH 0x0020 // Bit 5: set flush -#define DPC_CLR_TMEM_CTR 0x0040 // Bit 6: clear TMEM CTR -#define DPC_CLR_PIPE_CTR 0x0080 // Bit 7: clear pipe CTR -#define DPC_CLR_CMD_CTR 0x0100 // Bit 8: clear CMD CTR -#define DPC_CLR_CLOCK_CTR 0x0200 // Bit 9: clear clock CTR +#define DPC_CLR_XBUS_DMEM_DMA 0x0001 // Bit 0: Clear xbus_dmem_dma +#define DPC_SET_XBUS_DMEM_DMA 0x0002 // Bit 1: Set xbus_dmem_dma +#define DPC_CLR_FREEZE 0x0004 // Bit 2: Clear freeze +#define DPC_SET_FREEZE 0x0008 // Bit 3: Set freeze +#define DPC_CLR_FLUSH 0x0010 // Bit 4: Clear flush +#define DPC_SET_FLUSH 0x0020 // Bit 5: Set flush +#define DPC_CLR_TMEM_CTR 0x0040 // Bit 6: Clear TMEM CTR +#define DPC_CLR_PIPE_CTR 0x0080 // Bit 7: Clear pipe CTR +#define DPC_CLR_CMD_CTR 0x0100 // Bit 8: Clear CMD CTR +#define DPC_CLR_CLOCK_CTR 0x0200 // Bit 9: Clear clock CTR #define DPC_STATUS_XBUS_DMEM_DMA 0x001 // Bit 0: xbus_dmem_dma -#define DPC_STATUS_FREEZE 0x002 // Bit 1: freeze -#define DPC_STATUS_FLUSH 0x004 // Bit 2: flush -#define DPC_STATUS_START_GCLK 0x008 // Bit 3: start GCLK +#define DPC_STATUS_FREEZE 0x002 // Bit 1: Freeze +#define DPC_STATUS_FLUSH 0x004 // Bit 2: Flush +#define DPC_STATUS_START_GCLK 0x008 // Bit 3: Start GCLK #define DPC_STATUS_TMEM_BUSY 0x010 // Bit 4: TMEM busy -#define DPC_STATUS_PIPE_BUSY 0x020 // Bit 5: pipe busy +#define DPC_STATUS_PIPE_BUSY 0x020 // Bit 5: Pipe busy #define DPC_STATUS_CMD_BUSY 0x040 // Bit 6: CMD busy #define DPC_STATUS_CBUF_READY 0x080 // Bit 7: CBUF ready #define DPC_STATUS_DMA_BUSY 0x100 // Bit 8: DMA busy -#define DPC_STATUS_END_VALID 0x200 // Bit 9: end valid -#define DPC_STATUS_START_VALID 0x400 // Bit 10: start valid +#define DPC_STATUS_END_VALID 0x200 // Bit 9: End valid +#define DPC_STATUS_START_VALID 0x400 // Bit 10: Start valid #define R4300i_SP_Intr 0x1 diff --git a/Source/RSP/Recompiler Analysis.c b/Source/RSP/Recompiler Analysis.c index 83c9aff60..a1c818f09 100644 --- a/Source/RSP/Recompiler Analysis.c +++ b/Source/RSP/Recompiler Analysis.c @@ -11,12 +11,11 @@ //#define COMPARE_INSTRUCTIONS_VERBOSE -/************************************************************ -** IsOpcodeNop -** -** Output: Boolean whether opcode at PC is a NOP -** Input: PC -*************************************************************/ +/* +IsOpcodeNop +Output: Boolean whether opcode at PC is a NOP +Input: PC +*/ Boolean IsOpcodeNop(DWORD PC) { @@ -30,12 +29,11 @@ Boolean IsOpcodeNop(DWORD PC) return FALSE; } -/************************************************************ -** IsNextInstructionMmx -** -** Output: determines EMMS status -** Input: PC -*************************************************************/ +/* +IsNextInstructionMmx +Output: Determines EMMS status +Input: PC +*/ Boolean IsNextInstructionMmx(DWORD PC) { @@ -98,15 +96,13 @@ Boolean IsNextInstructionMmx(DWORD PC) return FALSE; } -/************************************************************ -** WriteToAccum2 -** -** Output: -** TRUE: Accumulation series -** FALSE: Accumulator is reset after this op -** -** Input: PC, location in accumulator -*************************************************************/ +/* +WriteToAccum2 +Output: +True: Accumulation series +False: Accumulator is reset after this op +Input: PC, location in accumulator +*/ #define HIT_BRANCH 0x2 @@ -180,7 +176,7 @@ DWORD WriteToAccum2(int Location, int PC, Boolean RecursiveCall) if (Compiler.bAudioUcode && (((int)(RspOp.target << 2) & 0xFFC) < PC)) { return FALSE; } - // Rarely occurs let them have their way + // Rarely occurs, so we let them have their way else { Instruction_State = DO_DELAY_SLOT; break; @@ -378,7 +374,7 @@ DWORD WriteToAccum2(int Location, int PC, Boolean RecursiveCall) if (BranchImmed < 0) { if (BranchTaken != FALSE) { - // took this back branch and found a place + // Took this back branch and found a place // that needs this vector as a source return TRUE; @@ -414,14 +410,13 @@ Boolean WriteToAccum(int Location, int PC) return value; } -/************************************************************ -** WriteToVectorDest -** -** Output: -** TRUE: Destination is used as a source later -** FALSE: Destination is over-written later -** Input: PC, Register -*************************************************************/ +/* +WriteToVectorDest +Output: +True: Destination is used as a source later +False: Destination is overwritten later +Input: PC, Register +*/ Boolean WriteToVectorDest2(DWORD DestReg, int PC, Boolean RecursiveCall) { @@ -495,7 +490,7 @@ Boolean WriteToVectorDest2(DWORD DestReg, int PC, Boolean RecursiveCall) if (Compiler.bAudioUcode && (int)(RspOp.target << 2) < PC) { return FALSE; } - // Rarely occurs let them have their way + // Rarely occurs, so we let them have their way return TRUE; case RSP_JAL: @@ -751,16 +746,15 @@ Boolean WriteToVectorDest(DWORD DestReg, int PC) return value; } -/************************************************************ -** UseRspFlags -** -** Output: -** TRUE: Flags are determined not in use -** FALSE: Either unable to determine or are in use -** Input: PC -*************************************************************/ +/* +UseRspFlags +Output: +True: Flags are determined not in use +False: Either unable to determine or are in use +Input: PC +*/ -// TODO: consider delay slots and such in a branch? +// TODO: Consider delay slots and such in a branch? Boolean UseRspFlags(int PC) { OPCODE RspOp; @@ -977,14 +971,13 @@ Boolean UseRspFlags(int PC) return TRUE; } -/************************************************************ -** IsRegisterConstant -** -** Output: -** TRUE: Register is constant throughout -** FALSE: Register is not constant at all -** Input: PC, Pointer to constant to fill -*************************************************************/ +/* +IsRegisterConstant +Output: +True: Register is constant throughout +False: Register is not constant at all +Input: PC, Pointer to constant to fill +*/ Boolean IsRegisterConstant(DWORD Reg, DWORD * Constant) { @@ -1153,14 +1146,13 @@ Boolean IsRegisterConstant(DWORD Reg, DWORD * Constant) } } -/************************************************************ -** IsOpcodeBranch -** -** Output: -** TRUE: opcode is a branch -** FALSE: opcode is not a branch -** Input: PC -*************************************************************/ +/* +IsOpcodeBranch +Output: +True: Opcode is a branch +False: Opcode is not a branch +Input: PC +*/ Boolean IsOpcodeBranch(DWORD PC, OPCODE RspOp) { @@ -1252,17 +1244,14 @@ Boolean IsOpcodeBranch(DWORD PC, OPCODE RspOp) return FALSE; } -/************************************************************ -** GetInstructionInfo -** -** Output: None in regard to return value -** -** Input: -** pointer to info structure, fills this -** with valid opcode data -*************************************************************/ +/* +GetInstructionInfo +Output: None in regard to return value +Input: Pointer to info structure, fills this +with valid opcode data +*/ -// 3 possible values, GPR, VEC, VEC & GPR, NOOP is zero +// 3 possible values, GPR, VEC, VEC and GPR, NOOP is zero #define GPR_Instruction 0x0001 /* GPR Instruction flag */ #define VEC_Instruction 0x0002 /* Vec Instruction flag */ #define COPO_MF_Instruction 0x0080 /* MF Cop 0 Instruction */ @@ -1631,15 +1620,13 @@ void GetInstructionInfo(DWORD PC, OPCODE * RspOp, OPCODE_INFO * info) { } } -/************************************************************ -** DelaySlotAffectBranch -** -** Output: -** TRUE: Delay slot does affect the branch -** FALSE: Registers do not affect each other -** -** Input: PC -*************************************************************/ +/* +DelaySlotAffectBranch +Output: +True: Delay slot does affect the branch +False: Registers do not affect each other +Input: PC +*/ Boolean DelaySlotAffectBranch(DWORD PC) { @@ -1673,17 +1660,14 @@ Boolean DelaySlotAffectBranch(DWORD PC) return FALSE; } -/************************************************************ -** CompareInstructions -** -** Output: -** TRUE: The opcodes are fine, no dependency -** FALSE: Watch it, these ops cant be touched -** -** Input: -** Top, not the current operation, the one above -** Bottom: the current opcode for re-ordering bubble style -*************************************************************/ +/* +CompareInstructions +Output: +TRUE: The opcodes are fine, no dependency +FALSE: Watch it, these ops cant be touched +Input: Top, not the current operation, the one above +Bottom: The current opcode for re-ordering bubble style +*/ Boolean CompareInstructions(DWORD PC, OPCODE * Top, OPCODE * Bottom) { @@ -1734,10 +1718,9 @@ Boolean CompareInstructions(DWORD PC, OPCODE * Top, OPCODE * Bottom) case 0x0A: // Vector then Vector - 10,10 /* - ** Check for vector store then vector multiply (VMULF) - ** - ** This basically gives preferences to putting stores - ** as close to the finish of an operation as possible + Check for vector store then vector multiply (VMULF) + This basically gives preferences to putting stores + as close to the finish of an operation as possible */ if ((info0.flags & Store_Operation) != 0 && (info1.flags & Accum_Operation) != 0 @@ -1755,7 +1738,7 @@ Boolean CompareInstructions(DWORD PC, OPCODE * Top, OPCODE * Bottom) return FALSE; } else if ((info1.flags & MemOperation_Mask) != 0) { - // Remember stored REG & loaded REG are the same + // Remember stored REG and loaded REG are the same if (info0.DestReg == info1.DestReg) { return FALSE; } if (info1.flags & Load_Operation) { @@ -1768,7 +1751,7 @@ Boolean CompareInstructions(DWORD PC, OPCODE * Top, OPCODE * Bottom) return TRUE; } else if ((info0.flags & MemOperation_Mask) != 0) { - // Remember stored REG & loaded REG are the same + // Remember stored REG and loaded REG are the same if (info0.DestReg == info1.DestReg) { return FALSE; } if (info0.flags & Load_Operation) { @@ -1783,27 +1766,27 @@ Boolean CompareInstructions(DWORD PC, OPCODE * Top, OPCODE * Bottom) } else if ((info0.flags & VEC_Accumulate) != 0) { /* - ** Example: - ** VMACF - ** VMUDH or VMADH or VADD + Example: + VMACF + VMUDH or VMADH or VADD */ return FALSE; } else if ((info1.flags & VEC_Accumulate) != 0) { /* - ** Example: - ** VMULF - ** VMADH + Example: + VMULF + VMADH */ return FALSE; } else { /* - ** Example: - ** VMULF or VADDC - ** VADD or VMUDH + Example: + VMULF or VADDC + VADD or VMUDH */ return FALSE; @@ -1827,35 +1810,35 @@ Boolean CompareInstructions(DWORD PC, OPCODE * Top, OPCODE * Bottom) case 0x0B: // Vector then COP2 - 10, 11 if (info1.flags & Load_Operation) { - // Move To COP2 (destination) from GPR (source) + // Move to COP2 (destination) from GPR (source) if (info1.DestReg == info0.DestReg) { return FALSE; } if (info1.DestReg == info0.SourceReg0) { return FALSE; } if (info1.DestReg == info0.SourceReg1) { return FALSE; } } else if (info1.flags & Store_Operation) { - // Move From COP2 (source) to GPR (destination) + // Move from COP2 (source) to GPR (destination) if (info1.SourceReg0 == info0.DestReg) { return FALSE; } if (info1.SourceReg0 == info0.SourceReg0) { return FALSE; } if (info1.SourceReg0 == info0.SourceReg1) { return FALSE; } } else { - CompilerWarning("Reorder: Unhandled Vector than COP2"); + CompilerWarning("Reorder: unhandled vector than COP2"); } // We want vectors on top return FALSE; case 0x0E: // COP2 then Vector - 11, 10 if (info0.flags & Load_Operation) { - // Move To COP2 (destination) from GPR (source) + // Move to COP2 (destination) from GPR (source) if (info0.DestReg == info1.DestReg) { return FALSE; } if (info0.DestReg == info1.SourceReg0) { return FALSE; } if (info0.DestReg == info1.SourceReg1) { return FALSE; } } else if (info0.flags & Store_Operation) { - // Move From COP2 (source) to GPR (destination) + // Move from COP2 (source) to GPR (destination) if (info0.SourceReg0 == info1.DestReg) { return FALSE; } if (info0.SourceReg0 == info1.SourceReg0) { return FALSE; } if (info0.SourceReg0 == info1.SourceReg1) { return FALSE; } if (info0.DestReg == info1.SourceReg0) { return FALSE; } } else { - CompilerWarning("Reorder: Unhandled COP2 than Vector"); + CompilerWarning("Reorder: unhandled COP2 than vector"); } // We want this at the top return TRUE; diff --git a/Source/RSP/Recompiler CPU.c b/Source/RSP/Recompiler CPU.c index a316f17b7..3bcb24871 100644 --- a/Source/RSP/Recompiler CPU.c +++ b/Source/RSP/Recompiler CPU.c @@ -401,14 +401,13 @@ void BuildRecompilerCPU ( void ) { #endif } -/****************************************************** -** ReOrderSubBlock -** -** Description: -** This can be done, but will be interesting to put -** between branches labels, and actual branches, whichever -** occurs first in code -********************************************************/ +/* +ReOrderSubBlock +Description: +This can be done, but will be interesting to put +between branches labels, and actual branches, whichever +occurs first in code +*/ void ReOrderInstructions(DWORD StartPC, DWORD EndPC) { DWORD InstructionCount = EndPC - StartPC; @@ -509,13 +508,12 @@ void ReOrderSubBlock(RSP_BLOCK * Block) { ReOrderInstructions(Block->CurrPC, end); } -/****************************************************** -** DetectGPRConstants -** -** Description: -** this needs to be called on a sub-block basis, like -** after every time we hit a branch and delay slot -********************************************************/ +/* +DetectGPRConstants +Description: +This needs to be called on a sub-block basis, like +after every time we hit a branch and delay slot +*/ void DetectGPRConstants(RSP_CODE * code) { DWORD Count, Constant = 0; @@ -543,15 +541,13 @@ void DetectGPRConstants(RSP_CODE * code) { CPU_Message(""); } -/****************************************************** -** CompilerToggleBuffer and ClearX86Code -** -** Description: -** 1> toggles the compiler buffer, useful for poorly -** taken branches like alignment -** -** 2> clears all the x86 code, jump tables etc. -********************************************************/ +/* +CompilerToggleBuffer and ClearX86Code +Description: +1: Toggles the compiler buffer, useful for poorly +taken branches like alignment +2: Clears all the x86 code, jump tables etc. +*/ void CompilerToggleBuffer(void) { if (dwBuffer == MainBuffer) { @@ -563,7 +559,7 @@ void CompilerToggleBuffer(void) { } RecompPos = pLastSecondary; - CPU_Message(" (Secondary Buffer Active 0x%08X)", pLastSecondary); + CPU_Message(" (Secondary buffer active 0x%08X)", pLastSecondary); } else { dwBuffer = MainBuffer; pLastSecondary = RecompPos; @@ -573,7 +569,7 @@ void CompilerToggleBuffer(void) { } RecompPos = pLastPrimary; - CPU_Message(" (Primary Buffer Active 0x%08X)", pLastPrimary); + CPU_Message(" (Primary buffer active 0x%08X)", pLastPrimary); } } @@ -591,11 +587,11 @@ void ClearAllx86Code (void) { pLastSecondary = NULL; } -/****************************************************** -** Link Branches -** Description: -** resolves all the collected branches, x86 style -********************************************************/ +/* +Link branches +Description: +Resolves all the collected branches, x86 style +*/ void LinkBranches(RSP_BLOCK * Block) { DWORD OrigPrgCount = *PrgCount; @@ -616,7 +612,7 @@ void LinkBranches(RSP_BLOCK * Block) { if (!X86Code) { *PrgCount = Target; CPU_Message(""); - CPU_Message("===== (Generate Code: %04X) =====", Target); + CPU_Message("===== (Generate code: %04X) =====", Target); Save = *Block; // Compile this block and link @@ -624,7 +620,7 @@ void LinkBranches(RSP_BLOCK * Block) { LinkBranches(Block); *Block = Save; - CPU_Message("===== (End Generate Code: %04X) =====", Target); + CPU_Message("===== (End generate code: %04X) =====", Target); CPU_Message(""); X86Code = *(JumpTable + (Target >> 2)); } @@ -636,18 +632,17 @@ void LinkBranches(RSP_BLOCK * Block) { JumpWord, Target, X86Code); } *PrgCount = OrigPrgCount; - CPU_Message("***** Done Linking Branches *****"); + CPU_Message("***** Done linking branches *****"); CPU_Message(""); } -/****************************************************** -** BuildBranchLabels -** -** Description: -** Branch labels are used to start and stop re-ordering -** sections as well as set the jump table to points -** within a block that are safe -********************************************************/ +/* +BuildBranchLabels +Description: +Branch labels are used to start and stop re-ordering +sections as well as set the jump table to points +within a block that are safe. +*/ void BuildBranchLabels(void) { OPCODE RspOp; @@ -662,12 +657,12 @@ void BuildBranchLabels(void) { if (TRUE == IsOpcodeBranch(i, RspOp)) { if (RspCode.LabelCount >= (sizeof(RspCode.BranchLabels) / sizeof(RspCode.BranchLabels[0])) - 1) { - CompilerWarning("Out of space for Branch Labels"); + CompilerWarning("Out of space for branch labels"); return; } if (RspCode.BranchCount >= (sizeof(RspCode.BranchLocations) / sizeof(RspCode.BranchLocations[0])) - 1) { - CompilerWarning("Out of space for Branch Locations"); + CompilerWarning("Out of space for branch locations"); return; } RspCode.BranchLocations[RspCode.BranchCount++] = i; @@ -749,11 +744,11 @@ void CompilerRSPBlock(void) } } - CPU_Message("====== block %d ======", BlockID++); + CPU_Message("====== Block %d ======", BlockID++); CPU_Message("x86 code at: %X",RecompPos); - CPU_Message("Jump Table: %X",Table ); - CPU_Message("Start of Block: %X",CurrentBlock.StartPC ); - CPU_Message("====== recompiled code ======"); + CPU_Message("Jump table: %X",Table ); + CPU_Message("Start of block: %X",CurrentBlock.StartPC ); + CPU_Message("====== Recompiled code ======"); if (Compiler.bReOrdering == TRUE) { memcpy(IMEM_SAVE, RSPInfo.IMEM, 0x1000); @@ -771,7 +766,7 @@ void CompilerRSPBlock(void) if (NextInstruction == NORMAL && IsJumpLabel(CompilePC)) { // Jumps come around twice if (NULL == *(JumpTable + (CompilePC >> 2))) { - CPU_Message("***** Adding Jump Table Entry for PC: %04X at X86: %08X *****", CompilePC, RecompPos); + CPU_Message("***** Adding jump table entry for PC: %04X at X86: %08X *****", CompilePC, RecompPos); CPU_Message(""); *(JumpTable + (CompilePC >> 2)) = RecompPos; @@ -809,7 +804,7 @@ void CompilerRSPBlock(void) if (RSPOpC.Hex == 0xFFFFFFFF) { // I think this pops up an unknown OP dialog - /* NextInstruction = FINISH_BLOCK; */ + // NextInstruction = FINISH_BLOCK; } else { RSP_Opcode[ RSPOpC.op ](); } @@ -837,7 +832,7 @@ void CompilerRSPBlock(void) NextInstruction = FINISH_BLOCK; } else if (NULL == *(JumpTable + (CompilePC >> 2))) { // This is for the new block being compiled now - CPU_Message("**** Continuing static SubBlock (jump table entry added for PC: %04X at X86: %08X) *****", CompilePC, RecompPos); + CPU_Message("***** Continuing static SubBlock (jump table entry added for PC: %04X at X86: %08X) *****", CompilePC, RecompPos); *(JumpTable + (CompilePC >> 2)) = RecompPos; CurrentBlock.CurrPC = CompilePC; @@ -850,12 +845,12 @@ void CompilerRSPBlock(void) case FINISH_BLOCK: break; default: - DisplayError("Rsp Main loop\n\nWTF NextInstruction = %d",NextInstruction); + DisplayError("RSP main loop\n\nWTF NextInstruction = %d",NextInstruction); CompilePC += 4; break; } } while (NextInstruction != FINISH_BLOCK && (CompilePC < 0x1000 || NextInstruction == DELAY_SLOT)); - CPU_Message("==== End of recompiled code ===="); + CPU_Message("===== End of recompiled code ====="); if (Compiler.bReOrdering == TRUE) { memcpy(RSPInfo.IMEM, IMEM_SAVE, 0x1000); diff --git a/Source/RSP/Recompiler Ops.c b/Source/RSP/Recompiler Ops.c index e4ebf97ca..9acbac180 100644 --- a/Source/RSP/Recompiler Ops.c +++ b/Source/RSP/Recompiler Ops.c @@ -38,7 +38,7 @@ DWORD BranchCompare = 0; #ifdef RSP_VectorMuls # define CompileVmulf // Verified 12/17/2000 - Jabo -# define CompileVmacf // Rewritten and Verified 12/15/2000 - Jabo +# define CompileVmacf // Rewritten and verified 12/15/2000 - Jabo # define CompileVmudm // Verified 12/17/2000 - Jabo # define CompileVmudh // Verified 12/17/2000 - Jabo # define CompileVmudn // Verified 12/17/2000 - Jabo @@ -80,7 +80,7 @@ DWORD BranchCompare = 0; # define CompileSqv // Verified 12/17/2000 - Jabo # define CompileSdv // Verified 12/17/2000 - Jabo # define CompileSsv // Verified 12/17/2000 - Jabo -# define CompileLrv // Rewritten & Verified 12/17/2000 - Jabo +# define CompileLrv // Rewritten and verified 12/17/2000 - Jabo # define CompileLqv // Verified 12/17/2000 - Jabo # define CompileLdv // Verified 12/17/2000 - Jabo # define CompileLsv // Verified 12/17/2000 - Jabo @@ -158,7 +158,7 @@ void CompileBranchExit(DWORD TargetPC, DWORD ContinuePC) Ret(); } -// OpCode functions +// Opcode functions void Compile_SPECIAL ( void ) { RSP_Special[ RSPOpC.funct ](); @@ -670,13 +670,13 @@ void Compile_LH ( void ) { Cheat_r4300iOpcodeNoMessage(RSP_Opcode_LH,"RSP_Opcode_LH"); } else { char Address[32]; - sprintf(Address, "Dmem + %Xh", Addr); + sprintf(Address, "DMEM + %Xh", Addr); MoveSxVariableToX86regHalf(RSPInfo.DMEM + (Addr ^ 2), Address, x86_EAX); MoveX86regToVariable(x86_EAX, &RSP_GPR[RSPOpC.rt].UW, GPR_Name(RSPOpC.rt)); } } else { char Address[32]; - sprintf(Address, "Dmem + %Xh", Addr); + sprintf(Address, "DMEM + %Xh", Addr); MoveSxVariableToX86regHalf(RSPInfo.DMEM + Addr, Address, x86_EAX); MoveX86regToVariable(x86_EAX, &RSP_GPR[RSPOpC.rt].UW, GPR_Name(RSPOpC.rt)); } @@ -732,16 +732,16 @@ void Compile_LW ( void ) { Cheat_r4300iOpcodeNoMessage(RSP_Opcode_LW,"RSP_Opcode_LW"); } else if ((Addr & 2) != 0) { char Address[32]; - sprintf(Address, "Dmem + %Xh", Addr - 2); + sprintf(Address, "DMEM + %Xh", Addr - 2); MoveVariableToX86regHalf(RSPInfo.DMEM + Addr - 2, Address, x86_EAX); - sprintf(Address, "Dmem + %Xh", Addr); + sprintf(Address, "DMEM + %Xh", Addr); MoveVariableToX86regHalf(RSPInfo.DMEM + Addr + 4, Address, x86_ECX); MoveX86regHalfToVariable(x86_EAX, &RSP_GPR[RSPOpC.rt].UHW[1], GPR_Name(RSPOpC.rt)); MoveX86regHalfToVariable(x86_ECX, &RSP_GPR[RSPOpC.rt].UHW[0], GPR_Name(RSPOpC.rt)); } else { char Address[32]; - sprintf(Address, "Dmem + %Xh", Addr); + sprintf(Address, "DMEM + %Xh", Addr); MoveVariableToX86reg(RSPInfo.DMEM + Addr, Address, x86_EAX); MoveX86regToVariable(x86_EAX, &RSP_GPR[RSPOpC.rt].UW, GPR_Name(RSPOpC.rt)); } @@ -753,7 +753,7 @@ void Compile_LW ( void ) { AndConstToX86Reg(x86_EBX, 0x0fff); TestConstToX86Reg(3, x86_EBX); - JneLabel32("UnAligned", 0); + JneLabel32("Unaligned", 0); Jump[0] = RecompPos - 4; CompilerToggleBuffer(); @@ -806,7 +806,7 @@ void Compile_LBU ( void ) { DWORD Addr = (MipsRegConst(RSPOpC.base) + Offset) ^ 3; Addr &= 0xfff; - sprintf(Address, "Dmem + %Xh", Addr); + sprintf(Address, "DMEM + %Xh", Addr); MoveZxVariableToX86regByte(RSPInfo.DMEM + Addr, Address, x86_EAX); MoveX86regToVariable(x86_EAX, &RSP_GPR[RSPOpC.rt].UW, GPR_Name(RSPOpC.rt)); return; @@ -845,14 +845,14 @@ void Compile_LHU ( void ) { Cheat_r4300iOpcodeNoMessage(RSP_Opcode_LHU, "RSP_Opcode_LHU"); } else { char Address[32]; - sprintf(Address, "Dmem + %Xh", Addr); + sprintf(Address, "DMEM + %Xh", Addr); MoveZxVariableToX86regHalf(RSPInfo.DMEM + (Addr ^ 2), Address, x86_ECX); MoveX86regToVariable(x86_ECX, &RSP_GPR[RSPOpC.rt].UW, GPR_Name(RSPOpC.rt)); } return; } else { char Address[32]; - sprintf(Address, "Dmem + %Xh", Addr); + sprintf(Address, "DMEM + %Xh", Addr); MoveZxVariableToX86regHalf(RSPInfo.DMEM + Addr, Address, x86_ECX); MoveX86regToVariable(x86_ECX, &RSP_GPR[RSPOpC.rt].UW, GPR_Name(RSPOpC.rt)); return; @@ -899,7 +899,7 @@ void Compile_SB ( void ) { char Address[32]; DWORD Addr = (MipsRegConst(RSPOpC.base) + Offset) ^ 3; Addr &= 0xfff; - sprintf(Address, "Dmem + %Xh", Addr); + sprintf(Address, "DMEM + %Xh", Addr); if (IsRegConst(RSPOpC.rt) == TRUE) { MoveConstByteToVariable(MipsRegConst(RSPOpC.rt), RSPInfo.DMEM + Addr, Address); @@ -951,7 +951,7 @@ void Compile_SH ( void ) { return; } else { char Address[32]; - sprintf(Address, "Dmem + %Xh", Addr); + sprintf(Address, "DMEM + %Xh", Addr); if (IsRegConst(RSPOpC.rt) == TRUE) { MoveConstHalfToVariable(MipsRegConst(RSPOpC.rt), RSPInfo.DMEM + Addr, Address); } else { @@ -1015,13 +1015,13 @@ void Compile_SW ( void ) { } if (IsRegConst(RSPOpC.rt) == TRUE) { DWORD Value = MipsRegConst(RSPOpC.rt); - sprintf(Address, "Dmem + %Xh", (Addr + 0) ^ 3); + sprintf(Address, "DMEM + %Xh", (Addr + 0) ^ 3); MoveConstByteToVariable((Value >> 24) & 0xFF, RSPInfo.DMEM + ((Addr + 0) ^ 3), Address); - sprintf(Address, "Dmem + %Xh", (Addr + 1) ^ 3); + sprintf(Address, "DMEM + %Xh", (Addr + 1) ^ 3); MoveConstByteToVariable((Value >> 16) & 0xFF, RSPInfo.DMEM + ((Addr + 1) ^ 3), Address); - sprintf(Address, "Dmem + %Xh", (Addr + 2) ^ 3); + sprintf(Address, "DMEM + %Xh", (Addr + 2) ^ 3); MoveConstByteToVariable((Value >> 8) & 0xFF, RSPInfo.DMEM + ((Addr + 2) ^ 3), Address); - sprintf(Address, "Dmem + %Xh", (Addr + 3) ^ 3); + sprintf(Address, "DMEM + %Xh", (Addr + 3) ^ 3); MoveConstByteToVariable((Value >> 0) & 0xFF, RSPInfo.DMEM + ((Addr + 3) ^ 3), Address); } else { CompilerWarning("Unaligned SW at constant address PC = %04X", CompilePC); @@ -1029,7 +1029,7 @@ void Compile_SW ( void ) { } return; } else { - sprintf(Address, "Dmem + %Xh", Addr); + sprintf(Address, "DMEM + %Xh", Addr); if (IsRegConst(RSPOpC.rt) == TRUE) { MoveConstToVariable(MipsRegConst(RSPOpC.rt), RSPInfo.DMEM + Addr, Address); @@ -1061,8 +1061,8 @@ void Compile_SW ( void ) { LeaSourceAndOffset(x86_EDX , x86_EBX, 3); XorConstToX86Reg(x86_ECX, 3); XorConstToX86Reg(x86_EDX, 3); - MoveVariableToX86regByte(&RSP_GPR[RSPOpC.rt].UB[1], GPR_Name(RSPOpC.rt),x86_EAX); //cx - MoveVariableToX86regByte(&RSP_GPR[RSPOpC.rt].UB[0], GPR_Name(RSPOpC.rt),x86_EBX); //dx + MoveVariableToX86regByte(&RSP_GPR[RSPOpC.rt].UB[1], GPR_Name(RSPOpC.rt),x86_EAX); // CX + MoveVariableToX86regByte(&RSP_GPR[RSPOpC.rt].UB[0], GPR_Name(RSPOpC.rt),x86_EBX); // DX MoveX86regByteToN64Mem(x86_EAX, x86_ECX); MoveX86regByteToN64Mem(x86_EBX, x86_EDX); Pop(x86_EBX); @@ -1072,8 +1072,8 @@ void Compile_SW ( void ) { XorConstToX86Reg(x86_EAX, 3); XorConstToX86Reg(x86_EBX, 3); - MoveVariableToX86regByte(&RSP_GPR[RSPOpC.rt].UB[3], GPR_Name(RSPOpC.rt),x86_ECX); //ax - MoveVariableToX86regByte(&RSP_GPR[RSPOpC.rt].UB[2], GPR_Name(RSPOpC.rt),x86_EDX); //bx + MoveVariableToX86regByte(&RSP_GPR[RSPOpC.rt].UB[3], GPR_Name(RSPOpC.rt),x86_ECX); // AX + MoveVariableToX86regByte(&RSP_GPR[RSPOpC.rt].UB[2], GPR_Name(RSPOpC.rt),x86_EDX); // BX MoveX86regByteToN64Mem(x86_ECX, x86_EAX); MoveX86regByteToN64Mem(x86_EDX, x86_EBX); @@ -1102,7 +1102,7 @@ void Compile_SC2 (void) { RSP_Sc2 [ RSPOpC.rd ](); } -// R4300i OpCodes: Special +// R4300i Opcodes: Special void Compile_Special_SLL ( void ) { #ifndef Compile_Special @@ -1500,7 +1500,7 @@ void Compile_Special_SLTU ( void ) { Cheat_r4300iOpcode(RSP_Special_SLTU,"RSP_Special_SLTU"); } -// R4300i OpCodes: RegImm +// R4300i Opcodes: RegImm void Compile_RegImm_BLTZ(void) { @@ -1787,7 +1787,7 @@ void Compile_Cop0_MF ( void ) { break; default: - DisplayError("have not implemented RSP MF CP0 reg %s (%d)",COP0_Name(RSPOpC.rd),RSPOpC.rd); + DisplayError("We have not implemented RSP MF CP0 reg %s (%d)",COP0_Name(RSPOpC.rd),RSPOpC.rd); } #endif } @@ -2099,7 +2099,7 @@ void RSP_MultiElement2Mmx(int MmxReg1, int MmxReg2) { * We must perform this swap correctly, this involves the 3-bit * exclusive or, 2-bits of which are done within a DWORD boundary, * the last bit, is ignored because we are loading the source linearly, - * so the exclusive or has transparently happened on that side + * so the exclusive or has transparently happened on that side. */ switch (Rs) { @@ -2421,11 +2421,11 @@ Boolean Compile_Vector_VMUDM_MMX(void) MmxMoveRegToReg(x86_MM2, x86_MM0); MmxMoveRegToReg(x86_MM3, x86_MM1); - /* high((u16)a * b) */ + // high((u16)a * b) MmxPmulhuwRegToReg(x86_MM0, x86_MM4); MmxPmulhuwRegToReg(x86_MM1, x86_MM5); - /* low((a >> 15) * b) */ + // low((a >> 15) * b) MmxPsrawImmed(x86_MM2, 15); MmxPsrawImmed(x86_MM3, 15); MmxPmullwRegToReg(x86_MM2, x86_MM4); @@ -2437,11 +2437,11 @@ Boolean Compile_Vector_VMUDM_MMX(void) MmxMoveRegToReg(x86_MM2, x86_MM0); MmxMoveRegToReg(x86_MM3, x86_MM1); - /* high((u16)a * b) */ + // high((u16)a * b) MmxPmulhuwRegToReg(x86_MM0, x86_MM4); MmxPmulhuwRegToReg(x86_MM1, x86_MM4); - /* low((a >> 15) * b) */ + // low((a >> 15) * b) MmxPsrawImmed(x86_MM2, 15); MmxPsrawImmed(x86_MM3, 15); MmxPmullwRegToReg(x86_MM2, x86_MM4); @@ -2453,11 +2453,11 @@ Boolean Compile_Vector_VMUDM_MMX(void) MmxMoveRegToReg(x86_MM2, x86_MM0); MmxMoveRegToReg(x86_MM3, x86_MM1); - /* high((u16)a * b) */ + // high((u16)a * b) MmxPmulhuwRegToReg(x86_MM0, x86_MM4); MmxPmulhuwRegToReg(x86_MM1, x86_MM5); - /* low((a >> 15) * b) */ + // low((a >> 15) * b) MmxPsrawImmed(x86_MM2, 15); MmxPsrawImmed(x86_MM3, 15); MmxPmullwRegToReg(x86_MM2, x86_MM4); @@ -3664,7 +3664,7 @@ void Compile_Vector_VABS ( void ) { CompConstToX86reg(x86_EBX, 0x00008000); CondMoveEqual(x86_EBX, x86_ECX); - /* sign clamp, dest = (eax >= 0) ? eax : ebx */ + // sign clamp, dest = (eax >= 0) ? eax : ebx CompConstToX86reg(x86_EAX, 0); CondMoveLess(x86_EAX, x86_EBX); @@ -3696,7 +3696,7 @@ void Compile_Vector_VABS ( void ) { CompConstToX86reg(x86_EBX, 0x00008000); CondMoveEqual(x86_EBX, x86_EDX); - /* sign clamp, dest = (eax >= 0) ? ecx : ebx */ + // sign clamp, dest = (eax >= 0) ? ecx : ebx CompConstToX86reg(x86_EAX, 0); CondMoveGreaterEqual(x86_EDI, x86_ECX); CondMoveLess(x86_EDI, x86_EBX); @@ -5151,9 +5151,9 @@ void Compile_Opcode_LSV ( void ) { DWORD Addr = (MipsRegConst(RSPOpC.base) + offset) & 0xfff; if ((Addr & 1) != 0) { - sprintf(Reg, "Dmem + %Xh", (Addr + 0) ^ 3); + sprintf(Reg, "DMEM + %Xh", (Addr + 0) ^ 3); MoveVariableToX86regByte(RSPInfo.DMEM + ((Addr + 0) ^ 3), Reg, x86_ECX); - sprintf(Reg, "Dmem + %Xh", (Addr + 1) ^ 3); + sprintf(Reg, "DMEM + %Xh", (Addr + 1) ^ 3); MoveVariableToX86regByte(RSPInfo.DMEM + ((Addr + 1) ^ 3), Reg, x86_EDX); sprintf(Reg, "RSP_Vect[%i].B[%i]", RSPOpC.rt, 15 - (RSPOpC.del + 0)); @@ -5161,7 +5161,7 @@ void Compile_Opcode_LSV ( void ) { sprintf(Reg, "RSP_Vect[%i].B[%i]", RSPOpC.rt, 15 - (RSPOpC.del + 1)); MoveX86regByteToVariable(x86_EDX, &RSP_Vect[RSPOpC.rt].B[15 - (RSPOpC.del + 1)], Reg); } else { - sprintf(Reg, "Dmem + %Xh", Addr ^ 2); + sprintf(Reg, "DMEM + %Xh", Addr ^ 2); MoveVariableToX86regHalf(RSPInfo.DMEM + (Addr ^ 2), Reg, x86_EDX); sprintf(Reg, "RSP_Vect[%i].B[%i]", RSPOpC.rt, 15 - (RSPOpC.del + 1)); MoveX86regHalfToVariable(x86_EDX, &RSP_Vect[RSPOpC.rt].B[15 - (RSPOpC.del + 1)], Reg); @@ -5219,7 +5219,7 @@ void Compile_Opcode_LLV ( void ) { return; } - sprintf(Reg, "Dmem + %Xh", Addr); + sprintf(Reg, "DMEM + %Xh", Addr); MoveVariableToX86reg(RSPInfo.DMEM + Addr, Reg, x86_EAX); sprintf(Reg, "RSP_Vect[%i].B[%i]", RSPOpC.rt, 16 - RSPOpC.del - 4); MoveX86regToVariable(x86_EAX, &RSP_Vect[RSPOpC.rt].B[16 - RSPOpC.del - 4], Reg); @@ -5269,7 +5269,6 @@ void Compile_Opcode_LDV ( void ) { CPU_Message(" %X %s",CompilePC,RSPOpcodeName(RSPOpC.Hex,CompilePC)); - // TODO: Conker's hits this //if ((RSPOpC.del & 0x7) != 0) { // rsp_UnknownOpcode(); // return; @@ -5289,9 +5288,9 @@ void Compile_Opcode_LDV ( void ) { return; } - sprintf(Reg, "Dmem + %Xh", Addr); + sprintf(Reg, "DMEM + %Xh", Addr); MoveVariableToX86reg(RSPInfo.DMEM + Addr + 0, Reg, x86_EAX); - sprintf(Reg, "Dmem + %Xh", Addr + 4); + sprintf(Reg, "DMEM + %Xh", Addr + 4); MoveVariableToX86reg(RSPInfo.DMEM + Addr + 4, Reg, x86_ECX); sprintf(Reg, "RSP_Vect[%i].B[%i]", RSPOpC.rt, 16 - RSPOpC.del - 4); @@ -5390,13 +5389,13 @@ void Compile_Opcode_LQV ( void ) { // Aligned store if (IsSseEnabled == FALSE) { - sprintf(Reg, "Dmem+%Xh+0", Addr); + sprintf(Reg, "DMEM+%Xh+0", Addr); MoveVariableToX86reg(RSPInfo.DMEM + Addr + 0, Reg, x86_EAX); - sprintf(Reg, "Dmem+%Xh+4", Addr); + sprintf(Reg, "DMEM+%Xh+4", Addr); MoveVariableToX86reg(RSPInfo.DMEM + Addr + 4, Reg, x86_EBX); - sprintf(Reg, "Dmem+%Xh+8", Addr); + sprintf(Reg, "DMEM+%Xh+8", Addr); MoveVariableToX86reg(RSPInfo.DMEM + Addr + 8, Reg, x86_ECX); - sprintf(Reg, "Dmem+%Xh+C", Addr); + sprintf(Reg, "DMEM+%Xh+C", Addr); MoveVariableToX86reg(RSPInfo.DMEM + Addr + 12, Reg, x86_EDX); sprintf(Reg, "RSP_Vect[%i].B[12]", RSPOpC.rt); @@ -5408,7 +5407,7 @@ void Compile_Opcode_LQV ( void ) { sprintf(Reg, "RSP_Vect[%i].B[0]", RSPOpC.rt); MoveX86regToVariable(x86_EDX, &RSP_Vect[RSPOpC.rt].B[0], Reg); } else { - sprintf(Reg, "Dmem+%Xh", Addr); + sprintf(Reg, "DMEM+%Xh", Addr); SseMoveUnalignedVariableToReg(RSPInfo.DMEM + Addr, Reg, x86_XMM0); SseShuffleReg(x86_XMM0, x86_MM0, 0x1b); sprintf(Reg, "RSP_Vect[%i].B[0]", RSPOpC.rt); @@ -5901,14 +5900,14 @@ void Compile_Opcode_SSV ( void ) { sprintf(Reg, "RSP_Vect[%i].B[%i]", RSPOpC.rt, 15 - (RSPOpC.del + 1)); MoveVariableToX86regByte(&RSP_Vect[RSPOpC.rt].B[15 - (RSPOpC.del + 1)], Reg, x86_EDX); - sprintf(Reg, "Dmem + %Xh", (Addr + 0) ^ 3); + sprintf(Reg, "DMEM + %Xh", (Addr + 0) ^ 3); MoveX86regByteToVariable(x86_ECX, RSPInfo.DMEM + ((Addr + 0) ^ 3), Reg); - sprintf(Reg, "Dmem + %Xh", (Addr + 1) ^ 3); + sprintf(Reg, "DMEM + %Xh", (Addr + 1) ^ 3); MoveX86regByteToVariable(x86_EDX, RSPInfo.DMEM + ((Addr + 1) ^ 3), Reg); } else { sprintf(Reg, "RSP_Vect[%i].B[%i]", RSPOpC.rt, 15 - (RSPOpC.del + 1)); MoveVariableToX86regHalf(&RSP_Vect[RSPOpC.rt].B[15 - (RSPOpC.del + 1)], Reg, x86_ECX); - sprintf(Reg, "Dmem + %Xh", Addr ^ 2); + sprintf(Reg, "DMEM + %Xh", Addr ^ 2); MoveX86regHalfToVariable(x86_ECX, RSPInfo.DMEM + (Addr ^ 2), Reg); } return; @@ -5965,7 +5964,7 @@ void Compile_Opcode_SLV ( void ) { sprintf(Reg, "RSP_Vect[%i].B[%i]", RSPOpC.rt, 16 - RSPOpC.del - 4); MoveVariableToX86reg(&RSP_Vect[RSPOpC.rt].B[16 - RSPOpC.del - 4], Reg, x86_EAX); - sprintf(Reg, "Dmem + %Xh", Addr); + sprintf(Reg, "DMEM + %Xh", Addr); MoveX86regToVariable(x86_EAX, RSPInfo.DMEM + Addr, Reg); return; } @@ -6032,9 +6031,9 @@ void Compile_Opcode_SDV ( void ) { sprintf(Reg, "RSP_Vect[%i].B[%i]", RSPOpC.rt, (16 - RSPOpC.del - 8) & 0xF); MoveVariableToX86reg(&RSP_Vect[RSPOpC.rt].B[(16 - RSPOpC.del - 8) & 0xF], Reg, x86_EBX); - sprintf(Reg, "Dmem + %Xh", Addr); + sprintf(Reg, "DMEM + %Xh", Addr); MoveX86regToVariable(x86_EAX, RSPInfo.DMEM + Addr, Reg); - sprintf(Reg, "Dmem + %Xh", Addr + 4); + sprintf(Reg, "DMEM + %Xh", Addr + 4); MoveX86regToVariable(x86_EBX, RSPInfo.DMEM + Addr + 4, Reg); return; } @@ -6131,13 +6130,13 @@ void Compile_Opcode_SQV ( void ) { MoveVariableToX86reg(&RSP_Vect[RSPOpC.rt].B[0], Reg, x86_EDX); } - sprintf(Reg, "Dmem+%Xh+0", Addr); + sprintf(Reg, "DMEM+%Xh+0", Addr); MoveX86regToVariable(x86_EAX, RSPInfo.DMEM + Addr + 0, Reg); - sprintf(Reg, "Dmem+%Xh+4", Addr); + sprintf(Reg, "DMEM+%Xh+4", Addr); MoveX86regToVariable(x86_EBX, RSPInfo.DMEM + Addr + 4, Reg); - sprintf(Reg, "Dmem+%Xh+8", Addr); + sprintf(Reg, "DMEM+%Xh+8", Addr); MoveX86regToVariable(x86_ECX, RSPInfo.DMEM + Addr + 8, Reg); - sprintf(Reg, "Dmem+%Xh+C", Addr); + sprintf(Reg, "DMEM+%Xh+C", Addr); MoveX86regToVariable(x86_EDX, RSPInfo.DMEM + Addr + 12, Reg); } else { sprintf(Reg, "RSP_Vect[%i].B[0]", RSPOpC.rt); @@ -6147,7 +6146,7 @@ void Compile_Opcode_SQV ( void ) { } else { SseShuffleReg(x86_XMM0, x86_MM0, 0x1b); } - sprintf(Reg, "Dmem+%Xh", Addr); + sprintf(Reg, "DMEM+%Xh", Addr); SseMoveUnalignedRegToVariable(x86_XMM0, RSPInfo.DMEM + Addr, Reg); } return; diff --git a/Source/RSP/Recompiler Ops.h b/Source/RSP/Recompiler Ops.h index 0223d422c..9f1854414 100644 --- a/Source/RSP/Recompiler Ops.h +++ b/Source/RSP/Recompiler Ops.h @@ -1,4 +1,4 @@ -// OpCode functions +// Opcode functions void Compile_SPECIAL ( void ); void Compile_REGIMM ( void ); @@ -29,7 +29,7 @@ void Compile_SW ( void ); void Compile_LC2 ( void ); void Compile_SC2 ( void ); -// R4300i OpCodes: Special +// R4300i Opcodes: Special void Compile_Special_SLL ( void ); void Compile_Special_SRL ( void ); @@ -51,7 +51,7 @@ void Compile_Special_NOR ( void ); void Compile_Special_SLT ( void ); void Compile_Special_SLTU ( void ); -// R4300i OpCodes: RegImm +// R4300i Opcodes: RegImm void Compile_RegImm_BLTZ ( void ); void Compile_RegImm_BGEZ ( void ); diff --git a/Source/RSP/Recompiler Sections.c b/Source/RSP/Recompiler Sections.c index a92900b90..a84d80c8b 100644 --- a/Source/RSP/Recompiler Sections.c +++ b/Source/RSP/Recompiler Sections.c @@ -251,11 +251,11 @@ void RSP_Sections_VMUDM ( OPCODE RspOp, DWORD AccumStyle ) { MmxMoveRegToReg(x86_MM2, x86_MM0); MmxMoveRegToReg(x86_MM3, x86_MM1); - /* high((u16)a * b) */ + // high((u16)a * b) MmxPmulhuwRegToReg(x86_MM0, x86_MM4); MmxPmulhuwRegToReg(x86_MM1, x86_MM5); - /* low((a >> 15) * b) */ + // low((a >> 15) * b) MmxPsrawImmed(x86_MM2, 15); MmxPsrawImmed(x86_MM3, 15); MmxPmullwRegToReg(x86_MM2, x86_MM4); @@ -267,11 +267,11 @@ void RSP_Sections_VMUDM ( OPCODE RspOp, DWORD AccumStyle ) { MmxMoveRegToReg(x86_MM2, x86_MM0); MmxMoveRegToReg(x86_MM3, x86_MM1); - /* high((u16)a * b) */ + // high((u16)a * b) MmxPmulhuwRegToReg(x86_MM0, x86_MM4); MmxPmulhuwRegToReg(x86_MM1, x86_MM4); - /* low((a >> 15) * b) */ + // low((a >> 15) * b) MmxPsrawImmed(x86_MM2, 15); MmxPsrawImmed(x86_MM3, 15); MmxPmullwRegToReg(x86_MM2, x86_MM4); @@ -283,11 +283,11 @@ void RSP_Sections_VMUDM ( OPCODE RspOp, DWORD AccumStyle ) { MmxMoveRegToReg(x86_MM2, x86_MM0); MmxMoveRegToReg(x86_MM3, x86_MM1); - /* high((u16)a * b) */ + // high((u16)a * b) MmxPmulhuwRegToReg(x86_MM0, x86_MM4); MmxPmulhuwRegToReg(x86_MM1, x86_MM5); - /* low((a >> 15) * b) */ + // low((a >> 15) * b) MmxPsrawImmed(x86_MM2, 15); MmxPsrawImmed(x86_MM3, 15); MmxPmullwRegToReg(x86_MM2, x86_MM4); @@ -349,11 +349,11 @@ void RSP_Sections_VMADM ( OPCODE RspOp, DWORD AccumStyle ) { MmxMoveRegToReg(x86_MM2 + 2, x86_MM0 + 2); MmxMoveRegToReg(x86_MM3 + 2, x86_MM1 + 2); - /* high((u16)a * b) */ + // high((u16)a * b) MmxPmulhuwRegToReg(x86_MM0 + 2, x86_MM4 + 2); MmxPmulhuwRegToReg(x86_MM1 + 2, x86_MM5 + 2); - /* low((a >> 15) * b) */ + // low((a >> 15) * b) MmxPsrawImmed(x86_MM2 + 2, 15); MmxPsrawImmed(x86_MM3 + 2, 15); MmxPmullwRegToReg(x86_MM2 + 2, x86_MM4 + 2); @@ -365,11 +365,11 @@ void RSP_Sections_VMADM ( OPCODE RspOp, DWORD AccumStyle ) { MmxMoveRegToReg(x86_MM2 + 2, x86_MM0 + 2); MmxMoveRegToReg(x86_MM3 + 2, x86_MM1 + 2); - /* high((u16)a * b) */ + // high((u16)a * b) MmxPmulhuwRegToReg(x86_MM0 + 2, x86_MM4 + 2); MmxPmulhuwRegToReg(x86_MM1 + 2, x86_MM4 + 2); - /* low((a >> 15) * b) */ + // low((a >> 15) * b) MmxPsrawImmed(x86_MM2 + 2, 15); MmxPsrawImmed(x86_MM3 + 2, 15); MmxPmullwRegToReg(x86_MM2 + 2, x86_MM4 + 2); @@ -381,11 +381,11 @@ void RSP_Sections_VMADM ( OPCODE RspOp, DWORD AccumStyle ) { MmxMoveRegToReg(x86_MM2 + 2, x86_MM0 + 2); MmxMoveRegToReg(x86_MM3 + 2, x86_MM1 + 2); - /* high((u16)a * b) */ + // high((u16)a * b) MmxPmulhuwRegToReg(x86_MM0 + 2, x86_MM4 + 2); MmxPmulhuwRegToReg(x86_MM1 + 2, x86_MM5 + 2); - /* low((a >> 15) * b) */ + // low((a >> 15) * b) MmxPsrawImmed(x86_MM2 + 2, 15); MmxPsrawImmed(x86_MM3 + 2, 15); MmxPmullwRegToReg(x86_MM2 + 2, x86_MM4 + 2); @@ -469,11 +469,11 @@ void RSP_Sections_VMUDN ( OPCODE RspOp, DWORD AccumStyle ) { MmxMoveRegToReg(x86_MM2, x86_MM0); MmxMoveRegToReg(x86_MM3, x86_MM1); - /* high((u16)a * b) */ + // high((u16)a * b) MmxPmulhuwRegToReg(x86_MM0, x86_MM4); MmxPmulhuwRegToReg(x86_MM1, x86_MM5); - /* low((a >> 15) * b) */ + // low((a >> 15) * b) MmxPsrawImmed(x86_MM2, 15); MmxPsrawImmed(x86_MM3, 15); MmxPmullwRegToReg(x86_MM2, x86_MM4); @@ -550,11 +550,11 @@ void RSP_Sections_VMADN ( OPCODE RspOp, DWORD AccumStyle ) { MmxMoveRegToReg(x86_MM2 + 2, x86_MM0 + 2); MmxMoveRegToReg(x86_MM3 + 2, x86_MM1 + 2); - /* high((u16)a * b) */ + // high((u16)a * b) MmxPmulhuwRegToReg(x86_MM0 + 2, x86_MM4 + 2); MmxPmulhuwRegToReg(x86_MM1 + 2, x86_MM5 + 2); - /* low((a >> 15) * b) */ + // low((a >> 15) * b) MmxPsrawImmed(x86_MM2 + 2, 15); MmxPsrawImmed(x86_MM3 + 2, 15); MmxPmullwRegToReg(x86_MM2 + 2, x86_MM4 + 2); @@ -743,7 +743,7 @@ void Compile_Section_000(void) { RSP_LW_IMEM(CompilePC + 0x00, &vmudn.Hex); - CPU_Message("Compiling: %X to ..., RSP Optimization $000", CompilePC); + CPU_Message("Compiling: %X to ..., RSP optimization $000", CompilePC); CPU_Message(" %X %s",CompilePC+0x00,RSPOpcodeName(vmudn.Hex,CompilePC + 0x00)); if (LogRDP){ char str[40]; @@ -846,7 +846,7 @@ void Compile_Section_001(void) { RSP_LW_IMEM(CompilePC + 0x00, &vmulf.Hex); - CPU_Message("Compiling: %X to ..., RSP Optimization $001", CompilePC); + CPU_Message("Compiling: %X to ..., RSP optimization $001", CompilePC); CPU_Message(" %X %s",CompilePC+0x00,RSPOpcodeName(vmulf.Hex,CompilePC + 0x00)); for (i = 0; i < Section_001_VMACF; i++) { @@ -945,7 +945,7 @@ void Compile_Section_002 ( void ) { OPCODE vmudh, vsaw; - CPU_Message("Compiling: %X to ..., RSP Optimization $002", CompilePC); + CPU_Message("Compiling: %X to ..., RSP optimization $002", CompilePC); for (Count = 0; Count < 0xC; Count++) { RSP_LW_IMEM(CompilePC + (Count * 0x04), &op[Count].Hex); CPU_Message(" %X %s",CompilePC+(Count*0x04),RSPOpcodeName(op[Count].Hex,CompilePC + (Count*0x04))); @@ -1047,7 +1047,7 @@ static void resampler_hle() { } void Compile_Section_003 ( void ) { - CPU_Message("Compiling: %X to ..., RSP Optimization $003", CompilePC); + CPU_Message("Compiling: %X to ..., RSP optimization $003", CompilePC); Call_Direct(resampler_hle, "Resampler_HLE"); CompilePC += 4 * sizeof(OPCODE); } diff --git a/Source/RSP/Rsp.h b/Source/RSP/Rsp.h index acf6b176d..252b5dc60 100644 --- a/Source/RSP/Rsp.h +++ b/Source/RSP/Rsp.h @@ -74,7 +74,7 @@ typedef struct { typedef struct { long left, top, right, bottom; -} rectangle; // equivalent: RECT +} rectangle; // equivalent: RECT typedef struct { void * hdc; Boolean fErase; @@ -82,7 +82,7 @@ typedef struct { Boolean fRestore; Boolean fIncUpdate; uint8_t rgbReserved[32]; -} window_paint; // equivalent: PAINTSTRUCT +} window_paint; // equivalent: PAINTSTRUCT typedef struct { // Menu diff --git a/Source/RSP/X86.c b/Source/RSP/X86.c index f86a7ef82..ab9a07f10 100644 --- a/Source/RSP/X86.c +++ b/Source/RSP/X86.c @@ -75,7 +75,7 @@ void AdcX86regToVariable(int x86reg, void * Variable, char * VariableName) { case x86_ESP: PUTDST16(RecompPos,0x2511); break; case x86_EBP: PUTDST16(RecompPos,0x2D11); break; default: - DisplayError("AddVariableToX86reg\nUnknown x86 Register"); + DisplayError("AddVariableToX86reg\nUnknown x86 register"); } PUTDSTPTR(RecompPos, Variable); } @@ -94,7 +94,7 @@ void AdcX86regHalfToVariable(int x86reg, void * Variable, char * VariableName) { case x86_ESP: PUTDST16(RecompPos,0x2511); break; case x86_EBP: PUTDST16(RecompPos,0x2D11); break; default: - DisplayError("AdcX86regHalfToVariable\nUnknown x86 Register"); + DisplayError("AdcX86regHalfToVariable\nUnknown x86 register"); } PUTDSTPTR(RecompPos, Variable); } @@ -118,7 +118,7 @@ void AdcConstToX86reg( BYTE Constant, int x86reg ) { case x86_ESP: PUTDST16(RecompPos,0xD483); break; case x86_EBP: PUTDST16(RecompPos,0xD583); break; default: - DisplayError("AdcConstantToX86reg\nUnknown x86 Register"); + DisplayError("AdcConstantToX86reg\nUnknown x86 register"); } PUTDST8(RecompPos,Constant); } @@ -189,7 +189,7 @@ void AddVariableToX86reg(int x86reg, void * Variable, char * VariableName) { case x86_ESP: PUTDST16(RecompPos,0x2503); break; case x86_EBP: PUTDST16(RecompPos,0x2D03); break; default: - DisplayError("AddVariableToX86reg\nUnknown x86 Register"); + DisplayError("AddVariableToX86reg\nUnknown x86 register"); } PUTDSTPTR(RecompPos, Variable); } @@ -206,7 +206,7 @@ void AddX86regToVariable(int x86reg, void * Variable, char * VariableName) { case x86_ESP: PUTDST16(RecompPos,0x2501); break; case x86_EBP: PUTDST16(RecompPos,0x2D01); break; default: - DisplayError("AddVariableToX86reg\nUnknown x86 Register"); + DisplayError("AddVariableToX86reg\nUnknown x86 register"); } PUTDSTPTR(RecompPos, Variable); } @@ -226,7 +226,7 @@ void AddX86regHalfToVariable(int x86reg, void * Variable, char * VariableName) { case x86_ESP: PUTDST16(RecompPos,0x2501); break; case x86_EBP: PUTDST16(RecompPos,0x2D01); break; default: - DisplayError("AddVariableToX86reg\nUnknown x86 Register"); + DisplayError("AddVariableToX86reg\nUnknown x86 register"); } PUTDSTPTR(RecompPos, Variable); } @@ -397,7 +397,7 @@ void AndX86RegHalfToX86RegHalf(int Destination, int Source) { } void BreakPointNotification (const char * const FileName, const int LineNumber) { - DisplayError("Break Point found\nFile: %s\nLine: %d",FileName,LineNumber); + DisplayError("Break point found\nFile: %s\nLine: %d",FileName,LineNumber); } void X86BreakPoint (LPCSTR FileName, int LineNumber) { @@ -739,7 +739,7 @@ void CompConstToX86reg(int x86Reg, DWORD Const) { case x86_ESP: PUTDST16(RecompPos,0xFC81); break; case x86_EBP: PUTDST16(RecompPos,0xFD81); break; default: - DisplayError("CompConstToX86reg\nUnknown x86 Register"); + DisplayError("CompConstToX86reg\nUnknown x86 register"); } PUTDST32(RecompPos,Const); } else { @@ -769,7 +769,7 @@ void CompX86regToVariable(int x86Reg, void * Variable, char * VariableName) { case x86_ESP: PUTDST16(RecompPos,0x253B); break; case x86_EBP: PUTDST16(RecompPos,0x2D3B); break; default: - DisplayError("Unknown x86 Register"); + DisplayError("Unknown x86 register"); } PUTDSTPTR(RecompPos, Variable); } @@ -786,7 +786,7 @@ void CompVariableToX86reg(int x86Reg, void * Variable, char * VariableName) { case x86_ESP: PUTDST16(RecompPos,0x2539); break; case x86_EBP: PUTDST16(RecompPos,0x2D39); break; default: - DisplayError("Unknown x86 Register"); + DisplayError("Unknown x86 register"); } PUTDSTPTR(RecompPos, Variable); } @@ -841,7 +841,7 @@ void DecX86reg(int x86reg) { case x86_ESP: PUTDST8 (RecompPos,0x4C); break; case x86_EBP: PUTDST8 (RecompPos,0x4D); break; default: - DisplayError("DecX86reg\nUnknown x86 Register"); + DisplayError("DecX86reg\nUnknown x86 register"); } } @@ -856,7 +856,7 @@ void DivX86reg(int x86reg) { case x86_ESP: PUTDST16(RecompPos,0xf4F7); break; case x86_EBP: PUTDST16(RecompPos,0xf5F7); break; default: - DisplayError("divX86reg\nUnknown x86 Register"); + DisplayError("divX86reg\nUnknown x86 register"); } } @@ -871,7 +871,7 @@ void idivX86reg(int x86reg) { case x86_ESP: PUTDST16(RecompPos,0xfcF7); break; case x86_EBP: PUTDST16(RecompPos,0xfdF7); break; default: - DisplayError("idivX86reg\nUnknown x86 Register"); + DisplayError("idivX86reg\nUnknown x86 register"); } } @@ -887,7 +887,7 @@ void imulX86reg(int x86reg) { case x86_ESP: PUTDST16(RecompPos,0xECF7); break; case x86_EBP: PUTDST16(RecompPos,0xEDF7); break; default: - DisplayError("imulX86reg\nUnknown x86 Register"); + DisplayError("imulX86reg\nUnknown x86 register"); } } @@ -934,7 +934,7 @@ void IncX86reg(int x86Reg) { case x86_ESP: PUTDST8 (RecompPos,0x44); break; case x86_EBP: PUTDST8 (RecompPos,0x45); break; default: - DisplayError("IncX86reg\nUnknown x86 Register"); + DisplayError("IncX86reg\nUnknown x86 register"); } } @@ -1038,7 +1038,7 @@ void JumpX86Reg( int x86reg ) { case x86_EDX: PUTDST16(RecompPos,0xe2ff); break; case x86_ESI: PUTDST16(RecompPos,0xe6ff); break; case x86_EDI: PUTDST16(RecompPos,0xe7ff); break; - default: DisplayError("JumpX86Reg: Unknown reg"); + default: DisplayError("JumpX86Reg: Unknown register"); } } @@ -1103,7 +1103,7 @@ void LeaSourceAndOffset(int x86DestReg, int x86SourceReg, size_t offset) { case x86_ESP: x86Command = 0xA08D; break; case x86_EBP: x86Command = 0xA88D; break; default: - DisplayError("LeaSourceAndOffset\nUnknown x86 Register"); + DisplayError("LeaSourceAndOffset\nUnknown x86 register"); } switch (x86SourceReg) { case x86_EAX: x86Command += 0x0000; break; @@ -1115,7 +1115,7 @@ void LeaSourceAndOffset(int x86DestReg, int x86SourceReg, size_t offset) { case x86_ESP: x86Command += 0x0400; break; case x86_EBP: x86Command += 0x0500; break; default: - DisplayError("LeaSourceAndOffset\nUnknown x86 Register"); + DisplayError("LeaSourceAndOffset\nUnknown x86 register"); } // TODO: Check high DWORD of offset for 64-bit x86 @@ -1142,7 +1142,7 @@ void MoveConstByteToN64Mem(BYTE Const, int AddrReg) { case x86_ESP: x86Command = 0x84C6; break; case x86_EBP: x86Command = 0x85C6; break; default: - DisplayError("MoveConstByteToN64Mem\nUnknown x86 Register"); + DisplayError("MoveConstByteToN64Mem\nUnknown x86 register"); } PUTDST16(RecompPos, x86Command); @@ -1165,7 +1165,7 @@ void MoveConstHalfToN64Mem(WORD Const, int AddrReg) { case x86_ESP: x86Command = 0x84; break; case x86_EBP: x86Command = 0x85; break; default: - DisplayError("MoveConstHalfToN64Mem\nUnknown x86 Register"); + DisplayError("MoveConstHalfToN64Mem\nUnknown x86 register"); } PUTDST8(RecompPos, x86Command); @@ -1202,7 +1202,7 @@ void MoveConstToN64Mem(DWORD Const, int AddrReg) { case x86_ESP: x86Command = 0x84C7; break; case x86_EBP: x86Command = 0x85C7; break; default: - DisplayError("MoveConstToN64Mem\nUnknown x86 Register"); + DisplayError("MoveConstToN64Mem\nUnknown x86 register"); } PUTDST16(RecompPos, x86Command); @@ -1229,7 +1229,7 @@ void MoveConstToX86reg(DWORD Const, int x86reg) { case x86_ESP: PUTDST16(RecompPos,0xC4C7); break; case x86_EBP: PUTDST16(RecompPos,0xC5C7); break; default: - DisplayError("MoveConstToX86reg\nUnknown x86 Register"); + DisplayError("MoveConstToX86reg\nUnknown x86 register"); } PUTDST32(RecompPos,Const); } @@ -1246,7 +1246,7 @@ void MoveOffsetToX86reg(size_t Const, char * VariableName, int x86reg) { case x86_ESP: PUTDST16(RecompPos,0xC4C7); break; case x86_EBP: PUTDST16(RecompPos,0xC5C7); break; default: - DisplayError("MoveOffsetToX86reg\nUnknown x86 Register"); + DisplayError("MoveOffsetToX86reg\nUnknown x86 register"); } PUTDST32(RecompPos,Const); } @@ -1263,7 +1263,7 @@ void MoveX86regPointerToX86regByte(int Destination, int AddrReg) { case x86_EDX: x86Command = 0x02; break; case x86_ESI: x86Command = 0x06; break; case x86_EDI: x86Command = 0x07; break; - default: DisplayError("MoveX86regPointerToX86regByte\nUnknown x86 Register"); + default: DisplayError("MoveX86regPointerToX86regByte\nUnknown x86 register"); } switch (Destination) { @@ -1271,7 +1271,7 @@ void MoveX86regPointerToX86regByte(int Destination, int AddrReg) { case x86_EBX: x86Command += 0x18; break; case x86_ECX: x86Command += 0x08; break; case x86_EDX: x86Command += 0x10; break; - default: DisplayError("MoveX86regPointerToX86regByte\nUnknown x86 Register"); + default: DisplayError("MoveX86regPointerToX86regByte\nUnknown x86 register"); } PUTDST8(RecompPos, 0x8A); @@ -1290,7 +1290,7 @@ void MoveX86regPointerToX86regHalf(int Destination, int AddrReg) { case x86_EDX: x86Amb = 0x02; break; case x86_ESI: x86Amb = 0x06; break; case x86_EDI: x86Amb = 0x07; break; - default: DisplayError("MoveX86regPointerToX86regHalf\nUnknown x86 Register"); + default: DisplayError("MoveX86regPointerToX86regHalf\nUnknown x86 register"); } switch (Destination) { @@ -1302,7 +1302,7 @@ void MoveX86regPointerToX86regHalf(int Destination, int AddrReg) { case x86_EDI: x86Amb += 0x38; break; case x86_ESP: x86Amb += 0x20; break; case x86_EBP: x86Amb += 0x28; break; - default: DisplayError("MoveX86regPointerToX86regHalf\nUnknown x86 Register"); + default: DisplayError("MoveX86regPointerToX86regHalf\nUnknown x86 register"); } PUTDST16(RecompPos, 0x8B66); @@ -1322,7 +1322,7 @@ void MoveX86regPointerToX86reg(int Destination, int AddrReg) { case x86_EDI: x86Amb = 0x07; break; case x86_ESP: x86Amb = 0x04; break; case x86_EBP: x86Amb = 0x05; break; - default: DisplayError("MoveX86regPointerToX86reg\nUnknown x86 Register"); + default: DisplayError("MoveX86regPointerToX86reg\nUnknown x86 register"); } switch (Destination) { @@ -1334,7 +1334,7 @@ void MoveX86regPointerToX86reg(int Destination, int AddrReg) { case x86_EDI: x86Amb += 0x38; break; case x86_ESP: x86Amb += 0x20; break; case x86_EBP: x86Amb += 0x28; break; - default: DisplayError("MoveX86regPointerToX86reg\nUnknown x86 Register"); + default: DisplayError("MoveX86regPointerToX86reg\nUnknown x86 register"); } PUTDST8(RecompPos, 0x8B); @@ -1354,7 +1354,7 @@ void MoveX86regByteToX86regPointer(int Source, int AddrReg) { case x86_EDI: x86Amb = 0x07; break; case x86_ESP: x86Amb = 0x04; break; case x86_EBP: x86Amb = 0x05; break; - default: DisplayError("MoveX86regBytePointer\nUnknown x86 Register"); + default: DisplayError("MoveX86regBytePointer\nUnknown x86 register"); } switch (Source) { @@ -1366,7 +1366,7 @@ void MoveX86regByteToX86regPointer(int Source, int AddrReg) { case x86_EDI: x86Amb += 0x38; break; case x86_ESP: x86Amb += 0x20; break; case x86_EBP: x86Amb += 0x28; break; - default: DisplayError("MoveX86regBytePointer\nUnknown x86 Register"); + default: DisplayError("MoveX86regBytePointer\nUnknown x86 register"); } PUTDST8(RecompPos, 0x88); @@ -1387,7 +1387,7 @@ void MoveX86regHalfToX86regPointer(int Source, int AddrReg) { case x86_EDI: x86Amb = 0x07; break; case x86_ESP: x86Amb = 0x04; break; case x86_EBP: x86Amb = 0x05; break; - default: DisplayError("MoveX86regBytePointer\nUnknown x86 Register"); + default: DisplayError("MoveX86regBytePointer\nUnknown x86 register"); } switch (Source) { @@ -1399,7 +1399,7 @@ void MoveX86regHalfToX86regPointer(int Source, int AddrReg) { case x86_EDI: x86Amb += 0x38; break; case x86_ESP: x86Amb += 0x20; break; case x86_EBP: x86Amb += 0x28; break; - default: DisplayError("MoveX86regBytePointer\nUnknown x86 Register"); + default: DisplayError("MoveX86regBytePointer\nUnknown x86 register"); } PUTDST16(RecompPos, 0x8966); @@ -1420,7 +1420,7 @@ void MoveX86regHalfToX86regPointerDisp(int Source, int AddrReg, BYTE Disp) { case x86_EDI: x86Amb = 0x07; break; case x86_ESP: x86Amb = 0x04; break; case x86_EBP: x86Amb = 0x05; break; - default: DisplayError("MoveX86regBytePointer\nUnknown x86 Register"); + default: DisplayError("MoveX86regBytePointer\nUnknown x86 register"); } switch (Source) { @@ -1432,7 +1432,7 @@ void MoveX86regHalfToX86regPointerDisp(int Source, int AddrReg, BYTE Disp) { case x86_EDI: x86Amb += 0x38; break; case x86_ESP: x86Amb += 0x20; break; case x86_EBP: x86Amb += 0x28; break; - default: DisplayError("MoveX86regBytePointer\nUnknown x86 Register"); + default: DisplayError("MoveX86regBytePointer\nUnknown x86 register"); } PUTDST16(RecompPos, 0x8966); @@ -1453,7 +1453,7 @@ void MoveX86regToX86regPointer(int Source, int AddrReg) { case x86_EDI: x86Amb = 0x07; break; case x86_ESP: x86Amb = 0x04; break; case x86_EBP: x86Amb = 0x05; break; - default: DisplayError("MoveX86regToX86regPointer\nUnknown x86 Register"); + default: DisplayError("MoveX86regToX86regPointer\nUnknown x86 register"); } switch (Source) { @@ -1465,7 +1465,7 @@ void MoveX86regToX86regPointer(int Source, int AddrReg) { case x86_EDI: x86Amb += 0x38; break; case x86_ESP: x86Amb += 0x20; break; case x86_EBP: x86Amb += 0x28; break; - default: DisplayError("MoveX86regToX86regPointer\nUnknown x86 Register"); + default: DisplayError("MoveX86regToX86regPointer\nUnknown x86 register"); } PUTDST8(RecompPos, 0x89); @@ -1485,7 +1485,7 @@ void MoveX86RegToX86regPointerDisp ( int Source, int AddrReg, BYTE Disp ) { case x86_EDI: x86Amb = 0x07; break; case x86_ESP: DisplayError("MoveX86RegToX86regPointerDisp: ESP is invalid"); break; case x86_EBP: x86Amb = 0x05; break; - default: DisplayError("MoveX86regToX86regPointer\nUnknown x86 Register"); + default: DisplayError("MoveX86regToX86regPointer\nUnknown x86 register"); } switch (Source) { @@ -1497,7 +1497,7 @@ void MoveX86RegToX86regPointerDisp ( int Source, int AddrReg, BYTE Disp ) { case x86_EDI: x86Amb += 0x38; break; case x86_ESP: x86Amb += 0x20; break; case x86_EBP: x86Amb += 0x28; break; - default: DisplayError("MoveX86regToX86regPointer\nUnknown x86 Register"); + default: DisplayError("MoveX86regToX86regPointer\nUnknown x86 register"); } PUTDST8(RecompPos, 0x89); @@ -1582,7 +1582,7 @@ void MoveN64MemToX86regByte(int x86reg, int AddrReg) { case x86_ECX: x86Command += 0x8800; break; case x86_EDX: x86Command += 0x9000; break; default: - DisplayError("MoveN64MemToX86regByte\nInvalid x86 Register"); + DisplayError("MoveN64MemToX86regByte\nInvalid x86 register"); break; } PUTDST16(RecompPos,x86Command); @@ -1738,7 +1738,7 @@ void MoveVariableToX86reg(void *Variable, char *VariableName, int x86reg) { case x86_EDI: PUTDST16(RecompPos,0x3D8B); break; case x86_ESP: PUTDST16(RecompPos,0x258B); break; case x86_EBP: PUTDST16(RecompPos,0x2D8B); break; - default: DisplayError("MoveVariableToX86reg\nUnknown x86 Register"); + default: DisplayError("MoveVariableToX86reg\nUnknown x86 register"); } PUTDSTPTR(RecompPos, Variable); } @@ -1750,7 +1750,7 @@ void MoveVariableToX86regByte(void *Variable, char *VariableName, int x86reg) { case x86_EBX: PUTDST16(RecompPos,0x1D8A); break; case x86_ECX: PUTDST16(RecompPos,0x0D8A); break; case x86_EDX: PUTDST16(RecompPos,0x158A); break; - default: DisplayError("MoveVariableToX86regByte\nUnknown x86 Register"); + default: DisplayError("MoveVariableToX86regByte\nUnknown x86 register"); } PUTDSTPTR(RecompPos, Variable); } @@ -1767,7 +1767,7 @@ void MoveVariableToX86regHalf(void *Variable, char *VariableName, int x86reg) { case x86_EDI: PUTDST16(RecompPos,0x3D8B); break; case x86_ESP: PUTDST16(RecompPos,0x258B); break; case x86_EBP: PUTDST16(RecompPos,0x2D8B); break; - default: DisplayError("MoveVariableToX86reg\nUnknown x86 Register"); + default: DisplayError("MoveVariableToX86reg\nUnknown x86 register"); } PUTDSTPTR(RecompPos, Variable); } @@ -1780,7 +1780,7 @@ void MoveX86regByteToVariable(int x86reg, void * Variable, char * VariableName) case x86_ECX: PUTDST16(RecompPos,0x0D88); break; case x86_EDX: PUTDST16(RecompPos,0x1588); break; default: - DisplayError("MoveX86regByteToVariable\nUnknown x86 Register"); + DisplayError("MoveX86regByteToVariable\nUnknown x86 register"); } PUTDSTPTR(RecompPos, Variable); } @@ -1798,7 +1798,7 @@ void MoveX86regHalfToVariable(int x86reg, void * Variable, char * VariableName) case x86_ESP: PUTDST16(RecompPos,0x2589); break; case x86_EBP: PUTDST16(RecompPos,0x2D89); break; default: - DisplayError("MoveX86regHalfToVariable\nUnknown x86 Register"); + DisplayError("MoveX86regHalfToVariable\nUnknown x86 register"); } PUTDSTPTR(RecompPos, Variable); } @@ -1815,7 +1815,7 @@ void MoveX86regToVariable(int x86reg, void * Variable, char * VariableName) { case x86_ESP: PUTDST16(RecompPos,0x2589); break; case x86_EBP: PUTDST16(RecompPos,0x2D89); break; default: - DisplayError("MoveX86regToVariable\nUnknown x86 Register"); + DisplayError("MoveX86regToVariable\nUnknown x86 register"); } PUTDSTPTR(RecompPos, Variable); } @@ -1924,7 +1924,7 @@ void MoveSxVariableToX86regByte(void *Variable, char *VariableName, int x86reg) case x86_EDI: PUTDST8(RecompPos,0x3D); break; case x86_ESP: PUTDST8(RecompPos,0x25); break; case x86_EBP: PUTDST8(RecompPos,0x2D); break; - default: DisplayError("MoveSxVariableToX86regByte\nUnknown x86 Register"); + default: DisplayError("MoveSxVariableToX86regByte\nUnknown x86 register"); } PUTDSTPTR(RecompPos, Variable); } @@ -1943,7 +1943,7 @@ void MoveSxVariableToX86regHalf(void *Variable, char *VariableName, int x86reg) case x86_EDI: PUTDST8(RecompPos,0x3D); break; case x86_ESP: PUTDST8(RecompPos,0x25); break; case x86_EBP: PUTDST8(RecompPos,0x2D); break; - default: DisplayError("MoveSxVariableToX86regHalf\nUnknown x86 Register"); + default: DisplayError("MoveSxVariableToX86regHalf\nUnknown x86 register"); } PUTDSTPTR(RecompPos, Variable); } @@ -1968,7 +1968,7 @@ void MoveSxN64MemToX86regByte(int x86reg, int AddrReg) { case x86_ECX: x86Command += 0x8800; break; case x86_EDX: x86Command += 0x9000; break; default: - DisplayError("MoveSxN64MemToX86regByte\nInvalid x86 Register"); + DisplayError("MoveSxN64MemToX86regByte\nInvalid x86 register"); break; } PUTDST8(RecompPos,0x0f); @@ -2082,7 +2082,7 @@ void MoveZxVariableToX86regByte(void *Variable, char *VariableName, int x86reg) case x86_EDI: PUTDST8(RecompPos,0x3D); break; case x86_ESP: PUTDST8(RecompPos,0x25); break; case x86_EBP: PUTDST8(RecompPos,0x2D); break; - default: DisplayError("MoveZxVariableToX86regByte\nUnknown x86 Register"); + default: DisplayError("MoveZxVariableToX86regByte\nUnknown x86 register"); } PUTDSTPTR(RecompPos, Variable); } @@ -2101,7 +2101,7 @@ void MoveZxVariableToX86regHalf(void *Variable, char *VariableName, int x86reg) case x86_EDI: PUTDST8(RecompPos,0x3D); break; case x86_ESP: PUTDST8(RecompPos,0x25); break; case x86_EBP: PUTDST8(RecompPos,0x2D); break; - default: DisplayError("MoveZxVariableToX86regHalf\nUnknown x86 Register"); + default: DisplayError("MoveZxVariableToX86regHalf\nUnknown x86 register"); } PUTDSTPTR(RecompPos, Variable); } @@ -2126,7 +2126,7 @@ void MoveZxN64MemToX86regByte(int x86reg, int AddrReg) { case x86_ECX: x86Command += 0x8800; break; case x86_EDX: x86Command += 0x9000; break; default: - DisplayError("MoveZxN64MemToX86regByte\nInvalid x86 Register"); + DisplayError("MoveZxN64MemToX86regByte\nInvalid x86 register"); break; } PUTDST8(RecompPos,0x0f); @@ -2177,7 +2177,7 @@ void MulX86reg(int x86reg) { case x86_ESP: PUTDST16(RecompPos,0xE4F7); break; case x86_EBP: PUTDST16(RecompPos,0xE5F7); break; default: - DisplayError("MulX86reg\nUnknown x86 Register"); + DisplayError("MulX86reg\nUnknown x86 register"); } } @@ -2193,7 +2193,7 @@ void NegateX86reg(int x86reg) { case x86_ESP: PUTDST16(RecompPos,0xdcf7); break; case x86_EBP: PUTDST16(RecompPos,0xddf7); break; default: - DisplayError("NegateX86reg\nUnknown x86 Register"); + DisplayError("NegateX86reg\nUnknown x86 register"); } } @@ -2209,7 +2209,7 @@ void NotX86reg(int x86reg) { case x86_ESP: PUTDST16(RecompPos, 0xd4f7); break; case x86_EBP: PUTDST16(RecompPos, 0xd5f7); break; default: - DisplayError("NotX86reg\nUnknown x86 Register"); + DisplayError("NotX86reg\nUnknown x86 register"); } } @@ -2382,7 +2382,7 @@ void Setl(int x86reg) { case x86_ECX: PUTDST8(RecompPos,0xC1); break; case x86_EDX: PUTDST8(RecompPos,0xC2); break; default: - DisplayError("Setl\nUnknown x86 Register"); + DisplayError("Setl\nUnknown x86 register"); } } @@ -2409,7 +2409,7 @@ void Setb(int x86reg) { case x86_ECX: PUTDST8(RecompPos,0xC1); break; case x86_EDX: PUTDST8(RecompPos,0xC2); break; default: - DisplayError("Setb\nUnknown x86 Register"); + DisplayError("Setb\nUnknown x86 register"); } } @@ -2429,7 +2429,7 @@ void Setg(int x86reg) { case x86_ECX: PUTDST8(RecompPos,0xC1); break; case x86_EDX: PUTDST8(RecompPos,0xC2); break; default: - DisplayError("Setg\nUnknown x86 Register"); + DisplayError("Setg\nUnknown x86 register"); } } @@ -2456,7 +2456,7 @@ void Seta(int x86reg) { case x86_ECX: PUTDST8(RecompPos,0xC1); break; case x86_EDX: PUTDST8(RecompPos,0xC2); break; default: - DisplayError("Seta\nUnknown x86 Register"); + DisplayError("Seta\nUnknown x86 register"); } } @@ -2476,7 +2476,7 @@ void Setae(int x86reg) { case x86_ECX: PUTDST8(RecompPos,0xC1); break; case x86_EDX: PUTDST8(RecompPos,0xC2); break; default: - DisplayError("Seta\nUnknown x86 Register"); + DisplayError("Seta\nUnknown x86 register"); } } @@ -2489,7 +2489,7 @@ void Setz(int x86reg) { case x86_ECX: PUTDST8(RecompPos,0xC1); break; case x86_EDX: PUTDST8(RecompPos,0xC2); break; default: - DisplayError("Setz\nUnknown x86 Register"); + DisplayError("Setz\nUnknown x86 register"); } } @@ -2509,7 +2509,7 @@ void Setnz(int x86reg) { case x86_ECX: PUTDST8(RecompPos,0xC1); break; case x86_EDX: PUTDST8(RecompPos,0xC2); break; default: - DisplayError("Setnz\nUnknown x86 Register"); + DisplayError("Setnz\nUnknown x86 register"); } } @@ -2633,7 +2633,7 @@ void ShiftRightSignImmed(int x86reg, BYTE Immediate) { case x86_ESP: PUTDST16(RecompPos,0xFCC1); break; case x86_EBP: PUTDST16(RecompPos,0xFDC1); break; default: - DisplayError("ShiftRightSignImmed\nUnknown x86 Register"); + DisplayError("ShiftRightSignImmed\nUnknown x86 register"); } PUTDST8(RecompPos,Immediate); } @@ -2731,7 +2731,7 @@ void SubVariableFromX86reg(int x86reg, void * Variable, char * VariableName) { case x86_ESP: PUTDST16(RecompPos,0x252B); break; case x86_EBP: PUTDST16(RecompPos,0x2D2B); break; default: - DisplayError("SubVariableFromX86reg\nUnknown x86 Register"); + DisplayError("SubVariableFromX86reg\nUnknown x86 register"); } PUTDSTPTR(RecompPos, Variable); } @@ -2748,7 +2748,7 @@ void SubX86regFromVariable(int x86reg, void * Variable, char * VariableName) { case x86_ESP: PUTDST16(RecompPos,0x2529); break; case x86_EBP: PUTDST16(RecompPos,0x2D29); break; default: - DisplayError("SubX86regFromVariable\nUnknown x86 Register"); + DisplayError("SubX86regFromVariable\nUnknown x86 register"); } PUTDSTPTR(RecompPos, Variable); } @@ -2932,7 +2932,7 @@ void XorVariableToX86reg(void *Variable, char *VariableName, int x86reg) { case x86_EDI: PUTDST16(RecompPos,0x3D33); break; case x86_ESP: PUTDST16(RecompPos,0x2533); break; case x86_EBP: PUTDST16(RecompPos,0x2D33); break; - default: DisplayError("XorVariableToX86reg\nUnknown x86 Register"); + default: DisplayError("XorVariableToX86reg\nUnknown x86 register"); } PUTDSTPTR(RecompPos, Variable); } @@ -2948,7 +2948,7 @@ void XorX86RegToVariable(void *Variable, char *VariableName, int x86reg) { case x86_EDI: PUTDST16(RecompPos,0x3D31); break; case x86_ESP: PUTDST16(RecompPos,0x2531); break; case x86_EBP: PUTDST16(RecompPos,0x2D31); break; - default: DisplayError("XorX86RegToVariable\nUnknown x86 Register"); + default: DisplayError("XorX86RegToVariable\nUnknown x86 register"); } PUTDSTPTR(RecompPos, Variable); } diff --git a/Source/RSP/breakpoint.c b/Source/RSP/breakpoint.c index c4b201036..21bb47e82 100644 --- a/Source/RSP/breakpoint.c +++ b/Source/RSP/breakpoint.c @@ -24,7 +24,7 @@ int AddRSP_BPoint( DWORD Location, int Confirm ) if (NoOfBpoints == MaxBPoints) { - DisplayError("Max amount of break points set"); + DisplayError("Max amount of breakpoints set"); return FALSE; } @@ -32,7 +32,7 @@ int AddRSP_BPoint( DWORD Location, int Confirm ) { if (BPoint[count].Location == Location) { - DisplayError("You already have this break point"); + DisplayError("You already have this breakpoint"); return FALSE; } } @@ -42,7 +42,7 @@ int AddRSP_BPoint( DWORD Location, int Confirm ) char Message[150]; int Response; - sprintf(Message,"Break when:\n\nRSP's Program Counter = 0x%03X\n\nIs this correct?", + sprintf(Message,"Break when:\n\nRSP's program counter = 0x%03X\n\nIs this correct?", Location); Response = MessageBox(BPoint_Win_hDlg, Message, "Breakpoint", MB_YESNO | MB_ICONINFORMATION); if (Response == IDNO) diff --git a/Source/nragev20/ControllerSpecs/Controller #1.1.h b/Source/nragev20/ControllerSpecs/Controller #1.1.h index e6e5be5d3..b28e5ad65 100644 --- a/Source/nragev20/ControllerSpecs/Controller #1.1.h +++ b/Source/nragev20/ControllerSpecs/Controller #1.1.h @@ -1,10 +1,8 @@ -/********************************************************************************** -Common Controller plugin spec, version #1.1 maintained by -zilmar (zilmar@emulation64.com) +// Common controller plugin specification, version 1.1 maintained by Zilmar + +// All questions or suggestions should go through the emutalk plugin forum. +// http://www.emutalk.net/cgi-bin/ikonboard/ikonboard.cgi?s=3bd272222f66ffff;act=SF;f=20 -All questions or suggestions should go through the emutalk plugin forum. -http://www.emutalk.net/cgi-bin/ikonboard/ikonboard.cgi?s=3bd272222f66ffff;act=SF;f=20 -**********************************************************************************/ #ifndef _CONTR_H_INCLUDED__ #define _CONTR_H_INCLUDED__ @@ -12,7 +10,7 @@ http://www.emutalk.net/cgi-bin/ikonboard/ikonboard.cgi?s=3bd272222f66ffff;act=SF extern "C" { #endif - /* Note: BOOL, BYTE, WORD, DWORD, TRUE, FALSE are defined in windows.h */ +// Note: BOOL, BYTE, WORD, DWORD, TRUE, FALSE are defined in windows.h #define PLUGIN_TYPE_CONTROLLER 4 @@ -20,34 +18,34 @@ extern "C" { #define SPECS_VERSION 0x0101 #endif - /*** Conteroller plugin's ****/ +// Controller plugins #define PLUGIN_NONE 1 #define PLUGIN_MEMPAK 2 - // not implemeted for non raw data +// not implemented for non-raw data #define PLUGIN_RUMBLE_PAK 3 - // not implemeted for non raw data +// not implemented for non-raw data #define PLUGIN_TRANSFER_PAK 4 - // the controller plugin is passed in raw data +// The controller plugin is passed in raw data #define PLUGIN_RAW 5 - /********************************************************************************* - Note about Conteroller plugin's: - the rumble pak needs a function for the force feed back joystick and tranfer pak - probaly needs a function for the plugin to be able to select the GB rom and - eeprom... maybe this should be done by the emu instead of the plugin, but I think - it probaly should be done by the plugin. I will see about adding these functions - in the next spec - **********************************************************************************/ +/* +Note about controller plugin's: +The rumble pak needs a function for the force feedback joystick and transfer pak +probably needs a function for the plugin to be able to select the Game Boy ROM and +EEPROM...maybe this should be done by the emu instead of the plugin, but I think +it probably should be done by the plugin. I will see about adding these functions +in the next specification. +*/ #define EXPORT __declspec(dllexport) #define CALL _cdecl - /***** Structures *****/ + // Structures typedef struct { - WORD Version; /* Should be set to 0x0101 */ - WORD Type; /* Set to PLUGIN_TYPE_CONTROLLER */ - char Name[100]; /* Name of the DLL */ + WORD Version; // Should be set to 0x0101 + WORD Type; // Set to PLUGIN_TYPE_CONTROLLER + char Name[100]; // Name of the DLL BOOL Reserved1; BOOL Reserved2; } PLUGIN_INFO; @@ -93,153 +91,165 @@ extern "C" { HWND hMainWindow; HINSTANCE hinst; - BOOL MemoryBswaped; // If this is set to TRUE, then the memory has been pre - // bswap on a dword (32 bits) boundry, only effects header. + BOOL MemoryBswaped; // If this is set to TRUE, then the memory has been pre-bswap'd on a DWORD (32-bit) boundary, only effects header. // eg. the first 8 bytes are stored like this: - // 4 3 2 1 8 7 6 5 - BYTE * HEADER; // This is the rom header (first 40h bytes of the rom) - CONTROL *Controls; // A pointer to an array of 4 controllers .. eg: + // 4 3 2 1 8 7 6 5 + BYTE * HEADER; // This is the ROM header (first 40h bytes of the ROM) + CONTROL *Controls; // A pointer to an array of 4 controllers. eg: // CONTROL Controls[4]; } CONTROL_INFO; - /****************************************************************** - Function: CloseDLL - Purpose: This function is called when the emulator is closing - down allowing the dll to de-initialise. - input: none - output: none - *******************************************************************/ + /* + Function: CloseDLL + Purpose: This function is called when the emulator is closing + down allowing the DLL to de-initialize. + Input: None + Output: None + */ + EXPORT void CALL CloseDLL(void); - /****************************************************************** - Function: ControllerCommand - Purpose: To process the raw data that has just been sent to a - specific controller. - input: - Controller Number (0 to 3) and -1 signalling end of - processing the pif ram. - - Pointer of data to be processed. - output: none + /* + Function: ControllerCommand + Purpose: To process the raw data that has just been sent to a + specific controller. + Input: Controller number (0 to 3) and -1 signaling end of + processing the PIF RAM. + - Pointer of data to be processed. + Output: None - note: This function is only needed if the DLL is allowing raw - data, or the plugin is set to raw + Note: This function is only needed if the DLL is allowing raw + data, or the plugin is set to raw. - the data that is being processed looks like this: - initilize controller: 01 03 00 FF FF FF - read controller: 01 04 01 FF FF FF FF - *******************************************************************/ + The data that is being processed looks like this: + Initialize controller: 01 03 00 FF FF FF + Read controller: 01 04 01 FF FF FF FF + */ + EXPORT void CALL ControllerCommand(int Control, BYTE * Command); - /****************************************************************** - Function: DllAbout - Purpose: This function is optional function that is provided - to give further information about the DLL. - input: a handle to the window that calls this function - output: none - *******************************************************************/ + /* + Function: DllAbout + Purpose: This function is optional function that is provided + to give further information about the DLL. + Input: A handle to the window that calls this function + Output: None + */ + EXPORT void CALL DllAbout(HWND hParent); - /****************************************************************** - Function: DllConfig - Purpose: This function is optional function that is provided - to allow the user to configure the dll - input: a handle to the window that calls this function - output: none - *******************************************************************/ + /* + Function: DllConfig + Purpose: This function is optional function that is provided + to allow the user to configure the DLL. + Input: A handle to the window that calls this function + Output: None + */ + EXPORT void CALL DllConfig(HWND hParent); - /****************************************************************** - Function: DllTest - Purpose: This function is optional function that is provided - to allow the user to test the dll - input: a handle to the window that calls this function - output: none - *******************************************************************/ + /* + Function: DllTest + Purpose: This function is optional function that is provided + to allow the user to test the DLL. + Input: A handle to the window that calls this function + Output: None + */ + EXPORT void CALL DllTest(HWND hParent); - /****************************************************************** - Function: GetDllInfo - Purpose: This function allows the emulator to gather information - about the dll by filling in the PluginInfo structure. - input: a pointer to a PLUGIN_INFO stucture that needs to be - filled by the function. (see def above) - output: none - *******************************************************************/ + /* + Function: GetDllInfo + Purpose: This function allows the emulator to gather information + about the DLL by filling in the PluginInfo structure. + Input: A pointer to a PLUGIN_INFO structure that needs to be + filled by the function. (see def above) + Output: None + */ + EXPORT void CALL GetDllInfo(PLUGIN_INFO * PluginInfo); - /****************************************************************** - Function: GetKeys - Purpose: To get the current state of the controllers buttons. - input: - Controller Number (0 to 3) - - A pointer to a BUTTONS structure to be filled with - the controller state. - output: none - *******************************************************************/ + /* + Function: GetKeys + Purpose: To get the current state of the controllers buttons. + Input: Controller number (0 to 3) + - A pointer to a BUTTONS structure to be filled with + the controller state. + Output: None + */ + EXPORT void CALL GetKeys(int Control, BUTTONS * Keys); - /****************************************************************** - Function: InitiateControllers - Purpose: This function initialises how each of the controllers - should be handled. - input: - The handle to the main window. - - A controller structure that needs to be filled for - the emulator to know how to handle each controller. - output: none - *******************************************************************/ + /* + Function: InitiateControllers + Purpose: This function initializes how each of the controllers + should be handled. + Input: The handle to the main window. + - A controller structure that needs to be filled for + the emulator to know how to handle each controller. + Output: None + */ + #if (SPECS_VERSION < 0x0101) EXPORT void CALL InitiateControllers(void * hMainWindow, CONTROL Controls[4]); #elif (SPECS_VERSION == 0x0101) EXPORT void CALL InitiateControllers(CONTROL_INFO ControlInfo); -/* Typo in the official specs, but it works! */ +// Typo in the official specs, but it works! #else EXPORT void CALL InitiateControllers(CONTROL_INFO * ControlInfo); #endif - /****************************************************************** - Function: ReadController - Purpose: To process the raw data in the pif ram that is about to - be read. - input: - Controller Number (0 to 3) and -1 signalling end of - processing the pif ram. - - Pointer of data to be processed. - output: none - note: This function is only needed if the DLL is allowing raw - data. - *******************************************************************/ + /* + Function: ReadController + Purpose: To process the raw data in the PIF RAM that is about to + be read. + Input: Controller Number (0 to 3) and -1 signaling end of + processing the PIF RAM. + - Pointer of data to be processed. + Output: None + Note: This function is only needed if the DLL is allowing raw + data. + */ + EXPORT void CALL ReadController(int Control, BYTE * Command); - /****************************************************************** - Function: RomClosed - Purpose: This function is called when a rom is closed. - input: none - output: none - *******************************************************************/ + /* + Function: RomClosed + Purpose: This function is called when a rom is closed. + Input: None + Output: None + */ + EXPORT void CALL RomClosed(void); - /****************************************************************** - Function: RomOpen - Purpose: This function is called when a rom is open. (from the - emulation thread) - input: none - output: none - *******************************************************************/ + /* + Function: RomOpen + Purpose: This function is called when a rom is open. (from the + emulation thread) + Input: None + Output: None + */ + EXPORT void CALL RomOpen(void); - /****************************************************************** - Function: WM_KeyDown - Purpose: To pass the WM_KeyDown message from the emulator to the - plugin. - input: wParam and lParam of the WM_KEYDOWN message. - output: none - *******************************************************************/ + /* + Function: WM_KeyDown + Purpose: To pass the WM_KeyDown message from the emulator to the + plugin. + Input: wParam and lParam of the WM_KEYDOWN message. + Output: None + */ + EXPORT void CALL WM_KeyDown(WPARAM wParam, LPARAM lParam); - /****************************************************************** - Function: WM_KeyUp - Purpose: To pass the WM_KEYUP message from the emulator to the - plugin. - input: wParam and lParam of the WM_KEYDOWN message. - output: none - *******************************************************************/ + /* + Function: WM_KeyUp + Purpose: To pass the WM_KEYUP message from the emulator to the + plugin. + Input: wParam and lParam of the WM_KEYDOWN message. + Output: None + */ + EXPORT void CALL WM_KeyUp(WPARAM wParam, LPARAM lParam); #if defined(__cplusplus) diff --git a/Source/nragev20/Debug.cpp b/Source/nragev20/Debug.cpp index 1220e758e..2572df729 100644 --- a/Source/nragev20/Debug.cpp +++ b/Source/nragev20/Debug.cpp @@ -1,24 +1,23 @@ /* - N-Rage`s Dinput8 Plugin - (C) 2002, 2006 Norbert Wladyka +N-Rage`s Dinput8 Plugin +(C) 2002, 2006 Norbert Wladyka - Author`s Email: norbert.wladyka@chello.at - Website: http://go.to/nrage +Author`s Email: norbert.wladyka@chello.at +Website: http://go.to/nrage +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the free Software Foundation; either version 2 of the License, or +(at your option) any later version. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the free Software Foundation; either version 2 of the License, or - (at your option) any later version. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include diff --git a/Source/nragev20/Debug.h b/Source/nragev20/Debug.h index 3565a12f4..ec3fa49b8 100644 --- a/Source/nragev20/Debug.h +++ b/Source/nragev20/Debug.h @@ -1,24 +1,23 @@ /* - N-Rage`s Dinput8 Plugin - (C) 2002, 2006 Norbert Wladyka +N-Rage`s Dinput8 Plugin +(C) 2002, 2006 Norbert Wladyka - Author`s Email: norbert.wladyka@chello.at - Website: http://go.to/nrage +Author`s Email: norbert.wladyka@chello.at +Website: http://go.to/nrage +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the free Software Foundation; either version 2 of the License, or +(at your option) any later version. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the free Software Foundation; either version 2 of the License, or - (at your option) any later version. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _DEBUG_H_ diff --git a/Source/nragev20/DirectInput.cpp b/Source/nragev20/DirectInput.cpp index ddde4f1a1..584c84173 100644 --- a/Source/nragev20/DirectInput.cpp +++ b/Source/nragev20/DirectInput.cpp @@ -1,24 +1,23 @@ /* - N-Rage`s Dinput8 Plugin - (C) 2002, 2006 Norbert Wladyka +N-Rage`s Dinput8 Plugin +(C) 2002, 2006 Norbert Wladyka - Author`s Email: norbert.wladyka@chello.at - Website: http://go.to/nrage +Author`s Email: norbert.wladyka@chello.at +Website: http://go.to/nrage +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the free Software Foundation; either version 2 of the License, or +(at your option) any later version. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the free Software Foundation; either version 2 of the License, or - (at your option) any later version. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include @@ -37,18 +36,18 @@ using std::min; using std::max; -// ProtoTypes // +// Prototypes HRESULT AcquireDevice( LPDIRECTINPUTDEVICE8 lpDirectInputDevice ); -// global Variables // +// Global variables LPDIRECTINPUT8 g_pDIHandle = NULL; // Base DirectInput8-Handle -//LPDIRECTINPUTDEVICE8 g_apInputDevice[6] = { NULL, NULL, NULL, NULL, NULL, NULL }; // array of Handles for devices - // 0:Keyboard, 1:Mouse, the rest are FF gamepads +//LPDIRECTINPUTDEVICE8 g_apInputDevice[6] = { NULL, NULL, NULL, NULL, NULL, NULL }; // Array of handles for devices + // 0:keyboard, 1:mouse, the rest are force feedback gamepads -// BYTE g_acKeystate[256]; // use g_sysKeyboard.stateAs.rgbButtons instead +// BYTE g_acKeystate[256]; // Use g_sysKeyboard.stateAs.rgbButtons instead // DIMOUSESTATE2 g_msMouseState = { 0, 0, 0 }; // Store our mouse state data between reads (because every time we read data, it resets the device data) - // moved to g_sysMouse.stateAs... +// Moved to g_sysMouse.stateAs... // Update device data tables (so we only have to poll and read the devices once). This is called by GetKeys and ReadController. void GetDeviceDatas() @@ -59,7 +58,7 @@ void GetDeviceDatas() { hr = g_sysKeyboard.didHandle->Poll(); if( FAILED( hr )) - AcquireDevice( g_sysKeyboard.didHandle ); // we'll try again next time + AcquireDevice( g_sysKeyboard.didHandle ); // We'll try again next time hr = g_sysKeyboard.didHandle->GetDeviceState( sizeof(g_sysKeyboard.stateAs.rgbButtons), &g_sysKeyboard.stateAs.rgbButtons ); @@ -72,7 +71,7 @@ void GetDeviceDatas() hr = g_sysMouse.didHandle->Poll(); if( FAILED( hr )) - AcquireDevice( g_sysMouse.didHandle ); // we'll try again next time + AcquireDevice( g_sysMouse.didHandle ); // We'll try again next time hr = g_sysMouse.didHandle->GetDeviceState( sizeof(DIMOUSESTATE2), &g_sysMouse.stateAs.mouseState ); @@ -80,13 +79,13 @@ void GetDeviceDatas() ZeroMemory( &g_sysMouse.stateAs.mouseState, sizeof(DIMOUSESTATE2) ); } - // need to just poll every damn device we're using + // Need to just poll every device we're using for( int i = 0; i < g_nDevices; i++ ) { if( g_devList[i].didHandle ) { if( FAILED( g_devList[i].didHandle->Poll() )) - AcquireDevice( g_devList[i].didHandle ); // we'll try again next time + AcquireDevice( g_devList[i].didHandle ); // We'll try again next time switch (LOBYTE(g_devList[i].dwDevType)) { @@ -103,7 +102,8 @@ void GetDeviceDatas() else hr = DIERR_NOTACQUIRED; - if( hr == DIERR_NOTACQUIRED ) // changed this because in the rare condition that we lose input between polling and GetDeviceState we don't want to reset our current controls --rabid + if( hr == DIERR_NOTACQUIRED ) // Changed this because in the rare condition that we lose input between polling and GetDeviceState we don't want to + // reset our current controls (comment by rabid) { ZeroMemory( &g_devList[i].stateAs.joyState, sizeof(DEVICE::INPUTSTATE)); if (g_devList[i].dwDevType != DI8DEVTYPE_KEYBOARD && g_devList[i].dwDevType != DI8DEVTYPE_MOUSE) @@ -112,9 +112,9 @@ void GetDeviceDatas() } } -// hacked up piece of shit, but it works +// Hacked up, but it works inline bool GetJoyPadPOV( PDWORD dwDegree, BYTE AxeId ) -// TRUE if specified Direction is Pressed +// True if specified direction is pressed { if( LOWORD( *dwDegree ) == 0xFFFF ) return false; @@ -143,14 +143,14 @@ inline bool GetJoyPadPOV( PDWORD dwDegree, BYTE AxeId ) } // Fill in button states and axis states for controller indexController, into the struct pdwData. -// pdwData is a pointer to a 4 byte BUTTONS union, if anyone cares +// pdwData is a pointer to a 4 byte BUTTONS union, if matters to anybody bool GetNControllerInput ( const int indexController, LPDWORD pdwData ) { *pdwData = 0; WORD w_Buttons = 0; // WORD w_Axes = 0; - LPCONTROLLER pcController = &g_pcControllers[indexController]; // still needs to be here, but not as important --rabid + LPCONTROLLER pcController = &g_pcControllers[indexController]; // Still needs to be here, but not as important (comment by rabid) bool b_Value; long l_Value = 0; @@ -158,13 +158,13 @@ bool GetNControllerInput ( const int indexController, LPDWORD pdwData ) long lAxisValueX = ZEROVALUE; long lAxisValueY = ZEROVALUE; - // take this info from the N64 controller struct, regardless of input devices + // Take this info from the N64 controller struct, regardless of input devices float d_ModifierX = (float)pcController->bStickRange / 100.0f; float d_ModifierY = (float)pcController->bStickRange / 100.0f; int i; - // do N64-Buttons / modifiers + // Do N64-Buttons / modifiers for (i = 0; i < pcController->nModifiers; i++ ) { BUTTON btnButton = pcController->pModifiers[i].btnButton; @@ -174,7 +174,7 @@ bool GetNControllerInput ( const int indexController, LPDWORD pdwData ) bool fChangeMod = false; if( pcController->pModifiers[i].bModType == MDT_CONFIG ) - { // Config-Type + { // Config type if( pcController->pModifiers[i].fToggle ) { if( b_Value && !btnButton.fPrevPressed) @@ -190,7 +190,7 @@ bool GetNControllerInput ( const int indexController, LPDWORD pdwData ) } } else - { // Move / Macro Type + { // Move / macro type if( pcController->pModifiers[i].fToggle ) { if( b_Value && !btnButton.fPrevPressed ) @@ -218,7 +218,7 @@ bool GetNControllerInput ( const int indexController, LPDWORD pdwData ) { LPMODSPEC_MACRO args = (LPMODSPEC_MACRO)&pcController->pModifiers[i].dwSpecific; - if (args->fRapidFire) // w00t! Rapid Fire here + if (args->fRapidFire) // Rapid fire here { if ((unsigned) b_Value != btnButton.fPrevPressed) // New macro pressed { @@ -239,20 +239,20 @@ bool GetNControllerInput ( const int indexController, LPDWORD pdwData ) lAxisValueY += MAXAXISVALUE; } - // Ok, update the firing counters here + // OK, update the firing counters here if (args->fRapidFireRate) // Do the rapid fire slowly - { // Note that this updates State2 before State... Makes a nice slower square-wave type pulse for the update + { // Note that this updates State2 before State...makes a nice slower square-wave type pulse for the update args->fPrevFireState2 = (args->fPrevFireState2 + 1) & 1; if (!args->fPrevFireState2) { args->fPrevFireState = (args->fPrevFireState + 1) & 1; - DebugWriteA("Slow Rapid Fire - Mark 2\n"); + DebugWriteA("Slow rapid fire - Mark 2\n"); } } else // Do a fast rapid fire { args->fPrevFireState = (args->fPrevFireState + 1) & 1; - DebugWriteA("Fast Rapid Fire\n"); + DebugWriteA("Fast rapid fire\n"); } } else @@ -265,7 +265,7 @@ bool GetNControllerInput ( const int indexController, LPDWORD pdwData ) if( args->fAnalogDown ) lAxisValueY -= MAXAXISVALUE; - else if( args->fAnalogUp ) // up + else if( args->fAnalogUp ) // Up lAxisValueY += MAXAXISVALUE; args->fPrevFireState = 0; @@ -312,9 +312,9 @@ bool GetNControllerInput ( const int indexController, LPDWORD pdwData ) btnButton.fPrevPressed = b_Value; pcController->pModifiers[i].btnButton = btnButton; - } // END N64 MODIFIERS for + } // End N64 modifiers for - // do N64-Buttons / modifiers + // Do N64 buttons / modifiers for( i = 0; i < PF_APADR; i++ ) { BUTTON btnButton = pcController->aButton[i]; @@ -322,12 +322,12 @@ bool GetNControllerInput ( const int indexController, LPDWORD pdwData ) b_Value = IsBtnPressed( btnButton ); w_Buttons |= (((WORD)b_Value) << i); - } // END N64 BUTTONS for + } // End N64 buttons for long lDeadZoneValue = pcController->bPadDeadZone * RANGERELATIVE / 100; float fDeadZoneRelation = (float)RANGERELATIVE / (float)( RANGERELATIVE - lDeadZoneValue ); - // do N64 joystick axes + // Do N64 joystick axes for ( i = 0; i < 4; i++ ) { // 0 : right @@ -351,7 +351,7 @@ bool GetNControllerInput ( const int indexController, LPDWORD pdwData ) case DT_JOYAXE: l_Value = plRawState[btnButton.bOffset] - ZEROVALUE; - if( btnButton.bAxisID ) // negative Range + if( btnButton.bAxisID ) // Negative range { fNegInput = !fNegInput; @@ -443,7 +443,7 @@ bool GetNControllerInput ( const int indexController, LPDWORD pdwData ) pcController->wAxeBuffer[i] = 0; } - if( btnButton.bAxisID == AI_AXE_N) // the mouse axis has the '-' flag set + if( btnButton.bAxisID == AI_AXE_N) // The mouse axis has the '-' flag set { fNegInput = !fNegInput; @@ -536,7 +536,7 @@ bool GetNControllerInput ( const int indexController, LPDWORD pdwData ) lRangeX = lRangeY * lAbsoluteX / lAbsoluteY; } - // TODO: optimize this --rabid + // TODO: We should optimize this (comment by rabid) double dRangeDiagonal = sqrt((double)(lRangeX * lRangeX + lRangeY * lRangeY)); // __asm{ // fld fRangeDiagonal @@ -568,7 +568,7 @@ bool InitDirectInput( HWND hWnd ) { ErrorMessage(IDS_ERR_DINOTFOUND, 0, false); } - else if( !g_pDIHandle ) // is NULL if not yet initialized + else if( !g_pDIHandle ) // This is NULL if not yet initialized { HRESULT (WINAPI *lpGetDIHandle)( HINSTANCE, DWORD, REFIID, LPVOID*, LPUNKNOWN ) = NULL; lpGetDIHandle = (HRESULT (WINAPI *)( HINSTANCE, DWORD, REFIID, LPVOID*, LPUNKNOWN ))GetProcAddress( g_hDirectInputDLL, "DirectInput8Create" ); @@ -591,7 +591,7 @@ bool InitDirectInput( HWND hWnd ) return (g_pDIHandle != NULL); } -// release a DirectInput device. We don't need it anymore. +// Release a DirectInput device since we don't need it anymore void ReleaseDevice( LPDIRECTINPUTDEVICE8 &lpDirectInputDevice ) { if( lpDirectInputDevice != NULL) @@ -603,49 +603,49 @@ void ReleaseDevice( LPDIRECTINPUTDEVICE8 &lpDirectInputDevice ) return; } -// release a DirectInput effect. We don't need it anymore. +// Release a DirectInput device since we don't need it anymore void ReleaseEffect( LPDIRECTINPUTEFFECT &lpDirectEffect ) { if( lpDirectEffect != NULL) { - // should unload the effect on release, I hope + // We should unload the effect on release lpDirectEffect->Release(); lpDirectEffect = NULL; } return; } -// release our DirectInput effects and devices, our DirectInput handle, and then unload dinput library +// Release our DirectInput effects and devices, our DirectInput handle, and then unload DInput library void FreeDirectInput () { int i; - // release effects + // Release effects for( i = 0; i < ARRAYSIZE( g_apdiEffect ); ++i ) ReleaseEffect( g_apdiEffect[i] ); ZeroMemory( g_apdiEffect, sizeof(g_apdiEffect) ); - // release FF devices + // Release force feedback devices for( i = 0; i << ARRAYSIZE(g_apFFDevice); ++i ) ReleaseDevice( g_apFFDevice[i] ); ZeroMemory( g_apFFDevice, sizeof(g_apFFDevice) ); - // release normal devices + // Release normal devices for( i = 0; i < g_nDevices; i++ ) ReleaseDevice( g_devList[i].didHandle ); ZeroMemory( g_devList, sizeof(g_devList) ); g_nDevices = 0; - // release mouse device + // Release mouse device ReleaseDevice( g_sysMouse.didHandle ); ZeroMemory( &g_sysMouse, sizeof(g_sysMouse) ); - // Release any DirectInput handles. + // Release any DirectInput handles if( g_pDIHandle != NULL ) { g_pDIHandle->Release(); g_pDIHandle = NULL; } - // Unload the library. + // Unload the library if( g_hDirectInputDLL != NULL ) { FreeLibrary( g_hDirectInputDLL ); @@ -654,7 +654,7 @@ void FreeDirectInput () return; } -// Acquire our device. Our device might get unacquired for many many reasons, and we need to be able to reacquire it to get input again. +// Acquire our device. Our device might get unacquired for many many reasons, and we need to be able to reacquire it to get input again. // We use this a LOT. inline HRESULT AcquireDevice( LPDIRECTINPUTDEVICE8 lpDirectInputDevice ) { @@ -666,7 +666,7 @@ inline HRESULT AcquireDevice( LPDIRECTINPUTDEVICE8 lpDirectInputDevice ) return hResult; } -// Called by the DirectInput enumerator for each FF device. What kind of force feedback effects does this device support? We'll store it in pvRef. +// Called by the DirectInput enumerator for each force feedback device. What kind of force feedback effects does this device support? We'll store it in pvRef. BOOL CALLBACK EnumGetEffectTypes( LPCDIEFFECTINFO pdei, LPVOID pvRef ) { BYTE bFFType = *(LPBYTE)pvRef; @@ -680,23 +680,23 @@ BOOL CALLBACK EnumGetEffectTypes( LPCDIEFFECTINFO pdei, LPVOID pvRef ) } // Called by the DirectInput enumerator for each attached DI device. We use it to make a list of devices. -// EnumMakeDeviceList has been rewritten. --rabid +// EnumMakeDeviceList has been rewritten (comment by rabid) BOOL CALLBACK EnumMakeDeviceList( LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef ) { switch (GET_DIDEVICE_TYPE(lpddi->dwDevType)) { - // we don't need to do anything with these generic devices + // We don't need to do anything with these generic devices case DI8DEVTYPE_DEVICE: return DIENUM_CONTINUE; break; - // these are potential xinput controllers, check them + // These are potential XInput controllers, check them case DI8DEVTYPE_GAMEPAD: case DI8DEVTYPE_DRIVING: case DI8DEVTYPE_JOYSTICK: case DI8DEVTYPE_FLIGHT: - if (IsXInputDevice(&lpddi->guidProduct)) // Check if is XInput device --tecnicors + if (IsXInputDevice(&lpddi->guidProduct)) // Check if is XInput device (comment by tecnicors) return DIENUM_CONTINUE; break; - // for all other devices, continue on + // For all other devices, continue on default: break; } @@ -708,13 +708,13 @@ BOOL CALLBACK EnumMakeDeviceList( LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef ) if (IsEqualGUID(g_devList[i].guidInstance, lpddi->guidInstance)) return ( g_nDevices < ARRAYSIZE(g_devList) ) ? DIENUM_CONTINUE : DIENUM_STOP; - if (g_nDevices < ARRAYSIZE(g_devList)) // our buffer isn't full yet and the device doesn't already exist in our table + if (g_nDevices < ARRAYSIZE(g_devList)) // Our buffer isn't full yet and the device doesn't already exist in our table { lstrcpyn( g_devList[g_nDevices].szProductName, lpddi->tszProductName, MAX_PATH ); g_devList[g_nDevices].dwDevType = lpddi->dwDevType; g_devList[g_nDevices].guidInstance = lpddi->guidInstance; - g_devList[g_nDevices].bProductCounter = 0; // counting similar devices + g_devList[g_nDevices].bProductCounter = 0; // Counting similar devices for( int i = 0; i < g_nDevices; ++i ) { if( !lstrcmp( lpddi->tszProductName, g_devList[i].szProductName )) @@ -726,7 +726,7 @@ BOOL CALLBACK EnumMakeDeviceList( LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef ) g_devList[i].bProductCounter = 1; } else - g_devList[g_nDevices].bProductCounter++; // give em instance numbers + g_devList[g_nDevices].bProductCounter++; // Give them instance numbers } } if( !lstrcmp( lpddi->tszProductName, TEXT( STRING_ADAPTOID ))) @@ -746,7 +746,7 @@ BOOL CALLBACK EnumMakeDeviceList( LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef ) return ( g_nDevices < ARRAYSIZE(g_devList) ) ? DIENUM_CONTINUE : DIENUM_STOP; } -// Called by an enumerator in GetInputDevice to determine if a device is attached at all. +// Called by an enumerator in GetInputDevice to determine if a device is attached at all BOOL CALLBACK EnumIsDeviceAvailable( LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef ) { if( lpddi->guidInstance == *(GUID*)((LPVOID*)pvRef)[0] ) @@ -758,7 +758,7 @@ BOOL CALLBACK EnumIsDeviceAvailable( LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef ) return DIENUM_CONTINUE; } -// Called by an axis enumerator in GetInputDevice. Set the min and max range so we can pass the rec'd value right to the emulator. +// Called by an axis enumerator in GetInputDevice. Set the minimum and maximum range so we can pass the recorded value right to the emulator BOOL CALLBACK EnumSetObjectsAxis( LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef) { LPDIRECTINPUTDEVICE8 lpDirectInputDevice = (LPDIRECTINPUTDEVICE8)pvRef; @@ -771,21 +771,20 @@ BOOL CALLBACK EnumSetObjectsAxis( LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef diprg.lMin = MINAXISVALUE; diprg.lMax = MAXAXISVALUE; - lpDirectInputDevice->SetProperty(DIPROP_RANGE, &diprg.diph); // HACK: Usually works, but not all devices support setting range. + lpDirectInputDevice->SetProperty(DIPROP_RANGE, &diprg.diph); // HACK: Usually works, but not all devices support setting range return DIENUM_CONTINUE; } -// **if passed an existing DirectInputDevice which matches gGuid -// unacquires it, and sets its cooperative level (reinitialize) -// **if the existing device does not match the passed gGuid, the existing device is released -// **if no device was passed or gGuid did not match -// searches for the controller matching gGuid in connected and available devices -// creates a DirectInputDevice -// sets its data format -// sets its cooperative level -// for joysticks, calls EnumSetObjectsAxis for each axis -// GetInputDevice always leaves the returned device in an UNACQUIRED state. +/* +If passed an existing DirectInputDevice which matches gGuid +unacquires it, and sets its cooperative level (reinitialize) +If the existing device does not match the passed gGuid, the existing device is released +If no device was passed or gGuid did not match it searches for the controller matching gGuid in connected and available devices +Creates a DirectInputDevice, sets its data format, sets its cooperative level for joysticks, calls EnumSetObjectsAxis for each axis +GetInputDevice always leaves the returned device in an UNACQUIRED state. +*/ + bool GetInputDevice( HWND hWnd, LPDIRECTINPUTDEVICE8 &lpDirectInputDevice, GUID gGuid, DWORD dwDevType, DWORD dwCooperativeLevel ) { DebugWriteA("GetInputDevice: gGuid is {%08.8lX-%04.4hX-%04.4hX-%02.2X%02.2X-%02.2X%02.2X%02.2X%02.2X%02.2X%02.2X}\n", gGuid.Data1, gGuid.Data2, gGuid.Data3, gGuid.Data4[0], gGuid.Data4[1], gGuid.Data4[2], gGuid.Data4[3], gGuid.Data4[4], gGuid.Data4[5], gGuid.Data4[6], gGuid.Data4[7]); @@ -796,8 +795,8 @@ bool GetInputDevice( HWND hWnd, LPDIRECTINPUTDEVICE8 &lpDirectInputDevice, GUID lpDirectInputDevice->GetDeviceInfo( &didDev ); if( didDev.guidInstance == gGuid ) - { // we've already gotten this device; unacquire it and initialize - DebugWriteA("GetInputDevice: already created, attempting to reinit\n"); + { // We've already gotten this device; unacquire it and initialize + DebugWriteA("GetInputDevice: Already created, attempting to reinitialize\n"); lpDirectInputDevice->Unacquire(); lpDirectInputDevice->SetCooperativeLevel( hWnd, dwCooperativeLevel ); return true; @@ -826,7 +825,7 @@ bool GetInputDevice( HWND hWnd, LPDIRECTINPUTDEVICE8 &lpDirectInputDevice, GUID //case DI8DEVTYPE_DRIVING: //case DI8DEVTYPE_1STPERSON: //case DI8DEVTYPE_FLIGHT: - default: // assume everything else is a gamepad; probably not the best idea but it works + default: // Assume everything else is a controller; probably not the best idea but it works ppDiDataFormat = &c_dfDIJoystick; break; } @@ -835,7 +834,7 @@ bool GetInputDevice( HWND hWnd, LPDIRECTINPUTDEVICE8 &lpDirectInputDevice, GUID VOID* aRef[2] = { &gGuid, &bDeviceAvailable }; - // for each available device in our dwDevType category, run EnumIsDeviceAvailable with params "aRef" + // For each available device in our dwDevType category, run EnumIsDeviceAvailable with params "aRef" g_pDIHandle->EnumDevices( DI8DEVCLASS_ALL, EnumIsDeviceAvailable, (LPVOID)aRef, DIEDFL_ATTACHEDONLY ); if( !bDeviceAvailable ) @@ -887,7 +886,7 @@ bool CreateEffectHandle( HWND hWnd, LPDIRECTINPUTDEVICE8 lpDirectInputDevice, LP HRESULT hResult; - // count the FF - axes of the joystick + // Count the force feedback - axes of the joystick lpDirectInputDevice->EnumObjects( EnumCountFFAxes, &nAxes, DIDFT_FFACTUATOR | DIDFT_AXIS ); if( nAxes == 0 ) @@ -895,12 +894,12 @@ bool CreateEffectHandle( HWND hWnd, LPDIRECTINPUTDEVICE8 lpDirectInputDevice, LP nAxes = min( nAxes, 2 ); - // Must be unaquired for setting stuff like Co-op Level + // Must be unaquired for setting stuff like co-op level hResult = lpDirectInputDevice->Unacquire(); - //FF Requires EXCLUSIVE LEVEL, took me hours to find the reason why it wasnt working + // Force feedback Requires EXCLUSIVE LEVEL, took me hours to find the reason why it wasn't working hResult = lpDirectInputDevice->SetCooperativeLevel( hWnd, DIB_FF ); - // fail if we can't set coop level --rabid + // Fail if we can't set coop level (comment by rabid) if (hResult != DI_OK) { DebugWriteA("CreateEffectHandle: couldn't set coop level: %08X\n", hResult); @@ -928,7 +927,7 @@ bool CreateEffectHandle( HWND hWnd, LPDIRECTINPUTDEVICE8 lpDirectInputDevice, LP eff.dwGain = lStrength * 100; eff.dwTriggerButton = DIEB_NOTRIGGER; eff.dwTriggerRepeatInterval = 0; - eff.cAxes = nAxes; //Number of Axes + eff.cAxes = nAxes; // Number of axes eff.rgdwAxes = rgdwAxes; eff.rglDirection = rglDirection; eff.lpEnvelope = NULL; @@ -943,7 +942,7 @@ bool CreateEffectHandle( HWND hWnd, LPDIRECTINPUTDEVICE8 lpDirectInputDevice, LP case RUMBLE_CONSTANT: EffectGuid = (GUID*)&GUID_ConstantForce; - eff.dwDuration = 150000; // microseconds + eff.dwDuration = 150000; // Microseconds eff.dwSamplePeriod = 0; eff.cbTypeSpecificParams = sizeof(DICONSTANTFORCE); eff.lpvTypeSpecificParams = &cf; @@ -953,7 +952,7 @@ bool CreateEffectHandle( HWND hWnd, LPDIRECTINPUTDEVICE8 lpDirectInputDevice, LP case RUMBLE_RAMP: EffectGuid = (GUID*)&GUID_RampForce; - eff.dwDuration = 300000; // microseconds + eff.dwDuration = 300000; // Microseconds eff.dwSamplePeriod = 0; eff.cbTypeSpecificParams = sizeof(DIRAMPFORCE); eff.lpvTypeSpecificParams = &rf; @@ -966,7 +965,7 @@ bool CreateEffectHandle( HWND hWnd, LPDIRECTINPUTDEVICE8 lpDirectInputDevice, LP case RUMBLE_PERIODIC: EffectGuid = (GUID*)&GUID_Sine; - eff.dwDuration = 150000; // microseconds + eff.dwDuration = 150000; // Microseconds eff.dwSamplePeriod = 0; eff.cbTypeSpecificParams = sizeof(DIPERIODIC); eff.lpvTypeSpecificParams = &pf; @@ -997,7 +996,7 @@ bool CreateEffectHandle( HWND hWnd, LPDIRECTINPUTDEVICE8 lpDirectInputDevice, LP return SUCCEEDED( hResult ); } -// Counts how many of each type of button assignment (keyboard, mouse, gamepad) +// Counts how many of each type of button assignment (keyboard, mouse, controller) DWORD CountControllerStructDevs( CONTROLLER *pController ) { BYTE bMouse = 0, bKeyboard = 0, bGamePad = 0; @@ -1045,8 +1044,7 @@ DWORD CountControllerStructDevs( CONTROLLER *pController ) return MAKELONG( MAKEWORD( bGamePad, bMouse ), MAKEWORD( bKeyboard, ( bMouse + bKeyboard + bGamePad ))); } - -// PrepareInputDevices rewritten --rabid +// PrepareInputDevices rewritten (comment by rabid) bool PrepareInputDevices() { bool fKeyboard = false; @@ -1062,11 +1060,11 @@ bool PrepareInputDevices() fKeyboard = g_pcControllers[i].fKeyboard != 0; fMouse = g_pcControllers[i].fMouse != 0; - fGamePad = ( g_pcControllers[i].fGamePad != 0); // we'll assume for now that there's a gamepad to go with those buttons + fGamePad = ( g_pcControllers[i].fGamePad != 0); // We'll assume for now that there's a controller to go with those buttons } ReleaseEffect( g_apdiEffect[i] ); - if( g_pcControllers[i].guidFFDevice != GUID_NULL && GetInputDevice( g_strEmuInfo.hMainWindow, g_apFFDevice[i], g_pcControllers[i].guidFFDevice, DI8DEVTYPE_JOYSTICK, DIB_FF )) // not necessarily a joystick type device, but we don't use the data anyway + if( g_pcControllers[i].guidFFDevice != GUID_NULL && GetInputDevice( g_strEmuInfo.hMainWindow, g_apFFDevice[i], g_pcControllers[i].guidFFDevice, DI8DEVTYPE_JOYSTICK, DIB_FF )) // Not necessarily a joystick type device, but we don't use the data anyway { DIDEVICEINSTANCE diDev; diDev.dwSize = sizeof( DIDEVICEINSTANCE ); @@ -1076,7 +1074,7 @@ bool PrepareInputDevices() if( !lstrcmp( diDev.tszProductName, _T( STRING_ADAPTOID ))) { g_pcControllers[i].fIsAdaptoid = true; - DebugWriteA("FF device on controller %d is of type Adaptoid\n", i+1); + DebugWriteA("Force feedback device on controller %d is of type Adaptoid\n", i+1); } else { @@ -1086,15 +1084,15 @@ bool PrepareInputDevices() if ( CreateEffectHandle( i, g_pcControllers[i].bRumbleTyp, g_pcControllers[i].bRumbleStrength ) ) { AcquireDevice( g_apFFDevice[i] ); - DebugWriteA("Got FF device %d\n", i); + DebugWriteA("Got force feedback device %d\n", i); } else - DebugWriteA("Couldn't get FF device: CreateEffectHandle failed!\n"); + DebugWriteA("Couldn't get force feedback device: CreateEffectHandle failed!\n"); } else { g_apFFDevice[i] = NULL; - DebugWriteA("Didn't get FF device %d\n", i); + DebugWriteA("Didn't get force feedback device %d\n", i); } } @@ -1123,12 +1121,12 @@ bool IsAdaptoidCommandSupported( LPDIRECTINPUTDEVICE8 lpDirectInputDevice, DWORD HRESULT hr; esc.dwSize = sizeof(esc); - esc.dwCommand = ADAPT_TEST; // command to determine if a command is supported + esc.dwCommand = ADAPT_TEST; // Command to determine if a command is supported esc.lpvInBuffer = &inbuf; esc.cbInBuffer = 4; esc.lpvOutBuffer = &outbuf; esc.cbOutBuffer = 4; - inbuf = cmd; // command that we are asking is supported + inbuf = cmd; // Command that we are asking is supported outbuf = 0; hr = lpDirectInputDevice->Escape(&esc); @@ -1137,7 +1135,7 @@ bool IsAdaptoidCommandSupported( LPDIRECTINPUTDEVICE8 lpDirectInputDevice, DWORD } #ifdef _DEBUG -// Direct Adaptoid debugging stuff. +// Direct Adaptoid debugging stuff void _debugAd( LPCSTR szMessage, HRESULT res ) { LPCSTR suc = (SUCCEEDED(res)) ? "OK" : "FAILED"; @@ -1151,7 +1149,7 @@ HRESULT DirectRumbleCommand( LPDIRECTINPUTDEVICE8 lpDirectInputDevice, DWORD cmd DIEFFESCAPE esc; esc.dwSize = sizeof(esc); - esc.dwCommand = ADAPT_RUMBLE; // send rumble command + esc.dwCommand = ADAPT_RUMBLE; // Send rumble command esc.lpvInBuffer = &cmd; // 1=go, 0=stop esc.cbInBuffer = 4; esc.lpvOutBuffer = NULL; @@ -1171,7 +1169,7 @@ HRESULT InitializeAdaptoid( LPDIRECTINPUTDEVICE8 lpDirectInputDevice, LPBYTE sta DIEFFESCAPE esc; esc.dwSize = sizeof(esc); - esc.dwCommand = ADAPT_INIT; // Initialize Pak + esc.dwCommand = ADAPT_INIT; // Initialize pak esc.lpvInBuffer = NULL; esc.cbInBuffer = 0; esc.lpvOutBuffer = status; @@ -1269,7 +1267,7 @@ void InitMouse() g_sysMouse.didHandle = NULL; } -// treat btnButton as a b_Value, and return whether it is pressed or not +// Treat btnButton as a b_Value, and return whether it is pressed or not bool IsBtnPressed(BUTTON btnButton) { long l_Value; @@ -1299,7 +1297,7 @@ bool IsBtnPressed(BUTTON btnButton) return ( btnButton.parentDevice->stateAs.mouseState.rgbButtons[btnButton.bOffset] & 0x80 ) != 0; case DT_MOUSEAXE: - l_Value = MOUSEMOVE; // a.k.a. lvalue is button threshold + l_Value = MOUSEMOVE; // AKA lvalue is button threshold if( btnButton.bAxisID ) return ( ((LPLONG)(&btnButton.parentDevice->stateAs.mouseState))[btnButton.bOffset] < -l_Value ); diff --git a/Source/nragev20/DirectInput.h b/Source/nragev20/DirectInput.h index 7b766186c..cef15c215 100644 --- a/Source/nragev20/DirectInput.h +++ b/Source/nragev20/DirectInput.h @@ -1,24 +1,23 @@ /* - N-Rage`s Dinput8 Plugin - (C) 2002, 2006 Norbert Wladyka +N-Rage`s Dinput8 Plugin +(C) 2002, 2006 Norbert Wladyka - Author`s Email: norbert.wladyka@chello.at - Website: http://go.to/nrage +Author`s Email: norbert.wladyka@chello.at +Website: http://go.to/nrage +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the free Software Foundation; either version 2 of the License, or +(at your option) any later version. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the free Software Foundation; either version 2 of the License, or - (at your option) any later version. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _DIRECTINPUT_H_ @@ -61,20 +60,19 @@ HRESULT WriteAdaptoidPak( LPDIRECTINPUTDEVICE8 lpDirectInputDevice, DWORD addr, #define THRESHOLD 50 #define RANGERELATIVE (MAXAXISVALUE - ZEROVALUE + 1) #define ABSTHRESHOLD (RANGERELATIVE * THRESHOLD / 100) - // plus or minus this many 1/100 degrees counts as GetJoyPadPOV being pressed +// Plus or minus this many 1/100 degrees counts as GetJoyPadPOV being pressed #define POVANGLETHRESH 5675 #define MOUSEMOVE 5 - // by default, scale the mouse input by this much +// By default, scale the mouse input by this much #define MOUSESCALEVALUE 10 - // percent to decay mouse buffer every frame. - // Tweak this from 0-100 to control how much the mouse drifts; values closer to 100 drift more, - // while values closer to 0 are very stiff (deadpan) and don't turn well +// Percent to decay mouse buffer every frame +// Tweak this from 0-100 to control how much the mouse drifts; values closer to 100 drift more, +// while values closer to 0 are very stiff (deadpan) and don't turn well #define MOUSEBUFFERDECAY 80 #define N64DIVIDER 258 - #define DID_KEYBOARD 0 #define DID_MOUSE 1 #define DID_GAMEPAD 2 @@ -99,22 +97,22 @@ HRESULT WriteAdaptoidPak( LPDIRECTINPUTDEVICE8 lpDirectInputDevice, DWORD addr, #define RUMBLE_EFF2 RUMBLE_RAMP #define RUMBLE_EFF3 RUMBLE_DIRECT - // Reported Name of the Adaptoid +// Reported name of the Adaptoid #define STRING_ADAPTOID "Adaptoid" #define STRING_GUID_SYSKEYBOARD _T("Keyboard") #define STRING_GUID_SYSMOUSE _T("SysMouse") - // Query API - pass in command #, returns 0xB0CAB0CA if supported +// Query API - pass in command #, returns 0xB0CAB0CA if supported #define ADAPT_TEST 0x7834BB00 - // Send command to rumble pack (DWORD 0=stop, 1=go) +// Send command to rumble pack (DWORD 0=stop, 1=go) #define ADAPT_RUMBLE 0x7834BB08 - // Initialize pak (returns pak status bit flags) +// Initialize pak (returns pak status bit flags) #define ADAPT_INIT 0x7834BB0C - // Read from pak (reads 32 bytes of data) +// Read from pak (reads 32 bytes of data) #define ADAPT_READPAK 0x7834BB0D - // Write to pak (writes 32 bytes of data) +// Write to pak (writes 32 bytes of data) #define ADAPT_WRITEPAK 0x7834BB0E - // Send command directly to controller - synchronous +// Send command directly to controller - synchronous #define ADAPT_DIRECTCOMMAND 0x7834BB28 // The following inline functions are all overloads for existing functions @@ -123,7 +121,7 @@ inline bool CreateEffectHandle( int iDevice, BYTE bRumbleTyp, long lStrength ) return CreateEffectHandle( g_strEmuInfo.hMainWindow, g_apFFDevice[iDevice], g_apdiEffect[iDevice], bRumbleTyp, lStrength ); } -// this used to exist, but it was only used once and makes things more confusing. Removed. --rabid +// This used to exist, but it was only used once and makes things more confusing. It has been removed. (comment by rabid) //inline void ReleaseEffect( int iEffect ) //{ // ReleaseEffect( g_apdiEffect[iEffect] ); diff --git a/Source/nragev20/FileAccess.cpp b/Source/nragev20/FileAccess.cpp index 5a13741f4..01dbd743a 100644 --- a/Source/nragev20/FileAccess.cpp +++ b/Source/nragev20/FileAccess.cpp @@ -1,24 +1,23 @@ - /* - N-Rage`s Dinput8 Plugin - (C) 2002, 2006 Norbert Wladyka +/* +N-Rage`s Dinput8 Plugin +(C) 2002, 2006 Norbert Wladyka - Author`s Email: norbert.wladyka@chello.at - Website: http://go.to/nrage +Author`s Email: norbert.wladyka@chello.at +Website: http://go.to/nrage +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the free Software Foundation; either version 2 of the License, or +(at your option) any later version. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the free Software Foundation; either version 2 of the License, or - (at your option) any later version. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include @@ -56,7 +55,7 @@ void DumpControllerSettings(FILE * fFile, int i, bool bIsINI); void FormatControlsBlock(string * strMouse, string strDevs[], string * strNull, int i); void FormatModifiersBlock(string * strMouse, string strDevs[], string * strNull, int i); -// return true if the file exists... let's just use CreateFile with OPEN_EXISTING +// Return true if the file exists, let's just use CreateFile with OPEN_EXISTING bool CheckFileExists( LPCTSTR FileName ) { HANDLE hFile = CreateFile(FileName, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); @@ -77,7 +76,7 @@ bool CheckFileExists( LPCTSTR FileName ) // PL_CATEGORY and removes the brackets if the line looks like a keymapping // PL_VERSIONSTRING and returns the version number if it's a version line // for other cases, another PL return value and truncates before the equal sign; so strings like "Button=blah" -> "blah" -// TODO: Perhaps buffer overflow and crash potential here... needs auditing +// TODO: Perhaps buffer overflow and crash potential here...needs auditing DWORD ParseLine( LPSTR pszLine ) { DWORD dwReturn = PL_NOHIT; @@ -85,7 +84,7 @@ DWORD ParseLine( LPSTR pszLine ) switch (pszLine[0]) { - case '\0': // shortcut out on null string + case '\0': // Shortcut out on null string case '#': // # indicates comment line return PL_NOHIT; case '[': @@ -96,14 +95,14 @@ DWORD ParseLine( LPSTR pszLine ) } if( *pChar == ']' ) { - MoveMemory( pszLine, pszLine+1, (pChar-pszLine) - 1 * sizeof(pszLine[0]) ); // TODO: please double check this --rabid - *(pChar - 1) = '\0'; // since we moved everything back one character, we need to change this ref as well + MoveMemory( pszLine, pszLine+1, (pChar-pszLine) - 1 * sizeof(pszLine[0]) ); // TODO: Please double check this (comment by rabid) + *(pChar - 1) = '\0'; // Since we moved everything back one character, we need to change this ref as well return PL_CATEGORY; } else - return PL_NOHIT; // an open bracket with no closing returns nohit + return PL_NOHIT; // An open bracket with no closing returns no hit case '@': - switch( djbHash(pszLine)) // the hash check is case sensitive, and includes the @ symbol + switch( djbHash(pszLine)) // The hash check is case sensitive, and includes the @ symbol { case CHK_PROFILEVERSION20: lstrcpyA( pszLine, "2.0" ); @@ -118,20 +117,20 @@ DWORD ParseLine( LPSTR pszLine ) DebugWriteA("Unknown version string found with hash %u: %s\n", djbHash(pszLine), pszLine); return PL_NOHIT; } // end switch (dbjHash(pszLine)) - // default: keep running + // Default: keep running } pChar = strchr(pszLine, '='); - if( !pChar ) // no = sign + if( !pChar ) // No = sign { return PL_NOHIT; } - else // there is an '=' sign + else // There is an '=' sign { // We hash the string. If the hash matches the hash of one of our targets, we compare strings to verify. - // If we don't use hashes, we have to compare vs a LOT of strings. - *pChar = '\0'; // truncate at the '=' for now + // If we don't use hashes, we have to compare vs many strings. + *pChar = '\0'; // Truncate at the '=' for now for (char *pIter = pszLine; *pIter; pIter++) *pIter = toupper(*pIter); dwReturn = djbHash(pszLine); @@ -144,8 +143,8 @@ DWORD ParseLine( LPSTR pszLine ) return dwReturn; } -// Called immediately after ParseLine to assign values based on whatever the keyname was -// notes: pszFFDevice may be overwritten with whatever is in pszLine; please make sure pszLine is not too big! +// Called immediately after ParseLine to assign values based on whatever the key name was +// Notes: pszFFDevice may be overwritten with whatever is in pszLine; please make sure pszLine is not too big! bool ProcessKey( DWORD dwKey, DWORD dwSection, LPCSTR pszLine, LPTSTR pszFFDevice, LPBYTE bFFDeviceNr, bool bIsInterface ) { static TCHAR pszDeviceName[MAX_PATH]; @@ -153,9 +152,9 @@ bool ProcessKey( DWORD dwKey, DWORD dwSection, LPCSTR pszLine, LPTSTR pszFFDevic static GUID gGUID; bool bReturn = true; - LPCONTROLLER pController = NULL; // used when we're assigning things in the [Controller X] category + LPCONTROLLER pController = NULL; // Used when we're assigning things in the [Controller X] category LPSHORTCUTS pShortcuts = NULL; - unsigned int iLength = lstrlenA( pszLine ) / 2; // 2 HEX characters correspond to one BYTE; thus iLength represents the length of pszLine after conversion to BYTEs + unsigned int iLength = lstrlenA( pszLine ) / 2; // 2 hex characters correspond to one byte; thus iLength represents the length of pszLine after converting to bytes switch (dwSection) { @@ -334,7 +333,7 @@ bool ProcessKey( DWORD dwKey, DWORD dwSection, LPCSTR pszLine, LPTSTR pszFFDevic bReturn = StringtoGUIDA(&pController->guidFFDevice, pszLine); if (bIsInterface && bReturn) { - // For some reason, we use ONLY device names and numbers inside the interface for FF device selection. So if we don't set those, + // For some reason, we use only device names and numbers inside the interface for force feedback device selection. So if we don't set those, // FFDevice won't load properly. int nDevice = FindDeviceinList(pController->guidFFDevice); if (nDevice != -1 && pszFFDevice && bFFDeviceNr) @@ -355,7 +354,7 @@ bool ProcessKey( DWORD dwKey, DWORD dwSection, LPCSTR pszLine, LPTSTR pszFFDevic case CHK_FFDEVICENAME: if( pController && pszFFDevice ) { - CHAR_TO_TCHAR( pszFFDevice, pszLine, MAX_PATH ); // HACK: pszLine is read from a file; could overflow easily. guessed size of pszFFDevice buffer. + CHAR_TO_TCHAR( pszFFDevice, pszLine, MAX_PATH ); // Hack: pszLine is read from a file; could overflow easily. We guessed size of pszFFDevice buffer. return true; } break; @@ -387,12 +386,12 @@ bool ProcessKey( DWORD dwKey, DWORD dwSection, LPCSTR pszLine, LPTSTR pszFFDevic break; case CHK_DINPUTNAME: - gGUID = GUID_NULL; // invalidate current GUID + gGUID = GUID_NULL; // Invalidate current GUID CHAR_TO_TCHAR( pszDeviceName, pszLine, MAX_PATH ); break; case CHK_DINPUTNR: - gGUID = GUID_NULL; // invalidate current GUID + gGUID = GUID_NULL; // Invalidate current GUID if( iLength >= sizeof(BYTE) ) { TexttoHexA( pszLine, &bDeviceNr, sizeof(BYTE) ); @@ -403,7 +402,7 @@ bool ProcessKey( DWORD dwKey, DWORD dwSection, LPCSTR pszLine, LPTSTR pszFFDevic return true; else { - gGUID = GUID_NULL; // invalidate current GUID + gGUID = GUID_NULL; // Invalidate current GUID return false; } break; @@ -421,31 +420,31 @@ bool ProcessKey( DWORD dwKey, DWORD dwSection, LPCSTR pszLine, LPTSTR pszFFDevic if (sscanf(pszLine, "%d %d %x %u %u", &controlnum, &buttonID, &tOffset, &tAxisID, &tBtnType) != 5) return false; - // done to overcome issues with sscanf and "small" data blocks + // Done to overcome issues with sscanf and "small" data blocks btnWorking.bOffset = tOffset; btnWorking.bAxisID = tAxisID; btnWorking.bBtnType = tBtnType; if (pController) { - // special case: if we're in one of the categories CHK_CONTROLLER_n, assume we're processing a Profile file. - // Ignore the read controlnum and use our input controller number. - controlnum = (int)(dwSection - CHK_CONTROLLER_1); // HACK: assume our hash reproduces these linearly + // Special case: if we're in one of the categories CHK_CONTROLLER_n, assume we're processing a profile file. + // Ignore the read control number and use our input controller number. + controlnum = (int)(dwSection - CHK_CONTROLLER_1); // Hack: Assume our hash reproduces these linearly } - // Now we need to assign parentdevice. If we have a valid gGUID, we'll use that... + // Now we need to assign a parent device. If we have a valid gGUID, we'll use that int found = FindDeviceinList(gGUID); if (found != -1) btnWorking.parentDevice = &g_devList[found]; else { - // ... otherwise, we do the following in order: - // 1. If bBtnType is of type DT_MOUSEBUTTON or DT_MOUSEAXE, set gGUID to that of g_sysMouse (ignoring the given name and number) + // Otherwise, we do the following in order: + // 1. If bBtnType is of type DT_MOUSEBUTTON or DT_MOUSEAXE, set gGUID to that of g_sysMouse (ignoring the given name and number) if ( btnWorking.bBtnType == DT_MOUSEBUTTON || btnWorking.bBtnType == DT_MOUSEAXE ) { btnWorking.parentDevice = &g_sysMouse; } - // 2. If bBtnType is of type DT_KEYBUTTON, set gGUID to that of SysKeyboard + // 2. If bBtnType is of type DT_KEYBUTTON, set gGUID to that of SysKeyboard else if ( btnWorking.bBtnType == DT_KEYBUTTON ) { gGUID = GUID_SysKeyboard; @@ -455,7 +454,7 @@ bool ProcessKey( DWORD dwKey, DWORD dwSection, LPCSTR pszLine, LPTSTR pszFFDevic else btnWorking.parentDevice = NULL; } - // 3. otherwise, look up the name and number using FindDeviceinList, and set gGUID to that + // 3. Otherwise, look up the name and number using FindDeviceinList, and set gGUID to that else { found = FindDeviceinList(pszDeviceName, bDeviceNr, true); @@ -476,10 +475,10 @@ bool ProcessKey( DWORD dwKey, DWORD dwSection, LPCSTR pszLine, LPTSTR pszFFDevic if (pShortcuts) { - // bounds check on controlnum and buttonID + // Bounds check on control number and buttonID if ( (controlnum == -1 && buttonID != 0) && ((controlnum < 0) || (controlnum > 3) || (buttonID < 0) || (buttonID >= SC_TOTAL)) ) { - gGUID = GUID_NULL; // since we may have cached an invalid GUID, invalidate it + gGUID = GUID_NULL; // Since we may have cached an invalid GUID, invalidate it return false; } @@ -495,12 +494,12 @@ bool ProcessKey( DWORD dwKey, DWORD dwSection, LPCSTR pszLine, LPTSTR pszFFDevic else g_scShortcuts.Player[controlnum].aButtons[buttonID] = btnWorking; } - else // it's a controller button + else // It's a controller button { - // bounds check on controlnum and buttonID + // Bounds check on control number and buttonID if ( (controlnum < 0) || (controlnum > 3) || (buttonID < 0) || (buttonID >= ARRAYSIZE(g_pcControllers[0].aButton)) ) { - gGUID = GUID_NULL; // since we may have cached an invalid GUID, invalidate it + gGUID = GUID_NULL; // Since we may have cached an invalid GUID, invalidate it return false; } @@ -528,28 +527,28 @@ bool ProcessKey( DWORD dwKey, DWORD dwSection, LPCSTR pszLine, LPTSTR pszFFDevic &tBtnType, &tModType, &tToggle, &tStatus, &tSpecific) != 8) return false; - // done to overcome issues with sscanf and "small" data blocks + // Done to overcome issues with sscanf and "small" data blocks modWorking.btnButton.bOffset = tOffset; modWorking.btnButton.bAxisID = tAxisID; modWorking.btnButton.bBtnType = tBtnType; modWorking.bModType = tModType; modWorking.fToggle = tToggle; modWorking.fStatus = tStatus; - modWorking.dwSpecific = tSpecific; // looks stupid, but unsigned int might not always be DWORD32 + modWorking.dwSpecific = tSpecific; // Looks stupid, but unsigned int might not always be DWORD32 - // Now we need to assign parentdevice. If we have a valid gGUID, we'll use that... + // Now we need to assign a parent device. If we have a valid gGUID, we'll use that int found = FindDeviceinList(gGUID); if (found != -1) modWorking.btnButton.parentDevice = &g_devList[found]; else { - // ... otherwise, we do the following in order: - // 1. If bBtnType is of type DT_MOUSEBUTTON or DT_MOUSEAXE, set gGUID to that of g_sysMouse (ignoring the given name and number) + // Otherwise, we do the following in order: + // 1. If bBtnType is of type DT_MOUSEBUTTON or DT_MOUSEAXE, set gGUID to that of g_sysMouse (ignoring the given name and number) if ( modWorking.btnButton.bBtnType == DT_MOUSEBUTTON || modWorking.btnButton.bBtnType == DT_MOUSEAXE ) { modWorking.btnButton.parentDevice = &g_sysMouse; } - // 2. If bBtnType is of type DT_KEYBUTTON, set gGUID to that of SysKeyboard + // 2. If bBtnType is of type DT_KEYBUTTON, set gGUID to that of SysKeyboard else if ( modWorking.btnButton.bBtnType == DT_KEYBUTTON ) { gGUID = GUID_SysKeyboard; @@ -559,7 +558,7 @@ bool ProcessKey( DWORD dwKey, DWORD dwSection, LPCSTR pszLine, LPTSTR pszFFDevic else modWorking.btnButton.parentDevice = NULL; } - // 3. otherwise, look up the name and number using FindDeviceinList, and set gGUID to that + // 3. Otherwise, look up the name and number using FindDeviceinList, and set gGUID to that else { found = FindDeviceinList(pszDeviceName, bDeviceNr, true); @@ -578,10 +577,10 @@ bool ProcessKey( DWORD dwKey, DWORD dwSection, LPCSTR pszLine, LPTSTR pszFFDevic } } - // bounds check on controlnum and buttonID + // Bounds check on control number and buttonID if ( (controlnum < 0) || (controlnum > 3) ) { - gGUID = GUID_NULL; // since we may have cached an invalid GUID, invalidate it + gGUID = GUID_NULL; // Since we may have cached an invalid GUID, invalidate it return false; } @@ -620,9 +619,8 @@ bool ProcessKey( DWORD dwKey, DWORD dwSection, LPCSTR pszLine, LPTSTR pszFFDevic return bReturn; } -/****************** -Load the default profile from the raw "resource" data (i.e. the builtin defaults contained in the dll) -******************/ +// Load the default profile from the raw "resource" data (i.e. the built-in defaults contained in the DLL) + bool LoadProfileFromResource( LPCTSTR pszResource, int iController, bool bIsInterface ) { const DWORD dwControllerSect[] = { CHK_CONTROLLER_1 , CHK_CONTROLLER_2, CHK_CONTROLLER_3, CHK_CONTROLLER_4 }; @@ -647,14 +645,13 @@ bool LoadProfileFromResource( LPCTSTR pszResource, int iController, bool bIsInte szLine[i] = '\0'; dwCommand = ParseLine( szLine ); - ProcessKey( dwCommand, dwControllerSect[iController], szLine, 0, 0, bIsInterface ); // resource will not contain a FF device + ProcessKey( dwCommand, dwControllerSect[iController], szLine, 0, 0, bIsInterface ); // Resource will not contain a force feedback device } return true; } -/****************** -See overloaded function above -******************/ +// See overloaded function above + bool LoadProfileFromResource( int indexController, bool bIsInterface ) { const int resIds[] = { IDR_PROFILE_DEFAULT1, IDR_PROFILE_DEFAULT2, IDR_PROFILE_DEFAULT3, IDR_PROFILE_DEFAULT4 }; @@ -665,7 +662,7 @@ bool LoadProfileFromResource( int indexController, bool bIsInterface ) } // Load a controller profile from a saved configuration file -// need to incorporate type (keyb/mouse/joy), GUID for joy, and bOffset +// Need to incorporate type (keyboard/mouse/controller), GUID for controller, and bOffset bool LoadProfileFile( const TCHAR *pszFileName, int iController, TCHAR *pszFFDevice, BYTE *bFFDeviceNr ) { const DWORD dwControllerSect[] = { CHK_CONTROLLER_1 , CHK_CONTROLLER_2, CHK_CONTROLLER_3, CHK_CONTROLLER_4 }; @@ -676,14 +673,14 @@ bool LoadProfileFile( const TCHAR *pszFileName, int iController, TCHAR *pszFFDev if ( (proFile = _tfopen(pszFileName, _T("rS")) ) == NULL) return false; - // Test if right Version + // Test if right version while( !iVersion && ( fgets(szLine, sizeof(szLine) - 1, proFile) ) ) { - szLine[strlen(szLine) - 1] = '\0'; // remove newline + szLine[strlen(szLine) - 1] = '\0'; // Remove newline if( ParseLine( szLine ) == PL_VERSIONSTRING ) iVersion = (int)(atof( szLine ) * 100); } - if( iVersion != 220 ) // HACK: this should probably not be a hardcoded value + if( iVersion != 220 ) // TODO: Hack: this should probably not be a hardcoded value { fclose(proFile); return false; @@ -697,7 +694,7 @@ bool LoadProfileFile( const TCHAR *pszFileName, int iController, TCHAR *pszFFDev DWORD dwCommand = PL_NOHIT; while( fgets(szLine, sizeof(szLine) - 1, proFile) ) { - szLine[strlen(szLine) - 1] = '\0'; // remove newline + szLine[strlen(szLine) - 1] = '\0'; // Remove newline dwCommand = ParseLine( szLine ); ProcessKey( dwCommand, dwControllerSect[iController], szLine, pszFFDevice, bFFDeviceNr, true ); } @@ -708,7 +705,7 @@ bool LoadProfileFile( const TCHAR *pszFileName, int iController, TCHAR *pszFFDev } // Load a controller profile from a saved configuration file -// need to incorporate type (keyb/mouse/joy), GUID for joy, and bOffset +// Need to incorporate type (keyboard/mouse/controller), GUID for controller, and bOffset bool LoadShortcutsFile( const TCHAR *pszFileName ) { FILE *fShortsFile = NULL; @@ -718,14 +715,14 @@ bool LoadShortcutsFile( const TCHAR *pszFileName ) if ( (fShortsFile = _tfopen(pszFileName, _T("rS")) ) == NULL) return false; - // Test if right Version + // Test if right version while( !iVersion && ( fgets(szLine, sizeof(szLine) - 1, fShortsFile) ) ) { - szLine[strlen(szLine) - 1] = '\0'; // remove newline + szLine[strlen(szLine) - 1] = '\0'; // Remove newline if( ParseLine( szLine ) == PL_VERSIONSTRING ) iVersion = (int)(atof( szLine ) * 100); } - if( iVersion != 220 ) // HACK: this should probably not be a hardcoded value + if( iVersion != 220 ) // Hack: this should probably not be a hardcoded value { fclose(fShortsFile); return false; @@ -737,7 +734,7 @@ bool LoadShortcutsFile( const TCHAR *pszFileName ) DWORD dwCommand = PL_NOHIT; while( fgets(szLine, sizeof(szLine) - 1, fShortsFile) ) { - szLine[strlen(szLine) - 1] = '\0'; // remove newline + szLine[strlen(szLine) - 1] = '\0'; // Remove newline dwCommand = ParseLine( szLine ); ProcessKey( dwCommand, CHK_SHORTCUTS, szLine, 0, 0, true ); } @@ -747,8 +744,8 @@ bool LoadShortcutsFile( const TCHAR *pszFileName ) return true; } -// Serializes the profile for the CURRENT controller for saving to a file -// called in one place, from within Interface.cpp, ControllerTabProc (when you click "Save Profile") +// Serializes the profile for the current controller for saving to a file +// Called in one place, from within Interface.cpp, ControllerTabProc (when you click "Save Profile") void FormatProfileBlock( FILE * fFile, const int i ) { DumpControllerSettings(fFile, i, false); @@ -771,7 +768,7 @@ void FormatProfileBlock( FILE * fFile, const int i ) DumpStreams(fFile, strMouse, strDevs, strNull, false); } -// same as FormatProfileBlock, but saves shortcuts instead +// Same as FormatProfileBlock, but saves shortcuts instead void FormatShortcutsBlock(FILE * fFile, bool bIsINI) { // I'm going to use STL strings here because I don't want to screw with buffer management @@ -783,12 +780,12 @@ void FormatShortcutsBlock(FILE * fFile, bool bIsINI) { for ( int j = 0; j < SC_TOTAL; j++ ) // aButtons for { - if (g_ivConfig->Shortcuts.Player[i].aButtons[j].parentDevice) // possibly unbound + if (g_ivConfig->Shortcuts.Player[i].aButtons[j].parentDevice) // Possibly unbound { if ( IsEqualGUID(g_sysMouse.guidInstance, g_ivConfig->Shortcuts.Player[i].aButtons[j].parentDevice->guidInstance) ) { char szBuf[DEFAULT_BUFFER]; - // add to the mouse stream + // Add to the mouse stream sprintf(szBuf, STRING_INI_BUTTON "=%d %d %02X %d %d\n", i, j, g_ivConfig->Shortcuts.Player[i].aButtons[j].bOffset, g_ivConfig->Shortcuts.Player[i].aButtons[j].bAxisID, g_ivConfig->Shortcuts.Player[i].aButtons[j].bBtnType); strMouse.append(szBuf); } @@ -797,22 +794,22 @@ void FormatShortcutsBlock(FILE * fFile, bool bIsINI) if ( IsEqualGUID(g_devList[match].guidInstance, g_ivConfig->Shortcuts.Player[i].aButtons[j].parentDevice->guidInstance) ) { char szBuf[DEFAULT_BUFFER]; - // add to the appropriate device stream + // Add to the appropriate device stream sprintf(szBuf, STRING_INI_BUTTON "=%d %d %02X %d %d\n", i, j, g_ivConfig->Shortcuts.Player[i].aButtons[j].bOffset, g_ivConfig->Shortcuts.Player[i].aButtons[j].bAxisID, g_ivConfig->Shortcuts.Player[i].aButtons[j].bBtnType); strDevs[match].append(szBuf); break; } } } // end buttons for - } // end Player for + } // end player for - // gotta do it again for that one pesky mouselock button - if (g_ivConfig->Shortcuts.bMouseLock.parentDevice) // possibly unbound + // We have to do it again for that one pesky mouse lock button + if (g_ivConfig->Shortcuts.bMouseLock.parentDevice) // Possibly unbound { if ( IsEqualGUID(g_sysMouse.guidInstance, g_ivConfig->Shortcuts.bMouseLock.parentDevice->guidInstance) ) { char szBuf[DEFAULT_BUFFER]; - // add to the mouse stream + // Add to the mouse stream sprintf(szBuf, STRING_INI_BUTTON "=%d %d %02X %d %d\n", -1, 0, g_ivConfig->Shortcuts.bMouseLock.bOffset, g_ivConfig->Shortcuts.bMouseLock.bAxisID, g_ivConfig->Shortcuts.bMouseLock.bBtnType); strMouse.append(szBuf); } @@ -821,7 +818,7 @@ void FormatShortcutsBlock(FILE * fFile, bool bIsINI) if ( IsEqualGUID(g_devList[match].guidInstance, g_ivConfig->Shortcuts.bMouseLock.parentDevice->guidInstance) ) { char szBuf[DEFAULT_BUFFER]; - // add to the appropriate device stream + // Add to the appropriate device stream sprintf(szBuf, STRING_INI_BUTTON "=%d %d %02X %d %d\n", -1, 0, g_ivConfig->Shortcuts.bMouseLock.bOffset, g_ivConfig->Shortcuts.bMouseLock.bAxisID, g_ivConfig->Shortcuts.bMouseLock.bBtnType); strDevs[match].append(szBuf); break; @@ -831,7 +828,7 @@ void FormatShortcutsBlock(FILE * fFile, bool bIsINI) DumpStreams(fFile, strMouse, strDevs, strNull, bIsINI); } -// load shortcuts from "resources", i.e. builtin defaults +// Load shortcuts from "resources", i.e. built-in defaults bool LoadShortcutsFromResource(bool bIsInterface) { if (bIsInterface) @@ -863,9 +860,9 @@ bool LoadShortcutsFromResource(bool bIsInterface) } -// returns the user-chosen default directory (path) for each of the following: -// application dir, mempak dir, gameboy rom dir, gameboyrom save dir -// Tries to query user settings; if blank or invalid, returns their defaults +// Returns the user-chosen default directory (path) for each of the following: +// Application directory, memory pak directory, Game Boy ROM directory, Game Boy ROM save directory +// Tries to query user settings; if blank or invalid, returns their defaults // Massages the output directory a bit bool GetDirectory( LPTSTR pszDirectory, WORD wDirID ) { @@ -900,12 +897,12 @@ bool GetDirectory( LPTSTR pszDirectory, WORD wDirID ) break; default: - // we don't know what the hell you're talking about, set pszFileName to current .exe directory + // We don't know what you're talking about, set pszFileName to current .exe directory // and return false bReturn = false; } - if( pszDirectory[1] == ':' || ( pszDirectory[1] == '\\' && pszDirectory[0] == '\\' )) // Absolute Path( x: or \\ ) + if( pszDirectory[1] == ':' || ( pszDirectory[1] == '\\' && pszDirectory[0] == '\\' )) // Absolute path( x: or \\ ) lstrcpyn( szBuffer, pszDirectory, MAX_PATH ); else { @@ -935,8 +932,8 @@ bool GetDirectory( LPTSTR pszDirectory, WORD wDirID ) } // Attempts to store the "absolute" filename for a file; -// if szFileName is an absolute filename (starting with a letter and colon or two backslashes) it is simply copied -// otherwise, it is concatenated with the known directory, such as mempak directory (type given by wDirID) +// if szFileName is an absolute filename (starting with a letter and colon or two backslashes) it is simply copied +// Otherwise, it is concatenated with the known directory, such as memory pak directory (type given by wDirID) void GetAbsoluteFileName( TCHAR *szAbsolute, const TCHAR *szFileName, const WORD wDirID ) { if( szFileName[1] == ':' || (szFileName[1] == '\\' && szFileName[0] == '\\')) @@ -944,11 +941,11 @@ void GetAbsoluteFileName( TCHAR *szAbsolute, const TCHAR *szFileName, const WORD else { GetDirectory( szAbsolute, wDirID ); - lstrcat( szAbsolute, szFileName); // HACK: possible buffer overflow + lstrcat( szAbsolute, szFileName); // Hack: possible buffer overflow } } -// Populates the list of mempak/transfer pak files from the config'd directory +// Populates the list of memory pak/transfer pak files from the configured directory BOOL SendFilestoList( HWND hDlgItem, WORD wType ) { HANDLE hFindFile; @@ -1070,7 +1067,7 @@ bool GetInitialBrowseDir( TCHAR *pszFileName, DWORD dwType ) lstrcpyn(pszFileName, g_aszLastBrowse[dwType], MAX_PATH); return true; - default: // we don't know what the hell you're talking about + default: // We don't know what you're talking about return GetDirectory( pszFileName, DIRECTORY_INVALID ); } } @@ -1200,7 +1197,7 @@ bool BrowseFile( HWND hDlg, TCHAR *pszFileName, DWORD dwType, bool fSave ) oFile.lpstrFile = szFileName; oFile.nMaxFile = MAX_PATH; oFile.lpstrFileTitle = NULL; - oFile.nMaxFileTitle = MAX_PATH; // ignored + oFile.nMaxFileTitle = MAX_PATH; // Ignored oFile.lpstrInitialDir = szInitialDir; oFile.lpstrTitle = pszTitle; oFile.Flags = dwFlags; @@ -1252,8 +1249,8 @@ bool ReadMemPakFile( TCHAR *pszMemPakFile, BYTE *aMemPak, bool fCreate ) return false; } -// Used by Interface to create or modify mempak files (not mapped). -// pszMemPakFile is a filename, aMemPak is the data, fCreate tells whether to create a new file +// Used by interface to create or modify memory pak files (not mapped). +// pszMemPakFile is a filename, aMemPak is the data, fCreate tells whether or not to create a new file bool WriteMemPakFile( TCHAR *pszMemPakFile, BYTE *aMemPak, bool fCreate ) { DWORD dwCreationDisposition = fCreate ? OPEN_ALWAYS : OPEN_EXISTING; @@ -1289,8 +1286,8 @@ bool WriteMemPakFile( TCHAR *pszMemPakFile, BYTE *aMemPak, bool fCreate ) return false; } -// This func stores the current config data to INI. It stores the Interface's idea of configuration -// As such, it should only be called from the config window (Interface). Otherwise, it will fail. +// This function stores the current config data to the INI file. It stores the interface's idea of configuration +// As such, it should only be called from the config window (interface). Otherwise, it will fail. // Returns true if saved OK, false if there was a problem. bool StoreConfigToINI() { @@ -1301,7 +1298,7 @@ bool StoreConfigToINI() TCHAR szFilename[MAX_PATH]; GetDirectory(szFilename, DIRECTORY_CONFIG); _tcscat(szFilename, _T("NRage.ini")); - FILE *fFile = _tfopen(szFilename, _T("wS")); // write, optimize for sequential + FILE *fFile = _tfopen(szFilename, _T("wS")); // TODO: Write, optimize for sequential if (!fFile) { @@ -1309,7 +1306,7 @@ bool StoreConfigToINI() return false; } - // first write out any standard header stuff here + // First write out any standard header stuff here fputs(STRING_INI_HEADER, fFile); // General @@ -1353,10 +1350,10 @@ bool StoreConfigToINI() fputs("\n[" STRING_INI_CONTROLS "]\n", fFile); fputs("# Button format: controlnum buttonID bOffset bAxisID bBtnType\n", fFile); - for ( int i = 0; i < 4; i++ ) // controllers for + for ( int i = 0; i < 4; i++ ) // Controllers for { FormatControlsBlock(&strMouse, strDevs, &strNull, i); - } // end controllers for + } // End controllers for DumpStreams(fFile, strMouse, strDevs, strNull, true); @@ -1376,10 +1373,10 @@ bool StoreConfigToINI() fputs("\n[" STRING_INI_MODIFIERS "]\n", fFile); fputs("# Modifiers format: controlnum bOffset bAxisID bBtnType bModType fToggle fStatus dwSpecific\n", fFile); - for ( int i = 0; i < 4; i++ ) // controllers for + for ( int i = 0; i < 4; i++ ) // Controllers for { FormatModifiersBlock(&strMouse, strDevs, &strNull, i); - } // end controllers for + } // End controllers for DumpStreams(fFile, strMouse, strDevs, strNull, true); @@ -1388,19 +1385,19 @@ bool StoreConfigToINI() return true; } -// This func loads the config data from INI into working emulator space. Does not copy into Interface; -// you need to call GetCurrentConfiguration() if you want to do that. +// This function loads the config data from INI into working emulator space. Does not copy into interface; +// You need to call GetCurrentConfiguration() if you want to do that. // Returns true if loaded OK, false if there was a problem. bool LoadConfigFromINI() { FILE *fFile = NULL; - DWORD dwSection = 0; // this will eval to the bracketed "[Section]" we are currently in. + DWORD dwSection = 0; // This will evaluate to the bracketed "[Section]" we are currently in. char szLine[4096]; TCHAR szFilename[MAX_PATH]; GetDirectory(szFilename, DIRECTORY_CONFIG); _tcscat(szFilename, _T("NRage.ini")); - fFile = _tfopen(szFilename, _T("rS")); // read, optimize for sequential + fFile = _tfopen(szFilename, _T("rS")); // Read, optimize for sequential if (!fFile) { @@ -1415,12 +1412,12 @@ bool LoadConfigFromINI() DWORD dwCommand = PL_NOHIT; while(( fgets(szLine, sizeof(szLine) - 1, fFile) ) ) { - szLine[strlen(szLine) - 1] = '\0'; // remove newline + szLine[strlen(szLine) - 1] = '\0'; // Remove newline dwCommand = ParseLine( szLine ); if (dwCommand == PL_NOHIT) continue; else if (dwCommand == PL_CATEGORY) - // section changed to szLine + // Section changed to szLine dwSection = djbHash(szLine); else ProcessKey( dwCommand, dwSection, szLine, 0, 0, false ); @@ -1431,7 +1428,7 @@ bool LoadConfigFromINI() return true; } -// basically a stripped down version of GetConfigFromINI, called at the very beginning to get our language +// Basically a stripped down version of GetConfigFromINI, called at the very beginning to get our language LANGID GetLanguageFromINI() { FILE *fFile = NULL; @@ -1440,7 +1437,7 @@ LANGID GetLanguageFromINI() TCHAR szFilename[MAX_PATH]; GetDirectory(szFilename, DIRECTORY_CONFIG); _tcscat(szFilename, _T("NRage.ini")); - fFile = _tfopen(szFilename, _T("rS")); // read, optimize for sequential + fFile = _tfopen(szFilename, _T("rS")); // Read, optimize for sequential if (!fFile) { @@ -1452,7 +1449,7 @@ LANGID GetLanguageFromINI() DWORD dwCommand = PL_NOHIT; while(( fgets(szLine, sizeof(szLine) - 1, fFile) ) ) { - szLine[strlen(szLine) - 1] = '\0'; // remove newline + szLine[strlen(szLine) - 1] = '\0'; // Remove newline dwCommand = ParseLine( szLine ); if (dwCommand == CHK_LANGUAGE) { @@ -1470,7 +1467,7 @@ LANGID GetLanguageFromINI() return 0; } -// both the following functions assume the buffer is big enough +// Both the following functions assume the buffer is big enough inline void GUIDtoStringA( char * szGUIDbuf, const GUID guid ) { _snprintf( szGUIDbuf, GUID_STRINGLENGTH + 1, "{%08.8lX-%04.4hX-%04.4hX-%02.2X%02.2X-%02.2X%02.2X%02.2X%02.2X%02.2X%02.2X}", guid.Data1, guid.Data2, guid.Data3, guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]); @@ -1489,7 +1486,7 @@ inline bool StringtoGUIDA( LPGUID guid, const char * szGUIDbuf ) return false; } -// Takes in a file to dump to, and an int i telling which controller's settings to dump. Does not dump buttons or modifiers. +// Takes in a file to dump to, and an 'int i' telling which controller's settings to dump. Does not dump buttons or modifiers. void DumpControllerSettings(FILE * fFile, int i, bool bIsINI) { char szANSIBuf[DEFAULT_BUFFER]; @@ -1548,10 +1545,10 @@ void DumpControllerSettings(FILE * fFile, int i, bool bIsINI) fprintf(fFile, STRING_INI_GBROMSAVE "=%s\n", szANSIBuf); } -// private func, called by StoreConfigToINI to dump cached Button strings to file +// Private function, called by StoreConfigToINI to dump cached button strings to file void DumpStreams(FILE * fFile, string strMouse, string strDevs[], string strNull, bool bIsINI) { - // dump all streams to file, with appropriate DInput lines and name comment + // Dump all streams to file, with appropriate DInput lines and name comment char szANSIBuf[DEFAULT_BUFFER]; if (!(strMouse.empty())) { @@ -1581,7 +1578,7 @@ void DumpStreams(FILE * fFile, string strMouse, string strDevs[], string strNull } else { - fprintf(fFile, STRING_INI_DINPUTNAME "=\n"); // leave blank + fprintf(fFile, STRING_INI_DINPUTNAME "=\n"); // Leave blank fprintf(fFile, STRING_INI_DINPUTNR "=\n"); } fputs(strNull.c_str(), fFile); @@ -1613,14 +1610,14 @@ void DumpStreams(FILE * fFile, string strMouse, string strDevs[], string strNull void FormatControlsBlock(string * strMouse, string strDevs[], string * strNull, int i) { - for ( int j = 0; j < ARRAYSIZE(g_ivConfig->Controllers[i].aButton); j++ ) // buttons for + for ( int j = 0; j < ARRAYSIZE(g_ivConfig->Controllers[i].aButton); j++ ) // Buttons for { - if (g_ivConfig->Controllers[i].aButton[j].parentDevice) // possibly unbound + if (g_ivConfig->Controllers[i].aButton[j].parentDevice) // Possibly unbound { if ( IsEqualGUID(g_sysMouse.guidInstance, g_ivConfig->Controllers[i].aButton[j].parentDevice->guidInstance) ) { char szBuf[DEFAULT_BUFFER]; - // add to the mouse stream + // Add to the mouse stream sprintf(szBuf, STRING_INI_BUTTON "=%d %d %02X %d %d\n", i, j, g_ivConfig->Controllers[i].aButton[j].bOffset, g_ivConfig->Controllers[i].aButton[j].bAxisID, g_ivConfig->Controllers[i].aButton[j].bBtnType); strMouse->append(szBuf); } @@ -1631,7 +1628,7 @@ void FormatControlsBlock(string * strMouse, string strDevs[], string * strNull, if ( IsEqualGUID(g_devList[match].guidInstance, g_ivConfig->Controllers[i].aButton[j].parentDevice->guidInstance) ) { char szBuf[DEFAULT_BUFFER]; - // add to the appropriate device stream + // Add to the appropriate device stream sprintf(szBuf, STRING_INI_BUTTON "=%d %d %02X %d %d\n", i, j, g_ivConfig->Controllers[i].aButton[j].bOffset, g_ivConfig->Controllers[i].aButton[j].bAxisID, g_ivConfig->Controllers[i].aButton[j].bBtnType); strDevs[match].append(szBuf); break; @@ -1644,19 +1641,19 @@ void FormatControlsBlock(string * strMouse, string strDevs[], string * strNull, int k = g_ivConfig->Controllers[i].aButton[j].bBtnType; DebugWriteA("Controller %d button %d is of bBtnType %d but has no parentDevice!\n", i, j, k); } - } // end buttons for + } // End buttons for } void FormatModifiersBlock(string * strMouse, string strDevs[], string * strNull, int i) { for ( int j = 0; j < g_ivConfig->Controllers[i].nModifiers; j++ ) { - if (g_ivConfig->Controllers[i].pModifiers[j].btnButton.parentDevice) // is it assigned to a key? + if (g_ivConfig->Controllers[i].pModifiers[j].btnButton.parentDevice) // Is it assigned to a key? { if ( IsEqualGUID(g_sysMouse.guidInstance, g_ivConfig->Controllers[i].pModifiers[j].btnButton.parentDevice->guidInstance) ) { char szBuf[DEFAULT_BUFFER]; - // add to the mouse stream + // Add to the mouse stream sprintf(szBuf, STRING_INI_MODIFIER "=%d %02X %d %d %d %d %d %08X\n", i, g_ivConfig->Controllers[i].pModifiers[j].btnButton.bOffset, g_ivConfig->Controllers[i].pModifiers[j].btnButton.bAxisID, g_ivConfig->Controllers[i].pModifiers[j].btnButton.bBtnType, g_ivConfig->Controllers[i].pModifiers[j].bModType, g_ivConfig->Controllers[i].pModifiers[j].fToggle, @@ -1668,7 +1665,7 @@ void FormatModifiersBlock(string * strMouse, string strDevs[], string * strNull, if ( IsEqualGUID(g_devList[match].guidInstance, g_ivConfig->Controllers[i].pModifiers[j].btnButton.parentDevice->guidInstance) ) { char szBuf[DEFAULT_BUFFER]; - // add to the mouse stream + // Add to the mouse stream sprintf(szBuf, STRING_INI_MODIFIER "=%d %02X %d %d %d %d %d %08X\n", i, g_ivConfig->Controllers[i].pModifiers[j].btnButton.bOffset, g_ivConfig->Controllers[i].pModifiers[j].btnButton.bAxisID, g_ivConfig->Controllers[i].pModifiers[j].btnButton.bBtnType, g_ivConfig->Controllers[i].pModifiers[j].bModType, g_ivConfig->Controllers[i].pModifiers[j].fToggle, @@ -1677,10 +1674,10 @@ void FormatModifiersBlock(string * strMouse, string strDevs[], string * strNull, break; } } - else // save modifiers without a keybind + else // Save modifiers without a keybind { char szBuf[DEFAULT_BUFFER]; - // add to the mouse stream + // Add to the mouse stream sprintf(szBuf, STRING_INI_MODIFIER "=%d %02X %d %d %d %d %d %08X\n", i, g_ivConfig->Controllers[i].pModifiers[j].btnButton.bOffset, g_ivConfig->Controllers[i].pModifiers[j].btnButton.bAxisID, g_ivConfig->Controllers[i].pModifiers[j].btnButton.bBtnType, g_ivConfig->Controllers[i].pModifiers[j].bModType, g_ivConfig->Controllers[i].pModifiers[j].fToggle, @@ -1696,7 +1693,7 @@ unsigned long djbHash(const char *str) int c; while ((c = *str++)) - hash = ((hash << 5) + hash) + c; /* hash * 33 + c */ + hash = ((hash << 5) + hash) + c; // hash * 33 + c return hash; } diff --git a/Source/nragev20/FileAccess.h b/Source/nragev20/FileAccess.h index 6554454ca..d1164bff7 100644 --- a/Source/nragev20/FileAccess.h +++ b/Source/nragev20/FileAccess.h @@ -1,24 +1,23 @@ /* - N-Rage`s Dinput8 Plugin - (C) 2002, 2006 Norbert Wladyka +N-Rage`s Dinput8 Plugin +(C) 2002, 2006 Norbert Wladyka - Author`s Email: norbert.wladyka@chello.at - Website: http://go.to/nrage +Author`s Email: norbert.wladyka@chello.at +Website: http://go.to/nrage +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the free Software Foundation; either version 2 of the License, or +(at your option) any later version. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the free Software Foundation; either version 2 of the License, or - (at your option) any later version. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _FILEACCESS_H_ @@ -67,7 +66,7 @@ unsigned long djbHash(const char *str); #define STRING_DEF_GBROMSAVE _T("GBxSaves") #define STRING_INI_HEADER "# Generated by NRage input plugin V2 version " VER_FILE_VERSION_STR "\n" -// We use these names for loading from INI files and NRage config files +// We use these names for loading from INI files and N-Rage config files #define STRING_INI_GENERAL "General" #define STRING_INI_CONTROLLER "Controller" #define STRING_INI_FOLDERS "Folders" @@ -126,14 +125,14 @@ unsigned long djbHash(const char *str); #define STRING_INI_DINPUTNR "DInputNr" -// the following are hashes for the string values above +// The following are hashes for the string values above -// version strings, including the @ in front +// Version strings, including the @ in front #define CHK_PROFILEVERSION20 2278962538UL #define CHK_PROFILEVERSION21 2278962539UL #define CHK_PROFILEVERSION22 2278962540UL -// categories +// Categories #define CHK_GENERAL 63249731UL #define CHK_FOLDERS 3455681620UL #define CHK_LASTBROWSERDIR 2659654652UL @@ -145,7 +144,7 @@ unsigned long djbHash(const char *str); #define CHK_SHORTCUTS 2945387732UL #define CHK_MODIFIERS 95935975UL -// assignments (to the left of the '=' sign) +// Assignments (to the left of the '=' sign) #define CHK_LANGUAGE 3857633481UL #define CHK_SHOWMESSAGES 638097246UL @@ -196,17 +195,16 @@ unsigned long djbHash(const char *str); // If any of the following values conflict with djbHash return values (such as a blank string), there will be problems! -// nothing +// Nothing #define PL_NOHIT 0 - // [Category] +// [Category] #define PL_CATEGORY 1 - // @STRING_PROFILEVERSION +// @STRING_PROFILEVERSION #define PL_VERSIONSTRING 10 - // resets the static vars in ProcessKey +// Resets the static vars in ProcessKey #define PL_RESET 200 - #define DIRECTORY_MEMPAK 0 #define DIRECTORY_GBROMS 1 #define DIRECTORY_GBSAVES 2 @@ -216,7 +214,6 @@ unsigned long djbHash(const char *str); #define DIRECTORY_APPLICATION 255 #define DIRECTORY_INVALID 256 - #define FILIST_MEM 1 #define FILIST_TRANSFER 2 @@ -230,7 +227,7 @@ unsigned long djbHash(const char *str); #define BF_NOTE 4 #define BF_SHORTCUTS 5 - // 32 hex characters, 4 hyphens, 2 end braces +// 32 hex characters, 4 hyphens, 2 end braces #define GUID_STRINGLENGTH 32+4+2 #endif // #ifndef _FILEACCESS_H_ diff --git a/Source/nragev20/GBCart.cpp b/Source/nragev20/GBCart.cpp index 6a6493950..92bf259dc 100644 --- a/Source/nragev20/GBCart.cpp +++ b/Source/nragev20/GBCart.cpp @@ -1,13 +1,6 @@ /* -** -** -** -** This file's purpose is to emulate the inner workings of a -** GameBoy Game Pak cartrige. -** -** All code is by Mark McGough. MadManMarkAu@hotmail.com -** -** +This file's purpose is to emulate the inner workings of a +Game Boy game pak cartridge. All code is by Mark McGough. */ #include @@ -33,16 +26,16 @@ bool ReadCartCamera(LPGBCART Cart, WORD dwAddress, BYTE *Data); bool WriteCartCamera(LPGBCART Cart, WORD dwAddress, BYTE *Data); // Tries to read RTC data from separate file (not integrated into SAV) -// success sets the useTDF flag -// failure inits the RTC at zero and maybe throws a warning +// Success sets the useTDF flag +// Failure initializes the RTC at zero and maybe throws a warning void ReadTDF(LPGBCART Cart) { } void WriteTDF(LPGBCART Cart) { - // check useTDF flag - // write data from RTC to TDF file + // Check useTDF flag + // Write data from RTC to TDF file } void UpdateRTC(LPGBCART Cart) @@ -80,25 +73,25 @@ void UpdateRTC(LPGBCART Cart) } -// returns true if the ROM was loaded OK +// Returns true if the ROM was loaded correctly bool LoadCart(LPGBCART Cart, LPCTSTR RomFileName, LPCTSTR RamFileName, LPCTSTR TdfFileName) { HANDLE hTemp; DWORD dwFilesize; DWORD NumQuarterBlocks = 0; - UnloadCart(Cart); // first, make sure any previous carts have been unloaded + UnloadCart(Cart); // First, make sure any previous carts have been unloaded Cart->iCurrentRamBankNo = 0; Cart->iCurrentRomBankNo = 1; Cart->bRamEnableState = 0; Cart->bMBC1RAMbanking = 0; - // Attempt to load the ROM file. + // Attempt to load the ROM file hTemp = CreateFile(RomFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if (hTemp != INVALID_HANDLE_VALUE && (Cart->hRomFile = CreateFileMapping(hTemp, NULL, PAGE_READONLY, 0, 0, NULL) ) ) { - // if the first case fails, the file doesn't exist. The second case can fail if the file size is zero. + // If the first case fails, the file doesn't exist. The second case can fail if the file size is zero. dwFilesize = GetFileSize(hTemp, NULL); CloseHandle(hTemp); Cart->RomData = (const unsigned char *)MapViewOfFile( Cart->hRomFile, FILE_MAP_READ, 0, 0, 0 ); @@ -107,26 +100,26 @@ bool LoadCart(LPGBCART Cart, LPCTSTR RomFileName, LPCTSTR RamFileName, LPCTSTR T { DebugWriteA("Couldn't load the ROM file, GetLastError returned %08x\n", GetLastError()); if (hTemp != INVALID_HANDLE_VALUE) - CloseHandle(hTemp); // if file size was zero, make sure we don't leak the handle + CloseHandle(hTemp); // If file size was zero, make sure we don't leak the handle ErrorMessage(IDS_ERR_GBROM, 0, false); return false; } - if (dwFilesize < 0x8000) // a Rom file has to be at least 32kb + if (dwFilesize < 0x8000) // A ROM file has to be at least 32KB { - DebugWriteA("ROM file wasn't big enough to be a GB ROM!\n"); + DebugWriteA("ROM file wasn't big enough to be a Game Boy ROM!\n"); ErrorMessage(IDS_ERR_GBROM, 0, false); UnloadCart(Cart); return false; } - DebugWriteA(" Cartridge Type #:"); + DebugWriteA(" cartridge type #:"); DebugWriteByteA(Cart->RomData[0x147]); DebugWriteA("\n"); switch (Cart->RomData[0x147]) - { // if we hadn't checked the file size before, this might have caused an access violation + { // If we hadn't checked the file size before, this might have caused an access violation case 0x00: Cart->iCartType = GB_NORM; Cart->bHasRam = false; @@ -291,12 +284,12 @@ bool LoadCart(LPGBCART Cart, LPCTSTR RomFileName, LPCTSTR RamFileName, LPCTSTR T break; default: WarningMessage( IDS_ERR_GBROM, MB_OK | MB_ICONWARNING); - DebugWriteA("TPak: unsupported paktype\n"); + DebugWriteA("TPak: unsupported pak type\n"); UnloadCart(Cart); return false; } - // assign read/write handlers + // Assign read/write handlers switch (Cart->iCartType) { case GB_NORM: // Raw cartridge @@ -326,7 +319,7 @@ bool LoadCart(LPGBCART Cart, LPCTSTR RomFileName, LPCTSTR RamFileName, LPCTSTR T default: // Don't pretend we know how to handle carts we don't support Cart->ptrfnReadCart = NULL; Cart->ptrfnWriteCart = NULL; - DebugWriteA("Unsupported paktype: can't read/write cart type %02X\n", Cart->iCartType); + DebugWriteA("Unsupported pak type: can't read/write cart type %02X\n", Cart->iCartType); UnloadCart(Cart); return false; } @@ -397,10 +390,10 @@ bool LoadCart(LPGBCART Cart, LPCTSTR RomFileName, LPCTSTR RamFileName, LPCTSTR T break; } - DebugWriteA("GB cart has %d ROM banks, %d RAM quarter banks\n", Cart->iNumRomBanks, NumQuarterBlocks); + DebugWriteA("Game Boy cart has %d ROM banks, %d RAM quarter banks\n", Cart->iNumRomBanks, NumQuarterBlocks); if (Cart->bHasTimer) { - DebugWriteA("GB cart timer present\n"); + DebugWriteA("Game Boy cart timer present\n"); } // Attempt to load the SRAM file, but only if RAM is supposed to be present. @@ -411,7 +404,7 @@ bool LoadCart(LPGBCART Cart, LPCTSTR RomFileName, LPCTSTR RamFileName, LPCTSTR T { hTemp = CreateFile( RamFileName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, 0, NULL ); if( hTemp == INVALID_HANDLE_VALUE ) - {// test if Read-only access is possible + {// Test if read-only access is possible hTemp = CreateFile( RamFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_ALWAYS, 0, NULL ); if (Cart->bHasTimer && Cart->bHasBattery) { @@ -441,7 +434,7 @@ bool LoadCart(LPGBCART Cart, LPCTSTR RomFileName, LPCTSTR RamFileName, LPCTSTR T } } else - { // file is OK, use a mapping + { // File is OK, use a mapping if (Cart->bHasTimer && Cart->bHasBattery) Cart->hRamFile = CreateFileMapping( hTemp, NULL, PAGE_READWRITE, 0, NumQuarterBlocks * 0x0800 + sizeof(gbCartRTC), NULL); else @@ -452,7 +445,7 @@ bool LoadCart(LPGBCART Cart, LPCTSTR RomFileName, LPCTSTR RamFileName, LPCTSTR T Cart->RamData = (LPBYTE)MapViewOfFile( Cart->hRamFile, FILE_MAP_ALL_ACCESS, 0, 0, 0 ); } else - { // could happen, if the file isn't big enough AND can't be grown to fit + { // Could happen, if the file isn't big enough and can't be grown to fit DWORD dwBytesRead; if (Cart->bHasTimer && Cart->bHasBattery) { @@ -482,7 +475,7 @@ bool LoadCart(LPGBCART Cart, LPCTSTR RomFileName, LPCTSTR RamFileName, LPCTSTR T dwFilesize = GetFileSize(hTemp, 0); if (dwFilesize >= (NumQuarterBlocks * 0x0800 + sizeof(gbCartRTC) ) ) { - // Looks like there is extra data in the SAV file than just RAM data... assume it is RTC data. + // Looks like there is extra data in the SAV file than just RAM data...assume it is RTC data gbCartRTC RTCTimer; CopyMemory( &RTCTimer, &Cart->RamData[NumQuarterBlocks * 0x0800], sizeof(RTCTimer) ); Cart->TimerData[0] = RTCTimer.mapperSeconds; @@ -500,7 +493,7 @@ bool LoadCart(LPGBCART Cart, LPCTSTR RomFileName, LPCTSTR RamFileName, LPCTSTR T } else { - ReadTDF(Cart); // try to open TDF format, clear/init Cart->TimerData if that fails + ReadTDF(Cart); // Try to open TDF format, clear/initialize Cart->TimerData if that fails } } @@ -508,7 +501,7 @@ bool LoadCart(LPGBCART Cart, LPCTSTR RomFileName, LPCTSTR RamFileName, LPCTSTR T } else { - // no battery; just allocate some RAM + // No battery; just allocate some RAM Cart->RamData = (LPBYTE)P_malloc(Cart->iNumRamBanks * 0x2000); } } @@ -521,17 +514,17 @@ bool LoadCart(LPGBCART Cart, LPCTSTR RomFileName, LPCTSTR RamFileName, LPCTSTR T // Done bool ReadCartNorm(LPGBCART Cart, WORD dwAddress, BYTE *Data) // For all non-MBC carts; fixed 0x8000 ROM; fixed, optional 0x2000 RAM { - switch (dwAddress >> 13) // hack: examine highest 3 bits + switch (dwAddress >> 13) // Hack: examine highest 3 bits { case 0: case 1: case 2: case 3: // if ((dwAddress >= 0) && (dwAddress <= 0x7FFF)) CopyMemory(Data, &Cart->RomData[dwAddress], 32); - DebugWriteA("Nonbanked ROM read - RAW\n"); + DebugWriteA("Non-banked ROM read - raw\n"); break; case 5: - if (Cart->bHasRam) // no MBC, so no enable state to check + if (Cart->bHasRam) // No MBC, so no enable state to check { if (Cart->RomData[0x149] == 1 && (dwAddress - 0xA000) / 0x0800 ) // Only 1/4 of the RAM space is used, and we're out of bounds { @@ -551,7 +544,7 @@ bool ReadCartNorm(LPGBCART Cart, WORD dwAddress, BYTE *Data) // For all non-MBC } break; default: - DebugWriteA("Bad read from RAW cart, address %04X\n", dwAddress); + DebugWriteA("Bad read from raw cart, address %04X\n", dwAddress); } return true; @@ -567,7 +560,7 @@ bool WriteCartNorm(LPGBCART Cart, WORD dwAddress, BYTE *Data) } if (Cart->RomData[0x149] == 1) - { // Whoops... Only 1/4 of the RAM space is used. + { // Whoops...Only 1/4 of the RAM space is used. if ((dwAddress >= 0xA000) && (dwAddress <= 0xA7FF)) { // Write to RAM DebugWriteA("RAM write: Unbanked\n"); @@ -595,7 +588,7 @@ bool ReadCartMBC1(LPGBCART Cart, WORD dwAddress, BYTE *Data) if ((dwAddress >= 0) && (dwAddress <= 0x3FFF)) { CopyMemory(Data, &Cart->RomData[dwAddress], 32); - DebugWriteA("Nonbanked ROM read - MBC1\n"); + DebugWriteA("Non-banked ROM read - MBC1\n"); } else if ((dwAddress >= 0x4000) && (dwAddress <= 0x7FFF)) { @@ -650,10 +643,10 @@ bool WriteCartMBC1(LPGBCART Cart, WORD dwAddress, BYTE *Data) } else if ((dwAddress >= 0x2000) && (dwAddress <= 0x3FFF)) // ROM bank select { - Cart->iCurrentRomBankNo &= 0x60; // keep MSB + Cart->iCurrentRomBankNo &= 0x60; // Keep MSB Cart->iCurrentRomBankNo |= Data[0] & 0x1F; - // emulate quirk: 0x00 -> 0x01, 0x20 -> 0x21, 0x40->0x41, 0x60 -> 0x61 + // Emulate quirk: 0x00 -> 0x01, 0x20 -> 0x21, 0x40->0x41, 0x60 -> 0x61 if ((Cart->iCurrentRomBankNo & 0x1F) == 0) { Cart->iCurrentRomBankNo |= 0x01; @@ -670,28 +663,28 @@ bool WriteCartMBC1(LPGBCART Cart, WORD dwAddress, BYTE *Data) else { Cart->iCurrentRomBankNo &= 0x1F; - Cart->iCurrentRomBankNo |= ((Data[0] & 0x03) << 5); // set bits 5 and 6 of ROM bank + Cart->iCurrentRomBankNo |= ((Data[0] & 0x03) << 5); // Set bits 5 and 6 of ROM bank DebugWriteA("Set ROM Bank MSB, ROM bank now: %02X\n", Cart->iCurrentRomBankNo); } } else if ((dwAddress >= 0x6000) && (dwAddress <= 0x7FFF)) // MBC1 mode select { - // this is overly complicated, but it keeps us from having to do bitwise math later + // This is overly complicated, but it keeps us from having to do bitwise math later. // Basically we shuffle the 2 "magic bits" between iCurrentRomBankNo and iCurrentRamBankNo as necessary. if (Cart->bMBC1RAMbanking != (Data[0] & 0x01)) { - // we should only alter the ROM and RAM bank numbers if we have changed modes + // We should only alter the ROM and RAM bank numbers if we have changed modes Cart->bMBC1RAMbanking = Data[0] & 0x01; if (Cart->bMBC1RAMbanking) { - Cart->iCurrentRamBankNo = Cart->iCurrentRomBankNo >> 5; // set the ram bank to the "magic bits" - Cart->iCurrentRomBankNo &= 0x1F; // zero out bits 5 and 6 to keep consistency + Cart->iCurrentRamBankNo = Cart->iCurrentRomBankNo >> 5; // Set the ram bank to the "magic bits" + Cart->iCurrentRomBankNo &= 0x1F; // Zero out bits 5 and 6 to keep consistency } else { Cart->iCurrentRomBankNo &= 0x1F; Cart->iCurrentRomBankNo |= (Cart->iCurrentRamBankNo << 5); - Cart->iCurrentRamBankNo = 0x00; // we can only reach RAM page 0 + Cart->iCurrentRamBankNo = 0x00; // We can only reach RAM page 0 } DebugWriteA("Set MBC1 mode: %s\n", Cart->bMBC1RAMbanking ? "ROMbanking" : "RAMbanking"); } @@ -726,7 +719,7 @@ bool ReadCartMBC2(LPGBCART Cart, WORD dwAddress, BYTE *Data) if ((dwAddress <= 0x3FFF)) { CopyMemory(Data, &Cart->RomData[dwAddress], 32); - DebugWriteA("Nonbanked ROM read - MBC2\n"); + DebugWriteA("Non-banked ROM read - MBC2\n"); } else if ((dwAddress >= 0x4000) && (dwAddress <= 0x7FFF)) { @@ -809,9 +802,9 @@ bool ReadCartMBC3(LPGBCART Cart, WORD dwAddress, BYTE *Data) if ((dwAddress < 0x4000)) //Rom Bank 0 { CopyMemory(Data, &Cart->RomData[dwAddress], 32); - DebugWriteA("Nonbanked ROM read - MBC3\n"); + DebugWriteA("Non-banked ROM read - MBC3\n"); } - else if ((dwAddress >= 0x4000) && (dwAddress < 0x8000)) //Switchable Rom Bank + else if ((dwAddress >= 0x4000) && (dwAddress < 0x8000)) // Switchable ROM bank { if (Cart->iCurrentRomBankNo >= Cart->iNumRomBanks) { @@ -824,11 +817,11 @@ bool ReadCartMBC3(LPGBCART Cart, WORD dwAddress, BYTE *Data) DebugWriteA("Banked ROM read: Bank %02X\n", Cart->iCurrentRomBankNo); } } - else if ((dwAddress >= 0xA000) && (dwAddress <= 0xC000)) //Upper Bounds of memory map + else if ((dwAddress >= 0xA000) && (dwAddress <= 0xC000)) // Upper Bounds of memory map { if (Cart->bHasTimer && (Cart->iCurrentRamBankNo >= 0x08 && Cart->iCurrentRamBankNo <= 0x0c)) { - // w00t! the Timer was just read!! + // The timer was just read! if (Cart->TimerDataLatched) { for (int i = 0; i < 32; i++) @@ -890,9 +883,9 @@ bool WriteCartMBC3(LPGBCART Cart, WORD dwAddress, BYTE *Data) if (Cart->iCurrentRomBankNo == 0) { Cart->iCurrentRomBankNo = 1; } - DebugWriteA("Set Rom Bank: %02X\n", Cart->iCurrentRomBankNo); + DebugWriteA("Set ROM Bank: %02X\n", Cart->iCurrentRomBankNo); } - else if ((dwAddress >= 0x4000) && (dwAddress <= 0x5FFF)) // RAM/Clock bank select + else if ((dwAddress >= 0x4000) && (dwAddress <= 0x5FFF)) // RAM/clock bank select { if (Cart->bHasRam) { @@ -915,12 +908,12 @@ bool WriteCartMBC3(LPGBCART Cart, WORD dwAddress, BYTE *Data) for (i = 0; i < 4; i++) Cart->LatchedTimerData[i] = Cart->TimerData[i]; Cart->TimerDataLatched = true; - DebugWriteA("Timer Data Latch: Enable\n"); + DebugWriteA("Timer data latch: Enable\n"); } else { Cart->TimerDataLatched = false; - DebugWriteA("Timer Data Latch: Disable\n"); + DebugWriteA("Timer data latch: Disable\n"); } } else if ((dwAddress >= 0xA000) && (dwAddress <= 0xBFFF)) // Write to RAM @@ -954,9 +947,9 @@ bool ReadCartMBC5(LPGBCART Cart, WORD dwAddress, BYTE *Data) if ((dwAddress < 0x4000)) //Rom Bank 0 { CopyMemory(Data, &Cart->RomData[dwAddress], 32); - DebugWriteA("Nonbanked ROM read - MBC5\n"); + DebugWriteA("Non-banked ROM read - MBC5\n"); } - else if ((dwAddress >= 0x4000) && (dwAddress < 0x8000)) //Switchable ROM BANK + else if ((dwAddress >= 0x4000) && (dwAddress < 0x8000)) // Switchable ROM bank { if (Cart->iCurrentRomBankNo >= Cart->iNumRomBanks) { @@ -972,7 +965,7 @@ bool ReadCartMBC5(LPGBCART Cart, WORD dwAddress, BYTE *Data) DebugWriteA("\n"); } } - else if ((dwAddress >= 0xA000) && (dwAddress <= 0xC000)) //Upper bounds of memory map + else if ((dwAddress >= 0xA000) && (dwAddress <= 0xC000)) // Upper bounds of memory map { if (Cart->bHasRam) { @@ -1059,12 +1052,12 @@ bool WriteCartMBC5(LPGBCART Cart, WORD dwAddress, BYTE *Data) // Done bool ReadCartCamera(LPGBCART Cart, WORD dwAddress, BYTE *Data) { - if ((dwAddress < 0x4000)) //Rom Bank 0 + if ((dwAddress < 0x4000)) // ROM bank 0 { CopyMemory(Data, &Cart->RomData[dwAddress], 32); - DebugWriteA("Nonbanked ROM read - CAMERA\n"); + DebugWriteA("Non-banked ROM read - CAMERA\n"); } - else if ((dwAddress >= 0x4000) && (dwAddress < 0x8000)) //Switchable ROM BANK + else if ((dwAddress >= 0x4000) && (dwAddress < 0x8000)) // Switchable ROM bank { if (Cart->iCurrentRomBankNo >= Cart->iNumRomBanks) { @@ -1080,17 +1073,17 @@ bool ReadCartCamera(LPGBCART Cart, WORD dwAddress, BYTE *Data) DebugWriteA("\n"); } } - else if ((dwAddress >= 0xA000) && (dwAddress <= 0xC000)) //Upper bounds of memory map + else if ((dwAddress >= 0xA000) && (dwAddress <= 0xC000)) // Upper bounds of memory map { if (Cart->iCurrentRamBankNo & 0x10) { - //REGISTER MODE + // Register mode ZeroMemory(Data, 32); DebugWriteA("REGISTER read (Camera): All Zero\n", Cart->iCurrentRamBankNo); } else { - //RAM MODE + // RAM mode if (Cart->bHasRam) { if (Cart->iCurrentRamBankNo >= Cart->iNumRamBanks) @@ -1113,13 +1106,13 @@ bool ReadCartCamera(LPGBCART Cart, WORD dwAddress, BYTE *Data) } else { - DebugWriteA("Bad read from GBCamera cart, address %04X\n", dwAddress); + DebugWriteA("Bad read from Game Boy Camera cart, address %04X\n", dwAddress); } return true; } -//Done +// Done bool WriteCartCamera(LPGBCART Cart, WORD dwAddress, BYTE *Data) { if ((dwAddress >= 0x0000) && (dwAddress <= 0x1FFF)) // We shouldn't be able to read/write to RAM unless this is toggled on @@ -1134,17 +1127,17 @@ bool WriteCartCamera(LPGBCART Cart, WORD dwAddress, BYTE *Data) // Cart->iCurrentRomBankNo = ((int) Data[0]) | (Cart->iCurrentRomBankNo & 0x100); DebugWriteA("Set ROM Bank: %02X\n", Cart->iCurrentRomBankNo); } - else if ((dwAddress >= 0x4000) && (dwAddress <= 0x4FFF)) // Camera Register & RAM bank select + else if ((dwAddress >= 0x4000) && (dwAddress <= 0x4FFF)) // Camera register and RAM bank select { if (Data[0] & 0x10) { - //REGISTER MODE + // Register mode Cart->iCurrentRamBankNo = Data[0]; DebugWriteA("Set Register Bank (Camera): %02X\n", Cart->iCurrentRamBankNo); } else { - //RAM MODE + // RAM mode if (Cart->bHasRam) { Cart->iCurrentRamBankNo = Data[0] & 0x0F; @@ -1156,12 +1149,12 @@ bool WriteCartCamera(LPGBCART Cart, WORD dwAddress, BYTE *Data) { if (Cart->iCurrentRamBankNo & 0x10) { - //REGISTER MODE (DO NOTHING) + // Register mode (do nothing) DebugWriteA("REGISTER write (Camera): Do nothing\n"); } else { - //RAM MODE + // RAM mode if (Cart->bHasRam) { if (Cart->iCurrentRamBankNo >= Cart->iNumRamBanks) @@ -1180,7 +1173,7 @@ bool WriteCartCamera(LPGBCART Cart, WORD dwAddress, BYTE *Data) } else { - DebugWriteA("Bad write to GBCamera cart, address %04X\n", dwAddress); + DebugWriteA("Bad write to Game Boy Camera cart, address %04X\n", dwAddress); } return true; @@ -1211,9 +1204,9 @@ bool SaveCart(LPGBCART Cart, LPTSTR SaveFile, LPTSTR TimeFile) FlushViewOfFile( Cart->RamData, NumQuarterBlocks * 0x0800 ); if (Cart->bHasTimer) { - // Save RTC in VisualBoy Advance format - // TODO: Check if VBA saves are compatible with other emus. - // TODO: Only write RTC data if VBA RTC data was originaly present + // Save RTC in Visual Boy Advance format + // TODO: Check if VBA saves are compatible with other emus + // TODO: Only write RTC data if VBA RTC data was originally present RTCTimer.mapperSeconds = Cart->TimerData[0]; RTCTimer.mapperMinutes = Cart->TimerData[1]; RTCTimer.mapperHours = Cart->TimerData[2]; diff --git a/Source/nragev20/GBCart.h b/Source/nragev20/GBCart.h index 91d14de65..e32f24b0c 100644 --- a/Source/nragev20/GBCart.h +++ b/Source/nragev20/GBCart.h @@ -29,15 +29,15 @@ typedef struct _GBCART bool bHasTimer; bool bHasRumble; bool bRamEnableState; - bool bMBC1RAMbanking; // if false, use 2 magic bits for Most Significant Bits of ROM banking (default); if true, use the 2 magic bits for RAM banking + bool bMBC1RAMbanking; // If false, use 2 magic bits for most significant bits of ROM banking (default); if true, use the 2 magic bits for RAM banking unsigned int iNumRomBanks; unsigned int iNumRamBanks; BYTE TimerData[5]; BYTE LatchedTimerData[5]; time_t timerLastUpdate; bool TimerDataLatched; - HANDLE hRomFile; // a file mapping handle - HANDLE hRamFile; // a file mapping handle, must be NULL if malloc'd ram is being used instead of a valid memory mapped file + HANDLE hRomFile; // A file mapping handle + HANDLE hRamFile; // A file mapping handle, must be NULL if malloc'd RAM is being used instead of a valid memory mapped file const unsigned char * RomData; // max [0x200 * 0x4000]; LPBYTE RamData; // max [0x10 * 0x2000]; bool (*ptrfnReadCart)(_GBCART * Cart, WORD dwAddress, BYTE *Data); // ReadCart handler diff --git a/Source/nragev20/Interface.cpp b/Source/nragev20/Interface.cpp index f67db1f4a..a29a3407b 100644 --- a/Source/nragev20/Interface.cpp +++ b/Source/nragev20/Interface.cpp @@ -1,24 +1,23 @@ /* - N-Rage`s Dinput8 Plugin - (C) 2002, 2006 Norbert Wladyka +N-Rage`s Dinput8 Plugin +(C) 2002, 2006 Norbert Wladyka - Author`s Email: norbert.wladyka@chello.at - Website: http://go.to/nrage +Author`s Email: norbert.wladyka@chello.at +Website: http://go.to/nrage +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the free Software Foundation; either version 2 of the License, or +(at your option) any later version. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the free Software Foundation; either version 2 of the License, or - (at your option) any later version. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include @@ -37,10 +36,10 @@ #include "XInputController.h" #include -// Prototypes // +// Prototypes BOOL CALLBACK ControllerTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ); BOOL CALLBACK ControlsTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ); -BOOL CALLBACK XControlsTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ); // Xinput Control main proc. --tecnicors +BOOL CALLBACK XControlsTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ); // XInput control main process (comment by tecnicors) BOOL CALLBACK DevicesTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ); BOOL CALLBACK ModifierTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ); BOOL CALLBACK ControllerPakTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ); @@ -54,7 +53,7 @@ LRESULT CALLBACK BlockerProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam BOOL InitOverlay(); HWND MakeOverlay(); -// BOOL CALLBACK EnumGetKeyDesc( LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef ); // nope, sorry. --rabid +// BOOL CALLBACK EnumGetKeyDesc( LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef ); // Nope, sorry (comment by rabid) bool GetButtonID( LPDWORD ButtonID, const BYTE bIndex, const BYTE bButtonSet ); bool GetButtonText( const BUTTON& btnButton, LPTSTR Buffer); DWORD ScanDevices( LPDWORD lpdwCounter, LPBUTTON pButton ); @@ -63,11 +62,11 @@ void DeleteControllerSettings( int indexController ); void GetCurrentConfiguration(); void UpdateControllerStructures(); -// global Variables // -INTERFACEVALUES *g_ivConfig = NULL; // this structure holds all GUI-Data; it points to a valid struct only if the config window is open -LPDIRECTINPUTDEVICE8 g_pConfigDevice = NULL; // one device handle for current FF device; between messages so it needs to be persistent -LPDIRECTINPUTEFFECT g_pConfigEffect = NULL; // FF-effect handle -HWND g_hMainDialog = NULL; // handle of base-dialog +// Global variables +INTERFACEVALUES *g_ivConfig = NULL; // This structure holds all GUI data; it points to a valid struct only if the config window is open +LPDIRECTINPUTDEVICE8 g_pConfigDevice = NULL; // One device handle for current force feedback device; between messages so it needs to be persistent +LPDIRECTINPUTEFFECT g_pConfigEffect = NULL; // Force feedback effect handle +HWND g_hMainDialog = NULL; // Handle of base dialog // Main dialog control handler BOOL CALLBACK MainDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) @@ -81,14 +80,14 @@ BOOL CALLBACK MainDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) case WM_INITDIALOG: { DebugWriteA("Config interface: Open\n"); - g_ivConfig = (INTERFACEVALUES*)P_malloc( sizeof(INTERFACEVALUES) ); // TODO: CHECK THIS MALLOC! + g_ivConfig = (INTERFACEVALUES*)P_malloc( sizeof(INTERFACEVALUES) ); // TODO: Check this malloc! ZeroMemory( g_ivConfig, sizeof(INTERFACEVALUES) ); CopyMemory( &g_ivConfig->Shortcuts, &g_scShortcuts ,sizeof(SHORTCUTS) ); for( i = 0; i < 4; ++i ) DeleteControllerSettings( i ); - EnterCriticalSection( &g_critical ); // block because the InitiateControllers code may still be running. + EnterCriticalSection( &g_critical ); // Block because the InitiateControllers code may still be running if( !g_strEmuInfo.fInitialisedPlugin ) { LoadConfigFromINI(); @@ -101,7 +100,7 @@ BOOL CALLBACK MainDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) g_hMainDialog = hDlg; - // Display Version + // Display version { TCHAR tszBuffer[DEFAULT_BUFFER], tszMsg[DEFAULT_BUFFER / 2]; @@ -111,7 +110,7 @@ BOOL CALLBACK MainDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) } - // Tab - Control // + // Tab - control hTabControl = NULL; hDlgItem = GetDlgItem( hDlg, IDC_UPPERTAB ); @@ -131,7 +130,7 @@ BOOL CALLBACK MainDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) LoadString( g_hResourceDLL, IDS_TAB_SHORTCUTS, tszText, DEFAULT_BUFFER ); TabCtrl_InsertItem( hDlgItem, TAB_SHORTCUTS, &tcItem ); - // Tab - Control End // + // Tab - control end g_ivConfig->ChosenTab = TAB_CONTROLLER1; TabCtrl_SetCurSel( GetDlgItem( hDlg, IDC_UPPERTAB), g_ivConfig->ChosenTab ); @@ -141,7 +140,7 @@ BOOL CALLBACK MainDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) nmInit.code = TCN_SELCHANGE; MainDlgProc( hDlg, WM_NOTIFY, IDC_UPPERTAB, (LPARAM)&nmInit ); - // we can't click "Use" without saving when not emulating, because the emu resets controls before loading a ROM + // We can't click "use" without saving when not emulating, because the emulator resets controls before loading a ROM if( !g_bRunning ) EnableWindow( GetDlgItem( hDlg, IDUSE ), FALSE ); @@ -151,9 +150,9 @@ BOOL CALLBACK MainDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) InitOverlay(); } - // call routine to show content( recursive call ) + // Call routine to show content (recursive call) MainDlgProc( hDlg, WM_USER_UPDATE, 0, 0 ); - return TRUE; // the system sets focus to one control element + return TRUE; // The system sets focus to one control element case WM_NOTIFY: hDlgItem = ((LPNMHDR)lParam)->hwndFrom; @@ -197,7 +196,7 @@ BOOL CALLBACK MainDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) } RECT rectWindow, - rectTab, rectMain; // need to know the position of the calling tab window relative to its parent + rectTab, rectMain; // Need to know the position of the calling tab window relative to its parent GetWindowRect( hDlg, &rectMain ); GetWindowRect( hDlgItem, &rectTab ); @@ -205,7 +204,7 @@ BOOL CALLBACK MainDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) GetClientRect( hDlgItem, &rectWindow ); TabCtrl_AdjustRect( hDlgItem, FALSE, &rectWindow ); - // second, third param: plus Tabwindow's position relative to main + // Second, third parameter: plus Tabwindow's position relative to main MoveWindow( hTabControl, (rectTab.left - rectMain.left), (rectTab.top - rectMain.top), rectWindow.right - rectWindow.left, rectWindow.bottom - rectWindow.top, FALSE ); ShowWindow( hTabControl, SW_SHOW ); } @@ -227,7 +226,7 @@ BOOL CALLBACK MainDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) } DebugWriteA("Config interface: Save\n"); StoreConfigToINI(); - // NO BREAK-- this is intentional + // No break, this is intentional case IDUSE: if( hTabControl ) { @@ -263,7 +262,7 @@ BOOL CALLBACK MainDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) case IDC_ERASEFROMDB: case IDC_SAVEPROFILE: case IDC_LOADPROFILE: - // we don't have handlers for these, so fall through to FALSE + // We don't have handlers for these, so fall through to false default: return FALSE; } @@ -300,7 +299,7 @@ BOOL CALLBACK MainDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) case WM_USER_UPDATE: #ifdef _UNICODE - // filling DropDownlist with languages + // Filling DropDownlist with languages hDlgItem = GetDlgItem( hDlg, IDC_LANGUAGE ); SendMessage (hDlgItem, CB_RESETCONTENT, 0, 0); @@ -308,7 +307,7 @@ BOOL CALLBACK MainDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) TCHAR szBuffer[MAX_PATH]; TCHAR * pSlash; WIN32_FIND_DATA fData; - long lLangFound = 0; // the index matching our current language + long lLangFound = 0; // The index matching our current language VerLanguageName(0x0009, szBuffer, DEFAULT_BUFFER); // English (default resource) j = SendMessage( hDlgItem, CB_ADDSTRING, 0, (LPARAM)szBuffer ); @@ -318,7 +317,7 @@ BOOL CALLBACK MainDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) pSlash = _tcsrchr( szBuffer, '\\' ); _tcscpy(pSlash + 1, _T("NRage-Language-*.dll")); - // Search for any file available called NRage-Language-XXXX.dll (where X is numbers) + // Search for any file available called NRage-Language-XXXX.dll (where X is most likely a number) HANDLE fSearch = FindFirstFile(szBuffer, &fData); while ( fSearch != INVALID_HANDLE_VALUE ) @@ -337,9 +336,9 @@ BOOL CALLBACK MainDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) } FindClose(fSearch); - SendMessage( hDlgItem, CB_SETCURSEL, lLangFound, 0 ); // set combo box selection + SendMessage( hDlgItem, CB_SETCURSEL, lLangFound, 0 ); // Set combo box selection } - // DropDownlist End + // DropDownlist end #else hDlgItem = GetDlgItem( hDlg, IDC_LANGUAGE ); SendMessage(hDlgItem, CB_RESETCONTENT, 0, 0); @@ -347,15 +346,15 @@ BOOL CALLBACK MainDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) SendMessage( hDlgItem, CB_SETITEMDATA, j, 0 ); SendMessage(hDlgItem, CB_SETCURSEL, 0, 0); #endif // #ifdef _UNICODE - // call child-dialog(s) to update their content as well + // Call child dialog(s) to update their content as well if( hTabControl ) SendMessage( hTabControl, WM_USER_UPDATE, 0, 0 ); return TRUE; default: - return FALSE; //false means the msg didn't got processed + return FALSE; // False means the message didn't get processed } -// return TRUE; //msg got processed +// return TRUE; // Message did get processed } BOOL CALLBACK ControllerTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) @@ -371,7 +370,7 @@ BOOL CALLBACK ControllerTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPa case WM_INITDIALOG: hTabControl = NULL; - // Tab - Control // + // Tab - control hDlgItem = GetDlgItem( hDlg, IDC_CONTROLLERTAB ); TCITEM tcItem; @@ -394,15 +393,15 @@ BOOL CALLBACK ControllerTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPa nmInit.idFrom = IDC_CONTROLLERTAB; nmInit.code = TCN_SELCHANGE; - // initiate Tab-Display + // Initiate tab display ControllerTabProc( hDlg, WM_NOTIFY, IDC_CONTROLLERTAB, (LPARAM)&nmInit ); - // Tab - Control End // + // Tab - control end - // call routine to show content( recursive call ) + // Call routine to show content (recursive call) ControllerTabProc( hDlg, WM_USER_UPDATE, 0, 0 ); - return FALSE; // don't give it focus + return FALSE; // Don't give it focus case WM_NOTIFY: hDlgItem = ((LPNMHDR)lParam)->hwndFrom; @@ -422,7 +421,7 @@ BOOL CALLBACK ControllerTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPa switch( i ) { case TAB_CONTROLS: - if( pcController->fXInput) // added to show the xinput controller config tab --tecnicors + if( pcController->fXInput) // Added to show the XInput controller config tab (comment by tecnicors) hTabControl = CreateDialog(g_hResourceDLL, MAKEINTRESOURCE(IDD_XCONTROLS), hDlg, (DLGPROC)XControlsTabProc); else hTabControl = CreateDialog(g_hResourceDLL, MAKEINTRESOURCE(IDD_CONTROLS), hDlg, (DLGPROC)ControlsTabProc); @@ -443,7 +442,7 @@ BOOL CALLBACK ControllerTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPa hDlgItem = GetDlgItem( hDlg, IDC_CONTROLLERTAB ); RECT rectWindow, - rectTab, rectMain; // need to know the position of the calling tab window relative to its parent + rectTab, rectMain; // Need to know the position of the calling tab window relative to its parent GetWindowRect( hDlg, &rectMain ); GetWindowRect( hDlgItem, &rectTab ); @@ -486,7 +485,7 @@ BOOL CALLBACK ControllerTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPa { DeleteControllerSettings( g_ivConfig->ChosenTab ); LoadProfileFromResource( g_ivConfig->ChosenTab, true); - *(g_ivConfig->FFDevices[g_ivConfig->ChosenTab].szProductName) = '\0'; // default profile has no FF device + *(g_ivConfig->FFDevices[g_ivConfig->ChosenTab].szProductName) = '\0'; // Default profile has no force feedback device g_ivConfig->FFDevices[g_ivConfig->ChosenTab].bProductCounter = 0; ControllerTabProc( hDlg, WM_USER_UPDATE, 0, 0 ); } @@ -526,7 +525,7 @@ BOOL CALLBACK ControllerTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPa } return TRUE; - case IDC_XINPUT_ENABLER: // change to xinput config --tecnicors + case IDC_XINPUT_ENABLER: // Change to XInput config (comment by tecnicors) pcController->fXInput = ( IsDlgButtonChecked( hDlg, LOWORD(wParam) ) == BST_CHECKED ); if( hTabControl ) DestroyWindow( hTabControl ); @@ -538,7 +537,7 @@ BOOL CALLBACK ControllerTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPa hDlgItem = GetDlgItem( hDlg, IDC_CONTROLLERTAB ); RECT rectWindow, - rectTab, rectMain; // need to know the position of the calling tab window relative to its parent + rectTab, rectMain; // Need to know the position of the calling tab window relative to its parent GetWindowRect( hDlg, &rectMain ); GetWindowRect( hDlgItem, &rectTab ); @@ -564,7 +563,7 @@ BOOL CALLBACK ControllerTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPa } case WM_USER_UPDATE: - // for this dialog + // For this dialog CheckDlgButton( hDlg, IDC_PLUGGED, pcController->fPlugged ? BST_CHECKED : BST_UNCHECKED ); CheckDlgButton( hDlg, IDC_XINPUT_ENABLER, pcController->fXInput ? BST_CHECKED : BST_UNCHECKED ); CheckDlgButton( hDlg, IDC_N64MOUSE, pcController->fN64Mouse ? BST_CHECKED : BST_UNCHECKED); @@ -582,7 +581,7 @@ BOOL CALLBACK ControllerTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPa hDlgItem = GetDlgItem( hDlg, IDC_CONTROLLERTAB ); RECT rectWindow, - rectTab, rectMain; // need to know the position of the calling tab window relative to its parent + rectTab, rectMain; // Need to know the position of the calling tab window relative to its parent GetWindowRect( hDlg, &rectMain ); GetWindowRect( hDlgItem, &rectTab ); @@ -594,20 +593,20 @@ BOOL CALLBACK ControllerTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPa ShowWindow( hTabControl, SW_SHOW ); } - // call child-dialog(s) to update their content as well + // Call child dialog(s) to update their content as well if( hTabControl ) SendMessage( hTabControl, WM_USER_UPDATE, 0, 0 ); return TRUE; default: - return FALSE; //false means the msg didn't got processed + return FALSE; // False means the message didn't get processed } } -// "Controls" tab +// Controls tab BOOL CALLBACK ControlsTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) { - static LPBUTTON aButtons = NULL; // should point to g_ivConfig->Controllers[g_ivConfig->ChosenTab].aButton array - static DWORD dwButtonID[3]; // 0:ID of PushButton 1:ID of TextWindow 2:offset in aButtons struct + static LPBUTTON aButtons = NULL; // Should point to g_ivConfig->Controllers[g_ivConfig->ChosenTab].aButton array + static DWORD dwButtonID[3]; // 0: ID of PushButton 1: ID of TextWindow 2: Offset in aButtons struct static DWORD dwCounter; static bool bScanRunning; static HWND hFocus = NULL; @@ -632,9 +631,9 @@ BOOL CALLBACK ControlsTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara SendMessage( hDlgItem, TBM_SETTICFREQ, (WPARAM) 1, 0 ); SendMessage( hDlgItem, TBM_SETPAGESIZE, (WPARAM) 0, 1 ); - // call routine to show content( recursive call ) + // Call routine to show content (recursive call) ControlsTabProc( hDlg, WM_USER_UPDATE, 0, 0 ); - return FALSE; // don't give it focus + return FALSE; // Don't give it focus case WM_COMMAND: hDlgItem = GetDlgItem( hDlg, LOWORD(wParam) ); @@ -682,9 +681,9 @@ BOOL CALLBACK ControlsTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara case IDC_CDOWN: case IDC_ABUTTON: case IDC_BBUTTON: - case IDC_SBUTTON: // any of these cases means user wants to assign a button + case IDC_SBUTTON: // Any of these cases means user wants to assign a button if( bScanRunning ) - { ; // do nothing + { ; // Do nothing /* bScanRunning = false; KillTimer( hDlg, TIMER_BUTTON ); GetButtonText( aButtons[dwButtonID[2]], szBuffer ); @@ -712,7 +711,7 @@ BOOL CALLBACK ControlsTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara return FALSE; } - case WM_TIMER: // when assigning buttons, this gets called every 20ms (or value in INTERVAL_BUTTON) + case WM_TIMER: // When assigning buttons, this gets called every 20ms (or value in INTERVAL_BUTTON) if( wParam == TIMER_BUTTON && bScanRunning ) { BUTTON newButton; @@ -726,7 +725,7 @@ BOOL CALLBACK ControlsTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara EnterCriticalSection(&g_critical); if( i == SC_SCANESCAPE ) // Scan aborted ZeroMemory(&aButtons[dwButtonID[2]], sizeof(BUTTON)); //aButtons[dwButtonID[2]].dwButton = 0; - else if( i == SC_SCANSUCCEED ) // Got a key, mouseclick, joybutton, or axis + else if( i == SC_SCANSUCCEED ) // Got a key, mouse click, button press, or axis aButtons[dwButtonID[2]] = newButton; DestroyWindow( hBlocker ); @@ -818,12 +817,12 @@ BOOL CALLBACK ControlsTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara return TRUE; default: - return FALSE; //false means the msg didn't got processed + return FALSE; // false means the message didn't get processed } -// return TRUE; //msg got processed +// return TRUE; // Message did get processed } -// XInput controllers tab --tecnicors +// XInput controllers tab (comment by tecnicors) BOOL CALLBACK XControlsTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) { LPXCONTROLLER gController = &g_ivConfig->Controllers[g_ivConfig->ChosenTab].xiController; @@ -874,7 +873,7 @@ BOOL CALLBACK XControlsTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPar default: return FALSE; } -}// END Xinput Controller Tab --tecnicors +}// END XInput controller tab (comment by tecnicors) BOOL CALLBACK DevicesTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) { @@ -910,9 +909,9 @@ BOOL CALLBACK DevicesTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam } // TrackBars End - DevicesTabProc( hDlg, WM_USER_UPDATE, 0, 0 ); // setting values + DevicesTabProc( hDlg, WM_USER_UPDATE, 0, 0 ); // Setting values - return FALSE; // don't give it focus + return FALSE; // Don't give it focus case WM_COMMAND: hDlgItem = GetDlgItem( hDlg, LOWORD(wParam) ); @@ -1038,7 +1037,7 @@ BOOL CALLBACK DevicesTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam return TRUE; default: - return FALSE; //false means the msg didn't got processed + return FALSE; // False means the message didn't get processed } } @@ -1072,7 +1071,7 @@ BOOL CALLBACK MoveModifierDialog( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lP for( i = 0; i < (sizeof(sTics) / sizeof(short)); ++i ) SendMessage( hDlgItem, TBM_SETTIC, 0, sTics[i] ); } - return FALSE; // don't give it focus + return FALSE; // Don't give it focus case WM_HSCROLL: // TrackBars case WM_VSCROLL: @@ -1142,7 +1141,7 @@ BOOL CALLBACK MoveModifierDialog( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lP return TRUE; default: - return FALSE; //false means the msg didn't got processed + return FALSE; // False means the message didn't get processed } } @@ -1161,7 +1160,7 @@ BOOL CALLBACK MacroModifierDialog( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM l switch(uMsg) { case WM_INITDIALOG: - return FALSE; // don't give it focus + return FALSE; // Don't give it focus case WM_USER_UPDATE: if( wParam == MDT_MACRO ) @@ -1201,7 +1200,7 @@ BOOL CALLBACK MacroModifierDialog( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM l return TRUE; default: - return FALSE; //false means the msg didn't got processed + return FALSE; // False means the message didn't get processed } } @@ -1223,7 +1222,7 @@ BOOL CALLBACK ConfigModifierDialog( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM switch(uMsg) { case WM_INITDIALOG: - return FALSE; // don't give it focus + return FALSE; // Don't give it focus case WM_COMMAND: switch( LOWORD(wParam) ) @@ -1234,7 +1233,7 @@ BOOL CALLBACK ConfigModifierDialog( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM case IDC_CONFIGCYCLE: if(( HIWORD(wParam) == BN_CLICKED ) || ( HIWORD(wParam) == BN_DBLCLK )) { - EnterCriticalSection(&g_critical); // has a possibility of affecting the buttons we're writing to + EnterCriticalSection(&g_critical); // This has a possibility of affecting the buttons we're writing to bool bCheck = ( IsDlgButtonChecked( hDlg, LOWORD(wParam) ) == BST_CHECKED ) ? false : true; CheckDlgButton( hDlg, IDC_CONFIG1, BST_UNCHECKED ); CheckDlgButton( hDlg, IDC_CONFIG2, BST_UNCHECKED ); @@ -1306,7 +1305,7 @@ BOOL CALLBACK ConfigModifierDialog( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM return TRUE; default: - return FALSE; //false means the msg didn't got processed + return FALSE; // False means the message didn't get processed } } @@ -1440,7 +1439,7 @@ BOOL CALLBACK ModifierTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara bScanRunning = false; hModProperties = NULL; bDisplayedProbs = MDT_NONE; - // List View + // List view hDlgItem = GetDlgItem( hDlg, IDC_MODIFIERLIST ); LVCOLUMN lvColumn; @@ -1466,9 +1465,9 @@ BOOL CALLBACK ModifierTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara ListView_InsertColumn( hDlgItem, 2, &lvColumn ); ListView_SetExtendedListViewStyle( hDlgItem, LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP ); - // ListView End + // List view end - // DropDown + // Drop down hDlgItem = GetDlgItem( hDlg, IDC_MODTYP ); i = SendMessage( hDlgItem, CB_ADDSTRING, 0, (LPARAM)pszModTypes[0] ); @@ -1482,13 +1481,13 @@ BOOL CALLBACK ModifierTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara i = SendMessage( hDlgItem, CB_ADDSTRING, 0, (LPARAM)pszModTypes[3] ); SendMessage( hDlgItem, CB_SETITEMDATA, i, MDT_CONFIG ); - // DropDown End + // Drop down end ZeroMemory(&storage, sizeof(BUTTON)); - ModifierTabProc( hDlg, WM_USER_UPDATE, 0, 0 ); // setting values + ModifierTabProc( hDlg, WM_USER_UPDATE, 0, 0 ); // Setting values - return FALSE; // don't give it focus + return FALSE; // Don't give it focus case WM_COMMAND: hDlgItem = GetDlgItem( hDlg, LOWORD(wParam) ); @@ -1562,7 +1561,7 @@ BOOL CALLBACK ModifierTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara return TRUE; case IDC_APPCHANGES: - // ModType + // Mod type EnterCriticalSection(&g_critical); hDlgItem = GetDlgItem( hDlg, IDC_MODTYP ); i = SendMessage( hDlgItem, CB_GETCURSEL, 0, 0 ); @@ -1573,13 +1572,13 @@ BOOL CALLBACK ModifierTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara // Status pcController->pModifiers[iSelectedMod].fStatus = ( IsDlgButtonChecked( hDlg, IDC_STATE ) == BST_CHECKED ); - // Specific Data + // Specific data if( hModProperties ) SendMessage( hModProperties, WM_USER_READVALUES, (WPARAM)&pcController->pModifiers[iSelectedMod].dwSpecific, 0 ); else pcController->pModifiers[iSelectedMod].dwSpecific = 0; - // ModButton + // Mod button pcController->pModifiers[iSelectedMod].btnButton = storage; LeaveCriticalSection(&g_critical); @@ -1600,7 +1599,7 @@ BOOL CALLBACK ModifierTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara return FALSE; } - case WM_TIMER: // when assigning modifiers, this gets called every 20ms (or value in INTERVAL_BUTTON) + case WM_TIMER: // When assigning modifiers, this gets called every 20ms (or value in INTERVAL_BUTTON) if( wParam == TIMER_BUTTON && bScanRunning ) { BUTTON newButton; @@ -1613,7 +1612,7 @@ BOOL CALLBACK ModifierTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara hDlgItem = GetDlgItem( hDlg, IDC_ASSIGNMOD ); EnterCriticalSection(&g_critical); - if( i == SC_SCANESCAPE ) // Got an escape char from keyboard; cancel + if( i == SC_SCANESCAPE ) // Got an escape character from keyboard; cancel ZeroMemory(&storage, sizeof(BUTTON)); else if( i == SC_SCANSUCCEED ) // Got a button or axis storage = newButton; @@ -1669,7 +1668,7 @@ BOOL CALLBACK ModifierTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara if( wParam == 0 ) { - // Update Modifier List + // Update modifier list ListView_DeleteAllItems( hDlgItem ); if( lParam == 0 ) iSelectedMod = -1; @@ -1697,7 +1696,7 @@ BOOL CALLBACK ModifierTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara } else { - // Get selected Modifier + // Get selected modifier iSelectedMod = -1; if( ListView_GetSelectedCount( hDlgItem ) > 0 ) { @@ -1717,7 +1716,7 @@ BOOL CALLBACK ModifierTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara if( lParam == 0 ) { if( iSelectedMod >= 0 ) - { // a mod is selected + { // A mod is selected EnableWindow( GetDlgItem( hDlg, IDC_ASSIGNMOD ), TRUE ); EnableWindow( GetDlgItem( hDlg, IDT_ASSIGNMOD ), TRUE ); EnableWindow( GetDlgItem( hDlg, IDC_TOGGLE ), TRUE ); @@ -1727,7 +1726,7 @@ BOOL CALLBACK ModifierTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara EnableWindow( GetDlgItem( hDlg, IDC_RESET ), TRUE ); for( i = SendMessage( hDlgItem, CB_GETCOUNT, 0, 0 )-1; i >= 0; i-- ) - { // looking which Mod-Typ + { // Looking at which mod type bByte = (BYTE)SendMessage( hDlgItem, CB_GETITEMDATA, i, 0 ); if( pcController->pModifiers[iSelectedMod].bModType == bByte ) { @@ -1800,7 +1799,7 @@ BOOL CALLBACK ModifierTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara if( hModProperties ) { - RECT rectProp, rectMain; // need to know the position of the calling tab window relative to its parent + RECT rectProp, rectMain; // Need to know the position of the calling tab window relative to its parent GetWindowRect( hDlg, &rectMain ); GetWindowRect( hDlgItem, &rectProp ); @@ -1814,7 +1813,7 @@ BOOL CALLBACK ModifierTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara return TRUE; default: - return FALSE; //false means the msg didn't got processed + return FALSE; // False means the message didn't get processed } } @@ -1835,7 +1834,7 @@ BOOL CALLBACK ControllerPakTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM bAdaptoidInList = false; bCurrentPak = (BYTE)(-1); - // DropDown-List; + // Drop down list hDlgItem = GetDlgItem( hDlg, IDC_PAKTYPE ); LoadString( g_hResourceDLL, IDS_P_NONE, tszMsg, DEFAULT_BUFFER ); i = SendMessage( hDlgItem, CB_ADDSTRING, 0, (LPARAM)tszMsg ); @@ -1863,7 +1862,7 @@ BOOL CALLBACK ControllerPakTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM #endif ControllerPakTabProc( hDlg, WM_USER_UPDATE, 0, 0 ); - return FALSE; // don't give it focus + return FALSE; // Don't give it focus case WM_COMMAND: hDlgItem = GetDlgItem( hDlg, LOWORD(wParam) ); @@ -1889,14 +1888,14 @@ BOOL CALLBACK ControllerPakTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM case WM_USER_UPDATE: CheckDlgButton( hDlg, IDC_RAWMODE, g_ivConfig->Controllers[g_ivConfig->ChosenTab].fRawData ? BST_CHECKED : BST_UNCHECKED ); - //Set Dropdownlist + // Set drop down list hDlgItem = GetDlgItem( hDlg, IDC_PAKTYPE ); if( g_ivConfig->Controllers[g_ivConfig->ChosenTab].fRawData && !lstrcmp( g_ivConfig->FFDevices[g_ivConfig->ChosenTab].szProductName, _T(STRING_ADAPTOID) ) && !bAdaptoidInList ) { - // add Adaptoid Pak to list + // Add Adaptoid pak to list LoadString( g_hResourceDLL, IDS_P_ADAPTOIDPAK, tszMsg, DEFAULT_BUFFER ); i = SendMessage( hDlgItem, CB_ADDSTRING, 0, (LPARAM)tszMsg ); SendMessage( hDlgItem, CB_SETITEMDATA, i, PAK_ADAPTOID ); @@ -1907,7 +1906,7 @@ BOOL CALLBACK ControllerPakTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM ( lstrcmp( g_ivConfig->FFDevices[g_ivConfig->ChosenTab].szProductName, _T(STRING_ADAPTOID) ) || !g_ivConfig->Controllers[g_ivConfig->ChosenTab].fRawData )) { - // remove Adaptoid Pak from list + // Remove Adaptoid pak from list i = SendMessage( hDlgItem, CB_GETCOUNT, 0, 0 ) - 1; while(( i >= 0 )) { @@ -1939,7 +1938,7 @@ BOOL CALLBACK ControllerPakTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM if( i != -10 ) SendMessage( hDlgItem, CB_SETCURSEL, 0, 0 ); - // Update Pak-Display + // Update pak display if( g_ivConfig->Controllers[g_ivConfig->ChosenTab].fRawData ) { i = SendMessage( GetDlgItem( hDlg, IDC_PAKTYPE ), CB_GETCURSEL, 0, 0 ); @@ -1982,7 +1981,7 @@ BOOL CALLBACK ControllerPakTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM } if( hPakWindow ) { - RECT rectProp, rectMain; // need to know the position of the calling tab window relative to its parent + RECT rectProp, rectMain; // Need to know the position of the calling tab window relative to its parent GetWindowRect( hDlg, &rectMain ); GetWindowRect( hDlgItem, &rectProp ); @@ -1995,7 +1994,7 @@ BOOL CALLBACK ControllerPakTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM return TRUE; default: - return FALSE; //false means the msg didn't got processed + return FALSE; // False means the message didn't get processed } } @@ -2009,7 +2008,7 @@ BOOL CALLBACK PakProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) { case WM_INITDIALOG: PakProc( hDlg, WM_USER_UPDATE, 0, 0 ); - return FALSE; // don't give it focus + return FALSE; // Don't give it focus case WM_USER_UPDATE: bRAW = g_ivConfig->Controllers[g_ivConfig->ChosenTab].fRawData ? 1 : 0; @@ -2042,7 +2041,7 @@ BOOL CALLBACK PakProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) return TRUE; default: - return FALSE; //false means the msg didn't got processed + return FALSE; // False means the message didn't get processed } } @@ -2095,8 +2094,8 @@ BOOL CALLBACK MemPakProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) ListView_SetExtendedListViewStyle( hDlgItem, LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP ); - MemPakProc( hDlg, WM_USER_UPDATE, 0, 0 ); // setting values - return FALSE; // don't give it focus + MemPakProc( hDlg, WM_USER_UPDATE, 0, 0 ); // Setting values + return FALSE; // Don't give it focus case WM_COMMAND: hDlgItem = GetDlgItem( hDlg, LOWORD(wParam) ); @@ -2261,7 +2260,7 @@ BOOL CALLBACK MemPakProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) pszMemPakFile = g_ivConfig->Controllers[g_ivConfig->ChosenTab].szMempakFile; iSelectedNote = -1; - // Mempak List Window + // Memory pak list window if( wParam == 0 && lParam == 0 ) { hDlgItem = GetDlgItem( hDlg, IDC_MEMPAKLIST ); @@ -2289,12 +2288,12 @@ BOOL CALLBACK MemPakProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) } SendMessage( hDlgItem, LB_SETCURSEL, j, 0 ); } - // Mempak List Window End + // Memory pak list window end - // MamPak Full Path+Name + // Memory pak full path and name GetAbsoluteFileName( szBuffer, pszMemPakFile, DIRECTORY_MEMPAK ); - // MemPak Browser + // Memory pak browser ListView_DeleteAllItems( GetDlgItem( hDlg, IDC_MEMPAKBROWSER )); if( (!lstrcmpi( &szBuffer[lstrlen(szBuffer)-4], _T(".mpk") )) || (!lstrcmpi( &szBuffer[lstrlen(szBuffer)-4], _T(".n64") ))) @@ -2302,7 +2301,7 @@ BOOL CALLBACK MemPakProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) BYTE aMemPakHeader[0x500]; bool bMemPakUsed = false; - // first, if we're running emulation we need to make sure we haven't selected a file that's currently in use + // First, if we're running an emulation instance we need to make sure we haven't selected a file that's currently in use if (g_bRunning) { TCHAR szMemPakFile[MAX_PATH+1]; @@ -2313,7 +2312,7 @@ BOOL CALLBACK MemPakProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) GetAbsoluteFileName( szMemPakFile, g_pcControllers[i].szMempakFile, DIRECTORY_MEMPAK ); if( !lstrcmp( szMemPakFile, szBuffer )) { - // grab the file info from memory instead of the file... but keep in mind we can't do anything dangerous with it + // Grab the file info from memory instead of the file...but keep in mind we can't do anything dangerous with it EnterCriticalSection( &g_critical ); wMemPakState = ShowMemPakContent( ((MEMPAK*)g_pcControllers[i].pPakData)->aMemPakData, GetDlgItem( hDlg, IDC_MEMPAKBROWSER )); LeaveCriticalSection( &g_critical ); @@ -2378,7 +2377,7 @@ BOOL CALLBACK MemPakProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) wsprintf( szBuffer, szTemp, LOBYTE(wMemPakState) ); break; case MPAK_INUSE: - // text field already set + // Text field already set break; case MPAK_WRONGSIZE: LoadString( g_hResourceDLL, IDS_P_MEM_WRONGSIZE, szTemp, MAX_PATH + 1 ); @@ -2425,7 +2424,7 @@ BOOL CALLBACK MemPakProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) return TRUE; default: - return FALSE; //false means the msg didn't got processed + return FALSE; // False means the message didn't get processed } } @@ -2448,7 +2447,7 @@ BOOL CALLBACK RumblePakProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam SendMessage( hDlgItem, TBM_SETPAGESIZE, (WPARAM) 0, 1 ); RumblePakProc( hDlg, WM_USER_UPDATE, 0, 0 ); - return FALSE; // don't give it focus + return FALSE; // Don't give it focus case WM_COMMAND: hDlgItem = GetDlgItem( hDlg, LOWORD(wParam) ); @@ -2474,11 +2473,11 @@ BOOL CALLBACK RumblePakProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam } LeaveCriticalSection(&g_critical); - RumblePakProc( hDlg, WM_USER_UPDATE, 0, 0 ); // en/disabling RumbleOptions + RumblePakProc( hDlg, WM_USER_UPDATE, 0, 0 ); // Enabling/disabling rumble options } return TRUE; - // the following three cases use fallthrough assignment + // The following three cases use fall through assignment case IDC_RUMBLE1: if( LOWORD(wParam) == IDC_RUMBLE1 ) i = RUMBLE_EFF1; @@ -2520,26 +2519,26 @@ BOOL CALLBACK RumblePakProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam switch (hRslt) { case DIERR_INCOMPLETEEFFECT: - DebugWriteA("Test Rumble: DIError: incomplete effect.\n"); + DebugWriteA("Test rumble: DIError: incomplete effect.\n"); break; case DIERR_INVALIDPARAM: - DebugWriteA("Test Rumble: DIError: invalid param.\n"); + DebugWriteA("Test rumble: DIError: invalid parameter.\n"); break; case DIERR_NOTEXCLUSIVEACQUIRED: - DebugWriteA("Test Rumble: DIError: not exclusive acquired.\n"); + DebugWriteA("Test rumble: DIError: not exclusive acquired.\n"); break; case DIERR_NOTINITIALIZED: - DebugWriteA("Test Rumble: DIError: not initialized.\n"); + DebugWriteA("Test rumble: DIError: not initialized.\n"); break; case DIERR_UNSUPPORTED: - DebugWriteA("Test Rumble: DIError: unsupported.\n"); + DebugWriteA("Test rumble: DIError: unsupported.\n"); break; default: - DebugWriteA("Test Rumble: DIError: undocumented: %lX\n", hRslt); + DebugWriteA("Test rumble: DIError: undocumented: %lX\n", hRslt); } } else - DebugWriteA("Test Rumble: OK\n"); + DebugWriteA("Test rumble: OK\n"); } return TRUE; @@ -2547,7 +2546,7 @@ BOOL CALLBACK RumblePakProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam return FALSE; } - case WM_HSCROLL: // TrackBars + case WM_HSCROLL: // Track bars case WM_VSCROLL: i = GetWindowLong( (HWND)lParam, GWL_ID ); switch( i ) @@ -2564,16 +2563,16 @@ BOOL CALLBACK RumblePakProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam } case WM_USER_UPDATE: - // filling DropDownlist with devices + // Filling drop down list with devices hDlgItem = GetDlgItem( hDlg, IDC_CTRDEVICE ); - SendMessage (hDlgItem, CB_RESETCONTENT, 0, 0); // HACK: yeah this isn't the best way to do this, but it works. + SendMessage (hDlgItem, CB_RESETCONTENT, 0, 0); // Hack: Yeah this isn't the best way to do this, but it works. LoadString( g_hResourceDLL, IDS_P_R_NODEVICE, szBuffer, DEFAULT_BUFFER ); j = SendMessage( hDlgItem, CB_ADDSTRING, 0, (LPARAM)szBuffer ); SendMessage( hDlgItem, CB_SETITEMDATA, j, -1 ); for( i = 0; i < g_nDevices; i++ ) { bool bMatch = false; - // if device is not already set as a FF device in some other tab + // If device is not already set as a force feedback device in some other tab for( int m = 0; m < 4; m++) { if( g_ivConfig->ChosenTab != m) @@ -2592,7 +2591,7 @@ BOOL CALLBACK RumblePakProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam SendMessage( hDlgItem, CB_SETITEMDATA, j, i ); } } - // DropDownlist End + // Drop down list end EnterCriticalSection(&g_critical); j = FindDeviceinList( pifDevice->szProductName, pifDevice->bProductCounter, true ); @@ -2601,7 +2600,7 @@ BOOL CALLBACK RumblePakProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ReleaseDevice( g_pConfigDevice ); if( j == -1 || !g_devList[j].bEffType) { - SendMessage( hDlgItem, CB_SETCURSEL, 0, 0 ); // set "None" + SendMessage( hDlgItem, CB_SETCURSEL, 0, 0 ); // Set "none" EnableWindow( GetDlgItem( hDlg, IDC_RUMBLE1 ), FALSE ); EnableWindow( GetDlgItem( hDlg, IDC_RUMBLE2 ), FALSE ); EnableWindow( GetDlgItem( hDlg, IDC_RUMBLE3 ), FALSE ); @@ -2621,16 +2620,16 @@ BOOL CALLBACK RumblePakProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam DebugWriteA("GetInputDevice in RumblePakProc: OK\n"); } - // DropDownList + // Drop down list if( g_devList[j].bProductCounter == 0 ) i = SendMessage( hDlgItem, CB_FINDSTRINGEXACT, (WPARAM)(-1), (LPARAM)g_devList[j].szProductName ); else { wsprintf( szBuffer, _T("%s %i"), g_devList[j].szProductName, g_devList[j].bProductCounter ); - i = SendMessage( hDlgItem, CB_FINDSTRINGEXACT, (WPARAM)(-1), (LPARAM)szBuffer ); // search index of Device-String + i = SendMessage( hDlgItem, CB_FINDSTRINGEXACT, (WPARAM)(-1), (LPARAM)szBuffer ); // Search index of device string } - SendMessage( hDlgItem, CB_SETCURSEL, i, 0 ); // select the right string + SendMessage( hDlgItem, CB_SETCURSEL, i, 0 ); // Select the right string if( g_devList[j].bEffType & RUMBLE_EFF1 ) EnableWindow( GetDlgItem( hDlg, IDC_RUMBLE1 ), TRUE ); @@ -2689,7 +2688,7 @@ BOOL CALLBACK RumblePakProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam CheckDlgButton( hDlg, IDC_VISUALRUMBLE, pcController->fVisualRumble ? BST_CHECKED : BST_UNCHECKED ); - // TrackBars + // Track bars SendMessage( GetDlgItem( hDlg, IDC_RUMBLESTRENGTH ), TBM_SETPOS, TRUE, pcController->bRumbleStrength ); LoadString( g_hResourceDLL, IDS_D_RUMBLESTR, szTemp, DEFAULT_BUFFER ); wsprintf( szBuffer, szTemp, pcController->bRumbleStrength ); @@ -2698,7 +2697,7 @@ BOOL CALLBACK RumblePakProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam return TRUE; default: - return FALSE; //false means the msg didn't got processed + return FALSE; // False means the message didn't get processed } } @@ -2718,8 +2717,8 @@ BOOL CALLBACK TransferPakProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara SendMessage( GetDlgItem( hDlg, IDC_CHGDIR ), WM_SETTEXT, 0, (LPARAM)tszMsg ); } - TransferPakProc( hDlg, WM_USER_UPDATE, 0, 0 ); // setting values - return FALSE; // don't give it focus + TransferPakProc( hDlg, WM_USER_UPDATE, 0, 0 ); // Setting values + return FALSE; // Don't give it focus case WM_COMMAND: switch( LOWORD(wParam) ) @@ -2776,7 +2775,7 @@ BOOL CALLBACK TransferPakProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara return TRUE; default: - return FALSE; //false means the msg didn't got processed + return FALSE; // False means the message didn't get processed } } @@ -2786,7 +2785,7 @@ BOOL CALLBACK ShortcutsTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPar static DWORD dwButtonID[3]; static DWORD dwCounter; static HWND hFocus = NULL; - static int iPlayer = 5; // HACK: player "5" is obviously out of bounds, so indicates no control has been set + static int iPlayer = 5; // Hack: Player "5" is obviously out of bounds, so indicates no control has been set long i; static HWND hBlocker = NULL; @@ -2799,8 +2798,8 @@ BOOL CALLBACK ShortcutsTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPar bScanRunning = false; iPlayer = 5; - ShortcutsTabProc( hDlg, WM_USER_UPDATE, 0, 0 ); // setting values - return FALSE; // don't give it focus + ShortcutsTabProc( hDlg, WM_USER_UPDATE, 0, 0 ); // Setting values + return FALSE; // Don't give it focus case WM_COMMAND: switch( LOWORD(wParam) ) @@ -2931,7 +2930,7 @@ BOOL CALLBACK ShortcutsTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPar return FALSE; } - case WM_TIMER: // when assigning shortcuts, this gets called every 20ms (or value in INTERVAL_BUTTON) + case WM_TIMER: // When assigning shortcuts, this gets called every 20ms (or value in INTERVAL_BUTTON) if( wParam == TIMER_BUTTON && bScanRunning ) { BUTTON newButton; @@ -2950,7 +2949,7 @@ BOOL CALLBACK ShortcutsTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPar else ZeroMemory(&g_ivConfig->Shortcuts.Player[iPlayer].aButtons[dwButtonID[2] % SC_TOTAL], sizeof(BUTTON)); } - else if( i == SC_SCANSUCCEED ) // Got a key, mouseclick, joybutton, or axis + else if( i == SC_SCANSUCCEED ) // Got a key, mouse click, button press, or axis if (iPlayer == -1) g_ivConfig->Shortcuts.bMouseLock = newButton; else @@ -2962,7 +2961,7 @@ BOOL CALLBACK ShortcutsTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPar GetButtonText( g_ivConfig->Shortcuts.bMouseLock, szBuffer ); else GetButtonText( g_ivConfig->Shortcuts.Player[iPlayer].aButtons[dwButtonID[2] % SC_TOTAL], szBuffer ); - iPlayer = 5; // reset invalid player value + iPlayer = 5; // Reset invalid player value LeaveCriticalSection(&g_critical); SendMessage( GetDlgItem( hDlg, dwButtonID[1] ), WM_SETTEXT , 0, (LPARAM)szBuffer ); @@ -2993,13 +2992,13 @@ BOOL CALLBACK ShortcutsTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPar bScanRunning = false; KillTimer( hDlg, TIMER_BUTTON ); - for ( i = 0; i < 4; i++ ) // controllers - for( int j = 0; j < SC_TOTAL * 4; j++ ) // shortcuts + for ( i = 0; i < 4; i++ ) // Controllers + for( int j = 0; j < SC_TOTAL * 4; j++ ) // Shortcuts { DWORD aIDs[3]; aIDs[2] = i * SC_TOTAL + j; if( !GetButtonID( aIDs, 2, BSET_SHORTCUTS )) - continue; // for not implemented Buttons, otherwise the behaviour is unsafe + continue; // For not implemented buttons, otherwise the behavior is unsafe GetButtonText( g_ivConfig->Shortcuts.Player[i].aButtons[j], szBuffer ); SendMessage( GetDlgItem( hDlg, aIDs[1] ), WM_SETTEXT , 0, (LPARAM)szBuffer ); @@ -3017,7 +3016,7 @@ BOOL CALLBACK ShortcutsTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPar return TRUE; default: - return FALSE; //false means the msg didn't got processed + return FALSE; // False means the message didn't get processed } } @@ -3064,7 +3063,7 @@ BOOL CALLBACK FoldersDialogProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPa for( int i = 0; i < sizeof(aChilds)/sizeof(int); ++i ) DestroyWindow( GetDlgItem( hDlg, aChilds[i] )); } -#pragma message( "unimplemented Features from the Folderdialog will be removed" ) +#pragma message( "unimplemented features from the folder dialog will be removed" ) #endif // #ifdef HIDEUNIMPLEMENTED GetDirectory( szApplication, DIRECTORY_GBROMS ); @@ -3074,7 +3073,7 @@ BOOL CALLBACK FoldersDialogProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPa GetDirectory( szApplication, DIRECTORY_APPLICATION ); i = lstrlen( szApplication ); - // MemPak Directory + // Memory pak directory lstrcpyn(szBuffer, g_aszDefFolders[DIRECTORY_MEMPAK], MAX_PATH); if( szBuffer[0] != 0 && ( szBuffer[1] == ':' || ( szBuffer[1] == '\\' && szBuffer[0] == '\\' ))) @@ -3107,7 +3106,7 @@ BOOL CALLBACK FoldersDialogProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPa if( pcSlash && ( pcSlash[1] == '\0' )) *pcSlash = '\0'; SendMessage( GetDlgItem( hDlg, IDC_MEMPAK_ABS_EDIT ), WM_SETTEXT, 0, (LPARAM)szBuffer ); - // GBRom Directory + // Game Boy ROM directory lstrcpyn(szBuffer, g_aszDefFolders[DIRECTORY_GBROMS], MAX_PATH); if( szBuffer[0] != 0 && ( szBuffer[1] == _T(':') || ( szBuffer[1] == _T('\\') && szBuffer[0] == _T('\\') ))) @@ -3140,7 +3139,7 @@ BOOL CALLBACK FoldersDialogProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPa if( pcSlash && ( pcSlash[1] == _T('\0') )) *pcSlash = '\0'; SendMessage( GetDlgItem( hDlg, IDC_GBROM_ABS_EDIT ), WM_SETTEXT, 0, (LPARAM)szBuffer ); - // GBSave Directory + // Game Boy save directory lstrcpyn(szBuffer, g_aszDefFolders[DIRECTORY_GBSAVES], MAX_PATH); if( !j ) @@ -3183,7 +3182,7 @@ BOOL CALLBACK FoldersDialogProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPa if( pcSlash && ( pcSlash[1] == _T('\0') )) *pcSlash = '\0'; SendMessage( GetDlgItem( hDlg, IDC_GBSAVE_ABS_EDIT ), WM_SETTEXT, 0, (LPARAM)szBuffer ); - return FALSE; // don't give it focus + return FALSE; // Don't give it focus case WM_COMMAND: switch( LOWORD(wParam) ) @@ -3224,7 +3223,7 @@ BOOL CALLBACK FoldersDialogProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPa if( BrowseFolders( hDlg, NULL, szBuffer )) { i = lstrlen( szApplication ); - lstrcpyn( szBuffer, &szBuffer[i], ARRAYSIZE(szBuffer) ); // HACK: The lstrcpyn function has an undefined behavior if source and destination buffers overlap. + lstrcpyn( szBuffer, &szBuffer[i], ARRAYSIZE(szBuffer) ); // Hack: The lstrcpyn function has an undefined behavior if source and destination buffers overlap SendMessage( GetDlgItem( hDlg, IDC_MEMPAK_REL_EDIT ), WM_SETTEXT, 0, (LPARAM)szBuffer ); } return TRUE; @@ -3235,7 +3234,7 @@ BOOL CALLBACK FoldersDialogProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPa if( BrowseFolders( hDlg, NULL, szBuffer )) { i = lstrlen( szApplication ); - lstrcpyn( szBuffer, &szBuffer[i], ARRAYSIZE(szBuffer) ); // HACK: The lstrcpyn function has an undefined behavior if source and destination buffers overlap. + lstrcpyn( szBuffer, &szBuffer[i], ARRAYSIZE(szBuffer) ); // Hack: The lstrcpyn function has an undefined behavior if source and destination buffers overlap SendMessage( GetDlgItem( hDlg, IDC_GBROM_REL_EDIT ), WM_SETTEXT, 0, (LPARAM)szBuffer ); } return TRUE; @@ -3246,7 +3245,7 @@ BOOL CALLBACK FoldersDialogProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPa if( BrowseFolders( hDlg, NULL, szBuffer )) { i = lstrlen( szApplication ); - lstrcpyn( szBuffer, &szBuffer[i], ARRAYSIZE(szBuffer) ); // HACK: The lstrcpyn function has an undefined behavior if source and destination buffers overlap. + lstrcpyn( szBuffer, &szBuffer[i], ARRAYSIZE(szBuffer) ); // Hack: The lstrcpyn function has an undefined behavior if source and destination buffers overlap SendMessage( GetDlgItem( hDlg, IDC_GBSAVE_REL_EDIT ), WM_SETTEXT, 0, (LPARAM)szBuffer ); } return TRUE; @@ -3310,29 +3309,30 @@ BOOL CALLBACK FoldersDialogProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPa return TRUE; default: - return FALSE; // unhandled WM_COMMAND + return FALSE; // Unhandled WM_COMMAND } default: - return FALSE; //false means the msg didn't got processed + return FALSE; // False means the message didn't get processed } } -/////////////////////////////////////////////////////////////////////////////// -// A wonderful n squared algorithm to store the key names in a string... what for??? -// called by EnumObjects in MainDlgProcess to enumerate the keys on the keyboard...? +// TODO: Check this for possible removal or updating +// A wonderful n squared algorithm to store the key names in a string +// called by EnumObjects in MainDlgProcess to enumerate the keys on the keyboard /* BOOL CALLBACK EnumGetKeyDesc( LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef ) { // REMOVED // -} // I am putting this function out of its misery before it causes more grief. --rabid */ +} // I am putting this function out of its misery before it causes more grief. (comment by rabid) */ -// ButtonID is where we store an array of 3 DWORDs: ID of pushbutton, ID of text window, and an offset in the button-structure controls +// ButtonID is where we store an array of 3 DWORDs: ID of pushbutton, ID of text window, and an offset in the button structure controls // bIndex tells us what information to copy, but in a confusing way -// bButtonSet tells us whether we want the data from the Controls array or the Shortcuts array below -// This function is confusing, but not much I can do to fix it now. I'm sorry. --rabid +// bButtonSet tells us whether we want the data from the controls array or the shortcuts array below +// This function is confusing, but not much I can do to fix it now. I'm sorry. (comment by rabid) bool GetButtonID( LPDWORD ButtonID, const BYTE bIndex, const BYTE bButtonSet ) { - // TODO: make these const, read from a resource or a define, or something... I don't know + // TODO: Check this + // TODO: make these constant, read from a resource or a define, or something...I don't know LPDWORD ButtonTable = NULL; int nEntries = 0; @@ -3395,7 +3395,7 @@ bool GetButtonID( LPDWORD ButtonID, const BYTE bIndex, const BYTE bButtonSet ) if( bButtonSet == BSET_CONTROLS ) { - ButtonTable = (LPDWORD)Controls; // HACK: what an ugly solution, using a cast like that + ButtonTable = (LPDWORD)Controls; // TODO: Hack: what an ugly solution, using a cast like that nEntries = ARRAYSIZE( Controls ); } @@ -3407,7 +3407,7 @@ bool GetButtonID( LPDWORD ButtonID, const BYTE bIndex, const BYTE bButtonSet ) bool bReturn = false; - // TODO: fix this! just use 2 dimensional arrays for crying out loud! + // TODO: Fix this! Just use 2 dimensional arrays? if( ButtonTable != NULL ) { nEntries *= 3; @@ -3428,7 +3428,7 @@ bool GetButtonID( LPDWORD ButtonID, const BYTE bIndex, const BYTE bButtonSet ) return bReturn; } -// a text-munging routine to spit out what PC control was assigned to a button +// A text munging routine to spit out what PC control was assigned to a button bool GetButtonText( const BUTTON& btnButton, LPTSTR Buffer ) { const UINT iDevice[] ={ IDS_BUTTON_UNASSIGNED, @@ -3458,7 +3458,7 @@ bool GetButtonText( const BUTTON& btnButton, LPTSTR Buffer ) TEXT( " >" ), TEXT( " \\/" ), TEXT( " <" ) }; - TCHAR a[16], b[16], buff[16]; // gotta allocate the space, stack is easier than P_malloc + TCHAR a[16], b[16], buff[16]; // We have to allocate the space, stack is easier than P_malloc TCHAR Btn[6]; LPTSTR Text[] = {a, b, NULL }; bool bReturn = true; @@ -3491,7 +3491,7 @@ bool GetButtonText( const BUTTON& btnButton, LPTSTR Buffer ) break; case DT_KEYBUTTON: LoadString( g_hResourceDLL, iDevice[2], Text[0], 16 ); - //TODO: this is great! can we do this for all of them? + // TODO: This is great! Can we do this for all of them? if (btnButton.parentDevice->didHandle->GetObjectInfo(&didoi, btnButton.bOffset, DIPH_BYOFFSET) == DI_OK) Text[1] = didoi.tszName; else @@ -3520,7 +3520,7 @@ bool GetButtonText( const BUTTON& btnButton, LPTSTR Buffer ) return ( bReturn ); } -// called when scanning devices to assign N64 buttons +// Called when scanning devices to assign N64 buttons DWORD ScanKeyboard( LPDEVICE lpDevice, LPDWORD lpdwCounter, LPBUTTON pButton ) { HRESULT hr; @@ -3555,7 +3555,7 @@ DWORD ScanKeyboard( LPDEVICE lpDevice, LPDWORD lpdwCounter, LPBUTTON pButton ) return iGotKey; } -// called when scanning devices to assign N64 buttons +// Called when scanning devices to assign N64 buttons DWORD ScanMouse( LPDEVICE lpDevice, LPDWORD lpdwCounter, LPBUTTON pButton ) { static BYTE rgbInitButtons[8]; @@ -3634,8 +3634,8 @@ DWORD ScanMouse( LPDEVICE lpDevice, LPDWORD lpdwCounter, LPBUTTON pButton ) return iGotKey; } -// called when scanning devices to assign N64 buttons -// tries to read any possible button presses or axes from lpDirectInputDevice; called by ScanDevices +// Called when scanning devices to assign N64 buttons +// Tries to read any possible button presses or axes from lpDirectInputDevice; called by ScanDevices DWORD ScanGamePad ( LPDEVICE lpDevice, LPDWORD lpdwCounter, LPBUTTON pButton, int iDeviceNumber ) { static DIJOYSTATE dj_Initial[MAX_DEVICES]; @@ -3656,7 +3656,7 @@ DWORD ScanGamePad ( LPDEVICE lpDevice, LPDWORD lpdwCounter, LPBUTTON pButton, in { dj_Initial[iDeviceNumber] = lpDevice->stateAs.joyState; bFirstScan = false; - return FALSE; // initial scan done; gotta wait until next time + return FALSE; // Initial scan done; we have to wait until next time } long lAxePos = ZEROVALUE + ( RANGERELATIVE * CONFIGTHRESHOLD / 100 ); @@ -3743,12 +3743,12 @@ DWORD ScanGamePad ( LPDEVICE lpDevice, LPDWORD lpdwCounter, LPBUTTON pButton, in return iGotKey; } -// called when we assign a control to an N64 button -// returns FALSE if no keyscans recorded, SC_SCANESCAPE if escape pressed on keyboard (to abort), or SC_SUCCEED for a good read +// Called when we assign a control to an N64 button +// Returns FALSE if no key scans recorded, SC_SCANESCAPE if escape pressed on keyboard (to abort), or SC_SUCCEED for a good read // *apDirectInputDevices is an array of only 2 devices; sys keyboard, sys mouse DWORD ScanDevices( LPDWORD lpdwCounter, LPBUTTON pButton ) { - // Do ALL our polling first-- this ensures consistency (i.e. every device always gets polled at same interval) + // Do all our polling first, this ensures consistency (i.e. every device always gets polled at same interval) /* if( g_sysKeyboard.didHandle ) { if( FAILED(g_sysKeyboard.didHandle->Poll())) @@ -3766,7 +3766,7 @@ DWORD ScanDevices( LPDWORD lpdwCounter, LPBUTTON pButton ) // While we have devices to scan, // if it's a keyboard, ScanKeyboard; if it's a mouse, ScanMouse; - // otherwise ScanGamePad. + // otherwise ScanGamePad DWORD dwReturn = FALSE; @@ -3776,7 +3776,7 @@ DWORD ScanDevices( LPDWORD lpdwCounter, LPBUTTON pButton ) if( !dwReturn && g_sysMouse.didHandle ) dwReturn = ScanMouse( &g_sysMouse, lpdwCounter, pButton ); - // ScanGamePad on ALL remaining devices + // ScanGamePad on all remaining devices for (int i = 0; !dwReturn && i < g_nDevices; i++) if (g_devList[i].didHandle) { @@ -3796,9 +3796,9 @@ DWORD ScanDevices( LPDWORD lpdwCounter, LPBUTTON pButton ) return dwReturn; } -// sets controller defaults; called when user clicks on "Clear Controller" or "Default Config" -// also called before loading stuff from the INI or from profile files, in case something isn't defined -// DEFAULTS TO NOT PLUGGED. Make sure you "plug" the first controller manually. +// Sets controller defaults; called when user clicks on "Clear Controller" or "Default Config" +// Also called before loading stuff from the INI or from profile files, in case something isn't defined +// Defaults to not connected. Make sure you "connect" the first controller manually. void SetControllerDefaults( LPCONTROLLER pcController ) { freePakData( pcController ); @@ -3922,7 +3922,7 @@ void UpdateControllerStructures() g_iFirstController = -1; #ifdef _UNICODE - // might as well use this time to copy over language info and open the new DLL as well... --rabid + // Might as well use this time to copy over language info and open the new DLL as well (comment by rabid) g_strEmuInfo.Language = g_ivConfig->Language; if (g_hResourceDLL != g_strEmuInfo.hinst) FreeLibrary(g_hResourceDLL); @@ -3931,7 +3931,7 @@ void UpdateControllerStructures() { g_strEmuInfo.Language = 0; g_hResourceDLL = g_strEmuInfo.hinst; - DebugWriteA("couldn't load language DLL, falling back to defaults\n"); + DebugWriteA("Couldn't load language DLL, falling back to defaults\n"); } #endif // #ifdef _UNICODE @@ -3944,7 +3944,7 @@ void UpdateControllerStructures() SaveControllerPak( i ); CloseControllerPak( i ); -// freePakData( &g_pcControllers[i] ); // called already by CloseControllerPak +// freePakData( &g_pcControllers[i] ); // Called already by CloseControllerPak freeModifiers( &g_pcControllers[i] ); CopyMemory( &g_pcControllers[i], pcController, sizeof(CONTROLLER)); @@ -3999,7 +3999,7 @@ LRESULT CALLBACK BlockerProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) BOOL InitOverlay(void) { - // registers our overlay class + // Registers our overlay class WNDCLASS wc; @@ -4007,17 +4007,17 @@ BOOL InitOverlay(void) // that describe the main window. wc.style = 0; - wc.lpfnWndProc = BlockerProc; // window procedure - wc.cbClsExtra = 0; // no extra class memory - wc.cbWndExtra = 0; // no extra window memory + wc.lpfnWndProc = BlockerProc; // Window procedure + wc.cbClsExtra = 0; // No extra class memory + wc.cbWndExtra = 0; // No extra window memory wc.hInstance = g_strEmuInfo.hinst; wc.hIcon = 0; wc.hCursor = NULL; wc.hbrBackground = NULL; wc.lpszMenuName = NULL; - wc.lpszClassName = _T("BlockerClass"); // name of window class + wc.lpszClassName = _T("BlockerClass"); // Name of window class - // Register the window class. + // Register the window class return RegisterClass(&wc); } @@ -4036,14 +4036,14 @@ HWND MakeOverlay() _T("BlockerClass"), _T("Blocker"), WS_POPUP, - size.left, // horizontal position - size.top, // vertical position - size.right - size.left, // width - size.bottom - size.top, // height - g_hMainDialog, // owner window - (HMENU) NULL, // menu - g_strEmuInfo.hinst, // handle to application instance - (LPVOID) NULL // window-creation data + size.left, // Horizontal position + size.top, // Vertical position + size.right - size.left, // Width + size.bottom - size.top, // Height + g_hMainDialog, // Owner window + (HMENU) NULL, // Menu + g_strEmuInfo.hinst, // Handle to application instance + (LPVOID) NULL // Window creation data ); if (!hwnd) return NULL; diff --git a/Source/nragev20/Interface.h b/Source/nragev20/Interface.h index 9f386403f..74deb9aec 100644 --- a/Source/nragev20/Interface.h +++ b/Source/nragev20/Interface.h @@ -1,24 +1,23 @@ /* - N-Rage`s Dinput8 Plugin - (C) 2002, 2006 Norbert Wladyka +N-Rage`s Dinput8 Plugin +(C) 2002, 2006 Norbert Wladyka - Author`s Email: norbert.wladyka@chello.at - Website: http://go.to/nrage +Author`s Email: norbert.wladyka@chello.at +Website: http://go.to/nrage +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _NRINTERFACE_ @@ -28,9 +27,9 @@ BOOL CALLBACK MainDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ); void SetModifier( CONTROLLER *pcController ); void SetControllerDefaults( CONTROLLER *pcController ); - // application internal message +// Application internal message #define WM_USER_UPDATE WM_USER + 1 - // application internal message +// Application internal message #define WM_USER_READVALUES WM_USER + 2 #define CONFIGTHRESHOLD 50 diff --git a/Source/nragev20/International.cpp b/Source/nragev20/International.cpp index 1e0eab5f3..ee7b40ea7 100644 --- a/Source/nragev20/International.cpp +++ b/Source/nragev20/International.cpp @@ -1,27 +1,26 @@ /* - N-Rage`s Dinput8 Plugin - (C) 2002, 2006 Norbert Wladyka +N-Rage`s Dinput8 Plugin +(C) 2002, 2006 Norbert Wladyka - Author`s Email: norbert.wladyka@chello.at - Website: http://go.to/nrage +Author`s Email: norbert.wladyka@chello.at +Website: http://go.to/nrage +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the free Software Foundation; either version 2 of the License, or +(at your option) any later version. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the free Software Foundation; either version 2 of the License, or - (at your option) any later version. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -// Internationalization routines go in this file. +// Internationalization routines go in this file #include #include @@ -37,7 +36,7 @@ BOOL IsHongKongVersion(); BOOL CALLBACK EnumLangProc(HANDLE hModule, LPCTSTR lpszType, LPCTSTR lpszName, WORD wIDLanguage, LONG_PTR lParam); // The following routines are ripped straight from the SatDLL sample project on the Visual Studio .NET CDs. -// Props to the MS coders for making this solid piece of work. --rabid +// Props to the MS coders for making this solid piece of work (comment by rabid) // "If it ain't broke, don't fix it." // Loads the satellite DLL specified for the language DesiredLanguage @@ -52,7 +51,7 @@ HMODULE LoadLanguageDLL(LANGID DesiredLanguage) if( hDLL ) return hDLL; else - { // try the primary language ID + { // Try the primary language ID DesiredLanguage = PRIMARYLANGID(DesiredLanguage); _stprintf(SatellitePath, _T("NRage-Language-%u.dll"), DesiredLanguage); hDLL = LoadLibraryEx(SatellitePath, 0, 0); @@ -79,11 +78,11 @@ BOOL CALLBACK EnumLangProc(HANDLE hModule, LPCTSTR lpszType, LPCTSTR lpszName, LangInfo->Count++; LangInfo->LangID = wIDLanguage; - return (TRUE); // continue enumeration + return (TRUE); // Continue enumeration } // Detects the language of ntdll.dll with some specific processing for -// the Hongkong SAR version +// the Hong Kong SAR version LANGID GetNTDLLNativeLangID() { LANGINFO LangInfo; @@ -92,7 +91,7 @@ LANGID GetNTDLLNativeLangID() ZeroMemory(&LangInfo,sizeof(LangInfo)); - // Get the HModule for ntdll. + // Get the HModule for ntdll HMODULE hMod = GetModuleHandle(_T("ntdll.dll")); if (hMod==NULL) { @@ -108,7 +107,7 @@ LANGID GetNTDLLNativeLangID() return (LangInfo.LangID); } -// Checks if NT4 system is Hongkong SAR version +// Checks if NT4 system is Hong Kong SAR version BOOL IsHongKongVersion() { HMODULE hMod; @@ -147,24 +146,24 @@ LANGID DetectLanguage() switch( VersionInfo.dwPlatformId ) { - // On Windows NT, Windows 2000 or higher + // On Windows NT, Windows 2000, or higher case VER_PLATFORM_WIN32_NT: if( VersionInfo.dwMajorVersion >= 5) // Windows 2000 or higher { - // we need to dynamically link the GetUserDefaultUILanguage func + // We need to dynamically link the GetUserDefaultUILanguage function HMODULE hmKernDLL = LoadLibrary(_T("kernel32.dll")); if (hmKernDLL) { LANGID (*fpGetLang)() = NULL; fpGetLang = (LANGID(*)(void))GetProcAddress(hmKernDLL, "GetUserDefaultUILanguage"); uiLangID = fpGetLang(); - } // and if we couldn't load kernel32.dll, just fall back to default language + } // And if we couldn't load kernel32.dll, just fall back to default language } else - { // for NT4 check the language of ntdll.dll + { // For NT4 check the language of ntdll.dll uiLangID = GetNTDLLNativeLangID(); if (uiLangID == 1033) - { // special processing for Honkong SAR version of NT4 + { // Special processing for Hong Kong SAR version of NT4 if (IsHongKongVersion()) { uiLangID = 3076; @@ -172,7 +171,7 @@ LANGID DetectLanguage() } } break; - // On Windows 95, Windows 98 or Windows ME + // On Windows 95, Windows 98, or Windows ME case VER_PLATFORM_WIN32_WINDOWS: // Open the registry key for the UI language if( RegOpenKeyEx(HKEY_CURRENT_USER,_T("Default\\Control Panel\\Desktop\\ResourceLocale"), 0, @@ -197,6 +196,6 @@ LANGID DetectLanguage() { uiLangID = GetUserDefaultLangID(); } - // Return the found language ID. + // Return the found language ID return (uiLangID); } diff --git a/Source/nragev20/International.h b/Source/nragev20/International.h index 0edcde48a..5e185ab2f 100644 --- a/Source/nragev20/International.h +++ b/Source/nragev20/International.h @@ -1,24 +1,23 @@ /* - N-Rage`s Dinput8 Plugin - (C) 2002, 2006 Norbert Wladyka +N-Rage`s Dinput8 Plugin +(C) 2002, 2006 Norbert Wladyka - Author`s Email: norbert.wladyka@chello.at - Website: http://go.to/nrage +Author`s Email: norbert.wladyka@chello.at +Website: http://go.to/nrage +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the free Software Foundation; either version 2 of the License, or +(at your option) any later version. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the free Software Foundation; either version 2 of the License, or - (at your option) any later version. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include @@ -35,7 +34,7 @@ typedef struct LANGINFO_DEF } LANGINFO; typedef LANGINFO *PLANGINFO; -// only export these functions if UNICODE support is enabled +// Only export these functions if UNICODE support is enabled #ifdef _UNICODE LANGID DetectLanguage(); HMODULE LoadLanguageDLL(LANGID DesiredLanguage); diff --git a/Source/nragev20/NRagePluginV2.cpp b/Source/nragev20/NRagePluginV2.cpp index c83617fc5..99e214d54 100644 --- a/Source/nragev20/NRagePluginV2.cpp +++ b/Source/nragev20/NRagePluginV2.cpp @@ -1,24 +1,23 @@ /* - N-Rage`s Dinput8 Plugin - (C) 2002, 2006 Norbert Wladyka +N-Rage`s Dinput8 Plugin +(C) 2002, 2006 Norbert Wladyka - Author`s Email: norbert.wladyka@chello.at - Website: http://go.to/nrage +Author`s Email: norbert.wladyka@chello.at +Website: http://go.to/nrage +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the free Software Foundation; either version 2 of the License, or +(at your option) any later version. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the free Software Foundation; either version 2 of the License, or - (at your option) any later version. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include @@ -36,7 +35,7 @@ #include "International.h" #include "Version.h" -// ProtoTypes // +// Prototypes bool prepareHeap(); void FillControls(CONTROL * Controls); void InitiatePaks( bool bInitialize ); @@ -44,32 +43,32 @@ void DoShortcut( int iPlayer, int iShortcut ); DWORD WINAPI MsgThreadFunction( LPVOID lpParam ); DWORD WINAPI DelayedShortcut(LPVOID lpParam); -// Global Variables // +// Global Variables HMODULE g_hDirectInputDLL = NULL; // Handle to DirectInput8 library -HMODULE g_hXInputDLL = NULL; // Handle to XInput Library +HMODULE g_hXInputDLL = NULL; // Handle to XInput library HMODULE g_hResourceDLL = NULL; // Handle to resource library; used by LoadString for internationalization HANDLE g_hHeap = NULL; // Handle to our heap -int g_nDevices = 0; // number of devices in g_devList -DEVICE g_devList[MAX_DEVICES]; // list of attached input devices, except SysMouse - // note: we never purge the list of devices during normal operation -DEVICE g_sysMouse; // we need to treat the sysmouse differently, as we may use "locking"; changed from g_apInputDevice[1] --rabid +int g_nDevices = 0; // Number of devices in g_devList +DEVICE g_devList[MAX_DEVICES]; // List of attached input devices, except SysMouse + // Note: we never purge the list of devices during normal operation +DEVICE g_sysMouse; // We need to treat the sysmouse differently, as we may use "locking"; changed from g_apInputDevice[1] (comment by rabid) -EMULATOR_INFO g_strEmuInfo; // emulator info? Stores stuff like our hWnd handle and whether the plugin is initialized yet -TCHAR g_aszDefFolders[3][MAX_PATH]; // default folders: DIRECTORY_MEMPAK, DIRECTORY_GBROMS, DIRECTORY_GBSAVES -TCHAR g_aszLastBrowse[6][MAX_PATH]; // last browsed folders: BF_MEMPAK, BF_GBROM, BF_GBSAVE, BF_PROFILE, BF_NOTE, BF_SHORTCUTS +EMULATOR_INFO g_strEmuInfo; // Emulator info? Stores stuff like our hWnd handle and whether the plugin is initialized yet +TCHAR g_aszDefFolders[3][MAX_PATH]; // Default folders: DIRECTORY_MEMPAK, DIRECTORY_GBROMS, DIRECTORY_GBSAVES +TCHAR g_aszLastBrowse[6][MAX_PATH]; // Last browsed folders: BF_MEMPAK, BF_GBROM, BF_GBSAVE, BF_PROFILE, BF_NOTE, BF_SHORTCUTS -CRITICAL_SECTION g_critical; // our critical section semaphore +CRITICAL_SECTION g_critical; // Our critical section semaphore int g_iFirstController = -1; // The first controller which is plugged in // Normally controllers are scanned all at once in sequence, 1-4. We only want to scan devices once per pass; - // this is so we get consistent sample rates on our mouse. + // This is so we get consistent sample rates on our mouse bool g_bRunning = false; // Is the emulator running (i.e. have we opened a ROM)? bool g_bConfiguring = false; // Are we currently in a config menu? -bool g_bExclusiveMouse = true; // Do we have an exclusive mouse lock? defaults to true unless we have no bound mouse buttons/axes +bool g_bExclusiveMouse = true; // Do we have an exclusive mouse lock? This defaults to true unless we have no bound mouse buttons/axes. CONTROLLER g_pcControllers[4]; // Our four N64 controllers, connected or otherwise SHORTCUTS g_scShortcuts; -LPDIRECTINPUTDEVICE8 g_apFFDevice[4] = { NULL, NULL, NULL, NULL }; // added by rabid -LPDIRECTINPUTEFFECT g_apdiEffect[4] = { NULL, NULL, NULL, NULL }; // array of handles for FF-Effects, one for each controller +LPDIRECTINPUTDEVICE8 g_apFFDevice[4] = { NULL, NULL, NULL, NULL }; // Added by rabid +LPDIRECTINPUTEFFECT g_apdiEffect[4] = { NULL, NULL, NULL, NULL }; // Array of handles for FF-Effects, one for each controller TCHAR g_pszThreadMessage[DEFAULT_BUFFER] = _T(""); BOOL APIENTRY DllMain( HINSTANCE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) @@ -80,28 +79,28 @@ BOOL APIENTRY DllMain( HINSTANCE hModule, DWORD ul_reason_for_call, LPVOID lpRe DisableThreadLibraryCalls( hModule ); if( !prepareHeap()) return FALSE; - DebugWriteA("*** DLL Attach (" VER_FILE_VERSION_STR "-Debugbuild | built on " __DATE__ " at " __TIME__")\n"); + DebugWriteA("DLL attach (" VER_FILE_VERSION_STR "-Debugbuild | built on " __DATE__ " at " __TIME__")\n"); ZeroMemory( &g_strEmuInfo, sizeof(g_strEmuInfo) ); ZeroMemory( g_devList, sizeof(g_devList) ); ZeroMemory( &g_sysMouse, sizeof(g_sysMouse) ); ZeroMemory( g_aszDefFolders, sizeof(g_aszDefFolders) ); ZeroMemory( g_aszLastBrowse, sizeof(g_aszLastBrowse) ); g_strEmuInfo.hinst = hModule; - g_strEmuInfo.fDisplayShortPop = true; // display pak switching message windows by default + g_strEmuInfo.fDisplayShortPop = true; // Display pak switching message windows by default #ifdef _UNICODE { g_strEmuInfo.Language = GetLanguageFromINI(); if ( g_strEmuInfo.Language == 0 ) { g_strEmuInfo.Language = DetectLanguage(); - DebugWriteA("Autoselect language: %d\n", g_strEmuInfo.Language); + DebugWriteA("Auto select language: %d\n", g_strEmuInfo.Language); } - g_hResourceDLL = LoadLanguageDLL(g_strEmuInfo.Language); // HACK: it's theoretically not safe to call LoadLibraryEx from DllMain... --rabid + g_hResourceDLL = LoadLanguageDLL(g_strEmuInfo.Language); // HACK: it's theoretically not safe to call LoadLibraryEx from DllMain... (comment by rabid) if( g_hResourceDLL == NULL ) { g_strEmuInfo.Language = 0; g_hResourceDLL = hModule; - DebugWriteA("couldn't load language DLL, falling back to defaults\n"); + DebugWriteA("Couldn't load language DLL, falling back to defaults\n"); } } #else @@ -123,13 +122,13 @@ BOOL APIENTRY DllMain( HINSTANCE hModule, DWORD ul_reason_for_call, LPVOID lpRe if (g_hResourceDLL != g_strEmuInfo.hinst) FreeLibrary(g_hResourceDLL); // HACK: it's not safe to call FreeLibrary from DllMain... but screw it - DebugWriteA("*** DLL Detach\n"); + DebugWriteA("DLL detach\n"); CloseDebugFile(); // Moved here from CloseDll DeleteCriticalSection( &g_critical ); - // Moved here from CloseDll... Heap is created from DllMain, - // and now it's destroyed by DllMain... just safer code --rabid + // Moved here from CloseDll, then heap is created from DllMain, + // and now it's destroyed by DllMain...just safer code (comment by rabid) if( g_hHeap != NULL ) { HeapDestroy( g_hHeap ); @@ -141,33 +140,35 @@ BOOL APIENTRY DllMain( HINSTANCE hModule, DWORD ul_reason_for_call, LPVOID lpRe } -/****************************************************************** - Function: GetDllInfo - Purpose: This function allows the emulator to gather information - about the dll by filling in the PluginInfo structure. - input: a pointer to a PLUGIN_INFO stucture that needs to be - filled by the function. (see def above) - output: none -*******************************************************************/ +/* +Function: GetDllInfo +Purpose: This function allows the emulator to gather information +about the DLL by filling in the PluginInfo structure. +Input: a pointer to a PLUGIN_INFO structure that needs to be +filled by the function. (see def above) +Output: None +*/ + EXPORT void CALL GetDllInfo ( PLUGIN_INFO* PluginInfo ) { DebugWriteA("CALLED: GetDllInfo\n"); #ifdef _DEBUG - sprintf(PluginInfo->Name,"N-Rage For PJ64 (Debug): %s",VER_FILE_VERSION_STR); + sprintf(PluginInfo->Name,"N-Rage For Project64 (debug): %s",VER_FILE_VERSION_STR); #else - sprintf(PluginInfo->Name,"N-Rage For PJ64: %s",VER_FILE_VERSION_STR); + sprintf(PluginInfo->Name,"N-Rage For Project64: %s",VER_FILE_VERSION_STR); #endif PluginInfo->Type = PLUGIN_TYPE_CONTROLLER; PluginInfo->Version = SPECS_VERSION; } -/****************************************************************** - Function: DllAbout - Purpose: This function is optional function that is provided - to give further information about the DLL. - input: a handle to the window that calls this function - output: none -*******************************************************************/ +/* +Function: DllAbout +Purpose: This function is optional function that is provided +to give further information about the DLL. +Input: A handle to the window that calls this function +Output: None +*/ + EXPORT void CALL DllAbout ( HWND hParent ) { DebugWriteA("CALLED: DllAbout\n"); @@ -181,7 +182,7 @@ EXPORT void CALL DllAbout ( HWND hParent ) _T("Done by N-Rage\n") \ _T("\n") \ _T(" - - - - -\n") \ - _T("Transferpak emulation done by MadManMarkAu\n") \ + _T("Transfer pak emulation done by MadManMarkAu\n") \ _T("Cleanup, tweaks, and language support by RabidDeity\n"); LoadString( g_hResourceDLL, IDS_DLG_ABOUT, tszTranslator, DEFAULT_BUFFER ); @@ -192,13 +193,14 @@ EXPORT void CALL DllAbout ( HWND hParent ) return; } -/****************************************************************** - Function: DllConfig - Purpose: This function is optional function that is provided - to allow the user to configure the dll - input: a handle to the window that calls this function - output: none -*******************************************************************/ +/* +Function: DllConfig +Purpose: This function is optional function that is provided +to allow the user to configure the DLL +Input: A handle to the window that calls this function +Output: None +*/ + EXPORT void CALL DllConfig ( HWND hParent ) { DebugWriteA("CALLED: DllConfig\n"); @@ -222,8 +224,8 @@ EXPORT void CALL DllConfig ( HWND hParent ) { if (!InitXinput()) { - //TODO Disable ability to set XInput - //TODO Make XInput and DirectInput settings same page + // TODO: Disable ability to set XInput + // TODO: Make XInput and DirectInput settings same page } } @@ -234,12 +236,12 @@ EXPORT void CALL DllConfig ( HWND hParent ) { INITCOMMONCONTROLSEX ccCtrls = { sizeof(INITCOMMONCONTROLSEX), ICC_BAR_CLASSES | ICC_TAB_CLASSES | ICC_LISTVIEW_CLASSES }; - InitCommonControlsEx( &ccCtrls ); // needed for TrackBars & Tabs + InitCommonControlsEx( &ccCtrls ); // Needed for TrackBars and Tabs } EnterCriticalSection( &g_critical ); if( g_sysMouse.didHandle ) - { // unlock mouse while configuring + { // Unlock mouse while configuring g_sysMouse.didHandle->SetCooperativeLevel( g_strEmuInfo.hMainWindow, DIB_DEVICE ); g_sysMouse.didHandle->Acquire(); } @@ -247,24 +249,24 @@ EXPORT void CALL DllConfig ( HWND hParent ) int iOK = DialogBox(g_hResourceDLL, MAKEINTRESOURCE(IDD_MAINCFGDIALOG), hParent, (DLGPROC)MainDlgProc); - // If we go into the dialog box, and the user navigates to the Rumble window, our FF device can get unacquired. - // So let's reinit them now if we're running, just to be safe --rabid + // If we go into the dialog box, and the user navigates to the rumble window, our FF device can get unacquired. + // So let's reinitialize them now if we're running, just to be safe (comment by rabid) if( g_bRunning ) { EnterCriticalSection( &g_critical ); // PrepareInputDevices resets g_bExclusiveMouse to false if no mouse keys are bound, and the only way to // re-enable exclusive mouse is with a shortcut. - // This is undesirable behavior, but it beats the alternative (and we REALLY need to re-init FF devices here) + // This is undesirable behavior, but it beats the alternative (and we REALLY need to re-initialize FF devices here) PrepareInputDevices(); if (iOK) { - InitiatePaks( false ); // only re-init the mempaks and such if the user clicked Save or Use + InitiatePaks( false ); // only re-initialize the memory paks and such if the user clicked save or use } if( g_sysMouse.didHandle ) { if ( g_bExclusiveMouse ) - { // if we have exclusive mouse, we need to relock mouse after closing the config + { // If we have exclusive mouse, we need to relock mouse after closing the config g_sysMouse.didHandle->SetCooperativeLevel( g_strEmuInfo.hMainWindow, DIB_MOUSE ); g_sysMouse.didHandle->Acquire(); if (g_strEmuInfo.fDisplayShortPop) @@ -289,13 +291,14 @@ EXPORT void CALL DllConfig ( HWND hParent ) return; } -/****************************************************************** - Function: DllTest - Purpose: This function is optional function that is provided - to allow the user to test the dll - input: a handle to the window that calls this function - output: none -*******************************************************************/ +/* +Function: DllTest +Purpose: This function is optional function that is provided +to allow the user to test the DLL +Input: A handle to the window that calls this function +Output: None +*/ + EXPORT void CALL DllTest ( HWND hParent ) { DebugWriteA("CALLED: DllTest\n"); @@ -303,16 +306,17 @@ EXPORT void CALL DllTest ( HWND hParent ) } // It's easier to maintain one version of this, as not much really changes -// between versions. --rabid +// between versions (comment by rabid) + +/* +Function: InitiateControllers +Purpose: This function initializes how each of the controllers +should be handled. +Input: A controller structure that needs to be filled for +the emulator to know how to handle each controller. +Output: None +*/ -/****************************************************************** - Function: InitiateControllers - Purpose: This function initialises how each of the controllers - should be handled. - input: - A controller structure that needs to be filled for - the emulator to know how to handle each controller. - output: none -*******************************************************************/ EXPORT void CALL InitiateControllers( #if (SPECS_VERSION < 0x0101) void * hMainWindow, CONTROL Controls[4] @@ -345,9 +349,9 @@ EXPORT void CALL InitiateControllers( #endif // UNDONE: Instead of just storing the header, figure out what ROM we're running and save that information somewhere - // The emulator expects us to tell what controllers are plugged in and what their paks are at this point. + // The emulator expects us to tell what controllers are plugged in and what their paks are at this point - if( !g_pDIHandle ) // if we don't have a directinput handle, we need to make one, attach it to the main window (so it will die if our emulator dies), and enumerate devices + if( !g_pDIHandle ) // If we don't have a DirectInput handle, we need to make one, attach it to the main window (so it will die if our emulator dies), and enumerate devices { if( InitDirectInput( g_strEmuInfo.hMainWindow )) { @@ -365,26 +369,26 @@ EXPORT void CALL InitiateControllers( { if (!InitXinput()) { - //TODO Disable ability to set XInput - //TODO Make XInput and DirectInput settings same page + // TODO: Disable ability to set XInput + // TODO: Make XInput and DirectInput settings same page } } - //To handle XInput controllers better, we need to set id to 0 + // To handle XInput controllers better, we need to set ID to 0 iXinputControlId = 0; int iDevice; EnterCriticalSection( &g_critical ); - // ZeroMemory( g_apFFDevice, sizeof(g_apFFDevice) ); // NO, we'll reinit the existing reference if it's already loaded - // ZeroMemory( g_apdiEffect, sizeof(g_apdiEffect) ); // NO, we'll release it with CloseControllerPak + // ZeroMemory( g_apFFDevice, sizeof(g_apFFDevice) ); // No, we'll reinitialize the existing reference if it's already loaded + // ZeroMemory( g_apdiEffect, sizeof(g_apdiEffect) ); // No, we'll release it with CloseControllerPak for( int i = 3; i >= 0; i-- ) { SaveControllerPak( i ); CloseControllerPak( i ); - // freePakData( &g_pcControllers[i] ); // already called by CloseControllerPak + // freePakData( &g_pcControllers[i] ); // Already called by CloseControllerPak freeModifiers( &g_pcControllers[i] ); SetControllerDefaults( &g_pcControllers[i] ); } @@ -399,7 +403,7 @@ EXPORT void CALL InitiateControllers( LoadShortcutsFromResource(false); } - // Init: Find force-feedback devices and init + // Init: Find force feedback devices and initialize for( int i = 0; i < 4; i++ ) { DebugWriteA("Controller %d: ", i+1); @@ -412,28 +416,28 @@ EXPORT void CALL InitiateControllers( //continue; } - // Search for right Controller + // Search for right controller iDevice = FindDeviceinList( g_pcControllers[i].guidFFDevice ); if( iDevice != -1 && g_devList[iDevice].bEffType ) { - DebugWriteA("rumble device set, "); + DebugWriteA("Rumble device set, "); } - else // we couldn't find the device specified in the INI file, or it was already null + else // We couldn't find the device specified in the INI file, or it was already null { g_pcControllers[i].guidFFDevice = GUID_NULL; - DebugWriteA("no rumble device/effect type set, "); + DebugWriteA("No rumble device/effect type set, "); } if( g_pcControllers[i].nModifiers > 0) SetModifier( &g_pcControllers[i] ); g_iFirstController = i; - DebugWriteA("plugged in, with paktype %d, ", g_pcControllers[i].PakType); + DebugWriteA("Plugged in, with pak type %d, ", g_pcControllers[i].PakType); DebugWriteA("RawMode is %d\n", g_pcControllers[i].fRawData); } else { - DebugWriteA("unplugged\n"); - freePakData( &g_pcControllers[i] ); // we don't need to do this again, but there's not much overhead so I'll leave it --rabid + DebugWriteA("Unplugged\n"); + freePakData( &g_pcControllers[i] ); // We don't need to do this again, but there's not much overhead so I'll leave it (comment by rabid) freeModifiers( &g_pcControllers[i] ); } } @@ -457,18 +461,19 @@ EXPORT void CALL InitiateControllers( return; } // end InitiateControllers -/****************************************************************** - Function: RomOpen - Purpose: This function is called when a rom is open. (from the - emulation thread) - input: none - output: none -*******************************************************************/ +/* +Function: RomOpen +Purpose: This function is called when a ROM is open (from the +emulation thread) +Input: None +Output: None +*/ + EXPORT void CALL RomOpen (void) { DebugWriteA("CALLED: RomOpen\n"); - //XInputEnable( TRUE ); // enables xinput --tecnicors + //XInputEnable( TRUE ); // Enables XInput (comment by tecnicors) if( !g_strEmuInfo.fInitialisedPlugin ) { @@ -477,25 +482,26 @@ EXPORT void CALL RomOpen (void) } EnterCriticalSection( &g_critical ); - // re-init our paks and shortcuts + // Re-initialize our paks and shortcuts InitiatePaks( true ); - // LoadShortcuts( &g_scShortcuts ); WHY are we loading shortcuts again?? Should already be loaded! + // LoadShortcuts( &g_scShortcuts ); Why are we loading shortcuts again? They should already be loaded! LeaveCriticalSection( &g_critical ); g_bRunning = true; return; } -/****************************************************************** - Function: RomClosed - Purpose: This function is called when a rom is closed. - input: none - output: none -*******************************************************************/ +/* +Function: RomClosed +Purpose: This function is called when a ROM is closed +Input: None +Output: None +*/ + EXPORT void CALL RomClosed(void) { int i; - //XInputEnable( FALSE ); // disables xinput --tecnicors + //XInputEnable( FALSE ); // Disables XInput (comment by tecnicors) DebugWriteA("CALLED: RomClosed\n"); EnterCriticalSection( &g_critical ); @@ -503,7 +509,7 @@ EXPORT void CALL RomClosed(void) if (g_sysMouse.didHandle) { g_sysMouse.didHandle->Unacquire(); - g_sysMouse.didHandle->SetCooperativeLevel(g_strEmuInfo.hMainWindow, DIB_KEYBOARD); // unlock the mouse, just in case + g_sysMouse.didHandle->SetCooperativeLevel(g_strEmuInfo.hMainWindow, DIB_KEYBOARD); // Unlock the mouse, just in case } for( i = 0; i < ARRAYSIZE(g_pcControllers); ++i ) @@ -513,8 +519,8 @@ EXPORT void CALL RomClosed(void) SaveControllerPak( i ); CloseControllerPak( i ); } - // freePakData( &g_pcControllers[i] ); already done by CloseControllerPak --rabid - // DON'T free the modifiers! + // freePakData( &g_pcControllers[i] ); // Already done by CloseControllerPak (comment by rabid) + // Don't free the modifiers! // ZeroMemory( &g_pcControllers[i], sizeof(CONTROLLER) ); } @@ -528,14 +534,15 @@ EXPORT void CALL RomClosed(void) return; } -/****************************************************************** - Function: GetKeys - Purpose: To get the current state of the controllers buttons. - input: - Controller Number (0 to 3) - - A pointer to a BUTTONS structure to be filled with - the controller state. - output: none -*******************************************************************/ +/* +Function: GetKeys +Purpose: To get the current state of the controllers buttons. +Input: Controller Number (0 to 3) +A pointer to a BUTTONS structure to be filled with +the controller state. +Output: None +*/ + EXPORT void CALL GetKeys(int Control, BUTTONS * Keys ) { #ifdef ENABLE_RAWPAK_DEBUG @@ -554,7 +561,7 @@ EXPORT void CALL GetKeys(int Control, BUTTONS * Keys ) GetDeviceDatas(); CheckShortcuts(); } - if( g_pcControllers[Control].fXInput ) // reads the xinput controller keys, if connected --tecnicors + if( g_pcControllers[Control].fXInput ) // Reads the XInput controller keys, if connected (comment by tecnicors) GetXInputControllerKeys( Control, &Keys->Value ); else GetNControllerInput( Control, &Keys->Value ); @@ -564,22 +571,22 @@ EXPORT void CALL GetKeys(int Control, BUTTONS * Keys ) return; } -/****************************************************************** - Function: ControllerCommand - Purpose: To process the raw data that has just been sent to a - specific controller. - input: - Controller Number (0 to 3) and -1 signalling end of - processing the pif ram. - - Pointer of data to be processed. - output: none +/* +Function: ControllerCommand +Purpose: To process the raw data that has just been sent to a +specific controller. +Input: Controller Number (0 to 3) and -1 signaling end of +processing the PIF RAM. +- Pointer of data to be processed. +Output: None - note: This function is only needed if the DLL is allowing raw - data. +Note: This function is only needed if the DLL is allowing raw +data. +The data that is being processed looks like this: +Initialize controller: 01 03 00 FF FF FF +Read controller: 01 04 01 FF FF FF FF +*/ - the data that is being processed looks like this: - initilize controller: 01 03 00 FF FF FF - read controller: 01 04 01 FF FF FF FF -*******************************************************************/ EXPORT void CALL ControllerCommand( int Control, BYTE * Command) { // We don't need to use this because it will be echoed immediately afterwards @@ -587,17 +594,18 @@ EXPORT void CALL ControllerCommand( int Control, BYTE * Command) return; } -/****************************************************************** - Function: ReadController - Purpose: To process the raw data in the pif ram that is about to - be read. - input: - Controller Number (0 to 3) and -1 signalling end of - processing the pif ram. - - Pointer of data to be processed. - output: none - note: This function is only needed if the DLL is allowing raw - data. -*******************************************************************/ +/* +Function: ReadController +Purpose: To process the raw data in the PIF RAM that is about to +be read. +Input: - Controller Number (0 to 3) and -1 signaling end of +processing the PIF RAM. +- Pointer of data to be processed. +Output: None +Note: This function is only needed if the DLL is allowing raw +data. +*/ + EXPORT void CALL ReadController( int Control, BYTE * Command ) { #ifdef ENABLE_RAWPAK_DEBUG @@ -621,8 +629,8 @@ EXPORT void CALL ReadController( int Control, BYTE * Command ) case RD_RESETCONTROLLER: WriteDatasA( "ResetController-PreProcessing", Control, Command, 0); case RD_GETSTATUS: - // expected: controller gets 1 byte (command), controller sends back 3 bytes - // should be: Command[0] == 0x01 + // Expected: controller gets 1 byte (command), controller sends back 3 bytes + // Should be: Command[0] == 0x01 // Command[1] == 0x03 #ifdef ENABLE_RAWPAK_DEBUG WriteDatasA( "GetStatus-PreProcessing", Control, Command, 0); @@ -630,7 +638,7 @@ EXPORT void CALL ReadController( int Control, BYTE * Command ) Command[3] = RD_GAMEPAD | RD_ABSOLUTE; Command[4] = RD_NOEEPROM; - if (g_pcControllers[Control].fN64Mouse) // Is Controller a mouse? + if (g_pcControllers[Control].fN64Mouse) // Is controller a mouse? Command[3] = RD_RELATIVE; if( g_pcControllers[Control].fPakInitialized && g_pcControllers[Control].pPakData ) @@ -683,10 +691,9 @@ EXPORT void CALL ReadController( int Control, BYTE * Command ) break; case RD_READKEYS: - // expected: controller gets 1 byte (command), controller sends back 4 bytes - // should be: Command[0] == 0x01 + // Expected: controller gets 1 byte (command), controller sends back 4 bytes + // Should be: Command[0] == 0x01 // Command[1] == 0x04 - if( g_bConfiguring || (!g_pcControllers[Control].bBackgroundInput && GetForegroundWindow() != g_strEmuInfo.hMainWindow) ) Command[3] = Command[4] = Command[5] = Command[6] = 0; else @@ -696,7 +703,7 @@ EXPORT void CALL ReadController( int Control, BYTE * Command ) GetDeviceDatas(); CheckShortcuts(); } - if( g_pcControllers[Control].fXInput ) // reads xinput controller kesy, if connected --tecnicors + if( g_pcControllers[Control].fXInput ) // Reads XInput controller keys, if connected (comment by tecnicors) GetXInputControllerKeys( Control, (LPDWORD)&Command[3] ); else GetNControllerInput( Control, (DWORD*)&Command[3] ); @@ -711,7 +718,7 @@ EXPORT void CALL ReadController( int Control, BYTE * Command ) ReadControllerPak( Control, &Command[3] ); else { - DebugWriteA("Tried to read, but pak wasn't initialized!!\n"); + DebugWriteA("Tried to read, but pak wasn't initialized!\n"); // InitControllerPak( Control ); Command[1] |= RD_ERROR; //ZeroMemory( &Command[5], 32 ); @@ -730,7 +737,7 @@ EXPORT void CALL ReadController( int Control, BYTE * Command ) WriteControllerPak( Control, &Command[3] ); else { - DebugWriteA("Tried to write, but pak wasn't initialized! (paktype was %u)\n", g_pcControllers[Control].PakType); + DebugWriteA("Tried to write, but pak wasn't initialized! (pak type was %u)\n", g_pcControllers[Control].PakType); // InitControllerPak( Control ); Command[1] |= RD_ERROR; } @@ -740,19 +747,19 @@ EXPORT void CALL ReadController( int Control, BYTE * Command ) #endif break; case RD_READEEPROM: - // Should be handled by the Emulator + // Should be handled by the emulator WriteDatasA( "ReadEeprom-PreProcessing", Control, Command, 0); WriteDatasA( "ReadEeprom-PostProcessing", Control, Command, 0); DebugWriteA( NULL ); break; case RD_WRITEEPROM: - // Should be handled by the Emulator + // Should be handled by the emulator WriteDatasA( "WriteEeprom-PreProcessing", Control, Command, 0); WriteDatasA( "WriteEeprom-PostProcessing", Control, Command, 0); DebugWriteA( NULL ); break; default: - // only accessible if the Emulator has bugs.. or maybe the Rom is flawed + // Only accessible if the emulator has bugs, or maybe the ROM is flawed in some way WriteDatasA( "ReadController: Bad read", Control, Command, 0); DebugWriteA( NULL ); Command[1] = Command[1] | RD_ERROR; @@ -762,39 +769,42 @@ EXPORT void CALL ReadController( int Control, BYTE * Command ) return; } -/****************************************************************** - Function: WM_KeyDown - Purpose: To pass the WM_KeyDown message from the emulator to the - plugin. - input: wParam and lParam of the WM_KEYDOWN message. - output: none -*******************************************************************/ +/* +Function: WM_KeyDown +Purpose: To pass the WM_KeyDown message from the emulator to the +plugin. +Input: wParam and lParam of the WM_KEYDOWN message. +Output: None +*/ + EXPORT void CALL WM_KeyDown( WPARAM wParam, LPARAM lParam ) { return; } -/****************************************************************** - Function: WM_KeyUp - Purpose: To pass the WM_KEYUP message from the emulator to the - plugin. - input: wParam and lParam of the WM_KEYDOWN message. - output: none -*******************************************************************/ +/* +Function: WM_KeyUp +Purpose: To pass the WM_KEYUP message from the emulator to the +plugin. +Input: wParam and lParam of the WM_KEYDOWN message. +Output: None +*/ + EXPORT void CALL WM_KeyUp( WPARAM wParam, LPARAM lParam ) { return; } -/****************************************************************** - Function: CloseDLL - Purpose: This function is called when the emulator is closing - down allowing the dll to de-initialise. - input: none - output: none -*******************************************************************/ +/* +Function: CloseDLL +Purpose: This function is called when the emulator is closing +down allowing the DLL to de-initialize. +Input: None +Output: None +*/ + EXPORT void CALL CloseDLL (void) -{ // HACK: THIS IS BROKEN IN PJ64 1.6 (it calls CloseDLL too often) +{ // Hack: This is broken in Project64 1.6 (it calls CloseDLL too often) DebugWriteA("CALLED: CloseDLL\n"); if( g_bRunning ) RomClosed(); @@ -804,14 +814,14 @@ EXPORT void CALL CloseDLL (void) freeModifiers( &g_pcControllers[i] ); } - // ZeroMemory( g_pcControllers, sizeof(g_pcControllers) ); // why zero the memory if we're just going to close down? + // ZeroMemory( g_pcControllers, sizeof(g_pcControllers) ); // Why zero the memory if we're just going to close down? FreeDirectInput(); FreeXinput(); return; } -// Prepare a global heap. Use P_malloc and P_free as wrappers to grab/release memory. +// Prepare a global heap. Use P_malloc and P_free as wrappers to grab/release memory. bool prepareHeap() { if( g_hHeap == NULL ) @@ -819,7 +829,7 @@ bool prepareHeap() return (g_hHeap != NULL); } -// Frees pakdata memory (called more often than you'd think). +// Frees pak data memory (called more often than you'd think) void freePakData( CONTROLLER *pcController ) { if( pcController && pcController->pPakData ) @@ -880,10 +890,11 @@ int FindDeviceinList( REFGUID rGUID ) return -1; } -// Let's initialize all plugged in controllers' paks. -// Input: false means run InitControlPak on each plugged controller. Input true means just clear each pak's CRC error status? +// Let's initialize all connected controller paks. +// Input: false means run InitControlPak on each plugged controller. Input true means just clear each paks CRC error status? // When we call this from RomOpen, it's true, otherwise (in DllConfig) it's false. // Rather counterintuitive. + void InitiatePaks( bool bInitialize ) { for( int i = 0; i < 4; i++ ) @@ -898,7 +909,7 @@ void InitiatePaks( bool bInitialize ) g_pcControllers[i].fPakInitialized = InitControllerPak( i ); } else - { // we only support "RAW mode" paks so this won't do much + { // We only support "raw mode" paks so this won't do much ;//if( g_pcControllers[i].PakType == PAK_RUMBLE ) // CreateEffectHandle( i, g_pcControllers[i].bRumbleTyp, g_pcControllers[i].bRumbleStrength ); } @@ -907,9 +918,9 @@ void InitiatePaks( bool bInitialize ) } // This used to be "NotifyEmulator" which was supposed to tell the emulator if we changed the way it sees controllers. -// Unfortunately the spec doesn't work that way. Fixed the func and changed the func name to something that makes more sense. +// Unfortunately the spec doesn't work that way. Fixed the function and changed the function name to something that makes more sense. // FillControls takes a Controls array from InitiateControllers and fills it with what we know about whether -// a controller is plugged in, accepting raw data, and what type of pak is plugged in. +// a controller is plugged in, accepting raw data, and what type of pak is plugged in. void FillControls(CONTROL * Controls) { for( int i = 4-1; i >= 0; i-- ) @@ -952,18 +963,18 @@ void FillControls(CONTROL * Controls) } } -// called after a poll to execute any shortcuts +// Called after a poll to execute any shortcuts void CheckShortcuts() { static bool bWasPressed[ sizeof(SHORTCUTSPL)/sizeof(BUTTON) ][4]; - static bool bMLWasPressed; // mouselock + static bool bMLWasPressed; // Mouselock bool bMatching = false; if ( g_bConfiguring || !g_bRunning ) - return; // we don't process shortcuts if we're in a config menu or are not running emulation + return; // We don't process shortcuts if we're in a config menu or are not running emulation - // just process if key wasnt pressed before - for ( int i = 0; i < 4; i++ ) // controllers + // just process if key wasn't pressed before + for ( int i = 0; i < 4; i++ ) // Controllers { for( int j = 0; j < SC_TOTAL; j++ ) { @@ -979,7 +990,7 @@ void CheckShortcuts() bMatching = IsBtnPressed( g_scShortcuts.bMouseLock ); if( bMatching && !bMLWasPressed ) - DoShortcut(-1, -1); // controller -1 means do mouselock shortcut + DoShortcut(-1, -1); // Controller -1 means do mouselock shortcut bMLWasPressed = bMatching; } @@ -1150,9 +1161,9 @@ void DoShortcut( int iControl, int iShortcut ) } // switch (iShortcut) } // else if - // let the game code re-init the pak. + // Let the game code re-initialize the pak - if (bEjectFirst) // we need to eject the current pack first; then set a DoShortcut to try again in 1 second + if (bEjectFirst) // We need to eject the current pack first; then set a DoShortcut to try again in 1 second { EnterCriticalSection( &g_critical ); g_pcControllers[iControl].PakType = PAK_NONE; @@ -1166,7 +1177,7 @@ void DoShortcut( int iControl, int iShortcut ) lpmNextShortcut->iControl = iControl; lpmNextShortcut->iShortcut = iShortcut; CreateThread(NULL, 0, DelayedShortcut, lpmNextShortcut, 0, NULL); - iControl = -2; // this is just a hack to get around the check that appends "Changing Pak X to ..." + iControl = -2; // This is just a hack to get around the check that appends "Changing pak X to..." } if( g_strEmuInfo.fDisplayShortPop && _tcslen(pszMessage) > 0 ) @@ -1187,11 +1198,12 @@ void DoShortcut( int iControl, int iShortcut ) // Use string table refs to generate and throw an error message with title IDS_ERR_TITLE (see string table in resources) // Also if compiled with DEBUG, will log the message with DebugWrite -// uID the string table ref to display -// dwError if nonzero, will display a Windows error message using FormatMessage (for use when an API function fails) -// fUserChoose if true, display buttons Retry and Cancel. if false, display single button OK. -// for fUserChoose==true; ErrorMessage returns true if user selects Retry, and false if user selects Cancel. -// for fUserChoose==false; ErrorMessage always returns false. +// uID - The string table ref to display +// dwError - If nonzero, will display a Windows error message using FormatMessage (for use when an API function fails) +// fUserChoose - If true, display buttons Retry and Cancel. If false, display single button OK. +// for fUserChoose==true; ErrorMessage returns true if user selects Retry, and false if user selects Cancel. +// for fUserChoose==false; ErrorMessage always returns false. + bool ErrorMessage( UINT uID, DWORD dwError, bool fUserChoose ) { TCHAR pszFirstLine[DEFAULT_BUFFER]; @@ -1239,16 +1251,18 @@ int WarningMessage( UINT uTextID, UINT uType ) } -/* H.Morii - MsgThreadFunction is used because the SetTimer function relies - on the WM_TIMER message which is low priority and will not be - executed if other windows messages are frequently dispatched. */ +/* +H.Morii +MsgThreadFunction is used because the SetTimer function relies +on the WM_TIMER message which is low priority and will not be +executed if other windows messages are frequently dispatched. +*/ DWORD WINAPI MsgThreadFunction( LPVOID lpParam ) { HWND hMessage = CreateWindowEx( WS_EX_NOPARENTNOTIFY | WS_EX_STATICEDGE | WS_EX_TOPMOST, _T("STATIC"), NULL, WS_CHILD | WS_VISIBLE, 10, 10, 200, 40, g_strEmuInfo.hMainWindow, NULL, g_strEmuInfo.hinst, NULL ); - /* prepare the screen to bitblt */ + // Prepare the screen to bitblt RECT rt; GetClientRect(hMessage, &rt); HDC hdc = GetDC(hMessage); @@ -1256,24 +1270,23 @@ DWORD WINAPI MsgThreadFunction( LPVOID lpParam ) HBITMAP hbitmap = CreateCompatibleBitmap(hdc, rt.right - rt.left, rt.bottom - rt.top); SelectObject(memdc, hbitmap); - /* draw some nice stuff. - choose fonts, paint the back ground, etc here. */ + // Draw some things here, like choosing fonts, painting the background, etc. here FillRect(memdc, &rt, (HBRUSH)(COLOR_WINDOW+1)); DrawText(memdc, (LPCTSTR)lpParam, -1, &rt, DT_WORDBREAK); - /* bitblt to kingdom come */ + // bitblt to kingdom come for (int i = 0; i < 60; i++) { Sleep(16); // 1/60 second BitBlt(hdc, rt.left, rt.top, rt.right - rt.left, rt.bottom - rt.top, memdc, 0, 0, SRCCOPY); } - /* cleanup */ + // Cleanup DeleteObject(hbitmap); DeleteDC(memdc); ReleaseDC(hMessage, hdc); - /* Can only destroy windows created from the owner thread */ + // Can only destroy windows created from the owner thread DestroyWindow(hMessage); return 0; @@ -1284,9 +1297,9 @@ DWORD WINAPI MsgThreadFunction( LPVOID lpParam ) DWORD WINAPI DelayedShortcut(LPVOID lpParam) { LPMSHORTCUT sc = (LPMSHORTCUT)lpParam; - if (sc && sc->iShortcut != SC_SWMEMRUMB && sc->iShortcut != SC_SWMEMADAPT) // don't allow recursion into self, it would cause a deadlock + if (sc && sc->iShortcut != SC_SWMEMRUMB && sc->iShortcut != SC_SWMEMADAPT) // Don't allow recursion into self, it would cause a deadlock { - Sleep(1000); // sleep a little bit before calling DoShortcut again + Sleep(1000); // Sleep a little bit before calling DoShortcut again DoShortcut(sc->iControl, sc->iShortcut); } P_free(lpParam); diff --git a/Source/nragev20/NRagePluginV2.h b/Source/nragev20/NRagePluginV2.h index 089868063..cffc1bcda 100644 --- a/Source/nragev20/NRagePluginV2.h +++ b/Source/nragev20/NRagePluginV2.h @@ -1,24 +1,24 @@ /* - N-Rage`s Dinput8 Plugin - (C) 2002, 2006 Norbert Wladyka +N-Rage`s Dinput8 Plugin +(C) 2002, 2006 Norbert Wladyka - Author`s Email: norbert.wladyka@chello.at - Website: http://go.to/nrage +Author`s Email: norbert.wladyka@chello.at +Website: http://go.to/nrage - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the free Software Foundation; either version 2 of the License, or - (at your option) any later version. +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the free Software Foundation; either version 2 of the License, or +(at your option) any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ +You should have received a copy of the GNU General Public License +along with this program; if not, write to the free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ #ifndef _NRAGEPLUGIN_ #define _NRAGEPLUGIN_ @@ -27,14 +27,13 @@ #include "XInputController.h" -///////////////////////////////////////////////////////////////////////////////// -//General Plugin +// General plugin #define TIMER_MESSAGEWINDOW 123 -// maximum number of devices other than SysMouse +// Maximum number of devices other than SysMouse #define MAX_DEVICES 32 -// maximum number of modifiers +// Maximum number of modifiers #define MAX_MODIFIERS 256 #define DEFAULT_STICKRANGE 66 @@ -52,7 +51,7 @@ #define PAK_VOICE 4 #define PAK_ADAPTOID 7 -// just used to display text in GUI +// Just used to display text in GUI #define PAK_NONRAW 16 typedef struct _EMULATOR_INFO @@ -61,21 +60,20 @@ typedef struct _EMULATOR_INFO HWND hMainWindow; HINSTANCE hinst; LANGID Language; - bool fDisplayShortPop; // do we display shortcut message popups? + bool fDisplayShortPop; // Do we display shortcut message popups? /* - * 2015.11.09 cxd4 - * Added to keep the real address of the CONTROL array stored. - * - * This became necessary due to conflicts between specs #1.0, #1.1 and #1.2. - */ +11/09/2015 Comment by cxd4 +Added to keep the real address of the CONTROL array stored. +This became necessary due to conflicts between specs #1.0, #1.1 and #1.2. +*/ + CONTROL * controllers; - // BOOL MemoryBswaped; // If this is set to TRUE, then the memory has been pre - // bswap on a dword (32 bits) boundry, only effects header. + // BOOL MemoryBswaped; // If this is set to TRUE, then the memory has been pre-bswap'd on a DWORD (32-bit) boundary, only effects header. // eg. the first 8 bytes are stored like this: - // 4 3 2 1 8 7 6 5 - // BYTE * HEADER; // This is the rom header (first 40h bytes of the rom) + // 4 3 2 1 8 7 6 5 + // BYTE * HEADER; // This is the ROM header (first 40h bytes of the ROM) } EMULATOR_INFO, *LPEMULATOR_INFO; typedef struct _DEVICE @@ -84,13 +82,13 @@ typedef struct _DEVICE TCHAR szProductName[MAX_PATH]; BYTE bProductCounter; GUID guidInstance; - DWORD dwDevType; // can be DI8DEVTYPE_KEYBOARD, DI8DEVTYPE_MOUSE, etc + DWORD dwDevType; // Can be DI8DEVTYPE_KEYBOARD, DI8DEVTYPE_MOUSE, etc. BYTE bEffType; // What rumble effects does this device support? - union INPUTSTATE // the last polled data from this device + union INPUTSTATE // The last polled data from this device { DIJOYSTATE joyState; DIMOUSESTATE2 mouseState; - BYTE rgbButtons[256]; // keyboard state + BYTE rgbButtons[256]; // Keyboard state } stateAs; } DEVICE, *LPDEVICE; @@ -98,19 +96,19 @@ typedef struct _BUTTON { bool fPrevPressed; // Was this button pressed last time we checked? (not to be saved in config) BYTE bOffset; // Offset in the DirectInput data structure - BYTE bAxisID; // Tells which range of the Axe/POV is important (see AI_AXE_P, AI_POV_UP, etc) - BYTE bBtnType; // Type of device/button: Keyboard key, Joystick axis, Joystick button, Mouse axis, etc - LPDEVICE parentDevice; // pointer to the DEVICE this assignment came from + BYTE bAxisID; // Tells which range of the Axe/POV is important (see AI_AXE_P, AI_POV_UP, etc.) + BYTE bBtnType; // Type of device/button: keyboard key, joystick axis, joystick button, mouse axis, etc. + LPDEVICE parentDevice; // Pointer to the DEVICE this assignment came from } BUTTON, *LPBUTTON; -// Modifiers are a feature built into NRage. Emulator turbo buttons, macros, stuff like that. +// Modifiers are a feature built into N-Rage. Emulator turbo buttons, macros, stuff like that. typedef struct _MODIFIER { - BUTTON btnButton; // button to associate with + BUTTON btnButton; // Button to associate with BYTE bModType; // Type of modifier (None, Movement, Macro, Config) - BOOL fToggle; // false if you have to hold the button down to activate, true if the modifier toggles on button press - BOOL fStatus; // if true, control defaults to ACTIVE, and deactivates on button press - DWORD32 dwSpecific; // will be cast to MODSPEC_MOVE, MODSPEC_MACRO, or MODSPEC_CONFIG + BOOL fToggle; // False if you have to hold the button down to activate, true if the modifier toggles on button press + BOOL fStatus; // If true, control defaults to ACTIVE, and deactivates on button press + DWORD32 dwSpecific; // Will be cast to MODSPEC_MOVE, MODSPEC_MACRO, or MODSPEC_CONFIG } MODIFIER, *LPMODIFIER; // bModType (modifiers) @@ -119,58 +117,57 @@ typedef struct _MODIFIER #define MDT_MACRO 2 #define MDT_CONFIG 3 -// buffered +// Buffered #define MM_BUFF 0 -// absolute +// Absolute #define MM_ABS 1 -// deadpan +// Deadpan #define MM_DEAD 2 -// Number of analog axes. Standard N64 controller has just 2: X and Y joystick. +// Number of analog axes. Standard N64 controller has just 2: X and Y joystick. #define PF_AXESETS 2 -typedef struct _CONTROLLER // AN N64 CONTROLLER +typedef struct _CONTROLLER // An N64 controller { - unsigned fPlugged; // is the controller "plugged" (i.e. does the emulator see a controller on this port?) - unsigned fXInput; // is the controller an xInput device? - unsigned fN64Mouse; // is the controller a N64 Mouse (Relative)? - unsigned fRawData; // are we using RAW mode for this controller? - unsigned fIsAdaptoid; // is it an adaptoid? + unsigned fPlugged; // Is the controller "plugged" / connected? (i.e. does the emulator see a controller on this port?) + unsigned fXInput; // Is the controller an XInput device? + unsigned fN64Mouse; // Is the controller an N64 mouse (relative)? + unsigned fRawData; // Are we using raw mode for this controller? + unsigned fIsAdaptoid; // Is it an Adaptoid? - unsigned fKeyboard; // does it use a keyboard? - unsigned fMouse; // does it use a mouse? - unsigned fGamePad; // does it use a gamepad/joystick? + unsigned fKeyboard; // Does it use a keyboard? + unsigned fMouse; // Does it use a mouse? + unsigned fGamePad; // Does it use a gamepad/joystick? - unsigned fRealN64Range; // does it have the "Real N64 Range" flag set? - unsigned bAxisSet; // which set of axes are we using? (Control 1, Control 2) - unsigned bMouseMoveX; // does it use buffered/absolute mouse for X? MM_BUFF, MM_ABS, MM_DEAD - unsigned bMouseMoveY; // does it use buffered/absolute mouse for Y? - unsigned fKeyAbsoluteX; // does it use absolute key for X? - unsigned fKeyAbsoluteY; // does it use absolute key for Y? + unsigned fRealN64Range; // Does it have the "real N64 range" flag set? + unsigned bAxisSet; // Which set of axes are we using? (Control 1, Control 2) + unsigned bMouseMoveX; // Does it use buffered/absolute mouse for X? MM_BUFF, MM_ABS, MM_DEAD + unsigned bMouseMoveY; // Does it use buffered/absolute mouse for Y? + unsigned fKeyAbsoluteX; // Does it use absolute key for X? + unsigned fKeyAbsoluteY; // Does it use absolute key for Y? - unsigned fPakInitialized; // Has our pak been initialized? Used to make sure we don't try to write to a mempak that doesn't point to anything. - unsigned fPakCRCError; // The ROM sends CRC data when it tries to write to a mempak. Is the CRC incorrect? Usually indicates a bad ROM. - unsigned PakType; // what type of controller pak? mempak? rumble? transfer? etc - unsigned fVisualRumble; // is visual rumble enabled for this controller? + unsigned fPakInitialized; // Has our pak been initialized? Used to make sure we don't try to write to a memory pak that doesn't point to anything. + unsigned fPakCRCError; // The ROM sends CRC data when it tries to write to a memory pak. Is the CRC incorrect? Usually indicates a bad ROM. + unsigned PakType; // What type of controller pak? Memory pak? Rumble pak? Transfer pak? etc. + unsigned fVisualRumble; // Is visual rumble enabled for this controller? - unsigned bBackgroundInput; // allow input while main window isn't focused? + unsigned bBackgroundInput; // Allow input while main window isn't focused? - unsigned XcheckTime; // checks for newly connected gamepads timer + unsigned XcheckTime; // Checks for newly connected gamepads timer - BYTE bRumbleTyp; // what type of rumble effect? none, constant, ramp, or direct? + BYTE bRumbleTyp; // What type of rumble effect? None, constant, ramp, or direct? GUID guidFFDevice; // GUID of the device that rumble gets sent to - BYTE bStickRange; // our "range modifier". + BYTE bStickRange; // Our "range modifier" - long wAxeBuffer[4]; // makes pseudo-relative Movement possible through keyboard or buttons - // also acts as a mouse buffer + long wAxeBuffer[4]; // Makes pseudo-relative movement possible through keyboard or buttons and also acts as a mouse buffer - WORD wMouseSensitivityX; // set per N64 controller, that's OK + WORD wMouseSensitivityX; // Set per N64 controller, that's OK WORD wMouseSensitivityY; - BYTE bPadDeadZone; // our manual dead zone, set per N64 controller - BYTE bRumbleStrength; // set per N64 controller - unsigned short nModifiers; // number of modifiers + BYTE bPadDeadZone; // Our manual dead zone, set per N64 controller + BYTE bRumbleStrength; // Set per N64 controller + unsigned short nModifiers; // Number of modifiers bool bRapidFireEnabled; BYTE bRapidFireRate; @@ -180,17 +177,17 @@ typedef struct _CONTROLLER // AN N64 CONTROLLER TCHAR szTransferRom[MAX_PATH + 1]; // GameBoyRom-Filename TCHAR szTransferSave[MAX_PATH + 1]; // GameBoyEEPRom-Filename - BUTTON aButton[14 + PF_AXESETS * 4]; // Ten buttons, 4 d-pad directions times two (for Config 1 and Config 2) + BUTTON aButton[14 + PF_AXESETS * 4]; // Ten buttons, 4 D-pad directions times two (for Config 1 and Config 2) - MODIFIER *pModifiers; // Array of Modifiers + MODIFIER *pModifiers; // Array of modifiers - void *pPakData; // Pointer to Pak Data (specific): see PakIO.h + void *pPakData; // Pointer to pak Data (specific): see PakIO.h // pPakData->bPakType will always be a BYTE indicating what the current pak type is - XCONTROLLER xiController; // To handle an XInput enabled controller --tecnicors + XCONTROLLER xiController; // To handle an XInput-enabled controller (comment by tecnicors) } CONTROLLER, *LPCONTROLLER; -// This is the Index of WORD PROFILE.Button[X] +// This is the index of WORD PROFILE.Button[X] // Buttons: #define PF_DPADR 0 #define PF_DPADL 1 @@ -207,27 +204,26 @@ typedef struct _CONTROLLER // AN N64 CONTROLLER #define PF_TRIGGERR 12 #define PF_TRIGGERL 13 -// Analog Stick -// cause you can assign Buttons to it, I need 4 of 'em +// Analog stick +// Because you can assign buttons to it, we need 4 of them #define PF_APADR 14 #define PF_APADL 15 #define PF_APADD 16 #define PF_APADU 17 -// second Set +// Second set // #define PF_APADR 18 // #define PF_APADL 19 // #define PF_APADD 20 // #define PF_APADU 21 -// Data Format of DWORD Controller.Button: -// +// Data format of DWORD Controller.Button: -// BYTE bBtnType : Determines the Device and general Type of Control -// BYTE bAxisID : AxeIndentifier, Tells which range of the Axe/POV is important -// BYTE bOffset : Offset in the DirectInput data structure +// BYTE bBtnType: Determines the device and general type of control +// BYTE bAxisID: AxeIndentifier, which tells which range of the axes/POV is important +// BYTE bOffset: Offset in the DirectInput data structure -// BYTE bBtnType : Determines the Device and general Type of Control +// BYTE bBtnType: Determines the device and general type of control #define DT_UNASSIGNED 0 // Joystick #define DT_JOYBUTTON 1 @@ -242,11 +238,11 @@ typedef struct _CONTROLLER // AN N64 CONTROLLER #define DT_MOUSEBUTTON 6 #define DT_MOUSEAXE 7 -// BYTE bAxisID : AxeIndentifier, Tells which range of the Axe/POV is important +// BYTE bAxisID: AxeIndentifier, which tells which range of the axes/POV is important -// Positive Range of an Axe +// Positive range of a the axes #define AI_AXE_P 0 -// Negative Range +// Negative range #define AI_AXE_N 1 // Applies to POVs obviously @@ -255,7 +251,7 @@ typedef struct _CONTROLLER // AN N64 CONTROLLER #define AI_POV_DOWN 2 #define AI_POV_LEFT 3 -// BYTE bOffset : Offset in the DirectInput data structure +// BYTE bOffset: Offset in the DirectInput data structure typedef union _MODSPEC_MOVE { @@ -335,8 +331,8 @@ typedef union _MODSPEC_CONFIG #define SC_SWMEMRUMB 6 #define SC_SWMEMADAPT 7 -// total arraysize of aButtons in SHORTCUTSPL; -// make sure you update this if you change the list above +// Total array size of aButtons in SHORTCUTSPL; +// Make sure you update this if you change the list above #define SC_TOTAL 8 typedef struct _SHORTCUTSPL @@ -361,7 +357,7 @@ typedef struct _SHORTCUTS typedef struct _MSHORTCUT { int iControl; int iShortcut; -} MSHORTCUT, *LPMSHORTCUT; // shortcut message +} MSHORTCUT, *LPMSHORTCUT; // Shortcut message #define CHECK_WHITESPACES( str ) ( str == '\r' || str == '\n' || str == '\t' ) diff --git a/Source/nragev20/PakIO.cpp b/Source/nragev20/PakIO.cpp index 3de8838ea..26d20ebd5 100644 --- a/Source/nragev20/PakIO.cpp +++ b/Source/nragev20/PakIO.cpp @@ -1,24 +1,23 @@ /* - N-Rage`s Dinput8 Plugin - (C) 2002, 2006 Norbert Wladyka +N-Rage`s Dinput8 Plugin +(C) 2002, 2006 Norbert Wladyka - Author`s Email: norbert.wladyka@chello.at - Website: http://go.to/nrage +Author`s Email: norbert.wladyka@chello.at +Website: http://go.to/nrage +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the free Software Foundation; either version 2 of the License, or +(at your option) any later version. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the free Software Foundation; either version 2 of the License, or - (at your option) any later version. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include @@ -39,13 +38,13 @@ using std::min; using std::max; -// ProtoTypes +// Prototypes BYTE AddressCRC( const unsigned char * Address ); BYTE DataCRC( const unsigned char * Data, const int iLength ); VOID CALLBACK WritebackProc( HWND hWnd, UINT msg, UINT_PTR idEvent, DWORD dwTime ); bool InitControllerPak( const int iControl ) -// Prepares the Pak +// Prepares the pak { if( !g_pcControllers[iControl].fPlugged ) return false; @@ -67,7 +66,7 @@ bool InitControllerPak( const int iControl ) mPak->fDexSave = false; mPak->hMemPakHandle = NULL; - DWORD dwFilesize = PAK_MEM_SIZE; // expected file size + DWORD dwFilesize = PAK_MEM_SIZE; // Expected file size TCHAR szBuffer[MAX_PATH+1], szFullPath[MAX_PATH+1], *pcFile; @@ -78,10 +77,10 @@ bool InitControllerPak( const int iControl ) bool isNewfile = !CheckFileExists( szBuffer ); if( pcFile == NULL ) - { // no Filename specified + { // No filename specified WarningMessage( IDS_ERR_MEM_NOSPEC, MB_OK | MB_ICONWARNING ); g_pcControllers[iControl].PakType = PAK_NONE; - break; // memory is freed at the end of this function + break; // Memory is freed at the end of this function } TCHAR *pcPoint = _tcsrchr( pcFile, '.' ); @@ -97,7 +96,7 @@ bool InitControllerPak( const int iControl ) HANDLE hFileHandle = CreateFile( szFullPath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, 0, NULL ); if( hFileHandle == INVALID_HANDLE_VALUE ) - {// test if Read-only access is possible + {// Test if read-only access is possible hFileHandle = CreateFile( szFullPath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_ALWAYS, 0, NULL ); if( hFileHandle != INVALID_HANDLE_VALUE ) { @@ -108,7 +107,7 @@ bool InitControllerPak( const int iControl ) wsprintf( szBuffer, tszText, pcFile ); MessageBox( g_strEmuInfo.hMainWindow, szBuffer, tszTitle, MB_OK | MB_ICONWARNING ); mPak->fReadonly = true; - DebugWriteA("Ramfile opened in READ ONLY mode.\n"); + DebugWriteA("RAM file opened in read only mode.\n"); } else { @@ -118,9 +117,9 @@ bool InitControllerPak( const int iControl ) LoadString( g_hResourceDLL, IDS_DLG_WARN_TITLE, tszTitle, DEFAULT_BUFFER ); wsprintf( szBuffer, tszText, pcFile ); MessageBox( g_strEmuInfo.hMainWindow, szBuffer, tszTitle, MB_OK | MB_ICONWARNING ); - g_pcControllers[iControl].PakType = PAK_NONE; // set so that CloseControllerPak doesn't try to close a file that isn't open - DebugWrite(_T("Unable to read or create MemPak file %s.\n"), pcFile); - break; // memory is freed at the end of this function + g_pcControllers[iControl].PakType = PAK_NONE; // Set so that CloseControllerPak doesn't try to close a file that isn't open + DebugWrite(_T("Unable to read or create memory pak file %s.\n"), pcFile); + break; // Memory is freed at the end of this function } } @@ -161,23 +160,23 @@ bool InitControllerPak( const int iControl ) } else { - // use mapped file + // Use mapped file mPak->hMemPakHandle = CreateFileMapping( hFileHandle, NULL, mPak->fReadonly ? PAGE_READONLY : PAGE_READWRITE, 0, dwFilesize, NULL); - // test for invalid handle + // Test for invalid handle if (mPak->hMemPakHandle == NULL) { - // note: please don't move the CloseHandle call before GetLastError - DebugWriteA("Couldn't CreateFileMapping for MemPak file : %08x\n", GetLastError()); + // Note: please don't move the CloseHandle call before GetLastError + DebugWriteA("Couldn't CreateFileMapping for memory pak file : %08x\n", GetLastError()); CloseHandle(hFileHandle); - break; // memory is freed at the end of the function + break; // Memory is freed at the end of the function } - CloseHandle(hFileHandle); // we can close the file handle now with no problems + CloseHandle(hFileHandle); // We can close the file handle now with no problems mPak->aMemPakData = (LPBYTE)MapViewOfFile( mPak->hMemPakHandle, FILE_MAP_ALL_ACCESS, 0, 0, mPak->fDexSave ? PAK_MEM_SIZE + PAK_MEM_DEXOFFSET : PAK_MEM_SIZE ); - // this is a bit tricky: - // if it's a dexsave, move the pakdata pointer forward so it points to where the actual mempak data starts - // we need to make sure to move it back when we UnmapViewOfFile + // This is a bit tricky: + // If it's a dexsave, move the pak data pointer forward so it points to where the actual memory pak data starts + // We need to make sure to move it back when we UnmapViewOfFile if (mPak->aMemPakData == NULL) ErrorMessage(IDS_ERR_MAPVIEW, GetLastError(), false); @@ -192,7 +191,7 @@ bool InitControllerPak( const int iControl ) if (mPak->fDexSave ) { PVOID pHeader = MapViewOfFile( mPak->hMemPakHandle, FILE_MAP_ALL_ACCESS, 0, 0, PAK_MEM_DEXOFFSET ); - const char szHeader[] = "123-456-STD"; // "OMG-WTF-BBQ"? --rabid + const char szHeader[] = "123-456-STD"; // "OMG-WTF-BBQ"? (comment by rabid) ZeroMemory( pHeader, PAK_MEM_DEXOFFSET ); CopyMemory( pHeader, szHeader, sizeof(szHeader) ); FlushViewOfFile( pHeader, PAK_MEM_DEXOFFSET ); @@ -211,11 +210,11 @@ bool InitControllerPak( const int iControl ) RUMBLEPAK *rPak = (RUMBLEPAK*)g_pcControllers[iControl].pPakData; rPak->bPakType = PAK_RUMBLE; - rPak->fLastData = true; // statistically, if uninitted it would return true --rabid + rPak->fLastData = true; // Statistically, if uninitialized it would return true (comment by rabid) // rPak->bRumbleTyp = g_pcControllers[iControl].bRumbleTyp; // rPak->bRumbleStrength = g_pcControllers[iControl].bRumbleStrength; // rPak->fVisualRumble = g_pcControllers[iControl].fVisualRumble; - if( !g_pcControllers[iControl].fXInput ) //used to make sure only xinput cotroller rumbles --tecnicors + if( !g_pcControllers[iControl].fXInput ) // Used to make sure only XInput controller rumbles (comment by tecnicors) CreateEffectHandle( iControl, g_pcControllers[iControl].bRumbleTyp, g_pcControllers[iControl].bRumbleStrength ); bReturn = true; } @@ -232,10 +231,10 @@ bool InitControllerPak( const int iControl ) tPak->gbCart.RamData = NULL; /* - * Once the Interface is implemented g_pcControllers[iControl].szTransferRom will hold filename of the GB-Rom - * and g_pcControllers[iControl].szTransferSave holds Filename of the SRAM Save + * Once the Interface is implemented g_pcControllers[iControl].szTransferRom will hold filename of the Game Boy ROM + * and g_pcControllers[iControl].szTransferSave holds Filename of the SRAM save * - * Here, both files should be opened and the handles stored in tPak ( modify the struct for Your own purposes, only bPakType must stay at first ) + * Here, both files should be opened and the handles stored in tPak (modify the struct for your own purposes, only bPakType must stay at first) */ //CreateFile( g_pcControllers[iControl].szTransferSave, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_ALWAYS, 0, NULL ); @@ -248,11 +247,11 @@ bool InitControllerPak( const int iControl ) if (tPak->bPakInserted) { - DebugWriteA( "*** Init Transfer Pak - Success***\n" ); + DebugWriteA( "*** Initialize transfer pak - success***\n" ); } else { - DebugWriteA( "*** Init Transfer Pak - FAILURE***\n" ); + DebugWriteA( "*** Initialize transfer pak - failure***\n" ); } bReturn = true; @@ -279,7 +278,7 @@ bool InitControllerPak( const int iControl ) aPak->bIdentifier = 0x80; #ifdef ADAPTOIDPAK_RUMBLEFIX aPak->fRumblePak = true; -#pragma message( "Driver-fix for Rumble with Adaptoid enabled" ) +#pragma message( "Driver fix for rumble with Adaptoid enabled" ) #else aPak->fRumblePak = false; #endif @@ -290,7 +289,7 @@ bool InitControllerPak( const int iControl ) break;*/ } - // if there were any unrecoverable errors and we have allocated pPakData, free it and set paktype to NONE + // If there were any unrecoverable errors and we have allocated pPakData, free it and set pak type to NONE if( !bReturn && g_pcControllers[iControl].pPakData ) CloseControllerPak( iControl ); @@ -342,7 +341,7 @@ BYTE ReadControllerPak( const int iControl, LPBYTE Command ) else ZeroMemory( Data, 32 ); - if( g_pcControllers[iControl].fXInput ) // xinput controller rumble --tecnicors + if( g_pcControllers[iControl].fXInput ) // XInput controller rumble (comment by tecnicors) VibrateXInputController( g_pcControllers[iControl].xiController.nControl, 0, 0); else if (g_apFFDevice[iControl]) g_apFFDevice[iControl]->Acquire(); @@ -357,15 +356,15 @@ BYTE ReadControllerPak( const int iControl, LPBYTE Command ) case PAK_TRANSFER: { LPTRANSFERPAK tPak = (LPTRANSFERPAK)g_pcControllers[iControl].pPakData; // TODO: null pointer check on tPak - // set bReturn = RD_OK when implementing Transferpak + // Set bReturn = RD_OK when implementing transfer pak bReturn = RD_OK; - DebugWriteA( "TPak Read:\n" ); + DebugWriteA( "Transfer pak Read:\n" ); DebugWriteA( " Address: %04X\n", dwAddress ); switch (dwAddress >> 12) { case 0x8: // if ((dwAddress >= 0x8000) && (dwAddress <= 0x8FFF)) - DebugWriteA( "Query Enable State: %u\n", tPak->iEnableState ); + DebugWriteA( "Query enable state: %u\n", tPak->iEnableState ); if (tPak->iEnableState == false) ZeroMemory(Data, 32); else @@ -374,25 +373,25 @@ BYTE ReadControllerPak( const int iControl, LPBYTE Command ) case 0xB: // if ((dwAddress >= 0xB000) && (dwAddress <= 0xBFFF)) if (tPak->iEnableState == true) { - DebugWriteA( "Query Cart. State:" ); + DebugWriteA( "Query cart. State:" ); if (tPak->bPakInserted) { if (tPak->iCurrentAccessMode == 1) { FillMemory(Data, 32, 0x89); - DebugWriteA( " Inserted, Access Mode 1\n" ); + DebugWriteA( " Inserted, access mode 1\n" ); } else { FillMemory(Data, 32, 0x80); - DebugWriteA( " Inserted, Access Mode 0\n" ); + DebugWriteA( " Inserted, access mode 0\n" ); } Data[0] = Data[0] | tPak->iAccessModeChanged; } else { - FillMemory(Data, 32, 0x40); // Cart not inserted. - DebugWriteA( " Not Inserted\n" ); + FillMemory(Data, 32, 0x40); // Cart not inserted + DebugWriteA( " not inserted\n" ); } tPak->iAccessModeChanged = 0; } @@ -403,19 +402,19 @@ BYTE ReadControllerPak( const int iControl, LPBYTE Command ) case 0xF: // if ((dwAddress >= 0xC000)) if (tPak->iEnableState == true) { - DebugWriteA( "Cart Read: Bank:%i\n", tPak->iCurrentBankNo ); + DebugWriteA( "Cart read: Bank:%i\n", tPak->iCurrentBankNo ); DebugWriteA( " Address:%04X\n", ((dwAddress & 0xFFE0) - 0xC000) + ((tPak->iCurrentBankNo & 3) * 0x4000) ); tPak->gbCart.ptrfnReadCart(&tPak->gbCart, ((dwAddress & 0xFFE0) - 0xC000) + ((tPak->iCurrentBankNo & 3) * 0x4000), Data); } break; default: - DebugWriteA("WARNING: Unusual Pak Read\n" ); + DebugWriteA("Warning: unusual pak read\n" ); DebugWriteA(" Address: %04X\n", dwAddress); } // end switch (dwAddress >> 12) #ifdef ENABLE_RAWPAK_DEBUG - DebugWriteA( "TPak Data: " ); + DebugWriteA( "Transfer pak data: " ); for (int i = 0; i < 32; i ++) { @@ -450,7 +449,7 @@ BYTE ReadControllerPak( const int iControl, LPBYTE Command ) || (( dwAddress < 0x8000 ) && ( Data[0] != 0x00 ))) { ((ADAPTOIDPAK*)g_pcControllers[iControl].pPakData)->fRumblePak = false; - DebugWriteA( "\nAssuming the inserted Pak AINT a RumblePak\nDisabling Rumblefix\n" ); + DebugWriteA( "\nAssuming the inserted pak isn't a rumble pak\nDisabling rumble fix\n" ); } } } @@ -463,7 +462,7 @@ BYTE ReadControllerPak( const int iControl, LPBYTE Command ) return bReturn; } -// Called when the N64 tries to write to the controller pak, e.g. a mempak +// Called when the N64 tries to write to the controller pak, like a memory pak BYTE WriteControllerPak( const int iControl, LPBYTE Command ) { BYTE bReturn = RD_ERROR; @@ -488,15 +487,15 @@ BYTE WriteControllerPak( const int iControl, LPBYTE Command ) { case PAK_MEM: { - // Switched to memory-mapped file - // That way, if the computer dies due to power loss or something mid-play, the savegame is still there. + // Switched to memory mapped file + // That way, if the computer dies due to power loss or something during gameplay, the save game is still there MEMPAK *mPak = (MEMPAK*)g_pcControllers[iControl].pPakData; if( dwAddress < 0x8000 ) { CopyMemory( &mPak->aMemPakData[dwAddress], Data, 32 ); if (!mPak->fReadonly ) - SetTimer( g_strEmuInfo.hMainWindow, PAK_MEM, 2000, (TIMERPROC) WritebackProc ); // if we go 2 seconds without a write, call the Writeback proc (which will flush the cache) + SetTimer( g_strEmuInfo.hMainWindow, PAK_MEM, 2000, (TIMERPROC) WritebackProc ); // If we go 2 seconds without a write, call the Writeback proc (which will flush the cache) } else CopyMemory( &mPak->aMemPakTemp[(dwAddress%0x100)], Data, 32 ); @@ -507,7 +506,7 @@ BYTE WriteControllerPak( const int iControl, LPBYTE Command ) case PAK_RUMBLE: if( dwAddress == PAK_IO_RUMBLE ) { - if( g_pcControllers[iControl].fXInput ) // xinput controller rumble --tecnicors + if( g_pcControllers[iControl].fXInput ) // XInput controller rumble (comment by tecnicors) { if( *Data ) VibrateXInputController( g_pcControllers[iControl].xiController.nControl ); @@ -519,12 +518,12 @@ BYTE WriteControllerPak( const int iControl, LPBYTE Command ) if( g_pcControllers[iControl].fVisualRumble ) FlashWindow( g_strEmuInfo.hMainWindow, ( *Data != 0 ) ? TRUE : FALSE ); if( g_pcControllers[iControl].bRumbleTyp == RUMBLE_DIRECT ) - { // Adaptoid Direct Rumble + { // Adaptoid direct rumble if( g_pcControllers[iControl].fIsAdaptoid ) DirectRumbleCommand( iControl, *Data ); } else - { // FF-FeedBack Rumble + { // Force feedback rumble if( g_apdiEffect[iControl] ) { g_apFFDevice[iControl]->Acquire(); @@ -533,7 +532,7 @@ BYTE WriteControllerPak( const int iControl, LPBYTE Command ) // g_apdiEffect[iControl]->Start( 1, DIES_SOLO ); HRESULT hr; hr = g_apdiEffect[iControl]->Start( 1, DIES_NODOWNLOAD ); - if( hr != DI_OK )// just download if needed( seems to work smoother) + if( hr != DI_OK )// Just download if needed (seems to work smoother) { hr = g_apdiEffect[iControl]->Start( 1, 0 ); if (hr != DI_OK) @@ -559,15 +558,15 @@ BYTE WriteControllerPak( const int iControl, LPBYTE Command ) rPak->fLastData = (*Data) ? true : false; } -end_rumble: // added so after xinput controller rumbles, gets here --tecnicors +end_rumble: // Added so after XInput controller rumbles, gets here (comment by tecnicors) Data[32] = DataCRC( Data, 32 ); bReturn = RD_OK; break; case PAK_TRANSFER: { LPTRANSFERPAK tPak = (LPTRANSFERPAK)g_pcControllers[iControl].pPakData; - // set bReturn = RD_OK when implementing Transferpak - DebugWriteA( "TPak Write:\n" ); + // Set bReturn = RD_OK when implementing transfer pak + DebugWriteA( "Transfer pak write:\n" ); DebugWriteA( " Address: %04X\n", dwAddress ); #ifdef ENABLE_RAWPAK_DEBUG @@ -594,17 +593,17 @@ end_rumble: // added so after xinput controller rumbles, gets here --tecnico case 0x8: // if ((dwAddress >= 0x8000) && (dwAddress <= 0x8FFF)) if (Data[0] == 0xFE) { - DebugWriteA("Cart Disable\n" ); + DebugWriteA("Cart disable\n" ); tPak->iEnableState = false; } else if (Data[0] == 0x84) { - DebugWriteA("Cart Enable\n" ); + DebugWriteA("Cart enable\n" ); tPak->iEnableState = true; } else { - DebugWriteA("WARNING: Unusual Cart Enable/Disable\n" ); + DebugWriteA("Warning: Unusual cart enable/disable\n" ); DebugWriteA(" Address: " ); DebugWriteWordA(dwAddress); DebugWriteA("\n" ); @@ -617,7 +616,7 @@ end_rumble: // added so after xinput controller rumbles, gets here --tecnico if (tPak->iEnableState == true) { tPak->iCurrentBankNo = Data[0]; - DebugWriteA("Set TPak Bank No:%02X\n", Data[0] ); + DebugWriteA("Set transfer pak bank No:%02X\n", Data[0] ); } break; case 0xB: // if ((dwAddress >= 0xB000) && (dwAddress <= 0xBFFF)) @@ -625,10 +624,10 @@ end_rumble: // added so after xinput controller rumbles, gets here --tecnico { tPak->iCurrentAccessMode = Data[0] & 1; tPak->iAccessModeChanged = 4; - DebugWriteA("Set TPak Access Mode: %04X\n", tPak->iCurrentAccessMode); + DebugWriteA("Set tranfer pak access mode: %04X\n", tPak->iCurrentAccessMode); if ((Data[0] != 1) && (Data[0] != 0)) { - DebugWriteA("WARNING: Unusual Access Mode Change\n" ); + DebugWriteA("Warning: Unusual access mode change\n" ); DebugWriteA(" Address: " ); DebugWriteWordA(dwAddress); DebugWriteA("\n" ); @@ -647,7 +646,7 @@ end_rumble: // added so after xinput controller rumbles, gets here --tecnico SetTimer( g_strEmuInfo.hMainWindow, PAK_TRANSFER, 2000, (TIMERPROC) WritebackProc ); // if we go 2 seconds without a write, call the Writeback proc (which will flush the cache) break; default: - DebugWriteA("WARNING: Unusual Pak Write\n" ); + DebugWriteA("Warning: Unusual pak write\n" ); DebugWriteA(" Address: %04X\n", dwAddress); } // end switch (dwAddress >> 12) @@ -697,7 +696,7 @@ void SaveControllerPak( const int iControl ) MEMPAK *mPak = (MEMPAK*)g_pcControllers[iControl].pPakData; if( !mPak->fReadonly ) - FlushViewOfFile( mPak->aMemPakData, PAK_MEM_SIZE ); // we've already written the stuff, just flush the cache + FlushViewOfFile( mPak->aMemPakData, PAK_MEM_SIZE ); // We've already written the stuff, just flush the cache } break; case PAK_RUMBLE: @@ -705,12 +704,12 @@ void SaveControllerPak( const int iControl ) case PAK_TRANSFER: { LPTRANSFERPAK tPak = (LPTRANSFERPAK)g_pcControllers[iControl].pPakData; - // here the changes( if any ) in the SRAM should be saved + // Here the changes(if any) in the SRAM should be saved if (tPak->gbCart.hRamFile != NULL) { SaveCart(&tPak->gbCart, g_pcControllers[iControl].szTransferSave, _T("")); - DebugWriteA( "*** Save Transfer Pak ***\n" ); + DebugWriteA( "*** Save transfer pak ***\n" ); } } break; @@ -723,7 +722,7 @@ void SaveControllerPak( const int iControl ) } } -// if there is pPakData for the controller, does any closing of handles before freeing the pPakData struct and setting it to NULL +// If there is pPakData for the controller, does any closing of handles before freeing the pPakData struct and setting it to NULL // also sets fPakInitialized to false void CloseControllerPak( const int iControl ) { @@ -746,7 +745,7 @@ void CloseControllerPak( const int iControl ) else { FlushViewOfFile( mPak->aMemPakData, PAK_MEM_SIZE ); - // if it's a dexsave, our original mapped view is not aMemPakData + // If it's a dexsave, our original mapped view is not aMemPakData UnmapViewOfFile( mPak->fDexSave ? mPak->aMemPakData - PAK_MEM_DEXOFFSET : mPak->aMemPakData ); if ( mPak->hMemPakHandle != NULL ) CloseHandle( mPak->hMemPakHandle ); @@ -761,8 +760,8 @@ void CloseControllerPak( const int iControl ) { LPTRANSFERPAK tPak = (LPTRANSFERPAK)g_pcControllers[iControl].pPakData; UnloadCart(&tPak->gbCart); - DebugWriteA( "*** Close Transfer Pak ***\n" ); - // close files and free any additionally ressources + DebugWriteA( "*** Close transfer pak ***\n" ); + // Close files and free any additional resources } break; case PAK_VOICE: @@ -777,7 +776,7 @@ void CloseControllerPak( const int iControl ) return; } -// returns the number of remaining blocks in a mempak +// Returns the number of remaining blocks in a memory pak // aNoteSizes should be an array of 16 bytes, which will be overwritten with the size in blocks of each note inline WORD CountBlocks( const unsigned char * bMemPakBinary, LPBYTE aNoteSizes ) { @@ -811,7 +810,8 @@ void FormatMemPak( LPBYTE aMemPak ) FillMemory(aMemPak, 0x100, 0xFF); aMemPak[0] = 0x81; - // generate a valid code( i hope i can calculate it one day) + // TODO: Check this code since it seems the author isn't convinced it's complete + // Generate a valid code BYTE aValidCodes[] = { 0x12, 0xC5, 0x8F, 0x6F, 0xA4, 0x28, 0x5B, 0xCA }; BYTE aCode[8]; @@ -820,8 +820,6 @@ void FormatMemPak( LPBYTE aMemPak ) for (n = 0; n < 8; n++) aCode[n] = aValidCodes[n + iRand]; - //---------- - aMemPak[0x20+0] = aMemPak[0x60+0] = aMemPak[0x80+0] = aMemPak[0xC0+0] = 0xFF; aMemPak[0x20+1] = aMemPak[0x60+1] = aMemPak[0x80+1] = aMemPak[0xC0+1] = 0xFF; aMemPak[0x20+2] = aMemPak[0x60+2] = aMemPak[0x80+2] = aMemPak[0xC0+2] = 0xFF; @@ -832,7 +830,7 @@ void FormatMemPak( LPBYTE aMemPak ) aMemPak[0x20+6] = aMemPak[0x60+6] = aMemPak[0x80+6] = aMemPak[0xC0+6] = aCode[2]; aMemPak[0x20+7] = aMemPak[0x60+7] = aMemPak[0x80+7] = aMemPak[0xC0+7] = aCode[3]; - //aMemPak[0x30+9] = aMemPak[0x70+9] = aMemPak[0x90+9] = aMemPak[0xD0+9] = 0x01; // not sure + //aMemPak[0x30+9] = aMemPak[0x70+9] = aMemPak[0x90+9] = aMemPak[0xD0+9] = 0x01; // Not sure aMemPak[0x30+10] = aMemPak[0x70+10] = aMemPak[0x90+10] = aMemPak[0xD0+10] = 0x01; aMemPak[0x30+12] = aMemPak[0x70+12] = aMemPak[0x90+12] = aMemPak[0xD0+12] = aCode[4]; @@ -850,16 +848,17 @@ void FormatMemPak( LPBYTE aMemPak ) FillMemory( &aMemPak[0x500], 0x7B00, 0xFF ); } -// Translates a mempak header into a real Unicode string, for display in the Mempaks window -// bNote is now where you want to START translating, Text is where the output gets sent, iChars is the number of TCHARs you want translated -// return value is the number of characters actually translated -// Text automatically gets a terminating null, so make sure there's enough space. +// TODO: Possibly update this since it seems it could be hacky or incomplete +// Translates a memory pak header into a real Unicode string, for display in the memory paks window +// bNote is now where you want to start translating, text is where the output gets sent, iChars is the number of TCHARs you want translated +// Return value is the number of characters actually translated +// Text automatically gets a terminating null, so make sure there's enough space int TranslateNotesW( const unsigned char * bNote, LPWSTR Text, const int iChars ) { WCHAR aSpecial[] = { 0x0021, 0x0022, 0x0023, 0x0060, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, 0x003A, 0x003D, 0x003F, 0x0040, 0x2122, 0x00A9, 0x00AE }; // { '!' , '\"', '#' , '`' , '*' , '+' , ',' , '-' , '.' , '/' , ':' , '=' , '?' , '>' , 'tm', '(c)', '(r)' }; - const WCHAR aJmap[] = { // map of Japanese characters N64 to UTF-16, starting at 0x45 - 0x00A1, 0x30A3, 0x30A5, 0x30A7, 0x30A9, 0x30E3, 0x30E5, 0x30E7, 0x30C3, 0x30F2, // small a-i-u-e-o, next are probably small ya-yu-yo, small tsu, wo + const WCHAR aJmap[] = { // Map of Japanese characters N64 to UTF-16, starting at 0x45 + 0x00A1, 0x30A3, 0x30A5, 0x30A7, 0x30A9, 0x30E3, 0x30E5, 0x30E7, 0x30C3, 0x30F2, // Small a-i-u-e-o, next are probably small ya-yu-yo, small tsu, wo 0x30F3, // 0x4F -> 'n' 0x30A2, 0x30A4, 0x30A6, 0x30A8, 0x30AA, 0x30AB, 0x30AD, 0x30AF, 0x30B1, 0x30B3, 0x30B5, 0x30B7, 0x30B9, 0x30BB, 0x30BD, // nil-K-S 0x30BF, 0x30C1, 0x30C4, 0x30C6, 0x30C8, 0x30CA, 0x30CB, 0x30CC, 0x30CD, 0x30CE, 0x30CF, 0x30D2, 0x30D5, 0x30D8, 0x30DB, // T-N-H @@ -873,21 +872,21 @@ int TranslateNotesW( const unsigned char * bNote, LPWSTR Text, const int iChars while (iChars - iReturn > 0 && *bNote) { BYTE b = *bNote; - if( b <= 0x0F ) // translate Icons as Spaces + if( b <= 0x0F ) // Translate icons as spaces *Text = 0x0020; else if( b <= 0x19 ) // Numbers *Text = 0x0020 + b; else if( b <= 0x33 ) // English characters *Text = 0x0047 + b; - else if( b <= 0x44 ) // special symbols + else if( b <= 0x44 ) // Special symbols *Text = aSpecial[b - 0x34]; else if( b <= 0x94 ) // Japanese (halfwidth katakana, mapped similarly to JIS X 0201 but not enough that we can use a simple codepage) { - aSpecial[7] = 0x30fc; // change regular dash to Japanese "long sound dash" + aSpecial[7] = 0x30fc; // Change regular dash to Japanese "long sound dash" *Text = aJmap[b - 0x45]; } - else // unknown - *Text = 0x00A4; // unknown characters become "currency sign" (looks like a letter o superimposed on an x) + else // Unknown + *Text = 0x00A4; // Unknown characters become "currency sign" (looks like a letter o superimposed on an x) Text++; iReturn++; bNote++; @@ -899,10 +898,10 @@ int TranslateNotesW( const unsigned char * bNote, LPWSTR Text, const int iChars } // TODO: rename this function! It serves a completely different function from TranslateNotesW -// Translates a mempak header into an ASCII string for output to .a64 file -// bNote is now where you want to START translating, Text is where the output gets sent, iChars is the number of chars you want translated -// return value is the number of characters actually translated -// Text automatically gets a terminating null, so make sure there's enough space. +// Translates a memory pak header into an ASCII string for output to .a64 file +// bNote is now where you want to start translating, text is where the output gets sent, iChars is the number of chars you want translated +// Return value is the number of characters actually translated +// Text automatically gets a terminating null, so make sure there's enough space int TranslateNotesA( const unsigned char * bNote, LPSTR Text, const int iChars ) { const UCHAR aSpecial[] ={ 0x21, 0x22, 0x23, 0x60, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x3A, 0x3D, 0x3F, 0x40, 0x99, 0xA9, 0xAE }; @@ -912,18 +911,18 @@ int TranslateNotesA( const unsigned char * bNote, LPSTR Text, const int iChars ) while (iChars - iReturn > 0 && *bNote) { BYTE b = *bNote; - if( b <= 0x0F ) // translate Icons as Spaces + if( b <= 0x0F ) // Translate icons as spaces *Text = 0x20; else if( b <= 0x19 ) // Numbers *Text = 0x20 + b; else if( b <= 0x33 ) // English characters *Text = 0x47 + b; - else if( b <= 0x44 ) // special symbols + else if( b <= 0x44 ) // Special symbols *Text = aSpecial[b - 0x34]; else if( b <= 0x94 ) // Japan *Text = 0xC0 + ( b % 40 ); - else // unknown - *Text = (UCHAR)0xA4; // HACK: this will screw up any save with unknown characters + else // Unknown + *Text = (UCHAR)0xA4; // Hack: this will screw up any save with unknown characters Text++; iReturn++; @@ -1111,7 +1110,7 @@ void HextoTextA( const unsigned char * Data, LPSTR szText, const int nBytes ) *szText = '\0'; } -// used when reading in a Note file, to convert text to binary (unserialize) +// Used when reading in a note file, to convert text to binary (unserialize) void TexttoHexA( LPCSTR szText, LPBYTE Data, const int nBytes ) { bool fLowByte = false; @@ -1174,7 +1173,7 @@ bool SaveNoteFileA( const unsigned char * aMemPak, const int iNote, LPCTSTR pszF DWORD dwBytesWritten = 0; - lstrcpyA( szLine, "a64-notes\r\ndescription of game save goes here...\r\na64-data\r\n" ); + lstrcpyA( szLine, "a64-notes\r\nDescription of game save goes here...\r\na64-data\r\n" ); WriteFile( hFile, szLine, lstrlenA(szLine), &dwBytesWritten, NULL ); CopyMemory( szLine, aNote, 4 ); @@ -1207,9 +1206,9 @@ bool SaveNoteFileA( const unsigned char * aMemPak, const int iNote, LPCTSTR pszF WriteFile( hFile, szLine, lstrlenA(szLine), &dwBytesWritten, NULL ); WriteFile( hFile, "\r\n", 2, &dwBytesWritten, NULL ); } - WriteFile( hFile, "a64-crc\r\n", 9, &dwBytesWritten, NULL ); + WriteFile( hFile, "a64-CRC\r\n", 9, &dwBytesWritten, NULL ); - // TODO: insert crc here + // TODO: insert CRC here lstrcpynA( szLine, "00000000\r\n", 70 ); WriteFile( hFile, szLine, lstrlenA(szLine), &dwBytesWritten, NULL ); // @@ -1226,8 +1225,8 @@ bool SaveNoteFileA( const unsigned char * aMemPak, const int iNote, LPCTSTR pszF return bReturn; } -// read a Note from a file pszFileName (.a64 format), and insert it into the given MemPak -// returns true on success, false otherwise +// Read a note from a file pszFileName (.a64 format), and insert it into the given memory pak +// Returns true on success, false otherwise bool InsertNoteFile( LPBYTE aMemPak, LPCTSTR pszFileName ) { // bool bReturn = false; @@ -1248,12 +1247,12 @@ bool InsertNoteFile( LPBYTE aMemPak, LPCTSTR pszFileName ) } } - // assumes the file keeps going... - // discard the next line - fgets(szLine, sizeof(szLine) - 1, nFile); // not really necessary to check for EOF, as it will fail gracefully when dwNoteSize is zero. + // Assumes the file keeps going + // Discard the next line + fgets(szLine, sizeof(szLine) - 1, nFile); // Not really necessary to check for EOF, as it will fail gracefully when dwNoteSize is zero DWORD dwNoteSize = 0; - while( fgets(szLine, sizeof(szLine) - 1, nFile) && strncmp( "a64-crc", szLine, 7 )) + while( fgets(szLine, sizeof(szLine) - 1, nFile) && strncmp( "a64-CRC", szLine, 7 )) { dwNoteSize++; } @@ -1298,16 +1297,16 @@ bool InsertNoteFile( LPBYTE aMemPak, LPCTSTR pszFileName ) } } - // HEADER START + // Header start // .a64 header should look something like this: // NBCE 01 0203 0 {} {BLASTCORPS GAME} - // first 4 chars are the first 4 bytes - // next 2 chars are the next 2 bytes - // next 4 chars are bytes 8 and 9, in hex (huh?) - // next character is byte 10, in hex (but only one character this time) - // now we've got two sets of braces... the first one contains byte 12 in encoded form (use ReverseNotesA) - // the second one should contain bytes 16 through 31 (ReverseNotesA) + // First 4 chars are the first 4 bytes + // Next 2 chars are the next 2 bytes + // Next 4 chars are bytes 8 and 9, in hex + // Next character is byte 10, in hex (but only one character this time) + // Now we've got two sets of braces...the first one contains byte 12 in encoded form (use ReverseNotesA) + // The second one should contain bytes 16 through 31 (ReverseNotesA) BYTE *pBlock; fsetpos(nFile, &pDataStart); @@ -1318,7 +1317,7 @@ bool InsertNoteFile( LPBYTE aMemPak, LPCTSTR pszFileName ) return false; } - szLine[strlen(szLine) - 1] = '\0'; // remove newline + szLine[strlen(szLine) - 1] = '\0'; // Remove newline pBlock = &aMemPak[0x300 + ifreeNote*32]; CopyMemory( pBlock, szLine, 4 ); @@ -1355,7 +1354,7 @@ bool InsertNoteFile( LPBYTE aMemPak, LPCTSTR pszFileName ) i++; szLine[i] = '\0'; - // HEADER END + // Header end BYTE bDataBlock = 5; pBlock = &pBlock[7]; @@ -1377,7 +1376,7 @@ bool InsertNoteFile( LPBYTE aMemPak, LPCTSTR pszFileName ) return false; } - szLine[strlen(szLine) - 1] = '\0'; // remove newline + szLine[strlen(szLine) - 1] = '\0'; // Remove newline TexttoHexA( szLine, &pDataBlock[i], 32 ); } bDataBlock++; @@ -1402,7 +1401,7 @@ bool InsertNoteFile( LPBYTE aMemPak, LPCTSTR pszFileName ) return false; } -// Remove a mempak "Note" +// Remove a memory pak "note" // See "MemPak-Format.doc" for more info bool RemoveNote( LPBYTE aMemPak, const int iNote ) { @@ -1474,12 +1473,12 @@ BYTE DataCRC( const unsigned char * Data, const int iLength ) VOID CALLBACK WritebackProc( HWND hWnd, UINT msg, UINT_PTR idEvent, DWORD dwTime ) { - KillTimer(hWnd, idEvent); // timer suicide + KillTimer(hWnd, idEvent); // Timer killed switch (idEvent) { case PAK_MEM: - DebugWriteA("Mempak: WritebackProc flushed file writes\n"); + DebugWriteA("Memory pak: WritebackProc flushed file writes\n"); for( int i = 0; i < 4; i++ ) { MEMPAK *mPak = (MEMPAK*)g_pcControllers[i].pPakData; @@ -1489,7 +1488,7 @@ VOID CALLBACK WritebackProc( HWND hWnd, UINT msg, UINT_PTR idEvent, DWORD dwTime } return; case PAK_TRANSFER: - DebugWriteA("TPak: WritebackProc flushed file writes\n"); + DebugWriteA("Transfer pak: WritebackProc flushed file writes\n"); for( int i = 0; i < 4; i++ ) { LPTRANSFERPAK tPak = (LPTRANSFERPAK)g_pcControllers[i].pPakData; diff --git a/Source/nragev20/PakIO.h b/Source/nragev20/PakIO.h index b6586efad..6515f9ace 100644 --- a/Source/nragev20/PakIO.h +++ b/Source/nragev20/PakIO.h @@ -1,24 +1,23 @@ /* - N-Rage`s Dinput8 Plugin - (C) 2002, 2006 Norbert Wladyka +N-Rage`s Dinput8 Plugin +(C) 2002, 2006 Norbert Wladyka - Author`s Email: norbert.wladyka@chello.at - Website: http://go.to/nrage +Author`s Email: norbert.wladyka@chello.at +Website: http://go.to/nrage +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the free Software Foundation; either version 2 of the License, or +(at your option) any later version. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the free Software Foundation; either version 2 of the License, or - (at your option) any later version. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _PAKIO_H_ @@ -49,75 +48,75 @@ void HextoTextA( const unsigned char * Data, LPSTR szText, const int nBytes ); #endif -//************Raw Data***********// - //byte 1 = number of bytes to send - //byte 2 = number of bytes to recieve - //byte 3 = Command Type +// Raw data +// Byte 1 = Number of bytes to send +// Byte 2 = Number of bytes to receive +// Byte 3 = Command type - // get status +// Get status #define RD_GETSTATUS 0x00 - // read button values +// Read button values #define RD_READKEYS 0x01 - // read from controllerpak +// Read from controller pak #define RD_READPAK 0x02 - // write to controllerpack +// Write to controller pak #define RD_WRITEPAK 0x03 - // reset controller +// Reset controller #define RD_RESETCONTROLLER 0xff - // read eeprom +// Read EEPROM #define RD_READEEPROM 0x04 - // write eeprom +// Write EEPROM #define RD_WRITEEPROM 0x05 - // Codes for retrieving status - // 0x010300 - A1B2C3FF +// Codes for retrieving status +// 0x010300 - A1B2C3FF - //A1 - // Default GamePad +// A1 +// Default controller #define RD_ABSOLUTE 0x01 #define RD_RELATIVE 0x02 - // Default GamePad +// Default controller #define RD_GAMEPAD 0x04 - //B2 +// B2 #define RD_EEPROM 0x80 #define RD_NOEEPROM 0x00 - //C3 - // No Plugin in Controller +// C3 +// No plugin in controller #define RD_NOPLUGIN 0x00 - // Plugin in Controller (Mempack, RumblePack etc) +// Plugin in controller (memory pak, rumble pak, etc.) #define RD_PLUGIN 0x01 - // Pak interface was uninitialized before the call +// Pak interface was uninitialized before the call #define RD_NOTINITIALIZED 0x02 - // Address of last Pak I/O was invalid +// Address of last pak I/O was invalid #define RD_ADDRCRCERR 0x04 - // eeprom busy +// EEPROM busy #define RD_EEPROMBUSY 0x80 -// The Error values are as follows: +// The error values are as follows: // 0x01ER00 - ........ - //ER - // no error, operation successful. +// ER +// No error, operation successful #define RD_OK 0x00 - // error, device not present for specified command. +// Error, device not present for specified command #define RD_ERROR 0x80 - // error, unable to send/recieve the number bytes for command type. +// Error, unable to send/receive the number of bytes for command type #define RD_WRONGSIZE 0x40 - // the address where rumble-commands are sent to - // this is really 0xC01B but our addressing code truncates the last several bits. +// The address where rumble-commands are sent to +// This is really 0xC01B but our addressing code truncates the last several bits #define PAK_IO_RUMBLE 0xC000 - // 32 KB mempak +// 32KB memory pak #define PAK_MEM_SIZE 32*1024 #define PAK_MEM_DEXOFFSET 0x1040 -// Pak Specific Data // -// First BYTE always determines current Paktype -// this can be different to the paktype in the Controller-structure. -// that makes sure to corectly handle/close the pak. +// Pak-specific data +// First byte always determines current pak type +// This can be different to the pak type in the controller structure +// That makes sure to correctly handle/close the pak //PAK_NONE //pPakData = NULL; @@ -125,22 +124,22 @@ void HextoTextA( const unsigned char * Data, LPSTR szText, const int nBytes ); //PAK_MEM typedef struct _MEMPAK { - BYTE bPakType; // set to PAK_MEM - HANDLE hMemPakHandle; // a file mapping handle - bool fDexSave; // true if .n64 file, false if .mpk file - bool fReadonly; // set if we can't open mempak file in "write" mode + BYTE bPakType; // Set to PAK_MEM + HANDLE hMemPakHandle; // A file mapping handle + bool fDexSave; // True if .n64 file, false if .mpk file + bool fReadonly; // Set if we can't open memory pak file in "write" mode LPBYTE aMemPakData; //[PAK_MEM_SIZE]; - BYTE aMemPakTemp[0x100]; // some extra on the top for "test" (temporary) data + BYTE aMemPakTemp[0x100]; // Some extra on the top for "test" (temporary) data } MEMPAK, *LPMEMPAK; //PAK_RUMBLE typedef struct _RUMBLEPAK { BYTE bPakType; -// BYTE bRumbleTyp; // obsolete: use g_pcControllers[i].xyz instead --rabid +// BYTE bRumbleTyp; // Obsolete: use g_pcControllers[i].xyz instead (comment by rabid) // BYTE bRumbleStrength; // bool fVisualRumble; - bool fLastData; // true if the last data sent to block 0x8000 was nonzero + bool fLastData; // True if the last data sent to block 0x8000 was non-zero } RUMBLEPAK, *LPRUMBLEPAK; #include "GBCart.h" @@ -157,7 +156,7 @@ typedef struct _TRANSFERPAK } TRANSFERPAK, *LPTRANSFERPAK; //PAK_VOICE -typedef struct _VOICEPAK //not supported +typedef struct _VOICEPAK // Not supported { BYTE bPakType; } VOICEPAK, *LPVOICEPAK; diff --git a/Source/nragev20/Version.h.in b/Source/nragev20/Version.h.in index 71f953022..a7aa0cf6e 100644 --- a/Source/nragev20/Version.h.in +++ b/Source/nragev20/Version.h.in @@ -1,25 +1,25 @@ /* - N-Rage`s Dinput8 Plugin - (C) 2002, 2006 Norbert Wladyka +N-Rage`s Dinput8 Plugin +(C) 2002, 2006 Norbert Wladyka - Author`s Email: norbert.wladyka@chello.at - Website: http://go.to/nrage +Author`s Email: norbert.wladyka@chello.at +Website: http://go.to/nrage +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the free Software Foundation; either version 2 of the License, or +(at your option) any later version. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the free Software Foundation; either version 2 of the License, or - (at your option) any later version. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #define STRINGIZE2(s) #s #define STRINGIZE(s) STRINGIZE2(s) diff --git a/Source/nragev20/XInputController.cpp b/Source/nragev20/XInputController.cpp index 62f25c10d..62536baaf 100644 --- a/Source/nragev20/XInputController.cpp +++ b/Source/nragev20/XInputController.cpp @@ -1,25 +1,25 @@ /* - XInput Controller support for N-Rage`s Dinput8 Plugin by tecnicors - (C) 2009 Daniel Rehren - XInput Controller support +XInput Controller support for N-Rage`s Dinput8 Plugin by tecnicors +(C) 2009 Daniel Rehren - XInput Controller support - Author's Email: rehren_007@hotmail.com +Author's Email: rehren_007@hotmail.com - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the free Software Foundation; either version 2 of the License, or - (at your option) any later version. +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the free Software Foundation; either version 2 of the License, or +(at your option) any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -//code from http://msdn.microsoft.com/en-us/library/ee417014(VS.85).aspx +// Code from http://msdn.microsoft.com/en-us/library/ee417014(VS.85).aspx #include #include @@ -31,7 +31,7 @@ #include "FileAccess.h" #include "resource.h" -//We need to keep track of XInput control id's +// We need to keep track of XInput control ID's int iXinputControlId = 0; BOOL IsXInputDevice( const GUID* pGuidProductFromDirectInput ) @@ -72,7 +72,7 @@ BOOL IsXInputDevice( const GUID* pGuidProductFromDirectInput ) if( FAILED(hr) || pIWbemServices == NULL ) goto LCleanup; - // Switch security level to IMPERSONATE. + // Switch security level to IMPERSONATE CoSetProxyBlanket( pIWbemServices, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL, RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE ); @@ -324,13 +324,13 @@ void VibrateXInputController( DWORD nController, int LeftMotorVal, int RightMoto bool InitXinput() { - //Lets dynamically load in the XInput library + // Lets dynamically load in the XInput library if (g_hXInputDLL == NULL) g_hXInputDLL = LoadLibrary(L"Xinput1_4.dll"); if (g_hXInputDLL == NULL) { - //Ok since 1.4 is present, try 9.1.0 as its present on Vista and newer + // OK, since 1.4 is present, try 9.1.0 as its present on Vista and newer g_hXInputDLL = LoadLibrary(L"Xinput9_1_0.dll"); } if (g_hXInputDLL == NULL) @@ -338,7 +338,7 @@ bool InitXinput() return false; } - //Prepare the functions where going to use, nice and simple for XInput + // Prepare the functions we're going to use, nice and simple for XInput fnXInputSetState = (DWORD(WINAPI *) (DWORD, XINPUT_VIBRATION*))GetProcAddress(g_hXInputDLL, "XInputSetState"); fnXInputGetState = (DWORD(WINAPI *) (DWORD, XINPUT_STATE*))GetProcAddress(g_hXInputDLL, "XInputGetState"); return true; @@ -346,7 +346,7 @@ bool InitXinput() void FreeXinput() { - //Unload the Library + // Unload the Library if (g_hXInputDLL != NULL) { FreeLibrary(g_hXInputDLL); @@ -522,11 +522,11 @@ int GetComboBoxXInputKey( int ComboBox ) case IDC_XC_START: return XINPUT_GAMEPAD_START; case IDC_XC_LB: return XINPUT_GAMEPAD_LEFT_SHOULDER; case IDC_XC_RB: return XINPUT_GAMEPAD_RIGHT_SHOULDER; - case IDC_XC_LT: return -1; // triggers don't use these macros + case IDC_XC_LT: return -1; // Triggers don't use these macros case IDC_XC_RT: return -1; case IDC_XC_LTSB: return XINPUT_GAMEPAD_LEFT_THUMB; case IDC_XC_RTSB: return XINPUT_GAMEPAD_RIGHT_THUMB; - case IDC_XC_DPAD: return -2; // to handle analogs and dpad + case IDC_XC_DPAD: return -2; // To handle analogs and D-pad case IDC_XC_LTS: return -2; case IDC_XC_RTS: return -2; default: return 0; @@ -534,7 +534,8 @@ int GetComboBoxXInputKey( int ComboBox ) } int GetN64ButtonCode( TCHAR *btnName ) //esta wea esta muy fea, hay que buscar una mejor manera definitivamente.. -{ +{ // ^ This translated means "This wea is very ugly, we must definitely find a better way" + // I'm assuming there must be some perceived "better way to handle this, so maybe TODO: ?" using namespace N64_BUTTONS; int value = 0; @@ -602,7 +603,7 @@ void StoreAnalogConfig( LPXCONTROLLER gController, int ComboBox, int index ) switch( index ) { - case 1: // DPAD + case 1: // D-pad switch( ComboBox ) { case IDC_XC_DPAD: @@ -621,7 +622,7 @@ void StoreAnalogConfig( LPXCONTROLLER gController, int ComboBox, int index ) break; } break; - case 2: // C Buttons + case 2: // C buttons switch( ComboBox ) { case IDC_XC_DPAD: @@ -745,7 +746,7 @@ void LoadXInputConfigFromFile( FILE *file, LPXCONTROLLER gController ) while( fgets( buffer, 4096, file )) { - if( strlen( buffer ) == 1 ) // means end of controller config + if( strlen( buffer ) == 1 ) // Means end of controller config break; c++; switch( buffer[0] ) diff --git a/Source/nragev20/XInputController.h b/Source/nragev20/XInputController.h index 940a95773..3a537663b 100644 --- a/Source/nragev20/XInputController.h +++ b/Source/nragev20/XInputController.h @@ -1,28 +1,28 @@ /* - XInput Controller support for N-Rage`s Dinput8 Plugin - (C) 2002, 2006 Norbert Wladyka - N-Rage`s Dinput8 Plugin - (C) 2009 Daniel Rehren - XInput Controller support +XInput Controller support for N-Rage`s Dinput8 Plugin +(C) 2002, 2006 Norbert Wladyka - N-Rage`s Dinput8 Plugin +(C) 2009 Daniel Rehren - XInput Controller support - N-Rage`s Dinput8 Plugin: - Author`s Email: norbert.wladyka@chello.at - Website: http://go.to/nrage +N-Rage`s Dinput8 Plugin: +Author`s Email: norbert.wladyka@chello.at +Website: http://go.to/nrage - XInput Controller support: - Author's Email: rehren_007@hotmail.com +XInput Controller support: +Author's Email: rehren_007@hotmail.com - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the free Software Foundation; either version 2 of the License, or - (at your option) any later version. +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the free Software Foundation; either version 2 of the License, or +(at your option) any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _XINPUTCONTROLLER_H @@ -30,10 +30,10 @@ //#include <-- only needed for SAFE_RELEASE(x) -/* fixes undefined FILE, etc. type errors in MSVC 2010 build -- cxd4 */ +// Fixes undefined FILE, etc. type errors in MSVC 2010 build -- cxd4 #include -#ifndef SAFE_RELEASE // when Windows Media Device M? is not present +#ifndef SAFE_RELEASE // When Windows Media Device M? is not present #define SAFE_RELEASE(x) \ if(x != NULL) \ { \ @@ -42,33 +42,33 @@ } #endif -//----------------------------------------------------------------------------- + // Enum each PNP device using WMI and check each device ID to see if it contains // "IG_" (ex. "VID_045E&PID_028E&IG_00"). If it does, then it's an XInput device // Unfortunately this information can not be found by just using DirectInput -//----------------------------------------------------------------------------- + BOOL IsXInputDevice( const GUID* pGuidProductFromDirectInput ); //END conde from ... /* - Xinput header for NRage Plugin, by tecnicors. +XInput header for N-Rage Plugin, by tecnicors. - XInput Controller is going to take over the N64 control that matches its - number, ie. first XInput controller is first N64 player, etc. +XInput Controller is going to take over the N64 control that matches its +number, ie. first XInput controller is first N64 player, etc. */ #include "commonIncludes.h" #include -//defines +// Defines #define N64_ANALOG_MAX 127 #define XC_ANALOG_MAX 32767 #define BUTTON_ANALOG_VALUE 60 -//enums +// Enums namespace N64_BUTTONS { - // Whith this we can asign buttons to the xinput struct + // With this we can assign buttons to the XInput struct enum _N64_BUTTONS { A = 0x0080, B = 0x0040, Z = 0x0020, R = 0x1000, L = 0x2000, XAxis = 0x4000, Start = 0x0010, DUp = 0x0008, DDown = 0x0004, DLeft = 0x0002, YAxis = 0x8000, DRight = 0x0001, CUp = 0x0800, CDown = 0x0400, CLeft = 0x0200, CRight = 0x0100, @@ -103,13 +103,13 @@ typedef XCONTROLLER *LPXCONTROLLER; extern int iXinputControlId; -//Initiates XInput library +// Initiates XInput library bool InitXinput(); -//Free the Xinput library +// Free the XInput library void FreeXinput(); -// Sets the keys pressed for Xinput controller gController, into keys. +// Sets the keys pressed for XInput controller gController, into keys void GetXInputControllerKeys( const int indexController, LPDWORD Keys ); -// Sets the default keys for Xinput controller gController. +// Sets the default keys for XInput controller gController void DefaultXInputControllerKeys( LPXCONTROLLER gController); // Vibrates the XInput Control void VibrateXInputController( DWORD nController, int LeftMotorVal = 65535, int RightMotorVal = 65535 ); @@ -125,11 +125,11 @@ static DWORD(WINAPI * fnXInputSetState) (DWORD dwUserIndex, XINPUT_VIBRATION* pV #define XC_LTBS 2 #define XC_RTBS 3 -// Reads current XInput controller key config, and shows it in the dialog. +// Reads current XInput controller key config, and shows it in the dialog bool ReadXInputControllerKeys( HWND hDlg, LPXCONTROLLER gController ); -// Stores dialog's button configuration into the XCONTROLLER struct. +// Stores dialog's button configuration into the XCONTROLLER struct void StoreXInputControllerKeys( HWND hDlg, LPXCONTROLLER gController ); -// Fills N64 button comobox with its buttons. +// Fills N64 button comobox with its buttons inline void FillN64ButtonComboBox( HWND hDlg, int ComboBox ) { SendDlgItemMessage( hDlg, ComboBox, CB_ADDSTRING, 0, ( LPARAM )_T( "None" )); @@ -160,7 +160,7 @@ inline void FillN64AnalogComboBox( HWND hDlg, int ComboBox ) SendDlgItemMessage( hDlg, ComboBox, CB_SETCURSEL, 0, ( LPARAM )0); } -// Save/Load Keys from own config file +// Save/load keys from own config file void SaveXInputConfigToFile( FILE *file, LPXCONTROLLER gController ); void LoadXInputConfigFromFile( FILE *file, LPXCONTROLLER gController ); diff --git a/Source/nragev20/commonIncludes.h b/Source/nragev20/commonIncludes.h index c61c99071..0c8c582ce 100644 --- a/Source/nragev20/commonIncludes.h +++ b/Source/nragev20/commonIncludes.h @@ -1,24 +1,23 @@ /* - N-Rage`s Dinput8 Plugin - (C) 2002, 2006 Norbert Wladyka +N-Rage`s Dinput8 Plugin +(C) 2002, 2006 Norbert Wladyka - Author`s Email: norbert.wladyka@chello.at - Website: http://go.to/nrage +Author`s Email: norbert.wladyka@chello.at +Website: http://go.to/nrage +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the free Software Foundation; either version 2 of the License, or +(at your option) any later version. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the free Software Foundation; either version 2 of the License, or - (at your option) any later version. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _COMMONINCLUDES_H_ diff --git a/Source/nragev20/settings.h b/Source/nragev20/settings.h index a1065de2b..1a853e131 100644 --- a/Source/nragev20/settings.h +++ b/Source/nragev20/settings.h @@ -1,24 +1,23 @@ /* - N-Rage`s Dinput8 Plugin - (C) 2002, 2006 Norbert Wladyka +N-Rage`s Dinput8 Plugin +(C) 2002, 2006 Norbert Wladyka - Author`s Email: norbert.wladyka@chello.at - Website: http://go.to/nrage +Author`s Email: norbert.wladyka@chello.at +Website: http://go.to/nrage +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the free Software Foundation; either version 2 of the License, or +(at your option) any later version. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the free Software Foundation; either version 2 of the License, or - (at your option) any later version. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _SETTINGS_H_ @@ -26,7 +25,7 @@ #define DIRECTINPUT_VERSION 0x0800 -// hacks for GNU C compilers // No thank you.... +// Hacks for GNU C compilers? No, thank you... #ifdef __GNUC__ #ifndef WINVER @@ -44,82 +43,77 @@ #endif // #ifdef __GNUC__ - // Our default buffer size for TCHAR arrays (resources get loaded through here) - // MAKE SURE localized resources do not exceed this limit, or they will be cut off. +// Our default buffer size for TCHAR arrays (resources get loaded through here) +// Make sure localized resources do not exceed this limit, or they will be cut off #define DEFAULT_BUFFER 256 - // use default settings for Release and Debugbuild +// Use default settings for 'release' and 'debug' builds #define STDCONFIG #ifndef STDCONFIG -// ---------------------------------------------------------------------------- -// custom (nonstandard) settings here - // workaround for a Adaptoiddriver bug; - // basically if the Adaptoid USB driver doesn't respond that there's a pak, say there is one anyway + +// Custom (nonstandard) settings here +// Workaround for a Adaptoid driver bug +// Basically if the Adaptoid USB driver doesn't respond that there's a pak, say there is one anyway #define ADAPTOIDPAK_RUMBLEFIX - // remove unimplemented Elements of the GUI +// Remove unimplemented elements of the GUI // #define HIDEUNIMPLEMENTED - // check controllercommands for valid CRC +// Check controller commands for valid CRC // #define MAKEADRESSCRCCHECK - // display Button for writing Shortcuts binary +// Display button for writing shortcuts binary // #define RAWPROFILEWRITE - // enable selection of Transferpak +// Enable selection of transfer pak // #define V_TRANSFERPAK - // enable selection of VoicePak +// Enable selection of voice pak // #define V_VOICEPAK -// ---------------------------------------------------------------------------- #else -// Standard Settings +// Standard settings #ifdef _DEBUG -// ---------------------------------------------------------------------------- -// Standard Debug Settings - // workaround for a Adaptoiddriver bug + +// Standard debug settings +// Workaround for a Adaptoid driver bug #define ADAPTOIDPAK_RUMBLEFIX - // remove unimplemented Elements of the GUI +// Remove unimplemented Elements of the GUI // #define HIDEUNIMPLEMENTED - // check controllercommands for valid CRC +// Check controller commands for valid CRC #define MAKEADRESSCRCCHECK - // display Button for writing Shortcuts binary +// Display button for writing shortcuts binary #define RAWPROFILEWRITE - // enable selection of Transferpak +// Enable selection of transfer pak #define V_TRANSFERPAK - // enable selection of VoicePak +// Enable selection of voice pak #define V_VOICEPAK -// spits out loads of extra info for ControllerCommand and ReadController +// Spits out loads of extra info for ControllerCommand and ReadController // #define ENABLE_RAWPAK_DEBUG -// ---------------------------------------------------------------------------- - #else -// ---------------------------------------------------------------------------- -// Standard Release Settings - // workaround for a Adaptoiddriver bug + +// Standard release settings +// Workaround for a Adaptoid driver bug #define ADAPTOIDPAK_RUMBLEFIX - // remove unimplemented Elements of the GUI +// Remove unimplemented elements of the GUI #define HIDEUNIMPLEMENTED - // check controllercommands for valid CRC +// Check controller commands for valid CRC // #define MAKEADRESSCRCCHECK - // display Button for writing Shortcuts binary +// Display button for writing shortcuts binary // #define RAWPROFILEWRITE - // enable selection of Transferpak +// Enable selection of transfer pak #define V_TRANSFERPAK - // enable selection of VoicePak +// Enable selection of voice pak // #define V_VOICEPAK -// ---------------------------------------------------------------------------- - #endif // #ifdef _DEBUG #endif // #ifndef STDCONFIG #undef STDCONFIG