diff --git a/Source/Project64-audio/AudioMain.cpp b/Source/Project64-audio/AudioMain.cpp index b919b931d..04468decb 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) @@ -115,7 +122,7 @@ EXPORT void CALL AiDacrateChanged(int SystemType) BufferSize = (Frequency / divider) + 3 & ~0x3; - if (hack == 'BH' && SystemType != SYSTEM_PAL) BufferSize -= 16; + if (hack == 0x4248 /*BH*/ && SystemType != SYSTEM_PAL) BufferSize -= 16; g_SoundDriver->AI_SetFrequency(Frequency, BufferSize); } @@ -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..3eccd468b 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/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..eff2d33f2 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-core/Project64-core.vcxproj b/Source/Project64-core/Project64-core.vcxproj index 14e66a173..531a2d147 100644 --- a/Source/Project64-core/Project64-core.vcxproj +++ b/Source/Project64-core/Project64-core.vcxproj @@ -132,6 +132,8 @@ + + diff --git a/Source/Project64-core/Project64-core.vcxproj.filters b/Source/Project64-core/Project64-core.vcxproj.filters index 117e46d82..b34b4cb90 100644 --- a/Source/Project64-core/Project64-core.vcxproj.filters +++ b/Source/Project64-core/Project64-core.vcxproj.filters @@ -94,6 +94,9 @@ {ec73ae9e-54e8-4cbe-93fb-1d98d6755619} + + {65f0fadd-3c4e-4491-b941-797478303ce8} + @@ -668,6 +671,12 @@ Header Files\N64 System\Enhancement + + Header Files\Plugin Spec + + + Header Files\Plugin Spec + diff --git a/Source/Project64-input/CProject64Input.h b/Source/Project64-input/CProject64Input.h index f0b0c021f..219638211 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 diff --git a/Source/Project64-input/DirectInput.cpp b/Source/Project64-input/DirectInput.cpp index aa8dba5fe..2b4427ba1 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 f29c30da7..42507d9e7 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 90f5b2ab0..15d80b203 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" @@ -94,8 +94,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 53d872c2f..a28e01054 100644 --- a/Source/Project64-input/InputSettings.h +++ b/Source/Project64-input/InputSettings.h @@ -2,7 +2,7 @@ #include #include #include "N64Controller.h" -#include "ControllerSpec1.1.h" +#include class CInputSettings { 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-audio/Audio_1.1.h b/Source/Project64-plugin-spec/Audio.h similarity index 71% rename from Source/Project64-audio/Audio_1.1.h rename to Source/Project64-plugin-spec/Audio.h index e66fadfc6..909c06067 100644 --- a/Source/Project64-audio/Audio_1.1.h +++ b/Source/Project64-plugin-spec/Audio.h @@ -1,64 +1,18 @@ -// 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 "Base.h" -#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 +#if defined(__cplusplus) +extern "C" { #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 * 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. + int32_t Reserved; + + uint8_t * HEADER; uint8_t * RDRAM; uint8_t * DMEM; uint8_t * IMEM; @@ -80,12 +34,11 @@ 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 +AUDIO_SYSTEM_NTSC 0 +AUDIO_SYSTEM_PAL 1 +AUDIO_SYSTEM_MPAL 2 Output: None */ - EXPORT void CALL AiDacrateChanged(int32_t SystemType); /* @@ -95,7 +48,6 @@ AiLen registers value has been changed. Input: None Output: None */ - EXPORT void CALL AiLenChanged(void); /* @@ -105,7 +57,6 @@ value that AI_LEN_REG should equal Input: None Output: The amount of bytes still left to play. */ - EXPORT uint32_t CALL AiReadLength(void); /* @@ -120,7 +71,6 @@ 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); /* @@ -130,7 +80,6 @@ down allowing the DLL to de-initialize. Input: None Output: None */ - EXPORT void CALL CloseDLL(void); /* @@ -140,7 +89,6 @@ 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); /* @@ -150,7 +98,6 @@ 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); /* @@ -160,7 +107,6 @@ 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); /* @@ -171,7 +117,6 @@ 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); /* @@ -188,7 +133,6 @@ 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); /* @@ -199,7 +143,6 @@ about the AList itself. Input: None Output: None */ - EXPORT void CALL ProcessAList(void); /* @@ -208,5 +151,8 @@ 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..4c37e7d5a --- /dev/null +++ b/Source/Project64-plugin-spec/Base.h @@ -0,0 +1,124 @@ +#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: 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 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 58% rename from Source/Project64-input/ControllerSpec1.1.h rename to Source/Project64-plugin-spec/Input.h index 359c31383..9080b1cb9 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,16 +15,9 @@ enum PLUGIN_RAW = 5, }; -// 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 { @@ -71,9 +52,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; @@ -81,23 +62,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 @@ -112,50 +83,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. @@ -164,7 +93,6 @@ Input: Controller number (0 to 3) the controller state. Output: None */ - EXPORT void CALL GetKeys(int32_t Control, BUTTONS * Keys); /* @@ -176,7 +104,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); /* @@ -190,28 +117,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: WM_KeyDown Purpose: To pass the WM_KeyDown message from the emulator to the @@ -219,7 +126,6 @@ plugin. Input: wParam and lParam of the WM_KEYDOWN message. Output: None */ - EXPORT void CALL WM_KeyDown(uint32_t wParam, uint32_t lParam); /* @@ -229,5 +135,8 @@ plugin. Input: wParam and lParam of the WM_KEYDOWN message. Output: None */ - EXPORT void CALL WM_KeyUp(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..32faacc71 --- /dev/null +++ b/Source/Project64-plugin-spec/Rsp.h @@ -0,0 +1,93 @@ +#pragma once +#include "Base.h" + +typedef struct _RSP_INFO +{ + 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) (int32_t 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..32f3cdf9e --- /dev/null +++ b/Source/Project64-plugin-spec/Video.h @@ -0,0 +1,186 @@ +#pragma once +#include "Base.h" + +#if defined(__cplusplus) +extern "C" { +#endif + +typedef struct +{ + void * hWnd; + void * hStatusBar; + + int32_t Reserved; + + uint8_t * HEADER; + 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; + +/* +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(const 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: 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: 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: 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 + +#if defined(__cplusplus) +} +#endif diff --git a/Source/RSP/Main.cpp b/Source/RSP/Main.cpp index 5570f256b..bbeee7b67 100644 --- a/Source/RSP/Main.cpp +++ b/Source/RSP/Main.cpp @@ -209,15 +209,15 @@ Output: None EXPORT void GetDllInfo(PLUGIN_INFO * PluginInfo) { - PluginInfo->Version = 0x0103; - PluginInfo->Type = PLUGIN_TYPE_RSP; + PluginInfo->Version = 0x0103; + PluginInfo->Type = PLUGIN_TYPE_RSP; #ifdef _DEBUG - sprintf(PluginInfo->Name, "RSP debug plugin %s", VER_FILE_VERSION_STR); + sprintf(PluginInfo->Name, "RSP debug plugin %s", VER_FILE_VERSION_STR); #else - sprintf(PluginInfo->Name, "RSP plugin %s", VER_FILE_VERSION_STR); + sprintf(PluginInfo->Name, "RSP plugin %s", VER_FILE_VERSION_STR); #endif - PluginInfo->NormalMemory = FALSE; - PluginInfo->MemoryBswaped = TRUE; + PluginInfo->Reserved2 = false; + PluginInfo->Reserved1 = true; } /* diff --git a/Source/RSP/Rsp.h b/Source/RSP/Rsp.h index 252b5dc60..be6e078b3 100644 --- a/Source/RSP/Rsp.h +++ b/Source/RSP/Rsp.h @@ -1,135 +1,15 @@ -#pragma once - -#if defined(__cplusplus) -extern "C" { -#endif +#pragma once +#include #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); @@ -142,7 +22,3 @@ extern uint32_t CPUCore; extern DEBUG_INFO DebugInfo; extern RSP_INFO RSPInfo; extern void * hinstDLL; - -#if defined(__cplusplus) -} -#endif