Linux GLideN64 compilation fixes (#16)

* Initial gliden64 src port for linux

* Further fixes for linux compilation

* Fixed compiling on Windows
This commit is contained in:
metronidazole 2022-05-02 22:27:09 +10:00 committed by GitHub
parent f495dd4209
commit 2ea13b0ff8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 2972 additions and 10 deletions

6
meson.build Normal file
View File

@ -0,0 +1,6 @@
project('GLideN64', 'c', 'cpp',
version : '0.1',
default_options : ['default_library=static', 'c_std=c11', 'cpp_std=c++17','buildtype=release'])
# Subdir hack
subdir('src')

18
meson_options.txt Normal file
View File

@ -0,0 +1,18 @@
option('EGL', type : 'boolean', value : false, description : 'If targeting an EGL device')
option('PANDORA', type : 'boolean', value : false, description : 'If targeting an OpenPandora')
option('ODROID', type : 'boolean', value : false, description : 'If targeting an Odroid')
option('MUPENPLUSAPI', type : 'boolean', value : false, description : 'For compiling Mupen64Plus plugin')
option('MUPENPLUSAPI_GLIDENUI', type : 'boolean', value : false, description : 'For compiling GLideNUI for Mupen64Plus')
option('MESA', type : 'boolean', value : false, description : 'Disable Raspberry Pi autodetection')
option('VERO4K', type : 'boolean', value : false, description : 'If targeting a Vero4k')
option('ANDROID', type : 'boolean', value : false, description : 'If targeting an Android device')
option('GL_PROFILE', type : 'boolean', value : false, description : 'to turn on GL profiling')
option('VEC4_OPT', type : 'boolean', value : false, description : 'to turn on Vec4 Optimizations')
option('CRC_ARMV8', type : 'boolean', value : false, description : 'to turn on CRC Optimization for ARMv8')
option('CRC_OPT', type : 'boolean', value : false, description : 'to turn on CRC Optimization')
option('CRC_NEON', type : 'boolean', value : false, description : 'to turn on CRC Optimization for NEON')
option('NEON_OPT', type : 'boolean', value : false, description : 'to turn on NEON Optimization')
option('X86_OPT', type : 'boolean', value : false, description : 'to turn on X86 Optimization')
option('NO_ASSERT', type : 'boolean', value : true, description : 'to turn off assert()')
option('NOHQ', type : 'boolean', value : true, description : 'Disable using GLideNHQ')
option('x64', type : 'boolean', value : false, description : 'Build for x64 architecture', yield : true)

View File

@ -122,12 +122,14 @@ void Config::resetToDefaults()
textureFilter.txHiresVramLimit = 0u;
#ifndef OS_LINUX
api().GetUserDataPath(textureFilter.txPath);
gln_wcscat(textureFilter.txPath, wst("/hires_texture"));
api().GetUserCachePath(textureFilter.txCachePath);
gln_wcscat(textureFilter.txCachePath, wst("/cache"));
api().GetUserCachePath(textureFilter.txDumpPath);
gln_wcscat(textureFilter.txDumpPath, wst("/texture_dump"));
#endif
#ifdef OS_WINDOWS
font.name.assign("arial.ttf");

View File

@ -15,8 +15,16 @@
#include "osal_keys.h"
#ifndef MUPENPLUSAPI
#if defined(OS_LINUX)
#define BOOL bool
#define WORD unsigned int
#undef CALL
#define CALL
#define HWND void*
#else
#include "windows/GLideN64_windows.h"
#endif
#endif
Debugger g_debugger;

38
src/GLideNHQ/meson.build Normal file
View File

@ -0,0 +1,38 @@
glidenhq_sources = ['TextureFilters.cpp', 'TextureFilters_2xsai.cpp', 'TextureFilters_hq2x.cpp', 'TextureFilters_hq4x.cpp', 'TextureFilters_xbrz.cpp', 'TxCache.cpp', 'TxDbg.cpp', 'TxFilter.cpp', 'TxFilterExport.cpp', 'TxHiResLoader.cpp', 'TxHiResCache.cpp', 'TxHiResNoCache.cpp', 'TxImage.cpp', 'TxQuantize.cpp', 'TxReSample.cpp', 'TxTexCache.cpp', 'TxUtil.cpp']
pic_flags = []
glidenhq_includes = include_directories('.')
# platform specific files
message('target_os = ' + target_os)
if target_os == 'linux'
gliden64_sources += gliden64_sources_unix
args_platform += [ '-DOS_LINUX', '-DNDEBUG']
pic_flags += '-fPIC'
elif target_os == 'darwin'
gliden64_sources += gliden64_sources_unix
args_platform += [ '-DOS_MAC_OS_X', '-DNDEBUG']
pic_flags += '-fPIC'
elif target_os == 'windows'
gliden64_sources += gliden64_sources_win
args_platform += [ '-DWIN32', '-DOS_WINDOWS', '-D_CRT_SECURE_NO_WARNINGS']
arg_linker += [ '-lopengl32' ]
#if '${CMAKE_CXX_COMPILER_ID}', 'STREQUAL', 'MSVC'
# # add_definitions('-D__MSC__')
#endif
endif
# Build type
glidenhq_name = 'GLideNHQ'
if get_option('buildtype') == 'debug'
glidenhq_name += 'd'
endif
glidenhq_lib = static_library('GLideNHQd', glidenhq_sources,
include_directories : [ osal_includes, gliden64_includes, glidenhq_includes ],
cpp_args : [ args_platform ] )
libpng_dep = dependency('libpng', fallback : ['libpng', 'libpng_dep'], native: false, default_options: ['default_library=static'])
zlib_dep = dependency('zlib', fallback : ['zlib', 'zlib_dep'], native: false, default_options: ['default_library=static'])
glidenhq_dep = declare_dependency(include_directories : '.', link_with : glidenhq_lib, dependencies : [libpng_dep, zlib_dep, libosal_dep])

View File

@ -209,7 +209,11 @@ void initGLFunctions()
#elif defined(ODROID)
void *gles2so = dlopen("/usr/lib/arm-linux-gnueabihf/libGLESv2.so", RTLD_NOW);
#elif defined(VERO4K)
void *gles2so = dlopen("/opt/vero3/lib/libGLESv2.so", RTLD_NOW);
void *gles2so = dlopen("/opt/vero3/lib/libGLESv2.so", RTLD_NOW);
#elif defined(__APPLE__)
void *libgl = dlopen("/System/Library/Frameworks/OpenGL.framework/OpenGL", RTLD_LAZY | RTLD_GLOBAL);
#elif defined(OS_LINUX)
void *libgl = dlopen("libGL.so.1", RTLD_LAZY | RTLD_GLOBAL);
#endif
#if defined(EGL) || defined(OS_IOS)

View File

@ -22,8 +22,12 @@
#ifdef MUPENPLUSAPI
#include <mupenplus/GLideN64_mupenplus.h>
#else
#if defined(OS_LINUX)
#include <Graphics/OpenGLContext/linux/WindowsWGL.h>
#else
#include <Graphics/OpenGLContext/windows/WindowsWGL.h>
#endif
#endif
namespace opengl {

View File

@ -0,0 +1,41 @@
#define GL_GLEXT_PROTOTYPES 1
#include "WindowsWGL.h"
#include <Config.h>
#include <GLideN64.h>
#include <Graphics/OpenGLContext/GLFunctions.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#if defined(__MINGW32__) || defined(USE_SDL2_INCLUDE_PATH_SHORT)
#include <SDL.h>
#include <SDL_opengl.h>
#else
#include <SDL2/SDL.h>
#include <SDL2/SDL_opengl.h>
#endif
#include <GL/gl.h>
static SDL_Window *_wind = NULL;
void WindowsWGL_GrabWindow(void *wind) {
_wind = (SDL_Window*)wind;
}
bool WindowsWGL::start()
{
initGLFunctions();
return true;
}
void WindowsWGL::stop()
{
/* Do Nothing. */
}
void WindowsWGL::swapBuffers()
{
SDL_GL_SwapWindow(_wind);
}

View File

@ -0,0 +1,14 @@
#pragma once
#include <stdio.h>
#include <GL/gl.h>
class WindowsWGL
{
public:
static bool start();
static void stop();
static void swapBuffers();
private:
};

View File

@ -0,0 +1,161 @@
#include <GLideN64.h>
#include <Config.h>
#include <N64.h>
#include <RSP.h>
#include <FrameBuffer.h>
#include <Graphics/Context.h>
#include <Graphics/Parameters.h>
#include <DisplayWindow.h>
#include <windows/ScreenShot.h>
#include <Graphics/OpenGLContext/ThreadedOpenGl/opengl_Wrapper.h>
bool isMemoryWritable(void * ptr, size_t byteCount) {
return true;
}
using namespace opengl;
class DisplayWindowWindows : public DisplayWindow
{
public:
DisplayWindowWindows() = default;
private:
bool _start() override;
void _stop() override;
void _restart() override;
void _swapBuffers() override;
void _saveScreenshot() override;
void _saveBufferContent(graphics::ObjectHandle _fbo, CachedTexture *_pTexture) override;
bool _resizeWindow() override;
void _changeWindow() override;
void _readScreen(void **_pDest, long *_pWidth, long *_pHeight) override;
void _readScreen2(void * _dest, int * _width, int * _height, int _front) override {}
graphics::ObjectHandle _getDefaultFramebuffer() override;
};
DisplayWindow & DisplayWindow::get()
{
static DisplayWindowWindows video;
return video;
}
bool DisplayWindowWindows::_start()
{
FunctionWrapper::setThreadedMode(config.video.threadedVideo);
FunctionWrapper::windowsStart();
return _resizeWindow();
}
void DisplayWindowWindows::_stop()
{
FunctionWrapper::windowsStop();
}
void DisplayWindowWindows::_restart()
{
}
void DisplayWindowWindows::_swapBuffers()
{
//Don't let the command queue grow too big buy waiting on no more swap buffers being queued
FunctionWrapper::WaitForSwapBuffersQueued();
FunctionWrapper::windowsSwapBuffers();
}
void DisplayWindowWindows::_saveScreenshot()
{
unsigned char * pixelData = NULL;
GLint oldMode;
glGetIntegerv(GL_READ_BUFFER, &oldMode);
gfxContext.bindFramebuffer(graphics::bufferTarget::READ_FRAMEBUFFER, graphics::ObjectHandle::defaultFramebuffer);
glReadBuffer(GL_FRONT);
pixelData = (unsigned char*)malloc(m_screenWidth * m_screenHeight * 3);
glReadPixels(0, m_heightOffset, m_screenWidth, m_screenHeight, GL_RGB, GL_UNSIGNED_BYTE, pixelData);
if (graphics::BufferAttachmentParam(oldMode) == graphics::bufferAttachment::COLOR_ATTACHMENT0) {
FrameBuffer * pBuffer = frameBufferList().getCurrent();
if (pBuffer != nullptr)
gfxContext.bindFramebuffer(graphics::bufferTarget::READ_FRAMEBUFFER, pBuffer->m_FBO);
}
glReadBuffer(oldMode);
size_t size = (wcslen(m_strScreenDirectory) + 1) * sizeof(wchar_t);
char *cBuf = new char[size];
std::wcstombs(cBuf, m_strScreenDirectory, size);
SaveScreenshot(cBuf, RSP.romname, m_screenWidth, m_screenHeight, pixelData);
delete cBuf;
free( pixelData );
}
void DisplayWindowWindows::_saveBufferContent(graphics::ObjectHandle _fbo, CachedTexture *_pTexture)
{
unsigned char * pixelData = NULL;
GLint oldMode;
glGetIntegerv(GL_READ_BUFFER, &oldMode);
gfxContext.bindFramebuffer(graphics::bufferTarget::READ_FRAMEBUFFER, _fbo);
pixelData = (unsigned char*)malloc(_pTexture->width * _pTexture->height * 3);
glReadPixels(0, 0, _pTexture->width, _pTexture->height, GL_RGB, GL_UNSIGNED_BYTE, pixelData);
if (graphics::BufferAttachmentParam(oldMode) == graphics::bufferAttachment::COLOR_ATTACHMENT0) {
FrameBuffer * pCurrentBuffer = frameBufferList().getCurrent();
if (pCurrentBuffer != nullptr)
gfxContext.bindFramebuffer(graphics::bufferTarget::READ_FRAMEBUFFER, pCurrentBuffer->m_FBO);
}
glReadBuffer(oldMode);
size_t size = (wcslen(m_strScreenDirectory) + 1) * sizeof(wchar_t);
char *cBuf = new char[size];
std::wcstombs(cBuf, m_strScreenDirectory, size);
SaveScreenshot(cBuf, RSP.romname, _pTexture->width, _pTexture->height, pixelData);
delete cBuf;
free(pixelData);
}
void DisplayWindowWindows::_changeWindow()
{
_resizeWindow();
}
bool DisplayWindowWindows::_resizeWindow()
{
m_screenWidth = m_width = config.video.windowedWidth;
m_screenHeight = config.video.windowedHeight;
_setBufferSize();
return true;
}
void DisplayWindowWindows::_readScreen(void **_pDest, long *_pWidth, long *_pHeight)
{
*_pWidth = m_width;
*_pHeight = m_height;
*_pDest = malloc(m_height * m_width * 3);
if (*_pDest == nullptr)
return;
#ifndef GLESX
GLint oldMode;
glGetIntegerv(GL_READ_BUFFER, &oldMode);
gfxContext.bindFramebuffer(graphics::bufferTarget::READ_FRAMEBUFFER, graphics::ObjectHandle::defaultFramebuffer);
glReadBuffer(GL_FRONT);
glReadPixels(0, m_heightOffset, m_width, m_height, GL_BGR_EXT, GL_UNSIGNED_BYTE, *_pDest);
if (graphics::BufferAttachmentParam(oldMode) == graphics::bufferAttachment::COLOR_ATTACHMENT0) {
FrameBuffer * pBuffer = frameBufferList().getCurrent();
if (pBuffer != nullptr)
gfxContext.bindFramebuffer(graphics::bufferTarget::READ_FRAMEBUFFER, pBuffer->m_FBO);
}
glReadBuffer(oldMode);
#else
glReadPixels(0, m_heightOffset, m_width, m_height, GL_RGB, GL_UNSIGNED_BYTE, *_pDest);
#endif
}
graphics::ObjectHandle DisplayWindowWindows::_getDefaultFramebuffer()
{
return graphics::ObjectHandle::null;
}

View File

@ -7,7 +7,9 @@
#endif
#include "m64p_plugin.h"
#else
#if defined(OS_WINDOWS)
#include "windows/GLideN64_windows.h"
#endif
#include "ZilmarGFX_1_3.h"
#include "FrameBufferInfoAPI.h"
//#define RSPTHREAD

View File

@ -94,21 +94,25 @@ void TextureFilterHandler::init()
wchar_t txCachePath[PLUGIN_PATH_SIZE + 16];
wchar_t * pTexCachePath = config.textureFilter.txCachePath;
#if !defined(OS_LINUX)
if (::wcslen(config.textureFilter.txCachePath) == 0 ||
osal_is_absolute_path(config.textureFilter.txCachePath) == 0) {
api().GetUserCachePath(txCachePath);
gln_wcscat(txCachePath, wst("/cache"));
pTexCachePath = txCachePath;
}
#endif
wchar_t txDumpPath[PLUGIN_PATH_SIZE + 16];
wchar_t * pTexDumpPath = config.textureFilter.txDumpPath;
#if !defined(OS_LINUX)
if (::wcslen(config.textureFilter.txDumpPath) == 0 ||
osal_is_absolute_path(config.textureFilter.txDumpPath) == 0) {
api().GetUserCachePath(txDumpPath);
gln_wcscat(txDumpPath, wst("/texture_dump"));
pTexDumpPath = txDumpPath;
}
#endif
m_inited = txfilter_init(maxTextureSize, // max texture width supported by hardware
maxTextureSize, // max texture height supported by hardware

View File

@ -19,12 +19,26 @@ txfilter_filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat,
return 0;
}
TAPI boolean TAPIENTRY
txfilter_filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat,
uint64 g64crc, N64FormatSize n64FmtSz, GHQTexInfo *info)
{
return 0;
}
TAPI boolean TAPIENTRY
txfilter_hirestex(uint64 g64crc, uint64 r_crc64, uint16 *palette, GHQTexInfo *info)
{
return 0;
}
TAPI boolean TAPIENTRY
txfilter_hirestex(uint64 g64crc, Checksum r_crc64, uint16 *palette, N64FormatSize n64FmtSz, GHQTexInfo *info)
{
return 0;
}
TAPI uint64 TAPIENTRY
txfilter_checksum(uint8 *src, int width, int height, int size, int rowStride, uint8 *palette)
{
@ -37,6 +51,12 @@ txfilter_dmptx(uint8 *src, int width, int height, int rowStridePixel, uint16 gfm
return 0;
}
TAPI boolean TAPIENTRY
txfilter_dmptx(uint8 *src, int width, int height, int rowStridePixel, uint16 gfmt, N64FormatSize n64FmtSz, Checksum r_crc64)
{
return 0;
}
TAPI boolean TAPIENTRY
txfilter_reloadhirestex()
{

View File

@ -19,6 +19,10 @@ the plugin
#ifndef _GFX_H_INCLUDED__
#define _GFX_H_INCLUDED__
#ifdef OS_LINUX
#include "Platform.h"
#endif
#ifndef word
#include "porting.h"
#endif

View File

@ -0,0 +1,27 @@
#include <algorithm>
#include <string>
#include "../PluginAPI.h"
#include "../RSP.h"
int PluginAPI::InitiateGFX(const GFX_INFO & _gfxInfo)
{
_initiateGFX(_gfxInfo);
return TRUE;
}
void PluginAPI::FindPluginPath(wchar_t * _strPath)
{
wcscpy(_strPath, L".");
return;
}
void PluginAPI::GetUserDataPath(wchar_t * _strPath)
{
FindPluginPath(_strPath);
}
void PluginAPI::GetUserCachePath(wchar_t * _strPath)
{
FindPluginPath(_strPath);
}

281
src/meson.build Normal file
View File

@ -0,0 +1,281 @@
# Platform config
target_os = target_machine.system()
build_os = build_machine.system()
# 32 bit
arch_bits = '-m32'
if get_option('x64')
arch_bits = []
endif
if not meson.is_subproject()
add_global_arguments(arch_bits, language : ['c', 'cpp'])
endif
arg_linker = [ arch_bits ]
args_platform = []
arg_options = ['-DGBI_FLOATS']
gliden64_sources_platform = []
opengl_dep = dependency('gl')
thread_dep = dependency('threads', native: false)
freetype2_dep = dependency('freetype2', native: false, default_options: ['default_library=static', 'png=disabled', 'zlib=disabled'])
sdl2_dep = dependency('sdl2', native: false)
libpng_dep = dependency('libpng', fallback : ['libpng', 'libpng_dep'], native: false, default_options: ['default_library=static'])
zlib_dep = dependency('zlib', fallback : ['zlib', 'zlib_dep'], native: false, default_options: ['default_library=static', 'solo=true'])
gliden64_deps = [ sdl2_dep, freetype2_dep, libpng_dep, zlib_dep, thread_dep, opengl_dep ]
args_deps = ['-DUSE_SDL', '-DUSE_FREETYPE']
if build_os == 'linux' or build_os == 'darwin'
script_extension = '.sh'
elif build_os == 'windows'
script_extension = '.bat'
endif
# run script to generate Revision.h
# check if system has working git and we are in a git repo
fs = import('fs')
get_revision = find_program( [ 'getRevision', 'getRevision'+ script_extension ], required : false)
git = find_program('git', required : false)
if git.found() and ( fs.is_dir(meson.source_root() + '/../.git') or fs.is_file(meson.source_root() + '/../.git') )
revision_h = custom_target(
'revision.h',
output : 'revision.h',
command : [ get_revision ] )
else
revision_h = custom_target(
'revision.h',
output : 'revision.h',
command : [ get_revision, '--nogit' ] )
endif
gliden64_sources = [
'3DMath.cpp',
'Combiner.cpp',
'CombinerKey.cpp',
'CommonPluginAPI.cpp',
'Config.cpp',
'convert.cpp',
'DebugDump.cpp',
'Debugger.cpp',
'DepthBuffer.cpp',
'DisplayWindow.cpp',
'DisplayLoadProgress.cpp',
'FrameBuffer.cpp',
'FrameBufferInfo.cpp',
'GBI.cpp',
'gDP.cpp',
'GLideN64.cpp',
'GraphicsDrawer.cpp',
'gSP.cpp',
'Log.cpp',
'N64.cpp',
'NoiseTexture.cpp',
'PaletteTexture.cpp',
'Performance.cpp',
'PostProcessor.cpp',
'RDP.cpp',
'RSP.cpp',
'RSP_LoadMatrix.cpp',
'SoftwareRender.cpp',
'TexrectDrawer.cpp',
'TextDrawer.cpp',
'TextureFilterHandler.cpp',
'Textures.cpp',
'VI.cpp',
'ZlutTexture.cpp',
'BufferCopy/BlueNoiseTexture.cpp',
'BufferCopy/ColorBufferToRDRAM.cpp',
'BufferCopy/DepthBufferToRDRAM.cpp',
'BufferCopy/RDRAMtoColorBuffer.cpp',
'DepthBufferRender/ClipPolygon.cpp',
'DepthBufferRender/DepthBufferRender.cpp',
'common/CommonAPIImpl_common.cpp',
'native/FileClass.cpp',
'native/GlSettings.cpp',
'native/IniFileClass.cpp',
'native/Native.cpp',
'native/NativeSettings.cpp',
'native/util/util.cpp',
'native/util/path.cpp',
'native/util/StdString.cpp',
'Graphics/Context.cpp',
'Graphics/ColorBufferReader.cpp',
'Graphics/CombinerProgram.cpp',
'Graphics/ObjectHandle.cpp',
'Graphics/OpenGLContext/GLFunctions.cpp',
'Graphics/OpenGLContext/ThreadedOpenGl/opengl_Command.cpp',
'Graphics/OpenGLContext/ThreadedOpenGl/opengl_ObjectPool.cpp',
'Graphics/OpenGLContext/ThreadedOpenGl/opengl_Wrapper.cpp',
'Graphics/OpenGLContext/ThreadedOpenGl/opengl_WrappedFunctions.cpp',
'Graphics/OpenGLContext/ThreadedOpenGl/RingBufferPool.cpp',
'Graphics/OpenGLContext/opengl_Attributes.cpp',
'Graphics/OpenGLContext/opengl_BufferedDrawer.cpp',
'Graphics/OpenGLContext/opengl_BufferManipulationObjectFactory.cpp',
'Graphics/OpenGLContext/opengl_CachedFunctions.cpp',
'Graphics/OpenGLContext/opengl_ColorBufferReaderWithBufferStorage.cpp',
'Graphics/OpenGLContext/opengl_ColorBufferReaderWithPixelBuffer.cpp',
'Graphics/OpenGLContext/opengl_ColorBufferReaderWithReadPixels.cpp',
'Graphics/OpenGLContext/opengl_ContextImpl.cpp',
'Graphics/OpenGLContext/opengl_GLInfo.cpp',
'Graphics/OpenGLContext/opengl_Parameters.cpp',
'Graphics/OpenGLContext/opengl_TextureManipulationObjectFactory.cpp',
'Graphics/OpenGLContext/opengl_UnbufferedDrawer.cpp',
'Graphics/OpenGLContext/opengl_Utils.cpp',
'Graphics/OpenGLContext/GLSL/glsl_CombinerInputs.cpp',
'Graphics/OpenGLContext/GLSL/glsl_CombinerProgramBuilder.cpp',
'Graphics/OpenGLContext/GLSL/glsl_CombinerProgramBuilderCommon.cpp',
'Graphics/OpenGLContext/GLSL/glsl_CombinerProgramBuilderAccurate.cpp',
'Graphics/OpenGLContext/GLSL/glsl_CombinerProgramBuilderFast.cpp',
'Graphics/OpenGLContext/GLSL/glsl_CombinerProgramImpl.cpp',
'Graphics/OpenGLContext/GLSL/glsl_CombinerProgramUniformFactory.cpp',
'Graphics/OpenGLContext/GLSL/glsl_CombinerProgramUniformFactoryCommon.cpp',
'Graphics/OpenGLContext/GLSL/glsl_CombinerProgramUniformFactoryAccurate.cpp',
'Graphics/OpenGLContext/GLSL/glsl_CombinerProgramUniformFactoryFast.cpp',
'Graphics/OpenGLContext/GLSL/glsl_FXAA.cpp',
'Graphics/OpenGLContext/GLSL/glsl_ShaderStorage.cpp',
'Graphics/OpenGLContext/GLSL/glsl_SpecialShadersFactory.cpp',
'Graphics/OpenGLContext/GLSL/glsl_Utils.cpp',
'uCodes/F3D.cpp',
'uCodes/F3DBETA.cpp',
'uCodes/F3DDKR.cpp',
'uCodes/F3DEX.cpp',
'uCodes/F3DAM.cpp',
'uCodes/F3DEX2.cpp',
'uCodes/F3DEX2ACCLAIM.cpp',
'uCodes/F3DEX2CBFD.cpp',
'uCodes/F3DZEX2.cpp',
'uCodes/F3DFLX2.cpp',
'uCodes/F3DGOLDEN.cpp',
'uCodes/F3DTEXA.cpp',
'uCodes/F3DPD.cpp',
'uCodes/F3DSETA.cpp',
'uCodes/F5Indi_Naboo.cpp',
'uCodes/F5Rogue.cpp',
'uCodes/L3D.cpp',
'uCodes/L3DEX2.cpp',
'uCodes/L3DEX.cpp',
'uCodes/S2DEX2.cpp',
'uCodes/S2DEX.cpp',
'uCodes/T3DUX.cpp',
'uCodes/Turbo3D.cpp',
'uCodes/ZSort.cpp',
'uCodes/ZSortBOSS.cpp']
#glidenui_sources = ['ZilmarPluginAPI.cpp', 'windows/ZilmarAPIImpl_windows.cpp', 'GLideNUI/Config_GLideNUI.cpp', 'GLideNUI/AboutDialog.cpp', 'GLideNUI/AboutDialog.ui', 'GLideNUI/ConfigDialog.cpp', 'GLideNUI/Config_GLideNUI.cpp', 'GLideNUI/GLideNUI.cpp', 'GLideNUI/Settings.cpp', 'GLideNUI/QtKeyToHID.cpp', 'GLideNUI/HIDKeyToName.cpp', 'GLideNUI/configDialog.ui', 'GLideNUI/icon.qrc']
# Build type
gliden64_dll_name = 'GLideN64'
if (get_option('NO_ASSERT')) or (get_option('buildtype') == 'release')
args_platform += [ '-UDEBUG', '-DNDEBUG' ]
message('Building Release version of GLideN64')
else
gliden64_dll_name = 'GLideN64d'
args_platform += [ '-UNDEBUG', '-DDEBUG' ]
message('Building Debug version of GLideN64')
endif
# Compiler detection
cc = meson.get_compiler('c')
args_sdl = []
sdl_include_path_full = '''#include <SDL2/SDL.h>
void func() { SDL_Init(0); }
'''
sdl_include_path_short = '''#include <SDL.h>
void func() { SDL_Init(0); }
'''
if sdl2_dep.type_name() == 'internal'
args_sdl += [ '-DUSE_SDL2_INCLUDE_PATH_SHORT' ]
message('Using SDL2 include path <SDL.h>')
else
result_sdl_path_long = cc.compiles( sdl_include_path_full, name : 'sdl_include_long', dependencies : sdl2_dep )
if result_sdl_path_long
message('Using SDL2 include path <SDL2/SDL.h>')
else
result_sdl_path_short = cc.compiles( sdl_include_path_short, name : 'sdl_include_short', dependencies : sdl2_dep )
if result_sdl_path_short
args_sdl += [ '-DUSE_SDL2_INCLUDE_PATH_SHORT' ]
message('Using SDL2 include path <SDL.h>')
else
error('Could not find SDL2 include path')
endif
endif
endif
# Add what we learned to the platform args
args_platform += args_sdl
gliden64_sources_unix = ['Graphics/OpenGLContext/linux/windows_DisplayWindow.cpp', 'Graphics/OpenGLContext/linux/WindowsWGL.cpp', 'linux/CommonAPIImpl_linux.cpp', 'windows/ScreenShot.cpp']
gliden64_sources_win = [ 'windows/CommonAPIImpl_windows.cpp', 'windows/MemoryStatus_windows.cpp', 'windows/ScreenShot.cpp', 'Graphics/OpenGLContext/windows/windows_DisplayWindow.cpp', 'Graphics/OpenGLContext/windows/WindowsWGL.cpp', 'windows/GLideN64_windows.cpp']
gliden64_includes = include_directories('.')
# Subdir projects
subdir('osal')
gliden64_deps += [ libosal_dep ]
# platform specific files
message('target_os = ' + target_os)
if target_os == 'linux' or target_os == 'darwin'
gliden64_sources += gliden64_sources_unix
args_platform += [ '-DOS_LINUX', '-DNATIVE', '-DGL_USE_UNIFORMBLOCK' ]
arg_linker += [ '-pthread' ]
dl_dep = cc.find_library('dl')
gliden64_deps += dl_dep
elif target_os == 'windows'
gliden64_sources += gliden64_sources_win
args_platform += [ '-DOS_WINDOWS', '-D__WIN32__', '-DWIN32', '-D_WIN32_ASM', '-D_CRT_SECURE_NO_WARNINGS', '-D__MSC__', '-DNATIVE', '-DGL_USE_UNIFORMBLOCK']
#arg_linker += [ '-lopengl32' ]
endif
#if 'PANDORA'
# #Pandora as a SGX530, but it should share the bugs and limitations as SGX540
# args_platform += [ '-DPANDORA', '-DPowerVR_SGX_540', '-DEGL' ]
#endif
#if 'ODROID'
# args_platform += [ '-DODROID' ]
#endif
#if 'VERO4K'
# args_platform += [ '-DVERO4K' ]
#endif
if get_option('VEC4_OPT')
arg_options += [ '-D__VEC4_OPT' ]
endif
if get_option('CRC_ARMV8')
gliden64_sources_platform += [ 'CRC32_ARMV8.cpp' ]
elif get_option('CRC_OPT')
gliden64_sources_platform += [ 'CRC_OPT.cpp' ]
elif get_option('CRC_NEON')
gliden64_sources_platform += [ 'Neon/CRC_OPT_NEON.cpp' ]
else
gliden64_sources_platform += [ 'CRC32.cpp' ]
endif
if get_option('X86_OPT')
gliden64_sources_platform += [ '3DMath.cpp', 'RSP_LoadMatrixX86.cpp' ]
elif get_option('NEON_OPT')
gliden64_sources_platform += [ 'Neon/3DMathNeon.cpp', 'Neon/gSPNeon.cpp', 'Neon/RSP_LoadMatrixNeon.cpp' ]
else
gliden64_sources_platform += [ '3DMath.cpp', 'RSP_LoadMatrix.cpp' ]
endif
if get_option('NOHQ')
gliden64_sources_platform += [ 'TxFilterStub.cpp' ]
else
message('Compiling GLideN64 with GLideNHQ support!')
subdir('GLideNHQ')
gliden64_deps += [ glidenhq_dep ]
endif
if get_option('GL_PROFILE')
arg_options += [ '-DGL_PROFILE', '-DGL_DEBUG' ]
endif
#if 'EGL'
# # add_definitions('-DEGL')
# opengl_libraries = egl_lib
#endif
glidne64_dll = shared_library(gliden64_dll_name, sources: [ gliden64_sources, gliden64_sources_platform, revision_h ] , include_directories : gliden64_includes,
cpp_args : [ arg_options, args_platform] , link_args : arg_linker,
dependencies : gliden64_deps,
name_prefix: '',
install : true)
gliden64_dep = declare_dependency( link_args : arg_linker, link_with : glidne64_dll )

View File

@ -5,6 +5,9 @@
#include <Windows.h>
#else
#include <unistd.h>
#include <cstring>
#include <cstdio>
#include "util/path.h"
#endif
#if defined(_MSC_VER)
@ -347,4 +350,4 @@ bool CFile::SetEndOfFile()
return ftruncate(fileno((FILE *)m_hFile),GetPosition()) == 0;
#endif
#endif
}
}

View File

@ -1,7 +1,11 @@
#pragma once
#include <cstring>
#ifndef _WIN32
#include <strings.h>
#define _stricmp strcasecmp
#define stricmp strcasecmp
#define sprintf_s snprintf
#define _vscprintf(foo, ...) vsnprintf(NULL, 0, foo, __VA_ARGS__)
#endif
#include "FileClass.h"

View File

@ -10,7 +10,7 @@
#include "FrameBuffer.h"
#include "FrameBufferInfo.h"
#include <wchar.h>
#include "settings.h"
#include "Settings.h"
#define START_WIDTH 1280
#define START_HEIGHT 720
@ -140,8 +140,10 @@ extern "C" {
RDRAMSize = (word)-1;
api().RomOpen(romName);
// Fixme: linux port (wsprintf)
#ifndef OS_LINUX
wsprintf(config.textureFilter.txCachePath, L".");
#endif
config.textureFilter.txHiresTextureFileStorage = highres_hts ? 1 : 0;
}
@ -280,6 +282,12 @@ void Config_DoConfig(/*HWND hParent*/)
void LoadConfig(const wchar_t* _strFileName)
{
#if defined(OS_LINUX)
std::wstring wStrFile(_strFileName);
std::string IniFolder(wStrFile.begin(), wStrFile.end());
loadSettings(IniFolder.c_str());
return;
#else
std::string IniFolder;
uint32_t slength = WideCharToMultiByte(CP_ACP, 0, _strFileName, -1, NULL, 0, NULL, NULL);
IniFolder.resize(slength);
@ -287,10 +295,17 @@ void LoadConfig(const wchar_t* _strFileName)
IniFolder.resize(slength - 1); //Remove null end char
loadSettings(IniFolder.c_str());
#endif
}
void LoadCustomRomSettings(const wchar_t* _strFileName, const char* _romName)
{
#if defined(OS_LINUX)
std::wstring wStrFile(_strFileName);
std::string IniFolder(wStrFile.begin(), wStrFile.end());
loadCustomRomSettings(IniFolder.c_str(), _romName);
return;
#else
std::string IniFolder;
uint32_t slength = WideCharToMultiByte(CP_ACP, 0, _strFileName, -1, NULL, 0, NULL, NULL);
IniFolder.resize(slength);
@ -298,6 +313,7 @@ void LoadCustomRomSettings(const wchar_t* _strFileName, const char* _romName)
IniFolder.resize(slength - 1); //Remove null end char
loadCustomRomSettings(IniFolder.c_str(), _romName);
#endif
}
void Config_LoadConfig()
@ -308,4 +324,4 @@ void Config_LoadConfig()
if(config.generalEmulation.enableCustomSettings != 0)
LoadCustomRomSettings(strIniFolderPath, RSP.romname);
config.validate();
}
}

