Skip to content

Commit

Permalink
Add ability to force backdrop color for sprite extraction.
Browse files Browse the repository at this point in the history
Only Gtk hotkey is hooked up so far.
  • Loading branch information
bearoso committed Mar 31, 2023
1 parent d29098c commit 79e1508
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 3 deletions.
21 changes: 21 additions & 0 deletions controls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ static const int ptrspeeds[4] = { 1, 1, 4, 8 };
S(ToggleBG1), \
S(ToggleBG2), \
S(ToggleBG3), \
S(ToggleBackdrop), \
S(ToggleEmuTurbo), \
S(ToggleSprites), \
S(ToggleTransparency) \
Expand Down Expand Up @@ -2360,6 +2361,26 @@ void S9xApplyCommand (s9xcommand_t cmd, int16 data1, int16 data2)
S9xSetInfoString("All sound channels on");
break;

case ToggleBackdrop:
switch (Settings.ForcedBackdrop)
{
case 0:
Settings.ForcedBackdrop = 0xf81f;
break;
case 0xf81f:
Settings.ForcedBackdrop = 0x07e0;
break;
case 0x07e0:
Settings.ForcedBackdrop = 0x07ff;
break;
default:
Settings.ForcedBackdrop = 0;
break;
}
sprintf(buf, "Setting backdrop to 0x%04x", Settings.ForcedBackdrop);
S9xSetInfoString(buf);
break;

case ToggleBG0:
Settings.BG_Forced ^= 1;
DisplayStateChange("BG#0", !(Settings.BG_Forced & 1));
Expand Down
1 change: 1 addition & 0 deletions gfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ bool8 S9xGraphicsInit (void)

IPPU.OBJChanged = TRUE;
Settings.BG_Forced = 0;
Settings.ForcedBackdrop = 0;
S9xFixColourBrightness();
S9xBuildDirectColourMaps();

Expand Down
2 changes: 1 addition & 1 deletion gtk/src/gtk_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const BindingLink b_links[] =
{ "b_bg_layer_2", "ToggleBG2" },
{ "b_bg_layer_3", "ToggleBG3" },
{ "b_sprites", "ToggleSprites" },
{ "b_bg_layering_hack", "BGLayeringHack" },
{ "toggle_backdrop", "ToggleBackdrop" },
{ "b_screenshot", "Screenshot" },
{ "b_fullscreen", "GTK_fullscreen" },
{ "b_state_save_current", "GTK_state_save_current" },
Expand Down
4 changes: 2 additions & 2 deletions gtk/src/snes9x.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7198,7 +7198,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">BG layering hack</property>
<property name="label" translatable="yes">Toggle forced backdrop color</property>
</object>
<packing>
<property name="top_attach">5</property>
Expand Down Expand Up @@ -7324,7 +7324,7 @@
</packing>
</child>
<child>
<object class="GtkEntry" id="b_bg_layering_hack">
<object class="GtkEntry" id="toggle_backdrop">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
Expand Down
1 change: 1 addition & 0 deletions snes9x.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ struct SSettings
bool8 Transparency;
uint8 BG_Forced;
bool8 DisableGraphicWindows;
uint16 ForcedBackdrop;

bool8 DisplayTime;
bool8 DisplayFrameRate;
Expand Down
2 changes: 2 additions & 0 deletions tileimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,8 @@ namespace TileImpl {

GFX.RealScreenColors = IPPU.ScreenColors;
GFX.ScreenColors = GFX.ClipColors ? BlackColourMap : GFX.RealScreenColors;
if (Settings.ForcedBackdrop)
GFX.ScreenColors = &Settings.ForcedBackdrop;

OFFSET_IN_LINE;
for (l = GFX.StartY; l <= GFX.EndY; l++, Offset += GFX.PPL)
Expand Down

0 comments on commit 79e1508

Please sign in to comment.