From 6188566e38a0257cbd23a5178478495f8711aca8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Strohh=C3=A4cker?= Date: Thu, 20 Sep 2007 16:42:43 +0000 Subject: [PATCH] add partial ega-only machine Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2992 --- include/dosbox.h | 5 ++++ src/dos/dev_con.h | 4 +-- src/dos/dos_keyboard_layout.cpp | 2 +- src/dosbox.cpp | 11 +++++--- src/hardware/dma.cpp | 7 ++--- src/hardware/gus.cpp | 4 +-- src/hardware/sblaster.cpp | 4 +-- src/hardware/vga.cpp | 2 +- src/hardware/vga_attr.cpp | 28 ++++++++++++------- src/hardware/vga_crtc.cpp | 30 +++++++++++++-------- src/hardware/vga_dac.cpp | 18 +++++++++++-- src/hardware/vga_draw.cpp | 48 ++++++++++++++++++++------------- src/hardware/vga_gfx.cpp | 8 +++--- src/hardware/vga_memory.cpp | 2 +- src/hardware/vga_misc.cpp | 8 +++--- src/hardware/vga_seq.cpp | 24 ++++++++++------- src/hardware/vga_xga.cpp | 6 +---- src/ints/bios.cpp | 6 ++--- src/ints/int10.cpp | 34 ++++++++++++++++++----- src/ints/int10_char.cpp | 7 +++-- src/ints/int10_memory.cpp | 16 ++++++----- src/ints/int10_modes.cpp | 36 ++++++++++++++++++------- src/ints/int10_pal.cpp | 9 ++++--- 23 files changed, 208 insertions(+), 111 deletions(-) diff --git a/include/dosbox.h b/include/dosbox.h index d74eb8ee..efe7a50b 100644 --- a/include/dosbox.h +++ b/include/dosbox.h @@ -44,6 +44,7 @@ enum MachineType { MCH_CGA, MCH_TANDY, MCH_PCJR, + MCH_EGA, MCH_VGA }; @@ -57,7 +58,11 @@ extern MachineType machine; extern bool SDLNetInited; #define IS_TANDY_ARCH ((machine==MCH_TANDY) || (machine==MCH_PCJR)) +#define IS_EGAVGA_ARCH ((machine==MCH_EGA) || (machine==MCH_VGA)) +#define IS_VGA_ARCH (machine==MCH_VGA) #define TANDY_ARCH_CASE MCH_TANDY: case MCH_PCJR +#define EGAVGA_ARCH_CASE MCH_EGA: case MCH_VGA +#define VGA_ARCH_CASE MCH_VGA #ifndef DOSBOX_LOGGING_H #include "logging.h" diff --git a/src/dos/dev_con.h b/src/dos/dev_con.h index 358a0448..3b55ac67 100644 --- a/src/dos/dev_con.h +++ b/src/dos/dev_con.h @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: dev_con.h,v 1.32 2007-06-30 19:33:45 c2woody Exp $ */ +/* $Id: dev_con.h,v 1.33 2007-09-20 16:42:43 c2woody Exp $ */ #include "dos_inc.h" #include "../ints/int10.h" @@ -62,7 +62,7 @@ bool device_CON::Read(Bit8u * data,Bit16u * size) { readcache=0; } while (*size>count) { - reg_ah=(machine==MCH_VGA)?0x10:0x0; + reg_ah=(IS_EGAVGA_ARCH)?0x10:0x0; CALLBACK_RunRealInt(0x16); switch(reg_al) { case 13: diff --git a/src/dos/dos_keyboard_layout.cpp b/src/dos/dos_keyboard_layout.cpp index 64ba936c..641a3c39 100644 --- a/src/dos/dos_keyboard_layout.cpp +++ b/src/dos/dos_keyboard_layout.cpp @@ -887,7 +887,7 @@ Bitu keyboard_layout::read_codepage_file(const char* codepage_file_name, Bit32s dos.loaded_codepage=(Bit16u)(codepage_id&0xffff); // update font if necessary - if (font_changed && (CurMode->type==M_TEXT) && (machine==MCH_VGA)) { + if (font_changed && (CurMode->type==M_TEXT) && (IS_EGAVGA_ARCH)) { INT10_LoadFont(Real2Phys(int10.rom.font_16),true,256,0,0,16); } INT10_SetupRomMemoryChecksum(); diff --git a/src/dosbox.cpp b/src/dosbox.cpp index b54554c6..3e831398 100644 --- a/src/dosbox.cpp +++ b/src/dosbox.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: dosbox.cpp,v 1.121 2007-08-16 07:50:31 c2woody Exp $ */ +/* $Id: dosbox.cpp,v 1.122 2007-09-20 16:42:43 c2woody Exp $ */ #include #include @@ -254,7 +254,7 @@ static void DOSBOX_RealInit(Section * sec) { "# They are used to (briefly) document the effect of each option.\n"); MAPPER_AddHandler(DOSBOX_UnlockSpeed, MK_f12, MMOD2,"speedlock","Speedlock"); - svgaCard = SVGA_S3Trio; + svgaCard=SVGA_None; machine=MCH_VGA; std::string cmd_machine; const char * mtype; @@ -264,8 +264,11 @@ static void DOSBOX_RealInit(Section * sec) { else if (strcasecmp(mtype,"tandy")==0) machine=MCH_TANDY; else if (strcasecmp(mtype,"pcjr")==0) machine=MCH_PCJR; else if (strcasecmp(mtype,"hercules")==0) machine=MCH_HERC; - else if (strcasecmp(mtype,"vga")==0) machine=MCH_VGA; - else LOG_MSG("DOSBOX:Unknown machine type %s",mtype); + else if (strcasecmp(mtype,"ega")==0) machine=MCH_EGA; + else if (strcasecmp(mtype,"vga")==0) { + machine=MCH_VGA; + svgaCard=SVGA_S3Trio; + } else LOG_MSG("DOSBOX:Unknown machine type %s",mtype); } diff --git a/src/hardware/dma.cpp b/src/hardware/dma.cpp index 681082e6..68de882d 100644 --- a/src/hardware/dma.cpp +++ b/src/hardware/dma.cpp @@ -325,7 +325,8 @@ public: DMA(Section* configuration):Module_base(configuration){ Bitu i; DmaControllers[0] = new DmaController(0); - if (machine==MCH_VGA) DmaControllers[1] = new DmaController(1); + if (IS_EGAVGA_ARCH) DmaControllers[1] = new DmaController(1); + else DmaControllers[1] = NULL; for (i=0;i<0x10;i++) { Bitu mask=IO_MB; @@ -333,7 +334,7 @@ public: /* install handler for first DMA controller ports */ DmaControllers[0]->DMA_WriteHandler[i].Install(i,DMA_Write_Port,mask); DmaControllers[0]->DMA_ReadHandler[i].Install(i,DMA_Read_Port,mask); - if (machine==MCH_VGA) { + if (IS_EGAVGA_ARCH) { /* install handler for second DMA controller ports */ DmaControllers[1]->DMA_WriteHandler[i].Install(0xc0+i*2,DMA_Write_Port,mask); DmaControllers[1]->DMA_ReadHandler[i].Install(0xc0+i*2,DMA_Read_Port,mask); @@ -343,7 +344,7 @@ public: DmaControllers[0]->DMA_WriteHandler[0x10].Install(0x81,DMA_Write_Port,IO_MB,3); DmaControllers[0]->DMA_ReadHandler[0x10].Install(0x81,DMA_Read_Port,IO_MB,3); - if (machine==MCH_VGA) { + if (IS_EGAVGA_ARCH) { /* install handlers for ports 0x81-0x83 (on the second DMA controller) */ DmaControllers[1]->DMA_WriteHandler[0x10].Install(0x89,DMA_Write_Port,IO_MB,3); DmaControllers[1]->DMA_ReadHandler[0x10].Install(0x89,DMA_Read_Port,IO_MB,3); diff --git a/src/hardware/gus.cpp b/src/hardware/gus.cpp index 33cd96f9..c952d14a 100644 --- a/src/hardware/gus.cpp +++ b/src/hardware/gus.cpp @@ -791,7 +791,7 @@ private: MixerObject MixerChan; public: GUS(Section* configuration):Module_base(configuration){ - if(machine!=MCH_VGA) return; + if(!IS_EGAVGA_ARCH) return; Section_prop * section=static_cast(configuration); if(!section->Get_bool("gus")) return; @@ -864,7 +864,7 @@ public: ~GUS() { - if(machine!=MCH_VGA) return; + if(!IS_EGAVGA_ARCH) return; Section_prop * section=static_cast(m_configuration); if(!section->Get_bool("gus")) return; diff --git a/src/hardware/sblaster.cpp b/src/hardware/sblaster.cpp index cfeeba7c..112433ac 100644 --- a/src/hardware/sblaster.cpp +++ b/src/hardware/sblaster.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: sblaster.cpp,v 1.66 2007-08-08 08:03:48 qbix79 Exp $ */ +/* $Id: sblaster.cpp,v 1.67 2007-09-20 16:42:43 c2woody Exp $ */ #include #include @@ -1314,7 +1314,7 @@ private: else type=SBT_16; if (type==SBT_16) { - if ((machine!=MCH_VGA) || !SecondDMAControllerAvailable()) type=SBT_PRO2; + if ((!IS_EGAVGA_ARCH) || !SecondDMAControllerAvailable()) type=SBT_PRO2; } /* OPL/CMS Init */ diff --git a/src/hardware/vga.cpp b/src/hardware/vga.cpp index f8e4d953..1ef5192b 100644 --- a/src/hardware/vga.cpp +++ b/src/hardware/vga.cpp @@ -56,7 +56,7 @@ void VGA_DetermineMode(void) { } /* Test for graphics or alphanumeric mode */ } else if (vga.attr.mode_control & 1) { - if (vga.gfx.mode & 0x40) VGA_SetMode(M_VGA); + if (IS_VGA_ARCH && (vga.gfx.mode & 0x40)) VGA_SetMode(M_VGA); else if (vga.gfx.mode & 0x20) VGA_SetMode(M_CGA4); else if ((vga.gfx.miscellaneous & 0x0c)==0x0c) VGA_SetMode(M_CGA2); else { diff --git a/src/hardware/vga_attr.cpp b/src/hardware/vga_attr.cpp index 3a0e3f90..5f5ce3bf 100644 --- a/src/hardware/vga_attr.cpp +++ b/src/hardware/vga_attr.cpp @@ -27,6 +27,15 @@ void VGA_ATTR_SetPalette(Bit8u index,Bit8u val) { if (vga.attr.mode_control & 0x80) val = (val&0xf) | (vga.attr.color_select << 4); val &= 63; val |= (vga.attr.color_select & 0xc) << 4; + if (GCC_UNLIKELY(!IS_VGA_ARCH)) { + if ((vga.misc_output&0xc4)==0x40) { + if (val&0x10) val|=0x38; + else { + val&=0x7; + if (val==6) val=0x14; + } + } + } VGA_DAC_CombineColor(index,val); } @@ -61,6 +70,7 @@ void write_p3c0(Bitu port,Bitu val,Bitu iolen) { */ break; case 0x10: /* Mode Control Register */ + if (!IS_VGA_ARCH) val&=0x1f; // not really correct, but should do it if ((attr(mode_control) ^ val) & 0x80) { attr(mode_control)^=0x80; for (Bitu i=0;i<0x10;i++) { @@ -143,6 +153,10 @@ void write_p3c0(Bitu port,Bitu val,Bitu iolen) { */ break; case 0x14: /* Color Select Register */ + if (!IS_VGA_ARCH) { + attr(color_select)=0; + break; + } if (attr(color_select) ^ val) { attr(color_select)=val; for (Bitu i=0;i<0x10;i++) { @@ -190,16 +204,12 @@ Bitu read_p3c1(Bitu port,Bitu iolen) { }; - - - - void VGA_SetupAttr(void) { - if (machine==MCH_VGA) { - IO_RegisterReadHandler(0x3c0,read_p3c0,IO_MB); + if (IS_EGAVGA_ARCH) { IO_RegisterWriteHandler(0x3c0,write_p3c0,IO_MB); - IO_RegisterReadHandler(0x3c1,read_p3c1,IO_MB); + if (IS_VGA_ARCH) { + IO_RegisterReadHandler(0x3c0,read_p3c0,IO_MB); + IO_RegisterReadHandler(0x3c1,read_p3c1,IO_MB); + } } } - - diff --git a/src/hardware/vga_crtc.cpp b/src/hardware/vga_crtc.cpp index 0f8fcf52..58f81b80 100644 --- a/src/hardware/vga_crtc.cpp +++ b/src/hardware/vga_crtc.cpp @@ -124,7 +124,8 @@ void vga_write_p3d5(Bitu port,Bitu val,Bitu iolen) { case 0x08: /* Preset Row Scan Register */ crtc(preset_row_scan)=val; vga.config.hlines_skip=val&31; - vga.config.bytes_skip=(val>>5)&3; + if (IS_VGA_ARCH) vga.config.bytes_skip=(val>>5)&3; + else vga.config.bytes_skip=0; // LOG_DEBUG("Skip lines %d bytes %d",vga.config.hlines_skip,vga.config.bytes_skip); /* 0-4 Number of lines we have scrolled down in the first character row. @@ -135,7 +136,8 @@ void vga_write_p3d5(Bitu port,Bitu val,Bitu iolen) { */ break; case 0x09: /* Maximum Scan Line Register */ - vga.config.line_compare=(vga.config.line_compare & 0x5ff)|(val&0x40)<<3; + if (IS_VGA_ARCH) + vga.config.line_compare=(vga.config.line_compare & 0x5ff)|(val&0x40)<<3; if ((vga.crtc.maximum_scan_line ^ val) & 0xbf) { crtc(maximum_scan_line)=val; VGA_StartResize(); @@ -154,7 +156,8 @@ void vga_write_p3d5(Bitu port,Bitu val,Bitu iolen) { case 0x0A: /* Cursor Start Register */ crtc(cursor_start)=val; vga.draw.cursor.sline=val&0x1f; - vga.draw.cursor.enabled=!(val&0x20); + if (IS_VGA_ARCH) vga.draw.cursor.enabled=!(val&0x20); + else vga.draw.cursor.enabled=true; /* 0-4 First scanline of cursor within character. 5 Turns Cursor off if set @@ -203,7 +206,8 @@ void vga_write_p3d5(Bitu port,Bitu val,Bitu iolen) { break; case 0x11: /* Vertical Retrace End Register */ crtc(vertical_retrace_end)=val; - crtc(read_only)=(val & 128)>0; + if (IS_VGA_ARCH) crtc(read_only)=(val & 128)>0; + else crtc(read_only)=false; /* 0-3 Vertical Retrace ends when the last 4 bits of the line counter equals this value. @@ -242,13 +246,17 @@ void vga_write_p3d5(Bitu port,Bitu val,Bitu iolen) { break; case 0x14: /* Underline Location Register */ crtc(underline_location)=val; - //Byte,word,dword mode - if ( crtc(underline_location) & 0x20 ) - vga.config.addr_shift = 2; - else if ( crtc( mode_control) & 0x40 ) - vga.config.addr_shift = 0; - else + if (IS_VGA_ARCH) { + //Byte,word,dword mode + if ( crtc(underline_location) & 0x20 ) + vga.config.addr_shift = 2; + else if ( crtc( mode_control) & 0x40 ) + vga.config.addr_shift = 0; + else + vga.config.addr_shift = 1; + } else { vga.config.addr_shift = 1; + } /* 0-4 Position of underline within Character cell. 5 If set memory address is only changed every fourth character clock. @@ -291,8 +299,8 @@ void vga_write_p3d5(Bitu port,Bitu val,Bitu iolen) { vga.tandy.addr_mask = ~0; vga.tandy.line_shift = 0; } - VGA_DetermineMode(); //Should we really need to do a determinemode here? +// VGA_DetermineMode(); /* 0 If clear use CGA compatible memory addressing system by substituting character row scan counter bit 0 for address bit 13, diff --git a/src/hardware/vga_dac.cpp b/src/hardware/vga_dac.cpp index 955a6cb6..d568eec0 100644 --- a/src/hardware/vga_dac.cpp +++ b/src/hardware/vga_dac.cpp @@ -202,15 +202,29 @@ void VGA_SetupDAC(void) { vga.dac.state=DAC_READ; vga.dac.read_index=0; vga.dac.write_index=0; - if (machine==MCH_VGA) { + if (IS_VGA_ARCH) { /* Setup the DAC IO port Handlers */ IO_RegisterWriteHandler(0x3c6,write_p3c6,IO_MB); IO_RegisterReadHandler(0x3c6,read_p3c6,IO_MB); IO_RegisterWriteHandler(0x3c7,write_p3c7,IO_MB); IO_RegisterReadHandler(0x3c7,read_p3c7,IO_MB); - IO_RegisterReadHandler(0x3c8,read_p3c8,IO_MB); IO_RegisterWriteHandler(0x3c8,write_p3c8,IO_MB); + IO_RegisterReadHandler(0x3c8,read_p3c8,IO_MB); IO_RegisterWriteHandler(0x3c9,write_p3c9,IO_MB); IO_RegisterReadHandler(0x3c9,read_p3c9,IO_MB); + } else if (machine==MCH_EGA) { + for (Bitu i=0;i<64;i++) { + if ((i&4)>0) vga.dac.rgb[i].red=0x2a; + else vga.dac.rgb[i].red=0; + if ((i&32)>0) vga.dac.rgb[i].red+=0x15; + + if ((i&2)>0) vga.dac.rgb[i].green=0x2a; + else vga.dac.rgb[i].green=0; + if ((i&16)>0) vga.dac.rgb[i].green+=0x15; + + if ((i&1)>0) vga.dac.rgb[i].blue=0x2a; + else vga.dac.rgb[i].blue=0; + if ((i&8)>0) vga.dac.rgb[i].blue+=0x15; + } } }; diff --git a/src/hardware/vga_draw.cpp b/src/hardware/vga_draw.cpp index 9ef5836b..c8161f78 100644 --- a/src/hardware/vga_draw.cpp +++ b/src/hardware/vga_draw.cpp @@ -531,6 +531,8 @@ static void VGA_VerticalTimer(Bitu val) { vga.draw.address = vga.config.real_start; vga.draw.address_line = vga.config.hlines_skip; vga.draw.split_line = (vga.config.line_compare/vga.draw.lines_scaled); + // go figure... +// if (machine==MCH_EGA) vga.draw.split_line = ((((vga.config.line_compare&0x5ff)+1)*2-1)/vga.draw.lines_scaled); switch (vga.mode) { case M_EGA: case M_LIN4: @@ -653,12 +655,13 @@ void VGA_SetupDrawing(Bitu val) { float fps; Bitu clock; Bitu htotal, hdend, hbstart, hbend, hrstart, hrend; Bitu vtotal, vdend, vbstart, vbend, vrstart, vrend; - if (machine==MCH_VGA) { - htotal = 5 + vga.crtc.horizontal_total; + if (IS_EGAVGA_ARCH) { + htotal = 2 + vga.crtc.horizontal_total; + if (IS_VGA_ARCH) htotal += 3; hdend = 1 + vga.crtc.horizontal_display_end; hbstart = vga.crtc.start_horizontal_blanking; - hbend = vga.crtc.end_horizontal_blanking&0x1F | - ((vga.crtc.end_horizontal_retrace&0x80)>>2); + hbend = vga.crtc.end_horizontal_blanking&0x1F; + if (IS_VGA_ARCH) hbend |= (vga.crtc.end_horizontal_retrace&0x80)>>2; hbend = hbstart + ((hbend - hbstart) & 0x3F); hrstart = vga.crtc.start_horizontal_retrace; hrend = vga.crtc.end_horizontal_retrace & 0x1f; @@ -668,15 +671,17 @@ void VGA_SetupDrawing(Bitu val) { else hrend = hrstart + hrend; - vtotal=2 + vga.crtc.vertical_total | - ((vga.crtc.overflow & 1) << 8) | ((vga.crtc.overflow & 0x20) << 4); - vdend = 1 + (vga.crtc.vertical_display_end | - ((vga.crtc.overflow & 2)<<7) | - ((vga.crtc.overflow & 0x40) << 3) | - ((vga.s3.ex_ver_overflow & 0x2) << 9)); - vrstart = vga.crtc.vertical_retrace_start + - ((vga.crtc.overflow & 0x04) << 6) | - ((vga.crtc.overflow & 0x80) << 2); + vtotal= 2 + vga.crtc.vertical_total | ((vga.crtc.overflow & 1) << 8); + vdend = 1 + vga.crtc.vertical_display_end | ((vga.crtc.overflow & 2)<<7); + vrstart = vga.crtc.vertical_retrace_start + ((vga.crtc.overflow & 0x04) << 6); + if (IS_VGA_ARCH) { + // additional bits only present on vga cards + vtotal |= (vga.crtc.overflow & 0x20) << 4; + vdend |= ((vga.crtc.overflow & 0x40) << 3) | + ((vga.s3.ex_ver_overflow & 0x2) << 9); + vrstart |= ((vga.crtc.overflow & 0x80) << 2); + } + vrend = vga.crtc.vertical_retrace_end & 0xF; vrend = ( vrend - vrstart)&0xF; if ( !vrend) @@ -684,10 +689,13 @@ void VGA_SetupDrawing(Bitu val) { else vrend = vrstart + vrend; - vbstart = vga.crtc.start_vertical_blanking | - ((vga.crtc.overflow & 0x08) << 5) | - ((vga.crtc.maximum_scan_line & 0x20) << 4); - vbend = vga.crtc.end_vertical_blanking & 0x3f; + vbstart = vga.crtc.start_vertical_blanking | ((vga.crtc.overflow & 0x08) << 5); + if (IS_VGA_ARCH) { + vbstart |= ((vga.crtc.maximum_scan_line & 0x20) << 4); + vbend = vga.crtc.end_vertical_blanking & 0x3f; + } else { + vbend = vga.crtc.end_vertical_blanking & 0xf; + } vbend = (vbend - vbstart) & 0x3f; if ( !vbend) vbend = vbstart + 0x3f + 1; @@ -720,7 +728,9 @@ void VGA_SetupDrawing(Bitu val) { vga.draw.address_line_total=(vga.crtc.maximum_scan_line&0xf)+1; /* Check for dual transfer whatever thing,master clock/2 */ if (vga.s3.pll.cmd & 0x10) clock/=2; - vga.draw.double_scan=(vga.crtc.maximum_scan_line&0x80)>0; + + if (IS_VGA_ARCH) vga.draw.double_scan=(vga.crtc.maximum_scan_line&0x80)>0; + else vga.draw.double_scan=false; // might actually be a special implementation of double scanning for ega } else { htotal = vga.other.htotal + 1; hdend = vga.other.hdend; @@ -988,7 +998,7 @@ void VGA_SetupDrawing(Bitu val) { height/=2; doubleheight=true; } - //Only check for exra double heigh in vga modes + //Only check for extra double height in vga modes if (!doubleheight && (vga.mode> 4); + Bit8u font1=(val & 0x3) << 1; + if (IS_VGA_ARCH) font1|=(val & 0x10) >> 4; vga.draw.font_tables[0]=&vga.draw.font[font1*8*1024]; - Bit8u font2=((val & 0xc) >> 1) | ((val & 0x20) >> 5); + Bit8u font2=((val & 0xc) >> 1); + if (IS_VGA_ARCH) font2|=(val & 0x20) >> 5; vga.draw.font_tables[1]=&vga.draw.font[font2*8*1024]; } /* @@ -94,10 +96,12 @@ void write_p3c5(Bitu port,Bitu val,Bitu iolen) { rather than the Map Mask and Read Map Select Registers. */ seq(memory_mode)=val; - /* Changing this means changing the VGA Memory Read/Write Handler */ - if (val&0x08) vga.config.chained=true; - else vga.config.chained=false; - VGA_SetupHandlers(); + if (IS_VGA_ARCH) { + /* Changing this means changing the VGA Memory Read/Write Handler */ + if (val&0x08) vga.config.chained=true; + else vga.config.chained=false; + VGA_SetupHandlers(); + } break; default: switch (svgaCard) { @@ -139,11 +143,13 @@ Bitu read_p3c5(Bitu port,Bitu iolen) { void VGA_SetupSEQ(void) { - if (machine==MCH_VGA) { + if (IS_EGAVGA_ARCH) { IO_RegisterWriteHandler(0x3c4,write_p3c4,IO_MB); IO_RegisterWriteHandler(0x3c5,write_p3c5,IO_MB); - IO_RegisterReadHandler(0x3c4,read_p3c4,IO_MB); - IO_RegisterReadHandler(0x3c5,read_p3c5,IO_MB); + if (IS_VGA_ARCH) { + IO_RegisterReadHandler(0x3c4,read_p3c4,IO_MB); + IO_RegisterReadHandler(0x3c5,read_p3c5,IO_MB); + } } } diff --git a/src/hardware/vga_xga.cpp b/src/hardware/vga_xga.cpp index 83b4a634..e8557970 100644 --- a/src/hardware/vga_xga.cpp +++ b/src/hardware/vga_xga.cpp @@ -1073,7 +1073,7 @@ Bitu XGA_Read(Bitu port, Bitu len) { } void VGA_SetupXGA(void) { - if (machine!=MCH_VGA) return; + if (!IS_VGA_ARCH) return; memset(&xga, 0, sizeof(XGAStatus)); @@ -1165,8 +1165,4 @@ void VGA_SetupXGA(void) { IO_RegisterWriteHandler(0xe2ea,&XGA_Write,IO_MB | IO_MW | IO_MD); IO_RegisterReadHandler(0xe2ea,&XGA_Read,IO_MB | IO_MW | IO_MD); - - - } - diff --git a/src/ints/bios.cpp b/src/ints/bios.cpp index 7aa3bf92..d1c9467e 100644 --- a/src/ints/bios.cpp +++ b/src/ints/bios.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: bios.cpp,v 1.68 2007-06-12 20:22:08 c2woody Exp $ */ +/* $Id: bios.cpp,v 1.69 2007-09-20 16:42:43 c2woody Exp $ */ #include "dosbox.h" #include "mem.h" @@ -705,7 +705,7 @@ static Bitu INT15_Handler(void) { LOG(LOG_BIOS,LOG_ERROR)("INT15:Unknown call %4X",reg_ax); reg_ah=0x86; CALLBACK_SCF(true); - if ((machine==MCH_VGA) || (machine==MCH_CGA)) { + if ((IS_EGAVGA_ARCH) || (machine==MCH_CGA)) { /* relict from comparisons, as int15 exits with a retf2 instead of an iret */ CALLBACK_SZF(false); } @@ -917,7 +917,7 @@ public: //Startup monochrome config|=0x30; break; - case MCH_VGA: + case EGAVGA_ARCH_CASE: case MCH_CGA: case TANDY_ARCH_CASE: //Startup 80x25 color diff --git a/src/ints/int10.cpp b/src/ints/int10.cpp index ea495db0..90b13178 100644 --- a/src/ints/int10.cpp +++ b/src/ints/int10.cpp @@ -140,7 +140,9 @@ static Bitu INT10_Handler(void) { reg_al=real_readb(BIOSMEM_SEG,BIOSMEM_CURRENT_MODE)|(real_readb(BIOSMEM_SEG,BIOSMEM_VIDEO_CTL)&0x80); reg_ah=(Bit8u)real_readw(BIOSMEM_SEG,BIOSMEM_NB_COLS); break; - case 0x10: /* EGA/VGA Palette functions */ + case 0x10: /* Palette functions */ + if ((machine==MCH_CGA) || ((!IS_VGA_ARCH) && (reg_al>0x02))) break; + //TODO: subfunction 0x03 for ega switch (reg_al) { case 0x00: /* SET SINGLE PALETTE REGISTER */ INT10_SetSinglePaletteRegister(reg_bl,reg_bh); @@ -195,7 +197,7 @@ static Bitu INT10_Handler(void) { } break; case 0x11: /* Character generator functions */ - if (machine7) return; mem_address=page*real_readw(BIOSMEM_SEG,BIOSMEM_PAGE_SIZE); /* Write the new page start */ real_writew(BIOSMEM_SEG,BIOSMEM_CURRENT_START,mem_address); - if (machine==MCH_VGA && CurMode->mode<0x8) mem_address>>=1; + if (IS_EGAVGA_ARCH && CurMode->mode<0x8) mem_address>>=1; /* Write the new start address in vgahardware */ Bit16u base=real_readw(BIOSMEM_SEG,BIOSMEM_CRTC_ADDRESS); IO_Write(base,0x0c); @@ -522,7 +521,7 @@ void WriteChar(Bit16u col,Bit16u row,Bit8u page,Bit8u chr,Bit8u attr,bool useatt void INT10_WriteChar(Bit8u chr,Bit8u attr,Bit8u page,Bit16u count,bool showattr) { if (CurMode->type!=M_TEXT) { switch (machine) { - case MCH_VGA: + case EGAVGA_ARCH_CASE: page%=CurMode->ptotal; break; case MCH_CGA: diff --git a/src/ints/int10_memory.cpp b/src/ints/int10_memory.cpp index 2fd73d0e..4779f9af 100644 --- a/src/ints/int10_memory.cpp +++ b/src/ints/int10_memory.cpp @@ -78,14 +78,16 @@ void INT10_SetupRomMemory(void) { PhysPt rom_base=PhysMake(0xc000,0); Bitu i; int10.rom.used=3; - if (machine==MCH_VGA) { + if (IS_EGAVGA_ARCH) { // set up the start of the ROM phys_writew(rom_base+0,0xaa55); phys_writeb(rom_base+2,0x40); // Size of ROM: 64 512-blocks = 32KB - phys_writeb(rom_base+0x1e,0x49); // IBM string - phys_writeb(rom_base+0x1f,0x42); - phys_writeb(rom_base+0x20,0x4d); - phys_writeb(rom_base+0x21,0x00); + if (IS_VGA_ARCH) { + phys_writeb(rom_base+0x1e,0x49); // IBM string + phys_writeb(rom_base+0x1f,0x42); + phys_writeb(rom_base+0x20,0x4d); + phys_writeb(rom_base+0x21,0x00); + } int10.rom.used=0x100; } int10.rom.font_8_first=RealMake(0xC000,int10.rom.used); @@ -116,7 +118,7 @@ void INT10_SetupRomMemory(void) { if (IS_TANDY_ARCH) { RealSetVec(0x44,int10.rom.font_8_first); } - if (machine == MCH_VGA) { //EGA/VGA. Just to be safe + if (IS_EGAVGA_ARCH) { //EGA/VGA. Just to be safe //Reserve checksum location checksumlocation = int10.rom.used++; } @@ -145,7 +147,7 @@ void INT10_ReloadRomFonts(void) { } void INT10_SetupRomMemoryChecksum(void) { - if (machine == MCH_VGA) { //EGA/VGA. Just to be safe + if (IS_EGAVGA_ARCH) { //EGA/VGA. Just to be safe /* Sum of all bytes in rom module 256 should be 0 */ Bit8u sum = 0; PhysPt rom_base = PhysMake(0xc000,0); diff --git a/src/ints/int10_modes.cpp b/src/ints/int10_modes.cpp index c58e0697..0f405232 100644 --- a/src/ints/int10_modes.cpp +++ b/src/ints/int10_modes.cpp @@ -272,7 +272,7 @@ static void FinishSetMode(bool clearmem) { real_writeb(BIOSMEM_SEG,BIOSMEM_MODESET_CTL,real_readb(BIOSMEM_SEG,BIOSMEM_MODESET_CTL)&0x7f); // FIXME We nearly have the good tables. to be reworked - if (machine==MCH_VGA) real_writeb(BIOSMEM_SEG,BIOSMEM_DCC_INDEX,0x08); // 8 is VGA should be ok for now + if (IS_VGA_ARCH) real_writeb(BIOSMEM_SEG,BIOSMEM_DCC_INDEX,0x08); // 8 is VGA should be ok for now real_writew(BIOSMEM_SEG,BIOSMEM_VS_POINTER,0x00); real_writew(BIOSMEM_SEG,BIOSMEM_VS_POINTER+2,0x00); @@ -468,7 +468,11 @@ bool INT10_SetVideoMode(Bitu mode) { mode-=0x80; } LOG(LOG_INT10,LOG_NORMAL)("Set Video Mode %X",mode); - if (machine!=MCH_VGA) return INT10_SetVideoMode_OTHER(mode,clearmem); + if (!IS_EGAVGA_ARCH) return INT10_SetVideoMode_OTHER(mode,clearmem); + if ((machine==MCH_EGA) && (mode>0x10)) { + LOG(LOG_INT10,LOG_ERROR)("EGA:Trying to set illegal mode %X",mode); + return false; + } Bit8u modeset_ctl,video_ctl,vga_switches; if (!SetCurMode(ModeList_VGA,mode)){ @@ -643,7 +647,10 @@ bool INT10_SetVideoMode(Bitu mode) { ver_overflow|=(line_compare & 0x400) >> 4; Bit8u underline=0; /* Maximum scanline / Underline Location */ - if (CurMode->special & _EGA_LINE_DOUBLE) max_scanline|=0x80; + if (CurMode->special & _EGA_LINE_DOUBLE) { + if (machine==MCH_EGA) max_scanline=1; + else max_scanline|=0x80; + } switch (CurMode->type) { case M_TEXT: max_scanline|=CurMode->cheight-1; @@ -661,7 +668,8 @@ bool INT10_SetVideoMode(Bitu mode) { break; case M_CGA2: case M_CGA4: - max_scanline|=1; + if (machine==MCH_EGA) max_scanline|=2; + else max_scanline|=1; break; } if (CurMode->vdispend==350) underline=0x0f; @@ -819,13 +827,23 @@ bool INT10_SetVideoMode(Bitu mode) { for (i=1;i<16;i++) att_data[i]=0x3f; break; case 0x10: - case 0x12: goto att_text16; + case 0x12: + if (IS_VGA_ARCH) + goto att_text16; + // ega fallthrough default: if ( CurMode->type == M_LIN4 ) goto att_text16; - for (i=0;i<8;i++) { - att_data[i]=i; - att_data[i+8]=i+0x10; + if (!IS_VGA_ARCH) { + for (i=0;i<8;i++) { + att_data[i]=i; + att_data[i+8]=i+0x38; + } + } else { + for (i=0;i<8;i++) { + att_data[i]=i; + att_data[i+8]=i+0x10; + } } break; } @@ -929,7 +947,7 @@ dac_text16: } break; } - if (machine==MCH_VGA) { + if (IS_VGA_ARCH) { /* check if gray scale summing is enabled */ if (real_readb(BIOSMEM_SEG,BIOSMEM_MODESET_CTL) & 2) { INT10_PerformGrayScaleSumming(0,256); diff --git a/src/ints/int10_pal.cpp b/src/ints/int10_pal.cpp index 810343cb..c017e79d 100644 --- a/src/ints/int10_pal.cpp +++ b/src/ints/int10_pal.cpp @@ -39,7 +39,8 @@ void INT10_SetSinglePaletteRegister(Bit8u reg,Bit8u val) { IO_Read(VGAREG_TDY_RESET); WriteTandyACTL(reg+0x10,val); break; - case MCH_VGA: + case EGAVGA_ARCH_CASE: + if (!IS_VGA_ARCH) reg&=0x1f; if(reg<=ACTL_MAX_REG) { ResetACTL(); IO_Write(VGAREG_ACTL_ADDRESS,reg); @@ -70,7 +71,7 @@ void INT10_SetAllPaletteRegisters(PhysPt data) { // Then the border WriteTandyACTL(0x02,mem_readb(data)); break; - case MCH_VGA: + case EGAVGA_ARCH_CASE: ResetACTL(); // First the colors for(Bit8u i=0;i<0x10;i++) { @@ -215,7 +216,7 @@ void INT10_SetBackgroundBorder(Bit8u val) { real_writeb(BIOSMEM_SEG,BIOSMEM_CURRENT_PAL,temp); if (machine == MCH_CGA || IS_TANDY_ARCH) IO_Write(0x3d9,temp); - else if (machine == MCH_VGA) { + else if (IS_EGAVGA_ARCH) { val = ((val << 1) & 0x10) | (val & 0x7); /* Aways set the overscan color */ INT10_SetSinglePaletteRegister( 0x11, val ); @@ -238,7 +239,7 @@ void INT10_SetColorSelect(Bit8u val) { real_writeb(BIOSMEM_SEG,BIOSMEM_CURRENT_PAL,temp); if (machine == MCH_CGA || IS_TANDY_ARCH) IO_Write(0x3d9,temp); - else if (machine == MCH_VGA) { + else if (IS_EGAVGA_ARCH) { if (CurMode->mode <= 3) //Maybe even skip the total function! return; val = (temp & 0x10) | 2 | val;