diff --git a/Makefile b/Makefile index 15c8292..98fa095 100644 --- a/Makefile +++ b/Makefile @@ -207,8 +207,6 @@ I386_GUESS := $(call cc-i386) # Special include/lib dirs # ------------------------- DX_INC = $(TOPDIR)/wine-dx -ST_INC = $(TOPDIR)/scitech/include -ST_LIBDIR = scitech/lib/win32/vc # --------------------------------------- # Define some build variables @@ -702,13 +700,10 @@ endif endif ifeq ($(VID_TARGET),win) CL_CPPFLAGS += -idirafter $(DX_INC) -SW_CPPFLAGS += -idirafter $(ST_INC) SW_OBJS += vid_win.o GL_OBJS += vid_wgl.o -SW_LIBS += mgllt gdi32 # gdi32 needs to come after mgllt -GL_LIBS += gdi32 +CL_LIBS += gdi32 GL_LIBS += comctl32 -SW_LFLAGS += $(call libdir-check,$(ST_LIBDIR)) endif ifeq ($(VID_TARGET),sdl) SW_OBJS += vid_sdl.o sdl_common.o diff --git a/common/sys_win.c b/common/sys_win.c index 758e64d..043d5b5 100644 --- a/common/sys_win.c +++ b/common/sys_win.c @@ -95,9 +95,6 @@ Sys_FileTime(const char *path) FILE *f; int ret; -#ifndef SERVERONLY - int t = VID_ForceUnlockedAndReturnState(); -#endif f = fopen(path, "rb"); if (f) { fclose(f); @@ -105,9 +102,6 @@ Sys_FileTime(const char *path) } else { ret = -1; } -#ifndef SERVERONLY - VID_ForceLockState(t); -#endif return ret; } @@ -206,7 +200,6 @@ Sys_Error(const char *error, ...) if (!in_sys_error3) { in_sys_error3 = 1; - VID_ForceUnlockedAndReturnState(); } va_start(argptr, error); @@ -311,7 +304,6 @@ void Sys_Quit(void) { #ifndef SERVERONLY - VID_ForceUnlockedAndReturnState(); Host_Shutdown(); if (tevent) CloseHandle(tevent); diff --git a/common/vid_win.c b/common/vid_win.c index 7909c32..84ca9c2 100644 --- a/common/vid_win.c +++ b/common/vid_win.c @@ -21,7 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include -#include #include "cdaudio.h" #include "cmd.h" @@ -57,7 +56,6 @@ static void VID_MenuDraw(void); static void VID_MenuKey(int key); static int VID_SetMode(int modenum, unsigned char *palette); -static qboolean dibonly; static qboolean Minimized; qboolean @@ -84,12 +82,10 @@ static DEVMODE gdevmode; static qboolean startwindowed = true, windowed_mode_set = false; static int firstupdate = 1; static qboolean vid_initialized = false, vid_palettized; -static int lockcount; static int vid_fulldib_on_focus_mode; -static qboolean force_minimized, in_mode_set, is_mode0x13, force_mode_set; -static int vid_stretched; -static qboolean palette_changed, pal_is_nostatic; -static qboolean syscolchg, vid_mode_set, hide_window; +static qboolean force_minimized, in_mode_set, force_mode_set; +static qboolean palette_changed; +static qboolean vid_mode_set, hide_window; static HICON hIcon; @@ -131,7 +127,6 @@ static cvar_t vid_windowed_mode = { static cvar_t vid_wait = { "vid_wait", "0" }; static cvar_t vid_nopageflip = { "vid_nopageflip", "0", true }; static cvar_t _vid_wait_override = { "_vid_wait_override", "0", true }; -static cvar_t vid_stretch_by_2 = { "vid_stretch_by_2", "0", true }; static cvar_t block_switch = { "block_switch", "0", true }; static cvar_t vid_window_x = { "vid_window_x", "0", true }; static cvar_t vid_window_y = { "vid_window_y", "0", true }; @@ -143,13 +138,6 @@ typedef struct { int height; } lmode_t; -static lmode_t lowresmodes[] = { - {320, 200}, - {320, 240}, - {400, 300}, - {512, 384}, -}; - static int windowed_default; static int vid_default = VID_MODE_WINDOWED; static int vid_modenum = VID_MODE_NONE; @@ -167,31 +155,18 @@ static unsigned char vid_curpal[256 * 3]; unsigned short d_8to16table[256]; unsigned d_8to24table[256]; -static int driver = grDETECT, mode; -static bool useWinDirect = false, useDirectDraw = true; -static MGLDC *mgldc = NULL, *memdc = NULL, *dibdc = NULL, *windc = NULL; - typedef struct { modestate_t type; int width; int height; int modenum; - int mode13; - int stretched; - int dib; int fullscreen; - int bpp; - int halfscreen; char modedesc[13]; } vmode_t; static vmode_t modelist[MAX_MODE_LIST]; static int nummodes; -static int aPage; // Current active display page -static int vPage; // Current visible display page -static int waitVRT = true; // True to wait for retrace on flip - static vmode_t badmode; static byte backingbuf[48 * 24]; @@ -200,6 +175,106 @@ static void AppActivate(BOOL fActive, BOOL minimize); static LONG WINAPI MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); +typedef struct dibinfo +{ + BITMAPINFOHEADER header; + RGBQUAD acolors[256]; +} dibinfo_t; + + +static HGDIOBJ previously_selected_GDI_obj = NULL; +static HBITMAP hDIBSection; +static unsigned char *pDIBBase = NULL; +static HDC hdcDIBSection = NULL; +static HDC maindc = NULL; + +static void +VID_ShutdownDIB(void) +{ + if (hdcDIBSection) { + SelectObject (hdcDIBSection, previously_selected_GDI_obj); + DeleteDC (hdcDIBSection); + hdcDIBSection = NULL; + } + if (hDIBSection) { + DeleteObject (hDIBSection); + hDIBSection = NULL; + pDIBBase = NULL; + } + if (maindc) { + // if maindc exists mainwindow must also be valid + ReleaseDC (mainwindow, maindc); + maindc = NULL; + } +} + +static void +VID_CreateDIB(int width, int height, unsigned char *palette) +{ + dibinfo_t dibheader; + BITMAPINFO *pbmiDIB = (BITMAPINFO *)&dibheader; + int i; + + maindc = GetDC(mainwindow); + memset(&dibheader, 0, sizeof(dibheader)); + + // fill in the bitmap info + pbmiDIB->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + pbmiDIB->bmiHeader.biWidth = width; + pbmiDIB->bmiHeader.biHeight = height; + pbmiDIB->bmiHeader.biPlanes = 1; + pbmiDIB->bmiHeader.biBitCount = 8; + pbmiDIB->bmiHeader.biCompression = BI_RGB; + pbmiDIB->bmiHeader.biSizeImage = 0; + pbmiDIB->bmiHeader.biXPelsPerMeter = 0; + pbmiDIB->bmiHeader.biYPelsPerMeter = 0; + pbmiDIB->bmiHeader.biClrUsed = 256; + pbmiDIB->bmiHeader.biClrImportant = 256; + + // fill in the palette + for (i = 0; i < 256; i++) { + // d_8to24table isn't filled in yet so this is just for testing + dibheader.acolors[i].rgbRed = palette[i * 3]; + dibheader.acolors[i].rgbGreen = palette[i * 3 + 1]; + dibheader.acolors[i].rgbBlue = palette[i * 3 + 2]; + } + + // create the DIB section + hDIBSection = CreateDIBSection(maindc, pbmiDIB, DIB_RGB_COLORS, + (void **)&pDIBBase, NULL, 0); + + // set video buffers + if (pbmiDIB->bmiHeader.biHeight > 0) { + // bottom up + vid.buffer = pDIBBase + (height - 1) * width; + vid.rowbytes = -width; + } else { + // top down + vid.buffer = pDIBBase; + vid.rowbytes = vid.width; + } + + /* + * set the rest of the buffers we need (why not just use one + * single buffer instead of all this crap? oh well, it's Quake...) + */ + vid.conbuffer = vid.direct = vid.buffer; + + // more crap for the console + vid.conrowbytes = vid.rowbytes; + + // clear the buffer + memset(pDIBBase, 0xff, width * height); + + hdcDIBSection = CreateCompatibleDC(maindc); + if (!hdcDIBSection) + Sys_Error("%s: CreateCompatibleDC failed\n", __func__); + + previously_selected_GDI_obj = SelectObject(hdcDIBSection, hDIBSection); + if (!previously_selected_GDI_obj) + Sys_Error("%s: SelectObject failed\n", __func__); +} + /* ================ VID_RememberWindowPos @@ -340,290 +415,6 @@ VID_AllocBuffers(int width, int height) return true; } - -static void -initFatalError(void) -{ - MGL_exit(); - MGL_fatalError(MGL_errorMsg(MGL_result())); - exit(EXIT_FAILURE); -} - - -static m_int -VID_Suspend(MGLDC *dc, m_int flags) -{ - if (flags & MGL_DEACTIVATE) { - // FIXME: this doesn't currently work on NT - if (block_switch.value && !WinNT) { - return MGL_NO_DEACTIVATE; - } - - S_BlockSound(); - S_ClearBuffer(); - IN_RestoreOriginalMouseState(); - CDAudio_Pause(); - - in_mode_set = true; /* keep WM_PAINT from trying to redraw */ - scr_block_drawing = true; /* don't try to draw while switched away */ - - return MGL_NO_SUSPEND_APP; - - } else if (flags & MGL_REACTIVATE) { - IN_SetQuakeMouseState(); - - /* - * fix the leftover Alt from any Alt-Tab or the like that switched us - * away - */ - ClearAllStates(); - - CDAudio_Resume(); - S_UnblockSound(); - - in_mode_set = false; - vid.recalc_refdef = 1; - scr_block_drawing = false; - - return MGL_NO_SUSPEND_APP; - } - - Sys_Error("%s: called with invalid flags (%x)", __func__, (unsigned)flags); -} - - -static void -registerAllDispDrivers(void) -{ - /* Event though these driver require WinDirect, we register - * them so that they will still be available even if DirectDraw - * is present and the user has disable the high performance - * WinDirect modes. - */ - MGL_registerDriver(MGL_VGA8NAME, VGA8_driver); - - /* Register display drivers */ - if (useWinDirect) { - MGL_registerDriver(MGL_LINEAR8NAME, LINEAR8_driver); - if (!COM_CheckParm("-novbeaf")) - MGL_registerDriver(MGL_ACCEL8NAME, ACCEL8_driver); - } - if (useDirectDraw) - MGL_registerDriver(MGL_DDRAW8NAME, DDRAW8_driver); -} - - -static void -registerAllMemDrivers(void) -{ - /* Register memory context drivers */ - MGL_registerDriver(MGL_PACKED8NAME, PACKED8_driver); -} - - -static void -VID_InitMGLFull(HINSTANCE hInstance) -{ - int i; - int xRes, yRes, bits, lowres, curmode, temp; - int lowstretchedres, stretchedmode, lowstretched; - uchar *m; - - /* - * FIXME: NT is checked for because MGL currently has a bug that causes it - * to try to use WinDirect modes even on NT - */ - if (!WinNT && - (COM_CheckParm("-usewindirect") || COM_CheckParm("-usevesa"))) { - useWinDirect = true; - } - - if (COM_CheckParm("-nodirectdraw") || COM_CheckParm("-noddraw") - || COM_CheckParm("-nodd")) - useDirectDraw = false; - - /* Initialise the MGL */ - MGL_unregisterAllDrivers(); - registerAllDispDrivers(); - registerAllMemDrivers(); - MGL_detectGraph(&driver, &mode); - m = MGL_availableModes(); - - // FIXME - stretched mode may be uninitialised, understand -> fix - stretchedmode = 0; - - if (m[0] != 0xFF) { - lowres = lowstretchedres = 99999; - lowstretched = 0; - curmode = 0; - - // find the lowest-res mode, or a mode we can stretch up to and get - // lowest-res that way - for (i = 0; m[i] != 0xFF; i++) { - MGL_modeResolution(m[i], &xRes, &yRes, &bits); - - if ((bits == 8) && - (xRes <= MAXWIDTH) && - (yRes <= MAXHEIGHT) && (curmode < MAX_MODE_LIST)) { - if (m[i] == grVGA_320x200x256) - is_mode0x13 = true; - - if (!COM_CheckParm("-noforcevga")) { - if (m[i] == grVGA_320x200x256) { - mode = i; - break; - } - } - if (xRes < lowres) { - lowres = xRes; - mode = i; - } - if ((xRes < lowstretchedres) && ((xRes >> 1) >= 320)) { - lowstretchedres = xRes >> 1; - stretchedmode = i; - } - } - curmode++; - } - - // if there's a mode we can stretch by 2 up to, thereby effectively - // getting a lower-res mode than the lowest-res real but still at least - // 320x200, that will be our default mode - if (lowstretchedres < lowres) { - mode = stretchedmode; - lowres = lowstretchedres; - lowstretched = 1; - } - - // build the mode list - // leave room for the low-res stretched mode, if any - nummodes++; // leave room for default mode - - for (i = 0; m[i] != 0xFF; i++) { - MGL_modeResolution(m[i], &xRes, &yRes, &bits); - if ((bits == 8) && - (xRes <= MAXWIDTH) && - (yRes <= MAXHEIGHT) && (nummodes < MAX_MODE_LIST)) { - if (i == mode) { - if (lowstretched) { - stretchedmode = nummodes; - curmode = nummodes++; - } else { - curmode = VID_MODE_FULLSCREEN_DEFAULT; - } - } else { - curmode = nummodes++; - } - - modelist[curmode].type = MS_FULLSCREEN; - modelist[curmode].width = xRes; - modelist[curmode].height = yRes; - sprintf(modelist[curmode].modedesc, "%dx%d", xRes, yRes); - - if (m[i] == grVGA_320x200x256) - modelist[curmode].mode13 = 1; - else - modelist[curmode].mode13 = 0; - - modelist[curmode].modenum = m[i]; - modelist[curmode].stretched = 0; - modelist[curmode].dib = 0; - modelist[curmode].fullscreen = 1; - modelist[curmode].halfscreen = 0; - modelist[curmode].bpp = 8; - } - } - - if (lowstretched) { - modelist[VID_MODE_FULLSCREEN_DEFAULT] = modelist[stretchedmode]; - modelist[VID_MODE_FULLSCREEN_DEFAULT].stretched = 1; - modelist[VID_MODE_FULLSCREEN_DEFAULT].width >>= 1; - modelist[VID_MODE_FULLSCREEN_DEFAULT].height >>= 1; - sprintf(modelist[VID_MODE_FULLSCREEN_DEFAULT].modedesc, "%dx%d", - modelist[VID_MODE_FULLSCREEN_DEFAULT].width, - modelist[VID_MODE_FULLSCREEN_DEFAULT].height); - } - - vid_default = VID_MODE_FULLSCREEN_DEFAULT; - - temp = m[0]; - - if (!MGL_init(&driver, &temp, "")) { - initFatalError(); - } - } - MGL_setSuspendAppCallback(VID_Suspend); -} - - -/* - * Function: createDisplayDC - * Returns: Pointer to the MGL device context to use for the application - * - * Description: Initialises the MGL and creates an appropriate display - * device context to be used by the GUI. This creates and - * apropriate device context depending on the system being - * compile for, and should be the only place where system - * specific code is required. - */ -static MGLDC * -createDisplayDC(int forcemem) -{ - MGLDC *dc; - pixel_format_t pf; - int npages; - - // Start the specified video mode - if (!MGL_changeDisplayMode(mode)) - initFatalError(); - - npages = MGL_availablePages(mode); - - if (npages > 3) - npages = 3; - - if (!COM_CheckParm("-notriplebuf")) { - if (npages > 2) - npages = 2; - } - - if ((dc = MGL_createDisplayDC(npages)) == NULL) - return NULL; - - if (!forcemem && (MGL_surfaceAccessType(dc)) == MGL_LINEAR_ACCESS - && (dc->mi.maxPage > 0)) { - MGL_makeCurrentDC(dc); - memdc = NULL; - } else { - // Set up for blitting from a memory buffer - memdc = - MGL_createMemoryDC(MGL_sizex(dc) + 1, MGL_sizey(dc) + 1, 8, &pf); - MGL_makeCurrentDC(memdc); - } - - // Enable page flipping even for even for blitted surfaces - if (forcemem) { - vid.numpages = 1; - } else { - vid.numpages = dc->mi.maxPage + 1; - if (vid.numpages > 1) { - // Set up for page flipping - MGL_setActivePage(dc, aPage = 1); - MGL_setVisualPage(dc, vPage = 0, false); - } - if (vid.numpages > 3) - vid.numpages = 3; - } - - if (vid.numpages == 2) - waitVRT = true; - else - waitVRT = false; - - return dc; -} - - static void InitWindowedMode(vmode_t *mode, int num, int width, int height) { @@ -631,27 +422,22 @@ InitWindowedMode(vmode_t *mode, int num, int width, int height) mode->width = width; mode->height = height; snprintf(mode->modedesc, sizeof(mode->modedesc), "%dx%d", width, height); - mode->mode13 = 0; mode->modenum = num; - mode->stretched = 0; - mode->dib = 1; mode->fullscreen = 0; - mode->halfscreen = 0; - mode->bpp = 8; } - static void -VID_InitMGLDIB(HINSTANCE hInstance) +VID_InitModes(HINSTANCE hInstance) { WNDCLASS wc; HDC hdc; + int width; hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON2)); /* Register the frame class */ - wc.style = 0; - wc.lpfnWndProc = (WNDPROC) MainWndProc; + wc.style = CS_OWNDC; + wc.lpfnWndProc = (WNDPROC)MainWndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; @@ -664,105 +450,80 @@ VID_InitMGLDIB(HINSTANCE hInstance) if (!RegisterClass(&wc)) Sys_Error("Couldn't register window class"); - /* Find the size for the DIB window */ - /* Initialise the MGL for windowed operation */ - MGL_setAppInstance(hInstance); - registerAllMemDrivers(); - MGL_initWindowed(""); - InitWindowedMode(&modelist[0], 0, 320, 240); InitWindowedMode(&modelist[1], 1, 640, 480); InitWindowedMode(&modelist[2], 2, 800, 600); InitWindowedMode(&modelist[3], 3, 1024, 768); InitWindowedMode(&modelist[4], 4, 1280, 960); -// automatically stretch the default mode up if > 640x480 desktop resolution + /* + * automatically stretch the default mode up if > 640x480 desktop + * resolution + */ hdc = GetDC(NULL); - - /* FIXME - what is this test for? */ - if ((GetDeviceCaps(hdc, HORZRES) > 640) - && !COM_CheckParm("-noautostretch")) { + width = GetDeviceCaps(hdc, HORZRES); + if (width > 800 && !COM_CheckParm("-noautostretch")) + vid_default = VID_MODE_WINDOWED + 2; + else if (width > 640 && !COM_CheckParm("-noautostretch")) vid_default = VID_MODE_WINDOWED + 1; - } else { + else vid_default = VID_MODE_WINDOWED; - } windowed_default = vid_default; ReleaseDC(NULL, hdc); nummodes = NUM_WINDOWED_MODES; - DDActive = 0; } - /* ================= -VID_InitFullDIB +VID_GetDisplayModes ================= */ static void -VID_InitFullDIB(HINSTANCE hInstance) +VID_GetDisplayModes(void) { DEVMODE devmode; - int i, j, modenum, existingmode, originalnummodes, lowestres; - int numlowresmodes, bpp, done; - int cstretch, istretch, mstretch; + int i, modenum, originalnummodes, lowestres; BOOL stat; + LONG result; -// enumerate 8 bpp modes + /* enumerate > 8 bpp modes */ originalnummodes = nummodes; modenum = 0; - lowestres = 99999; + lowestres = 999999; do { stat = EnumDisplaySettings(NULL, modenum, &devmode); - if ((devmode.dmBitsPerPel == 8) && - (devmode.dmPelsWidth <= MAXWIDTH) && - (devmode.dmPelsHeight <= MAXHEIGHT) && - (nummodes < MAX_MODE_LIST)) { + if (devmode.dmPelsWidth <= MAXWIDTH && + devmode.dmPelsHeight <= MAXHEIGHT && + devmode.dmPelsWidth >= 640 && + devmode.dmPelsHeight >= 480 && + nummodes < MAX_MODE_LIST) { devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; - if (ChangeDisplaySettings(&devmode, CDS_TEST | CDS_FULLSCREEN) == - DISP_CHANGE_SUCCESSFUL) { + result = ChangeDisplaySettings(&devmode, CDS_TEST | CDS_FULLSCREEN); + if (result == DISP_CHANGE_SUCCESSFUL) { modelist[nummodes].type = MS_FULLDIB; modelist[nummodes].width = devmode.dmPelsWidth; modelist[nummodes].height = devmode.dmPelsHeight; modelist[nummodes].modenum = 0; - modelist[nummodes].mode13 = 0; - modelist[nummodes].stretched = 0; - modelist[nummodes].halfscreen = 0; - modelist[nummodes].dib = 1; modelist[nummodes].fullscreen = 1; - modelist[nummodes].bpp = devmode.dmBitsPerPel; sprintf(modelist[nummodes].modedesc, "%ldx%ld", devmode.dmPelsWidth, devmode.dmPelsHeight); - // if the width is more than twice the height, reduce it by - // half because this is probably a dual-screen monitor - if (!COM_CheckParm("-noadjustaspect")) { - if (modelist[nummodes].width > - (modelist[nummodes].height << 1)) { - modelist[nummodes].width >>= 1; - modelist[nummodes].halfscreen = 1; - sprintf(modelist[nummodes].modedesc, "%dx%d", - modelist[nummodes].width, - modelist[nummodes].height); - } - } - - for (i = originalnummodes, existingmode = 0; i < nummodes; - i++) { - if ((modelist[nummodes].width == modelist[i].width) - && (modelist[nummodes].height == modelist[i].height)) { - existingmode = 1; + /* + * see is the mode already there (same dimensions but + * different refresh rate) + */ + for (i = originalnummodes; i < nummodes; i++) { + if (modelist[nummodes].width == modelist[i].width + && modelist[nummodes].height == modelist[i].height) break; - } } - - if (!existingmode) { + if (i == nummodes) { if (modelist[nummodes].width < lowestres) lowestres = modelist[nummodes].width; - nummodes++; } } @@ -771,197 +532,20 @@ VID_InitFullDIB(HINSTANCE hInstance) modenum++; } while (stat); -// see if any of them were actually settable; if so, this is our mode list, -// else enumerate all modes; our mode list is whichever ones are settable -// with > 8 bpp - if (nummodes == originalnummodes) { - modenum = 0; - lowestres = 99999; - - Con_SafePrintf("No 8-bpp fullscreen DIB modes found\n"); - - do { - stat = EnumDisplaySettings(NULL, modenum, &devmode); - - if ((((devmode.dmPelsWidth <= MAXWIDTH) && - (devmode.dmPelsHeight <= MAXHEIGHT)) || - (!COM_CheckParm("-noadjustaspect") && - (devmode.dmPelsWidth <= (MAXWIDTH * 2)) && - (devmode.dmPelsWidth > (devmode.dmPelsHeight * 2)))) && - (nummodes < MAX_MODE_LIST) && (devmode.dmBitsPerPel > 8)) { - devmode.dmFields = DM_BITSPERPEL | - DM_PELSWIDTH | DM_PELSHEIGHT; - - if (ChangeDisplaySettings - (&devmode, - CDS_TEST | CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL) { - modelist[nummodes].type = MS_FULLDIB; - modelist[nummodes].width = devmode.dmPelsWidth; - modelist[nummodes].height = devmode.dmPelsHeight; - modelist[nummodes].modenum = 0; - modelist[nummodes].mode13 = 0; - modelist[nummodes].stretched = 0; - modelist[nummodes].halfscreen = 0; - modelist[nummodes].dib = 1; - modelist[nummodes].fullscreen = 1; - modelist[nummodes].bpp = devmode.dmBitsPerPel; - sprintf(modelist[nummodes].modedesc, "%ldx%ld", - devmode.dmPelsWidth, devmode.dmPelsHeight); - - // if the width is more than twice the height, reduce it by - // half because this is probably a dual-screen monitor - if (!COM_CheckParm("-noadjustaspect")) { - if (modelist[nummodes].width > - (modelist[nummodes].height * 2)) { - modelist[nummodes].width >>= 1; - modelist[nummodes].halfscreen = 1; - sprintf(modelist[nummodes].modedesc, "%dx%d", - modelist[nummodes].width, - modelist[nummodes].height); - } - } - - for (i = originalnummodes, existingmode = 0; i < nummodes; - i++) { - if ((modelist[nummodes].width == modelist[i].width) - && (modelist[nummodes].height == - modelist[i].height)) { - // pick the lowest available bpp - if (modelist[nummodes].bpp < modelist[i].bpp) - modelist[i] = modelist[nummodes]; - - existingmode = 1; - break; - } - } - - if (!existingmode) { - if (modelist[nummodes].width < lowestres) - lowestres = modelist[nummodes].width; - - nummodes++; - } - } - } - - modenum++; - } while (stat); - } -// see if there are any low-res modes that aren't being reported - numlowresmodes = sizeof(lowresmodes) / sizeof(lowresmodes[0]); - bpp = 8; - done = 0; - -// first make sure the driver doesn't just answer yes to all tests - devmode.dmBitsPerPel = 8; - devmode.dmPelsWidth = 42; - devmode.dmPelsHeight = 37; - devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; - - if (ChangeDisplaySettings(&devmode, CDS_TEST | CDS_FULLSCREEN) == - DISP_CHANGE_SUCCESSFUL) { - done = 1; - } - - while (!done) { - for (j = 0; (j < numlowresmodes) && (nummodes < MAX_MODE_LIST); j++) { - devmode.dmBitsPerPel = bpp; - devmode.dmPelsWidth = lowresmodes[j].width; - devmode.dmPelsHeight = lowresmodes[j].height; - devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; - - if (ChangeDisplaySettings(&devmode, CDS_TEST | CDS_FULLSCREEN) == - DISP_CHANGE_SUCCESSFUL) { - modelist[nummodes].type = MS_FULLDIB; - modelist[nummodes].width = devmode.dmPelsWidth; - modelist[nummodes].height = devmode.dmPelsHeight; - modelist[nummodes].modenum = 0; - modelist[nummodes].mode13 = 0; - modelist[nummodes].stretched = 0; - modelist[nummodes].halfscreen = 0; - modelist[nummodes].dib = 1; - modelist[nummodes].fullscreen = 1; - modelist[nummodes].bpp = devmode.dmBitsPerPel; - sprintf(modelist[nummodes].modedesc, "%ldx%ld", - devmode.dmPelsWidth, devmode.dmPelsHeight); - - // we only want the lowest-bpp version of each mode - for (i = originalnummodes, existingmode = 0; i < nummodes; - i++) { - if ((modelist[nummodes].width == modelist[i].width) - && (modelist[nummodes].height == modelist[i].height) - && (modelist[nummodes].bpp >= modelist[i].bpp)) { - existingmode = 1; - break; - } - } - - if (!existingmode) { - if (modelist[nummodes].width < lowestres) - lowestres = modelist[nummodes].width; - - nummodes++; - } - } - } - - switch (bpp) { - case 8: - bpp = 16; - break; - - case 16: - bpp = 32; - break; - - case 32: - done = 1; - break; - } - } - - /* - * Now add the lowest stretch-by-2 pseudo-modes between 320-wide - * (inclusive) and lowest real res (not inclusive). Don't bother if we - * have a real VGA mode 0x13 mode - */ - if (!is_mode0x13) { - mstretch = 0; // FIXME - Uninitialized - cstretch = 0; // FIXME - Uninitialized - for (i = originalnummodes; i < nummodes; i++) { - if (((modelist[i].width >> 1) < lowestres) && - ((modelist[i].width >> 1) >= 320)) { - lowestres = modelist[i].width >> 1; - cstretch = 1; - mstretch = i; - } - } - - if ((nummodes + cstretch) > MAX_MODE_LIST) - cstretch = MAX_MODE_LIST - nummodes; - - if (cstretch > 0) { - for (i = (nummodes - 1); i >= originalnummodes; i--) - modelist[i + cstretch] = modelist[i]; - - nummodes += cstretch; - istretch = originalnummodes; - - modelist[istretch] = modelist[mstretch]; - modelist[istretch].width >>= 1; - modelist[istretch].height >>= 1; - modelist[istretch].stretched = 1; - sprintf(modelist[istretch].modedesc, "%dx%d", - modelist[istretch].width, modelist[istretch].height); - } - } - - if (nummodes != originalnummodes) - vid_default = VID_MODE_FULLSCREEN_DEFAULT; - else + if (nummodes == originalnummodes) Con_SafePrintf("No fullscreen DIB modes found\n"); } +static void +VID_DestroyWindow (void) +{ + if (modestate == MS_FULLDIB) + ChangeDisplaySettings (NULL, CDS_FULLSCREEN); + + VID_ShutdownDIB (); +} + + /* ================= @@ -989,47 +573,6 @@ VID_GetModePtr(int modenum) return &badmode; } - -/* -====================== -VID_CheckModedescFixup -====================== -*/ -static void -VID_CheckModedescFixup(int mode) -{ -#if 0 - int x, y, stretch; - - /* - * FIXME - assuming JC had a purpose for this? - * Ok, so this was only done for 800x600 originally. - * default vid_config_x == 800, vid_config_y == 600 - * These two cvars do nothing else, so... wtf? - */ - if (mode == VID_MODE_SETTABLE_WINDOW /* VID_MODE_WINDOWED + 2 */) { - modelist[mode].stretched = ((int)vid_stretch_by_2.value) ? 1 : 0; - stretch = modelist[mode].stretched; - - /* Make sure vid_config_{x,y} are big enough to hold the lowest vid - mode with current stretch settings. wtf? */ - if (vid_config_x.value < (320 << stretch)) - vid_config_x.value = 320 << stretch; - if (vid_config_y.value < (200 << stretch)) - vid_config_y.value = 200 << stretch; - - x = (int)vid_config_x.value; - y = (int)vid_config_y.value; - - sprintf(modelist[mode].modedesc, "%dx%d", x, y); - - modelist[mode].width = x; - modelist[mode].height = y; - } -#endif -} - - /* ================= VID_GetModeDescriptionMemCheck @@ -1044,8 +587,6 @@ VID_GetModeDescriptionMemCheck(int mode) if ((mode < 0) || (mode >= nummodes)) return NULL; - VID_CheckModedescFixup(mode); - pv = VID_GetModePtr(mode); pinfo = pv->modedesc; @@ -1071,8 +612,6 @@ VID_GetModeDescription(int mode) if ((mode < 0) || (mode >= nummodes)) return NULL; - VID_CheckModedescFixup(mode); - pv = VID_GetModePtr(mode); pinfo = pv->modedesc; return pinfo; @@ -1095,8 +634,6 @@ VID_GetModeDescription2(int mode) if ((mode < 0) || (mode >= nummodes)) return NULL; - VID_CheckModedescFixup(mode); - pv = VID_GetModePtr(mode); if (modelist[mode].type == MS_FULLSCREEN) { @@ -1110,87 +647,9 @@ VID_GetModeDescription2(int mode) return pinfo; } - -// KJB: Added this to return the mode driver name in description for console -static char * -VID_GetExtModeDescription(int mode) -{ - static char pinfo[40]; - vmode_t *pv; - - if ((mode < 0) || (mode >= nummodes)) - return NULL; - - VID_CheckModedescFixup(mode); - - pv = VID_GetModePtr(mode); - if (modelist[mode].type == MS_FULLSCREEN) { - sprintf(pinfo, "%s fullscreen %s", pv->modedesc, - MGL_modeDriverName(pv->modenum)); - } else if (modelist[mode].type == MS_FULLDIB) { - sprintf(pinfo, "%s fullscreen DIB", pv->modedesc); - } else { - sprintf(pinfo, "%s windowed", pv->modedesc); - } - - return pinfo; -} - - -static void -DestroyDIBWindow(void) -{ - - if (modestate == MS_WINDOWED) { - // destroy the associated MGL DC's; the window gets reused - if (windc) - MGL_destroyDC(windc); - if (dibdc) - MGL_destroyDC(dibdc); - windc = dibdc = NULL; - } -} - - -static void -DestroyFullscreenWindow(void) -{ - - if (modestate == MS_FULLSCREEN) { - // destroy the existing fullscreen mode and DC's - if (mgldc) - MGL_destroyDC(mgldc); - if (memdc) - MGL_destroyDC(memdc); - mgldc = memdc = NULL; - } -} - - - -static void -DestroyFullDIBWindow(void) -{ - if (modestate == MS_FULLDIB) { - ChangeDisplaySettings(NULL, CDS_FULLSCREEN); - - // Destroy the fullscreen DIB window and associated MGL DC's - if (windc) - MGL_destroyDC(windc); - if (dibdc) - MGL_destroyDC(dibdc); - windc = dibdc = NULL; - } -} - - static qboolean VID_SetWindowedMode(int modenum) { - HDC hdc; - pixel_format_t pf; - qboolean stretched; - if (!windowed_mode_set) { if (COM_CheckParm("-resetwinpos")) { Cvar_SetValue("vid_window_x", 0.0); @@ -1199,44 +658,22 @@ VID_SetWindowedMode(int modenum) windowed_mode_set = true; } - VID_CheckModedescFixup(modenum); - - DDActive = 0; - - DestroyFullscreenWindow(); - DestroyFullDIBWindow(); - - if (windc) - MGL_destroyDC(windc); - if (dibdc) - MGL_destroyDC(dibdc); - windc = dibdc = NULL; - -// KJB: Signal to the MGL that we are going back to windowed mode - if (!MGL_changeDisplayMode(grWINDOWED)) - initFatalError(); + VID_DestroyWindow(); WindowRect.top = WindowRect.left = 0; - WindowRect.right = modelist[modenum].width; WindowRect.bottom = modelist[modenum].height; - stretched = modelist[modenum].stretched; - DIBWidth = modelist[modenum].width; DIBHeight = modelist[modenum].height; - - if (stretched) { - DIBWidth >>= 1; - DIBHeight >>= 1; - } - WindowStyle = WS_OVERLAPPED | WS_BORDER | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; ExWindowStyle = 0; AdjustWindowRectEx(&WindowRect, WindowStyle, FALSE, 0); -// the first time we're called to set the mode, create the window we'll use -// for the rest of the session + /* + * the first time we're called to set the mode, create the window + * we'll use for the rest of the session + */ if (!vid_mode_set) { mainwindow = CreateWindowEx(ExWindowStyle, "TyrQuake", @@ -1250,9 +687,6 @@ VID_SetWindowedMode(int modenum) if (!mainwindow) Sys_Error("Couldn't create DIB window"); - // tell MGL to use this window for fullscreen modes - MGL_registerFullScreenWindow(mainwindow); - vid_mode_set = true; } else { SetWindowLong(mainwindow, GWL_STYLE, WindowStyle | WS_VISIBLE); @@ -1271,7 +705,7 @@ VID_SetWindowedMode(int modenum) if (hide_window) return true; -// position and show the DIB window + /* position and show the DIB window */ VID_CheckWindowXY(); SetWindowPos(mainwindow, NULL, (int)vid_window_x.value, (int)vid_window_y.value, 0, 0, @@ -1283,29 +717,9 @@ VID_SetWindowedMode(int modenum) ShowWindow(mainwindow, SW_SHOWDEFAULT); UpdateWindow(mainwindow); - modestate = MS_WINDOWED; vid_fulldib_on_focus_mode = 0; -// because we have set the background brush for the window to NULL -// (to avoid flickering when re-sizing the window on the desktop), -// we clear the window to black when created, otherwise it will be -// empty while Quake starts up. - hdc = GetDC(mainwindow); - PatBlt(hdc, 0, 0, WindowRect.right, WindowRect.bottom, BLACKNESS); - ReleaseDC(mainwindow, hdc); - - /* Create the MGL window DC and the MGL memory DC */ - if ((windc = MGL_createWindowedDC(mainwindow)) == NULL) - MGL_fatalError("Unable to create Windowed DC!"); - - if ((dibdc = MGL_createMemoryDC(DIBWidth, DIBHeight, 8, &pf)) == NULL) - MGL_fatalError("Unable to create Memory DC!"); - - MGL_makeCurrentDC(dibdc); - - vid.buffer = vid.conbuffer = vid.direct = dibdc->surface; - vid.rowbytes = vid.conrowbytes = dibdc->mi.bytesPerLine; vid.numpages = 1; vid.maxwarpwidth = WARP_WIDTH; vid.maxwarpheight = WARP_HEIGHT; @@ -1313,117 +727,41 @@ VID_SetWindowedMode(int modenum) vid.width = vid.conwidth = DIBWidth; vid.aspect = ((float)vid.height / (float)vid.width) * (320.0 / 240.0); - vid_stretched = stretched; - - SendMessage(mainwindow, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)hIcon); - SendMessage(mainwindow, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)hIcon); + SendMessage(mainwindow, WM_SETICON, (WPARAM)TRUE, (LPARAM)hIcon); + SendMessage(mainwindow, WM_SETICON, (WPARAM)FALSE, (LPARAM)hIcon); return true; } - -static qboolean -VID_SetFullscreenMode(int modenum) -{ - DDActive = 1; - - DestroyDIBWindow(); - DestroyFullDIBWindow(); - - mode = modelist[modenum].modenum; - - // Destroy old DC's, resetting back to fullscreen mode - if (mgldc) - MGL_destroyDC(mgldc); - if (memdc) - MGL_destroyDC(memdc); - mgldc = memdc = NULL; - - if ((mgldc = createDisplayDC(modelist[modenum].stretched || - (int)vid_nopageflip.value)) == NULL) { - return false; - } - - modestate = MS_FULLSCREEN; - vid_fulldib_on_focus_mode = 0; - - vid.buffer = vid.conbuffer = vid.direct = NULL; - vid.maxwarpwidth = WARP_WIDTH; - vid.maxwarpheight = WARP_HEIGHT; - DIBHeight = vid.height = vid.conheight = modelist[modenum].height; - DIBWidth = vid.width = vid.conwidth = modelist[modenum].width; - vid.aspect = ((float)vid.height / (float)vid.width) * (320.0 / 240.0); - - vid_stretched = modelist[modenum].stretched; - -// needed because we're not getting WM_MOVE messages fullscreen on NT - window_x = 0; - window_y = 0; - -// set the large icon, so the Quake icon will show up in the taskbar - SendMessage(mainwindow, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)hIcon); - SendMessage(mainwindow, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)hIcon); - -// shouldn't be needed, but Kendall needs to let us get the activation -// message for this not to be needed on NT - AppActivate(true, false); - - return true; -} - - static qboolean VID_SetFullDIBMode(int modenum) { - HDC hdc; - pixel_format_t pf; + LONG result; - DDActive = 0; - - DestroyFullscreenWindow(); - DestroyDIBWindow(); - - if (windc) - MGL_destroyDC(windc); - if (dibdc) - MGL_destroyDC(dibdc); - windc = dibdc = NULL; - -// KJB: Signal to the MGL that we are going back to windowed mode - if (!MGL_changeDisplayMode(grWINDOWED)) - initFatalError(); + VID_DestroyWindow(); gdevmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; - gdevmode.dmBitsPerPel = modelist[modenum].bpp; - gdevmode.dmPelsWidth = - modelist[modenum].width << modelist[modenum]. - stretched << modelist[modenum].halfscreen; - gdevmode.dmPelsHeight = - modelist[modenum].height << modelist[modenum].stretched; + gdevmode.dmPelsWidth = modelist[modenum].width; + gdevmode.dmPelsHeight = modelist[modenum].height; gdevmode.dmSize = sizeof(gdevmode); - if (ChangeDisplaySettings(&gdevmode, CDS_FULLSCREEN) != - DISP_CHANGE_SUCCESSFUL) + result = ChangeDisplaySettings(&gdevmode, CDS_FULLSCREEN); + if (result != DISP_CHANGE_SUCCESSFUL) Sys_Error("Couldn't set fullscreen DIB mode"); modestate = MS_FULLDIB; vid_fulldib_on_focus_mode = modenum; - WindowRect.top = WindowRect.left = 0; - hdc = GetDC(NULL); - - WindowRect.right = modelist[modenum].width << modelist[modenum].stretched; - WindowRect.bottom = - modelist[modenum].height << modelist[modenum].stretched; - - ReleaseDC(NULL, hdc); + WindowRect.right = modelist[modenum].width; + WindowRect.bottom = modelist[modenum].height; DIBWidth = modelist[modenum].width; DIBHeight = modelist[modenum].height; WindowStyle = WS_POPUP | WS_SYSMENU | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; ExWindowStyle = 0; + AdjustWindowRectEx(&WindowRect, WindowStyle, FALSE, 0); SetWindowLong(mainwindow, GWL_STYLE, WindowStyle | WS_VISIBLE); @@ -1437,31 +775,13 @@ VID_SetFullDIBMode(int modenum) SWP_NOCOPYBITS | SWP_NOZORDER)) { Sys_Error("Couldn't resize DIB window"); } -// position and show the DIB window + + /* position and show the DIB window */ SetWindowPos(mainwindow, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW | SWP_DRAWFRAME); ShowWindow(mainwindow, SW_SHOWDEFAULT); UpdateWindow(mainwindow); - // Because we have set the background brush for the window to NULL - // (to avoid flickering when re-sizing the window on the desktop), we - // clear the window to black when created, otherwise it will be - // empty while Quake starts up. - hdc = GetDC(mainwindow); - PatBlt(hdc, 0, 0, WindowRect.right, WindowRect.bottom, BLACKNESS); - ReleaseDC(mainwindow, hdc); - - /* Create the MGL window DC and the MGL memory DC */ - if ((windc = MGL_createWindowedDC(mainwindow)) == NULL) - MGL_fatalError("Unable to create Fullscreen DIB DC!"); - - if ((dibdc = MGL_createMemoryDC(DIBWidth, DIBHeight, 8, &pf)) == NULL) - MGL_fatalError("Unable to create Memory DC!"); - - MGL_makeCurrentDC(dibdc); - - vid.buffer = vid.conbuffer = vid.direct = dibdc->surface; - vid.rowbytes = vid.conrowbytes = dibdc->mi.bytesPerLine; vid.numpages = 1; vid.maxwarpwidth = WARP_WIDTH; vid.maxwarpheight = WARP_HEIGHT; @@ -1469,9 +789,7 @@ VID_SetFullDIBMode(int modenum) vid.width = vid.conwidth = DIBWidth; vid.aspect = ((float)vid.height / (float)vid.width) * (320.0 / 240.0); - vid_stretched = modelist[modenum].stretched; - -// needed because we're not getting WM_MOVE messages fullscreen on NT + /* needed because we're not getting WM_MOVE messages fullscreen on NT */ window_x = 0; window_y = 0; @@ -1495,7 +813,6 @@ VID_RestoreOldMode(int original_mode) if (!VID_SetMode(original_mode, vid_curpal)) { vid_modenum = VID_MODE_NONE; - if (!VID_SetMode(windowed_default, vid_curpal)) Sys_Error("Can't set any video mode"); } @@ -1562,18 +879,17 @@ VID_SetMode(int modenum, unsigned char *palette) IN_ShowMouse(); stat = VID_SetWindowedMode(modenum); } - } else if (modelist[modenum].type == MS_FULLDIB) { - stat = VID_SetFullDIBMode(modenum); - IN_ActivateMouse(); - IN_HideMouse(); } else { - stat = VID_SetFullscreenMode(modenum); + stat = VID_SetFullDIBMode(modenum); IN_ActivateMouse(); IN_HideMouse(); } - window_width = vid.width << vid_stretched; - window_height = vid.height << vid_stretched; + /* Create the DIB */ + VID_CreateDIB(DIBWidth, DIBHeight, palette); + + window_width = vid.width; + window_height = vid.height; VID_UpdateWindowStatus(); CDAudio_Resume(); @@ -1625,6 +941,7 @@ VID_SetMode(int modenum, unsigned char *palette) } Sleep(100); + if (!force_minimized) { SetWindowPos(mainwindow, HWND_TOP, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW @@ -1641,160 +958,41 @@ VID_SetMode(int modenum, unsigned char *palette) VID_GetModeDescription(vid_modenum)); VID_SetPalette(palette); - in_mode_set = false; vid.recalc_refdef = 1; return true; } -void -VID_LockBuffer(void) -{ - if (dibdc) - return; - - lockcount++; - - if (lockcount > 1) - return; - - MGL_beginDirectAccess(); - - if (memdc) { - /* Update surface pointer for linear access modes */ - vid.buffer = vid.conbuffer = vid.direct = memdc->surface; - vid.rowbytes = vid.conrowbytes = memdc->mi.bytesPerLine; - } else if (mgldc) { - /* Update surface pointer for linear access modes */ - vid.buffer = vid.conbuffer = vid.direct = mgldc->surface; - vid.rowbytes = vid.conrowbytes = mgldc->mi.bytesPerLine; - } - - if (r_dowarp) - d_viewbuffer = r_warpbuffer; - else - d_viewbuffer = (void *)(byte *)vid.buffer; - - if (r_dowarp) - screenwidth = WARP_WIDTH; - else - screenwidth = vid.rowbytes; -} - - -void -VID_UnlockBuffer(void) -{ - if (dibdc) - return; - - lockcount--; - - if (lockcount > 0) - return; - - if (lockcount < 0) - Sys_Error("Unbalanced unlock"); - - MGL_endDirectAccess(); - - /* to turn up any unlocked accesses */ - vid.buffer = vid.conbuffer = vid.direct = d_viewbuffer = NULL; -} - - -int -VID_ForceUnlockedAndReturnState(void) -{ - int lk; - - if (!lockcount) - return 0; - - lk = lockcount; - - if (dibdc) { - lockcount = 0; - } else { - lockcount = 1; - VID_UnlockBuffer(); - } - - return lk; -} - - -void -VID_ForceLockState(int lk) -{ - if (!dibdc && lk) { - lockcount = 0; - VID_LockBuffer(); - } - lockcount = lk; -} - - void VID_SetPalette(unsigned char *palette) { INT i; - palette_t pal[256]; - HDC hdc; + RGBQUAD colors[256]; + unsigned char *pal; - if (window_visible()) { - palette_changed = true; - - // make sure we have the static colors if we're the active app - hdc = GetDC(NULL); - - if (vid_palettized && ActiveApp) { - if (GetSystemPaletteUse(hdc) == SYSPAL_STATIC) { - // switch to SYSPAL_NOSTATIC and remap the colors - SetSystemPaletteUse(hdc, SYSPAL_NOSTATIC); - syscolchg = true; - pal_is_nostatic = true; - } + if (window_visible() && hdcDIBSection) { + /* incoming palette is 3 component */ + pal = palette + 3; + for (i = 1; i < 255; i++, pal += 3) { + colors[i].rgbRed = pal[0]; + colors[i].rgbGreen = pal[1]; + colors[i].rgbBlue = pal[2]; + colors[i].rgbReserved = 0; } - ReleaseDC(NULL, hdc); + colors[0].rgbRed = 0; + colors[0].rgbGreen = 0; + colors[0].rgbBlue = 0; + colors[255].rgbRed = 0xff; + colors[255].rgbGreen = 0xff; + colors[255].rgbBlue = 0xff; - // Translate the palette values to an MGL palette array and - // set the values. - for (i = 0; i < 256; i++) { - pal[i].red = palette[i * 3]; - pal[i].green = palette[i * 3 + 1]; - pal[i].blue = palette[i * 3 + 2]; - } - - if (DDActive) { - if (!mgldc) - return; - - MGL_setPalette(mgldc, pal, 256, 0); - MGL_realizePalette(mgldc, 256, 0, false); - if (memdc) - MGL_setPalette(memdc, pal, 256, 0); - } else { - if (!windc) - return; - - MGL_setPalette(windc, pal, 256, 0); - MGL_realizePalette(windc, 256, 0, false); - if (dibdc) { - MGL_setPalette(dibdc, pal, 256, 0); - MGL_realizePalette(dibdc, 256, 0, false); - } - } + if (!SetDIBColorTable(hdcDIBSection, 0, 256, colors)) + Con_SafePrintf("%s: SetDIBColorTable failed\n", __func__); } memcpy(vid_curpal, palette, sizeof(vid_curpal)); - - if (syscolchg) { - PostMessage(HWND_BROADCAST, WM_SYSCOLORCHANGE, (WPARAM)0, (LPARAM)0); - syscolchg = false; - } } @@ -1813,7 +1011,7 @@ VID_DescribeCurrentMode_f static void VID_DescribeCurrentMode_f(void) { - Con_Printf("%s\n", VID_GetExtModeDescription(vid_modenum)); + Con_Printf("%s\n", VID_GetModeDescription2(vid_modenum)); } @@ -1843,7 +1041,7 @@ VID_DescribeMode_f(void) int modenum; modenum = Q_atoi(Cmd_Argv(1)); - Con_Printf("%s\n", VID_GetExtModeDescription(modenum)); + Con_Printf("%s\n", VID_GetModeDescription2(modenum)); } @@ -1866,7 +1064,7 @@ VID_DescribeModes_f(void) for (i = 0; i < lnummodes; i++) { pv = VID_GetModePtr(i); - pinfo = VID_GetExtModeDescription(i); + pinfo = VID_GetModeDescription2(i); if (VID_CheckAdequateMem(pv->width, pv->height)) { Con_Printf("%2d: %s\n", i, pinfo); @@ -1971,7 +1169,6 @@ void VID_Init(unsigned char *palette) { int i, bestmatch, bestmatchmetric, t, dr, dg, db; - int basenummodes; byte *ptmp; Cvar_RegisterVariable(&vid_mode); @@ -1980,7 +1177,6 @@ VID_Init(unsigned char *palette) Cvar_RegisterVariable(&_vid_wait_override); Cvar_RegisterVariable(&_vid_default_mode); Cvar_RegisterVariable(&_vid_default_mode_win); - Cvar_RegisterVariable(&vid_stretch_by_2); Cvar_RegisterVariable(&_windowed_mouse); Cvar_RegisterVariable(&vid_fullscreen_mode); Cvar_RegisterVariable(&vid_windowed_mode); @@ -1998,23 +1194,9 @@ VID_Init(unsigned char *palette) Cmd_AddCommand("vid_fullscreen", VID_Fullscreen_f); Cmd_AddCommand("vid_minimize", VID_Minimize_f); - if (COM_CheckParm("-dibonly")) - dibonly = true; - VID_InitMGLDIB(global_hInstance); - - basenummodes = nummodes; - - if (!dibonly) - VID_InitMGLFull(global_hInstance); - -// if there are no non-windowed modes, or only windowed and mode 0x13, then use -// fullscreen DIBs as well - if (((nummodes == basenummodes) || - ((nummodes == (basenummodes + 1)) && is_mode0x13)) && - !COM_CheckParm("-nofulldib")) { - VID_InitFullDIB(global_hInstance); - } + VID_InitModes(global_hInstance); + VID_GetDisplayModes(); vid.maxwarpwidth = WARP_WIDTH; vid.maxwarpheight = WARP_HEIGHT; @@ -2022,10 +1204,12 @@ VID_Init(unsigned char *palette) vid.fullbright = 256 - LittleLong(*((int *)vid.colormap + 2048)); vid_testingmode = 0; -// GDI doesn't let us remap palette index 0, so we'll remap color -// mappings from that black to another one + /* + * GDI doesn't let us remap palette index 0, so we'll remap color + * mappings from that black to another one + */ bestmatchmetric = 256 * 256 * 3; - bestmatch = 0; // FIXME - uninitialized -> guessing 0... + bestmatch = 0; for (i = 1; i < 256; i++) { dr = palette[0] - palette[i * 3]; @@ -2048,18 +1232,22 @@ VID_Init(unsigned char *palette) *ptmp = bestmatch; } + startwindowed = 1; + vid_default = windowed_default; + if (hwnd_dialog) DestroyWindow(hwnd_dialog); /* keep the window minimized until we're ready for the first mode set */ + hide_window = true; + VID_SetMode(VID_MODE_WINDOWED, palette); hide_window = false; - if (!VID_SetMode(VID_MODE_WINDOWED, palette)) { - force_mode_set = true; - VID_SetMode(vid_default, palette); - force_mode_set = false; - } vid_initialized = true; + force_mode_set = true; + VID_SetMode(vid_default, palette); + force_mode_set = false; + vid_realmode = vid_modenum; VID_SetPalette(palette); vid_menudrawfn = VID_MenuDraw; @@ -2080,23 +1268,18 @@ VID_Shutdown(void) PostMessage(HWND_BROADCAST, WM_SYSCOLORCHANGE, (WPARAM)0, (LPARAM)0); AppActivate(false, false); - DestroyDIBWindow(); - DestroyFullscreenWindow(); - DestroyFullDIBWindow(); + VID_DestroyWindow(); if (hwnd_dialog) DestroyWindow(hwnd_dialog); if (mainwindow) DestroyWindow(mainwindow); - MGL_exit(); - vid_testingmode = 0; vid_initialized = 0; } } - /* ================ FlipScreen @@ -2105,69 +1288,100 @@ FlipScreen static void FlipScreen(vrect_t *rects) { - // Flip the surfaces - if (DDActive) { - if (mgldc) { - if (memdc) { - while (rects) { - if (vid_stretched) { - MGL_stretchBltCoord(mgldc, memdc, - rects->x, - rects->y, - rects->x + rects->width, - rects->y + rects->height, - rects->x << 1, - rects->y << 1, - (rects->x + rects->width) << 1, - (rects->y + rects->height) << 1); - } else { - MGL_bitBltCoord(mgldc, memdc, - rects->x, rects->y, - (rects->x + rects->width), - (rects->y + rects->height), - rects->x, rects->y, MGL_REPLACE_MODE); - } - rects = rects->pnext; - } - } + if (!hdcDIBSection) + return; - if (vid.numpages > 1) { - // We have a flipping surface, so do a hard page flip - aPage = (aPage + 1) % vid.numpages; - vPage = (vPage + 1) % vid.numpages; - MGL_setActivePage(mgldc, aPage); - MGL_setVisualPage(mgldc, vPage, waitVRT); - } - } - } else { - HDC hdcScreen; - - hdcScreen = GetDC(mainwindow); - if (windc && dibdc) { - MGL_setWinDC(windc, hdcScreen); - while (rects) { - if (vid_stretched) { - MGL_stretchBltCoord(windc, dibdc, - rects->x, rects->y, - rects->x + rects->width, - rects->y + rects->height, - rects->x << 1, rects->y << 1, - (rects->x + rects->width) << 1, - (rects->y + rects->height) << 1); - } else { - MGL_bitBltCoord(windc, dibdc, - rects->x, rects->y, - rects->x + rects->width, - rects->y + rects->height, rects->x, - rects->y, MGL_REPLACE_MODE); - } - rects = rects->pnext; - } - } - ReleaseDC(mainwindow, hdcScreen); + while (rects) { + BitBlt(maindc, rects->x, rects->y, + rects->x + rects->width, rects->y + rects->height, + hdcDIBSection, rects->x, rects->y, SRCCOPY); + rects = rects->pnext; } } +/* +================ +D_BeginDirectRect +================ +*/ +void +D_BeginDirectRect(int x, int y, const byte *pbitmap, int width, int height) +{ + int i, j, reps, repshift; + vrect_t rect; + + if (!vid_initialized) + return; + if (!vid.direct) + return; + + if (vid.aspect > 1.5) { + reps = 2; + repshift = 1; + } else { + reps = 1; + repshift = 0; + } + + for (i = 0; i < (height << repshift); i += reps) { + for (j = 0; j < reps; j++) { + memcpy(&backingbuf[(i + j) * 24], + vid.direct + x + ((y << repshift) + i + j) * vid.rowbytes, + width); + memcpy(vid.direct + x + ((y << repshift) + i + j) * vid.rowbytes, + &pbitmap[(i >> repshift) * width], width); + } + } + + rect.x = x; + rect.y = y; + rect.width = width; + rect.height = height << repshift; + rect.pnext = NULL; + + FlipScreen(&rect); +} + + +/* +================ +D_EndDirectRect +================ +*/ +void +D_EndDirectRect(int x, int y, int width, int height) +{ + int i, j, reps, repshift; + vrect_t rect; + + if (!vid_initialized) + return; + if (!vid.direct) + return; + + if (vid.aspect > 1.5) { + reps = 2; + repshift = 1; + } else { + reps = 1; + repshift = 0; + } + + for (i = 0; i < (height << repshift); i += reps) { + for (j = 0; j < reps; j++) { + memcpy(vid.direct + x + ((y << repshift) + i + j) * vid.rowbytes, + &backingbuf[(i + j) * 24], width); + } + } + + rect.x = x; + rect.y = y; + rect.width = width; + rect.height = height << repshift; + rect.pnext = NULL; + + FlipScreen(&rect); +} void VID_Update(vrect_t *rects) @@ -2259,169 +1473,6 @@ VID_Update(vrect_t *rects) } -/* -================ -D_BeginDirectRect -================ -*/ -void -D_BeginDirectRect(int x, int y, const byte *pbitmap, int width, int height) -{ - int i, j, reps, repshift; - vrect_t rect; - - if (!vid_initialized) - return; - - if (vid.aspect > 1.5) { - reps = 2; - repshift = 1; - } else { - reps = 1; - repshift = 0; - } - - if (vid.numpages == 1) { - VID_LockBuffer(); - - if (!vid.direct) - Sys_Error("NULL vid.direct pointer"); - - for (i = 0; i < (height << repshift); i += reps) { - for (j = 0; j < reps; j++) { - memcpy(&backingbuf[(i + j) * 24], - vid.direct + x + ((y << repshift) + i + - j) * vid.rowbytes, width); - memcpy(vid.direct + x + - ((y << repshift) + i + j) * vid.rowbytes, - &pbitmap[(i >> repshift) * width], width); - } - } - - VID_UnlockBuffer(); - - rect.x = x; - rect.y = y; - rect.width = width; - rect.height = height << repshift; - rect.pnext = NULL; - - FlipScreen(&rect); - } else { - // unlock if locked - if (lockcount > 0) - MGL_endDirectAccess(); - - // set the active page to the displayed page - MGL_setActivePage(mgldc, vPage); - - // lock the screen - MGL_beginDirectAccess(); - - // save from and draw to screen - for (i = 0; i < (height << repshift); i += reps) { - for (j = 0; j < reps; j++) { - memcpy(&backingbuf[(i + j) * 24], - (byte *)mgldc->surface + x + - ((y << repshift) + i + j) * mgldc->mi.bytesPerLine, - width); - memcpy((byte *)mgldc->surface + x + - ((y << repshift) + i + j) * mgldc->mi.bytesPerLine, - &pbitmap[(i >> repshift) * width], width); - } - } - - // unlock the screen - MGL_endDirectAccess(); - - // restore the original active page - MGL_setActivePage(mgldc, aPage); - - // relock the screen if it was locked - if (lockcount > 0) - MGL_beginDirectAccess(); - } -} - - -/* -================ -D_EndDirectRect -================ -*/ -void -D_EndDirectRect(int x, int y, int width, int height) -{ - int i, j, reps, repshift; - vrect_t rect; - - if (!vid_initialized) - return; - - if (vid.aspect > 1.5) { - reps = 2; - repshift = 1; - } else { - reps = 1; - repshift = 0; - } - - if (vid.numpages == 1) { - VID_LockBuffer(); - - if (!vid.direct) - Sys_Error("NULL vid.direct pointer"); - - for (i = 0; i < (height << repshift); i += reps) { - for (j = 0; j < reps; j++) { - memcpy(vid.direct + x + - ((y << repshift) + i + j) * vid.rowbytes, - &backingbuf[(i + j) * 24], width); - } - } - - VID_UnlockBuffer(); - - rect.x = x; - rect.y = y; - rect.width = width; - rect.height = height << repshift; - rect.pnext = NULL; - - FlipScreen(&rect); - } else { - // unlock if locked - if (lockcount > 0) - MGL_endDirectAccess(); - - // set the active page to the displayed page - MGL_setActivePage(mgldc, vPage); - - // lock the screen - MGL_beginDirectAccess(); - - // restore to the screen - for (i = 0; i < (height << repshift); i += reps) { - for (j = 0; j < reps; j++) { - memcpy((byte *)mgldc->surface + x + - ((y << repshift) + i + j) * mgldc->mi.bytesPerLine, - &backingbuf[(i + j) * 24], width); - } - } - - // unlock the screen - MGL_endDirectAccess(); - - // restore the original active page - MGL_setActivePage(mgldc, aPage); - - // relock the screen if it was locked - if (lockcount > 0) - MGL_beginDirectAccess(); - } -} - - //========================================================================== static knum_t scantokey[128] = { @@ -2486,31 +1537,10 @@ AppActivate(BOOL fActive, BOOL minimize) ActiveApp = false; } - MGL_appActivate(windc, ActiveApp); - if (vid_initialized) { // yield the palette if we're losing the focus hdc = GetDC(NULL); - if (GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) { - if (ActiveApp) { - if ((modestate == MS_WINDOWED) || (modestate == MS_FULLDIB)) { - if (GetSystemPaletteUse(hdc) == SYSPAL_STATIC) { - // switch to SYSPAL_NOSTATIC and remap the colors - SetSystemPaletteUse(hdc, SYSPAL_NOSTATIC); - syscolchg = true; - pal_is_nostatic = true; - } - } - } else if (pal_is_nostatic) { - if (GetSystemPaletteUse(hdc) == SYSPAL_NOSTATIC) { - // switch back to SYSPAL_STATIC and the old mapping - SetSystemPaletteUse(hdc, SYSPAL_STATIC); - syscolchg = true; - } - pal_is_nostatic = false; - } - } if (!Minimized) VID_SetPalette(vid_curpal); @@ -2616,7 +1646,7 @@ MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) switch (wParam & ~0x0F) { case SC_MAXIMIZE: // if minimized, bring up as a window before going fullscreen, - // so MGL will have the right state to restore + // so we will have the right state to restore if (Minimized) { force_mode_set = true; VID_SetMode(vid_modenum, vid_curpal); @@ -2675,15 +1705,14 @@ MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) away */ ClearAllStates(); - if (!in_mode_set) { - if (windc) - MGL_activatePalette(windc, true); + if (!in_mode_set) VID_SetPalette(vid_curpal); - } break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); + if (!hdc) + break; if (!in_mode_set && host_initialized) SCR_UpdateWholeScreen(); EndPaint(hWnd, &ps); @@ -2738,32 +1767,6 @@ MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) Key_Event(K_MWHEELDOWN, false); } break; - // KJB: Added these new palette functions - case WM_PALETTECHANGED: - if ((HWND)wParam == hWnd) - break; - /* Fall through to WM_QUERYNEWPALETTE */ - case WM_QUERYNEWPALETTE: - hdc = GetDC(NULL); - - if (GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) - vid_palettized = true; - else - vid_palettized = false; - - ReleaseDC(NULL, hdc); - scr_fullupdate = 0; - - if (vid_initialized && !in_mode_set && windc - && MGL_activatePalette(windc, false) && !Minimized) { - VID_SetPalette(vid_curpal); - InvalidateRect(mainwindow, NULL, false); - - /* specifically required if WM_QUERYNEWPALETTE realizes a new - palette */ - lRet = TRUE; - } - break; case WM_DISPLAYCHANGE: if (!in_mode_set && (modestate == MS_WINDOWED) @@ -2810,7 +1813,6 @@ typedef struct { int modenum; char *desc; int iscur; - int ismode13; int width; int height; } modedesc_t; @@ -2843,7 +1845,6 @@ VID_MenuDraw(void) ptr = VID_GetModeDescriptionMemCheck(i); modedescs[i].modenum = modelist[i].modenum; modedescs[i].desc = ptr; - modedescs[i].ismode13 = 0; modedescs[i].iscur = 0; if (vid_modenum == i) @@ -2873,8 +1874,7 @@ VID_MenuDraw(void) } if (dup || (vid_wmodes < MAX_MODEDESCS)) { - if (!dup || !modedescs[dupmode].ismode13 - || COM_CheckParm("-noforcevga")) { + if (!dup || COM_CheckParm("-noforcevga")) { if (dup) { k = dupmode; } else { @@ -2883,10 +1883,9 @@ VID_MenuDraw(void) modedescs[k].modenum = i; modedescs[k].desc = ptr; - modedescs[k].ismode13 = pv->mode13; modedescs[k].iscur = 0; modedescs[k].width = pv->width; - modedescs[k].width = pv->height; + modedescs[k].height = pv->height; if (i == vid_modenum) modedescs[k].iscur = 1; @@ -3122,3 +2121,6 @@ VID_IsFullScreen() { return VID_GetModePtr(vid_modenum)->fullscreen; } + +void VID_LockBuffer(void) {} +void VID_UnlockBuffer(void) {} diff --git a/scitech/include/debug.h b/scitech/include/debug.h deleted file mode 100644 index f5331dc..0000000 --- a/scitech/include/debug.h +++ /dev/null @@ -1,292 +0,0 @@ -/**************************************************************************** -* -* Copyright (C) 1996 SciTech Software -* All rights reserved. -* -* Filename: $Workfile: debug.h $ -* Version: $Revision: 1.17 $ -* -* Language: ANSI C -* Environment: any -* -* Description: General header file for operating system portable code. -* -* $Date: 04 Mar 1997 11:34:08 $ $Author: KendallB $ -* -****************************************************************************/ - -#ifndef __DEBUG_H -#define __DEBUG_H - -/* We have the following defines to identify the compilation environment: - * - * __16BIT__ Compiling for 16 bit code (any environment) - * __32BIT__ Compiling for 32 bit code (any environment) - * __MSDOS__ Compiling for MS-DOS (includes __WINDOWS16__, __WIN386__) - * __REALDOS__ Compiling for MS-DOS (excludes __WINDOWS16__) - * __MSDOS16__ Compiling for 16 bit MS-DOS - * __MSDOS32__ Compiling for 32 bit MS-DOS - * __WINDOWS__ Compiling for Windows - * __WINDOWS16__ Compiling for 16 bit Windows (__MSDOS__ also defined) - * __WINDOWS32__ Compiling for 32 bit Windows - * __WIN386__ Compiling for Watcom C++ Win386 extended Windows - * __OS2__ Compiling for OS/2 - * __OS2_16__ Compiling for 16 bit OS/2 - * __OS2_32__ Compiling for 32 bit OS/2 - * __UNIX__ Compiling for Unix - * - */ - -#ifdef __SC__ -#if __INTSIZE == 4 -#define __SC386__ -#endif -#endif - -#ifdef __GNUC__ -#define __cdecl /* GCC doesn't know about __cdecl modifiers */ -#define __FLAT__ /* GCC is always 32 bit flat model */ -#define __HAS_BOOL__ /* Latest GNU C++ has bool type */ -#endif - -#ifdef __BORLANDC__ -#if (__BORLANDC__ >= 0x500) || defined(CLASSLIB_DEFS_H) -#define __HAS_BOOL__ /* Borland C++ 5.0 and later define bool type */ -#endif -#endif - -/* For the Metaware High C/C++ compiler, there is no _cdecl calling - * convention. The conventions can be changed, but it is a complicated - * process involving #pragmas, and all externally referenced functions - * will use stack based calling conventions. We also need to change the - * global aliasing conventions to use underscores for external function - * and variables names, so that our assembler routines will link - * correctly (except of course the main function - man what a PAIN!). - */ - -#ifdef __HIGHC__ -#define __cdecl -#define __FLAT__ /* High C is always 32 bit flat model */ -#pragma Global_aliasing_convention("_%r") -extern main(); - -#pragma Alias(main,"main") -#endif - -#if defined(__MSDOS__) || defined(__DOS__) || defined(__DPMI32__) || (defined(M_I86) && !defined(__SC386__)) -#ifndef __MSDOS__ -#define __MSDOS__ -#endif -#if defined(__386__) || defined(__FLAT__) || defined(__NT__) || defined(__SC386__) -#ifndef __MSDOS32__ -#define __MSDOS32__ -#endif -#ifndef __32BIT__ -#define __32BIT__ -#endif -#ifndef __REALDOS__ -#define __REALDOS__ -#endif -#elif (defined(_Windows) || defined(_WINDOWS)) && !defined(__DPMI16__) -#ifndef __16BIT__ -#define __16BIT__ -#endif -#ifndef __WINDOWS16__ -#define __WINDOWS16__ -#endif -#ifndef __WINDOWS__ -#define __WINDOWS__ -#endif -#ifndef __MSDOS__ -#define __MSDOS__ -#endif -#else -#ifndef __16BIT__ -#define __16BIT__ -#endif -#ifndef __MSDOS16__ -#define __MSDOS16__ -#endif -#ifndef __REALDOS__ -#define __REALDOS__ -#endif -#endif -#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) -#ifndef __32BIT__ -#define __32BIT__ -#endif -#ifndef __WINDOWS32__ -#define __WINDOWS32__ -#endif -#ifndef _WIN32 -#define _WIN32 /* Microsoft Win32 SDK headers use _WIN32 */ -#endif -#ifndef WIN32 -#define WIN32 /* OpenGL headers use WIN32 */ -#endif -#ifndef __WINDOWS__ -#define __WINDOWS__ -#endif -#elif defined(__WINDOWS_386__) -#ifndef __32BIT__ -#define __32BIT__ -#endif -#ifndef __WIN386__ -#define __WIN386__ -#endif -#ifndef __WINDOWS__ -#define __WINDOWS__ -#endif -#ifndef __MSDOS__ -#define __MSDOS__ -#endif -#elif defined(__OS2__) -#ifndef __OS2__ /* TODO: to be completed */ -#define __OS2__ -#define __OS2_32__ /* Default to 32 bit OS/2 */ -#endif -#else -#define __UNIX__ /* TODO: to be completed */ -#endif - -/* We have the following defines to define the calling conventions for - * publicly accesible functions: - * - * _PUBAPI - Compiler default calling conventions for all public 'C' functions - * _ASMAPI - Calling conventions for all public assembler functions - * _DLLAPI - Calling conventions for all DLL exported functions - * _DLLVAR - Modifier to export/import globals in 32 bit DLL's - * _EXPORT - Expands to _export when compiling a DLL - * _VARAPI - Modifiers for variables; Watcom C++ mangles C++ globals - */ - -#define _PUBAPI -#define _ASMAPI __cdecl - -#if defined(_MSC_VER) && defined(_WIN32) && !defined(__SC__) -#define __PASCAL __stdcall -#define __export -#define __import -#else -#define __PASCAL __pascal -#endif - -#if defined(__WATCOMC__) -#define _VARAPI __cdecl -#else -#define _VARAPI -#endif - -#if defined(__WINDOWS__) -#ifdef BUILD_DLL -#define _DLLASM __export __cdecl -#define _EXPORT __export -#ifdef __WINDOWS32__ -#define _DLLAPI __export __PASCAL -#define _DLLVAR __export -#else -#define _DLLAPI __export __far __pascal -#define _DLLVAR -#endif -#else -#define _DLLASM __cdecl -#define _EXPORT -#ifdef __WINDOWS32__ -#define _DLLAPI __PASCAL -#define _DLLVAR __import -#else -#define _DLLAPI __far __pascal -#define _DLLVAR -#endif -#endif -#else -#define _EXPORT -#define _DLLAPI -#define _DLLVAR -#endif - -/* Useful macros */ - -#define PRIVATE static -#define PUBLIC - -#ifdef DEBUG -# define DBG(x) x -#else -# define DBG(x) -#endif - -#ifndef NULL -# define NULL 0L -#endif - -#ifndef MAX -# define MAX(a,b) ( ((a) > (b)) ? (a) : (b)) -#endif -#ifndef MIN -# define MIN(a,b) ( ((a) < (b)) ? (a) : (b)) -#endif -#ifndef ABS -# define ABS(a) ((a) >= 0 ? (a) : -(a)) -#endif -#ifndef SIGN -# define SIGN(a) ((a) > 0 ? 1 : -1) -#endif - -/* General typedefs */ - -#ifndef __GENDEFS -#define __GENDEFS -typedef unsigned char uchar; -typedef unsigned short ushort; -typedef unsigned int uint; -typedef unsigned long ulong; -typedef int ibool; /* Integer boolean type */ - -#ifndef __cplusplus -#define bool ibool /* Standard C */ -#else -#ifndef __HAS_BOOL__ -#define bool ibool /* Older C++ compilers */ -#endif -#endif /* __cplusplus */ -#endif /* __GENDEFS */ - -/* Includes Windows headers, as they define TRUE and FALSE */ - -#ifdef __WINDOWS__ -#ifndef _WINDOWS_ /* Dont include if already included */ -#ifndef __WIN386__ -#define STRICT -#define WIN32_LEAN_AND_MEAN -#endif -#include -#endif -#endif - -/* Boolean truth values */ - -#undef false -#undef true -#undef NO -#undef YES -#undef FALSE -#undef TRUE - -#ifdef __cplusplus /* Cast to bool's for C++ code */ -#define false ((bool)0) -#define true ((bool)1) -#define NO ((bool)0) -#define YES ((bool)1) -#define FALSE ((bool)0) -#define TRUE ((bool)1) -#else /* Define to 0 and 1 for C code */ -#define false 0 -#define true 1 -#define NO 0 -#define YES 1 -#define FALSE 0 -#define TRUE 1 -#endif - -#endif /* __DEBUG_H */ diff --git a/scitech/include/mgldos.h b/scitech/include/mgldos.h deleted file mode 100644 index c8fb359..0000000 --- a/scitech/include/mgldos.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -* -* MegaGraph Graphics Library -* -* Copyright (C) 1996 SciTech Software. -* All rights reserved. -* -* Filename: $Workfile: mgldos.h $ -* Version: $Revision: 1.9 $ -* -* Language: ANSI C -* Environment: IBM PC (MS DOS) -* -* Description: Header file for the MGLDOS binding for the MSDOS environment. -* -* $Date: 30 Jan 1997 17:31:58 $ $Author: KendallB $ -* -****************************************************************************/ - -#ifndef __MGLDOS_H -#define __MGLDOS_H - -#ifndef MGLDOS -#define MGLDOS -#endif - -/*---------------------- Macros and type definitions ----------------------*/ - -typedef void *MGL_HWND; - -/*------------------------- Function Prototypes ---------------------------*/ - -#ifdef __cplusplus -extern "C" { /* Use "C" linkage when in C++ mode */ -#endif - -/* Initialise the MGL for fullscreen output */ - - bool MGLAPI MGL_init(m_int * driver, m_int * mode, const char *mglpath); - -/* Change the active display mode. You must destroy all display device - * contexts before calling this function, and re-create them again with - * the new display mode. Does not affect any event handling hooks. - */ - - bool MGLAPI MGL_changeDisplayMode(m_int mode); - -/* Disable/enable event handling (call before calling MGL_init */ - - void MGLAPI MGL_useEvents(bool use); - -/* Device context management */ - - MGLDC *MGLAPI MGL_createDisplayDC(m_int numBuffers); - MGLDC *MGLAPI MGL_createScrollingDC(m_int virtualX, m_int virtualY, - m_int numBuffers); - MGLDC *MGLAPI MGL_createOffscreenDC(void); - MGLDC *MGLAPI MGL_createLinearOffscreenDC(void); - MGLDC *MGLAPI MGL_createMemoryDC(m_int xSize, m_int ySize, - m_int bitsPerPixel, pixel_format_t *pf); - bool MGLAPI MGL_destroyDC(MGLDC *dc); - -/* Generic helper functions */ - - ulong MGLAPI MGL_getTicks(void); - ulong MGLAPI MGL_getTickResolution(void); - void MGLAPI MGL_delay(m_int millseconds); - void MGLAPI MGL_beep(m_int freq, m_int milliseconds); - void MGLAPI MGL_suspend(void); - void MGLAPI MGL_resume(void); - -/* Fullscreen specific routines */ - - void MGLAPI MGL_setPaletteSnowLevel(MGLDC *dc, m_int level); - m_int MGLAPI MGL_getPaletteSnowLevel(MGLDC *dc); - -/* Determine if a specific scancode'ed key is held down (PC specific) */ - - bool MGLAPI EVT_isKeyDown(uchar scanCode); - -#ifdef __cplusplus -} /* End of "C" linkage for C++ */ -#endif -#endif /* __MGLDOS_H */ diff --git a/scitech/include/mglwin.h b/scitech/include/mglwin.h deleted file mode 100644 index a390dd8..0000000 --- a/scitech/include/mglwin.h +++ /dev/null @@ -1,153 +0,0 @@ -/**************************************************************************** -* -* MegaGraph Graphics Library -* -* Copyright (C) 1996 SciTech Software. -* All rights reserved. -* -* Filename: $Workfile: mglwin.h $ -* Version: $Revision: 1.14 $ -* -* Language: ANSI C -* Environment: IBM PC (MS DOS) -* -* Description: Header file for the MGLWIN bindings for MS Windows using -* WinG in a window and WinDirect for full screen. The MGLWIN -* binding only targets Win32 applications, so cannot be used -* for 16 bit Windows development. -* -* $Date: 14 Mar 1997 16:09:34 $ $Author: KendallB $ -* -****************************************************************************/ - -#ifndef __MGLWIN_H -#define __MGLWIN_H - -#ifndef MGLWIN -#define MGLWIN -#endif - -/*---------------------- Macros and type definitions ----------------------*/ - -typedef HWND MGL_HWND; -typedef HDC MGL_HDC; -typedef HINSTANCE MGL_HINSTANCE; - -/*------------------------- Function Prototypes ---------------------------*/ - -#ifdef __cplusplus -extern "C" { /* Use "C" linkage when in C++ mode */ -#endif - -/* Initialise the MGL for fullscreen output */ - - bool MGLAPI MGL_init(m_int * driver, m_int * mode, const char *mglpath); - -/* Initialise the MGL just for Windowed output, not full screen */ - - bool MGLAPI MGL_initWindowed(const char *mglpath); - -/* Function to register a fullscreen window with the MGL. If you wish - * for the MGL to use your own window for fullscreen modes, you can - * register it with this function. Note that when the MGL goes into - * fullscreen modes, the attributes, size and position of the window are - * modified to make it into a fullscreen Window necessary to cover the - * entire desktop, and the state of the window will be restore to the original - * format on return to normal GDI mode. - * - * Note that if you are using a common window for Windowed mode and fullscreen - * modes of your application, you will need to ensure that certain messages - * that you window normally handles in windowed modes are ignored when in - * fullscreen modes. - */ - - void MGLAPI MGL_registerFullScreenWindow(HWND hwndFullScreen); - -/* Function to register a fullscreen event handling window procedure. - * If you wish to do your own event handling, you can register your window - * procedure with the MGL using this function and it will be called - * when there are messages to be handled. You can still call the MGL_event() - * functions even if you have registered an event handling procedure. - */ - - void MGLAPI MGL_registerEventProc(WNDPROC userWndProc); - -/* Change the active display mode. You must destroy all display device - * contexts before calling this function, and re-create them again with - * the new display mode. Does not affect any event handling hooks. - */ - - bool MGLAPI MGL_changeDisplayMode(m_int mode); - -/* Obtain the handle to the MGL fullscreen window when in fullscreen modes */ - - MGL_HWND MGLAPI MGL_getFullScreenWindow(void); - -/* Tell the MGL what your applications main window is */ - - void MGLAPI MGL_setMainWindow(MGL_HWND hwnd); - -/* Tell the MGL your applications instance handle (call before all funcs!) */ - - void MGLAPI MGL_setAppInstance(MGL_HINSTANCE hInstApp); - -/* Device context management */ - - MGLDC *MGLAPI MGL_createDisplayDC(m_int numBuffers); - MGLDC *MGLAPI MGL_createSrollingDC(m_int virtualX, m_int virtualY, - m_int numBuffers); - MGLDC *MGLAPI MGL_createOffscreenDC(void); - MGLDC *MGLAPI MGL_createLinearOffscreenDC(void); - MGLDC *MGLAPI MGL_createWindowedDC(MGL_HWND hwnd); - MGLDC *MGLAPI MGL_createMemoryDC(m_int xSize, m_int ySize, - m_int bitsPerPixel, pixel_format_t *pf); - bool MGLAPI MGL_destroyDC(MGLDC *dc); - -/* Get a Windows HDC for the MGL device context. You can use this returned - * HDC to get GDI to draw to the device context surface, such as rendering - * and using TrueType fonts with the MGL. If a Windows compatible HDC is not - * available, this function will return NULL. - */ - - HDC MGLAPI MGL_getWinDC(MGLDC *dc); - -/* Associate a Window manager DC with the MGLDC for painting */ - - bool MGLAPI MGL_setWinDC(MGLDC *dc, MGL_HDC hdc); - -/* Activate the WindowDC's palette */ - - bool MGLAPI MGL_activatePalette(MGLDC *dc, bool unrealize); - -/* Let the MGL know when your application is being activated or deactivated. - * This function only needs to be called when running in Windowed modes and - * you have set the system palette to SYSPAL_NOSTATIC mode, to ensure - * that the MGL can properly re-map your application palette when your - * app is not active and allow Windows to re-map your bitmap colors on the - * fly. This function should be passed a pointer to the currently active - * MGL Windowed DC and a flag to indicate whether the app is in the background - * or not. - */ - - void MGLAPI MGL_appActivate(MGLDC *winDC, bool active); - -/* Generic helper functions */ - - ulong MGLAPI MGL_getTicks(void); - ulong MGLAPI MGL_getTickResolution(void); - void MGLAPI MGL_delay(m_int millseconds); - void MGLAPI MGL_beep(m_int freq, m_int milliseconds); - -/* Fullscreen specific routines */ - - void MGLAPI MGL_setPaletteSnowLevel(MGLDC *dc, m_int level); - m_int MGLAPI MGL_getPaletteSnowLevel(MGLDC *dc); - -/* Determine if a specific scancode'ed key is held down (PC specific) */ - - bool MGLAPI EVT_isKeyDown(uchar scanCode); - -#ifdef __cplusplus -} /* End of "C" linkage for C++ */ -#endif -#endif /* __MGLWIN_H */ diff --git a/scitech/include/mgraph.h b/scitech/include/mgraph.h deleted file mode 100644 index 84521c0..0000000 --- a/scitech/include/mgraph.h +++ /dev/null @@ -1,2121 +0,0 @@ -/**************************************************************************** -* -* MegaGraph Graphics Library -* -* Copyright (C) 1996 SciTech Software. -* All rights reserved. -* -* Filename: $Workfile: mgraph.h $ -* Version: $Revision: 1.29 $ -* -* Language: ANSI C -* Environment: IBM PC (MS DOS) -* -* Description: Header file for the MegaGraph Graphics Library. You can -* defined one of the following to specify which MGL API you -* wish to use. -* -* MGL_LITE - Compile for the MGL/Lite API -* MGL_PRO - Compile for the MGL/Pro API -* MGL_FIX3D - Compile for the MGL/3D API (fixed point) -* MGL_FLT3D - Compile for the MGL/3D API (floating point) -* -* If you do not define any of these, MGL_FIX3D will be defined -* automatically for compatibility with older versions of the -* MGL. -* -* $Date: 11 Mar 1997 16:46:42 $ $Author: KendallB $ -* -****************************************************************************/ - -#ifndef __MGRAPH_H -#define __MGRAPH_H - -#include - -#ifndef __DEBUG_H -#include "debug.h" -#endif - -#if !defined(MGL_LITE) && !defined(MGL_PRO) && !defined(MGL_FIX3D) \ - && !defined(MGL_FLT3D) -#define MGL_FIX3D -#endif - -#if defined(MGL_FIX3D) || defined(MGL_FLT3D) -#define MGL_3D -#endif - -/*---------------------- Macros and type definitions ----------------------*/ - -#pragma pack(1) /* Pack structures to byte granularity */ - -/* Define the version number for the MGL release */ - -#define MGL_VERSION_STR "3.1" - -/* Define the calling conventions for all public MGL functions. If we - * are compiling the MGL as a DLL, then all public functions are compiled - * and exported with standard C calling conventions, otherwise we use - * the default calling conventions provided by the compiler. - * - * Note that because Watcom C++ uses register based parameter passing - * by default we also provide special DLL's for watcom that are compiled - * with register parameter passing. This is necessary to work with all - * the extra libraries provided as they are all compiled to call MGL - * functions with arguments in registers whenever possible. You can still - * use the standard DLL but if you do you will need to re-compile all - * of the extra libraries with the MGL_DLL #define to change the calling - * conventions for the MGL functions. - */ - -#if defined(MGL_DLL) -#define MGLAPI _EXPORT __cdecl -#else -#define MGLAPI _EXPORT _PUBAPI -#endif -#define ASMAPI _EXPORT __cdecl - -/* Define a type for integers used in the library. For most environments - * we simply define it as a normal integer (16 or 32 bits), however for - * 16 bit Windows it is defined as a 32 bit integer as all the real code - * lives in a 32 bit DLL that uses 32 bit integers. - */ - -#ifndef __M_INT_DEFINED -#if defined(__WINDOWS16__) -typedef long m_int; -typedef unsigned long m_uint; -#else -typedef int m_int; -typedef unsigned int m_uint; -#endif -#define __M_INT_DEFINED -#endif - -/* Define the graphics subsystems available */ - -typedef enum { - grDETECT = -1, /* Auto detect the graphics subsystem */ - grNONE = 0, /* No graphics hardware detected */ - grVGA, /* Standard VGA */ - grVESA, /* VESA VBE compliant SuperVGA */ - grSVGA, /* Unaccelerated SuperVGA */ - grACCEL, /* Accelerated SuperVGA */ - grDDRAW, /* Unaccelerated DirectDraw */ - grDDRAWACCEL, /* Accelerated DirectDraw */ - grDDRAW3D, /* 3D Accelerated DirectDraw */ - grMAXDRIVER, /* Maximum driver number */ -} MGL_driverType; - -/* Graphics modes supported - the only video modes supported by this - * graphics library are those that support at least 16 colors per pixel. - */ - -typedef enum { - /* 16 color VGA video modes */ - - grVGA_320x200x16, - grVGA_640x200x16, - grVGA_640x350x16, - grVGA_640x400x16, - grVGA_640x480x16, - grSVGA_800x600x16, - - /* 256 color VGA ModeX video modes */ - - grVGAX_320x200x256, - grVGAX_320x240x256, - grVGAX_320x400x256, - grVGAX_320x480x256, - - /* 256 color VGA video modes */ - - grVGA_320x200x256, - - /* 256 color VGA/SuperVGA video modes */ - - grSVGA_320x200x256, - grSVGA_320x240x256, - grSVGA_320x400x256, - grSVGA_320x480x256, - grSVGA_400x300x256, - grSVGA_512x384x256, - grSVGA_640x350x256, - grSVGA_640x400x256, - grSVGA_640x480x256, - grSVGA_800x600x256, - grSVGA_1024x768x256, - grSVGA_1152x864x256, - grSVGA_1280x960x256, - grSVGA_1280x1024x256, - grSVGA_1600x1200x256, - - /* 32,768 color Super VGA video modes */ - - grSVGA_320x200x32k, - grSVGA_320x240x32k, - grSVGA_320x400x32k, - grSVGA_320x480x32k, - grSVGA_400x300x32k, - grSVGA_512x384x32k, - grSVGA_640x350x32k, - grSVGA_640x400x32k, - grSVGA_640x480x32k, - grSVGA_800x600x32k, - grSVGA_1024x768x32k, - grSVGA_1152x864x32k, - grSVGA_1280x960x32k, - grSVGA_1280x1024x32k, - grSVGA_1600x1200x32k, - - /* 65,536 color Super VGA video modes */ - - grSVGA_320x200x64k, - grSVGA_320x240x64k, - grSVGA_320x400x64k, - grSVGA_320x480x64k, - grSVGA_400x300x64k, - grSVGA_512x384x64k, - grSVGA_640x350x64k, - grSVGA_640x400x64k, - grSVGA_640x480x64k, - grSVGA_800x600x64k, - grSVGA_1024x768x64k, - grSVGA_1152x864x64k, - grSVGA_1280x960x64k, - grSVGA_1280x1024x64k, - grSVGA_1600x1200x64k, - - /* 16 million color, 24 bits per pixel Super VGA video modes */ - - grSVGA_320x200x16m, - grSVGA_320x240x16m, - grSVGA_320x400x16m, - grSVGA_320x480x16m, - grSVGA_400x300x16m, - grSVGA_512x384x16m, - grSVGA_640x350x16m, - grSVGA_640x400x16m, - grSVGA_640x480x16m, - grSVGA_800x600x16m, - grSVGA_1024x768x16m, - grSVGA_1152x864x16m, - grSVGA_1280x960x16m, - grSVGA_1280x1024x16m, - grSVGA_1600x1200x16m, - - /* 16 million color, 32 bits per pixel Super VGA video modes */ - - grSVGA_320x200x4G, - grSVGA_320x240x4G, - grSVGA_320x400x4G, - grSVGA_320x480x4G, - grSVGA_400x300x4G, - grSVGA_512x384x4G, - grSVGA_640x350x4G, - grSVGA_640x400x4G, - grSVGA_640x480x4G, - grSVGA_800x600x4G, - grSVGA_1024x768x4G, - grSVGA_1152x864x4G, - grSVGA_1280x960x4G, - grSVGA_1280x1024x4G, - grSVGA_1600x1200x4G, - - /* Render into Windowing System DC (Windows, OS/2 PM, X11) */ - - grWINDOWED, - - grMAXMODE, /* Maximum mode number */ -} MGL_modeType; - -/* MGL_result() error codes */ - -typedef enum { - grOK = 0, /* No error */ - grNoInit = -1, /* Graphics driver has not been installed */ - grNotDetected = -2, /* Graphics hardware was not detected */ - grDriverNotFound = -3, /* Graphics driver file not found */ - grBadDriver = -4, /* File loaded was not a graphics driver */ - grLoadMem = -5, /* Not enough memory to load graphics driver */ - grInvalidMode = -6, /* Invalid graphics mode for selected driver */ - grError = -8, /* General graphics error */ - grInvalidName = -9, /* Invalid driver name */ - grNoMem = -10, /* Not enough memory to perform operation */ - grNoModeSupport = -11, /* Select video mode not supported by hard. */ - grInvalidFont = -12, /* Invalid font data */ - grBadFontFile = -13, /* File loaded was not a font file */ - grFontNotFound = -14, /* Font file was not found */ - grOldDriver = -15, /* Driver file is an old version */ - grInvalidDevice = -16, /* Invalid device for selected operation */ - grInvalidDC = -17, /* Invalid device context */ - grInvalidCursor = -18, /* Invalid cursor file */ - grCursorNotFound = -19, /* Cursor file was not found */ - grInvalidIcon = -20, /* Invalid icon file */ - grIconNotFound = -21, /* Icon file was not found */ - grInvalidBitmap = -22, /* Invalid bitmap file */ - grBitmapNotFound = -23, /* Bitmap file was not found */ - grZbufferTooBig = -24, /* Zbuffer allocation is too large */ - grNewFontFile = -25, /* Only Windows 2.x font files supported */ - grNoDoubleBuff = -26, /* Double buffering is not available */ - grNoHardwareBlt = -28, /* No hardware bitBlt for OffscreenDC */ - grNoOffscreenMem = -29, /* No available offscreen memory */ - grInvalidPF = -30, /* Invalid pixel format for memory DC */ - - grLastError = -31, /* Last error number in list */ -} MGL_errorType; - -#define MGL_CLIPON true -#define MGL_CLIPOFF false - -/* Color mapped modes */ - -typedef enum { - MGL_CMAP_MODE, /* Normal Color mapped mode */ - MGL_DITHER_RGB_MODE, /* 24 bit RGB halftone dithered */ -} MGL_colorModes; - -/* Standard colors - this is the standard set of colors for the IBM PC. The - * default palette will have been programmed to contain these values when a - * graphics modes is started. If the palette has been changed, they will - * not correspond to the actual colors on the screen. Under a Windowing - * manage environment these colors will also not be setup by default. - */ - -enum MGL_COLORS { - MGL_BLACK, /* dark colors */ - MGL_BLUE, - MGL_GREEN, - MGL_CYAN, - MGL_RED, - MGL_MAGENTA, - MGL_BROWN, - MGL_LIGHTGRAY, - MGL_DARKGRAY, /* light colors */ - MGL_LIGHTBLUE, - MGL_LIGHTGREEN, - MGL_LIGHTCYAN, - MGL_LIGHTRED, - MGL_LIGHTMAGENTA, - MGL_YELLOW, - MGL_WHITE, -}; - -/* Windows standard color indices for 256 color bitmaps. 8,9,246,247 are - * reserved and you should not count on these colors always being the - * same. For 16 color bitmaps, colors 248-255 map to colors 8-15. - */ - -enum MGL_WIN_COLORS { - MGL_WIN_BLACK = 0, - MGL_WIN_DARKRED = 1, - MGL_WIN_DARKGREEN = 2, - MGL_WIN_DARKYELLOW = 3, - MGL_WIN_DARKBLUE = 4, - MGL_WIN_DARKMAGENTA = 5, - MGL_WIN_DARKCYAN = 6, - MGL_WIN_LIGHTGRAY = 7, - MGL_WIN_TURQUOISE = 8, /* Reserved; dont count on this */ - MGL_WIN_SKYBLUE = 9, /* Reserved; dont count on this */ - MGL_WIN_CREAM = 246, /* Reserved; dont count on this */ - MGL_WIN_MEDIUMGRAY = 247, /* Reserved; dont count on this */ - MGL_WIN_DARKGRAY = 248, - MGL_WIN_LIGHTRED = 249, - MGL_WIN_LIGHTGREEN = 250, - MGL_WIN_LIGHTYELLOW = 251, - MGL_WIN_LIGHTBLUE = 252, - MGL_WIN_LIGHTMAGENTA = 253, - MGL_WIN_LIGHTCYAN = 254, - MGL_WIN_WHITE = 255, -}; - -typedef enum { - MGL_MARKER_SQUARE, - MGL_MARKER_CIRCLE, - MGL_MARKER_X, -} MGL_markerStyleType; - -typedef enum { /* Write mode operators */ - MGL_REPLACE_MODE, /* Replace mode */ - MGL_AND_MODE, /* AND mode */ - MGL_OR_MODE, /* OR mode */ - MGL_XOR_MODE, /* XOR mode */ -} MGL_writeModeType; - -typedef enum { - MGL_BITMAP_SOLID, - MGL_BITMAP_OPAQUE, - MGL_BITMAP_TRANSPARENT, - MGL_PIXMAP, -} MGL_fillStyleType; - -typedef enum { - MGL_LINE_PENSTYLE, /* Line drawn in current pen style */ - MGL_LINE_STIPPLE, /* Line drawn with current stipple */ -} MGL_lineStyleType; - -typedef enum { - MGL_CONVEX_POLYGON, /* Monotone vertical polygon */ - MGL_COMPLEX_POLYGON, /* Non-Simple polygons */ - MGL_AUTO_POLYGON, /* Auto detect the polygon type */ -} MGL_polygonType; - -/* Text manipulation defines */ - -typedef enum { - MGL_LEFT_TEXT = 0, /* Justify from left */ - MGL_TOP_TEXT = 0, /* Justify from top */ - MGL_CENTER_TEXT = 1, /* Center the text */ - MGL_RIGHT_TEXT = 2, /* Justify from right */ - MGL_BOTTOM_TEXT = 2, /* Justify from bottom */ - MGL_BASELINE_TEXT = 3, /* Justify from the baseline */ -} MGL_textJustType; - -typedef enum { - MGL_LEFT_DIR = 0, /* Text goes to left */ - MGL_UP_DIR = 1, /* Text goes up */ - MGL_RIGHT_DIR = 2, /* Text goes right */ - MGL_DOWN_DIR = 3, /* Text goes down */ -} MGL_textDirType; - -/* Font types */ - -typedef enum { - MGL_VECTORFONT = 1, /* Vector font */ - MGL_FIXEDFONT, /* Fixed width bitmap font */ - MGL_PROPFONT, /* Proportional width bitmap font */ -} MGL_fontType; - -/* Palette rotation directions */ - -typedef enum { - MGL_ROTATE_UP, /* Rotate the palette values up */ - MGL_ROTATE_DOWN, /* Rotate the palette values down */ -} MGL_palRotateType; - -/* Border drawing routine styles */ - -typedef enum { - MGL_BDR_INSET, /* Interior is inset into screen */ - MGL_BDR_OUTSET, /* Interior is outset from screen */ - MGL_BDR_OUTLINE, /* Border is 3d outline */ -} MGL_bdrStyleType; - -/* Standard display driver names */ - -#define MGL_VGA4NAME "VGA4.DRV" /* Standard VGA drivers */ -#define MGL_VGA8NAME "VGA8.DRV" -#define MGL_VGAXNAME "VGAX.DRV" - -#define MGL_SVGA4NAME "SVGA4.DRV" /* Generic SuperVGA drivers */ -#define MGL_SVGA8NAME "SVGA8.DRV" -#define MGL_SVGA16NAME "SVGA16.DRV" -#define MGL_SVGA24NAME "SVGA24.DRV" -#define MGL_SVGA32NAME "SVGA32.DRV" - -#define MGL_LINEAR8NAME "LINEAR8.DRV" /* Linear framebuffer drivers */ -#define MGL_LINEAR16NAME "LINEAR16.DRV" -#define MGL_LINEAR24NAME "LINEAR24.DRV" -#define MGL_LINEAR32NAME "LINEAR32.DRV" - -#define MGL_ACCEL8NAME "ACCEL8.DRV" /* VBE/AF Accelerated drivers */ -#define MGL_ACCEL16NAME "ACCEL16.DRV" -#define MGL_ACCEL24NAME "ACCEL24.DRV" -#define MGL_ACCEL32NAME "ACCEL32.DRV" - -#define MGL_DDRAW8NAME "DDRAW8.DRV" /* DirectDraw drivers */ -#define MGL_DDRAW16NAME "DDRAW16.DRV" -#define MGL_DDRAW24NAME "DDRAW24.DRV" -#define MGL_DDRAW32NAME "DDRAW32.DRV" - -/* Standard memory driver names */ - -#define MGL_PACKED1NAME "PACK1.DRV" -#define MGL_PACKED4NAME "PACK4.DRV" -#define MGL_PACKED8NAME "PACK8.DRV" -#define MGL_PACKED16NAME "PACK16.DRV" -#define MGL_PACKED24NAME "PACK24.DRV" -#define MGL_PACKED32NAME "PACK32.DRV" - -/* Standard bitmap names */ - -#define MGL_EMPTY_FILL _MGL_getEmptyPat() -#define MGL_GRAY_FILL _MGL_getGrayPat() -#define MGL_SOLID_FILL _MGL_getSolidPat() - -/* Event message masks for keyDown events */ - -#define EVT_ASCIIMASK 0x00FF /* Ascii code of key pressed */ -#define EVT_SCANMASK 0xFF00 /* Scan code of key pressed */ -#define EVT_COUNTMASK 0x7FFF0000L /* Count for KEYREPEAT's */ - -#define EVT_asciiCode(m) ( (uchar) (m & EVT_ASCIIMASK) ) -#define EVT_scanCode(m) ( (uchar) ( (m & EVT_SCANMASK) >> 8 ) ) -#define EVT_repeatCount(m) ( (short) ( (m & EVT_COUNTMASK) >> 16 ) ) - -/* Event message masks for mouse events */ - -#define EVT_LEFTBMASK 0x0001 /* Left button is bit 0 */ -#define EVT_RIGHTBMASK 0x0004 /* Right button is bit 1 */ -#define EVT_BOTHBMASK 0x0005 /* Both left and right together */ -#define EVT_ALLBMASK 0x0005 /* All buttons pressed */ - -/* Modifier masks */ - -#define EVT_LEFTBUT 0x0001 /* Set if left button was down */ -#define EVT_RIGHTBUT 0x0002 /* Set if right button was down */ -#define EVT_RIGHTSHIFT 0x0008 /* Set if right shift down */ -#define EVT_LEFTSHIFT 0x0010 /* Set if left shift down */ -#define EVT_CTRLSTATE 0x0020 /* Set if ctrl key down */ -#define EVT_ALTSTATE 0x0040 /* Set if alt key down */ -#define EVT_LEFTCTRL 0x0080 /* Set if left ctrl key down */ -#define EVT_LEFTALT 0x0100 /* Set if left alt key down */ -#define EVT_SHIFTKEY 0x0018 /* Any shift key */ - -/* Event codes */ - -#define EVT_NULLEVT 0x0000 /* A null event */ -#define EVT_KEYDOWN 0x0001 /* Key down event */ -#define EVT_KEYREPEAT 0x0002 /* Key repeat event */ -#define EVT_KEYUP 0x0004 /* Key up event */ -#define EVT_MOUSEDOWN 0x0008 /* Mouse down event */ -#define EVT_MOUSEUP 0x0010 /* Mouse up event */ -#define EVT_MOUSEMOVE 0x0020 /* Mouse movement event */ -#define EVT_TIMERTICK 0x0040 /* Timer tick event */ -#define EVT_USEREVT 0x0080 /* First user event */ - -/* Event code masks */ - -#define EVT_KEYEVT (EVT_KEYDOWN | EVT_KEYREPEAT | EVT_KEYUP) -#define EVT_MOUSEEVT (EVT_MOUSEDOWN | EVT_MOUSEUP | EVT_MOUSEMOVE) -#define EVT_MOUSECLICK (EVT_MOUSEDOWN | EVT_MOUSEUP) -#define EVT_EVERYEVT 0xFFFF - -/* Suspend Application callback type codes. This callback is called - * when the user presses one of the corresponding keys indicating that - * they wish to change the active application. The MGL will catch these - * events and if you have registered a callback, will call the callback to - * save the state of the application so that it can be properly restored - * when the user switches back to your application. The MGL takes care of - * all the details about saving and restoring the state of the hardware, - * and all your application needs to do is save its own state so that you can - * re-draw the application screen upon re-activation. - * - * NOTE: Your application suspend callback may get called twice with the - * MGL_DEACTIVATE flag in order to test whether the switch should - * occur (under both DirectDraw and WinDirect fullscreen modes). - * - * NOTE: When your callback is called with the MGL_DEACTIVATE flag, you - * cannot assume that you have access to the display memory surfaces - * as they may have been lost by the time your callback has been called. - */ - -#define MGL_DEACTIVATE 0x0001 /* Application losing active focus */ -#define MGL_REACTIVATE 0x0002 /* Application regaining active focus */ - -/* Return codes from the suspend application callback. The normal value - * to be returned is MGL_SUSPEND_APP and this will cause the app to be - * suspended while back in GDI mode until the app is re-activated again - * by the user. - * - * MGL_NO_DEACTIVATE signals to WinDirect that the application does not want - * to allow switching to occur, and the switch request will be ignored and - * the app will remain in fullscreen mode. - * - * MGL_NO_SUSPEND_APP can be used to tell WinDirect to switch back to the - * desktop, but not to suspend the application. This must be used with - * care as the suspend application callback is then responsible for setting - * a flag in the application that will stop the application from doing any - * rendering to the framebuffer while the application is in GDI mode. This - * return value is useful for games that need to maintain network - * connectivity while the user has temporarily switched back to GDI mode. - */ - -#define MGL_NO_DEACTIVATE 0 /* Dont allow app to be deactivated */ -#define MGL_SUSPEND_APP 1 /* Suspend application until restored */ -#define MGL_NO_SUSPEND_APP 2 /* Dont suspend, but allow switch */ - -/* Here we define the structures used to represent points and rectangles */ - -typedef struct { - m_int x, y; -} point_t; - -typedef struct { - m_int left; - m_int top; - m_int right; - m_int bottom; -} rect_t; - -/* All colors are represented as longs by the library. This allows - * code to work correctly with up to 24 bit color device drivers. The - * device drivers themselves expect the color to be a color index if in - * a color mapped mode, or a 15/16/24 bit RGB tuple in a hicolor or truecolor - * mode. You can use the appropriate routines to pack and unpack - * colors into the color_t format. - */ - -typedef ulong color_t; - -/* Define the value used to clear the software ZBuffer. The MGL always uses - * a > operator for the z compare, and the smallest value is 0. - */ - -#define MGL_ZCLEARVAL 0 - -/* Structures for passing vertex information to polygon rendering routines. - * All fixed point coordinates are passed in 16.16 signed fixed point - * format, while zbuffer coordinates are passed in 4.28 signed fixed point - * format. The sign bit is used purely for overflow and arithmetic - * internally, and all user passed zbuffer values should be greater than - * 0. All shaded rendering routines either take a color index in 8.16 fixed - * point format (range 0-255.9) or separate RGB components in 8.16 fixed - * point format (range 0-255.9). - */ - -#ifdef __FX_FIXED_H -#define fix32_t FXFixed -#else -typedef long fix32_t; -#endif -typedef fix32_t fxcolor_t; -typedef long zfix32_t; - -typedef struct { - fix32_t x, y; -} fxpoint_t; - -typedef struct { - fxcolor_t r, g, b; -} fxrgb_t; - -typedef struct { - fix32_t w, s, t; -} fxtex_t; - -typedef struct { - fxcolor_t c; - fxpoint_t p; -} fxpointc_t; - -typedef struct { - fxrgb_t c; - fxpoint_t p; -} fxpointrgb_t; - -typedef struct { - fxpoint_t p; - zfix32_t z; -} fxpointz_t; - -typedef struct { - fxcolor_t c; - fxpoint_t p; - zfix32_t z; -} fxpointcz_t; - -typedef struct { - fxrgb_t c; - fxpoint_t p; - zfix32_t z; -} fxpointrgbz_t; - -/* Macros to convert between integer and 32 bit fixed point format */ - -#define MGL_FIX_1 0x10000L -#define MGL_FIX_2 0x20000L -#define MGL_FIX_HALF 0x08000L -#define MGL_TOFIX(i) ((long)(i) << 16) -#define MGL_FIXTOINT(f) ((m_int)((f) >> 16)) -#define MGL_FIXROUND(f) ((m_int)(((f) + MGL_FIX_HALF) >> 16)) - -#define MGL_ZFIX_1 0x10000000L -#define MGL_ZFIX_HALF 0x08000000L -#define MGL_FIXTOZ(i) ((i) << 12) -#define MGL_ZTOFIX(i) ((i) >> 12) -#define MGL_TOZFIX(i) ((long)(i) << 28) -#define MGL_ZFIXTOINT(f) ((m_int)((f) >> 28)) -#define MGL_ZFIXROUND(f) ((m_int)(((f) + MGL_ZFIX_HALF) >> 28)) - -/* Region structure */ - -#ifdef BUILD_MGL -struct _span_t; -typedef struct _span_t span_t; -#else -typedef void span_t; -#endif - -typedef struct { - rect_t rect; /* Bounding rectangle for region */ - span_t *spans; /* Start of span list for region */ -} region_t; - -/* Palette entry structure */ - -typedef struct { - uchar blue; /* Blue component of color */ - uchar green; /* Green component of color */ - uchar red; /* Blue component of color */ - uchar alpha; /* Alpha or alignment byte */ -} palette_t; - -/* Maximum value for each palette entry component */ - -#define PALMAX 255 /* Max value for palette components */ - -/* Pixel format structure */ - -typedef struct { - uchar redMask, greenMask; /* Mask values for pixels */ - uchar blueMask, rsvdMask; - m_int redPos, redAdjust; /* Red position and adjustment */ - m_int greenPos, greenAdjust; /* Green position and adjustment */ - m_int bluePos, blueAdjust; /* Blue position and adjustment */ - m_int rsvdPos, rsvdAdjust; /* Reserved position and adjustment */ -} pixel_format_t; - -/* Structure to hold arc coordinate information */ - -typedef struct { - m_int x, y; /* Centre point of the arc */ - m_int startX, startY; /* Starting point on arc */ - m_int endX, endY; /* Ending point on arc */ -} arc_coords_t; - -/* Mouse cursor structure */ - -typedef struct { - ulong xorMask[32]; - ulong andMask[32]; - m_int xHotSpot; - m_int yHotSpot; -} cursor_t; - -/* Bitmap structure - always packed pixel DIB format */ - -typedef struct { - m_int width; /* Width of bitmap in pixels */ - m_int height; /* Height of bitmap in pixels */ - m_int bitsPerPixel; /* Pixel width */ - m_int bytesPerLine; /* Bytes per line value for surface */ - uchar *surface; /* Pointer to bitmap surface */ - palette_t *pal; /* Palette (NULL if not loaded) */ - pixel_format_t *pf; /* Pixel format (NULL if none) */ - - /* ... palette, pixel format and bitmap data are store contiguously */ -} bitmap_t; - -/* Icon structure - can be 32x23, 64x64 or in fact any size */ - -typedef struct { - m_int byteWidth; /* Byte with for AND mask */ - uchar *andMask; /* Hold punch mask for icon */ - bitmap_t xorMask; /* XOR mask for the icon */ - - /* ... AND mask and bitmap structure are stored contiguously */ -} icon_t; - -/* Default cursor name */ - -#define MGL_DEF_CURSOR _MGL_getDefCursor() - -/* Generic Font structure */ - -#define _MGL_FNAMESIZE 58 - -typedef struct { - char name[_MGL_FNAMESIZE]; /* Name of the font */ - short fontType; /* Type of font */ - short maxWidth; /* Maximum character width */ - short maxKern; /* Maximum character kern */ - short fontWidth; /* Font width */ - short fontHeight; /* Font height */ - short ascent; /* Font ascent value */ - short descent; /* Font descent value */ - short leading; /* Font leading value */ -} font_t; - -/* Character and font metrics structure */ - -typedef struct { - m_int width; /* Width of character or font */ - m_int fontWidth; /* Character width (tightest fit) */ - m_int fontHeight; /* Height of the font */ - m_int ascent; /* Ascent value */ - m_int descent; /* Descent value */ - m_int leading; /* Leading value */ - m_int kern; /* Kern value */ -} metrics_t; - -/* Text settings structure */ - -typedef struct { - m_int horizJust; /* Horizontal justfication */ - m_int vertJust; /* Vertical justification */ - m_int dir; /* Text drawing direction */ - m_int szNumerx; /* Text x size numerator */ - m_int szNumery; /* Text y size numerator */ - m_int szDenomx; /* Text x size denominator */ - m_int szDenomy; /* Text y size denominator */ - m_int spaceExtra; /* Space extra term */ - font_t *font; /* Currently selected font */ -} text_settings_t; - -/* Macros to access the (left,top) and (right,bottom) points of a - * rectangle. - */ - -#define MGL_leftTop(r) (((point_t *) &(r))[0]) -#define MGL_rightBottom(r) (((point_t *) &(r))[1]) - -typedef uchar pattern_t[8]; -typedef color_t pixpattern_t[8][8]; - -/* Attributes structure */ - -typedef struct { - color_t color; /* Foreground color */ - color_t backColor; /* Background color */ - m_int colorMode; /* Current color mode */ - m_int markerSize; /* Size of markers in pixels */ - m_int markerStyle; /* Style of markers */ - color_t markerColor; /* Color to draw markers in */ - color_t bdrBright; /* Border bright color */ - color_t bdrDark; /* Border dark color */ - point_t CP; /* Graphics pen position */ - m_int writeMode; /* Scan conversion write mode op. */ - m_int penStyle; /* Pen style */ - m_int penHeight; /* Height of pen */ - m_int penWidth; /* Width of pen */ - pattern_t penPat; /* Pattern for pen */ - pixpattern_t penPixPat; /* Pixmap pattern for pen */ - m_int lineStyle; /* Line style */ - ushort lineStipple; /* Line stipple */ - m_uint stippleCount; /* Current line stipple count */ - rect_t viewPort; /* Viewport dimensions */ - point_t viewPortOrg; /* Logical viewport origin */ - rect_t clipRect; /* Clipping rectangle dimensions */ - m_int clip; /* Is clipping on? */ - m_int polyType; /* Polygon drawing type */ - text_settings_t ts; /* Text drawing attributes */ -} attributes_t; - -/* Mode specific format information. This structrure can be used by - * the device driver to build tables of values for all supported modes - */ - -typedef struct { - m_int xRes; /* Device x resolution - 1 */ - m_int yRes; /* Device y resolution - 1 */ - m_int bitsPerPixel; /* Number of bits per pixel */ - m_int numberOfPlanes; /* Number of planes in image */ - color_t maxColor; /* Maximum number of colors - 1 */ - m_int maxPage; /* Maximum number of video pages - 1 */ - m_int bytesPerLine; /* Number of bytes in a line */ - m_int aspectRatio; /* Mode aspect ratio (horiz/vert * 1000) */ - long pageSize; /* Number of bytes in a page */ - m_int scratch1; /* Scratch pad value 1 */ - m_int scratch2; /* Scratch pad value 2 */ - char redMaskSize; /* Size of direct color red mask */ - char redFieldPosition; /* Bit posn of lsb of red mask */ - char greenMaskSize; /* Size of direct color green mask */ - char greenFieldPosition; /* Bit posn of lsb of green mask */ - char blueMaskSize; /* Size of direct color blue mask */ - char blueFieldPosition; /* Bit posn of lsb of blue mask */ - char rsvdMaskSize; /* Size of reserved mask */ - char rsvdFieldPosition; /* Bit posn of reserved mask */ -} gmode_t; - -/* Public Device Context Structure. The 'surface' member along with the - * gmode_t information block, provides direct access to the active - * display surface for user applications. The MGL virtualises the surface - * in SuperVGA modes that dont have a real linear framebuffer. - */ - -typedef struct { - attributes_t a; /* Active device attributes */ - void *surface; /* Pointer to active device surface */ - void *zbuffer; /* Pointer to Z-buffer if allocated */ - m_int zbits; /* Bits per zbuffer element */ - m_int zwidth; /* Width of the zbuffer in pixels */ - gmode_t mi; /* Mode specific information block */ - pixel_format_t pf; /* Current pixel format for device context */ - color_t *colorTab; /* Color lookup table cache */ - color_t *shadeTab; /* Currently active shade table */ - m_int bankOffset; /* Offset of starting bank number */ - - /* Remainder of Device Context structure is private and internal */ -} publicDevCtx_t; - -#ifndef BUILD_MGL -typedef publicDevCtx_t MGLDC; -#else -struct internalDevCtx_t; -typedef struct internalDevCtx_t MGLDC; -#endif - -typedef struct { - ulong which; /* Which window for window manager code */ - m_uint what; /* Event code */ - ulong when; /* Clock ticks since midnight */ - m_int where_x; /* Mouse location */ - m_int where_y; - ulong message; /* Event specific message */ - ulong modifiers; /* Modifier flags */ - m_int next; /* Next event in queue */ - m_int prev; /* Previous event in queue */ -} event_t; - -/* Structure containing file I/O functions allowing the user application to - * completely replace the MGL's file I/O functions with their own. This - * allows the app to store all MGL related files in a single large file, - * with encryption or compression is desired. By default normal file I/O - * functions will be used. - */ - -typedef struct { - FILE *(*fopen) (const char *filename, const char *mode); - int (*fclose) (FILE *f); - int (*fseek) (FILE *f, long offset, int whence); - long (*ftell) (FILE *f); - size_t(*fread) (void *ptr, size_t size, size_t n, FILE *f); - - - - - - - - - - - - - - - - - - - size_t(*fwrite) (const void *ptr, size_t size, size_t n, FILE *f); -} fileio_t; - -/* Define the flags for the types of direct surface access provided */ - -#define MGL_NO_ACCESS 0x0 /* Surface cannot be accessed */ -#define MGL_VIRTUAL_ACCESS 0x1 /* Surface is virtualised */ -#define MGL_LINEAR_ACCESS 0x2 /* Surface can be linearly accessed */ -#define MGL_SURFACE_FLAGS 0x3 - -/* Define the flags for the types of direct zbuffer access provided */ - -#define MGL_NO_ZACCESS 0x0 /* Zbuffer cannot be accessed */ -#define MGL_VIRTUAL_ZACCESS 0x4 /* Zbuffer is virtualised in */ -#define MGL_LINEAR_ZACCESS 0x8 /* Zbuffer can be linearly accessed */ -#define MGL_ZBUFFER_FLAGS 0xC - -/* Define the flags for the types of hardware acceleration supported by - * the device context. This will allow the application to tailor the use of - * MGL functions depending upon whether specific hardware support is - * available. Hence applications can use specialised software rendering - * support if the desired hardware support is not available. - * - * NOTE: If the hardware flags are not MGL_HW_NONE, you *must* call - * the MGL_beginDirectAccess() and MGL_endDirectAccess() functions - * before and after any custom code that does direct framebuffer - * rendering!! - * - * This is not necessary for non-accelerated device context, so you - * might want to optimise these calls out if there is no hardware - * acceleration support. - */ - -#define MGL_HW_NONE 0x0000 /* No hardware acceleration */ -#define MGL_HW_LINE 0x0010 /* Hardware line drawing */ -#define MGL_HW_STIPPLE_LINE 0x0020 /* Hardware stippled line drawing */ -#define MGL_HW_POLY 0x0040 /* Hardware polygon filling */ -#define MGL_HW_RECT 0x0080 /* Hardware rectangle fill */ -#define MGL_HW_PATT_RECT 0x0100 /* Hardware pattern rectangle fill */ -#define MGL_HW_CLRPATT_RECT 0x0200 /* Hardware color pattern fill */ -#define MGL_HW_SCR_BLT 0x0400 /* Hardware screen/screen bitBlt */ -#define MGL_HW_SRCTRANS_BLT 0x0800 /* Hardware source transparent blt */ -#define MGL_HW_DSTTRANS_BLT 0x1000 /* Hardware dest. transparent blt */ -#define MGL_HW_MONO_BLT 0x2000 /* Hardware monochrome blt */ -#define MGL_HW_CLIP 0x4000 /* Hardware clipping */ -#define MGL_HW_FLAGS 0xFFF0 - -#ifdef __cplusplus -extern "C" { /* Use "C" linkage when in C++ mode */ -#endif - -/*------------------------- Function Prototypes ---------------------------*/ - -/*--------------------------------------------------------------------------- - * Routines bound to a specific device context. These routines all take - * an MGLDC as a parmeter for the context to work with and hence dont work - * with the current context. If however the context passed is the currently - * active context, all changes to that context are reflected in the - * currently active context as well. - *-------------------------------------------------------------------------*/ - -/* Environment detection and initialisation */ - - m_int MGLAPI MGL_registerDriver(const char *name, void *driver); - void MGLAPI MGL_unregisterAllDrivers(void); - void MGLAPI MGL_registerAllDispDrivers(bool useLinear, - bool useDirectDraw, - bool useWinDirect); - void MGLAPI MGL_registerAllMemDrivers(void); - void MGLAPI MGL_detectGraph(m_int * driver, m_int * mode); - uchar *MGLAPI MGL_availableModes(void); - m_int MGLAPI MGL_availablePages(m_int mode); - m_int MGLAPI MGL_modeResolution(m_int mode, m_int * xRes, m_int * yRes, - m_int * bitsPerPixel); - bool MGLAPI MGL_isDisplayDC(MGLDC *dc); - bool MGLAPI MGL_isWindowedDC(MGLDC *dc); - bool MGLAPI MGL_isMemoryDC(MGLDC *dc); - void MGLAPI MGL_exit(void); - void MGLAPI MGL_setBufSize(unsigned size); - void MGLAPI MGL_fatalError(const char *msg); - m_int MGLAPI MGL_result(void); - void MGLAPI MGL_setResult(m_int result); - const char *MGLAPI MGL_errorMsg(m_int err); - const char *MGLAPI MGL_modeName(m_int mode); - const char *MGLAPI MGL_modeDriverName(m_int mode); - const char *MGLAPI MGL_driverName(m_int driver); - m_int MGLAPI MGL_getDriver(MGLDC *dc); - m_int MGLAPI MGL_getMode(MGLDC *dc); - m_int MGLAPI MGL_surfaceAccessType(MGLDC *dc); - m_int MGLAPI MGL_zbufferAccessType(MGLDC *dc); - long MGLAPI MGL_getHardwareFlags(MGLDC *dc); - void MGLAPI MGL_defaultAttributes(MGLDC *dc); - void MGLAPI MGL_makeSubDC(MGLDC *dc, m_int left, m_int top, m_int right, - m_int bottom); - -/* Viewport and clip rectangle manipulation bound to a specific DC */ - - void MGLAPI MGL_setViewportDC(MGLDC *dc, rect_t view); - void MGLAPI MGL_setRelViewportDC(MGLDC *dc, rect_t view); - void MGLAPI MGL_getViewportDC(MGLDC *dc, rect_t * view); - void MGLAPI MGL_setViewportOrgDC(MGLDC *dc, point_t org); - void MGLAPI MGL_getViewportOrgDC(MGLDC *dc, point_t * org); - void MGLAPI MGL_globalToLocalDC(MGLDC *dc, point_t * p); - void MGLAPI MGL_localToGlobalDC(MGLDC *dc, point_t * p); - m_int MGLAPI MGL_maxxDC(MGLDC *dc); - m_int MGLAPI MGL_maxyDC(MGLDC *dc); - void MGLAPI MGL_setClipRectDC(MGLDC *dc, rect_t clip); - void MGLAPI MGL_getClipRectDC(MGLDC *dc, rect_t * clip); - void MGLAPI MGL_setClipModeDC(MGLDC *dc, bool mode); - bool MGLAPI MGL_getClipModeDC(MGLDC *dc); - -/* Color and palette manipulation */ - - color_t MGLAPI MGL_realColor(MGLDC *dc, m_int color); - color_t MGLAPI MGL_rgbColor(MGLDC *dc, uchar R, uchar G, uchar B); - void MGLAPI MGL_setPaletteEntry(MGLDC *dc, m_int entry, uchar red, - uchar green, uchar blue); - void MGLAPI MGL_getPaletteEntry(MGLDC *dc, m_int entry, uchar *red, - uchar *green, uchar *blue); - void MGLAPI MGL_setPalette(MGLDC *dc, palette_t * pal, m_int numColors, - m_int startIndex); - void MGLAPI MGL_getPalette(MGLDC *dc, palette_t * pal, m_int numColors, - m_int startIndex); - void ASMAPI MGL_rotatePalette(MGLDC *dc, m_int numColors, - m_int startIndex, m_int direction); - bool ASMAPI MGL_fadePalette(MGLDC *dc, palette_t * fullIntensity, - m_int numColors, m_int startIndex, - uchar intensity); - void MGLAPI MGL_realizePalette(MGLDC *dc, m_int numColors, - m_int startIndex, m_int waitVRT); - m_int MGLAPI MGL_getPaletteSize(MGLDC *dc); - void MGLAPI MGL_getDefaultPalette(MGLDC *dc, palette_t * pal); - void MGLAPI MGL_setDefaultPalette(MGLDC *dc); -#ifndef MGL_LITE - bool MGLAPI MGL_checkIdentityPalette(bool enable); - void MGLAPI MGL_mapToPalette(MGLDC *dc, palette_t * pal); -#endif - -/* Generic device context information and manipulation */ - - bool MGLAPI MGL_haveWidePalette(MGLDC *dc); - m_int MGLAPI MGL_getBitsPerPixel(MGLDC *dc); - color_t MGLAPI MGL_maxColor(MGLDC *dc); - m_int MGLAPI MGL_maxPage(MGLDC *dc); - m_int MGLAPI MGL_sizex(MGLDC *dc); - m_int MGLAPI MGL_sizey(MGLDC *dc); - void MGLAPI MGL_getPixelFormat(MGLDC *dc, pixel_format_t *pf); - void *MGLAPI MGL_computePixelAddr(MGLDC *dc, int x, int y); - -/* Double buffering support */ - - void MGLAPI MGL_setActivePage(MGLDC *dc, m_int page); - m_int MGLAPI MGL_getActivePage(MGLDC *dc); - void MGLAPI MGL_setVisualPage(MGLDC *dc, m_int page, m_int waitVRT); - m_int MGLAPI MGL_getVisualPage(MGLDC *dc); - void MGLAPI MGL_setDisplayStart(MGLDC *dc, m_int x, m_int y, - m_int waitFlag); - void MGLAPI MGL_getDisplayStart(MGLDC *dc, m_int * x, m_int * y); - void MGLAPI MGL_vSync(MGLDC *dc); - bool MGLAPI MGL_doubleBuffer(MGLDC *dc); - void MGLAPI MGL_singleBuffer(MGLDC *dc); - void MGLAPI MGL_swapBuffers(MGLDC *dc, m_int waitVRT); - -/* Zbuffering support */ - -#ifdef MGL_3D - m_int MGLAPI MGL_getHardwareZBufferDepth(MGLDC *dc); - bool ASMAPI MGL_zBegin(MGLDC *dc, m_int zbits); - bool MGLAPI MGL_zShareZBuffer(MGLDC *dc, MGLDC *dcShared, m_int zbits); -#endif - -/* Event handling support */ - - bool MGLAPI EVT_getNext(event_t * evt, m_uint mask); - bool MGLAPI EVT_peekNext(event_t * evt, m_uint mask); - bool MGLAPI EVT_post(ulong which, m_uint what, ulong message, - ulong modifiers); - void MGLAPI EVT_flush(m_uint mask); - void MGLAPI EVT_halt(event_t * evt, m_uint mask); - m_int MGLAPI EVT_setTimerTick(m_int ticks); - -/*--------------------------------------------------------------------------- - * Routines bound to the currently active context. All these routines work - * with the currently active context and do not reflect any changes made - * to the global context to the original user supplied context (because it - * may be cached). The cached DC is automatically flushed back to the - * original DC when a new context is enabled with MGL_makeCurrentDC(). - * - * Before destroying a DC that is current, make sure you call - * MGL_makeCurrentDC(NULL) first! - *-------------------------------------------------------------------------*/ - -/* Routines to change the active global device context */ - - MGLDC *MGLAPI MGL_makeCurrentDC(MGLDC *dc); - bool MGLAPI MGL_isCurrentDC(MGLDC *dc); - -/* Current device context information and manipulation */ - - m_int MGLAPI MGL_getAspectRatio(void); - void MGLAPI MGL_setAspectRatio(m_int aspectRatio); - void ASMAPI MGL_setColor(color_t color); - void MGLAPI MGL_setColorRGB(uchar R, uchar G, uchar B); - void MGLAPI MGL_setColorCI(m_int index); - color_t MGLAPI MGL_getColor(void); - void ASMAPI MGL_setBackColor(color_t color); - color_t MGLAPI MGL_getBackColor(void); - color_t ASMAPI MGL_packColor(pixel_format_t *pf, uchar R, uchar G, - uchar B); - void MGLAPI MGL_unpackColor(pixel_format_t *pf, color_t color, - uchar *R, uchar *G, uchar *B); - color_t ASMAPI MGL_packColorRGB(uchar R, uchar G, uchar B); - void MGLAPI MGL_unpackColorRGB(color_t color, uchar *R, uchar *G, - uchar *B); - color_t MGLAPI MGL_defaultColor(void); -#ifndef MGL_LITE - void MGLAPI MGL_setMarkerSize(m_int size); - m_int MGLAPI MGL_getMarkerSize(void); - void MGLAPI MGL_setMarkerStyle(m_int style); - m_int MGLAPI MGL_getMarkerStyle(void); - void MGLAPI MGL_setMarkerColor(color_t color); - color_t MGLAPI MGL_getMarkerColor(void); - void MGLAPI MGL_setBorderColors(color_t bright, color_t dark); - void MGLAPI MGL_getBorderColors(color_t * bright, color_t * dark); - void ASMAPI MGL_setWriteMode(m_int mode); - m_int MGLAPI MGL_getWriteMode(void); - void ASMAPI MGL_setPenStyle(m_int style); - m_int MGLAPI MGL_getPenStyle(void); - void MGLAPI MGL_setLineStyle(m_int style); - m_int MGLAPI MGL_getLineStyle(void); - void ASMAPI MGL_setLineStipple(ushort stipple); - ushort MGLAPI MGL_getLineStipple(void); - void ASMAPI MGL_setLineStippleCount(m_uint stippleCount); - m_uint MGLAPI MGL_getLineStippleCount(void); - void ASMAPI MGL_setPenBitmapPattern(const pattern_t * pat); - void MGLAPI MGL_getPenBitmapPattern(pattern_t * pat); - void ASMAPI MGL_setPenPixmapPattern(const pixpattern_t * pat); - void MGLAPI MGL_getPenPixmapPattern(pixpattern_t * pat); - void MGLAPI MGL_setPenSize(m_int height, m_int width); - void MGLAPI MGL_getPenSize(m_int * height, m_int * width); -#ifndef MGL_LITE - void MGLAPI MGL_setColorMapMode(m_int mode); - m_int MGLAPI MGL_getColorMapMode(void); -#endif - void MGLAPI MGL_setPolygonType(m_int type); - m_int MGLAPI MGL_getPolygonType(void); -#endif - void MGLAPI MGL_getAttributes(attributes_t * attr); - void MGLAPI MGL_restoreAttributes(attributes_t * attr); - -/* Device clearing */ - - void ASMAPI MGL_clearDevice(void); - void MGLAPI MGL_clearViewport(void); - -/* Viewport and clip rectangle manipulation */ - - void MGLAPI MGL_setViewport(rect_t view); - void MGLAPI MGL_setRelViewport(rect_t view); - void MGLAPI MGL_getViewport(rect_t * view); - void MGLAPI MGL_setViewportOrg(point_t org); - void MGLAPI MGL_getViewportOrg(point_t * org); - void MGLAPI MGL_globalToLocal(point_t * p); - void MGLAPI MGL_localToGlobal(point_t * p); - m_int MGLAPI MGL_maxx(void); - m_int MGLAPI MGL_maxy(void); - void MGLAPI MGL_setClipRect(rect_t clip); - void MGLAPI MGL_getClipRect(rect_t * clip); - void MGLAPI MGL_setClipMode(bool mode); - bool MGLAPI MGL_getClipMode(void); - -/* Pixel plotting */ - - void MGLAPI MGL_pixelCoord(m_int x, m_int y); - color_t MGLAPI MGL_getPixelCoord(m_int x, m_int y); - void ASMAPI MGL_beginPixel(void); - void MGLAPI MGL_pixelCoordFast(m_int x, m_int y); - color_t MGLAPI MGL_getPixelCoordFast(m_int x, m_int y); - void ASMAPI MGL_endPixel(void); - -/* Line drawing and clipping */ - - void MGLAPI MGL_moveToCoord(m_int x, m_int y); - void MGLAPI MGL_moveRelCoord(m_int dx, m_int dy); - void MGLAPI MGL_lineToCoord(m_int x, m_int y); - void MGLAPI MGL_lineRelCoord(m_int dx, m_int dy); - m_int MGLAPI MGL_getX(void); - m_int MGLAPI MGL_getY(void); - void MGLAPI MGL_getCP(point_t * CP); - void MGLAPI MGL_lineCoord(m_int x1, m_int y1, m_int x2, m_int y2); - void MGLAPI MGL_lineCoordFX(fix32_t x1, fix32_t y1, fix32_t x2, - fix32_t y2); - void MGLAPI MGL_lineCoordFast(m_int x1, m_int y1, m_int x2, m_int y2); - void MGLAPI MGL_lineCoordFastFX(fix32_t x1, fix32_t y1, fix32_t x2, - fix32_t y2); - void MGLAPI MGL_lineEngine(fix32_t x1, fix32_t y1, fix32_t x2, - fix32_t y2, - void (ASMAPI * plotPoint) (m_int x, m_int y)); - bool MGLAPI MGL_clipLineFX(fix32_t * x1, fix32_t * y1, fix32_t * x2, - fix32_t * y2, fix32_t left, fix32_t top, - fix32_t right, fix32_t bottom); -#ifndef MGL_LITE - void ASMAPI MGL_scanLine(m_int y, m_int x1, m_int x2); -#endif - -/* Routines to perform bank switching for banked framebuffers for custom - * rendering code. The first version is callable only from assembler and - * requires the new bank value to be passed in the DL register. The second - * version is callable directly from C. DO NOT CALL THESE FUNCTIONS WHEN - * RUNNING WITH A LINEAR FRAMEBUFFER!!! - */ - - void _ASMAPI SVGA_setBank(void); - void _ASMAPI SVGA_setBankC(int bank); - -/* Routines to begin/end direct framebuffer access. You must call these - * functions is you wish to render directly to a hardware accelerated - * device surface. - */ - - void ASMAPI MGL_beginDirectAccess(void); - void ASMAPI MGL_endDirectAccess(void); - -/* Routines to begin/end fast rendering of flat shaded lines, scanlines - * and polygons. - */ - - void ASMAPI MGL_beginDrawing(void); - void ASMAPI MGL_endDrawing(void); - -/* Routines to begin/end fast rendering of smooth shaded lines, scanlines - * and polygons. - */ - -#ifdef MGL_3D - void ASMAPI MGL_beginShadedDrawing(void); - void ASMAPI MGL_endShadedDrawing(void); -#endif - -/* Routines to begin/end fast rendering of flat shaded, zbuffered lines and - * polygons. - */ - -#ifdef MGL_3D - void ASMAPI MGL_beginZDrawing(void); - void ASMAPI MGL_endZDrawing(void); -#endif - -/* Routines to begin/end fast rendering of smooth shaded, zbuffered lines and - * polygons. - */ - -#ifdef MGL_3D - void ASMAPI MGL_beginZShadedDrawing(void); - void ASMAPI MGL_endZShadedDrawing(void); -#endif - -/* Polygon drawing: Note that the following fast polygon routines - * only work with convex polygons. The integer coordinate versions are - * provided for compatibility only, and convert the coordinates to fixed - * point and call the appropriate fixed point routines below. - */ - -#ifndef MGL_LITE - void MGLAPI MGL_fillPolygon(m_int count, point_t * vArray, m_int xOffset, - m_int yOffset); - void MGLAPI MGL_fillPolygonFast(m_int count, point_t * vArray, - m_int xOffset, m_int yOffset); - void ASMAPI MGL_fillPolygonFX(m_int count, fxpoint_t * vArray, - m_int vinc, fix32_t xOffset, - fix32_t yOffset); - void ASMAPI MGL_fillPolygonFastFX(m_int count, fxpoint_t * vArray, - m_int vinc, fix32_t xOffset, - fix32_t yOffset); -#endif - -/* 3D rasterization routines */ - -#ifdef MGL_3D - void MGLAPI MGL_zClearCoord(m_int left, m_int top, m_int right, - m_int bottom, zfix32_t clearVal); -#endif - -#ifdef MGL_FIX3D - void ASMAPI MGL_cLineCoordFast(fix32_t x1, fix32_t y1, fix32_t c1, - fix32_t x2, fix32_t y2, fix32_t c2); - void ASMAPI MGL_rgbLineCoordFast(fix32_t x1, fix32_t y1, fix32_t r1, - fix32_t g1, fix32_t b1, fix32_t x2, - fix32_t y2, fix32_t r2, fix32_t g2, - fix32_t b2); - void ASMAPI MGL_zLineCoordFast(fix32_t x1, fix32_t y1, zfix32_t z1, - fix32_t x2, fix32_t y2, zfix32_t z2); - void ASMAPI MGL_czLineCoordFast(fix32_t x1, fix32_t y1, zfix32_t z1, - fix32_t c1, fix32_t x2, fix32_t y2, - zfix32_t z2, fix32_t c2); - void ASMAPI MGL_rgbzLineCoordFast(fix32_t x1, fix32_t y1, zfix32_t z1, - fix32_t r1, fix32_t g1, fix32_t b1, - fix32_t x2, fix32_t y2, zfix32_t z2, - fix32_t r2, fix32_t g2, fix32_t b2); - - void ASMAPI MGL_triFast(fxpoint_t * v1, fxpoint_t * v2, fxpoint_t * v3, - fix32_t xOffset, fix32_t yOffset); - void ASMAPI MGL_cTriFast(fxpointc_t * v1, fxpointc_t * v2, - fxpointc_t * v3, fix32_t xOffset, - fix32_t yOffset); - void ASMAPI MGL_rgbTriFast(fxpointrgb_t * v1, fxpointrgb_t * v2, - fxpointrgb_t * v3, fix32_t xOffset, - fix32_t yOffset); - void ASMAPI MGL_zTriFast(fxpointz_t * v1, fxpointz_t * v2, - fxpointz_t * v3, fix32_t xOffset, - fix32_t yOffset, zfix32_t zOffset); - void ASMAPI MGL_czTriFast(fxpointcz_t * v1, fxpointcz_t * v2, - fxpointcz_t * v3, fix32_t xOffset, - fix32_t yOffset, zfix32_t zOffset); - void ASMAPI MGL_rgbzTriFast(fxpointrgbz_t * v1, fxpointrgbz_t * v2, - fxpointrgbz_t * v3, fix32_t xOffset, - fix32_t yOffset, zfix32_t zOffset); - - void ASMAPI MGL_quadFast(fxpoint_t * v1, fxpoint_t * v2, fxpoint_t * v3, - fxpoint_t * v4, fix32_t xOffset, - fix32_t yOffset); - void ASMAPI MGL_cQuadFast(fxpointc_t * v1, fxpointc_t * v2, - fxpointc_t * v3, fxpointc_t * v4, - fix32_t xOffset, fix32_t yOffset); - void ASMAPI MGL_rgbQuadFast(fxpointrgb_t * v1, fxpointrgb_t * v2, - fxpointrgb_t * v3, fxpointrgb_t * v4, - fix32_t xOffset, fix32_t yOffset); - void ASMAPI MGL_zQuadFast(fxpointz_t * v1, fxpointz_t * v2, - fxpointz_t * v3, fxpointz_t * v4, - fix32_t xOffset, fix32_t yOffset, - zfix32_t zOffset); - void ASMAPI MGL_czQuadFast(fxpointcz_t * v1, fxpointcz_t * v2, - fxpointcz_t * v3, fxpointcz_t * v4, - fix32_t xOffset, fix32_t yOffset, - zfix32_t zOffset); - void ASMAPI MGL_rgbzQuadFast(fxpointrgbz_t * v1, fxpointrgbz_t * v2, - fxpointrgbz_t * v3, fxpointrgbz_t * v4, - fix32_t xOffset, fix32_t yOffset, - zfix32_t zOffset); -#endif - -/* Routine to set the currently active shade table. In HiColor and TrueColor - * video modes, you must set a valid shadeTable before you call any of the - * color index shaded rendering routines (MGL_cTri() etc). These routines - * will interpolate an index into the current shade table rather than - * each of the RGB color channels, and the appropriate full RGB color is - * extracted directly from the shade table. The shade table can be any size, - * but the application must ensure that the indices passed in are within - * the range of the current shade table. - */ - -#ifdef MGL_3D - void MGLAPI MGL_setShadeTable(color_t * shadeTab); -#endif - -/* Polyline drawing */ - -#ifndef MGL_LITE - void MGLAPI MGL_marker(point_t p); - void MGLAPI MGL_polyPoint(m_int count, point_t * vArray); - void MGLAPI MGL_polyMarker(m_int count, point_t * vArray); - void MGLAPI MGL_polyLine(m_int count, point_t * vArray); -#endif - -/* Rectangle drawing */ - -#ifndef MGL_LITE - void MGLAPI MGL_rectCoord(m_int left, m_int top, m_int right, - m_int bottom); - void MGLAPI MGL_fillRectCoord(m_int left, m_int top, m_int right, - m_int bottom); -#endif - -/* Scanline color scanning. Thee routines are primitive, and do not perform - * any clipping or viewport mapping, so can be used to build you own - * high performance floodfilling routines (see the example file ffill.c - * for pre-built high speed floodfill routines). - */ - -#ifndef MGL_LITE - m_int ASMAPI MGL_scanRightForColor(m_int x, m_int y, color_t color); - m_int ASMAPI MGL_scanLeftForColor(m_int x, m_int y, color_t color); - m_int ASMAPI MGL_scanRightWhileColor(m_int x, m_int y, color_t color); - m_int ASMAPI MGL_scanLeftWhileColor(m_int x, m_int y, color_t color); -#endif - -/* Psuedo 3D border drawing */ - -#ifndef MGL_LITE - void MGLAPI MGL_drawBorderCoord(m_int left, m_int top, m_int right, - m_int bottom, m_int style, - m_int thickness); - void MGLAPI MGL_drawHDivider(m_int y, m_int x1, m_int x2); - void MGLAPI MGL_drawVDivider(m_int x, m_int y1, m_int y2); -#endif - -/* Ellipse drawing */ - -#ifndef MGL_LITE - void MGLAPI MGL_ellipseArc(rect_t extentRect, m_int startAngle, - m_int endAngle); - void MGLAPI MGL_ellipseArcCoord(m_int x, m_int y, m_int xradius, - m_int yradius, m_int startAngle, - m_int endAngle); - void ASMAPI MGL_getArcCoords(arc_coords_t * coords); - void MGLAPI MGL_ellipse(rect_t extentRect); - void MGLAPI MGL_ellipseCoord(m_int x, m_int y, m_int xradius, - m_int yradius); - void MGLAPI MGL_fillEllipseArc(rect_t extentRect, m_int startAngle, - m_int endAngle); - void MGLAPI MGL_fillEllipseArcCoord(m_int x, m_int y, m_int xradius, - m_int yradius, m_int startAngle, - m_int endAngle); - void MGLAPI MGL_fillEllipse(rect_t extentRect); - void MGLAPI MGL_fillEllipseCoord(m_int x, m_int y, m_int xradius, - m_int yradius); - void MGLAPI MGL_ellipseEngine(rect_t extentRect, - void (ASMAPI * setup) (m_int topY, - m_int botY, - m_int left, - m_int right), - void (ASMAPI * set4pixels) (bool inc_x, - bool inc_y, - bool region1), - void (ASMAPI * finished) (void)); - void MGLAPI MGL_ellipseArcEngine(rect_t extentRect, m_int startAngle, - m_int endAngle, arc_coords_t * ac, - void (ASMAPI * plotPoint) (m_int x, - m_int y)); -#endif - -/* Text attribute manipulation */ - -#ifndef MGL_LITE - void MGLAPI MGL_setTextJustify(m_int horiz, m_int vert); - void MGLAPI MGL_getTextJustify(m_int * horiz, m_int * vert); - void MGLAPI MGL_setTextDirection(m_int direction); - m_int MGLAPI MGL_getTextDirection(void); - void MGLAPI MGL_setTextSize(m_int numerx, m_int denomx, m_int numery, - m_int denomy); - void MGLAPI MGL_getTextSize(m_int * numerx, m_int * denomx, - m_int * numery, m_int * denomy); - void MGLAPI MGL_setSpaceExtra(m_int extra); - m_int MGLAPI MGL_getSpaceExtra(void); - void MGLAPI MGL_setTextSettings(text_settings_t * settings); - void MGLAPI MGL_getTextSettings(text_settings_t * settings); - m_int MGLAPI MGL_textHeight(void); - m_int MGLAPI MGL_textWidth(const char *str); - void MGLAPI MGL_textBounds(m_int x, m_int y, const char *str, - rect_t * bounds); - m_int MGLAPI MGL_charWidth(char ch); - void MGLAPI MGL_getFontMetrics(metrics_t * metrics); - void MGLAPI MGL_getCharMetrics(char ch, metrics_t * metrics); - m_int MGLAPI MGL_maxCharWidth(void); - void MGLAPI MGL_underScoreLocation(m_int * x, m_int * y, const char *str); -#endif - -/* Text drawing */ - -#ifndef MGL_LITE - void MGLAPI MGL_drawStr(const char *str); - void MGLAPI MGL_drawStrXY(m_int x, m_int y, const char *str); - bool MGLAPI MGL_useFont(font_t * font); - font_t *MGLAPI MGL_getFont(void); - bool MGLAPI MGL_vecFontEngine(m_int x, m_int y, const char *str, - void (ASMAPI * move) (m_int x, m_int y), - void (ASMAPI * draw) (m_int x, m_int y)); -#endif - -/* BitBlt support */ - - void MGLAPI MGL_bitBltCoord(MGLDC *dst, MGLDC *src, m_int left, - m_int top, m_int right, m_int bottom, - m_int dstLeft, m_int dstTop, m_int op); - void MGLAPI MGL_stretchBltCoord(MGLDC *dst, MGLDC *src, m_int left, - m_int top, m_int right, m_int bottom, - m_int dstLeft, m_int dstTop, - m_int dstRight, m_int dstBottom); -#ifndef MGL_LITE - void MGLAPI MGL_getDivotCoord(MGLDC *dc, m_int left, m_int top, - m_int right, m_int bottom, void *divot); - void MGLAPI MGL_putDivot(MGLDC *dc, void *divot); - long MGLAPI MGL_divotSizeCoord(MGLDC *dc, m_int left, m_int top, - m_int right, m_int bottom); - void MGLAPI MGL_putMonoImage(MGLDC *dc, m_int x, m_int y, - m_int byteWidth, m_int height, void *image); - void MGLAPI MGL_putBitmap(MGLDC *dc, m_int x, m_int y, - const bitmap_t * bitmap, m_int op); - void MGLAPI MGL_putBitmapSection(MGLDC *dc, m_int left, m_int top, - m_int right, m_int bottom, - m_int dstLeft, m_int dstTop, - const bitmap_t * bitmap, m_int op); - void MGLAPI MGL_putBitmapTransparent(MGLDC *dc, m_int x, m_int y, - const bitmap_t * bitmap, - color_t transparent, - bool sourceTrans); - void MGLAPI MGL_putBitmapTransparentSection(MGLDC *dc, m_int left, - m_int top, m_int right, - m_int bottom, m_int dstLeft, - m_int dstTop, - const bitmap_t * bitmap, - color_t transparent, - bool sourceTrans); - void MGLAPI MGL_putBitmapMask(MGLDC *dc, m_int x, m_int y, - const bitmap_t * mask, color_t color); - void MGLAPI MGL_stretchBitmap(MGLDC *dc, m_int left, m_int top, - m_int right, m_int bottom, - const bitmap_t * bitmap); - void MGLAPI MGL_putIcon(MGLDC *dc, m_int x, m_int y, const icon_t * icon); - void MGLAPI MGL_transBltCoord(MGLDC *dst, MGLDC *src, m_int left, - m_int top, m_int right, m_int bottom, - m_int dstLeft, m_int dstTop, - color_t transparent, bool sourceTrans); -#endif - -/* Linear offscreen DC BitBlt support */ - -#ifndef MGL_LITE - void MGLAPI MGL_bitBltLinCoord(MGLDC *dst, MGLDC *src, ulong srcOfs, - m_int dstLeft, m_int dstTop, - m_int dstRight, m_int dstBottom, m_int op); - void MGLAPI MGL_transBltLinCoord(MGLDC *dst, MGLDC *src, ulong srcOfs, - m_int dstLeft, m_int dstTop, - m_int dstRight, m_int dstBottom, - color_t transparent, bool sourceTrans); -#endif - -/* Monochrome bitmap manipulation */ - -#ifndef MGL_LITE - void MGLAPI MGL_drawGlyph(font_t * g, m_int x, m_int y, uchar glyph); - m_int MGLAPI MGL_getGlyphWidth(font_t * font, uchar glyph); - m_int MGLAPI MGL_getGlyphHeight(font_t * font); - void MGLAPI MGL_rotateGlyph(uchar *dst, uchar *src, m_int * byteWidth, - m_int * height, m_int rotation); - void MGLAPI MGL_mirrorGlyph(uchar *dst, uchar *src, m_int byteWidth, - m_int height); -#endif - -/* Region management */ - -#ifndef MGL_LITE - region_t *MGLAPI MGL_newRegion(void); - region_t *MGLAPI MGL_copyRegion(const region_t * s); - void MGLAPI MGL_clearRegion(region_t * r); - void MGLAPI MGL_freeRegion(region_t * r); - void MGLAPI MGL_drawRegion(m_int x, m_int y, const region_t * r); -#endif - -/* Region generation primitives */ - -#ifndef MGL_LITE - region_t *MGLAPI MGL_rgnLineCoord(m_int x1, m_int y1, m_int x2, - m_int y2, const region_t * pen); - region_t *MGLAPI MGL_rgnLineCoordFX(fix32_t x1, fix32_t y1, fix32_t x2, - fix32_t y2, const region_t * pen); -/*region_t * MGLAPI MGL_rgnPolygon(m_int count,point_t *vArray);*/ -/*region_t * MGLAPI MGL_rgnPolygonFast(m_int count,point_t *vArray);*/ - region_t *MGLAPI MGL_rgnSolidRectCoord(m_int left, m_int top, - m_int right, m_int bottom); - region_t *MGLAPI MGL_rgnEllipse(rect_t extentRect, const region_t * pen); - region_t *MGLAPI MGL_rgnEllipseArc(rect_t extentRect, m_int startAngle, - m_int endAngle, const region_t * pen); - void MGLAPI MGL_rgnGetArcCoords(arc_coords_t * coords); - region_t *MGLAPI MGL_rgnSolidEllipse(rect_t extentRect); - region_t *MGLAPI MGL_rgnSolidEllipseArc(rect_t extentRect, - m_int startAngle, m_int endAngle); -#endif - -/* Region alegbra */ - -#ifndef MGL_LITE - region_t *MGLAPI MGL_sectRegion(const region_t * r1, const region_t * r2); - region_t *MGLAPI MGL_sectRegionRect(const region_t * r1, - const rect_t * r2); - bool MGLAPI MGL_unionRegion(region_t * r1, const region_t * r2); - bool MGLAPI MGL_unionRegionRect(region_t * r1, const rect_t * r2); - bool MGLAPI MGL_unionRegionOfs(region_t * r1, const region_t * r2, - m_int xOffset, m_int yOffset); - bool MGLAPI MGL_diffRegion(region_t * r1, const region_t * r2); - bool MGLAPI MGL_diffRegionRect(region_t * r1, const rect_t * r2); - void MGLAPI MGL_optimizeRegion(region_t * r); - void MGLAPI MGL_offsetRegion(region_t * r, m_int dx, m_int dy); - bool MGLAPI MGL_emptyRegion(const region_t * r); - bool MGLAPI MGL_equalRegion(const region_t * r1, const region_t * r2); - bool MGLAPI MGL_ptInRegionCoord(m_int x, m_int y, const region_t * r); -#endif - -/* Region traversal */ - -#ifndef MGL_LITE - typedef void (ASMAPI * rgncallback_t) (const rect_t * r); - - void MGLAPI MGL_traverseRegion(region_t * rgn, rgncallback_t doRect); -#endif - -/* RGB to 8 bit halftone dithering routines */ - -#ifndef MGL_LITE - void MGLAPI MGL_getHalfTonePalette(palette_t * pal); - uchar MGLAPI MGL_halfTonePixel(m_int x, m_int y, uchar R, uchar G, - uchar B); -#endif - -/* Resource loading/unloading */ - - font_t *MGLAPI MGL_loadFont(const char *fontname); - bool MGLAPI MGL_availableFont(const char *fontname); - void MGLAPI MGL_unloadFont(font_t * font); - cursor_t *MGLAPI MGL_loadCursor(const char *cursorName); - bool MGLAPI MGL_availableCursor(const char *cursorName); - void MGLAPI MGL_unloadCursor(cursor_t * cursor); -#ifndef MGL_LITE - icon_t *MGLAPI MGL_loadIcon(const char *iconName, bool loadPalette); - bool MGLAPI MGL_availableIcon(const char *iconName); - void MGLAPI MGL_unloadIcon(icon_t * icon); -#endif - -/* Windows BMP bitmap loading/unloading/saving */ - -#ifndef MGL_LITE - bitmap_t *MGLAPI MGL_loadBitmap(const char *bitmapName, bool loadPalette); - bool MGLAPI MGL_availableBitmap(const char *bitmapName); - void MGLAPI MGL_unloadBitmap(bitmap_t * bitmap); - bool MGLAPI MGL_getBitmapSize(const char *bitmapName, m_int * width, - m_int * height, m_int * bitsPerPixel, - pixel_format_t *pf); - bool MGLAPI MGL_loadBitmapIntoDC(MGLDC *dc, const char *bitmapName, - m_int dstLeft, m_int dstTop, - bool loadPalette); - bool MGLAPI MGL_saveBitmapFromDC(MGLDC *dc, const char *bitmapName, - m_int left, m_int top, m_int right, - m_int bottom); - bitmap_t *MGLAPI MGL_getBitmapFromDC(MGLDC *dc, m_int left, m_int top, - m_int right, m_int bottom, - bool savePalette); - bitmap_t *MGLAPI MGL_buildMonoMask(bitmap_t * bitmap, - color_t transparent); -#endif - -/* PCX bitmap loading/unloading/saving (1/4/8 bpp only) */ - -#ifndef MGL_LITE - bitmap_t *MGLAPI MGL_loadPCX(const char *bitmapName, bool loadPalette); - bool MGLAPI MGL_availablePCX(const char *bitmapName); - bool MGLAPI MGL_getPCXSize(const char *bitmapName, m_int * width, - m_int * height, m_int * bitsPerPixel); - bool MGLAPI MGL_loadPCXIntoDC(MGLDC *dc, const char *bitmapName, - m_int dstLeft, m_int dstTop, - bool loadPalette); - bool MGLAPI MGL_savePCXFromDC(MGLDC *dc, const char *bitmapName, - m_int left, m_int top, m_int right, - m_int bottom); -#endif - -/* Random number generation routines for shorts and longs with full range */ - - void ASMAPI MGL_srand(m_uint seed); - ushort ASMAPI MGL_random(ushort max); - ulong ASMAPI MGL_randoml(ulong max); - -/* Mouse support */ - - bool MGLAPI MS_available(void); - void MGLAPI MS_show(void); - void MGLAPI MS_hide(void); - void MGLAPI MS_obscure(void); - void MGLAPI MS_setCursor(cursor_t * curs); - void MGLAPI MS_setCursorColor(color_t color); - void MGLAPI MS_moveTo(m_int x, m_int y); - void MGLAPI MS_getPos(m_int * x, m_int * y); - void MGLAPI MS_drawCursor(void); - -/* Rectangle and Point manipulation */ - - rect_t MGLAPI MGL_defRect(m_int left, m_int top, m_int right, - m_int bottom); - rect_t MGLAPI MGL_defRectPt(point_t leftTop, point_t rightBottom); - bool MGLAPI MGL_sectRect(rect_t s1, rect_t s2, rect_t * d); - bool MGLAPI MGL_sectRectCoord(m_int left1, m_int top1, m_int right1, - m_int bottom1, m_int left2, m_int top2, - m_int right2, m_int bottom2, rect_t * d); - void MGLAPI MGL_unionRect(rect_t s1, rect_t s2, rect_t * d); - void MGLAPI MGL_unionRectCoord(m_int left1, m_int top1, m_int right1, - m_int bottom1, m_int left2, m_int top2, - m_int right2, m_int bottom2, rect_t * d); - -/* Built-in patterns and mouse cursor */ - -#ifndef MGL_LITE - pattern_t *MGLAPI _MGL_getEmptyPat(void); - pattern_t *MGLAPI _MGL_getGrayPat(void); - pattern_t *MGLAPI _MGL_getSolidPat(void); -#endif - cursor_t *MGLAPI _MGL_getDefCursor(void); - -/* Fixed point multiplication/divide routines */ - -#if defined(__WATCOMC__) && defined(__386__) - -/* For Watcom C++ we can use special inline assembler code that is much - * faster than calling the 386 assembler functions. Currently this is the - * the only compiler that will allow inline assembler to be expanded - * directly as inline functions. - */ - - fix32_t MGL_FixMul(fix32_t a, fix32_t b); -#pragma aux MGL_FixMul = \ - "imul edx" \ - "add eax,8000h" \ - "adc edx,0" \ - "shrd eax,edx,16" \ - parm [eax] [edx] \ - value [eax] \ - modify exact [eax edx]; - - fix32_t MGL_FixDiv(fix32_t a, fix32_t b); -#pragma aux MGL_FixDiv = \ - "xor eax,eax" \ - "shrd eax,edx,16" \ - "sar edx,16" \ - "idiv ebx" \ - parm [edx] [ebx] \ - value [eax] \ - modify exact [eax edx]; - - fix32_t MGL_FixMulDiv(fix32_t a, fix32_t b, fix32_t c); -#pragma aux MGL_FixMulDiv = \ - "imul ebx" \ - "idiv ecx" \ - parm [eax] [ebx] [ecx] \ - value [eax] \ - modify exact [eax edx]; - - m_int MGL_backfacing(fix32_t dx1, fix32_t dy1, fix32_t dx2, fix32_t dy2); -#pragma aux MGL_backfacing = \ - "imul ebx" \ - "mov ebx,eax" \ - "mov ecx,edx" \ - "mov eax,esi" \ - "imul edi" \ - "sub eax,ebx" \ - "mov eax,1" \ - "sbb edx,ecx" \ - "jns @@Backfacing" \ - "xor eax,eax" \ - "@@Backfacing:" \ - parm [eax] [esi] [edi] [ebx] \ - value [eax] \ - modify exact [eax ecx edx]; - - void MGL_memcpy(void *dst, void *src, m_int n); -#pragma aux MGL_memcpy = \ - "mov eax,ecx" \ - "shr ecx,2" \ - "rep movsd" \ - "mov cl,al" \ - "and cl,3" \ - "rep movsb" \ - parm [edi] [esi] [ecx] \ - modify exact [eax ecx esi edi]; - -#else - - fix32_t ASMAPI MGL_FixMul(fix32_t a, fix32_t b); - fix32_t ASMAPI MGL_FixDiv(fix32_t a, fix32_t b); - fix32_t ASMAPI MGL_FixMulDiv(fix32_t a, fix32_t b, fix32_t c); - m_int ASMAPI MGL_backfacing(fix32_t dx1, fix32_t dy1, fix32_t dx2, - fix32_t dy2); - void ASMAPI MGL_memcpy(void *dst, void *src, m_int n); - -#endif - -/* The following are special memcpy routines that properly handler reading - * and writing to virtual linear buffer memory by forcing the proper - * alignment. Note that the copy is extended to use a DWORD copy of speed. - */ - - void ASMAPI MGL_memcpyVIRTSRC(void *dst, void *src, m_int n); - void ASMAPI MGL_memcpyVIRTDST(void *dst, void *src, m_int n); - -/* Function to find an MGL system file's full pathname */ - - bool MGLAPI _MGL_findFile(char *validpath, const char *dir, - const char *filename, const char *mode); - -/* Override the internal MGL file I/O functions */ - - void MGLAPI MGL_setFileIO(fileio_t * fio); - -/* The following dummy symbols are used to link in driver files to be used. A - * driver is not active until it is linked in with the MGL_registerDriver - * call. Because we dont export globals in DLLs, we provide functions to - * get the address of the drivers. However for a static link library we - * need to use globals so that if the driver data is unreferenced, it will - * not be linked in with the code. - */ - -#ifndef BUILD_MGL -#if defined(MGL_DLL) && !defined(BUILD_MGLDLL) - void *MGLAPI VGA4_getDriverAddr(void); - void *MGLAPI VGAX_getDriverAddr(void); - void *MGLAPI SVGA4_getDriverAddr(void); - void *MGLAPI SVGA8_getDriverAddr(void); - void *MGLAPI SVGA16_getDriverAddr(void); - void *MGLAPI SVGA24_getDriverAddr(void); - void *MGLAPI SVGA32_getDriverAddr(void); -#if !defined(__16BIT__) - void *MGLAPI VGA8_getDriverAddr(void); - void *MGLAPI LINEAR8_getDriverAddr(void); - void *MGLAPI LINEAR16_getDriverAddr(void); - void *MGLAPI LINEAR24_getDriverAddr(void); - void *MGLAPI LINEAR32_getDriverAddr(void); - void *MGLAPI ACCEL8_getDriverAddr(void); - void *MGLAPI ACCEL16_getDriverAddr(void); - void *MGLAPI ACCEL24_getDriverAddr(void); - void *MGLAPI ACCEL32_getDriverAddr(void); -#if defined(MGLWIN) || defined(__WINDOWS__) - void *MGLAPI DDRAW8_getDriverAddr(void); - void *MGLAPI DDRAW16_getDriverAddr(void); - void *MGLAPI DDRAW24_getDriverAddr(void); - void *MGLAPI DDRAW32_getDriverAddr(void); -#endif -#endif - void *MGLAPI PACKED1_getDriverAddr(void); - void *MGLAPI PACKED4_getDriverAddr(void); - void *MGLAPI PACKED8_getDriverAddr(void); - void *MGLAPI PACKED16_getDriverAddr(void); - void *MGLAPI PACKED24_getDriverAddr(void); - void *MGLAPI PACKED32_getDriverAddr(void); -#define VGA4_driver VGA4_getDriverAddr() -#define VGAX_driver VGAX_getDriverAddr() -#define SVGA4_driver SVGA4_getDriverAddr() -#define SVGA8_driver SVGA8_getDriverAddr() -#define SVGA16_driver SVGA16_getDriverAddr() -#define SVGA24_driver SVGA24_getDriverAddr() -#define SVGA32_driver SVGA32_getDriverAddr() -#if !defined(__16BIT__) -#define VGA8_driver VGA8_getDriverAddr() -#define LINEAR8_driver LINEAR8_getDriverAddr() -#define LINEAR16_driver LINEAR16_getDriverAddr() -#define LINEAR24_driver LINEAR24_getDriverAddr() -#define LINEAR32_driver LINEAR32_getDriverAddr() -#define ACCEL8_driver ACCEL8_getDriverAddr() -#define ACCEL16_driver ACCEL16_getDriverAddr() -#define ACCEL24_driver ACCEL24_getDriverAddr() -#define ACCEL32_driver ACCEL32_getDriverAddr() -#if defined(MGLWIN) || defined(__WINDOWS__) -#define DDRAW8_driver DDRAW8_getDriverAddr() -#define DDRAW16_driver DDRAW16_getDriverAddr() -#define DDRAW24_driver DDRAW24_getDriverAddr() -#define DDRAW32_driver DDRAW32_getDriverAddr() -#endif -#endif -#define PACKED1_driver PACKED1_getDriverAddr() -#define PACKED4_driver PACKED4_getDriverAddr() -#define PACKED8_driver PACKED8_getDriverAddr() -#define PACKED16_driver PACKED16_getDriverAddr() -#define PACKED24_driver PACKED24_getDriverAddr() -#define PACKED32_driver PACKED32_getDriverAddr() -#else - extern m_int _VARAPI VGA4_driver[]; - extern m_int _VARAPI VGAX_driver[]; - extern m_int _VARAPI SVGA4_driver[]; - extern m_int _VARAPI SVGA8_driver[]; - extern m_int _VARAPI SVGA16_driver[]; - extern m_int _VARAPI SVGA24_driver[]; - extern m_int _VARAPI SVGA32_driver[]; -#if !defined(__16BIT__) - extern m_int _VARAPI VGA8_driver[]; - extern m_int _VARAPI LINEAR8_driver[]; - extern m_int _VARAPI LINEAR16_driver[]; - extern m_int _VARAPI LINEAR24_driver[]; - extern m_int _VARAPI LINEAR32_driver[]; - extern m_int _VARAPI ACCEL8_driver[]; - extern m_int _VARAPI ACCEL16_driver[]; - extern m_int _VARAPI ACCEL24_driver[]; - extern m_int _VARAPI ACCEL32_driver[]; -#if defined(MGLWIN) || defined(__WINDOWS__) - extern m_int _VARAPI DDRAW8_driver[]; - extern m_int _VARAPI DDRAW16_driver[]; - extern m_int _VARAPI DDRAW24_driver[]; - extern m_int _VARAPI DDRAW32_driver[]; -#endif -#endif - extern m_int _VARAPI PACKED1_driver[]; - extern m_int _VARAPI PACKED4_driver[]; - extern m_int _VARAPI PACKED8_driver[]; - extern m_int _VARAPI PACKED16_driver[]; - extern m_int _VARAPI PACKED24_driver[]; - extern m_int _VARAPI PACKED32_driver[]; -#endif -#endif - -/*--------------------------------------------------------------------------- - * Memory allocation and utility functions. - *-------------------------------------------------------------------------*/ - -#ifndef __16BIT__ -#define _HUGE -#else -#define _HUGE _huge -#endif - - void MGL_availableMemory(ulong * physical, ulong * total); - void MGL_useLocalMalloc(void _HUGE * (*malloc) (long size), - void (*free) (void _HUGE * p)); - void *MGLAPI MGL_malloc(long size); - void *MGLAPI MGL_calloc(long size, long n); - void MGLAPI MGL_free(void _HUGE * p); - void MGLAPI MGL_memset(void _HUGE * s, m_int c, long n); - void MGLAPI MGL_memsetw(void _HUGE * s, m_int c, long n); - void MGLAPI MGL_memsetl(void _HUGE * s, long c, long n); - -/*--------------------------------------------------------------------------- - * Set a fullscreen suspend application callback function. This is used in - * fullscreen video modes to allow switching back to the normal operating - * system graphical shell (such as Windows GDI, OS/2 PM etc). - *-------------------------------------------------------------------------*/ - - typedef m_int(ASMAPI * MGL_suspend_cb_t) (MGLDC *dc, m_int flags); - void MGLAPI MGL_setSuspendAppCallback(MGL_suspend_cb_t staveState); - -/*--------------------------------------------------------------------------- - * Tell the MGL to use a pre-loaded ACCEL.DRV driver file. This allows - * you to link with the SciTech WinDirect/Pro and WinDirect/Ultra device - * support libraries and tell the MGL to use the device support drivers. - * If the user has a real ACCEL.DRV driver file in the standard location - * on their machine, this driver file will still be used. - *-------------------------------------------------------------------------*/ - - void MGLAPI MGL_setACCELDriver(void *driver); - -/*---------------------- Inline functions as Macros -----------------------*/ - -#define MGL_equalPoint(p1,p2) ((p1).x == (p2).x && (p1).y == (p2).y) - -#define MGL_equalRect(r1,r2) ((r1).left == (r2).left && \ - (r1).top == (r2).top && \ - (r1).right == (r2).right && \ - (r1).bottom == (r2).bottom) - -#define MGL_emptyRect(r) ((r).bottom <= (r).top || \ - (r).right <= (r).left) - -#define MGL_disjointRect(r1,r2) ((r1).right <= (r2).left || \ - (r1).left >= (r2).right || \ - (r1).bottom <= (r2).top || \ - (r1).top >= (r2).bottom) - -#define MGL_sectRect(s1,s2,d) \ - ((d)->left = MAX((s1).left,(s2).left), \ - (d)->right = MIN((s1).right,(s2).right), \ - (d)->top = MAX((s1).top,(s2).top), \ - (d)->bottom = MIN((s1).bottom,(s2).bottom), \ - !MGL_emptyRect(*d)) - -#define MGL_sectRectFast(s1,s2,d) \ - (d)->left = MAX((s1).left,(s2).left); \ - (d)->right = MIN((s1).right,(s2).right); \ - (d)->top = MAX((s1).top,(s2).top); \ - (d)->bottom = MIN((s1).bottom,(s2).bottom) - -#define MGL_sectRectCoord(l1,t1,r1,b1,l2,t2,r2,b2,d) \ - ((d)->left = MAX(l1,l2), \ - (d)->right = MIN(r1,r2), \ - (d)->top = MAX(t1,t2), \ - (d)->bottom = MIN(b1,b2), \ - !MGL_emptyRect(*d)) - -#define MGL_sectRectFastCoord(l1,t1,r1,b1,l2,t2,r2,b2,d) \ - (d)->left = MAX(l1,l2); \ - (d)->right = MIN(r1,r2); \ - (d)->top = MAX(t1,t2); \ - (d)->bottom = MIN(b1,b2) - -#define MGL_unionRect(s1,s2,d) \ - (d)->left = MIN((s1).left,(s2).left); \ - (d)->right = MAX((s1).right,(s2).right); \ - (d)->top = MIN((s1).top,(s2).top); \ - (d)->bottom = MAX((s1).bottom,(s2).bottom) - -#define MGL_unionRectCoord(l1,t1,r1,b1,l2,t2,r2,b2,d) \ - (d)->left = MIN(l1,l2); \ - (d)->right = MAX(r1,r2); \ - (d)->top = MIN(t1,t2); \ - (d)->bottom = MAX(b1,b2) - -#define MGL_offsetRect(r,dx,dy) \ - { (r).left += dx; (r).right += dx; \ - (r).top += dy; (r).bottom += dy; } - -#define MGL_insetRect(r,dx,dy) \ - { (r).left += dx; (r).right -= dx; \ - (r).top += dy; (r).bottom -= dy; \ - if (MGL_emptyRect(r)) \ - (r).left = (r).right = (r).top = (r).bottom = 0; } - -#define MGL_ptInRect(p,r) ((p).x >= (r).left && \ - (p).x < (r).right && \ - (p).y >= (r).top && \ - (p).y < (r).bottom) - -#define MGL_ptInRectCoord(x,y,r) ((x) >= (r).left && \ - (x) < (r).right && \ - (y) >= (r).top && \ - (y) < (r).bottom) - -#define MGL_ptInRegion(p,r) MGL_ptInRegionCoord((p).x,(p).y,r) - -#define MGL_pixel(p) MGL_pixelCoord((p).x,(p).y) -#define MGL_getPixel(p) MGL_getPixelCoord((p).x,(p).y) -#define MGL_pixelFast(p) MGL_pixelCoordFast((p).x,(p).y) -#define MGL_getPixelFast(p) MGL_getPixelCoordFast((p).x,(p).y) -#define MGL_moveTo(p) MGL_moveToCoord((p).x,(p).y) -#define MGL_moveRel(p) MGL_moveRelCoord((p).x,(p).y) -#define MGL_line(p1,p2) MGL_lineCoord((p1).x,(p1).y,(p2).x,(p2).y) -#define MGL_lineFast(p1,p2) MGL_lineCoordFast((p1).x,(p1).y,(p2).x,(p2).y) -#define MGL_lineFX(p1,p2) MGL_lineCoordFX((p1).x,(p1).y,(p2).x,(p2).y) -#define MGL_lineFastFX(p1,p2) MGL_lineCoordFastFX((p1).x,(p1).y,(p2).x,(p2).y) -#define MGL_cLineFast(p1,p2) MGL_cLineCoordFast((p1).p.x,(p1).p.y,(p1).c,(p2).p.x,(p2).p.y,(p2).c) -#define MGL_rgbLineFast(p1,p2) MGL_rgbLineCoordFast((p1).p.x,(p1).p.y,(p1).c.r,(p1).c.g,(p1).c.b,(p2).p.x,(p2).p.y,(p2).c.r,(p2).c.g,(p2).c.b) -#define MGL_zLineFast(p1,p2) MGL_zLineCoordFast((p1).p.x,(p1).p.y,(p1).z,(p2).p.x,(p2).p.y,(p2).z) -#define MGL_czLineFast(p1,p2) MGL_czLineCoordFast((p1).p.x,(p1).p.y,(p1).z,(p1).c,(p2).p.x,(p2).p.y,(p2).z,(p2).c) -#define MGL_rgbzLineFast(p1,p2) MGL_rgbzLineCoordFast((p1).p.x,(p1).p.y,(p1).z,(p1).c.r,(p1).c.g,(p1).c.b,(p2).p.x,(p2).p.y,(p2).z,(p2).c.r,(p2).c.g,(p2).c.b) - -#define MGL_zClearPt(lt,rb,z) MGL_zClearCoord((lt).x,(lt).y, \ - (rb).x,(rb).y,z) -#define MGL_zClear(r,z) MGL_zClearCoord((r).left,(r).top, \ - (r).right,(r).bottom,z) -#define MGL_lineTo(p) MGL_lineToCoord((p).x,(p).y) -#define MGL_lineRel(p) MGL_lineRelCoord((p).x,(p).y); -#define MGL_rectPt(lt,rb) MGL_rectCoord((lt).x,(lt).y,(rb).x,(rb).y) -#define MGL_rect(r) MGL_rectCoord((r).left,(r).top, \ - (r).right,(r).bottom) -#define MGL_drawBorder(r,s,t) MGL_drawBorderCoord((r).left,(r).top, \ - (r).right,(r).bottom,(s),(t)) -#define MGL_fillRectPt(lt,rb) MGL_fillRectCoord((lt).x,(lt).y, \ - (rb).x,(rb).y) -#define MGL_fillRect(r) MGL_fillRectCoord((r).left,(r).top, \ - (r).right,(r).bottom) -#define MGL_bitBlt(d,s,r,dl,dt,op) MGL_bitBltCoord((d),(s),(r).left, \ - (r).top,(r).right,(r).bottom,dl,dt,op) -#define MGL_bitBltLin(d,s,so,r,op) MGL_bitBltLinCoord((d),(s),so, \ - (r).left,(r).top,(r).right,(r).bottom,op) -#define MGL_stretchBlt(d,s,sr,dr) MGL_stretchBltCoord((d),(s),(sr).left, \ - (sr).top,(sr).right,(sr).bottom, \ - (dr).left,(dr).top,(dr).right,(dr).bottom) -#define MGL_transBlt(d,s,r,dl,dt,c,st) MGL_transBltCoord((d),(s),(r).left, \ - (r).top,(r).right,(r).bottom,dl,dt,c,st) -#define MGL_transBltLin(d,s,so,r,c,st) MGL_transBltLinCoord((d),(s),so, \ - (r).left,(r).top,(r).right,(r).bottom,c,st) -#define MGL_getDivot(dc,r,divot) MGL_getDivotCoord(dc,(r).left,(r).top, \ - (r).right,(r).bottom,divot) -#define MGL_divotSize(dc,r) MGL_divotSizeCoord(dc,(r).left,(r).top,\ - (r).right,(r).bottom) -#define MGL_isSimpleRegion(r) (((region_t*)(r))->spans == NULL) -#define MGL_rgnLine(p1,p2,p) MGL_rgnLineCoord((p1).x,(p1).y,(p2).x,(p2).y,p) -#define MGL_rgnLineFX(p1,p2,p) MGL_rgnLineCoordFX((p1).x,(p1).y,(p2).x,(p2).y,p) -#define MGL_rgnSolidRectPt(lt,rb) MGL_rgnSolidRectCoord((lt).x,(lt).y, \ - (rb).x,(rb).y) -#define MGL_rgnSolidRect(r) MGL_rgnSolidRectCoord((r).left,(r).top, \ - (r).right,(r).bottom) - -/* Fast color packing/unpacking routines implemented as macros */ - -#define MGL_packColorFast(pf,R,G,B) \ - ((ulong)(((uchar)(R) >> (pf)->redAdjust) & (pf)->redMask) << (pf)->redPos) \ - | ((ulong)(((uchar)(G) >> (pf)->greenAdjust) & (pf)->greenMask) << (pf)->greenPos) \ - | ((ulong)(((uchar)(B) >> (pf)->blueAdjust) & (pf)->blueMask) << (pf)->bluePos) - -#define MGL_unpackColorFast(pf,c,R,G,B) \ -{ \ - (R) = (uchar)((((ulong)(c) >> (pf)->redPos) & (pf)->redMask) << (pf)->redAdjust); \ - (G) = (uchar)((((ulong)(c) >> (pf)->greenPos) & (pf)->greenMask) << (pf)->greenAdjust);\ - (B) = (uchar)((((ulong)(c) >> (pf)->bluePos) & (pf)->blueMask) << (pf)->blueAdjust); \ -} - -/* Macros to access the RGB components in a packed 24 bit RGB tuple */ - -#define MGL_rgbRed(c) (((uchar*)&(c))[2]) -#define MGL_rgbGreen(c) (((uchar*)&(c))[1]) -#define MGL_rgbBlue(c) (((uchar*)&(c))[0]) - -/* Fast 24 bit color packing/unpacking routines implemented as macros */ - -#define MGL_packColorRGBFast(R,G,B) \ - (((ulong)((uchar)(R)) << 16) | ((ulong)((uchar)(G)) << 8) | (uchar)(B)) - -#define MGL_packColorRGBFast2(c,R,G,B) \ -{ \ - MGL_rgbRed(c) = (uchar)(R); \ - MGL_rgbGreen(c) = (uchar)(G); \ - MGL_rgbBlue(c) = (uchar)(B); \ -} - -#define MGL_unpackColorRGBFast(c,R,G,B) \ -{ \ - (R) = MGL_rgbRed(c); \ - (G) = MGL_rgbGreen(c); \ - (B) = MGL_rgbBlue(c); \ -} - -#ifdef __cplusplus -} /* End of "C" linkage for C++ */ -#include "mglrect.hpp" /* Include C++ point/rectangle classes */ -#endif /* __cplusplus */ -/* Include appropriate platform specific bindings */ -#if defined(MGLWIN) || defined(__WINDOWS__) -#include "mglwin.h" -#elif defined(MGLPM) || defined(__OS2__) -/*#include "mglpm.h"*/ -#elif defined(MGLX) || defined(__UNIX__) -/*#include "mglx.h"*/ -#else -#include "mgldos.h" -#endif -#pragma pack() /* Return to default packing */ -#endif /* __MGRAPH_H */ diff --git a/scitech/lib/win32/vc/mgllt.lib b/scitech/lib/win32/vc/mgllt.lib deleted file mode 100644 index 6416e27..0000000 Binary files a/scitech/lib/win32/vc/mgllt.lib and /dev/null differ