Merge remote-tracking branch 'origin/Saturn-Next' into lugstuff
This commit is contained in:
commit
32c371b981
13 files changed
+175
-269
No files matched your search
@@ -1,104 +1,36 @@
|
||||
# SRB2Kart: Saturn
|
||||
# SRB2Kart-Saturn
|
||||
|
||||
SRB2Kart-Saturn is a modification of SRB2Kart with a focus on new Features, Fixes, Optimizations and general Improvements, all while retaining 100% compatibility with vanilla SRB2Kart.
|
||||
|
||||
[SRB2Kart](https://srb2.org/mods/) is a kart racing mod based on the 3D Sonic the Hedgehog fangame [Sonic Robo Blast 2](https://srb2.org/), based on a modified version of [Doom Legacy](http://doomlegacy.sourceforge.net/).
|
||||
|
||||
## Saturn Features (Take a look at the "Saturn Options" menu c;)
|
||||
For more information on Saturn´s features check out the changelogs on the [Releases](https://github.com/Indev450/SRB2Kart-Saturn/releases) page and the ingame "Saturn Options" menu.
|
||||
|
||||
- Sprites player rotation on slopes; going on hills, levitate, going down, and so on alters your sprites (configurable)
|
||||
- You can alter all the base kart HUD element offsets on the fly in the Saturn Options settings menu
|
||||
- `addfilelocal` Command, for those who want to use things like their custom hud in netgames (Same as addfile but completely client sided)
|
||||
- Palette rendering, make the OpenGL renderer (almost) look like software mode!
|
||||
- OpenMPT for Tracker module playback instead of GME
|
||||
- Fixes looping and sounds better
|
||||
- Allows filter configuration
|
||||
- Colourize your Kart HUD, to either your player color or whichever colour you like! (optional / requieres extra2.kart file)
|
||||
- The minimal brightness with Shaders can be configured, now you can seeeee in dark areas (0-255 , uses Sector brightness values)
|
||||
- Lua HUD hooks for Intermission (ex: You can make hostmod votes still visible during intermission!)
|
||||
- Lua HUD hooks for Vote Screen (ex: You can make hostmod votes still visible during map vote screen!)
|
||||
- Saltyhop! do a funny hop
|
||||
- Smaller Speedometer (optional / requieres extra.kart file)
|
||||
- Record Attack input display can now be used everywhere
|
||||
- Smaller minimap icons and also show player names on the minimap (toggable)
|
||||
- Support for animated votescreens!
|
||||
- `showmusiccredit` command, shows you the current music track again
|
||||
- `listskins` show a list of all skins currently loaded
|
||||
- Visual Portals from Haya's HEP Client
|
||||
- Horizonline effect in OpenGL (watch the endless bricks on SNES Bowsers Castle!)
|
||||
- Localskins! use whatever skin you like!
|
||||
- Toggable lowercase menu's also from Haya's HEP client
|
||||
- Everything that Galaxy has
|
||||
Also be sure to check the LUASTUFF file for more information on all the extra lua features Saturn has.
|
||||
|
||||
## Improvements / Bug fixes
|
||||
|
||||
- Replay size has been increased to 10MiB minimum, to make replay overflows very unlikely to happen
|
||||
- can be set to 100MiB max with `maxdemosize` command in console
|
||||
- Music changes now properly show the music credits (ex: Kart maps with easter eggs that alter the music)
|
||||
- The mapper still has to provide a MusicDEF for this to work.
|
||||
- Configurable chatlog length (yay can read those messages from 30 mins ago without opening log.txt)
|
||||
- Configurable timeout for waiting to join a full server (in vanilla this is capped to 5 minutes before it boots you out)
|
||||
- Characters now spin in skin selection menu (configurable)
|
||||
- HTTP Addon download speed has been raised dramatically
|
||||
- configurable with `downloadspeed` command
|
||||
- HWR Drawnodes have been refactored, this should fix a few rare crashes esp in regards to OpenGL Visportals
|
||||
- The Position Number in the corner is alot smaller now (half the size!)
|
||||
- Toggable Lap animation
|
||||
- Main menu shows the current renderer being used
|
||||
- MSAA and A2C Antialiasing support (Configurable in renderer.txt file)
|
||||
- A simple button to rejoin your last visited server
|
||||
- Ability to show ALL maps in the mapselect screen, this includes hidden or hellmaps "showallmaps yes/no"
|
||||
- Ability to toggle the Stagetitlecard "maptitles on/off"
|
||||
|
||||
## Performance / Debugging
|
||||
|
||||
- Access for `mobj_t` and `player_t` fields from Lua has been completely rewritten, for much better performance with many Lua scripts
|
||||
- Lua shows Tracebacks whenever an error occurs
|
||||
- The Lua Perfstats page now has multiple pages and is more organized (ps_thinkframe_page X in console)
|
||||
- People with lower end hardware can disable "screen textures" with "gr_screentextures" command, huge performance gain with minimal visual loss
|
||||
- Intermission backgrounds, heat wave effects and etc are broken with this
|
||||
- `ffloorclip`, exclusive to Software, which boosts performance on maps with many Floor over Floor sectors
|
||||
|
||||
## Technical fixes
|
||||
|
||||
- ZFigthing Textures in Opengl mode have been fixed in engine (well almost all of it)
|
||||
- FOFs intersecting with slopes have less issues and now render correctly in Opengl
|
||||
- Midtextures on slopes in Opengl are fixed, many weird guardrails and fences, aswell as some of those sticking out textures from the ground on some maps should be gone
|
||||
- The annoying depraction messages for `P_TeleportMove` and `P_AproxDistance` have been silenced
|
||||
- Silenced the annoying "cant find next map..." messages as theyre super useless and annoying anyways
|
||||
- Added a small cooldown on `map` command due to spamming causing a SIGSEGV
|
||||
- Many bugfixes to the Software renderer, so its much less prone to crashing
|
||||
- Many bugfixes to the OpenGL renderer (too many too list all of them here; check the changelogs for more information)
|
||||
- Bugfixes to the soundsystem, mainly regarding Sound muting
|
||||
- Refactored Zone Memory Allocations (helps a bit with large maps)
|
||||
- Many many more crash fixes and other bugfixes to the basegame (too many too list all of them here; check the changelogs for more information)
|
||||
|
||||
- Crash Backtraces have been replaced by libbacktrace (except for 32bit Windows builds)
|
||||
Crashlogs now contain alot more informations. and even more if your build has debug symbols
|
||||
Also allows 64bit Windows builds to produce Crashlogs!
|
||||
|
||||
## MISC
|
||||
- Bird's Camera Tilting feature is no longer turned on by default
|
||||
- Bird's warning on the title screen has been removed
|
||||
|
||||
## Bugs
|
||||
- On maps which change the song multiple times on map start (exp: Wandering Falls) may show multiple music credits appearing
|
||||
- A2C antialiasing makes transparent surfaces even more transparent
|
||||
- You tell us! c:
|
||||
|
||||
## Note
|
||||
Check the LUASTUFF file for more information on all the lua things Saturn has.
|
||||
We also have a Flatpak available on [Flathub](https://flathub.org/en/apps/org.srb2.SRB2Kart-Saturn)! (many thanks to riomccloud!)
|
||||
|
||||
## Dependencies
|
||||
- SDL2 (Linux/OS X only)
|
||||
- SDL2-Mixer (Linux/OS X only)
|
||||
- libupnp (Linux/OS X only)
|
||||
- libgme (Linux/OS X only)
|
||||
- libopenmpt (Linux/OS X only)
|
||||
- libbacktrace (Linux/OS X only)
|
||||
- libbacktrace (Linux/OS X only, optional, disable support with NOLIBBACKTRACE)
|
||||
- libupnp (Linux/OS X only, optional, enable support with HAVE_MINIUPNPC)
|
||||
|
||||
## Compiling
|
||||
|
||||
See [SRB2 Wiki/Source code compiling](http://wiki.srb2.org/wiki/Source_code_compiling). The compiling process for SRB2Kart is largely identical to SRB2.
|
||||
Visual C++ (MSVC) is unsupported
|
||||
|
||||
Currently only the Makefile build system with GCC or Clang compiler is supported.
|
||||
|
||||
Visual C++ (MSVC) is unsupported.
|
||||
|
||||
64-bit Windows builds are supported and recommended over 32-bit builds, they will build automatically when using the MSYS2 MinGW 64-bit executable (requires the mingw-w64-x86_64-gcc package), no extra flags needed!
|
||||
The specific DLLs can be found under /libs/dll-binaries/(i686 for 32bit/x86_64 for 64-bit)/ or in the Release packages
|
||||
|
||||
Alternatively the [srb2bld](https://github.com/Bijman/srb2bld) script by Bijman can be used aswell!
|
||||
|
||||
## Disclaimer
|
||||
Kart Krew is in no way affiliated with SEGA or Sonic Team. We do not claim ownership of any of SEGA's intellectual property used in SRB2.
|
||||
@@ -65,7 +65,7 @@ void I_WaitVBL(INT32 count)
|
||||
(void)count;
|
||||
}
|
||||
|
||||
void I_ReadScreen(UINT8 *scr)
|
||||
void I_ReadScreen(UINT8 * restrict scr, INT32 scale)
|
||||
{
|
||||
(void)scr;
|
||||
}
|
||||
|
||||
@@ -89,9 +89,10 @@ void I_UpdateNoVsync(void)
|
||||
//
|
||||
// I_ReadScreen
|
||||
//
|
||||
void I_ReadScreen(UINT8 *scr)
|
||||
void I_ReadScreen(UINT8 * restrict scr, INT32 scale)
|
||||
{
|
||||
(void)scr;
|
||||
(void)scale;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
+2
-2
@@ -314,7 +314,7 @@ void F_WipeStartScreen(void)
|
||||
}
|
||||
#endif
|
||||
wipe_scr_start = vid.screens[3];
|
||||
I_ReadScreen(wipe_scr_start);
|
||||
I_ReadScreen(wipe_scr_start, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -331,7 +331,7 @@ void F_WipeEndScreen(void)
|
||||
}
|
||||
#endif
|
||||
wipe_scr_end = vid.screens[4];
|
||||
I_ReadScreen(wipe_scr_end);
|
||||
I_ReadScreen(wipe_scr_end, 1);
|
||||
V_DrawBlock(0, 0, 0, vid.width, vid.height, wipe_scr_start);
|
||||
#endif
|
||||
}
|
||||
|
||||
+3
-28
@@ -23,7 +23,6 @@
|
||||
#include "hw_glob.h"
|
||||
#include "hw_gl.h"
|
||||
|
||||
#include "../m_misc.h" //FIL_WriteFile()
|
||||
#include "../r_draw.h" //viewborderlump
|
||||
#include "../r_main.h"
|
||||
#include "../w_wad.h"
|
||||
@@ -1218,42 +1217,18 @@ static inline boolean saveTGA(const char *file_name, void *buffer,
|
||||
// --------------------------------------------------------------------------
|
||||
// screen shot
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
UINT8 *HWR_GetScreenshot(void)
|
||||
UINT8 *HWR_GetScreenshot(INT32 scale)
|
||||
{
|
||||
static UINT8 *buf = NULL;
|
||||
|
||||
buf = realloc(buf, vid.width * vid.height * 3);
|
||||
buf = realloc(buf, (vid.width/scale)*(vid.height/scale)*3);
|
||||
|
||||
if (!buf)
|
||||
return NULL;
|
||||
|
||||
// returns 24bit 888 RGB
|
||||
GL_ReadScreenTexture(HWD_SCREENTEXTURE_GENERIC2, (void *)buf);
|
||||
GL_ReadScreenTexture(HWD_SCREENTEXTURE_GENERIC2, (void *)buf, scale);
|
||||
return buf;
|
||||
}
|
||||
|
||||
boolean HWR_Screenshot(const char *pathname)
|
||||
{
|
||||
boolean ret;
|
||||
UINT8 *buf = malloc(vid.width * vid.height * 3 * sizeof (*buf));
|
||||
|
||||
if (!buf)
|
||||
{
|
||||
CONS_Debug(DBG_RENDER, "HWR_Screenshot: Failed to allocate memory\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
// returns 24bit 888 RGB
|
||||
GL_ReadScreenTexture(HWD_SCREENTEXTURE_GENERIC2, (void *)buf);
|
||||
|
||||
#ifdef USE_PNG
|
||||
ret = M_SavePNG(pathname, buf, vid.width, vid.height, NULL);
|
||||
#else
|
||||
ret = saveTGA(pathname, buf, vid.width, vid.height);
|
||||
#endif
|
||||
free(buf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif //HWRENDER
|
||||
@@ -54,7 +54,7 @@ INT32 GL_GetTextureUsed(void);
|
||||
|
||||
void GL_CreateModelVBOs(model_t *model);
|
||||
|
||||
void GL_ReadScreenTexture(int tex, UINT16 *dst_data);
|
||||
void GL_ReadScreenTexture(int tex, UINT8 *dst_data, INT32 scale);
|
||||
void GL_GClipRect(INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip, float farclip);
|
||||
|
||||
void GL_MakeScreenTexture(int tex);
|
||||
|
||||
@@ -104,8 +104,7 @@ void HWR_DrawConsoleBack(UINT32 color, INT32 height);
|
||||
void HWR_DrawViewBorder(INT32 clearlines);
|
||||
void HWR_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum);
|
||||
|
||||
UINT8 *HWR_GetScreenshot(void);
|
||||
boolean HWR_Screenshot(const char *lbmname);
|
||||
UINT8 *HWR_GetScreenshot(INT32 scale);
|
||||
|
||||
// hw_main.c
|
||||
void HWR_SetViewSize(void);
|
||||
|
||||
@@ -41,6 +41,12 @@
|
||||
|
||||
#include "../../i_video.h"
|
||||
|
||||
// requires GL 4.3
|
||||
//#define GLDEBUGMESSAGE
|
||||
#ifdef GLDEBUGMESSAGE
|
||||
#include "../../console.h"
|
||||
#endif
|
||||
|
||||
#ifdef GLDEBUGMESSAGE
|
||||
#include "../../console.h"
|
||||
#endif
|
||||
@@ -1414,23 +1420,14 @@ void SetupGLInfo(void)
|
||||
sscanf((const char*)versionGL, "%d.%d", &majorGL, &minorGL);
|
||||
}
|
||||
|
||||
// Writes screen texture tex into dst_data.
|
||||
// Pixel format is 24-bit RGB. Row order is top to bottom.
|
||||
// Dimensions are screen_width * screen_height.
|
||||
void GL_ReadScreenTexture(int tex, UINT16 *dst_data)
|
||||
// ------------------+
|
||||
// ReadScreenTexture : Reads out a screen texture
|
||||
// ------------------+
|
||||
void GL_ReadScreenTexture(int tex, UINT8 *restrict dest, INT32 scale)
|
||||
{
|
||||
INT32 i;
|
||||
int dst_stride = screen_width * 3; // stride between rows of image data
|
||||
GLubyte *top, *bottom;
|
||||
GLubyte *row;
|
||||
|
||||
row = malloc(dst_stride);
|
||||
|
||||
if (!row)
|
||||
return;
|
||||
|
||||
top = (GLvoid*)dst_data;
|
||||
bottom = top + dst_stride * (screen_height - 1);
|
||||
const INT32 stride = (screen_width/scale)*3;
|
||||
INT32 scanlines = screen_height;
|
||||
GLubyte * restrict image;
|
||||
|
||||
// at the time this function is called, generic2 can be found drawn on the framebuffer
|
||||
// if some other screen texture is needed, draw it to the framebuffer
|
||||
@@ -1439,24 +1436,29 @@ void GL_ReadScreenTexture(int tex, UINT16 *dst_data)
|
||||
if (tex != HWD_SCREENTEXTURE_GENERIC2)
|
||||
GL_DrawScreenTexture(tex, NULL, 0);
|
||||
|
||||
image = malloc(screen_width*screen_height*3);
|
||||
pglPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||
pglReadPixels(0, 0, screen_width, screen_height, GL_RGB, GL_UNSIGNED_BYTE, dst_data);
|
||||
pglReadPixels(0, 0, screen_width, screen_height, GL_RGB, GL_UNSIGNED_BYTE, image);
|
||||
|
||||
if (tex != HWD_SCREENTEXTURE_GENERIC2)
|
||||
GL_DrawScreenTexture(HWD_SCREENTEXTURE_GENERIC2, NULL, 0);
|
||||
|
||||
// Flip image upside down.
|
||||
// In other words, convert OpenGL's "bottom->top" row order into "top->bottom".
|
||||
for (i = 0; i < screen_height/2; i++)
|
||||
// TODO the downscaling happens in the screen capture code now,
|
||||
// yet we're still doing this on the CPU? sheesh...
|
||||
// this is where actual knowledge of OpenGL would've come in handy
|
||||
image += scanlines*screen_width*3;
|
||||
while ((scanlines -= scale) >= 0)
|
||||
{
|
||||
memcpy(row, top, dst_stride);
|
||||
memcpy(top, bottom, dst_stride);
|
||||
memcpy(bottom, row, dst_stride);
|
||||
top += dst_stride;
|
||||
bottom -= dst_stride;
|
||||
image -= screen_width*scale*3;
|
||||
if (scale == 1)
|
||||
memcpy(dest, image, stride);
|
||||
else for (INT32 i = 0; i < stride; i += 3)
|
||||
memcpy(dest + i, image + i*scale, 3);
|
||||
dest += stride;
|
||||
}
|
||||
|
||||
free(row);
|
||||
// ...yet still, restrict doesn't make the inner loop any faster
|
||||
free(image - ((screen_height % scale) * screen_width*3));
|
||||
}
|
||||
|
||||
// -----------------+
|
||||
|
||||
+1
-1
@@ -126,7 +126,7 @@ void I_WaitVBL(INT32 count);
|
||||
|
||||
\return void
|
||||
*/
|
||||
void I_ReadScreen(UINT8 *scr);
|
||||
void I_ReadScreen(UINT8 * restrict scr, INT32 scale);
|
||||
|
||||
/** \brief Start disk icon
|
||||
*/
|
||||
|
||||
+83
-101
@@ -49,6 +49,15 @@ static precise_t gif_prevframetime = 0;
|
||||
static UINT32 gif_delayus = 0; // "us" is microseconds
|
||||
static UINT8 gif_writeover = 0;
|
||||
|
||||
// SCReen BUFfer (obviously)
|
||||
// ---
|
||||
static UINT8 *scrbuf_pos;
|
||||
static UINT8 *scrbuf_linebegin;
|
||||
static UINT8 *scrbuf_lineend;
|
||||
static UINT8 *scrbuf_writeend;
|
||||
static INT16 scrbuf_downscaleamt = 1;
|
||||
static UINT16 scrbuf_width, scrbuf_height;
|
||||
static UINT8 *scrbuf_screens;
|
||||
|
||||
// OPTIMIZE gif output
|
||||
// ---
|
||||
@@ -63,13 +72,13 @@ static UINT8 gif_writeover = 0;
|
||||
static UINT8 GIF_optimizecmprow(const UINT8 *dst, const UINT8 *src, INT32 row,
|
||||
INT32 *last, INT32 *left, INT32 *right)
|
||||
{
|
||||
const UINT8 *dp = dst + (vid.width * row);
|
||||
const UINT8 *sp = src + (vid.width * row);
|
||||
const UINT8 *dp = dst + (scrbuf_width * row);
|
||||
const UINT8 *sp = src + (scrbuf_width * row);
|
||||
const UINT8 *dtmp, *stmp;
|
||||
UINT8 doleft = 1, doright = 1;
|
||||
INT32 i = 0;
|
||||
|
||||
if (!memcmp(sp, dp, vid.width))
|
||||
if (!memcmp(sp, dp, scrbuf_width))
|
||||
return 0; // unchanged.
|
||||
|
||||
*last = row;
|
||||
@@ -96,14 +105,14 @@ static UINT8 GIF_optimizecmprow(const UINT8 *dst, const UINT8 *src, INT32 row,
|
||||
}
|
||||
|
||||
// right side
|
||||
i = vid.width - 1;
|
||||
if (*right == vid.width - 1) // edge reached
|
||||
i = scrbuf_width - 1;
|
||||
if (*right == scrbuf_width - 1) // edge reached
|
||||
doright = 0;
|
||||
else if (*right >= 0) // right set, non-end-of-width
|
||||
{
|
||||
dtmp = dp + *right + 1;
|
||||
stmp = sp + *right + 1;
|
||||
if (!memcmp(stmp, dtmp, vid.width - (*right + 1)))
|
||||
if (!memcmp(stmp, dtmp, scrbuf_width - (*right + 1)))
|
||||
doright = 0; // right side not changed
|
||||
}
|
||||
while (doright)
|
||||
@@ -133,7 +142,7 @@ static UINT8 GIF_optimizecmprow(const UINT8 *dst, const UINT8 *src, INT32 row,
|
||||
static void GIF_optimizeregion(const UINT8 *dst, const UINT8 *src,
|
||||
INT32 *x, INT32 *y, INT32 *w, INT32 *h)
|
||||
{
|
||||
INT32 st = 0, sb = vid.height - 1; // work from both directions
|
||||
INT32 st = 0, sb = scrbuf_height - 1; // work from both directions
|
||||
INT32 firstchg_t = -1, firstchg_b = -1; // store first changed row.
|
||||
INT32 lastchg_t = -1, lastchg_b = -1; // Store last row... just in case
|
||||
INT32 lmpix = -1, rmpix = -1; // store left and rightmost change
|
||||
@@ -144,7 +153,7 @@ static void GIF_optimizeregion(const UINT8 *dst, const UINT8 *src,
|
||||
if (!stopt)
|
||||
{
|
||||
if (GIF_optimizecmprow(dst, src, st++, &lastchg_t, &lmpix, &rmpix)
|
||||
&& lmpix == 0 && rmpix == vid.width - 1)
|
||||
&& lmpix == 0 && rmpix == scrbuf_width - 1)
|
||||
stopt = 1;
|
||||
if (firstchg_t < 0 && lastchg_t >= 0)
|
||||
firstchg_t = lastchg_t;
|
||||
@@ -152,7 +161,7 @@ static void GIF_optimizeregion(const UINT8 *dst, const UINT8 *src,
|
||||
if (!stopb)
|
||||
{
|
||||
if (GIF_optimizecmprow(dst, src, sb--, &lastchg_b, &lmpix, &rmpix)
|
||||
&& lmpix == 0 && rmpix == vid.width - 1)
|
||||
&& lmpix == 0 && rmpix == scrbuf_width - 1)
|
||||
stopb = 1;
|
||||
if (firstchg_b < 0 && lastchg_b >= 0)
|
||||
firstchg_b = lastchg_b;
|
||||
@@ -222,18 +231,6 @@ static void GIF_bwrwrite(UINT32 idata)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// SCReen BUFfer (obviously)
|
||||
// ---
|
||||
static UINT8 *scrbuf_pos;
|
||||
static UINT8 *scrbuf_linebegin;
|
||||
static UINT8 *scrbuf_lineend;
|
||||
static UINT8 *scrbuf_writeend;
|
||||
static INT16 scrbuf_downscaleamt = 1;
|
||||
|
||||
|
||||
|
||||
// GIF LZW algorithm
|
||||
// ---
|
||||
#define GIFLZW_TABLECLR 0x100
|
||||
@@ -359,12 +356,14 @@ static void GIF_lzw(void)
|
||||
GIF_bwrwrite(GIFLZW_TABLECLR);
|
||||
GIF_prepareLZW();
|
||||
}
|
||||
if ((scrbuf_pos += scrbuf_downscaleamt) >= scrbuf_lineend)
|
||||
|
||||
if (++scrbuf_pos >= scrbuf_lineend)
|
||||
{
|
||||
scrbuf_lineend += (vid.width * scrbuf_downscaleamt);
|
||||
scrbuf_linebegin += (vid.width * scrbuf_downscaleamt);
|
||||
scrbuf_lineend += scrbuf_width;
|
||||
scrbuf_linebegin += scrbuf_width;
|
||||
scrbuf_pos = scrbuf_linebegin;
|
||||
}
|
||||
|
||||
// Just a bit of overflow prevention
|
||||
if (gifbwr_bufsize >= 248)
|
||||
break;
|
||||
@@ -413,7 +412,6 @@ static void GIF_headwrite(void)
|
||||
UINT8 *p = gifhead;
|
||||
RGBA_t *c;
|
||||
INT32 i;
|
||||
UINT16 rwidth, rheight;
|
||||
|
||||
if (!gif_out)
|
||||
return;
|
||||
@@ -424,17 +422,18 @@ static void GIF_headwrite(void)
|
||||
if (gif_downscale)
|
||||
{
|
||||
scrbuf_downscaleamt = vid.dupx;
|
||||
rwidth = (vid.width / scrbuf_downscaleamt);
|
||||
rheight = (vid.height / scrbuf_downscaleamt);
|
||||
scrbuf_width = (vid.width / scrbuf_downscaleamt);
|
||||
scrbuf_height = (vid.height / scrbuf_downscaleamt);
|
||||
}
|
||||
else
|
||||
{
|
||||
scrbuf_downscaleamt = 1;
|
||||
rwidth = vid.width;
|
||||
rheight = vid.height;
|
||||
scrbuf_width = vid.width;
|
||||
scrbuf_height = vid.height;
|
||||
}
|
||||
WRITEUINT16(p, rwidth);
|
||||
WRITEUINT16(p, rheight);
|
||||
|
||||
WRITEUINT16(p, scrbuf_width);
|
||||
WRITEUINT16(p, scrbuf_height);
|
||||
|
||||
// colors, aspect, etc
|
||||
WRITEUINT8(p, 0xF7);
|
||||
@@ -475,26 +474,16 @@ static size_t gifframe_size = 8192;
|
||||
#ifdef HWRENDER
|
||||
static colorlookup_t gif_colorlookup;
|
||||
|
||||
static void GIF_rgbconvert(UINT8 *linear, UINT8 *scr)
|
||||
static void GIF_rgbconvert(UINT8 * restrict linear, UINT8 * restrict scr)
|
||||
{
|
||||
UINT8 r, g, b;
|
||||
size_t src, dest;
|
||||
int x, y;
|
||||
|
||||
InitColorLUT(&gif_colorlookup, gif_palette, true);
|
||||
|
||||
for (x = 0; x < vid.width; x += scrbuf_downscaleamt)
|
||||
for (INT32 i = 0; i < scrbuf_width*scrbuf_height; i++)
|
||||
{
|
||||
for (y = 0; y < vid.height; y += scrbuf_downscaleamt)
|
||||
{
|
||||
dest = y*vid.width + x;
|
||||
src = dest*3;
|
||||
|
||||
r = (UINT8)linear[src];
|
||||
g = (UINT8)linear[src + 1];
|
||||
b = (UINT8)linear[src + 2];
|
||||
scr[dest] = GetColorLUTDirect(&gif_colorlookup, r, g, b);
|
||||
}
|
||||
UINT8 r = *linear++;
|
||||
UINT8 g = *linear++;
|
||||
UINT8 b = *linear++;
|
||||
*scr++ = GetColorLUTDirect(&gif_colorlookup, r, g, b);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -506,7 +495,8 @@ static void GIF_rgbconvert(UINT8 *linear, UINT8 *scr)
|
||||
static void GIF_framewrite(void)
|
||||
{
|
||||
UINT8 *p;
|
||||
UINT8 *movie_screen = vid.screens[2];
|
||||
UINT8 *base_screen = scrbuf_screens;
|
||||
UINT8 *movie_screen = scrbuf_screens;
|
||||
INT32 blitx, blity, blitw, blith;
|
||||
|
||||
if (!gifframe_data)
|
||||
@@ -516,47 +506,34 @@ static void GIF_framewrite(void)
|
||||
if (!gif_out)
|
||||
return;
|
||||
|
||||
// select your framebuffer
|
||||
if (gif_frames & 1)
|
||||
base_screen += scrbuf_width*scrbuf_height;
|
||||
else
|
||||
movie_screen += scrbuf_width*scrbuf_height;
|
||||
|
||||
// blit to temp screen
|
||||
if (rendermode == render_soft)
|
||||
I_ReadScreen(movie_screen, scrbuf_downscaleamt);
|
||||
#ifdef HWRENDER
|
||||
else if (rendermode == render_opengl)
|
||||
{
|
||||
UINT8 *linear = HWR_GetScreenshot(scrbuf_downscaleamt);
|
||||
GIF_rgbconvert(linear, movie_screen);
|
||||
//free(linear); // Allocated 'statically', no need to free now
|
||||
}
|
||||
#endif
|
||||
|
||||
// Compare image data (for optimizing GIF)
|
||||
if (gif_optimize && gif_frames > 0)
|
||||
{
|
||||
// before blit movie_screen points to last frame, cur_screen points to this frame
|
||||
UINT8 *cur_screen = vid.screens[0];
|
||||
GIF_optimizeregion(cur_screen, movie_screen, &blitx, &blity, &blitw, &blith);
|
||||
|
||||
// blit to temp screen
|
||||
if (rendermode == render_soft)
|
||||
I_ReadScreen(movie_screen);
|
||||
#ifdef HWRENDER
|
||||
else if (rendermode == render_opengl)
|
||||
{
|
||||
UINT8 *linear = HWR_GetScreenshot();
|
||||
GIF_rgbconvert(linear, movie_screen);
|
||||
//free(linear); // Allocated 'statically', no need to free now
|
||||
}
|
||||
#endif
|
||||
GIF_optimizeregion(base_screen, movie_screen, &blitx, &blity, &blitw, &blith);
|
||||
}
|
||||
else
|
||||
{
|
||||
blitx = blity = 0;
|
||||
blitw = vid.width;
|
||||
blith = vid.height;
|
||||
|
||||
#ifdef HWRENDER
|
||||
// Copy the current OpenGL frame into the base screen
|
||||
if (rendermode == render_opengl)
|
||||
{
|
||||
UINT8 *linear = HWR_GetScreenshot();
|
||||
GIF_rgbconvert(linear, vid.screens[0]);
|
||||
//free(linear); // Allocated 'statically', no need to free now
|
||||
}
|
||||
#endif
|
||||
|
||||
// Copy the first frame into the movie screen
|
||||
// OpenGL already does the same above.
|
||||
if (gif_frames == 0 && rendermode == render_soft)
|
||||
I_ReadScreen(movie_screen);
|
||||
|
||||
movie_screen = vid.screens[0];
|
||||
blitw = scrbuf_width;
|
||||
blith = scrbuf_height;
|
||||
}
|
||||
|
||||
// screen regions are handled in GIF_lzw
|
||||
@@ -564,7 +541,7 @@ static void GIF_framewrite(void)
|
||||
UINT16 delay = 0;
|
||||
INT32 startline;
|
||||
|
||||
if (gif_dynamicdelay ==(UINT8) 2)
|
||||
if (gif_dynamicdelay ==(UINT8) 2)
|
||||
{
|
||||
// golden's attempt at creating a "dynamic delay"
|
||||
UINT16 mingifdelay = 10; // minimum gif delay in milliseconds (keep at 10 because gifs can't get more precise).
|
||||
@@ -600,24 +577,17 @@ static void GIF_framewrite(void)
|
||||
WRITEUINT8(p, 0);
|
||||
WRITEUINT8(p, 0); // end of GCE
|
||||
|
||||
if (scrbuf_downscaleamt > 1)
|
||||
{
|
||||
// Ensure our downscaled blitx/y starts and ends on a pixel.
|
||||
blitx -= (blitx % scrbuf_downscaleamt);
|
||||
blity -= (blity % scrbuf_downscaleamt);
|
||||
blitw = ((blitw + (scrbuf_downscaleamt - 1)) / scrbuf_downscaleamt) * scrbuf_downscaleamt;
|
||||
blith = ((blith + (scrbuf_downscaleamt - 1)) / scrbuf_downscaleamt) * scrbuf_downscaleamt;
|
||||
}
|
||||
|
||||
WRITEUINT8(p, 0x2C);
|
||||
WRITEUINT16(p, (UINT16)(blitx / scrbuf_downscaleamt));
|
||||
WRITEUINT16(p, (UINT16)(blity / scrbuf_downscaleamt));
|
||||
WRITEUINT16(p, (UINT16)(blitw / scrbuf_downscaleamt));
|
||||
WRITEUINT16(p, (UINT16)(blith / scrbuf_downscaleamt));
|
||||
|
||||
WRITEUINT16(p, (UINT16)blitx);
|
||||
WRITEUINT16(p, (UINT16)blity);
|
||||
WRITEUINT16(p, (UINT16)blitw);
|
||||
WRITEUINT16(p, (UINT16)blith);
|
||||
|
||||
WRITEUINT8(p, 0); // no local table of colors
|
||||
|
||||
scrbuf_pos = movie_screen + blitx + (blity * vid.width);
|
||||
scrbuf_writeend = scrbuf_pos + (blitw - 1) + ((blith - 1) * vid.width);
|
||||
scrbuf_pos = movie_screen + blitx + (blity * scrbuf_width);
|
||||
scrbuf_writeend = scrbuf_pos + (blitw - 1) + ((blith - 1) * scrbuf_width);
|
||||
|
||||
if (!gifbwr_buf)
|
||||
gifbwr_buf = Z_Malloc(256, PU_STATIC, NULL);
|
||||
@@ -627,8 +597,8 @@ static void GIF_framewrite(void)
|
||||
giflzw_workingCode = UINT16_MAX;
|
||||
WRITEUINT8(p, gifbwr_bits_min - 1);
|
||||
|
||||
startline = (scrbuf_pos - movie_screen) / vid.width;
|
||||
scrbuf_linebegin = movie_screen + (startline * vid.width) + blitx;
|
||||
startline = (scrbuf_pos - movie_screen) / scrbuf_width;
|
||||
scrbuf_linebegin = movie_screen + (startline * scrbuf_width) + blitx;
|
||||
scrbuf_lineend = scrbuf_linebegin + blitw;
|
||||
|
||||
//prewrite a table clear
|
||||
@@ -658,7 +628,7 @@ static void GIF_framewrite(void)
|
||||
}
|
||||
fwrite(gifframe_data, 1, (p - gifframe_data), gif_out);
|
||||
++gif_frames;
|
||||
gif_prevframetime = I_GetPreciseTime();
|
||||
gif_prevframetime = I_GetPreciseTime();
|
||||
}
|
||||
|
||||
|
||||
@@ -691,12 +661,22 @@ INT32 GIF_open(const char *filename)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void GIF_checkscreens(void)
|
||||
{
|
||||
if (scrbuf_screens == NULL)
|
||||
Z_Malloc(scrbuf_width * scrbuf_height * 2, PU_STATIC, &scrbuf_screens);
|
||||
|
||||
I_Assert(scrbuf_width == vid.width / scrbuf_downscaleamt);
|
||||
I_Assert(scrbuf_height == vid.height / scrbuf_downscaleamt);
|
||||
}
|
||||
|
||||
//
|
||||
// GIF_frame
|
||||
// writes a frame into the output gif
|
||||
//
|
||||
void GIF_frame(void)
|
||||
{
|
||||
GIF_checkscreens();
|
||||
// there's not much actually needed here, is there.
|
||||
GIF_framewrite();
|
||||
}
|
||||
@@ -727,6 +707,8 @@ INT32 GIF_close(void)
|
||||
Z_Free(giflzw_hashTable);
|
||||
giflzw_hashTable = NULL;
|
||||
|
||||
Z_Free(scrbuf_screens);
|
||||
|
||||
CONS_Printf(M_GetText("Animated gif closed; wrote %d frames\n"), gif_frames);
|
||||
return 1;
|
||||
}
|
||||
|
||||
+20
-19
@@ -1240,7 +1240,7 @@ void M_SaveFrame(void)
|
||||
{
|
||||
// munge planar buffer to linear
|
||||
linear = vid.screens[2];
|
||||
I_ReadScreen(linear);
|
||||
I_ReadScreen(linear, 1);
|
||||
}
|
||||
#ifdef HWRENDER
|
||||
else
|
||||
@@ -1506,6 +1506,7 @@ void M_DoScreenShot(void)
|
||||
char pathname[MAX_WADPATH];
|
||||
boolean ret = false;
|
||||
UINT8 *linear = NULL;
|
||||
UINT8 *palette;
|
||||
|
||||
// Don't take multiple screenshots, obviously
|
||||
takescreenshot = false;
|
||||
@@ -1538,30 +1539,30 @@ void M_DoScreenShot(void)
|
||||
freename = Newsnapshotfile(pathname,"tga");
|
||||
#endif
|
||||
|
||||
if (!freename)
|
||||
goto failure;
|
||||
|
||||
if (rendermode == render_soft)
|
||||
{
|
||||
// munge planar buffer to linear
|
||||
linear = vid.screens[2];
|
||||
I_ReadScreen(linear);
|
||||
}
|
||||
|
||||
if (!freename)
|
||||
goto failure;
|
||||
|
||||
// save the pcx file
|
||||
#ifdef HWRENDER
|
||||
if (rendermode == render_opengl)
|
||||
ret = HWR_Screenshot(va(pandf,pathname,freename));
|
||||
else
|
||||
#endif
|
||||
{
|
||||
I_ReadScreen(linear, 1);
|
||||
M_CreateScreenShotPalette();
|
||||
#ifdef USE_PNG
|
||||
ret = M_SavePNG(va(pandf,pathname,freename), linear, vid.width, vid.height, screenshot_palette);
|
||||
#else
|
||||
ret = WritePCXfile(va(pandf,pathname,freename), linear, vid.width, vid.height, screenshot_palette);
|
||||
#endif
|
||||
palette = screenshot_palette;
|
||||
}
|
||||
#ifdef HWRENDER
|
||||
else if (rendermode == render_opengl)
|
||||
{
|
||||
linear = HWR_GetScreenshot(1);
|
||||
palette = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_PNG
|
||||
ret = M_SavePNG(va(pandf,pathname,freename), linear, vid.width, vid.height, palette);
|
||||
#else
|
||||
ret = WritePCXfile(va(pandf,pathname,freename), linear, vid.width, vid.height, palette);
|
||||
#endif
|
||||
|
||||
failure:
|
||||
if (ret)
|
||||
|
||||
@@ -121,6 +121,9 @@ void SCR_SetMode(void)
|
||||
if (!setmodeneeded || WipeInAction)
|
||||
return; // should never happen and don't change it during a wipe, BAD!
|
||||
|
||||
if (vid.modenum != setmodeneeded - 1)
|
||||
M_StopMovie(); // nope, cry about it
|
||||
|
||||
VID_SetMode(--setmodeneeded);
|
||||
|
||||
V_SetPalette(0);
|
||||
|
||||
+13
-2
@@ -1423,12 +1423,23 @@ void I_UpdateNoVsync(void)
|
||||
//
|
||||
// I_ReadScreen
|
||||
//
|
||||
void I_ReadScreen(UINT8 *scr)
|
||||
void I_ReadScreen(UINT8 * restrict scr, INT32 scale)
|
||||
{
|
||||
if (rendermode != render_soft)
|
||||
I_Error ("I_ReadScreen: called while in non-software mode");
|
||||
else
|
||||
else if (scale == 1)
|
||||
VID_BlitLinearScreen(vid.screens[0], scr, vid.width, vid.height, vid.rowbytes, vid.rowbytes);
|
||||
else
|
||||
{
|
||||
UINT8 * restrict source = vid.screens[0];
|
||||
uintptr_t w = vid.width/scale*scale, h = vid.height/scale*scale;
|
||||
|
||||
// size_t saves a lea + movsxd over INT32. mind your types!
|
||||
// uintptr_t is even better since it's guaranteed to be the size of a pointer
|
||||
for (uintptr_t y = 0; y < h; y += scale)
|
||||
for (uintptr_t x = 0; x < w; x += scale)
|
||||
*scr++ = source[y*vid.width + x];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
Reference in new issue
Block a user