diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2025-04-22 04:49:35 +0300 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2025-04-23 06:51:22 +0300 |
commit | 522d0aafc73e4412439921e2dcd10f698984a94f (patch) | |
tree | 07c2c594182e8b502d70916019f49ce8791a3e03 /tecterm.c | |
parent | 21a986f52bd2fb1e6522503cc9796adf71b29a37 (diff) | |
download | videoteco-fork-522d0aafc73e4412439921e2dcd10f698984a94f.tar.gz |
DOS: implemented console size detection
This is done via 10h interrupts and special memory regions.
The alternative would have been to use set the cursor to 9999,9999
and query the cursor position via ANSI escape sequences.
Diffstat (limited to 'tecterm.c')
-rw-r--r-- | tecterm.c | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -1069,6 +1069,32 @@ term_flush() }/* End Routine */ +#ifdef MSDOS + +#define VIDEO 0x10 + +static int +term_isvga(void) +{ + union REGS regs; + regs.x.ax = 0x1a00; + int86(VIDEO, ®s, ®s); + return regs.h.al == 0x1a && regs.h.bl > 6; +} + +static int +term_isega(void) +{ + union REGS regs; + if(term_isvga()) return 0; + regs.h.ah = 0x12; + regs.h.bl = 0x10; + int86(VIDEO, ®s, ®s); + return regs.h.bl != 0x10; +} + +#endif + /** @@ -1115,6 +1141,15 @@ init_term_description( void ) * really knows the size of the terminal window, and in this case, we will * leave it alone. */ +#ifdef MSDOS + /* + * NOTE: It could also be done generically with + * term_goto(9999,9999), followed by \e[6n + */ + if(!term_columns) term_columns = *(uint8_t*)MK_FP(0x40,0x4a) & 255; + if(!term_lines && (term_isvga() || term_isega())) term_lines = *(uint8_t*)MK_FP(0x40,0x84) + 1; +#endif + #ifdef TERMCAP if(!term_columns) term_columns = tgetnum("co"); if(!term_lines) term_lines = tgetnum("li"); |