Пример #1
0
ibool VBEAPI VBE_setBytesPerLine(int bytesPerLine,int *newBytes,
    int *newPixels,int *maxScanlines)
/****************************************************************************
*
* Function:     VBE_setBytesPerLine
* Parameters:   pixelsPerLine   - Pixels per scanline
*               newBytes        - Storage for bytes per line value set
*               newPixels       - Storage for pixels per line value set
*               maxScanLines    - Storage for maximum number of scanlines
* Returns:      True on success, false on failure
*
* Description:  Sets the scanline length for the video mode to the specified
*               number of bytes per scanline (valid for VBE 2.0 only).
*
****************************************************************************/
{
    RMREGS  regs;

    regs.x.ax = 0x4F06;
    regs.h.bl = 2;
    regs.x.cx = bytesPerLine;
    PM_int86(0x10,&regs,&regs);
    *newBytes = regs.x.bx;
    *newPixels = regs.x.cx;
    *maxScanlines = regs.x.dx;
    return regs.x.ax == VBE_SUCCESS;
}
Пример #2
0
int VBEAPI VBE_getDisplayStartStatus(void)
/****************************************************************************
*
* Function:     VBE_getDisplayStartStatus
* Returns:      0 if last flip not occurred, 1 if already flipped
*               -1 if not supported
*
* Description:  Returns the status of the previous display start request.
*               If this function is supported the programmer can implement
*               hardware triple buffering using this function.
*
*               NOTE: Requires VBE/Core 3.0
*
****************************************************************************/
{
    RMREGS  regs;

    if (state->VBEVersion >= 0x300) {
	regs.x.ax = 0x4F07;
	regs.x.bx = 0x0004;
	PM_int86(0x10,&regs,&regs);
	if (regs.x.ax == VBE_SUCCESS)
	    return (regs.x.cx != 0);
	}
    return -1;
}
Пример #3
0
ibool VBEAPI VBE_setStereoDisplayStart(ulong leftAddr,ulong rightAddr,
    ibool waitVRT)
/****************************************************************************
*
* Function:     VBE_setStereoDisplayStart
* Parameters:   leftAddr    - 32-bit start address for left image
*               rightAddr   - 32-bit start address for right image
*               waitVRT     - True to wait for vertical retrace, false if not
* Returns:      True if function was successful, false if not supported.
*
* Description:  Sets the new starting display position to the specified
*               32-bit display start address. Note that this function is
*               different the the version above, since it takes a 32-bit
*               byte offset in video memory as the starting address which
*               gives the programmer maximum control over the stat address.
*
*               NOTE: Requires VBE/Core 3.0
*
****************************************************************************/
{
    RMREGS  regs;

    if (state->VBEVersion >= 0x300) {
	regs.x.ax = 0x4F07;
	regs.x.bx = waitVRT ? 0x83 : 0x03;
	regs.e.ecx = leftAddr;
	regs.e.edx = rightAddr;
	PM_int86(0x10,&regs,&regs);
	return regs.x.ax == VBE_SUCCESS;
	}
    return false;
}
Пример #4
0
/****************************************************************************
REMARKS:
Call the VBE/Core software interrupt to change display banks.
****************************************************************************/
void PMAPI PM_setBankAB(
    int bank)
{
    RMREGS  regs;

    /* TODO: This does a bank switch function by calling the real mode */
    /*       VESA BIOS. If you do not support BIOS access, this function should */
    /*       be empty. */
    regs.x.ax = 0x4F05;
    regs.x.bx = 0x0000;
    regs.x.dx = bank;
    PM_int86(0x10,&regs,&regs);
    regs.x.ax = 0x4F05;
    regs.x.bx = 0x0001;
    regs.x.dx = bank;
    PM_int86(0x10,&regs,&regs);
}
Пример #5
0
void PMAPI PM_restoreMouseHandler(void)
{
    RMREGS  regs;

    if (_PM_mouseHandler) {
	regs.x.ax = 33;
	PM_int86(0x33, &regs, &regs);
	_PM_mouseHandler = NULL;
	}
}
Пример #6
0
void PMAPI PM_resetMouseDriver(int hardReset)
{
    RMREGS          regs;
    PM_mouseHandler oldHandler = _PM_mouseHandler;

    PM_restoreMouseHandler();
    regs.x.ax = hardReset ? 0 : 33;
    PM_int86(0x33, &regs, &regs);
    if (oldHandler)
	PM_setMouseHandler(_PM_mouseMask, oldHandler);
}
Пример #7
0
ibool VBEAPI VBE_setBytesPerLine(int bytesPerLine,int *newBytes,
    int *newPixels,int *maxScanlines)
