/********************************************************************** * EMS_Ioctl_Handler * * Handler for interrupt 21h IOCTL routine for device "EMMXXXX0". */ void WINAPI EMS_Ioctl_Handler( CONTEXT86 *context ) { assert(AH_reg(context) == 0x44); switch AL_reg(context) { case 0x00: /* IOCTL - GET DEVICE INFORMATION */ RESET_CFLAG(context); /* operation was successful */ SET_DX( context, 0x4080 ); /* bit 14 (support ioctl read) and * bit 7 (is_device) */ break; case 0x02: /* EMS - GET MEMORY MANAGER INFORMATION */ /* * This is what is called "Windows Global EMM Import Specification". * Undocumented of course! Supports three requests: * GET API ENTRY POINT * GET EMM IMPORT STRUCTURE ADDRESS * GET MEMORY MANAGER VERSION */ INT_BARF(context,0x21); break; case 0x07: /* IOCTL - GET OUTPUT STATUS */ RESET_CFLAG(context); /* operation was successful */ SET_AL( context, 0xff ); /* device is ready */ break; default: INT_BARF(context,0x21); break; } }
/********************************************************************** * INT_Int3dHandler (WPROCS.161) * * Handler for int 3d (FLOATING POINT EMULATION - STANDALONE FWAIT). */ void WINAPI INT_Int3dHandler(CONTEXT86 *context) { switch(AH_reg(context)) { case 0x00: break; case 0x02: case 0x03: case 0x04: case 0x05: case 0xb: AH_reg(context) = 0; break; default: INT_BARF( context, 0x3d ); } }
/********************************************************************** * DOSVM_Int2aHandler * * Handler for int 2ah (network). */ static void WINAPI DOSVM_Int2aHandler( CONTEXT86 *context ) { switch(AH_reg(context)) { case 0x00: /* NETWORK INSTALLATION CHECK */ break; default: INT_BARF( context, 0x2a ); } }
/*********************************************************************** * DOSVM_Int4bHandler * */ static void WINAPI DOSVM_Int4bHandler( CONTEXT86 *context ) { switch(AH_reg(context)) { case 0x81: /* Virtual DMA Spec (IBM SCSI interface) */ if(AL_reg(context) != 0x02) /* if not install check */ { SET_CFLAG(context); SET_AL( context, 0x0f ); /* function is not implemented */ } break; default: INT_BARF(context, 0x4b); } }
/********************************************************************** * DOSVM_Int17Handler * * Handler for int 17h (printer - output character). */ static void WINAPI DOSVM_Int17Handler( CONTEXT86 *context ) { switch( AH_reg(context) ) { case 0x00:/* Send character*/ FIXME("Send character not supported yet\n"); SET_AH( context, 0x00 );/*Timeout*/ break; case 0x01: /* PRINTER - INITIALIZE */ FIXME("Initialize Printer - Not Supported\n"); SET_AH( context, 0x30 ); /* selected | out of paper */ break; case 0x02: /* PRINTER - GET STATUS */ FIXME("Get Printer Status - Not Supported\n"); break; default: SET_AH( context, 0 ); /* time out */ INT_BARF( context, 0x17 ); } }
/********************************************************************** * DOSVM_Int10Handler * * Handler for int 10h (video). * * NOTE: * Most INT 10 functions for text-mode, CGA, EGA, and VGA cards * are present in this list. (SVGA and XGA are not) That is not * to say that all these functions should be supported, but if * anyone is brain-damaged enough to want to emulate one of these * beasts then this should get you started. * * NOTE: * Several common graphical extensions used by Microsoft hook * off of here. I have *not* added them to this list (yet). They * include: * * MSHERC.COM - More functionality for Hercules cards. * EGA.SYS (also MOUSE.COM) - More for EGA cards. * * Yes, MS also added this support into their mouse driver. Don't * ask me, I don't work for them. * * Joseph Pranevich - 9/98 * * Jess Haas 2/99 * Added support for Vesa. It is not complete but is a start. * NOTE: Im not sure if I did all this right or if any of it works. * Currently I don't have a program that uses Vesa that actually gets far * enough without crashing to do vesa stuff. * * Added additional vga graphic support - 3/99 */ void WINAPI DOSVM_Int10Handler( CONTEXT *context ) { BIOSDATA *data = DOSVM_BiosData(); INT10_InitializeVideoMode( data ); switch(AH_reg(context)) { case 0x00: /* SET VIDEO MODE */ TRACE( "Set VGA video mode %02x\n", AL_reg(context) ); if (!INT10_SetVideoMode( data, AL_reg(context) )) FIXME( "Unsupported VGA video mode requested: %#x\n", AL_reg(context) ); break; case 0x01: /* SET CURSOR SHAPE */ TRACE("Set Cursor Shape start %d end %d options %d\n", CH_reg(context) & 0x1f, CL_reg(context) & 0x1f, CH_reg(context) & 0xe0); data->VideoCursorType = CX_reg(context); /* direct copy */ VGA_SetCursorShape(CH_reg(context), CL_reg(context)); break; case 0x02: /* SET CURSOR POSITION */ /* BH = Page Number */ /* Not supported */ /* DH = Row */ /* 0 is left */ /* DL = Column */ /* 0 is top */ INT10_SetCursorPos(data,BH_reg(context),DL_reg(context),DH_reg(context)); if (BH_reg(context)) { FIXME("Set Cursor Position: Cannot set to page %d\n", BH_reg(context)); } else { VGA_SetCursorPos(DL_reg(context), DH_reg(context)); TRACE("Set Cursor Position: %d/%d\n", DL_reg(context), DH_reg(context)); } break; case 0x03: /* GET CURSOR POSITION AND SIZE */ { unsigned row, col; TRACE("Get cursor position and size (page %d)\n", BH_reg(context)); SET_CX( context, data->VideoCursorType ); INT10_GetCursorPos(data,BH_reg(context),&col,&row); SET_DH( context, row ); SET_DL( context, col ); TRACE("Cursor Position: %d/%d\n", DL_reg(context), DH_reg(context)); } break; case 0x04: /* READ LIGHT PEN POSITION */ FIXME("Read Light Pen Position - Not Supported\n"); SET_AH( context, 0x00 ); /* Not down */ break; case 0x05: /* SELECT ACTIVE DISPLAY PAGE */ FIXME("Select Active Display Page (%d) - Not Supported\n", AL_reg(context)); data->VideoCurPage = AL_reg(context); break; case 0x06: /* SCROLL UP WINDOW */ /* AL = Lines to scroll */ /* BH = Attribute */ /* CH,CL = row, col upper-left */ /* DH,DL = row, col lower-right */ TRACE("Scroll Up Window %d\n", AL_reg(context)); if (AL_reg(context) == 0) VGA_ClearText( CH_reg(context), CL_reg(context), DH_reg(context), DL_reg(context), BH_reg(context) ); else VGA_ScrollUpText( CH_reg(context), CL_reg(context), DH_reg(context), DL_reg(context), AL_reg(context), BH_reg(context) ); break; case 0x07: /* SCROLL DOWN WINDOW */ /* AL = Lines to scroll */ /* BH = Attribute */ /* CH,CL = row, col upper-left */ /* DH,DL = row, col lower-right */ TRACE("Scroll Down Window %d\n", AL_reg(context)); if (AL_reg(context) == 0) VGA_ClearText( CH_reg(context), CL_reg(context), DH_reg(context), DL_reg(context), BH_reg(context) ); else VGA_ScrollDownText( CH_reg(context), CL_reg(context), DH_reg(context), DL_reg(context), AL_reg(context), BH_reg(context) ); break; case 0x08: /* READ CHARACTER AND ATTRIBUTE AT CURSOR POSITION */ { if (BH_reg(context)) /* Write to different page */ { FIXME("Read character and attribute at cursor position -" " Can't read from non-0 page\n"); SET_AL( context, ' ' ); /* That page is blank */ SET_AH( context, 7 ); } else { BYTE ascii, attr; TRACE("Read Character and Attribute at Cursor Position\n"); VGA_GetCharacterAtCursor(&ascii, &attr); SET_AL( context, ascii ); SET_AH( context, attr ); } } break; case 0x09: /* WRITE CHARACTER AND ATTRIBUTE AT CURSOR POSITION */ case 0x0a: /* WRITE CHARACTER ONLY AT CURSOR POSITION */ /* AL = Character to display. */ /* BH = Page Number */ /* We can't write to non-0 pages, yet. */ /* BL = Attribute / Color */ /* CX = Times to Write Char */ /* Note here that the cursor is not advanced. */ { unsigned row, col; INT10_GetCursorPos(data,BH_reg(context),&col,&row); VGA_WriteChars(col, row, AL_reg(context), (AH_reg(context) == 0x09) ? BL_reg(context) : -1, CX_reg(context)); if (CX_reg(context) > 1) TRACE("Write Character%s at Cursor Position (Rep. %d): %c\n", (AH_reg(context) == 0x09) ? " and Attribute" : "", CX_reg(context), AL_reg(context)); else TRACE("Write Character%s at Cursor Position: %c\n", (AH_reg(context) == 0x09) ? " and Attribute" : "", AL_reg(context)); } break; case 0x0b: switch BH_reg(context) { case 0x00: /* SET BACKGROUND/BORDER COLOR */ /* In text modes, this sets only the border... */ /* According to the interrupt list and one of my books. */ /* Funny though that Beyond Zork seems to indicate that it also sets up the default background attributes for clears and scrolls... */ /* Bear in mind here that we do not want to change, apparently, the foreground or attribute of the background with this call, so we should check first to see what the foreground already is... FIXME */ /* For CGA modes, background color change is the same as writing to I/O address 0x3d9 bit 4 */ if(data->VideoMode >= 4 && data->VideoMode <= 6) { VGA_SetBright((BL_reg(context) & 0x10) != 0); VGA_UpdatePalette(); } else FIXME("Set Background/Border Color: %d/%d\n", BH_reg(context), BL_reg(context)); break; case 0x01: /* SET PALETTE */ /* For CGA modes, palette color change is the same as writing to I/O address 0x3d9 bit 5 */ if(data->VideoMode >= 4 && data->VideoMode <= 6) { VGA_SetPaletteIndex(BL_reg(context) & 1); VGA_UpdatePalette(); } else FIXME("Set Palette - Not Supported: %02X\n", BL_reg(context)); break; default: FIXME("INT 10 AH = 0x0b BH = 0x%x - Unknown\n", BH_reg(context)); break; } break; case 0x0c: /* WRITE GRAPHICS PIXEL */ /* Only supported in CGA mode for now */ if(data->VideoMode >= 4 && data->VideoMode <= 6) { VGA_WritePixel(AL_reg(context), BH_reg(context), CX_reg(context), DX_reg(context)); } else FIXME("Write pixel not implemented for current mode\n"); break; case 0x0d: /* READ GRAPHICS PIXEL */ /* Not in graphics mode, can ignore w/o error */ FIXME("Read Graphics Pixel - Not Supported\n"); break; case 0x0e: /* TELETYPE OUTPUT */ TRACE("Teletype Output\n"); DOSVM_PutChar(AL_reg(context)); break; case 0x0f: /* GET CURRENT VIDEO MODE */ TRACE("Get current video mode: -> mode %d, columns %d\n", data->VideoMode, data->VideoColumns); /* Note: This should not be a constant value. */ SET_AL( context, data->VideoMode ); SET_AH( context, data->VideoColumns ); SET_BH( context, 0 ); /* Display page 0 */ break; case 0x10: switch AL_reg(context) { case 0x00: /* SET SINGLE PALETTE REGISTER - A.C. */ TRACE("Set Single Palette Register - Reg 0x0%x Value 0x0%x\n", BL_reg(context),BH_reg(context)); /* BH is the value BL is the register */ VGA_SetColor16((int)BL_reg(context),(int)BH_reg(context)); break; case 0x01: /* SET BORDER (OVERSCAN) */ /* Text terminals have no overscan */ /* I'm setting it anyway. - A.C. */ TRACE("Set Border (Overscan) - Ignored but set.\n"); VGA_SetColor16(16,(int)BH_reg(context)); break; case 0x02: /* SET ALL PALETTE REGISTERS - A.C.*/ TRACE("Set all palette registers\n"); /* ES:DX points to a 17 byte table of colors */ /* No return data listed */ /* I'll have to update my table and the default palette */ VGA_Set16Palette(CTX_SEG_OFF_TO_LIN(context, context->SegEs, context->Edx)); break; case 0x03: /* TOGGLE INTENSITY/BLINKING BIT */ FIXME("Toggle Intensity/Blinking Bit - Not Supported\n"); break; case 0x07: /* GET INDIVIDUAL PALETTE REGISTER - A.C.*/ TRACE("Get Individual Palette Register 0x0%x\n",BL_reg(context)); /* BL is register to read [ 0-15 ] BH is return value */ SET_BH( context, VGA_GetColor16((int)BL_reg(context)) ); break; case 0x08: /* READ OVERSCAN (BORDER COLOR) REGISTER - A.C. */ TRACE("Read Overscan (Border Color) Register\n"); SET_BH( context, VGA_GetColor16(16) ); break; case 0x09: /* READ ALL PALETTE REGISTERS AND OVERSCAN REGISTER - A.C.*/ TRACE("Read All Palette Registers and Overscan Register\n"); /* ES:DX points to a 17 byte table where the results */ /* of this call should be stored. */ VGA_Get16Palette(CTX_SEG_OFF_TO_LIN(context, context->SegEs, context->Edx)); break; case 0x10: /* SET INDIVIDUAL DAC REGISTER */ { PALETTEENTRY paldat; TRACE("Set Individual DAC register\n"); paldat.peRed = DH_reg(context); paldat.peGreen = CH_reg(context); paldat.peBlue = CL_reg(context); paldat.peFlags = 0; VGA_SetPalette(&paldat,BX_reg(context)&0xFF,1); } break; case 0x12: /* SET BLOCK OF DAC REGISTERS */ { int i; PALETTEENTRY paldat; BYTE *pt; TRACE("Set Block of DAC registers\n"); pt = CTX_SEG_OFF_TO_LIN(context,context->SegEs,context->Edx); for (i=0;i<CX_reg(context);i++) { paldat.peRed = (*(pt+i*3+0)) << 2; paldat.peGreen = (*(pt+i*3+1)) << 2; paldat.peBlue = (*(pt+i*3+2)) << 2; paldat.peFlags = 0; VGA_SetPalette(&paldat,(BX_reg(context)+i)&0xFF,1); } } break; case 0x13: /* SELECT VIDEO DAC COLOR PAGE */ FIXME("Select video DAC color page - Not Supported\n"); break; case 0x15: /* READ INDIVIDUAL DAC REGISTER */ FIXME("Read individual DAC register - Not Supported\n"); break; case 0x17: /* READ BLOCK OF DAC REGISTERS */ FIXME("Read block of DAC registers - Not Supported\n"); break; case 0x18: /* SET PEL MASK */ FIXME("Set PEL mask - Not Supported\n"); break; case 0x19: /* READ PEL MASK */ FIXME("Read PEL mask - Not Supported\n"); break; case 0x1a: /* GET VIDEO DAC COLOR PAGE STATE */ FIXME("Get video DAC color page state - Not Supported\n"); break; case 0x1b: /* PERFORM GRAY-SCALE SUMMING */ FIXME("Perform Gray-scale summing - Not Supported\n"); break; default: FIXME("INT 10 AH = 0x10 AL = 0x%x - Unknown\n", AL_reg(context)); break; } break; case 0x11: /* TEXT MODE CHARGEN */ /* Note that second subfunction is *almost* identical. */ /* See INTERRUPT.A for details. */ switch AL_reg(context) { case 0x00: /* LOAD USER SPECIFIED PATTERNS */ case 0x10: FIXME("Load User Specified Patterns - Not Supported\n"); break; case 0x01: /* LOAD ROM MONOCHROME PATTERNS */ case 0x11: FIXME("Load ROM Monochrome Patterns - Not Supported\n"); break; case 0x02: /* LOAD ROM 8x8 DOUBLE-DOT PATTERNS */ case 0x12: FIXME( "Load ROM 8x8 Double Dot Patterns - Not Supported\n"); break; case 0x03: /* SET BLOCK SPECIFIER */ FIXME("Set Block Specifier - Not Supported\n"); break; case 0x04: /* LOAD ROM 8x16 CHARACTER SET */ case 0x14: FIXME("Load ROM 8x16 Character Set - Not Supported\n"); break; case 0x20: /* SET USER 8x16 GRAPHICS CHARS */ FIXME("Set User 8x16 Graphics Chars - Not Supported\n"); break; case 0x21: /* SET USER GRAPICS CHARACTERS */ FIXME("Set User Graphics Characters - Not Supported\n"); break; case 0x22: /* SET ROM 8x14 GRAPHICS CHARS */ FIXME("Set ROM 8x14 Graphics Chars - Not Supported\n"); break; case 0x23: /* SET ROM 8x8 DBL DOT CHARS */ FIXME( "Set ROM 8x8 Dbl Dot Chars (Graphics) - Not Supported\n"); break; case 0x24: /* LOAD 8x16 GRAPHIC CHARS */ FIXME("Load 8x16 Graphic Chars - Not Supported\n"); break; case 0x30: /* GET FONT INFORMATION */ FIXME("Get Font Information - Not Supported\n"); break; default: FIXME("INT 10 AH = 0x11 AL = 0x%x - Unknown\n", AL_reg(context)); break; } break; case 0x12: /* ALTERNATE FUNCTION SELECT */ switch BL_reg(context) { case 0x10: /* GET EGA INFO */ TRACE("EGA info requested\n"); SET_BH( context, 0x00 ); /* Color screen */ SET_BL( context, data->ModeOptions >> 5 ); /* EGA memory size */ SET_CX( context, data->FeatureBitsSwitches ); break; case 0x20: /* ALTERNATE PRTSC */ FIXME("Install Alternate Print Screen - Not Supported\n"); break; case 0x30: /* SELECT VERTICAL RESOLUTION */ FIXME("Select vertical resolution - not supported\n"); break; case 0x31: /* ENABLE/DISABLE DEFAULT PALETTE LOADING */ FIXME("Default palette loading - not supported\n"); data->VGASettings = (data->VGASettings & 0xf7) | ((AL_reg(context) == 1) << 3); break; case 0x32: /* ENABLE/DISABLE VIDEO ADDRESSING */ FIXME("Video Addressing - Not Supported\n"); break; case 0x33: /* ENABLE/DISABLE GRAY SCALE SUMMING */ FIXME("Gray Scale Summing - Not Supported\n"); break; case 0x34: /* ENABLE/DISABLE CURSOR EMULATION */ TRACE("Set cursor emulation to %d\n", AL_reg(context)); data->ModeOptions = (data->ModeOptions & 0xfe)|(AL_reg(context) == 1); break; case 0x36: /* VIDEO ADDRESS CONTROL */ FIXME("Video Address Control - Not Supported\n"); break; default: FIXME("INT 10 AH = 0x11 AL = 0x%x - Unknown\n", AL_reg(context)); break; } break; case 0x13: /* WRITE STRING */ /* This one does not imply that string be at cursor. */ FIXME("Write String - Not Supported\n"); break; case 0x1a: switch AL_reg(context) { case 0x00: /* GET DISPLAY COMBINATION CODE */ TRACE("Get Display Combination Code\n"); SET_AL( context, 0x1a ); /* Function supported */ SET_BL( context, INT10_DCC ); /* Active display */ SET_BH( context, 0x00 ); /* No alternate display */ break; case 0x01: /* SET DISPLAY COMBINATION CODE */ FIXME("Set Display Combination Code - Not Supported\n"); break; default: FIXME("INT 10 AH = 0x1a AL = 0x%x - Unknown\n", AL_reg(context)); break; } break; case 0x1b: /* FUNCTIONALITY/STATE INFORMATION */ TRACE("Get functionality/state information\n"); if (BX_reg(context) == 0x0000) { BYTE *ptr = CTX_SEG_OFF_TO_LIN(context, context->SegEs, context->Edi); SET_AL( context, 0x1b ); /* Function is supported */ INT10_FillStateInformation( ptr, data ); } break; case 0x1c: /* SAVE/RESTORE VIDEO STATE */ FIXME("Save/Restore Video State - Not Supported\n"); break; case 0xef: /* get video mode for hercules-compatibles */ /* There's no reason to really support this */ /* is there?....................(A.C.) */ TRACE("Just report the video not hercules compatible\n"); SET_DX( context, 0xffff ); break; case 0x4f: /* VESA */ INT10_HandleVESA(context); break; case 0xfe: /* GET SHADOW BUFFER */ TRACE( "GET SHADOW BUFFER %x:%x - ignored\n", context->SegEs, DI_reg(context) ); break; default: FIXME("Unknown - 0x%x\n", AH_reg(context)); INT_BARF( context, 0x10 ); } }
/********************************************************************** * INT10_HandleVESA * * Handler for VESA functions (int10 function 0x4f). */ static void INT10_HandleVESA( CONTEXT *context ) { BIOSDATA *data = DOSVM_BiosData(); switch(AL_reg(context)) { case 0x00: /* RETURN CONTROLLER INFORMATION */ TRACE( "VESA RETURN CONTROLLER INFORMATION\n" ); { BYTE *ptr = CTX_SEG_OFF_TO_LIN(context, context->SegEs, context->Edi); INT10_FillControllerInformation( ptr ); SET_AL( context, 0x4f ); SET_AH( context, 0x00 ); /* 0x00 = successful 0x01 = failed */ } break; case 0x01: /* RETURN MODE INFORMATION */ TRACE( "VESA RETURN MODE INFORMATION %04x\n", CX_reg(context) ); { struct _ModeInfoBlock *ptr = CTX_SEG_OFF_TO_LIN(context, context->SegEs, context->Edi); SET_AL( context, 0x4f ); if (INT10_FillModeInformation( ptr, CX_reg(context) )) SET_AH( context, 0x00 ); /* status: success */ else SET_AH( context, 0x01 ); /* status: failed */ } break; case 0x02: /* SET SuperVGA VIDEO MODE */ TRACE( "Set VESA video mode %04x\n", BX_reg(context) ); SET_AL( context, 0x4f ); /* function supported */ if (INT10_SetVideoMode( data, BX_reg(context) )) SET_AH( context, 0x00 ); /* success */ else SET_AH( context, 0x01 ); /* failed */ break; case 0x03: /* VESA SuperVGA BIOS - GET CURRENT VIDEO MODE */ SET_AL( context, 0x4f ); SET_AH( context, 0x00 ); SET_BX( context, INT10_GetHeap()->VesaCurrentMode ); break; case 0x04: /* VESA SuperVGA BIOS - SAVE/RESTORE SuperVGA VIDEO STATE */ ERR("VESA SAVE/RESTORE Video State - Not Implemented\n"); /* AL_reg(context) = 0x4f; = supported so not set since not implemented */ /* maybe we should do this instead ? */ /* AH_reg(context = 0x01; not implemented so just fail */ break; case 0x05: /* VESA SuperVGA BIOS - CPU VIDEO MEMORY CONTROL */ /* * This subfunction supports only Window A (BL_reg == 0) and * it assumes that window granularity is 64k. */ switch(BH_reg(context)) { case 0x00: /* select video memory window */ SET_AL( context, 0x4f ); /* function supported */ if(BL_reg(context) == 0) { VGA_SetWindowStart(DX_reg(context) * 64 * 1024); SET_AH( context, 0x00 ); /* status: successful */ } else SET_AH( context, 0x01 ); /* status: failed */ break; case 0x01: /* get video memory window */ SET_AL( context, 0x4f ); /* function supported */ if(BL_reg(context) == 0) { SET_DX( context, VGA_GetWindowStart() / 64 / 1024 ); SET_AH( context, 0x00 ); /* status: successful */ } else SET_AH( context, 0x01 ); /* status: failed */ break; default: INT_BARF( context, 0x10 ); } break; case 0x06: /* VESA GET/SET LOGICAL SCAN LINE LENGTH */ ERR("VESA GET/SET LOGICAL SCAN LINE LENGTH - Not Implemented\n"); /* AL_reg(context) = 0x4f; = supported so not set since not implemented */ /* maybe we should do this instead ? */ /* AH_reg(context = 0x001; not implemented so just fail */ break; case 0x07: /* GET/SET DISPLAY START */ ERR("VESA GET/SET DISPLAY START - Not Implemented\n"); /* AL_reg(context) = 0x4f; = supported so not set since not implemented */ /* maybe we should do this instead ? */ /* AH_reg(context = 0x001; not implemented so just fail */ break; case 0x08: /* GET/SET DAC PALETTE CONTROL */ ERR("VESA GET/SET DAC PALETTE CONTROL- Not Implemented\n"); /* AL_reg(context) = 0x4f; = supported so not set since not implemented */ /* maybe we should do this instead ? */ /* AH_reg(context = 0x001; not implemented so just fail */ break; case 0x09: /* SET PALETTE ENTRIES */ FIXME("VESA Set palette entries - not implemented\n"); break; case 0x0a: /* GET PROTECTED-MODE CODE */ FIXME("VESA Get protected-mode code - not implemented\n"); break; case 0x10: /* Display Power Management Extensions */ FIXME("VESA Display Power Management Extensions - not implemented\n"); break; case 0xef: /* get video mode for hercules-compatibles */ /* There's no reason to really support this */ /* is there?....................(A.C.) */ TRACE("Just report the video not hercules compatible\n"); SET_DX( context, 0xffff ); break; case 0xff: /* Turn VESA ON/OFF */ /* I don't know what to do */ break; default: FIXME("VESA Function (0x%x) - Not Supported\n", AH_reg(context)); break; } }
void WINAPI XMS_Handler( CONTEXT86 *context ) { switch(AH_reg(context)) { case 0x00: /* Get XMS version number */ TRACE("get XMS version number\n"); SET_AX( context, 0x0200 ); /* 2.0 */ SET_BX( context, 0x0000 ); /* internal revision */ SET_DX( context, 0x0001 ); /* HMA exists */ break; case 0x08: /* Query Free Extended Memory */ { MEMORYSTATUS status; TRACE("query free extended memory\n"); GlobalMemoryStatus( &status ); SET_DX( context, status.dwAvailVirtual >> 10 ); SET_AX( context, status.dwAvailVirtual >> 10 ); TRACE("returning largest %dK, total %dK\n", AX_reg(context), DX_reg(context)); } break; case 0x09: /* Allocate Extended Memory Block */ TRACE("allocate extended memory block (%dK)\n", DX_reg(context)); SET_DX( context, GlobalAlloc16(GMEM_MOVEABLE, (DWORD)DX_reg(context)<<10) ); SET_AX( context, DX_reg(context) ? 1 : 0 ); if (!DX_reg(context)) SET_BL( context, 0xA0 ); /* out of memory */ break; case 0x0a: /* Free Extended Memory Block */ TRACE("free extended memory block %04x\n",DX_reg(context)); if(!DX_reg(context) || GlobalFree16(DX_reg(context))) { SET_AX( context, 0 ); /* failure */ SET_BL( context, 0xa2 ); /* invalid handle */ } else SET_AX( context, 1 ); /* success */ break; case 0x0b: /* Move Extended Memory Block */ { MOVESTRUCT*move=CTX_SEG_OFF_TO_LIN(context, context->SegDs,context->Esi); BYTE*src,*dst; TRACE("move extended memory block\n"); src=XMS_Offset(&move->Source); dst=XMS_Offset(&move->Dest); memcpy(dst,src,move->Length); if (move->Source.Handle) GlobalUnlock16(move->Source.Handle); if (move->Dest.Handle) GlobalUnlock16(move->Dest.Handle); break; } case 0x88: /* Query Any Free Extended Memory */ { MEMORYSTATUS status; SYSTEM_INFO info; TRACE("query any free extended memory\n"); GlobalMemoryStatus( &status ); GetSystemInfo( &info ); context->Eax = status.dwAvailVirtual >> 10; context->Edx = status.dwAvailVirtual >> 10; context->Ecx = (DWORD)info.lpMaximumApplicationAddress; SET_BL( context, 0 ); /* No errors. */ TRACE("returning largest %dK, total %dK, highest 0x%x\n", context->Eax, context->Edx, context->Ecx); } break; default: INT_BARF( context, 0x31 ); SET_AX( context, 0x0000 ); /* failure */ SET_BL( context, 0x80 ); /* function not implemented */ break; } }
/********************************************************************** * DOSVM_Int1aHandler * * Handler for int 1ah. */ static void WINAPI DOSVM_Int1aHandler( CONTEXT86 *context ) { switch(AH_reg(context)) { case 0x00: /* GET SYSTEM TIME */ { BIOSDATA *data = DOSVM_BiosData(); SET_CX( context, HIWORD(data->Ticks) ); SET_DX( context, LOWORD(data->Ticks) ); SET_AL( context, 0 ); /* FIXME: midnight flag is unsupported */ TRACE( "GET SYSTEM TIME - ticks=%d\n", data->Ticks ); } break; case 0x01: /* SET SYSTEM TIME */ FIXME( "SET SYSTEM TIME - not allowed\n" ); break; case 0x02: /* GET REAL-TIME CLOCK TIME */ TRACE( "GET REAL-TIME CLOCK TIME\n" ); { SYSTEMTIME systime; GetLocalTime( &systime ); SET_CH( context, BIN_TO_BCD(systime.wHour) ); SET_CL( context, BIN_TO_BCD(systime.wMinute) ); SET_DH( context, BIN_TO_BCD(systime.wSecond) ); SET_DL( context, 0 ); /* FIXME: assume no daylight saving */ RESET_CFLAG(context); } break; case 0x03: /* SET REAL-TIME CLOCK TIME */ FIXME( "SET REAL-TIME CLOCK TIME - not allowed\n" ); break; case 0x04: /* GET REAL-TIME CLOCK DATE */ TRACE( "GET REAL-TIME CLOCK DATE\n" ); { SYSTEMTIME systime; GetLocalTime( &systime ); SET_CH( context, BIN_TO_BCD(systime.wYear / 100) ); SET_CL( context, BIN_TO_BCD(systime.wYear % 100) ); SET_DH( context, BIN_TO_BCD(systime.wMonth) ); SET_DL( context, BIN_TO_BCD(systime.wDay) ); RESET_CFLAG(context); } break; case 0x05: /* SET REAL-TIME CLOCK DATE */ FIXME( "SET REAL-TIME CLOCK DATE - not allowed\n" ); break; case 0x06: /* SET ALARM */ FIXME( "SET ALARM - unimplemented\n" ); break; case 0x07: /* CANCEL ALARM */ FIXME( "CANCEL ALARM - unimplemented\n" ); break; case 0x08: /* SET RTC ACTIVATED POWER ON MODE */ case 0x09: /* READ RTC ALARM TIME AND STATUS */ case 0x0a: /* READ SYSTEM-TIMER DAY COUNTER */ case 0x0b: /* SET SYSTEM-TIMER DAY COUNTER */ case 0x0c: /* SET RTC DATE/TIME ACTIVATED POWER-ON MODE */ case 0x0d: /* RESET RTC DATE/TIME ACTIVATED POWER-ON MODE */ case 0x0e: /* GET RTC DATE/TIME ALARM AND STATUS */ case 0x0f: /* INITIALIZE REAL-TIME CLOCK */ INT_BARF( context, 0x1a ); break; case 0xb0: if (CX_reg(context) == 0x4d52 && DX_reg(context) == 0x4349 && AL_reg(context) == 0x01) { /* * Microsoft Real-Time Compression Interface (MRCI). * Ignoring this call indicates MRCI is not supported. */ TRACE( "Microsoft Real-Time Compression Interface - not supported\n" ); } else { INT_BARF(context, 0x1a); } break; default: INT_BARF( context, 0x1a ); } }
void WINAPI DOSVM_Int16Handler( CONTEXT86 *context ) { BIOSDATA *data = NULL; BYTE ascii, scan; switch AH_reg(context) { case 0x00: /* Get Keystroke */ /* Returns: AH = Scan code AL = ASCII character */ TRACE("Get Keystroke\n"); DOSVM_Int16ReadChar(&ascii, &scan, context); SET_AL( context, ascii ); SET_AH( context, scan ); break; case 0x01: /* Check for Keystroke */ /* Returns: ZF set if no keystroke */ /* AH = Scan code */ /* AL = ASCII character */ TRACE("Check for Keystroke\n"); if (!DOSVM_Int16ReadChar(&ascii, &scan, NULL)) { SET_ZFLAG(context); } else { SET_AL( context, ascii ); SET_AH( context, scan ); RESET_ZFLAG(context); } /* don't miss the opportunity to break some tight timing loop in DOS * programs causing 100% CPU usage (by doing a Sleep here) */ Sleep(5); break; case 0x02: /* Get Shift Flags */ /* read value from BIOS data segment's keyboard status flags field */ data = DOSVM_BiosData(); SET_AL( context, data->KbdFlags1 ); TRACE("Get Shift Flags: returning 0x%02x\n", AL_reg(context)); break; case 0x03: /* Set Typematic Rate and Delay */ FIXME("Set Typematic Rate and Delay - Not Supported\n"); break; case 0x05:/*simulate Keystroke*/ FIXME("Simulating a keystroke is not supported yet\n"); break; case 0x09: /* Get Keyboard Functionality */ FIXME("Get Keyboard Functionality - Not Supported\n"); /* As a temporary measure, say that "nothing" is supported... */ SET_AL( context, 0 ); break; case 0x0a: /* Get Keyboard ID */ FIXME("Get Keyboard ID - Not Supported\n"); break; case 0x10: /* Get Enhanced Keystroke */ TRACE("Get Enhanced Keystroke - Partially supported\n"); /* Returns: AH = Scan code AL = ASCII character */ DOSVM_Int16ReadChar(&ascii, &scan, context); SET_AL( context, ascii ); SET_AH( context, scan ); break; case 0x11: /* Check for Enhanced Keystroke */ /* Returns: ZF set if no keystroke */ /* AH = Scan code */ /* AL = ASCII character */ TRACE("Check for Enhanced Keystroke - Partially supported\n"); if (!DOSVM_Int16ReadChar(&ascii, &scan, NULL)) { SET_ZFLAG(context); } else { SET_AL( context, ascii ); SET_AH( context, scan ); RESET_ZFLAG(context); } break; case 0x12: /* Get Extended Shift States */ FIXME("Get Extended Shift States - Not Supported\n"); break; default: FIXME("Unknown INT 16 function - 0x%x\n", AH_reg(context)); break; } }
/********************************************************************** * DOSVM_Int13Handler * * Handler for int 13h (disk I/O). */ void WINAPI DOSVM_Int13Handler( CONTEXT *context ) { TRACE( "AH=%02x\n", AH_reg( context ) ); switch( AH_reg( context ) ) { case 0x00: /* RESET DISK SYSTEM */ INT13_SetStatus( context, 0x00 ); /* success */ break; case 0x01: /* STATUS OF DISK SYSTEM */ INT13_SetStatus( context, INT13_last_status ); break; case 0x02: /* READ SECTORS INTO MEMORY */ SET_AL( context, 0 ); /* number of sectors transferred */ INT13_SetStatus( context, 0x00 ); /* success */ break; case 0x03: /* WRITE SECTORS FROM MEMORY */ SET_AL( context, 0 ); /* number of sectors transferred */ INT13_SetStatus( context, 0x00 ); /* success */ break; case 0x04: /* VERIFY DISK SECTOR(S) */ SET_AL( context, 0 ); /* number of sectors verified */ INT13_SetStatus( context, 0x00 ); /* success */ break; case 0x05: /* FORMAT TRACK */ case 0x06: /* FORMAT TRACK AND SET BAD SECTOR FLAGS */ case 0x07: /* FORMAT DRIVE STARTING AT GIVEN TRACK */ INT13_SetStatus( context, 0x0c ); /* unsupported track or invalid media */ break; case 0x08: /* GET DRIVE PARAMETERS */ if (DL_reg( context ) & 0x80) { /* hard disk ? */ INT13_SetStatus( context, 0x07 ); /* drive parameter activity failed */ } else { /* floppy disk */ INT13_ReadFloppyParams( context ); } break; case 0x09: /* INITIALIZE CONTROLLER WITH DRIVE PARAMETERS */ case 0x0a: /* FIXED DISK - READ LONG */ case 0x0b: /* FIXED DISK - WRITE LONG */ case 0x0c: /* SEEK TO CYLINDER */ case 0x0d: /* ALTERNATE RESET HARD DISK */ INT13_SetStatus( context, 0x00 ); /* success */ break; case 0x0e: /* READ SECTOR BUFFER */ case 0x0f: /* WRITE SECTOR BUFFER */ INT13_SetStatus( context, 0x01 ); /* invalid function */ break; case 0x10: /* CHECK IF DRIVE READY */ case 0x11: /* RECALIBRATE DRIVE */ INT13_SetStatus( context, 0x00 ); /* success */ break; case 0x12: /* CONTROLLER RAM DIAGNOSTIC */ case 0x13: /* DRIVE DIAGNOSTIC */ INT13_SetStatus( context, 0x01 ); /* invalid function */ break; case 0x14: /* CONTROLLER INTERNAL DIAGNOSTIC */ INT13_SetStatus( context, 0x00 ); /* success */ break; case 0x15: /* GET DISK TYPE */ if (DL_reg( context ) & 0x80) { /* hard disk ? */ INT13_SetStatus( context, 0x00 ); /* success */ /* type is fixed disk, overwrites status */ SET_AH( context, 0x03 ); } else { /* floppy disk */ INT13_SetStatus( context, 0x00 ); /* success */ /* type is floppy with change detection, overwrites status */ SET_AH( context, 0x02 ); } break; case 0x16: /* FLOPPY - CHANGE OF DISK STATUS */ INT13_SetStatus( context, 0x00 ); /* success */ break; case 0x17: /* SET DISK TYPE FOR FORMAT */ if (DL_reg( context ) < 4) INT13_SetStatus( context, 0x00 ); /* successful completion */ else INT13_SetStatus( context, 0x01 ); /* error */ break; case 0x18: /* SET MEDIA TYPE FOR FORMAT */ if (DL_reg( context ) < 4) INT13_SetStatus( context, 0x00 ); /* success */ else INT13_SetStatus( context, 0x01 ); /* error */ break; case 0x19: /* FIXED DISK - PARK HEADS */ INT13_SetStatus( context, 0x00 ); /* success */ break; default: INT_BARF( context, 0x13 ); INT13_SetStatus( context, 0x01 ); /* invalid function */ } }
/********************************************************************** * DOSVM_Int67Handler * * Handler for interrupt 67h EMS routines. */ void WINAPI DOSVM_Int67Handler( CONTEXT *context ) { switch (AH_reg(context)) { case 0x40: /* EMS - GET MANAGER STATUS */ SET_AH( context, 0 ); /* status: ok */ break; case 0x41: /* EMS - GET PAGE FRAME SEGMENT */ EMS_init(); SET_BX( context, EMS_record->frame_selector ); /* segment of page frame */ SET_AH( context, 0 ); /* status: ok */ break; case 0x42: /* EMS - GET NUMBER OF PAGES */ EMS_init(); /* unallocated 16k pages */ SET_BX( context, EMS_MAX_PAGES - EMS_record->used_pages ); /* total number of 16k pages */ SET_DX( context, EMS_MAX_PAGES ); /* status: ok */ SET_AH( context, 0 ); break; case 0x43: /* EMS - GET HANDLE AND ALLOCATE MEMORY */ EMS_init(); EMS_alloc(context); break; case 0x44: /* EMS - MAP MEMORY */ EMS_init(); SET_AH( context, EMS_map( AL_reg(context), DX_reg(context), BX_reg(context) ) ); break; case 0x45: /* EMS - RELEASE HANDLE AND MEMORY */ EMS_init(); EMS_free(context); break; case 0x46: /* EMS - GET EMM VERSION */ SET_AL( context, 0x40 ); /* version 4.0 */ SET_AH( context, 0 ); /* status: ok */ break; case 0x47: /* EMS - SAVE MAPPING CONTEXT */ EMS_init(); EMS_save_context(context); break; case 0x48: /* EMS - RESTORE MAPPING CONTEXT */ EMS_init(); EMS_restore_context(context); break; case 0x49: /* EMS - reserved - GET I/O PORT ADDRESSES */ case 0x4a: /* EMS - reserved - GET TRANSLATION ARRAY */ INT_BARF(context,0x67); break; case 0x4b: /* EMS - GET NUMBER OF EMM HANDLES */ SET_BX( context, EMS_MAX_HANDLES ); /* EMM handles */ SET_AH( context, 0 ); /* status: ok */ break; case 0x4c: /* EMS - GET PAGES OWNED BY HANDLE */ case 0x4d: /* EMS - GET PAGES FOR ALL HANDLES */ case 0x4e: /* EMS - GET OR SET PAGE MAP */ case 0x4f: /* EMS 4.0 - GET/SET PARTIAL PAGE MAP */ INT_BARF(context,0x67); break; case 0x50: /* EMS 4.0 - MAP/UNMAP MULTIPLE HANDLE PAGES */ EMS_init(); EMS_map_multiple(context); break; case 0x51: /* EMS 4.0 - REALLOCATE PAGES */ case 0x52: /* EMS 4.0 - GET/SET HANDLE ATTRIBUTES */ INT_BARF(context,0x67); break; case 0x53: /* EMS 4.0 - GET/SET HANDLE NAME */ EMS_init(); EMS_access_name(context); break; case 0x54: /* EMS 4.0 - GET HANDLE DIRECTORY */ case 0x55: /* EMS 4.0 - ALTER PAGE MAP AND JUMP */ case 0x56: /* EMS 4.0 - ALTER PAGE MAP AND CALL */ case 0x57: /* EMS 4.0 - MOVE/EXCHANGE MEMORY REGION */ case 0x58: /* EMS 4.0 - GET MAPPABLE PHYSICAL ADDRESS ARRAY */ INT_BARF(context,0x67); break; case 0x59: /* EMS 4.0 - GET EXPANDED MEMORY HARDWARE INFORMATION */ if(AL_reg(context) == 0x01) { EMS_init(); /* unallocated raw pages */ SET_BX( context, EMS_MAX_PAGES - EMS_record->used_pages ); /* total number raw pages */ SET_DX( context, EMS_MAX_PAGES ); /* status: ok */ SET_AH( context, 0 ); } else INT_BARF(context,0x67); break; case 0x5a: /* EMS 4.0 - ALLOCATE STANDARD/RAW PAGES */ case 0x5b: /* EMS 4.0 - ALTERNATE MAP REGISTER SET */ case 0x5c: /* EMS 4.0 - PREPARE EXPANDED MEMORY HARDWARE FOR WARM BOOT */ case 0x5d: /* EMS 4.0 - ENABLE/DISABLE OS FUNCTION SET FUNCTIONS */ INT_BARF(context,0x67); break; case 0xde: /* Virtual Control Program Interface (VCPI) */ if(AL_reg(context) == 0x00) { /* * VCPI INSTALLATION CHECK * (AH_reg() != 0) means VCPI is not present */ TRACE("- VCPI installation check\n"); return; } else INT_BARF(context,0x67); break; default: INT_BARF(context,0x67); } }
/********************************************************************** * INT_Int15Handler (WPROCS.121) * * Handler for int 15h */ void WINAPI INT_Int15Handler( CONTEXT86 *context ) { switch(AH_reg(context)) { case 0x84: /* read joystick information */ FIXME("Read joystick information not implemented\n"); /* FIXME: report status as if no game port exists */ switch(DX_reg(context)) { case 0x0: /* read joystick switches */ AL_reg(context) = 0x0; /* all switches open */ break; case 0x1: /* read joystick position */ AX_reg(context) = 0x0; BX_reg(context) = 0x0; CX_reg(context) = 0x0; DX_reg(context) = 0x0; break; default: INT_BARF( context, 0x15 ); break; } RESET_CFLAG(context); break; case 0x88: /* get size of memory above 1 M */ AX_reg(context) = 64; /* FIXME: are 64K ok? */ RESET_CFLAG(context); break; case 0xc0: /* GET CONFIGURATION */ if (ISV86(context)) /* real */ context->SegEs = 0xf000; else context->SegEs = DOSMEM_BiosSysSeg; BX_reg(context) = 0xe6f5; AH_reg(context) = 0x0; RESET_CFLAG(context); break; case 0xc2: switch(AL_reg(context)) { case 0x00: /* Enable-Disable Pointing Device (mouse) */ /* BH = newstate, 00h = disabled 01h = enabled */ switch(BH_reg(context)) { case 0x00: FIXME("Disable Pointing Device - not implemented\n"); break; case 0x01: FIXME("Enable Pointing Device - not implemented\n"); break; default: INT_BARF( context, 0x15 ); break; } AH_reg(context) = 0x00; /* successful */ break; case 0x02: /* Set Sampling Rate */ /* BH = sampling rate */ FIXME("Set Sampling Rate - not implemented\n"); AH_reg(context) = 0x00; /* successful */ break; case 0x04: /* Get Pointing Device Type */ FIXME("Get Pointing Device Type - not implemented\n"); BH_reg(context) = 0x01;/*Device id FIXME what is it supposed to be?*/ break; default: INT_BARF( context, 0x15 ); } break; default: INT_BARF( context, 0x15 ); } }