Commit 3fa613cf authored by Alexandre Julliard's avatar Alexandre Julliard

Moved internal context macros out of winnt.h.

Added SET_AX etc. macros to avoid non-portable pointer manipulations.
parent c08aa31f
......@@ -40,6 +40,7 @@
#include "flatthunk.h"
#include "heap.h"
#include "module.h"
#include "miscemu.h"
#include "selectors.h"
#include "stackframe.h"
#include "task.h"
......@@ -1459,8 +1460,8 @@ void WINAPI C16ThkSL01(CONTEXT86 *context)
else
{
WORD *stack = MapSL( MAKESEGPTR(context->SegSs, LOWORD(context->Esp)) );
DX_reg(context) = HIWORD(td->apiDB[targetNr].errorReturnValue);
AX_reg(context) = LOWORD(td->apiDB[targetNr].errorReturnValue);
SET_DX( context, HIWORD(td->apiDB[targetNr].errorReturnValue) );
SET_AX( context, LOWORD(td->apiDB[targetNr].errorReturnValue) );
context->Eip = stack[2];
context->SegCs = stack[3];
context->Esp += td->apiDB[targetNr].nrArgBytes + 4;
......@@ -1858,10 +1859,10 @@ void WINAPI CBClientGlueSL( CONTEXT86 *context )
LPWORD stackLin = MapSL( stackSeg );
SEGPTR glue, *glueTab;
stackLin[3] = BP_reg( context );
stackLin[2] = SI_reg( context );
stackLin[1] = DI_reg( context );
stackLin[0] = context->SegDs;
stackLin[3] = (WORD)context->Ebp;
stackLin[2] = (WORD)context->Esi;
stackLin[1] = (WORD)context->Edi;
stackLin[0] = (WORD)context->SegDs;
context->Ebp = OFFSETOF( stackSeg ) + 6;
context->Esp = OFFSETOF( stackSeg ) - 4;
......@@ -1882,7 +1883,7 @@ void WINAPI CBClientThunkSL( CONTEXT86 *context )
{
/* Call 32-bit relay code */
LPWORD args = MapSL( MAKESEGPTR( context->SegSs, BP_reg( context ) ) );
LPWORD args = MapSL( MAKESEGPTR( context->SegSs, LOWORD(context->Ebp) ) );
FARPROC proc = CBClientRelay32[ args[2] ][ args[1] ];
context->Eax = CALL32_CBClient( proc, args, &context->Esi );
......@@ -1896,7 +1897,7 @@ void WINAPI CBClientThunkSLEx( CONTEXT86 *context )
{
/* Call 32-bit relay code */
LPWORD args = MapSL( MAKESEGPTR( context->SegSs, BP_reg( context ) ) );
LPWORD args = MapSL( MAKESEGPTR( context->SegSs, LOWORD(context->Ebp) ) );
FARPROC proc = CBClientRelay32[ args[2] ][ args[1] ];
INT nArgs;
LPWORD stackLin;
......@@ -1905,9 +1906,9 @@ void WINAPI CBClientThunkSLEx( CONTEXT86 *context )
/* Restore registers saved by CBClientGlueSL */
stackLin = (LPWORD)((LPBYTE)CURRENT_STACK16 + sizeof(STACK16FRAME) - 4);
BP_reg( context ) = stackLin[3];
SI_reg( context ) = stackLin[2];
DI_reg( context ) = stackLin[1];
context->Ebp = (context->Ebp & ~0xffff) | stackLin[3];
SET_SI( context, stackLin[2] );
SET_DI( context, stackLin[1] );
context->SegDs = stackLin[0];
context->Esp += 16+nArgs;
......@@ -2064,7 +2065,7 @@ void WINAPI Catch16( LPCATCHBUF lpbuf, CONTEXT86 *context )
lpbuf[6] = context->SegDs;
lpbuf[7] = 0;
lpbuf[8] = context->SegSs;
AX_reg(context) = 0; /* Return 0 */
SET_AX( context, 0 ); /* Return 0 */
}
......@@ -2080,7 +2081,7 @@ void WINAPI Throw16( LPCATCHBUF lpbuf, INT16 retval, CONTEXT86 *context )
STACK32FRAME *frame32;
TEB *teb = NtCurrentTeb();
AX_reg(context) = retval;
SET_AX( context, retval );
/* Find the frame32 corresponding to the frame16 we are jumping to */
pFrame = THREAD_STACK16(teb);
......
......@@ -59,7 +59,7 @@ static WORD Inthandler02hVar = 1;
static void WIN87_ClearCtrlWord( CONTEXT86 *context )
{
AX_reg(context) = 0;
SET_AX( context, 0 );
if (Installed)
#ifdef __i386__
__asm__("fclex");
......@@ -72,7 +72,7 @@ static void WIN87_ClearCtrlWord( CONTEXT86 *context )
static void WIN87_SetCtrlWord( CONTEXT86 *context )
{
CtrlWord_1 = AX_reg(context);
AX_reg(context) &= 0xff3c;
context->Eax &= ~0x00c3;
if (Installed) {
CtrlWord_Internal = AX_reg(context);
#ifdef __i386__
......@@ -91,7 +91,7 @@ void WIN87_Init( CONTEXT86 *context )
#endif
}
StackBottom = StackTop;
AX_reg(context) = 0x1332;
SET_AX( context, 0x1332 );
WIN87_SetCtrlWord(context);
WIN87_ClearCtrlWord(context);
}
......@@ -115,7 +115,7 @@ void WINAPI WIN87_fpmath( CONTEXT86 *context )
InstallIntVecs02hAnd75h();
#endif
WIN87_Init(context);
AX_reg(context) = 0;
SET_AX( context, 0 );
break;
case 1: /* Init Emulator */
......@@ -144,7 +144,7 @@ void WINAPI WIN87_fpmath( CONTEXT86 *context )
break;
case 5: /* return internal control word in AX */
AX_reg(context) = CtrlWord_1;
SET_AX( context, CtrlWord_1 );
break;
case 6: /* round top of stack to integer using method AX & 0x0C00 */
......@@ -179,21 +179,20 @@ void WINAPI WIN87_fpmath( CONTEXT86 *context )
/* FIXME: could someone who really understands asm() fix this please? --AJ */
/* __asm__("fistp %0;wait" : "=m" (dw) : : "memory"); */
TRACE("On top of stack was %ld\n",dw);
AX_reg(context) = LOWORD(dw);
DX_reg(context) = HIWORD(dw);
SET_AX( context, LOWORD(dw) );
SET_DX( context, HIWORD(dw) );
}
break;
case 8: /* restore internal status words from emulator status word */
AX_reg(context) = 0;
SET_AX( context, 0 );
if (Installed) {
#ifdef __i386__
__asm__("fstsw %0;wait" : "=m" (StatusWord_1));
#endif
AL_reg(context) = (BYTE)StatusWord_1 & 0x3f;
SET_AL( context, (BYTE)StatusWord_1 & 0x3f );
}
AX_reg(context) |= StatusWord_2;
AX_reg(context) &= 0x1fff;
context->Eax = (context->Eax | StatusWord_2) & ~0xe000;
StatusWord_2 = AX_reg(context);
break;
......@@ -202,12 +201,12 @@ void WINAPI WIN87_fpmath( CONTEXT86 *context )
break;
case 10: /* dunno. but looks like returning nr. of things on stack in AX */
AX_reg(context) = 0;
SET_AX( context, 0 );
break;
case 11: /* just returns the installed flag in DX:AX */
DX_reg(context) = 0;
AX_reg(context) = Installed;
SET_DX( context, 0 );
SET_AX( context, Installed );
break;
case 12: /* save AX in some internal state var */
......@@ -216,7 +215,8 @@ void WINAPI WIN87_fpmath( CONTEXT86 *context )
default: /* error. Say that loud and clear */
FIXME("unhandled switch %d\n",BX_reg(context));
AX_reg(context) = DX_reg(context) = 0xFFFF;
SET_AX( context, 0xFFFF );
SET_DX( context, 0xFFFF );
break;
}
}
......@@ -248,4 +248,3 @@ void WINAPI WIN87_WinEm87Save(void *pWin87EmSaveArea, int cbWin87EmSaveArea)
FIXME("(%p,%d), stub !\n",
pWin87EmSaveArea,cbWin87EmSaveArea);
}
......@@ -22,6 +22,7 @@
#include <stdlib.h>
#include "windef.h"
#include "module.h"
#include "miscemu.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(dll);
......
......@@ -148,6 +148,8 @@ typedef struct
#define DOS_DATASEG_OFF(xxx) FIELD_OFFSET(DOS_DATASEG, xxx)
DWORD DOS_LOLSeg;
struct _DOS_LISTOFLISTS * DOSMEM_LOL()
{
return PTR_REAL_TO_LIN(HIWORD(DOS_LOLSeg),0);
......
......@@ -219,12 +219,12 @@ void WINAPI DOSVM_ASPIHandler( CONTEXT86 *context )
*p = DPMI_AllocInternalRMCB(ASPI_DOS_func);
TRACE("allocated real mode proc %p\n", *p);
AX_reg(context) = CX_reg(context);
SET_AX( context, CX_reg(context) );
return;
}
error_exit:
/* Return some error... General Failure sounds okay */
AX_reg(context) = ERROR_GEN_FAILURE;
SET_AX( context, ERROR_GEN_FAILURE );
SET_CFLAG(context);
}
......@@ -38,6 +38,7 @@ typedef void (*DOSRELAY)(CONTEXT86*,void*);
extern WORD DOSVM_psp; /* psp of current DOS task */
extern WORD DOSVM_retval; /* return value of previous DOS task */
extern DWORD DOS_LOLSeg;
#if defined(linux) && defined(__i386__)
#define MZ_SUPPORTED
......@@ -74,6 +75,7 @@ extern int DOSDEV_Read(DWORD dev, DWORD buf, int buflen);
extern int DOSDEV_Write(DWORD dev, DWORD buf, int buflen, int verify);
extern int DOSDEV_IoctlRead(DWORD dev, DWORD buf, int buflen);
extern int DOSDEV_IoctlWrite(DWORD dev, DWORD buf, int buflen);
extern struct _DOS_LISTOFLISTS * DOSMEM_LOL();
/* dma.c */
extern int DMA_Transfer(int channel,int reqlength,void* buffer);
......
......@@ -93,14 +93,14 @@ static void DOSVM_Int10Handler_VESA( CONTEXT86 *context )
memcpy(CTX_SEG_OFF_TO_LIN(context,context->SegEs,context->Edi),
(char *)BIOS_SYS + DOSMEM_GetBiosSysStructOffset(OFF_VESAINFO),
sizeof(VESAINFO));
AL_reg(context) = 0x4f;
AH_reg(context) = 0x00; /* 0x00 = successful 0x01 = failed */
SET_AL( context, 0x4f );
SET_AH( context, 0x00 ); /* 0x00 = successful 0x01 = failed */
break;
case 0x01: /* GET SuperVGA MODE INFORMATION */
FIXME("VESA GET SuperVGA Mode Information - Not supported\n");
AL_reg(context) = 0x4f;
AH_reg(context) = 0x01; /* 0x00 = successful 0x01 = failed */
SET_AL( context, 0x4f );
SET_AH( context, 0x01 ); /* 0x00 = successful 0x01 = failed */
break;
case 0x02: /* SET SuperVGA VIDEO MODE */
......@@ -240,14 +240,14 @@ static void DOSVM_Int10Handler_VESA( CONTEXT86 *context )
FIXME("VESA Set Video Mode (0x%x) - Not Supported\n", BX_reg(context));
}
data->VideoMode = BX_reg(context);
AL_reg(context) = 0x4f;
AH_reg(context) = 0x00;
SET_AL( context, 0x4f );
SET_AH( context, 0x00 );
break;
case 0x03: /* VESA SuperVGA BIOS - GET CURRENT VIDEO MODE */
AL_reg(context) = 0x4f;
AH_reg(context) = 0x00; /* should probly check if a vesa mode has ben set */
BX_reg(context) = data->VideoMode;
SET_AL( context, 0x4f );
SET_AH( context, 0x00 ); /* should probly check if a vesa mode has ben set */
SET_BX( context, data->VideoMode );
break;
case 0x04: /* VESA SuperVGA BIOS - SAVE/RESTORE SuperVGA VIDEO STATE */
......@@ -264,20 +264,20 @@ static void DOSVM_Int10Handler_VESA( CONTEXT86 *context )
*/
switch(BH_reg(context)) {
case 0x00: /* select video memory window */
AL_reg(context) = 0x4f; /* function supported */
SET_AL( context, 0x4f ); /* function supported */
if(BL_reg(context) == 0) {
VGA_SetWindowStart(DX_reg(context) * 64 * 1024);
AH_reg(context) = 0x00; /* status: successful */
SET_AH( context, 0x00 ); /* status: successful */
} else
AH_reg(context) = 0x01; /* status: failed */
SET_AH( context, 0x01 ); /* status: failed */
break;
case 0x01: /* get video memory window */
AL_reg(context) = 0x4f; /* function supported */
SET_AL( context, 0x4f ); /* function supported */
if(BL_reg(context) == 0) {
DX_reg(context) = VGA_GetWindowStart() / 64 / 1024;
AH_reg(context) = 0x00; /* status: successful */
SET_DX( context, VGA_GetWindowStart() / 64 / 1024 );
SET_AH( context, 0x00 ); /* status: successful */
} else
AH_reg(context) = 0x01; /* status: failed */
SET_AH( context, 0x01 ); /* status: failed */
break;
default:
INT_BARF( context, 0x10 );
......@@ -321,7 +321,7 @@ static void DOSVM_Int10Handler_VESA( CONTEXT86 *context )
/* There's no reason to really support this */
/* is there?....................(A.C.) */
TRACE("Just report the video not hercules compatible\n");
DX_reg(context) = 0xffff;
SET_DX( context, 0xffff );
break;
case 0xff: /* Turn VESA ON/OFF */
......@@ -358,7 +358,7 @@ void WINAPI DOSVM_Int10Handler( CONTEXT86 *context )
}
/* FIXME: Should we keep the bit 7 in the Bios Data memory? */
AL_reg(context) &= ~0x80;
context->Eax &= ~0x80;
switch (AL_reg(context)) {
case 0x00: /* 40x25 */
......@@ -437,17 +437,17 @@ void WINAPI DOSVM_Int10Handler( CONTEXT86 *context )
unsigned row, col;
TRACE("Get cursor position and size (page %d)\n", BH_reg(context));
CX_reg(context) = data->VideoCursorType;
SET_CX( context, data->VideoCursorType );
BIOS_GetCursorPos(data,BH_reg(context),&col,&row);
DH_reg(context) = row;
DL_reg(context) = col;
SET_DH( context, row );
SET_DL( context, col );
TRACE("Cursor Position: %d %d\n", DH_reg(context), DL_reg(context));
}
break;
case 0x04: /* READ LIGHT PEN POSITION */
FIXME("Read Light Pen Position - Not Supported\n");
AH_reg(context) = 0x00; /* Not down */
SET_AH( context, 0x00 ); /* Not down */
break;
case 0x05: /* SELECT ACTIVE DISPLAY PAGE */
......@@ -483,13 +483,16 @@ void WINAPI DOSVM_Int10Handler( CONTEXT86 *context )
{
FIXME("Read character and attribute at cursor position -"
" Can't read from non-0 page\n");
AL_reg(context) = ' '; /* That page is blank */
AH_reg(context) = 7;
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(&AL_reg(context), &AH_reg(context));
VGA_GetCharacterAtCursor(&ascii, &attr);
SET_AL( context, ascii );
SET_AH( context, attr );
}
}
break;
......@@ -563,9 +566,9 @@ void WINAPI DOSVM_Int10Handler( CONTEXT86 *context )
case 0x0f: /* GET CURRENT VIDEO MODE */
TRACE("Get current video mode\n");
/* Note: This should not be a constant value. */
AL_reg(context) = data->VideoMode;
AH_reg(context) = data->VideoColumns;
BH_reg(context) = 0; /* Display page 0 */
SET_AL( context, data->VideoMode );
SET_AH( context, data->VideoColumns );
SET_BH( context, 0 ); /* Display page 0 */
break;
case 0x10:
......@@ -595,11 +598,11 @@ void WINAPI DOSVM_Int10Handler( CONTEXT86 *context )
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 */
BH_reg(context) = VGA_GetColor16((int)BL_reg(context));
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");
BH_reg(context) = VGA_GetColor16(16);
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");
......@@ -719,11 +722,9 @@ void WINAPI DOSVM_Int10Handler( CONTEXT86 *context )
switch BL_reg(context) {
case 0x10: /* GET EGA INFO */
TRACE("EGA info requested\n");
BH_reg(context) = 0x00; /* Color screen */
BL_reg(context) =
data->ModeOptions >> 5; /* EGA memory size */
CX_reg(context) =
data->FeatureBitsSwitches;
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");
......@@ -767,9 +768,9 @@ void WINAPI DOSVM_Int10Handler( CONTEXT86 *context )
switch AL_reg(context) {
case 0x00: /* GET DISPLAY COMBINATION CODE */
TRACE("Get Display Combination Code\n");
AX_reg(context) = 0x001a;
BL_reg(context) = 0x08; /* VGA w/ color analog display */
BH_reg(context) = 0x00; /* No secondary hardware */
SET_AX( context, 0x001a );
SET_BL( context, 0x08 ); /* VGA w/ color analog display */
SET_BH( context, 0x00 ); /* No secondary hardware */
break;
case 0x01: /* SET DISPLAY COMBINATION CODE */
FIXME("Set Display Combination Code - Not Supported\n");
......@@ -785,7 +786,7 @@ void WINAPI DOSVM_Int10Handler( CONTEXT86 *context )
TRACE("Get functionality/state information\n");
if (BX_reg(context) == 0x0)
{
AL_reg(context) = 0x1b;
SET_AL( context, 0x1b );
/* Copy state information structure to ES:DI */
memcpy(CTX_SEG_OFF_TO_LIN(context,context->SegEs,context->Edi),
(char *)BIOS_SYS + DOSMEM_GetBiosSysStructOffset(OFF_VIDEOSTATE),sizeof(VIDEOSTATE));
......@@ -800,7 +801,7 @@ void WINAPI DOSVM_Int10Handler( CONTEXT86 *context )
/* There's no reason to really support this */
/* is there?....................(A.C.) */
TRACE("Just report the video not hercules compatible\n");
DX_reg(context) = 0xffff;
SET_DX( context, 0xffff );
break;
case 0x4f: /* VESA */
......
......@@ -51,13 +51,16 @@ WINE_DEFAULT_DEBUG_CHANNEL(int);
void WINAPI DOSVM_Int16Handler( CONTEXT86 *context )
{
BYTE ascii, scan;
switch AH_reg(context) {
case 0x00: /* Get Keystroke */
/* Returns: AH = Scan code
AL = ASCII character */
TRACE("Get Keystroke\n");
DOSVM_Int16ReadChar(&AL_reg(context), &AH_reg(context), FALSE);
DOSVM_Int16ReadChar(&ascii, &scan, FALSE);
SET_AL( context, ascii );
SET_AH( context, scan );
break;
case 0x01: /* Check for Keystroke */
......@@ -65,12 +68,14 @@ void WINAPI DOSVM_Int16Handler( CONTEXT86 *context )
/* AH = Scan code */
/* AL = ASCII character */
TRACE("Check for Keystroke\n");
if (!DOSVM_Int16ReadChar(&AL_reg(context), &AH_reg(context), TRUE))
if (!DOSVM_Int16ReadChar(&ascii, &scan, TRUE))
{
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
......@@ -79,24 +84,24 @@ void WINAPI DOSVM_Int16Handler( CONTEXT86 *context )
break;
case 0x02: /* Get Shift Flags */
AL_reg(context) = 0;
SET_AL( context, 0 );
if (GetAsyncKeyState(VK_RSHIFT))
AL_reg(context) |= 0x01;
context->Eax |= 0x01;
if (GetAsyncKeyState(VK_LSHIFT))
AL_reg(context) |= 0x02;
context->Eax |= 0x02;
if (GetAsyncKeyState(VK_LCONTROL) || GetAsyncKeyState(VK_RCONTROL))
AL_reg(context) |= 0x04;
context->Eax |= 0x04;
if (GetAsyncKeyState(VK_LMENU) || GetAsyncKeyState(VK_RMENU))
AL_reg(context) |= 0x08;
context->Eax |= 0x08;
if (GetAsyncKeyState(VK_SCROLL))
AL_reg(context) |= 0x10;
context->Eax |= 0x10;
if (GetAsyncKeyState(VK_NUMLOCK))
AL_reg(context) |= 0x20;
context->Eax |= 0x20;
if (GetAsyncKeyState(VK_CAPITAL))
AL_reg(context) |= 0x40;
context->Eax |= 0x40;
if (GetAsyncKeyState(VK_INSERT))
AL_reg(context) |= 0x80;
context->Eax |= 0x80;
TRACE("Get Shift Flags: returning 0x%02x\n", AL_reg(context));
break;
......@@ -107,7 +112,7 @@ void WINAPI DOSVM_Int16Handler( CONTEXT86 *context )
case 0x09: /* Get Keyboard Functionality */
FIXME("Get Keyboard Functionality - Not Supported\n");
/* As a temporary measure, say that "nothing" is supported... */
AL_reg(context) = 0;
SET_AL( context, 0 );
break;
case 0x0a: /* Get Keyboard ID */
......@@ -118,7 +123,9 @@ void WINAPI DOSVM_Int16Handler( CONTEXT86 *context )
TRACE("Get Enhanced Keystroke - Partially supported\n");
/* Returns: AH = Scan code
AL = ASCII character */
DOSVM_Int16ReadChar(&AL_reg(context), &AH_reg(context), FALSE);
DOSVM_Int16ReadChar(&ascii, &scan, FALSE);
SET_AL( context, ascii );
SET_AH( context, scan );
break;
......@@ -127,12 +134,14 @@ void WINAPI DOSVM_Int16Handler( CONTEXT86 *context )
/* AH = Scan code */
/* AL = ASCII character */
TRACE("Check for Enhanced Keystroke - Partially supported\n");
if (!DOSVM_Int16ReadChar(&AL_reg(context), &AH_reg(context), TRUE))
if (!DOSVM_Int16ReadChar(&ascii, &scan, TRUE))
{
SET_ZFLAG(context);
}
else
{
SET_AL( context, ascii );
SET_AH( context, scan );
RESET_ZFLAG(context);
}
break;
......
......@@ -38,13 +38,13 @@ void WINAPI DOSVM_Int17Handler( CONTEXT86 *context )
{
case 0x01: /* PRINTER - INITIALIZE */
FIXME("Initialize Printer - Not Supported\n");
AH_reg(context) = 0; /* time out */
SET_AH( context, 0 ); /* time out */
break;
case 0x02: /* PRINTER - GET STATUS */
FIXME("Get Printer Status - Not Supported\n");
break;
default:
AH_reg(context) = 0; /* time out */
SET_AH( context, 0 ); /* time out */
INT_BARF( context, 0x17 );
}
}
......@@ -55,7 +55,7 @@ void WINAPI DOSVM_Int21Handler_Ioctl( CONTEXT86 *context )
CX_reg(context), DX_reg(context));
if (!CX_reg(context))
{
AX_reg(context) = 1;
SET_AX( context, 1 );
SET_CFLAG(context);
break;
}
......@@ -76,6 +76,7 @@ void WINAPI DOSVM_Int21Handler_Ioctl( CONTEXT86 *context )
*/
void WINAPI DOSVM_Int21Handler( CONTEXT86 *context )
{
BYTE ascii;
RESET_CFLAG(context); /* Not sure if this is a good idea */
if(AH_reg(context) == 0x0c) /* FLUSH BUFFER AND READ STANDARD INPUT */
......@@ -91,7 +92,7 @@ void WINAPI DOSVM_Int21Handler( CONTEXT86 *context )
if(al != 0x01 && al != 0x06 && al != 0x07 && al != 0x08 && al != 0x0a)
return;
AH_reg(context) = al;
SET_AH( context, al );
}
switch(AH_reg(context))
......@@ -103,9 +104,10 @@ void WINAPI DOSVM_Int21Handler( CONTEXT86 *context )
case 0x01: /* READ CHARACTER FROM STANDARD INPUT, WITH ECHO */
TRACE("DIRECT CHARACTER INPUT WITH ECHO\n");
DOSVM_Int16ReadChar(&AL_reg(context), NULL, FALSE);
DOSVM_Int16ReadChar(&ascii, NULL, FALSE);
SET_AL( context, ascii );
DOSVM_PutChar(AL_reg(context));
break;
break;
case 0x02: /* WRITE CHARACTER TO STANDARD OUTPUT */
TRACE("Write Character to Standard Output\n");
......@@ -119,21 +121,20 @@ void WINAPI DOSVM_Int21Handler( CONTEXT86 *context )
TRACE("Direct Console Input\n");
if (scan) {
/* return pending scancode */
AL_reg(context) = scan;
SET_AL( context, scan );
RESET_ZFLAG(context);
scan = 0;
} else {
char ascii;
if (DOSVM_Int16ReadChar(&ascii,&scan,TRUE)) {
DOSVM_Int16ReadChar(&ascii,&scan,FALSE);
/* return ASCII code */
AL_reg(context) = ascii;
SET_AL( context, ascii );
RESET_ZFLAG(context);
/* return scan code on next call only if ascii==0 */
if (ascii) scan = 0;
} else {
/* nothing pending, clear everything */
AL_reg(context) = 0;
SET_AL( context, 0 );
SET_ZFLAG(context);
scan = 0; /* just in case */
}
......@@ -147,22 +148,24 @@ void WINAPI DOSVM_Int21Handler( CONTEXT86 *context )
case 0x07: /* DIRECT CHARACTER INPUT WITHOUT ECHO */
/* FIXME: Use DOSDEV_Peek/Read(DOSDEV_Console(),...) !! */
TRACE("DIRECT CHARACTER INPUT WITHOUT ECHO\n");
DOSVM_Int16ReadChar(&AL_reg(context), NULL, FALSE);
DOSVM_Int16ReadChar(&ascii, NULL, FALSE);
SET_AL( context, ascii );
break;
case 0x08: /* CHARACTER INPUT WITHOUT ECHO */
/* FIXME: Use DOSDEV_Peek/Read(DOSDEV_Console(),...) !! */
TRACE("CHARACTER INPUT WITHOUT ECHO\n");
DOSVM_Int16ReadChar(&AL_reg(context), NULL, FALSE);
DOSVM_Int16ReadChar(&ascii, NULL, FALSE);
SET_AL( context, ascii );
break;
case 0x0b: /* GET STDIN STATUS */
{
BIOSDATA *data = BIOS_DATA;
if(data->FirstKbdCharPtr == data->NextKbdCharPtr)
AL_reg(context) = 0;
SET_AL( context, 0 );
else
AL_reg(context) = 0xff;
SET_AL( context, 0xff );
}
break;
......@@ -176,7 +179,7 @@ void WINAPI DOSVM_Int21Handler( CONTEXT86 *context )
{
FARPROC16 addr = DOSVM_GetRMHandler( AL_reg(context) );
context->SegEs = SELECTOROF(addr);
BX_reg(context) = OFFSETOF(addr);
SET_BX( context, OFFSETOF(addr) );
}
break;
......@@ -203,7 +206,7 @@ void WINAPI DOSVM_Int21Handler( CONTEXT86 *context )
if (!MZ_Exec( context, CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx),
AL_reg(context), CTX_SEG_OFF_TO_LIN(context, context->SegEs, context->Ebx) ))
{
AX_reg(context) = GetLastError();
SET_AX( context, GetLastError() );
SET_CFLAG(context);
}
break;
......@@ -215,7 +218,7 @@ void WINAPI DOSVM_Int21Handler( CONTEXT86 *context )
case 0x4d: /* GET RETURN CODE */
TRACE("GET RETURN CODE (ERRORLEVEL)\n");
AX_reg(context) = DOSVM_retval;
SET_AX( context, DOSVM_retval );
DOSVM_retval = 0;
break;
......@@ -228,14 +231,14 @@ void WINAPI DOSVM_Int21Handler( CONTEXT86 *context )
TRACE("GET CURRENT PROCESS ID (GET PSP ADDRESS)\n");
/* FIXME: should we return the original DOS PSP upon */
/* Windows startup ? */
BX_reg(context) = DOSVM_psp;
SET_BX( context, DOSVM_psp );
break;
case 0x52: /* "SYSVARS" - GET LIST OF LISTS */
TRACE("SYSVARS - GET LIST OF LISTS\n");
{
context->SegEs = HIWORD(DOS_LOLSeg);
BX_reg(context) = FIELD_OFFSET(DOS_LISTOFLISTS, ptr_first_DPB);
SET_BX( context, FIELD_OFFSET(DOS_LISTOFLISTS, ptr_first_DPB) );
}
break;
......@@ -243,7 +246,7 @@ void WINAPI DOSVM_Int21Handler( CONTEXT86 *context )
TRACE("GET CURRENT PSP ADDRESS\n");
/* FIXME: should we return the original DOS PSP upon */
/* Windows startup ? */
BX_reg(context) = DOSVM_psp;
SET_BX( context, DOSVM_psp );
break;
default:
......
......@@ -51,8 +51,8 @@ void WINAPI DOSVM_Int33Handler( CONTEXT86 *context )
switch (LOWORD(context->Eax)) {
case 0x00:
TRACE("Reset mouse driver and request status\n");
AX_reg(context) = 0xFFFF; /* installed */
BX_reg(context) = 3; /* # of buttons */
SET_AX( context, 0xFFFF ); /* installed */
SET_BX( context, 3 ); /* # of buttons */
memset( &mouse_info, 0, sizeof(mouse_info) );
/* Set the default mickey/pixel ratio */
mouse_info.HMPratio = 8;
......@@ -67,9 +67,9 @@ void WINAPI DOSVM_Int33Handler( CONTEXT86 *context )
case 0x03:
TRACE("Return mouse position and button status: (%ld,%ld) and %ld\n",
mouse_info.x, mouse_info.y, mouse_info.but);
BX_reg(context) = mouse_info.but;
CX_reg(context) = mouse_info.x;
DX_reg(context) = mouse_info.y;
SET_BX( context, mouse_info.but );
SET_CX( context, mouse_info.x );
SET_DX( context, mouse_info.y );
break;
case 0x04:
FIXME("Position mouse cursor\n");
......@@ -78,17 +78,17 @@ void WINAPI DOSVM_Int33Handler( CONTEXT86 *context )
TRACE("Return Mouse button press Information for %s mouse button\n",
BX_reg(context) ? "right" : "left");
if (BX_reg(context)) {
BX_reg(context) = mouse_info.rbcount;
SET_BX( context, mouse_info.rbcount );
mouse_info.rbcount = 0;
CX_reg(context) = mouse_info.rlastx;
DX_reg(context) = mouse_info.rlasty;
SET_CX( context, mouse_info.rlastx );
SET_DX( context, mouse_info.rlasty );
} else {
BX_reg(context) = mouse_info.lbcount;
SET_BX( context, mouse_info.lbcount );
mouse_info.lbcount = 0;
CX_reg(context) = mouse_info.llastx;
DX_reg(context) = mouse_info.llasty;
SET_CX( context, mouse_info.llastx );
SET_DX( context, mouse_info.llasty );
}
AX_reg(context) = mouse_info.but;
SET_AX( context, mouse_info.but );
break;
case 0x07:
FIXME("Define horizontal mouse cursor range\n");
......@@ -104,8 +104,8 @@ void WINAPI DOSVM_Int33Handler( CONTEXT86 *context )
break;
case 0x0B:
TRACE("Read Mouse motion counters\n");
CX_reg(context) = (mouse_info.x - mouse_info.oldx) * (mouse_info.HMPratio / 8);
DX_reg(context) = (mouse_info.y - mouse_info.oldy) * (mouse_info.VMPratio / 8);
SET_CX( context, (mouse_info.x - mouse_info.oldx) * (mouse_info.HMPratio / 8) );
SET_DX( context, (mouse_info.y - mouse_info.oldy) * (mouse_info.VMPratio / 8) );
mouse_info.oldx = mouse_info.x;
mouse_info.oldy = mouse_info.y;
break;
......
......@@ -118,20 +118,20 @@ static void EMS_alloc( CONTEXT86 *context )
hindex++;
if(hindex == EMS_MAX_HANDLES) {
AH_reg(context) = 0x85; /* status: no more handles available */
SET_AH( context, 0x85 ); /* status: no more handles available */
} else {
int pages = BX_reg(context);
void *buffer = HeapAlloc( GetProcessHeap(), 0, pages * EMS_PAGE_SIZE );
if(!buffer) {
AH_reg(context) = 0x88; /* status: insufficient pages available */
SET_AH( context, 0x88 ); /* status: insufficient pages available */
} else {
EMS_record->handle[hindex].address = buffer;
EMS_record->handle[hindex].pages = pages;
EMS_record->used_pages += pages;
DX_reg(context) = hindex; /* handle to allocated memory*/
AH_reg(context) = 0; /* status: ok */
SET_DX( context, hindex ); /* handle to allocated memory*/
SET_AH( context, 0 ); /* status: ok */
}
}
}
......@@ -146,7 +146,7 @@ static void EMS_access_name( CONTEXT86 *context )
char *ptr;
int hindex = DX_reg(context);
if(hindex < 0 || hindex >= EMS_MAX_HANDLES) {
AH_reg(context) = 0x83; /* invalid handle */
SET_AH( context, 0x83 ); /* invalid handle */
return;
}
......@@ -154,13 +154,13 @@ static void EMS_access_name( CONTEXT86 *context )
case 0x00: /* get name */
ptr = PTR_REAL_TO_LIN(context->SegEs, DI_reg(context));
memcpy(ptr, EMS_record->handle[hindex].name, 8);
AH_reg(context) = 0;
SET_AH( context, 0 );
break;
case 0x01: /* set name */
ptr = PTR_REAL_TO_LIN(context->SegDs, SI_reg(context));
memcpy(EMS_record->handle[hindex].name, ptr, 8);
AH_reg(context) = 0;
SET_AH( context, 0 );
break;
default:
......@@ -241,7 +241,7 @@ static void EMS_map_multiple( CONTEXT86 *context )
status = 0x8f; /* status: undefined subfunction */
}
AH_reg(context) = status;
SET_AH( context, status );
}
/**********************************************************************
......@@ -255,12 +255,12 @@ static void EMS_free( CONTEXT86 *context )
int i;
if(hindex < 0 || hindex >= EMS_MAX_HANDLES) {
AH_reg(context) = 0x83; /* status: invalid handle */
SET_AH( context, 0x83 ); /* status: invalid handle */
return;
}
if(!EMS_record->handle[hindex].address) {
AH_reg(context) = 0; /* status: ok */
SET_AH( context, 0 ); /* status: ok */
return;
}
......@@ -275,7 +275,7 @@ static void EMS_free( CONTEXT86 *context )
HeapFree( GetProcessHeap(), 0, EMS_record->handle[hindex].address );
EMS_record->handle[hindex].address = 0;
AH_reg(context) = 0; /* status: ok */
SET_AH( context, 0 ); /* status: ok */
}
/**********************************************************************
......@@ -293,7 +293,7 @@ static void EMS_save_context( CONTEXT86 *context )
EMS_record->mapping_save_area[h][i].logical_page = EMS_record->mapping[i].logical_page;
}
AX_reg(context) = 0; /* status: ok */
SET_AX( context, 0 ); /* status: ok */
}
......@@ -312,12 +312,12 @@ static void EMS_restore_context( CONTEXT86 *context )
int logical_page = EMS_record->mapping_save_area[handle][i].logical_page;
if(EMS_map( i, hindex, logical_page )) {
AX_reg(context) = 0x8e; /* status: restore of mapping context failed */
SET_AX( context, 0x8e ); /* status: restore of mapping context failed */
return;
}
}
AX_reg(context) = 0; /* status: ok */
SET_AX( context, 0 ); /* status: ok */
}
/**********************************************************************
......@@ -330,23 +330,23 @@ void WINAPI DOSVM_Int67Handler( CONTEXT86 *context )
switch AH_reg(context) {
case 0x40: /* EMS - GET MANAGER STATUS */
AH_reg(context) = 0; /* status: ok */
SET_AH( context, 0 ); /* status: ok */
break;
case 0x41: /* EMS - GET PAGE FRAME SEGMENT */
EMS_init();
BX_reg(context) = EMS_record->frame_selector; /* segment of page frame */
AH_reg(context) = 0; /* status: ok */
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 */
BX_reg(context) = EMS_MAX_PAGES - EMS_record->used_pages;
SET_BX( context, EMS_MAX_PAGES - EMS_record->used_pages );
/* total number of 16k pages */
DX_reg(context) = EMS_MAX_PAGES;
SET_DX( context, EMS_MAX_PAGES );
/* status: ok */
AH_reg(context) = 0;
SET_AH( context, 0 );
break;
case 0x43: /* EMS - GET HANDLE AND ALLOCATE MEMORY */
......@@ -356,7 +356,7 @@ void WINAPI DOSVM_Int67Handler( CONTEXT86 *context )
case 0x44: /* EMS - MAP MEMORY */
EMS_init();
AH_reg(context) = EMS_map( AL_reg(context), DX_reg(context), BX_reg(context) );
SET_AH( context, EMS_map( AL_reg(context), DX_reg(context), BX_reg(context) ) );
break;
case 0x45: /* EMS - RELEASE HANDLE AND MEMORY */
......@@ -365,8 +365,8 @@ void WINAPI DOSVM_Int67Handler( CONTEXT86 *context )
break;
case 0x46: /* EMS - GET EMM VERSION */
AL_reg(context) = 0x40; /* version 4.0 */
AH_reg(context) = 0; /* status: ok */
SET_AL( context, 0x40 ); /* version 4.0 */
SET_AH( context, 0 ); /* status: ok */
break;
case 0x47: /* EMS - SAVE MAPPING CONTEXT */
......@@ -385,8 +385,8 @@ void WINAPI DOSVM_Int67Handler( CONTEXT86 *context )
break;
case 0x4b: /* EMS - GET NUMBER OF EMM HANDLES */
BX_reg(context) = EMS_MAX_HANDLES; /* EMM handles */
AH_reg(context) = 0; /* status: ok */
SET_BX( context, EMS_MAX_HANDLES ); /* EMM handles */
SET_AH( context, 0 ); /* status: ok */
break;
case 0x4c: /* EMS - GET PAGES OWNED BY HANDLE */
......@@ -423,11 +423,11 @@ void WINAPI DOSVM_Int67Handler( CONTEXT86 *context )
if(AL_reg(context) == 0x01) {
EMS_init();
/* unallocated raw pages */
BX_reg(context) = EMS_MAX_PAGES - EMS_record->used_pages;
SET_BX( context, EMS_MAX_PAGES - EMS_record->used_pages );
/* total number raw pages */
DX_reg(context) = EMS_MAX_PAGES;
SET_DX( context, EMS_MAX_PAGES );
/* status: ok */
AH_reg(context) = 0;
SET_AH( context, 0 );
} else
INT_BARF(context,0x67);
break;
......@@ -454,7 +454,7 @@ void WINAPI EMS_Ioctl_Handler( CONTEXT86 *context )
switch AL_reg(context) {
case 0x00: /* IOCTL - GET DEVICE INFORMATION */
RESET_CFLAG(context); /* operation was successful */
DX_reg(context) = 0x4080; /* bit 14 (support ioctl read) and
SET_DX( context, 0x4080 ); /* bit 14 (support ioctl read) and
* bit 7 (is_device) */
break;
......@@ -471,7 +471,7 @@ void WINAPI EMS_Ioctl_Handler( CONTEXT86 *context )
case 0x07: /* IOCTL - GET OUTPUT STATUS */
RESET_CFLAG(context); /* operation was successful */
AL_reg(context) = 0xff; /* device is ready */
SET_AL( context, 0xff ); /* device is ready */
break;
default:
......
......@@ -61,9 +61,9 @@ void WINAPI XMS_Handler( CONTEXT86 *context )
{
case 0x00: /* Get XMS version number */
TRACE("get XMS version number\n");
AX_reg(context) = 0x0200; /* 2.0 */
BX_reg(context) = 0x0000; /* internal revision */
DX_reg(context) = 0x0001; /* HMA exists */
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 */
{
......@@ -71,25 +71,25 @@ void WINAPI XMS_Handler( CONTEXT86 *context )
TRACE("query free extended memory\n");
GlobalMemoryStatus( &status );
AX_reg(context) = DX_reg(context) = status.dwAvailVirtual >> 10;
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));
DX_reg(context) = GlobalAlloc16(GMEM_MOVEABLE,
(DWORD)DX_reg(context)<<10);
AX_reg(context) = DX_reg(context) ? 1 : 0;
if (!DX_reg(context)) BL_reg(context) = 0xA0; /* out of memory */
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))) {
AX_reg(context) = 0; /* failure */
BL_reg(context) = 0xa2; /* invalid handle */
SET_AX( context, 0 ); /* failure */
SET_BL( context, 0xa2 ); /* invalid handle */
} else
AX_reg(context) = 1; /* success */
SET_AX( context, 1 ); /* success */
break;
case 0x0b: /* Move Extended Memory Block */
{
......@@ -106,8 +106,8 @@ void WINAPI XMS_Handler( CONTEXT86 *context )
}
default:
INT_BARF( context, 0x31 );
AX_reg(context) = 0x0000; /* failure */
BL_reg(context) = 0x80; /* function not implemented */
SET_AX( context, 0x0000 ); /* failure */
SET_BL( context, 0x80 ); /* function not implemented */
break;
}
}
......@@ -349,8 +349,8 @@ void RELAY_DebugCallFrom16( CONTEXT86 *context )
if (call->arg_types[0] & ARG_REGISTER)
DPRINTF(" AX=%04x BX=%04x CX=%04x DX=%04x SI=%04x DI=%04x ES=%04x EFL=%08lx\n",
AX_reg(context), BX_reg(context), CX_reg(context),
DX_reg(context), SI_reg(context), DI_reg(context),
(WORD)context->Eax, (WORD)context->Ebx, (WORD)context->Ecx,
(WORD)context->Edx, (WORD)context->Esi, (WORD)context->Edi,
(WORD)context->SegEs, context->EFlags );
SYSLEVEL_CheckNotLevel( 2 );
......@@ -379,8 +379,8 @@ void RELAY_DebugCallFrom16Ret( CONTEXT86 *context, int ret_val )
DPRINTF("retval=none ret=%04x:%04x ds=%04x\n",
(WORD)context->SegCs, LOWORD(context->Eip), (WORD)context->SegDs);
DPRINTF(" AX=%04x BX=%04x CX=%04x DX=%04x SI=%04x DI=%04x ES=%04x EFL=%08lx\n",
AX_reg(context), BX_reg(context), CX_reg(context),
DX_reg(context), SI_reg(context), DI_reg(context),
(WORD)context->Eax, (WORD)context->Ebx, (WORD)context->Ecx,
(WORD)context->Edx, (WORD)context->Esi, (WORD)context->Edi,
(WORD)context->SegEs, context->EFlags );
}
else if (call->arg_types[0] & ARG_RET16)
......@@ -427,9 +427,9 @@ void RELAY_DebugCallTo16( LPVOID target, int nb_args, BOOL reg_func )
DPRINTF(") ss:sp=%04x:%04x", SELECTOROF(teb->cur_stack),
OFFSETOF(teb->cur_stack) );
DPRINTF(" ax=%04x bx=%04x cx=%04x dx=%04x si=%04x di=%04x bp=%04x es=%04x fs=%04x\n",
AX_reg(context), BX_reg(context), CX_reg(context),
DX_reg(context), SI_reg(context), DI_reg(context),
BP_reg(context), (WORD)context->SegEs, (WORD)context->SegFs );
(WORD)context->Eax, (WORD)context->Ebx, (WORD)context->Ecx,
(WORD)context->Edx, (WORD)context->Esi, (WORD)context->Edi,
(WORD)context->Ebp, (WORD)context->SegEs, (WORD)context->SegFs );
}
else
{
......@@ -468,8 +468,8 @@ void RELAY_DebugCallTo16Ret( BOOL reg_func, int ret_val )
SELECTOROF(NtCurrentTeb()->cur_stack),
OFFSETOF(NtCurrentTeb()->cur_stack));
DPRINTF(" ax=%04x bx=%04x cx=%04x dx=%04x bp=%04x sp=%04x\n",
AX_reg(context), BX_reg(context), CX_reg(context),
DX_reg(context), BP_reg(context), LOWORD(context->Esp));
(WORD)context->Eax, (WORD)context->Ebx, (WORD)context->Ecx,
(WORD)context->Edx, (WORD)context->Ebp, (WORD)context->Esp );
}
SYSLEVEL_CheckNotLevel( 2 );
......
......@@ -330,14 +330,16 @@ void WINAPI SNOOP16_Return(FARPROC proc, LPBYTE args, CONTEXT86 *context) {
if (max!=ret->dll->funs[ret->ordinal].nrofargs)
DPRINTF(" ...");
DPRINTF(") retval = %04x:%04x ret=%04x:%04x\n",
DX_reg(context),AX_reg(context),HIWORD(ret->origreturn),LOWORD(ret->origreturn)
(WORD)context->Edx,(WORD)context->Eax,
HIWORD(ret->origreturn),LOWORD(ret->origreturn)
);
HeapFree(GetProcessHeap(),0,ret->args);
ret->args = NULL;
} else
DPRINTF("RET %s.%ld: %s() retval = %04x:%04x ret=%04x:%04x\n",
ret->dll->name,ret->ordinal,ret->dll->funs[ret->ordinal].name,
DX_reg(context),AX_reg(context),HIWORD(ret->origreturn),LOWORD(ret->origreturn)
(WORD)context->Edx,(WORD)context->Eax,
HIWORD(ret->origreturn),LOWORD(ret->origreturn)
);
ret->origreturn = NULL; /* mark as empty */
}
......
......@@ -163,9 +163,6 @@ extern WORD DOSMEM_xms_seg;
extern WORD DOSMEM_dpmi_seg;
extern WORD DOSMEM_dpmi_sel;
extern DWORD DOS_LOLSeg;
extern struct _DOS_LISTOFLISTS * DOSMEM_LOL();
extern BOOL DOSMEM_Init(BOOL);
extern void DOSMEM_Tick(WORD timer);
extern WORD DOSMEM_AllocSelector(WORD);
......@@ -277,4 +274,45 @@ extern char IO_pp_init(void);
LOWORD((context)->Ecx), LOWORD((context)->Edx), LOWORD((context)->Esi), \
LOWORD((context)->Edi), (WORD)(context)->SegDs, (WORD)(context)->SegEs )
/* Macros for easier access to i386 context registers */
#define AX_reg(context) ((WORD)(context)->Eax)
#define BX_reg(context) ((WORD)(context)->Ebx)
#define CX_reg(context) ((WORD)(context)->Ecx)
#define DX_reg(context) ((WORD)(context)->Edx)
#define SI_reg(context) ((WORD)(context)->Esi)
#define DI_reg(context) ((WORD)(context)->Edi)
#define AL_reg(context) ((BYTE)(context)->Eax)
#define AH_reg(context) ((BYTE)((context)->Eax >> 8))
#define BL_reg(context) ((BYTE)(context)->Ebx)
#define BH_reg(context) ((BYTE)((context)->Ebx >> 8))
#define CL_reg(context) ((BYTE)(context)->Ecx)
#define CH_reg(context) ((BYTE)((context)->Ecx >> 8))
#define DL_reg(context) ((BYTE)(context)->Edx)
#define DH_reg(context) ((BYTE)((context)->Edx >> 8))
#define SET_CFLAG(context) ((context)->EFlags |= 0x0001)
#define RESET_CFLAG(context) ((context)->EFlags &= ~0x0001)
#define SET_ZFLAG(context) ((context)->EFlags |= 0x0040)
#define RESET_ZFLAG(context) ((context)->EFlags &= ~0x0040)
#define ISV86(context) ((context)->EFlags & 0x00020000)
#define SET_AX(context,val) ((context)->Eax = ((context)->Eax & ~0xffff) | (WORD)(val))
#define SET_BX(context,val) ((context)->Ebx = ((context)->Ebx & ~0xffff) | (WORD)(val))
#define SET_CX(context,val) ((context)->Ecx = ((context)->Ecx & ~0xffff) | (WORD)(val))
#define SET_DX(context,val) ((context)->Edx = ((context)->Edx & ~0xffff) | (WORD)(val))
#define SET_SI(context,val) ((context)->Esi = ((context)->Esi & ~0xffff) | (WORD)(val))
#define SET_DI(context,val) ((context)->Edi = ((context)->Edi & ~0xffff) | (WORD)(val))
#define SET_AL(context,val) ((context)->Eax = ((context)->Eax & ~0xff) | (BYTE)(val))
#define SET_BL(context,val) ((context)->Ebx = ((context)->Ebx & ~0xff) | (BYTE)(val))
#define SET_CL(context,val) ((context)->Ecx = ((context)->Ecx & ~0xff) | (BYTE)(val))
#define SET_DL(context,val) ((context)->Edx = ((context)->Edx & ~0xff) | (BYTE)(val))
#define SET_AH(context,val) ((context)->Eax = ((context)->Eax & ~0xff00) | (((BYTE)(val)) << 8))
#define SET_BH(context,val) ((context)->Ebx = ((context)->Ebx & ~0xff00) | (((BYTE)(val)) << 8))
#define SET_CH(context,val) ((context)->Ecx = ((context)->Ecx & ~0xff00) | (((BYTE)(val)) << 8))
#define SET_DH(context,val) ((context)->Edx = ((context)->Edx & ~0xff00) | (((BYTE)(val)) << 8))
#endif /* __WINE_MISCEMU_H */
......@@ -1084,32 +1084,6 @@ typedef CONTEXT *PCONTEXT;
#ifdef __WINE__
/* Macros for easier access to i386 context registers */
#define AX_reg(context) (*(WORD*)&(context)->Eax)
#define BX_reg(context) (*(WORD*)&(context)->Ebx)
#define CX_reg(context) (*(WORD*)&(context)->Ecx)
#define DX_reg(context) (*(WORD*)&(context)->Edx)
#define SI_reg(context) (*(WORD*)&(context)->Esi)
#define DI_reg(context) (*(WORD*)&(context)->Edi)
#define BP_reg(context) (*(WORD*)&(context)->Ebp)
#define AL_reg(context) (*(BYTE*)&(context)->Eax)
#define AH_reg(context) (*((BYTE*)&(context)->Eax + 1))
#define BL_reg(context) (*(BYTE*)&(context)->Ebx)
#define BH_reg(context) (*((BYTE*)&(context)->Ebx + 1))
#define CL_reg(context) (*(BYTE*)&(context)->Ecx)
#define CH_reg(context) (*((BYTE*)&(context)->Ecx + 1))
#define DL_reg(context) (*(BYTE*)&(context)->Edx)
#define DH_reg(context) (*((BYTE*)&(context)->Edx + 1))
#define SET_CFLAG(context) ((context)->EFlags |= 0x0001)
#define RESET_CFLAG(context) ((context)->EFlags &= ~0x0001)
#define SET_ZFLAG(context) ((context)->EFlags |= 0x0040)
#define RESET_ZFLAG(context) ((context)->EFlags &= ~0x0040)
#define ISV86(context) ((context)->EFlags & 0x00020000)
/* Macros to retrieve the current context */
#ifdef __i386__
......
......@@ -1135,7 +1135,7 @@ void WINAPI SwitchStackBack16( CONTEXT86 *context )
/* Pop bp from the previous stack */
BP_reg(context) = *(WORD *)MapSL(pData->old_ss_sp);
context->Ebp = (context->Ebp & ~0xffff) | *(WORD *)MapSL(pData->old_ss_sp);
pData->old_ss_sp += sizeof(WORD);
/* Switch back to the old stack */
......
......@@ -169,8 +169,7 @@ static void call_timer_proc16( WORD timer )
context.Eip = OFFSETOF( proc );
context.Ebp = OFFSETOF( NtCurrentTeb()->cur_stack )
+ (WORD)&((STACK16FRAME*)0)->bp;
AX_reg( &context ) = timer;
context.Eax = timer;
wine_call_to_16_regs_short( &context, 0 );
}
......@@ -247,4 +246,3 @@ void WINAPI Restore80x87State16( const char *ptr )
__asm__(".byte 0x66; frstor %0" : : "m" (ptr) );
#endif
}
......@@ -91,8 +91,6 @@ WORD DOSMEM_xms_seg;
WORD DOSMEM_dpmi_seg;
WORD DOSMEM_dpmi_sel;
DWORD DOS_LOLSeg;
/***********************************************************************
* DOSMEM_MemoryTop
*
......
......@@ -344,8 +344,8 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
}
else
{
CX_reg(context) = HIWORD(W32S_WINE2APP(dw));
DX_reg(context) = LOWORD(W32S_WINE2APP(dw));
SET_CX( context, HIWORD(W32S_WINE2APP(dw)) );
SET_DX( context, LOWORD(W32S_WINE2APP(dw)) );
}
break;
......@@ -373,9 +373,9 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
case 0x000a: /* Allocate selector alias */
TRACE("allocate selector alias (0x%04x)\n",BX_reg(context));
if (!(AX_reg(context) = AllocCStoDSAlias16( BX_reg(context) )))
if (!SET_AX( context, AllocCStoDSAlias16( BX_reg(context) )))
{
AX_reg(context) = 0x8011; /* descriptor unavailable */
SET_AX( context, 0x8011 ); /* descriptor unavailable */
SET_CFLAG(context);
}
break;
......@@ -401,18 +401,18 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
case 0x000d: /* Allocate specific LDT descriptor */
FIXME("allocate descriptor (0x%04x), stub!\n",BX_reg(context));
AX_reg(context) = 0x8011; /* descriptor unavailable */
SET_AX( context, 0x8011 ); /* descriptor unavailable */
SET_CFLAG(context);
break;
case 0x0100: /* Allocate DOS memory block */
TRACE("allocate DOS memory block (0x%x paragraphs)\n",BX_reg(context));
dw = GlobalDOSAlloc16((DWORD)BX_reg(context)<<4);
if (dw) {
AX_reg(context) = HIWORD(dw);
DX_reg(context) = LOWORD(dw);
SET_AX( context, HIWORD(dw) );
SET_DX( context, LOWORD(dw) );
} else {
AX_reg(context) = 0x0008; /* insufficient memory */
BX_reg(context) = DOSMEM_Available()>>4;
SET_AX( context, 0x0008 ); /* insufficient memory */
SET_BX( context, DOSMEM_Available()>>4 );
SET_CFLAG(context);
}
break;
......@@ -420,7 +420,7 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
TRACE("free DOS memory block (0x%04x)\n",DX_reg(context));
dw = GlobalDOSFree16(DX_reg(context));
if (!dw) {
AX_reg(context) = 0x0009; /* memory block address invalid */
SET_AX( context, 0x0009 ); /* memory block address invalid */
SET_CFLAG(context);
}
break;
......@@ -436,8 +436,8 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
case 0x0204: /* Get protected mode interrupt vector */
TRACE("get protected mode interrupt handler (0x%02x), stub!\n",BL_reg(context));
dw = (DWORD)INT_GetPMHandler( BL_reg(context) );
CX_reg(context) = HIWORD(dw);
DX_reg(context) = LOWORD(dw);
SET_CX( context, HIWORD(dw) );
SET_DX( context, LOWORD(dw) );
break;
case 0x0205: /* Set protected mode interrupt vector */
......@@ -470,23 +470,23 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
case 0x0305: /* Get State Save/Restore Addresses */
TRACE("get state save/restore addresses\n");
/* we probably won't need this kind of state saving */
AX_reg(context) = 0;
SET_AX( context, 0 );
/* real mode: just point to the lret */
BX_reg(context) = DOSMEM_wrap_seg;
SET_BX( context, DOSMEM_wrap_seg );
context->Ecx = 2;
/* protected mode: don't have any handler yet... */
FIXME("no protected-mode dummy state save/restore handler yet\n");
SI_reg(context) = 0;
SET_SI( context, 0 );
context->Edi = 0;
break;
case 0x0306: /* Get Raw Mode Switch Addresses */
TRACE("get raw mode switch addresses\n");
/* real mode, point to standard DPMI return wrapper */
BX_reg(context) = DOSMEM_wrap_seg;
SET_BX( context, DOSMEM_wrap_seg );
context->Ecx = 0;
/* protected mode, point to DPMI call wrapper */
SI_reg(context) = DOSMEM_dpmi_sel;
SET_SI( context, DOSMEM_dpmi_sel );
context->Edi = 8; /* offset of the INT 0x31 call */
break;
case 0x0400: /* Get DPMI version */
......@@ -495,10 +495,10 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
SYSTEM_INFO si;
GetSystemInfo(&si);
AX_reg(context) = 0x005a; /* DPMI version 0.90 */
BX_reg(context) = 0x0005; /* Flags: 32-bit, virtual memory */
CL_reg(context) = si.wProcessorLevel;
DX_reg(context) = 0x0102; /* Master/slave interrupt controller base*/
SET_AX( context, 0x005a ); /* DPMI version 0.90 */
SET_BX( context, 0x0005 ); /* Flags: 32-bit, virtual memory */
SET_CL( context, si.wProcessorLevel );
SET_DX( context, 0x0102 ); /* Master/slave interrupt controller base*/
break;
}
case 0x0500: /* Get free memory information */
......@@ -519,11 +519,13 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
TRACE("allocate memory block (%ld)\n",MAKELONG(CX_reg(context),BX_reg(context)));
if (!(ptr = (BYTE *)DPMI_xalloc(MAKELONG(CX_reg(context), BX_reg(context)))))
{
AX_reg(context) = 0x8012; /* linear memory not available */
SET_AX( context, 0x8012 ); /* linear memory not available */
SET_CFLAG(context);
} else {
BX_reg(context) = SI_reg(context) = HIWORD(W32S_WINE2APP(ptr));
CX_reg(context) = DI_reg(context) = LOWORD(W32S_WINE2APP(ptr));
SET_BX( context, HIWORD(W32S_WINE2APP(ptr)) );
SET_CX( context, LOWORD(W32S_WINE2APP(ptr)) );
SET_SI( context, HIWORD(W32S_WINE2APP(ptr)) );
SET_DI( context, LOWORD(W32S_WINE2APP(ptr)) );
}
break;
......@@ -541,11 +543,13 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
(void *)W32S_APP2WINE(MAKELONG(DI_reg(context),SI_reg(context))),
MAKELONG(CX_reg(context),BX_reg(context)))))
{
AX_reg(context) = 0x8012; /* linear memory not available */
SET_AX( context, 0x8012 ); /* linear memory not available */
SET_CFLAG(context);
} else {
BX_reg(context) = SI_reg(context) = HIWORD(W32S_WINE2APP(ptr));
CX_reg(context) = DI_reg(context) = LOWORD(W32S_WINE2APP(ptr));
SET_BX( context, HIWORD(W32S_WINE2APP(ptr)) );
SET_CX( context, LOWORD(W32S_WINE2APP(ptr)) );
SET_SI( context, HIWORD(W32S_WINE2APP(ptr)) );
SET_DI( context, LOWORD(W32S_WINE2APP(ptr)) );
}
break;
......@@ -571,8 +575,8 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
case 0x0604: /* Get page size */
TRACE("get pagesize\n");
BX_reg(context) = 0;
CX_reg(context) = getpagesize();
SET_BX( context, 0 );
SET_CX( context, getpagesize() );
break;
case 0x0702: /* Mark page as demand-paging candidate */
......@@ -587,20 +591,20 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
FIXME("map real to linear (0x%08lx)\n",MAKELONG(CX_reg(context),BX_reg(context)));
if(!(ptr=DOSMEM_MapRealToLinear(MAKELONG(CX_reg(context),BX_reg(context)))))
{
AX_reg(context) = 0x8021;
SET_AX( context, 0x8021 );
SET_CFLAG(context);
}
else
{
BX_reg(context) = HIWORD(W32S_WINE2APP(ptr));
CX_reg(context) = LOWORD(W32S_WINE2APP(ptr));
SET_BX( context, HIWORD(W32S_WINE2APP(ptr)) );
SET_CX( context, LOWORD(W32S_WINE2APP(ptr)) );
RESET_CFLAG(context);
}
break;
default:
INT_BARF( context, 0x31 );
AX_reg(context) = 0x8001; /* unsupported function */
SET_AX( context, 0x8001 ); /* unsupported function */
SET_CFLAG(context);
break;
}
......
......@@ -98,6 +98,5 @@ void WINAPI INT_Int11Handler( CONTEXT86 *context )
if (parallelports > 3) /* 2 bits -- maximum value = 3 */
parallelports=3;
AX_reg(context) = (diskdrives << 6) | (serialports << 9) |
(parallelports << 14) | 0x02;
SET_AX( context, (diskdrives << 6) | (serialports << 9) | (parallelports << 14) | 0x02 );
}
......@@ -11,5 +11,5 @@
*/
void WINAPI INT_Int12Handler( CONTEXT86 *context )
{
AX_reg(context) = 640;
SET_AX( context, 640 );
}
......@@ -41,13 +41,13 @@ void WINAPI INT_Int15Handler( CONTEXT86 *context )
switch(DX_reg(context))
{
case 0x0: /* read joystick switches */
AL_reg(context) = 0x0; /* all switches open */
SET_AL( 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;
SET_AX( context, 0x0 );
SET_BX( context, 0x0 );
SET_CX( context, 0x0 );
SET_DX( context, 0x0 );
break;
default:
INT_BARF( context, 0x15 );
......@@ -59,7 +59,7 @@ void WINAPI INT_Int15Handler( CONTEXT86 *context )
break;
case 0x88: /* get size of memory above 1 M */
AX_reg(context) = 64; /* FIXME: are 64K ok? */
SET_AX( context, 64 ); /* FIXME: are 64K ok? */
RESET_CFLAG(context);
break;
......@@ -68,8 +68,8 @@ void WINAPI INT_Int15Handler( CONTEXT86 *context )
context->SegEs = 0xf000;
else
context->SegEs = DOSMEM_BiosSysSeg;
BX_reg(context) = 0xe6f5;
AH_reg(context) = 0x0;
SET_BX( context, 0xe6f5 );
SET_AH( context, 0x0 );
RESET_CFLAG(context);
break;
case 0xc2:
......@@ -89,16 +89,16 @@ void WINAPI INT_Int15Handler( CONTEXT86 *context )
INT_BARF( context, 0x15 );
break;
}
AH_reg(context) = 0x00; /* successful */
SET_AH( context, 0x00 ); /* successful */
break;
case 0x02: /* Set Sampling Rate */
/* BH = sampling rate */
FIXME("Set Sampling Rate - not implemented\n");
AH_reg(context) = 0x00; /* successful */
SET_AH( 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?*/
SET_BH( context, 0x01 );/*Device id FIXME what is it supposed to be?*/
break;
default:
INT_BARF( context, 0x15 );
......
......@@ -75,9 +75,9 @@ void WINAPI INT_Int1aHandler( CONTEXT86 *context )
{
case 0x00:
ticks = INT1A_GetTicksSinceMidnight();
CX_reg(context) = HIWORD(ticks);
DX_reg(context) = LOWORD(ticks);
AX_reg(context) = 0; /* No midnight rollover */
SET_CX( context, HIWORD(ticks) );
SET_DX( context, LOWORD(ticks) );
SET_AX( context, 0 ); /* No midnight rollover */
TRACE("int1a: AH=00 -- ticks=%ld\n", ticks);
break;
......@@ -85,17 +85,17 @@ void WINAPI INT_Int1aHandler( CONTEXT86 *context )
ltime = time(NULL);
bdtime = localtime(&ltime);
CX_reg(context) = (BIN_TO_BCD(bdtime->tm_hour)<<8) |
BIN_TO_BCD(bdtime->tm_min);
DX_reg(context) = (BIN_TO_BCD(bdtime->tm_sec)<<8);
SET_CX( context, (BIN_TO_BCD(bdtime->tm_hour)<<8) |
BIN_TO_BCD(bdtime->tm_min) );
SET_DX( context, (BIN_TO_BCD(bdtime->tm_sec)<<8) );
case 0x04:
ltime = time(NULL);
bdtime = localtime(&ltime);
CX_reg(context) = (BIN_TO_BCD(bdtime->tm_year/100)<<8) |
BIN_TO_BCD((bdtime->tm_year-1900)%100);
DX_reg(context) = (BIN_TO_BCD(bdtime->tm_mon)<<8) |
BIN_TO_BCD(bdtime->tm_mday);
SET_CX( context, (BIN_TO_BCD(bdtime->tm_year/100)<<8) |
BIN_TO_BCD((bdtime->tm_year-1900)%100) );
SET_DX( context, (BIN_TO_BCD(bdtime->tm_mon)<<8) |
BIN_TO_BCD(bdtime->tm_mday) );
break;
/* setting the time,date or RTC is not allow -EB */
......
......@@ -47,7 +47,7 @@ void WINAPI INT_Int25Handler( CONTEXT86 *context )
if (!DRIVE_IsValid(LOBYTE(context->Eax)))
{
SET_CFLAG(context);
AX_reg(context) = 0x0201; /* unknown unit */
SET_AX( context, 0x0201 ); /* unknown unit */
return;
}
......@@ -70,4 +70,3 @@ void WINAPI INT_Int25Handler( CONTEXT86 *context )
DRIVE_RawRead(LOBYTE(context->Eax), begin, length, dataptr, TRUE);
RESET_CFLAG(context);
}
......@@ -45,7 +45,7 @@ void WINAPI INT_Int26Handler( CONTEXT86 *context )
if (!DRIVE_IsValid(LOBYTE(context->Eax)))
{
SET_CFLAG(context);
AX_reg(context) = 0x0201; /* unknown unit */
SET_AX( context, 0x0201 ); /* unknown unit */
return;
}
......
......@@ -53,7 +53,7 @@ void WINAPI INT_Int2fHandler( CONTEXT86 *context )
switch(AH_reg(context))
{
case 0x10:
AL_reg(context) = 0xff; /* share is installed */
SET_AL( context, 0xff ); /* share is installed */
break;
case 0x11: /* Network Redirector / IFSFUNC */
......@@ -93,7 +93,7 @@ void WINAPI INT_Int2fHandler( CONTEXT86 *context )
case 0x04:
case 0x06:
context->SegEs = 0x0001;
DI_reg(context) = 0x0000;
SET_DI( context, 0x0000 );
break;
case 0x08:
FIXME("No real-mode handler for errors yet! (bye!)\n");
......@@ -125,12 +125,12 @@ void WINAPI INT_Int2fHandler( CONTEXT86 *context )
{
case 0x00: /* XMS v2+ installation check */
WARN("XMS is not fully implemented\n");
AL_reg(context) = 0x80;
SET_AL( context, 0x80 );
break;
case 0x10: /* XMS v2+ get driver address */
{
context->SegEs = DOSMEM_xms_seg;
BX_reg(context) = 0;
SET_BX( context, 0 );
break;
}
default:
......@@ -138,7 +138,7 @@ void WINAPI INT_Int2fHandler( CONTEXT86 *context )
}
#else
FIXME("check for XMS (not supported)\n");
AL_reg(context) = 0x42; /* != 0x80 */
SET_AL( context, 0x42 ); /* != 0x80 */
#endif
break;
......@@ -194,7 +194,7 @@ void WINAPI INT_Int2fHandler( CONTEXT86 *context )
switch(LOBYTE(context->Eax))
{
case 0x01: /* check if redirected drive */
AL_reg(context) = 0; /* not redirected */
SET_AL( context, 0 ); /* not redirected */
break;
default:
INT_BARF( context, 0x2f );
......@@ -204,7 +204,7 @@ void WINAPI INT_Int2fHandler( CONTEXT86 *context )
switch (LOBYTE(context->Eax))
{
case 0x0: /* Low-level Netware installation check AL=0 not installed.*/
AL_reg(context) = 0;
SET_AL( context, 0 );
break;
case 0x20: /* Get VLM Call Address */
/* return nothing -> NetWare not installed */
......@@ -215,7 +215,7 @@ void WINAPI INT_Int2fHandler( CONTEXT86 *context )
}
break;
case 0xb7: /* append */
AL_reg(context) = 0; /* not installed */
SET_AL( context, 0 ); /* not installed */
break;
case 0xb8: /* network */
switch (LOBYTE(context->Eax))
......@@ -229,7 +229,7 @@ void WINAPI INT_Int2fHandler( CONTEXT86 *context )
}
break;
case 0xbd: /* some Novell network install check ??? */
AX_reg(context) = 0xa5a5; /* pretend to have Novell IPX installed */
SET_AX( context, 0xa5a5 ); /* pretend to have Novell IPX installed */
break;
case 0xbf: /* REDIRIFS.EXE */
switch (LOBYTE(context->Eax))
......@@ -298,15 +298,13 @@ static void do_int2f_16( CONTEXT86 *context )
switch(LOBYTE(context->Eax))
{
case 0x00: /* Windows enhanced mode installation check */
AX_reg(context) = (GetWinFlags16() & WF_ENHANCED) ?
LOWORD(GetVersion16()) : 0;
SET_AX( context, (GetWinFlags16() & WF_ENHANCED) ? LOWORD(GetVersion16()) : 0 );
break;
case 0x0a: /* Get Windows version and type */
AX_reg(context) = 0;
BX_reg(context) = (LOWORD(GetVersion16()) << 8) |
(LOWORD(GetVersion16()) >> 8);
CX_reg(context) = (GetWinFlags16() & WF_ENHANCED) ? 3 : 2;
SET_AX( context, 0 );
SET_BX( context, (LOWORD(GetVersion16()) << 8) | (LOWORD(GetVersion16()) >> 8) );
SET_CX( context, (GetWinFlags16() & WF_ENHANCED) ? 3 : 2 );
break;
case 0x0b: /* Identify Windows-aware TSRs */
......@@ -331,7 +329,7 @@ static void do_int2f_16( CONTEXT86 *context )
* *doesn't* use 100% CPU...
*/
Sleep(55); /* just wait 55ms (one "timer tick") for now. */
AL_reg(context) = 0;
SET_AL( context, 0 );
break;
case 0x81: /* Begin critical section. */
......@@ -348,7 +346,7 @@ static void do_int2f_16( CONTEXT86 *context )
* According to Ralf Brown's Interrupt List, never return 0. But it
* seems to work okay (returning 0), just to be sure we return 1.
*/
BX_reg(context) = 1; /* VM 1 is probably the System VM */
SET_BX( context, 1 ); /* VM 1 is probably the System VM */
break;
case 0x84: /* Get device API entry point */
......@@ -359,25 +357,25 @@ static void do_int2f_16( CONTEXT86 *context )
if (!addr) /* not supported */
ERR("Accessing unknown VxD %04x - Expect a failure now.\n", BX_reg(context) );
context->SegEs = SELECTOROF(addr);
DI_reg(context) = OFFSETOF(addr);
SET_DI( context, OFFSETOF(addr) );
}
break;
case 0x86: /* DPMI detect mode */
AX_reg(context) = 0; /* Running under DPMI */
SET_AX( context, 0 ); /* Running under DPMI */
break;
case 0x87: /* DPMI installation check */
{
SYSTEM_INFO si;
GetSystemInfo(&si);
AX_reg(context) = 0x0000; /* DPMI Installed */
BX_reg(context) = 0x0001; /* 32bits available */
CL_reg(context) = si.wProcessorLevel;
DX_reg(context) = 0x005a; /* DPMI major/minor 0.90 */
SI_reg(context) = 0; /* # of para. of DOS extended private data */
SET_AX( context, 0x0000 ); /* DPMI Installed */
SET_BX( context, 0x0001 ); /* 32bits available */
SET_CL( context, si.wProcessorLevel );
SET_DX( context, 0x005a ); /* DPMI major/minor 0.90 */
SET_SI( context, 0 ); /* # of para. of DOS extended private data */
context->SegEs = DOSMEM_dpmi_seg;
DI_reg(context) = 0; /* ES:DI is DPMI switch entry point */
SET_DI( context, 0 ); /* ES:DI is DPMI switch entry point */
break;
}
case 0x8a: /* DPMI get vendor-specific API entry point. */
......@@ -477,17 +475,17 @@ static void MSCDEX_Handler(CONTEXT86* context)
}
}
TRACE("Installation check: %d cdroms, starting at %d\n", count, drive);
BX_reg(context) = count;
CX_reg(context) = (drive < 26) ? drive : 0;
SET_BX( context, count );
SET_CX( context, (drive < 26) ? drive : 0 );
break;
case 0x0B: /* drive check */
AX_reg(context) = is_cdrom(CX_reg(context));
BX_reg(context) = 0xADAD;
SET_AX( context, is_cdrom(CX_reg(context)) );
SET_BX( context, 0xADAD );
break;
case 0x0C: /* get version */
BX_reg(context) = 0x020a;
SET_BX( context, 0x020a );
TRACE("Version number => %04x\n", BX_reg(context));
break;
......
......@@ -20,7 +20,7 @@ void WINAPI INT_Int4bHandler( CONTEXT86 *context )
if(AL_reg(context) != 0x02) /* if not install check */
{
SET_CFLAG(context);
AL_reg(context) = 0x0f; /* function is not implemented */
SET_AL( context, 0x0f ); /* function is not implemented */
}
break;
default:
......
......@@ -35,6 +35,6 @@ void WINAPI NetBIOSCall16( CONTEXT86 *context )
BYTE* ptr;
ptr = MapSL( MAKESEGPTR(context->SegEs,BX_reg(context)) );
FIXME("(%p): command code %02x (ignored)\n",context, *ptr);
AL_reg(context) = *(ptr+0x01) = 0xFB; /* NetBIOS emulator not found */
*(ptr+0x01) = 0xFB; /* NetBIOS emulator not found */
SET_AL( context, 0xFB );
}
......@@ -72,13 +72,13 @@ void WINAPI VXD_VMM ( CONTEXT86 *context )
switch(service)
{
case 0x0000: /* version */
AX_reg(context) = VXD_WinVersion();
SET_AX( context, VXD_WinVersion() );
RESET_CFLAG(context);
break;
case 0x026d: /* Get_Debug_Flag '/m' */
case 0x026e: /* Get_Debug_Flag '/n' */
AL_reg(context) = 0;
SET_AL( context, 0 );
RESET_CFLAG(context);
break;
......@@ -102,13 +102,13 @@ void WINAPI VXD_PageFile( CONTEXT86 *context )
{
case 0x00: /* get version, is this windows version? */
TRACE("returning version\n");
AX_reg(context) = VXD_WinVersion();
SET_AX( context, VXD_WinVersion() );
RESET_CFLAG(context);
break;
case 0x01: /* get swap file info */
TRACE("VxD PageFile: returning swap file info\n");
AX_reg(context) = 0x00; /* paging disabled */
SET_AX( context, 0x00 ); /* paging disabled */
context->Ecx = 0; /* maximum size of paging file */
/* FIXME: do I touch DS:SI or DS:DI? */
RESET_CFLAG(context);
......@@ -145,7 +145,7 @@ void WINAPI VXD_Reboot ( CONTEXT86 *context )
switch(service)
{
case 0x0000: /* version */
AX_reg(context) = VXD_WinVersion();
SET_AX( context, VXD_WinVersion() );
RESET_CFLAG(context);
break;
......@@ -166,7 +166,7 @@ void WINAPI VXD_VDD ( CONTEXT86 *context )
switch(service)
{
case 0x0000: /* version */
AX_reg(context) = VXD_WinVersion();
SET_AX( context, VXD_WinVersion() );
RESET_CFLAG(context);
break;
......@@ -187,7 +187,7 @@ void WINAPI VXD_VMD ( CONTEXT86 *context )
switch(service)
{
case 0x0000: /* version */
AX_reg(context) = VXD_WinVersion();
SET_AX( context, VXD_WinVersion() );
RESET_CFLAG(context);
break;
......@@ -209,8 +209,8 @@ void WINAPI VXD_VXDLoader( CONTEXT86 *context )
{
case 0x0000: /* get version */
TRACE("returning version\n");
AX_reg(context) = 0x0000;
DX_reg(context) = VXD_WinVersion();
SET_AX( context, 0x0000 );
SET_DX( context, VXD_WinVersion() );
RESET_CFLAG(context);
break;
......@@ -218,21 +218,21 @@ void WINAPI VXD_VXDLoader( CONTEXT86 *context )
FIXME("load device %04lx:%04x (%s)\n",
context->SegDs, DX_reg(context),
debugstr_a(MapSL(MAKESEGPTR(context->SegDs, DX_reg(context)))));
AX_reg(context) = 0x0000;
SET_AX( context, 0x0000 );
context->SegEs = 0x0000;
DI_reg(context) = 0x0000;
SET_DI( context, 0x0000 );
RESET_CFLAG(context);
break;
case 0x0002: /* unload device */
FIXME("unload device (%08lx)\n", context->Ebx);
AX_reg(context) = 0x0000;
SET_AX( context, 0x0000 );
RESET_CFLAG(context);
break;
default:
VXD_BARF( context, "VXDLDR" );
AX_reg(context) = 0x000B; /* invalid function number */
SET_AX( context, 0x000B ); /* invalid function number */
SET_CFLAG(context);
break;
}
......@@ -251,7 +251,7 @@ void WINAPI VXD_Shell( CONTEXT86 *context )
{
case 0x0000:
TRACE("returning version\n");
AX_reg(context) = VXD_WinVersion();
SET_AX( context, VXD_WinVersion() );
context->Ebx = 1; /* system VM Handle */
break;
......@@ -310,7 +310,7 @@ void WINAPI VXD_Shell( CONTEXT86 *context )
/* the new Win95 shell API */
case 0x0100: /* get version */
AX_reg(context) = VXD_WinVersion();
SET_AX( context, VXD_WinVersion() );
break;
case 0x0104: /* retrieve Hook_Properties list */
......@@ -344,7 +344,7 @@ void WINAPI VXD_Comm( CONTEXT86 *context )
{
case 0x0000: /* get version */
TRACE("returning version\n");
AX_reg(context) = VXD_WinVersion();
SET_AX( context, VXD_WinVersion() );
RESET_CFLAG(context);
break;
......@@ -368,7 +368,7 @@ void WINAPI VXD_Timer( CONTEXT86 *context )
switch(service)
{
case 0x0000: /* version */
AX_reg(context) = VXD_WinVersion();
SET_AX( context, VXD_WinVersion() );
RESET_CFLAG(context);
break;
......@@ -404,7 +404,7 @@ void WINAPI VXD_TimerAPI ( CONTEXT86 *context )
switch(service)
{
case 0x0000: /* version */
AX_reg(context) = VXD_WinVersion();
SET_AX( context, VXD_WinVersion() );
RESET_CFLAG(context);
break;
......@@ -415,7 +415,7 @@ void WINAPI VXD_TimerAPI ( CONTEXT86 *context )
CreateSystemTimer( 55, System_Time_Tick );
}
AX_reg(context) = System_Time_Selector;
SET_AX( context, System_Time_Selector );
RESET_CFLAG(context);
break;
......@@ -436,7 +436,7 @@ void WINAPI VXD_ConfigMG ( CONTEXT86 *context )
switch(service)
{
case 0x0000: /* version */
AX_reg(context) = VXD_WinVersion();
SET_AX( context, VXD_WinVersion() );
RESET_CFLAG(context);
break;
......@@ -457,7 +457,7 @@ void WINAPI VXD_Enable ( CONTEXT86 *context )
switch(service)
{
case 0x0000: /* version */
AX_reg(context) = VXD_WinVersion();
SET_AX( context, VXD_WinVersion() );
RESET_CFLAG(context);
break;
......@@ -478,7 +478,7 @@ void WINAPI VXD_APM ( CONTEXT86 *context )
switch(service)
{
case 0x0000: /* version */
AX_reg(context) = VXD_WinVersion();
SET_AX( context, VXD_WinVersion() );
RESET_CFLAG(context);
break;
......
......@@ -1080,8 +1080,8 @@ static DWORD VxDCall_VWin32( DWORD service, CONTEXT86 *context )
TRACE("Int31/DPMI dispatch(%08lx)\n", callnum);
AX_reg(context) = callnum;
CX_reg(context) = parm;
SET_AX( context, callnum );
SET_CX( context, parm );
INT_Int31Handler(context);
return LOWORD(context->Eax);
......
......@@ -369,11 +369,11 @@ void WINAPI keybd_event16( CONTEXT86 *context )
{
DWORD dwFlags = 0;
if (AH_reg(context) & 0x80) dwFlags |= KEYEVENTF_KEYUP;
if (BH_reg(context) & 1 ) dwFlags |= KEYEVENTF_EXTENDEDKEY;
if (HIBYTE(context->Eax) & 0x80) dwFlags |= KEYEVENTF_KEYUP;
if (HIBYTE(context->Ebx) & 0x01) dwFlags |= KEYEVENTF_EXTENDEDKEY;
keybd_event( AL_reg(context), BL_reg(context),
dwFlags, MAKELONG(SI_reg(context), DI_reg(context)) );
keybd_event( LOBYTE(context->Eax), LOBYTE(context->Ebx),
dwFlags, MAKELONG(LOWORD(context->Esi), LOWORD(context->Edi)) );
}
......@@ -401,8 +401,8 @@ void WINAPI mouse_event( DWORD dwFlags, DWORD dx, DWORD dy,
*/
void WINAPI mouse_event16( CONTEXT86 *context )
{
mouse_event( AX_reg(context), BX_reg(context), CX_reg(context),
DX_reg(context), MAKELONG(SI_reg(context), DI_reg(context)) );
mouse_event( LOWORD(context->Eax), LOWORD(context->Ebx), LOWORD(context->Ecx),
LOWORD(context->Edx), MAKELONG(context->Esi, context->Edi) );
}
/***********************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment