Skip to content

Commit

Permalink
oops
Browse files Browse the repository at this point in the history
  • Loading branch information
echoline committed Apr 4, 2021
1 parent 8bd0b76 commit 0de555f
Showing 1 changed file with 154 additions and 34 deletions.
188 changes: 154 additions & 34 deletions src/main/yquake2.patch
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,28 @@ index 1a72939d..00bbd00c 100644

void
diff --git a/src/backends/unix/system.c b/src/backends/unix/system.c
index 9f241440..acdd7e81 100644
index 9f241440..765df06b 100644
--- a/src/backends/unix/system.c
+++ b/src/backends/unix/system.c
@@ -47,6 +47,11 @@
@@ -47,6 +47,17 @@
#include "../../common/header/common.h"
#include "../../common/header/glob.h"

+#ifdef ANDROID
+#include <android/log.h>
+#include <android/dlext.h>
+#include <sys/mman.h>
+struct android_namespace_t* android_create_namespace(const char* name,
+ const char* ld_library_path,
+ const char* default_library_path,
+ uint64_t type,
+ const char* permitted_when_isolated_path);
+#endif
+
// Pointer to game library
static void *game_library;

@@ -78,8 +83,11 @@ Sys_Error(char *error, ...)
@@ -78,8 +89,11 @@ Sys_Error(char *error, ...)
va_start(argptr, error);
vsnprintf(string, 1024, error, argptr);
va_end(argptr);
Expand All @@ -86,7 +92,7 @@ index 9f241440..acdd7e81 100644
exit(1);
}

@@ -160,7 +168,11 @@ Sys_ConsoleInput(void)
@@ -160,7 +174,11 @@ Sys_ConsoleInput(void)
void
Sys_ConsoleOutput(char *string)
{
Expand All @@ -98,7 +104,7 @@ index 9f241440..acdd7e81 100644
}

/* ================================================================ */
@@ -334,10 +346,12 @@ Sys_FindClose(void)
@@ -334,10 +352,12 @@ Sys_FindClose(void)
void
Sys_UnloadGame(void)
{
Expand All @@ -111,7 +117,7 @@ index 9f241440..acdd7e81 100644

game_library = NULL;
}
@@ -355,21 +369,33 @@ Sys_GetGameAPI(void *parms)
@@ -355,21 +375,48 @@ Sys_GetGameAPI(void *parms)
#else
const char *gamename = "game.so";
#endif
Expand All @@ -125,19 +131,34 @@ index 9f241440..acdd7e81 100644

- Com_Printf("Loading library: %s\n", gamename);
+#ifdef ANDROID
+//#define LIBSIZE 1024*1024*2
+// void* start = mmap(NULL, LIBSIZE, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ android_dlextinfo extinfo;
+ extinfo.flags = 0;
+// extinfo.flags = ANDROID_DLEXT_RESERVED_ADDRESS;
+// extinfo.flags = ANDROID_DLEXT_USE_NAMESPACE;
+// extinfo.library_namespace = android_create_namespace("private", NULL, "");
+// extinfo.reserved_addr = start;
+// extinfo.reserved_size = LIBSIZE;
+
+ gamename = Cvar_VariableString("game");
+ if (gamename[0] == '\0')
+ gamename = "game";
+ snprintf(name, MAX_OSPATH, "lib%s.so", gamename);
+ game_library = dlopen(name, RTLD_NOW);
+ Com_Printf("Loading library: %s\n", name);
+// game_library = android_dlopen_ext(name, RTLD_NOW | RTLD_GLOBAL, &extinfo);
+ game_library = dlopen(name, RTLD_NOW|RTLD_GLOBAL);
+ if (game_library == NULL) {
+ Com_Printf("failed: %s", dlerror());
+ gamename = "game";
+ snprintf(name, MAX_OSPATH, "lib%s.so", gamename);
+ game_library = dlopen(name, RTLD_NOW);
+// game_library = android_dlopen_ext(name, RTLD_NOW | RTLD_GLOBAL, &extinfo);
+ game_library = dlopen(name, RTLD_NOW|RTLD_GLOBAL);
+ Com_Printf("Loading library: %s\n", name);
+ }
+#endif
+
+#else
+ Com_Printf("Loading library: %s\n", name);
+#endif

/* now run through the search paths */
path = NULL;
Expand All @@ -150,19 +171,19 @@ index 9f241440..acdd7e81 100644
path = FS_NextPath(path);

