1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-02 09:03:37 +00:00

Fix compilation errors when MUPENPLUSAPI enabled

This commit is contained in:
Sergey Lipskiy 2013-10-24 16:20:05 +07:00
parent 5d81e4f2f3
commit 0a1499caed
11 changed files with 341 additions and 157 deletions

View File

@ -34,15 +34,25 @@ set(GLideN64_SOURCES
VI.cpp
)
include_directories( inc )
set(GLideN64_SOURCES_WIN
Config.cpp
)
set(GLideN64_SOURCES_LINUX
Config_linux.cpp
)
if(MUPENPLUSAPI)
add_definitions(
-DMUPENPLUSAPI
)
include_directories( inc )
set(GLideN64_SOURCES_WIN
Config_mupen.cpp
)
set(GLideN64_SOURCES_LINUX
Config_mupen.cpp
)
else(MUPENPLUSAPI)
set(GLideN64_SOURCES_WIN
Config.cpp
)
set(GLideN64_SOURCES_LINUX
Config_linux.cpp
)
endif(MUPENPLUSAPI)
if(UNIX)
list(APPEND GLideN64_SOURCES ${GLideN64_SOURCES_LINUX})
@ -70,9 +80,19 @@ if(WIN32)
endif(WIN32)
if(SDL)
include(FindPkgConfig)
pkg_check_modules(SDL REQUIRED sdl)
include_directories(${SDL_INCLUDE_DIRS})
endif(SDL)
find_package(OpenGL REQUIRED)
include_directories(${OpenGL_INCLUDE_DIRS})
link_directories(${OpenGL_LIBRARY_DIRS})
add_definitions(${OpenGL_DEFINITIONS})
if(NOT OPENGL_FOUND)
message(ERROR " OPENGL not found!")
endif(NOT OPENGL_FOUND)
add_library( GLideN64 SHARED ${GLideN64_SOURCES})
SET_TARGET_PROPERTIES(
@ -82,3 +102,5 @@ SET_TARGET_PROPERTIES(
PREFIX ""
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/plugin
)
target_link_libraries(GLideN64 ${OPENGL_LIBRARIES} ${SDL_LIBRARIES})

128
Config_mupen.cpp Normal file
View File

@ -0,0 +1,128 @@
#include "winlnxdefs.h"
# include <SDL/SDL.h>
#include <errno.h>
#include <string.h>
#include "Config.h"
#include "GLideN64.h"
#include "RSP.h"
#include "Textures.h"
#include "OpenGL.h"
struct Option
{
const char* name;
unsigned int* data;
const int initial;
};
Option configOptions[] =
{
{"#GLideN64 Graphics Plugin for N64", NULL, 0},
// {"config version", &config.version, 0},
{"", NULL, 0},
// {"#Window Settings:", NULL, 0},
{"window width", &OGL.windowedWidth, 640},
{"window height", &OGL.windowedHeight, 480},
{"force bilinear", &OGL.forceBilinear, 0},
{"enable 2xSAI", &OGL.enable2xSaI, 0},
{"enable fog", &OGL.fog, 1},
{"cache size", &cache.maxBytes, 64*1048576},
{"enable HardwareFB", &OGL.frameBufferTextures, 0},
{"texture depth", &OGL.textureBitDepth, 1}
};
const int configOptionsSize = sizeof(configOptions) / sizeof(Option);
void Config_WriteConfig(const char *filename)
{
//config.version = CONFIG_VERSION;
FILE* f = fopen(filename, "w");
if (!f) {
fprintf( stderr, "[GLideN64]: Could Not Open %s for writing\n", filename);
return;
}
for(int i=0; i<configOptionsSize; i++) {
Option *o = &configOptions[i];
fprintf(f, "%s", o->name);
if (o->data)
fprintf(f,"=%i", *(o->data));
fprintf(f, "\n");
}
fclose(f);
}
void Config_SetDefault()
{
for(int i=0; i < configOptionsSize; i++) {
Option *o = &configOptions[i];
if (o->data) *(o->data) = o->initial;
}
OGL.fullscreenWidth = 640;
OGL.fullscreenHeight = 480;
}
void Config_SetOption(char* line, char* val)
{
for(int i=0; i< configOptionsSize; i++) {
Option *o = &configOptions[i];
if (strcasecmp(line, o->name) == 0) {
if (o->data) {
int v = atoi(val);
*(o->data) = v;
}
break;
}
}
}
void Config_LoadConfig()
{
static bool loaded = false;
FILE *f;
char line[4096];
if (loaded)
return;
loaded = true;
Config_SetDefault();
// read configuration
const char *filename = ConfigGetSharedDataFilepath("glN64.conf");
f = fopen(filename, "r");
if (!f) {
fprintf( stderr, "[GLideN64]: (WW) Couldn't open config file '%s' for reading: %s\n", filename, strerror( errno ) );
fprintf( stderr, "[GLideN64]: Attempting to write new Config \n");
Config_WriteConfig(filename);
return;
}
while (!feof( f )) {
char *val;
fgets( line, 4096, f );
if (line[0] == '#' || line[0] == '\n')
continue;
val = strchr( line, '=' );
if (!val) continue;
*val++ = '\0';
Config_SetOption(line,val);
}
/*
if (config.version < CONFIG_VERSION)
{
LOG(LOG_WARNING, "[gles2N64]: Wrong config version, rewriting config with defaults\n");
Config_SetDefault();
Config_WriteConfig(filename);
}
*/
fclose(f);
}

View File

@ -24,7 +24,7 @@ bool g_bIgnoreCFB = true;
static const GLint depthTextureInternalFormat = g_bUseFloatDepthTexture ? GL_R32F : GL_R16;
static const GLenum depthTextureType = g_bUseFloatDepthTexture ? GL_FLOAT : GL_UNSIGNED_INT;
FrameBufferInfo frameBuffer;
FrameBufferList frameBuffer;
class FrameBufferToRDRAM
{

View File

@ -21,14 +21,14 @@ struct FrameBuffer
float scaleX, scaleY;
};
struct FrameBufferInfo
struct FrameBufferList
{
FrameBuffer *top, *bottom, *current;
int numBuffers;
GLenum drawBuffer;
};
extern FrameBufferInfo frameBuffer;
extern FrameBufferList frameBuffer;
extern bool g_bCopyToRDRAM;
extern bool g_bCopyDepthToRDRAM;
extern bool g_bCopyFromRDRAM;

View File

@ -1,3 +1,4 @@
#include <assert.h>
#include <stdio.h>
#include "GLideN64.h"
#include "GBI.h"
@ -103,6 +104,7 @@ void GBI_Unknown( u32 w0, u32 w1 )
#endif
}
#ifndef MUPENPLUSAPI
#ifndef __LINUX__
INT_PTR CALLBACK MicrocodeDlgProc( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
@ -272,6 +274,7 @@ static int MicrocodeDialog()
return selectedMicrocode;
}
#endif // __LINUX__
#endif // MUPENPLUSAPI
MicrocodeInfo *GBI_AddMicrocode()
{
@ -430,6 +433,7 @@ MicrocodeInfo *GBI_DetectMicrocode( u32 uc_start, u32 uc_dstart, u16 uc_dsize )
}
}
#ifndef MUPENPLUSAPI
// Let the user choose the microcode
#ifndef __LINUX__
current->type = (u32)DialogBox( hInstance, MAKEINTRESOURCE( IDD_MICROCODEDLG ), hWnd, MicrocodeDlgProc );
@ -437,6 +441,9 @@ MicrocodeInfo *GBI_DetectMicrocode( u32 uc_start, u32 uc_dstart, u16 uc_dsize )
printf( "glN64: Warning - unknown ucode!!!\n" );
current->type = MicrocodeDialog();
#endif // __LINUX__
#else // MUPENPLUSAPI
assert(false && "Unknown microcode!");
#endif // MUPENPLUSAPI
return current;
}

