]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
OSD font update.
authorToni Wilen <twilen@winuae.net>
Sat, 26 Sep 2020 14:47:55 +0000 (17:47 +0300)
committerToni Wilen <twilen@winuae.net>
Sat, 26 Sep 2020 14:47:55 +0000 (17:47 +0300)
cfgfile.cpp
include/statusline.h
od-win32/statusline_win32.cpp
statusline.cpp

index d5932c2cdcad9989af929fa3997aac2eec190afd..0d7fda1f59af4700b1937eb540902d01670803f1 100644 (file)
@@ -160,7 +160,6 @@ static const TCHAR *compmode[] = { _T("direct"), _T("indirect"), _T("indirectKS"
 static const TCHAR *flushmode[] = { _T("soft"), _T("hard"), 0 };
 static const TCHAR *kbleds[] = { _T("none"), _T("POWER"), _T("DF0"), _T("DF1"), _T("DF2"), _T("DF3"), _T("HD"), _T("CD"), _T("DFx"), 0 };
 static const TCHAR *onscreenleds[] = { _T("false"), _T("true"), _T("rtg"), _T("both"), 0 };
-static const TCHAR *ledscale[] = { _T("automatic"), _T("1x"), _T("2x"), _T("3x"), _T("4x"), 0 };
 static const TCHAR *soundfiltermode1[] = { _T("off"), _T("emulated"), _T("on"), 0 };
 static const TCHAR *soundfiltermode2[] = { _T("standard"), _T("enhanced"), 0 };
 static const TCHAR *lorestype1[] = { _T("lores"), _T("hires"), _T("superhires"), 0 };
@@ -2303,8 +2302,11 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type)
        cfgfile_dwrite_bool (f, _T("show_leds_rtg"), !!(p->leds_on_screen & STATUSLINE_RTG));
        write_leds(f, _T("show_leds_enabled"), p->leds_on_screen_mask[0]);
        write_leds(f, _T("show_leds_enabled_rtg"), p->leds_on_screen_mask[1]);
-       cfgfile_dwrite_str(f, _T("show_leds_size"), ledscale[p->leds_on_screen_multiplier[0]]);
-       cfgfile_dwrite_str(f, _T("show_leds_size_rtg"), ledscale[p->leds_on_screen_multiplier[1]]);
+       for (int i = 0; i < 2; i++) {
+               if (p->leds_on_screen_multiplier[i] > 0) {
+                       cfgfile_dwrite(f, i ? _T("show_leds_size_rtg") : _T("show_leds_size"), _T("%.2f"), p->leds_on_screen_multiplier[i] / 100.0);
+               }
+       }
        cfgfile_dwrite_bool(f, _T("show_refresh_indicator"), p->refresh_indicator);
        cfgfile_dwrite(f, _T("power_led_dim"), _T("%d"), p->power_led_dim);
 
@@ -3575,7 +3577,11 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value)
        }
        if (_tcscmp(option, _T("show_leds_size")) == 0 || _tcscmp(option, _T("show_leds_size_rtg")) == 0) {
                int idx = _tcscmp(option, _T("show_leds_size")) == 0 ? 0 : 1;
-               cfgfile_strval(option, value, option, &p->leds_on_screen_multiplier[idx], ledscale, 0);
+               p->leds_on_screen_multiplier[idx] = 0;
+               float f = 0;
+               if (cfgfile_floatval(option, value, option, &f)) {
+                       p->leds_on_screen_multiplier[idx] = (int)(f * 100);
+               }
                return 1;
        }
        if (_tcscmp (option, _T("show_leds_enabled")) == 0 || _tcscmp (option, _T("show_leds_enabled_rtg")) == 0) {
index b8713e7eb9b8505482016d877044fafaf3edfaad..f2234f66c905755098e0462f1ffe7d722781d897 100644 (file)
@@ -5,19 +5,23 @@
 
 #define TD_PADX 4
 #define TD_PADY 2
-#define TD_WIDTH 30
-#define TD_LED_WIDTH 24
-#define TD_LED_HEIGHT 4
+#define TD_DEFAULT_WIDTH 30
+#define TD_DEFAULT_LED_WIDTH 24
+#define TD_DEFAULT_LED_HEIGHT 4
 
 #define TD_RIGHT 1
 #define TD_BOTTOM 2
 
-static int td_pos = (TD_RIGHT | TD_BOTTOM);
+extern int td_numbers_pos;
+extern int td_numbers_width, td_numbers_height;
+extern const TCHAR *td_characters;
+extern int td_led_width;
+extern int td_width;
 
-#define TD_NUM_WIDTH 7
-#define TD_NUM_HEIGHT 7
+#define TD_DEFAULT_NUM_WIDTH 7
+#define TD_DEFAULT_NUM_HEIGHT 7
 
-#define TD_TOTAL_HEIGHT (TD_PADY * 2 + TD_NUM_HEIGHT)
+#define TD_TOTAL_HEIGHT (TD_PADY * 2 + td_numbers_height)
 
 #define NUMBERS_NUM 20
 
@@ -49,5 +53,6 @@ bool has_statusline_updated(void);
 const TCHAR *statusline_fetch(void);
 int statusline_set_multiplier(int, int, int);
 int statusline_get_multiplier(int monid);
+void statusline_set_font(const char *newnumbers, int width, int height);
 
 #endif /* UAE_STATUSLINE_H */
index bd5f7ebed0ba6c0f3db9ccf05126bd1e90c2961f..268fcb8e705844a363487203e7c956fd17550f46 100644 (file)
@@ -22,6 +22,7 @@ static int statusline_height = TD_TOTAL_HEIGHT;
 static HFONT statusline_font;
 static HPALETTE statusline_palette;
 static bool statusline_was_updated;
+static char *td_new_numbers;
 
 bool softstatusline(void)
 {
@@ -37,7 +38,7 @@ void deletestatusline(int monid)
        struct AmigaMonitor *mon = &AMonitors[monid];
        if (!statusline_hdc)
                return;
-       if (!statusline_bitmap)
+       if (statusline_bitmap)
                DeleteObject(statusline_bitmap);
        if (statusline_hdc)
                ReleaseDC(NULL, statusline_hdc);
@@ -51,6 +52,138 @@ void deletestatusline(int monid)
        statusline_palette = NULL;
 }
 
+static void create_led_font(int monid)
+{
+       HDC hdc;
+       LPLOGPALETTE lp;
+       HPALETTE hpal;
+       BITMAPINFO *bi;
+       BITMAPINFOHEADER *bih;
+       HBITMAP bitmap = NULL;
+       int width = 128;
+       int height = 128;
+       void *bm;
+
+       statusline_set_font(NULL, 0, 0);
+
+       xfree(td_new_numbers);
+
+       hdc = CreateCompatibleDC(NULL);
+       if (hdc) {
+               int fontsize = -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72);
+               fontsize = fontsize * statusline_get_multiplier(monid) / 100;
+               lp = (LOGPALETTE *)xcalloc(uae_u8, sizeof(LOGPALETTE) + 3 * sizeof(PALETTEENTRY));
+               if (lp) {
+                       lp->palNumEntries = 4;
+                       lp->palVersion = 0x300;
+                       lp->palPalEntry[1].peBlue = lp->palPalEntry[1].peGreen = lp->palPalEntry[0].peRed = 0x10;
+                       lp->palPalEntry[2].peBlue = lp->palPalEntry[2].peGreen = lp->palPalEntry[2].peRed = 0xff;
+                       lp->palPalEntry[3].peBlue = lp->palPalEntry[3].peGreen = lp->palPalEntry[3].peRed = 0x7f;
+                       hpal = CreatePalette(lp);
+                       if (hpal) {
+                               SelectPalette(hdc, hpal, FALSE);
+                               bi = (BITMAPINFO*)xcalloc(uae_u8, sizeof(BITMAPINFOHEADER) + 4 * sizeof(RGBQUAD));
+                               if (bi) {
+                                       bih = &bi->bmiHeader;
+                                       bih->biSize = sizeof(BITMAPINFOHEADER);
+                                       bih->biWidth = width;
+                                       bih->biHeight = -height;
+                                       bih->biPlanes = 1;
+                                       bih->biBitCount = 8;
+                                       bih->biCompression = BI_RGB;
+                                       bih->biClrUsed = 4;
+                                       bih->biClrImportant = 4;
+                                       bi->bmiColors[1].rgbBlue = bi->bmiColors[1].rgbGreen = bi->bmiColors[1].rgbRed = 0x10;
+                                       bi->bmiColors[2].rgbBlue = bi->bmiColors[2].rgbGreen = bi->bmiColors[2].rgbRed = 0xff;
+                                       bi->bmiColors[3].rgbBlue = bi->bmiColors[3].rgbGreen = bi->bmiColors[3].rgbRed = 0x7f;
+                                       bitmap = CreateDIBSection(hdc, bi, DIB_RGB_COLORS, &bm, NULL, 0);
+                                       if (bitmap) {
+                                               SelectObject(hdc, bitmap);
+                                               RealizePalette(hdc);
+                                               HFONT font = CreateFont(fontsize, 0,
+                                                       0, 0,
+                                                       FW_BOLD,
+                                                       FALSE,
+                                                       FALSE,
+                                                       FALSE,
+                                                       DEFAULT_CHARSET,
+                                                       OUT_TT_PRECIS,
+                                                       CLIP_DEFAULT_PRECIS,
+                                                       PROOF_QUALITY,
+                                                       FIXED_PITCH | FF_DONTCARE,
+                                                       _T("Courier New"));
+                                               if (font) {
+                                                       SelectObject(hdc, font);
+                                                       SetTextColor(hdc, PALETTEINDEX(2));
+                                                       SetBkColor(hdc, PALETTEINDEX(1));
+                                                       TEXTMETRIC tm;
+                                                       GetTextMetrics(hdc, &tm);
+                                                       int w = 0;
+                                                       int h = tm.tmAscent;
+                                                       for (int i = 0; i < td_characters[i]; i++) {
+                                                               SIZE sz;
+                                                               if (GetTextExtentPoint32(hdc, &td_characters[i], 1, &sz)) {
+                                                                       if (sz.cx > w)
+                                                                               w = sz.cx;
+                                                               }
+                                                       }
+                                                       int offsetx = 10;
+                                                       int offsety = 10 + (tm.tmDescent + 1) / 2;
+                                                       td_new_numbers = xcalloc(char, w * h * NUMBERS_NUM);
+                                                       if (td_new_numbers) {
+                                                               for (int i = 0; i < td_characters[i]; i++) {
+                                                                       SetBkMode(hdc, OPAQUE);
+                                                                       BitBlt(hdc, 0, 0, width, height, NULL, 0, 0, BLACKNESS);
+                                                                       TextOut(hdc, 10, 10, &td_characters[i], 1);
+                                                                       for (int y = 0; y < h; y++) {
+                                                                               uae_u8 *src = (uae_u8 *)bm + (y + offsety) * width + offsetx;
+                                                                               char *dst = td_new_numbers + i * w + y * w * NUMBERS_NUM;
+                                                                               for (int x = 0; x < w; x++) {
+                                                                                       uae_u8 b = *src++;
+                                                                                       if (b == 2) {
+                                                                                               *dst = 'x';
+                                                                                       } else {
+                                                                                               *dst = '-';
+                                                                                       }
+                                                                                       dst++;
+                                                                               }
+                                                                       }
+
+                                                                       BitBlt(hdc, 0, 0, width, height, NULL, 0, 0, BLACKNESS);
+                                                                       SetBkMode(hdc, TRANSPARENT);
+                                                                       TextOut(hdc, 9, 9, &td_characters[i], 1);
+                                                                       TextOut(hdc, 11, 9, &td_characters[i], 1);
+                                                                       TextOut(hdc, 11, 11, &td_characters[i], 1);
+                                                                       TextOut(hdc, 9, 11, &td_characters[i], 1);
+                                                                       for (int y = 0; y < h; y++) {
+                                                                               uae_u8 *src = (uae_u8 *)bm + (y + offsety) * width + offsetx;
+                                                                               char *dst = td_new_numbers + i * w + y * w * NUMBERS_NUM;
+                                                                               for (int x = 0; x < w; x++) {
+                                                                                       uae_u8 b = *src++;
+                                                                                       if (b == 2 && dst[0] == '-') {
+                                                                                               *dst = '+';
+                                                                                       }
+                                                                                       dst++;
+                                                                               }
+                                                                       }
+
+                                                               }
+                                                       }
+                                                       statusline_set_font(td_new_numbers, w, h);
+                                                       DeleteObject(font);
+                                               }
+                                               DeleteObject(bitmap);
+                                       }
+                                       xfree(bi);
+                               }
+                               DeleteObject(hpal);
+                       }
+                       xfree(lp);
+               }
+               ReleaseDC(NULL, hdc);
+       }
+}
+
 bool createstatusline(int monid)
 {
        struct AmigaMonitor *mon = &AMonitors[monid];
@@ -65,29 +198,34 @@ bool createstatusline(int monid)
        if (!statusline_hdc)
                return false;
        lp = (LOGPALETTE*)xcalloc(uae_u8, sizeof(LOGPALETTE) + 3 * sizeof(PALETTEENTRY));
+       if (!lp)
+               return false;
        lp->palNumEntries = 4;
        lp->palVersion = 0x300;
        lp->palPalEntry[1].peBlue = lp->palPalEntry[1].peGreen = lp->palPalEntry[0].peRed = 0x10;
        lp->palPalEntry[2].peBlue = lp->palPalEntry[2].peGreen = lp->palPalEntry[2].peRed = 0xff;
        lp->palPalEntry[3].peBlue = lp->palPalEntry[3].peGreen = lp->palPalEntry[3].peRed = 0x7f;
        statusline_palette = CreatePalette(lp);
+       xfree(lp);
        SelectPalette(statusline_hdc, statusline_palette, FALSE);
        statusline_width = (WIN32GFX_GetWidth(mon) + 31) & ~31;
        bi = (BITMAPINFO*)xcalloc(uae_u8, sizeof(BITMAPINFOHEADER) + 4 * sizeof(RGBQUAD));
-       bih = &bi->bmiHeader;
-       bih->biSize = sizeof(BITMAPINFOHEADER);
-       bih->biWidth = statusline_width;
-       bih->biHeight = -statusline_height;
-       bih->biPlanes = 1;
-       bih->biBitCount = 8;
-       bih->biCompression = BI_RGB;
-       bih->biClrUsed = 4;
-       bih->biClrImportant = 4;
-       bi->bmiColors[1].rgbBlue = bi->bmiColors[1].rgbGreen = bi->bmiColors[1].rgbRed = 0x10;
-       bi->bmiColors[2].rgbBlue = bi->bmiColors[2].rgbGreen = bi->bmiColors[2].rgbRed = 0xff;
-       bi->bmiColors[3].rgbBlue = bi->bmiColors[3].rgbGreen = bi->bmiColors[3].rgbRed = 0x7f;
-       statusline_bitmap = CreateDIBSection(statusline_hdc, bi, DIB_RGB_COLORS, &statusline_bm, NULL, 0);
-       xfree(bi);
+       if (bi) {
+               bih = &bi->bmiHeader;
+               bih->biSize = sizeof(BITMAPINFOHEADER);
+               bih->biWidth = statusline_width;
+               bih->biHeight = -statusline_height;
+               bih->biPlanes = 1;
+               bih->biBitCount = 8;
+               bih->biCompression = BI_RGB;
+               bih->biClrUsed = 4;
+               bih->biClrImportant = 4;
+               bi->bmiColors[1].rgbBlue = bi->bmiColors[1].rgbGreen = bi->bmiColors[1].rgbRed = 0x10;
+               bi->bmiColors[2].rgbBlue = bi->bmiColors[2].rgbGreen = bi->bmiColors[2].rgbRed = 0xff;
+               bi->bmiColors[3].rgbBlue = bi->bmiColors[3].rgbGreen = bi->bmiColors[3].rgbRed = 0x7f;
+               statusline_bitmap = CreateDIBSection(statusline_hdc, bi, DIB_RGB_COLORS, &statusline_bm, NULL, 0);
+               xfree(bi);
+       }
        if (!statusline_bitmap) {
                deletestatusline(mon->monitor_id);
                return false;
@@ -95,6 +233,8 @@ bool createstatusline(int monid)
        SelectObject(statusline_hdc, statusline_bitmap);
        RealizePalette(statusline_hdc);
 
+       create_led_font(monid);
+
        statusline_font = CreateFont(-10, 0,
                0, 0,
                FW_NORMAL,
@@ -111,6 +251,7 @@ bool createstatusline(int monid)
        SetTextColor(statusline_hdc, PALETTEINDEX(2));
        SetBkColor(statusline_hdc, PALETTEINDEX(1));
        SetBkMode(statusline_hdc, OPAQUE);
+
        return true;
 }
 
@@ -148,12 +289,12 @@ void statusline_render(int monid, uae_u8 *buf, int bpp, int pitch, int width, in
        if (GetTextExtentPoint32(statusline_hdc, text, _tcslen(text), &size)) {
                textwidth = size.cx;
                if (isfullscreen()) {
-                       if (td_pos & TD_RIGHT) {
-                               bar_xstart = width - TD_PADX - VISIBLE_LEDS * TD_WIDTH;
-                               x = bar_xstart - textwidth - TD_LED_WIDTH;
+                       if (td_numbers_pos & TD_RIGHT) {
+                               bar_xstart = width - TD_PADX - VISIBLE_LEDS * td_width;
+                               x = bar_xstart - textwidth - td_led_width;
                        } else {
                                bar_xstart = TD_PADX;
-                               x = bar_xstart + textwidth + TD_LED_WIDTH;
+                               x = bar_xstart + textwidth + td_led_width;
                        }
                }
        }
index bd924cd2713358dc6782afeda7d3c5fd316118e7..030885ffa350a315cde08bfd9f57e7e4586e9532 100644 (file)
 * Some code to put status information on the screen.
 */
 
+static bool td_custom;
+
 void statusline_getpos(int monid, int *x, int *y, int width, int height)
 {
-       int mx = statusline_get_multiplier(monid);
+       int mx = td_custom ? 1 : statusline_get_multiplier(monid) / 100;
        int total_height = TD_TOTAL_HEIGHT * mx;
        if (currprefs.osd_pos.x >= 20000) {
                if (currprefs.osd_pos.x >= 30000)
@@ -47,7 +49,15 @@ void statusline_getpos(int monid, int *x, int *y, int width, int height)
        }
 }
 
-static const char *numbers = { /* ugly  0123456789CHD%+-PNKV */
+int td_numbers_pos = TD_RIGHT | TD_BOTTOM;
+int td_numbers_width = TD_DEFAULT_NUM_WIDTH;
+int td_numbers_height = TD_DEFAULT_NUM_HEIGHT;
+const TCHAR *td_characters = _T("0123456789CHD%+-PNKV");
+int td_led_width = TD_DEFAULT_LED_WIDTH;
+static int td_led_height = TD_DEFAULT_LED_HEIGHT;
+int td_width = TD_DEFAULT_WIDTH;
+
+static const char *numbers_default = { /* ugly  0123456789CHD%+-PNKV */
        "+++++++--++++-+++++++++++++++++-++++++++++++++++++++++++++++++++++++++++++++-++++++-++++----++---+--------------++++++++++-++++++++++++  +++"
        "+xxxxx+--+xx+-+xxxxx++xxxxx++x+-+x++xxxxx++xxxxx++xxxxx++xxxxx++xxxxx++xxxx+-+x++x+-+xxx++-+xx+-+x---+----------+xxxxx++x+-+x++x++x++x+  +x+"
        "+x+++x+--++x+-+++++x++++++x++x+++x++x++++++x++++++++++x++x+++x++x+++x++x++++-+x++x+-+x++x+--+x++x+--+x+----+++--+x---x++xx++x++x+x+++x+  +x+"
@@ -58,6 +68,9 @@ static const char *numbers = { /* ugly  0123456789CHD%+-PNKV */
 //   x      x      x      x      x      x      x      x      x      x      x      x      x      x      x      x      x      x      x      x      x  
 };
 
+static const char *numbers = numbers_default;
+
+
 STATIC_INLINE uae_u32 ledcolor(uae_u32 c, uae_u32 *rc, uae_u32 *gc, uae_u32 *bc, uae_u32 *a)
 {
        uae_u32 v = rc[(c >> 16) & 0xff] | gc[(c >> 8) & 0xff] | bc[(c >> 0) & 0xff];
@@ -71,8 +84,8 @@ static void write_tdnumber(uae_u8 *buf, int bpp, int x, int y, int num, uae_u32
        int j;
        const char *numptr;
 
-       numptr = numbers + num * TD_NUM_WIDTH + NUMBERS_NUM * TD_NUM_WIDTH * y;
-       for (j = 0; j < TD_NUM_WIDTH; j++) {
+       numptr = numbers + num * td_numbers_width + NUMBERS_NUM * td_numbers_width * y;
+       for (j = 0; j < td_numbers_width; j++) {
                for (int k = 0; k < mult; k++) {
                        if (*numptr == 'x')
                                putpixel(buf, NULL, bpp, x + j * mult + k, c1, 1);
@@ -98,16 +111,35 @@ static uae_u32 rgbmuldiv(uae_u32 rgb, int mul, int div)
 
 static int statusline_mult[2];
 
+void statusline_set_font(const char *newnumbers, int width, int height)
+{
+       td_numbers_width = TD_DEFAULT_NUM_WIDTH;
+       td_numbers_height = TD_DEFAULT_NUM_HEIGHT;
+       td_led_width = TD_DEFAULT_LED_WIDTH;
+       td_led_height = TD_DEFAULT_LED_HEIGHT;
+       td_width = TD_DEFAULT_WIDTH;
+       td_custom = false;
+       numbers = numbers_default;
+       if (!newnumbers)
+               return;
+       numbers = newnumbers;
+       td_numbers_width = width;
+       td_numbers_height = height;
+       td_led_width = td_numbers_width * 3;
+       td_width = td_led_width + 10;
+       td_custom = true;
+}
+
 int statusline_set_multiplier(int monid, int width, int height)
 {
        struct amigadisplay *ad = &adisplays[monid];
        int idx = ad->picasso_on ? 1 : 0;
        int mult = currprefs.leds_on_screen_multiplier[idx];
-       if (!mult) {
-               mult = 1;
+       if (mult < 100) {
+               mult = 100;
        }
-       if (mult > 4) {
-               mult = 4;
+       if (mult > 4 * 100) {
+               mult = 4 * 100;
        }
        statusline_mult[idx] = mult;
        return mult;
@@ -127,7 +159,7 @@ void draw_status_line_single(int monid, uae_u8 *buf, int bpp, int y, int totalwi
        struct amigadisplay *ad = &adisplays[monid];
        int x_start, j, led, border;
        uae_u32 c1, c2, cb;
-       int mult = statusline_mult[ad->picasso_on ? 1 : 0];
+       int mult = td_custom ? 1 : statusline_mult[ad->picasso_on ? 1 : 0] / 100;
 
        if (!mult)
                return;
@@ -137,8 +169,8 @@ void draw_status_line_single(int monid, uae_u8 *buf, int bpp, int y, int totalwi
        c1 = ledcolor (0x00ffffff, rc, gc, bc, alpha);
        c2 = ledcolor (0x00000000, rc, gc, bc, alpha);
 
-       if (td_pos & TD_RIGHT)
-               x_start = totalwidth - (TD_PADX + VISIBLE_LEDS * TD_WIDTH) * mult;
+       if (td_numbers_pos & TD_RIGHT)
+               x_start = totalwidth - (TD_PADX + VISIBLE_LEDS * td_width) * mult;
        else
                x_start = TD_PADX * mult;
 
@@ -342,12 +374,12 @@ void draw_status_line_single(int monid, uae_u8 *buf, int bpp, int y, int totalwi
                        border = 1;
                }
 
-               x = x_start + pos * TD_WIDTH * mult;
+               x = x_start + pos * td_width * mult;
                for (int xx = 0; xx < mult; xx++) {
                        if (!border) {
                                putpixel(buf, NULL, bpp, x - mult + xx, cb, 0);
                        }
-                       for (j = 0; j < TD_LED_WIDTH * mult; j += mult) {
+                       for (j = 0; j < td_led_width * mult; j += mult) {
                                putpixel(buf, NULL, bpp, x + j + xx, c, 0);
                        }
                        if (!border) {
@@ -355,19 +387,19 @@ void draw_status_line_single(int monid, uae_u8 *buf, int bpp, int y, int totalwi
                        }
                }
 
-               if (y >= TD_PADY && y - TD_PADY < TD_NUM_HEIGHT) {
+               if (y >= TD_PADY && y - TD_PADY < td_numbers_height) {
                        if (num3 >= 0) {
-                               x += (TD_LED_WIDTH - am * TD_NUM_WIDTH) * mult / 2;
+                               x += (td_led_width - am * td_numbers_width) * mult / 2;
                                if (num1 > 0) {
                                        write_tdnumber(buf, bpp, x, y - TD_PADY, num1, pen_rgb, c2, mult);
-                                       x += TD_NUM_WIDTH * mult;
+                                       x += td_numbers_width * mult;
                                }
                                if (num2 >= 0) {
                                        write_tdnumber(buf, bpp, x, y - TD_PADY, num2, pen_rgb, c2, mult);
-                                       x += TD_NUM_WIDTH * mult;
+                                       x += td_numbers_width * mult;
                                }
                                write_tdnumber(buf, bpp, x, y - TD_PADY, num3, pen_rgb, c2, mult);
-                               x += TD_NUM_WIDTH * mult;
+                               x += td_numbers_width * mult;
                                if (num4 > 0)
                                        write_tdnumber(buf, bpp, x, y - TD_PADY, num4, pen_rgb, c2, mult);
                        }