/****************************************************************************
*
* Function:     VBE_setBytesPerLine
* Parameters:   pixelsPerLine   - Pixels per scanline
*               newBytes        - Storage for bytes per line value set
*               newPixels       - Storage for pixels per line value set
*               maxScanLines    - Storage for maximum number of scanlines
* Returns:      True on success, false on failure
*
* Description:  Sets the scanline length for the video mode to the specified
*               number of bytes per scanline (valid for VBE 2.0 only).
*
****************************************************************************/
{
    RMREGS  regs;

    regs.x.ax = 0x4F06;
    regs.h.bl = 2;
    regs.x.cx = bytesPerLine;
    PM_int86(0x10,&regs,&regs);

    /* This function is buggy on some implementations and returns with smaller
       than requested value for no good reason; trying to set larger scanline
       length may come up with what we originally wanted. Or it may not.  */
    if (regs.x.bx < bytesPerLine) {
        int i = 1;
        while ((regs.x.bx < bytesPerLine) && (regs.x.ax == VBE_SUCCESS) && (i < 256)) {
            regs.x.ax = 0x4F06;
            regs.h.bl = 2;
            regs.x.cx = bytesPerLine + i++;
            PM_int86(0x10,&regs,&regs);
            }
        }

    *newBytes = regs.x.bx;
    *newPixels = regs.x.cx;
    *maxScanlines = regs.x.dx;
    return regs.x.ax == VBE_SUCCESS;
}
Пример #8
0
void PMAPI PM_restoreMouseHandler(void)
{
    RMREGS  regs;

    if (_PM_mouseHandler) {
	regs.x.ax = 33;
	PM_int86(0x33, &regs, &regs);
	PM_freeRealSeg(mousePtr);
	_DPMI_freeCallback(mouseRMCB);
	_PM_mouseHandler = NULL;
	}
}
Пример #9
0
ibool VBEAPI VBE_setVideoModeExt(int mode,VBE_CRTCInfo *crtc)
/****************************************************************************
*
* Function:     VBE_setVideoModeExt
* Parameters:   mode    - SuperVGA video mode to set.
* Returns:      True if the mode was set, false if not.
*
* Description:  Attempts to set the specified video mode. This version
*               includes support for the VBE/Core 3.0 refresh rate control
*               mechanism.
*
****************************************************************************/
{
    RMREGS  regs;

    if (state->VBEVersion < 0x200 && mode < 0x100) {
	/* Some VBE implementations barf terribly if you try to set non-VBE
	 * video modes with the VBE set mode call. VBE 2.0 implementations
	 * must be able to handle this.
	 */
	regs.h.al = (ushort)mode;
	regs.h.ah = 0;
	PM_int86(0x10,&regs,&regs);
	}
    else {
	if (state->VBEVersion < 0x300 && (mode & vbeRefreshCtrl))
	    return false;
	regs.x.ax = 0x4F02;
	regs.x.bx = (ushort)mode;
	if ((mode & vbeRefreshCtrl) && crtc)
	    VBE_callESDI(&regs, crtc, sizeof(*crtc));
	else
	    PM_int86(0x10,&regs,&regs);
	if (regs.x.ax != VBE_SUCCESS)
	    return false;
	}
    return true;
}
Пример #10
0
int VBEAPI VBE_getVideoMode(void)
/****************************************************************************
*
* Function:     VBE_getVideoMode
* Returns:      Current video mode
*
****************************************************************************/
{
    RMREGS  regs;

    regs.x.ax = 0x4F03;
    PM_int86(0x10,&regs,&regs);
    if (regs.x.ax != VBE_SUCCESS)
	return -1;
    return regs.x.bx;
}
Пример #11
0
/****************************************************************************
REMARKS:
Call the VBE/Core software interrupt to change display start address.
****************************************************************************/
void PMAPI PM_setCRTStart(
    int x,
    int y,
    int waitVRT)
{
    RMREGS  regs;

    /* TODO: This changes the display start address by calling the real mode */
    /*       VESA BIOS. If you do not support BIOS access, this function */
    /*       should be empty. */
    regs.x.ax = 0x4F07;
    regs.x.bx = waitVRT;
    regs.x.cx = x;
    regs.x.dx = y;
    PM_int86(0x10,&regs,&regs);
}
Пример #12
0
ibool VBEAPI VBE_setDACWidth(int width)
/****************************************************************************
*
* Function:     VBE_setDACWidth
* Parameters:   width   - Width to set the DAC to
* Returns:      True on success, false on failure
*
****************************************************************************/
{
    RMREGS  regs;

    regs.x.ax = 0x4F08;
    regs.h.bl = 0x00;
    regs.h.bh = width;
    PM_int86(0x10,&regs,&regs);
    return regs.x.ax == VBE_SUCCESS;
}
Пример #13
0
int VBEAPI VBE_getDACWidth(void)
/****************************************************************************
*
* Function:     VBE_getDACWidth
* Returns:      Current width of the palette DAC
*
****************************************************************************/
{
    RMREGS  regs;

    regs.x.ax = 0x4F08;
    regs.h.bl = 0x01;
    PM_int86(0x10,&regs,&regs);
    if (regs.x.ax != VBE_SUCCESS)
	return -1;
    return regs.h.bh;
}
Пример #14
0
/****************************************************************************
PARAMETERS:
mask        - Event mask
butstate    - Button state
x           - Mouse x coordinate
y           - Mouse y coordinate

REMARKS:
Mouse event handling routine. This gets called when a mouse event occurs,
and we call the addMouseEvent() routine to add the appropriate mouse event
to the event queue.

Note: Interrupts are ON when this routine is called by the mouse driver code.
****************************************************************************/
static void EVTAPI mouseISR(
	uint mask,
	uint butstate,
	int x,
	int y,
	int mickeyX,
	int mickeyY)
{
	RMREGS	regs;
	uint	ps;

	if (mask & 1) {
		/* Save the current mouse coordinates */
		_EVT_mx = x; _EVT_my = y;

		/* Call mouse function 11 to clear the motion counters */
		regs.x.ax = 11;
		PM_int86(0x33,&regs,&regs);
		mickeyX = (short)regs.x.cx;
		mickeyY = (short)regs.x.dx;

		/* If the last event was a movement event, then modify the last
		 * event rather than post a new one, so that the queue will not
		 * become saturated. Before we modify the data structures, we
		 * MUST ensure that interrupts are off.
		 */
		ps = _EVT_disableInt();
		if (oldMove != -1) {
			evtq[oldMove].where_x = x;  		/* Modify existing one  */
			evtq[oldMove].where_y = y;
			evtq[oldMove].relative_x += mickeyX;
			evtq[oldMove].relative_y += mickeyY;
			}
		else {
			oldMove = freeHead;			/* Save id of this move event	*/
			addMouseEvent(EVT_MOUSEMOVE,0,x,y,mickeyX,mickeyY,butstate);
			}
		_EVT_restoreInt(ps);
		}
	if (mask & 0x2A) {
		ps = _EVT_disableInt();
		addMouseEvent(EVT_MOUSEDOWN,mask >> 1,x,y,0,0,butstate);
		oldMove = -1;
		_EVT_restoreInt(ps);
		}
Пример #15
0
ibool VBEAPI VBE_getDisplayStart(int *x,int *y)
/****************************************************************************
*
* Function:     VBE_getDisplayStart
* Parameters:   x,y - Place to store starting address value
* Returns:      True if function was successful.
*
****************************************************************************/
{
    RMREGS  regs;

    regs.x.ax = 0x4F07;
    regs.x.bx = 0x01;
    PM_int86(0x10,&regs,&regs);
    *x = regs.x.cx;
    *y = regs.x.dx;
    return regs.x.ax == VBE_SUCCESS;
}
Пример #16
0
ibool VBEAPI VBE_setBank(int window,int bank)
/****************************************************************************
*
* Function:     VBE_setBank
* Parameters:   window  - Window to set
*               bank    - Bank number to set window to
* Returns:      True on success, false on failure.
*
****************************************************************************/
{
    RMREGS  regs;

    regs.x.ax = 0x4F05;
    regs.h.bh = 0;
    regs.h.bl = window;
    regs.x.dx = bank;
    PM_int86(0x10,&regs,&regs);
    return regs.x.ax == VBE_SUCCESS;
}
Пример #17
0
ibool VBEAPI VBE_getMaxScanlineLength(int *maxBytes,int *maxPixels)
/****************************************************************************
*
* Function:     VBE_getMaxScanlineLength
* Parameters:   maxBytes    - Maximum scanline width in bytes
*               maxPixels   - Maximum scanline width in pixels
* Returns:      True if successful, false if function failed
*
****************************************************************************/
{
    RMREGS  regs;

    regs.x.ax = 0x4F06;
    regs.h.bl = 3;
    PM_int86(0x10,&regs,&regs);
    *maxBytes = regs.x.bx;
    *maxPixels = regs.x.cx;
    return regs.x.ax == VBE_SUCCESS;
}
Пример #18
0
int VBEAPI VBE_getBank(int window)
/****************************************************************************
*
* Function:     VBE_setBank
* Parameters:   window  - Window to read
* Returns:      Bank number for the window (-1 on failure)
*
****************************************************************************/
{
    RMREGS  regs;

    regs.x.ax = 0x4F05;
    regs.h.bh = 1;
    regs.h.bl = window;
    PM_int86(0x10,&regs,&regs);
    if (regs.x.ax != VBE_SUCCESS)
	return -1;
    return regs.x.dx;
}
Пример #19
0
ibool VBEAPI VBE_getScanlineLength(int *bytesPerLine,int *pixelsPerLine,
    int *maxScanlines)
/****************************************************************************
*
* Function:     VBE_getScanlineLength
* Parameters:   bytesPerLine    - Storage for bytes per scanline
*               pixelsPerLine   - Storage for pixels per scanline
*               maxScanLines    - Storage for maximum number of scanlines
* Returns:      True on success, false on failure
*
****************************************************************************/
{
    RMREGS  regs;

    regs.x.ax = 0x4F06;
    regs.h.bl = 1;
    PM_int86(0x10,&regs,&regs);
    *bytesPerLine = regs.x.bx;
    *pixelsPerLine = regs.x.cx;
    *maxScanlines = regs.x.dx;
    return regs.x.ax == VBE_SUCCESS;
}
Пример #20
0
ulong VBEAPI VBE_getClosestClock(ushort mode,ulong pixelClock)
/****************************************************************************
*
* Function:     VBE_getClosestClock
* Parameters:   mode        - VBE mode to be used (include vbeLinearBuffer)
*               pixelClock  - Desired pixel clock
* Returns:      Closest pixel clock to desired clock (-1 if not supported)
*
* Description:  Calls the VBE/Core 3.0 interface to determine the closest
*               pixel clock to the requested value. The BIOS will always
*               search for a pixel clock that is no more than 1% below the
*               requested clock or somewhere higher than the clock. If the
*               clock is higher note that it may well be many Mhz higher
*               that requested and the application will have to check that
*               the returned value is suitable for it's needs. This function
*               returns the actual pixel clock that will be programmed by
*               the hardware.
*
*               Note that if the pixel clock will be used with a linear
*               framebuffer mode, make sure you pass in the linear
*               framebuffer flag to this function.
*
*               NOTE: Requires VBE/Core 3.0
*
****************************************************************************/
{
    RMREGS  regs;

    if (state->VBEVersion >= 0x300) {
	regs.x.ax = 0x4F0B;
	regs.h.bl = 0x00;
	regs.e.ecx = pixelClock;
	regs.x.dx = mode;
	PM_int86(0x10,&regs,&regs);
	if (regs.x.ax == VBE_SUCCESS)
	    return regs.e.ecx;
	}
    return -1;
}
Пример #21
0
ibool VBEAPI VBE_disableStereoMode(void)
/****************************************************************************
*
* Function:     VBE_disableStereoMode
* Returns:      True if stereo mode disabled, false if not supported.
*
* Description:  Puts the system back into normal, non-stereo display mode
*               after having stereo mode enabled.
*
*               NOTE: Requires VBE/Core 3.0
*
****************************************************************************/
{
    RMREGS  regs;

    if (state->VBEVersion >= 0x300) {
	regs.x.ax = 0x4F07;
	regs.x.bx = 0x0006;
	PM_int86(0x10,&regs,&regs);
	return regs.x.ax == VBE_SUCCESS;
	}
    return false;
}
Пример #22
0
ibool VBEAPI VBE_setDisplayStart(int x,int y,ibool waitVRT)
/****************************************************************************
*
* Function:     VBE_setDisplayStart
* Parameters:   x,y     - Position of the first pixel to display
*               waitVRT - True to wait for retrace, false if not
* Returns:      True if function was successful.
*
* Description:  Sets the new starting display position to implement
*               hardware scrolling.
*
****************************************************************************/
{
    RMREGS  regs;

    regs.x.ax = 0x4F07;
    if (waitVRT)
	regs.x.bx = 0x80;
    else regs.x.bx = 0x00;
    regs.x.cx = x;
    regs.x.dx = y;
    PM_int86(0x10,&regs,&regs);
    return regs.x.ax == VBE_SUCCESS;
}
Пример #23
0
ibool VBEAPI VBE_enableStereoMode(void)
/****************************************************************************
*
* Function:     VBE_enableStereoMode
* Returns:      True if stereo mode enabled, false if not supported.
*
* Description:  Puts the system into hardware stereo mode for LC shutter
*               glasses, where the display swaps between two display start
*               addresses every vertical retrace.
*
*               NOTE: Requires VBE/Core 3.0
*
****************************************************************************/
{
    RMREGS  regs;

    if (state->VBEVersion >= 0x300) {
	regs.x.ax = 0x4F07;
	regs.x.bx = 0x0005;
	PM_int86(0x10,&regs,&regs);
	return regs.x.ax == VBE_SUCCESS;
	}
    return false;
}