diff --git a/SourceX/DiabloUI/diabloui.cpp b/SourceX/DiabloUI/diabloui.cpp index 98f43977f..c2758ba15 100644 --- a/SourceX/DiabloUI/diabloui.cpp +++ b/SourceX/DiabloUI/diabloui.cpp @@ -90,6 +90,8 @@ int MAKEINTRESOURCE(int i) case IDD_DIALOG11: return 9; } + + return -1; } int DialogBoxParam(HINSTANCE hInstance, int msgId, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam) @@ -425,7 +427,7 @@ BOOL __stdcall UiCopyProtError(int *pdwResult) void __stdcall UiAppActivate(BOOL bActive) { - UNIMPLEMENTED(); + DUMMY(); } BOOL __fastcall UiValidPlayerName(char *name) diff --git a/SourceX/dx.cpp b/SourceX/dx.cpp index 22ebd988b..804af224d 100644 --- a/SourceX/dx.cpp +++ b/SourceX/dx.cpp @@ -80,7 +80,10 @@ class StubSurface : public IDirectDrawSurface { SDL_Rect dst_rect = { (int)dwX, (int)dwY, w, h }; // Convert from 8-bit to 32-bit - SDL_CHECK(SDL_BlitSurface(pal_surface, &src_rect, surface, &dst_rect)); + if (SDL_BlitSurface(pal_surface, &src_rect, surface, &dst_rect) != 0) { + SDL_Log("SDL_BlitSurface: %s\n", SDL_GetError()); + return E_FAIL; + } surface_dirty = true; return S_OK; @@ -189,7 +192,8 @@ class StubSurface : public IDirectDrawSurface { } METHOD HRESULT SetPalette(LPDIRECTDRAWPALETTE lpDDPalette) { - UNIMPLEMENTED(); + DUMMY(); + return S_OK; } METHOD HRESULT Unlock(LPVOID lpSurfaceData) { @@ -267,7 +271,8 @@ class StubDraw : public IDirectDraw { METHOD HRESULT CreatePalette(DWORD dwFlags, LPPALETTEENTRY lpColorTable, LPDIRECTDRAWPALETTE *lplpDDPalette, IUnknown *pUnkOuter) { - UNIMPLEMENTED(); + DUMMY(); + return S_OK; } METHOD HRESULT CreateSurface(LPDDSURFACEDESC lpDDSurfaceDesc, LPDIRECTDRAWSURFACE *lplpDDSurface, IUnknown *pUnkOuter) @@ -354,14 +359,58 @@ static StubPalette stub_palette; void __fastcall dx_init(HWND hWnd) { DUMMY(); + renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_PRESENTVSYNC); + if (renderer == NULL) { + SDL_Log("SDL_CreateRenderer: %s\n", SDL_GetError()); + return NULL; + } + + SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "2"); + if (SDL_RenderSetLogicalSize(renderer, SCREEN_WIDTH, SCREEN_HEIGHT) != 0) { + SDL_Log("SDL_RenderSetLogicalSize: %s\n", SDL_GetError()); + return NULL; + } + + surface = SDL_CreateRGBSurface(0, SCREEN_WIDTH, SCREEN_HEIGHT, 32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF); + if (surface == NULL) { + SDL_Log("SDL_CreateRGBSurface: %s\n", SDL_GetError()); + return NULL; + } + + texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STREAMING, SCREEN_WIDTH, SCREEN_HEIGHT); + if (texture == NULL) { + SDL_Log("SDL_CreateTexture: %s\n", SDL_GetError()); + return NULL; + } + + palette = SDL_AllocPalette(256); + if (palette == NULL) { + SDL_Log("SDL_AllocPalette: %s\n", SDL_GetError()); + return NULL; + } - gbActive = TRUE; + const int pitch = 64 + SCREEN_WIDTH + 64; + gpBuffer = malloc(sizeof(Screen)); + gpBufEnd += (unsigned int)gpBuffer; + + pal_surface = SDL_CreateRGBSurfaceFrom(gpBuffer, pitch, 160 + SCREEN_HEIGHT + 16, 8, pitch, 0, 0, 0, 0); + if (pal_surface == NULL) { + SDL_Log("SDL_CreateRGBSurfaceFrom: %s\n", SDL_GetError()); + return NULL; + } + + if (SDL_SetSurfacePalette(pal_surface, palette) != 0) { + SDL_Log("SDL_SetSurfacePalette: %s\n", SDL_GetError()); + return NULL; + } + + MainWndProc(NULL, WM_ACTIVATEAPP, TRUE, NULL); lpDDInterface = &stub_draw; lpDDSPrimary = &stub_surface; lpDDSBackBuf = &stub_surface; lpDDPalette = &stub_palette; - LoadGamma(); + palette_init(); } void __cdecl dx_cleanup() @@ -374,19 +423,25 @@ void sdl_update_entire_surface() { assert(surface && pal_surface); SDL_Rect src_rect = { 64, 160, SCREEN_WIDTH, SCREEN_HEIGHT }; - SDL_CHECK(SDL_BlitSurface(pal_surface, &src_rect, surface, NULL)); + if (SDL_BlitSurface(pal_surface, &src_rect, surface, NULL) != 0) { + SDL_Log("SDL_BlitSurface: %s\n", SDL_GetError()); + } } void sdl_present_surface() { assert(!SDL_MUSTLOCK(surface)); - SDL_CHECK(SDL_UpdateTexture(texture, NULL, surface->pixels, surface->pitch)); //pitch is 2560 + if (SDL_UpdateTexture(texture, NULL, surface->pixels, surface->pitch) != 0) { //pitch is 2560 + SDL_Log("SDL_UpdateTexture: %s\n", SDL_GetError()); + } // Clear the entire screen to our selected color. SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); SDL_RenderClear(renderer); - SDL_CHECK(SDL_RenderCopy(renderer, texture, NULL, NULL)); + if (SDL_RenderCopy(renderer, texture, NULL, NULL) != 0) { + SDL_Log("SDL_RenderCopy: %s\n", SDL_GetError()); + } SDL_RenderPresent(renderer); surface_dirty = false; @@ -394,18 +449,6 @@ void sdl_present_surface() void __fastcall j_lock_buf_priv(BYTE idx) { - if (!gpBuffer) { - printf("GpBuffer Created\n"); - const int pitch = SCREEN_WIDTH + 64 + 64; - gpBuffer = (Screen *)malloc(sizeof(Screen)); - printf("SIZE OF SCREEN %d\n", sizeof(Screen)); - gpBufEnd += (unsigned int)gpBuffer; - - pal_surface = SDL_CreateRGBSurfaceFrom(gpBuffer, pitch, 160 + SCREEN_HEIGHT + 16, 8, pitch, 0, 0, 0, 0); - assert(pal_surface); - SDL_CHECK(SDL_SetSurfacePalette(pal_surface, palette)); - } - j_unlock_buf_priv(idx); // what is idx? } @@ -445,7 +488,10 @@ BOOL STORMAPI SDrawUpdatePalette(unsigned int firstentry, unsigned int numentrie } assert(palette); - SDL_CHECK(SDL_SetPaletteColors(palette, colors, firstentry, numentries)); + if (SDL_SetPaletteColors(palette, colors, firstentry, numentries) != 0) { + SDL_Log("SDL_SetPaletteColors: %s\n", SDL_GetError()); + return FALSE; + } if (pal_surface) { sdl_update_entire_surface(); diff --git a/SourceX/miniwin.cpp b/SourceX/miniwin.cpp index dc85033a3..93db6b239 100644 --- a/SourceX/miniwin.cpp +++ b/SourceX/miniwin.cpp @@ -117,6 +117,7 @@ WINBOOL WINAPI GetComputerNameA(LPSTR lpBuffer, LPDWORD nSize) DUMMY(); strncpy(lpBuffer, "localhost", *nSize); *nSize = strlen(lpBuffer); + return TRUE; } DWORD GetFileVersionInfoSizeA(LPCSTR lptstrFilename, LPDWORD lpdwHandle) @@ -262,7 +263,7 @@ HWND CreateWindowExA( LPVOID lpParam) { if (SDL_Init(SDL_INIT_EVERYTHING) != 0) { - SDL_Log("SDL_RenderSetLogicalSize: %s\n", SDL_GetError()); + SDL_Log("SDL_Init: %s\n", SDL_GetError()); return 1; } atexit(SDL_Quit); @@ -274,38 +275,6 @@ HWND CreateWindowExA( window = SDL_CreateWindow(lpWindowName, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, nWidth, nHeight, flags); atexit(FakeWMDestroy); - renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_PRESENTVSYNC); - if (renderer == NULL) { - SDL_Log("SDL_CreateRenderer: %s\n", SDL_GetError()); - return NULL; - } - - SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "2"); - if (SDL_RenderSetLogicalSize(renderer, nWidth, nHeight) != 0) { - SDL_Log("SDL_RenderSetLogicalSize: %s\n", SDL_GetError()); - return NULL; - } - - surface = SDL_CreateRGBSurface(0, nWidth, nHeight, 32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF); - if (surface == NULL) { - SDL_Log("SDL_CreateRGBSurface: %s\n", SDL_GetError()); - return NULL; - } - - texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STREAMING, nWidth, nHeight); - if (texture == NULL) { - SDL_Log("SDL_CreateTexture: %s\n", SDL_GetError()); - return NULL; - } - - palette = SDL_AllocPalette(256); - if (palette == NULL) { - SDL_Log("SDL_AllocPalette: %s\n", SDL_GetError()); - return NULL; - } - - j_lock_buf_priv(0); //FIXME 0? - return window; } @@ -314,6 +283,8 @@ HWND CreateWindowExA( */ BOOL UpdateWindow(HWND hWnd) { + DUMMY(); + return TRUE; } BOOL ShowWindow(HWND hWnd, int nCmdShow) @@ -323,11 +294,14 @@ BOOL ShowWindow(HWND hWnd, int nCmdShow) } else if (nCmdShow == SW_SHOWNORMAL) { SDL_ShowWindow(window); } + + return TRUE; } WINUSERAPI ATOM WINAPI RegisterClassExA(const WNDCLASSEX *lpwcx) { DUMMY(); + return 1; } /** @@ -337,10 +311,12 @@ int GetSystemMetrics(int nIndex) { switch (nIndex) { case SM_CXSCREEN: - return 640; + return SCREEN_WIDTH; case SM_CYSCREEN: - return 480; + return SCREEN_HEIGHT; } + + return 0; } /** @@ -357,6 +333,7 @@ HGDIOBJ GetStockObject(int i) HICON LoadIconA(HINSTANCE hInstance, LPCSTR lpIconName) { DUMMY(); //SDL_SetWindowIcon + return NULL; } /** @@ -365,11 +342,13 @@ HICON LoadIconA(HINSTANCE hInstance, LPCSTR lpIconName) HANDLE LoadImageA(HINSTANCE hInst, LPCSTR name, UINT type, int cx, int cy, UINT fuLoad) { DUMMY(); + return NULL; } HCURSOR LoadCursorA(HINSTANCE hInstance, LPCSTR lpCursorName) { DUMMY(); //SDL_CreateCursor + return NULL; } /** @@ -437,19 +416,24 @@ VOID WINAPI GetSystemInfo(LPSYSTEM_INFO lpSystemInfo) HDC WINAPI GetDC(HWND hWnd) { - UNIMPLEMENTED(); + DUMMY(); + return NULL; } int WINAPI ReleaseDC(HWND hWnd, HDC hDC) { - UNIMPLEMENTED(); + DUMMY(); + return 0; } int WINAPI GetDeviceCaps(HDC hdc, int index) { SDL_DisplayMode current; - SDL_GetCurrentDisplayMode(0, ¤t); + if (SDL_GetCurrentDisplayMode(0, ¤t) != 0) { + SDL_Log("SDL_GetCurrentDisplayMode: %s", SDL_GetError()); + return 0; + } if (index == HORZRES) { return current.w; @@ -476,7 +460,8 @@ BOOL GetWindowRect(HWND hDlg, tagRECT *Rect) UINT WINAPI GetSystemPaletteEntries(HDC hdc, UINT iStart, UINT cEntries, LPPALETTEENTRY pPalEntries) { - UNIMPLEMENTED(); + DUMMY(); + return 0; } WINBOOL WINAPI CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, @@ -599,14 +584,17 @@ void PostQuitMessage(int nExitCode) LRESULT DefWindowProcA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { DUMMY(); + return NULL; } LONG GetWindowLongA(HWND hWnd, int nIndex) { DUMMY(); + return 0; } LONG SetWindowLongA(HWND hWnd, int nIndex, LONG dwNewLong) { DUMMY(); + return 0; } diff --git a/SourceX/miniwin_sdl.h b/SourceX/miniwin_sdl.h index 43fd5e703..f3c0912a7 100644 --- a/SourceX/miniwin_sdl.h +++ b/SourceX/miniwin_sdl.h @@ -2,8 +2,6 @@ #include -#define SDL_CHECK(e) assert(e == 0) - extern SDL_Window *window; extern SDL_Renderer *renderer; extern SDL_Texture *texture; diff --git a/SourceX/storm.cpp b/SourceX/storm.cpp index 47559f39c..9075c3c0c 100644 --- a/SourceX/storm.cpp +++ b/SourceX/storm.cpp @@ -443,11 +443,13 @@ void __stdcall SDrawMessageBox(char *Text, char *Title, int Flags) BOOLEAN __cdecl StormDestroy(void) { DUMMY(); + return TRUE; } BOOLEAN __stdcall SFileSetBasePath(char *) { DUMMY(); + return TRUE; } void __cdecl SDrawRealizePalette(void)