Skip to content

Commit

Permalink
TWL links now
Browse files Browse the repository at this point in the history
  • Loading branch information
shinyquagsire23 committed Sep 22, 2023
1 parent 6b1b6d8 commit 0770829
Show file tree
Hide file tree
Showing 9 changed files with 158 additions and 41 deletions.
2 changes: 1 addition & 1 deletion build_twl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ OPENJKDF2_BUILD_DIR=$(pwd)
# Prevent macOS headers from getting linked in
export -n SDKROOT MACOSX_DEPLOYMENT_TARGET CPLUS_INCLUDE_PATH C_INCLUDE_PATH

cmake .. --toolchain $(pwd)/../cmake_modules/toolchain_twl.cmake && make -j1 openjkdf2
cmake .. --toolchain $(pwd)/../cmake_modules/toolchain_twl.cmake && make -j10 openjkdf2
cd ..
5 changes: 5 additions & 0 deletions cmake_modules/config_platform_deps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ if(TARGET_MACOS)
add_definitions(-DLINUX)
endif()

if(TARGET_TWL)
file(GLOB TARGET_TWL_SRCS ${PROJECT_SOURCE_DIR}/src/Platform/TWL/*.c)
list(APPEND ENGINE_SOURCE_FILES ${TARGET_TWL_SRCS})
endif()

if(TARGET_WASM)
add_definitions(-DLINUX)
endif()
Expand Down
6 changes: 4 additions & 2 deletions cmake_modules/plat_twl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ macro(plat_initialize)

add_definitions(-DPLAT_MISSING_WIN32)
add_definitions(-DTARGET_TWL)
add_definitions(-D_XOPEN_SOURCE=500)
add_definitions(-D_DEFAULT_SOURCE)

# These are the standard features for full game support
set(TARGET_USE_PHYSFS FALSE)
Expand All @@ -27,7 +29,7 @@ macro(plat_initialize)

set(TARGET_TWL TRUE)

add_link_options(-fno-exceptions)
add_link_options(-fno-exceptions -fshort-wchar)
add_compile_options(-fno-exceptions)
add_compile_options(-O2 -Wuninitialized -fshort-wchar -Wall -Wno-unused-variable -Wno-parentheses -Wno-missing-braces)
endmacro()
Expand All @@ -37,6 +39,6 @@ macro(plat_specific_deps)
endmacro()

macro(plat_link_and_package)
target_link_libraries(${BIN_NAME} PRIVATE -lm -lSDL2 -lSDL2_mixer -lGL -lGLEW -lopenal)
target_link_libraries(${BIN_NAME} PRIVATE -lm)
target_link_libraries(sith_engine PRIVATE nlohmann_json::nlohmann_json)
endmacro()
11 changes: 8 additions & 3 deletions src/General/stdFileUtil.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#include "General/stdFnames.h"
#include "jk.h"

#ifdef PLATFORM_POSIX
#ifdef PLATFORM_POSIX
#include <assert.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -207,15 +208,19 @@ int stdFileUtil_Deltree(const char* lpPathName)
}
#endif

#ifndef TARGET_TWL
nftw(tmp, rmFiles, 10, FTW_DEPTH|FTW_MOUNT|FTW_PHYS);
#else
assert(0);
#endif

//rmdir(tmp);
return 0;
}
#endif // _WIN32
#endif

#ifdef LINUX
#ifdef PLATFORM_POSIX

static char* search_ext = "";

Expand Down Expand Up @@ -386,4 +391,4 @@ int stdFileUtil_DelFile(char* lpFileName)

return 1;
}
#endif
#endif // PLATFORM_POSIX
9 changes: 7 additions & 2 deletions src/Gui/jkGUIMods.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,16 @@ int jkGuiMods_OpenURL(const char *url)
}
return 0;
}
#else
#elif defined(SDL2_RENDER)
int jkGuiMods_OpenURL(const char* url)
{
return SDL_OpenURL(url);
}
#else
int jkGuiMods_OpenURL(const char* url)
{
return 0;
}
#endif

void jkGuiMods_Startup()
Expand Down Expand Up @@ -275,7 +280,7 @@ void jkGuiMods_PopulateEntries(Darray *pListDisplayed, jkGuiElement *element)
char tmpCwd[512];
char tmpKeyPath[512];

#if !defined(ARCH_WASM) && !defined(TARGET_ANDROID)
#if !defined(ARCH_WASM) && !defined(TARGET_ANDROID) && !defined(TARGET_TWL)
Main_bMotsCompat = !Main_bMotsCompat;
InstallHelper_GetLocalDataDir(tmpCwd, sizeof(tmpCwd), 0);
Main_bMotsCompat = !Main_bMotsCompat;
Expand Down
94 changes: 94 additions & 0 deletions src/Platform/TWL/std3D.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#include "Platform/std3D.h"

int std3D_bReinitHudElements = 0;

int std3D_Startup()
{
return 0;
}
void std3D_Shutdown() {}
int std3D_StartScene()
{
return 0;
}
int std3D_EndScene()
{
return 0;
}
void std3D_ResetRenderList() {}
int std3D_RenderListVerticesFinish()
{
return 0;
}
void std3D_DrawRenderList() {}
int std3D_SetCurrentPalette(rdColor24 *a1, int a2)
{
return 0;
}
void std3D_GetValidDimension(unsigned int inW, unsigned int inH, unsigned int *outW, unsigned int *outH) {}
int std3D_DrawOverlay()
{
return 0;
}
void std3D_UnloadAllTextures() {}
void std3D_AddRenderListTris(rdTri *tris, unsigned int num_tris) {}
void std3D_AddRenderListLines(rdLine* lines, uint32_t num_lines) {}
int std3D_AddRenderListVertices(D3DVERTEX *vertex_array, int count)
{
return 0;
}
void std3D_UpdateFrameCount(rdDDrawSurface *surface) {}
void std3D_PurgeTextureCache() {}
int std3D_ClearZBuffer()
{
return 0;
}
int std3D_AddToTextureCache(stdVBuffer *vbuf, rdDDrawSurface *texture, int is_alpha_tex, int no_alpha)
{
return 0;
}
void std3D_DrawMenu() {}
void std3D_DrawSceneFbo() {}
void std3D_FreeResources() {}
void std3D_InitializeViewport(rdRect *viewRect) {}
int std3D_GetValidDimensions(int a1, int a2, int a3, int a4)
{
return 0;
}
int std3D_FindClosestDevice(uint32_t index, int a2)
{
return 0;
}
int std3D_SetRenderList(intptr_t a1)
{
return 0;
}
intptr_t std3D_GetRenderList()
{
return 0;
}
int std3D_CreateExecuteBuffer()
{
return 0;
}

int std3D_HasAlpha() { return 0; }
int std3D_HasAlphaFlatStippled() { return 0; }
int std3D_HasModulateAlpha() { return 0; }



void std3D_PurgeUIEntry(int i, int idx) {}
void std3D_PurgeTextureEntry(int i) {}
void std3D_PurgeBitmapRefs(stdBitmap *pBitmap) {}
void std3D_PurgeSurfaceRefs(rdDDrawSurface *texture) {}
void std3D_UpdateSettings() {}
void std3D_Screenshot(const char* pFpath) {}

void std3D_ResetUIRenderList() {}
int std3D_AddBitmapToTextureCache(stdBitmap *texture, int mipIdx, int is_alpha_tex, int no_alpha) {}
void std3D_DrawUIBitmapRGBA(stdBitmap* pBmp, int mipIdx, float dstX, float dstY, rdRect* srcRect, float scaleX, float scaleY, int bAlphaOverwrite, uint8_t color_r, uint8_t color_g, uint8_t color_b, uint8_t color_a) {}
void std3D_DrawUIBitmap(stdBitmap* pBmp, int mipIdx, float dstX, float dstY, rdRect* srcRect, float scale, int bAlphaOverwrite) {}
void std3D_DrawUIClearedRect(uint8_t palIdx, rdRect* dstRect) {}
void std3D_DrawUIClearedRectRGBA(uint8_t color_r, uint8_t color_g, uint8_t color_b, uint8_t color_a, rdRect* dstRect) {}
int std3D_IsReady() {}
51 changes: 25 additions & 26 deletions src/Platform/std3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,31 @@ int std3D_HasAlpha();
int std3D_HasModulateAlpha();
int std3D_HasAlphaFlatStippled();

#ifdef SDL2_RENDER
#if !defined(SDL2_RENDER) && defined(WIN32)
static int (*std3D_Startup)() = (void*)std3D_Startup_ADDR;
static void (*std3D_Shutdown)() = (void*)std3D_Shutdown_ADDR;
static int (*std3D_StartScene)() = (void*)std3D_StartScene_ADDR;
static int (*std3D_EndScene)() = (void*)std3D_EndScene_ADDR;
static void (*std3D_ResetRenderList)() = (void*)std3D_ResetRenderList_ADDR;
static int (*std3D_RenderListVerticesFinish)() = (void*)std3D_RenderListVerticesFinish_ADDR;
static void (*std3D_DrawRenderList)() = (void*)std3D_DrawRenderList_ADDR;
static int (*std3D_SetCurrentPalette)(rdColor24 *a1, int a2) = (void*)std3D_SetCurrentPalette_ADDR;
static unsigned int* (*std3D_GetValidDimension)(unsigned int a1, unsigned int a2, unsigned int *a3, unsigned int *a4) = (void*)std3D_GetValidDimension_ADDR;;
static int (*std3D_DrawOverlay)() = (void*)std3D_DrawOverlay_ADDR;
static void (*std3D_UnloadAllTextures)() = (void*)std3D_UnloadAllTextures_ADDR;
static void (*std3D_AddRenderListTris)(rdTri *tris, unsigned int num_tris) = (void*)std3D_AddRenderListTris_ADDR;
static int (*std3D_AddRenderListVertices)(D3DVERTEX *vertex_array, int count) = (void*)std3D_AddRenderListVertices_ADDR;
static int (*std3D_ClearZBuffer)() = (void*)std3D_ClearZBuffer_ADDR;
static int (*std3D_AddToTextureCache)(stdVBuffer *a1, rdDDrawSurface *tex_2, int is_16bit_maybe, int no_alpha) = (void*)std3D_AddToTextureCache_ADDR;
static void (*std3D_UpdateFrameCount)(rdDDrawSurface *surface) = (void*)std3D_UpdateFrameCount_ADDR;
static void (*std3D_PurgeTextureCache)() = (void*)std3D_PurgeTextureCache_ADDR;
void std3D_InitializeViewport(rdRect *viewRect);
int std3D_GetValidDimensions(int a1, int a2, int a3, int a4);
static int (*std3D_FindClosestDevice)(uint32_t index, int a2) = (void*)std3D_FindClosestDevice_ADDR;
int std3D_SetRenderList(intptr_t a1);
intptr_t std3D_GetRenderList();
static int (*std3D_CreateExecuteBuffer)() = (void*)std3D_CreateExecuteBuffer_ADDR;
#else
int std3D_Startup();
void std3D_Shutdown();
int std3D_StartScene();
Expand All @@ -72,7 +96,6 @@ void std3D_AddRenderListLines(rdLine* lines, uint32_t num_lines);
int std3D_AddRenderListVertices(D3DVERTEX *vertex_array, int count);
void std3D_UpdateFrameCount(rdDDrawSurface *surface);
void std3D_PurgeTextureCache();
void std3D_Shutdown();
int std3D_ClearZBuffer();
int std3D_AddToTextureCache(stdVBuffer *vbuf, rdDDrawSurface *texture, int is_alpha_tex, int no_alpha);
void std3D_DrawMenu();
Expand All @@ -84,30 +107,6 @@ int std3D_FindClosestDevice(uint32_t index, int a2);
int std3D_SetRenderList(intptr_t a1);
intptr_t std3D_GetRenderList();
int std3D_CreateExecuteBuffer();
#else
static int (*std3D_Startup)() = (void*)std3D_Startup_ADDR;
static void (*std3D_Shutdown)() = (void*)std3D_Shutdown_ADDR;
static int (*std3D_StartScene)() = (void*)std3D_StartScene_ADDR;
static int (*std3D_EndScene)() = (void*)std3D_EndScene_ADDR;
static void (*std3D_ResetRenderList)() = (void*)std3D_ResetRenderList_ADDR;
static int (*std3D_RenderListVerticesFinish)() = (void*)std3D_RenderListVerticesFinish_ADDR;
static void (*std3D_DrawRenderList)() = (void*)std3D_DrawRenderList_ADDR;
static int (*std3D_SetCurrentPalette)(rdColor24 *a1, int a2) = (void*)std3D_SetCurrentPalette_ADDR;
static unsigned int* (*std3D_GetValidDimension)(unsigned int a1, unsigned int a2, unsigned int *a3, unsigned int *a4) = (void*)std3D_GetValidDimension_ADDR;;
static int (*std3D_DrawOverlay)() = (void*)std3D_DrawOverlay_ADDR;
static void (*std3D_UnloadAllTextures)() = (void*)std3D_UnloadAllTextures_ADDR;
static void (*std3D_AddRenderListTris)(rdTri *tris, unsigned int num_tris) = (void*)std3D_AddRenderListTris_ADDR;
static int (*std3D_AddRenderListVertices)(D3DVERTEX *vertex_array, int count) = (void*)std3D_AddRenderListVertices_ADDR;
static int (*std3D_ClearZBuffer)() = (void*)std3D_ClearZBuffer_ADDR;
static int (*std3D_AddToTextureCache)(stdVBuffer *a1, rdDDrawSurface *tex_2, int is_16bit_maybe, int no_alpha) = (void*)std3D_AddToTextureCache_ADDR;
static void (*std3D_UpdateFrameCount)(rdDDrawSurface *surface) = (void*)std3D_UpdateFrameCount_ADDR;
static void (*std3D_PurgeTextureCache)() = (void*)std3D_PurgeTextureCache_ADDR;
void std3D_InitializeViewport(rdRect *viewRect);
int std3D_GetValidDimensions(int a1, int a2, int a3, int a4);
static int (*std3D_FindClosestDevice)(uint32_t index, int a2) = (void*)std3D_FindClosestDevice_ADDR;
int std3D_SetRenderList(intptr_t a1);
intptr_t std3D_GetRenderList();
static int (*std3D_CreateExecuteBuffer)() = (void*)std3D_CreateExecuteBuffer_ADDR;
#endif

void std3D_PurgeUIEntry(int i, int idx);
Expand Down
17 changes: 10 additions & 7 deletions src/Win95/Window_Twl.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
#include "Window.h"

#ifdef TARGET_TWL
int Window_xSize = WINDOW_DEFAULT_WIDTH;
int Window_ySize = WINDOW_DEFAULT_HEIGHT;
int Window_screenXSize = WINDOW_DEFAULT_WIDTH;
int Window_screenYSize = WINDOW_DEFAULT_HEIGHT;
int Window_isHiDpi = 0;
int Window_isFullscreen = 0;
int Window_needsRecreate = 0;


static int dword_855E98 = 0;
static int dword_855DE4 = 0;
Expand All @@ -32,4 +26,13 @@ int last_jkQuakeConsole_bOpen = 0;
int Window_menu_mouseX = 0;
int Window_menu_mouseY = 0;

int Window_Main_Linux(int argc, char** argv)
{
}

int Window_DefaultHandler(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, void* unused)
{
return 0;
}

#endif
4 changes: 4 additions & 0 deletions src/stdPlatform.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ static void* Linux_realloc(void* ptr, uint32_t len)

static int Linux_stdFeof(stdFile_t fhand)
{
#ifdef TARGET_TWL
return 0;
#else
return feof((void*)fhand);
#endif
}

uint32_t stdPlatform_GetTimeMsec()
Expand Down

0 comments on commit 0770829

Please sign in to comment.