View File

@ -19,6 +19,8 @@
#include "Textures.h"
#include "Combiner.h"
char pluginName[] = "GLideN64 alpha";
#ifndef MUPENPLUSAPI
#include "ZilmarGFX_1_3.h"
@ -30,7 +32,6 @@ HWND hToolBar;
HINSTANCE hInstance;
#endif // !__LINUX__
char pluginName[] = "GLideN64 alpha";
char *screenDirectory;
void (*CheckInterrupts)( void );
@ -133,108 +134,6 @@ BOOL CALLBACK FindToolBarProc( HWND hWnd, LPARAM lParam )
}
#endif // !__LINUX__
EXPORT void CALL RomClosed (void)
{
#ifdef RSPTHREAD
int i;
if (RSP.thread)
{
// if (OGL.fullscreen)
// ChangeWindow();
if (RSP.busy)
{
RSP.halt = TRUE;
WaitForSingleObject( RSP.threadFinished, INFINITE );
}
SetEvent( RSP.threadMsg[RSPMSG_CLOSE] );
WaitForSingleObject( RSP.threadFinished, INFINITE );
for (i = 0; i < 4; i++)
if (RSP.threadMsg[i])
CloseHandle( RSP.threadMsg[i] );
CloseHandle( RSP.threadFinished );
CloseHandle( RSP.thread );
}
RSP.thread = NULL;
#else
OGL_Stop();
#endif
#ifdef DEBUG
CloseDebugDlg();
#endif
}
EXPORT void CALL RomOpen (void)
{
#ifdef RSPTHREAD
# ifndef __LINUX__
DWORD threadID;
int i;
// Create RSP message events
for (i = 0; i < 6; i++)
{
RSP.threadMsg[i] = CreateEvent( NULL, FALSE, FALSE, NULL );
if (RSP.threadMsg[i] == NULL)
{
MessageBox( hWnd, "Error creating video thread message events, closing video thread...", "glN64 Error", MB_OK | MB_ICONERROR );
return;
}
}
// Create RSP finished event
RSP.threadFinished = CreateEvent( NULL, FALSE, FALSE, NULL );
if (RSP.threadFinished == NULL)
{
MessageBox( hWnd, "Error creating video thread finished event, closing video thread...", "glN64 Error", MB_OK | MB_ICONERROR );
return;
}
RSP.thread = CreateThread( NULL, 4096, RSP_ThreadProc, NULL, NULL, &threadID );
WaitForSingleObject( RSP.threadFinished, INFINITE );
# else // !__LINUX__
# endif // __LINUX__
#else
RSP_Init();
#endif
OGL_ResizeWindow();
#ifdef DEBUG
OpenDebugDlg();
#endif
}
EXPORT void CALL ShowCFB (void)
{
gSP.changed |= CHANGED_CPU_FB_WRITE;
}
EXPORT void CALL UpdateScreen (void)
{
#ifdef RSPTHREAD
if (RSP.thread)
{
SetEvent( RSP.threadMsg[RSPMSG_UPDATESCREEN] );
WaitForSingleObject( RSP.threadFinished, INFINITE );
}
#else
VI_UpdateScreen();
#endif
}
EXPORT void CALL ViStatusChanged (void)
{
}
EXPORT void CALL ViWidthChanged (void)
{
}
EXPORT void CALL ReadScreen (void **dest, long *width, long *height)
{
@ -242,6 +141,8 @@ EXPORT void CALL ReadScreen (void **dest, long *width, long *height)
}
#else // MUPENPLUSAPI
#include "m64p_plugin.h"
ptr_ConfigGetSharedDataFilepath ConfigGetSharedDataFilepath = NULL;
void (*CheckInterrupts)( void );
@ -273,10 +174,10 @@ EXPORT m64p_error CALL PluginGetVersion(m64p_plugin_type *PluginType,
*PluginVersion = PLUGIN_VERSION;
if (APIVersion != NULL)
*APIVersion = PLUGIN_API_VERSION;
*APIVersion = VIDEO_PLUGIN_API_VERSION;
if (PluginNamePtr != NULL)
*PluginNamePtr = PLUGIN_NAME;
*PluginNamePtr = pluginName;
if (Capabilities != NULL)
{
@ -286,6 +187,28 @@ EXPORT m64p_error CALL PluginGetVersion(m64p_plugin_type *PluginType,
return M64ERR_SUCCESS;
}
EXPORT void CALL ReadScreen2(void *dest, int *width, int *height, int front)
{
//OGL_ReadScreen( dest, width, height );
}
EXPORT void CALL SetRenderingCallback(void (*callback)(int))
{
static void (*renderCallback)(int) = NULL;
renderCallback = callback;
}
EXPORT void CALL FBRead(u32 addr)
{
}
EXPORT void CALL FBWrite(u32 addr, u32 size) {
}
EXPORT void CALL FBGetFrameBufferInfo(void *p)
{
}
EXPORT void CALL ResizeVideoOutput(int Width, int Height)
{
}
@ -424,7 +347,7 @@ EXPORT BOOL CALL InitiateGFX (GFX_INFO Gfx_Info)
#endif // __LINUX__
#else // MUPENPLUSAPI
Config_LoadConfig();
Config_LoadRomConfig(Gfx_Info.HEADER);
// Config_LoadRomConfig(Gfx_Info.HEADER);
#endif // MUPENPLUSAPI
//OGL_Start();
@ -471,4 +394,106 @@ EXPORT void CALL ProcessRDPList(void)
// }
}
EXPORT void CALL RomClosed (void)
{
#ifdef RSPTHREAD
int i;
if (RSP.thread)
{
// if (OGL.fullscreen)
// ChangeWindow();
if (RSP.busy)
{
RSP.halt = TRUE;
WaitForSingleObject( RSP.threadFinished, INFINITE );
}
SetEvent( RSP.threadMsg[RSPMSG_CLOSE] );
WaitForSingleObject( RSP.threadFinished, INFINITE );
for (i = 0; i < 4; i++)
if (RSP.threadMsg[i])
CloseHandle( RSP.threadMsg[i] );
CloseHandle( RSP.threadFinished );
CloseHandle( RSP.thread );
}
RSP.thread = NULL;
#else
OGL_Stop();
#endif
#ifdef DEBUG
CloseDebugDlg();
#endif
}
EXPORT void CALL RomOpen (void)
{
#ifdef RSPTHREAD
# ifndef __LINUX__
DWORD threadID;
int i;
// Create RSP message events
for (i = 0; i < 6; i++)
{
RSP.threadMsg[i] = CreateEvent( NULL, FALSE, FALSE, NULL );
if (RSP.threadMsg[i] == NULL)
{
MessageBox( hWnd, "Error creating video thread message events, closing video thread...", "glN64 Error", MB_OK | MB_ICONERROR );
return;
}
}
// Create RSP finished event
RSP.threadFinished = CreateEvent( NULL, FALSE, FALSE, NULL );
if (RSP.threadFinished == NULL)
{
MessageBox( hWnd, "Error creating video thread finished event, closing video thread...", "glN64 Error", MB_OK | MB_ICONERROR );
return;
}
RSP.thread = CreateThread( NULL, 4096, RSP_ThreadProc, NULL, NULL, &threadID );
WaitForSingleObject( RSP.threadFinished, INFINITE );
# else // !__LINUX__
# endif // __LINUX__
#else
RSP_Init();
#endif
OGL_ResizeWindow();
#ifdef DEBUG
OpenDebugDlg();
#endif
}
EXPORT void CALL ShowCFB (void)
{
gSP.changed |= CHANGED_CPU_FB_WRITE;
}
EXPORT void CALL UpdateScreen (void)
{
#ifdef RSPTHREAD
if (RSP.thread)
{
SetEvent( RSP.threadMsg[RSPMSG_UPDATESCREEN] );
WaitForSingleObject( RSP.threadFinished, INFINITE );
}
#else
VI_UpdateScreen();
#endif
}
EXPORT void CALL ViStatusChanged (void)
{
}
EXPORT void CALL ViWidthChanged (void)
{
}
}

