int BurnCacheRead(unsigned char * dst, int blockid) { if ( pBurnCacheFile ) { show_rom_loading_text(bcHeader.blocks[blockid].desc, bcHeader.blocks[blockid+1].offset-bcHeader.blocks[blockid].offset, BurnCacheSize); lseek( pBurnCacheFile, bcHeader.blocks[blockid].offset, SEEK_SET ); read( pBurnCacheFile, dst, bcHeader.blocks[blockid+1].offset - bcHeader.blocks[blockid].offset ); return 0; } return 1; }
void * BurnCacheMap(int blockid) { if ( BurnCacheBase ) { if ( (bcHeader.blocks[blockid+1].offset - bcHeader.blocks[blockid].offset) > 0 ) { show_rom_loading_text(bcHeader.blocks[blockid].desc, bcHeader.blocks[blockid+1].offset-bcHeader.blocks[blockid].offset, BurnCacheSize); return (unsigned char *)BurnCacheBase + bcHeader.blocks[blockid].offset; } else return 0; } else return 0; }
void run_fba_emulator(const char *fn) { char build_version[] = "Finalburn Alpha Plus for Pi ("__DATE__")"; // process rom path and name char romname[MAX_PATH]; if (BurnCacheInit(fn, romname)) goto finish; if(config_options.option_showfps) bShowFPS=true; BurnLibInit(); // find rom by name for (nBurnDrvSelect=0; nBurnDrvSelect<nBurnDrvCount; nBurnDrvSelect++) if ( strcasecmp(romname, BurnDrvGetTextA(DRV_NAME)) == 0 ) break; if (nBurnDrvSelect >= nBurnDrvCount) { // unsupport rom ... nBurnDrvSelect = ~0U; logoutput ("rom not supported!\n"); printf ("rom not supported!\n"); goto finish; } logoutput("Attempt to initialise '%s'\n", BurnDrvGetTextA(DRV_FULLNAME)); memset (titlefb, 0, 320*240*2); DrawString (build_version, (uint16*)&titlefb, 10, 20, 320); DrawString ("Based on FinalBurnAlpha", (uint16*)&titlefb, 10, 35, 320); DrawString ("Now loading ... ", (uint16 *)&titlefb, 10, 105, 320); show_rom_loading_text("Open Zip", 0, 0); memcpy (VideoBuffer, titlefb, 320*240*2); pi_video_flip(); InpInit(); InpDIP(); VideoInit(); if (DrvInit(nBurnDrvSelect, false) != 0) { logoutput ("Driver initialisation failed! Likely causes are:\n- Corrupt/Missing ROM(s)\n- I/O Error\n- Memory error\n\n"); printf ("Driver initialisation failed! Likely causes are:\n- Corrupt/Missing ROM(s)\n- I/O Error\n- Memory error\n\n"); goto finish; } RunReset(); frame_count = 0; GameLooping = true; EZX_StartTicks(); logoutput ("Lets go!\n"); logflush(); if (config_options.option_sound_enable) { int timer = 0, tick=0, i=0, fps = 0; bool bRenderFrame; if (SndOpen() == 0) { while (GameLooping) { if (bShowFPS) { timer = EZX_GetTicks(); if(timer-tick>1000000) { fps = nFramesRendered; nFramesRendered = 0; tick = timer; } } //We need to render more audio: bRenderFrame=true; // Render last frame RunOneFrame(bRenderFrame,fps); update_audio_stream(pBurnSoundOut); pi_process_events(); } } } else { int now, done=0, timer = 0, ticks=0, tick=0, i=0, fps = 0; unsigned int frame_limit = nBurnFPS/100, frametime = 100000000/nBurnFPS; while (GameLooping) { timer = EZX_GetTicks()/frametime;; if(timer-tick>frame_limit && bShowFPS) { fps = nFramesRendered; nFramesRendered = 0; tick = timer; } now = timer; ticks=now-done; if(ticks<1) continue; if(ticks>10) ticks=10; for (i=0; i<ticks-1; i++) { RunOneFrame(false,fps); } if(ticks>=1) { RunOneFrame(true,fps); } done = now; } } logoutput ("Finished emulating\n"); finish: logoutput("---- Shutdown Finalburn Alpha plus ----\n\n"); DrvExit(); BurnLibExit(); if (config_options.option_sound_enable) SndExit(); VideoExit(); InpExit(); BurnCacheExit(); }
static int __cdecl BzipBurnLoadRom(unsigned char* Dest, int* pnWrote, int i) { struct BurnRomInfo ri; int nWantZip = 0; TCHAR szText[128]; char* pszRomName = NULL; //int nRet = 0; if (i < 0 || i >= nRomCount) { return 1; } ri.nLen = 0; BurnDrvGetRomInfo(&ri, i); // Get info // show what we're doing BurnDrvGetRomName(&pszRomName, i, 0); if (pszRomName == NULL) { pszRomName = "unknown"; } sprintf(szText, "%-12s ... %4dKb", pszRomName, ri.nLen/1024 ); if (ri.nType & (BRF_PRG | BRF_GRA | BRF_SND | BRF_BIOS)) { if (ri.nType & BRF_BIOS) { sprintf (szText + strlen(szText), " %s", "BIOS "); } if (ri.nType & BRF_PRG) { sprintf (szText + strlen(szText), " %s", "program "); } if (ri.nType & BRF_GRA) { sprintf (szText + strlen(szText), " %s", "graphics "); } if (ri.nType & BRF_SND) { sprintf (szText + strlen(szText), " %s", "sound "); } } ProgressUpdateBurner(ri.nLen ? 1.0 / ((double)nTotalSize / ri.nLen) : 0, szText, 0); // FIXME: eliminate later in favor of ProgressUpdateBurner show_rom_loading_text(szText, ri.nLen, nTotalSize); 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); ProgressError(szTemp, 1); return 1; } nWantZip = RomFind[i].nZip; // Which zip file it is in if (nCurrentZip != nWantZip) { // If we haven't got the right zip file currently open ZipClose(); nCurrentZip = -1; if (ZipOpen(szBzipName[nWantZip])) { printf("%s (open zip err: %s)\n", szText, szBzipName[nWantZip]); return 1; } nCurrentZip = nWantZip; } // Read in file and return how many bytes we read if (ZipLoadFile(Dest, ri.nLen, pnWrote, RomFind[i].nPos)) { printf("%s (ERR)\n", szText); return 1; } printf("%s (OK)\n", szText); return 0; }
static int __cdecl BzipBurnLoadRom(unsigned char* Dest, int* pnWrote, int i) { #if defined (BUILD_WIN32) MSG Msg; #endif struct BurnRomInfo ri; int nWantZip = 0; TCHAR szText[128]; char* pszRomName = NULL; int nRet = 0; //printf("i=%d nRomCount=%d\n",i,nRomCount); if (i < 0 || i >= nRomCount) { return 1; } ri.nLen = 0; BurnDrvGetRomInfo(&ri, i); // Get info // show what we're doing BurnDrvGetRomName(&pszRomName, i, 0); if (pszRomName == NULL) { pszRomName = "unknown"; } _stprintf(szText, _T("Loading")); if (ri.nType & 0x83) { if (ri.nType & 0x80) { _stprintf (szText + _tcslen(szText), _T(" %s"), _T("BIOS ")); } if (ri.nType & 0x10) { _stprintf (szText + _tcslen(szText), _T(" %s"), _T("program ")); } if (ri.nType & 0x01) { _stprintf (szText + _tcslen(szText), _T(" %s"), _T("graphics ")); } if (ri.nType & 0x02) { _stprintf (szText + _tcslen(szText), _T(" %s"), _T("sound ")); } _stprintf(szText + _tcslen(szText), _T("(%hs)..."), pszRomName); } else { _stprintf(szText + _tcslen(szText), _T(" %hs..."), pszRomName); } ProgressUpdateBurner(ri.nLen ? 1.0 / ((double)nTotalSize / ri.nLen) : 0, szText, 0); //fprintf(stderr,"%s (OK)\n", szText); show_rom_loading_text(szText, ri.nLen, nTotalSize); #if defined (BUILD_WIN32) // Check for messages: while (PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) { DispatchMessage(&Msg); } #endif if (RomFind[i].nState == 0) { // Rom not found in zip at all fprintf(stderr,"%s (not found) \n",szText); show_rom_error_text(szText); exit(0); return 1; } nWantZip = RomFind[i].nZip; // Which zip file it is in if (nCurrentZip != nWantZip) { // If we haven't got the right zip file currently open ZipClose(); nCurrentZip = -1; if (ZipOpen(TCHARToANSI(szBzipName[nWantZip], NULL, 0))) { return 1; } nCurrentZip = nWantZip; } // Read in file and return how many bytes we read if (ZipLoadFile(Dest, ri.nLen, pnWrote, RomFind[i].nPos)) { // 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])); AppError(szTemp, 1); return 1; } fprintf(stderr,"%s (OK)\n", szText); return 0; }