Browse Source

Progress with miniwin macros

pull/35/head
Xadhoom 7 years ago
parent
commit
30fbfa36a1
  1. 16
      CMakeLists.txt
  2. 10
      SourceS/miniwin.h
  3. 10
      SourceS/miniwin_popdecl.h
  4. 19
      SourceS/miniwin_pushdecl.h
  5. 2
      SourceX/DiabloUI/credits.cpp
  6. 44
      SourceX/DiabloUI/diabloui.cpp
  7. 4
      SourceX/DiabloUI/diabloui.h
  8. 4
      SourceX/DiabloUI/mainmenu.cpp
  9. 2
      SourceX/DiabloUI/progress.cpp
  10. 2
      SourceX/DiabloUI/selconn.cpp
  11. 2
      SourceX/DiabloUI/selgame.cpp
  12. 32
      SourceX/DiabloUI/selhero.cpp
  13. 2
      SourceX/DiabloUI/title.cpp
  14. 2
      SourceX/dvlnet/abstract_net.h
  15. 5
      SourceX/dvlnet/tcp_client.cpp
  16. 20
      SourceX/dx.cpp
  17. 92
      SourceX/miniwin.cpp
  18. 18
      SourceX/miniwin_io.cpp
  19. 10
      SourceX/miniwin_msg_sdl.cpp
  20. 24
      SourceX/miniwin_thread.cpp
  21. 42
      SourceX/sound.cpp
  22. 98
      SourceX/storm.cpp
  23. 40
      SourceX/storm_net.cpp
  24. 2
      types.h

