From owner-freebsd-hackers Thu Nov 7 14:41:47 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id OAA22469 for hackers-outgoing; Thu, 7 Nov 1996 14:41:47 -0800 (PST) Received: from who.cdrom.com (who.cdrom.com [204.216.27.3]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id OAA22459 for ; Thu, 7 Nov 1996 14:41:41 -0800 (PST) Received: from profane.iq.org (profane.iq.org [203.4.184.222]) by who.cdrom.com (8.7.5/8.6.11) with ESMTP id KAA17489 for ; Thu, 7 Nov 1996 10:02:40 -0800 (PST) Received: (from smtpd@localhost) by profane.iq.org (8.8.2/8.8.2) id AAA01322 for ; Fri, 8 Nov 1996 00:19:50 +1100 (EST) Message-Id: <199611071319.AAA01322@profane.iq.org> Received: from localhost(127.0.0.1), claiming to be "profane.iq.org" via SMTP by localhost, id smtpd001024; Thu Nov 7 06:28:02 1996 To: hackers@freebsd.org Subject: patches for nice text modes (170x48x16 etc) (syscons.c) Date: Thu, 07 Nov 1996 17:28:00 +1100 From: Julian Assange Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk --- sys/i386/isa/syscons.c.orig Thu Oct 17 00:51:11 1996 +++ sys/i386/isa/syscons.c Fri Oct 18 05:19:47 1996 @@ -195,6 +195,7 @@ static void set_vgaregs(char *modetable); static void set_font_mode(void); static void set_normal_mode(void); +static int change_mode (struct tty *tp, scr_stat *scp, int mode); static void set_destructive_cursor(scr_stat *scp); static void set_mouse_pos(scr_stat *scp); static void mouse_cut_start(scr_stat *scp); @@ -840,62 +841,10 @@ case SW_ENH_B40x25: case SW_ENH_C40x25: case SW_ENH_B80x25: case SW_ENH_C80x25: case SW_ENH_B80x43: case SW_ENH_C80x43: - + case SW_USER: if (!crtc_vga || video_mode_ptr == NULL) return ENXIO; - switch (cmd & 0xff) { - case M_VGA_C80x60: case M_VGA_M80x60: - if (!(fonts_loaded & FONT_8)) - return EINVAL; - scp->xsize = 80; - scp->ysize = 60; - break; - case M_VGA_C80x50: case M_VGA_M80x50: - if (!(fonts_loaded & FONT_8)) - return EINVAL; - scp->xsize = 80; - scp->ysize = 50; - break; - case M_ENH_B80x43: case M_ENH_C80x43: - if (!(fonts_loaded & FONT_8)) - return EINVAL; - scp->xsize = 80; - scp->ysize = 43; - break; - case M_VGA_C80x30: case M_VGA_M80x30: - scp->xsize = 80; - scp->ysize = 30; - break; - default: - if ((cmd & 0xff) > M_VGA_CG320) - return EINVAL; - else - scp->xsize = *(video_mode_ptr+((cmd&0xff)*64)); - scp->ysize = *(video_mode_ptr+((cmd&0xff)*64)+1)+1; - break; - } - scp->mode = cmd & 0xff; - free(scp->scr_buf, M_DEVBUF); - scp->scr_buf = (u_short *) - malloc(scp->xsize*scp->ysize*sizeof(u_short), M_DEVBUF, M_WAITOK); - scp->cursor_pos = scp->cursor_oldpos = - scp->scr_buf + scp->xpos + scp->ypos * scp->xsize; - scp->mouse_pos = scp->mouse_oldpos = - scp->scr_buf + ((scp->mouse_ypos/scp->font_size)*scp->xsize + - scp->mouse_xpos/8); - free(cut_buffer, M_DEVBUF); - cut_buffer = (char *)malloc(scp->xsize*scp->ysize, M_DEVBUF, M_NOWAIT); - cut_buffer[0] = 0x00; - if (scp == cur_console) - set_mode(scp); - scp->status &= ~UNKNOWN_MODE; - clear_screen(scp); - if (tp->t_winsize.ws_col != scp->xsize - || tp->t_winsize.ws_row != scp->ysize) { - tp->t_winsize.ws_col = scp->xsize; - tp->t_winsize.ws_row = scp->ysize; - pgsignal(tp->t_pgrp, SIGWINCH, 1); - } + change_mode(tp, scp, cmd&0xff); return 0; /* GRAPHICS MODES */ @@ -906,7 +855,7 @@ if (!crtc_vga || video_mode_ptr == NULL) return ENXIO; - scp->mode = cmd & 0xFF; + scp->mode = cmd&0xff; scp->xpixel = (*(video_mode_ptr + (scp->mode*64))) * 8; scp->ypixel = (*(video_mode_ptr + (scp->mode*64) + 1) + 1) * (*(video_mode_ptr + (scp->mode*64) + 2)); @@ -1004,6 +953,21 @@ *data = get_scr_num()+1; return 0; + case VT_RESIZE: /* proff */ + { + int n; + vt_consize_t *v = (vt_consize_t*)data; + for (n=0; nysize = v->v_rows; /* number of rows */ + console[n]->xsize = v->v_cols; /* number of columns */ + change_mode(VIRTUAL_TTY(n), console[n], M_USER); + } + } + } + case KDENABIO: /* allow io operations */ error = suser(p->p_ucred, &p->p_acflag); if (error != 0) @@ -1021,7 +985,7 @@ switch (*data) { case KD_TEXT: /* switch to TEXT (known) mode */ /* restore fonts & palette ! */ - if (crtc_vga) { + if (crtc_vga && scp->mode != M_USER) { if (fonts_loaded & FONT_8) copy_font(LOAD, FONT_8, font_8); if (fonts_loaded & FONT_14) @@ -2569,6 +2533,10 @@ history_to_screen(cur_console); } switch (scancode) { + case 0x53: /* grey delete key */ + change_mode(VIRTUAL_TTY(get_scr_num()), cur_console, M_VGA_C80x25); + goto next_code; + case 0x47: /* home key */ cur_console->history_pos = cur_console->history_head; history_to_screen(cur_console); @@ -2951,6 +2919,9 @@ /* setup video hardware for the given mode */ switch (scp->mode) { + case M_USER: + return; + case M_VGA_M80x60: bcopyw(video_mode_ptr+(64*M_VGA_M80x25), &special_modetable, 64); goto special_80x60; @@ -3051,6 +3022,67 @@ /* set border color for this (virtual) console */ set_border(scp->border); return; +} + +static int +change_mode (struct tty *tp, scr_stat *scp, int mode) +{ + switch (mode) { + case M_VGA_C80x60: case M_VGA_M80x60: + if (!(fonts_loaded & FONT_8)) + return EINVAL; + scp->xsize = 80; + scp->ysize = 60; + break; + case M_VGA_C80x50: case M_VGA_M80x50: + if (!(fonts_loaded & FONT_8)) + return EINVAL; + scp->xsize = 80; + scp->ysize = 50; + break; + case M_ENH_B80x43: case M_ENH_C80x43: + if (!(fonts_loaded & FONT_8)) + return EINVAL; + scp->xsize = 80; + scp->ysize = 43; + break; + case M_VGA_C80x30: case M_VGA_M80x30: + scp->xsize = 80; + scp->ysize = 30; + break; + case M_USER: + break; + default: + if (mode > M_VGA_CG320) + return EINVAL; + else + scp->xsize = *(video_mode_ptr+((mode)*64)); + scp->ysize = *(video_mode_ptr+((mode)*64)+1)+1; + break; + } + scp->mode = mode; + free(scp->scr_buf, M_DEVBUF); + scp->scr_buf = (u_short *) + malloc(scp->xsize*scp->ysize*sizeof(u_short), M_DEVBUF, M_WAITOK); + scp->cursor_pos = scp->cursor_oldpos = + scp->scr_buf + scp->xpos + scp->ypos * scp->xsize; + scp->mouse_pos = scp->mouse_oldpos = + scp->scr_buf + ((scp->mouse_ypos/scp->font_size)*scp->xsize + + scp->mouse_xpos/8); + free(cut_buffer, M_DEVBUF); + cut_buffer = (char *)malloc(scp->xsize*scp->ysize, M_DEVBUF, M_NOWAIT); + cut_buffer[0] = 0x00; + if (scp == cur_console) + set_mode(scp); + scp->status &= ~UNKNOWN_MODE; + clear_screen(scp); + if (tp->t_winsize.ws_col != scp->xsize + || tp->t_winsize.ws_row != scp->ysize) { + tp->t_winsize.ws_col = scp->xsize; + tp->t_winsize.ws_row = scp->ysize; + pgsignal(tp->t_pgrp, SIGWINCH, 1); + } + return 0; } void --- sys/i386/include/console.h.orig Thu Oct 17 01:10:16 1996 +++ sys/i386/include/console.h Thu Oct 17 02:55:17 1996 @@ -91,6 +91,7 @@ #define VT_ACTIVATE _IO('v', 5) #define VT_WAITACTIVE _IO('v', 6) #define VT_GETACTIVE _IOR('v', 7, int) +#define VT_RESIZE _IOW('v', 8, vt_consize_t) /* set kernel's idea of screensize */ #define VT_FALSE 0 #define VT_TRUE 1 @@ -219,6 +220,15 @@ u_char mk_keylock; }; +struct vt_consize { + unsigned short v_rows; /* number of rows */ + unsigned short v_cols; /* number of columns */ + unsigned short v_vlin; /* number of pixel rows on screen */ + unsigned short v_clin; /* number of pixel rows per character */ + unsigned short v_vcol; /* number of pixel columns on screen */ + unsigned short v_ccol; /* number of pixel columns per character */ +}; + #define MAXSSAVER 16 struct ssaver { @@ -232,6 +242,7 @@ typedef struct fkeyarg fkeyarg_t; typedef struct vid_info vid_info_t; typedef struct vt_mode vtmode_t; +typedef struct vt_consize vt_consize_t; typedef struct mouse_info mouse_info_t; typedef struct {char scrmap[256];} scrmap_t; typedef struct {char fnt8x8[8*256];} fnt8_t; @@ -335,6 +346,8 @@ #define M_VGA_C80x60 34 /* vga 8x8 font on color */ #define M_VGA_M80x60 35 /* vga 8x8 font on color */ +#define M_USER 36 /* user defined mode */ + #define M_ENH_B80x43 0x70 /* ega black & white 80x43 */ #define M_ENH_C80x43 0x71 /* ega color 80x43 */ #define M_HGC_P0 0xe0 /* hercules graphics - page 0 @ B0000 */ @@ -382,6 +395,7 @@ #define SW_CG640x480 _IO('S', M_VGA12) #define SW_VGA13 _IO('S', M_VGA13) #define SW_VGA_CG320 _IO('S', M_VGA13) +#define SW_USER _IO('S', M_USER) #endif /* PC98 */ #endif /* !_MACHINE_CONSOLE_H_ */