static void TANDY_FindMode(void) {
	if (vga.tandy.mode_control & 0x2) {
		if (vga.tandy.gfx_control & 0x10) VGA_SetMode(M_TANDY16);
		else if (vga.tandy.gfx_control & 0x08) VGA_SetMode(M_TANDY4);
		else if (vga.tandy.mode_control & 0x10) VGA_SetMode(M_TANDY2);
		else VGA_SetMode(M_TANDY4);
		write_color_select(vga.tandy.color_select);
	} else {
		VGA_SetMode(M_TANDY_TEXT);
	}
}
static void write_mode_control(Bit8u val) {
	/* Check if someone changes the blinking/hi intensity bit */
	vga.tandy.mode_control=val;
	VGA_SetBlinking((val & 0x20));
	if (val & 0x2) {
		if (val & 0x10) {
		} else VGA_SetMode(M_CGA4);
		write_color_select(vga.tandy.color_select);	//Setup the correct palette
	} else {
		VGA_SetMode(M_TEXT);
	}
}
Exemple #3
0
void DetermineMode_PVGA1A() {
	// Close replica from the base implementation. It will stay here
	// until I figure a way to either distinguish M_VGA and M_LIN8 or
	// merge them.
	if (vga.attr.mode_control & 1) {
		if (vga.gfx.mode & 0x40) VGA_SetMode((pvga1a.biosMode<=0x13)?M_VGA:M_LIN8);
		else if (vga.gfx.mode & 0x20) VGA_SetMode(M_CGA4);
		else if ((vga.gfx.miscellaneous & 0x0c)==0x0c) VGA_SetMode(M_CGA2);
		else VGA_SetMode((pvga1a.biosMode<=0x13)?M_EGA:M_LIN4);
	} else {
		VGA_SetMode(M_TEXT);
	}
}
static void PCJr_FindMode(void) {
	if (vga.tandy.mode_control & 0x2) {
		if (vga.tandy.mode_control & 0x10) {
			/* bit4 of mode control 1 signals 16 colour graphics mode */
			VGA_SetMode(M_TANDY16);
		} else if (vga.tandy.gfx_control & 0x08) {
			/* bit3 of mode control 2 signals 2 colour graphics mode */
			VGA_SetMode(M_TANDY2);
		} else {
			/* otherwise some 4-colour graphics mode */
			VGA_SetMode(M_TANDY4);
		}
		write_color_select(vga.tandy.color_select);
	} else {
		VGA_SetMode(M_TANDY_TEXT);
	}
}
static void write_hercules(Bitu port,Bitu val,Bitu iolen) {
	switch (port) {
	case 0x3b8: {
		// the protected bits can always be cleared but only be set if the 
		// protection bits are set
		if (vga.herc.mode_control&0x2) {
			// already set
			if (!(val&0x2)) {
				vga.herc.mode_control &= ~0x2;
				VGA_SetMode(M_HERC_TEXT);
			}
		} else {
			// not set, can only set if protection bit is set
			if ((val & 0x2) && (vga.herc.enable_bits & 0x1)) {
				vga.herc.mode_control |= 0x2;
				VGA_SetMode(M_HERC_GFX);
			}
		}
		if (vga.herc.mode_control&0x80) {
			if (!(val&0x80)) {
				vga.herc.mode_control &= ~0x80;
				vga.tandy.draw_base = &vga.mem.linear[0];
			}
		} else {
			if ((val & 0x80) && (vga.herc.enable_bits & 0x2)) {
				vga.herc.mode_control |= 0x80;
				vga.tandy.draw_base = &vga.mem.linear[32*1024];
			}
		}
		vga.draw.blinking = (val&0x20)!=0;
		vga.herc.mode_control &= 0x82;
		vga.herc.mode_control |= val & ~0x82;
		break;
		}
	case 0x3bf:
		vga.herc.enable_bits=val;
		break;
	}
}
static void write_hercules(Bitu port,Bitu val,Bitu iolen) {
	switch (port) {
	case 0x3b8:
		if (vga.herc.enable_bits & 1) {
			vga.herc.mode_control&=~0x2;
			vga.herc.mode_control|=(val&0x2);
			if (val & 0x2) {
				VGA_SetMode(M_HERC_GFX);
			} else {
				VGA_SetMode(M_HERC_TEXT);
			}
		}
		if ((vga.herc.enable_bits & 0x2) && ((vga.herc.mode_control ^ val)&0x80)) {
			vga.herc.mode_control^=0x80;
			VGA_SetupHandlers();
		}
		break;
	case 0x3bf:
		vga.herc.enable_bits=val;
		break;
	}
}
static void write_cga(Bitu port,Bitu val,Bitu iolen) {
	switch (port) {
	case 0x3d8:
		vga.tandy.mode_control=val;
		if (vga.tandy.mode_control & 0x2) {
			if (vga.tandy.mode_control & 0x10) {
				if (!(val & 0x4) && machine==MCH_CGA) {
					VGA_SetMode(M_CGA16);		//Video burst 16 160x200 color mode
				} else {
					VGA_SetMode(M_TANDY2);
				}
			} else VGA_SetMode(M_TANDY4);
			write_color_select(vga.tandy.color_select);
		} else {
			VGA_SetMode(M_TANDY_TEXT);
		}
		VGA_SetBlinking(val & 0x20);
		break;
	case 0x3d9:
		write_color_select(val);
		break;
	}
}
Exemple #8
0
static WORD DISPDIB_Begin(WORD wFlags)
{
    unsigned Xres,Yres,Depth;

    switch(wFlags&DISPLAYDIB_MODE) {
        case DISPLAYDIB_MODE_DEFAULT:
            /* FIXME: is this supposed to autodetect? */
        case DISPLAYDIB_MODE_320x200x8:
            Xres=320; Yres=200; Depth=8; break;
        case DISPLAYDIB_MODE_320x240x8:
            Xres=320; Yres=240; Depth=8; break;
        default:
            return DISPLAYDIB_NOTSUPPORTED;
    }
    /* more or less dummy calls to Death/Resurrection, for completeness */
    /* FIXME: what arguments should they get? */
    Death16(0);
    if (VGA_SetMode(Xres,Yres,Depth)) {
         Resurrection16(0,0,0,0,0,0,0);
         return DISPLAYDIB_NOTSUPPORTED;
    }
    return DISPLAYDIB_NOERROR;
}
Exemple #9
0
/**********************************************************************
 *         INT10_SetVideoMode
 *
 * Change current video mode to any VGA or VESA mode.
 * Returns TRUE if mode is supported.
 *
 * Mode bitfields:
 * 0-6: .. Mode number (combined with bit 8).
 *   7: =0 Clear screen.
 *      =1 Preserve display memory on mode change (VGA modes).
 *   8: =0 VGA mode.
 *      =1 VESA mode.
 *   9: .. Reserved, must be zero.
 *  10: .. Reserved, must be zero.
 *  11: =0 Use default refresh rate.
 *      =1 Use user specified refresh rate.
 *  12: .. Reserved, must be zero.
 *  13: .. Reserved, must be zero.
 *  14: =0 Use windowed frame buffer model.
 *      =1 Use linear frame buffer model.
 *  15: =0 Clear screen.
 *      =1 Preserve display memory on mode change (VESA modes).
 */