16
CMakeLists.txt

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.7) cmake_minimum_required(VERSION 3.13)
include(CMake/out_of_tree.cmake) include(CMake/out_of_tree.cmake)
@ -64,7 +64,7 @@ add_library(Radon STATIC
3rdParty/Radon/Radon/source/Named.cpp 3rdParty/Radon/Radon/source/Named.cpp
3rdParty/Radon/Radon/source/Section.cpp) 3rdParty/Radon/Radon/source/Section.cpp)
add_library(StormLib STATIC add_library(StormLib OBJECT
3rdParty/StormLib/src/FileStream.cpp 3rdParty/StormLib/src/FileStream.cpp
3rdParty/StormLib/src/SBaseCommon.cpp 3rdParty/StormLib/src/SBaseCommon.cpp
3rdParty/StormLib/src/SBaseFileTable.cpp 3rdParty/StormLib/src/SBaseFileTable.cpp
@ -77,11 +77,11 @@ add_library(StormLib STATIC
3rdParty/StormLib/src/SFileOpenFileEx.cpp 3rdParty/StormLib/src/SFileOpenFileEx.cpp
3rdParty/StormLib/src/SFileReadFile.cpp) 3rdParty/StormLib/src/SFileReadFile.cpp)
add_library(PKWare STATIC add_library(PKWare OBJECT
3rdParty/PKWare/explode.cpp 3rdParty/PKWare/explode.cpp
3rdParty/PKWare/implode.cpp) 3rdParty/PKWare/implode.cpp)
add_library(devilution STATIC add_library(devilution OBJECT
Source/appfat.cpp Source/appfat.cpp
Source/automap.cpp Source/automap.cpp
Source/capture.cpp Source/capture.cpp
@ -183,10 +183,10 @@ add_executable(devilutionx
target_include_directories(devilutionx PRIVATE SourceS SourceX 3rdParty/asio/include .) target_include_directories(devilutionx PRIVATE SourceS SourceX 3rdParty/asio/include .)
target_link_libraries(devilution PUBLIC PKWare Threads::Threads) target_link_libraries(devilution PRIVATE Threads::Threads)
target_link_libraries(devilutionx PRIVATE target_link_libraries(devilutionx PRIVATE
devilution devilution
PKWare
StormLib StormLib
smacker smacker
Radon Radon
@ -215,6 +215,10 @@ if(DIST)
target_link_libraries(devilutionx PUBLIC -static-libgcc -static-libstdc++) target_link_libraries(devilutionx PUBLIC -static-libgcc -static-libstdc++)
endif() endif()
if(WIN32)
target_link_libraries(devilutionx PRIVATE wsock32 ws2_32 wininet)
endif()
# Note: In Debug mode, GCC generates spurious memory references that upset Valgrind, # Note: In Debug mode, GCC generates spurious memory references that upset Valgrind,
# these options fix that. # these options fix that.
target_compile_options(devilution PUBLIC $<$<CONFIG:Debug>:-fno-omit-frame-pointer>) target_compile_options(devilution PUBLIC $<$<CONFIG:Debug>:-fno-omit-frame-pointer>)

10
SourceS/miniwin.h

@ -26,16 +26,6 @@
#define NO_ERROR 0 #define NO_ERROR 0
// Remove calling conventions (original calling conventions confuse address-sanitizer and aren't supported by all compilers)
#define __cdecl
#define __fastcall
#define __stdcall
#define CALLBACK
#define APIENTRY
#define WINAPI
#define WINAPIV
#define WINUSERAPI
#ifndef _WIN32 #ifndef _WIN32
#define __int8 char #define __int8 char
#define __int16 short #define __int16 short

10
SourceS/miniwin_popdecl.h

@ -0,0 +1,10 @@
#ifndef DEVILUTION_ENGINE
#pragma pop_macro("__cdecl")
#pragma pop_macro("__fastcall")
#pragma pop_macro("__stdcall")
#pragma pop_macro("CALLBACK")
#pragma pop_macro("APIENTRY")
#pragma pop_macro("WINAPI")
#pragma pop_macro("WINAPIV")
#pragma pop_macro("WINUSERAPI")
#endif

19
SourceS/miniwin_pushdecl.h

@ -0,0 +1,19 @@
#ifndef DEVILUTION_ENGINE
#pragma push_macro("__cdecl")
#pragma push_macro("__fastcall")
#pragma push_macro("__stdcall")
#pragma push_macro("CALLBACK")
#pragma push_macro("APIENTRY")
#pragma push_macro("WINAPI")
#pragma push_macro("WINAPIV")
#pragma push_macro("WINUSERAPI")
#endif
#define __cdecl
#define __fastcall
#define __stdcall
#define CALLBACK
#define APIENTRY
#define WINAPI
#define WINAPIV
#define WINUSERAPI

2
SourceX/DiabloUI/credits.cpp

@ -527,7 +527,7 @@ void credts_Render()
} }
} }
BOOL __stdcall UiCreditsDialog(int a1) BOOL UiCreditsDialog(int a1)
{ {
credts_Load(); credts_Load();

44
SourceX/DiabloUI/diabloui.cpp

@ -14,10 +14,10 @@ Art ArtBackground;
Art ArtCursor; Art ArtCursor;
Art ArtHero; Art ArtHero;
void(__stdcall *gfnSoundFunction)(char *file); void(*gfnSoundFunction)(char *file);
void(__stdcall *gfnListFocus)(int value); void(*gfnListFocus)(int value);
void(__stdcall *gfnListSelect)(int value); void(*gfnListSelect)(int value);
void(__stdcall *gfnListEsc)(); void(*gfnListEsc)();
UI_Item *gUiItems; UI_Item *gUiItems;
int gUiItemCnt; int gUiItemCnt;
bool UiItemsWraps; bool UiItemsWraps;
@ -121,7 +121,7 @@ BOOL SetWindowPos(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy,
return TRUE; return TRUE;
} }
void __cdecl UiDestroy() void UiDestroy()
{ {
DUMMY(); DUMMY();
mem_free_dbg(ArtHero.data); mem_free_dbg(ArtHero.data);
@ -131,7 +131,7 @@ void __cdecl UiDestroy()
font = NULL; font = NULL;
} }
void UiInitList(int min, int max, void(__stdcall *fnFocus)(int value), void(__stdcall *fnSelect)(int value), void(__stdcall *fnEsc)(), UI_Item *items, int itemCnt, bool itemsWraps) void UiInitList(int min, int max, void(*fnFocus)(int value), void(*fnSelect)(int value), void(*fnEsc)(), UI_Item *items, int itemCnt, bool itemsWraps)
{ {
SelectedItem = min; SelectedItem = min;
SelectedItemMin = min; SelectedItemMin = min;
@ -392,7 +392,7 @@ void UiInitialize()
InitFont(); InitFont();
} }
int __cdecl UiProfileGetString() int UiProfileGetString()
{ {
DUMMY(); DUMMY();
return 0; return 0;
@ -400,7 +400,7 @@ int __cdecl UiProfileGetString()
char connect_plrinfostr[128]; char connect_plrinfostr[128];
char connect_categorystr[128]; char connect_categorystr[128];
void __stdcall UiSetupPlayerInfo(char *infostr, _uiheroinfo *pInfo, DWORD type) void UiSetupPlayerInfo(char *infostr, _uiheroinfo *pInfo, DWORD type)
{ {
DUMMY(); DUMMY();
SStrCopy(connect_plrinfostr, infostr, 128); SStrCopy(connect_plrinfostr, infostr, 128);
@ -423,17 +423,17 @@ void __stdcall UiSetupPlayerInfo(char *infostr, _uiheroinfo *pInfo, DWORD type)
pInfo->spawned); pInfo->spawned);
} }
BOOL __stdcall UiCopyProtError(int *pdwResult) BOOL UiCopyProtError(int *pdwResult)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
void __stdcall UiAppActivate(BOOL bActive) void UiAppActivate(BOOL bActive)
{ {
DUMMY(); DUMMY();
} }
BOOL __fastcall UiValidPlayerName(char *name) BOOL UiValidPlayerName(char *name)
{ {
if (!strlen(name)) if (!strlen(name))
return FALSE; return FALSE;
@ -448,59 +448,59 @@ BOOL __fastcall UiValidPlayerName(char *name)
return TRUE; return TRUE;
} }
void __cdecl UiProfileCallback() void UiProfileCallback()
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
void __cdecl UiProfileDraw() void UiProfileDraw()
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
BOOL __stdcall UiCategoryCallback(int a1, int a2, int a3, int a4, int a5, _DWORD *a6, _DWORD *a7) BOOL UiCategoryCallback(int a1, int a2, int a3, int a4, int a5, _DWORD *a6, _DWORD *a7)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
BOOL __stdcall UiGetDataCallback(int game_type, int data_code, void *a3, int a4, int a5) BOOL UiGetDataCallback(int game_type, int data_code, void *a3, int a4, int a5)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
BOOL __stdcall UiAuthCallback(int a1, char *a2, char *a3, char a4, char *a5, LPSTR lpBuffer, int cchBufferMax) BOOL UiAuthCallback(int a1, char *a2, char *a3, char a4, char *a5, LPSTR lpBuffer, int cchBufferMax)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
BOOL __stdcall UiSoundCallback(int a1, int type, int a3) BOOL UiSoundCallback(int a1, int type, int a3)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
void __stdcall UiMessageBoxCallback(HWND hWnd, char *lpText, LPCSTR lpCaption, UINT uType) void UiMessageBoxCallback(HWND hWnd, char *lpText, LPCSTR lpCaption, UINT uType)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
BOOL __stdcall UiDrawDescCallback(int game_type, COLORREF color, LPCSTR lpString, char *a4, int a5, UINT align, time_t a7, BOOL UiDrawDescCallback(int game_type, COLORREF color, LPCSTR lpString, char *a4, int a5, UINT align, time_t a7,
HDC *a8) HDC *a8)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
BOOL __stdcall UiCreateGameCallback(int a1, int a2, int a3, int a4, int a5, int a6) BOOL UiCreateGameCallback(int a1, int a2, int a3, int a4, int a5, int a6)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
BOOL __stdcall UiArtCallback(int game_type, unsigned int art_code, PALETTEENTRY *pPalette, void *pBuffer, BOOL UiArtCallback(int game_type, unsigned int art_code, PALETTEENTRY *pPalette, void *pBuffer,
DWORD dwBuffersize, DWORD *pdwWidth, DWORD *pdwHeight, DWORD *pdwBpp) DWORD dwBuffersize, DWORD *pdwWidth, DWORD *pdwHeight, DWORD *pdwBpp)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
BOOL __stdcall UiCreatePlayerDescription(_uiheroinfo *info, DWORD mode, char *desc) BOOL UiCreatePlayerDescription(_uiheroinfo *info, DWORD mode, char *desc)
{ {
char format[32] = ""; char format[32] = "";
strncpy(format, (char *)&mode, 4); strncpy(format, (char *)&mode, 4);

4
SourceX/DiabloUI/diabloui.h

@ -96,7 +96,7 @@ constexpr size_t size(T (&)[N])
return N; return N;
} }
extern void(__stdcall *gfnSoundFunction)(char *file); extern void(*gfnSoundFunction)(char *file);
bool IsInsideRect(const SDL_Event *event, const SDL_Rect *rect); bool IsInsideRect(const SDL_Event *event, const SDL_Rect *rect);
void UiFadeIn(int steps = 16); void UiFadeIn(int steps = 16);
@ -113,7 +113,7 @@ void LoadMaskedArtFont(char *pszFile, Art *art, int frames, int mask = 250);
void SetMenu(int MenuId); void SetMenu(int MenuId);
void UiFocusNavigationSelect(); void UiFocusNavigationSelect();
void UiFocusNavigationEsc(); void UiFocusNavigationEsc();
void UiInitList(int min, int max, void(__stdcall *fnFocus)(int value), void(__stdcall *fnSelect)(int value), void(__stdcall *fnEsc)(), UI_Item *items, int size, bool wraps = false); void UiInitList(int min, int max, void(*fnFocus)(int value), void(*fnSelect)(int value), void(*fnEsc)(), UI_Item *items, int size, bool wraps = false);
void UiRender(); void UiRender();
void UiRenderItems(UI_Item *items, int size); void UiRenderItems(UI_Item *items, int size);
void WordWrap(UI_Item *item); void WordWrap(UI_Item *item);

4
SourceX/DiabloUI/mainmenu.cpp

@ -23,7 +23,7 @@ void mainmenu_Esc()
UiMainMenuSelect(MAINMENU_EXIT_DIABLO); UiMainMenuSelect(MAINMENU_EXIT_DIABLO);
} }
void mainmenu_Load(char *name, void(__stdcall *fnSound)(char *file)) void mainmenu_Load(char *name, void(*fnSound)(char *file))
{ {
gfnSoundFunction = fnSound; gfnSoundFunction = fnSound;
MAINMENU_DIALOG[6].caption = name; MAINMENU_DIALOG[6].caption = name;
@ -44,7 +44,7 @@ void mainmenu_Free()
ArtBackground.data = NULL; ArtBackground.data = NULL;
} }
BOOL __stdcall UiMainMenuDialog(char *name, int *pdwResult, void(__stdcall *fnSound)(char *file), int a4) BOOL UiMainMenuDialog(char *name, int *pdwResult, void(*fnSound)(char *file), int a4)
{ {
mainmenu_Load(name, fnSound); mainmenu_Load(name, fnSound);

2
SourceX/DiabloUI/progress.cpp

@ -68,7 +68,7 @@ void progress_Render(BYTE progress)
} }
} }
int __stdcall UiProgressDialog(HWND window, char *msg, int enable, int(__cdecl *fnfunc)(), int rate) int UiProgressDialog(HWND window, char *msg, int enable, int(*fnfunc)(), int rate)
{ {
progress_Load(msg); progress_Load(msg);

2
SourceX/DiabloUI/selconn.cpp

@ -98,7 +98,7 @@ void selconn_Select(int value)
selconn_Load(); selconn_Load();
} }
int __stdcall UiSelectProvider( int UiSelectProvider(
int a1, int a1,
_SNETPROGRAMDATA *client_info, _SNETPROGRAMDATA *client_info,
_SNETPLAYERDATA *user_info, _SNETPLAYERDATA *user_info,

2
SourceX/DiabloUI/selgame.cpp

@ -206,7 +206,7 @@ void selgame_Password_Esc()
selgame_GameSelection_Select(selgame_selectedGame); selgame_GameSelection_Select(selgame_selectedGame);
} }
int __stdcall UiSelectGame(int a1, _SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, _SNETUIDATA *ui_info, int UiSelectGame(int a1, _SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, _SNETUIDATA *ui_info,
_SNETVERSIONDATA *file_info, int *playerId) _SNETVERSIONDATA *file_info, int *playerId)
{ {
gdwPlayerId = playerId; gdwPlayerId = playerId;

32
SourceX/DiabloUI/selhero.cpp

@ -15,9 +15,9 @@ int selhero_result;
bool selhero_endMenu; bool selhero_endMenu;
bool isMultiPlayer; bool isMultiPlayer;
BOOL(__stdcall *gfnHeroStats) BOOL(*gfnHeroStats)
(unsigned int, _uidefaultstats *); (unsigned int, _uidefaultstats *);
BOOL(__stdcall *gfnHeroCreate) BOOL(*gfnHeroCreate)
(_uiheroinfo *); (_uiheroinfo *);
UI_Item SELHERO_DIALOG[] = { UI_Item SELHERO_DIALOG[] = {
@ -212,7 +212,7 @@ void selhero_Load_Select(int value)
selhero_result = NEW_GAME; selhero_result = NEW_GAME;
} }
BOOL __stdcall SelHero_GetHeroInfo(_uiheroinfo *pInfo) BOOL SelHero_GetHeroInfo(_uiheroinfo *pInfo)
{ {
heros[selhero_SaveCount] = *pInfo; heros[selhero_SaveCount] = *pInfo;
selhero_SaveCount++; selhero_SaveCount++;
@ -221,9 +221,9 @@ BOOL __stdcall SelHero_GetHeroInfo(_uiheroinfo *pInfo)
} }
BOOL UiSelHeroDialog( BOOL UiSelHeroDialog(
BOOL(__stdcall *fninfo)(BOOL(__stdcall *fninfofunc)(_uiheroinfo *)), BOOL(*fninfo)(BOOL(*fninfofunc)(_uiheroinfo *)),
BOOL(__stdcall *fncreate)(_uiheroinfo *), BOOL(*fncreate)(_uiheroinfo *),
BOOL(__stdcall *fnstats)(unsigned int, _uidefaultstats *), BOOL(*fnstats)(unsigned int, _uidefaultstats *),
int *dlgresult, int *dlgresult,
char *name) char *name)
{ {
@ -255,11 +255,11 @@ BOOL UiSelHeroDialog(
return TRUE; return TRUE;
} }
BOOL __stdcall UiSelHeroSingDialog( BOOL UiSelHeroSingDialog(
BOOL(__stdcall *fninfo)(BOOL(__stdcall *fninfofunc)(_uiheroinfo *)), BOOL(*fninfo)(BOOL(*fninfofunc)(_uiheroinfo *)),
BOOL(__stdcall *fncreate)(_uiheroinfo *), BOOL(*fncreate)(_uiheroinfo *),
BOOL(__stdcall *fnremove)(_uiheroinfo *), BOOL(*fnremove)(_uiheroinfo *),
BOOL(__stdcall *fnstats)(unsigned int, _uidefaultstats *), BOOL(*fnstats)(unsigned int, _uidefaultstats *),
int *dlgresult, int *dlgresult,
char *name, char *name,
int *difficulty) int *difficulty)
@ -268,11 +268,11 @@ BOOL __stdcall UiSelHeroSingDialog(
return UiSelHeroDialog(fninfo, fncreate, fnstats, dlgresult, name); return UiSelHeroDialog(fninfo, fncreate, fnstats, dlgresult, name);
} }
BOOL __stdcall UiSelHeroMultDialog( BOOL UiSelHeroMultDialog(
BOOL(__stdcall *fninfo)(BOOL(__stdcall *fninfofunc)(_uiheroinfo *)), BOOL(*fninfo)(BOOL(*fninfofunc)(_uiheroinfo *)),
BOOL(__stdcall *fncreate)(_uiheroinfo *), BOOL(*fncreate)(_uiheroinfo *),
BOOL(__stdcall *fnremove)(_uiheroinfo *), BOOL(*fnremove)(_uiheroinfo *),
BOOL(__stdcall *fnstats)(unsigned int, _uidefaultstats *), BOOL(*fnstats)(unsigned int, _uidefaultstats *),
int *dlgresult, int *dlgresult,
BOOL *hero_is_created, BOOL *hero_is_created,
char *name) char *name)

2
SourceX/DiabloUI/title.cpp

@ -16,7 +16,7 @@ void title_Free()
ArtLogos[LOGO_BIG].data = NULL; ArtLogos[LOGO_BIG].data = NULL;
} }
BOOL __stdcall UiTitleDialog(int a1) BOOL UiTitleDialog(int a1)
{ {
UI_Item TITLESCREEN_DIALOG[] = { UI_Item TITLESCREEN_DIALOG[] = {
{ { 0, 0, 640, 480 }, UI_IMAGE, 0, 0, NULL, &ArtBackground }, { { 0, 0, 640, 480 }, UI_IMAGE, 0, 0, NULL, &ArtBackground },

2
SourceX/dvlnet/abstract_net.h

@ -9,7 +9,7 @@
namespace dvl { namespace net { namespace dvl { namespace net {
typedef std::vector<unsigned char> buffer_t; typedef std::vector<unsigned char> buffer_t;
typedef void(__stdcall *snet_event_func)(struct _SNETEVENT*); typedef void(*snet_event_func)(struct _SNETEVENT*);
typedef unsigned long provider_t; typedef unsigned long provider_t;
class dvlnet_exception : public std::exception {}; class dvlnet_exception : public std::exception {};

5
SourceX/dvlnet/tcp_client.cpp

@ -1,12 +1,11 @@
#include "dvlnet/tcp_client.h" #include "dvlnet/tcp_client.h"
#include <functional> #include <functional>
#include <thread>
#include <chrono>
#include <exception> #include <exception>
#include <system_error> #include <system_error>
#include <stdexcept> #include <stdexcept>
#include <sodium.h> #include <sodium.h>
#include <SDL.h>
namespace dvl { namespace net { namespace dvl { namespace net {
@ -51,7 +50,7 @@ int tcp_client::join(std::string addrstr, std::string passwd)
} }
if (plr_self != PLR_BROADCAST) if (plr_self != PLR_BROADCAST)
break; // join successful break; // join successful
std::this_thread::sleep_for(std::chrono::milliseconds(ms_sleep)); SDL_Delay(ms_sleep);
} }
} }
return (plr_self == PLR_BROADCAST ? -1 : plr_self); return (plr_self == PLR_BROADCAST ? -1 : plr_self);

20
SourceX/dx.cpp

@ -35,7 +35,7 @@ bool surface_dirty;
// DirectDraw COM interface stub implementations // DirectDraw COM interface stub implementations
// //
#define METHOD virtual __stdcall #define METHOD virtual
class StubSurface : public IDirectDrawSurface { class StubSurface : public IDirectDrawSurface {
METHOD HRESULT QueryInterface(DVL_REFIID refiid, LPVOID *lpvoid) METHOD HRESULT QueryInterface(DVL_REFIID refiid, LPVOID *lpvoid)
@ -358,7 +358,7 @@ static StubPalette stub_palette;
// Main functions // Main functions
// //
void __fastcall dx_init(HWND hWnd) void dx_init(HWND hWnd)
{ {
DUMMY(); DUMMY();
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_PRESENTVSYNC); renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_PRESENTVSYNC);
@ -415,7 +415,7 @@ void __fastcall dx_init(HWND hWnd)
palette_init(); palette_init();
} }
void __cdecl dx_cleanup() void dx_cleanup()
{ {
DUMMY(); DUMMY();
} }
@ -449,12 +449,12 @@ void sdl_present_surface()
surface_dirty = false; surface_dirty = false;
} }
void __fastcall j_lock_buf_priv(BYTE idx) void j_lock_buf_priv(BYTE idx)
{ {
j_unlock_buf_priv(idx); // what is idx? j_unlock_buf_priv(idx); // what is idx?
} }
void __fastcall j_unlock_buf_priv(BYTE idx) void j_unlock_buf_priv(BYTE idx)
{ {
gpBufEnd -= (uintptr_t)gpBufEnd; gpBufEnd -= (uintptr_t)gpBufEnd;
@ -465,7 +465,7 @@ void __fastcall j_unlock_buf_priv(BYTE idx)
sdl_present_surface(); sdl_present_surface();
} }
void __cdecl dx_reinit() void dx_reinit()
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
@ -474,7 +474,7 @@ void __cdecl dx_reinit()
// Storm functions // Storm functions
// //
BOOL STORMAPI SDrawUpdatePalette(unsigned int firstentry, unsigned int numentries, PALETTEENTRY *pPalEntries, int a4) BOOL SDrawUpdatePalette(unsigned int firstentry, unsigned int numentries, PALETTEENTRY *pPalEntries, int a4)
{ {
assert(firstentry == 0); assert(firstentry == 0);
assert(numentries == 256); assert(numentries == 256);
@ -507,7 +507,7 @@ BOOL STORMAPI SDrawUpdatePalette(unsigned int firstentry, unsigned int numentrie
// Windows API functions // Windows API functions
// //
WINBOOL WINAPI SetCursorPos(int X, int Y) WINBOOL SetCursorPos(int X, int Y)
{ {
assert(renderer); assert(renderer);
assert(window); assert(window);
@ -526,14 +526,14 @@ WINBOOL WINAPI SetCursorPos(int X, int Y)
return TRUE; return TRUE;
} }
int WINAPI ShowCursor(WINBOOL bShow) int ShowCursor(WINBOOL bShow)
{ {
SDL_ShowCursor(bShow ? SDL_ENABLE : SDL_DISABLE); SDL_ShowCursor(bShow ? SDL_ENABLE : SDL_DISABLE);
return bShow; return bShow;
} }
WINBOOL WINAPI TextOutA(HDC hdc, int x, int y, LPCSTR lpString, int c) WINBOOL TextOutA(HDC hdc, int x, int y, LPCSTR lpString, int c)
{ {
DUMMY_ONCE(); DUMMY_ONCE();

92
SourceX/miniwin.cpp

@ -7,17 +7,17 @@ namespace dvl {
DWORD last_error; DWORD last_error;
DWORD WINAPI GetLastError() DWORD GetLastError()
{ {
return last_error; return last_error;
} }
void WINAPI SetLastError(DWORD dwErrCode) void SetLastError(DWORD dwErrCode)
{ {
last_error = dwErrCode; last_error = dwErrCode;
} }
char __cdecl *_strlwr(char *str) char *_strlwr(char *str)
{ {
for (char *p = str; *p; ++p) { for (char *p = str; *p; ++p) {
*p = tolower(*p); *p = tolower(*p);
@ -25,24 +25,24 @@ char __cdecl *_strlwr(char *str)
return str; return str;
} }
int WINAPIV wsprintfA(LPSTR dest, LPCSTR format, ...) int wsprintfA(LPSTR dest, LPCSTR format, ...)
{ {
va_list args; va_list args;
va_start(args, format); va_start(args, format);
return vsprintf(dest, format, args); return vsprintf(dest, format, args);
} }
int WINAPIV wvsprintfA(LPSTR dest, LPCSTR format, va_list arglist) int wvsprintfA(LPSTR dest, LPCSTR format, va_list arglist)
{ {
return vsnprintf(dest, 256, format, arglist); return vsnprintf(dest, 256, format, arglist);
} }
int __cdecl _strcmpi(const char *_Str1, const char *_Str2) int _strcmpi(const char *_Str1, const char *_Str2)
{ {
return strcasecmp(_Str1, _Str2); return strcasecmp(_Str1, _Str2);
} }
char *__cdecl _itoa(int _Value, char *_Dest, int _Radix) char *_itoa(int _Value, char *_Dest, int _Radix)
{ {
switch (_Radix) { switch (_Radix) {
case 8: case 8:
@ -62,23 +62,23 @@ char *__cdecl _itoa(int _Value, char *_Dest, int _Radix)
return _Dest; return _Dest;
} }
DWORD WINAPI GetTickCount() DWORD GetTickCount()
{ {
return SDL_GetTicks(); return SDL_GetTicks();
} }
void WINAPI Sleep(DWORD dwMilliseconds) void Sleep(DWORD dwMilliseconds)
{ {
usleep(dwMilliseconds * 1000); usleep(dwMilliseconds * 1000);
} }
HANDLE WINAPI FindFirstFileA(LPCSTR lpFileName, LPWIN32_FIND_DATAA lpFindFileData) HANDLE FindFirstFileA(LPCSTR lpFileName, LPWIN32_FIND_DATAA lpFindFileData)
{ {
DUMMY(); DUMMY();
return (HANDLE)-1; return (HANDLE)-1;
} }
WINBOOL WINAPI FindClose(HANDLE hFindFile) WINBOOL FindClose(HANDLE hFindFile)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
@ -86,7 +86,7 @@ WINBOOL WINAPI FindClose(HANDLE hFindFile)
/** /**
* @brief Normally this would get the Windows install, but Diablo uses it to find the old save game folder * @brief Normally this would get the Windows install, but Diablo uses it to find the old save game folder
*/ */
UINT WINAPI GetWindowsDirectoryA(LPSTR lpBuffer, UINT uSize) UINT GetWindowsDirectoryA(LPSTR lpBuffer, UINT uSize)
{ {
char *name = SDL_GetPrefPath("diasurgical", "devilution"); char *name = SDL_GetPrefPath("diasurgical", "devilution");
strncpy(lpBuffer, name, uSize); strncpy(lpBuffer, name, uSize);
@ -99,7 +99,7 @@ UINT WINAPI GetWindowsDirectoryA(LPSTR lpBuffer, UINT uSize)
return len - 1; return len - 1;
} }
WINBOOL WINAPI GetDiskFreeSpaceA(LPCSTR lpRootPathName, LPDWORD lpSectorsPerCluster, LPDWORD lpBytesPerSector, WINBOOL GetDiskFreeSpaceA(LPCSTR lpRootPathName, LPDWORD lpSectorsPerCluster, LPDWORD lpBytesPerSector,
LPDWORD lpNumberOfFreeClusters, LPDWORD lpTotalNumberOfClusters) LPDWORD lpNumberOfFreeClusters, LPDWORD lpTotalNumberOfClusters)
{ {
#ifndef _WIN32 #ifndef _WIN32
@ -126,7 +126,7 @@ WINBOOL WINAPI GetDiskFreeSpaceA(LPCSTR lpRootPathName, LPDWORD lpSectorsPerClus
/** /**
* @brief Used for getting save path, by removing up to and including the last "\" * @brief Used for getting save path, by removing up to and including the last "\"
*/ */
DWORD WINAPI GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize) DWORD GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize)
{ {
char *name = SDL_GetPrefPath("diasurgical", "devilution"); char *name = SDL_GetPrefPath("diasurgical", "devilution");
strncpy(lpFilename, name, nSize); strncpy(lpFilename, name, nSize);
@ -139,7 +139,7 @@ DWORD WINAPI GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize)
return len; return len;
} }
WINBOOL WINAPI GetComputerNameA(LPSTR lpBuffer, LPDWORD nSize) WINBOOL GetComputerNameA(LPSTR lpBuffer, LPDWORD nSize)
{ {
DUMMY(); DUMMY();
strncpy(lpBuffer, "localhost", *nSize); strncpy(lpBuffer, "localhost", *nSize);
@ -210,61 +210,61 @@ UINT GetDriveTypeA(LPCSTR lpRootPathName)
return DVL_DRIVE_CDROM; return DVL_DRIVE_CDROM;
} }
WINBOOL WINAPI DeleteFileA(LPCSTR lpFileName) WINBOOL DeleteFileA(LPCSTR lpFileName)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
WINBOOL WINAPI CopyFileA(LPCSTR lpExistingFileName, LPCSTR lpNewFileName, WINBOOL bFailIfExists) WINBOOL CopyFileA(LPCSTR lpExistingFileName, LPCSTR lpNewFileName, WINBOOL bFailIfExists)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
HFILE WINAPI OpenFile(LPCSTR lpFileName, LPOFSTRUCT lpReOpenBuff, UINT uStyle) HFILE OpenFile(LPCSTR lpFileName, LPOFSTRUCT lpReOpenBuff, UINT uStyle)
{ {
DUMMY(); DUMMY();
return DVL_HFILE_ERROR; return DVL_HFILE_ERROR;
} }
HWND WINAPI SetCapture(HWND hWnd) HWND SetCapture(HWND hWnd)
{ {
DUMMY_ONCE(); DUMMY_ONCE();
return hWnd; return hWnd;
} }
WINBOOL WINAPI ReleaseCapture() WINBOOL ReleaseCapture()
{ {
DUMMY_ONCE(); DUMMY_ONCE();
return TRUE; return TRUE;
} }
WINBOOL WINAPI DestroyWindow(HWND hWnd) WINBOOL DestroyWindow(HWND hWnd)
{ {
DUMMY(); DUMMY();
return TRUE; return TRUE;
} }
HWND WINAPI GetLastActivePopup(HWND hWnd) HWND GetLastActivePopup(HWND hWnd)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
HWND WINAPI GetTopWindow(HWND hWnd) HWND GetTopWindow(HWND hWnd)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
WINBOOL WINAPI SetForegroundWindow(HWND hWnd) WINBOOL SetForegroundWindow(HWND hWnd)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
HWND WINAPI SetFocus(HWND hWnd) HWND SetFocus(HWND hWnd)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
HWND WINAPI FindWindowA(LPCSTR lpClassName, LPCSTR lpWindowName) HWND FindWindowA(LPCSTR lpClassName, LPCSTR lpWindowName)
{ {
DUMMY_PRINT("class: %s window: %s", nullstr(lpClassName), nullstr(lpWindowName)); DUMMY_PRINT("class: %s window: %s", nullstr(lpClassName), nullstr(lpWindowName));
return NULL; return NULL;
@ -331,7 +331,7 @@ BOOL ShowWindow(HWND hWnd, int nCmdShow)
return TRUE; return TRUE;
} }
WINUSERAPI ATOM WINAPI RegisterClassExA(const WNDCLASSEXA *lpwcx) ATOM RegisterClassExA(const WNDCLASSEXA *lpwcx)
{ {
DUMMY(); DUMMY();
return 1; return 1;
@ -419,13 +419,13 @@ void GetLocalTime(LPSYSTEMTIME lpSystemTime)
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
long __cdecl _findfirst(const char *, struct _finddata_t *) long _findfirst(const char *, struct _finddata_t *)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
return -1; return -1;
} }
int __cdecl _findnext(long, struct _finddata_t *) int _findnext(long, struct _finddata_t *)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
return -1; return -1;
@ -434,12 +434,12 @@ int __cdecl _findnext(long, struct _finddata_t *)
/** /**
* @brief Used to shutdown a MS Office 95 tool bar * @brief Used to shutdown a MS Office 95 tool bar
*/ */
HWND WINAPI GetForegroundWindow() HWND GetForegroundWindow()
{ {
return NULL; return NULL;
} }
LPTOP_LEVEL_EXCEPTION_FILTER WINAPI SetUnhandledExceptionFilter(LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter) LPTOP_LEVEL_EXCEPTION_FILTER SetUnhandledExceptionFilter(LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter)
{ {
DUMMY(); DUMMY();
return lpTopLevelExceptionFilter; return lpTopLevelExceptionFilter;
@ -505,26 +505,26 @@ BOOL FindNextFileA(HANDLE hFindFile, LPWIN32_FIND_DATAA lpFindFileData)
return FALSE; return FALSE;
} }
void WINAPI GetSystemInfo(LPSYSTEM_INFO lpSystemInfo) void GetSystemInfo(LPSYSTEM_INFO lpSystemInfo)
{ {
DUMMY(); DUMMY();
memset(lpSystemInfo, 0, sizeof(*lpSystemInfo)); memset(lpSystemInfo, 0, sizeof(*lpSystemInfo));
lpSystemInfo->dwPageSize = 4096; lpSystemInfo->dwPageSize = 4096;
} }
HDC WINAPI GetDC(HWND hWnd) HDC GetDC(HWND hWnd)
{ {
DUMMY(); DUMMY();
return NULL; return NULL;
} }
int WINAPI ReleaseDC(HWND hWnd, HDC hDC) int ReleaseDC(HWND hWnd, HDC hDC)
{ {
DUMMY(); DUMMY();
return 0; return 0;
} }
int WINAPI GetDeviceCaps(HDC hdc, int index) int GetDeviceCaps(HDC hdc, int index)
{ {
SDL_DisplayMode current; SDL_DisplayMode current;
@ -557,7 +557,7 @@ BOOL GetWindowRect(HWND hDlg, tagRECT *Rect)
return TRUE; return TRUE;
} }
UINT WINAPI GetSystemPaletteEntries(HDC hdc, UINT iStart, UINT cEntries, LPPALETTEENTRY pPalEntries) UINT GetSystemPaletteEntries(HDC hdc, UINT iStart, UINT cEntries, LPPALETTEENTRY pPalEntries)
{ {
DUMMY(); DUMMY();
return 0; return 0;
@ -576,7 +576,7 @@ void lstrcpynA(LPSTR lpString1, LPCSTR lpString2, int iMaxLength)
strncpy(lpString1, lpString2, iMaxLength); strncpy(lpString1, lpString2, iMaxLength);
} }
WINBOOL WINAPI CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, WINBOOL CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes, WINBOOL bInheritHandles, DWORD dwCreationFlags, LPSECURITY_ATTRIBUTES lpThreadAttributes, WINBOOL bInheritHandles, DWORD dwCreationFlags,
LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo,
LPPROCESS_INFORMATION lpProcessInformation) LPPROCESS_INFORMATION lpProcessInformation)
@ -585,18 +585,18 @@ WINBOOL WINAPI CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPS
return FALSE; return FALSE;
} }
void WINAPI ExitProcess(UINT uExitCode) void ExitProcess(UINT uExitCode)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
DWORD WINAPI GetCurrentProcessId() DWORD GetCurrentProcessId()
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
return 0; return 0;
} }
HANDLE WINAPI CreateFileMappingA(HANDLE hFile, LPSECURITY_ATTRIBUTES lpFileMappingAttributes, DWORD flProtect, HANDLE CreateFileMappingA(HANDLE hFile, LPSECURITY_ATTRIBUTES lpFileMappingAttributes, DWORD flProtect,
DWORD dwMaximumSizeHigh, DWORD dwMaximumSizeLow, LPCSTR lpName) DWORD dwMaximumSizeHigh, DWORD dwMaximumSizeLow, LPCSTR lpName)
{ {
DUMMY(); DUMMY();
@ -604,33 +604,33 @@ HANDLE WINAPI CreateFileMappingA(HANDLE hFile, LPSECURITY_ATTRIBUTES lpFileMappi
return NULL; return NULL;
} }
LPVOID WINAPI MapViewOfFile(HANDLE hFileMappingObject, DWORD dwDesiredAccess, DWORD dwFileOffsetHigh, LPVOID MapViewOfFile(HANDLE hFileMappingObject, DWORD dwDesiredAccess, DWORD dwFileOffsetHigh,
DWORD dwFileOffsetLow, SIZE_T dwNumberOfBytesToMap) DWORD dwFileOffsetLow, SIZE_T dwNumberOfBytesToMap)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
WINBOOL WINAPI UnmapViewOfFile(LPCVOID lpBaseAddress) WINBOOL UnmapViewOfFile(LPCVOID lpBaseAddress)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
DWORD WINAPI WaitForInputIdle(HANDLE hProcess, DWORD dwMilliseconds) DWORD WaitForInputIdle(HANDLE hProcess, DWORD dwMilliseconds)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
HWND WINAPI GetWindow(HWND hWnd, UINT uCmd) HWND GetWindow(HWND hWnd, UINT uCmd)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
DWORD WINAPI GetWindowThreadProcessId(HWND hWnd, LPDWORD lpdwProcessId) DWORD GetWindowThreadProcessId(HWND hWnd, LPDWORD lpdwProcessId)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
DWORD WINAPI GetPrivateProfileStringA(LPCSTR lpAppName, LPCSTR lpKeyName, LPCSTR lpDefault, LPSTR lpReturnedString, DWORD GetPrivateProfileStringA(LPCSTR lpAppName, LPCSTR lpKeyName, LPCSTR lpDefault, LPSTR lpReturnedString,
DWORD nSize, LPCSTR lpFileName) DWORD nSize, LPCSTR lpFileName)
{ {
if (!SRegLoadString(lpAppName, lpKeyName, 0, lpReturnedString, nSize)) { if (!SRegLoadString(lpAppName, lpKeyName, 0, lpReturnedString, nSize)) {

18
SourceX/miniwin_io.cpp

@ -15,7 +15,7 @@ extern "C" void TranslateFileName(char *dst, int dstLen, const char *src)
static std::set<HANDLE> files; static std::set<HANDLE> files;
HANDLE WINAPI CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, HANDLE CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition,
DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
{ {
@ -41,7 +41,7 @@ HANDLE WINAPI CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShar
return fd; return fd;
} }
WINBOOL WINAPI ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, WINBOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead,
LPOVERLAPPED lpOverlapped) LPOVERLAPPED lpOverlapped)
{ {
DUMMY_ONCE(); DUMMY_ONCE();
@ -53,7 +53,7 @@ WINBOOL WINAPI ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRea
return TRUE; return TRUE;
} }
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh) DWORD GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
{ {
DUMMY_ONCE(); DUMMY_ONCE();
@ -64,7 +64,7 @@ DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
return s.st_size; return s.st_size;
} }
WINBOOL WINAPI WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, WINBOOL WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten,
LPOVERLAPPED lpOverlapped) LPOVERLAPPED lpOverlapped)
{ {
DUMMY_ONCE(); DUMMY_ONCE();
@ -79,7 +79,7 @@ WINBOOL WINAPI WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToW
return TRUE; return TRUE;
} }
DWORD WINAPI SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod) DWORD SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod)
{ {
DUMMY_ONCE(); DUMMY_ONCE();
@ -96,7 +96,7 @@ DWORD WINAPI SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistance
return (DWORD)ret; return (DWORD)ret;
} }
WINBOOL WINAPI SetEndOfFile(HANDLE hFile) WINBOOL SetEndOfFile(HANDLE hFile)
{ {
DUMMY_ONCE(); DUMMY_ONCE();
@ -107,7 +107,7 @@ WINBOOL WINAPI SetEndOfFile(HANDLE hFile)
return TRUE; return TRUE;
} }
DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName) DWORD GetFileAttributesA(LPCSTR lpFileName)
{ {
char name[260]; char name[260];
TranslateFileName(name, sizeof(name), lpFileName); TranslateFileName(name, sizeof(name), lpFileName);
@ -125,13 +125,13 @@ DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName)
return 0x80; return 0x80;
} }
WINBOOL WINAPI SetFileAttributesA(LPCSTR lpFileName, DWORD dwFileAttributes) WINBOOL SetFileAttributesA(LPCSTR lpFileName, DWORD dwFileAttributes)
{ {
DUMMY_PRINT("file: %s", lpFileName); DUMMY_PRINT("file: %s", lpFileName);
return TRUE; return TRUE;
} }
WINBOOL WINAPI CloseHandle(HANDLE hObject) WINBOOL CloseHandle(HANDLE hObject)
{ {
if (files.find(hObject) != files.end()) { if (files.find(hObject) != files.end()) {
int ret = close((intptr_t)hObject); int ret = close((intptr_t)hObject);

10
SourceX/miniwin_msg_sdl.cpp

@ -97,7 +97,7 @@ static WINBOOL false_avail()
return FALSE; return FALSE;
} }
WINBOOL WINAPI PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg) WINBOOL PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg)
{ {
if (wMsgFilterMin != 0) if (wMsgFilterMin != 0)
UNIMPLEMENTED(); UNIMPLEMENTED();
@ -192,7 +192,7 @@ WINBOOL WINAPI PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMs
return TRUE; return TRUE;
} }
WINBOOL WINAPI TranslateMessage(CONST MSG *lpMsg) WINBOOL TranslateMessage(CONST MSG *lpMsg)
{ {
assert(lpMsg->hwnd == 0); assert(lpMsg->hwnd == 0);
if (lpMsg->message == WM_KEYDOWN) { if (lpMsg->message == WM_KEYDOWN) {
@ -267,14 +267,14 @@ WINBOOL WINAPI TranslateMessage(CONST MSG *lpMsg)
return TRUE; return TRUE;
} }
SHORT WINAPI GetAsyncKeyState(int vKey) SHORT GetAsyncKeyState(int vKey)
{ {
DUMMY_ONCE(); DUMMY_ONCE();
// TODO: Not handled yet. // TODO: Not handled yet.
return 0; return 0;
} }
LRESULT WINAPI DispatchMessageA(CONST MSG *lpMsg) LRESULT DispatchMessageA(CONST MSG *lpMsg)
{ {
DUMMY_ONCE(); DUMMY_ONCE();
assert(lpMsg->hwnd == 0); assert(lpMsg->hwnd == 0);
@ -284,7 +284,7 @@ LRESULT WINAPI DispatchMessageA(CONST MSG *lpMsg)
return CurrentProc(lpMsg->hwnd, lpMsg->message, lpMsg->wParam, lpMsg->lParam); return CurrentProc(lpMsg->hwnd, lpMsg->message, lpMsg->wParam, lpMsg->lParam);
} }
WINBOOL WINAPI PostMessageA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) WINBOOL PostMessageA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{ {
DUMMY(); DUMMY();

24
SourceX/miniwin_thread.cpp

@ -10,7 +10,7 @@ struct event_emul {
SDL_cond *cond; SDL_cond *cond;
}; };
uintptr_t __cdecl _beginthreadex(void *_Security, unsigned _StackSize, unsigned(__stdcall *_StartAddress)(void *), uintptr_t _beginthreadex(void *_Security, unsigned _StackSize, unsigned(*_StartAddress)(void *),
void *_ArgList, unsigned _InitFlag, unsigned *_ThrdAddr) void *_ArgList, unsigned _InitFlag, unsigned *_ThrdAddr)
{ {
if (_Security != NULL) if (_Security != NULL)
@ -26,47 +26,47 @@ uintptr_t __cdecl _beginthreadex(void *_Security, unsigned _StackSize, unsigned(
return (uintptr_t)ret; return (uintptr_t)ret;
} }
DWORD WINAPI GetCurrentThreadId() DWORD GetCurrentThreadId()
{ {
// DWORD is compatible with SDL_threadID // DWORD is compatible with SDL_threadID
return SDL_GetThreadID(NULL); return SDL_GetThreadID(NULL);
} }
HANDLE WINAPI GetCurrentThread() HANDLE GetCurrentThread()
{ {
// Only used for SetThreadPriority, which is unimplemented // Only used for SetThreadPriority, which is unimplemented
return NULL; return NULL;
} }
WINBOOL WINAPI SetThreadPriority(HANDLE hThread, int nPriority) WINBOOL SetThreadPriority(HANDLE hThread, int nPriority)
{ {
// SDL cannot set the priority of the non-current thread // SDL cannot set the priority of the non-current thread
// (and e.g. unprivileged processes on Linux cannot increase it) // (and e.g. unprivileged processes on Linux cannot increase it)
return TRUE; return TRUE;
} }
void WINAPI InitializeCriticalSection(LPCRITICAL_SECTION lpCriticalSection) void InitializeCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
{ {
SDL_mutex *m = SDL_CreateMutex(); SDL_mutex *m = SDL_CreateMutex();
*lpCriticalSection = m; *lpCriticalSection = m;
} }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection) void EnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
{ {
SDL_LockMutex(*((SDL_mutex **)lpCriticalSection)); SDL_LockMutex(*((SDL_mutex **)lpCriticalSection));
} }
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection) void LeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
{ {
SDL_UnlockMutex(*((SDL_mutex **)lpCriticalSection)); SDL_UnlockMutex(*((SDL_mutex **)lpCriticalSection));
} }
void WINAPI DeleteCriticalSection(LPCRITICAL_SECTION lpCriticalSection) void DeleteCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
{ {
SDL_DestroyMutex(*((SDL_mutex **)lpCriticalSection)); SDL_DestroyMutex(*((SDL_mutex **)lpCriticalSection));
} }
HANDLE WINAPI CreateEventA(LPSECURITY_ATTRIBUTES lpEventAttributes, WINBOOL bManualReset, WINBOOL bInitialState, HANDLE CreateEventA(LPSECURITY_ATTRIBUTES lpEventAttributes, WINBOOL bManualReset, WINBOOL bInitialState,
LPCSTR lpName) LPCSTR lpName)
{ {
if (lpName != NULL && !strcmp(lpName, "DiabloEvent")) { if (lpName != NULL && !strcmp(lpName, "DiabloEvent")) {
@ -91,7 +91,7 @@ HANDLE WINAPI CreateEventA(LPSECURITY_ATTRIBUTES lpEventAttributes, WINBOOL bMan
return ret; return ret;
} }
BOOL WINAPI SetEvent(HANDLE hEvent) BOOL SetEvent(HANDLE hEvent)
{ {
struct event_emul *e = (struct event_emul *)hEvent; struct event_emul *e = (struct event_emul *)hEvent;
SDL_LockMutex(e->mutex); SDL_LockMutex(e->mutex);
@ -100,7 +100,7 @@ BOOL WINAPI SetEvent(HANDLE hEvent)
return 1; return 1;
} }
BOOL WINAPI ResetEvent(HANDLE hEvent) BOOL ResetEvent(HANDLE hEvent)
{ {
struct event_emul *e = (struct event_emul *)hEvent; struct event_emul *e = (struct event_emul *)hEvent;
SDL_LockMutex(e->mutex); SDL_LockMutex(e->mutex);
@ -132,7 +132,7 @@ static DWORD wait_for_sdl_thread(HANDLE hHandle, DWORD dwMilliseconds)
return 0; return 0;
} }
DWORD WINAPI WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds) DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds)
{ {
// return value different from WinAPI // return value different from WinAPI
if (threads.find((uintptr_t)hHandle) != threads.end()) if (threads.find((uintptr_t)hHandle) != threads.end())

42
SourceX/sound.cpp

@ -35,7 +35,7 @@ char unk_volume[4][2] = {
{ 30, -31 } { 30, -31 }
}; };
void __fastcall snd_update(BOOL bStopAll) void snd_update(BOOL bStopAll)
{ {
DWORD error_code, i; DWORD error_code, i;
@ -45,14 +45,14 @@ void __fastcall snd_update(BOOL bStopAll)
Mix_HaltChannel(-1); Mix_HaltChannel(-1);
} }
void __fastcall snd_stop_snd(TSnd *pSnd) void snd_stop_snd(TSnd *pSnd)
{ {
DUMMY_ONCE(); DUMMY_ONCE();
if (pSnd && pSnd->DSB) if (pSnd && pSnd->DSB)
Mix_HaltChannel(-1); Mix_HaltChannel(-1);
} }
BOOL __fastcall snd_playing(TSnd *pSnd) BOOL snd_playing(TSnd *pSnd)
{ {
DWORD error_code; // TODO should probably be HRESULT DWORD error_code; // TODO should probably be HRESULT
@ -67,7 +67,7 @@ BOOL __fastcall snd_playing(TSnd *pSnd)
return FALSE; return FALSE;
} }
void __fastcall snd_play_snd(TSnd *pSnd, int lVolume, int lPan) void snd_play_snd(TSnd *pSnd, int lVolume, int lPan)
{ {
LPDIRECTSOUNDBUFFER DSB; LPDIRECTSOUNDBUFFER DSB;
DWORD tc; DWORD tc;
@ -111,7 +111,7 @@ void __fastcall snd_play_snd(TSnd *pSnd, int lVolume, int lPan)
pSnd->start_tc = tc; pSnd->start_tc = tc;
} }
LPDIRECTSOUNDBUFFER __fastcall sound_dup_channel(LPDIRECTSOUNDBUFFER DSB) LPDIRECTSOUNDBUFFER sound_dup_channel(LPDIRECTSOUNDBUFFER DSB)
{ {
DWORD i; DWORD i;
@ -126,7 +126,7 @@ LPDIRECTSOUNDBUFFER __fastcall sound_dup_channel(LPDIRECTSOUNDBUFFER DSB)
return NULL; return NULL;
} }
BOOL __fastcall sound_file_reload(TSnd *sound_file, LPDIRECTSOUNDBUFFER DSB) BOOL sound_file_reload(TSnd *sound_file, LPDIRECTSOUNDBUFFER DSB)
{ {
HANDLE file; HANDLE file;
LPVOID buf1, buf2; LPVOID buf1, buf2;
@ -145,7 +145,7 @@ BOOL __fastcall sound_file_reload(TSnd *sound_file, LPDIRECTSOUNDBUFFER DSB)
return rv; return rv;
} }
TSnd *__fastcall sound_file_load(char *path) TSnd *sound_file_load(char *path)
{ {
HANDLE file; HANDLE file;
BYTE *wave_file; BYTE *wave_file;
@ -184,7 +184,7 @@ TSnd *__fastcall sound_file_load(char *path)
} }
// 456F07: could not find valid save-restore pair for esi // 456F07: could not find valid save-restore pair for esi
void __fastcall sound_CreateSoundBuffer(TSnd *sound_file) void sound_CreateSoundBuffer(TSnd *sound_file)
{ {
DUMMY_ONCE(); DUMMY_ONCE();
DSBUFFERDESC DSB; DSBUFFERDESC DSB;
@ -197,7 +197,7 @@ void __fastcall sound_CreateSoundBuffer(TSnd *sound_file)
DSB.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLPAN | DSBCAPS_STATIC; DSB.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLPAN | DSBCAPS_STATIC;
} }
void __fastcall sound_file_cleanup(TSnd *sound_file) void sound_file_cleanup(TSnd *sound_file)
{ {
if (sound_file) { if (sound_file) {
if (sound_file->DSB) { if (sound_file->DSB) {
@ -210,7 +210,7 @@ void __fastcall sound_file_cleanup(TSnd *sound_file)
} }
} }
void __fastcall snd_init(HWND hWnd) void snd_init(HWND hWnd)
{ {
DUMMY(); DUMMY();
sound_load_volume("Sound Volume", &sglSoundVolume); sound_load_volume("Sound Volume", &sglSoundVolume);
@ -231,7 +231,7 @@ void __fastcall snd_init(HWND hWnd)
gbSndInited = true; gbSndInited = true;
} }
void __fastcall sound_load_volume(char *value_name, int *value) void sound_load_volume(char *value_name, int *value)
{ {
int v = *value; int v = *value;
if (!SRegLoadValue("Diablo", value_name, 0, &v)) { if (!SRegLoadValue("Diablo", value_name, 0, &v)) {
@ -247,7 +247,7 @@ void __fastcall sound_load_volume(char *value_name, int *value)
*value -= *value % 100; *value -= *value % 100;
} }
void __fastcall sound_create_primary_buffer(HANDLE music_track) void sound_create_primary_buffer(HANDLE music_track)
{ {
DUMMY(); DUMMY();
HRESULT error_code; HRESULT error_code;
@ -301,10 +301,10 @@ void __fastcall sound_create_primary_buffer(HANDLE music_track)
} }
// 69F100: using guessed type int sglpDSB; // 69F100: using guessed type int sglpDSB;
HRESULT __fastcall sound_DirectSoundCreate(LPGUID lpGuid, LPDIRECTSOUND *ppDS, LPUNKNOWN pUnkOuter) HRESULT sound_DirectSoundCreate(LPGUID lpGuid, LPDIRECTSOUND *ppDS, LPUNKNOWN pUnkOuter)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
HRESULT(WINAPI * DirectSoundCreate) HRESULT(* DirectSoundCreate)
(LPGUID lpGuid, LPDIRECTSOUND * ppDS, LPUNKNOWN pUnkOuter); (LPGUID lpGuid, LPDIRECTSOUND * ppDS, LPUNKNOWN pUnkOuter);
if (hDsound_dll == NULL) { if (hDsound_dll == NULL) {
@ -319,7 +319,7 @@ HRESULT __fastcall sound_DirectSoundCreate(LPGUID lpGuid, LPDIRECTSOUND *ppDS, L
return DirectSoundCreate(lpGuid, ppDS, pUnkOuter); return DirectSoundCreate(lpGuid, ppDS, pUnkOuter);
} }
void __cdecl sound_cleanup() void sound_cleanup()
{ {
snd_update(TRUE); snd_update(TRUE);
SVidDestroy(); SVidDestroy();
@ -337,12 +337,12 @@ void __cdecl sound_cleanup()
} }
} }
void __fastcall sound_store_volume(char *key, int value) void sound_store_volume(char *key, int value)
{ {
SRegSaveValue("Diablo", key, 0, value); SRegSaveValue("Diablo", key, 0, value);
} }
void __cdecl music_stop() void music_stop()
{ {
if (sgpMusicTrack) { if (sgpMusicTrack) {
Mix_HaltMusic(); Mix_HaltMusic();
@ -352,7 +352,7 @@ void __cdecl music_stop()
} }
} }
void __fastcall music_start(int nTrack) void music_start(int nTrack)
{ {
BOOL success; BOOL success;
@ -384,7 +384,7 @@ void __fastcall music_start(int nTrack)
} }
} }
void __fastcall sound_disable_music(BOOL disable) void sound_disable_music(BOOL disable)
{ {
if (disable) { if (disable) {
music_stop(); music_stop();
@ -393,7 +393,7 @@ void __fastcall sound_disable_music(BOOL disable)
} }
} }
int __fastcall sound_get_or_set_music_volume(int volume) int sound_get_or_set_music_volume(int volume)
{ {
if (volume == 1) if (volume == 1)
return sglMusicVolume; return sglMusicVolume;
@ -406,7 +406,7 @@ int __fastcall sound_get_or_set_music_volume(int volume)
return sglMusicVolume; return sglMusicVolume;
} }
int __fastcall sound_get_or_set_sound_volume(int volume) int sound_get_or_set_sound_volume(int volume)
{ {
if (volume == 1) if (volume == 1)
return sglSoundVolume; return sglSoundVolume;

98
SourceX/storm.cpp

@ -18,17 +18,17 @@ std::string getIniPath()
radon::File ini(getIniPath()); radon::File ini(getIniPath());
// BOOL STORMAPI SFileCloseArchive(HANDLE hArchive) // BOOL SFileCloseArchive(HANDLE hArchive)
// { // {
// UNIMPLEMENTED(); // UNIMPLEMENTED();
// } // }
// BOOL STORMAPI SFileCloseFile(HANDLE hFile) // BOOL SFileCloseFile(HANDLE hFile)
// { // {
// UNIMPLEMENTED(); // UNIMPLEMENTED();
// } // }
BOOL STORMAPI SFileDdaBeginEx(HANDLE directsound, DWORD flags, DWORD mask, unsigned __int32 lDistanceToMove, BOOL SFileDdaBeginEx(HANDLE directsound, DWORD flags, DWORD mask, unsigned __int32 lDistanceToMove,
signed __int32 volume, signed int pan, int a7) signed __int32 volume, signed int pan, int a7)
{ {
DUMMY(); // Todo track when the sound can be released, see sfx_stop() DUMMY(); // Todo track when the sound can be released, see sfx_stop()
@ -48,54 +48,54 @@ BOOL STORMAPI SFileDdaBeginEx(HANDLE directsound, DWORD flags, DWORD mask, unsig
return 1; return 1;
} }
BOOL STORMAPI SFileDdaDestroy() BOOL SFileDdaDestroy()
{ {
DUMMY(); DUMMY();
return 0; return 0;
} }
BOOL STORMAPI SFileDdaEnd(HANDLE directsound) BOOL SFileDdaEnd(HANDLE directsound)
{ {
DUMMY(); DUMMY();
return 0; return 0;
} }
BOOL STORMAPI SFileDdaGetPos(HANDLE directsound, int a2, int a3) BOOL SFileDdaGetPos(HANDLE directsound, int a2, int a3)
{ {
DUMMY_ONCE(); DUMMY_ONCE();
return TRUE; return TRUE;
} }
BOOL STORMAPI SFileDdaInitialize(HANDLE directsound) BOOL SFileDdaInitialize(HANDLE directsound)
{ {
DUMMY(); DUMMY();
return 0; return 0;
} }
BOOL STORMAPI SFileDdaSetVolume(HANDLE directsound, signed int bigvolume, signed int volume) BOOL SFileDdaSetVolume(HANDLE directsound, signed int bigvolume, signed int volume)
{ {
Mix_VolumeMusic(MIX_MAX_VOLUME - MIX_MAX_VOLUME * bigvolume / VOLUME_MIN); Mix_VolumeMusic(MIX_MAX_VOLUME - MIX_MAX_VOLUME * bigvolume / VOLUME_MIN);
return TRUE; return TRUE;
} }
BOOL STORMAPI SFileGetFileArchive(HANDLE hFile, HANDLE *archive) BOOL SFileGetFileArchive(HANDLE hFile, HANDLE *archive)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
// LONG STORMAPI SFileGetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh) // LONG SFileGetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
// { // {
// UNIMPLEMENTED(); // UNIMPLEMENTED();
// } // }
// BOOL STORMAPI SFileOpenArchive(const char *szMpqName, DWORD dwPriority, DWORD dwFlags, HANDLE // BOOL SFileOpenArchive(const char *szMpqName, DWORD dwPriority, DWORD dwFlags, HANDLE
// *phMpq) // *phMpq)
// { // {
// UNIMPLEMENTED(); // UNIMPLEMENTED();
// } // }
BOOL STORMAPI SFileOpenFile(const char *filename, HANDLE *phFile) BOOL SFileOpenFile(const char *filename, HANDLE *phFile)
{ {
//eprintf("%s: %s\n", __FUNCTION__, filename); //eprintf("%s: %s\n", __FUNCTION__, filename);
@ -112,19 +112,19 @@ BOOL STORMAPI SFileOpenFile(const char *filename, HANDLE *phFile)
return result; return result;
} }
// BOOL STORMAPI SFileOpenFileEx(HANDLE hMpq, const char *szFileName, DWORD dwSearchScope, HANDLE // BOOL SFileOpenFileEx(HANDLE hMpq, const char *szFileName, DWORD dwSearchScope, HANDLE
// *phFile) // *phFile)
// { // {
// UNIMPLEMENTED(); // UNIMPLEMENTED();
// } // }
// BOOL STORMAPI SFileReadFile(HANDLE hFile, void *buffer, DWORD nNumberOfBytesToRead, DWORD *read, // BOOL SFileReadFile(HANDLE hFile, void *buffer, DWORD nNumberOfBytesToRead, DWORD *read,
// LONG lpDistanceToMoveHigh) // LONG lpDistanceToMoveHigh)
// { // {
// UNIMPLEMENTED(); // UNIMPLEMENTED();
// } // }
BOOL __stdcall SBmpLoadImage(const char *pszFileName, PALETTEENTRY *pPalette, BYTE *pBuffer, DWORD dwBuffersize, DWORD *pdwWidth, DWORD *dwHeight, DWORD *pdwBpp) BOOL SBmpLoadImage(const char *pszFileName, PALETTEENTRY *pPalette, BYTE *pBuffer, DWORD dwBuffersize, DWORD *pdwWidth, DWORD *dwHeight, DWORD *pdwBpp)
{ {
HANDLE hFile; HANDLE hFile;
size_t size; size_t size;
@ -232,32 +232,32 @@ BOOL __stdcall SBmpLoadImage(const char *pszFileName, PALETTEENTRY *pPalette, BY
return true; return true;
} }
// int __stdcall SFileSetFilePointer(HANDLE, int, HANDLE, int) // int SFileSetFilePointer(HANDLE, int, HANDLE, int)
// { // {
// UNIMPLEMENTED(); // UNIMPLEMENTED();
// } // }
HWND STORMAPI SDrawGetFrameWindow(HWND *sdraw_framewindow) HWND SDrawGetFrameWindow(HWND *sdraw_framewindow)
{ {
DUMMY(); DUMMY();
return NULL; return NULL;
} }
// BOOL STORMAPI SDrawManualInitialize(HWND hWnd, LPDIRECTDRAW ddInterface, LPDIRECTDRAWSURFACE // BOOL SDrawManualInitialize(HWND hWnd, LPDIRECTDRAW ddInterface, LPDIRECTDRAWSURFACE
// primarySurface, LPDIRECTDRAWSURFACE surface2, LPDIRECTDRAWSURFACE surface3, LPDIRECTDRAWSURFACE // primarySurface, LPDIRECTDRAWSURFACE surface2, LPDIRECTDRAWSURFACE surface3, LPDIRECTDRAWSURFACE
// backSurface, LPDIRECTDRAWPALETTE ddPalette, HPALETTE hPalette) // backSurface, LPDIRECTDRAWPALETTE ddPalette, HPALETTE hPalette)
//{ //{
// UNIMPLEMENTED(); // UNIMPLEMENTED();
//} //}
void *STORMAPI SMemAlloc(unsigned int amount, char *logfilename, int logline, char defaultValue) void *SMemAlloc(unsigned int amount, char *logfilename, int logline, char defaultValue)
{ {
// fprintf(stderr, "%s: %d (%s:%d)\n", __FUNCTION__, amount, logfilename, logline); // fprintf(stderr, "%s: %d (%s:%d)\n", __FUNCTION__, amount, logfilename, logline);
assert(amount != -1u); assert(amount != -1u);
return malloc(amount); return malloc(amount);
} }
BOOL STORMAPI SMemFree(void *location, char *logfilename, int logline, char defaultValue) BOOL SMemFree(void *location, char *logfilename, int logline, char defaultValue)
{ {
// fprintf(stderr, "%s: (%s:%d)\n", __FUNCTION__, logfilename, logline); // fprintf(stderr, "%s: (%s:%d)\n", __FUNCTION__, logfilename, logline);
assert(location); assert(location);
@ -265,7 +265,7 @@ BOOL STORMAPI SMemFree(void *location, char *logfilename, int logline, char defa
return TRUE; return TRUE;
} }
void *STORMAPI SMemReAlloc(void *location, unsigned int amount, char *logfilename, int logline, char defaultValue) void *SMemReAlloc(void *location, unsigned int amount, char *logfilename, int logline, char defaultValue)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
@ -310,17 +310,17 @@ void setIniValue(const char *sectionName, const char *keyName, char *value, int
ini.saveToFile(); ini.saveToFile();
} }
BOOL STORMAPI SRegLoadData(const char *keyname, const char *valuename, int size, LPBYTE lpData, BYTE flags, LPDWORD lpcbData) BOOL SRegLoadData(const char *keyname, const char *valuename, int size, LPBYTE lpData, BYTE flags, LPDWORD lpcbData)
{ {
return getIniValue(keyname, valuename, (char *)lpData, size, (int *)lpcbData); return getIniValue(keyname, valuename, (char *)lpData, size, (int *)lpcbData);
} }
BOOL STORMAPI SRegLoadString(const char *keyname, const char *valuename, BYTE flags, char *buffer, unsigned int buffersize) BOOL SRegLoadString(const char *keyname, const char *valuename, BYTE flags, char *buffer, unsigned int buffersize)
{ {
return getIniValue(keyname, valuename, buffer, buffersize); return getIniValue(keyname, valuename, buffer, buffersize);
} }
BOOL STORMAPI SRegLoadValue(const char *keyname, const char *valuename, BYTE flags, int *value) BOOL SRegLoadValue(const char *keyname, const char *valuename, BYTE flags, int *value)
{ {
char string[10]; char string[10];
if (getIniValue(keyname, valuename, string, 10)) { if (getIniValue(keyname, valuename, string, 10)) {
@ -331,21 +331,21 @@ BOOL STORMAPI SRegLoadValue(const char *keyname, const char *valuename, BYTE fla
return FALSE; return FALSE;
} }
BOOL STORMAPI SRegSaveData(const char *keyname, const char *valuename, int size, BYTE *lpData, DWORD cbData) BOOL SRegSaveData(const char *keyname, const char *valuename, int size, BYTE *lpData, DWORD cbData)
{ {
setIniValue(keyname, valuename, (char *)lpData, cbData); setIniValue(keyname, valuename, (char *)lpData, cbData);
return TRUE; return TRUE;
} }
BOOL STORMAPI SRegSaveString(const char *keyname, const char *valuename, BYTE flags, char *string) BOOL SRegSaveString(const char *keyname, const char *valuename, BYTE flags, char *string)
{ {
setIniValue(keyname, valuename, string); setIniValue(keyname, valuename, string);
return TRUE; return TRUE;
} }
BOOL STORMAPI SRegSaveValue(const char *keyname, const char *valuename, BYTE flags, DWORD result) BOOL SRegSaveValue(const char *keyname, const char *valuename, BYTE flags, DWORD result)
{ {
char str[10]; char str[10];
sprintf(str, "%d", result); sprintf(str, "%d", result);
@ -354,13 +354,13 @@ BOOL STORMAPI SRegSaveValue(const char *keyname, const char *valuename, BYTE fla
return TRUE; return TRUE;
} }
BOOL STORMAPI SVidInitialize(HANDLE video) BOOL SVidInitialize(HANDLE video)
{ {
DUMMY(); DUMMY();
return TRUE; return TRUE;
} }
BOOL STORMAPI SVidDestroy() BOOL SVidDestroy()
{ {
DUMMY(); DUMMY();
return TRUE; return TRUE;
@ -376,7 +376,7 @@ SDL_Surface *SVidSurface;
BYTE *SVidBuffer; BYTE *SVidBuffer;
SDL_AudioDeviceID deviceId; SDL_AudioDeviceID deviceId;
BOOL STORMAPI SVidPlayBegin(char *filename, int a2, int a3, int a4, int a5, int flags, HANDLE *video) BOOL SVidPlayBegin(char *filename, int a2, int a3, int a4, int a5, int flags, HANDLE *video)
{ {
if (flags & 0x10000 || flags & 0x20000000) { if (flags & 0x10000 || flags & 0x20000000) {
return FALSE; return FALSE;
@ -471,7 +471,7 @@ BOOL SVidLoadNextFrame()
return TRUE; return TRUE;
} }
BOOL __cdecl SVidPlayContinue(void) BOOL SVidPlayContinue(void)
{ {
if (smk_palette_updated(SVidSMK)) { if (smk_palette_updated(SVidSMK)) {
SDL_Color colors[256]; SDL_Color colors[256];
@ -525,7 +525,7 @@ BOOL __cdecl SVidPlayContinue(void)
return SVidLoadNextFrame(); return SVidLoadNextFrame();
} }
BOOL STORMAPI SVidPlayEnd(HANDLE video) BOOL SVidPlayEnd(HANDLE video)
{ {
if (deviceId) { if (deviceId) {
SDL_ClearQueuedAudio(deviceId); SDL_ClearQueuedAudio(deviceId);
@ -555,92 +555,92 @@ BOOL STORMAPI SVidPlayEnd(HANDLE video)
return TRUE; return TRUE;
} }
BOOL STORMAPI SErrDisplayError(DWORD dwErrMsg, const char *logfilename, int logline, const char *message, BOOL SErrDisplayError(DWORD dwErrMsg, const char *logfilename, int logline, const char *message,
BOOL allowOption, int exitCode) BOOL allowOption, int exitCode)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
BOOL STORMAPI SErrGetErrorStr(DWORD dwErrCode, char *buffer, unsigned int bufferchars) BOOL SErrGetErrorStr(DWORD dwErrCode, char *buffer, unsigned int bufferchars)
{ {
DUMMY(); DUMMY();
return FALSE; return FALSE;
} }
DWORD STORMAPI SErrGetLastError() DWORD SErrGetLastError()
{ {
return nLastError; return nLastError;
} }
void STORMAPI SErrSetLastError(DWORD dwErrCode) void SErrSetLastError(DWORD dwErrCode)
{ {
nLastError = dwErrCode; nLastError = dwErrCode;
} }
void STORMAPI SMemCopy(void *dest, const void *source, unsigned int size) void SMemCopy(void *dest, const void *source, unsigned int size)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
void STORMAPI SMemFill(void *location, unsigned int length, char fillWith) void SMemFill(void *location, unsigned int length, char fillWith)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
void STORMAPI SMemZero(void *location, DWORD length) void SMemZero(void *location, DWORD length)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
int STORMAPI SMemCmp(void *location1, void *location2, DWORD size) int SMemCmp(void *location1, void *location2, DWORD size)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
int STORMAPI SStrCopy(char *dest, const char *src, int max_length) int SStrCopy(char *dest, const char *src, int max_length)
{ {
strncpy(dest, src, max_length); strncpy(dest, src, max_length);
return strlen(dest); return strlen(dest);
} }
int STORMAPI SStrCmp(const char *string1, const char *string2, unsigned int size) int SStrCmp(const char *string1, const char *string2, unsigned int size)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
int STORMAPI SStrCmpI(const char *string1, const char *string2, unsigned int size) int SStrCmpI(const char *string1, const char *string2, unsigned int size)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
void __stdcall SDrawMessageBox(char *Text, char *Title, int Flags) void SDrawMessageBox(char *Text, char *Title, int Flags)
{ {
MessageBoxA(NULL, Text, Title, Flags); MessageBoxA(NULL, Text, Title, Flags);
} }
// void __cdecl SDrawDestroy(void) // void SDrawDestroy(void)
//{ //{
// UNIMPLEMENTED(); // UNIMPLEMENTED();
//} //}
BOOLEAN __cdecl StormDestroy(void) BOOLEAN StormDestroy(void)
{ {
DUMMY(); DUMMY();
return TRUE; return TRUE;
} }
BOOLEAN __stdcall SFileSetBasePath(char *) BOOLEAN SFileSetBasePath(char *)
{ {
DUMMY(); DUMMY();
return TRUE; return TRUE;
} }
void __cdecl SDrawRealizePalette(void) void SDrawRealizePalette(void)
{ {
DUMMY(); DUMMY();
} }
BOOL __stdcall SFileEnableDirectAccess(BOOL enable) BOOL SFileEnableDirectAccess(BOOL enable)
{ {
DUMMY(); DUMMY();
return TRUE; return TRUE;

40
SourceX/storm_net.cpp

@ -5,7 +5,7 @@ namespace dvl {
static std::unique_ptr<net::abstract_net> dvlnet_inst; static std::unique_ptr<net::abstract_net> dvlnet_inst;
BOOL STORMAPI SNetReceiveMessage(int *senderplayerid, char **data, int *databytes) BOOL SNetReceiveMessage(int *senderplayerid, char **data, int *databytes)
{ {
if (!dvlnet_inst->SNetReceiveMessage(senderplayerid, data, databytes)) { if (!dvlnet_inst->SNetReceiveMessage(senderplayerid, data, databytes)) {
SErrSetLastError(STORM_ERROR_NO_MESSAGES_WAITING); SErrSetLastError(STORM_ERROR_NO_MESSAGES_WAITING);
@ -14,12 +14,12 @@ BOOL STORMAPI SNetReceiveMessage(int *senderplayerid, char **data, int *databyte
return TRUE; return TRUE;
} }
BOOL STORMAPI SNetSendMessage(int playerID, void *data, unsigned int databytes) BOOL SNetSendMessage(int playerID, void *data, unsigned int databytes)
{ {
return dvlnet_inst->SNetSendMessage(playerID, data, databytes); return dvlnet_inst->SNetSendMessage(playerID, data, databytes);
} }
BOOL STORMAPI SNetReceiveTurns(int a1, int arraysize, char **arraydata, unsigned int *arraydatabytes, BOOL SNetReceiveTurns(int a1, int arraysize, char **arraydata, unsigned int *arraydatabytes,
DWORD *arrayplayerstatus) DWORD *arrayplayerstatus)
{ {
if (a1 != 0) if (a1 != 0)
@ -33,49 +33,49 @@ BOOL STORMAPI SNetReceiveTurns(int a1, int arraysize, char **arraydata, unsigned
return TRUE; return TRUE;
} }
BOOL STORMAPI SNetSendTurn(char *data, unsigned int databytes) BOOL SNetSendTurn(char *data, unsigned int databytes)
{ {
return dvlnet_inst->SNetSendTurn(data, databytes); return dvlnet_inst->SNetSendTurn(data, databytes);
} }
int __stdcall SNetGetProviderCaps(struct _SNETCAPS *caps) int SNetGetProviderCaps(struct _SNETCAPS *caps)
{ {
return dvlnet_inst->SNetGetProviderCaps(caps); return dvlnet_inst->SNetGetProviderCaps(caps);
} }
void *__stdcall SNetUnregisterEventHandler(int evtype, void(__stdcall *func)(struct _SNETEVENT *)) void *SNetUnregisterEventHandler(int evtype, void(*func)(struct _SNETEVENT *))
{ {
return dvlnet_inst->SNetUnregisterEventHandler(*(event_type *)&evtype, func); return dvlnet_inst->SNetUnregisterEventHandler(*(event_type *)&evtype, func);
} }
void *__stdcall SNetRegisterEventHandler(int evtype, void(__stdcall *func)(struct _SNETEVENT *)) void *SNetRegisterEventHandler(int evtype, void(*func)(struct _SNETEVENT *))
{ {
return dvlnet_inst->SNetRegisterEventHandler(*(event_type *)&evtype, func); return dvlnet_inst->SNetRegisterEventHandler(*(event_type *)&evtype, func);
} }
BOOL STORMAPI SNetDestroy() BOOL SNetDestroy()
{ {
DUMMY(); DUMMY();
return TRUE; return TRUE;
} }
BOOL STORMAPI SNetDropPlayer(int playerid, DWORD flags) BOOL SNetDropPlayer(int playerid, DWORD flags)
{ {
return dvlnet_inst->SNetDropPlayer(playerid, flags); return dvlnet_inst->SNetDropPlayer(playerid, flags);
} }
BOOL STORMAPI SNetGetGameInfo(int type, void *dst, unsigned int length, unsigned int *byteswritten) BOOL SNetGetGameInfo(int type, void *dst, unsigned int length, unsigned int *byteswritten)
{ {
DUMMY(); DUMMY();
return TRUE; return TRUE;
} }
BOOL STORMAPI SNetLeaveGame(int type) BOOL SNetLeaveGame(int type)
{ {
return dvlnet_inst->SNetLeaveGame(type); return dvlnet_inst->SNetLeaveGame(type);
} }
BOOL STORMAPI SNetSendServerChatCommand(const char *command) BOOL SNetSendServerChatCommand(const char *command)
{ {
DUMMY(); DUMMY();
return TRUE; return TRUE;
@ -86,7 +86,7 @@ BOOL STORMAPI SNetSendServerChatCommand(const char *command)
* @param provider BNET, IPXN, MODM, SCBL or UDPN * @param provider BNET, IPXN, MODM, SCBL or UDPN
* @param fileinfo Ignore * @param fileinfo Ignore
*/ */
int __stdcall SNetInitializeProvider(unsigned long provider, struct _SNETPROGRAMDATA *client_info, int SNetInitializeProvider(unsigned long provider, struct _SNETPROGRAMDATA *client_info,
struct _SNETPLAYERDATA *user_info, struct _SNETUIDATA *ui_info, struct _SNETPLAYERDATA *user_info, struct _SNETUIDATA *ui_info,
struct _SNETVERSIONDATA *fileinfo) struct _SNETVERSIONDATA *fileinfo)
{ {
@ -97,7 +97,7 @@ int __stdcall SNetInitializeProvider(unsigned long provider, struct _SNETPROGRAM
/** /**
* @brief Called by engine for single, called by ui for multi * @brief Called by engine for single, called by ui for multi
*/ */
BOOL STORMAPI SNetCreateGame(const char *pszGameName, const char *pszGamePassword, const char *pszGameStatString, BOOL SNetCreateGame(const char *pszGameName, const char *pszGamePassword, const char *pszGameStatString,
DWORD dwGameType, char *GameTemplateData, int GameTemplateSize, int playerCount, DWORD dwGameType, char *GameTemplateData, int GameTemplateSize, int playerCount,
char *creatorName, char *a11, int *playerID) char *creatorName, char *a11, int *playerID)
{ {
@ -112,7 +112,7 @@ BOOL STORMAPI SNetCreateGame(const char *pszGameName, const char *pszGamePasswor
return *playerID != -1; return *playerID != -1;
} }
BOOL STORMAPI SNetJoinGame(int id, char *pszGameName, char *pszGamePassword, char *playerName, char *userStats, int *playerID) BOOL SNetJoinGame(int id, char *pszGameName, char *pszGamePassword, char *playerName, char *userStats, int *playerID)
{ {
*playerID = dvlnet_inst->join(pszGameName, pszGamePassword); *playerID = dvlnet_inst->join(pszGameName, pszGamePassword);
return *playerID != -1; return *playerID != -1;
@ -121,12 +121,12 @@ BOOL STORMAPI SNetJoinGame(int id, char *pszGameName, char *pszGamePassword, cha
/** /**
* @brief Is this the mirror image of SNetGetTurnsInTransit? * @brief Is this the mirror image of SNetGetTurnsInTransit?
*/ */
BOOL __stdcall SNetGetOwnerTurnsWaiting(DWORD *turns) BOOL SNetGetOwnerTurnsWaiting(DWORD *turns)
{ {
return dvlnet_inst->SNetGetOwnerTurnsWaiting(turns); return dvlnet_inst->SNetGetOwnerTurnsWaiting(turns);
} }
BOOL STORMAPI SNetGetTurnsInTransit(int *turns) BOOL SNetGetTurnsInTransit(int *turns)
{ {
return dvlnet_inst->SNetGetTurnsInTransit(turns); return dvlnet_inst->SNetGetTurnsInTransit(turns);
} }
@ -134,7 +134,7 @@ BOOL STORMAPI SNetGetTurnsInTransit(int *turns)
/** /**
* @brief engine calls this only once with argument 1 * @brief engine calls this only once with argument 1
*/ */
BOOLEAN __stdcall SNetSetBasePlayer(int) BOOLEAN SNetSetBasePlayer(int)
{ {
return TRUE; return TRUE;
} }
@ -142,7 +142,7 @@ BOOLEAN __stdcall SNetSetBasePlayer(int)
/** /**
* @brief since we never signal STORM_ERROR_REQUIRES_UPGRADE the engine will not call this function * @brief since we never signal STORM_ERROR_REQUIRES_UPGRADE the engine will not call this function
*/ */
BOOL STORMAPI SNetPerformUpgrade(DWORD *upgradestatus) BOOL SNetPerformUpgrade(DWORD *upgradestatus)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
@ -150,7 +150,7 @@ BOOL STORMAPI SNetPerformUpgrade(DWORD *upgradestatus)
/** /**
* @brief not called from engine * @brief not called from engine
*/ */
BOOL STORMAPI SNetSetGameMode(DWORD modeFlags, bool makePublic) BOOL SNetSetGameMode(DWORD modeFlags, bool makePublic)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
return TRUE; return TRUE;

2
types.h

@ -47,6 +47,7 @@
#define DEVILUTION_BEGIN_NAMESPACE namespace dvl { #define DEVILUTION_BEGIN_NAMESPACE namespace dvl {
#define DEVILUTION_END_NAMESPACE } #define DEVILUTION_END_NAMESPACE }
#include "miniwin_pushdecl.h"
#include "miniwin.h" #include "miniwin.h"
#endif #endif
@ -153,6 +154,7 @@ DEVILUTION_BEGIN_NAMESPACE
//} //}
//#endif //#endif
#include "miniwin_popdecl.h"
DEVILUTION_END_NAMESPACE DEVILUTION_END_NAMESPACE
#endif #endif

Loading…
Cancel
Save