View File

@ -1,6 +1,8 @@
#ifndef GLIDEN64_H
#define GLIDEN64_H
extern char pluginName[];
#ifndef MUPENPLUSAPI
#ifndef __LINUX__
@ -17,8 +19,6 @@ extern HINSTANCE hInstance;
//#define DEBUG
//#define RSPTHREAD
extern char pluginName[];
extern void (*CheckInterrupts)( void );
extern char *screenDirectory;
@ -34,7 +34,6 @@ extern char *screenDirectory;
//#define DEBUG
#define PLUGIN_NAME "GLideN64 alpha"
#define PLUGIN_VERSION 0x020000
#define VIDEO_PLUGIN_API_VERSION 0x020200
#define CONFIG_API_VERSION 0x020000

View File

@ -52,7 +52,7 @@ struct GLInfo
BOOL enable2xSaI;
BOOL frameBufferTextures;
int textureBitDepth;
u32 textureBitDepth;
float originAdjust;
GLVertex vertices[256];

View File

@ -3,22 +3,22 @@
typedef unsigned char u8; /* unsigned 8-bit */
typedef unsigned short u16; /* unsigned 16-bit */
typedef unsigned long u32; /* unsigned 32-bit */
typedef unsigned int u32; /* unsigned 32-bit */
typedef unsigned long long u64; /* unsigned 64-bit */
typedef signed char s8; /* signed 8-bit */
typedef short s16; /* signed 16-bit */
typedef long s32; /* signed 32-bit */
typedef int s32; /* signed 32-bit */
typedef long long s64; /* signed 64-bit */
typedef volatile unsigned char vu8; /* unsigned 8-bit */
typedef volatile unsigned short vu16; /* unsigned 16-bit */
typedef volatile unsigned long vu32; /* unsigned 32-bit */
typedef volatile unsigned int vu32; /* unsigned 32-bit */
typedef volatile unsigned long long vu64; /* unsigned 64-bit */
typedef volatile signed char vs8; /* signed 8-bit */
typedef volatile short vs16; /* signed 16-bit */
typedef volatile long vs32; /* signed 32-bit */
typedef volatile int vs32; /* signed 32-bit */
typedef volatile long long vs64; /* signed 64-bit */
typedef float f32; /* single prec floating point */

