📄 vid_1200.c
字号:
else
{
/* CLIPPING ON LEFT */
/* Adjust initial read for scale, checking for divide by zero */
xstart = hadjust;
initread = -x;
if (gfx_vid_dstw)
initread = ((-x) * gfx_vid_srcw) / gfx_vid_dstw;
else initread = 0;
}
/* CLIPPING ON RIGHT */
xend = x + w;
if (xend > gfx_get_hactive()) xend = gfx_get_hactive();
xend += hadjust;
/* CLIPPING ON TOP */
offset = gfx_vid_offset;
if (y >= 0)
{
ystart = y + vadjust;
}
else
{
ystart = vadjust;
line_size = (READ_VID32(SC1200_VIDEO_CONFIG) >> 7) & 0x000001FE;
if (READ_VID32(SC1200_VIDEO_CONFIG) & SC1200_VCFG_LINE_SIZE_UPPER)
line_size += 512;
if (gfx_vid_dsth)
offset = gfx_vid_offset + (line_size << 1) *
(((-y) * gfx_vid_srch) / gfx_vid_dsth);
}
/* CLIPPING ON BOTTOM */
yend = y + h;
if (yend >= gfx_get_vactive()) yend = gfx_get_vactive();
yend += vadjust;
/* SET VIDEO BUFFER OFFSET IN DISPLAY CONTROLLER */
/* Use private routine to abstract the display controller. */
gfx_set_display_video_offset(offset);
/* DISABLE REGISTER UPDATES */
vcfg = READ_VID32(SC1200_VIDEO_CONFIG);
vcfg &= ~SC1200_VCFG_VID_REG_UPDATE;
WRITE_VID32(SC1200_VIDEO_CONFIG, vcfg);
/* SET VIDEO POSITION */
WRITE_VID32(SC1200_VIDEO_X_POS, (xend << 16) | xstart);
WRITE_VID32(SC1200_VIDEO_Y_POS, (yend << 16) | ystart);
/* SET INITIAL READ ADDRESS AND ENABLE REGISTER UPDATES */
vcfg &= ~SC1200_VCFG_INIT_READ_MASK;
vcfg |= (initread << 15) & SC1200_VCFG_INIT_READ_MASK;
vcfg |= SC1200_VCFG_VID_REG_UPDATE;
WRITE_VID32(SC1200_VIDEO_CONFIG, vcfg);
return(0);
}
/*---------------------------------------------------------------------------
* gfx_set_video_color_key
*
* This routine specifies the color key value and mask for the video overlay
* hardware. To disable color key, the color and mask should both be set to
* zero. The hardware uses the color key in the following equation:
*
* ((source data) & (color key mask)) == ((color key) & (color key mask))
*
* The source data can be either graphics data or video data. The bluescreen
* parameter is set to have the hardware compare video data and clear to
* comapare graphics data.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int sc1200_set_video_color_key(unsigned long key, unsigned long mask,
int graphics)
#else
int gfx_set_video_color_key(unsigned long key, unsigned long mask,
int graphics)
#endif
{
unsigned long dcfg = 0;
/* SET SC1200 COLOR KEY VALUE */
WRITE_VID32(SC1200_VIDEO_COLOR_KEY, key);
WRITE_VID32(SC1200_VIDEO_COLOR_MASK, mask);
/* SAVE COLOR KEY VALUE */
/* Needed to restore values if window disabled then enabled again. */
sc1200_color_key = key;
sc1200_color_mask = mask;
/* SELECT GRAPHICS OR VIDEO DATA TO COMPARE TO THE COLOR KEY */
dcfg = READ_VID32(SC1200_DISPLAY_CONFIG);
if (graphics & 0x01) dcfg &= ~SC1200_DCFG_VG_CK;
else dcfg |= SC1200_DCFG_VG_CK;
WRITE_VID32(SC1200_DISPLAY_CONFIG, dcfg);
return(0);
}
/*---------------------------------------------------------------------------
* gfx_set_video_filter
*
* This routine enables or disables the video overlay filters.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int sc1200_set_video_filter(int xfilter, int yfilter)
#else
int gfx_set_video_filter(int xfilter, int yfilter)
#endif
{
unsigned long vcfg = 0;
/* ENABLE OR DISABLE SC1200 VIDEO OVERLAY FILTERS */
vcfg = READ_VID32(SC1200_VIDEO_CONFIG);
vcfg &= ~(SC1200_VCFG_X_FILTER_EN | SC1200_VCFG_Y_FILTER_EN);
if (xfilter) vcfg |= SC1200_VCFG_X_FILTER_EN;
if (yfilter) vcfg |= SC1200_VCFG_Y_FILTER_EN;
WRITE_VID32(SC1200_VIDEO_CONFIG, vcfg);
return(0);
}
/*---------------------------------------------------------------------------
* gfx_set_video_palette
*
* This routine loads the video hardware palette. If a NULL pointer is
* specified, the palette is bypassed (for SC1200, this means loading the
* palette with identity values).
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int sc1200_set_video_palette(unsigned long *palette)
#else
int gfx_set_video_palette(unsigned long *palette)
#endif
{
unsigned long i, entry;
/* LOAD SC1200 VIDEO PALETTE */
WRITE_VID32(SC1200_PALETTE_ADDRESS, 0);
for (i = 0; i < 256; i++)
{
if (palette) entry = palette[i];
else entry = i | (i << 8) | (i << 16);
WRITE_VID32(SC1200_PALETTE_DATA, entry);
}
return(0);
}
/*---------------------------------------------------------------------------
* gfx_set_alpha_enable
*
* This routine enables or disables the currently selected alpha region.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int sc1200_set_alpha_enable(int enable)
#else
int gfx_set_alpha_enable(int enable)
#endif
{
unsigned long address = 0, value = 0;
if (gfx_alpha_select > 2) return(GFX_STATUS_UNSUPPORTED);
/* SAVE ALPHA ENABLE */
/* Used to restore state on a video disable/enable combination. */
sc1200_alpha_enable[gfx_alpha_select] = enable;
address = SC1200_ALPHA_CONTROL_1 + (gfx_alpha_select << 4);
value = READ_VID32(address);
if (enable) value |= SC1200_ACTRL_WIN_ENABLE;
else value &= ~(SC1200_ACTRL_WIN_ENABLE);
WRITE_VID32(address, value);
return(GFX_STATUS_OK);
}
/*---------------------------------------------------------------------------
* gfx_set_alpha_size
*
* This routine sets the size of the currently selected alpha region.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int sc1200_set_alpha_size(unsigned short x, unsigned short y,
unsigned short width, unsigned short height)
#else
int gfx_set_alpha_size(unsigned short x, unsigned short y,
unsigned short width, unsigned short height)
#endif
{
unsigned long address = 0;
/* ADJUST POSITIONS */
x += gfx_get_htotal() - gfx_get_hsync_end() - 2;
y += gfx_get_vtotal() - gfx_get_vsync_end() + 1;
if (gfx_alpha_select > 2) return(GFX_STATUS_UNSUPPORTED);
address = SC1200_ALPHA_XPOS_1 + (gfx_alpha_select << 4);
WRITE_VID32(address, (unsigned long) x |
((unsigned long) (x + width) << 16));
WRITE_VID32(address + 4, (unsigned long) y |
((unsigned long) (y + height) << 16));
return(GFX_STATUS_OK);
}
/*---------------------------------------------------------------------------
* gfx_set_alpha_value
*
* This routine sets the alpha value for the currently selected alpha
* region. It also specifies an increment/decrement value for fading.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int sc1200_set_alpha_value(unsigned char alpha, char delta)
#else
int gfx_set_alpha_value(unsigned char alpha, char delta)
#endif
{
unsigned long address = 0, value = 0;
if (gfx_alpha_select > 2) return(GFX_STATUS_UNSUPPORTED);
address = SC1200_ALPHA_CONTROL_1 + (gfx_alpha_select << 4);
value = READ_VID32(address);
value &= SC1200_ACTRL_WIN_ENABLE; /* keep only enable bit */
value |= (unsigned long) alpha;
value |= ((unsigned long) delta) << 8;
value |= SC1200_ACTRL_LOAD_ALPHA;
WRITE_VID32(address, value);
return(GFX_STATUS_OK);
}
/*---------------------------------------------------------------------------
* gfx_set_alpha_priority
*
* This routine sets the priority of the currently selected alpha region.
* A higher value indicates a higher priority.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int sc1200_set_alpha_priority(int priority)
#else
int gfx_set_alpha_priority(int priority)
#endif
{
unsigned long pos = 0, value = 0;
if (priority > 3) return(GFX_STATUS_BAD_PARAMETER);
if (gfx_alpha_select > 2) return(GFX_STATUS_UNSUPPORTED);
value = READ_VID32(SC1200_VID_ALPHA_CONTROL);
pos = 16 + (gfx_alpha_select << 1);
value &= ~(0x03 << pos);
value |= priority << pos;
WRITE_VID32(SC1200_VID_ALPHA_CONTROL, value);
return(GFX_STATUS_OK);
}
/*---------------------------------------------------------------------------
* gfx_set_alpha_color
*
* This routine sets the color register for the currently selected alpha
* region. Bit 24 is set to enable the color register.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int sc1200_set_alpha_color(unsigned long color)
#else
int gfx_set_alpha_color(unsigned long color)
#endif
{
unsigned long address = 0;
if (gfx_alpha_select > 2) return(GFX_STATUS_UNSUPPORTED);
address = SC1200_ALPHA_COLOR_1 + (gfx_alpha_select << 4);
WRITE_VID32(address, color);
return(GFX_STATUS_OK);
}
/*************************************************************/
/* READ ROUTINES | INCLUDED FOR DIAGNOSTIC PURPOSES ONLY */
/*************************************************************/
#if GFX_READ_ROUTINES
/*---------------------------------------------------------------------------
* gfx_get_sync_polarities
*
* This routine returns the polarities of the sync pulses:
* Bit 0: Set if negative horizontal polarity.
* Bit 1: Set if negative vertical polarity.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int sc1200_get_sync_polarities(void)
#else
int gfx_get_sync_polarities(void)
#endif
{
int polarities = 0;
if (READ_VID32(SC1200_DISPLAY_CONFIG) & 0x00000100) polarities |= 1;
if (READ_VID32(SC1200_DISPLAY_CONFIG) & 0x00000200) polarities |= 2;
return(polarities);
}
/*-----------------------------------------------------------------------------
* gfx_get_video_enable
*
* This routine returns the value "one" if video overlay is currently enabled,
* otherwise it returns the value "zero".
*-----------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int sc1200_get_video_enable(void)
#else
int gfx_get_video_enable(void)
#endif
{
if (READ_VID32(SC1200_VIDEO_CONFIG) & SC1200_VCFG_VID_EN) return(1);
return(0);
}
/*-----------------------------------------------------------------------------
* gfx_get_video_format
*
* This routine returns the current video overlay format.
*-----------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int sc1200_get_video_format(void)
#else
int gfx_get_video_format(void)
#endif
{
unsigned long vcfg;
vcfg = READ_VID32(SC1200_VIDEO_CONFIG);
if (vcfg & SC1200_VCFG_CSC_BYPASS) return(4);
else return((vcfg >> 2) & 3);
}
/*-----------------------------------------------------------------------------
* gfx_get_video_src_size
*
* This routine returns the size of the source video overlay buffer. The
* return value is (height << 16) | width.
*-----------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
unsigned long sc1200_get_video_src_size(void)
#else
unsigned long gfx_get_video_src_size(void)
#endif
{
unsigned long width = 0, height = 0;
/* DETERMINE SOURCE WIDTH FROM THE SC1200 VIDEO LINE SIZE */
width = (READ_VID32(SC1200_VIDEO_CONFIG) >> 7) & 0x000001FE;
if (READ_VID32(SC1200_VIDEO_CONFIG) & SC1200_VCFG_LINE_SIZE_UPPER)
width += 512;
if (width)
{
/* DETERMINE HEIGHT BY DIVIDING TOTAL SIZE BY WIDTH */
/* Get total size from display controller - abtracted. */
height = gfx_get_display_video_size() / (width << 1);
}
return((height << 16) | width);
}
/*-----------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -