History

Fixed some minor bugs

1) The custom directory paths in the config could contain unwanted junk at the end if the loaded config file was saved from real FT2 2) If you were skilled enough to beat the very last Nibbles level, your potential entry in the highscore table would show garbled stage graphics 3) Show a warning if either of the Buttons/Desktop palette colors are so dark that you might have issues seeing the walls in Nibbles

Olav Sørensen committed 6 years ago

Commit 402bc1e1 parent 6c3d4b43 files · +73 −2Browse files

Showing the changes to src (3 of 3 files). Show all

Unified · Split

3 files
  1. src/ft2_config.c +17 −0
  2. src/ft2_header.h +1 −1
  3. src/ft2_nibbles.c +55 −1
src/ft2_config.c+17−0
@@ -111,6 +111,23 @@ static void loadConfigFromBuffer(void) · 110 unmodified lines
111111 config.patternsPath[80-1] = '\0';
112112 config.tracksPath[80-1] = '\0';
113113
114+ // clear data after the actual Pascal string length. FT2 can save garbage in that area.
115+
116+ if (config.modulesPathLen < 80)
117+ memset(&config.modulesPath[config.modulesPathLen], 0, 80-config.modulesPathLen);
118+
119+ if (config.instrPathLen < 80)
120+ memset(&config.instrPath[config.instrPathLen], 0, 80-config.instrPathLen);
121+
122+ if (config.samplesPathLen < 80)
123+ memset(&config.samplesPath[config.samplesPathLen], 0, 80-config.samplesPathLen);
124+
125+ if (config.patternsPathLen < 80)
126+ memset(&config.patternsPath[config.patternsPathLen], 0, 80-config.patternsPathLen);
127+
128+ if (config.tracksPathLen < 80)
129+ memset(&config.tracksPath[config.tracksPathLen], 0, 80-config.tracksPathLen);
130+
114131 config.boostLevel = CLAMP(config.boostLevel, 1, 32);
115132 config.masterVol = CLAMP(config.masterVol, 0, 256);
116133 config.ptnMaxChannels = CLAMP(config.ptnMaxChannels, 0, 3);
src/ft2_header.h+1−1
@@ -12,7 +12,7 @@ · 11 unmodified lines
1212 #endif
1313 #include "ft2_replayer.h"
1414
15−#define PROG_VER_STR "1.20"
15+#define PROG_VER_STR "1.21"
1616
1717 // do NOT change these! It will only mess things up...
1818
src/ft2_nibbles.c+55−1
@@ -54,6 +54,53 @@ static int32_t NI_P1Score, NI_P2Score; · 53 unmodified lines
5454 static nibbleCrd NI_P1[256], NI_P2[256];
5555 static nibbleBufferTyp nibblesBuffer[2];
5656
57+/* Non-FT2 feature: Check if either the Desktop or Buttons palette color
58+** is so close to black that the player would have troubles seeing the walls
59+** when playing Nibbles.
60+*/
61+// ------------------------------------------------------------------------
62+// ------------------------------------------------------------------------
63+static uint8_t rgb24ToLuminosity(uint32_t rgb24)
64+{
65+ const uint8_t R = RGB32_R(rgb24);
66+ const uint8_t G = RGB32_G(rgb24);
67+ const uint8_t B = RGB32_B(rgb24);
68+
69+ // get highest channel value
70+ uint8_t hi = 0;
71+ if (hi < R) hi = R;
72+ if (hi < G) hi = G;
73+ if (hi < B) hi = B;
74+
75+ // get lowest channel value
76+ uint8_t lo = 255;
77+ if (lo > R) lo = R;
78+ if (lo > G) lo = G;
79+ if (lo > B) lo = B;
80+
81+ return (hi + lo) >> 1; // 0..255
82+}
83+
84+static bool wallColorsAreCloseToBlack(void)
85+{
86+#define LUMINOSITY_THRESHOLD 4
87+
88+ uint8_t wallColor1L = rgb24ToLuminosity(video.palette[PAL_DESKTOP]);
89+ uint8_t wallColor2L = rgb24ToLuminosity(video.palette[PAL_BUTTONS]);
90+
91+ /* Since the rest of the wall colors are based on lower and higher
92+ ** contrast values from these two primary colors, we don't really
93+ ** need to check them all.
94+ */
95+
96+ if (wallColor1L <= LUMINOSITY_THRESHOLD || wallColor2L <= LUMINOSITY_THRESHOLD)
97+ return true;
98+
99+ return false;
100+}
101+// ------------------------------------------------------------------------
102+// ------------------------------------------------------------------------
103+
57104 static void redrawNibblesScreen(void)
58105 {
59106 uint8_t x, y, c;
@@ -409,6 +456,10 @@ static void nibblesDecLives(int16_t l1, int16_t l2) · 349 unmodified lines
409456 editor.NI_Play = false;
410457 okBox(0, "Nibbles message", "GAME OVER");
411458
459+ // prevent highscore table from showing overflowing level graphics
460+ if (NI_Level >= NI_MAXLEVEL)
461+ NI_Level = NI_MAXLEVEL - 1;
462+
412463 if (NI_P1Score > config.NI_HighScore[9].score)
413464 {
414465 strcpy(name, "Unknown");
@@ -786,6 +837,9 @@ void nibblesPlay(void) · 371 unmodified lines
786837 return;
787838 }
788839
840+ if (wallColorsAreCloseToBlack())
841+ okBox(0, "Nibbles warning", "The Desktop/Button colors are set to values that make the walls hard to see!");
842+
789843 assert(config.NI_Speed < 4);
790844 NI_CurSpeed = NI_Speeds[config.NI_Speed];
791845
@@ -798,7 +852,7 @@ void nibblesPlay(void) · 6 unmodified lines
798852 NI_P2Score = 0;
799853 NI_P1Lives = 5;
800854 NI_P2Lives = 5;
801− NI_Level = 0;
855+ NI_Level = 1;
802856
803857 newNibblesGame();
804858 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t