mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-22 09:01:57 -05:00
Initial OS/2 support.
This commit is contained in:
parent
95a1efe5f1
commit
7ca1219356
12 changed files with 187 additions and 10 deletions
4
Makefile
4
Makefile
|
@ -127,7 +127,7 @@ serenityos:
|
|||
$(MAKE) $(ENAME) PLAT=serenityos
|
||||
irix:
|
||||
$(MAKE) $(ENAME) PLAT=irix
|
||||
|
||||
|
||||
# consoles builds require special handling, so are moved to
|
||||
# separate makefiles to avoid having one giant messy makefile
|
||||
dreamcast:
|
||||
|
@ -161,6 +161,8 @@ switch:
|
|||
$(MAKE) -f misc/switch/Makefile PLAT=switch
|
||||
ds:
|
||||
$(MAKE) -f misc/ds/Makefile PLAT=ds
|
||||
os/2:
|
||||
$(MAKE) -f misc/os2/Makefile PLAT=os2
|
||||
|
||||
clean:
|
||||
$(DEL) $(OBJECTS)
|
||||
|
|
60
misc/os2/Makefile
Normal file
60
misc/os2/Makefile
Normal file
|
@ -0,0 +1,60 @@
|
|||
#--------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
# SOURCES is a list of directories containing source code
|
||||
# DATA is a list of directories containing data files
|
||||
#
|
||||
# NO_ICON: if set to anything, do not use icon.
|
||||
# NO_NACP: if set to anything, no .nacp file is generated.
|
||||
# APP_TITLE is the name of the app stored in the .nacp file (Optional)
|
||||
# APP_AUTHOR is the author of the app stored in the .nacp file (Optional)
|
||||
# APP_VERSION is the version of the app stored in the .nacp file (Optional)
|
||||
# APP_TITLEID is the titleID of the app stored in the .nacp file (Optional)
|
||||
# ICON is the filename of the icon (.jpg), relative to the project folder.
|
||||
# If not set, it attempts to use one of the following (in this order):
|
||||
# - <Project name>.jpg
|
||||
# - icon.jpg
|
||||
# - <libnx folder>/default_icon.jpg
|
||||
#
|
||||
# CONFIG_JSON is the filename of the NPDM config file (.json), relative to the project folder.
|
||||
# If not set, it attempts to use one of the following (in this order):
|
||||
# - <Project name>.json
|
||||
# - config.json
|
||||
# If a JSON file is provided or autodetected, an ExeFS PFS0 (.nsp) is built instead
|
||||
# of a homebrew executable (.nro). This is intended to be used for sysmodules.
|
||||
# NACP building is skipped as well.
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := ClassiCube
|
||||
BUILD_DIR := build
|
||||
SOURCE_DIR:= src
|
||||
DATA := data
|
||||
C_SOURCES := $(wildcard $(SOURCE_DIR)/*.c)
|
||||
C_OBJECTS := $(patsubst $(SOURCE_DIR)/%.c, $(BUILD_DIR)/%.o, $(C_SOURCES))
|
||||
|
||||
OBJECTS := $(C_OBJECTS) $(BUILD_DIR)/$(TARGET).res misc/os2/classicube.def
|
||||
ENAME = ClassiCube
|
||||
DEL = rm -f
|
||||
CFLAGS = -g -pipe -fno-math-errno
|
||||
LDFLAGS = -g -rdynamic
|
||||
APP_TITLE := ClassiCube
|
||||
APP_AUTHOR := UnknownShadow200
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
CC = gcc
|
||||
CFLAGS := -O3 -g -march=pentium4 -idirafter /@unixroot/usr/include/os2tk45 -DOS2
|
||||
LDFLAGS = -Zhigh-mem -Zomf -Zargs-wild -Zargs-resp -Zlinker DISABLE -Zlinker 1121
|
||||
LIBS := -lcx -lmmpm2 -lpthread -lSDL2
|
||||
|
||||
$(TARGET).exe: $(BUILD_DIR) $(OBJECTS)
|
||||
$(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(LIBS)
|
||||
|
||||
$(BUILD_DIR):
|
||||
mkdir -p $(BUILD_DIR)
|
||||
|
||||
$(C_OBJECTS): $(BUILD_DIR)/%.o : $(SOURCE_DIR)/%.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
$(BUILD_DIR)/$(TARGET).res: misc/os2/$(TARGET).rc
|
||||
wrc -r misc/os2/$(TARGET).rc -fo=$@
|
||||
|
|
@ -1494,6 +1494,12 @@ cc_result Audio_Poll(struct AudioContext* ctx, int* inUse) {
|
|||
static cc_bool Audio_FastPlay(struct AudioContext* ctx, struct AudioData* data) { return false; }
|
||||
|
||||
cc_bool Audio_DescribeError(cc_result res, cc_string* dst) { return false; }
|
||||
|
||||
cc_result Audio_AllocChunks(cc_uint32 size, void** chunks, int numChunks) {
|
||||
return ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
void Audio_FreeChunks(void** chunks, int numChunks) { }
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -381,6 +381,14 @@ typedef cc_uint8 cc_bool;
|
|||
#undef CC_BUILD_FREETYPE
|
||||
#undef CC_BUILD_RESOURCES
|
||||
#undef CC_BUILD_NETWORKING
|
||||
#elif defined OS2
|
||||
#define CC_BUILD_OS2
|
||||
#define CC_BUILD_POSIX
|
||||
#define CC_BUILD_SOFTGPU
|
||||
#define CC_BUILD_PORTABLEGL
|
||||
#define CC_BUILD_SDL
|
||||
#define CC_BUILD_CURL
|
||||
#define CC_BUILD_FREETYPE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
|
@ -283,9 +283,9 @@ void Gfx_CalcPerspectiveMatrix(struct Matrix* matrix, float fov, float aspect, f
|
|||
/*########################################################################################################################*
|
||||
*---------------------------------------------------------Rendering-------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
typedef struct Vector4 { float X, Y, Z, W; } Vector4;
|
||||
typedef struct Vector3 { float X, Y, Z; } Vector3;
|
||||
typedef struct Vector2 { float X, Y; } Vector2;
|
||||
typedef struct Vector4 { float x, y, z, w; } Vector4;
|
||||
typedef struct Vector3 { float x, y, z; } Vector3;
|
||||
typedef struct Vector2 { float x, y; } Vector2;
|
||||
|
||||
static void TransformVertex(int index, Vector4* frag, Vector2* uv, PackedCol* color) {
|
||||
// TODO: avoid the multiply, just add down in DrawTriangles
|
||||
|
@ -301,7 +301,7 @@ static void TransformVertex(int index, Vector4* frag, Vector2* uv, PackedCol* co
|
|||
frag->x = vp_hwidth * (1 + coord.x / coord.w);
|
||||
frag->y = vp_hheight * (1 - coord.y / coord.w);
|
||||
frag->z = coord.z / coord.w;
|
||||
frag.w = 1.0f / coord.w;
|
||||
frag->w = 1.0f / coord.w;
|
||||
|
||||
if (gfx_format != VERTEX_FORMAT_TEXTURED) {
|
||||
struct VertexColoured* v = (struct VertexColoured*)ptr;
|
||||
|
|
|
@ -70,7 +70,7 @@ static void Http_StartNextDownload(void) {
|
|||
|
||||
String_EncodeUtf8(urlStr, &url);
|
||||
res = interop_DownloadAsync(urlStr, req->requestType, req->id);
|
||||
|
||||
|
||||
if (res) {
|
||||
/* interop error code -> ClassiCube error code */
|
||||
if (res == 1) res = ERR_INVALID_DATA_URL;
|
||||
|
|
|
@ -179,6 +179,9 @@ static const cc_string curlAlt = String_FromConst("libcurl.so");
|
|||
#elif defined CC_BUILD_SERENITY
|
||||
static const cc_string curlLib = String_FromConst("/usr/local/lib/libcurl.so");
|
||||
static const cc_string curlAlt = String_FromConst("/usr/local/lib/libcurl.so");
|
||||
#elif defined CC_BUILD_OS2
|
||||
static const cc_string curlLib = String_FromConst("/@unixroot/usr/lib/curl7.dll");
|
||||
static const cc_string curlAlt = String_FromConst("/@unixroot/usr/local/lib/curl7.dll");
|
||||
#else
|
||||
static const cc_string curlLib = String_FromConst("libcurl.so.4");
|
||||
static const cc_string curlAlt = String_FromConst("libcurl.so.3");
|
||||
|
@ -186,10 +189,17 @@ static const cc_string curlAlt = String_FromConst("libcurl.so.3");
|
|||
|
||||
static cc_bool LoadCurlFuncs(void) {
|
||||
static const struct DynamicLibSym funcs[] = {
|
||||
#if !defined CC_BUILD_OS2
|
||||
DynamicLib_Sym(curl_global_init), DynamicLib_Sym(curl_global_cleanup),
|
||||
DynamicLib_Sym(curl_easy_init), DynamicLib_Sym(curl_easy_perform),
|
||||
DynamicLib_Sym(curl_easy_setopt), DynamicLib_Sym(curl_easy_cleanup),
|
||||
DynamicLib_Sym(curl_slist_free_all), DynamicLib_Sym(curl_slist_append)
|
||||
#else
|
||||
DynamicLib_SymC(curl_global_init), DynamicLib_SymC(curl_global_cleanup),
|
||||
DynamicLib_SymC(curl_easy_init), DynamicLib_SymC(curl_easy_perform),
|
||||
DynamicLib_SymC(curl_easy_setopt), DynamicLib_SymC(curl_easy_cleanup),
|
||||
DynamicLib_SymC(curl_slist_free_all), DynamicLib_SymC(curl_slist_append)
|
||||
#endif
|
||||
};
|
||||
cc_bool success;
|
||||
void* lib;
|
||||
|
@ -225,7 +235,6 @@ static void HttpBackend_Init(void) {
|
|||
if (!LoadCurlFuncs()) { Logger_WarnFunc(&msg); return; }
|
||||
res = _curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||
if (res) { Logger_SimpleWarn(res, "initing curl"); return; }
|
||||
|
||||
curl = _curl_easy_init();
|
||||
if (!curl) { Logger_SimpleWarn(res, "initing curl_easy"); return; }
|
||||
|
||||
|
|
|
@ -219,6 +219,7 @@ static void LWebTask_Reset(struct LWebTask* task) {
|
|||
|
||||
void LWebTask_Tick(struct LWebTask* task, LWebTask_ErrorCallback errorCallback) {
|
||||
struct HttpRequest item;
|
||||
|
||||
if (task->completed) return;
|
||||
if (!Http_GetResult(task->reqID, &item)) return;
|
||||
|
||||
|
|
|
@ -23,6 +23,9 @@ static HANDLE curProcess = CUR_PROCESS_HANDLE;
|
|||
#include <signal.h>
|
||||
/* These operating systems don't provide sys/ucontext.h */
|
||||
/* But register constants be found from includes in <signal.h> */
|
||||
#elif defined CC_BUILD_OS2
|
||||
#include <signal.h>
|
||||
#include <386/ucontext.h>
|
||||
#elif defined CC_BUILD_LINUX || defined CC_BUILD_ANDROID
|
||||
/* Need to define this to get REG_ constants */
|
||||
#define _GNU_SOURCE
|
||||
|
@ -244,7 +247,7 @@ static void DumpFrame(cc_string* trace, void* addr) {
|
|||
cc_uintptr addr_ = (cc_uintptr)addr;
|
||||
String_Format1(trace, "%x", &addr_);
|
||||
}
|
||||
#elif defined CC_BUILD_POSIX
|
||||
#elif defined CC_BUILD_POSIX && !defined CC_BUILD_OS2
|
||||
/* need to define __USE_GNU for dladdr */
|
||||
#ifndef __USE_GNU
|
||||
#define __USE_GNU
|
||||
|
@ -379,7 +382,7 @@ void Logger_Backtrace(cc_string* trace, void* ctx) {
|
|||
}
|
||||
#elif defined CC_BACKTRACE_BUILTIN
|
||||
/* Implemented later at end of the file */
|
||||
#elif defined CC_BUILD_POSIX
|
||||
#elif defined CC_BUILD_POSIX && !defined CC_BUILD_OS2
|
||||
#include <execinfo.h>
|
||||
void Logger_Backtrace(cc_string* trace, void* ctx) {
|
||||
void* addrs[MAX_BACKTRACE_FRAMES];
|
||||
|
|
|
@ -121,6 +121,9 @@ extern const cc_string DynamicLib_Ext;
|
|||
#define DYNAMICLIB_QUOTE(x) #x
|
||||
#define DynamicLib_Sym(sym) { DYNAMICLIB_QUOTE(sym), (void**)&_ ## sym }
|
||||
#define DynamicLib_Sym2(name, sym) { name, (void**)&_ ## sym }
|
||||
#if defined CC_BUILD_OS2
|
||||
#define DynamicLib_SymC(sym) { DYNAMICLIB_QUOTE(_ ## sym), (void**)&_ ## sym }
|
||||
#endif
|
||||
|
||||
CC_API cc_result DynamicLib_Load(const cc_string* path, void** lib); /* OBSOLETE */
|
||||
CC_API cc_result DynamicLib_Get(void* lib, const char* name, void** symbol); /* OBSOLETE */
|
||||
|
|
|
@ -61,6 +61,10 @@ cc_bool Platform_SingleProcess;
|
|||
/* TODO: Use load_image/resume_thread instead of fork */
|
||||
/* Otherwise opening browser never works because fork fails */
|
||||
#include <kernel/image.h>
|
||||
#elif defined CC_BUILD_OS2
|
||||
#include <libcx/net.h>
|
||||
#define INCL_DOSPROCESS
|
||||
#include <os2.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -514,6 +518,11 @@ void Platform_LoadSysFonts(void) {
|
|||
static const cc_string dirs[] = {
|
||||
String_FromConst("/res/fonts")
|
||||
};
|
||||
#elif defined CC_BUILD_OS2
|
||||
static const cc_string dirs[] = {
|
||||
String_FromConst("/@unixroot/usr/share/fonts"),
|
||||
String_FromConst("/@unixroot/usr/local/share/fonts")
|
||||
};
|
||||
#else
|
||||
static const cc_string dirs[] = {
|
||||
String_FromConst("/usr/share/fonts"),
|
||||
|
@ -529,6 +538,10 @@ void Platform_LoadSysFonts(void) {
|
|||
/*########################################################################################################################*
|
||||
*---------------------------------------------------------Socket----------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
#if defined CC_BUILD_OS2
|
||||
#undef AF_INET6
|
||||
#endif
|
||||
|
||||
union SocketAddress {
|
||||
struct sockaddr raw;
|
||||
struct sockaddr_in v4;
|
||||
|
@ -861,6 +874,16 @@ static cc_result Process_RawGetExePath(char* path, int* len) {
|
|||
*len = file.length;
|
||||
return 0;
|
||||
}
|
||||
#elif defined CC_BUILD_OS2
|
||||
static cc_result Process_RawGetExePath(char* path, int* len) {
|
||||
PPIB pib;
|
||||
DosGetInfoBlocks(NULL, &pib);
|
||||
if (pib && pib->pib_pchcmd) {
|
||||
Mem_Copy(path, pib->pib_pchcmd, strlen(pib->pib_pchcmd));
|
||||
*len = strlen(pib->pib_pchcmd);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -1060,7 +1083,8 @@ void* DynamicLib_Load2(const cc_string* path) {
|
|||
}
|
||||
|
||||
void* DynamicLib_Get2(void* lib, const char* name) {
|
||||
return dlsym(lib, name);
|
||||
void *result = dlsym(lib, name);
|
||||
return result;
|
||||
}
|
||||
|
||||
cc_bool DynamicLib_DescribeError(cc_string* dst) {
|
||||
|
|
|
@ -9,7 +9,9 @@
|
|||
#include <SDL2/SDL.h>
|
||||
static SDL_Window* win_handle;
|
||||
|
||||
#ifndef CC_BUILD_OS2
|
||||
#error "Some features are missing from the SDL backend. If possible, it is recommended that you use a native windowing backend instead"
|
||||
#endif
|
||||
|
||||
static void RefreshWindowBounds(void) {
|
||||
SDL_GetWindowSize(win_handle, &Window_Main.Width, &Window_Main.Height);
|
||||
|
@ -54,7 +56,11 @@ static void DoCreateWindow(int width, int height, int flags) {
|
|||
/* TODO grab using SDL_SetWindowGrab? seems to be unnecessary on Linux at least */
|
||||
}
|
||||
void Window_Create2D(int width, int height) { DoCreateWindow(width, height, 0); }
|
||||
#if !defined CC_BUILD_PORTABLEGL
|
||||
void Window_Create3D(int width, int height) { DoCreateWindow(width, height, SDL_WINDOW_OPENGL); }
|
||||
#else
|
||||
void Window_Create3D(int width, int height) { DoCreateWindow(width, height, 0); }
|
||||
#endif
|
||||
|
||||
void Window_SetTitle(const cc_string* title) {
|
||||
char str[NATIVE_STR_LEN];
|
||||
|
@ -395,5 +401,60 @@ void GLContext_SetFpsLimit(cc_bool vsync, float minFrameMs) {
|
|||
SDL_GL_SetSwapInterval(vsync);
|
||||
}
|
||||
void GLContext_GetApiInfo(cc_string* info) { }
|
||||
|
||||
#elif defined CC_BUILD_PORTABLEGL
|
||||
#define PORTABLEGL_IMPLEMENTATION
|
||||
#include <portablegl.h>
|
||||
|
||||
glContext pglContext;
|
||||
u32 *bbufpix;
|
||||
|
||||
typedef struct My_Uniforms
|
||||
{
|
||||
mat4 mvp_mat;
|
||||
vec4 v_color;
|
||||
} My_Uniforms;
|
||||
|
||||
void normal_vs(float* vs_output, void* vertex_attribs, Shader_Builtins* builtins, void* uniforms)
|
||||
{
|
||||
builtins->gl_Position = mult_mat4_vec4(*((mat4*)uniforms), ((vec4*)vertex_attribs)[0]);
|
||||
}
|
||||
|
||||
void normal_fs(float* fs_input, Shader_Builtins* builtins, void* uniforms)
|
||||
{
|
||||
builtins->gl_FragColor = ((My_Uniforms*)uniforms)->v_color;
|
||||
}
|
||||
|
||||
void GLContext_Create(void) {
|
||||
int width, height;
|
||||
|
||||
SDL_GetWindowSize(win_handle, &width, &height);
|
||||
if (!init_glContext(&pglContext, &bbufpix, width, height, 32,
|
||||
0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000)) {
|
||||
Logger_Abort("Failed to initialize portableglContext");
|
||||
}
|
||||
set_glContext(&pglContext);
|
||||
|
||||
//GLuint shader = pglCreateProgram(normal_vs, normal_fs, 0, NULL, GL_FALSE);
|
||||
//glUseProgram(shader);
|
||||
}
|
||||
|
||||
void GLContext_Update(void) { }
|
||||
cc_bool GLContext_TryRestore(void) { return true; }
|
||||
void GLContext_Free(void) {
|
||||
free_glContext(&pglContext);
|
||||
// TODO Free whatever
|
||||
}
|
||||
|
||||
void* GLContext_GetAddress(const char* function) {
|
||||
}
|
||||
|
||||
cc_bool GLContext_SwapBuffers(void) {
|
||||
}
|
||||
|
||||
void GLContext_SetFpsLimit(cc_bool vsync, float minFrameMs) {
|
||||
}
|
||||
void GLContext_GetApiInfo(cc_string* info) { }
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue