Skip to content

Commit

Permalink
More minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
bradharding committed Aug 24, 2024
1 parent d1b9044 commit b885639
Showing 3 changed files with 67 additions and 66 deletions.
10 changes: 5 additions & 5 deletions src/m_font.c
Original file line number Diff line number Diff line change
@@ -65,7 +65,7 @@ typedef struct
byte kerning; // flag field, but with only one flag
} fon2_header_t;

static fon2_char_t *chars = NULL;
static fon2_char_t *chars;
static int numchars;
static int height;
static int firstc;
@@ -124,11 +124,11 @@ bool M_LoadFON2(byte *gfx_data, int size)
if (!(translate = malloc(header->palsize + 1)))
return false;

for (int i = 0; i < header->palsize + 1; ++i)
for (int i = 0; i <= header->palsize; i++)
{
int r = *p++;
int g = *p++;
int b = *p++;
const byte r = *p++;
const byte g = *p++;
const byte b = *p++;

translate[i] = FindNearestColor(playpal, r, g, b);
}
117 changes: 59 additions & 58 deletions src/m_menu.c
Original file line number Diff line number Diff line change
@@ -687,57 +687,57 @@ static struct
//
void M_DrawString(int x, int y, char *string, bool highlight, bool shadow)
{
char prev = '\0';
const int len = (int)strlen(string);

if (M_DrawFON2String(x, y, string, highlight))
return;

for (int i = 0, j = -1; i < len; i++)
if (!M_DrawFON2String(x, y, string, highlight))
{
bool overlapping = false;

if (string[i] < 123)
j = chartoi[(int)string[i]];
char prev = '\0';
const int len = (int)strlen(string);

for (int k = 0; bigkern[k].char1; k++)
if (prev == bigkern[k].char1 && string[i] == bigkern[k].char2)
{
x += bigkern[k].adjust;
break;
}
for (int i = 0, j = -1; i < len; i++)
{
bool overlapping = false;

for (int k = 0; overlap[k].char1; k++)
if (prev == overlap[k].char1 && string[i] == overlap[k].char2)
{
overlapping = true;
break;
}
if (string[i] < 123)
j = chartoi[(int)string[i]];

if (j == -1)
x += SPACEWIDTH;
else
{
const int width = (int)strlen(redcharset[j]) / 18;
for (int k = 0; bigkern[k].char1; k++)
if (prev == bigkern[k].char1 && string[i] == bigkern[k].char2)
{
x += bigkern[k].adjust;
break;
}

for (int y1 = 0; y1 < 18; y1++)
for (int x1 = 0; x1 < width; x1++)
for (int k = 0; overlap[k].char1; k++)
if (prev == overlap[k].char1 && string[i] == overlap[k].char2)
{
const unsigned char dot = redcharset[j][y1 * width + x1];
overlapping = true;
break;
}

if (dot == (unsigned char)'\xC8')
if (j == -1)
x += SPACEWIDTH;
else
{
const int width = (int)strlen(redcharset[j]) / 18;

for (int y1 = 0; y1 < 18; y1++)
for (int x1 = 0; x1 < width; x1++)
{
if (!overlapping)
V_DrawPixel(x + x1, y + y1, PINK, highlight, shadow);
const unsigned char dot = redcharset[j][y1 * width + x1];

if (dot == (unsigned char)'\xC8')
{
if (!overlapping)
V_DrawPixel(x + x1, y + y1, PINK, highlight, shadow);
}
else
V_DrawPixel(x + x1, y + y1, (int)dot, highlight, shadow);
}
else
V_DrawPixel(x + x1, y + y1, (int)dot, highlight, shadow);
}

x += width - 2;
}
x += width - 2;
}

prev = string[i];
prev = string[i];
}
}
}

@@ -747,23 +747,24 @@ void M_DrawString(int x, int y, char *string, bool highlight, bool shadow)
//
static int M_BigStringWidth(char *string)
{
int width = M_GetFON2PixelWidth(string);
char prev = '\0';
const int len = (int)strlen(string);
int width = M_GetFON2PixelWidth(string);

if (width)
return width;

for (int i = 0; i < len; i++)
if (!width)
{
const int j = chartoi[(int)string[i]];
char prev = '\0';
const int len = (int)strlen(string);

for (int i = 0; i < len; i++)
{
const int j = chartoi[(int)string[i]];

for (int k = 0; bigkern[k].char1; k++)
if (prev == bigkern[k].char1 && string[i] == bigkern[k].char2)
width += bigkern[k].adjust;
for (int k = 0; bigkern[k].char1; k++)
if (prev == bigkern[k].char1 && string[i] == bigkern[k].char2)
width += bigkern[k].adjust;

width += (j == -1 ? SPACEWIDTH : (int)strlen(redcharset[j]) / 18 - 2);
prev = string[i];
width += (j == -1 ? SPACEWIDTH : (int)strlen(redcharset[j]) / 18 - 2);
prev = string[i];
}
}

return width;
@@ -2006,7 +2007,7 @@ static void M_DrawOptions(void)
patch, (itemon == msgs));
}
else
M_DrawString(OptionsDef.x + M_BigStringWidth(*currentmenu->menuitems[msgs].text) + 7,
M_DrawString(OptionsDef.x + M_BigStringWidth(*currentmenu->menuitems[msgs].text) + M_BigStringWidth(" "),
OptionsDef.y + 16 * msgs + OFFSET, s_M_ON, (itemon == msgs), true);
}
else
@@ -2023,7 +2024,7 @@ static void M_DrawOptions(void)
patch, (itemon == msgs));
}
else
M_DrawString(OptionsDef.x + M_BigStringWidth(*currentmenu->menuitems[msgs].text) + 7,
M_DrawString(OptionsDef.x + M_BigStringWidth(*currentmenu->menuitems[msgs].text) + M_BigStringWidth(" "),
OptionsDef.y + 16 * msgs + OFFSET, s_M_OFF, (itemon == msgs), true);
}

@@ -2041,7 +2042,7 @@ static void M_DrawOptions(void)
patch, (itemon == detail));
}
else
M_DrawString(OptionsDef.x + M_BigStringWidth(*currentmenu->menuitems[detail].text) + 7,
M_DrawString(OptionsDef.x + M_BigStringWidth(*currentmenu->menuitems[detail].text) + M_BigStringWidth(" "),
OptionsDef.y + 16 * detail + OFFSET, s_M_LOW, (itemon == detail), true);
}
else
@@ -2058,7 +2059,7 @@ static void M_DrawOptions(void)
patch, (itemon == detail));
}
else
M_DrawString(OptionsDef.x + M_BigStringWidth(*currentmenu->menuitems[detail].text) + 7,
M_DrawString(OptionsDef.x + M_BigStringWidth(*currentmenu->menuitems[detail].text) + M_BigStringWidth(" "),
OptionsDef.y + 16 * detail + OFFSET, s_M_HIGH, (itemon == detail), true);
}

@@ -4730,7 +4731,7 @@ void M_Init(void)
wadfile_t *wadfile = lumpinfo[lump]->wadfile;

if (M_LoadFON2(W_CacheLumpNum(lump), W_LumpLength(lump)))
C_Output("The " BOLD("DBIGFONT") " lump in the %s " BOLD("%s") " is being used.",
C_Output("The " BOLD("DBIGFONT") " lump in the %s " BOLD("%s") " is being used in the menu.",
(wadfile->type == IWAD ? "IWAD" : "PWAD"), wadfile->path);
}
}
6 changes: 3 additions & 3 deletions src/v_video.c
Original file line number Diff line number Diff line change
@@ -1973,14 +1973,14 @@ patch_t *V_LinearToTransPatch(const byte *data, int width, int height, int color
size_t post_len = 0;

post_len += 2; // two bytes for post header
post_len += 1; // dummy byte
post_len++; // dummy byte
post_len += array_size(columns[c].posts[p].pixels); // pixels
post_len += 1; // dummy byte
post_len++; // dummy byte

size += post_len;
}

size += 1; // room for 0xff cap byte
size++; // room for 0xFF cap byte
}

output = malloc(size);

0 comments on commit b885639

Please sign in to comment.