if (!path)
@@ -377,7 +403,11 @@ Sys_GetGameAPI(void *parms)
@@ -377,7 +424,11 @@ Sys_GetGameAPI(void *parms)
return NULL; /* couldn't find one anywhere */
}

+#ifndef ANDROID
snprintf(name, MAX_OSPATH, "%s/%s", path, gamename);
+#else
+ snprintf(name, MAX_OSPATH, "%s/lib%s", path, gamename);
+ snprintf(name, MAX_OSPATH, "%s/lib%s.so", path, gamename);
+#endif

/* skip it if it just doesn't exist */
fp = fopen(name, "rb");
@@ -438,7 +468,7 @@ Sys_Mkdir(const char *path)
@@ -438,7 +489,7 @@ Sys_Mkdir(const char *path)
{
if (mkdir(path, 0755) != 0)
{
Expand All @@ -171,7 +192,7 @@ index 9f241440..acdd7e81 100644
}
}
}
@@ -479,6 +509,10 @@ char *
@@ -479,6 +530,10 @@ char *
Sys_GetHomeDir(void)
{
static char gdir[MAX_OSPATH];
Expand Down Expand Up @@ -266,6 +287,32 @@ index a548ce8a..edd54d04 100644
CL_PredictMovement();

if (!cl.refresh_prepped && (cls.state == ca_active))
diff --git a/src/client/cl_screen.c b/src/client/cl_screen.c
index 00e9cd18..ea99f9a5 100644
--- a/src/client/cl_screen.c
+++ b/src/client/cl_screen.c
@@ -1521,18 +1521,18 @@ SCR_UpdateScreen(void)
return; /* not initialized yet */
}

- if ( gl1_stereo->value )
+ //if ( gl1_stereo->value )
{
numframes = 2;
separation[0] = -gl1_stereo_separation->value / 2;
separation[1] = +gl1_stereo_separation->value / 2;
}
- else
+ /*else
{
separation[0] = 0;
separation[1] = 0;
numframes = 1;
- }
+ }*/

