diff --git a/login.c b/login.c index 5554c0e..1223486 100644 --- a/login.c +++ b/login.c @@ -23,18 +23,75 @@ static uint8 script_login_name[64]; static uint8 script_file_server[52]; -#if defined(__WATCOMC__) -extern void textbackground(int color); -extern void textcolor(int color); -extern void clrscr(void); -extern void gotoxy(int x, int y); -#endif - -extern char **build_argv(char *buf, int bufsize, char *str); +static char **build_argv(char *buf, int bufsize, char *str); extern int read_command_file(char *fstr); extern int get_fs_name(int connid, char *name); +static uint8 login_video_attr = 0x07; + +static void login_gotoxy(int x, int y) +{ + REGS regs; + + regs.h.ah = 0x02; + regs.h.bh = 0x00; + regs.h.dh = (uint8)(y - 1); + regs.h.dl = (uint8)(x - 1); + int86(0x10, ®s, ®s); +} + +static void login_cls_attr(uint8 attr) +{ + REGS regs; + + regs.h.ah = 0x06; + regs.h.al = 0x00; + regs.h.bh = attr; + regs.h.ch = 0; + regs.h.cl = 0; + regs.h.dh = 24; + regs.h.dl = 79; + int86(0x10, ®s, ®s); + login_gotoxy(1, 1); +} + +static void login_write_attr(int x, int y, const char *s, uint8 attr) +{ + REGS regs; + int col = x; + + while (*s) { + login_gotoxy(col++, y); + regs.h.ah = 0x09; + regs.h.al = (uint8)*s++; + regs.h.bh = 0; + regs.h.bl = attr; + regs.x.cx = 1; + int86(0x10, ®s, ®s); + } + login_gotoxy(col, y); +} + +static void login_fill_line(int y, uint8 attr) +{ + REGS regs; + + login_gotoxy(1, y); + regs.h.ah = 0x09; + regs.h.al = ' '; + regs.h.bh = 0; + regs.h.bl = attr; + regs.x.cx = 80; + int86(0x10, ®s, ®s); +} + +static void login_screen_normal(void) +{ + login_video_attr = 0x07; +} + + static int login_help(void) { fprintf(stdout, "\n"); @@ -58,20 +115,12 @@ static int login_help(void) static void login_banner(void) { - int i; - - textbackground(BLUE); - textcolor(WHITE); - clrscr(); - - gotoxy(1, 1); - for (i = 0; i < 80; i++) putch(' '); - gotoxy(36, 1); - cputs("Mars NWE"); - - textbackground(BLACK); - textcolor(LIGHTGRAY); - gotoxy(1, 3); + login_video_attr = 0x1f; /* white on blue */ + login_cls_attr(login_video_attr); + login_fill_line(1, login_video_attr); + login_write_attr(36, 1, "Mars NWE", login_video_attr); + login_screen_normal(); + login_gotoxy(1, 3); } static char *skip_spaces(char *p) @@ -256,7 +305,7 @@ static int script_execute_line(char *line) } if (!strcmp(cmd, "CLS")) { - clrscr(); + login_cls_attr(0x07); return(0); } @@ -495,7 +544,7 @@ int func_login(int argc, char *argv[], int mode) if (argv[1][0] == '-' || argv[1][0] == '/') { if (argv[1][1] == 'u' || argv[1][1] == 'U') option |= 1; else if (!strcmp(argv[1], "/NS") || !strcmp(argv[1], "-NS")) no_script = 1; - else if (!strcmp(argv[1], "/CLS") || !strcmp(argv[1], "-CLS")) clrscr(); + else if (!strcmp(argv[1], "/CLS") || !strcmp(argv[1], "-CLS")) login_cls_attr(0x07); else return(login_usage()); argc--; argv++;