Skip to content

Commit

Permalink
Fix invisible food (number) in Nibbles (v1.89 bug)
Browse files Browse the repository at this point in the history
  • Loading branch information
8bitbubsy committed Dec 9, 2024
1 parent 987da7a commit 452664b
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/ft2_gfxdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extern const uint8_t font3BMP[584];
extern const uint8_t font4BMP[13604];
extern const uint8_t font6BMP[532];
extern const uint8_t font7BMP[472];
extern const uint8_t font8BMP[368];
extern const uint8_t font8BMP[368]; // small font for piano key and Nibbles (snake food number)

// ft2_bmp_logo.c
extern const uint8_t ft2AboutLogoBMP[23172];
Expand Down
3 changes: 3 additions & 0 deletions src/ft2_gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
#define FONT7_CHAR_W 6
#define FONT7_CHAR_H 7
#define FONT7_WIDTH 140
#define FONT8_WIDTH 80
#define FONT8_CHAR_W 5
#define FONT8_CHAR_H 7

enum
{
Expand Down
2 changes: 1 addition & 1 deletion src/ft2_header.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#endif
#include "ft2_replayer.h"

#define PROG_VER_STR "1.89"
#define PROG_VER_STR "1.90"

// do NOT change these! It will only mess things up...

Expand Down
8 changes: 4 additions & 4 deletions src/ft2_inst_ed.c
Original file line number Diff line number Diff line change
Expand Up @@ -1582,15 +1582,15 @@ static void pianoNumberOut(uint16_t xPos, uint16_t yPos, uint8_t fgPalette, uint
const uint32_t fg = video.palette[fgPalette];
const uint32_t bg = video.palette[bgPalette];
uint32_t *dstPtr = &video.frameBuffer[(yPos * SCREEN_W) + xPos];
const uint8_t *srcPtr = &bmp.font8[val * 5];
const uint8_t *srcPtr = &bmp.font8[val * FONT8_CHAR_W];

for (int32_t y = 0; y < 7; y++)
for (int32_t y = 0; y < FONT8_CHAR_H; y++)
{
for (int32_t x = 0; x < 5; x++)
for (int32_t x = 0; x < FONT8_CHAR_W; x++)
dstPtr[x] = srcPtr[x] ? fg : bg;

dstPtr += SCREEN_W;
srcPtr += 80;
srcPtr += FONT8_WIDTH;
}
}

Expand Down
28 changes: 23 additions & 5 deletions src/ft2_nibbles.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ typedef struct
static const char nibblesCheatCode1[] = "skip", nibblesCheatCode2[] = "triton";
static char nibblesCheatBuffer[16];

static const char convHexTable2[10] = { 7, 8, 9, 10, 11, 12, 13, 16, 17, 18 };
static const uint8_t NI_Speeds[4] = { 12, 8, 6, 4 };
static bool NI_EternalLives;
static uint8_t NI_CheatIndex, NI_CurSpeed, NI_CurTick60Hz, NI_CurSpeed60Hz, NI_Screen[51][23], NI_Level;
Expand Down Expand Up @@ -101,6 +100,24 @@ static bool wallColorsAreCloseToBlack(void)
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------

static void drawNibblesFoodNumber(int32_t xOut, int32_t yOut, int32_t number)
{
if (number > 9)
return;

uint32_t *dstPtr = &video.frameBuffer[(yOut * SCREEN_W) + xOut];
uint8_t *srcPtr = &bmp.font8[number * FONT8_CHAR_W];

for (int32_t y = 0; y < FONT8_CHAR_H; y++, srcPtr += FONT8_WIDTH, dstPtr += SCREEN_W)
{
for (int32_t x = 0; x < FONT8_CHAR_W; x++)
{
if (srcPtr[x] != 0)
dstPtr[x] = video.palette[PAL_FORGRND];
}
}
}

static void redrawNibblesScreen(void)
{
if (!editor.NI_Play)
Expand Down Expand Up @@ -128,7 +145,7 @@ static void redrawNibblesScreen(void)
}
else
{
charOut(xs + 2, ys, PAL_FORGRND, convHexTable2[NI_Number]);
drawNibblesFoodNumber(xs+2, ys, NI_Number);
}
}
}
Expand Down Expand Up @@ -340,8 +357,8 @@ static void nibblesGenNewNumber(void)
{
while (true)
{
const int16_t x = rand() % 51;
const int16_t y = rand() % 23;
int16_t x = rand() % 51;
int16_t y = rand() % 23;

bool blockIsSuitable;

Expand Down Expand Up @@ -370,7 +387,8 @@ static void nibblesGenNewNumber(void)
fillRect(xs, ys, 8, 7, PAL_BCKGRND);
}

charOut((x * 8) + 154, (y * 7) + 7, PAL_FORGRND, convHexTable2[NI_Number]);
drawNibblesFoodNumber((x * 8) + 154, (y * 7) + 7, NI_Number);

break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/gfxdata/ft2_bmp_fonts.c
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@ const uint8_t font7BMP[472] =
0x10,0x11,0x11,0x10,0x01,0x11,0x00,0x01,0x11,0x00,0x11,0x11,0x00,0x01,0x00,0x00
};

const uint8_t font8BMP[368] = // small font for piano key
const uint8_t font8BMP[368] = // small font for piano key and Nibbles (snake food number)
{
0x42,0x4D,0x70,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0x07,0x00,
0x00,0x00,0x01,0x00,0x04,0x00,0x02,0x00,0x00,0x00,0x32,0x01,0x00,0x00,0x12,0x0B,0x00,0x00,0x12,0x0B,0x00,0x00,0x02,0x00,
Expand Down

0 comments on commit 452664b

Please sign in to comment.