Skip to content

Commit 452664b

Browse files
committed
Fix invisible food (number) in Nibbles (v1.89 bug)
1 parent 987da7a commit 452664b

File tree

6 files changed

+33
-12
lines changed

6 files changed

+33
-12
lines changed

src/ft2_gfxdata.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ extern const uint8_t font3BMP[584];
1010
extern const uint8_t font4BMP[13604];
1111
extern const uint8_t font6BMP[532];
1212
extern const uint8_t font7BMP[472];
13-
extern const uint8_t font8BMP[368];
13+
extern const uint8_t font8BMP[368]; // small font for piano key and Nibbles (snake food number)
1414

1515
// ft2_bmp_logo.c
1616
extern const uint8_t ft2AboutLogoBMP[23172];

src/ft2_gui.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
#define FONT7_CHAR_W 6
3232
#define FONT7_CHAR_H 7
3333
#define FONT7_WIDTH 140
34+
#define FONT8_WIDTH 80
35+
#define FONT8_CHAR_W 5
36+
#define FONT8_CHAR_H 7
3437

3538
enum
3639
{

src/ft2_header.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#endif
1313
#include "ft2_replayer.h"
1414

15-
#define PROG_VER_STR "1.89"
15+
#define PROG_VER_STR "1.90"
1616

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

src/ft2_inst_ed.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,15 +1582,15 @@ static void pianoNumberOut(uint16_t xPos, uint16_t yPos, uint8_t fgPalette, uint
15821582
const uint32_t fg = video.palette[fgPalette];
15831583
const uint32_t bg = video.palette[bgPalette];
15841584
uint32_t *dstPtr = &video.frameBuffer[(yPos * SCREEN_W) + xPos];
1585-
const uint8_t *srcPtr = &bmp.font8[val * 5];
1585+
const uint8_t *srcPtr = &bmp.font8[val * FONT8_CHAR_W];
15861586

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

15921592
dstPtr += SCREEN_W;
1593-
srcPtr += 80;
1593+
srcPtr += FONT8_WIDTH;
15941594
}
15951595
}
15961596

src/ft2_nibbles.c

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ typedef struct
4444
static const char nibblesCheatCode1[] = "skip", nibblesCheatCode2[] = "triton";
4545
static char nibblesCheatBuffer[16];
4646

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

103+
static void drawNibblesFoodNumber(int32_t xOut, int32_t yOut, int32_t number)
104+
{
105+
if (number > 9)
106+
return;
107+
108+
uint32_t *dstPtr = &video.frameBuffer[(yOut * SCREEN_W) + xOut];
109+
uint8_t *srcPtr = &bmp.font8[number * FONT8_CHAR_W];
110+
111+
for (int32_t y = 0; y < FONT8_CHAR_H; y++, srcPtr += FONT8_WIDTH, dstPtr += SCREEN_W)
112+
{
113+
for (int32_t x = 0; x < FONT8_CHAR_W; x++)
114+
{
115+
if (srcPtr[x] != 0)
116+
dstPtr[x] = video.palette[PAL_FORGRND];
117+
}
118+
}
119+
}
120+
104121
static void redrawNibblesScreen(void)
105122
{
106123
if (!editor.NI_Play)
@@ -128,7 +145,7 @@ static void redrawNibblesScreen(void)
128145
}
129146
else
130147
{
131-
charOut(xs + 2, ys, PAL_FORGRND, convHexTable2[NI_Number]);
148+
drawNibblesFoodNumber(xs+2, ys, NI_Number);
132149
}
133150
}
134151
}
@@ -340,8 +357,8 @@ static void nibblesGenNewNumber(void)
340357
{
341358
while (true)
342359
{
343-
const int16_t x = rand() % 51;
344-
const int16_t y = rand() % 23;
360+
int16_t x = rand() % 51;
361+
int16_t y = rand() % 23;
345362

346363
bool blockIsSuitable;
347364

@@ -370,7 +387,8 @@ static void nibblesGenNewNumber(void)
370387
fillRect(xs, ys, 8, 7, PAL_BCKGRND);
371388
}
372389

373-
charOut((x * 8) + 154, (y * 7) + 7, PAL_FORGRND, convHexTable2[NI_Number]);
390+
drawNibblesFoodNumber((x * 8) + 154, (y * 7) + 7, NI_Number);
391+
374392
break;
375393
}
376394
}

src/gfxdata/ft2_bmp_fonts.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,7 @@ const uint8_t font7BMP[472] =
12381238
0x10,0x11,0x11,0x10,0x01,0x11,0x00,0x01,0x11,0x00,0x11,0x11,0x00,0x01,0x00,0x00
12391239
};
12401240

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

0 commit comments

Comments
 (0)