View File

@ -51,37 +51,36 @@ typedef struct {
// eg. the first 8 bytes are stored like this:
// 4 3 2 1 8 7 6 5
BYTE * HEADER; // This is the rom header (first 40h bytes of the rom
// This will be in the same memory format as the rest of the memory.
BYTE * RDRAM;
BYTE * DMEM;
BYTE * IMEM;
unsigned char * HEADER; /* This is the rom header (first 40h bytes of the rom) */
unsigned char * RDRAM;
unsigned char * DMEM;
unsigned char * IMEM;
DWORD * MI_INTR_REG;
unsigned int * MI_INTR_REG;
DWORD * DPC_START_REG;
DWORD * DPC_END_REG;
DWORD * DPC_CURRENT_REG;
DWORD * DPC_STATUS_REG;
DWORD * DPC_CLOCK_REG;
DWORD * DPC_BUFBUSY_REG;
DWORD * DPC_PIPEBUSY_REG;
DWORD * DPC_TMEM_REG;
unsigned int * DPC_START_REG;
unsigned int * DPC_END_REG;
unsigned int * DPC_CURRENT_REG;
unsigned int * DPC_STATUS_REG;
unsigned int * DPC_CLOCK_REG;
unsigned int * DPC_BUFBUSY_REG;
unsigned int * DPC_PIPEBUSY_REG;
unsigned int * DPC_TMEM_REG;
DWORD * VI_STATUS_REG;
DWORD * VI_ORIGIN_REG;
DWORD * VI_WIDTH_REG;
DWORD * VI_INTR_REG;
DWORD * VI_V_CURRENT_LINE_REG;
DWORD * VI_TIMING_REG;
DWORD * VI_V_SYNC_REG;
DWORD * VI_H_SYNC_REG;
DWORD * VI_LEAP_REG;
DWORD * VI_H_START_REG;
DWORD * VI_V_START_REG;
DWORD * VI_V_BURST_REG;
DWORD * VI_X_SCALE_REG;
DWORD * VI_Y_SCALE_REG;
unsigned int * VI_STATUS_REG;
unsigned int * VI_ORIGIN_REG;
unsigned int * VI_WIDTH_REG;
unsigned int * VI_INTR_REG;
unsigned int * VI_V_CURRENT_LINE_REG;
unsigned int * VI_TIMING_REG;
unsigned int * VI_V_SYNC_REG;
unsigned int * VI_H_SYNC_REG;
unsigned int * VI_LEAP_REG;
unsigned int * VI_H_START_REG;
unsigned int * VI_V_START_REG;
unsigned int * VI_V_BURST_REG;
unsigned int * VI_X_SCALE_REG;
unsigned int * VI_Y_SCALE_REG;
void (*CheckInterrupts)( void );
} GFX_INFO;

View File

@ -43,7 +43,7 @@
#define timeGetTime() time( 0 )
typedef unsigned int BOOL, BOOLEAN;
typedef unsigned long DWORD;
typedef unsigned int DWORD;
typedef unsigned long long DWORD64, QWORD;
typedef unsigned short WORD;
typedef unsigned char BYTE, byte;
@ -73,12 +73,16 @@ typedef const char *LPCSTR;
#define __declspec(dllexport)
#define _cdecl
#define WINAPI
#define APIENTRY
//#define APIENTRY
//#define EXPORT
//#define CALL
#define max( a, b ) ((a > b) ? a : b)
#ifndef min
#define min( a, b ) ((a > b) ? b : a)
#endif
#ifndef max
#define max( a, b ) ((a > b) ? a : b)
#endif
#ifndef FALSE
#define FALSE 0