From 61058cab741e9e6d3a69526c8280099f5ba6e470 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 6 Mar 2016 21:48:37 +0000 Subject: [PATCH] So many improvements! - Enabled 32 bit colour mode - Allowed any resolution (default now 800x600 for speed) - Improve world scale a bit - Reduce size of player sprite and give a bit of depth for comfort - Make DVR logo spin --- app/jni/build.bat | 4 +- app/jni/prboom/d_main.c | 14 +++-- app/jni/prboom/i_video.c | 55 ++++++++++++++----- app/jni/prboom/i_video_jni.c | 9 ++- app/jni/prboom/r_fps.c | 2 +- app/jni/prboom/r_main.c | 6 +- app/jni/prboom/r_things.c | 11 +++- app/jni/prboom/v_video.c | 2 +- app/src/main/assets/DVR.cfg | 6 +- .../java/com/drbeef/dvr/MainActivity.java | 27 +++++---- app/src/main/java/com/drbeef/dvr/OpenGL.java | 11 ++-- .../main/java/com/drbeef/dvr/WADChooser.java | 6 +- 12 files changed, 93 insertions(+), 60 deletions(-) diff --git a/app/jni/build.bat b/app/jni/build.bat index f582bd9..6e68bc0 100644 --- a/app/jni/build.bat +++ b/app/jni/build.bat @@ -11,6 +11,6 @@ rename libs.zip libs.jar REM Create an archive of the source cd ..\src\main\assets\source -REM del D-VRSource.zip -REM 7z a -r -x!.git* -x!*.o -x!*.d -x!obj -x!*.bin -x!app\build -x!app\libs -x!*.jar -x!*.so -x!*.log -x!*.jks -x!*.apk D-VRSource.zip ..\..\..\..\..\* +REM del DVRSource.zip +REM 7z a -r -x!.git* -x!*.o -x!*.d -x!obj -x!*.bin -x!app\build -x!app\libs -x!*.jar -x!*.so -x!*.log -x!*.jks -x!*.apk DVRSource.zip ..\..\..\..\..\* cd ..\..\..\..\jni diff --git a/app/jni/prboom/d_main.c b/app/jni/prboom/d_main.c index 1178029..7ae1084 100644 --- a/app/jni/prboom/d_main.c +++ b/app/jni/prboom/d_main.c @@ -179,7 +179,7 @@ void D_PostEvent(event_t *ev) static void D_Wipe(int eye) { - /* + boolean done; int wipestart = I_GetTime () - 1; @@ -200,7 +200,7 @@ static void D_Wipe(int eye) I_FinishUpdate(eye); // page flip or blit buffer } while (!done); - */ + M_Drawer(); // menu is drawn even on top of wipes I_FinishUpdate(eye); // page flip or blit buffer @@ -215,6 +215,7 @@ static void D_Wipe(int eye) gamestate_t wipegamestate = GS_DEMOSCREEN; extern boolean setsizeneeded; extern int showMessages; +int current_eye; void D_Display (int eye) { @@ -224,6 +225,7 @@ void D_Display (int eye) static gamestate_t oldgamestate = -1; boolean wipe; boolean viewactive = false, isborder = false; + current_eye = eye; if (nodrawers) // for comparative timing / profiling return; @@ -323,11 +325,11 @@ void D_Display (int eye) // normal update // if (!wipe || (V_GetMode() == VID_MODEGL)) I_FinishUpdate (eye); // page flip or blit buffer -// else { +/* else { // wipe update -// wipe_EndScreen(); -// D_Wipe(eye); -// } + wipe_EndScreen(); + D_Wipe(eye); + }*/ if (eye == 1) { I_EndDisplay(); diff --git a/app/jni/prboom/i_video.c b/app/jni/prboom/i_video.c index ed342f0..ab6e0ef 100644 --- a/app/jni/prboom/i_video.c +++ b/app/jni/prboom/i_video.c @@ -37,6 +37,7 @@ #endif #include +#include #ifdef HAVE_UNISTD_H #include @@ -454,24 +455,48 @@ static int newpal = 0; void I_FinishUpdate (int eye) { +// __android_log_print(ANDROID_LOG_INFO, "I_FinishUpdate", "got this far!"); + if (I_SkipFrame()) return; // screen size int size = SCREENWIDTH * SCREENHEIGHT; // ARGB pixels - int pixels[size], i; + static int *pixels = 0; + if (V_GetMode() == VID_MODE32) { + /*for (i = 0; i < size; i++) { + byte r = screens[0].data[i * 4]; + byte g = screens[0].data[i * 4 + 1]; + byte b = screens[0].data[i * 4 + 2]; + //alpha is ignored + byte a = screens[0].data[i * 4 + 3]; - for ( i = 0 ; i < size ; i ++) { - byte b = screens[0].data[i]; + pixels[i] = (0xFF << 24) + | (b << 16) + | (g << 8) + | r; + }*/ + //memcpy(pixels, screens[0].data, size * sizeof(int)); - XColor color = colours[b]; - - pixels[i] = (0xFF << 24) - | (color.red << 16) - | (color.green << 8) - | color.blue; + //We can literally just pass the pointer to the screen buffer + pixels = (int*)screens[0].data; + } + else if (V_GetMode() == VID_MODE8) { + if (!pixels) + { + pixels = (int*)malloc(size * sizeof(int) + 1); + } + int i; + for (i = 0; i < size; i++) { + byte b = screens[0].data[i]; + XColor color = colours[b]; + pixels[i] = (0xFF << 24) + | (color.red << 16) + | (color.green << 8) + | color.blue; + } } // Send pixels to java @@ -656,11 +681,11 @@ void I_CalculateRes(unsigned int width, unsigned int height) } else { */ SCREENWIDTH = (width+15) & ~15; SCREENHEIGHT = height; - if (!(SCREENWIDTH % 1024)) { - SCREENPITCH = SCREENWIDTH*V_GetPixelDepth()+32; - } else { +// if (!(SCREENWIDTH % 1024)) { +// SCREENPITCH = SCREENWIDTH*V_GetPixelDepth()+32; +// } else { SCREENPITCH = SCREENWIDTH*V_GetPixelDepth(); - } +// } // } } @@ -671,12 +696,12 @@ void I_SetRes(void) { int i; + I_CalculateRes(SCREENWIDTH, SCREENHEIGHT); + // Tell Java graphics have inited jni_printf("I_SetRes: Creating %dx%d image.", SCREENWIDTH, SCREENHEIGHT); jni_init_graphics(SCREENWIDTH, SCREENHEIGHT); - I_CalculateRes(SCREENWIDTH, SCREENHEIGHT); - // set first three to standard values for (i=0; i<3; i++) { screens[i].width = SCREENWIDTH; diff --git a/app/jni/prboom/i_video_jni.c b/app/jni/prboom/i_video_jni.c index 5c374be..049669c 100644 --- a/app/jni/prboom/i_video_jni.c +++ b/app/jni/prboom/i_video_jni.c @@ -460,11 +460,16 @@ void I_UpdateNoBlit (void) void I_FinishUpdate (int eye) { // Get pixels - int i; int size = X_width * X_height; // ARGB pixels - int pixels[size]; + // ARGB pixels + static int *pixels = 0; + if (!pixels) + { + pixels = (int*)malloc(size * sizeof(int) + 1); + } + int i; //printf("I_FinishUpdate\n"); diff --git a/app/jni/prboom/r_fps.c b/app/jni/prboom/r_fps.c index 6f792d5..10a9d07 100644 --- a/app/jni/prboom/r_fps.c +++ b/app/jni/prboom/r_fps.c @@ -63,7 +63,7 @@ tic_vars_t tic_vars; view_vars_t original_view_vars; -fixed_t r_stereo_offset = 0x40000; +fixed_t r_stereo_offset = 0x30000; extern int realtic_clock_rate; void D_Display(void); diff --git a/app/jni/prboom/r_main.c b/app/jni/prboom/r_main.c index 4254503..746d284 100644 --- a/app/jni/prboom/r_main.c +++ b/app/jni/prboom/r_main.c @@ -400,10 +400,10 @@ void R_ExecuteSetViewSize (void) // psprite scales // proff 08/17/98: Changed for high-res - pspritescale = FRACUNIT*viewwidth/320; - pspriteiscale = FRACUNIT*320/viewwidth; + pspritescale = FRACUNIT*viewwidth/480; + pspriteiscale = FRACUNIT*480/viewwidth; // proff 11/06/98: Added for high-res - pspriteyscale = (((SCREENHEIGHT*viewwidth)/SCREENWIDTH) << FRACBITS) / 200; + pspriteyscale = (((SCREENHEIGHT*viewwidth)/SCREENWIDTH) << FRACBITS) / 300; // thing clipping for (i=0 ; i #define MINZ (FRACUNIT*4) #define BASEYCENTER 100 @@ -86,6 +87,8 @@ int numsprites; static spriteframe_t sprtemp[MAX_SPRITE_FRAMES]; static int maxframe; +extern int current_eye; + // // R_InstallSpriteLump // Local function for R_InitSprites. @@ -725,14 +728,16 @@ static void R_DrawPSprite (pspdef_t *psp, int lightlevel) fixed_t tx; tx = psp->sx-160*FRACUNIT; + int r_stereo_offset = (current_eye == 0) ? 35 : -35; + tx -= patch->leftoffset<>FRACBITS; + x1 = ((centerxfrac + FixedMul (tx,pspritescale))>>FRACBITS) + r_stereo_offset; tx += patch->width<>FRACBITS) - 1; + x2 = (((centerxfrac + FixedMul (tx, pspritescale) ) >>FRACBITS) - 1) + r_stereo_offset; width = patch->width; - topoffset = patch->topoffset<topoffset - 30)<", 16, 220, paint); + canvas.drawText("<- " + GetChosenWAD() + " ->", 24, 220, paint); openGL.CopyBitmapToTexture(bitmap, openGL.fbo.ColorTexture[0]); } @@ -161,7 +159,7 @@ public class WADChooser { // Object first appears directly in front of user. Matrix.setIdentityM(openGL.modelScreen, 0); Matrix.translateM(openGL.modelScreen, 0, 0, 0, -openGL.screenDistance); - Matrix.scaleM(openGL.modelScreen, 0, openGL.wadChooserScale, openGL.wadChooserScale, 1.0f); + Matrix.scaleM(openGL.modelScreen, 0, openGL.screenScale, openGL.screenScale, 1.0f); Matrix.multiplyMM(openGL.modelView, 0, openGL.view, 0, openGL.modelScreen, 0); Matrix.multiplyMM(openGL.modelViewProjection, 0, perspective, 0, openGL.modelView, 0); GLES20.glVertexAttribPointer(openGL.positionParam, 3, GLES20.GL_FLOAT, false, 0, openGL.screenVertices);