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
Showing the changes to src (3 of 3 files). Show all
Unified · Split
| @@ -111,6 +111,23 @@ static void loadConfigFromBuffer(void) · 110 unmodified lines | |||
| 111 | config.patternsPath[80-1] = '\0'; | 111 | config.patternsPath[80-1] = '\0'; |
| 112 | config.tracksPath[80-1] = '\0'; | 112 | config.tracksPath[80-1] = '\0'; |
| 113 | 113 | ||
| 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 | |||
| 114 | config.boostLevel = CLAMP(config.boostLevel, 1, 32); | 131 | config.boostLevel = CLAMP(config.boostLevel, 1, 32); |
| 115 | config.masterVol = CLAMP(config.masterVol, 0, 256); | 132 | config.masterVol = CLAMP(config.masterVol, 0, 256); |
| 116 | config.ptnMaxChannels = CLAMP(config.ptnMaxChannels, 0, 3); | 133 | config.ptnMaxChannels = CLAMP(config.ptnMaxChannels, 0, 3); |
| @@ -12,7 +12,7 @@ · 11 unmodified lines | |||
| 12 | #endif | 12 | #endif |
| 13 | #include "ft2_replayer.h" | 13 | #include "ft2_replayer.h" |
| 14 | 14 | ||
| 15 | #define PROG_VER_STR "1.20" | 15 | #define PROG_VER_STR "1.21" |
| 16 | 16 | ||
| 17 | // do NOT change these! It will only mess things up... | 17 | // do NOT change these! It will only mess things up... |
| 18 | 18 | ||
| @@ -54,6 +54,53 @@ static int32_t NI_P1Score, NI_P2Score; · 53 unmodified lines | |||
| 54 | static nibbleCrd NI_P1[256], NI_P2[256]; | 54 | static nibbleCrd NI_P1[256], NI_P2[256]; |
| 55 | static nibbleBufferTyp nibblesBuffer[2]; | 55 | static nibbleBufferTyp nibblesBuffer[2]; |
| 56 | 56 | ||
| 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 | |||
| 57 | static void redrawNibblesScreen(void) | 104 | static void redrawNibblesScreen(void) |
| 58 | { | 105 | { |
| 59 | uint8_t x, y, c; | 106 | uint8_t x, y, c; |
| @@ -409,6 +456,10 @@ static void nibblesDecLives(int16_t l1, int16_t l2) · 349 unmodified lines | |||
| 409 | editor.NI_Play = false; | 456 | editor.NI_Play = false; |
| 410 | okBox(0, "Nibbles message", "GAME OVER"); | 457 | okBox(0, "Nibbles message", "GAME OVER"); |
| 411 | 458 | ||
| 459 | // prevent highscore table from showing overflowing level graphics | ||
| 460 | if (NI_Level >= NI_MAXLEVEL) | ||
| 461 | NI_Level = NI_MAXLEVEL - 1; | ||
| 462 | |||
| 412 | if (NI_P1Score > config.NI_HighScore[9].score) | 463 | if (NI_P1Score > config.NI_HighScore[9].score) |
| 413 | { | 464 | { |
| 414 | strcpy(name, "Unknown"); | 465 | strcpy(name, "Unknown"); |
| @@ -786,6 +837,9 @@ void nibblesPlay(void) · 371 unmodified lines | |||
| 786 | return; | 837 | return; |
| 787 | } | 838 | } |
| 788 | 839 | ||
| 840 | if (wallColorsAreCloseToBlack()) | ||
| 841 | okBox(0, "Nibbles warning", "The Desktop/Button colors are set to values that make the walls hard to see!"); | ||
| 842 | |||
| 789 | assert(config.NI_Speed < 4); | 843 | assert(config.NI_Speed < 4); |
| 790 | NI_CurSpeed = NI_Speeds[config.NI_Speed]; | 844 | NI_CurSpeed = NI_Speeds[config.NI_Speed]; |
| 791 | 845 | ||
| @@ -798,7 +852,7 @@ void nibblesPlay(void) · 6 unmodified lines | |||
| 798 | NI_P2Score = 0; | 852 | NI_P2Score = 0; |
| 799 | NI_P1Lives = 5; | 853 | NI_P1Lives = 5; |
| 800 | NI_P2Lives = 5; | 854 | NI_P2Lives = 5; |
| 801 | NI_Level = 0; | 855 | NI_Level = 1; |
| 802 | 856 | ||
| 803 | newNibblesGame(); | 857 | newNibblesGame(); |
| 804 | } | 858 | } |