Skip to content

Commit

Permalink
Fallback to 8x16 font in case 8x14 not present in VGA ROM (#2137)
Browse files Browse the repository at this point in the history
* for now use fonts placed in ram instead of the ones in rom

* switch to 8x16 font default, available on more (all?) known VGA
BIOS.

* revert back to romfonts

* Fallback to 8x16 font if 8x14 is not present in ROM (#1)

* fall back to 8x16 font if 8x14 not present
* added GETROM8x16 to romfont.h

* fix identation 2

* fix typo
  • Loading branch information
rafael2k authored Dec 16, 2024
1 parent f1c7683 commit 51ab9e2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
24 changes: 20 additions & 4 deletions elkscmd/nano-X/drivers/romfont.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,35 @@
#include "romfont.h"

/* local data*/
int ROM_CHAR_HEIGHT = 14; /* number of scan lines in fonts in ROM */
int ROM_CHAR_HEIGHT; /* number of scan lines in fonts in ROM */
FARADDR rom_char_addr;

/* init PC ROM routines, must be called in graphics mode*/
void
pcrom_init(PSD psd)
{
char * p;
FARADDR rom_char_addr_temp;

/* use INT 10h to get address of rom character table*/

/* we first compare if 8x14 font address is equal
* to the 8x16 font address. If yes, it means
* the 8x14 are not present, so we fallback to
* 8x16 fonts. Source:
* https://www.bttr-software.de/products/fix8x14/
*/

rom_char_addr = int10(FNGETROMADDR, GETROM8x14);
rom_char_addr_temp = int10(FNGETROMADDR, GETROM8x16);

if (rom_char_addr == rom_char_addr_temp) {
ROM_CHAR_HEIGHT = 16;
rom_char_addr = rom_char_addr_temp;
} else {
ROM_CHAR_HEIGHT = 14;
}

#if 0
/* check bios data area for actual character height,
* as the returned font isn't always 14 high
Expand All @@ -37,9 +55,7 @@ pcrom_init(PSD psd)
if(ROM_CHAR_HEIGHT > MAX_ROM_HEIGHT)
ROM_CHAR_HEIGHT = MAX_ROM_HEIGHT;
#endif
#if ELKS
ROM_CHAR_HEIGHT = 14;
#endif

p = getenv("CHARHEIGHT");
if(p)
ROM_CHAR_HEIGHT = atoi(p);
Expand Down
1 change: 1 addition & 0 deletions elkscmd/nano-X/drivers/romfont.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
/* int10 functions*/
#define FNGETROMADDR 0x1130 /* function for address of rom character table*/
#define GETROM8x14 0x0200 /* want address of ROM 8x14 char table*/
#define GETROM8x16 0x0600 /* want address of ROM 8x16 char table*/

/* entry points*/
void pcrom_init(PSD psd);
Expand Down

0 comments on commit 51ab9e2

Please sign in to comment.