2010-01-03 22:20:28 -07:00
|
|
|
/*
|
2011-06-16 15:53:39 -06:00
|
|
|
https://github.com/peterix/dfhack
|
|
|
|
Copyright (c) 2009-2011 Petr Mrázek (peterix@gmail.com)
|
2010-01-03 22:20:28 -07:00
|
|
|
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
|
|
warranty. In no event will the authors be held liable for any
|
|
|
|
damages arising from the use of this software.
|
|
|
|
|
|
|
|
Permission is granted to anyone to use this software for any
|
|
|
|
purpose, including commercial applications, and to alter it and
|
|
|
|
redistribute it freely, subject to the following restrictions:
|
|
|
|
|
|
|
|
1. The origin of this software must not be misrepresented; you must
|
|
|
|
not claim that you wrote the original software. If you use this
|
|
|
|
software in a product, an acknowledgment in the product documentation
|
|
|
|
would be appreciated but is not required.
|
|
|
|
|
|
|
|
2. Altered source versions must be plainly marked as such, and
|
|
|
|
must not be misrepresented as being the original software.
|
|
|
|
|
|
|
|
3. This notice may not be removed or altered from any source
|
|
|
|
distribution.
|
|
|
|
*/
|
|
|
|
|
2011-06-14 08:13:28 -06:00
|
|
|
#define DFhackCExport extern "C" __declspec(dllexport)
|
2010-03-04 16:05:01 -07:00
|
|
|
|
2011-06-22 06:25:39 -06:00
|
|
|
#include <windows.h>
|
2011-06-15 09:35:47 -06:00
|
|
|
#include <stdint.h>
|
2011-06-14 08:13:28 -06:00
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
#include "dfhack/Core.h"
|
2011-06-16 15:53:39 -06:00
|
|
|
#include "dfhack/FakeSDL.h"
|
2011-06-14 08:13:28 -06:00
|
|
|
#include <stdio.h>
|
2010-01-07 22:52:37 -07:00
|
|
|
|
2011-06-19 20:29:38 -06:00
|
|
|
/*
|
|
|
|
* Plugin loading functions
|
|
|
|
*/
|
2011-06-22 00:14:21 -06:00
|
|
|
namespace DFHack
|
2011-06-19 20:29:38 -06:00
|
|
|
{
|
2011-06-22 00:14:21 -06:00
|
|
|
DFLibrary * OpenPlugin (const char * filename)
|
|
|
|
{
|
|
|
|
return (DFLibrary *) LoadLibrary(filename);
|
|
|
|
}
|
|
|
|
void * LookupPlugin (DFLibrary * plugin ,const char * function)
|
|
|
|
{
|
|
|
|
return (DFLibrary *) GetProcAddress((HMODULE)plugin, function);
|
|
|
|
}
|
|
|
|
void ClosePlugin (DFLibrary * plugin)
|
|
|
|
{
|
|
|
|
FreeLibrary((HMODULE) plugin);
|
|
|
|
}
|
2011-06-19 20:29:38 -06:00
|
|
|
}
|
2010-01-07 22:52:37 -07:00
|
|
|
/*************************************************************************/
|
2011-06-14 08:13:28 -06:00
|
|
|
// extremely boring wrappers beyond this point. Only fix when broken
|
|
|
|
|
|
|
|
// we don't know which of the SDL functions will be called first... so we
|
|
|
|
// just catch the first one and init all our function pointers at that time
|
|
|
|
bool FirstCall(void);
|
|
|
|
bool inited = false;
|
2010-01-04 15:20:17 -07:00
|
|
|
|
|
|
|
/// wrappers for SDL 1.2 functions used in 40d16
|
|
|
|
/***** Condition variables
|
|
|
|
|
|
|
|
SDL_CreateCond
|
|
|
|
SDL_cond * SDLCALL SDL_CreateCond(void);
|
2010-01-03 22:41:53 -07:00
|
|
|
SDL_CondSignal
|
2010-01-04 15:20:17 -07:00
|
|
|
int SDLCALL SDL_CondSignal(SDL_cond *cond);
|
2010-01-03 22:41:53 -07:00
|
|
|
SDL_CondWait
|
2010-01-04 15:20:17 -07:00
|
|
|
int SDLCALL SDL_CondWait(SDL_cond *cond, SDL_mutex *mut);
|
|
|
|
SDL_DestroyCond
|
|
|
|
void SDLCALL SDL_DestroyCond(SDL_cond *cond);
|
|
|
|
*/
|
|
|
|
static vPtr (*_SDL_CreateCond)() = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport vPtr SDL_CreateCond()
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
return _SDL_CreateCond();
|
|
|
|
}
|
|
|
|
|
|
|
|
static int (*_SDL_CondSignal)(vPtr cond) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport int SDL_CondSignal(vPtr cond)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
return _SDL_CondSignal(cond);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int (*_SDL_CondWait)(vPtr cond, vPtr mutex) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport int SDL_CondWait(vPtr cond, vPtr mutex)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
return _SDL_CondWait(cond, mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void (*_SDL_DestroyCond)(vPtr cond) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport void SDL_DestroyCond(vPtr cond)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
_SDL_DestroyCond(cond);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***** mutexes
|
|
|
|
|
2010-01-03 22:41:53 -07:00
|
|
|
SDL_CreateMutex
|
2010-01-04 15:20:17 -07:00
|
|
|
SDL_mutex * SDLCALL SDL_CreateMutex(void);
|
|
|
|
SDL_mutexP
|
|
|
|
int SDLCALL SDL_mutexP(SDL_mutex *mutex);
|
|
|
|
SDL_DestroyMutex
|
|
|
|
void SDLCALL SDL_DestroyMutex(SDL_mutex *mutex);
|
|
|
|
*/
|
2011-06-16 18:09:03 -06:00
|
|
|
static DFMutex * (*_SDL_CreateMutex)(void) = 0;
|
|
|
|
DFhackCExport DFMutex * SDL_CreateMutex(void)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
return _SDL_CreateMutex();
|
|
|
|
}
|
|
|
|
|
2011-06-16 18:09:03 -06:00
|
|
|
static int (*_SDL_mutexP)(DFMutex * mutex) = 0;
|
|
|
|
DFhackCExport int SDL_mutexP(DFMutex * mutex)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
return _SDL_mutexP(mutex);
|
|
|
|
}
|
|
|
|
|
2011-06-16 18:09:03 -06:00
|
|
|
static int (*_SDL_mutexV)(DFMutex * mutex) = 0;
|
|
|
|
DFhackCExport int SDL_mutexV(DFMutex * mutex)
|
2011-06-16 15:53:39 -06:00
|
|
|
{
|
|
|
|
return _SDL_mutexV(mutex);
|
|
|
|
}
|
|
|
|
|
2011-06-16 18:09:03 -06:00
|
|
|
static void (*_SDL_DestroyMutex)(DFMutex * mutex) = 0;
|
|
|
|
DFhackCExport void SDL_DestroyMutex(DFMutex * mutex)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
_SDL_DestroyMutex(mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***** timers
|
|
|
|
|
|
|
|
SDL_AddTimer
|
|
|
|
SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval, SDL_NewTimerCallback callback, void *param);
|
|
|
|
SDL_RemoveTimer
|
|
|
|
SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID t);
|
|
|
|
SDL_GetTicks
|
|
|
|
Uint32 SDLCALL SDL_GetTicks(void);
|
|
|
|
*/
|
|
|
|
static vPtr (*_SDL_AddTimer)(uint32_t interval, fPtr callback, vPtr param) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport vPtr SDL_AddTimer(uint32_t interval, fPtr callback, vPtr param)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
return _SDL_AddTimer(interval, callback, param);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool (*_SDL_RemoveTimer)(vPtr timer) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport bool SDL_RemoveTimer(vPtr timer)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
return _SDL_RemoveTimer(timer);
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t (*_SDL_GetTicks)(void) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport uint32_t SDL_GetTicks(void)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
return _SDL_GetTicks();
|
|
|
|
}
|
|
|
|
|
|
|
|
/***** Surfaces
|
2010-01-03 22:41:53 -07:00
|
|
|
SDL_CreateRGBSurface
|
2010-01-04 15:20:17 -07:00
|
|
|
SDL_Surface * SDLCALL SDL_CreateRGBSurface
|
|
|
|
(Uint32 flags, int width, int height, int depth,
|
|
|
|
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
|
|
|
|
|
2010-01-03 22:41:53 -07:00
|
|
|
SDL_CreateRGBSurfaceFrom
|
2010-01-04 15:20:17 -07:00
|
|
|
SDL_Surface * SDLCALL SDL_CreateRGBSurfaceFrom
|
|
|
|
(void *pixels, int width, int height, int depth, int pitch,
|
|
|
|
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
|
|
|
|
|
2010-01-03 22:41:53 -07:00
|
|
|
SDL_FreeSurface
|
2010-01-04 15:20:17 -07:00
|
|
|
void SDLCALL SDL_FreeSurface(SDL_Surface *surface);
|
|
|
|
|
|
|
|
SDL_ConvertSurface
|
|
|
|
SDL_Surface * SDLCALL SDL_ConvertSurface
|
|
|
|
(SDL_Surface *src, SDL_PixelFormat *fmt, Uint32 flags);
|
|
|
|
|
2010-01-03 22:41:53 -07:00
|
|
|
SDL_LockSurface
|
2010-01-04 15:20:17 -07:00
|
|
|
int SDLCALL SDL_LockSurface(SDL_Surface *surface);
|
|
|
|
|
|
|
|
SDL_UnlockSurface
|
|
|
|
void SDLCALL SDL_UnlockSurface(SDL_Surface *surface);
|
|
|
|
*/
|
|
|
|
|
|
|
|
static vPtr (*_SDL_CreateRGBSurface)(uint32_t flags, int width, int height, int depth,
|
|
|
|
uint32_t Rmask, uint32_t Gmask, uint32_t Bmask, uint32_t Amask) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport vPtr SDL_CreateRGBSurface(uint32_t flags, int width, int height, int depth,
|
2010-01-04 15:20:17 -07:00
|
|
|
uint32_t Rmask, uint32_t Gmask, uint32_t Bmask, uint32_t Amask)
|
|
|
|
{
|
|
|
|
return _SDL_CreateRGBSurface(flags, width, height, depth, Rmask, Gmask, Bmask, Amask);
|
|
|
|
}
|
|
|
|
|
|
|
|
static vPtr (*_SDL_CreateRGBSurfaceFrom)(vPtr pixels, int width, int height, int depth, int pitch,
|
|
|
|
uint32_t Rmask, uint32_t Gmask, uint32_t Bmask, uint32_t Amask) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport vPtr SDL_CreateRGBSurfaceFrom(vPtr pixels, int width, int height, int depth, int pitch,
|
2010-01-04 15:20:17 -07:00
|
|
|
uint32_t Rmask, uint32_t Gmask, uint32_t Bmask, uint32_t Amask)
|
|
|
|
{
|
|
|
|
return _SDL_CreateRGBSurfaceFrom(pixels, width, height, depth, pitch, Rmask, Gmask, Bmask, Amask);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void (*_SDL_FreeSurface)(vPtr surface) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport void SDL_FreeSurface(vPtr surface)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
_SDL_FreeSurface(surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static vPtr (*_SDL_ConvertSurface)(vPtr surface, vPtr format, uint32_t flags) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport vPtr SDL_ConvertSurface(vPtr surface, vPtr format, uint32_t flags)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
return _SDL_ConvertSurface(surface, format, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int (*_SDL_LockSurface)(vPtr surface) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport int SDL_LockSurface(vPtr surface)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
return _SDL_LockSurface(surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void (*_SDL_UnlockSurface)(vPtr surface) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport void SDL_UnlockSurface(vPtr surface)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
_SDL_UnlockSurface(surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***** More surface stuff
|
2010-01-03 22:41:53 -07:00
|
|
|
SDL_MapRGB
|
2010-01-04 15:20:17 -07:00
|
|
|
Uint32 SDLCALL SDL_MapRGB
|
|
|
|
(const SDL_PixelFormat * const format, const Uint8 r, const Uint8 g, const Uint8 b);
|
|
|
|
|
2010-01-03 22:41:53 -07:00
|
|
|
SDL_SaveBMP_RW
|
2010-01-04 15:20:17 -07:00
|
|
|
int SDLCALL SDL_SaveBMP_RW
|
|
|
|
(SDL_Surface *surface, SDL_RWops *dst, int freedst);
|
|
|
|
|
2010-01-03 22:41:53 -07:00
|
|
|
SDL_SetAlpha
|
2010-01-04 15:20:17 -07:00
|
|
|
int SDLCALL SDL_SetAlpha(SDL_Surface *surface, Uint32 flag, Uint8 alpha);
|
|
|
|
|
2010-01-03 22:41:53 -07:00
|
|
|
SDL_SetColorKey
|
2010-01-04 15:20:17 -07:00
|
|
|
int SDLCALL SDL_SetColorKey(SDL_Surface *surface, Uint32 flag, Uint32 key);
|
|
|
|
|
|
|
|
SDL_GetVideoInfo
|
|
|
|
const SDL_VideoInfo * SDLCALL SDL_GetVideoInfo(void);
|
|
|
|
|
2010-01-03 22:41:53 -07:00
|
|
|
SDL_SetVideoMode
|
2010-01-04 15:20:17 -07:00
|
|
|
SDL_Surface * SDLCALL SDL_SetVideoMode
|
|
|
|
(int width, int height, int bpp, Uint32 flags);
|
|
|
|
|
2010-01-03 22:41:53 -07:00
|
|
|
SDL_UpperBlit
|
2010-01-04 15:20:17 -07:00
|
|
|
int SDLCALL SDL_UpperBlit
|
|
|
|
(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect);
|
|
|
|
*/
|
|
|
|
|
|
|
|
static uint32_t (*_SDL_MapRGB)(vPtr pixelformat, uint8_t r, uint8_t g, uint8_t b) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport uint32_t SDL_MapRGB(vPtr pixelformat, uint8_t r, uint8_t g, uint8_t b)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
return _SDL_MapRGB(pixelformat,r,g,b);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int (*_SDL_SaveBMP_RW)(vPtr surface, vPtr dst, int freedst) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport int SDL_SaveBMP_RW(vPtr surface, vPtr dst, int freedst)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
return _SDL_SaveBMP_RW(surface,dst,freedst);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int (*_SDL_SetAlpha)(vPtr surface, uint32_t flag, uint8_t alpha) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport int SDL_SetAlpha(vPtr surface, uint32_t flag, uint8_t alpha)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
return _SDL_SetAlpha(surface,flag,alpha);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int (*_SDL_SetColorKey)(vPtr surface, uint32_t flag, uint32_t key) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport int SDL_SetColorKey(vPtr surface, uint32_t flag, uint32_t key)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
return _SDL_SetColorKey(surface,flag,key);
|
|
|
|
}
|
|
|
|
|
|
|
|
static vPtr (*_SDL_GetVideoInfo)(void) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport vPtr SDL_GetVideoInfo(void)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
return _SDL_GetVideoInfo();
|
|
|
|
}
|
|
|
|
|
|
|
|
static vPtr (*_SDL_SetVideoMode)(int width, int height, int bpp, uint32_t flags) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport vPtr SDL_SetVideoMode(int width, int height, int bpp, uint32_t flags)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
return _SDL_SetVideoMode(width, height, bpp, flags);
|
|
|
|
}
|
|
|
|
static int (*_SDL_UpperBlit)(vPtr src, vPtr srcrect, vPtr dst, vPtr dstrect) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport int SDL_UpperBlit(vPtr src, vPtr srcrect, vPtr dst, vPtr dstrect)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
return _SDL_UpperBlit(src, srcrect, dst, dstrect);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***** Even more surface
|
|
|
|
SDL_GL_GetAttribute
|
|
|
|
int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int* value);
|
|
|
|
|
|
|
|
SDL_GL_SetAttribute
|
|
|
|
int SDLCALL SDL_GL_SetAttribute(SDL_GLattr attr, int value);
|
|
|
|
|
2010-01-03 22:41:53 -07:00
|
|
|
SDL_WM_SetCaption
|
2010-01-04 15:20:17 -07:00
|
|
|
void SDLCALL SDL_WM_SetCaption(const char *title, const char *icon);
|
|
|
|
|
2010-01-03 22:41:53 -07:00
|
|
|
SDL_WM_SetIcon
|
2010-01-04 15:20:17 -07:00
|
|
|
void SDLCALL SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask);
|
|
|
|
|
|
|
|
SDL_FillRect
|
|
|
|
int SDLCALL SDL_FillRect(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color);
|
|
|
|
*/
|
|
|
|
|
2010-02-10 21:56:24 -07:00
|
|
|
|
|
|
|
static void * (*_SDL_GetVideoSurface)( void ) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport void * SDL_GetVideoSurface(void)
|
2010-02-10 21:56:24 -07:00
|
|
|
{
|
|
|
|
return _SDL_GetVideoSurface();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void * (*_SDL_DisplayFormat)( void * surface ) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport void * SDL_DisplayFormat(void *surface)
|
2010-02-10 21:56:24 -07:00
|
|
|
{
|
|
|
|
return _SDL_DisplayFormat(surface);
|
|
|
|
}
|
|
|
|
|
2010-07-17 12:13:44 -06:00
|
|
|
// SDL_Surface *SDL_DisplayFormatAlpha(SDL_Surface *surface);
|
2010-07-16 17:55:18 -06:00
|
|
|
static void * (*_SDL_DisplayFormatAlpha)( void * surface ) = 0;
|
2010-07-17 12:13:44 -06:00
|
|
|
DFhackCExport void * SDL_DisplayFormatAlpha(void *surface)
|
2010-07-16 17:55:18 -06:00
|
|
|
{
|
|
|
|
return _SDL_DisplayFormatAlpha(surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
//void SDL_GetRGBA(Uint32 pixel, SDL_PixelFormat *fmt, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);
|
|
|
|
|
|
|
|
static void (*_SDL_GetRGBA)(uint32_t pixel, void * fmt, uint8_t * r, uint8_t * g, uint8_t * b, uint8_t *a) = 0;
|
|
|
|
DFhackCExport void SDL_GetRGBA(uint32_t pixel, void * fmt, uint8_t * r, uint8_t * g, uint8_t * b, uint8_t *a)
|
|
|
|
{
|
|
|
|
return _SDL_GetRGBA(pixel, fmt, r, g, b, a);
|
|
|
|
}
|
|
|
|
|
2010-01-04 15:20:17 -07:00
|
|
|
static int (*_SDL_GL_GetAttribute)(int attr, int * value) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport int SDL_GL_GetAttribute(int attr, int * value)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
return _SDL_GL_GetAttribute(attr,value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int (*_SDL_GL_SetAttribute)(int attr, int value) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport int SDL_GL_SetAttribute(int attr, int value)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
return _SDL_GL_SetAttribute(attr,value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void (*_SDL_WM_SetCaption)(const char *title, const char *icon) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport void SDL_WM_SetCaption(const char *title, const char *icon)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
2010-02-11 06:27:48 -07:00
|
|
|
//_SDL_WM_SetCaption("DwarfHacked the Fortress of Hacks",icon);
|
|
|
|
_SDL_WM_SetCaption(title,icon);
|
2010-01-04 15:20:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void (*_SDL_WM_SetIcon)(vPtr icon, uint8_t *mask) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport void SDL_WM_SetIcon(vPtr icon, uint8_t *mask)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
_SDL_WM_SetIcon(icon, mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int (*_SDL_FillRect)(vPtr dst, vPtr dstrect, uint32_t color) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport int SDL_FillRect(vPtr dst, vPtr dstrect, uint32_t color)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
2010-01-10 23:27:59 -07:00
|
|
|
return _SDL_FillRect(dst,dstrect,color);
|
2010-01-04 15:20:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/***** Events and input
|
|
|
|
SDL_EnableKeyRepeat
|
|
|
|
int SDLCALL SDL_EnableKeyRepeat(int delay, int interval);
|
|
|
|
SDL_EnableUNICODE
|
|
|
|
int SDLCALL SDL_EnableUNICODE(int enable);
|
|
|
|
SDL_GetKeyState
|
|
|
|
Uint8 * SDLCALL SDL_GetKeyState(int *numkeys);
|
|
|
|
SDL_PollEvent
|
|
|
|
int SDLCALL SDL_PollEvent(SDL_Event *event);
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int (*_SDL_EnableKeyRepeat)(int delay, int interval) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport int SDL_EnableKeyRepeat(int delay, int interval)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
return _SDL_EnableKeyRepeat(delay, interval);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int (*_SDL_EnableUNICODE)(int enable) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport int SDL_EnableUNICODE(int enable)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
return _SDL_EnableUNICODE(enable);
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint8_t * (*_SDL_GetKeyState)(int* numkeys) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport uint8_t * SDL_GetKeyState(int* numkeys)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
return _SDL_GetKeyState(numkeys);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int (*_SDL_PollEvent)(vPtr event) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport int SDL_PollEvent(vPtr event)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
return _SDL_PollEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***** error handling
|
|
|
|
SDL_GetError
|
|
|
|
char * SDLCALL SDL_GetError(void);
|
|
|
|
SDL_SetError
|
|
|
|
extern DECLSPEC void SDLCALL SDL_SetError(const char *fmt, ...);
|
|
|
|
SDL_ClearError
|
|
|
|
extern DECLSPEC void SDLCALL SDL_ClearError(void);
|
|
|
|
SDL_Error
|
|
|
|
extern DECLSPEC void SDLCALL SDL_Error(SDL_errorcode code);
|
|
|
|
*/
|
|
|
|
|
|
|
|
static char * (*_SDL_GetError)(void) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport char * SDL_GetError(void)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
return _SDL_GetError();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void (*_SDL_SetError)(const char *fmt, ...) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport void SDL_SetError(const char *fmt, ...)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
char buf[1024];
|
|
|
|
va_list args;
|
|
|
|
va_start(args,fmt);
|
|
|
|
vsnprintf(buf, sizeof(buf) - 1 ,fmt,args);
|
|
|
|
va_end(args);
|
|
|
|
_SDL_SetError(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void (*_SDL_ClearError)(void) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport void SDL_ClearError(void)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
_SDL_ClearError();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void (*_SDL_Error)(int code) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport void SDL_Error(int code)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
_SDL_Error(code);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***** symbol resolution
|
|
|
|
SDL_LoadFunction
|
|
|
|
extern DECLSPEC void * SDLCALL SDL_LoadFunction(void *handle, const char *name);
|
|
|
|
SDL_LoadObject
|
|
|
|
extern DECLSPEC void * SDLCALL SDL_LoadObject(const char *sofile);
|
|
|
|
SDL_UnloadObject
|
|
|
|
extern DECLSPEC void SDLCALL SDL_UnloadObject(void *handle);
|
|
|
|
*/
|
|
|
|
|
2011-06-19 17:12:07 -06:00
|
|
|
static void * (*_SDL_LoadFunction)(DFLibrary *handle, const char *name) = 0;
|
|
|
|
DFhackCExport void * SDL_LoadFunction(DFLibrary *handle, const char *name)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
return _SDL_LoadFunction(handle, name);
|
|
|
|
}
|
|
|
|
|
2011-06-19 20:29:38 -06:00
|
|
|
extern "C" static DFLibrary * (*_SDL_LoadObject)(const char *sofile) = 0;
|
2011-06-19 17:12:07 -06:00
|
|
|
DFhackCExport DFLibrary * SDL_LoadObject(const char *sofile)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
return _SDL_LoadObject(sofile);
|
|
|
|
}
|
|
|
|
|
2011-06-19 17:12:07 -06:00
|
|
|
static void (*_SDL_UnloadObject)(DFLibrary * handle) = 0;
|
|
|
|
DFhackCExport void SDL_UnloadObject(DFLibrary * handle)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
_SDL_UnloadObject(handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***** r/w
|
|
|
|
SDL_ReadBE32
|
|
|
|
extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops *src);
|
|
|
|
SDL_ReadLE16
|
|
|
|
extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops *src);
|
|
|
|
SDL_ReadLE32
|
|
|
|
extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops *src);
|
|
|
|
*/
|
|
|
|
|
|
|
|
static uint32_t (*_SDL_ReadBE32)(vPtr src) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport uint32_t SDL_ReadBE32(vPtr src)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
return _SDL_ReadBE32(src);
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint16_t (*_SDL_ReadLE16)(vPtr src) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport uint16_t SDL_ReadLE16(vPtr src)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
return _SDL_ReadLE16(src);
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t (*_SDL_ReadLE32)(vPtr src) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport uint32_t SDL_ReadLE32(vPtr src)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
return _SDL_ReadLE32(src);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***** Misc
|
|
|
|
SDL_RWFromFile
|
|
|
|
SDL_RWops * SDLCALL SDL_RWFromFile(const char *file, const char *mode);
|
|
|
|
SDL_SetModuleHandle
|
|
|
|
void SDLCALL SDL_SetModuleHandle(void *hInst);
|
|
|
|
SDL_ShowCursor
|
|
|
|
int SDLCALL SDL_ShowCursor(int toggle);
|
2010-01-03 22:41:53 -07:00
|
|
|
SDL_strlcpy
|
2010-01-04 15:20:17 -07:00
|
|
|
size_t SDLCALL SDL_strlcpy(char *dst, const char *src, size_t maxlen);
|
|
|
|
*/
|
|
|
|
|
|
|
|
static vPtr (*_SDL_RWFromFile)(const char* file, const char *mode) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport vPtr SDL_RWFromFile(const char* file, const char *mode)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
return _SDL_RWFromFile(file, mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void (*_SDL_SetModuleHandle)(vPtr hInst) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport void SDL_SetModuleHandle(vPtr hInst)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
_SDL_SetModuleHandle(hInst);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int (*_SDL_ShowCursor)(int toggle) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport int SDL_ShowCursor(int toggle)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
return _SDL_ShowCursor(toggle);
|
|
|
|
}
|
|
|
|
|
|
|
|
static size_t (*_SDL_strlcpy)(char *dst, const char *src, size_t maxlen) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport size_t SDL_strlcpy(char *dst, const char *src, size_t maxlen)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
if(!_SDL_strlcpy)
|
|
|
|
{
|
|
|
|
HMODULE realSDLlib = LoadLibrary("SDLreal.dll");
|
|
|
|
_SDL_strlcpy = (size_t (*)(char*, const char*, size_t))GetProcAddress(realSDLlib,"SDL_strlcpy");
|
|
|
|
}
|
|
|
|
return _SDL_strlcpy(dst,src,maxlen);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***** The real meat of this
|
|
|
|
SDL_Init
|
|
|
|
SDL_Quit
|
|
|
|
SDL_GL_SwapBuffers
|
|
|
|
void SDLCALL SDL_GL_SwapBuffers(void);
|
2010-01-03 22:41:53 -07:00
|
|
|
*/
|
2010-01-03 22:20:28 -07:00
|
|
|
|
2010-05-24 17:49:13 -06:00
|
|
|
|
|
|
|
// hook - called at program exit
|
2010-01-04 15:20:17 -07:00
|
|
|
static void (*_SDL_Quit)(void) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport void SDL_Quit(void)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
2011-06-14 08:13:28 -06:00
|
|
|
DFHack::Core & c = DFHack::Core::getInstance();
|
|
|
|
c.Shutdown();
|
2010-05-24 17:49:13 -06:00
|
|
|
if(_SDL_Quit)
|
|
|
|
{
|
|
|
|
_SDL_Quit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// this is supported from 0.31.04 forward
|
|
|
|
DFhackCExport int SDL_NumJoysticks(void)
|
|
|
|
{
|
2011-06-14 08:13:28 -06:00
|
|
|
DFHack::Core & c = DFHack::Core::getInstance();
|
|
|
|
return c.Update();
|
2010-01-04 15:20:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void (*_SDL_GL_SwapBuffers)(void) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport void SDL_GL_SwapBuffers(void)
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
2010-05-24 17:49:13 -06:00
|
|
|
if(!inited)
|
|
|
|
FirstCall();
|
2010-01-04 15:20:17 -07:00
|
|
|
_SDL_GL_SwapBuffers();
|
|
|
|
}
|
|
|
|
|
2010-02-10 21:56:24 -07:00
|
|
|
// hook - called every tick in the 2D mode of DF
|
|
|
|
static int (*_SDL_Flip)(void * some_ptr) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport int SDL_Flip(void * some_ptr)
|
2010-02-10 21:56:24 -07:00
|
|
|
{
|
2010-05-24 17:49:13 -06:00
|
|
|
if(!inited)
|
|
|
|
FirstCall();
|
|
|
|
return _SDL_Flip(some_ptr);
|
2010-02-10 21:56:24 -07:00
|
|
|
}
|
|
|
|
|
2010-01-04 15:20:17 -07:00
|
|
|
static int (*_SDL_Init)(uint32_t flags) = 0;
|
2010-02-12 17:47:08 -07:00
|
|
|
DFhackCExport int SDL_Init(uint32_t flags)
|
2010-05-24 17:49:13 -06:00
|
|
|
{
|
|
|
|
if(!inited)
|
|
|
|
FirstCall();
|
|
|
|
return _SDL_Init(flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
MORE CRAP
|
|
|
|
*/
|
|
|
|
static void * (*_SDL_CreateSemaphore)(uint32_t initial_value) = 0;
|
|
|
|
DFhackCExport void *SDL_CreateSemaphore(uint32_t initial_value)
|
|
|
|
{
|
|
|
|
if(!inited)
|
|
|
|
FirstCall();
|
|
|
|
return _SDL_CreateSemaphore(initial_value);
|
|
|
|
}
|
|
|
|
|
2011-06-16 18:09:03 -06:00
|
|
|
static DFThread * (*_SDL_CreateThread)(int (*fn)(void *), void *data) = 0;
|
|
|
|
DFhackCExport DFThread *SDL_CreateThread(int (*fn)(void *), void *data)
|
2010-05-24 17:49:13 -06:00
|
|
|
{
|
|
|
|
if(!inited)
|
|
|
|
FirstCall();
|
|
|
|
return _SDL_CreateThread(fn,data);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void (*_SDL_Delay)(uint32_t ms) = 0;
|
|
|
|
DFhackCExport void SDL_Delay(uint32_t ms)
|
|
|
|
{
|
|
|
|
if(!inited)
|
|
|
|
FirstCall();
|
|
|
|
_SDL_Delay(ms);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void (*_SDL_DestroySemaphore)(void *sem) = 0;
|
|
|
|
DFhackCExport void SDL_DestroySemaphore(void *sem)
|
|
|
|
{
|
|
|
|
if(!inited)
|
|
|
|
FirstCall();
|
|
|
|
_SDL_DestroySemaphore(sem);
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint8_t (*_SDL_GetAppState)(void) = 0;
|
|
|
|
DFhackCExport uint8_t SDL_GetAppState(void)
|
|
|
|
{
|
|
|
|
if(!inited)
|
|
|
|
FirstCall();
|
|
|
|
return _SDL_GetAppState();
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint8_t (*_SDL_GetMouseState)(int *, int *) = 0;
|
|
|
|
DFhackCExport uint8_t SDL_GetMouseState(int *x, int *y)
|
|
|
|
{
|
|
|
|
if(!inited)
|
|
|
|
FirstCall();
|
|
|
|
return _SDL_GetMouseState(x,y);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int (*_SDL_InitSubSystem)(uint32_t flags) = 0;
|
|
|
|
DFhackCExport int SDL_InitSubSystem(uint32_t flags)
|
|
|
|
{
|
|
|
|
if(!inited)
|
|
|
|
FirstCall();
|
|
|
|
return _SDL_InitSubSystem(flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int (*_SDL_SemPost)(void *sem) = 0;
|
|
|
|
DFhackCExport int SDL_SemPost(void *sem)
|
|
|
|
{
|
|
|
|
if(!inited)
|
|
|
|
FirstCall();
|
|
|
|
return _SDL_SemPost(sem);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int (*_SDL_SemTryWait)(void *sem) = 0;
|
|
|
|
DFhackCExport int SDL_SemTryWait(void *sem)
|
|
|
|
{
|
|
|
|
if(!inited)
|
|
|
|
FirstCall();
|
|
|
|
return _SDL_SemTryWait(sem);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int (*_SDL_SemWait)(void *sem) = 0;
|
|
|
|
DFhackCExport int SDL_SemWait(void *sem)
|
|
|
|
{
|
|
|
|
if(!inited)
|
|
|
|
FirstCall();
|
|
|
|
return _SDL_SemWait(sem);
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t (*_SDL_ThreadID)(void) = 0;
|
|
|
|
DFhackCExport uint32_t SDL_ThreadID(void)
|
|
|
|
{
|
|
|
|
if(!inited)
|
|
|
|
FirstCall();
|
|
|
|
return _SDL_ThreadID();
|
|
|
|
}
|
|
|
|
|
2011-06-14 08:49:53 -06:00
|
|
|
// FIXME: this has to be thread-safe.
|
2010-05-24 17:49:13 -06:00
|
|
|
bool FirstCall()
|
2010-01-04 15:20:17 -07:00
|
|
|
{
|
|
|
|
HMODULE realSDLlib = LoadLibrary("SDLreal.dll");
|
|
|
|
if(!realSDLlib)
|
|
|
|
{
|
2010-02-11 06:27:48 -07:00
|
|
|
MessageBox(0,"Can't load SDLreal.dll\n","Error", MB_OK);
|
2010-01-04 15:20:17 -07:00
|
|
|
fprintf(stderr, "Can't load SDLreal.dll\n");
|
2010-05-24 17:49:13 -06:00
|
|
|
return 0;
|
2010-01-04 15:20:17 -07:00
|
|
|
}
|
|
|
|
// stuff for DF
|
|
|
|
_SDL_AddTimer = (void*(*)(uint32_t, void*, void*)) GetProcAddress(realSDLlib,"SDL_AddTimer");
|
|
|
|
_SDL_CondSignal = (int (*)(void*))GetProcAddress(realSDLlib,"SDL_CondSignal");
|
|
|
|
_SDL_CondWait = (int (*)(void*, void*))GetProcAddress(realSDLlib,"SDL_CondWait");
|
|
|
|
_SDL_ConvertSurface = (void*(*)(void*, void*, uint32_t))GetProcAddress(realSDLlib,"SDL_ConvertSurface");
|
|
|
|
_SDL_CreateCond = (void*(*)())GetProcAddress(realSDLlib,"SDL_CreateCond");
|
2011-06-16 18:09:03 -06:00
|
|
|
_SDL_CreateMutex = (DFMutex*(*)())GetProcAddress(realSDLlib,"SDL_CreateMutex");
|
2010-01-04 15:20:17 -07:00
|
|
|
_SDL_CreateRGBSurface = (void*(*)(uint32_t, int, int, int, uint32_t, uint32_t, uint32_t, uint32_t))GetProcAddress(realSDLlib,"SDL_CreateRGBSurface");
|
|
|
|
_SDL_CreateRGBSurfaceFrom = (void*(*)(void*, int, int, int, int, uint32_t, uint32_t, uint32_t, uint32_t))GetProcAddress(realSDLlib,"SDL_CreateRGBSurfaceFrom");
|
|
|
|
_SDL_DestroyCond = (void (*)(void*))GetProcAddress(realSDLlib,"SDL_DestroyCond");
|
2011-06-16 18:09:03 -06:00
|
|
|
_SDL_DestroyMutex = (void (*)(DFMutex*))GetProcAddress(realSDLlib,"SDL_DestroyMutex");
|
2010-01-04 15:20:17 -07:00
|
|
|
_SDL_EnableKeyRepeat = (int (*)(int, int))GetProcAddress(realSDLlib,"SDL_EnableKeyRepeat");
|
|
|
|
_SDL_EnableUNICODE = (int (*)(int))GetProcAddress(realSDLlib,"SDL_EnableUNICODE");
|
2010-02-10 21:56:24 -07:00
|
|
|
_SDL_GetVideoSurface = (void*(*)())GetProcAddress(realSDLlib,"SDL_GetVideoSurface");
|
|
|
|
_SDL_DisplayFormat = (void * (*) (void *))GetProcAddress(realSDLlib,"SDL_DisplayFormat");
|
2010-07-16 17:55:18 -06:00
|
|
|
_SDL_DisplayFormatAlpha = (void * (*) (void *))GetProcAddress(realSDLlib,"SDL_DisplayFormatAlpha");
|
2010-07-17 12:13:44 -06:00
|
|
|
_SDL_GetRGBA = (void (*) (uint32_t, void *, uint8_t *, uint8_t *, uint8_t *, uint8_t *))GetProcAddress(realSDLlib,"SDL_GetRGBA");
|
2010-01-04 15:20:17 -07:00
|
|
|
_SDL_FreeSurface = (void (*)(void*))GetProcAddress(realSDLlib,"SDL_FreeSurface");
|
|
|
|
_SDL_GL_GetAttribute = (int (*)(int, int*))GetProcAddress(realSDLlib,"SDL_GL_GetAttribute");
|
|
|
|
_SDL_GL_SetAttribute = (int (*)(int, int))GetProcAddress(realSDLlib,"SDL_GL_SetAttribute");
|
|
|
|
_SDL_GL_SwapBuffers = (void (*)())GetProcAddress(realSDLlib,"SDL_GL_SwapBuffers");
|
|
|
|
_SDL_GetError = (char*(*)())GetProcAddress(realSDLlib,"SDL_GetError");
|
|
|
|
_SDL_GetKeyState = (uint8_t*(*)(int*))GetProcAddress(realSDLlib,"SDL_GetKeyState");
|
|
|
|
_SDL_GetTicks = (uint32_t (*)())GetProcAddress(realSDLlib,"SDL_GetTicks");
|
|
|
|
_SDL_GetVideoInfo = (void*(*)())GetProcAddress(realSDLlib,"SDL_GetVideoInfo");
|
|
|
|
_SDL_Init = (int (*)(uint32_t))GetProcAddress(realSDLlib,"SDL_Init");
|
2010-02-10 21:56:24 -07:00
|
|
|
_SDL_Flip = (int (*)( void * )) GetProcAddress(realSDLlib, "SDL_Flip");
|
2010-01-04 15:20:17 -07:00
|
|
|
_SDL_LockSurface = (int (*)(void*))GetProcAddress(realSDLlib,"SDL_LockSurface");
|
|
|
|
_SDL_MapRGB = (uint32_t (*)(void*, uint8_t, uint8_t, uint8_t))GetProcAddress(realSDLlib,"SDL_MapRGB");
|
|
|
|
_SDL_PollEvent = (int (*)(void*))GetProcAddress(realSDLlib,"SDL_PollEvent");
|
|
|
|
_SDL_Quit = (void (*)())GetProcAddress(realSDLlib,"SDL_Quit");
|
|
|
|
_SDL_RWFromFile = (void*(*)(const char*, const char*))GetProcAddress(realSDLlib,"SDL_RWFromFile");
|
|
|
|
_SDL_RemoveTimer = (bool (*)(void*))GetProcAddress(realSDLlib,"SDL_RemoveTimer");
|
|
|
|
_SDL_SaveBMP_RW = (int (*)(void*, void*, int))GetProcAddress(realSDLlib,"SDL_SaveBMP_RW");
|
|
|
|
_SDL_SetAlpha = (int (*)(void*, uint32_t, uint8_t))GetProcAddress(realSDLlib,"SDL_SetAlpha");
|
|
|
|
_SDL_SetColorKey = (int (*)(void*, uint32_t, uint32_t))GetProcAddress(realSDLlib,"SDL_SetColorKey");
|
|
|
|
_SDL_SetModuleHandle = (void (*)(void*))GetProcAddress(realSDLlib,"SDL_SetModuleHandle");
|
|
|
|
_SDL_SetVideoMode = (void*(*)(int, int, int, uint32_t))GetProcAddress(realSDLlib,"SDL_SetVideoMode");
|
|
|
|
_SDL_ShowCursor = (int (*)(int))GetProcAddress(realSDLlib,"SDL_ShowCursor");
|
|
|
|
_SDL_UnlockSurface = (void (*)(void*))GetProcAddress(realSDLlib,"SDL_UnlockSurface");
|
|
|
|
_SDL_UpperBlit = (int (*)(void*, void*, void*, void*))GetProcAddress(realSDLlib,"SDL_UpperBlit");
|
|
|
|
_SDL_WM_SetCaption = (void (*)(const char*, const char*))GetProcAddress(realSDLlib,"SDL_WM_SetCaption");
|
|
|
|
_SDL_WM_SetIcon = (void (*)(void*, uint8_t*))GetProcAddress(realSDLlib,"SDL_WM_SetIcon");
|
2011-06-16 18:09:03 -06:00
|
|
|
_SDL_mutexP = (int (*)(DFMutex*))GetProcAddress(realSDLlib,"SDL_mutexP");
|
|
|
|
_SDL_mutexV = (int (*)(DFMutex*))GetProcAddress(realSDLlib,"SDL_mutexV");
|
2010-01-04 15:20:17 -07:00
|
|
|
_SDL_strlcpy = (size_t (*)(char*, const char*, size_t))GetProcAddress(realSDLlib,"SDL_strlcpy");
|
|
|
|
|
|
|
|
// stuff for SDL_Image
|
|
|
|
_SDL_ClearError = (void (*)())GetProcAddress(realSDLlib,"SDL_ClearError");
|
|
|
|
_SDL_Error = (void (*)(int))GetProcAddress(realSDLlib,"SDL_Error");
|
2011-06-19 17:12:07 -06:00
|
|
|
_SDL_LoadFunction = (void*(*)(DFLibrary*, const char*))GetProcAddress(realSDLlib,"SDL_LoadFunction");
|
|
|
|
_SDL_LoadObject = (DFLibrary*(*)(const char*))GetProcAddress(realSDLlib,"SDL_LoadObject");
|
2010-01-04 15:20:17 -07:00
|
|
|
_SDL_ReadBE32 = (uint32_t (*)(void*))GetProcAddress(realSDLlib,"SDL_ReadBE32");
|
|
|
|
_SDL_ReadLE16 = (uint16_t (*)(void*))GetProcAddress(realSDLlib,"SDL_ReadLE16");
|
|
|
|
_SDL_ReadLE32 = (uint32_t (*)(void*))GetProcAddress(realSDLlib,"SDL_ReadLE32");
|
|
|
|
_SDL_SetError = (void (*)(const char*, ...))GetProcAddress(realSDLlib,"SDL_SetError");
|
2011-06-19 17:12:07 -06:00
|
|
|
_SDL_UnloadObject = (void (*)(DFLibrary*))GetProcAddress(realSDLlib,"SDL_UnloadObject");
|
2010-01-04 15:20:17 -07:00
|
|
|
_SDL_FillRect = (int (*)(void*,void*,uint32_t))GetProcAddress(realSDLlib,"SDL_FillRect");
|
|
|
|
|
2010-05-24 17:49:13 -06:00
|
|
|
// new in DF 0.31.04
|
|
|
|
_SDL_CreateSemaphore = (void* (*)(uint32_t))GetProcAddress(realSDLlib,"SDL_CreateSemaphore");
|
2011-06-16 18:09:03 -06:00
|
|
|
_SDL_CreateThread = (DFThread* (*)(int (*fn)(void *), void *data))GetProcAddress(realSDLlib,"SDL_CreateThread");
|
2010-05-24 17:49:13 -06:00
|
|
|
_SDL_Delay = (void (*)(uint32_t))GetProcAddress(realSDLlib,"SDL_Delay");
|
|
|
|
_SDL_DestroySemaphore = (void (*)(void *))GetProcAddress(realSDLlib,"SDL_DestroySemaphore");
|
|
|
|
_SDL_GetAppState = (uint8_t (*)(void))GetProcAddress(realSDLlib,"SDL_GetAppState");
|
|
|
|
_SDL_GetMouseState = (uint8_t (*)(int *, int *))GetProcAddress(realSDLlib,"SDL_GetMouseState");
|
|
|
|
_SDL_InitSubSystem = (int (*)(uint32_t))GetProcAddress(realSDLlib,"SDL_InitSubSystem");
|
|
|
|
_SDL_SemPost = (int (*)(void *))GetProcAddress(realSDLlib,"SDL_SemPost");
|
|
|
|
_SDL_SemTryWait = (int (*)(void *))GetProcAddress(realSDLlib,"SDL_SemTryWait");
|
|
|
|
_SDL_SemWait = (int (*)(void *))GetProcAddress(realSDLlib,"SDL_SemWait");
|
|
|
|
_SDL_ThreadID = (uint32_t (*)(void))GetProcAddress(realSDLlib,"SDL_ThreadID");
|
|
|
|
|
2010-01-04 15:20:17 -07:00
|
|
|
fprintf(stderr,"Initized HOOKS!\n");
|
2011-06-14 08:13:28 -06:00
|
|
|
inited = true;
|
2010-05-24 17:49:13 -06:00
|
|
|
return 1;
|
2010-01-04 15:20:17 -07:00
|
|
|
}
|
2011-06-14 22:09:24 -06:00
|
|
|
|