ref: 4693920efcc3440d5559d19a0cfd1fd840903200
parent: 5737c15614dcc55e4cc9e36488b6641ef5e8f4e6
author: DPS2004 <[email protected]>
date: Mon Feb 6 05:52:04 EST 2023
DimFlashes option (Fixes #221) DimFlashes can be used to lower screen flashing Co-authored-by: Snesrev <[email protected]>
--- a/config.c
+++ b/config.c
@@ -368,6 +368,8 @@
} else if (StringEqualsNoCase(key, "Shader")) {
g_config.shader = *value ? value : NULL;
return true;
+ } else if (StringEqualsNoCase(key, "DimFlashes")) {
+ return ParseBoolBit(value, &g_config.features0, kFeatures0_DimFlashes);
}
} else if (section == 2) {
if (StringEqualsNoCase(key, "EnableAudio")) {
--- a/ending.c
+++ b/ending.c
@@ -1211,7 +1211,7 @@
SetBackdropcolorBlack();
if (intro_times_pal_flash) {
if ((intro_times_pal_flash & 3) != 0) {
- (&COLDATA_copy0)[intro_sword_24] |= 0x1f;
+ (&COLDATA_copy0)[intro_sword_24] |= (enhanced_features0 & kFeatures0_DimFlashes) ? 0x05 : 0x1f;
intro_sword_24 = (intro_sword_24 == 2) ? 0 : intro_sword_24 + 1;
}
intro_times_pal_flash--;
--- a/features.h
+++ b/features.h
@@ -44,6 +44,8 @@
kFeatures0_GameChangingBugFixes = 16384,
kFeatures0_SwitchLRLimit = 32768,
+
+ kFeatures0_DimFlashes = 65536,
};
#define enhanced_features0 (*(uint32*)(g_ram+0x64c))
--- a/load_gfx.c
+++ b/load_gfx.c
@@ -1922,11 +1922,12 @@
}
uint16 Filter_Majorly_Whiten_Color(uint16 c) { // 8ed7fe
- int r = (c & 0x1f) + 14;
+ int amt = (enhanced_features0 & kFeatures0_DimFlashes) ? 3 : 14;
+ int r = (c & 0x1f) + amt;
+ int g = (c & 0x3e0) + (amt << 5);
+ int b = (c & 0x7c00) + (amt << 10);
if (r > 0x1f) r = 0x1f;
- int g = (c & 0x3e0) + 0x1c0;
if (g > 0x3e0) g = 0x3e0;
- int b = (c & 0x7c00) + 0x3800;
if (b > 0x7c00) b = 0x7c00;
return r | g | b;
}
--- a/main.c
+++ b/main.c
@@ -832,6 +832,12 @@
g_asset_ptrs[i] = data + offset;
offset += size;
}
+
+ if (g_config.features0 & kFeatures0_DimFlashes) { // patch dungeon floor palettes
+ kPalette_DungBgMain[0x484] = 0x70;
+ kPalette_DungBgMain[0x485] = 0x95;
+ kPalette_DungBgMain[0x486] = 0x57;
+ }
}
// Go some steps up and find zelda3.ini
--- a/player.c
+++ b/player.c
@@ -77,6 +77,7 @@
static const uint8 kBombosAnimDelays[] = { 5, 5, 5, 5, 5, 5, 5, 5, 3, 3, 3, 3, 3, 7, 1, 1, 1, 1, 1, 13 };
static const uint8 kBombosAnimStates[] = { 0, 1, 2, 3, 0, 1, 2, 3, 8, 9, 10, 11, 12, 10, 8, 13, 14, 15, 16, 17 };
static const uint8 kEtherAnimDelays[] = { 5, 5, 5, 5, 5, 5, 5, 5, 7, 7, 3, 3 };
+static const uint8 kEtherAnimDelaysNoFlash[] = { 5, 5, 5, 5, 5, 5, 5, 5, 7, 7, 24, 24 };
static const uint8 kEtherAnimStates[] = { 0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 6, 7 };
static const uint8 kQuakeAnimDelays[] = { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 19 };
static const uint8 kQuakeAnimStates[] = { 0, 1, 2, 3, 0, 1, 2, 3, 18, 19, 20, 22 };
@@ -2685,7 +2686,8 @@
} else if (step_counter_for_spin_attack == 12) {
step_counter_for_spin_attack = 10;
}
- link_delay_timer_spin_attack = kEtherAnimDelays[step_counter_for_spin_attack];
+ const uint8 *table = (enhanced_features0 & kFeatures0_DimFlashes) ? kEtherAnimDelaysNoFlash : kEtherAnimDelays;
+ link_delay_timer_spin_attack = table[step_counter_for_spin_attack];
state_for_spin_attack = kEtherAnimStates[step_counter_for_spin_attack];
if (!byte_7E0324 && step_counter_for_spin_attack == 10) {
byte_7E0324 = 1;
--- a/zelda3.ini
+++ b/zelda3.ini
@@ -54,6 +54,8 @@
# Get them with: git clone https://github.com/snesrev/glsl-shaders
Shader =
+# Recreate the behavior of the Virtual Console releases, where flashing effects are lessened
+DimFlashes = 0
[Sound]
EnableAudio = 1