mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 16:08:04 +02:00
added a few sanity checks
made coding style a bit more consistent
This commit is contained in:
parent
885f10706a
commit
0676fc357a
7 changed files with 1699 additions and 1681 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -23,7 +23,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* DOS/DJGPP device driver v1.4 for Mesa
|
||||
* DOS/DJGPP device driver v1.5 for Mesa
|
||||
*
|
||||
* Copyright (C) 2002 - Borca Daniel
|
||||
* Email : dborca@yahoo.com
|
||||
|
|
@ -36,100 +36,99 @@
|
|||
#include "internal.h"
|
||||
|
||||
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(x, y) (((x)<(y))?(y):(x))
|
||||
#define MAX(x, y) (((x) < (y)) ? (y) : (x))
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* _create_linear_mapping:
|
||||
* Maps a physical address range into linear memory.
|
||||
*/
|
||||
int _create_linear_mapping (unsigned long *linear, unsigned long physaddr, int size)
|
||||
int
|
||||
_create_linear_mapping (unsigned long *linear, unsigned long physaddr, int size)
|
||||
{
|
||||
__dpmi_meminfo meminfo;
|
||||
__dpmi_meminfo meminfo;
|
||||
|
||||
if (physaddr >= 0x100000) {
|
||||
/* map into linear memory */
|
||||
meminfo.address = physaddr;
|
||||
meminfo.size = size;
|
||||
if (__dpmi_physical_address_mapping(&meminfo) != 0)
|
||||
return -1;
|
||||
if (physaddr >= 0x100000) {
|
||||
/* map into linear memory */
|
||||
meminfo.address = physaddr;
|
||||
meminfo.size = size;
|
||||
if (__dpmi_physical_address_mapping(&meminfo) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
*linear = meminfo.address;
|
||||
} else {
|
||||
/* exploit 1 -> 1 physical to linear mapping in low megabyte */
|
||||
*linear = physaddr;
|
||||
}
|
||||
*linear = meminfo.address;
|
||||
} else {
|
||||
/* exploit 1 -> 1 physical to linear mapping in low megabyte */
|
||||
*linear = physaddr;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* _remove_linear_mapping:
|
||||
* Frees the DPMI resources being used to map a linear address range.
|
||||
*/
|
||||
void _remove_linear_mapping (unsigned long *linear)
|
||||
void
|
||||
_remove_linear_mapping (unsigned long *linear)
|
||||
{
|
||||
__dpmi_meminfo meminfo;
|
||||
__dpmi_meminfo meminfo;
|
||||
|
||||
if (*linear) {
|
||||
if (*linear >= 0x100000) {
|
||||
meminfo.address = *linear;
|
||||
__dpmi_free_physical_address_mapping(&meminfo);
|
||||
}
|
||||
if (*linear) {
|
||||
if (*linear >= 0x100000) {
|
||||
meminfo.address = *linear;
|
||||
__dpmi_free_physical_address_mapping(&meminfo);
|
||||
}
|
||||
|
||||
*linear = 0;
|
||||
}
|
||||
*linear = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* _create_selector:
|
||||
* Allocates a selector to access a region of linear memory.
|
||||
*/
|
||||
int _create_selector (int *segment, unsigned long base, int size)
|
||||
int
|
||||
_create_selector (int *segment, unsigned long base, int size)
|
||||
{
|
||||
/* allocate an ldt descriptor */
|
||||
if ((*segment=__dpmi_allocate_ldt_descriptors(1)) < 0) {
|
||||
*segment = 0;
|
||||
return -1;
|
||||
}
|
||||
/* allocate an ldt descriptor */
|
||||
if ((*segment=__dpmi_allocate_ldt_descriptors(1)) < 0) {
|
||||
*segment = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* create the linear mapping */
|
||||
if (_create_linear_mapping(&base, base, size)) {
|
||||
__dpmi_free_ldt_descriptor(*segment);
|
||||
*segment = 0;
|
||||
return -1;
|
||||
}
|
||||
/* create the linear mapping */
|
||||
if (_create_linear_mapping(&base, base, size)) {
|
||||
__dpmi_free_ldt_descriptor(*segment);
|
||||
*segment = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* set the descriptor base and limit */
|
||||
__dpmi_set_segment_base_address(*segment, base);
|
||||
__dpmi_set_segment_limit(*segment, MAX(size-1, 0xFFFF));
|
||||
/* set the descriptor base and limit */
|
||||
__dpmi_set_segment_base_address(*segment, base);
|
||||
__dpmi_set_segment_limit(*segment, MAX(size-1, 0xFFFF));
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* _remove_selector:
|
||||
* Frees a DPMI segment selector.
|
||||
*/
|
||||
void _remove_selector (int *segment)
|
||||
void
|
||||
_remove_selector (int *segment)
|
||||
{
|
||||
if (*segment) {
|
||||
unsigned long base;
|
||||
__dpmi_get_segment_base_address(*segment, &base);
|
||||
_remove_linear_mapping(&base);
|
||||
__dpmi_free_ldt_descriptor(*segment);
|
||||
*segment = 0;
|
||||
}
|
||||
if (*segment) {
|
||||
unsigned long base;
|
||||
__dpmi_get_segment_base_address(*segment, &base);
|
||||
_remove_linear_mapping(&base);
|
||||
__dpmi_free_ldt_descriptor(*segment);
|
||||
*segment = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Desc: retrieve CPU MMX capability
|
||||
*
|
||||
* In : -
|
||||
|
|
@ -137,12 +136,31 @@ void _remove_selector (int *segment)
|
|||
*
|
||||
* Note: -
|
||||
*/
|
||||
int _can_mmx (void)
|
||||
int
|
||||
_can_mmx (void)
|
||||
{
|
||||
#ifdef USE_MMX_ASM
|
||||
extern int _mesa_x86_cpu_features;
|
||||
return (_mesa_x86_cpu_features & 0x00800000);
|
||||
static int x86_cpu_features = 0;
|
||||
__asm("\n\
|
||||
pushfl \n\
|
||||
popl %%eax \n\
|
||||
movl %%eax, %%ecx \n\
|
||||
xorl $0x200000, %%eax\n\
|
||||
pushl %%eax \n\
|
||||
popfl \n\
|
||||
pushfl \n\
|
||||
popl %%eax \n\
|
||||
pushl %%ecx \n\
|
||||
popfl \n\
|
||||
xorl %%ecx, %%eax \n\
|
||||
jz 0f \n\
|
||||
movl $1, %%eax \n\
|
||||
cpuid \n\
|
||||
movl %%edx, %0 \n\
|
||||
0: \n\
|
||||
":"=g"(x86_cpu_features)::"%eax", "%ebx", "%ecx", "%edx");
|
||||
return (x86_cpu_features & 0x00800000);
|
||||
#else
|
||||
return 0;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* DOS/DJGPP device driver v1.5 for Mesa
|
||||
* DOS/DJGPP device driver v1.6 for Mesa
|
||||
*
|
||||
* Copyright (C) 2002 - Borca Daniel
|
||||
* Email : dborca@users.sourceforge.net
|
||||
|
|
@ -36,6 +36,7 @@
|
|||
|
||||
#include "../main/mtypes.h"
|
||||
|
||||
|
||||
/*
|
||||
* general purpose defines, etc.
|
||||
*/
|
||||
|
|
@ -54,39 +55,36 @@ typedef unsigned long word32;
|
|||
#define _32_ *(word32 *)&
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* video mode structure
|
||||
*/
|
||||
typedef struct vl_mode {
|
||||
int xres, yres;
|
||||
int bpp;
|
||||
int xres, yres;
|
||||
int bpp;
|
||||
|
||||
int mode;
|
||||
int scanlen;
|
||||
int mode;
|
||||
int scanlen;
|
||||
|
||||
int sel;
|
||||
int gran;
|
||||
int sel;
|
||||
int gran;
|
||||
} vl_mode;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* video driver structure
|
||||
*/
|
||||
typedef struct {
|
||||
vl_mode *(*init) (void);
|
||||
int (*entermode) (vl_mode *p, int refresh);
|
||||
void (*blit) (void);
|
||||
void (*setCI_f) (int index, float red, float green, float blue);
|
||||
void (*setCI_i) (int index, int red, int green, int blue);
|
||||
int (*get) (int pname, int *params);
|
||||
void (*restore) (void);
|
||||
void (*fini) (void);
|
||||
vl_mode *(*init) (void);
|
||||
int (*entermode) (vl_mode *p, int refresh);
|
||||
void (*blit) (void);
|
||||
void (*setCI_f) (int index, float red, float green, float blue);
|
||||
void (*setCI_i) (int index, int red, int green, int blue);
|
||||
int (*get) (int pname, int *params);
|
||||
void (*restore) (void);
|
||||
void (*fini) (void);
|
||||
} vl_driver;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* memory mapping
|
||||
*/
|
||||
|
|
@ -95,11 +93,13 @@ void _remove_linear_mapping (unsigned long *linear);
|
|||
int _create_selector (int *segment, unsigned long base, int size);
|
||||
void _remove_selector (int *segment);
|
||||
|
||||
|
||||
/*
|
||||
* system routines
|
||||
*/
|
||||
int _can_mmx (void);
|
||||
|
||||
|
||||
/*
|
||||
* asm routines to deal with virtual buffering
|
||||
*/
|
||||
|
|
@ -127,4 +127,5 @@ extern void v_putpixel16 (unsigned int offset, int color);
|
|||
extern void v_putpixel24 (unsigned int offset, int color);
|
||||
extern void v_putpixel32 (unsigned int offset, int color);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* DOS/DJGPP device driver v1.6 for Mesa
|
||||
* DOS/DJGPP device driver v1.7 for Mesa
|
||||
*
|
||||
* Copyright (C) 2002 - Borca Daniel
|
||||
* Email : dborca@users.sourceforge.net
|
||||
|
|
@ -38,58 +38,57 @@
|
|||
#include "null.h"
|
||||
|
||||
|
||||
|
||||
static vl_mode *modes;
|
||||
|
||||
#define null_color_precision 8
|
||||
|
||||
|
||||
|
||||
|
||||
static void null_blit_nop (void)
|
||||
static void
|
||||
null_blit_nop (void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Desc: Attempts to detect VGA, check video modes and create selectors.
|
||||
/* Desc: Attempts to detect NUL, check video modes and create selectors.
|
||||
*
|
||||
* In : -
|
||||
* Out : mode array
|
||||
*
|
||||
* Note: -
|
||||
*/
|
||||
static vl_mode *null_init (void)
|
||||
static vl_mode *
|
||||
null_init (void)
|
||||
{
|
||||
static int m[][2] = {
|
||||
{320, 200},
|
||||
{320, 240},
|
||||
{400, 300},
|
||||
{512, 384},
|
||||
{640, 400},
|
||||
{640, 480},
|
||||
{800, 600},
|
||||
{1024, 768},
|
||||
{1280, 1024},
|
||||
{1600, 1200}
|
||||
};
|
||||
static int b[] = {
|
||||
8,
|
||||
15,
|
||||
16,
|
||||
24,
|
||||
32
|
||||
};
|
||||
static int m[][2] = {
|
||||
{ 320, 200 },
|
||||
{ 320, 240 },
|
||||
{ 400, 300 },
|
||||
{ 512, 384 },
|
||||
{ 640, 400 },
|
||||
{ 640, 480 },
|
||||
{ 800, 600 },
|
||||
{ 1024, 768 },
|
||||
{ 1280, 1024 },
|
||||
{ 1600, 1200 }
|
||||
};
|
||||
static int b[] = {
|
||||
8,
|
||||
15,
|
||||
16,
|
||||
24,
|
||||
32
|
||||
};
|
||||
const unsigned int m_count = sizeof(m) / sizeof(m[0]);
|
||||
const unsigned int b_count = sizeof(b) / sizeof(b[0]);
|
||||
|
||||
unsigned int i, j, k;
|
||||
unsigned int i, j, k;
|
||||
|
||||
if (modes == NULL) {
|
||||
modes = malloc(sizeof(vl_mode) *
|
||||
(1 + (sizeof(m) / sizeof(m[0]) * sizeof(b) / sizeof(b[0]))));
|
||||
if (modes == NULL) {
|
||||
modes = malloc(sizeof(vl_mode) * (1 + m_count * b_count));
|
||||
|
||||
if (modes != NULL) {
|
||||
for (k = 0, i = 0; i < sizeof(m) / sizeof(m[0]); i++) {
|
||||
for (j = 0; j < sizeof(b) / sizeof(b[0]); j++, k++) {
|
||||
if (modes != NULL) {
|
||||
for (k = 0, i = 0; i < m_count; i++) {
|
||||
for (j = 0; j < b_count; j++, k++) {
|
||||
modes[k].xres = m[i][0];
|
||||
modes[k].yres = m[i][1];
|
||||
modes[k].bpp = b[j];
|
||||
|
|
@ -97,36 +96,39 @@ static vl_mode *null_init (void)
|
|||
modes[k].scanlen = m[i][0] * ((b[j] + 7) / 8);
|
||||
modes[k].sel = -1;
|
||||
modes[k].gran = -1;
|
||||
}
|
||||
}
|
||||
modes[k].xres = -1;
|
||||
modes[k].yres = -1;
|
||||
modes[k].bpp = -1;
|
||||
modes[k].mode = 0xffff;
|
||||
modes[k].scanlen = -1;
|
||||
modes[k].sel = -1;
|
||||
modes[k].gran = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
modes[k].xres = -1;
|
||||
modes[k].yres = -1;
|
||||
modes[k].bpp = -1;
|
||||
modes[k].mode = 0xffff;
|
||||
modes[k].scanlen = -1;
|
||||
modes[k].sel = -1;
|
||||
modes[k].gran = -1;
|
||||
}
|
||||
}
|
||||
|
||||
return modes;
|
||||
return modes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Desc: Frees all resources allocated by VGA init code.
|
||||
/* Desc: Frees all resources allocated by NUL init code.
|
||||
*
|
||||
* In : -
|
||||
* Out : -
|
||||
*
|
||||
* Note: -
|
||||
*/
|
||||
static void null_fini (void)
|
||||
static void
|
||||
null_fini (void)
|
||||
{
|
||||
if (modes != NULL) {
|
||||
free(modes);
|
||||
modes = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Desc: Attempts to enter specified video mode.
|
||||
*
|
||||
* In : ptr to mode structure, refresh rate
|
||||
|
|
@ -134,17 +136,17 @@ static void null_fini (void)
|
|||
*
|
||||
* Note: -
|
||||
*/
|
||||
static int null_entermode (vl_mode *p, int refresh)
|
||||
static int
|
||||
null_entermode (vl_mode *p, int refresh)
|
||||
{
|
||||
NUL.blit = null_blit_nop;
|
||||
NUL.blit = null_blit_nop;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
(void)(p && refresh); /* silence compiler warning */
|
||||
(void)(p && refresh); /* silence compiler warning */
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Desc: Restores to the mode prior to first call to null_entermode.
|
||||
*
|
||||
* In : -
|
||||
|
|
@ -152,12 +154,12 @@ static int null_entermode (vl_mode *p, int refresh)
|
|||
*
|
||||
* Note: -
|
||||
*/
|
||||
static void null_restore (void)
|
||||
static void
|
||||
null_restore (void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Desc: set one palette entry
|
||||
*
|
||||
* In : color index, R, G, B
|
||||
|
|
@ -165,13 +167,13 @@ static void null_restore (void)
|
|||
*
|
||||
* Note: uses integer values
|
||||
*/
|
||||
static void null_setCI_i (int index, int red, int green, int blue)
|
||||
static void
|
||||
null_setCI_i (int index, int red, int green, int blue)
|
||||
{
|
||||
(void)(index && red && green && blue); /* silence compiler warning */
|
||||
(void)(index && red && green && blue); /* silence compiler warning */
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Desc: set one palette entry
|
||||
*
|
||||
* In : color index, R, G, B
|
||||
|
|
@ -179,15 +181,15 @@ static void null_setCI_i (int index, int red, int green, int blue)
|
|||
*
|
||||
* Note: uses normalized values
|
||||
*/
|
||||
static void null_setCI_f (int index, float red, float green, float blue)
|
||||
static void
|
||||
null_setCI_f (int index, float red, float green, float blue)
|
||||
{
|
||||
float max = (1 << null_color_precision) - 1;
|
||||
float max = (1 << null_color_precision) - 1;
|
||||
|
||||
null_setCI_i(index, (int)(red * max), (int)(green * max), (int)(blue * max));
|
||||
null_setCI_i(index, (int)(red * max), (int)(green * max), (int)(blue * max));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Desc: state retrieval
|
||||
*
|
||||
* In : parameter name, ptr to storage
|
||||
|
|
@ -195,28 +197,28 @@ static void null_setCI_f (int index, float red, float green, float blue)
|
|||
*
|
||||
* Note: -
|
||||
*/
|
||||
static int null_get (int pname, int *params)
|
||||
static int
|
||||
null_get (int pname, int *params)
|
||||
{
|
||||
switch (pname) {
|
||||
default:
|
||||
params[0] = params[0]; /* silence compiler warning */
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
switch (pname) {
|
||||
default:
|
||||
params[0] = params[0]; /* silence compiler warning */
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* the driver
|
||||
*/
|
||||
vl_driver NUL = {
|
||||
null_init,
|
||||
null_entermode,
|
||||
NULL,
|
||||
null_setCI_f,
|
||||
null_setCI_i,
|
||||
null_get,
|
||||
null_restore,
|
||||
null_fini
|
||||
null_init,
|
||||
null_entermode,
|
||||
NULL,
|
||||
null_setCI_f,
|
||||
null_setCI_i,
|
||||
null_get,
|
||||
null_restore,
|
||||
null_fini
|
||||
};
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* DOS/DJGPP device driver v1.5 for Mesa
|
||||
* DOS/DJGPP device driver v1.6 for Mesa
|
||||
*
|
||||
* Copyright (C) 2002 - Borca Daniel
|
||||
* Email : dborca@users.sourceforge.net
|
||||
|
|
@ -44,7 +44,6 @@
|
|||
#include "vesa.h"
|
||||
|
||||
|
||||
|
||||
static vl_mode modes[128];
|
||||
|
||||
static word16 vesa_ver;
|
||||
|
|
@ -57,7 +56,6 @@ static word16 *vesa_pmcode;
|
|||
unsigned int vesa_gran_mask, vesa_gran_shift;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* VESA info
|
||||
*/
|
||||
|
|
@ -88,16 +86,16 @@ unsigned int vesa_gran_mask, vesa_gran_shift;
|
|||
* VESA 3.0 CRTC timings structure
|
||||
*/
|
||||
typedef struct CRTCInfoBlock {
|
||||
unsigned short HorizontalTotal;
|
||||
unsigned short HorizontalSyncStart;
|
||||
unsigned short HorizontalSyncEnd;
|
||||
unsigned short VerticalTotal;
|
||||
unsigned short VerticalSyncStart;
|
||||
unsigned short VerticalSyncEnd;
|
||||
unsigned char Flags;
|
||||
unsigned long PixelClock; /* units of Hz */
|
||||
unsigned short RefreshRate; /* units of 0.01 Hz */
|
||||
unsigned char reserved[40];
|
||||
unsigned short HorizontalTotal;
|
||||
unsigned short HorizontalSyncStart;
|
||||
unsigned short HorizontalSyncEnd;
|
||||
unsigned short VerticalTotal;
|
||||
unsigned short VerticalSyncStart;
|
||||
unsigned short VerticalSyncEnd;
|
||||
unsigned char Flags;
|
||||
unsigned long PixelClock; /* units of Hz */
|
||||
unsigned short RefreshRate; /* units of 0.01 Hz */
|
||||
unsigned char reserved[40];
|
||||
} __PACKED__ CRTCInfoBlock;
|
||||
|
||||
#define HNEG (1 << 2)
|
||||
|
|
@ -105,7 +103,6 @@ typedef struct CRTCInfoBlock {
|
|||
#define DOUBLESCAN (1 << 0)
|
||||
|
||||
|
||||
|
||||
/* Desc: Attempts to detect VESA, check video modes and create selectors.
|
||||
*
|
||||
* In : -
|
||||
|
|
@ -113,123 +110,122 @@ typedef struct CRTCInfoBlock {
|
|||
*
|
||||
* Note: -
|
||||
*/
|
||||
static vl_mode *vesa_init (void)
|
||||
static vl_mode *
|
||||
vesa_init (void)
|
||||
{
|
||||
__dpmi_regs r;
|
||||
word16 *p;
|
||||
vl_mode *q;
|
||||
char vesa_info[512], tmp[512];
|
||||
int maxsize = 0;
|
||||
word32 linearfb = 0;
|
||||
__dpmi_regs r;
|
||||
word16 *p;
|
||||
vl_mode *q;
|
||||
char vesa_info[512], tmp[512];
|
||||
int maxsize = 0;
|
||||
word32 linearfb = 0;
|
||||
|
||||
if (vesa_ver) {
|
||||
return modes;
|
||||
}
|
||||
if (vesa_ver) {
|
||||
return modes;
|
||||
}
|
||||
|
||||
_farpokel(_stubinfo->ds_selector, 0, 0x32454256);
|
||||
r.x.ax = 0x4f00;
|
||||
r.x.di = 0;
|
||||
r.x.es = _stubinfo->ds_segment;
|
||||
__dpmi_int(0x10, &r);
|
||||
movedata(_stubinfo->ds_selector, 0, _my_ds(), (unsigned)vesa_info, 512);
|
||||
if ((r.x.ax!=0x004f) || ((_32_ vesa_info[V_SIGN])!=0x41534556)) {
|
||||
return NULL;
|
||||
}
|
||||
_farpokel(_stubinfo->ds_selector, 0, 0x32454256);
|
||||
r.x.ax = 0x4f00;
|
||||
r.x.di = 0;
|
||||
r.x.es = _stubinfo->ds_segment;
|
||||
__dpmi_int(0x10, &r);
|
||||
movedata(_stubinfo->ds_selector, 0, _my_ds(), (unsigned)vesa_info, 512);
|
||||
if ((r.x.ax != 0x004f) || ((_32_ vesa_info[V_SIGN]) != 0x41534556)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
p = (word16 *)(((_16_ vesa_info[V_MODE_SEG])<<4) + (_16_ vesa_info[V_MODE_OFS]));
|
||||
q = modes;
|
||||
do {
|
||||
if ((q->mode=_farpeekw(__djgpp_dos_sel, (unsigned long)(p++)))==0xffff) {
|
||||
break;
|
||||
}
|
||||
p = (word16 *)(((_16_ vesa_info[V_MODE_SEG])<<4) + (_16_ vesa_info[V_MODE_OFS]));
|
||||
q = modes;
|
||||
do {
|
||||
if ((q->mode=_farpeekw(__djgpp_dos_sel, (unsigned long)(p++))) == 0xffff) {
|
||||
break;
|
||||
}
|
||||
|
||||
r.x.ax = 0x4f01;
|
||||
r.x.cx = q->mode;
|
||||
r.x.di = 512;
|
||||
r.x.es = _stubinfo->ds_segment;
|
||||
__dpmi_int(0x10, &r);
|
||||
movedata(_stubinfo->ds_selector, 512, _my_ds(), (unsigned)tmp, 256);
|
||||
switch (tmp[M_BPP]) {
|
||||
case 16:
|
||||
q->bpp = tmp[M_RED] + tmp[M_GREEN] + tmp[M_BLUE];
|
||||
break;
|
||||
case 8:
|
||||
case 15:
|
||||
case 24:
|
||||
case 32:
|
||||
q->bpp = tmp[M_BPP];
|
||||
break;
|
||||
default:
|
||||
q->bpp = 0;
|
||||
}
|
||||
if ((r.x.ax==0x004f) && ((tmp[M_ATTR]&0x11)==0x11) && q->bpp) {
|
||||
q->xres = _16_ tmp[M_XRES];
|
||||
q->yres = _16_ tmp[M_YRES];
|
||||
q->scanlen = _16_ tmp[M_SCANLEN];
|
||||
q->gran = (_16_ tmp[M_GRAN])<<10;
|
||||
if (tmp[M_ATTR]&0x80) {
|
||||
#if 0
|
||||
*(q+1) = *q++;
|
||||
#else
|
||||
vl_mode *q1 = q + 1;
|
||||
*q1 = *q++;
|
||||
#endif
|
||||
linearfb = _32_ tmp[M_PHYS_PTR];
|
||||
q->mode |= 0x4000;
|
||||
}
|
||||
if (maxsize<(q->scanlen*q->yres)) {
|
||||
maxsize = q->scanlen*q->yres;
|
||||
}
|
||||
q++;
|
||||
}
|
||||
} while (TRUE);
|
||||
r.x.ax = 0x4f01;
|
||||
r.x.cx = q->mode;
|
||||
r.x.di = 512;
|
||||
r.x.es = _stubinfo->ds_segment;
|
||||
__dpmi_int(0x10, &r);
|
||||
movedata(_stubinfo->ds_selector, 512, _my_ds(), (unsigned)tmp, 256);
|
||||
switch (tmp[M_BPP]) {
|
||||
case 16:
|
||||
q->bpp = tmp[M_RED] + tmp[M_GREEN] + tmp[M_BLUE];
|
||||
break;
|
||||
case 8:
|
||||
case 15:
|
||||
case 24:
|
||||
case 32:
|
||||
q->bpp = tmp[M_BPP];
|
||||
break;
|
||||
default:
|
||||
q->bpp = 0;
|
||||
}
|
||||
if ((r.x.ax == 0x004f) && ((tmp[M_ATTR] & 0x11) == 0x11) && q->bpp) {
|
||||
q->xres = _16_ tmp[M_XRES];
|
||||
q->yres = _16_ tmp[M_YRES];
|
||||
q->scanlen = _16_ tmp[M_SCANLEN];
|
||||
q->gran = (_16_ tmp[M_GRAN])<<10;
|
||||
if (tmp[M_ATTR] & 0x80) {
|
||||
vl_mode *q1 = q + 1;
|
||||
*q1 = *q++;
|
||||
linearfb = _32_ tmp[M_PHYS_PTR];
|
||||
q->mode |= 0x4000;
|
||||
}
|
||||
if (maxsize < (q->scanlen * q->yres)) {
|
||||
maxsize = q->scanlen * q->yres;
|
||||
}
|
||||
q++;
|
||||
}
|
||||
} while (TRUE);
|
||||
|
||||
if (q==modes) {
|
||||
return NULL;
|
||||
}
|
||||
if (linearfb) {
|
||||
maxsize = ((maxsize+0xfffUL)&~0xfffUL);
|
||||
if (_create_selector(&linear_selector, linearfb, maxsize)) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (_create_selector(&banked_selector, 0xa0000, modes[0].gran)) {
|
||||
_remove_selector(&linear_selector);
|
||||
return NULL;
|
||||
}
|
||||
if (q == modes) {
|
||||
return NULL;
|
||||
}
|
||||
if (linearfb) {
|
||||
maxsize = (maxsize + 0xfffUL) & ~0xfffUL;
|
||||
if (_create_selector(&linear_selector, linearfb, maxsize)) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (_create_selector(&banked_selector, 0xa0000, modes[0].gran)) {
|
||||
_remove_selector(&linear_selector);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (q=modes; q->mode!=0xffff; q++) {
|
||||
q->sel = (q->mode&0x4000) ? linear_selector : banked_selector;
|
||||
}
|
||||
for (q = modes; q->mode != 0xffff; q++) {
|
||||
q->sel = (q->mode & 0x4000) ? linear_selector : banked_selector;
|
||||
}
|
||||
|
||||
if (vesa_info[V_MAJOR] >= 2) {
|
||||
r.x.ax = 0x4f0a;
|
||||
r.x.bx = 0;
|
||||
__dpmi_int(0x10, &r);
|
||||
if (r.x.ax == 0x004f) {
|
||||
vesa_pmcode = (word16 *)malloc(r.x.cx);
|
||||
movedata(__djgpp_dos_sel, (r.x.es << 4) + r.x.di, _my_ds(), (unsigned)vesa_pmcode, r.x.cx);
|
||||
if (vesa_pmcode[3]) {
|
||||
p = (word16 *)((long)vesa_pmcode + vesa_pmcode[3]);
|
||||
while (*p++ != 0xffff) ;
|
||||
} else {
|
||||
p = NULL;
|
||||
}
|
||||
if (p && (*p != 0xffff)) {
|
||||
free(vesa_pmcode);
|
||||
vesa_pmcode = NULL;
|
||||
} else {
|
||||
vesa_swbank = (void *)((long)vesa_pmcode + vesa_pmcode[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (vesa_info[V_MAJOR] >= 2) {
|
||||
r.x.ax = 0x4f0a;
|
||||
r.x.bx = 0;
|
||||
__dpmi_int(0x10, &r);
|
||||
if (r.x.ax == 0x004f) {
|
||||
vesa_pmcode = (word16 *)malloc(r.x.cx);
|
||||
if (vesa_pmcode != NULL) {
|
||||
movedata(__djgpp_dos_sel, (r.x.es << 4) + r.x.di, _my_ds(), (unsigned)vesa_pmcode, r.x.cx);
|
||||
if (vesa_pmcode[3]) {
|
||||
p = (word16 *)((long)vesa_pmcode + vesa_pmcode[3]);
|
||||
while (*p++ != 0xffff) {
|
||||
}
|
||||
} else {
|
||||
p = NULL;
|
||||
}
|
||||
if (p && (*p != 0xffff)) {
|
||||
free(vesa_pmcode);
|
||||
vesa_pmcode = NULL;
|
||||
} else {
|
||||
vesa_swbank = (void *)((long)vesa_pmcode + vesa_pmcode[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vesa_ver = _16_ vesa_info[V_MINOR];
|
||||
return modes;
|
||||
vesa_ver = _16_ vesa_info[V_MINOR];
|
||||
return modes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Desc: Frees all resources allocated by VESA init code.
|
||||
*
|
||||
* In : -
|
||||
|
|
@ -237,20 +233,20 @@ static vl_mode *vesa_init (void)
|
|||
*
|
||||
* Note: -
|
||||
*/
|
||||
static void vesa_fini (void)
|
||||
static void
|
||||
vesa_fini (void)
|
||||
{
|
||||
if (vesa_ver) {
|
||||
_remove_selector(&linear_selector);
|
||||
_remove_selector(&banked_selector);
|
||||
if (vesa_pmcode != NULL) {
|
||||
free(vesa_pmcode);
|
||||
vesa_pmcode = NULL;
|
||||
}
|
||||
}
|
||||
if (vesa_ver) {
|
||||
_remove_selector(&linear_selector);
|
||||
_remove_selector(&banked_selector);
|
||||
if (vesa_pmcode != NULL) {
|
||||
free(vesa_pmcode);
|
||||
vesa_pmcode = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Desc: Uses VESA 3.0 function 0x4F0B to find the closest pixel clock to the requested value.
|
||||
*
|
||||
* In : mode, clock
|
||||
|
|
@ -258,21 +254,21 @@ static void vesa_fini (void)
|
|||
*
|
||||
* Note: -
|
||||
*/
|
||||
static unsigned long _closest_pixclk (int mode_no, unsigned long vclk)
|
||||
static unsigned long
|
||||
_closest_pixclk (int mode_no, unsigned long vclk)
|
||||
{
|
||||
__dpmi_regs r;
|
||||
__dpmi_regs r;
|
||||
|
||||
r.x.ax = 0x4F0B;
|
||||
r.h.bl = 0;
|
||||
r.d.ecx = vclk;
|
||||
r.x.dx = mode_no;
|
||||
__dpmi_int(0x10, &r);
|
||||
r.x.ax = 0x4F0B;
|
||||
r.h.bl = 0;
|
||||
r.d.ecx = vclk;
|
||||
r.x.dx = mode_no;
|
||||
__dpmi_int(0x10, &r);
|
||||
|
||||
return (r.x.ax==0x004f) ? r.d.ecx : 0;
|
||||
return (r.x.ax == 0x004f) ? r.d.ecx : 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Desc: Calculates CRTC mode timings.
|
||||
*
|
||||
* In : crtc block, geometry, adjust
|
||||
|
|
@ -280,82 +276,83 @@ static unsigned long _closest_pixclk (int mode_no, unsigned long vclk)
|
|||
*
|
||||
* Note:
|
||||
*/
|
||||
static void _crtc_timing (CRTCInfoBlock *crtc, int xres, int yres, int xadjust, int yadjust)
|
||||
static void
|
||||
_crtc_timing (CRTCInfoBlock *crtc, int xres, int yres, int xadjust, int yadjust)
|
||||
{
|
||||
int HTotal, VTotal;
|
||||
int HDisp, VDisp;
|
||||
int HSS, VSS;
|
||||
int HSE, VSE;
|
||||
int HSWidth, VSWidth;
|
||||
int SS, SE;
|
||||
int doublescan = FALSE;
|
||||
int HTotal, VTotal;
|
||||
int HDisp, VDisp;
|
||||
int HSS, VSS;
|
||||
int HSE, VSE;
|
||||
int HSWidth, VSWidth;
|
||||
int SS, SE;
|
||||
int doublescan = FALSE;
|
||||
|
||||
if (yres < 400) {
|
||||
doublescan = TRUE;
|
||||
yres *= 2;
|
||||
}
|
||||
if (yres < 400) {
|
||||
doublescan = TRUE;
|
||||
yres *= 2;
|
||||
}
|
||||
|
||||
HDisp = xres;
|
||||
HTotal = (int)(HDisp * 1.27) & ~0x7;
|
||||
HSWidth = (int)((HTotal - HDisp) / 5) & ~0x7;
|
||||
HSS = HDisp + 16;
|
||||
HSE = HSS + HSWidth;
|
||||
VDisp = yres;
|
||||
VTotal = VDisp * 1.07;
|
||||
VSWidth = (VTotal / 100) + 1;
|
||||
VSS = VDisp + ((int)(VTotal - VDisp) / 5) + 1;
|
||||
VSE = VSS + VSWidth;
|
||||
HDisp = xres;
|
||||
HTotal = (int)(HDisp * 1.27) & ~0x7;
|
||||
HSWidth = (int)((HTotal - HDisp) / 5) & ~0x7;
|
||||
HSS = HDisp + 16;
|
||||
HSE = HSS + HSWidth;
|
||||
VDisp = yres;
|
||||
VTotal = VDisp * 1.07;
|
||||
VSWidth = (VTotal / 100) + 1;
|
||||
VSS = VDisp + ((int)(VTotal - VDisp) / 5) + 1;
|
||||
VSE = VSS + VSWidth;
|
||||
|
||||
SS = HSS + xadjust;
|
||||
SE = HSE + xadjust;
|
||||
SS = HSS + xadjust;
|
||||
SE = HSE + xadjust;
|
||||
|
||||
if (xadjust < 0) {
|
||||
if (SS < (HDisp + 8)) {
|
||||
SS = HDisp + 8;
|
||||
SE = SS + HSWidth;
|
||||
}
|
||||
} else {
|
||||
if ((HTotal - 24) < SE) {
|
||||
SE = HTotal - 24;
|
||||
SS = SE - HSWidth;
|
||||
}
|
||||
}
|
||||
if (xadjust < 0) {
|
||||
if (SS < (HDisp + 8)) {
|
||||
SS = HDisp + 8;
|
||||
SE = SS + HSWidth;
|
||||
}
|
||||
} else {
|
||||
if ((HTotal - 24) < SE) {
|
||||
SE = HTotal - 24;
|
||||
SS = SE - HSWidth;
|
||||
}
|
||||
}
|
||||
|
||||
HSS = SS;
|
||||
HSE = SE;
|
||||
HSS = SS;
|
||||
HSE = SE;
|
||||
|
||||
SS = VSS + yadjust;
|
||||
SE = VSE + yadjust;
|
||||
SS = VSS + yadjust;
|
||||
SE = VSE + yadjust;
|
||||
|
||||
if (yadjust < 0) {
|
||||
if (SS < (VDisp + 3)) {
|
||||
SS = VDisp + 3;
|
||||
SE = SS + VSWidth;
|
||||
}
|
||||
} else {
|
||||
if ((VTotal - 4) < SE) {
|
||||
SE = VTotal - 4;
|
||||
SS = SE - VSWidth;
|
||||
}
|
||||
}
|
||||
if (yadjust < 0) {
|
||||
if (SS < (VDisp + 3)) {
|
||||
SS = VDisp + 3;
|
||||
SE = SS + VSWidth;
|
||||
}
|
||||
} else {
|
||||
if ((VTotal - 4) < SE) {
|
||||
SE = VTotal - 4;
|
||||
SS = SE - VSWidth;
|
||||
}
|
||||
}
|
||||
|
||||
VSS = SS;
|
||||
VSE = SE;
|
||||
VSS = SS;
|
||||
VSE = SE;
|
||||
|
||||
crtc->HorizontalTotal = HTotal;
|
||||
crtc->HorizontalSyncStart = HSS;
|
||||
crtc->HorizontalSyncEnd = HSE;
|
||||
crtc->VerticalTotal = VTotal;
|
||||
crtc->VerticalSyncStart = VSS;
|
||||
crtc->VerticalSyncEnd = VSE;
|
||||
crtc->Flags = HNEG | VNEG;
|
||||
crtc->HorizontalTotal = HTotal;
|
||||
crtc->HorizontalSyncStart = HSS;
|
||||
crtc->HorizontalSyncEnd = HSE;
|
||||
crtc->VerticalTotal = VTotal;
|
||||
crtc->VerticalSyncStart = VSS;
|
||||
crtc->VerticalSyncEnd = VSE;
|
||||
crtc->Flags = HNEG | VNEG;
|
||||
|
||||
if (doublescan)
|
||||
crtc->Flags |= DOUBLESCAN;
|
||||
if (doublescan) {
|
||||
crtc->Flags |= DOUBLESCAN;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Desc: Attempts to enter specified video mode.
|
||||
*
|
||||
* In : ptr to mode structure, refresh rate
|
||||
|
|
@ -363,78 +360,78 @@ static void _crtc_timing (CRTCInfoBlock *crtc, int xres, int yres, int xadjust,
|
|||
*
|
||||
* Note: -
|
||||
*/
|
||||
static int vesa_entermode (vl_mode *p, int refresh)
|
||||
static int
|
||||
vesa_entermode (vl_mode *p, int refresh)
|
||||
{
|
||||
__dpmi_regs r;
|
||||
__dpmi_regs r;
|
||||
|
||||
if (p->mode & 0x4000) {
|
||||
VESA.blit = _can_mmx() ? vesa_l_dump_virtual_mmx : vesa_l_dump_virtual;
|
||||
} else {
|
||||
VESA.blit = vesa_b_dump_virtual;
|
||||
{ int n; for (vesa_gran_shift=0, n=p->gran; n; vesa_gran_shift++, n>>=1) ; }
|
||||
vesa_gran_mask = (1<<(--vesa_gran_shift)) - 1;
|
||||
if ((unsigned)p->gran != (vesa_gran_mask+1)) {
|
||||
return !0;
|
||||
}
|
||||
}
|
||||
if (p->mode & 0x4000) {
|
||||
VESA.blit = _can_mmx() ? vesa_l_dump_virtual_mmx : vesa_l_dump_virtual;
|
||||
} else {
|
||||
VESA.blit = vesa_b_dump_virtual;
|
||||
{ int n; for (vesa_gran_shift=0, n=p->gran; n; vesa_gran_shift++, n>>=1) ; }
|
||||
vesa_gran_mask = (1 << (--vesa_gran_shift)) - 1;
|
||||
if ((unsigned)p->gran != (vesa_gran_mask+1)) {
|
||||
return !0;
|
||||
}
|
||||
}
|
||||
|
||||
if (oldmode == -1) {
|
||||
r.x.ax = 0x4f03;
|
||||
__dpmi_int(0x10, &r);
|
||||
oldmode = r.x.bx;
|
||||
}
|
||||
if (oldmode == -1) {
|
||||
r.x.ax = 0x4f03;
|
||||
__dpmi_int(0x10, &r);
|
||||
oldmode = r.x.bx;
|
||||
}
|
||||
|
||||
r.x.ax = 0x4f02;
|
||||
r.x.bx = p->mode;
|
||||
r.x.ax = 0x4f02;
|
||||
r.x.bx = p->mode;
|
||||
|
||||
if (refresh && ((vesa_ver>>8) >= 3)) {
|
||||
/* VESA 3.0 stuff for controlling the refresh rate */
|
||||
CRTCInfoBlock crtc;
|
||||
unsigned long vclk;
|
||||
double f0;
|
||||
if (refresh && ((vesa_ver>>8) >= 3)) {
|
||||
/* VESA 3.0 stuff for controlling the refresh rate */
|
||||
CRTCInfoBlock crtc;
|
||||
unsigned long vclk;
|
||||
double f0;
|
||||
|
||||
_crtc_timing(&crtc, p->xres, p->yres, 0, 0);
|
||||
_crtc_timing(&crtc, p->xres, p->yres, 0, 0);
|
||||
|
||||
vclk = (double)crtc.HorizontalTotal * crtc.VerticalTotal * refresh;
|
||||
vclk = _closest_pixclk(p->mode, vclk);
|
||||
vclk = (double)crtc.HorizontalTotal * crtc.VerticalTotal * refresh;
|
||||
vclk = _closest_pixclk(p->mode, vclk);
|
||||
|
||||
if (vclk != 0) {
|
||||
f0 = (double)vclk / (crtc.HorizontalTotal * crtc.VerticalTotal);
|
||||
/*_current_refresh_rate = (int)(f0 + 0.5);*/
|
||||
if (vclk != 0) {
|
||||
f0 = (double)vclk / (crtc.HorizontalTotal * crtc.VerticalTotal);
|
||||
/*_current_refresh_rate = (int)(f0 + 0.5);*/
|
||||
|
||||
crtc.PixelClock = vclk;
|
||||
crtc.RefreshRate = refresh * 100;
|
||||
crtc.PixelClock = vclk;
|
||||
crtc.RefreshRate = refresh * 100;
|
||||
|
||||
movedata(_my_ds(), (unsigned)&crtc, _stubinfo->ds_selector, 0, sizeof(crtc));
|
||||
movedata(_my_ds(), (unsigned)&crtc, _stubinfo->ds_selector, 0, sizeof(crtc));
|
||||
|
||||
r.x.di = 0;
|
||||
r.x.es = _stubinfo->ds_segment;
|
||||
r.x.bx |= 0x0800;
|
||||
}
|
||||
}
|
||||
r.x.di = 0;
|
||||
r.x.es = _stubinfo->ds_segment;
|
||||
r.x.bx |= 0x0800;
|
||||
}
|
||||
}
|
||||
|
||||
__dpmi_int(0x10, &r);
|
||||
if (r.x.ax != 0x004f) {
|
||||
return !0;
|
||||
}
|
||||
__dpmi_int(0x10, &r);
|
||||
if (r.x.ax != 0x004f) {
|
||||
return !0;
|
||||
}
|
||||
|
||||
if (p->bpp == 8) {
|
||||
r.x.ax = 0x4f08;
|
||||
r.x.bx = 0x0800;
|
||||
__dpmi_int(0x10, &r);
|
||||
if (r.x.ax == 0x004f) {
|
||||
r.x.ax = 0x4f08;
|
||||
r.h.bl = 0x01;
|
||||
__dpmi_int(0x10, &r);
|
||||
vesa_color_precision = r.h.bh;
|
||||
}
|
||||
}
|
||||
if (p->bpp == 8) {
|
||||
r.x.ax = 0x4f08;
|
||||
r.x.bx = 0x0800;
|
||||
__dpmi_int(0x10, &r);
|
||||
if (r.x.ax == 0x004f) {
|
||||
r.x.ax = 0x4f08;
|
||||
r.h.bl = 0x01;
|
||||
__dpmi_int(0x10, &r);
|
||||
vesa_color_precision = r.h.bh;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Desc: Restores to the mode prior to first call to vesa_entermode.
|
||||
*
|
||||
* In : -
|
||||
|
|
@ -442,20 +439,20 @@ static int vesa_entermode (vl_mode *p, int refresh)
|
|||
*
|
||||
* Note: -
|
||||
*/
|
||||
static void vesa_restore (void)
|
||||
static void
|
||||
vesa_restore (void)
|
||||
{
|
||||
__dpmi_regs r;
|
||||
__dpmi_regs r;
|
||||
|
||||
if (oldmode != -1) {
|
||||
r.x.ax = 0x4f02;
|
||||
r.x.bx = oldmode;
|
||||
__dpmi_int(0x10, &r);
|
||||
oldmode = -1;
|
||||
}
|
||||
if (oldmode != -1) {
|
||||
r.x.ax = 0x4f02;
|
||||
r.x.bx = oldmode;
|
||||
__dpmi_int(0x10, &r);
|
||||
oldmode = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Desc: set one palette entry
|
||||
*
|
||||
* In : color index, R, G, B
|
||||
|
|
@ -463,25 +460,25 @@ static void vesa_restore (void)
|
|||
*
|
||||
* Note: uses integer values
|
||||
*/
|
||||
static void vesa_setCI_i (int index, int red, int green, int blue)
|
||||
static void
|
||||
vesa_setCI_i (int index, int red, int green, int blue)
|
||||
{
|
||||
#if 0
|
||||
__asm("\n\
|
||||
movw $0x1010, %%ax \n\
|
||||
movb %1, %%dh \n\
|
||||
movb %2, %%ch \n\
|
||||
int $0x10 \n\
|
||||
"::"b"(index), "m"(red), "m"(green), "c"(blue):"%eax", "%edx");
|
||||
__asm("\n\
|
||||
movw $0x1010, %%ax \n\
|
||||
movb %1, %%dh \n\
|
||||
movb %2, %%ch \n\
|
||||
int $0x10 \n\
|
||||
"::"b"(index), "m"(red), "m"(green), "c"(blue):"%eax", "%edx");
|
||||
#else
|
||||
outportb(0x03C8, index);
|
||||
outportb(0x03C9, red);
|
||||
outportb(0x03C9, green);
|
||||
outportb(0x03C9, blue);
|
||||
outportb(0x03C8, index);
|
||||
outportb(0x03C9, red);
|
||||
outportb(0x03C9, green);
|
||||
outportb(0x03C9, blue);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Desc: set one palette entry
|
||||
*
|
||||
* In : color index, R, G, B
|
||||
|
|
@ -489,7 +486,8 @@ static void vesa_setCI_i (int index, int red, int green, int blue)
|
|||
*
|
||||
* Note: uses normalized values
|
||||
*/
|
||||
static void vesa_setCI_f (int index, float red, float green, float blue)
|
||||
static void
|
||||
vesa_setCI_f (int index, float red, float green, float blue)
|
||||
{
|
||||
float max = (1 << vesa_color_precision) - 1;
|
||||
|
||||
|
|
@ -497,7 +495,6 @@ static void vesa_setCI_f (int index, float red, float green, float blue)
|
|||
}
|
||||
|
||||
|
||||
|
||||
/* Desc: state retrieval
|
||||
*
|
||||
* In : parameter name, ptr to storage
|
||||
|
|
@ -505,30 +502,30 @@ static void vesa_setCI_f (int index, float red, float green, float blue)
|
|||
*
|
||||
* Note: -
|
||||
*/
|
||||
static int vesa_get (int pname, int *params)
|
||||
static int
|
||||
vesa_get (int pname, int *params)
|
||||
{
|
||||
switch (pname) {
|
||||
case VL_GET_CI_PREC:
|
||||
params[0] = vesa_color_precision;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
switch (pname) {
|
||||
case VL_GET_CI_PREC:
|
||||
params[0] = vesa_color_precision;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* the driver
|
||||
*/
|
||||
vl_driver VESA = {
|
||||
vesa_init,
|
||||
vesa_entermode,
|
||||
NULL,
|
||||
vesa_setCI_f,
|
||||
vesa_setCI_i,
|
||||
vesa_get,
|
||||
vesa_restore,
|
||||
vesa_fini
|
||||
vesa_init,
|
||||
vesa_entermode,
|
||||
NULL,
|
||||
vesa_setCI_f,
|
||||
vesa_setCI_i,
|
||||
vesa_get,
|
||||
vesa_restore,
|
||||
vesa_fini
|
||||
};
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* DOS/DJGPP device driver v1.6 for Mesa
|
||||
* DOS/DJGPP device driver v1.7 for Mesa
|
||||
*
|
||||
* Copyright (C) 2002 - Borca Daniel
|
||||
* Email : dborca@users.sourceforge.net
|
||||
|
|
@ -38,26 +38,25 @@
|
|||
#include "vga.h"
|
||||
|
||||
|
||||
|
||||
static vl_mode modes[] = {
|
||||
{
|
||||
/* .xres = */ 320,
|
||||
/* .yres = */ 200,
|
||||
/* .bpp = */ 8,
|
||||
/* .mode = */ 0x13 | 0x4000,
|
||||
/* .scanlen = */ 320,
|
||||
/* .sel = */ -1,
|
||||
/* .gran = */ 320*200
|
||||
},
|
||||
{
|
||||
/* .xres = */ -1,
|
||||
/* .yres = */ -1,
|
||||
/* .bpp = */ -1,
|
||||
/* .mode = */ 0xffff,
|
||||
/* .scanlen = */ -1,
|
||||
/* .sel = */ -1,
|
||||
/* .gran = */ -1
|
||||
}
|
||||
{
|
||||
/* .xres = */ 320,
|
||||
/* .yres = */ 200,
|
||||
/* .bpp = */ 8,
|
||||
/* .mode = */ 0x13 | 0x4000,
|
||||
/* .scanlen = */ 320,
|
||||
/* .sel = */ -1,
|
||||
/* .gran = */ 320*200
|
||||
},
|
||||
{
|
||||
/* .xres = */ -1,
|
||||
/* .yres = */ -1,
|
||||
/* .bpp = */ -1,
|
||||
/* .mode = */ 0xffff,
|
||||
/* .scanlen = */ -1,
|
||||
/* .sel = */ -1,
|
||||
/* .gran = */ -1
|
||||
}
|
||||
};
|
||||
|
||||
static word16 vga_ver;
|
||||
|
|
@ -67,7 +66,6 @@ static int oldmode = -1;
|
|||
#define vga_color_precision 6
|
||||
|
||||
|
||||
|
||||
/* Desc: Attempts to detect VGA, check video modes and create selectors.
|
||||
*
|
||||
* In : -
|
||||
|
|
@ -75,15 +73,16 @@ static int oldmode = -1;
|
|||
*
|
||||
* Note: -
|
||||
*/
|
||||
static vl_mode *vga_init (void)
|
||||
static vl_mode *
|
||||
vga_init (void)
|
||||
{
|
||||
int rv = 0;
|
||||
int rv = 0;
|
||||
|
||||
if (vga_ver) {
|
||||
return modes;
|
||||
}
|
||||
if (vga_ver) {
|
||||
return modes;
|
||||
}
|
||||
|
||||
__asm("\n\
|
||||
__asm("\n\
|
||||
movw $0x1a00, %%ax \n\
|
||||
int $0x10 \n\
|
||||
cmpb $0x1a, %%al \n\
|
||||
|
|
@ -92,23 +91,22 @@ static vl_mode *vga_init (void)
|
|||
jb 0f \n\
|
||||
andl $0xff, %%ebx \n\
|
||||
movl %%ebx, %0 \n\
|
||||
0:":"=g"(rv)::"%eax", "%ebx");
|
||||
if (rv == 0) {
|
||||
return NULL;
|
||||
}
|
||||
0:":"=g"(rv)::"%eax", "%ebx");
|
||||
if (rv == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (_create_selector(&linear_selector, 0xa0000, 0x10000)) {
|
||||
return NULL;
|
||||
}
|
||||
if (_create_selector(&linear_selector, 0xa0000, 0x10000)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
modes[0].sel = linear_selector;
|
||||
modes[0].sel = linear_selector;
|
||||
|
||||
vga_ver = rv;
|
||||
return modes;
|
||||
vga_ver = rv;
|
||||
return modes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Desc: Frees all resources allocated by VGA init code.
|
||||
*
|
||||
* In : -
|
||||
|
|
@ -116,15 +114,15 @@ static vl_mode *vga_init (void)
|
|||
*
|
||||
* Note: -
|
||||
*/
|
||||
static void vga_fini (void)
|
||||
static void
|
||||
vga_fini (void)
|
||||
{
|
||||
if (vga_ver) {
|
||||
_remove_selector(&linear_selector);
|
||||
}
|
||||
if (vga_ver) {
|
||||
_remove_selector(&linear_selector);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Desc: Attempts to enter specified video mode.
|
||||
*
|
||||
* In : ptr to mode structure, refresh rate
|
||||
|
|
@ -132,31 +130,31 @@ static void vga_fini (void)
|
|||
*
|
||||
* Note: -
|
||||
*/
|
||||
static int vga_entermode (vl_mode *p, int refresh)
|
||||
static int
|
||||
vga_entermode (vl_mode *p, int refresh)
|
||||
{
|
||||
if (!(p->mode & 0x4000)) {
|
||||
return -1;
|
||||
}
|
||||
VGA.blit = _can_mmx() ? vesa_l_dump_virtual_mmx : vesa_l_dump_virtual;
|
||||
if (!(p->mode & 0x4000)) {
|
||||
return -1;
|
||||
}
|
||||
VGA.blit = _can_mmx() ? vesa_l_dump_virtual_mmx : vesa_l_dump_virtual;
|
||||
|
||||
if (oldmode == -1) {
|
||||
__asm("\n\
|
||||
if (oldmode == -1) {
|
||||
__asm("\n\
|
||||
movb $0x0f, %%ah \n\
|
||||
int $0x10 \n\
|
||||
andl $0xff, %%eax \n\
|
||||
movl %%eax, %0 \n\
|
||||
":"=g"(oldmode)::"%eax", "%ebx");
|
||||
}
|
||||
":"=g"(oldmode)::"%eax", "%ebx");
|
||||
}
|
||||
|
||||
__asm("int $0x10"::"a"(p->mode&0xff));
|
||||
__asm("int $0x10"::"a"(p->mode&0xff));
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
(void)refresh; /* silence compiler warning */
|
||||
(void)refresh; /* silence compiler warning */
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Desc: Restores to the mode prior to first call to vga_entermode.
|
||||
*
|
||||
* In : -
|
||||
|
|
@ -164,16 +162,16 @@ static int vga_entermode (vl_mode *p, int refresh)
|
|||
*
|
||||
* Note: -
|
||||
*/
|
||||
static void vga_restore (void)
|
||||
static void
|
||||
vga_restore (void)
|
||||
{
|
||||
if (oldmode != -1) {
|
||||
__asm("int $0x10"::"a"(oldmode));
|
||||
oldmode = -1;
|
||||
}
|
||||
if (oldmode != -1) {
|
||||
__asm("int $0x10"::"a"(oldmode));
|
||||
oldmode = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Desc: set one palette entry
|
||||
*
|
||||
* In : color index, R, G, B
|
||||
|
|
@ -181,25 +179,25 @@ static void vga_restore (void)
|
|||
*
|
||||
* Note: uses integer values
|
||||
*/
|
||||
static void vga_setCI_i (int index, int red, int green, int blue)
|
||||
static void
|
||||
vga_setCI_i (int index, int red, int green, int blue)
|
||||
{
|
||||
#if 0
|
||||
__asm("\n\
|
||||
movw $0x1010, %%ax \n\
|
||||
movb %1, %%dh \n\
|
||||
movb %2, %%ch \n\
|
||||
int $0x10 \n\
|
||||
"::"b"(index), "m"(red), "m"(green), "c"(blue):"%eax", "%edx");
|
||||
__asm("\n\
|
||||
movw $0x1010, %%ax \n\
|
||||
movb %1, %%dh \n\
|
||||
movb %2, %%ch \n\
|
||||
int $0x10 \n\
|
||||
"::"b"(index), "m"(red), "m"(green), "c"(blue):"%eax", "%edx");
|
||||
#else
|
||||
outportb(0x03C8, index);
|
||||
outportb(0x03C9, red);
|
||||
outportb(0x03C9, green);
|
||||
outportb(0x03C9, blue);
|
||||
outportb(0x03C8, index);
|
||||
outportb(0x03C9, red);
|
||||
outportb(0x03C9, green);
|
||||
outportb(0x03C9, blue);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Desc: set one palette entry
|
||||
*
|
||||
* In : color index, R, G, B
|
||||
|
|
@ -207,15 +205,15 @@ static void vga_setCI_i (int index, int red, int green, int blue)
|
|||
*
|
||||
* Note: uses normalized values
|
||||
*/
|
||||
static void vga_setCI_f (int index, float red, float green, float blue)
|
||||
static void
|
||||
vga_setCI_f (int index, float red, float green, float blue)
|
||||
{
|
||||
float max = (1 << vga_color_precision) - 1;
|
||||
float max = (1 << vga_color_precision) - 1;
|
||||
|
||||
vga_setCI_i(index, (int)(red * max), (int)(green * max), (int)(blue * max));
|
||||
vga_setCI_i(index, (int)(red * max), (int)(green * max), (int)(blue * max));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Desc: state retrieval
|
||||
*
|
||||
* In : parameter name, ptr to storage
|
||||
|
|
@ -223,30 +221,30 @@ static void vga_setCI_f (int index, float red, float green, float blue)
|
|||
*
|
||||
* Note: -
|
||||
*/
|
||||
static int vga_get (int pname, int *params)
|
||||
static int
|
||||
vga_get (int pname, int *params)
|
||||
{
|
||||
switch (pname) {
|
||||
case VL_GET_CI_PREC:
|
||||
params[0] = vga_color_precision;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
switch (pname) {
|
||||
case VL_GET_CI_PREC:
|
||||
params[0] = vga_color_precision;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* the driver
|
||||
*/
|
||||
vl_driver VGA = {
|
||||
vga_init,
|
||||
vga_entermode,
|
||||
NULL,
|
||||
vga_setCI_f,
|
||||
vga_setCI_i,
|
||||
vga_get,
|
||||
vga_restore,
|
||||
vga_fini
|
||||
vga_init,
|
||||
vga_entermode,
|
||||
NULL,
|
||||
vga_setCI_f,
|
||||
vga_setCI_i,
|
||||
vga_get,
|
||||
vga_restore,
|
||||
vga_fini
|
||||
};
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* DOS/DJGPP device driver v1.5 for Mesa
|
||||
* DOS/DJGPP device driver v1.6 for Mesa
|
||||
*
|
||||
* Copyright (C) 2002 - Borca Daniel
|
||||
* Email : dborca@users.sourceforge.net
|
||||
|
|
@ -42,7 +42,6 @@
|
|||
#include "video.h"
|
||||
|
||||
|
||||
|
||||
static vl_driver *drv;
|
||||
/* based upon mode specific data: valid entire session */
|
||||
int vl_video_selector;
|
||||
|
|
@ -54,7 +53,6 @@ int vl_current_stride, vl_current_width, vl_current_height, vl_current_bytes;
|
|||
int vl_current_offset, vl_current_delta;
|
||||
|
||||
|
||||
|
||||
#if HUGE_LOOKUP
|
||||
/* These lookup tables are used to extract RGB values in [0,255]
|
||||
* from 15/16-bit pixel values.
|
||||
|
|
@ -102,7 +100,6 @@ static word8 array_g[256];
|
|||
static word8 array_b[256];
|
||||
|
||||
|
||||
|
||||
int (*vl_mixfix) (fixed r, fixed g, fixed b);
|
||||
int (*vl_mixrgb) (const unsigned char rgb[]);
|
||||
int (*vl_mixrgba) (const unsigned char rgba[]);
|
||||
|
|
@ -114,7 +111,6 @@ void (*vl_flip) (void);
|
|||
void (*vl_putpixel) (unsigned int offset, int color);
|
||||
|
||||
|
||||
|
||||
/* Desc: color composition (w/o ALPHA)
|
||||
*
|
||||
* In : R, G, B
|
||||
|
|
@ -122,35 +118,38 @@ void (*vl_putpixel) (unsigned int offset, int color);
|
|||
*
|
||||
* Note: -
|
||||
*/
|
||||
static int vl_mixfix8fake (fixed r, fixed g, fixed b)
|
||||
static int
|
||||
vl_mixfix8fake (fixed r, fixed g, fixed b)
|
||||
{
|
||||
return array_b[b>>FIXED_SHIFT]*G_CNT*R_CNT
|
||||
+ array_g[g>>FIXED_SHIFT]*R_CNT
|
||||
+ array_r[r>>FIXED_SHIFT];
|
||||
return array_b[b>>FIXED_SHIFT]*G_CNT*R_CNT
|
||||
+ array_g[g>>FIXED_SHIFT]*R_CNT
|
||||
+ array_r[r>>FIXED_SHIFT];
|
||||
}
|
||||
#define vl_mixfix8 vl_mixfix8fake
|
||||
static int vl_mixfix15 (fixed r, fixed g, fixed b)
|
||||
static int
|
||||
vl_mixfix15 (fixed r, fixed g, fixed b)
|
||||
{
|
||||
return ((r>>(3+FIXED_SHIFT))<<10)
|
||||
|((g>>(3+FIXED_SHIFT))<<5)
|
||||
|(b>>(3+FIXED_SHIFT));
|
||||
return ((r>>(3+FIXED_SHIFT))<<10)
|
||||
|((g>>(3+FIXED_SHIFT))<<5)
|
||||
| (b>>(3+FIXED_SHIFT));
|
||||
}
|
||||
static int vl_mixfix16 (fixed r, fixed g, fixed b)
|
||||
static int
|
||||
vl_mixfix16 (fixed r, fixed g, fixed b)
|
||||
{
|
||||
return ((r>>(3+FIXED_SHIFT))<<11)
|
||||
|((g>>(2+FIXED_SHIFT))<<5)
|
||||
|(b>>(3+FIXED_SHIFT));
|
||||
return ((r>>(3+FIXED_SHIFT))<<11)
|
||||
|((g>>(2+FIXED_SHIFT))<<5)
|
||||
| (b>>(3+FIXED_SHIFT));
|
||||
}
|
||||
#define vl_mixfix24 vl_mixfix32
|
||||
static int vl_mixfix32 (fixed r, fixed g, fixed b)
|
||||
static int
|
||||
vl_mixfix32 (fixed r, fixed g, fixed b)
|
||||
{
|
||||
return ((r>>FIXED_SHIFT)<<16)
|
||||
|((g>>FIXED_SHIFT)<<8)
|
||||
|(b>>FIXED_SHIFT);
|
||||
return ((r>>FIXED_SHIFT)<<16)
|
||||
|((g>>FIXED_SHIFT)<<8)
|
||||
| (b>>FIXED_SHIFT);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Desc: color composition (w/ ALPHA)
|
||||
*
|
||||
* In : array of integers (R, G, B, A)
|
||||
|
|
@ -162,17 +161,17 @@ static int vl_mixfix32 (fixed r, fixed g, fixed b)
|
|||
#define vl_mixrgba15 vl_mixrgb15
|
||||
#define vl_mixrgba16 vl_mixrgb16
|
||||
#define vl_mixrgba24 vl_mixrgb24
|
||||
static int vl_mixrgba32 (const unsigned char rgba[])
|
||||
static int
|
||||
vl_mixrgba32 (const unsigned char rgba[])
|
||||
{
|
||||
/* Hack alert:
|
||||
* currently, DMesa uses Mesa's alpha buffer;
|
||||
* so we don't really care about alpha value here...
|
||||
*/
|
||||
return /*(rgba[3]<<24)|*/(rgba[0]<<16)|(rgba[1]<<8)|(rgba[2]);
|
||||
/* Hack alert:
|
||||
* currently, DMesa uses Mesa's alpha buffer;
|
||||
* so we don't really care about alpha value here...
|
||||
*/
|
||||
return /*(rgba[3]<<24) | */(rgba[0]<<16) | (rgba[1]<<8) | (rgba[2]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Desc: color composition (w/o ALPHA)
|
||||
*
|
||||
* In : array of integers (R, G, B)
|
||||
|
|
@ -180,29 +179,32 @@ static int vl_mixrgba32 (const unsigned char rgba[])
|
|||
*
|
||||
* Note: -
|
||||
*/
|
||||
static int vl_mixrgb8fake (const unsigned char rgb[])
|
||||
static int
|
||||
vl_mixrgb8fake (const unsigned char rgb[])
|
||||
{
|
||||
return array_b[rgb[2]]*G_CNT*R_CNT
|
||||
+ array_g[rgb[1]]*R_CNT
|
||||
+ array_r[rgb[0]];
|
||||
return array_b[rgb[2]]*G_CNT*R_CNT
|
||||
+ array_g[rgb[1]]*R_CNT
|
||||
+ array_r[rgb[0]];
|
||||
}
|
||||
#define vl_mixrgb8 vl_mixrgb8fake
|
||||
static int vl_mixrgb15 (const unsigned char rgb[])
|
||||
static int
|
||||
vl_mixrgb15 (const unsigned char rgb[])
|
||||
{
|
||||
return ((rgb[0]>>3)<<10)|((rgb[1]>>3)<<5)|(rgb[2]>>3);
|
||||
return ((rgb[0]>>3)<<10) | ((rgb[1]>>3)<<5) | (rgb[2]>>3);
|
||||
}
|
||||
static int vl_mixrgb16 (const unsigned char rgb[])
|
||||
static int
|
||||
vl_mixrgb16 (const unsigned char rgb[])
|
||||
{
|
||||
return ((rgb[0]>>3)<<11)|((rgb[1]>>2)<<5)|(rgb[2]>>3);
|
||||
return ((rgb[0]>>3)<<11) | ((rgb[1]>>2)<<5) | (rgb[2]>>3);
|
||||
}
|
||||
#define vl_mixrgb24 vl_mixrgb32
|
||||
static int vl_mixrgb32 (const unsigned char rgb[])
|
||||
static int
|
||||
vl_mixrgb32 (const unsigned char rgb[])
|
||||
{
|
||||
return (rgb[0]<<16)|(rgb[1]<<8)|(rgb[2]);
|
||||
return (rgb[0]<<16) | (rgb[1]<<8) | (rgb[2]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Desc: color decomposition
|
||||
*
|
||||
* In : pixel offset, array of integers to hold color components (R, G, B, A)
|
||||
|
|
@ -210,71 +212,76 @@ static int vl_mixrgb32 (const unsigned char rgb[])
|
|||
*
|
||||
* Note: uses current read buffer
|
||||
*/
|
||||
static void v_getrgba8fake6 (unsigned int offset, unsigned char rgba[4])
|
||||
static void
|
||||
v_getrgba8fake6 (unsigned int offset, unsigned char rgba[4])
|
||||
{
|
||||
word32 c = VGAPalette[((word8 *)vl_current_read_buffer)[offset]];
|
||||
rgba[0] = _rgb_scale_6[(c >> 16) & 0x3F];
|
||||
rgba[1] = _rgb_scale_6[(c >> 8) & 0x3F];
|
||||
rgba[2] = _rgb_scale_6[c & 0x3F];
|
||||
/*rgba[3] = c >> 24;*/ /* dummy alpha; we have separate SW alpha, so ignore */
|
||||
word32 c = VGAPalette[((word8 *)vl_current_read_buffer)[offset]];
|
||||
rgba[0] = _rgb_scale_6[(c >> 16) & 0x3F];
|
||||
rgba[1] = _rgb_scale_6[(c >> 8) & 0x3F];
|
||||
rgba[2] = _rgb_scale_6[ c & 0x3F];
|
||||
/*rgba[3] = c >> 24;*/ /* dummy alpha; we have separate SW alpha, so ignore */
|
||||
}
|
||||
static void v_getrgba8fake8 (unsigned int offset, unsigned char rgba[4])
|
||||
static void
|
||||
v_getrgba8fake8 (unsigned int offset, unsigned char rgba[4])
|
||||
{
|
||||
word32 c = VGAPalette[((word8 *)vl_current_read_buffer)[offset]];
|
||||
rgba[0] = c >> 16;
|
||||
rgba[1] = c >> 8;
|
||||
rgba[2] = c;
|
||||
/*rgba[3] = c >> 24;*/ /* dummy alpha; we have separate SW alpha, so ignore */
|
||||
word32 c = VGAPalette[((word8 *)vl_current_read_buffer)[offset]];
|
||||
rgba[0] = c >> 16;
|
||||
rgba[1] = c >> 8;
|
||||
rgba[2] = c;
|
||||
/*rgba[3] = c >> 24;*/ /* dummy alpha; we have separate SW alpha, so ignore */
|
||||
}
|
||||
#define v_getrgba8 v_getrgba8fake6
|
||||
static void v_getrgba15 (unsigned int offset, unsigned char rgba[4])
|
||||
static void
|
||||
v_getrgba15 (unsigned int offset, unsigned char rgba[4])
|
||||
{
|
||||
word32 c = ((word16 *)vl_current_read_buffer)[offset];
|
||||
word32 c = ((word16 *)vl_current_read_buffer)[offset];
|
||||
#if HUGE_LOOKUP
|
||||
c &= 0x7fff;
|
||||
rgba[0] = pix15r[c];
|
||||
rgba[1] = pix15g[c];
|
||||
rgba[2] = pix15b[c];
|
||||
c &= 0x7fff;
|
||||
rgba[0] = pix15r[c];
|
||||
rgba[1] = pix15g[c];
|
||||
rgba[2] = pix15b[c];
|
||||
#else
|
||||
rgba[0] = _rgb_scale_5[(c >> 10) & 0x1F];
|
||||
rgba[1] = _rgb_scale_5[(c >> 5) & 0x1F];
|
||||
rgba[2] = _rgb_scale_5[c & 0x1F];
|
||||
rgba[0] = _rgb_scale_5[(c >> 10) & 0x1F];
|
||||
rgba[1] = _rgb_scale_5[(c >> 5) & 0x1F];
|
||||
rgba[2] = _rgb_scale_5[ c & 0x1F];
|
||||
#endif
|
||||
/*rgba[3] = 255;*/ /* dummy alpha; we have separate SW alpha, so ignore */
|
||||
/*rgba[3] = 255;*/ /* dummy alpha; we have separate SW alpha, so ignore */
|
||||
}
|
||||
static void v_getrgba16 (unsigned int offset, unsigned char rgba[4])
|
||||
static void
|
||||
v_getrgba16 (unsigned int offset, unsigned char rgba[4])
|
||||
{
|
||||
word32 c = ((word16 *)vl_current_read_buffer)[offset];
|
||||
word32 c = ((word16 *)vl_current_read_buffer)[offset];
|
||||
#if HUGE_LOOKUP
|
||||
rgba[0] = pix16r[c];
|
||||
rgba[1] = pix16g[c];
|
||||
rgba[2] = pix16b[c];
|
||||
rgba[0] = pix16r[c];
|
||||
rgba[1] = pix16g[c];
|
||||
rgba[2] = pix16b[c];
|
||||
#else
|
||||
rgba[0] = _rgb_scale_5[(c >> 11) & 0x1F];
|
||||
rgba[1] = _rgb_scale_6[(c >> 5) & 0x3F];
|
||||
rgba[2] = _rgb_scale_5[c & 0x1F];
|
||||
rgba[0] = _rgb_scale_5[(c >> 11) & 0x1F];
|
||||
rgba[1] = _rgb_scale_6[(c >> 5) & 0x3F];
|
||||
rgba[2] = _rgb_scale_5[ c & 0x1F];
|
||||
#endif
|
||||
/*rgba[3] = 255;*/ /* dummy alpha; we have separate SW alpha, so ignore */
|
||||
/*rgba[3] = 255;*/ /* dummy alpha; we have separate SW alpha, so ignore */
|
||||
}
|
||||
static void v_getrgba24 (unsigned int offset, unsigned char rgba[4])
|
||||
static void
|
||||
v_getrgba24 (unsigned int offset, unsigned char rgba[4])
|
||||
{
|
||||
word32 c = *(word32 *)((long)vl_current_read_buffer+offset*3);
|
||||
rgba[0] = c >> 16;
|
||||
rgba[1] = c >> 8;
|
||||
rgba[2] = c;
|
||||
/*rgba[3] = 255;*/ /* dummy alpha; we have separate SW alpha, so ignore */
|
||||
word32 c = *(word32 *)((long)vl_current_read_buffer+offset*3);
|
||||
rgba[0] = c >> 16;
|
||||
rgba[1] = c >> 8;
|
||||
rgba[2] = c;
|
||||
/*rgba[3] = 255;*/ /* dummy alpha; we have separate SW alpha, so ignore */
|
||||
}
|
||||
static void v_getrgba32 (unsigned int offset, unsigned char rgba[4])
|
||||
static void
|
||||
v_getrgba32 (unsigned int offset, unsigned char rgba[4])
|
||||
{
|
||||
word32 c = ((word32 *)vl_current_read_buffer)[offset];
|
||||
rgba[0] = c >> 16;
|
||||
rgba[1] = c >> 8;
|
||||
rgba[2] = c;
|
||||
/*rgba[3] = c >> 24;*/ /* dummy alpha; we have separate SW alpha, so ignore */
|
||||
word32 c = ((word32 *)vl_current_read_buffer)[offset];
|
||||
rgba[0] = c >> 16;
|
||||
rgba[1] = c >> 8;
|
||||
rgba[2] = c;
|
||||
/*rgba[3] = c >> 24;*/ /* dummy alpha; we have separate SW alpha, so ignore */
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Desc: pixel retrieval
|
||||
*
|
||||
* In : pixel offset
|
||||
|
|
@ -282,26 +289,29 @@ static void v_getrgba32 (unsigned int offset, unsigned char rgba[4])
|
|||
*
|
||||
* Note: uses current read buffer
|
||||
*/
|
||||
static int v_getpixel8 (unsigned int offset)
|
||||
static int
|
||||
v_getpixel8 (unsigned int offset)
|
||||
{
|
||||
return ((word8 *)vl_current_read_buffer)[offset];
|
||||
return ((word8 *)vl_current_read_buffer)[offset];
|
||||
}
|
||||
#define v_getpixel15 v_getpixel16
|
||||
static int v_getpixel16 (unsigned int offset)
|
||||
static int
|
||||
v_getpixel16 (unsigned int offset)
|
||||
{
|
||||
return ((word16 *)vl_current_read_buffer)[offset];
|
||||
return ((word16 *)vl_current_read_buffer)[offset];
|
||||
}
|
||||
static int v_getpixel24 (unsigned int offset)
|
||||
static int
|
||||
v_getpixel24 (unsigned int offset)
|
||||
{
|
||||
return *(word32 *)((long)vl_current_read_buffer+offset*3);
|
||||
return *(word32 *)((long)vl_current_read_buffer+offset*3);
|
||||
}
|
||||
static int v_getpixel32 (unsigned int offset)
|
||||
static int
|
||||
v_getpixel32 (unsigned int offset)
|
||||
{
|
||||
return ((word32 *)vl_current_read_buffer)[offset];
|
||||
return ((word32 *)vl_current_read_buffer)[offset];
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Desc: set one palette entry
|
||||
*
|
||||
* In : index, R, G, B
|
||||
|
|
@ -309,13 +319,13 @@ static int v_getpixel32 (unsigned int offset)
|
|||
*
|
||||
* Note: color components are in range [0.0 .. 1.0]
|
||||
*/
|
||||
void vl_setCI (int index, float red, float green, float blue)
|
||||
void
|
||||
vl_setCI (int index, float red, float green, float blue)
|
||||
{
|
||||
drv->setCI_f(index, red, green, blue);
|
||||
drv->setCI_f(index, red, green, blue);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Desc: set one palette entry
|
||||
*
|
||||
* In : color, R, G, B
|
||||
|
|
@ -323,15 +333,15 @@ void vl_setCI (int index, float red, float green, float blue)
|
|||
*
|
||||
* Note: -
|
||||
*/
|
||||
static void fake_setcolor (int c, int r, int g, int b)
|
||||
static void
|
||||
fake_setcolor (int c, int r, int g, int b)
|
||||
{
|
||||
VGAPalette[c] = 0xff000000 | (r<<16) | (g<<8) | b;
|
||||
VGAPalette[c] = 0xff000000 | (r<<16) | (g<<8) | b;
|
||||
|
||||
drv->setCI_i(c, r, g, b);
|
||||
drv->setCI_i(c, r, g, b);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Desc: build FakeColor palette
|
||||
*
|
||||
* In : CI precision in bits
|
||||
|
|
@ -339,36 +349,36 @@ static void fake_setcolor (int c, int r, int g, int b)
|
|||
*
|
||||
* Note: -
|
||||
*/
|
||||
static void fake_buildpalette (int bits)
|
||||
static void
|
||||
fake_buildpalette (int bits)
|
||||
{
|
||||
double c_r, c_g, c_b;
|
||||
int r, g, b, color = 0;
|
||||
double c_r, c_g, c_b;
|
||||
int r, g, b, color = 0;
|
||||
|
||||
double max = (1 << bits) - 1;
|
||||
double max = (1 << bits) - 1;
|
||||
|
||||
for (b=0; b<B_CNT; ++b) {
|
||||
for (g=0; g<G_CNT; ++g) {
|
||||
for (r=0; r<R_CNT; ++r) {
|
||||
c_r = 0.5 + (double)r*(max-R_BIAS)/(R_CNT-1.) + R_BIAS;
|
||||
c_g = 0.5 + (double)g*(max-G_BIAS)/(G_CNT-1.) + G_BIAS;
|
||||
c_b = 0.5 + (double)b*(max-B_BIAS)/(B_CNT-1.) + B_BIAS;
|
||||
fake_setcolor(color++, (int)c_r, (int)c_g, (int)c_b);
|
||||
for (b = 0; b < B_CNT; ++b) {
|
||||
for (g = 0; g < G_CNT; ++g) {
|
||||
for (r = 0; r < R_CNT; ++r) {
|
||||
c_r = 0.5 + (double)r * (max-R_BIAS) / (R_CNT-1.) + R_BIAS;
|
||||
c_g = 0.5 + (double)g * (max-G_BIAS) / (G_CNT-1.) + G_BIAS;
|
||||
c_b = 0.5 + (double)b * (max-B_BIAS) / (B_CNT-1.) + B_BIAS;
|
||||
fake_setcolor(color++, (int)c_r, (int)c_g, (int)c_b);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (color=0; color<256; color++) {
|
||||
c_r = (double)color*R_CNT/256.;
|
||||
c_g = (double)color*G_CNT/256.;
|
||||
c_b = (double)color*B_CNT/256.;
|
||||
array_r[color] = (int)c_r;
|
||||
array_g[color] = (int)c_g;
|
||||
array_b[color] = (int)c_b;
|
||||
}
|
||||
for (color = 0; color < 256; color++) {
|
||||
c_r = (double)color * R_CNT / 256.;
|
||||
c_g = (double)color * G_CNT / 256.;
|
||||
c_b = (double)color * B_CNT / 256.;
|
||||
array_r[color] = (int)c_r;
|
||||
array_g[color] = (int)c_g;
|
||||
array_b[color] = (int)c_b;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if HUGE_LOOKUP
|
||||
/* Desc: initialize lookup arrays
|
||||
*
|
||||
|
|
@ -377,46 +387,46 @@ static void fake_buildpalette (int bits)
|
|||
*
|
||||
* Note: -
|
||||
*/
|
||||
void v_init_pixeltables (void)
|
||||
void
|
||||
v_init_pixeltables (void)
|
||||
{
|
||||
unsigned int pixel;
|
||||
unsigned int pixel;
|
||||
|
||||
for (pixel = 0; pixel <= 0xffff; pixel++) {
|
||||
unsigned int r, g, b;
|
||||
for (pixel = 0; pixel <= 0xffff; pixel++) {
|
||||
unsigned int r, g, b;
|
||||
|
||||
if (pixel <= 0x7fff) {
|
||||
/* 15bit */
|
||||
r = (pixel & 0x7c00) >> 8;
|
||||
g = (pixel & 0x03E0) >> 3;
|
||||
b = (pixel & 0x001F) << 2;
|
||||
if (pixel <= 0x7fff) {
|
||||
/* 15bit */
|
||||
r = (pixel & 0x7c00) >> 8;
|
||||
g = (pixel & 0x03E0) >> 3;
|
||||
b = (pixel & 0x001F) << 2;
|
||||
|
||||
r = (unsigned int)(((double)r * 255. / 0x7c) + 0.5);
|
||||
g = (unsigned int)(((double)g * 255. / 0x7c) + 0.5);
|
||||
b = (unsigned int)(((double)b * 255. / 0x7c) + 0.5);
|
||||
r = (unsigned int)(((double)r * 255. / 0x7c) + 0.5);
|
||||
g = (unsigned int)(((double)g * 255. / 0x7c) + 0.5);
|
||||
b = (unsigned int)(((double)b * 255. / 0x7c) + 0.5);
|
||||
|
||||
pix15r[pixel] = r;
|
||||
pix15g[pixel] = g;
|
||||
pix15b[pixel] = b;
|
||||
}
|
||||
pix15r[pixel] = r;
|
||||
pix15g[pixel] = g;
|
||||
pix15b[pixel] = b;
|
||||
}
|
||||
|
||||
/* 16bit */
|
||||
r = (pixel & 0xF800) >> 8;
|
||||
g = (pixel & 0x07E0) >> 3;
|
||||
b = (pixel & 0x001F) << 3;
|
||||
/* 16bit */
|
||||
r = (pixel & 0xF800) >> 8;
|
||||
g = (pixel & 0x07E0) >> 3;
|
||||
b = (pixel & 0x001F) << 3;
|
||||
|
||||
r = (unsigned int)(((double)r * 255. / 0xF8) + 0.5);
|
||||
g = (unsigned int)(((double)g * 255. / 0xFC) + 0.5);
|
||||
b = (unsigned int)(((double)b * 255. / 0xF8) + 0.5);
|
||||
r = (unsigned int)(((double)r * 255. / 0xF8) + 0.5);
|
||||
g = (unsigned int)(((double)g * 255. / 0xFC) + 0.5);
|
||||
b = (unsigned int)(((double)b * 255. / 0xF8) + 0.5);
|
||||
|
||||
pix16r[pixel] = r;
|
||||
pix16g[pixel] = g;
|
||||
pix16b[pixel] = b;
|
||||
}
|
||||
pix16r[pixel] = r;
|
||||
pix16g[pixel] = g;
|
||||
pix16b[pixel] = b;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Desc: initialize hardware
|
||||
*
|
||||
* In : -
|
||||
|
|
@ -424,33 +434,33 @@ void v_init_pixeltables (void)
|
|||
*
|
||||
* Note: when returning non-NULL, global variable `drv' is guaranteed to be ok
|
||||
*/
|
||||
static vl_mode *v_init_hw (void)
|
||||
static vl_mode *
|
||||
v_init_hw (void)
|
||||
{
|
||||
static vl_mode *q = NULL;
|
||||
static vl_mode *q = NULL;
|
||||
|
||||
if (q == NULL) {
|
||||
/* are we forced to NUL driver? */
|
||||
if (getenv("DMESA_NULDRV")) {
|
||||
if ((q = NUL.init()) != NULL) {
|
||||
drv = &NUL;
|
||||
}
|
||||
return q;
|
||||
}
|
||||
/* initialize hardware */
|
||||
if ((q = VESA.init()) != NULL) {
|
||||
drv = &VESA;
|
||||
} else if ((q = VGA.init()) != NULL) {
|
||||
drv = &VGA;
|
||||
} else {
|
||||
drv = NULL;
|
||||
}
|
||||
}
|
||||
if (q == NULL) {
|
||||
/* are we forced to NUL driver? */
|
||||
if (getenv("DMESA_NULDRV")) {
|
||||
if ((q = NUL.init()) != NULL) {
|
||||
drv = &NUL;
|
||||
}
|
||||
return q;
|
||||
}
|
||||
/* initialize hardware */
|
||||
if ((q = VESA.init()) != NULL) {
|
||||
drv = &VESA;
|
||||
} else if ((q = VGA.init()) != NULL) {
|
||||
drv = &VGA;
|
||||
} else {
|
||||
drv = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return q;
|
||||
return q;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Desc: sync buffer with video hardware
|
||||
*
|
||||
* In : ptr to old buffer, position, size
|
||||
|
|
@ -458,36 +468,36 @@ static vl_mode *v_init_hw (void)
|
|||
*
|
||||
* Note: -
|
||||
*/
|
||||
int vl_sync_buffer (void **buffer, int x, int y, int width, int height)
|
||||
int
|
||||
vl_sync_buffer (void **buffer, int x, int y, int width, int height)
|
||||
{
|
||||
if ((width & 7) || (x < 0) || (y < 0) || (x+width > video_mode->xres) || (y+height > video_mode->yres)) {
|
||||
return -1;
|
||||
} else {
|
||||
void *newbuf = *buffer;
|
||||
if ((width & 7) || (x < 0) || (y < 0) || (x+width > video_mode->xres) || (y+height > video_mode->yres)) {
|
||||
return -1;
|
||||
} else {
|
||||
void *newbuf = *buffer;
|
||||
|
||||
if ((newbuf == NULL) || (vl_current_width != width) || (vl_current_height != height)) {
|
||||
newbuf = realloc(newbuf, width * height * video_bypp);
|
||||
}
|
||||
if ((newbuf == NULL) || (vl_current_width != width) || (vl_current_height != height)) {
|
||||
newbuf = realloc(newbuf, width * height * video_bypp);
|
||||
}
|
||||
|
||||
if (newbuf == NULL) {
|
||||
return -2;
|
||||
}
|
||||
if (newbuf == NULL) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
vl_current_width = width;
|
||||
vl_current_height = height;
|
||||
vl_current_stride = vl_current_width * video_bypp;
|
||||
vl_current_bytes = vl_current_stride * height;
|
||||
vl_current_width = width;
|
||||
vl_current_height = height;
|
||||
vl_current_stride = vl_current_width * video_bypp;
|
||||
vl_current_bytes = vl_current_stride * height;
|
||||
|
||||
vl_current_offset = video_scanlen * y + video_bypp * x;
|
||||
vl_current_delta = video_scanlen - vl_current_stride;
|
||||
vl_current_offset = video_scanlen * y + video_bypp * x;
|
||||
vl_current_delta = video_scanlen - vl_current_stride;
|
||||
|
||||
vl_current_draw_buffer = vl_current_read_buffer = *buffer = newbuf;
|
||||
return 0;
|
||||
}
|
||||
vl_current_draw_buffer = vl_current_read_buffer = *buffer = newbuf;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Desc: state retrieval
|
||||
*
|
||||
* In : name, storage
|
||||
|
|
@ -495,41 +505,40 @@ int vl_sync_buffer (void **buffer, int x, int y, int width, int height)
|
|||
*
|
||||
* Note: -
|
||||
*/
|
||||
int vl_get (int pname, int *params)
|
||||
int
|
||||
vl_get (int pname, int *params)
|
||||
{
|
||||
switch (pname) {
|
||||
case VL_GET_SCREEN_SIZE:
|
||||
params[0] = video_mode->xres;
|
||||
params[1] = video_mode->yres;
|
||||
break;
|
||||
case VL_GET_VIDEO_MODES:
|
||||
{
|
||||
int n;
|
||||
vl_mode *q;
|
||||
if ((q = v_init_hw()) == NULL) {
|
||||
return -1;
|
||||
}
|
||||
/* count available visuals */
|
||||
for (n = 0; q->mode != 0xffff; q++) {
|
||||
if ((q + 1)->mode == (q->mode | 0x4000)) {
|
||||
/* same mode, but linear */
|
||||
q++;
|
||||
}
|
||||
if (params) {
|
||||
params[n] = (int)q;
|
||||
}
|
||||
n++;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
default:
|
||||
return (drv != NULL) ? drv->get(pname, params) : -1;
|
||||
}
|
||||
return 0;
|
||||
switch (pname) {
|
||||
case VL_GET_SCREEN_SIZE:
|
||||
params[0] = video_mode->xres;
|
||||
params[1] = video_mode->yres;
|
||||
break;
|
||||
case VL_GET_VIDEO_MODES: {
|
||||
int n;
|
||||
vl_mode *q;
|
||||
if ((q = v_init_hw()) == NULL) {
|
||||
return -1;
|
||||
}
|
||||
/* count available visuals */
|
||||
for (n = 0; q->mode != 0xffff; q++) {
|
||||
if ((q + 1)->mode == (q->mode | 0x4000)) {
|
||||
/* same mode, but linear */
|
||||
q++;
|
||||
}
|
||||
if (params) {
|
||||
params[n] = (int)q;
|
||||
}
|
||||
n++;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
default:
|
||||
return (drv != NULL) ? drv->get(pname, params) : -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Desc: setup mode
|
||||
*
|
||||
* In : ptr to mode definition
|
||||
|
|
@ -537,54 +546,54 @@ int vl_get (int pname, int *params)
|
|||
*
|
||||
* Note: -
|
||||
*/
|
||||
static int vl_setup_mode (vl_mode *p)
|
||||
static int
|
||||
vl_setup_mode (vl_mode *p)
|
||||
{
|
||||
if (p == NULL) {
|
||||
return -1;
|
||||
}
|
||||
if (p == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
#define INITPTR(bpp) \
|
||||
vl_putpixel = v_putpixel##bpp; \
|
||||
vl_getrgba = v_getrgba##bpp; \
|
||||
vl_getpixel = v_getpixel##bpp; \
|
||||
vl_rect = v_rect##bpp; \
|
||||
vl_mixfix = vl_mixfix##bpp; \
|
||||
vl_mixrgb = vl_mixrgb##bpp; \
|
||||
vl_mixrgba = vl_mixrgba##bpp; \
|
||||
vl_clear = _can_mmx() ? v_clear##bpp##_mmx : v_clear##bpp
|
||||
vl_putpixel = v_putpixel##bpp; \
|
||||
vl_getrgba = v_getrgba##bpp; \
|
||||
vl_getpixel = v_getpixel##bpp; \
|
||||
vl_rect = v_rect##bpp; \
|
||||
vl_mixfix = vl_mixfix##bpp; \
|
||||
vl_mixrgb = vl_mixrgb##bpp; \
|
||||
vl_mixrgba = vl_mixrgba##bpp; \
|
||||
vl_clear = _can_mmx() ? v_clear##bpp##_mmx : v_clear##bpp
|
||||
|
||||
switch (p->bpp) {
|
||||
case 8:
|
||||
INITPTR(8);
|
||||
break;
|
||||
case 15:
|
||||
INITPTR(15);
|
||||
break;
|
||||
case 16:
|
||||
INITPTR(16);
|
||||
break;
|
||||
case 24:
|
||||
INITPTR(24);
|
||||
break;
|
||||
case 32:
|
||||
INITPTR(32);
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
switch (p->bpp) {
|
||||
case 8:
|
||||
INITPTR(8);
|
||||
break;
|
||||
case 15:
|
||||
INITPTR(15);
|
||||
break;
|
||||
case 16:
|
||||
INITPTR(16);
|
||||
break;
|
||||
case 24:
|
||||
INITPTR(24);
|
||||
break;
|
||||
case 32:
|
||||
INITPTR(32);
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
#undef INITPTR
|
||||
|
||||
video_mode = p;
|
||||
video_bypp = (p->bpp+7)/8;
|
||||
video_scanlen = p->scanlen;
|
||||
vl_video_selector = p->sel;
|
||||
video_mode = p;
|
||||
video_bypp = (p->bpp+7)/8;
|
||||
video_scanlen = p->scanlen;
|
||||
vl_video_selector = p->sel;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Desc: restore to the mode prior to first call to `vl_video_init'.
|
||||
*
|
||||
* In : -
|
||||
|
|
@ -592,15 +601,15 @@ static int vl_setup_mode (vl_mode *p)
|
|||
*
|
||||
* Note: -
|
||||
*/
|
||||
void vl_video_exit (void)
|
||||
void
|
||||
vl_video_exit (void)
|
||||
{
|
||||
drv->restore();
|
||||
drv->fini();
|
||||
video_mode = NULL;
|
||||
drv->restore();
|
||||
drv->fini();
|
||||
video_mode = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Desc: enter mode
|
||||
*
|
||||
* In : xres, yres, bits/pixel, RGB, refresh rate
|
||||
|
|
@ -608,52 +617,53 @@ void vl_video_exit (void)
|
|||
*
|
||||
* Note: -
|
||||
*/
|
||||
int vl_video_init (int width, int height, int bpp, int rgb, int refresh)
|
||||
int
|
||||
vl_video_init (int width, int height, int bpp, int rgb, int refresh)
|
||||
{
|
||||
int fake;
|
||||
vl_mode *p, *q;
|
||||
unsigned int min;
|
||||
int fake;
|
||||
vl_mode *p, *q;
|
||||
unsigned int min;
|
||||
|
||||
fake = 0;
|
||||
if (!rgb) {
|
||||
bpp = 8;
|
||||
} else if (bpp == 8) {
|
||||
fake = 1;
|
||||
}
|
||||
fake = 0;
|
||||
if (!rgb) {
|
||||
bpp = 8;
|
||||
} else if (bpp == 8) {
|
||||
fake = 1;
|
||||
}
|
||||
#if HUGE_LOOKUP
|
||||
else if (bpp < 24) {
|
||||
v_init_pixeltables();
|
||||
}
|
||||
else if (bpp < 24) {
|
||||
v_init_pixeltables();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* initialize hardware */
|
||||
if ((q = v_init_hw()) == NULL) {
|
||||
return 0;
|
||||
}
|
||||
/* initialize hardware */
|
||||
if ((q = v_init_hw()) == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* search for a mode that fits our request */
|
||||
for (min=-1, p=NULL; q->mode!=0xffff; q++) {
|
||||
if ((q->xres>=width) && (q->yres>=height) && (q->bpp==bpp)) {
|
||||
if (min>=(unsigned)(q->xres*q->yres)) {
|
||||
min = q->xres*q->yres;
|
||||
p = q;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* search for a mode that fits our request */
|
||||
for (min = -1, p = NULL; q->mode != 0xffff; q++) {
|
||||
if ((q->xres >= width) && (q->yres >= height) && (q->bpp == bpp)) {
|
||||
if (min >= (unsigned)(q->xres * q->yres)) {
|
||||
min = q->xres * q->yres;
|
||||
p = q;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* setup and enter mode */
|
||||
if ((vl_setup_mode(p) == 0) && (drv->entermode(p, refresh) == 0)) {
|
||||
vl_flip = drv->blit;
|
||||
if (fake) {
|
||||
drv->get(VL_GET_CI_PREC, (int *)(&min));
|
||||
fake_buildpalette(min);
|
||||
if (min == 8) {
|
||||
vl_getrgba = v_getrgba8fake8;
|
||||
}
|
||||
}
|
||||
return bpp;
|
||||
}
|
||||
/* setup and enter mode */
|
||||
if ((vl_setup_mode(p) == 0) && (drv->entermode(p, refresh) == 0)) {
|
||||
vl_flip = drv->blit;
|
||||
if (fake) {
|
||||
drv->get(VL_GET_CI_PREC, (int *)(&min));
|
||||
fake_buildpalette(min);
|
||||
if (min == 8) {
|
||||
vl_getrgba = v_getrgba8fake8;
|
||||
}
|
||||
}
|
||||
return bpp;
|
||||
}
|
||||
|
||||
/* abort */
|
||||
return 0;
|
||||
/* abort */
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue