From 8b2c66cc07bc1c1f5023bf57ae6c83c3640450e3 Mon Sep 17 00:00:00 2001 From: zilmar Date: Mon, 27 Jun 2022 19:32:38 +0930 Subject: [PATCH] Core: Move plugin specs to a central location --- Android/jni/Project64-core/CMakeLists.txt | 1 - Source/Android/Bridge/jniBridgeSettings.cpp | 2 +- Source/Android/PluginInput/Controller_1.1.h | 232 ---------- Source/Android/PluginInput/Main.cpp | 6 +- .../Android/PluginInput/PluginInput.vcxproj | 1 - .../PluginInput/PluginInput.vcxproj.filters | 3 - Source/Android/PluginRSP/common.h | 2 +- Source/Project64-audio/AudioMain.cpp | 13 +- Source/Project64-audio/AudioMain.h | 2 +- Source/Project64-audio/Audio_1.1.h | 212 --------- Source/Project64-audio/Driver/DirectSound.cpp | 2 +- Source/Project64-audio/Driver/OpenSLES.cpp | 2 +- Source/Project64-audio/Driver/OpenSLES.h | 2 +- Source/Project64-audio/Driver/SoundBase.h | 10 + .../Project64-audio/Project64-audio.vcxproj | 1 - .../Project64-audio.vcxproj.filters | 3 - Source/Project64-core/AppInit.cpp | 8 +- .../Project64-core/N64System/Mips/PifRam.cpp | 7 +- Source/Project64-core/N64System/N64System.cpp | 6 +- Source/Project64-core/Plugins/AudioPlugin.cpp | 64 +-- .../Plugins/ControllerPlugin.cpp | 4 +- .../Project64-core/Plugins/ControllerPlugin.h | 67 +-- Source/Project64-core/Plugins/GFXPlugin.cpp | 57 ++- Source/Project64-core/Plugins/GFXPlugin.h | 2 +- Source/Project64-core/Plugins/Plugin.cpp | 20 +- Source/Project64-core/Plugins/Plugin.h | 26 +- Source/Project64-core/Plugins/PluginBase.cpp | 37 +- Source/Project64-core/Plugins/PluginBase.h | 25 +- Source/Project64-core/Project64-core.vcxproj | 5 + .../Project64-core.vcxproj.filters | 18 + Source/Project64-core/Settings.cpp | 2 +- Source/Project64-core/Settings/SettingsID.h | 2 +- Source/Project64-core/TraceModulesProject64.h | 2 +- Source/Project64-input/CProject64Input.cpp | 6 +- Source/Project64-input/CProject64Input.h | 2 +- Source/Project64-input/DirectInput.cpp | 2 +- Source/Project64-input/DirectInput.h | 2 +- Source/Project64-input/InputMain.cpp | 6 +- Source/Project64-input/InputSettings.h | 2 +- Source/Project64-input/OptionsUI.cpp | 2 +- Source/Project64-input/OptionsUI.h | 2 +- Source/Project64-input/ShortcutsUI.h | 2 +- Source/Project64-plugin-spec/Audio.h | 158 +++++++ Source/Project64-plugin-spec/Base.h | 114 +++++ .../Input.h} | 121 +----- Source/Project64-plugin-spec/Rsp.h | 91 ++++ Source/Project64-plugin-spec/Video.h | 410 ++++++++++++++++++ Source/Project64-video/Gfx_1.3.h | 399 ++--------------- Source/Project64-video/Main.cpp | 8 +- Source/Project64-video/rdp.cpp | 14 +- Source/Project64/Plugins/PluginList.cpp | 2 +- Source/Project64/UserInterface/MainMenu.cpp | 20 +- Source/Project64/UserInterface/MainWindow.cpp | 12 +- .../Project64/UserInterface/Notification.cpp | 4 +- .../Settings/SettingsPage-Game-Plugin.cpp | 2 +- .../Settings/SettingsPage-Plugin.cpp | 2 +- Source/RSP/Cpu.c | 2 +- Source/RSP/Main.cpp | 4 +- Source/RSP/Recompiler CPU.c | 2 +- Source/RSP/Rsp.h | 121 +----- 60 files changed, 1015 insertions(+), 1343 deletions(-) delete mode 100644 Source/Android/PluginInput/Controller_1.1.h delete mode 100644 Source/Project64-audio/Audio_1.1.h create mode 100644 Source/Project64-plugin-spec/Audio.h create mode 100644 Source/Project64-plugin-spec/Base.h rename Source/{Project64-input/ControllerSpec1.1.h => Project64-plugin-spec/Input.h} (62%) create mode 100644 Source/Project64-plugin-spec/Rsp.h create mode 100644 Source/Project64-plugin-spec/Video.h diff --git a/Android/jni/Project64-core/CMakeLists.txt b/Android/jni/Project64-core/CMakeLists.txt index 0746d0f64..6f33a4c73 100644 --- a/Android/jni/Project64-core/CMakeLists.txt +++ b/Android/jni/Project64-core/CMakeLists.txt @@ -34,7 +34,6 @@ add_library(Project64-core STATIC N64System/MemoryHandler/SerialInterfaceHandler.cpp N64System/MemoryHandler/SPRegistersHandler.cpp N64System/MemoryHandler/VideoInterfaceHandler.cpp - N64System/Mips/Dma.cpp N64System/Mips/Disk.cpp N64System/Mips/GBCart.cpp N64System/Mips/MemoryVirtualMem.cpp diff --git a/Source/Android/Bridge/jniBridgeSettings.cpp b/Source/Android/Bridge/jniBridgeSettings.cpp index 2fadbf53c..c520f4b74 100644 --- a/Source/Android/Bridge/jniBridgeSettings.cpp +++ b/Source/Android/Bridge/jniBridgeSettings.cpp @@ -280,7 +280,7 @@ CJniBridegSettings::CJniBridegSettings() ADD_SETTING(Debugger_TraceAppCleanup); ADD_SETTING(Debugger_TraceN64System); ADD_SETTING(Debugger_TracePlugins); - ADD_SETTING(Debugger_TraceGFXPlugin); + ADD_SETTING(Debugger_TraceVideoPlugin); ADD_SETTING(Debugger_TraceAudioPlugin); ADD_SETTING(Debugger_TraceControllerPlugin); ADD_SETTING(Debugger_TraceRSPPlugin); diff --git a/Source/Android/PluginInput/Controller_1.1.h b/Source/Android/PluginInput/Controller_1.1.h deleted file mode 100644 index 5aa4159b9..000000000 --- a/Source/Android/PluginInput/Controller_1.1.h +++ /dev/null @@ -1,232 +0,0 @@ -// Common controller plugin specification, version 1.1 - -#pragma once -#include - -enum { PLUGIN_TYPE_CONTROLLER = 4 }; - -// Controller plugins - -enum -{ - PLUGIN_NONE = 1, - PLUGIN_MEMPAK = 2, - PLUGIN_RUMBLE_PAK = 3, - PLUGIN_TANSFER_PAK = 4, - PLUGIN_RAW = 5, -}; - -#if defined(_WIN32) -#define EXPORT extern "C" __declspec(dllexport) -#define CALL __cdecl -#else -#define EXPORT extern "C" __attribute__((visibility("default"))) -#define CALL -#endif - -// Structures - -typedef struct -{ - uint16_t Version; // Should be set to 0x0101 - uint16_t Type; // Set to PLUGIN_TYPE_CONTROLLER - char Name[100]; // Name of the DLL - int32_t Reserved1; - int32_t Reserved2; -} PLUGIN_INFO; - -typedef struct -{ - int32_t Present; - int32_t RawData; - int32_t Plugin; -} CONTROL; - -#pragma warning(push) -#pragma warning(disable : 4201) // warning C4201: nonstandard extension used: nameless struct/union - -typedef union -{ - uint32_t Value; - struct - { - unsigned R_DPAD : 1; - unsigned L_DPAD : 1; - unsigned D_DPAD : 1; - unsigned U_DPAD : 1; - unsigned START_BUTTON : 1; - unsigned Z_TRIG : 1; - unsigned B_BUTTON : 1; - unsigned A_BUTTON : 1; - - unsigned R_CBUTTON : 1; - unsigned L_CBUTTON : 1; - unsigned D_CBUTTON : 1; - unsigned U_CBUTTON : 1; - unsigned R_TRIG : 1; - unsigned L_TRIG : 1; - unsigned Reserved1 : 1; - unsigned Reserved2 : 1; - - signed X_AXIS : 8; - - signed Y_AXIS : 8; - }; -} BUTTONS; -#pragma warning(pop) - -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]; -} CONTROL_INFO; - -/* -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 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: -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 -*/ - -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 -*/ - -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 -*/ - -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 -*/ - -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 -*/ - -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. -- 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); - -/* -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, uint8_t * Command); - -/* -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 -*/ - -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 -*/ - -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 -*/ - -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 51cfde70f..163b4d6a6 100644 --- a/Source/Android/PluginInput/Main.cpp +++ b/Source/Android/PluginInput/Main.cpp @@ -1,5 +1,5 @@ -#include "Controller_1.1.h" #include "Version.h" +#include #include #include @@ -131,9 +131,9 @@ the emulator to know how to handle each controller. Output: None */ -EXPORT void CALL InitiateControllers (CONTROL_INFO ControlInfo) +EXPORT void CALL InitiateControllers (CONTROL_INFO * ControlInfo) { - g_control_info = ControlInfo; + g_control_info = *ControlInfo; g_control_info.Controls[0].Present = true; g_control_info.Controls[0].Plugin = PLUGIN_MEMPAK; } diff --git a/Source/Android/PluginInput/PluginInput.vcxproj b/Source/Android/PluginInput/PluginInput.vcxproj index 907bf77d0..004c550d3 100644 --- a/Source/Android/PluginInput/PluginInput.vcxproj +++ b/Source/Android/PluginInput/PluginInput.vcxproj @@ -36,7 +36,6 @@ - diff --git a/Source/Android/PluginInput/PluginInput.vcxproj.filters b/Source/Android/PluginInput/PluginInput.vcxproj.filters index 2e4cd97e8..edecba452 100644 --- a/Source/Android/PluginInput/PluginInput.vcxproj.filters +++ b/Source/Android/PluginInput/PluginInput.vcxproj.filters @@ -15,9 +15,6 @@ - - Header Files - Header Files diff --git a/Source/Android/PluginRSP/common.h b/Source/Android/PluginRSP/common.h index 82167c42b..fb48ad270 100644 --- a/Source/Android/PluginRSP/common.h +++ b/Source/Android/PluginRSP/common.h @@ -33,7 +33,7 @@ enum { PLUGIN_TYPE_RSP = 1, - PLUGIN_TYPE_GFX = 2, + PLUGIN_TYPE_VIDEO = 2, PLUGIN_TYPE_AUDIO = 3, PLUGIN_TYPE_CONTROLLER = 4, }; diff --git a/Source/Project64-audio/AudioMain.cpp b/Source/Project64-audio/AudioMain.cpp index b919b931d..d3e3c75dd 100644 --- a/Source/Project64-audio/AudioMain.cpp +++ b/Source/Project64-audio/AudioMain.cpp @@ -14,7 +14,7 @@ #else #include #endif -#include "audio_1.1.h" +#include #include "Version.h" #include #include @@ -44,6 +44,13 @@ DirectSoundDriver * g_SoundDriver = nullptr; OpenSLESDriver * g_SoundDriver = nullptr; #endif +enum SYSTEM_TYPE +{ + SYSTEM_NTSC = 0, + SYSTEM_PAL = 1, + SYSTEM_MPAL = 2, +}; + void PluginInit(void) { if (g_PluginInit) @@ -205,8 +212,8 @@ EXPORT void CALL GetDllInfo(PLUGIN_INFO * PluginInfo) #else sprintf(PluginInfo->Name, "Project64 audio plugin: %s", VER_FILE_VERSION_STR); #endif - PluginInfo->MemoryBswaped = true; - PluginInfo->NormalMemory = false; + PluginInfo->Reserved1 = false; + PluginInfo->Reserved2 = true; } EXPORT int32_t CALL InitiateAudio(AUDIO_INFO Audio_Info) diff --git a/Source/Project64-audio/AudioMain.h b/Source/Project64-audio/AudioMain.h index 9fcf08bfd..0257b2641 100644 --- a/Source/Project64-audio/AudioMain.h +++ b/Source/Project64-audio/AudioMain.h @@ -1,4 +1,4 @@ #pragma once -#include "audio_1.1.h" +#include extern AUDIO_INFO g_AudioInfo; diff --git a/Source/Project64-audio/Audio_1.1.h b/Source/Project64-audio/Audio_1.1.h deleted file mode 100644 index e66fadfc6..000000000 --- a/Source/Project64-audio/Audio_1.1.h +++ /dev/null @@ -1,212 +0,0 @@ -// Common audio plugin spec, version 1.1 - -/* -Notes: -Setting the appropriate bits in the MI_INTR_REG and calling CheckInterrupts which -are both passed to the DLL in InitiateAudio will generate an Interrupt from with in -the plugin. -*/ - -#pragma once - -#include - -enum { PLUGIN_TYPE_AUDIO = 3 }; - -#if defined(_WIN32) -#define EXPORT extern "C" __declspec(dllexport) -#define CALL __cdecl -#else -#define EXPORT extern "C" __attribute__((visibility("default"))) -#define CALL -#endif - -enum -{ - SYSTEM_NTSC = 0, - SYSTEM_PAL = 1, - SYSTEM_MPAL = 2, -}; - -enum -{ - AI_STATUS_FIFO_FULL = 0x80000000, // Bit 31: full - AI_STATUS_DMA_BUSY = 0x40000000, // Bit 30: busy - - MI_INTR_AI = 0x04, // Bit 2: AI INTR - AI_CONTROL_DMA_ON = 0x01, - AI_CONTROL_DMA_OFF = 0x00, -}; - -// Structures - -typedef struct -{ - uint16_t Version; // Should be set to 0x0101 - uint16_t Type; // Set to PLUGIN_TYPE_AUDIO - char Name[100]; // Name of the DLL - int32_t NormalMemory; - int32_t MemoryBswaped; -} PLUGIN_INFO; - -typedef struct -{ - void * hwnd; - void * hinst; - - 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. - uint8_t * RDRAM; - uint8_t * DMEM; - uint8_t * IMEM; - - uint32_t * MI_INTR_REG; - - uint32_t * AI_DRAM_ADDR_REG; - uint32_t * AI_LEN_REG; - uint32_t * AI_CONTROL_REG; - uint32_t * AI_STATUS_REG; - uint32_t * AI_DACRATE_REG; - uint32_t * AI_BITRATE_REG; - - void(CALL *CheckInterrupts)(void); -} AUDIO_INFO; - -/* -Function: AiDacrateChanged -Purpose: This function is called to notify the DLL that the -AiDacrate registers value has been changed. -Input: The system type: -SYSTEM_NTSC 0 -SYSTEM_PAL 1 -SYSTEM_MPAL 2 -Output: None -*/ - -EXPORT void CALL AiDacrateChanged(int32_t SystemType); - -/* -Function: AiLenChanged -Purpose: This function is called to notify the DLL that the -AiLen registers value has been changed. -Input: None -Output: None -*/ - -EXPORT void CALL AiLenChanged(void); - -/* -Function: AiReadLength -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. -*/ - -EXPORT uint32_t CALL AiReadLength(void); - -/* -Function: AiUpdate -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 -till there is a message in its message queue. -Output: None -*/ - -EXPORT void CALL AiUpdate(int32_t Wait); - -/* -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: 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(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 -*/ - -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 -*/ - -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 -*/ - -EXPORT void CALL GetDllInfo(PLUGIN_INFO * PluginInfo); - -/* -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 -above. -Output: True on success -FALSE on failure to initialize -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. -*/ - -EXPORT int32_t CALL InitiateAudio(AUDIO_INFO Audio_Info); - -/* -Function: ProcessAList -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 -*/ - -EXPORT void CALL ProcessAList(void); - -/* -Function: RomClosed -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 f5a6e2214..b1a29abb5 100644 --- a/Source/Project64-audio/Driver/DirectSound.cpp +++ b/Source/Project64-audio/Driver/DirectSound.cpp @@ -42,7 +42,7 @@ bool DirectSoundDriver::Initialize() return false; } - hr = lpds->SetCooperativeLevel((HWND)g_AudioInfo.hwnd, DSSCL_PRIORITY); + hr = lpds->SetCooperativeLevel((HWND)g_AudioInfo.hWnd, DSSCL_PRIORITY); if (FAILED(hr)) { WriteTrace(TraceAudioDriver, TraceWarning, "Failed to SetCooperativeLevel (hr: 0x%08X)", hr); diff --git a/Source/Project64-audio/Driver/OpenSLES.cpp b/Source/Project64-audio/Driver/OpenSLES.cpp index 772174800..52695088e 100644 --- a/Source/Project64-audio/Driver/OpenSLES.cpp +++ b/Source/Project64-audio/Driver/OpenSLES.cpp @@ -360,7 +360,7 @@ void queueCallback(SLAndroidSimpleBufferQueueItf caller, void *context) } #endif -void OpenSLESDriver::AI_SetFrequency(uint32_t freq, uint32_t BufferSize) +void OpenSLESDriver::AI_SetFrequency(uint32_t freq, uint32_t /*BufferSize*/) { WriteTrace(TraceAudioInitShutdown, TraceDebug, "Start (freq: %d)", freq); if (freq < 4000) diff --git a/Source/Project64-audio/Driver/OpenSLES.h b/Source/Project64-audio/Driver/OpenSLES.h index 8609aa499..9c85e53af 100644 --- a/Source/Project64-audio/Driver/OpenSLES.h +++ b/Source/Project64-audio/Driver/OpenSLES.h @@ -10,7 +10,7 @@ #pragma once #include -#include +#include #include "SoundBase.h" class OpenSLESDriver : diff --git a/Source/Project64-audio/Driver/SoundBase.h b/Source/Project64-audio/Driver/SoundBase.h index 5a8cc36a5..0fc821cdc 100644 --- a/Source/Project64-audio/Driver/SoundBase.h +++ b/Source/Project64-audio/Driver/SoundBase.h @@ -8,6 +8,16 @@ #include #include +enum +{ + AI_STATUS_FIFO_FULL = 0x80000000, // Bit 31: full + AI_STATUS_DMA_BUSY = 0x40000000, // Bit 30: busy + + MI_INTR_AI = 0x04, // Bit 2: AI INTR + AI_CONTROL_DMA_ON = 0x01, + AI_CONTROL_DMA_OFF = 0x00, +}; + class SoundDriverBase { public: diff --git a/Source/Project64-audio/Project64-audio.vcxproj b/Source/Project64-audio/Project64-audio.vcxproj index a8d072adf..cf84ae4d4 100644 --- a/Source/Project64-audio/Project64-audio.vcxproj +++ b/Source/Project64-audio/Project64-audio.vcxproj @@ -61,7 +61,6 @@ - diff --git a/Source/Project64-audio/Project64-audio.vcxproj.filters b/Source/Project64-audio/Project64-audio.vcxproj.filters index 5fcfdc0c6..13add89bf 100644 --- a/Source/Project64-audio/Project64-audio.vcxproj.filters +++ b/Source/Project64-audio/Project64-audio.vcxproj.filters @@ -44,9 +44,6 @@ - - Header Files - Header Files diff --git a/Source/Project64-core/AppInit.cpp b/Source/Project64-core/AppInit.cpp index 15612c6d6..61a37d2eb 100644 --- a/Source/Project64-core/AppInit.cpp +++ b/Source/Project64-core/AppInit.cpp @@ -59,7 +59,7 @@ void SetTraceModuleNames(void) TraceSetModuleName(TraceAppCleanup, "App Cleanup"); TraceSetModuleName(TraceN64System, "N64 System"); TraceSetModuleName(TracePlugins, "Plugins"); - TraceSetModuleName(TraceGFXPlugin, "GFX Plugin"); + TraceSetModuleName(TraceVideoPlugin, "GFX Plugin"); TraceSetModuleName(TraceAudioPlugin, "Audio Plugin"); TraceSetModuleName(TraceControllerPlugin, "Controller Plugin"); TraceSetModuleName(TraceRSPPlugin, "RSP Plugin"); @@ -85,7 +85,7 @@ void UpdateTraceLevel(void * /*NotUsed*/) g_ModuleLogLevel[TraceAppCleanup] = (uint8_t)g_Settings->LoadDword(Debugger_TraceAppCleanup); g_ModuleLogLevel[TraceN64System] = (uint8_t)g_Settings->LoadDword(Debugger_TraceN64System); g_ModuleLogLevel[TracePlugins] = (uint8_t)g_Settings->LoadDword(Debugger_TracePlugins); - g_ModuleLogLevel[TraceGFXPlugin] = (uint8_t)g_Settings->LoadDword(Debugger_TraceGFXPlugin); + g_ModuleLogLevel[TraceVideoPlugin] = (uint8_t)g_Settings->LoadDword(Debugger_TraceVideoPlugin); g_ModuleLogLevel[TraceAudioPlugin] = (uint8_t)g_Settings->LoadDword(Debugger_TraceAudioPlugin); g_ModuleLogLevel[TraceControllerPlugin] = (uint8_t)g_Settings->LoadDword(Debugger_TraceControllerPlugin); g_ModuleLogLevel[TraceRSPPlugin] = (uint8_t)g_Settings->LoadDword(Debugger_TraceRSPPlugin); @@ -113,7 +113,7 @@ void SetupTrace(void) g_Settings->RegisterChangeCB(Debugger_TraceAppCleanup, nullptr, (CSettings::SettingChangedFunc)UpdateTraceLevel); g_Settings->RegisterChangeCB(Debugger_TraceN64System, nullptr, (CSettings::SettingChangedFunc)UpdateTraceLevel); g_Settings->RegisterChangeCB(Debugger_TracePlugins, nullptr, (CSettings::SettingChangedFunc)UpdateTraceLevel); - g_Settings->RegisterChangeCB(Debugger_TraceGFXPlugin, nullptr, (CSettings::SettingChangedFunc)UpdateTraceLevel); + g_Settings->RegisterChangeCB(Debugger_TraceVideoPlugin, nullptr, (CSettings::SettingChangedFunc)UpdateTraceLevel); g_Settings->RegisterChangeCB(Debugger_TraceAudioPlugin, nullptr, (CSettings::SettingChangedFunc)UpdateTraceLevel); g_Settings->RegisterChangeCB(Debugger_TraceControllerPlugin, nullptr, (CSettings::SettingChangedFunc)UpdateTraceLevel); g_Settings->RegisterChangeCB(Debugger_TraceRSPPlugin, nullptr, (CSettings::SettingChangedFunc)UpdateTraceLevel); @@ -145,7 +145,7 @@ void CleanupTrace(void) g_Settings->UnregisterChangeCB(Debugger_TraceAppCleanup, nullptr, (CSettings::SettingChangedFunc)UpdateTraceLevel); g_Settings->UnregisterChangeCB(Debugger_TraceN64System, nullptr, (CSettings::SettingChangedFunc)UpdateTraceLevel); g_Settings->UnregisterChangeCB(Debugger_TracePlugins, nullptr, (CSettings::SettingChangedFunc)UpdateTraceLevel); - g_Settings->UnregisterChangeCB(Debugger_TraceGFXPlugin, nullptr, (CSettings::SettingChangedFunc)UpdateTraceLevel); + g_Settings->UnregisterChangeCB(Debugger_TraceVideoPlugin, nullptr, (CSettings::SettingChangedFunc)UpdateTraceLevel); g_Settings->UnregisterChangeCB(Debugger_TraceAudioPlugin, nullptr, (CSettings::SettingChangedFunc)UpdateTraceLevel); g_Settings->UnregisterChangeCB(Debugger_TraceControllerPlugin, nullptr, (CSettings::SettingChangedFunc)UpdateTraceLevel); g_Settings->UnregisterChangeCB(Debugger_TraceRSPPlugin, nullptr, (CSettings::SettingChangedFunc)UpdateTraceLevel); diff --git a/Source/Project64-core/N64System/Mips/PifRam.cpp b/Source/Project64-core/N64System/Mips/PifRam.cpp index 96f1233d4..8e6cdf950 100644 --- a/Source/Project64-core/N64System/Mips/PifRam.cpp +++ b/Source/Project64-core/N64System/Mips/PifRam.cpp @@ -12,6 +12,7 @@ #include #include #include +#include CPifRam::CPifRam(bool SavesReadOnly) : CEeprom(SavesReadOnly) @@ -469,7 +470,7 @@ void CPifRam::ProcessControllerCommand(int32_t Control, uint8_t * Command) Command[4] = 0x00; switch (Controllers[Control].Plugin) { - case PLUGIN_TANSFER_PAK: + case PLUGIN_TRANSFER_PAK: case PLUGIN_RUMBLE_PAK: case PLUGIN_MEMPAK: case PLUGIN_RAW: @@ -524,7 +525,7 @@ void CPifRam::ProcessControllerCommand(int32_t Control, uint8_t * Command) { case PLUGIN_RUMBLE_PAK: Rumblepak::ReadFrom(address, data); break; case PLUGIN_MEMPAK: g_Mempak->ReadFrom(Control, address, data); break; - case PLUGIN_TANSFER_PAK: Transferpak::ReadFrom((uint16_t)address, data); break; + case PLUGIN_TRANSFER_PAK: Transferpak::ReadFrom((uint16_t)address, data); break; case PLUGIN_RAW: if (g_Plugins->Control()->ControllerCommand) { g_Plugins->Control()->ControllerCommand(Control, Command); } break; default: memset(&Command[5], 0, 0x20); @@ -565,7 +566,7 @@ void CPifRam::ProcessControllerCommand(int32_t Control, uint8_t * Command) { case PLUGIN_MEMPAK: g_Mempak->WriteTo(Control, address, data); break; case PLUGIN_RUMBLE_PAK: Rumblepak::WriteTo(Control, address, data); break; - case PLUGIN_TANSFER_PAK: Transferpak::WriteTo((uint16_t)address, data); break; + case PLUGIN_TRANSFER_PAK: Transferpak::WriteTo((uint16_t)address, data); break; case PLUGIN_RAW: if (g_Plugins->Control()->ControllerCommand) { g_Plugins->Control()->ControllerCommand(Control, Command); } break; } diff --git a/Source/Project64-core/N64System/N64System.cpp b/Source/Project64-core/N64System/N64System.cpp index 4b01d5cea..e2514be4f 100644 --- a/Source/Project64-core/N64System/N64System.cpp +++ b/Source/Project64-core/N64System/N64System.cpp @@ -2487,17 +2487,17 @@ void CN64System::RefreshScreen() __except_try() { - WriteTrace(TraceGFXPlugin, TraceDebug, "UpdateScreen starting"); + WriteTrace(TraceVideoPlugin, TraceDebug, "UpdateScreen starting"); m_Plugins->Gfx()->UpdateScreen(); if (g_Debugger != nullptr && HaveDebugger()) { g_Debugger->FrameDrawn(); } - WriteTrace(TraceGFXPlugin, TraceDebug, "UpdateScreen done"); + WriteTrace(TraceVideoPlugin, TraceDebug, "UpdateScreen done"); } __except_catch() { - WriteTrace(TraceGFXPlugin, TraceError, "Exception caught"); + WriteTrace(TraceVideoPlugin, TraceError, "Exception caught"); } g_MMU->VideoInterface().UpdateFieldSerration((m_Reg.VI_STATUS_REG & 0x40) != 0); diff --git a/Source/Project64-core/Plugins/AudioPlugin.cpp b/Source/Project64-core/Plugins/AudioPlugin.cpp index f34e899df..f68a2fcb7 100644 --- a/Source/Project64-core/Plugins/AudioPlugin.cpp +++ b/Source/Project64-core/Plugins/AudioPlugin.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #ifdef _WIN32 #include #endif @@ -28,7 +29,7 @@ CAudioPlugin::~CAudioPlugin() bool CAudioPlugin::LoadFunctions(void) { - g_Settings->SaveBool(Setting_SyncViaAudioEnabled, false); + g_Settings->SaveBool(Setting_SyncViaAudioEnabled, false); // Find entries for functions in DLL void(CALL *InitiateAudio)(void); @@ -55,32 +56,6 @@ bool CAudioPlugin::LoadFunctions(void) bool CAudioPlugin::Initiate(CN64System * System, RenderWindow * Window) { - struct AUDIO_INFO - { - void * hwnd; - void * hinst; - - 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 - uint8_t * RDRAM; - uint8_t * DMEM; - uint8_t * IMEM; - - uint32_t * MI__INTR_REG; - - uint32_t * AI__DRAM_ADDR_REG; - uint32_t * AI__LEN_REG; - uint32_t * AI__CONTROL_REG; - uint32_t * AI__STATUS_REG; - uint32_t * AI__DACRATE_REG; - uint32_t * AI__BITRATE_REG; - - void(CALL *CheckInterrupts)(void); - }; - // Get function from DLL int32_t(CALL *InitiateAudio)(AUDIO_INFO Audio_Info); LoadFunction(InitiateAudio); @@ -89,13 +64,13 @@ bool CAudioPlugin::Initiate(CN64System * System, RenderWindow * Window) AUDIO_INFO Info = { 0 }; #ifdef _WIN32 - Info.hwnd = Window ? Window->GetWindowHandle() : nullptr; + Info.hWnd = Window ? Window->GetWindowHandle() : nullptr; Info.hinst = Window ? Window->GetModuleInstance() : nullptr; #else - Info.hwnd = nullptr; + Info.hWnd = nullptr; Info.hinst = nullptr; #endif - Info.MemoryBswaped = true; + Info.Reserved = true; Info.CheckInterrupts = DummyCheckInterrupts; // We are initializing the plugin before any ROM is loaded so we do not have any correct @@ -109,13 +84,13 @@ bool CAudioPlugin::Initiate(CN64System * System, RenderWindow * Window) Info.RDRAM = Buffer; Info.DMEM = Buffer; Info.IMEM = Buffer; - Info.MI__INTR_REG = &Value; - Info.AI__DRAM_ADDR_REG = &Value; - Info.AI__LEN_REG = &Value; - Info.AI__CONTROL_REG = &Value; - Info.AI__STATUS_REG = &Value; - Info.AI__DACRATE_REG = &Value; - Info.AI__BITRATE_REG = &Value; + Info.MI_INTR_REG = &Value; + Info.AI_DRAM_ADDR_REG = &Value; + Info.AI_LEN_REG = &Value; + Info.AI_CONTROL_REG = &Value; + Info.AI_STATUS_REG = &Value; + Info.AI_DACRATE_REG = &Value; + Info.AI_BITRATE_REG = &Value; } // Send initialization information to the DLL else @@ -130,15 +105,14 @@ bool CAudioPlugin::Initiate(CN64System * System, RenderWindow * Window) Info.RDRAM = MMU.Rdram(); Info.DMEM = MMU.Dmem(); Info.IMEM = MMU.Imem(); - Info.MI__INTR_REG = &Reg.m_AudioIntrReg; - Info.AI__DRAM_ADDR_REG = &Reg.AI_DRAM_ADDR_REG; - Info.AI__LEN_REG = &Reg.AI_LEN_REG; - Info.AI__CONTROL_REG = &Reg.AI_CONTROL_REG; - Info.AI__STATUS_REG = &Reg.AI_STATUS_REG; - Info.AI__DACRATE_REG = &Reg.AI_DACRATE_REG; - Info.AI__BITRATE_REG = &Reg.AI_BITRATE_REG; + Info.MI_INTR_REG = &Reg.m_AudioIntrReg; + Info.AI_DRAM_ADDR_REG = &Reg.AI_DRAM_ADDR_REG; + Info.AI_LEN_REG = &Reg.AI_LEN_REG; + Info.AI_CONTROL_REG = &Reg.AI_CONTROL_REG; + Info.AI_STATUS_REG = &Reg.AI_STATUS_REG; + Info.AI_DACRATE_REG = &Reg.AI_DACRATE_REG; + Info.AI_BITRATE_REG = &Reg.AI_BITRATE_REG; } - m_Initialized = InitiateAudio(Info) != 0; #ifdef _WIN32 diff --git a/Source/Project64-core/Plugins/ControllerPlugin.cpp b/Source/Project64-core/Plugins/ControllerPlugin.cpp index f0636a236..bb4b223c6 100644 --- a/Source/Project64-core/Plugins/ControllerPlugin.cpp +++ b/Source/Project64-core/Plugins/ControllerPlugin.cpp @@ -86,12 +86,12 @@ bool CControl_Plugin::Initiate(CN64System * System, RenderWindow * Window) ControlInfo.HEADER = (System == nullptr ? Buffer : g_Rom->GetRomAddress()); #ifdef _WIN32 ControlInfo.hinst = Window ? Window->GetModuleInstance() : nullptr; - ControlInfo.hMainWindow = Window ? Window->GetWindowHandle() : nullptr; + ControlInfo.hWnd = Window ? Window->GetWindowHandle() : nullptr; #else ControlInfo.hinst = nullptr; ControlInfo.hMainWindow = nullptr; #endif - ControlInfo.MemoryBswaped = true; + ControlInfo.Reserved = true; if (m_PluginInfo.Version == 0x0101) { diff --git a/Source/Project64-core/Plugins/ControllerPlugin.h b/Source/Project64-core/Plugins/ControllerPlugin.h index fdb7874f8..e08b51921 100644 --- a/Source/Project64-core/Plugins/ControllerPlugin.h +++ b/Source/Project64-core/Plugins/ControllerPlugin.h @@ -1,71 +1,6 @@ #pragma once #include - -#pragma warning(push) -#pragma warning(disable : 4201) // warning C4201: nonstandard extension used : nameless struct/union - -typedef union -{ - uint32_t Value; - struct - { - unsigned R_DPAD : 1; - unsigned L_DPAD : 1; - unsigned D_DPAD : 1; - unsigned U_DPAD : 1; - unsigned START_BUTTON : 1; - unsigned Z_TRIG : 1; - unsigned B_BUTTON : 1; - unsigned A_BUTTON : 1; - - unsigned R_CBUTTON : 1; - unsigned L_CBUTTON : 1; - unsigned D_CBUTTON : 1; - unsigned U_CBUTTON : 1; - unsigned R_TRIG : 1; - unsigned L_TRIG : 1; - unsigned Reserved1 : 1; - unsigned Reserved2 : 1; - - signed X_AXIS : 8; - - signed Y_AXIS : 8; - }; -} BUTTONS; -#pragma warning(pop) - -typedef struct -{ - int32_t Present; - int32_t RawData; - int32_t Plugin; -} CONTROL; - -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]; -} CONTROL_INFO; - -enum PluginType -{ - PLUGIN_NONE = 1, - PLUGIN_MEMPAK = 2, - PLUGIN_RUMBLE_PAK = 3, - PLUGIN_TANSFER_PAK = 4, // Not implemented for non-raw data - PLUGIN_RAW = 5, // The controller plugin is passed in raw data -}; - -enum PresentType -{ - PRESENT_NONE = 0, - PRESENT_CONT = 1, - PRESENT_MOUSE = 2, -}; +#include class CControl_Plugin; diff --git a/Source/Project64-core/Plugins/GFXPlugin.cpp b/Source/Project64-core/Plugins/GFXPlugin.cpp index 2b12e3933..a404ebc42 100644 --- a/Source/Project64-core/Plugins/GFXPlugin.cpp +++ b/Source/Project64-core/Plugins/GFXPlugin.cpp @@ -8,32 +8,32 @@ #include "GFXPlugin.h" CGfxPlugin::CGfxPlugin() : -CaptureScreen(nullptr), -ChangeWindow(nullptr), -DrawScreen(nullptr), -DrawStatus(nullptr), -MoveScreen(nullptr), -ProcessDList(nullptr), -ProcessRDPList(nullptr), -ShowCFB(nullptr), -UpdateScreen(nullptr), -ViStatusChanged(nullptr), -ViWidthChanged(nullptr), -SoftReset(nullptr), -GetRomBrowserMenu(nullptr), -OnRomBrowserMenuItem(nullptr), -GetDebugInfo(nullptr), -InitiateDebugger(nullptr) + CaptureScreen(nullptr), + ChangeWindow(nullptr), + DrawScreen(nullptr), + DrawStatus(nullptr), + MoveScreen(nullptr), + ProcessDList(nullptr), + ProcessRDPList(nullptr), + ShowCFB(nullptr), + UpdateScreen(nullptr), + ViStatusChanged(nullptr), + ViWidthChanged(nullptr), + SoftReset(nullptr), + GetRomBrowserMenu(nullptr), + OnRomBrowserMenuItem(nullptr), + GetDebugInfo(nullptr), + InitiateDebugger(nullptr) { memset(&m_GFXDebug, 0, sizeof(m_GFXDebug)); } CGfxPlugin::~CGfxPlugin() { - WriteTrace(TraceGFXPlugin, TraceDebug, "Start"); + WriteTrace(TraceVideoPlugin, TraceDebug, "Start"); Close(nullptr); UnloadPlugin(); - WriteTrace(TraceGFXPlugin, TraceDebug, "Done"); + WriteTrace(TraceVideoPlugin, TraceDebug, "Done"); } bool CGfxPlugin::LoadFunctions(void) @@ -99,7 +99,7 @@ bool CGfxPlugin::LoadFunctions(void) bool CGfxPlugin::Initiate(CN64System * System, RenderWindow * Window) { - WriteTrace(TraceGFXPlugin, TraceDebug, "Start"); + WriteTrace(TraceVideoPlugin, TraceDebug, "Start"); if (m_Initialized) { Close(Window); @@ -163,7 +163,7 @@ bool CGfxPlugin::Initiate(CN64System * System, RenderWindow * Window) _LoadFunction("InitiateGFX", InitiateGFX); if (InitiateGFX == nullptr) { - WriteTrace(TraceGFXPlugin, TraceDebug, "Failed to find InitiateGFX"); + WriteTrace(TraceVideoPlugin, TraceDebug, "Failed to find InitiateGFX"); return false; } @@ -186,7 +186,7 @@ bool CGfxPlugin::Initiate(CN64System * System, RenderWindow * Window) // 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); + WriteTrace(TraceVideoPlugin, TraceDebug, "System = %X", System); if (System == nullptr) { static uint8_t Buffer[100]; @@ -250,16 +250,16 @@ bool CGfxPlugin::Initiate(CN64System * System, RenderWindow * Window) Info.VI__Y_SCALE_REG = &Reg.VI_Y_SCALE_REG; } - WriteTrace(TraceGFXPlugin, TraceDebug, "Calling InitiateGFX"); + WriteTrace(TraceVideoPlugin, TraceDebug, "Calling InitiateGFX"); m_Initialized = InitiateGFX(Info) != 0; - WriteTrace(TraceGFXPlugin, TraceDebug, "Done (res: %s)", m_Initialized ? "true" : "false"); + WriteTrace(TraceVideoPlugin, TraceDebug, "Done (res: %s)", m_Initialized ? "true" : "false"); return m_Initialized; } void CGfxPlugin::UnloadPluginDetails(void) { - WriteTrace(TraceGFXPlugin, TraceDebug, "Start"); + WriteTrace(TraceVideoPlugin, TraceDebug, "Start"); if (m_LibHandle != nullptr) { DynamicLibraryClose(m_LibHandle); @@ -267,13 +267,10 @@ void CGfxPlugin::UnloadPluginDetails(void) } memset(&m_GFXDebug, 0, sizeof(m_GFXDebug)); - // CaptureScreen = nullptr; ChangeWindow = nullptr; GetDebugInfo = nullptr; DrawScreen = nullptr; DrawStatus = nullptr; - // FrameBufferRead = nullptr; - // FrameBufferWrite = nullptr; InitiateDebugger = nullptr; MoveScreen = nullptr; ProcessDList = nullptr; @@ -284,7 +281,7 @@ void CGfxPlugin::UnloadPluginDetails(void) ViWidthChanged = nullptr; GetRomBrowserMenu = nullptr; OnRomBrowserMenuItem = nullptr; - WriteTrace(TraceGFXPlugin, TraceDebug, "Done"); + WriteTrace(TraceVideoPlugin, TraceDebug, "Done"); } void CGfxPlugin::ProcessMenuItem(int32_t id) @@ -299,11 +296,11 @@ void CGfxPlugin::ProcessMenuItem(int32_t id) void CGfxPlugin::SwapBuffers(void) { RenderWindow * render = g_Plugins ? g_Plugins->MainWindow() : nullptr; - WriteTrace(TraceGFXPlugin, TraceDebug, "Start (render: %p)",render); + WriteTrace(TraceVideoPlugin, TraceDebug, "Start (render: %p)",render); if (render != nullptr) { render->SwapWindow(); } - WriteTrace(TraceGFXPlugin, TraceDebug, "Done"); + WriteTrace(TraceVideoPlugin, TraceDebug, "Done"); } #endif diff --git a/Source/Project64-core/Plugins/GFXPlugin.h b/Source/Project64-core/Plugins/GFXPlugin.h index 8922ace24..7847127bb 100644 --- a/Source/Project64-core/Plugins/GFXPlugin.h +++ b/Source/Project64-core/Plugins/GFXPlugin.h @@ -75,7 +75,7 @@ private: virtual int32_t GetDefaultSettingStartRange() const { return FirstGfxDefaultSet; } virtual int32_t GetSettingStartRange() const { return FirstGfxSettings; } - PLUGIN_TYPE type() { return PLUGIN_TYPE_GFX; } + PLUGIN_TYPE type() { return PLUGIN_TYPE_VIDEO; } void UnloadPluginDetails(void); diff --git a/Source/Project64-core/Plugins/Plugin.cpp b/Source/Project64-core/Plugins/Plugin.cpp index b3f27bec3..d2c40dee6 100644 --- a/Source/Project64-core/Plugins/Plugin.cpp +++ b/Source/Project64-core/Plugins/Plugin.cpp @@ -141,7 +141,7 @@ void CPlugins::CreatePlugins(void) { WriteTrace(TracePlugins, TraceInfo, "Start"); - LoadPlugin(Game_Plugin_Gfx, Plugin_GFX_CurVer, m_Gfx, m_PluginDir.c_str(), m_GfxFile, TraceGFXPlugin, "GFX", m_SyncPlugins); + LoadPlugin(Game_Plugin_Gfx, Plugin_GFX_CurVer, m_Gfx, m_PluginDir.c_str(), m_GfxFile, TraceVideoPlugin, "GFX", m_SyncPlugins); LoadPlugin(Game_Plugin_Audio, Plugin_AUDIO_CurVer, m_Audio, m_PluginDir.c_str(), m_AudioFile, TraceAudioPlugin, "Audio", m_SyncPlugins); 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); @@ -182,15 +182,15 @@ void CPlugins::DestroyGfxPlugin(void) { return; } - WriteTrace(TraceGFXPlugin, TraceDebug, "Before close"); + WriteTrace(TraceVideoPlugin, TraceDebug, "Before close"); m_Gfx->Close(m_MainWindow); - WriteTrace(TraceGFXPlugin, TraceInfo, "Deleting"); + WriteTrace(TraceVideoPlugin, TraceInfo, "Deleting"); delete m_Gfx; - WriteTrace(TraceGFXPlugin, TraceInfo, "m_Gfx deleted"); + WriteTrace(TraceVideoPlugin, TraceInfo, "m_Gfx deleted"); m_Gfx = nullptr; // g_Settings->UnknownSetting_GFX = nullptr; DestroyRspPlugin(); - WriteTrace(TraceGFXPlugin, TraceInfo, "Done"); + WriteTrace(TraceVideoPlugin, TraceInfo, "Done"); } void CPlugins::DestroyAudioPlugin(void) @@ -281,9 +281,9 @@ bool CPlugins::Initiate(CN64System * System) if (m_RSP == nullptr) { return false; } if (m_Control == nullptr) { return false; } - WriteTrace(TraceGFXPlugin, TraceDebug, "GFX initiate starting"); + WriteTrace(TraceVideoPlugin, TraceDebug, "GFX initiate starting"); if (!m_Gfx->Initiate(System, m_MainWindow)) { return false; } - WriteTrace(TraceGFXPlugin, TraceDebug, "GFX initiate done"); + WriteTrace(TraceVideoPlugin, 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"); @@ -331,9 +331,9 @@ bool CPlugins::Reset(CN64System * System) if (m_Gfx && bGfxChange) { - WriteTrace(TraceGFXPlugin, TraceDebug, "GFX initiate starting"); + WriteTrace(TraceVideoPlugin, TraceDebug, "GFX initiate starting"); if (!m_Gfx->Initiate(System, m_MainWindow)) { return false; } - WriteTrace(TraceGFXPlugin, TraceDebug, "GFX initiate done"); + WriteTrace(TraceVideoPlugin, TraceDebug, "GFX initiate done"); } if (m_Audio && bAudioChange) { @@ -382,7 +382,7 @@ void CPlugins::ConfigPlugin(void* hParent, PLUGIN_TYPE Type) } m_RSP->DllConfig(hParent); break; - case PLUGIN_TYPE_GFX: + case PLUGIN_TYPE_VIDEO: if (m_Gfx == nullptr || m_Gfx->DllConfig == nullptr) { break; } if (!m_Gfx->Initialized()) { diff --git a/Source/Project64-core/Plugins/Plugin.h b/Source/Project64-core/Plugins/Plugin.h index a810f1e92..e3243e0a3 100644 --- a/Source/Project64-core/Plugins/Plugin.h +++ b/Source/Project64-core/Plugins/Plugin.h @@ -2,22 +2,7 @@ #include #include #include - -#ifndef PLUGIN_INFO_STRUCT -#define PLUGIN_INFO_STRUCT - -typedef struct _PLUGIN_INFO -{ - 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 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 +#include // Enums enum SETTING_DATA_TYPE @@ -77,15 +62,6 @@ typedef struct void(*BreakPoint)(const char * FileName, int32_t LineNumber); } PLUGIN_NOTIFICATION; -enum PLUGIN_TYPE -{ - PLUGIN_TYPE_NONE = 0, - PLUGIN_TYPE_RSP = 1, - PLUGIN_TYPE_GFX = 2, - PLUGIN_TYPE_AUDIO = 3, - PLUGIN_TYPE_CONTROLLER = 4, -}; - class CSettings; class CGfxPlugin; class CAudioPlugin; class CRSP_Plugin; class CControl_Plugin; class CN64System; diff --git a/Source/Project64-core/Plugins/PluginBase.cpp b/Source/Project64-core/Plugins/PluginBase.cpp index 65fece0ae..43580b253 100644 --- a/Source/Project64-core/Plugins/PluginBase.cpp +++ b/Source/Project64-core/Plugins/PluginBase.cpp @@ -3,18 +3,18 @@ #include CPlugin::CPlugin() : -DllAbout(nullptr), -DllConfig(nullptr), -CloseDLL(nullptr), -RomOpen(nullptr), -RomClosed(nullptr), -PluginOpened(nullptr), -SetSettingInfo(nullptr), -SetSettingInfo2(nullptr), -SetSettingInfo3(nullptr), -m_LibHandle(nullptr), -m_Initialized(false), -m_RomOpen(false) + DllAbout(nullptr), + DllConfig(nullptr), + CloseDLL(nullptr), + RomOpen(nullptr), + RomClosed(nullptr), + PluginOpened(nullptr), + SetSettingInfo(nullptr), + SetSettingInfo2(nullptr), + SetSettingInfo3(nullptr), + m_LibHandle(nullptr), + m_Initialized(false), + m_RomOpen(false) { memset(&m_PluginInfo, 0, sizeof(m_PluginInfo)); } @@ -154,7 +154,7 @@ void CPlugin::RomOpened(RenderWindow * Render) } #ifdef ANDROID - if (m_PluginInfo.Type == PLUGIN_TYPE_GFX) + if (m_PluginInfo.Type == PLUGIN_TYPE_VIDEO) { WriteTrace(PluginTraceType(), TraceDebug, "Render = %p", Render); if (Render != nullptr) @@ -186,7 +186,7 @@ void CPlugin::RomClose(RenderWindow * Render) } #ifdef ANDROID - if (m_PluginInfo.Type == PLUGIN_TYPE_GFX) + if (m_PluginInfo.Type == PLUGIN_TYPE_VIDEO) { WriteTrace(PluginTraceType(), TraceDebug, "Render = %p", Render); if (Render != NULL) @@ -258,7 +258,7 @@ const char * CPlugin::PluginType() const switch (m_PluginInfo.Type) { case PLUGIN_TYPE_RSP: return "RSP"; - case PLUGIN_TYPE_GFX: return "GFX"; + case PLUGIN_TYPE_VIDEO: return "Video"; case PLUGIN_TYPE_AUDIO: return "Audio"; case PLUGIN_TYPE_CONTROLLER: return "Control"; } @@ -270,7 +270,7 @@ TraceModuleProject64 CPlugin::PluginTraceType() const switch (m_PluginInfo.Type) { case PLUGIN_TYPE_RSP: return TraceRSPPlugin; - case PLUGIN_TYPE_GFX: return TraceGFXPlugin; + case PLUGIN_TYPE_VIDEO: return TraceVideoPlugin; case PLUGIN_TYPE_AUDIO: return TraceAudioPlugin; case PLUGIN_TYPE_CONTROLLER: return TraceControllerPlugin; } @@ -282,21 +282,18 @@ bool CPlugin::ValidPluginVersion(PLUGIN_INFO & PluginInfo) switch (PluginInfo.Type) { case PLUGIN_TYPE_RSP: - if (!PluginInfo.MemoryBswaped) { return false; } if (PluginInfo.Version == 0x0001) { return true; } if (PluginInfo.Version == 0x0100) { return true; } if (PluginInfo.Version == 0x0101) { return true; } if (PluginInfo.Version == 0x0102) { return true; } if (PluginInfo.Version == 0x0103) { return true; } break; - case PLUGIN_TYPE_GFX: - if (!PluginInfo.MemoryBswaped) { return false; } + case PLUGIN_TYPE_VIDEO: if (PluginInfo.Version == 0x0102) { return true; } if (PluginInfo.Version == 0x0103) { return true; } if (PluginInfo.Version == 0x0104) { return true; } break; case PLUGIN_TYPE_AUDIO: - if (!PluginInfo.MemoryBswaped) { return false; } if (PluginInfo.Version == 0x0101) { return true; } if (PluginInfo.Version == 0x0102) { return true; } break; diff --git a/Source/Project64-core/Plugins/PluginBase.h b/Source/Project64-core/Plugins/PluginBase.h index 48babbd25..8bf00cf07 100644 --- a/Source/Project64-core/Plugins/PluginBase.h +++ b/Source/Project64-core/Plugins/PluginBase.h @@ -3,14 +3,9 @@ #include #include #include +#include #include -#if defined(_WIN32) -#define CALL __cdecl -#else -#define CALL -#endif - class CPlugin : private CDebugSettings { @@ -43,15 +38,15 @@ protected: virtual PLUGIN_TYPE type() = 0; virtual bool LoadFunctions(void) = 0; - void(CALL *CloseDLL) (void); - void(CALL *RomOpen) (void); - void(CALL *RomClosed) (void); - void(CALL *PluginOpened)(void); - void(CALL *SetSettingInfo)(PLUGIN_SETTINGS *); - void(CALL *SetSettingInfo2)(PLUGIN_SETTINGS2 *); - void(CALL *SetSettingInfo3)(PLUGIN_SETTINGS3 *); - void(CALL *SetSettingNotificationInfo)(PLUGIN_SETTINGS_NOTIFICATION *); - void(CALL *SetPluginNotification)(PLUGIN_NOTIFICATION *); + void(CALL * CloseDLL) (void); + void(CALL * RomOpen) (void); + void(CALL * RomClosed) (void); + void(CALL * PluginOpened)(void); + void(CALL * SetSettingInfo)(PLUGIN_SETTINGS *); + void(CALL * SetSettingInfo2)(PLUGIN_SETTINGS2 *); + void(CALL * SetSettingInfo3)(PLUGIN_SETTINGS3 *); + void(CALL * SetSettingNotificationInfo)(PLUGIN_SETTINGS_NOTIFICATION *); + void(CALL * SetPluginNotification)(PLUGIN_NOTIFICATION *); DynLibHandle m_LibHandle; bool m_Initialized, m_RomOpen; diff --git a/Source/Project64-core/Project64-core.vcxproj b/Source/Project64-core/Project64-core.vcxproj index 5b34dd387..b732d1e77 100644 --- a/Source/Project64-core/Project64-core.vcxproj +++ b/Source/Project64-core/Project64-core.vcxproj @@ -145,6 +145,11 @@ + + + + + diff --git a/Source/Project64-core/Project64-core.vcxproj.filters b/Source/Project64-core/Project64-core.vcxproj.filters index 96f6c2390..f11b15396 100644 --- a/Source/Project64-core/Project64-core.vcxproj.filters +++ b/Source/Project64-core/Project64-core.vcxproj.filters @@ -106,6 +106,9 @@ {f058be82-aec4-4e3d-a163-2eec0aa64feb} + + {a29536c1-cda4-43b0-b3c6-12a24f42be64} + @@ -773,6 +776,21 @@ Header Files\N64 System\MemoryHandler + + Header Files\Plugin Spec + + + Header Files\Plugin Spec + + + Header Files\Plugin Spec + + + Header Files\Plugin Spec + + + Header Files\Plugin Spec + diff --git a/Source/Project64-core/Settings.cpp b/Source/Project64-core/Settings.cpp index 1b4dd6f77..82fe8e47c 100644 --- a/Source/Project64-core/Settings.cpp +++ b/Source/Project64-core/Settings.cpp @@ -355,7 +355,7 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory) AddHandler(Debugger_TraceAppCleanup, new CSettingTypeApplication("Logging", "App Cleanup", (uint32_t)g_ModuleLogLevel[TraceAppCleanup])); AddHandler(Debugger_TraceN64System, new CSettingTypeApplication("Logging", "N64 System", (uint32_t)g_ModuleLogLevel[TraceN64System])); AddHandler(Debugger_TracePlugins, new CSettingTypeApplication("Logging", "Plugins", (uint32_t)g_ModuleLogLevel[TracePlugins])); - AddHandler(Debugger_TraceGFXPlugin, new CSettingTypeApplication("Logging", "GFX Plugin", (uint32_t)g_ModuleLogLevel[TraceGFXPlugin])); + AddHandler(Debugger_TraceVideoPlugin, new CSettingTypeApplication("Logging", "GFX Plugin", (uint32_t)g_ModuleLogLevel[TraceVideoPlugin])); AddHandler(Debugger_TraceAudioPlugin, new CSettingTypeApplication("Logging", "Audio Plugin", (uint32_t)g_ModuleLogLevel[TraceAudioPlugin])); AddHandler(Debugger_TraceControllerPlugin, new CSettingTypeApplication("Logging", "Controller Plugin", (uint32_t)g_ModuleLogLevel[TraceControllerPlugin])); AddHandler(Debugger_TraceRSPPlugin, new CSettingTypeApplication("Logging", "RSP Plugin", (uint32_t)g_ModuleLogLevel[TraceRSPPlugin])); diff --git a/Source/Project64-core/Settings/SettingsID.h b/Source/Project64-core/Settings/SettingsID.h index c52ae3870..337cb52c1 100644 --- a/Source/Project64-core/Settings/SettingsID.h +++ b/Source/Project64-core/Settings/SettingsID.h @@ -273,7 +273,7 @@ enum SettingID Debugger_TraceAppCleanup, Debugger_TraceN64System, Debugger_TracePlugins, - Debugger_TraceGFXPlugin, + Debugger_TraceVideoPlugin, Debugger_TraceAudioPlugin, Debugger_TraceControllerPlugin, Debugger_TraceRSPPlugin, diff --git a/Source/Project64-core/TraceModulesProject64.h b/Source/Project64-core/TraceModulesProject64.h index 2ca362eb3..6a336ba1b 100644 --- a/Source/Project64-core/TraceModulesProject64.h +++ b/Source/Project64-core/TraceModulesProject64.h @@ -9,7 +9,7 @@ enum TraceModuleProject64 TraceAppCleanup, TraceN64System, TracePlugins, - TraceGFXPlugin, + TraceVideoPlugin, TraceAudioPlugin, TraceControllerPlugin, TraceRSPPlugin, diff --git a/Source/Project64-input/CProject64Input.cpp b/Source/Project64-input/CProject64Input.cpp index 153ed6b8d..def108760 100644 --- a/Source/Project64-input/CProject64Input.cpp +++ b/Source/Project64-input/CProject64Input.cpp @@ -209,14 +209,14 @@ void CProject64Input::LockMouse() { if (IsMouseUsed() == false) return UnlockMouse(); if (m_MouseLock == true) return; - PostMessage((HWND)m_ControlInfo.hwnd, WM_HIDE_CUROSR, false, 0); + PostMessage((HWND)m_ControlInfo.hWnd, WM_HIDE_CUROSR, false, 0); m_MouseLock = true; } void CProject64Input::UnlockMouse() { if (m_MouseLock == false) return; - PostMessage((HWND)m_ControlInfo.hwnd, WM_HIDE_CUROSR, true, 0); + PostMessage((HWND)m_ControlInfo.hWnd, WM_HIDE_CUROSR, true, 0); m_MouseLock = false; } @@ -247,6 +247,6 @@ bool CProject64Input::IsMouseUsed() void CProject64Input::LockCursor() { RECT rect; - GetWindowRect((HWND)m_ControlInfo.hwnd, &rect); + GetWindowRect((HWND)m_ControlInfo.hWnd, &rect); SetCursorPos((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2); } diff --git a/Source/Project64-input/CProject64Input.h b/Source/Project64-input/CProject64Input.h index 22d126ae1..6837c797b 100644 --- a/Source/Project64-input/CProject64Input.h +++ b/Source/Project64-input/CProject64Input.h @@ -1,5 +1,5 @@ #pragma once -#include "ControllerSpec1.1.h" +#include #include "DirectInput.h" #include "N64Controller.h" #include "Shortcuts.h" diff --git a/Source/Project64-input/DirectInput.cpp b/Source/Project64-input/DirectInput.cpp index 3ce029e6b..9efbf90c7 100644 --- a/Source/Project64-input/DirectInput.cpp +++ b/Source/Project64-input/DirectInput.cpp @@ -48,7 +48,7 @@ CDirectInput::~CDirectInput() void CDirectInput::Initiate(CONTROL_INFO * ControlInfo) { - m_hWnd = (HWND)ControlInfo->hwnd; + m_hWnd = (HWND)ControlInfo->hWnd; } void CDirectInput::MapControllerDevice(N64CONTROLLER & Controller) diff --git a/Source/Project64-input/DirectInput.h b/Source/Project64-input/DirectInput.h index b633e7b39..72e541e4b 100644 --- a/Source/Project64-input/DirectInput.h +++ b/Source/Project64-input/DirectInput.h @@ -1,5 +1,5 @@ #pragma once -#include "ControllerSpec1.1.h" +#include #include "Button.h" #include "DeviceNotification.h" #include "N64Controller.h" diff --git a/Source/Project64-input/InputMain.cpp b/Source/Project64-input/InputMain.cpp index 30c12eaef..d2c31036b 100644 --- a/Source/Project64-input/InputMain.cpp +++ b/Source/Project64-input/InputMain.cpp @@ -1,4 +1,4 @@ -#include "ControllerSpec1.1.h" +#include #include "InputConfigUI.h" #include "Version.h" #include "CProject64Input.h" @@ -98,8 +98,8 @@ EXPORT void CALL GetDllInfo(PLUGIN_INFO * PluginInfo) #else sprintf(PluginInfo->Name, "Project64 input plugin: %s", VER_FILE_VERSION_STR); #endif - PluginInfo->MemoryBswaped = true; - PluginInfo->NormalMemory = false; + PluginInfo->Reserved2 = true; + PluginInfo->Reserved1 = false; } /* diff --git a/Source/Project64-input/InputSettings.h b/Source/Project64-input/InputSettings.h index 6f8554077..a6d1259ea 100644 --- a/Source/Project64-input/InputSettings.h +++ b/Source/Project64-input/InputSettings.h @@ -3,7 +3,7 @@ #include #include "N64Controller.h" #include "Shortcuts.h" -#include "ControllerSpec1.1.h" +#include class CInputSettings { diff --git a/Source/Project64-input/OptionsUI.cpp b/Source/Project64-input/OptionsUI.cpp index 4d2e73bd5..51b9c29a3 100644 --- a/Source/Project64-input/OptionsUI.cpp +++ b/Source/Project64-input/OptionsUI.cpp @@ -84,7 +84,7 @@ public: CComboBox ControllerPak(GetDlgItem(IDC_PAKTYPE)); DWORD_PTR Pak = ControllerPak.GetItemData(ControllerPak.GetCurSel()); - if (Pak != m_ControlInfo.Plugin) + if (Pak != (DWORD_PTR)m_ControlInfo.Plugin) { m_ControlInfo.Plugin = (Pak & 0xFFFFFFFF); bChanged = true; diff --git a/Source/Project64-input/OptionsUI.h b/Source/Project64-input/OptionsUI.h index ea7b0369d..8f2af6184 100644 --- a/Source/Project64-input/OptionsUI.h +++ b/Source/Project64-input/OptionsUI.h @@ -1,6 +1,6 @@ #pragma once #include -#include "ControllerSpec1.1.h" +#include #include "N64Controller.h" void ConfigOption(uint32_t ControlIndex, CONTROL & ControlInfo, N64CONTROLLER & Controller); diff --git a/Source/Project64-input/ShortcutsUI.h b/Source/Project64-input/ShortcutsUI.h index 7c7b0e975..adbabd8a7 100644 --- a/Source/Project64-input/ShortcutsUI.h +++ b/Source/Project64-input/ShortcutsUI.h @@ -1,6 +1,6 @@ #pragma once #include -#include "ControllerSpec1.1.h" +#include #include "Shortcuts.h" void ConfigShortcut(SHORTCUTS & Shortcuts); diff --git a/Source/Project64-plugin-spec/Audio.h b/Source/Project64-plugin-spec/Audio.h new file mode 100644 index 000000000..bd92d61e3 --- /dev/null +++ b/Source/Project64-plugin-spec/Audio.h @@ -0,0 +1,158 @@ +#pragma once +#include "base.h" + +#if defined(__cplusplus) +extern "C" { +#endif + + typedef struct + { + void * hWnd; + void * hinst; + + int32_t Reserved; + + uint8_t * HEADER; + uint8_t * RDRAM; + uint8_t * DMEM; + uint8_t * IMEM; + + uint32_t * MI_INTR_REG; + + uint32_t * AI_DRAM_ADDR_REG; + uint32_t * AI_LEN_REG; + uint32_t * AI_CONTROL_REG; + uint32_t * AI_STATUS_REG; + uint32_t * AI_DACRATE_REG; + uint32_t * AI_BITRATE_REG; + + void(CALL *CheckInterrupts)(void); + } AUDIO_INFO; + + /* + Function: AiDacrateChanged + Purpose: This function is called to notify the DLL that the + AiDacrate registers value has been changed. + Input: The system type: + AUDIO_SYSTEM_NTSC 0 + AUDIO_SYSTEM_PAL 1 + AUDIO_SYSTEM_MPAL 2 + Output: None + */ + EXPORT void CALL AiDacrateChanged(int32_t SystemType); + + /* + Function: AiLenChanged + Purpose: This function is called to notify the DLL that the + AiLen registers value has been changed. + Input: None + Output: None + */ + EXPORT void CALL AiLenChanged(void); + + /* + Function: AiReadLength + 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. + */ + EXPORT uint32_t CALL AiReadLength(void); + + /* + Function: AiUpdate + 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 + till there is a message in its message queue. + Output: None + */ + EXPORT void CALL AiUpdate(int32_t Wait); + + /* + 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: 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(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 + */ + 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 + */ + 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 + */ + EXPORT void CALL GetDllInfo(PLUGIN_INFO * PluginInfo); + + /* + 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 + above. + Output: True on success + FALSE on failure to initialize + 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. + */ + EXPORT int32_t CALL InitiateAudio(AUDIO_INFO Audio_Info); + + /* + Function: ProcessAList + 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 + */ + EXPORT void CALL ProcessAList(void); + + /* + Function: RomClosed + Purpose: This function is called when a ROM is closed. + Input: None + Output: None + */ + EXPORT void CALL RomClosed(void); + +#if defined(__cplusplus) +} +#endif diff --git a/Source/Project64-plugin-spec/Base.h b/Source/Project64-plugin-spec/Base.h new file mode 100644 index 000000000..edd242e1b --- /dev/null +++ b/Source/Project64-plugin-spec/Base.h @@ -0,0 +1,114 @@ +#pragma once +#include + +#if defined(__cplusplus) +extern "C" { +#endif + +#ifndef EXPORT +#if defined(__cplusplus) +#if defined(_WIN32) +#define EXPORT extern "C" __declspec(dllexport) +#else +#define EXPORT extern "C" __attribute__((visibility("default"))) +#endif +#else +#if defined(_WIN32) +#define EXPORT __declspec(dllexport) +#else +#define EXPORT __attribute__((visibility("default"))) +#endif +#endif +#endif + +#ifndef CALL +#if defined(_WIN32) +#define CALL __cdecl +#else +#define CALL +#endif +#endif + +enum PLUGIN_TYPE +{ + PLUGIN_TYPE_NONE = 0, + PLUGIN_TYPE_RSP = 1, + PLUGIN_TYPE_VIDEO = 2, + PLUGIN_TYPE_AUDIO = 3, + PLUGIN_TYPE_CONTROLLER = 4, +}; + +typedef struct +{ + uint16_t Version; // Should be set plugin spec version eg VIDEO_SPECS_VERSION + uint16_t Type; // Set to the plugin type, eg PLUGIN_TYPE_VIDEO + char Name[100]; // Name of the DLL + int32_t Reserved1; + int32_t Reserved2; +} PLUGIN_INFO; + +/* +Function: CloseDLL +Purpose: This function is called when the emulator is closing +down allowing the dll to de-initialise. +Input: none +Output: none +*/ +EXPORT void CALL 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 +*/ +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 +*/ +EXPORT void CALL DllConfig(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 stucture that needs to be +filled by the function. (see def above) +Output: none +*/ +EXPORT void CALL GetDllInfo(PLUGIN_INFO * PluginInfo); + +/* +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 +*/ +EXPORT void CALL RomOpen(void); + +/* +Function: PluginLoaded +Purpose: This function is called when the plugin is loaded +Input: none +Output: none +*/ +EXPORT void CALL PluginLoaded(void); + +#if defined(__cplusplus) +} +#endif diff --git a/Source/Project64-input/ControllerSpec1.1.h b/Source/Project64-plugin-spec/Input.h similarity index 62% rename from Source/Project64-input/ControllerSpec1.1.h rename to Source/Project64-plugin-spec/Input.h index 48b4066b5..eefb0f931 100644 --- a/Source/Project64-input/ControllerSpec1.1.h +++ b/Source/Project64-plugin-spec/Input.h @@ -1,24 +1,12 @@ -// Project64 controller plugin spec, version 1.1 - #pragma once -#include - -enum { PLUGIN_TYPE_CONTROLLER = 4 }; - -#if defined(_WIN32) -#define EXPORT extern "C" __declspec(dllexport) -#define CALL __cdecl -#else -#define EXPORT extern "C" __attribute__((visibility("default"))) -#define CALL -#endif +#include "Base.h" enum { CONTROLLER_SPECS_VERSION = 0x0102 }; -enum +enum PluginType { PLUGIN_NONE = 1, PLUGIN_MEMPAK = 2, @@ -27,23 +15,16 @@ enum PLUGIN_RAW = 5, }; -enum +enum PresentType { PRESENT_NONE = 0, PRESENT_CONT = 1, PRESENT_MOUSE = 2, }; -// Structures - -typedef struct -{ - uint16_t Version; // Should be set to 0x0101 - uint16_t Type; // Set to PLUGIN_TYPE_CONTROLLER - char Name[100]; // Name of the DLL - int32_t NormalMemory; - int32_t MemoryBswaped; -} PLUGIN_INFO; +#if defined(__cplusplus) +extern "C" { +#endif typedef struct { @@ -78,9 +59,9 @@ typedef union unsigned Reserved1 : 1; unsigned Reserved2 : 1; - signed X_AXIS : 8; + signed X_AXIS : 8; - signed Y_AXIS : 8; + signed Y_AXIS : 8; }; } BUTTONS; @@ -88,23 +69,13 @@ typedef union typedef struct { - void * hwnd; + void * hWnd; void * hinst; - int32_t MemoryBswaped; // Set this to true + int32_t Reserved; uint8_t * HEADER; // This is the ROM header (first 40h bytes of the ROM) CONTROL * Controls; // A pointer to an array of 4 controllers } CONTROL_INFO; -/* -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 @@ -119,50 +90,8 @@ 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(int32_t 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 -*/ - -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 -*/ - -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 -*/ - -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 -*/ - -EXPORT void CALL GetDllInfo(PLUGIN_INFO * PluginInfo); - /* Function: GetKeys Purpose: To get the current state of the controllers buttons. @@ -171,7 +100,6 @@ Input: Controller number (0 to 3) the controller state. Output: None */ - EXPORT void CALL GetKeys(int32_t Control, BUTTONS * Keys); /* @@ -183,7 +111,6 @@ Input: The handle to the main window. the emulator to know how to handle each controller. Output: None */ - EXPORT void CALL InitiateControllers(CONTROL_INFO * ControlInfo); /* @@ -197,28 +124,8 @@ 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 -*/ - -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 -*/ - -EXPORT void CALL RomOpen(void); - /* Function: EmulationPaused Purpose: This function is called when the emulation is paused. (from the @@ -226,7 +133,6 @@ emulation thread) Input: None Output: None */ - EXPORT void CALL EmulationPaused(void); /* @@ -236,7 +142,6 @@ plugin. Input: wParam and lParam of the WM_KEYDOWN message. Output: None */ - EXPORT void CALL WM_KeyDown(uint32_t wParam, uint32_t lParam); /* @@ -246,7 +151,6 @@ plugin. Input: wParam and lParam of the WM_KEYDOWN message. Output: None */ - EXPORT void CALL WM_KeyUp(uint32_t wParam, uint32_t lParam); /* @@ -256,5 +160,8 @@ plugin. Input: wParam and lParam of the WM_KILLFOCUS message. Output: None */ - EXPORT void CALL WM_KillFocus(uint32_t wParam, uint32_t lParam); + +#if defined(__cplusplus) +} +#endif diff --git a/Source/Project64-plugin-spec/Rsp.h b/Source/Project64-plugin-spec/Rsp.h new file mode 100644 index 000000000..cdb05b40a --- /dev/null +++ b/Source/Project64-plugin-spec/Rsp.h @@ -0,0 +1,91 @@ +#pragma once +#include "Base.h" + +typedef struct +{ + void * hInst; + 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; + uint8_t * RDRAM; + uint8_t * DMEM; + uint8_t * IMEM; + + uint32_t * MI_INTR_REG; + + uint32_t * SP_MEM_ADDR_REG; + uint32_t * SP_DRAM_ADDR_REG; + uint32_t * SP_RD_LEN_REG; + uint32_t * SP_WR_LEN_REG; + uint32_t * SP_STATUS_REG; + uint32_t * SP_DMA_FULL_REG; + uint32_t * SP_DMA_BUSY_REG; + uint32_t * SP_PC_REG; + uint32_t * SP_SEMAPHORE_REG; + + uint32_t * DPC_START_REG; + uint32_t * DPC_END_REG; + uint32_t * DPC_CURRENT_REG; + uint32_t * DPC_STATUS_REG; + uint32_t * DPC_CLOCK_REG; + uint32_t * DPC_BUFBUSY_REG; + uint32_t * DPC_PIPEBUSY_REG; + uint32_t * DPC_TMEM_REG; + + void(*CheckInterrupts)(void); + void(*ProcessDList)(void); + void(*ProcessAList)(void); + void(*ProcessRdpList)(void); + void(*ShowCFB)(void); +} RSP_INFO; + +typedef struct { + void(*UpdateBreakPoints)(void); + void(*UpdateMemory)(void); + void(*UpdateR4300iRegisters)(void); + void(*Enter_BPoint_Window)(void); + void(*Enter_R4300i_Commands_Window)(void); + void(*Enter_R4300i_Register_Window)(void); + void(*Enter_RSP_Commands_Window) (void); + void(*Enter_Memory_Window)(void); +} DEBUG_INFO; + +typedef struct { + long left, top, right, bottom; +} rectangle; // equivalent: RECT + +typedef struct { + void * hdc; + int32_t fErase; + rectangle rcPaint; + int32_t fRestore; + int32_t fIncUpdate; + uint8_t rgbReserved[32]; +} window_paint; // equivalent: PAINTSTRUCT + +typedef struct { + // Menu + // Items should have an ID between 5001 and 5100 + void * hRSPMenu; + void(*ProcessMenuItem) (int ID); + + // Breakpoints + int UseBPoints; + char BPPanelName[20]; + void(*Add_BPoint) (void); + void(*CreateBPPanel) (void * hDlg, rectangle rcBox); + void(*HideBPPanel) (void); + void(*PaintBPPanel) (window_paint ps); + void(*ShowBPPanel) (void); + void(*RefreshBpoints)(void * hList); + void(*RemoveBpoint) (void * hList, int index); + void(*RemoveAllBpoint) (void); + + // RSP command window + void(*Enter_RSP_Commands_Window) (void); +} RSPDEBUG_INFO; + +EXPORT uint32_t DoRspCycles(uint32_t Cycles); +EXPORT void GetRspDebugInfo(RSPDEBUG_INFO * DebugInfo); +EXPORT void InitiateRSP(RSP_INFO Rsp_Info, uint32_t * CycleCount); +EXPORT void InitiateRSPDebugger(DEBUG_INFO Debug_Info); +EXPORT void EnableDebugging(int Enabled); diff --git a/Source/Project64-plugin-spec/Video.h b/Source/Project64-plugin-spec/Video.h new file mode 100644 index 000000000..4ce4fad2e --- /dev/null +++ b/Source/Project64-plugin-spec/Video.h @@ -0,0 +1,410 @@ +// Project64 - A Nintendo 64 emulator +// http://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 +#include +#include // offsetof +#include +#include "Config.h" +#include "Settings.h" +#include "rdp.h" + +#if defined __VISUALC__ +#define GLIDE64_TRY __try +#define GLIDE64_CATCH __except (EXCEPTION_EXECUTE_HANDLER) +#else +#define GLIDE64_TRY try +#define GLIDE64_CATCH catch (...) +#endif + +#if defined(__cplusplus) +extern "C" { +#endif + + //******** + // Logging + + // ******************************** + // ** TAKE OUT BEFORE RELEASE!!! ** + //#define LOG_UCODE + + // note that some of these things are inserted/removed + // from within the code & may not be changed by this define. + + // ******************************** + + //#define CATCH_EXCEPTIONS // catch exceptions so it doesn't freeze and will report + // "The gfx plugin has caused an exception" instead. + + // Usually enabled +#define LARGE_TEXTURE_HANDLING // allow large-textured objects to be split? + + extern unsigned int BMASK; + + extern uint32_t update_screen_count; + + extern int GfxInitDone; + extern bool g_romopen; + extern int to_fullscreen; + + extern int ev_fullscreen; + + extern int exception; + + int InitGfx(); + void ReleaseGfx(); + + // The highest 8 bits are the segment # (1-16), and the lower 24 bits are the offset to + // add to it. + __inline uint32_t segoffset(uint32_t so) + { + return (rdp.segment[(so >> 24) & 0x0f] + (so&BMASK))&BMASK; + } + + /* Plugin types */ +#define PLUGIN_TYPE_GFX 2 + +#ifdef _WIN32 +#define EXPORT extern "C" __declspec(dllexport) +#define CALL __cdecl +#else +#define EXPORT __attribute__((visibility("default"))) +#define CALL +#endif + + /***** Structures *****/ + typedef struct + { + uint16_t Version; /* Set to 0x0103 */ + 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 */ + int NormalMemory; /* a normal uint8_t array */ + int MemoryBswaped; /* a normal uint8_t array where the memory has been pre + bswap on a dword (32 bits) boundry */ + } PLUGIN_INFO; + + typedef struct + { + void * hWnd; /* Render window */ + void * hStatusBar; /* if render window does not have a status bar then this is nullptr */ + + int32_t MemoryBswaped; // If this is set to TRUE, then the memory has been pre + // bswap on a dword (32 bits) boundry + // 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. + uint8_t * RDRAM; + uint8_t * DMEM; + uint8_t * IMEM; + + uint32_t * MI_INTR_REG; + + uint32_t * DPC_START_REG; + uint32_t * DPC_END_REG; + uint32_t * DPC_CURRENT_REG; + uint32_t * DPC_STATUS_REG; + uint32_t * DPC_CLOCK_REG; + uint32_t * DPC_BUFBUSY_REG; + uint32_t * DPC_PIPEBUSY_REG; + uint32_t * DPC_TMEM_REG; + + uint32_t * VI_STATUS_REG; + uint32_t * VI_ORIGIN_REG; + uint32_t * VI_WIDTH_REG; + uint32_t * VI_INTR_REG; + uint32_t * VI_V_CURRENT_LINE_REG; + uint32_t * VI_TIMING_REG; + uint32_t * VI_V_SYNC_REG; + uint32_t * VI_H_SYNC_REG; + uint32_t * VI_LEAP_REG; + uint32_t * VI_H_START_REG; + uint32_t * VI_V_START_REG; + uint32_t * VI_V_BURST_REG; + uint32_t * VI_X_SCALE_REG; + uint32_t * VI_Y_SCALE_REG; + + void(*CheckInterrupts)(void); +#ifdef ANDROID + void(CALL *SwapBuffers)(void); +#endif + } GFX_INFO; + + extern GFX_INFO gfx; + extern bool no_dlist; + + /****************************************************************** + Function: CaptureScreen + Purpose: This function dumps the current frame to a file + input: pointer to the directory to save the file to + output: none + *******************************************************************/ + EXPORT void CALL CaptureScreen(char * Directory); + + /****************************************************************** + Function: ChangeWindow + Purpose: to change the window between fullscreen and window + mode. If the window was in fullscreen this should + change the screen to window mode and vice vesa. + input: none + output: none + *******************************************************************/ + EXPORT void CALL ChangeWindow(void); + + /****************************************************************** + Function: CloseDLL + Purpose: This function is called when the emulator is closing + down allowing the dll to de-initialise. + input: none + output: none + *******************************************************************/ + EXPORT void CALL 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 + *******************************************************************/ + 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 + *******************************************************************/ + 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 + *******************************************************************/ + EXPORT void CALL DllTest(void * hParent); + + /****************************************************************** + Function: DrawScreen + Purpose: This function is called when the emulator receives a + WM_PAINT message. This allows the gfx to fit in when + it is being used in the desktop. + input: none + output: none + *******************************************************************/ + EXPORT void CALL DrawScreen(void); + + /****************************************************************** + 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 + *******************************************************************/ + EXPORT void CALL GetDllInfo(PLUGIN_INFO * PluginInfo); + + /****************************************************************** + Function: InitiateGFX + Purpose: This function is called when the DLL is started to give + information from the emulator that the n64 graphics + uses. This is not called from the emulation thread. + Input: Gfx_Info is passed to this function which is defined + above. + Output: TRUE on success + FALSE on failure to initialise + + ** 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. + *******************************************************************/ + EXPORT int CALL InitiateGFX(GFX_INFO Gfx_Info); + + /****************************************************************** + Function: MoveScreen + Purpose: This function is called in response to the emulator + receiving a WM_MOVE passing the xpos and ypos passed + from that message. + input: xpos - the x-coordinate of the upper-left corner of the + client area of the window. + ypos - y-coordinate of the upper-left corner of the + client area of the window. + output: none + *******************************************************************/ + EXPORT void CALL MoveScreen(int xpos, int ypos); + + /****************************************************************** + Function: ProcessDList + Purpose: This function is called when there is a Dlist to be + processed. (High level GFX list) + input: none + output: none + *******************************************************************/ + EXPORT void CALL ProcessDList(void); + + /****************************************************************** + Function: ProcessRDPList + Purpose: This function is called when there is a Dlist to be + processed. (Low level GFX list) + input: none + output: none + *******************************************************************/ + EXPORT void CALL ProcessRDPList(void); + + /****************************************************************** + 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 + *******************************************************************/ + EXPORT void CALL RomOpen(void); + + /****************************************************************** + Function: ShowCFB + Purpose: Useally once Dlists are started being displayed, cfb is + ignored. This function tells the dll to start displaying + them again. + input: none + output: none + *******************************************************************/ + EXPORT void CALL ShowCFB(void); + + /****************************************************************** + Function: UpdateScreen + Purpose: This function is called in response to a vsync of the + screen were the VI bit in MI_INTR_REG has already been + set + input: none + output: none + *******************************************************************/ + EXPORT void CALL UpdateScreen(void); + + /****************************************************************** + Function: ViStatusChanged + Purpose: This function is called to notify the dll that the + ViStatus registers value has been changed. + input: none + output: none + *******************************************************************/ + EXPORT void CALL ViStatusChanged(void); + + /****************************************************************** + Function: ViWidthChanged + Purpose: This function is called to notify the dll that the + ViWidth registers value has been changed. + input: none + output: none + *******************************************************************/ + EXPORT void CALL ViWidthChanged(void); + +#ifdef ANDROID + /****************************************************************** + Function: SurfaceCreated + Purpose: this function is called when the surface is created. + input: none + output: none + *******************************************************************/ + EXPORT void CALL SurfaceCreated(void); + /****************************************************************** + Function: SurfaceChanged + Purpose: this function is called when the surface is has changed. + input: none + output: none + *******************************************************************/ + EXPORT void CALL SurfaceChanged(int width, int height); +#endif + /****************************************************************** + Function: FrameBufferWrite + Purpose: This function is called to notify the dll that the + frame buffer has been modified by CPU at the given address. + input: addr rdram address + val val + size 1 = uint8_t, 2 = uint16_t, 4 = uint32_t + output: none + *******************************************************************/ + EXPORT void CALL FBWrite(uint32_t, uint32_t); + + typedef struct + { + uint32_t addr; + uint32_t val; + uint32_t size; // 1 = uint8_t, 2 = uint16_t, 4=uint32_t + } FrameBufferModifyEntry; + + /****************************************************************** + Function: FrameBufferWriteList + Purpose: This function is called to notify the dll that the + frame buffer has been modified by CPU at the given address. + input: FrameBufferModifyEntry *plist + size = size of the plist, max = 1024 + output: none + *******************************************************************/ + EXPORT void CALL FBWList(FrameBufferModifyEntry *plist, uint32_t size); + + /****************************************************************** + Function: FrameBufferRead + Purpose: This function is called to notify the dll that the + frame buffer memory is beening read at the given address. + DLL should copy content from its render buffer to the frame buffer + in N64 RDRAM + DLL is responsible to maintain its own frame buffer memory addr list + DLL should copy 4KB block content back to RDRAM frame buffer. + Emulator should not call this function again if other memory + is read within the same 4KB range + input: addr rdram address + val val + size 1 = uint8_t, 2 = uint16_t, 4 = uint32_t + output: none + *******************************************************************/ + EXPORT void CALL FBRead(uint32_t addr); + + /************************************************************************ + Function: FBGetFrameBufferInfo + Purpose: This function is called by the emulator core to retrieve depth + buffer information from the video plugin in order to be able + to notify the video plugin about CPU depth buffer read/write + operations + + size: + = 1 byte + = 2 word (16 bit) <-- this is N64 default depth buffer format + = 4 dword (32 bit) + + when depth buffer information is not available yet, set all values + in the FrameBufferInfo structure to 0 + + input: FrameBufferInfo *pinfo + pinfo is pointed to a FrameBufferInfo structure which to be + filled in by this function + output: Values are return in the FrameBufferInfo structure + ************************************************************************/ + EXPORT void CALL FBGetFrameBufferInfo(void *pinfo); + + EXPORT void CALL PluginLoaded(void); + +#if defined(__cplusplus) +} +#endif diff --git a/Source/Project64-video/Gfx_1.3.h b/Source/Project64-video/Gfx_1.3.h index 4ce4fad2e..b4ec14381 100644 --- a/Source/Project64-video/Gfx_1.3.h +++ b/Source/Project64-video/Gfx_1.3.h @@ -23,388 +23,47 @@ #define GLIDE64_CATCH catch (...) #endif -#if defined(__cplusplus) -extern "C" { -#endif +#include - //******** - // Logging +//******** +// Logging - // ******************************** - // ** TAKE OUT BEFORE RELEASE!!! ** - //#define LOG_UCODE +// ******************************** +// ** TAKE OUT BEFORE RELEASE!!! ** +//#define LOG_UCODE - // note that some of these things are inserted/removed - // from within the code & may not be changed by this define. +// note that some of these things are inserted/removed +// from within the code & may not be changed by this define. - // ******************************** +// ******************************** - //#define CATCH_EXCEPTIONS // catch exceptions so it doesn't freeze and will report - // "The gfx plugin has caused an exception" instead. +//#define CATCH_EXCEPTIONS // catch exceptions so it doesn't freeze and will report +// "The gfx plugin has caused an exception" instead. - // Usually enabled +// Usually enabled #define LARGE_TEXTURE_HANDLING // allow large-textured objects to be split? - extern unsigned int BMASK; +extern unsigned int BMASK; - extern uint32_t update_screen_count; +extern uint32_t update_screen_count; - extern int GfxInitDone; - extern bool g_romopen; - extern int to_fullscreen; +extern int GfxInitDone; +extern bool g_romopen; +extern int to_fullscreen; - extern int ev_fullscreen; +extern int ev_fullscreen; - extern int exception; +extern int exception; - int InitGfx(); - void ReleaseGfx(); +int InitGfx(); +void ReleaseGfx(); - // The highest 8 bits are the segment # (1-16), and the lower 24 bits are the offset to - // add to it. - __inline uint32_t segoffset(uint32_t so) - { - return (rdp.segment[(so >> 24) & 0x0f] + (so&BMASK))&BMASK; - } - - /* Plugin types */ -#define PLUGIN_TYPE_GFX 2 - -#ifdef _WIN32 -#define EXPORT extern "C" __declspec(dllexport) -#define CALL __cdecl -#else -#define EXPORT __attribute__((visibility("default"))) -#define CALL -#endif - - /***** Structures *****/ - typedef struct - { - uint16_t Version; /* Set to 0x0103 */ - 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 */ - int NormalMemory; /* a normal uint8_t array */ - int MemoryBswaped; /* a normal uint8_t array where the memory has been pre - bswap on a dword (32 bits) boundry */ - } PLUGIN_INFO; - - typedef struct - { - void * hWnd; /* Render window */ - void * hStatusBar; /* if render window does not have a status bar then this is nullptr */ - - int32_t MemoryBswaped; // If this is set to TRUE, then the memory has been pre - // bswap on a dword (32 bits) boundry - // 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. - uint8_t * RDRAM; - uint8_t * DMEM; - uint8_t * IMEM; - - uint32_t * MI_INTR_REG; - - uint32_t * DPC_START_REG; - uint32_t * DPC_END_REG; - uint32_t * DPC_CURRENT_REG; - uint32_t * DPC_STATUS_REG; - uint32_t * DPC_CLOCK_REG; - uint32_t * DPC_BUFBUSY_REG; - uint32_t * DPC_PIPEBUSY_REG; - uint32_t * DPC_TMEM_REG; - - uint32_t * VI_STATUS_REG; - uint32_t * VI_ORIGIN_REG; - uint32_t * VI_WIDTH_REG; - uint32_t * VI_INTR_REG; - uint32_t * VI_V_CURRENT_LINE_REG; - uint32_t * VI_TIMING_REG; - uint32_t * VI_V_SYNC_REG; - uint32_t * VI_H_SYNC_REG; - uint32_t * VI_LEAP_REG; - uint32_t * VI_H_START_REG; - uint32_t * VI_V_START_REG; - uint32_t * VI_V_BURST_REG; - uint32_t * VI_X_SCALE_REG; - uint32_t * VI_Y_SCALE_REG; - - void(*CheckInterrupts)(void); -#ifdef ANDROID - void(CALL *SwapBuffers)(void); -#endif - } GFX_INFO; - - extern GFX_INFO gfx; - extern bool no_dlist; - - /****************************************************************** - Function: CaptureScreen - Purpose: This function dumps the current frame to a file - input: pointer to the directory to save the file to - output: none - *******************************************************************/ - EXPORT void CALL CaptureScreen(char * Directory); - - /****************************************************************** - Function: ChangeWindow - Purpose: to change the window between fullscreen and window - mode. If the window was in fullscreen this should - change the screen to window mode and vice vesa. - input: none - output: none - *******************************************************************/ - EXPORT void CALL ChangeWindow(void); - - /****************************************************************** - Function: CloseDLL - Purpose: This function is called when the emulator is closing - down allowing the dll to de-initialise. - input: none - output: none - *******************************************************************/ - EXPORT void CALL 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 - *******************************************************************/ - 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 - *******************************************************************/ - 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 - *******************************************************************/ - EXPORT void CALL DllTest(void * hParent); - - /****************************************************************** - Function: DrawScreen - Purpose: This function is called when the emulator receives a - WM_PAINT message. This allows the gfx to fit in when - it is being used in the desktop. - input: none - output: none - *******************************************************************/ - EXPORT void CALL DrawScreen(void); - - /****************************************************************** - 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 - *******************************************************************/ - EXPORT void CALL GetDllInfo(PLUGIN_INFO * PluginInfo); - - /****************************************************************** - Function: InitiateGFX - Purpose: This function is called when the DLL is started to give - information from the emulator that the n64 graphics - uses. This is not called from the emulation thread. - Input: Gfx_Info is passed to this function which is defined - above. - Output: TRUE on success - FALSE on failure to initialise - - ** 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. - *******************************************************************/ - EXPORT int CALL InitiateGFX(GFX_INFO Gfx_Info); - - /****************************************************************** - Function: MoveScreen - Purpose: This function is called in response to the emulator - receiving a WM_MOVE passing the xpos and ypos passed - from that message. - input: xpos - the x-coordinate of the upper-left corner of the - client area of the window. - ypos - y-coordinate of the upper-left corner of the - client area of the window. - output: none - *******************************************************************/ - EXPORT void CALL MoveScreen(int xpos, int ypos); - - /****************************************************************** - Function: ProcessDList - Purpose: This function is called when there is a Dlist to be - processed. (High level GFX list) - input: none - output: none - *******************************************************************/ - EXPORT void CALL ProcessDList(void); - - /****************************************************************** - Function: ProcessRDPList - Purpose: This function is called when there is a Dlist to be - processed. (Low level GFX list) - input: none - output: none - *******************************************************************/ - EXPORT void CALL ProcessRDPList(void); - - /****************************************************************** - 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 - *******************************************************************/ - EXPORT void CALL RomOpen(void); - - /****************************************************************** - Function: ShowCFB - Purpose: Useally once Dlists are started being displayed, cfb is - ignored. This function tells the dll to start displaying - them again. - input: none - output: none - *******************************************************************/ - EXPORT void CALL ShowCFB(void); - - /****************************************************************** - Function: UpdateScreen - Purpose: This function is called in response to a vsync of the - screen were the VI bit in MI_INTR_REG has already been - set - input: none - output: none - *******************************************************************/ - EXPORT void CALL UpdateScreen(void); - - /****************************************************************** - Function: ViStatusChanged - Purpose: This function is called to notify the dll that the - ViStatus registers value has been changed. - input: none - output: none - *******************************************************************/ - EXPORT void CALL ViStatusChanged(void); - - /****************************************************************** - Function: ViWidthChanged - Purpose: This function is called to notify the dll that the - ViWidth registers value has been changed. - input: none - output: none - *******************************************************************/ - EXPORT void CALL ViWidthChanged(void); - -#ifdef ANDROID - /****************************************************************** - Function: SurfaceCreated - Purpose: this function is called when the surface is created. - input: none - output: none - *******************************************************************/ - EXPORT void CALL SurfaceCreated(void); - /****************************************************************** - Function: SurfaceChanged - Purpose: this function is called when the surface is has changed. - input: none - output: none - *******************************************************************/ - EXPORT void CALL SurfaceChanged(int width, int height); -#endif - /****************************************************************** - Function: FrameBufferWrite - Purpose: This function is called to notify the dll that the - frame buffer has been modified by CPU at the given address. - input: addr rdram address - val val - size 1 = uint8_t, 2 = uint16_t, 4 = uint32_t - output: none - *******************************************************************/ - EXPORT void CALL FBWrite(uint32_t, uint32_t); - - typedef struct - { - uint32_t addr; - uint32_t val; - uint32_t size; // 1 = uint8_t, 2 = uint16_t, 4=uint32_t - } FrameBufferModifyEntry; - - /****************************************************************** - Function: FrameBufferWriteList - Purpose: This function is called to notify the dll that the - frame buffer has been modified by CPU at the given address. - input: FrameBufferModifyEntry *plist - size = size of the plist, max = 1024 - output: none - *******************************************************************/ - EXPORT void CALL FBWList(FrameBufferModifyEntry *plist, uint32_t size); - - /****************************************************************** - Function: FrameBufferRead - Purpose: This function is called to notify the dll that the - frame buffer memory is beening read at the given address. - DLL should copy content from its render buffer to the frame buffer - in N64 RDRAM - DLL is responsible to maintain its own frame buffer memory addr list - DLL should copy 4KB block content back to RDRAM frame buffer. - Emulator should not call this function again if other memory - is read within the same 4KB range - input: addr rdram address - val val - size 1 = uint8_t, 2 = uint16_t, 4 = uint32_t - output: none - *******************************************************************/ - EXPORT void CALL FBRead(uint32_t addr); - - /************************************************************************ - Function: FBGetFrameBufferInfo - Purpose: This function is called by the emulator core to retrieve depth - buffer information from the video plugin in order to be able - to notify the video plugin about CPU depth buffer read/write - operations - - size: - = 1 byte - = 2 word (16 bit) <-- this is N64 default depth buffer format - = 4 dword (32 bit) - - when depth buffer information is not available yet, set all values - in the FrameBufferInfo structure to 0 - - input: FrameBufferInfo *pinfo - pinfo is pointed to a FrameBufferInfo structure which to be - filled in by this function - output: Values are return in the FrameBufferInfo structure - ************************************************************************/ - EXPORT void CALL FBGetFrameBufferInfo(void *pinfo); - - EXPORT void CALL PluginLoaded(void); - -#if defined(__cplusplus) +// The highest 8 bits are the segment # (1-16), and the lower 24 bits are the offset to +// add to it. +__inline uint32_t segoffset(uint32_t so) +{ + return (rdp.segment[(so >> 24) & 0x0f] + (so&BMASK))&BMASK; } -#endif + +extern GFX_INFO gfx; +extern bool no_dlist; \ No newline at end of file diff --git a/Source/Project64-video/Main.cpp b/Source/Project64-video/Main.cpp index 4a007c40a..c41ce9ced 100644 --- a/Source/Project64-video/Main.cpp +++ b/Source/Project64-video/Main.cpp @@ -608,7 +608,7 @@ Purpose: This function dumps the current frame to a file input: pointer to the directory to save the file to output: none *******************************************************************/ -EXPORT void CALL CaptureScreen(char * Directory) +void CALL CaptureScreen(const char * Directory) { g_capture_screen = true; g_capture_path = Directory; @@ -708,7 +708,7 @@ output: none void CALL GetDllInfo(PLUGIN_INFO * PluginInfo) { PluginInfo->Version = 0x0104; // Set to 0x0104 - PluginInfo->Type = PLUGIN_TYPE_GFX; // Set to PLUGIN_TYPE_GFX + PluginInfo->Type = PLUGIN_TYPE_VIDEO; // Set to PLUGIN_TYPE_GFX #ifdef _DEBUG sprintf(PluginInfo->Name, "Project64 Video Plugin (Debug): %s", VER_FILE_VERSION_STR); #else @@ -717,8 +717,8 @@ void CALL GetDllInfo(PLUGIN_INFO * PluginInfo) // If DLL supports memory these memory options then set them to TRUE or FALSE // if it does not support it - PluginInfo->NormalMemory = FALSE; // a normal uint8_t array - PluginInfo->MemoryBswaped = TRUE; // a normal uint8_t array where the memory has been pre + PluginInfo->Reserved1 = FALSE; // a normal uint8_t array + PluginInfo->Reserved2 = TRUE; // a normal uint8_t array where the memory has been pre // bswap on a dword (32 bits) boundry } diff --git a/Source/Project64-video/rdp.cpp b/Source/Project64-video/rdp.cpp index 8dfd5464a..2e24f8bcc 100644 --- a/Source/Project64-video/rdp.cpp +++ b/Source/Project64-video/rdp.cpp @@ -21,6 +21,7 @@ #include "trace.h" #include "SettingsID.h" #include +#include #ifdef _WIN32 #include @@ -3239,19 +3240,6 @@ EXPORT void CALL FBRead(uint32_t addr) } } -/****************************************************************** -Function: FrameBufferWriteList -Purpose: This function is called to notify the dll that the -frame buffer has been modified by CPU at the given address. -input: FrameBufferModifyEntry *plist -size = size of the plist, max = 1024 -output: none -*******************************************************************/ -EXPORT void CALL FBWList(FrameBufferModifyEntry* /*plist*/, uint32_t size) -{ - WriteTrace(TraceGlide64, TraceDebug, "size: %d", size); -} - /****************************************************************** Function: FrameBufferWrite Purpose: This function is called to notify the dll that the diff --git a/Source/Project64/Plugins/PluginList.cpp b/Source/Project64/Plugins/PluginList.cpp index b6d8b1bc7..893afb274 100644 --- a/Source/Project64/Plugins/PluginList.cpp +++ b/Source/Project64/Plugins/PluginList.cpp @@ -83,7 +83,7 @@ void CPluginList::AddPluginFromDir(CPath Dir) } PLUGIN Plugin = { 0 }; - Plugin.Info.MemoryBswaped = true; + Plugin.Info.Reserved2 = true; GetDllInfo(&Plugin.Info); if (!CPlugin::ValidPluginVersion(Plugin.Info)) { diff --git a/Source/Project64/UserInterface/MainMenu.cpp b/Source/Project64/UserInterface/MainMenu.cpp index e192c3a3b..7cad92d68 100644 --- a/Source/Project64/UserInterface/MainMenu.cpp +++ b/Source/Project64/UserInterface/MainMenu.cpp @@ -40,7 +40,7 @@ CMainMenu::CMainMenu(CMainGui * hMainWindow) : m_ChangeSettingList.push_back(Debugger_TraceAppCleanup); m_ChangeSettingList.push_back(Debugger_TraceN64System); m_ChangeSettingList.push_back(Debugger_TracePlugins); - m_ChangeSettingList.push_back(Debugger_TraceGFXPlugin); + m_ChangeSettingList.push_back(Debugger_TraceVideoPlugin); m_ChangeSettingList.push_back(Debugger_TraceAudioPlugin); m_ChangeSettingList.push_back(Debugger_TraceControllerPlugin); m_ChangeSettingList.push_back(Debugger_TraceRSPPlugin); @@ -211,9 +211,9 @@ void CMainMenu::OnEndEmulation(void) void CMainMenu::OnScreenShot(void) { stdstr Dir(g_Settings->LoadStringVal(Directory_SnapShot)); - WriteTrace(TraceGFXPlugin, TraceDebug, "CaptureScreen(%s): Starting", Dir.c_str()); + WriteTrace(TraceVideoPlugin, TraceDebug, "CaptureScreen(%s): Starting", Dir.c_str()); g_Plugins->Gfx()->CaptureScreen(Dir.c_str()); - WriteTrace(TraceGFXPlugin, TraceDebug, "CaptureScreen: Done"); + WriteTrace(TraceVideoPlugin, TraceDebug, "CaptureScreen: Done"); } void CMainMenu::OnSaveAs(HWND hWnd) @@ -412,9 +412,9 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI WriteTrace(TraceUserInterface, TraceDebug, "ID_OPTIONS_FULLSCREEN a"); m_Gui->MakeWindowOnTop(false); Notify().SetGfxPlugin(nullptr); - WriteTrace(TraceGFXPlugin, TraceDebug, "ChangeWindow: Starting"); + WriteTrace(TraceVideoPlugin, TraceDebug, "ChangeWindow: Starting"); g_Plugins->Gfx()->ChangeWindow(); - WriteTrace(TraceGFXPlugin, TraceDebug, "ChangeWindow: Done"); + WriteTrace(TraceVideoPlugin, TraceDebug, "ChangeWindow: Done"); ShowCursor(true); m_Gui->ShowStatusBar(g_Settings->LoadBool((SettingID)UserInterface_ShowStatusBar)); m_Gui->MakeWindowOnTop(UISettingsLoadBool(UserInterface_AlwaysOnTop)); @@ -429,9 +429,9 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI WriteTrace(TraceUserInterface, TraceDebug, "ID_OPTIONS_FULLSCREEN b 2"); try { - WriteTrace(TraceGFXPlugin, TraceDebug, "ChangeWindow: Starting"); + WriteTrace(TraceVideoPlugin, TraceDebug, "ChangeWindow: Starting"); g_Plugins->Gfx()->ChangeWindow(); - WriteTrace(TraceGFXPlugin, TraceDebug, "ChangeWindow: Done"); + WriteTrace(TraceVideoPlugin, TraceDebug, "ChangeWindow: Done"); } catch (...) { @@ -468,7 +468,7 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI break; case ID_OPTIONS_CONFIG_GFX: WriteTrace(TraceUserInterface, TraceDebug, "ID_OPTIONS_CONFIG_GFX"); - g_Plugins->ConfigPlugin(hWnd, PLUGIN_TYPE_GFX); + g_Plugins->ConfigPlugin(hWnd, PLUGIN_TYPE_VIDEO); break; case ID_OPTIONS_CONFIG_AUDIO: WriteTrace(TraceUserInterface, TraceDebug, "ID_OPTIONS_CONFIG_AUDIO"); @@ -535,7 +535,7 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI case ID_DEBUGGER_TRACE_APPCLEANUP: SetTraceModuleSetttings(Debugger_TraceAppCleanup); break; case ID_DEBUGGER_TRACE_N64SYSTEM: SetTraceModuleSetttings(Debugger_TraceN64System); break; case ID_DEBUGGER_TRACE_PLUGINS: SetTraceModuleSetttings(Debugger_TracePlugins); break; - case ID_DEBUGGER_TRACE_GFXPLUGIN: SetTraceModuleSetttings(Debugger_TraceGFXPlugin); break; + case ID_DEBUGGER_TRACE_GFXPLUGIN: SetTraceModuleSetttings(Debugger_TraceVideoPlugin); break; case ID_DEBUGGER_TRACE_AUDIOPLUGIN: SetTraceModuleSetttings(Debugger_TraceAudioPlugin); break; case ID_DEBUGGER_TRACE_CONTROLLERPLUGIN: SetTraceModuleSetttings(Debugger_TraceControllerPlugin); break; case ID_DEBUGGER_TRACE_RSPPLUGIN: SetTraceModuleSetttings(Debugger_TraceRSPPlugin); break; @@ -1131,7 +1131,7 @@ void CMainMenu::FillOutMenu(HMENU hMenu) DebugAppLoggingMenu.push_back(Item); Item.Reset(ID_DEBUGGER_TRACE_GFXPLUGIN, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"GFX plugin"); - Item.SetItemTicked(g_Settings->LoadDword(Debugger_TraceGFXPlugin) == TraceVerbose); + Item.SetItemTicked(g_Settings->LoadDword(Debugger_TraceVideoPlugin) == TraceVerbose); DebugAppLoggingMenu.push_back(Item); Item.Reset(ID_DEBUGGER_TRACE_AUDIOPLUGIN, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Audio plugin"); diff --git a/Source/Project64/UserInterface/MainWindow.cpp b/Source/Project64/UserInterface/MainWindow.cpp index 2b898bb5a..6f3ff2436 100644 --- a/Source/Project64/UserInterface/MainWindow.cpp +++ b/Source/Project64/UserInterface/MainWindow.cpp @@ -692,9 +692,9 @@ LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWO { if (g_Plugins->Gfx() && g_Plugins->Gfx()->MoveScreen) { - WriteTrace(TraceGFXPlugin, TraceDebug, "Starting"); + WriteTrace(TraceVideoPlugin, TraceDebug, "Starting"); g_Plugins->Gfx()->MoveScreen((int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam)); - WriteTrace(TraceGFXPlugin, TraceDebug, "Done"); + WriteTrace(TraceVideoPlugin, TraceDebug, "Done"); } } break; @@ -1110,9 +1110,9 @@ LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWO { if (g_Plugins->Gfx()) { - WriteTrace(TraceGFXPlugin, TraceDebug, "Starting"); + WriteTrace(TraceVideoPlugin, TraceDebug, "Starting"); g_Plugins->Gfx()->ProcessMenuItem(LOWORD(wParam)); - WriteTrace(TraceGFXPlugin, TraceDebug, "Done"); + WriteTrace(TraceVideoPlugin, TraceDebug, "Done"); } } else if (LOWORD(wParam) > 5200 && LOWORD(wParam) <= 5300) @@ -1127,9 +1127,9 @@ LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWO Rom.SaveRomSettingID(true); g_Notify->DisplayMessage(0, EMPTY_STRING); BYTE * RomHeader = Rom.GetRomAddress(); - WriteTrace(TraceGFXPlugin, TraceDebug, "OnRomBrowserMenuItem - Starting"); + WriteTrace(TraceVideoPlugin, TraceDebug, "OnRomBrowserMenuItem - Starting"); g_Plugins->Gfx()->OnRomBrowserMenuItem(LOWORD(wParam), hWnd, RomHeader); - WriteTrace(TraceGFXPlugin, TraceDebug, "OnRomBrowserMenuItem - Done"); + WriteTrace(TraceVideoPlugin, TraceDebug, "OnRomBrowserMenuItem - Done"); if (g_Rom) { g_Rom->SaveRomSettingID(false); diff --git a/Source/Project64/UserInterface/Notification.cpp b/Source/Project64/UserInterface/Notification.cpp index 73feb3cab..5c7abdeb7 100644 --- a/Source/Project64/UserInterface/Notification.cpp +++ b/Source/Project64/UserInterface/Notification.cpp @@ -112,9 +112,9 @@ void CNotificationImp::DisplayMessage(int DisplayTime, const char * Message) con { if (m_gfxPlugin && m_gfxPlugin->DrawStatus) { - WriteTrace(TraceGFXPlugin, TraceDebug, "DrawStatus - Starting"); + WriteTrace(TraceVideoPlugin, TraceDebug, "DrawStatus - Starting"); m_gfxPlugin->DrawStatus(Message, FALSE); - WriteTrace(TraceGFXPlugin, TraceDebug, "DrawStatus - Done"); + WriteTrace(TraceVideoPlugin, TraceDebug, "DrawStatus - Done"); } } else diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Game-Plugin.cpp b/Source/Project64/UserInterface/Settings/SettingsPage-Game-Plugin.cpp index 2e05f4085..5ee676adc 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-Game-Plugin.cpp +++ b/Source/Project64/UserInterface/Settings/SettingsPage-Game-Plugin.cpp @@ -29,7 +29,7 @@ CGamePluginPage::CGamePluginPage(HWND hParent, const RECT & rcDispay) m_ControlGroup.Attach(GetDlgItem(IDC_CONT_NAME)); m_RspGroup.Attach(GetDlgItem(IDC_RSP_NAME)); - AddPlugins(GFX_LIST, Game_EditPlugin_Gfx, PLUGIN_TYPE_GFX); + AddPlugins(GFX_LIST, Game_EditPlugin_Gfx, PLUGIN_TYPE_VIDEO); AddPlugins(AUDIO_LIST, Game_EditPlugin_Audio, PLUGIN_TYPE_AUDIO); AddPlugins(CONT_LIST, Game_EditPlugin_Contr, PLUGIN_TYPE_CONTROLLER); AddPlugins(RSP_LIST, Game_EditPlugin_RSP, PLUGIN_TYPE_RSP); diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Plugin.cpp b/Source/Project64/UserInterface/Settings/SettingsPage-Plugin.cpp index 16fcc75d5..6095673e9 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-Plugin.cpp +++ b/Source/Project64/UserInterface/Settings/SettingsPage-Plugin.cpp @@ -28,7 +28,7 @@ COptionPluginPage::COptionPluginPage(HWND hParent, const RECT & rcDispay) m_ControlGroup.Attach(GetDlgItem(IDC_CONT_NAME)); m_RspGroup.Attach(GetDlgItem(IDC_RSP_NAME)); - AddPlugins(GFX_LIST, Plugin_GFX_Current, PLUGIN_TYPE_GFX); + AddPlugins(GFX_LIST, Plugin_GFX_Current, PLUGIN_TYPE_VIDEO); AddPlugins(AUDIO_LIST, Plugin_AUDIO_Current, PLUGIN_TYPE_AUDIO); AddPlugins(CONT_LIST, Plugin_CONT_Current, PLUGIN_TYPE_CONTROLLER); AddPlugins(RSP_LIST, Plugin_RSP_Current, PLUGIN_TYPE_RSP); diff --git a/Source/RSP/Cpu.c b/Source/RSP/Cpu.c index 415e3efee..ecd8ec9d4 100644 --- a/Source/RSP/Cpu.c +++ b/Source/RSP/Cpu.c @@ -167,7 +167,7 @@ DWORD RunRecompilerCPU (DWORD Cycles); #define MI_INTR_SP 0x01 /* Bit 0: SP intr */ -__declspec(dllexport) DWORD DoRspCycles ( DWORD Cycles ) +uint32_t DoRspCycles (uint32_t Cycles ) { extern Boolean AudioHle, GraphicsHle; DWORD TaskType = *(DWORD*)(RSPInfo.DMEM + 0xFC0); diff --git a/Source/RSP/Main.cpp b/Source/RSP/Main.cpp index 5570f256b..d1f7c578d 100644 --- a/Source/RSP/Main.cpp +++ b/Source/RSP/Main.cpp @@ -216,8 +216,8 @@ EXPORT void GetDllInfo(PLUGIN_INFO * PluginInfo) #else sprintf(PluginInfo->Name, "RSP plugin %s", VER_FILE_VERSION_STR); #endif - PluginInfo->NormalMemory = FALSE; - PluginInfo->MemoryBswaped = TRUE; + PluginInfo->Reserved2 = FALSE; + PluginInfo->Reserved1 = TRUE; } /* diff --git a/Source/RSP/Recompiler CPU.c b/Source/RSP/Recompiler CPU.c index 3bcb24871..0fa02c7b1 100644 --- a/Source/RSP/Recompiler CPU.c +++ b/Source/RSP/Recompiler CPU.c @@ -24,7 +24,7 @@ #define X86_RECOMP_VERBOSE #define BUILD_BRANCHLABELS_VERBOSE -DWORD CompilePC, JumpTableSize, BlockID = 0; +uint32_t CompilePC, JumpTableSize, BlockID = 0; DWORD dwBuffer = MainBuffer; Boolean ChangedPC; diff --git a/Source/RSP/Rsp.h b/Source/RSP/Rsp.h index 252b5dc60..dd6bcd65e 100644 --- a/Source/RSP/Rsp.h +++ b/Source/RSP/Rsp.h @@ -1,4 +1,5 @@ -#pragma once +#pragma once +#include #if defined(__cplusplus) extern "C" { @@ -7,132 +8,14 @@ extern "C" { #include #include "Types.h" -#if defined(_WIN32) -#define EXPORT __declspec(dllexport) -#define CALL _cdecl -#else -#define EXPORT __attribute__((visibility("default"))) -#define CALL -#endif - // Profiling #define Default_ProfilingOn FALSE #define Default_IndvidualBlock FALSE #define Default_ShowErrors FALSE #define Default_AudioHle FALSE -#define PLUGIN_TYPE_RSP 1 -#define PLUGIN_TYPE_GFX 2 -#define PLUGIN_TYPE_AUDIO 3 -#define PLUGIN_TYPE_CONTROLLER 4 - -typedef struct { - uint16_t Version; // Should be set to 0x0101 - uint16_t Type; // Set to PLUGIN_TYPE_RSP - 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 - int NormalMemory; // A normal BYTE array - int MemoryBswaped; // A normal BYTE array where the memory has been pre-bswap'd on a DWORD (32-bit) boundary -} PLUGIN_INFO; - -typedef struct { - void * hInst; - 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; - uint8_t * RDRAM; - uint8_t * DMEM; - uint8_t * IMEM; - - uint32_t * MI_INTR_REG; - - uint32_t * SP_MEM_ADDR_REG; - uint32_t * SP_DRAM_ADDR_REG; - uint32_t * SP_RD_LEN_REG; - uint32_t * SP_WR_LEN_REG; - uint32_t * SP_STATUS_REG; - uint32_t * SP_DMA_FULL_REG; - uint32_t * SP_DMA_BUSY_REG; - uint32_t * SP_PC_REG; - uint32_t * SP_SEMAPHORE_REG; - - uint32_t * DPC_START_REG; - uint32_t * DPC_END_REG; - uint32_t * DPC_CURRENT_REG; - uint32_t * DPC_STATUS_REG; - uint32_t * DPC_CLOCK_REG; - uint32_t * DPC_BUFBUSY_REG; - uint32_t * DPC_PIPEBUSY_REG; - uint32_t * DPC_TMEM_REG; - - void (*CheckInterrupts)( void ); - void (*ProcessDList)( void ); - void (*ProcessAList)( void ); - void (*ProcessRdpList)( void ); - void (*ShowCFB)( void ); -} RSP_INFO; - -typedef struct { - long left, top, right, bottom; -} rectangle; // equivalent: RECT -typedef struct { - void * hdc; - Boolean fErase; - rectangle rcPaint; - Boolean fRestore; - Boolean fIncUpdate; - uint8_t rgbReserved[32]; -} window_paint; // equivalent: PAINTSTRUCT - -typedef struct { - // Menu - // Items should have an ID between 5001 and 5100 - void * hRSPMenu; - void (*ProcessMenuItem) ( int ID ); - - // Breakpoints - int UseBPoints; - char BPPanelName[20]; - void (*Add_BPoint) ( void ); - void (*CreateBPPanel) (void * hDlg, rectangle rcBox); - void (*HideBPPanel) ( void ); - void (*PaintBPPanel) (window_paint ps); - void (*ShowBPPanel) ( void ); - void (*RefreshBpoints)(void * hList); - void (*RemoveBpoint) (void * hList, int index); - void (*RemoveAllBpoint) ( void ); - - // RSP command window - void (*Enter_RSP_Commands_Window) ( void ); -} RSPDEBUG_INFO; - -typedef struct { - void (*UpdateBreakPoints)( void ); - void (*UpdateMemory)( void ); - void (*UpdateR4300iRegisters)( void ); - void (*Enter_BPoint_Window)( void ); - void (*Enter_R4300i_Commands_Window)( void ); - void (*Enter_R4300i_Register_Window)( void ); - void (*Enter_RSP_Commands_Window) ( void ); - void (*Enter_Memory_Window)( void ); -} DEBUG_INFO; - -EXPORT void CloseDLL(void); -EXPORT void DllAbout(void * hParent); -EXPORT uint32_t DoRspCycles(uint32_t Cycles); -EXPORT void GetDllInfo(PLUGIN_INFO * PluginInfo); -EXPORT void GetRspDebugInfo(RSPDEBUG_INFO * DebugInfo); -EXPORT void InitiateRSP(RSP_INFO Rsp_Info, uint32_t * CycleCount); -EXPORT void InitiateRSPDebugger(DEBUG_INFO Debug_Info); -EXPORT void RomOpen(void); -EXPORT void RomClosed(void); -EXPORT void DllConfig(void * hWnd); -EXPORT void EnableDebugging(int Enabled); -EXPORT void PluginLoaded(void); - uint32_t AsciiToHex(char * HexValue); void DisplayError(char * Message, ...); -int GetStoredWinPos(char * WinName, uint32_t * X, uint32_t * Y); #define InterpreterCPU 0 #define RecompilerCPU 1