static BOOL INT10_SetVideoMode( BIOSDATA *data, WORD mode )
{
    const VGA_MODE *ptr = VGA_GetModeInfo( mode );
    INT10_HEAP *heap = INT10_GetHeap();
    BOOL clearScreen = TRUE;

    if (!ptr)
        return FALSE;

    /*
     * Linear framebuffer is not supported.
     * FIXME - not sure this is valid since mode 19 is 256 color & linear
     *   of course only 1 window is addressable.
     */
    if (mode & 0x4000)
        return FALSE;

    /*
     * Check for VGA and VESA preserve video memory flag.
     */
    if ((mode & 0x0080) || (mode & 0x8000))
        clearScreen = FALSE;

    /*
     * Note that we do not mask out flags here on purpose.
     */
    heap->VesaCurrentMode = mode;
    if (mode <= 0xff)
        data->VideoMode = mode;
    else
        data->VideoMode = 0;

    if (ptr->ModeType == TEXT)
    {
        /* Text mode. */
        TRACE( "Setting %s %dx%d text mode (screen %s)\n", 
               IS_VESA_MODE(mode) ? "VESA" : "VGA", 
               ptr->TextCols, ptr->TextRows,
               clearScreen ? "cleared" : "preserved" );

        /*
         * FIXME: We should check here if alpha mode could be set.
         */
        VGA_SetAlphaMode( ptr->TextCols, ptr->TextRows );

        data->VideoColumns = ptr->TextCols;
        data->RowsOnScreenMinus1 = ptr->TextRows - 1;

        if (clearScreen)
        {            
            VGA_ClearText( 0, 0, ptr->TextCols-1, ptr->TextRows-1, 0x07 );
            INT10_SetCursorPos( data, 0, 0, 0 );
            VGA_SetCursorPos( 0, 0 );            
        }
    }
    else
    {
        /* Graphics mode. */
        TRACE( "Setting %s %dx%dx%d graphics mode (screen %s)\n", 
               IS_VESA_MODE(mode) ? "VESA" : "VGA", 
               ptr->Width, ptr->Height, ptr->Depth,
               clearScreen ? "cleared" : "preserved" );

        if ( VGA_SetMode(mode) )
            return FALSE;
    }

    return TRUE;
}