* Move the non-mapping drawFill out of the source code function and into the Lua interface.

* Add a drawFill fallback for COLORMAP too.
* Correct a few index mishaps.
This commit is contained in:
toasterbabe 2018-02-12 18:23:57 +00:00
parent c1b48ea79f
commit da3f8ceb8d
2 changed files with 10 additions and 9 deletions

View file

@ -683,15 +683,22 @@ static int libd_fadeScreen(lua_State *L)
{
UINT16 color = luaL_checkinteger(L, 1);
UINT8 strength = luaL_checkinteger(L, 2);
const UINT8 maxstrength = ((color & 0xFF00) ? 31 : 9);
const UINT8 maxstrength = ((color & 0xFF00) ? 32 : 10);
HUDONLY
if (!strength)
return 0;
if (strength > maxstrength)
return luaL_error(L, "%s fade strength %d out of range (0 - %d)", ((color & 0xFF00) ? "COLORMAP" : "TRANSMAP"), strength, maxstrength);
if (strength == maxstrength) // Allow as a shortcut for drawfill...
{
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, ((color & 0xFF00) ? 31 : color));
return 0;
}
V_DrawFadeScreen(color, strength);
return 0;
}

View file

@ -1321,7 +1321,7 @@ void V_DrawPatchFill(patch_t *pat)
//
// Fade all the screen buffer, so that the menu is more readable,
// especially now that we use the small hufont in the menus...
// If color is 0x00 to 0xFF, draw transtable (strength range 0-10).
// If color is 0x00 to 0xFF, draw transtable (strength range 0-9).
// Else, use COLORMAP lump (strength range 0-31).
// IF YOU ARE NOT CAREFUL, THIS CAN AND WILL CRASH!
// I have kept the safety checks out of this function;
@ -1332,12 +1332,6 @@ void V_DrawFadeScreen(UINT16 color, UINT8 strength)
if (!strength)
return;
if (!(color & 0xFF00) && strength == 10)
{
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, color);
return;
}
#ifdef HWRENDER
if (rendermode != render_soft && rendermode != render_none)
{
@ -1349,7 +1343,7 @@ void V_DrawFadeScreen(UINT16 color, UINT8 strength)
{
const UINT8 *fadetable = ((color & 0xFF00) // Color is not palette index?
? ((UINT8 *)colormaps + strength*256) // Do COLORMAP fade.
: ((UINT8 *)transtables + ((10-strength)<<FF_TRANSSHIFT) + color*256)); // Else, do TRANSMAP** fade.
: ((UINT8 *)transtables + ((9-strength)<<FF_TRANSSHIFT) + color*256)); // Else, do TRANSMAP** fade.
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
UINT8 *buf = screens[0];