예제 #1
0
int VidSScaleImage(RECT* pRect)
{
	int nScrnWidth, nScrnHeight;

	int nGameAspectX = 4, nGameAspectY = 3;
	int nWidth = pRect->right - pRect->left;
	int nHeight = pRect->bottom - pRect->top;

	if (bVidFullStretch) { // Arbitrary stretch
		return 0;
	}

	if (bDrvOkay) {
		if ((BurnDrvGetFlags() & (BDF_ORIENTATION_VERTICAL | BDF_ORIENTATION_FLIPPED))) {
			BurnDrvGetAspect(&nGameAspectY, &nGameAspectX);
		} else {
			BurnDrvGetAspect(&nGameAspectX, &nGameAspectY);
		}
	}

	nScrnWidth = nGameAspectX;
	nScrnHeight = nGameAspectY;

	int nWidthScratch = nHeight * nVidScrnAspectY * nGameAspectX * nScrnWidth /
			    (nScrnHeight * nVidScrnAspectX * nGameAspectY);

	if (nWidthScratch > nWidth) {	// The image is too wide
		if (nGamesWidth < nGamesHeight) { // Vertical games
			nHeight = nWidth * nVidScrnAspectY * nGameAspectY * nScrnWidth /
				  (nScrnHeight * nVidScrnAspectX * nGameAspectX);
		} else {		// Horizontal games
			nHeight = nWidth * nVidScrnAspectX * nGameAspectY * nScrnHeight /
				  (nScrnWidth * nVidScrnAspectY * nGameAspectX);
		}
	} else {
		nWidth = nWidthScratch;
	}

	pRect->left = (pRect->right + pRect->left) / 2;
	pRect->left -= nWidth / 2;
	pRect->right = pRect->left + nWidth;

	pRect->top = (pRect->top + pRect->bottom) / 2;
	pRect->top -= nHeight / 2;
	pRect->bottom = pRect->top + nHeight;

	return 0;
}
예제 #2
0
int scrnSize()
{
    if (!hScrnWnd || nVidFullscreen || bFakeFullscreen) {
        return 1;
    }

    int nBmapWidth = nVidImageWidth, nBmapHeight = nVidImageHeight;
    int nGameAspectX = 4, nGameAspectY = 3;

    // adjust the screen size for skin, added by regret
    if (!bDrvOkay) {
        if (nBmapWidth > DEFAULT_IMAGE_WIDTH) {
            nBmapWidth = DEFAULT_IMAGE_WIDTH;
        }
        if (nBmapHeight > DEFAULT_IMAGE_HEIGHT) {
            nBmapHeight = DEFAULT_IMAGE_HEIGHT;
        }
    }

    if (bDrvOkay) {
        if ((BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL) && (nVidRotationAdjust & 1)) {
            BurnDrvGetVisibleSize(&nBmapHeight, &nBmapWidth);
            BurnDrvGetAspect(&nGameAspectY, &nGameAspectX);
        } else {
            BurnDrvGetVisibleSize(&nBmapWidth, &nBmapHeight);
            BurnDrvGetAspect(&nGameAspectX, &nGameAspectY);
        }

        if (nBmapWidth <= 0 || nBmapHeight <= 0) {
            return 1;
        }
    }

    nDragX = GetSystemMetrics(SM_CXDRAG) / 2;
    nDragY = GetSystemMetrics(SM_CYDRAG) / 2;

    // Find the size of the visible WorkArea
    SystemParametersInfo(SPI_GETWORKAREA, 0, &SystemWorkArea, 0);

    int nScrnWidth = SystemWorkArea.right - SystemWorkArea.left;
    int nScrnHeight = SystemWorkArea.bottom - SystemWorkArea.top;

    int nMaxSize = nWindowSize;

    if (nMaxSize <= 0) {
        // auto size
        if (nBmapWidth < nBmapHeight) {
            if (nScrnHeight <= 600) {
                nMaxSize = 1;
            }
            else if (nScrnHeight <= 960) {
                nMaxSize = 2;
            }
            else if (nScrnHeight <= 1280) {
                nMaxSize = 3;
            }
            else {
                nMaxSize = 4;
            }
        } else {
            if (nScrnWidth <= 640) {
                nMaxSize = 1;
            }
            else if (nScrnWidth <= 1152) {
                nMaxSize = 2;
            }
            else if (nScrnWidth <= 1600) {
                nMaxSize = 3;
            }
            else {
                nMaxSize = 4;
            }
        }
    }

    // Find the width and height
    int w = nScrnWidth;
    int h = nScrnHeight;

    // Find out how much space is taken up by the borders
    int ew = getScrnExtraWidth();
    int eh = getScrnExtraHeight();

    if (bMenuEnabled) {
        // Subtract the border space
        w -= ew;
        h -= eh;
    }

    if (bVidCorrectAspect || bVidFullStretch) {
        int ww = w;
        int hh = h;

        do {
            if (nBmapWidth < nBmapHeight) {
                if (ww > nBmapWidth * nMaxSize) {
                    ww = nBmapWidth * nMaxSize;
                }
                if (hh > ww * vidScrnAspect * nGameAspectY * nScrnHeight / (nScrnWidth * nGameAspectX)) {
                    hh = ww * vidScrnAspect * nGameAspectY * nScrnHeight / (nScrnWidth * nGameAspectX);
                }
            } else {
                if (hh > nBmapHeight * nMaxSize) {
                    hh = nBmapHeight * nMaxSize;
                }
                if (ww > hh * nGameAspectX * nScrnWidth / (nScrnHeight * vidScrnAspect * nGameAspectY)) {
                    ww = hh * nGameAspectX * nScrnWidth / (nScrnHeight * vidScrnAspect * nGameAspectY);
                }
            }
        } while ((ww > w || hh > h) && nMaxSize-- > 1);
        w =	ww;
        h = hh;
    } else {
        while ((nBmapWidth * nMaxSize > w || nBmapHeight * nMaxSize > h) && nMaxSize > 1) {
            nMaxSize--;
        }

        if (w > nBmapWidth * nMaxSize || h > nBmapHeight * nMaxSize) {
            w = nBmapWidth * nMaxSize;
            h = nBmapHeight * nMaxSize;
        }
    }

    RECT rect = { 0, 0, w, h };
    VidScale(&rect, nBmapWidth, nBmapHeight);
    w = rect.right - rect.left + ew;
    h = rect.bottom - rect.top + eh;

    int x = nWindowPosX;
    int y = nWindowPosY;
    if (x + w > SystemWorkArea.right || y + h > SystemWorkArea.bottom) {
        // Find the midpoint for the window
        x = SystemWorkArea.left + SystemWorkArea.right;
        x /= 2;
        y = SystemWorkArea.bottom + SystemWorkArea.top;
        y /= 2;

        x -= w / 2;
        y -= h / 2;
    }

    bMaximised = false;

    MoveWindow(hScrnWnd, x, y, w, h, TRUE);
//	SetWindowPos(hScrnWnd, NULL, x, y, w, h, SWP_NOREDRAW | SWP_NOACTIVATE | SWP_NOSENDCHANGING | SWP_NOZORDER);
    if (bDrvOkay && bShowOnTop) {
        SetWindowPos(hScrnWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW | SWP_NOMOVE);
    }

    nWindowPosX = x;
    nWindowPosY = y;

    return 0;
}
예제 #3
0
파일: main.cpp 프로젝트: carstene1ns/fbagx
int ProcessCmdLine()
{
	unsigned int i;
	int nOptX = 0, nOptY = 0, nOptD = 0;
	int nOpt1Size;
	TCHAR szOpt2[3] = _T("");
	TCHAR szName[MAX_PATH];

	if (szCmdLine[0] == _T('\"')) {
		int nLen = _tcslen(szCmdLine);
		nOpt1Size = 1;
		while (szCmdLine[nOpt1Size] != _T('\"') && nOpt1Size < nLen) {
			nOpt1Size++;
		}
		if (nOpt1Size == nLen) {
			szName[0] = 0;
		} else {
			nOpt1Size++;
			_tcsncpy(szName, szCmdLine + 1, nOpt1Size - 2);
			szName[nOpt1Size - 2] = 0;
		}
	} else {
		int nLen = _tcslen(szCmdLine);
		nOpt1Size = 0;
		while (szCmdLine[nOpt1Size] != _T(' ') && nOpt1Size < nLen) {
			nOpt1Size++;
		}
		_tcsncpy(szName, szCmdLine, nOpt1Size);
		szName[nOpt1Size] = 0;
	}

	if (_tcslen(szName)) {
		if (_tcscmp(szName, _T("-listinfo")) == 0) {
			write_datfile(0, 0, stdout);
			return 1;
		}
		
		if (_tcscmp(szName, _T("-listinfowithmd")) == 0) {
			write_datfile(0, 1, stdout);
			return 1;
		}
		
		if (_tcscmp(szName, _T("-listinfomdonly")) == 0) {
			write_datfile(0, 2, stdout);
			return 1;
		}
		
		if (_tcscmp(szName, _T("-listextrainfo")) == 0) {
			int nWidth;
			int nHeight;
			int nAspectX;
			int nAspectY;
			for (i = 0; i < nBurnDrvCount; i++) {
				nBurnDrvSelect = i;
				BurnDrvGetVisibleSize(&nWidth, &nHeight);
				BurnDrvGetAspect(&nAspectX, &nAspectY);
				printf("%s\t%ix%i\t%i:%i\t0x%08X\t\"%s\"\t%i\t%i\t%x\t%x\t\"%s\"\n", BurnDrvGetTextA(DRV_NAME), nWidth, nHeight, nAspectX, nAspectY, BurnDrvGetHardwareCode(), BurnDrvGetTextA(DRV_SYSTEM), BurnDrvIsWorking(), BurnDrvGetMaxPlayers(), BurnDrvGetGenreFlags(), BurnDrvGetFamilyFlags(), BurnDrvGetTextA(DRV_COMMENT));
			}			
			return 1;
		}
	}

	_stscanf(&szCmdLine[nOpt1Size], _T("%2s %i x %i x %i"), szOpt2, &nOptX, &nOptY, &nOptD);

	if (_tcslen(szName)) {
		bool bFullscreen = 1;
		bCmdOptUsed = 1;

		if (_tcscmp(szOpt2, _T("-r")) == 0) {
			if (nOptX && nOptY) {
				nVidWidth = nOptX;
				nVidHeight = nOptY;
			}
			if (nOptD) {
				nVidDepth = nOptD;
			}
		} else {
			if (_tcscmp(szOpt2, _T("-a")) == 0) {
				bVidArcaderes = 1;
			} else {
				if (_tcscmp(szOpt2, _T("-w")) == 0) {
					bCmdOptUsed = 0;
					bFullscreen = 0;
				}
			}
		}

		if (bFullscreen) {
			nVidFullscreen = 1;
		}

		if (_tcscmp(&szName[_tcslen(szName) - 3], _T(".fs")) == 0) {
			if (BurnStateLoad(szName, 1, &DrvInitCallback)) {
				return 1;
			} else {
//				bRunPause = 1;
			}
		} else {
			if (_tcscmp(&szName[_tcslen(szName) - 3], _T(".fr")) == 0) {
				if (StartReplay(szName)) {
					return 1;
				}
			} else {
				for (i = 0; i < nBurnDrvCount; i++) {
					nBurnDrvSelect = i;
					if (_tcscmp(BurnDrvGetText(DRV_NAME), szName) == 0) {
						MediaInit();
						DrvInit(i, true);
						break;
					}
				}
				if (i == nBurnDrvCount) {
					FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_UI_NOSUPPORT), szName, _T(APP_TITLE));
					FBAPopupDisplay(PUF_TYPE_ERROR);
					return 1;
				}
			}
		}
	}

	POST_INITIALISE_MESSAGE;

	if (!nVidFullscreen) {
		MenuEnableItems();
	}

	return 0;
}