diff --git a/src/frontend_posix.c b/src/frontend_posix.c index 79e18cb..86fa058 100644 --- a/src/frontend_posix.c +++ b/src/frontend_posix.c @@ -44,6 +44,7 @@ static void posix_zzt_help(int argc, char **argv) { fprintf(stderr, " available types/formats: \n"); fprintf(stderr, " - charset:\n"); fprintf(stderr, " - chr (MegaZeux-like; 8x[height], 256 chars)\n"); + fprintf(stderr, " - default (builtin font; ega or cga)\n"); fprintf(stderr, " - palette:\n"); fprintf(stderr, " - pal (MegaZeux-like; 16 colors ranged 00-3F)\n"); fprintf(stderr, " - pld (Toshiba UPAL; 64 EGA colors ranged 00-3F)\n"); @@ -163,6 +164,15 @@ static int posix_zzt_init(int argc, char **argv) { type[filename - type - 1] = '\0'; } + if (strcmp(type, "charset:default") == 0) { + if (strcmp(filename, "ega") == 0) { + zzt_force_default_charset(DEFAULT_CHARSET_STYLE_EGA); + } else if (strcmp(filename, "cga") == 0) { + zzt_force_default_charset(DEFAULT_CHARSET_STYLE_CGA); + } + continue; + } + FILE *file = fopen(filename, "rb"); if (!file) { fprintf(stderr, "Could not open %s!\n", filename); diff --git a/src/zzt.c b/src/zzt.c index e97a106..115792e 100644 --- a/src/zzt.c +++ b/src/zzt.c @@ -277,6 +277,19 @@ static void zzt_load_charset_default() { } } +USER_FUNCTION +void zzt_force_default_charset(zzt_default_charset_style_t style) { + if (style == DEFAULT_CHARSET_STYLE_CGA) { + zzt_load_charset(8, 16, res_8x8dbl_bin, true); + } else if (style == DEFAULT_CHARSET_STYLE_EGA) { + zzt_load_charset(8, 14, res_8x14_bin, true); + } else { + return; + } + + zzt.charset_default = false; +} + static u16 cpu_func_port_in_main(cpu_state* cpu, u16 addr) { zzt_state* zzt = (zzt_state*) cpu; diff --git a/src/zzt.h b/src/zzt.h index b96886c..97ed8e2 100644 --- a/src/zzt.h +++ b/src/zzt.h @@ -30,6 +30,11 @@ #define MAX_FILES 16 #define TEXT_ADDR(x,y) (0xB8000 + ((y)*160) + ((x)*2)) +typedef enum { + DEFAULT_CHARSET_STYLE_EGA, + DEFAULT_CHARSET_STYLE_CGA +} zzt_default_charset_style_t; + // the long story: // 3.579545 MHz - NTSC dotclock // dotclock * 4 = 14.31818 @@ -97,6 +102,8 @@ int zzt_get_blink(void); USER_FUNCTION int zzt_load_charset(int width, int height, u8* data, bool is_default); USER_FUNCTION +void zzt_force_default_charset(zzt_default_charset_style_t style); +USER_FUNCTION int zzt_load_palette(u32* colors); USER_FUNCTION int zzt_load_ega_palette(u8* colors);