From 8e50f47aa4b3b7b986a4947d5e320ef95f96287d Mon Sep 17 00:00:00 2001 From: terminx Date: Wed, 30 Jan 2019 00:19:56 +0000 Subject: [PATCH] rotatesprite hack from Fox git-svn-id: https://svn.eduke32.com/eduke32@7321 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/build/include/build.h | 3 +++ source/build/src/baselayer.cpp | 2 ++ source/build/src/engine.cpp | 9 +++++++++ source/duke3d/src/gamedef.h | 2 ++ source/duke3d/src/gamestructures.cpp | 6 ++++++ source/duke3d/src/menus.cpp | 1 + 6 files changed, 23 insertions(+) diff --git a/source/build/include/build.h b/source/build/include/build.h index 9d0b64860..25155e922 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -668,6 +668,9 @@ EXTERN int32_t xdim, ydim, numpages, upscalefactor; EXTERN int32_t yxaspect, viewingrange; EXTERN intptr_t *ylookup; +EXTERN int32_t rotatesprite_y_offset; +EXTERN int32_t rotatesprite_yxaspect; + #ifndef GEKKO #define MAXVALIDMODES 256 #else diff --git a/source/build/src/baselayer.cpp b/source/build/src/baselayer.cpp index 33b9f6743..b23b1ae89 100644 --- a/source/build/src/baselayer.cpp +++ b/source/build/src/baselayer.cpp @@ -118,6 +118,8 @@ int32_t mouseReadAbs(vec2_t * const pResult, vec2_t const * const pInput) pResult->x = scale(pInput->x, xwidth, xres) - ((xwidth>>1) - (320<<15)); pResult->y = scale(pInput->y, 200<<16, yres); + pResult->y = divscale16(pResult->y - (200<<15), rotatesprite_yxaspect) + (200<<15) - rotatesprite_y_offset; + return 1; } diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index d4e397f8a..abac8d505 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -6379,6 +6379,8 @@ void dorotspr_handle_bit2(int32_t *sxptr, int32_t *syptr, int32_t *z, int32_t da int32_t zoomsc, sx=*sxptr, sy=*syptr; int32_t ouryxaspect = yxaspect, ourxyaspect = xyaspect; + sy += rotatesprite_y_offset; + // screen center to s[xy], 320<<16 coords. const int32_t normxofs = sx-(320<<15), normyofs = sy-(200<<15); @@ -6393,6 +6395,9 @@ void dorotspr_handle_bit2(int32_t *sxptr, int32_t *syptr, int32_t *z, int32_t da ourxyaspect = (10<<16)/12; } + ouryxaspect = mulscale16(ouryxaspect, rotatesprite_yxaspect); + ourxyaspect = divscale16(ourxyaspect, rotatesprite_yxaspect); + // nasty hacks go here if (!(dastat & RS_NOCLIP)) { @@ -6414,6 +6419,7 @@ void dorotspr_handle_bit2(int32_t *sxptr, int32_t *syptr, int32_t *z, int32_t da sx = ((twice_midcx+xbord)<<15) + scaledxofs; zoomsc = xdimenscale; //= scale(xdimen,yxaspect,320); + zoomsc = mulscale16(zoomsc, rotatesprite_yxaspect); if ((dastat & RS_ALIGN_MASK) == RS_ALIGN_MASK) zoomsc = scale(zoomsc, ydim, oydim); @@ -7692,6 +7698,9 @@ int32_t engineInit(void) xyaspect = -1; + rotatesprite_y_offset = 0; + rotatesprite_yxaspect = 65536; + showinvisibility = 0; for (i=1; i<1024; i++) diff --git a/source/duke3d/src/gamedef.h b/source/duke3d/src/gamedef.h index e4c8869bf..886c0a538 100644 --- a/source/duke3d/src/gamedef.h +++ b/source/duke3d/src/gamedef.h @@ -625,6 +625,8 @@ enum UserdefsLabel_t USERDEFS_RETURN, USERDEFS_USERBYTEVERSION, USERDEFS_AUTOSAVE, + USERDEFS_DRAW_Y, + USERDEFS_DRAW_YXASPECT, USERDEFS_END }; diff --git a/source/duke3d/src/gamestructures.cpp b/source/duke3d/src/gamestructures.cpp index 67ee16be3..7f06f922e 100644 --- a/source/duke3d/src/gamestructures.cpp +++ b/source/duke3d/src/gamestructures.cpp @@ -1344,6 +1344,8 @@ const memberlabel_t UserdefsLabels[]= { "return", USERDEFS_RETURN, LABEL_HASPARM2, MAX_RETURN_VALUES, -1 }, { "userbyteversion", USERDEFS_USERBYTEVERSION, 0, 0, -1 }, { "autosave", USERDEFS_AUTOSAVE, 0, 0, -1 }, + { "draw_y", USERDEFS_DRAW_Y, 0, 0, -1 }, + { "draw_yxaspect", USERDEFS_DRAW_YXASPECT, 0, 0, -1 }, }; int32_t __fastcall VM_GetUserdef(int32_t labelNum, int const lParm2) @@ -1531,6 +1533,8 @@ int32_t __fastcall VM_GetUserdef(int32_t labelNum, int const lParm2) break; case USERDEFS_USERBYTEVERSION: labelNum = ud.userbytever; break; case USERDEFS_AUTOSAVE: labelNum = ud.autosave; break; + case USERDEFS_DRAW_Y: labelNum = rotatesprite_y_offset; break; + case USERDEFS_DRAW_YXASPECT: labelNum = rotatesprite_yxaspect; break; default: EDUKE32_UNREACHABLE_SECTION(labelNum = -1; break); } @@ -1730,6 +1734,8 @@ void __fastcall VM_SetUserdef(int const labelNum, int const lParm2, int32_t cons break; case USERDEFS_USERBYTEVERSION: ud.userbytever = iSet; break; case USERDEFS_AUTOSAVE: ud.autosave = iSet; break; + case USERDEFS_DRAW_Y: rotatesprite_y_offset = iSet; break; + case USERDEFS_DRAW_YXASPECT: rotatesprite_yxaspect = iSet; break; } } diff --git a/source/duke3d/src/menus.cpp b/source/duke3d/src/menus.cpp index b00ad605b..3fb005bb5 100644 --- a/source/duke3d/src/menus.cpp +++ b/source/duke3d/src/menus.cpp @@ -4357,6 +4357,7 @@ static int32_t xdim_from_320_16(int32_t x) } static int32_t ydim_from_200_16(int32_t y) { + y = mulscale16(y + rotatesprite_y_offset - (200<<15), rotatesprite_yxaspect) + (200<<15); return scale(y, ydim, 200<<16); }