more sdl fixes (dmitry_smagin)
This commit is contained in:
parent
673161750d
commit
e90ea1c4ae
|
@ -207,8 +207,9 @@ drvobj += \
|
|||
\
|
||||
d_sg1000.o
|
||||
|
||||
depobj := bzip.o config.o drv.o inpdipsw.o main.o run.o stated.o stringset.o \
|
||||
ips_manager.o support_paths.o scrn.o \
|
||||
depobj += \
|
||||
bzip.o config.o drv.o inpdipsw.o main.o media.o run.o stated.o \
|
||||
stringset.o ips_manager.o support_paths.o scrn.o \
|
||||
\
|
||||
ioapi.o unzip.o conc.o cong.o dat.o gamc.o gami.o image.o \
|
||||
misc.o sshot.o state.o statec.o zipfn.o \
|
||||
|
|
|
@ -46,6 +46,10 @@ int AppError(TCHAR* szText, int bWarning);
|
|||
extern int RunMessageLoop();
|
||||
extern int RunReset();
|
||||
|
||||
// media.cpp
|
||||
int MediaInit();
|
||||
int MediaExit();
|
||||
|
||||
//inpdipsw.cpp
|
||||
void InpDIPSWResetDIPs();
|
||||
|
||||
|
|
|
@ -132,16 +132,19 @@ static int FindRom(int i)
|
|||
static int RomDescribe(StringSet* pss, struct BurnRomInfo* pri)
|
||||
{
|
||||
pss->Add(_T("The "));
|
||||
if (pri->nType & 0x10) {
|
||||
if (pri->nType & BRF_ESS) {
|
||||
pss->Add(_T("essential "));
|
||||
}
|
||||
if (pri->nType & 0x80) {
|
||||
if (pri->nType & BRF_BIOS) {
|
||||
pss->Add(_T("BIOS "));
|
||||
}
|
||||
if (pri->nType & 0x01) {
|
||||
if (pri->nType & BRF_PRG) {
|
||||
pss->Add(_T("program "));
|
||||
}
|
||||
if (pri->nType & BRF_GRA) {
|
||||
pss->Add(_T("graphics "));
|
||||
}
|
||||
if (pri->nType & 0x02) {
|
||||
if (pri->nType & BRF_SND) {
|
||||
pss->Add(_T("sound "));
|
||||
}
|
||||
pss->Add(_T("ROM "));
|
||||
|
@ -160,7 +163,7 @@ static int CheckRomsBoot()
|
|||
nState = RomFind[i].nState; // Get the state of the rom in the zip file
|
||||
|
||||
if (nState != 1 && ri.nType && ri.nCrc) {
|
||||
if (ri.nType & 0x80) {
|
||||
if (!(ri.nType & BRF_OPT) && !(ri.nType & BRF_NODUMP)) {
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
|
@ -196,8 +199,9 @@ static int CheckRoms()
|
|||
|
||||
memset(&ri, 0, sizeof(ri));
|
||||
BurnDrvGetRomInfo(&ri, i); // Find information about the wanted rom
|
||||
if (ri.nCrc && (ri.nType & 0x80) == 0) {
|
||||
if (ri.nCrc && (ri.nType & BRF_OPT) == 0 && (ri.nType & BRF_NODUMP)) {
|
||||
int nState = RomFind[i].nState; // Get the state of the rom in the zip file
|
||||
int nError = GetBZipError(nState);
|
||||
|
||||
if (nState == 0 && ri.nType) { // (A type of 0 means empty slot - no rom)
|
||||
char* szName = "Unknown";
|
||||
|
@ -206,20 +210,27 @@ static int CheckRoms()
|
|||
BzipDetail.Add(_T("%hs was not found.\n"), szName);
|
||||
}
|
||||
|
||||
if (ri.nType & 0x90) { // essential rom - without it the game may not run at all
|
||||
nBzipError |= GetBZipError(nState) << 0;
|
||||
if (nError == 0) {
|
||||
nBzipError |= 0x2000;
|
||||
}
|
||||
if (ri.nType & 0x01) { // rom which contains graphics information
|
||||
nBzipError |= GetBZipError(nState) << 1;
|
||||
|
||||
if (ri.nType & BRF_ESS) { // essential rom - without it the game may not run at all
|
||||
nBzipError |= nError << 0;
|
||||
}
|
||||
if (ri.nType & 0x02) { // rom which contains sound information
|
||||
nBzipError |= GetBZipError(nState) << 2;
|
||||
if (ri.nType & BRF_PRG) { // rom which contains program information
|
||||
nBzipError |= nError << 1;
|
||||
}
|
||||
if (ri.nType & BRF_GRA) { // rom which contains graphics information
|
||||
nBzipError |= nError << 2;
|
||||
}
|
||||
if (ri.nType & BRF_SND) { // rom which contains sound information
|
||||
nBzipError |= nError << 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!nZipsFound) {
|
||||
nBzipError |= 0x08; // No data at all!
|
||||
if (nBzipError & 0x0F0F) {
|
||||
nBzipError |= 0x4000;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -250,17 +261,17 @@ static int __cdecl BzipBurnLoadRom(unsigned char* Dest, int* pnWrote, int i)
|
|||
pszRomName = "unknown";
|
||||
}
|
||||
_stprintf(szText, _T("Loading"));
|
||||
if (ri.nType & 0x83) {
|
||||
if (ri.nType & 0x80) {
|
||||
if (ri.nType & (BRF_PRG | BRF_GRA | BRF_SND | BRF_BIOS)) {
|
||||
if (ri.nType & BRF_BIOS) {
|
||||
_stprintf (szText + _tcslen(szText), _T(" %s"), _T("BIOS "));
|
||||
}
|
||||
if (ri.nType & 0x10) {
|
||||
if (ri.nType & BRF_PRG) {
|
||||
_stprintf (szText + _tcslen(szText), _T(" %s"), _T("program "));
|
||||
}
|
||||
if (ri.nType & 0x01) {
|
||||
if (ri.nType & BRF_GRA) {
|
||||
_stprintf (szText + _tcslen(szText), _T(" %s"), _T("graphics "));
|
||||
}
|
||||
if (ri.nType & 0x02) {
|
||||
if (ri.nType & BRF_SND) {
|
||||
_stprintf (szText + _tcslen(szText), _T(" %s"), _T("sound "));
|
||||
}
|
||||
_stprintf(szText + _tcslen(szText), _T("(%hs)..."), pszRomName);
|
||||
|
@ -277,6 +288,10 @@ static int __cdecl BzipBurnLoadRom(unsigned char* Dest, int* pnWrote, int i)
|
|||
#endif
|
||||
|
||||
if (RomFind[i].nState == 0) { // Rom not found in zip at all
|
||||
TCHAR szTemp[128] = _T("");
|
||||
_stprintf(szTemp, "%s (not found)\n",szText);
|
||||
fprintf(stderr, szTemp);
|
||||
AppError(szTemp, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -295,10 +310,12 @@ static int __cdecl BzipBurnLoadRom(unsigned char* Dest, int* pnWrote, int i)
|
|||
// Error loading from the zip file
|
||||
TCHAR szTemp[128] = _T("");
|
||||
_stprintf(szTemp, _T("%s reading %.30hs from %.30s"), nRet == 2 ? _T("CRC error") : _T("Error"), pszRomName, GetFilenameW(szBzipName[nCurrentZip]));
|
||||
fprintf(stderr, szTemp);
|
||||
AppError(szTemp, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
fprintf(stderr, "%s (OK)\n", szText);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -386,7 +403,7 @@ int BzipOpen(bool bootApp)
|
|||
|
||||
BurnDrvGetRomInfo(&ri, i); // Get info about the rom
|
||||
|
||||
if ((ri.nType & 0x80) == 0) {
|
||||
if ((ri.nType & BRF_OPT) == 0 && (ri.nType & BRF_NODUMP) == 0) {
|
||||
nTotalSize += ri.nLen;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,16 +56,12 @@ static int DrvLoadRom(unsigned char* Dest, int* pnWrote, int i)
|
|||
int DrvInit(int nDrvNum, bool bRestore)
|
||||
{
|
||||
DrvExit(); // Make sure exitted
|
||||
AudSoundInit(); // Init Sound (not critical if it fails)
|
||||
MediaExit();
|
||||
|
||||
nBurnSoundRate = 0; // Assume no sound
|
||||
pBurnSoundOut = NULL;
|
||||
if (bAudOkay) {
|
||||
nBurnSoundRate = nAudSampleRate[0];
|
||||
nBurnSoundLen = nAudSegLen;
|
||||
}
|
||||
nBurnDrvSelect[0] = nDrvNum; // Set the driver number
|
||||
|
||||
MediaInit();
|
||||
|
||||
// Define nMaxPlayers early; GameInpInit() needs it (normally defined in DoLibInit()).
|
||||
nMaxPlayers = BurnDrvGetMaxPlayers();
|
||||
GameInpInit(); // Init game input
|
||||
|
@ -104,8 +100,6 @@ int DrvInitCallback()
|
|||
int DrvExit()
|
||||
{
|
||||
if (bDrvOkay) {
|
||||
VidExit();
|
||||
|
||||
if (nBurnDrvSelect[0] < nBurnDrvCount) {
|
||||
if (bSaveRAM) {
|
||||
|
||||
|
@ -122,12 +116,6 @@ int DrvExit()
|
|||
BurnExtLoadRom = NULL;
|
||||
|
||||
bDrvOkay = 0; // Stop using the BurnDrv functions
|
||||
|
||||
if (bAudOkay) {
|
||||
// // Write silence into the sound buffer on exit, and for drivers which don't use pBurnSoundOut
|
||||
memset(nAudNextSound, 0, nAudSegLen << 2);
|
||||
}
|
||||
|
||||
nBurnDrvSelect[0] = ~0U; // no driver selected
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -15,15 +15,6 @@ int nAppVirtualFps = 6000; // App fps * 100
|
|||
bool bRunPause=0;
|
||||
bool bAlwaysProcessKeyboardInput=0;
|
||||
|
||||
void init_emu(int gamenum)
|
||||
{
|
||||
bBurnUseASMCPUEmulation=0;
|
||||
bCheatsAllowed=false;
|
||||
ConfigAppLoad();
|
||||
ConfigAppSave();
|
||||
DrvInit(gamenum,0);
|
||||
}
|
||||
|
||||
void CheckFirstTime()
|
||||
{
|
||||
|
||||
|
@ -75,16 +66,21 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
InputInit();
|
||||
init_emu(i);
|
||||
bBurnUseASMCPUEmulation = 0;
|
||||
bCheatsAllowed = false;
|
||||
ConfigAppLoad();
|
||||
ConfigAppSave();
|
||||
|
||||
DrvInit(i, 0);
|
||||
|
||||
RunMessageLoop();
|
||||
InputExit();
|
||||
|
||||
DrvExit();
|
||||
MediaExit();
|
||||
|
||||
ConfigAppSave();
|
||||
BurnLibExit();
|
||||
SDL_Quit();
|
||||
//SDL_Quit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
// Media module
|
||||
#include "burner.h"
|
||||
|
||||
int MediaInit()
|
||||
{
|
||||
//ScrnInit() // Init the Scrn Window
|
||||
|
||||
if (!bInputOkay) {
|
||||
InputInit(); // Init Input
|
||||
}
|
||||
|
||||
nAppVirtualFps = nBurnFPS;
|
||||
|
||||
if (!bAudOkay) {
|
||||
AudSoundInit(); // Init Sound (not critical if it fails)
|
||||
}
|
||||
|
||||
nBurnSoundRate = 0; // Assume no sound
|
||||
pBurnSoundOut = NULL;
|
||||
if (bAudOkay) {
|
||||
nBurnSoundRate = nAudSampleRate[nAudSelect];
|
||||
nBurnSoundLen = nAudSegLen;
|
||||
}
|
||||
|
||||
if (!bVidOkay) {
|
||||
// Reinit the video plugin
|
||||
VidInit();
|
||||
if (!bVidOkay && nVidFullscreen) {
|
||||
|
||||
nVidFullscreen = 0;
|
||||
|
||||
MediaExit();
|
||||
return (MediaInit());
|
||||
}
|
||||
if (!nVidFullscreen) {
|
||||
//ScrnSize();
|
||||
}
|
||||
|
||||
if (!bVidOkay) {
|
||||
printf("Initialized video: %s\n", VidGetModuleName());
|
||||
}
|
||||
|
||||
if (bVidOkay && (bRunPause || !bDrvOkay)) {
|
||||
VidRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MediaExit()
|
||||
{
|
||||
nBurnSoundRate = 0; // Blank sound
|
||||
pBurnSoundOut = NULL;
|
||||
|
||||
AudSoundExit(); // Exit sound
|
||||
|
||||
VidExit();
|
||||
|
||||
InputExit();
|
||||
|
||||
//ScrnExit(); // Exit the Scrn Window
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -214,8 +214,7 @@ static int RunInit()
|
|||
static int RunExit()
|
||||
{
|
||||
nNormalLast = 0;
|
||||
// Stop sound if it was playing
|
||||
AudSoundStop();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -227,19 +226,7 @@ int RunMessageLoop()
|
|||
do {
|
||||
bRestartVideo = 0;
|
||||
|
||||
//MediaInit();
|
||||
|
||||
if (!bVidOkay) {
|
||||
|
||||
// Reinit the video plugin
|
||||
VidInit();
|
||||
if (!bVidOkay && nVidFullscreen) {
|
||||
|
||||
nVidFullscreen = 0;
|
||||
VidInit();
|
||||
}
|
||||
|
||||
}
|
||||
MediaInit();
|
||||
|
||||
RunInit();
|
||||
|
||||
|
|
|
@ -63,12 +63,8 @@ int SDLinpExit()
|
|||
if (!(nInitedSubsytems & SDL_INIT_JOYSTICK)) {
|
||||
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
|
||||
}
|
||||
if (!(nInitedSubsytems & SDL_INIT_VIDEO)) {
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
}
|
||||
nInitedSubsytems = 0;
|
||||
|
||||
// SDL_Quit();
|
||||
nInitedSubsytems = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -88,19 +84,12 @@ int SDLinpInit()
|
|||
}
|
||||
memset(JoyPrevAxes, 0, nSize);
|
||||
|
||||
// SDL_Init(0);
|
||||
nInitedSubsytems = SDL_WasInit(SDL_INIT_JOYSTICK);
|
||||
|
||||
nInitedSubsytems = SDL_WasInit(SDL_INIT_EVERYTHING);
|
||||
|
||||
if (!(nInitedSubsytems & SDL_INIT_VIDEO)) {
|
||||
SDL_InitSubSystem(SDL_INIT_VIDEO);
|
||||
}
|
||||
if (!(nInitedSubsytems & SDL_INIT_JOYSTICK)) {
|
||||
SDL_InitSubSystem(SDL_INIT_JOYSTICK);
|
||||
}
|
||||
|
||||
// SDL_SetVideoMode(320, 224, 0, SDL_RESIZABLE | SDL_HWSURFACE);
|
||||
|
||||
// Set up the joysticks
|
||||
nJoystickCount = SDL_NumJoysticks();
|
||||
for (int i = 0; i < nJoystickCount; i++) {
|
||||
|
|
|
@ -67,29 +67,36 @@ static int BlitFXInit()
|
|||
{
|
||||
int nMemLen = 0;
|
||||
|
||||
nVidImageWidth = nGamesWidth;
|
||||
nVidImageHeight = nGamesHeight;
|
||||
|
||||
nVidImageDepth = bDrvOkay ? 16 : 32;
|
||||
nVidImageBPP = (nVidImageDepth + 7) >> 3;
|
||||
nBurnBpp = nVidImageBPP;
|
||||
|
||||
SetBurnHighCol(nVidImageDepth);
|
||||
|
||||
if (!nRotateGame) {
|
||||
nVidImagePitch = nVidImageWidth * nVidImageBPP;
|
||||
nVidImageWidth = nGamesWidth;
|
||||
nVidImageHeight = nGamesHeight;
|
||||
} else {
|
||||
nVidImagePitch = nVidImageHeight * nVidImageBPP;
|
||||
nVidImageWidth = nGamesHeight;
|
||||
nVidImageHeight = nGamesWidth;
|
||||
}
|
||||
|
||||
nMemLen = nVidImageHeight * nVidImagePitch;
|
||||
nVidImagePitch = nVidImageWidth * nVidImageBPP;
|
||||
nBurnPitch = nVidImagePitch;
|
||||
|
||||
nMemLen = nVidImageWidth * nVidImageHeight * nVidImageBPP;
|
||||
|
||||
printf("nVidImageWidth=%d nVidImageHeight=%d nVidImagePitch=%d\n",
|
||||
nVidImageWidth, nVidImageHeight, nVidImagePitch);
|
||||
printf("nTextureWidth=%d nTextureHeight=%d TexturePitch=%d\n",
|
||||
nTextureWidth, nTextureHeight, nTextureWidth * nVidImageBPP);
|
||||
|
||||
texture = (unsigned char *)malloc(nTextureWidth * nTextureHeight * nVidImageBPP);
|
||||
|
||||
gamescreen = (unsigned char *)malloc(nMemLen);
|
||||
if (gamescreen) {
|
||||
memset(gamescreen, 0, nMemLen);
|
||||
pVidImage = gamescreen + nVidImagePitch;
|
||||
pVidImage = gamescreen;
|
||||
return 0;
|
||||
} else {
|
||||
pVidImage = NULL;
|
||||
|
@ -136,7 +143,7 @@ void init_gl()
|
|||
glEnable(GL_TEXTURE_2D);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, nVidImageBPP, nTextureWidth, nTextureHeight,
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, nTextureWidth, nTextureHeight,
|
||||
0, GL_RGB, texture_type, texture);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
|
@ -146,8 +153,8 @@ void init_gl()
|
|||
glRotatef(0.0, 0.0, 0.0, 1.0);
|
||||
glOrtho(0, nGamesWidth, nGamesHeight, 0, -1, 1);
|
||||
} else {
|
||||
glRotatef((bFlipped ? -90.0 : 90.0), 0.0, 0.0, 1.0);
|
||||
glOrtho(0, nGamesHeight, nGamesWidth, 0, -1, 5);
|
||||
glRotatef((bFlipped ? 270.0 : 90.0), 0.0, 0.0, 1.0);
|
||||
glOrtho(0, nGamesHeight, nGamesWidth, 0, -1, 1);
|
||||
}
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
@ -294,13 +301,13 @@ static void SurfToTex()
|
|||
unsigned char *ps = (unsigned char *)gamescreen;
|
||||
unsigned char *pd = (unsigned char *)texture;
|
||||
|
||||
for (int y = nGamesHeight; y--;) {
|
||||
for (int y = nVidImageHeight; y--;) {
|
||||
memcpy(pd, ps, nVidImagePitch);
|
||||
pd += nVidPitch;
|
||||
ps += nVidImagePitch;
|
||||
}
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, 3, nTextureWidth, nTextureHeight, 0,
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, nTextureWidth, nTextureHeight, 0,
|
||||
GL_RGB, texture_type, texture);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue