| 1 |
/* |
| 2 |
* Copyright (C) 2002-2010 The DOSBox Team |
| 3 |
* |
| 4 |
* This program is free software; you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU General Public License as published by |
| 6 |
* the Free Software Foundation; either version 2 of the License, or |
| 7 |
* (at your option) any later version. |
| 8 |
* |
| 9 |
* This program is distributed in the hope that it will be useful, |
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
* GNU General Public License for more details. |
| 13 |
* |
| 14 |
* You should have received a copy of the GNU General Public License |
| 15 |
* along with this program; if not, write to the Free Software |
| 16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 17 |
*/ |
| 18 |
|
| 19 |
/* $Id: int10.cpp,v 1.56 2009-09-06 19:25:34 c2woody Exp $ */ |
| 20 |
|
| 21 |
#include "dosbox.h" |
| 22 |
#include "mem.h" |
| 23 |
#include "callback.h" |
| 24 |
#include "regs.h" |
| 25 |
#include "inout.h" |
| 26 |
#include "int10.h" |
| 27 |
#include "setup.h" |
| 28 |
|
| 29 |
Int10Data int10; |
| 30 |
static Bitu call_10; |
| 31 |
static bool warned_ff=false; |
| 32 |
|
| 33 |
static Bitu INT10_Handler(void) { |
| 34 |
#if 0 |
| 35 |
switch (reg_ah) { |
| 36 |
case 0x02: |
| 37 |
case 0x03: |
| 38 |
case 0x09: |
| 39 |
case 0xc: |
| 40 |
case 0xd: |
| 41 |
case 0x0e: |
| 42 |
case 0x10: |
| 43 |
case 0x4f: |
| 44 |
|
| 45 |
break; |
| 46 |
default: |
| 47 |
LOG(LOG_INT10,LOG_NORMAL)("Function AX:%04X , BX %04X DX %04X",reg_ax,reg_bx,reg_dx); |
| 48 |
break; |
| 49 |
} |
| 50 |
#endif |
| 51 |
|
| 52 |
switch (reg_ah) { |
| 53 |
case 0x00: /* Set VideoMode */ |
| 54 |
INT10_SetVideoMode(reg_al); |
| 55 |
break; |
| 56 |
case 0x01: /* Set TextMode Cursor Shape */ |
| 57 |
INT10_SetCursorShape(reg_ch,reg_cl); |
| 58 |
break; |
| 59 |
case 0x02: /* Set Cursor Pos */ |
| 60 |
INT10_SetCursorPos(reg_dh,reg_dl,reg_bh); |
| 61 |
break; |
| 62 |
case 0x03: /* get Cursor Pos and Cursor Shape*/ |
| 63 |
// reg_ah=0; |
| 64 |
reg_dl=CURSOR_POS_COL(reg_bh); |
| 65 |
reg_dh=CURSOR_POS_ROW(reg_bh); |
| 66 |
reg_cx=real_readw(BIOSMEM_SEG,BIOSMEM_CURSOR_TYPE); |
| 67 |
break; |
| 68 |
case 0x04: /* read light pen pos YEAH RIGHT */ |
| 69 |
/* Light pen is not supported */ |
| 70 |
reg_ax=0; |
| 71 |
break; |
| 72 |
case 0x05: /* Set Active Page */ |
| 73 |
if ((reg_al & 0x80) && IS_TANDY_ARCH) { |
| 74 |
Bit8u crtcpu=real_readb(BIOSMEM_SEG, BIOSMEM_CRTCPU_PAGE); |
| 75 |
switch (reg_al) { |
| 76 |
case 0x80: |
| 77 |
reg_bh=crtcpu & 7; |
| 78 |
reg_bl=(crtcpu >> 3) & 0x7; |
| 79 |
break; |
| 80 |
case 0x81: |
| 81 |
crtcpu=(crtcpu & 0xc7) | ((reg_bl & 7) << 3); |
| 82 |
break; |
| 83 |
case 0x82: |
| 84 |
crtcpu=(crtcpu & 0xf8) | (reg_bh & 7); |
| 85 |
break; |
| 86 |
case 0x83: |
| 87 |
crtcpu=(crtcpu & 0xc0) | (reg_bh & 7) | ((reg_bl & 7) << 3); |
| 88 |
break; |
| 89 |
} |
| 90 |
if (machine==MCH_PCJR) { |
| 91 |
/* always return graphics mapping, even for invalid values of AL */ |
| 92 |
reg_bh=crtcpu & 7; |
| 93 |
reg_bl=(crtcpu >> 3) & 0x7; |
| 94 |
} |
| 95 |
IO_WriteB(0x3df,crtcpu); |
| 96 |
real_writeb(BIOSMEM_SEG, BIOSMEM_CRTCPU_PAGE,crtcpu); |
| 97 |
} |
| 98 |
else INT10_SetActivePage(reg_al); |
| 99 |
break; |
| 100 |
case 0x06: /* Scroll Up */ |
| 101 |
INT10_ScrollWindow(reg_ch,reg_cl,reg_dh,reg_dl,-reg_al,reg_bh,0xFF); |
| 102 |
break; |
| 103 |
case 0x07: /* Scroll Down */ |
| 104 |
INT10_ScrollWindow(reg_ch,reg_cl,reg_dh,reg_dl,reg_al,reg_bh,0xFF); |
| 105 |
break; |
| 106 |
case 0x08: /* Read character & attribute at cursor */ |
| 107 |
INT10_ReadCharAttr(®_ax,reg_bh); |
| 108 |
break; |
| 109 |
case 0x09: /* Write Character & Attribute at cursor CX times */ |
| 110 |
INT10_WriteChar(reg_al,reg_bl,reg_bh,reg_cx,true); |
| 111 |
break; |
| 112 |
case 0x0A: /* Write Character at cursor CX times */ |
| 113 |
INT10_WriteChar(reg_al,reg_bl,reg_bh,reg_cx,false); |
| 114 |
break; |
| 115 |
case 0x0B: /* Set Background/Border Colour & Set Palette*/ |
| 116 |
switch (reg_bh) { |
| 117 |
case 0x00: //Background/Border color |
| 118 |
INT10_SetBackgroundBorder(reg_bl); |
| 119 |
break; |
| 120 |
case 0x01: //Set color Select |
| 121 |
default: |
| 122 |
INT10_SetColorSelect(reg_bl); |
| 123 |
break; |
| 124 |
} |
| 125 |
break; |
| 126 |
case 0x0C: /* Write Graphics Pixel */ |
| 127 |
INT10_PutPixel(reg_cx,reg_dx,reg_bh,reg_al); |
| 128 |
break; |
| 129 |
case 0x0D: /* Read Graphics Pixel */ |
| 130 |
INT10_GetPixel(reg_cx,reg_dx,reg_bh,®_al); |
| 131 |
break; |
| 132 |
case 0x0E: /* Teletype OutPut */ |
| 133 |
INT10_TeletypeOutput(reg_al,reg_bl); |
| 134 |
break; |
| 135 |
case 0x0F: /* Get videomode */ |
| 136 |
reg_bh=real_readb(BIOSMEM_SEG,BIOSMEM_CURRENT_PAGE); |
| 137 |
reg_al=real_readb(BIOSMEM_SEG,BIOSMEM_CURRENT_MODE)|(real_readb(BIOSMEM_SEG,BIOSMEM_VIDEO_CTL)&0x80); |
| 138 |
reg_ah=(Bit8u)real_readw(BIOSMEM_SEG,BIOSMEM_NB_COLS); |
| 139 |
break; |
| 140 |
case 0x10: /* Palette functions */ |
| 141 |
if ((machine==MCH_CGA) || ((!IS_VGA_ARCH) && (reg_al>0x02))) break; |
| 142 |
//TODO: subfunction 0x03 for ega |
| 143 |
switch (reg_al) { |
| 144 |
case 0x00: /* SET SINGLE PALETTE REGISTER */ |
| 145 |
INT10_SetSinglePaletteRegister(reg_bl,reg_bh); |
| 146 |
break; |
| 147 |
case 0x01: /* SET BORDER (OVERSCAN) COLOR*/ |
| 148 |
INT10_SetOverscanBorderColor(reg_bh); |
| 149 |
break; |
| 150 |
case 0x02: /* SET ALL PALETTE REGISTERS */ |
| 151 |
INT10_SetAllPaletteRegisters(SegPhys(es)+reg_dx); |
| 152 |
break; |
| 153 |
case 0x03: /* TOGGLE INTENSITY/BLINKING BIT */ |
| 154 |
INT10_ToggleBlinkingBit(reg_bl); |
| 155 |
break; |
| 156 |
case 0x07: /* GET SINGLE PALETTE REGISTER */ |
| 157 |
INT10_GetSinglePaletteRegister(reg_bl,®_bh); |
| 158 |
break; |
| 159 |
case 0x08: /* READ OVERSCAN (BORDER COLOR) REGISTER */ |
| 160 |
INT10_GetOverscanBorderColor(®_bh); |
| 161 |
break; |
| 162 |
case 0x09: /* READ ALL PALETTE REGISTERS AND OVERSCAN REGISTER */ |
| 163 |
INT10_GetAllPaletteRegisters(SegPhys(es)+reg_dx); |
| 164 |
break; |
| 165 |
case 0x10: /* SET INDIVIDUAL DAC REGISTER */ |
| 166 |
INT10_SetSingleDacRegister(reg_bl,reg_dh,reg_ch,reg_cl); |
| 167 |
break; |
| 168 |
case 0x12: /* SET BLOCK OF DAC REGISTERS */ |
| 169 |
INT10_SetDACBlock(reg_bx,reg_cx,SegPhys(es)+reg_dx); |
| 170 |
break; |
| 171 |
case 0x13: /* SELECT VIDEO DAC COLOR PAGE */ |
| 172 |
INT10_SelectDACPage(reg_bl,reg_bh); |
| 173 |
break; |
| 174 |
case 0x15: /* GET INDIVIDUAL DAC REGISTER */ |
| 175 |
INT10_GetSingleDacRegister(reg_bl,®_dh,®_ch,®_cl); |
| 176 |
break; |
| 177 |
case 0x17: /* GET BLOCK OF DAC REGISTER */ |
| 178 |
INT10_GetDACBlock(reg_bx,reg_cx,SegPhys(es)+reg_dx); |
| 179 |
break; |
| 180 |
case 0x18: /* undocumented - SET PEL MASK */ |
| 181 |
INT10_SetPelMask(reg_bl); |
| 182 |
break; |
| 183 |
case 0x19: /* undocumented - GET PEL MASK */ |
| 184 |
INT10_GetPelMask(reg_bl); |
| 185 |
reg_bh=0; // bx for get mask |
| 186 |
break; |
| 187 |
case 0x1A: /* GET VIDEO DAC COLOR PAGE */ |
| 188 |
INT10_GetDACPage(®_bl,®_bh); |
| 189 |
break; |
| 190 |
case 0x1B: /* PERFORM GRAY-SCALE SUMMING */ |
| 191 |
INT10_PerformGrayScaleSumming(reg_bx,reg_cx); |
| 192 |
break; |
| 193 |
case 0xF0: /* ET4000: SET HiColor GRAPHICS MODE */ |
| 194 |
case 0xF1: /* ET4000: GET DAC TYPE */ |
| 195 |
case 0xF2: /* ET4000: CHECK/SET HiColor MODE */ |
| 196 |
default: |
| 197 |
LOG(LOG_INT10,LOG_ERROR)("Function 10:Unhandled EGA/VGA Palette Function %2X",reg_al); |
| 198 |
break; |
| 199 |
} |
| 200 |
break; |
| 201 |
case 0x11: /* Character generator functions */ |
| 202 |
if (!IS_EGAVGA_ARCH) |
| 203 |
break; |
| 204 |
switch (reg_al) { |
| 205 |
/* Textmode calls */ |
| 206 |
case 0x00: /* Load user font */ |
| 207 |
case 0x10: |
| 208 |
INT10_LoadFont(SegPhys(es)+reg_bp,reg_al==0x10,reg_cx,reg_dx,reg_bl,reg_bh); |
| 209 |
break; |
| 210 |
case 0x01: /* Load 8x14 font */ |
| 211 |
case 0x11: |
| 212 |
INT10_LoadFont(Real2Phys(int10.rom.font_14),reg_al==0x11,256,0,0,14); |
| 213 |
break; |
| 214 |
case 0x02: /* Load 8x8 font */ |
| 215 |
case 0x12: |
| 216 |
INT10_LoadFont(Real2Phys(int10.rom.font_8_first),reg_al==0x12,256,0,0,8); |
| 217 |
break; |
| 218 |
case 0x03: /* Set Block Specifier */ |
| 219 |
IO_Write(0x3c4,0x3);IO_Write(0x3c5,reg_bl); |
| 220 |
break; |
| 221 |
case 0x04: /* Load 8x16 font */ |
| 222 |
case 0x14: |
| 223 |
if (!IS_VGA_ARCH) break; |
| 224 |
INT10_LoadFont(Real2Phys(int10.rom.font_16),reg_al==0x14,256,0,0,16); |
| 225 |
break; |
| 226 |
/* Graphics mode calls */ |
| 227 |
case 0x20: /* Set User 8x8 Graphics characters */ |
| 228 |
RealSetVec(0x1f,RealMake(SegValue(es),reg_bp)); |
| 229 |
break; |
| 230 |
case 0x21: /* Set user graphics characters */ |
| 231 |
RealSetVec(0x43,RealMake(SegValue(es),reg_bp)); |
| 232 |
real_writew(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT,reg_cx); |
| 233 |
goto graphics_chars; |
| 234 |
case 0x22: /* Rom 8x14 set */ |
| 235 |
RealSetVec(0x43,int10.rom.font_14); |
| 236 |
real_writew(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT,14); |
| 237 |
goto graphics_chars; |
| 238 |
case 0x23: /* Rom 8x8 double dot set */ |
| 239 |
RealSetVec(0x43,int10.rom.font_8_first); |
| 240 |
real_writew(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT,8); |
| 241 |
goto graphics_chars; |
| 242 |
case 0x24: /* Rom 8x16 set */ |
| 243 |
if (!IS_VGA_ARCH) break; |
| 244 |
RealSetVec(0x43,int10.rom.font_16); |
| 245 |
real_writew(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT,16); |
| 246 |
goto graphics_chars; |
| 247 |
graphics_chars: |
| 248 |
switch (reg_bl) { |
| 249 |
case 0x00:real_writeb(BIOSMEM_SEG,BIOSMEM_NB_ROWS,reg_dl-1);break; |
| 250 |
case 0x01:real_writeb(BIOSMEM_SEG,BIOSMEM_NB_ROWS,13);break; |
| 251 |
case 0x03:real_writeb(BIOSMEM_SEG,BIOSMEM_NB_ROWS,42);break; |
| 252 |
case 0x02: |
| 253 |
default:real_writeb(BIOSMEM_SEG,BIOSMEM_NB_ROWS,24);break; |
| 254 |
} |
| 255 |
break; |
| 256 |
/* General */ |
| 257 |
case 0x30:/* Get Font Information */ |
| 258 |
switch (reg_bh) { |
| 259 |
case 0x00: /* interupt 0x1f vector */ |
| 260 |
{ |
| 261 |
RealPt int_1f=RealGetVec(0x1f); |
| 262 |
SegSet16(es,RealSeg(int_1f)); |
| 263 |
reg_bp=RealOff(int_1f); |
| 264 |
} |
| 265 |
break; |
| 266 |
case 0x01: /* interupt 0x43 vector */ |
| 267 |
{ |
| 268 |
RealPt int_43=RealGetVec(0x43); |
| 269 |
SegSet16(es,RealSeg(int_43)); |
| 270 |
reg_bp=RealOff(int_43); |
| 271 |
} |
| 272 |
break; |
| 273 |
case 0x02: /* font 8x14 */ |
| 274 |
SegSet16(es,RealSeg(int10.rom.font_14)); |
| 275 |
reg_bp=RealOff(int10.rom.font_14); |
| 276 |
break; |
| 277 |
case 0x03: /* font 8x8 first 128 */ |
| 278 |
SegSet16(es,RealSeg(int10.rom.font_8_first)); |
| 279 |
reg_bp=RealOff(int10.rom.font_8_first); |
| 280 |
break; |
| 281 |
case 0x04: /* font 8x8 second 128 */ |
| 282 |
SegSet16(es,RealSeg(int10.rom.font_8_second)); |
| 283 |
reg_bp=RealOff(int10.rom.font_8_second); |
| 284 |
break; |
| 285 |
case 0x05: /* alpha alternate 9x14 */ |
| 286 |
if (!IS_VGA_ARCH) break; |
| 287 |
SegSet16(es,RealSeg(int10.rom.font_14_alternate)); |
| 288 |
reg_bp=RealOff(int10.rom.font_14_alternate); |
| 289 |
break; |
| 290 |
case 0x06: /* font 8x16 */ |
| 291 |
if (!IS_VGA_ARCH) break; |
| 292 |
SegSet16(es,RealSeg(int10.rom.font_16)); |
| 293 |
reg_bp=RealOff(int10.rom.font_16); |
| 294 |
break; |
| 295 |
case 0x07: /* alpha alternate 9x16 */ |
| 296 |
if (!IS_VGA_ARCH) break; |
| 297 |
SegSet16(es,RealSeg(int10.rom.font_16_alternate)); |
| 298 |
reg_bp=RealOff(int10.rom.font_16_alternate); |
| 299 |
break; |
| 300 |
default: |
| 301 |
LOG(LOG_INT10,LOG_ERROR)("Function 11:30 Request for font %2X",reg_bh); |
| 302 |
break; |
| 303 |
} |
| 304 |
if ((reg_bh<=7) || (svgaCard==SVGA_TsengET4K)) { |
| 305 |
if (machine==MCH_EGA) { |
| 306 |
reg_cx=0x0e; |
| 307 |
reg_dl=0x18; |
| 308 |
} else { |
| 309 |
reg_cx=real_readw(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT); |
| 310 |
reg_dl=real_readb(BIOSMEM_SEG,BIOSMEM_NB_ROWS); |
| 311 |
} |
| 312 |
} |
| 313 |
break; |
| 314 |
default: |
| 315 |
LOG(LOG_INT10,LOG_ERROR)("Function 11:Unsupported character generator call %2X",reg_al); |
| 316 |
break; |
| 317 |
} |
| 318 |
break; |
| 319 |
case 0x12: /* alternate function select */ |
| 320 |
if (!IS_EGAVGA_ARCH) |
| 321 |
break; |
| 322 |
switch (reg_bl) { |
| 323 |
case 0x10: /* Get EGA Information */ |
| 324 |
reg_bh=(real_readw(BIOSMEM_SEG,BIOSMEM_CRTC_ADDRESS)==0x3B4); |
| 325 |
reg_bl=3; //256 kb |
| 326 |
reg_cl=real_readb(BIOSMEM_SEG,BIOSMEM_SWITCHES) & 0x0F; |
| 327 |
reg_ch=real_readb(BIOSMEM_SEG,BIOSMEM_SWITCHES) >> 4; |
| 328 |
break; |
| 329 |
case 0x20: /* Set alternate printscreen */ |
| 330 |
break; |
| 331 |
case 0x30: /* Select vertical resolution */ |
| 332 |
{ |
| 333 |
if (!IS_VGA_ARCH) break; |
| 334 |
LOG(LOG_INT10,LOG_WARN)("Function 12:Call %2X (select vertical resolution)",reg_bl); |
| 335 |
if (svgaCard != SVGA_None) { |
| 336 |
if (reg_al > 2) { |
| 337 |
reg_al=0; // invalid subfunction |
| 338 |
break; |
| 339 |
} |
| 340 |
} |
| 341 |
Bit8u modeset_ctl = real_readb(BIOSMEM_SEG,BIOSMEM_MODESET_CTL); |
| 342 |
Bit8u video_switches = real_readb(BIOSMEM_SEG,BIOSMEM_SWITCHES)&0xf0; |
| 343 |
switch(reg_al) { |
| 344 |
case 0: // 200 |
| 345 |
modeset_ctl &= 0xef; |
| 346 |
modeset_ctl |= 0x80; |
| 347 |
video_switches |= 8; // ega normal/cga emulation |
| 348 |
break; |
| 349 |
case 1: // 350 |
| 350 |
modeset_ctl &= 0x6f; |
| 351 |
video_switches |= 9; // ega enhanced |
| 352 |
break; |
| 353 |
case 2: // 400 |
| 354 |
modeset_ctl &= 0x6f; |
| 355 |
modeset_ctl |= 0x10; // use 400-line mode at next mode set |
| 356 |
video_switches |= 9; // ega enhanced |
| 357 |
break; |
| 358 |
default: |
| 359 |
modeset_ctl &= 0xef; |
| 360 |
video_switches |= 8; // ega normal/cga emulation |
| 361 |
break; |
| 362 |
} |
| 363 |
real_writeb(BIOSMEM_SEG,BIOSMEM_MODESET_CTL,modeset_ctl); |
| 364 |
real_writeb(BIOSMEM_SEG,BIOSMEM_SWITCHES,video_switches); |
| 365 |
reg_al=0x12; // success |
| 366 |
break; |
| 367 |
} |
| 368 |
case 0x31: /* Palette loading on modeset */ |
| 369 |
{ |
| 370 |
if (!IS_VGA_ARCH) break; |
| 371 |
if (svgaCard==SVGA_TsengET4K) reg_al&=1; |
| 372 |
if (reg_al>1) { |
| 373 |
reg_al=0; //invalid subfunction |
| 374 |
break; |
| 375 |
} |
| 376 |
Bit8u temp = real_readb(BIOSMEM_SEG,BIOSMEM_MODESET_CTL) & 0xf7; |
| 377 |
if (reg_al&1) temp|=8; // enable if al=0 |
| 378 |
real_writeb(BIOSMEM_SEG,BIOSMEM_MODESET_CTL,temp); |
| 379 |
reg_al=0x12; |
| 380 |
break; |
| 381 |
} |
| 382 |
case 0x32: /* Video adressing */ |
| 383 |
if (!IS_VGA_ARCH) break; |
| 384 |
LOG(LOG_INT10,LOG_ERROR)("Function 12:Call %2X not handled",reg_bl); |
| 385 |
if (svgaCard==SVGA_TsengET4K) reg_al&=1; |
| 386 |
if (reg_al>1) reg_al=0; //invalid subfunction |
| 387 |
else reg_al=0x12; //fake a success call |
| 388 |
break; |
| 389 |
case 0x33: /* SWITCH GRAY-SCALE SUMMING */ |
| 390 |
{ |
| 391 |
if (!IS_VGA_ARCH) break; |
| 392 |
if (svgaCard==SVGA_TsengET4K) reg_al&=1; |
| 393 |
if (reg_al>1) { |
| 394 |
reg_al=0; |
| 395 |
break; |
| 396 |
} |
| 397 |
Bit8u temp = real_readb(BIOSMEM_SEG,BIOSMEM_MODESET_CTL) & 0xfd; |
| 398 |
if (!(reg_al&1)) temp|=2; // enable if al=0 |
| 399 |
real_writeb(BIOSMEM_SEG,BIOSMEM_MODESET_CTL,temp); |
| 400 |
reg_al=0x12; |
| 401 |
break; |
| 402 |
} |
| 403 |
case 0x34: /* ALTERNATE FUNCTION SELECT (VGA) - CURSOR EMULATION */ |
| 404 |
{ |
| 405 |
// bit 0: 0=enable, 1=disable |
| 406 |
if (!IS_VGA_ARCH) break; |
| 407 |
if (svgaCard==SVGA_TsengET4K) reg_al&=1; |
| 408 |
if (reg_al>1) { |
| 409 |
reg_al=0; |
| 410 |
break; |
| 411 |
} |
| 412 |
Bit8u temp = real_readb(BIOSMEM_SEG,BIOSMEM_VIDEO_CTL) & 0xfe; |
| 413 |
real_writeb(BIOSMEM_SEG,BIOSMEM_VIDEO_CTL,temp|reg_al); |
| 414 |
reg_al=0x12; |
| 415 |
break; |
| 416 |
} |
| 417 |
case 0x35: |
| 418 |
if (!IS_VGA_ARCH) break; |
| 419 |
LOG(LOG_INT10,LOG_ERROR)("Function 12:Call %2X not handled",reg_bl); |
| 420 |
reg_al=0x12; |
| 421 |
break; |
| 422 |
case 0x36: { /* VGA Refresh control */ |
| 423 |
if (!IS_VGA_ARCH) break; |
| 424 |
if ((svgaCard==SVGA_S3Trio) && (reg_al>1)) { |
| 425 |
reg_al=0; |
| 426 |
break; |
| 427 |
} |
| 428 |
IO_Write(0x3c4,0x1); |
| 429 |
Bit8u clocking = IO_Read(0x3c5); |
| 430 |
|
| 431 |
if (reg_al==0) clocking &= ~0x20; |
| 432 |
else clocking |= 0x20; |
| 433 |
|
| 434 |
IO_Write(0x3c4,0x1); |
| 435 |
IO_Write(0x3c5,clocking); |
| 436 |
|
| 437 |
reg_al=0x12; // success |
| 438 |
break; |
| 439 |
} |
| 440 |
default: |
| 441 |
LOG(LOG_INT10,LOG_ERROR)("Function 12:Call %2X not handled",reg_bl); |
| 442 |
if (machine!=MCH_EGA) reg_al=0; |
| 443 |
break; |
| 444 |
} |
| 445 |
break; |
| 446 |
case 0x13: /* Write String */ |
| 447 |
INT10_WriteString(reg_dh,reg_dl,reg_al,reg_bl,SegPhys(es)+reg_bp,reg_cx,reg_bh); |
| 448 |
break; |
| 449 |
case 0x1A: /* Display Combination */ |
| 450 |
if (!IS_VGA_ARCH) break; |
| 451 |
if (reg_al==0) { // get dcc |
| 452 |
// walk the tables... |
| 453 |
RealPt vsavept=real_readd(BIOSMEM_SEG,BIOSMEM_VS_POINTER); |
| 454 |
RealPt svstable=real_readd(RealSeg(vsavept),RealOff(vsavept)+0x10); |
| 455 |
if (svstable) { |
| 456 |
RealPt dcctable=real_readd(RealSeg(svstable),RealOff(svstable)+0x02); |
| 457 |
Bit8u entries=real_readb(RealSeg(dcctable),RealOff(dcctable)+0x00); |
| 458 |
Bit8u idx=real_readb(BIOSMEM_SEG,BIOSMEM_DCC_INDEX); |
| 459 |
// check if index within range |
| 460 |
if (idx<entries) { |
| 461 |
Bit16u dccentry=real_readw(RealSeg(dcctable),RealOff(dcctable)+0x04+idx*2); |
| 462 |
if ((dccentry&0xff)==0) reg_bx=dccentry>>8; |
| 463 |
else reg_bx=dccentry; |
| 464 |
} else reg_bx=0xffff; |
| 465 |
} else reg_bx=0xffff; |
| 466 |
reg_ax=0x1A; // high part destroyed or zeroed depending on BIOS |
| 467 |
} else if (reg_al==1) { // set dcc |
| 468 |
Bit8u newidx=0xff; |
| 469 |
// walk the tables... |
| 470 |
RealPt vsavept=real_readd(BIOSMEM_SEG,BIOSMEM_VS_POINTER); |
| 471 |
RealPt svstable=real_readd(RealSeg(vsavept),RealOff(vsavept)+0x10); |
| 472 |
if (svstable) { |
| 473 |
RealPt dcctable=real_readd(RealSeg(svstable),RealOff(svstable)+0x02); |
| 474 |
Bit8u entries=real_readb(RealSeg(dcctable),RealOff(dcctable)+0x00); |
| 475 |
if (entries) { |
| 476 |
Bitu ct; |
| 477 |
Bit16u swpidx=reg_bh|(reg_bl<<8); |
| 478 |
// search the ddc index in the dcc table |
| 479 |
for (ct=0; ct<entries; ct++) { |
| 480 |
Bit16u dccentry=real_readw(RealSeg(dcctable),RealOff(dcctable)+0x04+ct*2); |
| 481 |
if ((dccentry==reg_bx) || (dccentry==swpidx)) { |
| 482 |
newidx=(Bit8u)ct; |
| 483 |
break; |
| 484 |
} |
| 485 |
} |
| 486 |
} |
| 487 |
} |
| 488 |
|
| 489 |
real_writeb(BIOSMEM_SEG,BIOSMEM_DCC_INDEX,newidx); |
| 490 |
reg_ax=0x1A; // high part destroyed or zeroed depending on BIOS |
| 491 |
} |
| 492 |
break; |
| 493 |
case 0x1B: /* functionality State Information */ |
| 494 |
if (!IS_VGA_ARCH) break; |
| 495 |
switch (reg_bx) { |
| 496 |
case 0x0000: |
| 497 |
INT10_GetFuncStateInformation(SegPhys(es)+reg_di); |
| 498 |
reg_al=0x1B; |
| 499 |
break; |
| 500 |
default: |
| 501 |
LOG(LOG_INT10,LOG_ERROR)("1B:Unhandled call BX %2X",reg_bx); |
| 502 |
reg_al=0; |
| 503 |
break; |
| 504 |
} |
| 505 |
break; |
| 506 |
case 0x1C: /* Video Save Area */ |
| 507 |
if (!IS_VGA_ARCH) break; |
| 508 |
switch (reg_al) { |
| 509 |
case 0: { |
| 510 |
Bitu ret=INT10_VideoState_GetSize(reg_cx); |
| 511 |
if (ret) { |
| 512 |
reg_al=0x1c; |
| 513 |
reg_bx=(Bit16u)ret; |
| 514 |
} else reg_al=0; |
| 515 |
} |
| 516 |
break; |
| 517 |
case 1: |
| 518 |
if (INT10_VideoState_Save(reg_cx,RealMake(SegValue(es),reg_bx))) reg_al=0x1c; |
| 519 |
else reg_al=0; |
| 520 |
break; |
| 521 |
case 2: |
| 522 |
if (INT10_VideoState_Restore(reg_cx,RealMake(SegValue(es),reg_bx))) reg_al=0x1c; |
| 523 |
else reg_al=0; |
| 524 |
break; |
| 525 |
default: |
| 526 |
if (svgaCard==SVGA_TsengET4K) reg_ax=0; |
| 527 |
else reg_al=0; |
| 528 |
break; |
| 529 |
} |
| 530 |
break; |
| 531 |
case 0x4f: /* VESA Calls */ |
| 532 |
if ((!IS_VGA_ARCH) || (svgaCard!=SVGA_S3Trio)) break; |
| 533 |
switch (reg_al) { |
| 534 |
case 0x00: /* Get SVGA Information */ |
| 535 |
reg_al=0x4f; |
| 536 |
reg_ah=VESA_GetSVGAInformation(SegValue(es),reg_di); |
| 537 |
break; |
| 538 |
case 0x01: /* Get SVGA Mode Information */ |
| 539 |
reg_al=0x4f; |
| 540 |
reg_ah=VESA_GetSVGAModeInformation(reg_cx,SegValue(es),reg_di); |
| 541 |
break; |
| 542 |
case 0x02: /* Set videomode */ |
| 543 |
reg_al=0x4f; |
| 544 |
reg_ah=VESA_SetSVGAMode(reg_bx); |
| 545 |
break; |
| 546 |
case 0x03: /* Get videomode */ |
| 547 |
reg_al=0x4f; |
| 548 |
reg_ah=VESA_GetSVGAMode(reg_bx); |
| 549 |
break; |
| 550 |
case 0x04: /* Save/restore state */ |
| 551 |
reg_al=0x4f; |
| 552 |
switch (reg_dl) { |
| 553 |
case 0: { |
| 554 |
Bitu ret=INT10_VideoState_GetSize(reg_cx); |
| 555 |
if (ret) { |
| 556 |
reg_ah=0; |
| 557 |
reg_bx=(Bit16u)ret; |
| 558 |
} else reg_ah=1; |
| 559 |
} |
| 560 |
break; |
| 561 |
case 1: |
| 562 |
if (INT10_VideoState_Save(reg_cx,RealMake(SegValue(es),reg_bx))) reg_ah=0; |
| 563 |
else reg_ah=1; |
| 564 |
break; |
| 565 |
case 2: |
| 566 |
if (INT10_VideoState_Restore(reg_cx,RealMake(SegValue(es),reg_bx))) reg_ah=0; |
| 567 |
else reg_ah=1; |
| 568 |
break; |
| 569 |
default: |
| 570 |
reg_ah=1; |
| 571 |
break; |
| 572 |
} |
| 573 |
break; |
| 574 |
case 0x05: |
| 575 |
if (reg_bh==0) { /* Set CPU Window */ |
| 576 |
reg_ah=VESA_SetCPUWindow(reg_bl,reg_dl); |
| 577 |
reg_al=0x4f; |
| 578 |
} else if (reg_bh == 1) { /* Get CPU Window */ |
| 579 |
reg_ah=VESA_GetCPUWindow(reg_bl,reg_dx); |
| 580 |
reg_al=0x4f; |
| 581 |
} else { |
| 582 |
LOG(LOG_INT10,LOG_ERROR)("Unhandled VESA Function %X Subfunction %X",reg_al,reg_bh); |
| 583 |
reg_ah=0x01; |
| 584 |
} |
| 585 |
break; |
| 586 |
case 0x06: |
| 587 |
reg_al=0x4f; |
| 588 |
reg_ah=VESA_ScanLineLength(reg_bl,reg_cx,reg_bx,reg_cx,reg_dx); |
| 589 |
break; |
| 590 |
case 0x07: |
| 591 |
switch (reg_bl) { |
| 592 |
case 0x80: /* Set Display Start during retrace ?? */ |
| 593 |
case 0x00: /* Set display Start */ |
| 594 |
reg_al=0x4f; |
| 595 |
reg_ah=VESA_SetDisplayStart(reg_cx,reg_dx); |
| 596 |
break; |
| 597 |
case 0x01: |
| 598 |
reg_al=0x4f; |
| 599 |
reg_bh=0x00; //reserved |
| 600 |
reg_ah=VESA_GetDisplayStart(reg_cx,reg_dx); |
| 601 |
break; |
| 602 |
default: |
| 603 |
LOG(LOG_INT10,LOG_ERROR)("Unhandled VESA Function %X Subfunction %X",reg_al,reg_bl); |
| 604 |
reg_ah=0x1; |
| 605 |
break; |
| 606 |
} |
| 607 |
break; |
| 608 |
case 0x09: |
| 609 |
switch (reg_bl) { |
| 610 |
case 0x80: /* Set Palette during retrace */ |
| 611 |
//TODO |
| 612 |
case 0x00: /* Set Palette */ |
| 613 |
reg_ah=VESA_SetPalette(SegPhys(es)+reg_di,reg_dx,reg_cx); |
| 614 |
reg_al=0x4f; |
| 615 |
break; |
| 616 |
case 0x01: /* Get Palette */ |
| 617 |
reg_ah=VESA_GetPalette(SegPhys(es)+reg_di,reg_dx,reg_cx); |
| 618 |
reg_al=0x4f; |
| 619 |
break; |
| 620 |
default: |
| 621 |
LOG(LOG_INT10,LOG_ERROR)("Unhandled VESA Function %X Subfunction %X",reg_al,reg_bl); |
| 622 |
reg_ah=0x01; |
| 623 |
break; |
| 624 |
} |
| 625 |
break; |
| 626 |
case 0x0a: /* Get Pmode Interface */ |
| 627 |
if (int10.vesa_oldvbe) { |
| 628 |
reg_ax=0x014f; |
| 629 |
break; |
| 630 |
} |
| 631 |
switch (reg_bl) { |
| 632 |
case 0x00: |
| 633 |
reg_edi=RealOff(int10.rom.pmode_interface); |
| 634 |
SegSet16(es,RealSeg(int10.rom.pmode_interface)); |
| 635 |
reg_cx=int10.rom.pmode_interface_size; |
| 636 |
reg_ax=0x004f; |
| 637 |
break; |
| 638 |
case 0x01: /* Get code for "set window" */ |
| 639 |
reg_edi=RealOff(int10.rom.pmode_interface)+int10.rom.pmode_interface_window; |
| 640 |
SegSet16(es,RealSeg(int10.rom.pmode_interface)); |
| 641 |
reg_cx=0x10; //0x10 should be enough for the callbacks |
| 642 |
reg_ax=0x004f; |
| 643 |
break; |
| 644 |
case 0x02: /* Get code for "set display start" */ |
| 645 |
reg_edi=RealOff(int10.rom.pmode_interface)+int10.rom.pmode_interface_start; |
| 646 |
SegSet16(es,RealSeg(int10.rom.pmode_interface)); |
| 647 |
reg_cx=0x10; //0x10 should be enough for the callbacks |
| 648 |
reg_ax=0x004f; |
| 649 |
break; |
| 650 |
case 0x03: /* Get code for "set palette" */ |
| 651 |
reg_edi=RealOff(int10.rom.pmode_interface)+int10.rom.pmode_interface_palette; |
| 652 |
SegSet16(es,RealSeg(int10.rom.pmode_interface)); |
| 653 |
reg_cx=0x10; //0x10 should be enough for the callbacks |
| 654 |
reg_ax=0x004f; |
| 655 |
break; |
| 656 |
default: |
| 657 |
reg_ax=0x014f; |
| 658 |
break; |
| 659 |
} |
| 660 |
break; |
| 661 |
|
| 662 |
default: |
| 663 |
LOG(LOG_INT10,LOG_ERROR)("Unhandled VESA Function %X",reg_al); |
| 664 |
reg_al=0x0; |
| 665 |
break; |
| 666 |
} |
| 667 |
break; |
| 668 |
case 0xf0: |
| 669 |
INT10_EGA_RIL_ReadRegister(reg_bl, reg_dx); |
| 670 |
break; |
| 671 |
case 0xf1: |
| 672 |
INT10_EGA_RIL_WriteRegister(reg_bl, reg_bh, reg_dx); |
| 673 |
break; |
| 674 |
case 0xf2: |
| 675 |
INT10_EGA_RIL_ReadRegisterRange(reg_ch, reg_cl, reg_dx, SegPhys(es)+reg_bx); |
| 676 |
break; |
| 677 |
case 0xf3: |
| 678 |
INT10_EGA_RIL_WriteRegisterRange(reg_ch, reg_cl, reg_dx, SegPhys(es)+reg_bx); |
| 679 |
break; |
| 680 |
case 0xf4: |
| 681 |
INT10_EGA_RIL_ReadRegisterSet(reg_cx, SegPhys(es)+reg_bx); |
| 682 |
break; |
| 683 |
case 0xf5: |
| 684 |
INT10_EGA_RIL_WriteRegisterSet(reg_cx, SegPhys(es)+reg_bx); |
| 685 |
break; |
| 686 |
case 0xfa: { |
| 687 |
RealPt pt=INT10_EGA_RIL_GetVersionPt(); |
| 688 |
SegSet16(es,RealSeg(pt)); |
| 689 |
reg_bx=RealOff(pt); |
| 690 |
} |
| 691 |
break; |
| 692 |
case 0xff: |
| 693 |
if (!warned_ff) LOG(LOG_INT10,LOG_NORMAL)("INT10:FF:Weird NC call"); |
| 694 |
warned_ff=true; |
| 695 |
break; |
| 696 |
default: |
| 697 |
LOG(LOG_INT10,LOG_ERROR)("Function %4X not supported",reg_ax); |
| 698 |
// reg_al=0x00; //Successfull, breaks marriage |
| 699 |
break; |
| 700 |
}; |
| 701 |
return CBRET_NONE; |
| 702 |
} |
| 703 |
|
| 704 |
static void INT10_Seg40Init(void) { |
| 705 |
// the default char height |
| 706 |
real_writeb(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT,16); |
| 707 |
// Clear the screen |
| 708 |
real_writeb(BIOSMEM_SEG,BIOSMEM_VIDEO_CTL,0x60); |
| 709 |
// Set the basic screen we have |
| 710 |
real_writeb(BIOSMEM_SEG,BIOSMEM_SWITCHES,0xF9); |
| 711 |
// Set the basic modeset options |
| 712 |
real_writeb(BIOSMEM_SEG,BIOSMEM_MODESET_CTL,0x51); |
| 713 |
// Set the default MSR |
| 714 |
real_writeb(BIOSMEM_SEG,BIOSMEM_CURRENT_MSR,0x09); |
| 715 |
} |
| 716 |
|
| 717 |
|
| 718 |
static void INT10_InitVGA(void) { |
| 719 |
/* switch to color mode and enable CPU access 480 lines */ |
| 720 |
IO_Write(0x3c2,0xc3); |
| 721 |
/* More than 64k */ |
| 722 |
IO_Write(0x3c4,0x04); |
| 723 |
IO_Write(0x3c5,0x02); |
| 724 |
} |
| 725 |
|
| 726 |
static void SetupTandyBios(void) { |
| 727 |
static Bit8u TandyConfig[130]= { |
| 728 |
0x21, 0x42, 0x49, 0x4f, 0x53, 0x20, 0x52, 0x4f, 0x4d, 0x20, 0x76, 0x65, 0x72, |
| 729 |
0x73, 0x69, 0x6f, 0x6e, 0x20, 0x30, 0x32, 0x2e, 0x30, 0x30, 0x2e, 0x30, 0x30, |
| 730 |
0x0d, 0x0a, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x74, 0x69, 0x62, 0x69, 0x6c, 0x69, |
| 731 |
0x74, 0x79, 0x20, 0x53, 0x6f, 0x66, 0x74, 0x77, 0x61, 0x72, 0x65, 0x0d, 0x0a, |
| 732 |
0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68, 0x74, 0x20, 0x28, 0x43, 0x29, |
| 733 |
0x20, 0x31, 0x39, 0x38, 0x34, 0x2c, 0x31, 0x39, 0x38, 0x35, 0x2c, 0x31, 0x39, |
| 734 |
0x38, 0x36, 0x2c, 0x31, 0x39, 0x38, 0x37, 0x0d, 0x0a, 0x50, 0x68, 0x6f, 0x65, |
| 735 |
0x6e, 0x69, 0x78, 0x20, 0x53, 0x6f, 0x66, 0x74, 0x77, 0x61, 0x72, 0x65, 0x20, |
| 736 |
0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x65, 0x73, 0x20, 0x4c, 0x74, |
| 737 |
0x64, 0x2e, 0x0d, 0x0a, 0x61, 0x6e, 0x64, 0x20, 0x54, 0x61, 0x6e, 0x64, 0x79 |
| 738 |
}; |
| 739 |
if (machine==MCH_TANDY) { |
| 740 |
Bitu i; |
| 741 |
for(i=0;i<130;i++) { |
| 742 |
phys_writeb(0xf0000+i+0xc000, TandyConfig[i]); |
| 743 |
} |
| 744 |
} |
| 745 |
} |
| 746 |
|
| 747 |
void INT10_Init(Section* /*sec*/) { |
| 748 |
INT10_InitVGA(); |
| 749 |
if (IS_TANDY_ARCH) SetupTandyBios(); |
| 750 |
/* Setup the INT 10 vector */ |
| 751 |
call_10=CALLBACK_Allocate(); |
| 752 |
CALLBACK_Setup(call_10,&INT10_Handler,CB_IRET,"Int 10 video"); |
| 753 |
RealSetVec(0x10,CALLBACK_RealPointer(call_10)); |
| 754 |
//Init the 0x40 segment and init the datastructures in the the video rom area |
| 755 |
INT10_SetupRomMemory(); |
| 756 |
INT10_Seg40Init(); |
| 757 |
INT10_SetupVESA(); |
| 758 |
INT10_SetupRomMemoryChecksum();//SetupVesa modifies the rom as well. |
| 759 |
INT10_SetVideoMode(0x3); |
| 760 |
} |