void gr_palette_clear() { int i; HRESULT ddresult; Assert(_lpDDPalActive!=0); // Zero out Palette for (i = 0; i < 256; i++) { PalGDIData.ScratchPal[i].peRed = PalGDIData.ScratchPal[i].peBlue = PalGDIData.ScratchPal[i].peGreen = 0; PalGDIData.ScratchPal[i].peFlags = 0; } if (!hPalGDI) { ddresult = IDirectDrawPalette_SetEntries(_lpDDPalActive, 0, 0, 256, PalGDIData.ScratchPal); Assert(ddresult == DD_OK); } else { HDC hdc; hdc = GetDC(GetLibraryWindow()); SetPaletteEntries(hPalGDI, 0, PalGDIData.num, PalGDIData.ScratchPal); RealizePalette(hdc); ReleaseDC(GetLibraryWindow(), hdc); } gr_palette_faded_out = 1; if (GRMODEINFO(emul)) DDClearDisplay(); }
void gr_palette_step_up( int r, int g, int b ) { HRESULT ddresult; int i; ubyte *p; int temp; Assert(_lpDDPalActive!=0); if (gr_palette_faded_out) return; if ( (r==last_r) && (g==last_g) && (b==last_b) ) return; last_r = r; last_g = g; last_b = b; p=gr_palette; for (i=0; i<256; i++ ) { temp = (int)(*p++) + r + gr_palette_gamma; if (temp<0) temp=0; else if (temp>63) temp=63; PalGDIData.ScratchPal[i].peRed = temp << 2; temp = (int)(*p++) + g + gr_palette_gamma; if (temp<0) temp=0; else if (temp>63) temp=63; PalGDIData.ScratchPal[i].peGreen = temp << 2; temp = (int)(*p++) + b + gr_palette_gamma; if (temp<0) temp=0; else if (temp>63) temp=63; PalGDIData.ScratchPal[i].peBlue = temp << 2; PalGDIData.ScratchPal[i].peFlags = PC_NOCOLLAPSE; } if (!PalGDI) { ddresult = IDirectDrawPalette_SetEntries(_lpDDPalActive, 0, 0, 256, PalGDIData.ScratchPal); Assert(ddresult == DD_OK); } else { HDC hdc; hdc = GetDC(GetLibraryWindow()); SetPaletteEntries(hPalGDI, 0, PalGDIData.num, PalGDIData.ScratchPal); RealizePalette(hdc); ReleaseDC(GetLibraryWindow(), hdc); } }
void gr_palette_load( ubyte * pal ) { int i; ubyte c; HRESULT ddresult; Assert(_lpDDPalActive!=0); for (i=0; i<256; i++ ) { c = pal[i*3] + gr_palette_gamma; if ( c > 63 ) c = 63; PalGDIData.ScratchPal[i].peRed = c << 2; gr_current_pal[i*3] = pal[i*3]; c = pal[i*3+1] + gr_palette_gamma; if ( c > 63 ) c = 63; PalGDIData.ScratchPal[i].peGreen = c << 2; gr_current_pal[i*3+1] = pal[i*3+1]; c = pal[i*3+2] + gr_palette_gamma; if ( c > 63 ) c = 63; PalGDIData.ScratchPal[i].peBlue = c << 2; gr_current_pal[i*3+2] = pal[i*3+2]; PalGDIData.ScratchPal[i].peFlags = 0; } if (!hPalGDI) { ddresult = IDirectDrawPalette_SetEntries(_lpDDPalActive, 0, 0, 256, PalGDIData.ScratchPal); Assert(ddresult == DD_OK); } else { HDC hdc; hdc = GetDC(GetLibraryWindow()); SetPaletteEntries(hPalGDI, 0, PalGDIData.num, PalGDIData.ScratchPal); RealizePalette(hdc); ReleaseDC(GetLibraryWindow(), hdc); } gr_palette_faded_out = 0; init_computed_colors(); }
BOOL CFileExecutor::Execute(LPCTSTR pszFile, BOOL bForce) { CString strPath, strType; CWaitCursor pCursor; GetFileComponents( pszFile, strPath, strType ); if ( strType.GetLength() > 0 && _tcsistr( _T("|co|collection|"), strType ) != NULL ) { if ( CLibraryWnd* pWnd = GetLibraryWindow() ) { pWnd->OnCollection( pszFile ); return TRUE; } } if ( bForce == NULL && strType.GetLength() && _tcsistr( Settings.Library.SafeExecute, strType ) == NULL ) { CString strFormat, strPrompt; Skin.LoadString( strFormat, IDS_LIBRARY_CONFIRM_EXECUTE ); strPrompt.Format( strFormat, pszFile ); int nResult = AfxMessageBox( strPrompt, MB_ICONQUESTION|MB_YESNOCANCEL|MB_DEFBUTTON2 ); if ( nResult == IDCANCEL ) return FALSE; else if ( nResult == IDNO ) return TRUE; } BOOL bShiftKey = ( GetAsyncKeyState( VK_SHIFT ) & 0x8000 ) != 0; if ( Settings.MediaPlayer.EnablePlay && strType.GetLength() && ! bShiftKey ) { if ( _tcsistr( Settings.MediaPlayer.FileTypes, strType ) != NULL ) { BOOL bAudio = _tcsistr( _T("|ape|mid|mp3|ogg|wav|wma|"), strType ) != NULL; if ( CMediaWnd* pWnd = GetMediaWindow( ! bAudio ) ) { pWnd->PlayFile( pszFile ); return TRUE; } } } if ( ! bShiftKey ) if ( Plugins.OnExecuteFile( pszFile ) ) return TRUE; ShellExecute( AfxGetMainWnd()->GetSafeHwnd(), NULL, pszFile, NULL, strPath, SW_SHOWNORMAL ); return TRUE; }
void grwin_set_palette_exclusive(int yes) { if (yes) { PalGDI = FALSE; if (hPalGDI) DeleteObject(hPalGDI); hPalGDI = 0; } else { HDC hdc; ClearSystemPalette(); PalGDI = TRUE; PalGDIData.ver = 0x300; PalGDIData.num = 256; hPalGDI = CreatePalette((PLOGPALETTE)&PalGDIData); hdc = GetDC(GetLibraryWindow()); SelectPalette(hdc, hPalGDI, FALSE); ReleaseDC(GetLibraryWindow(), hdc); } }
int xtapi_init(char *appname, int *numdevs) { LONG retval; BOOL reinit; if (TapiObj.hObj) return XTAPI_SUCCESS; TapiObj.hWnd = GetLibraryWindow(); reinit = TRUE; // Allow for reinitialization while (1) { retval = lineInitialize(&TapiObj.hObj, GetWindowInstance(TapiObj.hWnd), tapi_callback, appname, &TapiObj.num_devs); if (!retval) { break; } else if (retval == LINEERR_REINIT) { if (reinit) { timer_delay(0x50000); // delay 5 seconds reinit = FALSE; } else { return XTAPI_APPCONFLICT; // another app is using tapi resources we need } } else if (retval == LINEERR_NODEVICE) { return XTAPI_NODEVICES; // should tell user to install a modem } else return XTAPI_GENERAL_ERR; } *numdevs = (int)TapiObj.num_devs; TapiDev.valid = FALSE; return XTAPI_SUCCESS; }
BOOL DDInit(int mode) { LPDIRECTDRAW lpdd; DDCAPS ddcaps, ddcaps2; HRESULT ddresult; int num; DDWnd = GetLibraryWindow(); // Create Direct Draw Object (Use Emulation if Hardware is off) if (!_lpDD) { ddresult = DirectDrawCreate(NULL, &lpdd, NULL); if (ddresult == DDERR_NODIRECTDRAWHW) { ddresult = DirectDrawCreate( (LPVOID) DDCREATE_EMULATIONONLY, &lpdd, NULL ); if (!CheckDDResult(ddresult, "InitDD:DirectDrawCreate emulation")) return FALSE; DDUseEmulation = TRUE; logentry("DirectDraw: forcing emulation.\n"); } else if (ddresult != DD_OK) return FALSE; logentry("DirectDraw: DirectX API hardware compliant.\n"); } else return FALSE; atexit(DDKill); // Determine hardware caps // Determine capture mode (fullscreen takes exclusive, window is normal) if (mode == DDGR_FULLSCREEN) { DWORD flags; flags = DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN; #ifndef NDEBUG if (!FindArg("-nomodex")) flags |= DDSCL_ALLOWMODEX; #else flags |= DDSCL_ALLOWMODEX; #endif if (!FindArg("-disallowreboot")) flags |= DDSCL_ALLOWREBOOT; ddresult = IDirectDraw_SetCooperativeLevel(lpdd, DDWnd, flags); if (!CheckDDResult(ddresult, "DDInit::SetCooperativeLevel")) { IDirectDraw_Release(lpdd); return FALSE; } _DDExclusive = TRUE; _DDFullScreen = TRUE; } else if (mode == DDGR_EXWINDOW) { ddresult = IDirectDraw_SetCooperativeLevel(lpdd, DDWnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); if (!CheckDDResult(ddresult, "DDInit::SetCooperativeLevel")) return FALSE; _DDExclusive = TRUE; _DDFullScreen = FALSE; } else if (mode == DDGR_WINDOW) { ddresult = IDirectDraw_SetCooperativeLevel(lpdd, DDWnd, DDSCL_NORMAL); if (!CheckDDResult(ddresult, "DDInit::SetCooperativeLevel")) return FALSE; _DDExclusive = FALSE; _DDFullScreen = FALSE; } else return FALSE; // Get Display modes/Window Sizes // Force invalidation of all modes for now for (num = 0; num < 16; num++) { _DDModeList[num].rw = _DDModeList[num].w = -1; _DDModeList[num].rh = _DDModeList[num].h = -1; } W95DisplayMode = SM95_640x480x8; num = 0; if (mode == DDGR_FULLSCREEN) { ddresult = IDirectDraw_EnumDisplayModes(lpdd, 0, NULL, 0, EnumDispModesCB); if(!CheckDDResult(ddresult, "DDInit::EnumDisplayModes")) { IDirectDraw_Release(lpdd); return FALSE; } } else if (mode == DDGR_EXWINDOW) { _DDModeList[SM95_320x200x8X].rw = 320; _DDModeList[SM95_320x200x8X].rh = 200; _DDModeList[SM95_320x200x8X].w = 640; _DDModeList[SM95_320x200x8X].h = 480; _DDModeList[SM95_320x200x8X].emul = 1; _DDModeList[SM95_320x200x8X].dbuf = 0; _DDModeList[SM95_320x200x8X].modex = 0; _DDModeList[SM95_320x200x8X].paged = 0; _DDModeList[SM95_640x480x8].rw = 640; _DDModeList[SM95_640x480x8].rh = 480; _DDModeList[SM95_640x480x8].w = 640; _DDModeList[SM95_640x480x8].h = 480; _DDModeList[SM95_640x480x8].emul = 1; _DDModeList[SM95_640x480x8].dbuf = 0; _DDModeList[SM95_640x480x8].modex = 0; _DDModeList[SM95_640x480x8].paged = 0; _DDModeList[SM95_800x600x8].rw = 800; _DDModeList[SM95_800x600x8].rh = 600; _DDModeList[SM95_800x600x8].w = 640; _DDModeList[SM95_800x600x8].h = 480; _DDModeList[SM95_800x600x8].emul = 1; _DDModeList[SM95_800x600x8].dbuf = 0; _DDModeList[SM95_800x600x8].modex = 0; _DDModeList[SM95_800x600x8].paged = 0; _DDNumModes = 3; } else if (mode == DDGR_WINDOW) { _DDModeList[SM95_320x200x8X].rw = 320; _DDModeList[SM95_320x200x8X].rh = 200; _DDModeList[SM95_320x200x8X].w = 640; _DDModeList[SM95_320x200x8X].h = 480; _DDModeList[SM95_320x200x8X].emul = 1; _DDModeList[SM95_320x200x8X].dbuf = 0; _DDModeList[SM95_320x200x8X].modex = 0; _DDModeList[SM95_320x200x8X].paged = 0; _DDModeList[SM95_640x480x8].rw = 640; _DDModeList[SM95_640x480x8].rh = 480; _DDModeList[SM95_640x480x8].w = 640; _DDModeList[SM95_640x480x8].h = 480; _DDModeList[SM95_640x480x8].emul = 1; _DDModeList[SM95_640x480x8].dbuf = 0; _DDModeList[SM95_640x480x8].modex = 0; _DDModeList[SM95_640x480x8].paged = 0; _DDModeList[SM95_800x600x8].rw = 800; _DDModeList[SM95_800x600x8].rh = 600; _DDModeList[SM95_800x600x8].w = 800; _DDModeList[SM95_800x600x8].h = 600; _DDModeList[SM95_800x600x8].emul = 1; _DDModeList[SM95_800x600x8].dbuf = 0; _DDModeList[SM95_800x600x8].modex = 0; _DDModeList[SM95_800x600x8].paged = 0; _DDNumModes = 3; } else return FALSE; // Set appropriate display mode or window mode _lpDD = lpdd; memset(&ddcaps, 0, sizeof(ddcaps)); ddcaps.dwSize = sizeof(ddcaps); ddcaps2.dwSize = sizeof(ddcaps); ddresult = IDirectDraw_GetCaps(_lpDD, &ddcaps, NULL); if (!CheckDDResult(ddresult, "InitDD::GetCaps")) return FALSE; logentry("DirectDraw: VRAM free: %d\n", ddcaps.dwVidMemFree); logentry("DirectDraw: VRAM total: %d\n", ddcaps.dwVidMemTotal); #ifndef NDEBUG if (FindArg("-TsengDebug1")) { IDirectDraw_Release(lpdd); return FALSE; } #endif DDSetDisplayMode(W95DisplayMode, 0); #ifndef NDEBUG if (FindArg("-TsengDebug2")) { IDirectDraw_Release(lpdd); return FALSE; } #endif // If 'windowed' do this. if (!_DDFullScreen) { ddresult = IDirectDraw_CreateClipper(_lpDD, 0, &_lpDDClipper, NULL); if (!CheckDDResult(ddresult, "DDCreateScreen::CreateClipper")) return FALSE; ddresult = IDirectDrawClipper_SetHWnd(_lpDDClipper, 0, DDWnd); if (!CheckDDResult(ddresult, "DDCreateScreen::SetHWnd")) return FALSE; ddresult = IDirectDrawSurface_SetClipper(_lpDDSPrimary, _lpDDClipper); if (!CheckDDResult(ddresult, "DDCreateScreen::SetClipper")) return FALSE; } // Register Optimizations ddcaps.dwSize = sizeof(ddcaps); ddcaps2.dwSize = sizeof(ddcaps); ddresult = IDirectDraw_GetCaps(lpdd, &ddcaps, &ddcaps2); if (!CheckDDResult(ddresult, "DDInit::GetCaps")) return FALSE; #ifndef NDEBUG if (FindArg("-TsengDebug3")) { IDirectDraw_Release(lpdd); return FALSE; } #endif if (FindArg("-vidram")) { logentry("DirectDraw: Forcing VRAM rendering.\n"); _DDSysMemSurfacing = FALSE; } else if (FindArg("-sysram")) { logentry("DirectDraw: Forcing SRAM rendering.\n"); _DDSysMemSurfacing = TRUE; } else if (ddcaps.dwCaps & DDCAPS_BANKSWITCHED) { logentry("DirectDraw: Hardware is bank-switched. Using SRAM rendering.\n"); _DDSysMemSurfacing = TRUE; } else { logentry("DirectDraw: Hardware is not bank-switched. Using VRAM rendering.\n"); _DDSysMemSurfacing = FALSE; } if (ddcaps.dwCaps & DDCAPS_COLORKEYHWASSIST) ddDriverCaps.hwcolorkey = 1; else ddDriverCaps.hwcolorkey = 0; if (ddcaps.dwCaps & DDCAPS_BLTSTRETCH) ddDriverCaps.hwbltstretch = 1; else ddDriverCaps.hwbltstretch = 0; //@@ mprintf((0, "DD::Hardware=")); //@@ if (ddcaps.dwCaps & DDCAPS_NOHARDWARE) mprintf((0, "Off\n")); //@@ else mprintf((0, "On\n")); //@@ //@@ mprintf((0, "DD::VideoMem=%u bytes\n", ddcaps.dwVidMemTotal)); //@@ mprintf((0, "DD::SrcColorKey=")); //@@ if (ddcaps.dwCKeyCaps & DDCKEYCAPS_SRCBLT) mprintf((0, "Hardware\n")); //@@ else mprintf((0, "Emulation\n")); return TRUE; }
int joy95_init_stick(int joy, int spjoy) { UINT joyid; MMRESULT mmresult; char joyname[256]; if (!joy_installed) return 0; switch (SpecialDevice) { case TACTILE_CYBERNET: //@@ joystick.present_mask = JOY_1_X_AXIS | JOY_1_Y_AXIS | JOY_1_Z_AXIS | JOY_1_POV; //@@ joystick.has_pov = 1; break; case TACTILE_IMMERSION: mprintf((0, "Joystick name= I-Force compatible device.\n")); break; } // if (spjoy) return 1; joystick.joyid = 0; if (joy == 1) joystick.joyid = joyid = JOYSTICKID1; else return 0; mmresult = joyGetDevCaps(joyid, &WinJoyCaps, sizeof(WinJoyCaps)); if (mmresult != JOYERR_NOERROR) { mprintf((1, "Attempt to get Joystick %d caps failed.\n", joy)); return 0; } mprintf ((0,"Joystick name=%s\n",WinJoyCaps.szPname)); // Tell our Window App. about this joystick. joySetThreshold(joyid, WinJoyCaps.wXmax/256); mmresult = joySetCapture(GetLibraryWindow(), joyid, JOY_POLL_RATE, FALSE); if (mmresult != JOYERR_NOERROR) { mprintf((1, "Unable to capture joystick %d. Error=%d\n", joy,mmresult)); return 0; } // Get raw axis' min and max. joystick.threshold = WinJoyCaps.wXmax/256; joystick.max_timer = WinJoyCaps.wPeriodMax; joystick.threshold = WinJoyCaps.wXmax/256; joystick.max_timer = WinJoyCaps.wPeriodMax; joystick.axis_min[0] = WinJoyCaps.wXmin; joystick.axis_min[1] = WinJoyCaps.wYmin; joystick.axis_min[2] = WinJoyCaps.wZmin; joystick.axis_min[4] = WinJoyCaps.wRmin; joystick.axis_min[5] = WinJoyCaps.wUmin; joystick.axis_min[6] = WinJoyCaps.wVmin; joystick.axis_max[0] = WinJoyCaps.wXmax; joystick.axis_max[1] = WinJoyCaps.wYmax; joystick.axis_max[2] = WinJoyCaps.wZmax; joystick.axis_max[4] = WinJoyCaps.wRmax; joystick.axis_max[5] = WinJoyCaps.wUmax; joystick.axis_max[6] = WinJoyCaps.wVmax; joystick.axis_center[0] = (WinJoyCaps.wXmax-WinJoyCaps.wXmin)/2; joystick.axis_center[1] = (WinJoyCaps.wYmax-WinJoyCaps.wYmin)/2; joystick.axis_center[2] = (WinJoyCaps.wZmax-WinJoyCaps.wZmin)/2; joystick.axis_center[4] = (WinJoyCaps.wRmax-WinJoyCaps.wRmin)/2; joystick.axis_center[5] = (WinJoyCaps.wUmax-WinJoyCaps.wUmin)/2; joystick.axis_center[6] = (WinJoyCaps.wVmax-WinJoyCaps.wVmin)/2; joystick.present_mask = JOY_1_X_AXIS | JOY_1_Y_AXIS; if (WinJoyCaps.wCaps & JOYCAPS_HASPOV) { joystick.has_pov = 1; joystick.present_mask |= JOY_1_POV; } else joystick.has_pov = 0; if (WinJoyCaps.wCaps & JOYCAPS_HASZ) joystick.present_mask |= JOY_1_Z_AXIS; if (WinJoyCaps.wCaps & JOYCAPS_HASR) joystick.present_mask |= JOY_1_R_AXIS; if (WinJoyCaps.wCaps & JOYCAPS_HASU) joystick.present_mask |= JOY_1_U_AXIS; if (WinJoyCaps.wCaps & JOYCAPS_HASV) joystick.present_mask |= JOY_1_V_AXIS; joy95_get_name(JOYSTICKID1, joyname, 255); if (!strcmpi(joyname, "CH Flightstick Pro") || FindArg("-ordinaljoy")) { CHStickHack = 1; } else CHStickHack = 0; return 1; }
int gr_palette_fade_in(ubyte *pal, int nsteps, int allow_keys) { HRESULT ddresult; int i,j; ubyte c; fix fade_palette[768]; fix fade_palette_delta[768]; allow_keys = allow_keys; Assert(_lpDDPalActive!=0); if (!gr_palette_faded_out) return 0; #ifndef NDEBUG if (grd_fades_disabled) { gr_palette_load(pal); return 0; } #endif for (i=0; i<768; i++ ) { gr_current_pal[i] = pal[i]; fade_palette[i] = 0; fade_palette_delta[i] = i2f(pal[i]+gr_palette_gamma) / nsteps; } for (j=0; j<nsteps; j++ ) { for (i=0; i<256; i++ ) { fade_palette[i*3] += fade_palette_delta[i*3]; fade_palette[i*3+1] += fade_palette_delta[i*3+1]; fade_palette[i*3+2] += fade_palette_delta[i*3+2]; if (fade_palette[i*3] > i2f(pal[i*3]+gr_palette_gamma) ) fade_palette[i*3] = i2f(pal[i*3]+gr_palette_gamma); if (fade_palette[i*3+1] > i2f(pal[i*3+1]+gr_palette_gamma) ) fade_palette[i*3+1] = i2f(pal[i*3+1]+gr_palette_gamma); if (fade_palette[i*3+2] > i2f(pal[i*3+2]+gr_palette_gamma) ) fade_palette[i*3+2] = i2f(pal[i*3+2]+gr_palette_gamma); c = f2i(fade_palette[i*3]); if ( c > 63 ) c = 63; PalGDIData.ScratchPal[i].peRed = c << 2; c = f2i(fade_palette[i*3+1]); if ( c > 63 ) c = 63; PalGDIData.ScratchPal[i].peGreen = c << 2; c = f2i(fade_palette[i*3+2]); if ( c > 63 ) c = 63; PalGDIData.ScratchPal[i].peBlue = c << 2; PalGDIData.ScratchPal[i].peFlags = 0; } if (!hPalGDI) { IDirectDraw_WaitForVerticalBlank(lpDD, DDWAITVB_BLOCKBEGIN, NULL); ddresult = IDirectDrawPalette_SetEntries(_lpDDPalActive, 0, 0, 256, PalGDIData.ScratchPal); Assert (ddresult == DD_OK); } else { HDC hdc; hdc = GetDC(GetLibraryWindow()); SetPaletteEntries(hPalGDI, 0, PalGDIData.num, PalGDIData.ScratchPal); RealizePalette(hdc); ReleaseDC(GetLibraryWindow(), hdc); } } gr_palette_faded_out = 0; return 0; }