/* Copyright (C) 1998 BJ Eirich (aka vecna) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Lic See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include "verge.h" void BIOS_SetVideoMode(int mode) { REGISTERS r; SET_AX(r, mode); INTERRUPT(0x10, r); } // =============================== Mode 13h =================================== int Mode13hShutdown(int i) { if (i) BIOS_SetVideoMode(0x3); free(screen); return 0; } void InitMode13h(void) { BIOS_SetVideoMode(0x13); DriverDesc = "320x200 (Mode 13h, linear)"; sx=320, sy=200; tx=20, ty=13; cx1=0, cy1=0; cx2=sx-1, cy2=sy-1; // setup function drivers ShowPage=LFB_ShowPage; ShutdownVideo=Mode13hShutdown; video=(byte *) 0xA0000 + __djgpp_conventional_base; vscreen=(byte *) valloc(sx*sy, "vscreen", 0); screen=vscreen; memset(screen, 0, sx*sy); } // ================================= Mode-X ================================== #define SEQU_ADDR 0x3c4 #define CRTC_ADDR 0x3d4 #define MISC_OUTPUT 0x3c2 #define ATTRCON_ADDR 0x3c0 #define MISC_ADDR 0x3c2 #define VGAENABLE_ADDR 0x3c3 #define SEQ_ADDR 0x3c4 #define GRACON_ADDR 0x3ce #define CRTC_ADDR 0x3d4 #define STATUS_ADDR 0x3da typedef struct { unsigned port; byte index, value; } Register; typedef Register *RegisterPtr; Register scr256x256[] = { { 0x3c2, 0x00, 0xe3},{ 0x3d4, 0x00, 0x5f},{ 0x3d4, 0x01, 0x3f}, { 0x3d4, 0x02, 0x40},{ 0x3d4, 0x03, 0x82},{ 0x3d4, 0x04, 0x4A}, { 0x3d4, 0x05, 0x9A},{ 0x3d4, 0x06, 0x23},{ 0x3d4, 0x07, 0xb2}, { 0x3d4, 0x08, 0x00},{ 0x3d4, 0x09, 0x61},{ 0x3d4, 0x10, 0x0a}, { 0x3d4, 0x11, 0xac},{ 0x3d4, 0x12, 0xff},{ 0x3d4, 0x13, 0x20}, { 0x3d4, 0x14, 0x40},{ 0x3d4, 0x15, 0x07},{ 0x3d4, 0x16, 0x1a}, { 0x3d4, 0x17, 0xa3},{ 0x3c4, 0x01, 0x01},{ 0x3c4, 0x04, 0x0e}, { 0x3ce, 0x05, 0x40},{ 0x3ce, 0x06, 0x05},{ 0x3c0, 0x10, 0x41}, { 0x3c0, 0x13, 0x00} }; // ================================= Code ==================================== void plane(byte p) { int hi=1<>2; for (y=0; y= sx) { memcpy(d,s,sx); bytes-=sx; s+=sx; d+=sx; } else { memcpy(d,s,bytes); s+=bytes; span=sx-bytes; VESASetBank(bank++); d=video; bytes=65536; memcpy(d,s,span); bytes-=span; s+=span; d+=span; } } cpubyte=ETC; return 0; } void Set640x480() { REGISTERS r; DriverDesc = "640x480 (VESA, Banked)"; SET_BX(r, 0x0101); SET_AX(r, 0x4f02); INTERRUPT(0x10, r); sx=640; sy=480; tx=40; ty=30; cx1=0; cy1=0; cx2=sx-1;cy2=sy-1; } void InitVESA(int xres, int yres) { int found; found=0; if (xres==640 && yres==480) { Set640x480(); found=1; } if (!found) err("Internal error: unknown VESA resolution"); // setup driver functions ShowPage = VESAShowPage; // reassign for banked VESA video blt ShutdownVideo = VESAShutdown; video=(byte *) 0xA0000 + __djgpp_conventional_base; vscreen=(byte *) valloc(sx*sy, "vscreen", 0); screen=vscreen; memset(screen, 0, sx*sy); } // ============================================================================ int InitVideo(int xres, int yres) { int found; found=0; if (xres==320 && yres==200) { InitMode13h(); found=1; } if (xres==320 && yres==240) { InitModeX(xres,yres); found=1; } if (xres==360 && yres==240) { InitModeX(xres,yres); found=1; } if (xres==256 && yres==256) { InitModeX(xres,yres); found=1; } if (xres==640 && yres==480) { InitVESA(xres,yres); found=1; } if (found) { tsx=xres; tsy=yres; Logp("Sys: Initializing %s.", DriverDesc); InitMouse(tsx, tsy); } else { InitMode13h(); tsx=320; tsy=200; Logp("Unknown video mode %dx%d; defaulting to mode 13h.", xres, yres); InitMouse(tsx, tsy); } LogDone(); return found; }