for (i = 0; i < numframes; i++)
{
diff --git a/src/client/header/client.h b/src/client/header/client.h
index 04471802..abbc0bb4 100644
--- a/src/client/header/client.h
Expand Down Expand Up @@ -322,7 +369,7 @@ index f5fd4a2a..b624a26c 100644

if (joystick_forwardmove)
diff --git a/src/client/menu/menu.c b/src/client/menu/menu.c
index 270be5f7..f73cc295 100644
index 270be5f7..0b90aba3 100644
--- a/src/client/menu/menu.c
+++ b/src/client/menu/menu.c
@@ -226,24 +226,28 @@ Key_GetMenuKey(int key)
Expand Down Expand Up @@ -398,6 +445,16 @@ index 270be5f7..f73cc295 100644
{
case K_KP_ENTER:
case K_ENTER:
@@ -4933,7 +4934,8 @@ M_Init(void)

/* initialize the server address book cvars (adr0, adr1, ...)
* so the entries are not lost if you don't open the address book */
- for (int index = 0; index < NUM_ADDRESSBOOK_ENTRIES; index++)
+ Cvar_Get("adr0", "echoline.org", CVAR_ARCHIVE);
+ for (int index = 1; index < NUM_ADDRESSBOOK_ENTRIES; index++)
{
char buffer[20];
Com_sprintf(buffer, sizeof(buffer), "adr%d", index);
diff --git a/src/client/menu/videomenu.c b/src/client/menu/videomenu.c
index bfabcea3..9ef23c53 100644
--- a/src/client/menu/videomenu.c
Expand All @@ -414,7 +471,7 @@ index bfabcea3..9ef23c53 100644
// only show this option if we have multiple displays
if (GLimp_GetNumVideoDisplays() > 1)
diff --git a/src/client/refresh/gl3/gl3_draw.c b/src/client/refresh/gl3/gl3_draw.c
index 48ea046f..c388acad 100644
index 48ea046f..09d491f8 100644
--- a/src/client/refresh/gl3/gl3_draw.c
+++ b/src/client/refresh/gl3/gl3_draw.c
@@ -33,6 +33,8 @@ gl3image_t *draw_chars;
Expand All @@ -439,6 +496,59 @@ index 48ea046f..c388acad 100644
GL3_UseProgram(gl3state.si2D.shaderProgram);

glEnableVertexAttribArray(GL3_ATTRIB_POSITION);
@@ -300,6 +308,7 @@ GL3_Draw_Fill(int x, int y, int w, int h, int c)
void
GL3_Draw_Flash(const float color[4], float x, float y, float w, float h)
{
+#ifndef ANDROID
int i=0;

GLfloat vBuf[8] = {
@@ -326,13 +335,44 @@ GL3_Draw_Flash(const float color[4], float x, float y, float w, float h)
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

glDisable(GL_BLEND);
+#endif
}

void
GL3_Draw_FadeScreen(void)
{
float color[4] = {0, 0, 0, 0.6f};
+#ifndef ANDROID
GL3_Draw_Flash(color, 0, 0, vid.width, vid.height);
+#else
+ int i=0;
+ int x = 0, y = 0, h = vid.height, w = vid.width;
+
+ GLfloat vBuf[8] = {
+ // X, Y
+ x, y+h,
+ x, y,
+ x+w, y+h,
+ x+w, y
+ };
+
+ glEnable(GL_BLEND);
+
+ for(i=0; i<4; ++i) gl3state.uniCommonData.color.Elements[i] = color[i];
+
+ GL3_UpdateUBOCommon();
+
+ GL3_UseProgram(gl3state.si2Dcolor.shaderProgram);
+
+ GL3_BindVAO(vao2Dcolor);
+
+ GL3_BindVBO(vbo2D);
+ glBufferData(GL_ARRAY_BUFFER, sizeof(vBuf), vBuf, GL_STREAM_DRAW);
+
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+
+ glDisable(GL_BLEND);
+#endif
}

void
diff --git a/src/client/refresh/gl3/gl3_image.c b/src/client/refresh/gl3/gl3_image.c
index f5dfc161..ad9cd0e6 100644
--- a/src/client/refresh/gl3/gl3_image.c
Expand All @@ -453,7 +563,7 @@ index f5dfc161..ad9cd0e6 100644
if ((glt->type != it_pic) && (glt->type != it_sky)) /* mipmapped texture */
{
diff --git a/src/client/refresh/gl3/gl3_main.c b/src/client/refresh/gl3/gl3_main.c
index e1f63877..c8090cb2 100644
index e1f63877..b6078087 100644
--- a/src/client/refresh/gl3/gl3_main.c
+++ b/src/client/refresh/gl3/gl3_main.c
@@ -38,6 +38,12 @@
Expand Down Expand Up @@ -493,11 +603,20 @@ index e1f63877..c8090cb2 100644
- r_customwidth = ri.Cvar_Get("r_customwidth", "1024", CVAR_ARCHIVE);
- r_customheight = ri.Cvar_Get("r_customheight", "768", CVAR_ARCHIVE);
+ r_mode = ri.Cvar_Get("r_mode", "-1", CVAR_ARCHIVE);
+ r_customwidth = ri.Cvar_Get("r_customwidth", "400", CVAR_ARCHIVE);
+ r_customheight = ri.Cvar_Get("r_customheight", "400", CVAR_ARCHIVE);
+ r_customwidth = ri.Cvar_Get("r_customwidth", "300", CVAR_ARCHIVE);
+ r_customheight = ri.Cvar_Get("r_customheight", "300", CVAR_ARCHIVE);
gl3_particle_size = ri.Cvar_Get("gl3_particle_size", "40", CVAR_ARCHIVE);
gl3_particle_fade_factor = ri.Cvar_Get("gl3_particle_fade_factor", "1.2", CVAR_ARCHIVE);
gl3_particle_square = ri.Cvar_Get("gl3_particle_square", "0", CVAR_ARCHIVE);
@@ -227,7 +237,7 @@ GL3_Register(void)
gl_anisotropic = ri.Cvar_Get("r_anisotropic", "0", CVAR_ARCHIVE);

vid_fullscreen = ri.Cvar_Get("vid_fullscreen", "0", CVAR_ARCHIVE);
- vid_gamma = ri.Cvar_Get("vid_gamma", "1.2", CVAR_ARCHIVE);
+ vid_gamma = ri.Cvar_Get("vid_gamma", "1.9", CVAR_ARCHIVE);
gl3_intensity = ri.Cvar_Get("gl3_intensity", "1.5", CVAR_ARCHIVE);
gl3_intensity_2D = ri.Cvar_Get("gl3_intensity_2D", "1.5", CVAR_ARCHIVE);

@@ -366,69 +376,93 @@ SetMode_impl(int *pwidth, int *pheight, int mode, int fullscreen)
}

Expand Down Expand Up @@ -574,8 +693,8 @@ index e1f63877..c8090cb2 100644
+
+ /* a bit hackish approach to enable custom resolutions:
+ Glimp_SetMode needs these values set for mode -1 */
+ vid.width = r_customwidth->value;
+ vid.height = r_customheight->value;
+ vid.width = 300; //r_customwidth->value;
+ vid.height = 300; //r_customheight->value;
+ r_mode->value = -1;
+
+ if ((err = SetMode_impl(&vid.width, &vid.height, r_mode->value, fullscreen)) == rserr_ok) {
Expand Down Expand Up @@ -630,15 +749,15 @@ index e1f63877..c8090cb2 100644
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, 800, 400, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, 600, 300, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
+ if (glGetError() != GL_NO_ERROR)
+ Sys_Error("error 1");
+
+ SetTexture(texture_);
+
+ glGenRenderbuffers(1, &depthrenderbuffer);
+ glBindRenderbuffer(GL_RENDERBUFFER, depthrenderbuffer);
+ glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 800, 400);
+ glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 600, 300);
+ if (glGetError() != GL_NO_ERROR)
+ Sys_Error("error 2");
+
Expand Down Expand Up @@ -1149,7 +1268,7 @@ index 4fabb6a8..52747dc1 100644

/* Match to well-known muzzle flash sound names. */
diff --git a/src/client/vid/glimp_sdl.c b/src/client/vid/glimp_sdl.c
index 36cfbdcc..ce305502 100755
index 36cfbdcc..c349b6c4 100755
--- a/src/client/vid/glimp_sdl.c
+++ b/src/client/vid/glimp_sdl.c
@@ -30,8 +30,8 @@
Expand All @@ -1168,7 +1287,7 @@ index 36cfbdcc..ce305502 100755
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
}
- else if (width != 640 || height != 480 || (flags & fs_flag))
+ else if (width != 400 || height != 400 || (flags & fs_flag))
+ else if (width != 300 || height != 300 || (flags & fs_flag))
{
Com_Printf("SDL SetVideoMode failed: %s\n", SDL_GetError());
- Com_Printf("Reverting to windowed r_mode 4 (640x480).\n");
Expand All @@ -1183,13 +1302,13 @@ index 36cfbdcc..ce305502 100755
fullscreen = 0;
- *pwidth = width = 640;
- *pheight = height = 480;
+ *pwidth = width = 400;
+ *pheight = height = 400;
+ *pwidth = width = 300;
+ *pheight = height = 300;
flags &= ~fs_flag;
}
else
diff --git a/src/client/vid/vid.c b/src/client/vid/vid.c
index 0857e573..18c9ed1f 100644
index e6da7d5b..077cc6c6 100644
--- a/src/client/vid/vid.c
+++ b/src/client/vid/vid.c
@@ -30,6 +30,9 @@
Expand Down Expand Up @@ -1228,7 +1347,7 @@ index 0857e573..18c9ed1f 100644

// Fill in the struct exported to the renderer.
// FIXME: Do we really need all these?
@@ -495,8 +502,13 @@ VID_CheckChanges(void)
@@ -504,8 +511,13 @@ VID_CheckChanges(void)
* Initializes the video stuff.
*/
void
Expand All @@ -1244,7 +1363,7 @@ index 0857e573..18c9ed1f 100644
// Console variables
vid_gamma = Cvar_Get("vid_gamma", "1.0", CVAR_ARCHIVE);
vid_fullscreen = Cvar_Get("vid_fullscreen", "0", CVAR_ARCHIVE);
@@ -523,8 +535,10 @@ VID_Init(void)
@@ -532,8 +544,10 @@ VID_Init(void)
void
VID_Shutdown(void)
{
Expand Down Expand Up @@ -1313,17 +1432,18 @@ index 474ec5a2..ebdc248d 100644

void
diff --git a/src/common/header/shared.h b/src/common/header/shared.h
index 74b5088a..136fc2db 100644
index 74b5088a..74727e72 100644
--- a/src/common/header/shared.h
+++ b/src/common/header/shared.h
@@ -46,7 +46,9 @@
@@ -46,7 +46,10 @@
#undef false
#endif

-typedef enum {false, true} qboolean;
+typedef unsigned char qboolean;
+#define true 1
+#define false 0
+#define true 1
+typedef int qboolean;
+
typedef unsigned char byte;

#ifndef NULL

0 comments on commit 0de555f

Please sign in to comment.