Skip to content

Commit ec24777

Browse files
committed
render: Allow clear_screen render commands to be for a single frame.
Every render command from Lua code is queued and rerun every frame, so that UI stays consistent when the laserdisc is seeking and the Lua tick isn't run. But Mad Dog McCree uses a screen clear to flash the screen when firing the gun, and we don't want the whole screen to stay white during the duration of the seek, so allow these to be marked as only meant for a single-frame of rendering. This is slightly goofy, but the alternative is either rejigger the Lua tick to run during seeks in every game, or add a second optional tick_ui_only function that runs during seeks (probably the more correct approach, but also the more complicated).
1 parent 59585f9 commit ec24777

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

data/games/maddog/game.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ local function check_actions(inputs)
578578
gunsound = "empty"
579579
else
580580
-- flash the screen white for one frame when firing to give some weight to it. I learned this trick from The Fablemans, lol.
581-
DirkSimple.clear_screen(255, 255, 255)
581+
DirkSimple.clear_screen(255, 255, 255, true)
582582
gunsound = "shot"
583583
if not infinite_bullets then
584584
scene_manager.loaded_bullets = scene_manager.loaded_bullets - 1

dirksimple.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ typedef struct RenderCommand
5959
struct
6060
{
6161
uint8_t r, g, b;
62+
int one_frame_flash;
6263
} clear;
6364
struct
6465
{
@@ -1002,6 +1003,7 @@ static int luahook_DirkSimple_clear_screen(lua_State *L)
10021003
cmd->data.clear.r = (uint8_t) lua_tonumber(L, 1);
10031004
cmd->data.clear.g = (uint8_t) lua_tonumber(L, 2);
10041005
cmd->data.clear.b = (uint8_t) lua_tonumber(L, 3);
1006+
cmd->data.clear.one_frame_flash = lua_toboolean(L, 4) ? 1 : 0;
10051007
return 0;
10061008
}
10071009

@@ -1707,10 +1709,15 @@ static void send_rendering_primitives(void)
17071709
{
17081710
DirkSimple_beginframe();
17091711
for (int i = 0; i < GNumRenderCommands; i++) {
1710-
const RenderCommand *cmd = &GRenderCommands[i];
1712+
RenderCommand *cmd = &GRenderCommands[i];
17111713
switch (cmd->prim) {
17121714
case RENDPRIM_CLEAR:
1713-
DirkSimple_clearscreen(cmd->data.clear.r, cmd->data.clear.g, cmd->data.clear.b);
1715+
if (cmd->data.clear.one_frame_flash >= 0) {
1716+
DirkSimple_clearscreen(cmd->data.clear.r, cmd->data.clear.g, cmd->data.clear.b);
1717+
if (cmd->data.clear.one_frame_flash == 1) {
1718+
cmd->data.clear.one_frame_flash = -1;
1719+
}
1720+
}
17141721
break;
17151722
case RENDPRIM_RECT:
17161723
DirkSimple_drawrect(cmd->data.rect.x, cmd->data.rect.y, cmd->data.rect.w, cmd->data.rect.h,

0 commit comments

Comments
 (0)