From a1af9248ebdacbe8cad40c4b7852e34fccde1d1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Schmidt?= Date: Fri, 8 Aug 1997 22:52:30 +0000 Subject: [PATCH] Yeah I'm back hacking syscons !! Add support for MODEX 320x240x256color with "unchained" adressing, giving access to all 256K on all VGA's, those with that much memory that is :) Also make sysmouse use the right resolution in graphics modes. --- sys/alpha/include/console.h | 6 +++- sys/dev/syscons/syscons.c | 62 +++++++++++++++++++++++++++++++++---- sys/i386/include/console.h | 6 +++- sys/i386/isa/syscons.c | 62 +++++++++++++++++++++++++++++++++---- sys/isa/syscons.c | 62 +++++++++++++++++++++++++++++++++---- 5 files changed, 178 insertions(+), 20 deletions(-) diff --git a/sys/alpha/include/console.h b/sys/alpha/include/console.h index 6abf63e50c13..0dcd14cfd356 100644 --- a/sys/alpha/include/console.h +++ b/sys/alpha/include/console.h @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id$ + * $Id: console.h,v 1.29 1997/02/22 09:34:02 peter Exp $ */ #ifndef _MACHINE_CONSOLE_H_ @@ -312,6 +312,8 @@ typedef struct ssaver ssaver_t; #define M_VGA_M80x30 33 /* vga 8x16 font on color */ #define M_VGA_C80x60 34 /* vga 8x8 font on color */ #define M_VGA_M80x60 35 /* vga 8x8 font on color */ +#define M_VGA_CG640 36 /* vga 640x400 256 color */ +#define M_VGA_MODEX 37 /* vga 320x240 256 color */ #define M_ENH_B80x43 0x70 /* ega black & white 80x43 */ #define M_ENH_C80x43 0x71 /* ega color 80x43 */ @@ -360,6 +362,8 @@ typedef struct ssaver ssaver_t; #define SW_CG640x480 _IO('S', M_VGA12) #define SW_VGA13 _IO('S', M_VGA13) #define SW_VGA_CG320 _IO('S', M_VGA13) +#define SW_VGA_CG640 _IO('S', M_VGA_CG640) +#define SW_VGA_MODEX _IO('S', M_VGA_MODEX) #endif /* PC98 */ #endif /* !_MACHINE_CONSOLE_H_ */ diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c index 22c5d4a3442a..8b4add5af1cd 100644 --- a/sys/dev/syscons/syscons.c +++ b/sys/dev/syscons/syscons.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: syscons.c,v 1.227 1997/07/25 11:53:30 phk Exp $ + * $Id: syscons.c,v 1.228 1997/07/26 07:58:29 phk Exp $ */ #include "sc.h" @@ -1219,6 +1219,24 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) } return 0; + case SW_VGA_MODEX: + if (!crtc_vga || video_mode_ptr == NULL) + return ENXIO; + scp->mode = cmd & 0xFF; + if (scp == cur_console) + set_mode(scp); + scp->status |= UNKNOWN_MODE; /* graphics mode */ + /* clear_graphics();*/ + scp->xpixel = 320; + scp->ypixel = 240; + if (tp->t_winsize.ws_xpixel != scp->xpixel + || tp->t_winsize.ws_ypixel != scp->ypixel) { + tp->t_winsize.ws_xpixel = scp->xpixel; + tp->t_winsize.ws_ypixel = scp->ypixel; + pgsignal(tp->t_pgrp, SIGWINCH, 1); + } + return 0; + case VT_SETMODE: /* set screen switcher mode */ { struct vt_mode *mode; @@ -3498,12 +3516,40 @@ setup_mode: mark_all(scp); break; + case M_VGA_MODEX: + /* start out with std 320x200x256 mode */ + bcopy(video_mode_ptr+(64*M_VGA_CG320), &special_modetable, 64); + /* "unchain" the VGA mode */ + special_modetable[5-1+0x04] &= 0xf7; + special_modetable[5-1+0x04] |= 0x04; + /* turn off doubleword mode */ + special_modetable[10+0x14] &= 0xbf; + /* turn off word adressing */ + special_modetable[10+0x17] |= 0x40; + /* set logical screen width */ + special_modetable[10+0x13] = 80; + /* set 240 lines */ + special_modetable[10+0x11] = 0x2c; + special_modetable[10+0x06] = 0x0d; + special_modetable[10+0x07] = 0x3e; + special_modetable[10+0x10] = 0xea; + special_modetable[10+0x11] = 0xac; + special_modetable[10+0x12] = 0xdf; + special_modetable[10+0x15] = 0xe7; + special_modetable[10+0x16] = 0x06; + /* set vertical sync polarity to reflect aspect ratio */ + special_modetable[9] = 0xe3; + + modetable = special_modetable; + goto setup_grmode; + case M_BG320: case M_CG320: case M_BG640: case M_CG320_D: case M_CG640_E: case M_CG640x350: case M_ENH_CG640: case M_BG640x480: case M_CG640x480: case M_VGA_CG320: - - set_vgaregs(video_mode_ptr + (scp->mode * 64)); + modetable = video_mode_ptr + (scp->mode * 64); +setup_grmode: + set_vgaregs(modetable); scp->font_size = FONT_NONE; break; @@ -3862,14 +3908,18 @@ set_mouse_pos(scr_stat *scp) scp->mouse_xpos = 0; if (scp->mouse_ypos < 0) scp->mouse_ypos = 0; + if (scp->status & UNKNOWN_MODE) { + if (scp->mouse_xpos > scp->xpixel) + scp->mouse_xpos = scp->xpixel-1; + if (scp->mouse_ypos > scp->ypixel) + scp->mouse_ypos = scp->ypixel-1; + return; + } if (scp->mouse_xpos > (scp->xsize*8)-2) scp->mouse_xpos = (scp->xsize*8)-2; if (scp->mouse_ypos > (scp->ysize*scp->font_size)-2) scp->mouse_ypos = (scp->ysize*scp->font_size)-2; - if (scp->status & UNKNOWN_MODE) - return; - if (scp->mouse_xpos != last_xpos || scp->mouse_ypos != last_ypos) { scp->status |= MOUSE_MOVED; diff --git a/sys/i386/include/console.h b/sys/i386/include/console.h index 6abf63e50c13..0dcd14cfd356 100644 --- a/sys/i386/include/console.h +++ b/sys/i386/include/console.h @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id$ + * $Id: console.h,v 1.29 1997/02/22 09:34:02 peter Exp $ */ #ifndef _MACHINE_CONSOLE_H_ @@ -312,6 +312,8 @@ typedef struct ssaver ssaver_t; #define M_VGA_M80x30 33 /* vga 8x16 font on color */ #define M_VGA_C80x60 34 /* vga 8x8 font on color */ #define M_VGA_M80x60 35 /* vga 8x8 font on color */ +#define M_VGA_CG640 36 /* vga 640x400 256 color */ +#define M_VGA_MODEX 37 /* vga 320x240 256 color */ #define M_ENH_B80x43 0x70 /* ega black & white 80x43 */ #define M_ENH_C80x43 0x71 /* ega color 80x43 */ @@ -360,6 +362,8 @@ typedef struct ssaver ssaver_t; #define SW_CG640x480 _IO('S', M_VGA12) #define SW_VGA13 _IO('S', M_VGA13) #define SW_VGA_CG320 _IO('S', M_VGA13) +#define SW_VGA_CG640 _IO('S', M_VGA_CG640) +#define SW_VGA_MODEX _IO('S', M_VGA_MODEX) #endif /* PC98 */ #endif /* !_MACHINE_CONSOLE_H_ */ diff --git a/sys/i386/isa/syscons.c b/sys/i386/isa/syscons.c index 22c5d4a3442a..8b4add5af1cd 100644 --- a/sys/i386/isa/syscons.c +++ b/sys/i386/isa/syscons.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: syscons.c,v 1.227 1997/07/25 11:53:30 phk Exp $ + * $Id: syscons.c,v 1.228 1997/07/26 07:58:29 phk Exp $ */ #include "sc.h" @@ -1219,6 +1219,24 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) } return 0; + case SW_VGA_MODEX: + if (!crtc_vga || video_mode_ptr == NULL) + return ENXIO; + scp->mode = cmd & 0xFF; + if (scp == cur_console) + set_mode(scp); + scp->status |= UNKNOWN_MODE; /* graphics mode */ + /* clear_graphics();*/ + scp->xpixel = 320; + scp->ypixel = 240; + if (tp->t_winsize.ws_xpixel != scp->xpixel + || tp->t_winsize.ws_ypixel != scp->ypixel) { + tp->t_winsize.ws_xpixel = scp->xpixel; + tp->t_winsize.ws_ypixel = scp->ypixel; + pgsignal(tp->t_pgrp, SIGWINCH, 1); + } + return 0; + case VT_SETMODE: /* set screen switcher mode */ { struct vt_mode *mode; @@ -3498,12 +3516,40 @@ setup_mode: mark_all(scp); break; + case M_VGA_MODEX: + /* start out with std 320x200x256 mode */ + bcopy(video_mode_ptr+(64*M_VGA_CG320), &special_modetable, 64); + /* "unchain" the VGA mode */ + special_modetable[5-1+0x04] &= 0xf7; + special_modetable[5-1+0x04] |= 0x04; + /* turn off doubleword mode */ + special_modetable[10+0x14] &= 0xbf; + /* turn off word adressing */ + special_modetable[10+0x17] |= 0x40; + /* set logical screen width */ + special_modetable[10+0x13] = 80; + /* set 240 lines */ + special_modetable[10+0x11] = 0x2c; + special_modetable[10+0x06] = 0x0d; + special_modetable[10+0x07] = 0x3e; + special_modetable[10+0x10] = 0xea; + special_modetable[10+0x11] = 0xac; + special_modetable[10+0x12] = 0xdf; + special_modetable[10+0x15] = 0xe7; + special_modetable[10+0x16] = 0x06; + /* set vertical sync polarity to reflect aspect ratio */ + special_modetable[9] = 0xe3; + + modetable = special_modetable; + goto setup_grmode; + case M_BG320: case M_CG320: case M_BG640: case M_CG320_D: case M_CG640_E: case M_CG640x350: case M_ENH_CG640: case M_BG640x480: case M_CG640x480: case M_VGA_CG320: - - set_vgaregs(video_mode_ptr + (scp->mode * 64)); + modetable = video_mode_ptr + (scp->mode * 64); +setup_grmode: + set_vgaregs(modetable); scp->font_size = FONT_NONE; break; @@ -3862,14 +3908,18 @@ set_mouse_pos(scr_stat *scp) scp->mouse_xpos = 0; if (scp->mouse_ypos < 0) scp->mouse_ypos = 0; + if (scp->status & UNKNOWN_MODE) { + if (scp->mouse_xpos > scp->xpixel) + scp->mouse_xpos = scp->xpixel-1; + if (scp->mouse_ypos > scp->ypixel) + scp->mouse_ypos = scp->ypixel-1; + return; + } if (scp->mouse_xpos > (scp->xsize*8)-2) scp->mouse_xpos = (scp->xsize*8)-2; if (scp->mouse_ypos > (scp->ysize*scp->font_size)-2) scp->mouse_ypos = (scp->ysize*scp->font_size)-2; - if (scp->status & UNKNOWN_MODE) - return; - if (scp->mouse_xpos != last_xpos || scp->mouse_ypos != last_ypos) { scp->status |= MOUSE_MOVED; diff --git a/sys/isa/syscons.c b/sys/isa/syscons.c index 22c5d4a3442a..8b4add5af1cd 100644 --- a/sys/isa/syscons.c +++ b/sys/isa/syscons.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: syscons.c,v 1.227 1997/07/25 11:53:30 phk Exp $ + * $Id: syscons.c,v 1.228 1997/07/26 07:58:29 phk Exp $ */ #include "sc.h" @@ -1219,6 +1219,24 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) } return 0; + case SW_VGA_MODEX: + if (!crtc_vga || video_mode_ptr == NULL) + return ENXIO; + scp->mode = cmd & 0xFF; + if (scp == cur_console) + set_mode(scp); + scp->status |= UNKNOWN_MODE; /* graphics mode */ + /* clear_graphics();*/ + scp->xpixel = 320; + scp->ypixel = 240; + if (tp->t_winsize.ws_xpixel != scp->xpixel + || tp->t_winsize.ws_ypixel != scp->ypixel) { + tp->t_winsize.ws_xpixel = scp->xpixel; + tp->t_winsize.ws_ypixel = scp->ypixel; + pgsignal(tp->t_pgrp, SIGWINCH, 1); + } + return 0; + case VT_SETMODE: /* set screen switcher mode */ { struct vt_mode *mode; @@ -3498,12 +3516,40 @@ setup_mode: mark_all(scp); break; + case M_VGA_MODEX: + /* start out with std 320x200x256 mode */ + bcopy(video_mode_ptr+(64*M_VGA_CG320), &special_modetable, 64); + /* "unchain" the VGA mode */ + special_modetable[5-1+0x04] &= 0xf7; + special_modetable[5-1+0x04] |= 0x04; + /* turn off doubleword mode */ + special_modetable[10+0x14] &= 0xbf; + /* turn off word adressing */ + special_modetable[10+0x17] |= 0x40; + /* set logical screen width */ + special_modetable[10+0x13] = 80; + /* set 240 lines */ + special_modetable[10+0x11] = 0x2c; + special_modetable[10+0x06] = 0x0d; + special_modetable[10+0x07] = 0x3e; + special_modetable[10+0x10] = 0xea; + special_modetable[10+0x11] = 0xac; + special_modetable[10+0x12] = 0xdf; + special_modetable[10+0x15] = 0xe7; + special_modetable[10+0x16] = 0x06; + /* set vertical sync polarity to reflect aspect ratio */ + special_modetable[9] = 0xe3; + + modetable = special_modetable; + goto setup_grmode; + case M_BG320: case M_CG320: case M_BG640: case M_CG320_D: case M_CG640_E: case M_CG640x350: case M_ENH_CG640: case M_BG640x480: case M_CG640x480: case M_VGA_CG320: - - set_vgaregs(video_mode_ptr + (scp->mode * 64)); + modetable = video_mode_ptr + (scp->mode * 64); +setup_grmode: + set_vgaregs(modetable); scp->font_size = FONT_NONE; break; @@ -3862,14 +3908,18 @@ set_mouse_pos(scr_stat *scp) scp->mouse_xpos = 0; if (scp->mouse_ypos < 0) scp->mouse_ypos = 0; + if (scp->status & UNKNOWN_MODE) { + if (scp->mouse_xpos > scp->xpixel) + scp->mouse_xpos = scp->xpixel-1; + if (scp->mouse_ypos > scp->ypixel) + scp->mouse_ypos = scp->ypixel-1; + return; + } if (scp->mouse_xpos > (scp->xsize*8)-2) scp->mouse_xpos = (scp->xsize*8)-2; if (scp->mouse_ypos > (scp->ysize*scp->font_size)-2) scp->mouse_ypos = (scp->ysize*scp->font_size)-2; - if (scp->status & UNKNOWN_MODE) - return; - if (scp->mouse_xpos != last_xpos || scp->mouse_ypos != last_ypos) { scp->status |= MOUSE_MOVED;