sync with work (add IO callbacks, export wsdl functions, avoid error in ReadVersionString)
This was SVN commit r7627.
This commit is contained in:
parent
4fa5f1892b
commit
85bfdf0983
@ -312,30 +312,30 @@ LibError io_Scan(const PFile& file, off_t ofs, off_t size, IoCallback cb, uintpt
|
||||
}
|
||||
|
||||
|
||||
LibError io_Read(const PFile& file, off_t ofs, u8* alignedBuf, off_t size, u8*& data)
|
||||
LibError io_Read(const PFile& file, off_t ofs, u8* alignedBuf, off_t size, u8*& data, IoCallback cb, uintptr_t cbData)
|
||||
{
|
||||
IoSplitter splitter(ofs, alignedBuf, size);
|
||||
RETURN_ERR(splitter.Run(file));
|
||||
RETURN_ERR(splitter.Run(file, cb, cbData));
|
||||
data = alignedBuf + ofs - splitter.AlignedOfs();
|
||||
return INFO::OK;
|
||||
}
|
||||
|
||||
|
||||
LibError io_WriteAligned(const PFile& file, off_t alignedOfs, const u8* alignedData, off_t size)
|
||||
LibError io_WriteAligned(const PFile& file, off_t alignedOfs, const u8* alignedData, off_t size, IoCallback cb, uintptr_t cbData)
|
||||
{
|
||||
debug_assert(IsAligned_Offset(alignedOfs));
|
||||
debug_assert(IsAligned_Data(alignedData));
|
||||
|
||||
IoSplitter splitter(alignedOfs, const_cast<u8*>(alignedData), size);
|
||||
return splitter.Run(file);
|
||||
return splitter.Run(file, cb, cbData);
|
||||
}
|
||||
|
||||
|
||||
LibError io_ReadAligned(const PFile& file, off_t alignedOfs, u8* alignedBuf, off_t size)
|
||||
LibError io_ReadAligned(const PFile& file, off_t alignedOfs, u8* alignedBuf, off_t size, IoCallback cb, uintptr_t cbData)
|
||||
{
|
||||
debug_assert(IsAligned_Offset(alignedOfs));
|
||||
debug_assert(IsAligned_Data(alignedBuf));
|
||||
|
||||
IoSplitter splitter(alignedOfs, alignedBuf, size);
|
||||
return splitter.Run(file);
|
||||
return splitter.Run(file, cb, cbData);
|
||||
}
|
||||
|
@ -48,9 +48,9 @@ typedef LibError (*IoCallback)(uintptr_t cbData, const u8* block, size_t blockSi
|
||||
|
||||
LIB_API LibError io_Scan(const PFile& file, off_t ofs, off_t size, IoCallback cb, uintptr_t cbData);
|
||||
|
||||
LIB_API LibError io_Read(const PFile& file, off_t ofs, u8* alignedBuf, off_t size, u8*& data);
|
||||
LIB_API LibError io_Read(const PFile& file, off_t ofs, u8* alignedBuf, off_t size, u8*& data, IoCallback cb = 0, uintptr_t cbData = 0);
|
||||
|
||||
LIB_API LibError io_WriteAligned(const PFile& file, off_t alignedOfs, const u8* alignedData, off_t size);
|
||||
LIB_API LibError io_ReadAligned(const PFile& file, off_t alignedOfs, u8* alignedBuf, off_t size);
|
||||
LIB_API LibError io_WriteAligned(const PFile& file, off_t alignedOfs, const u8* alignedData, off_t size, IoCallback cb = 0, uintptr_t cbData = 0);
|
||||
LIB_API LibError io_ReadAligned(const PFile& file, off_t alignedOfs, u8* alignedBuf, off_t size, IoCallback cb = 0, uintptr_t cbData = 0);
|
||||
|
||||
#endif // #ifndef INCLUDED_IO
|
||||
|
@ -34,9 +34,9 @@
|
||||
# else
|
||||
# define LIB_API __declspec(dllimport)
|
||||
# ifdef NDEBUG
|
||||
# pragma comment(lib, "lib.lib")
|
||||
# pragma comment(lib, "lowlevel.lib")
|
||||
# else
|
||||
# pragma comment(lib, "lib_d.lib")
|
||||
# pragma comment(lib, "lowlevel_d.lib")
|
||||
# endif
|
||||
# endif
|
||||
# elif GCC_VERSION
|
||||
|
@ -87,6 +87,9 @@ static LibError ReadVersionString(const fs::wpath& modulePathname_, wchar_t* out
|
||||
|
||||
void wdll_ver_Append(const fs::wpath& pathname, std::wstring& list)
|
||||
{
|
||||
if(pathname.empty())
|
||||
return; // avoid error in ReadVersionString
|
||||
|
||||
// pathname may not have an extension (e.g. driver names from the
|
||||
// registry). note that always appending ".dll" would be incorrect
|
||||
// since some have ".sys" extension.
|
||||
|
@ -51,10 +51,11 @@
|
||||
|
||||
#include "lib/ogl.h" // needed to pull in the delay-loaded opengl32.dll
|
||||
|
||||
extern "C" {
|
||||
|
||||
WINIT_REGISTER_LATE_INIT(wsdl_Init);
|
||||
WINIT_REGISTER_EARLY_SHUTDOWN(wsdl_Shutdown);
|
||||
|
||||
|
||||
// in fullscreen mode, i.e. not windowed.
|
||||
// video mode will be restored when app is deactivated.
|
||||
static bool fullscreen;
|
||||
@ -371,12 +372,12 @@ int SDL_SetVideoMode(int w, int h, int bpp, unsigned long flags)
|
||||
const DWORD windowStyle = wnd_ChooseWindowStyle(fullscreen, g_hWnd);
|
||||
wnd_UpdateWindowDimensions(windowStyle, w, h);
|
||||
|
||||
UINT flags = SWP_FRAMECHANGED|SWP_NOZORDER|SWP_NOACTIVATE;
|
||||
UINT swp_flags = SWP_FRAMECHANGED|SWP_NOZORDER|SWP_NOACTIVATE;
|
||||
if(!fullscreen) // windowed: preserve the top-left corner
|
||||
flags |= SWP_NOMOVE;
|
||||
swp_flags |= SWP_NOMOVE;
|
||||
|
||||
WARN_IF_FALSE(SetWindowLongW(g_hWnd, GWL_STYLE, windowStyle));
|
||||
WARN_IF_FALSE(SetWindowPos(g_hWnd, 0, 0, 0, w, h, flags));
|
||||
WARN_IF_FALSE(SetWindowPos(g_hWnd, 0, 0, 0, w, h, swp_flags));
|
||||
|
||||
if(fullscreen)
|
||||
{
|
||||
@ -973,7 +974,7 @@ Uint8 SDL_GetMouseState(int* x, int* y)
|
||||
}
|
||||
|
||||
|
||||
inline void SDL_WarpMouse(int x, int y)
|
||||
void SDL_WarpMouse(int x, int y)
|
||||
{
|
||||
// SDL interface provides for int, but the values should be
|
||||
// idealized client coords (>= 0)
|
||||
@ -1221,7 +1222,7 @@ SDL_sem* SDL_CreateSemaphore(int cnt)
|
||||
return sem_from_HANDLE(h);
|
||||
}
|
||||
|
||||
inline void SDL_DestroySemaphore(SDL_sem* sem)
|
||||
void SDL_DestroySemaphore(SDL_sem* sem)
|
||||
{
|
||||
HANDLE h = HANDLE_from_sem(sem);
|
||||
CloseHandle(h);
|
||||
@ -1276,19 +1277,19 @@ void SDL_WM_SetCaption(const char* title, const char* icon)
|
||||
}
|
||||
|
||||
|
||||
inline u32 SDL_GetTicks()
|
||||
u32 SDL_GetTicks()
|
||||
{
|
||||
return GetTickCount();
|
||||
}
|
||||
|
||||
|
||||
inline void SDL_Delay(Uint32 ms)
|
||||
void SDL_Delay(Uint32 ms)
|
||||
{
|
||||
Sleep(ms);
|
||||
}
|
||||
|
||||
|
||||
inline void* SDL_GL_GetProcAddress(const char* name)
|
||||
void* SDL_GL_GetProcAddress(const char* name)
|
||||
{
|
||||
return wglGetProcAddress(name);
|
||||
}
|
||||
@ -1327,7 +1328,7 @@ void SDL_Quit()
|
||||
video_Shutdown();
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void RedirectStdout()
|
||||
{
|
||||
// this process is apparently attached to a console, and users might be
|
||||
@ -1361,7 +1362,7 @@ static void RedirectStdout()
|
||||
setvbuf(stdout, 0, _IONBF, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static LibError wsdl_Init()
|
||||
{
|
||||
// note: SDL does this in its WinMain hook. doing so in SDL_Init would be
|
||||
@ -1380,4 +1381,6 @@ static LibError wsdl_Shutdown()
|
||||
return INFO::OK;
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
#endif // #if CONFIG2_WSDL
|
||||
|
@ -27,9 +27,12 @@
|
||||
#ifndef INCLUDED_WSDL
|
||||
#define INCLUDED_WSDL
|
||||
|
||||
#include "lib/lib_api.h"
|
||||
#include "lib/byte_order.h"
|
||||
#include "SDL/SDL_keysym.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
typedef u8 Uint8;
|
||||
typedef u16 Uint16;
|
||||
typedef u32 Uint32;
|
||||
@ -41,9 +44,9 @@ typedef u32 Uint32;
|
||||
#define SDL_INIT_TIMER 0
|
||||
#define SDL_INIT_NOPARACHUTE 0
|
||||
|
||||
extern int SDL_Init(Uint32 flags);
|
||||
LIB_API int SDL_Init(Uint32 flags);
|
||||
|
||||
extern void SDL_Quit();
|
||||
LIB_API void SDL_Quit();
|
||||
|
||||
|
||||
//
|
||||
@ -57,14 +60,14 @@ typedef enum
|
||||
}
|
||||
SDL_GLattr;
|
||||
|
||||
extern int SDL_GL_SetAttribute(SDL_GLattr attr, int value);
|
||||
LIB_API int SDL_GL_SetAttribute(SDL_GLattr attr, int value);
|
||||
|
||||
// SDL_SetVideoMode() flags
|
||||
#define SDL_OPENGL 0
|
||||
#define SDL_FULLSCREEN 1
|
||||
#define SDL_RESIZABLE 2
|
||||
|
||||
extern int SDL_SetVideoMode(int w, int h, int bpp, unsigned long flags);
|
||||
LIB_API int SDL_SetVideoMode(int w, int h, int bpp, unsigned long flags);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@ -72,7 +75,7 @@ typedef struct
|
||||
}
|
||||
SDL_Surface;
|
||||
|
||||
extern SDL_Surface* SDL_GetVideoSurface();
|
||||
LIB_API SDL_Surface* SDL_GetVideoSurface();
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@ -80,11 +83,11 @@ typedef struct
|
||||
}
|
||||
SDL_VideoInfo;
|
||||
|
||||
extern SDL_VideoInfo* SDL_GetVideoInfo();
|
||||
LIB_API SDL_VideoInfo* SDL_GetVideoInfo();
|
||||
|
||||
extern void* SDL_GL_GetProcAddress(const char*);
|
||||
LIB_API void* SDL_GL_GetProcAddress(const char*);
|
||||
|
||||
extern void SDL_GL_SwapBuffers();
|
||||
LIB_API void SDL_GL_SwapBuffers();
|
||||
|
||||
|
||||
//
|
||||
@ -94,19 +97,19 @@ extern void SDL_GL_SwapBuffers();
|
||||
typedef void SDL_sem;
|
||||
typedef void SDL_Thread;
|
||||
|
||||
extern u32 SDL_GetTicks();
|
||||
extern void SDL_Delay(u32 ms);
|
||||
LIB_API u32 SDL_GetTicks();
|
||||
LIB_API void SDL_Delay(u32 ms);
|
||||
|
||||
extern SDL_sem* SDL_CreateSemaphore(int cnt);
|
||||
extern void SDL_DestroySemaphore(SDL_sem*);
|
||||
extern int SDL_SemPost(SDL_sem*);
|
||||
extern int SDL_SemWait(SDL_sem* sem);
|
||||
LIB_API SDL_sem* SDL_CreateSemaphore(int cnt);
|
||||
LIB_API void SDL_DestroySemaphore(SDL_sem*);
|
||||
LIB_API int SDL_SemPost(SDL_sem*);
|
||||
LIB_API int SDL_SemWait(SDL_sem* sem);
|
||||
|
||||
extern SDL_Thread* SDL_CreateThread(int (*)(void*), void*);
|
||||
extern int SDL_KillThread(SDL_Thread*);
|
||||
LIB_API SDL_Thread* SDL_CreateThread(int (*)(void*), void*);
|
||||
LIB_API int SDL_KillThread(SDL_Thread*);
|
||||
|
||||
|
||||
extern void SDL_WarpMouse(int, int);
|
||||
LIB_API void SDL_WarpMouse(int, int);
|
||||
|
||||
enum ShowCursorToggle
|
||||
{
|
||||
@ -114,10 +117,10 @@ enum ShowCursorToggle
|
||||
SDL_ENABLE = 1,
|
||||
SDL_QUERY = 2
|
||||
};
|
||||
extern int SDL_ShowCursor(int toggle);
|
||||
LIB_API int SDL_ShowCursor(int toggle);
|
||||
|
||||
|
||||
extern int SDL_SetGamma(float r, float g, float b);
|
||||
LIB_API int SDL_SetGamma(float r, float g, float b);
|
||||
|
||||
|
||||
//
|
||||
@ -254,10 +257,10 @@ typedef union
|
||||
SDL_Event;
|
||||
|
||||
|
||||
extern int SDL_EnableUNICODE(int enable);
|
||||
extern int SDL_WaitEvent(SDL_Event*);
|
||||
extern int SDL_PollEvent(SDL_Event* ev);
|
||||
extern int SDL_PushEvent(SDL_Event* ev);
|
||||
LIB_API int SDL_EnableUNICODE(int enable);
|
||||
LIB_API int SDL_WaitEvent(SDL_Event*);
|
||||
LIB_API int SDL_PollEvent(SDL_Event* ev);
|
||||
LIB_API int SDL_PushEvent(SDL_Event* ev);
|
||||
|
||||
|
||||
//
|
||||
@ -275,11 +278,13 @@ extern int SDL_PushEvent(SDL_Event* ev);
|
||||
#define SDL_EnableKeyRepeat(delay, interval)
|
||||
|
||||
|
||||
extern void SDL_WM_SetCaption(const char *title, const char *icon);
|
||||
LIB_API void SDL_WM_SetCaption(const char *title, const char *icon);
|
||||
|
||||
extern Uint8* SDL_GetKeyState(int* num_keys);
|
||||
extern Uint8 SDL_GetMouseState(int* x, int* y);
|
||||
LIB_API Uint8* SDL_GetKeyState(int* num_keys);
|
||||
LIB_API Uint8 SDL_GetMouseState(int* x, int* y);
|
||||
|
||||
extern Uint8 SDL_GetAppState();
|
||||
LIB_API Uint8 SDL_GetAppState();
|
||||
|
||||
} // extern "C"
|
||||
|
||||
#endif // #ifndef INCLUDED_WSDL
|
||||
|
Loading…
Reference in New Issue
Block a user