View File

@ -102,9 +102,15 @@ void _loadSettings(GlSettings & settings)
config.textureFilter.txSaveCache = settings.value("txSaveCache", config.textureFilter.txSaveCache).toInt();
config.textureFilter.txEnhancedTextureFileStorage = settings.value("txEnhancedTextureFileStorage", config.textureFilter.txEnhancedTextureFileStorage).toInt();
config.textureFilter.txHiresTextureFileStorage = settings.value("txHiresTextureFileStorage", config.textureFilter.txHiresTextureFileStorage).toInt();
#ifndef OS_LINUX
wcscpy_s(config.textureFilter.txPath, ToUTF16(settings.value("txPath", FromUTF16(config.textureFilter.txPath).c_str()).toString().c_str()).c_str());
wcscpy_s(config.textureFilter.txCachePath, ToUTF16(settings.value("txCachePath", FromUTF16(config.textureFilter.txCachePath).c_str()).toString().c_str()).c_str());
wcscpy_s(config.textureFilter.txDumpPath, ToUTF16(settings.value("txDumpPath", FromUTF16(config.textureFilter.txDumpPath).c_str()).toString().c_str()).c_str());
#else
wcscpy(config.textureFilter.txPath, L"");
wcscpy(config.textureFilter.txCachePath, L"");
wcscpy(config.textureFilter.txDumpPath, L"");
#endif
settings.endGroup();
settings.beginGroup("font");
@ -287,9 +293,15 @@ void writeSettings(const char * _strIniFolder)
settings.setValue("txSaveCache", config.textureFilter.txSaveCache);
settings.setValue("txEnhancedTextureFileStorage", config.textureFilter.txEnhancedTextureFileStorage);
settings.setValue("txHiresTextureFileStorage", config.textureFilter.txHiresTextureFileStorage);
#ifndef OS_LINUX
settings.setValue("txPath", FromUTF16(config.textureFilter.txPath).c_str());
settings.setValue("txCachePath", FromUTF16(config.textureFilter.txCachePath).c_str());
settings.setValue("txDumpPath", FromUTF16(config.textureFilter.txDumpPath).c_str());
#else
settings.setValue("txPath", "");
settings.setValue("txCachePath", "");
settings.setValue("txDumpPath", "");
#endif
settings.endGroup();
settings.beginGroup("font");
@ -325,7 +337,7 @@ static
std::string _getRomName(const char * _strRomName)
{
std::string RomName;
#ifndef OS_LINUX
enum { CP_SHIFT_JIS = 932 };
int utf16size = MultiByteToWideChar(CP_SHIFT_JIS, MB_ERR_INVALID_CHARS, _strRomName, -1, 0, 0);
if (utf16size != 0)
@ -355,6 +367,10 @@ std::string _getRomName(const char * _strRomName)
}
}
return RomName;
#else
// fixme: linux port (MultiByteToWideChar)
return "THE LEGEND OF ZELDA";
#endif
}
void loadCustomRomSettings(const char * _strIniFolder, const char * _strRomName)
@ -402,13 +418,17 @@ void saveCustomRomSettings(const char * _strIniFolder, const char * _strRomName)
if (origConfig.G.S != config.G.S || \
origConfig.G.S != settings.value(#S, config.G.S).toFloat()) \
settings.setValue(#S, config.G.S)
#ifndef OS_LINUX
#define WriteCustomSettingS(S) \
const std::string new##S = FromUTF16(config.textureFilter.S); \
const std::string orig##S = FromUTF16(origConfig.textureFilter.S); \
if (orig##S != new##S || \
orig##S != settings.value(#S, new##S.c_str()).toString()) \
settings.setValue(#S, new##S.c_str())
#else
#define WriteCustomSettingS(S)
#endif
settings.beginGroup(romName.c_str());
settings.beginGroup("video");

View File

@ -0,0 +1,287 @@
#include "StdString.h"
#include <malloc.h>
#include <cstring>
#include <algorithm>
#ifdef _WIN32
#include <windows.h>
#else
#define _vscprintf(foo, ...) vsnprintf(NULL, 0, foo, __VA_ARGS__)
#define _snprintf snprintf
#endif
stdstr::stdstr()
{
}
stdstr::stdstr(const std::string & str) :
std::string(str)
{
}
stdstr::stdstr(const stdstr & str) :
std::string((const std::string &)str)
{
}
stdstr::stdstr(const char * str) :
std::string(str ? str : "")
{
}
strvector stdstr::Tokenize(const char * delimiter) const
{
strvector tokens;
stdstr::size_type lastPos = find_first_not_of(delimiter, 0);
stdstr::size_type pos = find_first_of(delimiter, lastPos);
while (stdstr::npos != pos)
{
tokens.push_back(substr(lastPos, pos - lastPos));
lastPos = pos + 1;
pos = find_first_of(delimiter, lastPos);
}
if (stdstr::npos != lastPos)
{
tokens.push_back(substr(lastPos));
}
return tokens;
}
strvector stdstr::Tokenize(char delimiter) const
{
strvector tokens;
stdstr::size_type lastPos = find_first_not_of(delimiter, 0);
stdstr::size_type pos = find_first_of(delimiter, lastPos);
while (stdstr::npos != pos)
{
tokens.push_back(substr(lastPos, pos - lastPos));
lastPos = pos + 1;
pos = find_first_of(delimiter, lastPos);
}
if (stdstr::npos != lastPos)
{
tokens.push_back(substr(lastPos));
}
return tokens;
}
void stdstr::ArgFormat(const char * strFormat, va_list & args)
{
#pragma warning(push)
#pragma warning(disable:4996)
size_t nlen = _vscprintf(strFormat, args) + 1;
char * buffer = (char *)alloca(nlen * sizeof(char));
buffer[nlen - 1] = 0;
if (buffer != NULL)
{
vsprintf(buffer, strFormat, args);
*this = buffer;
}
#pragma warning(pop)
}
void stdstr::Format(const char * strFormat, ...)
{
va_list args;
va_start(args, strFormat);
ArgFormat(strFormat, args);
va_end(args);
}
stdstr& stdstr::ToLower(void)
{
std::transform(begin(), end(), begin(), (int(*)(int)) tolower);
return *this;
}
stdstr& stdstr::ToUpper(void)
{
std::transform(begin(), end(), begin(), (int(*)(int)) toupper);
return *this;
}
void stdstr::Replace(const char search, const char replace)
{
std::string& str = *this;
std::string::size_type pos = str.find(search);
while (pos != std::string::npos)
{
str.replace(pos, 1, &replace);
pos = str.find(search, pos + 1);
}
}
void stdstr::Replace(const char * search, const char replace)
{
std::string& str = *this;
std::string::size_type pos = str.find(search);
size_t SearchSize = strlen(search);
while (pos != std::string::npos)
{
str.replace(pos, SearchSize, &replace);
pos = str.find(search, pos + 1);
}
}
void stdstr::Replace(const std::string& search, const std::string& replace)
{
std::string& str = *this;
std::string::size_type pos = str.find(search);
size_t SearchSize = search.size();
while (pos != std::string::npos)
{
str.replace(pos, SearchSize, replace);
pos = str.find(search, pos + replace.length());
}
}
stdstr & stdstr::TrimLeft(const char * chars2remove)
{
if (!empty())
{
std::string::size_type pos = find_first_not_of(chars2remove);
if (pos != std::string::npos)
{
erase(0, pos);
}
else
{
erase(begin(), end()); // make empty
}
}
return *this;
}
stdstr & stdstr::TrimRight(const char * chars2remove)
{
if (!empty())
{
std::string::size_type pos = find_last_not_of(chars2remove);
if (pos != std::string::npos)
{
erase(pos + 1);
}
else
{
erase(begin(), end()); // make empty
}
}
return *this;
}
stdstr & stdstr::Trim(const char * chars2remove)
{
if (!empty())
{
std::string::size_type pos = find_first_not_of(chars2remove);
if (pos != std::string::npos)
{
erase(0, pos);
}
else
{
erase(begin(), end()); // make empty
}
pos = find_last_not_of(chars2remove);
if (pos != std::string::npos)
{
erase(pos + 1);
}
else
{
erase(begin(), end()); // make empty
}
}
return *this;
}
#ifdef _WIN32
stdstr & stdstr::FromUTF16(const wchar_t * UTF16Source, bool * bSuccess)
{
bool bConverted = false;
if (UTF16Source == NULL)
{
*this = "";
bConverted = true;
}
else if (wcslen(UTF16Source) > 0)
{
uint32_t nNeeded = WideCharToMultiByte(CODEPAGE_UTF8, 0, UTF16Source, -1, NULL, 0, NULL, NULL);
if (nNeeded > 0)
{
char * buf = (char *)alloca(nNeeded + 1);
if (buf != NULL)
{
memset(buf, 0, nNeeded + 1);
nNeeded = WideCharToMultiByte(CODEPAGE_UTF8, 0, UTF16Source, -1, buf, nNeeded, NULL, NULL);
if (nNeeded)
{
*this = buf;
bConverted = true;
}
}
}
}
if (bSuccess)
{
*bSuccess = bConverted;
}
return *this;
}
std::wstring stdstr::ToUTF16(unsigned int CodePage, bool * bSuccess)
{
bool bConverted = false;
std::wstring res;
DWORD nNeeded = MultiByteToWideChar(CodePage, 0, this->c_str(), (int)this->length(), NULL, 0);
if (nNeeded > 0)
{
wchar_t * buf = (wchar_t *)alloca((nNeeded + 1) * sizeof(wchar_t));
if (buf != NULL)
{
memset(buf, 0, (nNeeded + 1) * sizeof(wchar_t));
nNeeded = MultiByteToWideChar(CodePage, 0, this->c_str(), (int)this->length(), buf, nNeeded);
if (nNeeded)
{
res = buf;
bConverted = true;
}
}
}
if (bSuccess)
{
*bSuccess = bConverted;
}
return res;
}
#endif
stdstr_f::stdstr_f(const char * strFormat, ...)
{
va_list args;
va_start(args, strFormat);
ArgFormat(strFormat, args);
va_end(args);
}
#ifdef _WIN32
stdwstr_f::stdwstr_f(const wchar_t * strFormat, ...)
{
va_list args;
va_start(args, strFormat);
wchar_t Msg[1000];
_vsnwprintf(Msg, sizeof(Msg) - 1, strFormat, args);
va_end(args);
this->assign(Msg);
}
#endif

View File

@ -0,0 +1,64 @@
#pragma once
class stdstr;
#include <stdarg.h>
#include <vector>
#include <string>
#include <list>
typedef std::vector<stdstr> strvector;
class stdstr :
public std::string
{
public:
enum
{
CODEPAGE_UTF8 = 65001,
CODEPAGE_932 = 932,
};
stdstr();
stdstr(const std::string & str);
stdstr(const stdstr & str);
stdstr(const char * str);
strvector Tokenize(char delimiter) const;
strvector Tokenize(const char * delimiter) const;
void Format(const char * strFormat, ...);
stdstr& ToLower(void);
stdstr& ToUpper(void);
void Replace(const char search, const char replace);
void Replace(const char * search, const char replace);
void Replace(const std::string & search, const std::string & replace);
stdstr & Trim(const char * chars2remove = "\t ");
stdstr & TrimLeft(const char * chars2remove = "\t ");
stdstr & TrimRight(const char * chars2remove = "\t ");
#ifdef _WIN32
stdstr & FromUTF16(const wchar_t * UTF16Source, bool * bSuccess = NULL);
std::wstring ToUTF16(unsigned int CodePage = CODEPAGE_UTF8, bool * bSuccess = NULL);
#endif
void ArgFormat(const char * strFormat, va_list & args);
};
class stdstr_f : public stdstr
{
public:
stdstr_f(const char * strFormat, ...);
};
#ifdef _WIN32
class stdwstr_f : public std::wstring
{
public:
stdwstr_f(const wchar_t * strFormat, ... );
};
#endif
typedef std::list<stdstr> strlist;
typedef strlist::iterator strlist_iter;

1678
src/native/util/path.cpp Normal file

File diff suppressed because it is too large Load Diff

165
src/native/util/path.h Normal file
View File

@ -0,0 +1,165 @@
#pragma once
#include <string>
#include <stdint.h>
#include "StdString.h"
class CPath
{
//Enums
public:
enum DIR_CURRENT_DIRECTORY { CURRENT_DIRECTORY = 1 };
#ifdef _WIN32
enum DIR_MODULE_DIRECTORY { MODULE_DIRECTORY = 2 };
enum DIR_MODULE_FILE { MODULE_FILE = 3 };
#endif
enum
{
FIND_ATTRIBUTE_ALLFILES = 0xFFFF, // Search Include all files
FIND_ATTRIBUTE_FILES = 0x0000, // File can be read or written to without restriction
FIND_ATTRIBUTE_SUBDIR = 0x0010, // Subdirectories
};
//Attributes
private:
std::string m_strPath;
#ifdef _WIN32
void * m_hFindFile;
static void * m_hInst;
#else
void * m_OpenedDir;
std::string m_FindWildcard;
#endif
uint32_t m_dwFindFileAttributes;
public:
//Methods
//Construction / destruction
CPath();
CPath(const CPath& rPath);
CPath(const char * lpszPath);
CPath(const char * lpszPath, const char * NameExten);
CPath(const std::string& strPath);
CPath(const std::string& strPath, const char * NameExten);
CPath(const std::string& strPath, const std::string& NameExten);
CPath(DIR_CURRENT_DIRECTORY sdt, const char * NameExten = NULL);
#ifdef _WIN32
CPath(DIR_MODULE_DIRECTORY sdt, const char * NameExten = NULL);
CPath(DIR_MODULE_FILE sdt);
#endif
virtual ~CPath();
//Operators
CPath& operator = (const CPath& rPath);
CPath& operator = (const char * lpszPath);
CPath& operator = (const std::string & strPath);
bool operator == (const CPath& rPath) const;
bool operator != (const CPath& rPath) const;
operator const char *() const;
operator const std::string &() { return m_strPath; }
//Get path components
#ifdef _WIN32
void GetDriveDirectory(std::string & rDriveDirectory) const;
std::string GetDriveDirectory(void) const;
#endif
void GetDirectory(std::string& rDirectory) const;
std::string GetDirectory(void) const;
void GetName(std::string& rName) const;
std::string GetName(void) const;
void GetNameExtension(std::string& rNameExtension) const;
std::string GetNameExtension(void) const;
void GetExtension(std::string& rExtension) const;
std::string GetExtension(void) const;
void GetLastDirectory(std::string& rDirectory) const;
std::string GetLastDirectory(void) const;
void GetFullyQualified(std::string& rFullyQualified) const;
#ifdef _WIN32
void GetComponents(std::string* pDrive = NULL, std::string* pDirectory = NULL, std::string* pName = NULL, std::string* pExtension = NULL) const;
#else
void GetComponents(std::string* pDirectory = NULL, std::string* pName = NULL, std::string* pExtension = NULL) const;
#endif
//Get other state
bool IsEmpty() const { return m_strPath.empty(); }
bool IsRelative() const;
//Set path components
#ifdef _WIN32
void SetDrive(char chDrive);
void SetDriveDirectory(const char * lpszDriveDirectory);
#endif
void SetDirectory(const char * lpszDirectory, bool bEnsureAbsolute = false);
void SetName(const char * lpszName);
void SetName(int iName);
void SetNameExtension(const char * lpszNameExtension);
void SetExtension(const char * lpszExtension);
void SetExtension(int iExtension);
void AppendDirectory(const char * lpszSubDirectory);
void UpDirectory(std::string* pLastDirectory = NULL);
#ifdef _WIN32
void SetComponents(const char * lpszDrive, const char * lpszDirectory, const char * lpszName, const char * lpszExtension);
#else
void SetComponents(const char * lpszDirectory, const char * lpszName, const char * lpszExtension);
#endif
//Set whole path
void Empty() { m_strPath.erase(); }
void CurrentDirectory();
#ifdef _WIN32
void Module();
void Module(void * hInstance);
void ModuleDirectory();
void ModuleDirectory(void * hInstance);
#endif
//Directory information
bool IsDirectory() const;
bool DirectoryExists() const;
//File Information
bool IsFile() const { return !IsDirectory(); }
bool Exists() const;
#ifdef _WIN32
bool SelectFile(void * hwndOwner, const char * InitialDir, const char * FileFilter, bool FileMustExist);
#endif
//Directory operations
bool DirectoryCreate(bool bCreateIntermediates = true);
bool ChangeDirectory();
void NormalizePath(CPath BaseDir);
//File operations
bool Delete(bool bEvenIfReadOnly = true) const;
bool CopyTo(const char * lpcszTargetFile, bool bOverwrite = true);
bool MoveTo(const char * lpcszTargetFile, bool bOverwrite = true);
//Finders
bool FindFirst(uint32_t dwAttributes = 0);
bool FindNext();
// Helpers
#ifdef _WIN32
static void SethInst(void * hInst);
static void * GethInst();
#endif
private:
//Setup & Cleanup
inline void Init();
inline void Exit();
bool AttributesMatch(uint32_t dwTargetAttributes, uint32_t dwFileAttributes);
void cleanPathString(std::string& rDirectory) const;
void StripLeadingChar(std::string& rText, char chLeading) const;
void StripLeadingBackslash(std::string& Directory) const;
void StripTrailingChar(std::string& rText, char chTrailing) const;
void StripTrailingBackslash(std::string& rDirectory) const;
void EnsureTrailingBackslash(std::string& Directory) const;
void EnsureLeadingBackslash(std::string& Directory) const;
#ifndef _WIN32
bool wildcmp(const char *wild, const char *string);
#endif
};

View File

@ -1,4 +1,5 @@
#include "util.h"
#ifdef _WIN32
#include <windows.h>
#include <memory>
@ -55,3 +56,4 @@ std::wstring FormatStrW(const wchar_t * strFormat, ...)
return res;
}
#endif

25
src/osal/meson.build Normal file
View File

@ -0,0 +1,25 @@
# platform specific files
target_os = target_machine.system()
platform_flags = []
osal_sources = []
osal_includes = include_directories('.')
if target_os == 'linux'
osal_sources = [ 'osal_files_unix.c', 'osal_keys_linux.c' ]
platform_flags += [ '-DOS_LINUX', '-DNDEBUG' ]
elif target_os == 'darwin'
osal_sources = ['osal_files_unix.c', 'osal_keys_unix.c']
platform_flags += [ '-DNDEBUG' ]
elif target_os == 'windows'
osal_sources = ['osal_files_win32.c', 'osal_keys_win.c']
else
error( message: 'Unsupported platform: ', target_os )
endif
if get_option('buildtype') == 'debug'
osal_lib = static_library('osald', osal_sources)
else
osal_lib = static_library('osal', osal_sources)
endif
libosal_dep = declare_dependency(include_directories : osal_includes, link_with : osal_lib)

View File

@ -1,17 +1,25 @@
#include "osal_keys.h"
#include <linux/limits.h>
#include <linux/input.h>
#include <limits.h>
#include <dirent.h>
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <linux/input.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _WIN32
#ifndef PATH_MAX
#define PATH_MAX 260
#endif
#endif
static const unsigned char LINUX_HID_TO_NATIVE[256] = {
255, 255, 255, 255, KEY_A, KEY_B, KEY_C, KEY_D, KEY_E,
KEY_F, KEY_G, KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M,

View File

@ -3,11 +3,19 @@
#include "Config.h"
#include "../GLideNHQ/inc/png.h"
#if defined(OS_WINDOWS)
void write_png_file(const wchar_t * file_name, int width, int height, const uint8_t *buffer)
{
#pragma warning(disable: 4996)
FILE *fp = _wfopen(file_name, L"wb");
#pragma warning(default: 4996)
#else
static void write_png_file(const char * file_name, int width, int height, const uint8_t *buffer)
{
FILE *fp = fopen((const char*)file_name, "wb");
#endif
if (!fp) return;
png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
@ -76,6 +84,7 @@ void write_png_file(const wchar_t * file_name, int width, int height, const uint
fclose(fp);
}
#ifndef OS_LINUX
void SaveScreenshot(const wchar_t * _folder, const char * _name, int _width, int _height, const unsigned char * _data)
{
const wchar_t * fileExt = L"png";
@ -121,3 +130,18 @@ void SaveScreenshot(const wchar_t * _folder, const char * _name, int _width, int
write_png_file(fileName, _width, _height, _data);
}
#else
void SaveScreenshot(const char * _folder, const char * _name, int _width, int _height, const unsigned char * _data)
{
const char * fileExt = "png";
char fileName[256];
int i= 0;
std::string romName = std::string(_name);
for (size_t i = 0, n = romName.size(); i < n; i++) {
if (romName[i] == L' ') romName[i] = L'_';
if (romName[i] == L':') romName[i] = L';';
}
snprintf(fileName, 256, "GLideN64_%ls_%03i.%s", romName.c_str(), i, fileExt);
write_png_file(fileName, _width, _height, _data);
}
#endif

View File

@ -1,6 +1,11 @@
#ifndef SCREENSHOT_H
#define SCREENSHOT_H
#if defined(OS_WINDOWS)
void SaveScreenshot(const wchar_t * _folder, const char * _name, int _width, int _height, const unsigned char * _data);
#else
void SaveScreenshot(const char * _folder, const char * _name, int _width, int _height, const unsigned char * _data);
#endif
#endif // SCREENSHOT_H

27
x86-linux-gnu Normal file
View File

@ -0,0 +1,27 @@
[binaries]
c = '/usr/bin/gcc'
cpp = '/usr/bin/g++'
ar = '/usr/bin/gcc-ar'
strip = '/usr/bin/strip'
pkgconfig = '/usr/bin/i686-redhat-linux-gnu-pkg-config'
llvm-config = '/usr/bin/llvm-config32'
[built-in options]
c_args = ['-m32']
c_link_args = ['-m32']
cpp_args = ['-m32']
cpp_link_args = ['-m32']
prefix = '/usr'
libdir = 'lib'
bindir = 'bin'
[properties]
#pkg_config_libdir = '/usr/lib/pkgconfig'
#pkg_config_path = '/usr/lib/pkgconfig'
[host_machine]
system = 'linux'
cpu_family = 'x86'
cpu = 'i686'
endian = 'little'