static int DINF(FCEUFILE *fp) { char name[100], method[100]; uint8 d, m; uint16 y; int t; if(FCEU_fread(name,1,100,fp)!=100) return(0); if((t=FCEU_fgetc(fp))==EOF) return(0); d=t; if((t=FCEU_fgetc(fp))==EOF) return(0); m=t; if((t=FCEU_fgetc(fp))==EOF) return(0); y=t; if((t=FCEU_fgetc(fp))==EOF) return(0); y|=t<<8; if(FCEU_fread(method,1,100,fp)!=100) return(0); name[99]=method[99]=0; FCEU_printf(" Dumped by: %s\n",name); FCEU_printf(" Dumped with: %s\n",method); { char *months[12]={"January","February","March","April","May","June","July", "August","September","October","November","December"}; FCEU_printf(" Dumped on: %s %d, %d\n",months[(m-1)%12],d,y); } return(1); }
static int CTRL(FCEUFILE *fp) { int t; uint32 i; if(uchead.info == 1) { if ((t = FCEU_fgetc(fp)) == EOF) return(0); /* The information stored in this byte isn't very helpful, but it's better than nothing...maybe. */ if (t & 1) FCEUGameInfo->input[0] = FCEUGameInfo->input[1] = SI_GAMEPAD; else FCEUGameInfo->input[0] = FCEUGameInfo->input[1] = SI_NONE; if (t & 2) FCEUGameInfo->input[1] = SI_ZAPPER; } else { FCEU_printf(" Incorrect Control Chunk Size (%d). Data is:", uchead.info); for(i = 0; i < uchead.info; i++) { t = FCEU_fgetc(fp); FCEU_printf(" %02x", t); } FCEU_printf("\n"); FCEUGameInfo->input[0] = FCEUGameInfo->input[1] = SI_GAMEPAD; } return(1); }
static int LoadCHR(FCEUFILE *fp) { int z,t; z=uchead.ID[3]-'0'; if(z<0 || z>15) return(0); FCEU_printf(" CHR ROM %d size: %d",z,(int) uchead.info); if(malloced[16+z]) free(malloced[16+z]); t=FixRomSize(uchead.info,8192); if(!(malloced[16+z]=(uint8 *)FCEU_malloc(t))) return(0); mallocedsizes[16+z]=t; memset(malloced[16+z]+uchead.info,0xFF,t-uchead.info); if(FCEU_fread(malloced[16+z],1,uchead.info,fp)!=uchead.info) { FCEU_printf("Read Error!\n"); return(0); } else FCEU_printf("\n"); SetupCartCHRMapping(z,malloced[16+z],t,0); return(1); }
static int GetBPP(void) { DDPIXELFORMAT ddpix; memset(&ddpix,0,sizeof(ddpix)); ddpix.dwSize=sizeof(ddpix); ddrval=IDirectDrawSurface7_GetPixelFormat(lpDDSPrimary,&ddpix); if (ddrval != DD_OK) { //ShowDDErr("Error getting primary surface pixel format."); FCEU_printf("Error getting primary surface pixel format.\n"); return 0; } if(ddpix.dwFlags&DDPF_RGB) { //mbg merge 7/17/06 removed silly dummy union stuff now that we have c++ bpp=ddpix.dwRGBBitCount; CBM[0]=ddpix.dwRBitMask; CBM[1]=ddpix.dwGBitMask; CBM[2]=ddpix.dwBBitMask; } else { //ShowDDErr("RGB data not valid."); FCEU_printf("RGB data not valid.\n"); return 0; } if(bpp==15) bpp=16; return 1; }
int UNIFLoad(const char *name, FCEUFILE *fp) { FCEU_fseek(fp,0,SEEK_SET); FCEU_fread(&unhead,1,4,fp); if(memcmp(&unhead,"UNIF",4)) return 0; ResetCartMapping(); ResetExState(0,0); ResetUNIF(); if(!FCEU_read32le(&unhead.info,fp)) goto aborto; if(FCEU_fseek(fp,0x20,SEEK_SET)<0) goto aborto; if(!LoadUNIFChunks(fp)) goto aborto; { int x; struct md5_context md5; md5_starts(&md5); for(x=0;x<32;x++) if(malloced[x]) { md5_update(&md5,malloced[x],mallocedsizes[x]); } md5_finish(&md5,UNIFCart.MD5); FCEU_printf(" ROM MD5: 0x"); for(x=0;x<16;x++) FCEU_printf("%02x",UNIFCart.MD5[x]); FCEU_printf("\n"); memcpy(&GameInfo->MD5,&UNIFCart.MD5,sizeof(UNIFCart.MD5)); } if(!InitializeBoard()) goto aborto; #if !defined(GEKKO)|| !defined(_XBOX) FCEU_LoadGameSave(&UNIFCart); #endif strcpy(LoadedRomFName,name); //For the debugger list GameInterface=UNIFGI; return 1; aborto: FreeUNIF(); ResetUNIF(); return 0; }
POPUP_DISPLAY::POPUP_DISPLAY() { hwndScreenshotBitmap = 0; hwndNoteDescription = 0; // create BITMAPINFO screenshotBmi = (LPBITMAPINFO)malloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)); // 256 color in palette screenshotBmi->bmiHeader.biSize = sizeof(screenshotBmi->bmiHeader); screenshotBmi->bmiHeader.biWidth = SCREENSHOT_WIDTH; screenshotBmi->bmiHeader.biHeight = -SCREENSHOT_HEIGHT; // negative value = top-down bmp screenshotBmi->bmiHeader.biPlanes = 1; screenshotBmi->bmiHeader.biBitCount = 8; screenshotBmi->bmiHeader.biCompression = BI_RGB; screenshotBmi->bmiHeader.biSizeImage = 0; // register SCREENSHOT_DISPLAY window class winCl1.hInstance = fceu_hInstance; winCl1.lpszClassName = szClassName; winCl1.lpfnWndProc = screenshotBitmapWndProc; winCl1.style = CS_DBLCLKS; winCl1.cbSize = sizeof(WNDCLASSEX); winCl1.hIcon = 0; winCl1.hIconSm = 0; winCl1.hCursor = 0; winCl1.lpszMenuName = 0; winCl1.cbClsExtra = 0; winCl1.cbWndExtra = 0; winCl1.hbrBackground = 0; if (!RegisterClassEx(&winCl1)) FCEU_printf("Error registering SCREENSHOT_DISPLAY window class\n"); // register NOTE_DESCRIPTION window class winCl2.hInstance = fceu_hInstance; winCl2.lpszClassName = szClassName2; winCl2.lpfnWndProc = noteDescriptionWndProc; winCl2.style = CS_DBLCLKS; winCl2.cbSize = sizeof(WNDCLASSEX); winCl2.hIcon = 0; winCl2.hIconSm = 0; winCl2.hCursor = 0; winCl2.lpszMenuName = 0; winCl2.cbClsExtra = 0; winCl2.cbWndExtra = 0; winCl2.hbrBackground = 0; if (!RegisterClassEx(&winCl2)) FCEU_printf("Error registering NOTE_DESCRIPTION window class\n"); // create blendfunction blend.BlendOp = AC_SRC_OVER; blend.BlendFlags = 0; blend.AlphaFormat = 0; blend.SourceConstantAlpha = 255; }
int UNIFLoad(const char *name, int fp) { FCEU_fseek(fp,0,SEEK_SET); FCEU_fread(&unhead,1,4,fp); if(memcmp(&unhead,"UNIF",4)) return 0; ResetCartMapping(); ResetExState(0,0); ResetUNIF(); if(!FCEU_read32(&unhead.info,fp)) goto aborto; if(FCEU_fseek(fp,0x20,SEEK_SET)<0) goto aborto; if(!LoadUNIFChunks(fp)) goto aborto; { int x; struct md5_context md5; md5_starts(&md5); for(x=0;x<32;x++) if(malloced[x]) { md5_update(&md5,malloced[x],mallocedsizes[x]); } md5_finish(&md5,UNIFCart.MD5); FCEU_printf(" ROM MD5: 0x"); for(x=0;x<16;x++) FCEU_printf("%02x",UNIFCart.MD5[x]); FCEU_printf("\n"); memcpy(FCEUGameInfo.MD5,UNIFCart.MD5,sizeof(UNIFCart.MD5)); } if(!InitializeBoard()) goto aborto; FCEU_LoadGameSave(&UNIFCart); GameInterface=UNIFGI; return 1; aborto: FreeUNIF(); ResetUNIF(); return 0; }
static int EnableBattery(FCEUFILE *fp) { FCEU_printf(" Battery-backed.\n"); if (FCEU_fgetc(fp) == EOF) return(0); UNIFCart.battery = 1; return(1); }
static void Sync(void) { FCEU_printf("%02x: %02x %02x\n", bank_mode, bank_value, prgb[0]); switch(bank_mode&7) { case 0: setprg32(0x8000,bank_value&7); break; case 1: setprg16(0x8000,((8+(bank_value&7))>>1)+prgb[1]); setprg16(0xC000,(bank_value&7)>>1); case 4: setprg32(0x8000,8+(bank_value&7)); break; case 5: setprg16(0x8000,((8+(bank_value&7))>>1)+prgb[1]); setprg16(0xC000,((8+(bank_value&7))>>1)+prgb[3]); case 2: setprg8(0x8000,prgb[0]>>2); setprg8(0xa000,prgb[1]); setprg8(0xc000,prgb[2]); setprg8(0xe000,~0); break; case 3: setprg8(0x8000,prgb[0]); setprg8(0xa000,prgb[1]); setprg8(0xc000,prgb[2]); setprg8(0xe000,prgb[3]); break; } }
static DECLFW(UNLDSOUNDV1WriteSnd) { if(A == 0x5800) { if(V & 0xF0) { pcm_enable = 1; // pcmwrite(0x4011, (V & 0xF) << 3); pcmwrite(0x4011, decode(V & 0xf)); } else pcm_enable = 0; } else FCEU_printf("misc %04x:%02x\n", A, V); }
int DetectMMC5WRAMSize(uint32 crc32) { int x; for (x = 0; x < MMC5_NOCARTS; x++) { if (crc32 == MMC5CartList[x].crc32) { if (MMC5CartList[x].size > 1) FCEU_printf(" >8KB external WRAM present. Use UNIF if you hack the ROM image.\n"); return(MMC5CartList[x].size * 8); } } return 64; }
void Mapper4_Init(CartInfo *info) { int ws = 8; if ((info->CRC32 == 0x93991433 || info->CRC32 == 0xaf65aa84)) { FCEU_printf("Low-G-Man can not work normally in the iNES format.\nThis game has been recognized by its CRC32 value, and the appropriate changes will be made so it will run.\nIf you wish to hack this game, you should use the UNIF format for your hack.\n\n"); ws = 0; } GenMMC3_Init(info, 512, 256, ws, info->battery); info->Power = M4Power; hackm4 = info->mirror; }
static int SetBoardName(FCEUFILE *fp) { if (!(boardname = (uint8*)FCEU_malloc(uchead.info + 1))) return(0); FCEU_fread(boardname, 1, uchead.info, fp); boardname[uchead.info] = 0; FCEU_printf(" Board name: %s\n", boardname); sboardname = boardname; if (!memcmp(boardname, "NES-", 4) || !memcmp(boardname, "UNL-", 4) || !memcmp(boardname, "HVC-", 4) || !memcmp(boardname, "BTL-", 4) || !memcmp(boardname, "BMC-", 4)) sboardname += 4; return(1); }
static int NAME(FCEUFILE *fp) { char namebuf[100]; int index; int t; FCEU_printf(" Name: "); index = 0; while ((t = FCEU_fgetc(fp)) > 0) if (index < 99) namebuf[index++] = t; namebuf[index] = 0; FCEU_printf("%s\n", namebuf); if (!GameInfo->name) { GameInfo->name = (uint8*)malloc(strlen(namebuf) + 1); //mbg merge 7/17/06 added cast strcpy((char*)GameInfo->name, namebuf); //mbg merge 7/17/06 added cast } return(1); }
static int NAME(FCEUFILE *fp) { char namebuf[100]; int index; int t; FCEU_printf(" Name: "); index = 0; while ((t = FCEU_fgetc(fp)) > 0) if (index < 99) namebuf[index++] = t; namebuf[index] = 0; FCEU_printf("%s\n", namebuf); if (!FCEUGameInfo->name) { FCEUGameInfo->name = malloc(strlen(namebuf) + 1); strcpy(FCEUGameInfo->name, namebuf); } return(1); }
static int DoMirroring(FCEUFILE *fp) { uint8 t; t=FCEU_fgetc(fp); mirrortodo=t; { static char *stuffo[6]={"Horizontal","Vertical","$2000","$2400","\"Four-screen\"","Controlled by Mapper Hardware"}; if(t<6) FCEU_printf(" Name/Attribute Table Mirroring: %s\n",stuffo[t]); } return(1); }
static int InitializeDDraw(int fs) { //only init the palette the first time through if(firstInitialize) { firstInitialize = false; color_palette = (PALETTEENTRY*)malloc(256 * sizeof(PALETTEENTRY)); } //(disvaccel&(1<<(fs?1:0)))?(GUID FAR *)DDCREATE_EMULATIONONLY: ddrval = DirectDrawCreate((disvaccel&(1<<(fs?1:0)))?(GUID FAR *)DDCREATE_EMULATIONONLY:NULL, &lpDD, NULL); if (ddrval != DD_OK) { //ShowDDErr("Error creating DirectDraw object."); FCEU_printf("Error creating DirectDraw object.\n"); return 0; } //mbg merge 7/17/06 changed: ddrval = IDirectDraw_QueryInterface(lpDD,IID_IDirectDraw7,(LPVOID *)&lpDD7); //ddrval = IDirectDraw_QueryInterface(lpDD,&IID_IDirectDraw7,(LPVOID *)&lpDD7); IDirectDraw_Release(lpDD); if (ddrval != DD_OK) { //ShowDDErr("Error querying interface."); FCEU_printf("Error querying interface.\n"); return 0; } caps.dwSize=sizeof(caps); if(IDirectDraw7_GetCaps(lpDD7,&caps,0)!=DD_OK) { //ShowDDErr("Error getting capabilities."); FCEU_printf("Error getting capabilities.\n"); return 0; } return 1; }
static int TVCI(FCEUFILE *fp) { int t; if ((t = FCEU_fgetc(fp)) == EOF) return(0); if (t <= 2) { char *stuffo[3] = { "NTSC", "PAL", "NTSC and PAL" }; if (t == 0) FCEUGameInfo->vidsys = GIV_NTSC; else if (t == 1) FCEUGameInfo->vidsys = GIV_PAL; FCEU_printf(" TV Standard Compatibility: %s\n", stuffo[t]); } return(1); }
void POPUP_DISPLAY::changeScreenshotBitmap() { // uncompress uLongf destlen = SCREENSHOT_SIZE; int e = uncompress(&screenshotRasterPointer[0], &destlen, &bookmarks.bookmarksArray[bookmarks.itemUnderMouse].savedScreenshot[0], bookmarks.bookmarksArray[bookmarks.itemUnderMouse].savedScreenshot.size()); if (e != Z_OK && e != Z_BUF_ERROR) { // error decompressing FCEU_printf("Error decompressing screenshot %d\n", bookmarks.itemUnderMouse); // at least fill bitmap with zeros memset(&screenshotRasterPointer[0], 0, SCREENSHOT_SIZE); } redrawScreenshotBitmap(); }
static DECLFW(MCN22MWrite) { FCEU_printf("bs %04x %02x\n",A,V); switch(A) { case 0x8c00: case 0x8c01: case 0x8c02: reg[A&3]=V; break; case 0x8d10: reg[3]=V; break; case 0x8d11: reg[4]=V; break; case 0x8d16: reg[5]=V; break; case 0x8d17: reg[6]=V; break; } Sync(); }
static int DoMirroring(FCEUFILE *fp) { int t; uint32 i; if(uchead.info == 1) { if ((t = FCEU_fgetc(fp)) == EOF) return(0); mirrortodo = t; { static char *stuffo[6] = { "Horizontal", "Vertical", "$2000", "$2400", "\"Four-screen\"", "Controlled by Mapper Hardware" }; if (t < 6) FCEU_printf(" Name/Attribute Table Mirroring: %s\n", stuffo[t]); } } else { FCEU_printf(" Incorrect Mirroring Chunk Size (%d). Data is:", uchead.info); for(i = 0; i < uchead.info; i++) { if ((t = FCEU_fgetc(fp)) == EOF) return(0); FCEU_printf(" %02x", t); } FCEU_printf("\n Default Name/Attribute Table Mirroring: Horizontal\n", uchead.info); mirrortodo = 0; } return(1); }
static DECLFW(BMC13in1JY110Write) { FCEU_printf("%04x:%04x\n",A,V); switch(A) { case 0x8000: case 0x8001: case 0x8002: case 0x8003: prgb[A&3]=V; break; case 0xD000: bank_mode=V; break; case 0xD001: setmirror(V&3); case 0xD002: break; case 0xD003: bank_value=V; break; } Sync(); }
static int DetectMMC1WRAMSize(uint32 crc32) { switch(crc32) { case 0xc6182024: /* Romance of the 3 Kingdoms */ case 0x2225c20f: /* Genghis Khan */ case 0x4642dda6: /* Nobunaga's Ambition */ case 0x29449ba9: /* "" "" (J) */ case 0x2b11e0b0: /* "" "" (J) */ case 0xb8747abf: /* Best Play Pro Yakyuu Special (J) */ case 0xc9556b36: /* Final Fantasy I & II (J) [!] */ FCEU_printf(" >8KB external WRAM present. Use UNIF if you hack the ROM image.\n"); return(16); break; default: return(8); } }
FCEUGI *FCEUI_CopyFamiStart(void) { ResetGameLoaded(); FCEUGameInfo = malloc(sizeof(FCEUGI)); memset(FCEUGameInfo, 0, sizeof(FCEUGI)); FCEUGameInfo->soundchan = 0; FCEUGameInfo->soundrate = 0; FCEUGameInfo->name = "copyfami"; FCEUGameInfo->type = GIT_CART; FCEUGameInfo->vidsys = GIV_USER; FCEUGameInfo->input[0] = FCEUGameInfo->input[1] = -1; FCEUGameInfo->inputfc = -1; FCEUGameInfo->cspecial = 0; FCEU_printf("Starting CopyFamicom...\n\n"); if (!CopyFamiLoad()) { FCEU_PrintError("An error occurred while starting CopyFamicom."); return 0; } FCEU_ResetVidSys(); if (FCEUGameInfo->type != GIT_NSF) if (FSettings.GameGenie) FCEU_OpenGenie(); PowerNES(); FCEUSS_CheckStates(); FCEUMOV_CheckMovies(); if (FCEUGameInfo->type != GIT_NSF) { FCEU_LoadGamePalette(); FCEU_LoadGameCheats(0); } FCEU_ResetPalette(); FCEU_ResetMessages(); // Save state, status messages, etc. return(FCEUGameInfo); }
static int TVCI(int fp) { int t; if( (t=FCEU_fgetc(fp)) ==EOF) return(0); if(t<=2) { char *stuffo[3]={"NTSC","PAL","NTSC and PAL"}; if(t==0) { FCEUGameInfo.vidsys=GIV_NTSC; FCEUI_SetVidSystem(0); } else if(t==1) { FCEUGameInfo.vidsys=GIV_PAL; FCEUI_SetVidSystem(1); } FCEU_printf(" TV Standard Compatibility: %s\n",stuffo[t]); } return(1); }
FCEUGI *FCEUI_CopyFamiStart(void) { ResetGameLoaded(); FCEUGameInfo = malloc(sizeof(FCEUGI)); memset(FCEUGameInfo, 0, sizeof(FCEUGI)); FCEUGameInfo->soundchan = 0; FCEUGameInfo->soundrate = 0; FCEUGameInfo->name="copyfami"; FCEUGameInfo->type=GIT_CART; FCEUGameInfo->vidsys=GIV_USER; FCEUGameInfo->input[0]=FCEUGameInfo->input[1]=-1; FCEUGameInfo->inputfc=-1; FCEUGameInfo->cspecial=0; #ifdef FCEU_LOG FCEU_printf("Starting CopyFamicom...\n\n"); #endif if(!CopyFamiLoad()) return 0; /*An error occurred while starting CopyFamicom*/ FCEU_ResetVidSys(); if(FSettings.GameGenie) OpenGenie(); PowerNES(); FCEU_LoadGamePalette(); FCEU_LoadGameCheats(0); FCEU_ResetPalette(); return(FCEUGameInfo); }
static DECLFW(SSSNROMWrite) { #if 0 FCEU_printf("write %04x %02x\n",A,V); regs[A&7] = V; #endif }
/** * Attempts to initialize the graphical video display. Returns 0 on * success, -1 on failure. */ int InitVideo(FCEUGI *gi) { // XXX soules - const? is this necessary? const SDL_VideoInfo *vinf; int error, flags = 0; int doublebuf, xstretch, ystretch, xres, yres, show_fps; FCEUI_printf("Initializing video..."); // load the relevant configuration variables g_config->getOption("SDL.Fullscreen", &s_fullscreen); g_config->getOption("SDL.DoubleBuffering", &doublebuf); #ifdef OPENGL g_config->getOption("SDL.OpenGL", &s_useOpenGL); #endif g_config->getOption("SDL.SpecialFilter", &s_sponge); g_config->getOption("SDL.XStretch", &xstretch); g_config->getOption("SDL.YStretch", &ystretch); g_config->getOption("SDL.LastXRes", &xres); g_config->getOption("SDL.LastYRes", &yres); g_config->getOption("SDL.ClipSides", &s_clipSides); g_config->getOption("SDL.NoFrame", &noframe); g_config->getOption("SDL.ShowFPS", &show_fps); // check the starting, ending, and total scan lines FCEUI_GetCurrentVidSystem(&s_srendline, &s_erendline); s_tlines = s_erendline - s_srendline + 1; // check if we should auto-set x/y resolution // check for OpenGL and set the global flags #if OPENGL if(s_useOpenGL && !s_sponge) { flags = SDL_OPENGL; } #endif // initialize the SDL video subsystem if it is not already active if(!SDL_WasInit(SDL_INIT_VIDEO)) { error = SDL_InitSubSystem(SDL_INIT_VIDEO); if(error) { FCEUD_PrintError(SDL_GetError()); return -1; } } s_inited = 1; // shows the cursor within the display window SDL_ShowCursor(1); // determine if we can allocate the display on the video card vinf = SDL_GetVideoInfo(); if(vinf->hw_available) { flags |= SDL_HWSURFACE; } // get the monitor's current resolution if we do not already have it if(s_nativeWidth < 0) { s_nativeWidth = vinf->current_w; } if(s_nativeHeight < 0) { s_nativeHeight = vinf->current_h; } // check to see if we are showing FPS FCEUI_SetShowFPS(show_fps); // check if we are rendering fullscreen if(s_fullscreen) { int no_cursor; g_config->getOption("SDL.NoFullscreenCursor", &no_cursor); flags |= SDL_FULLSCREEN; SDL_ShowCursor(!no_cursor); } else { SDL_ShowCursor(1); } if(noframe) { flags |= SDL_NOFRAME; } // gives the SDL exclusive palette control... ensures the requested colors // flags |= SDL_HWPALETTE; // enable double buffering if requested and we have hardware support #ifdef OPENGL if(s_useOpenGL) { FCEU_printf("Initializing with OpenGL (Disable with '--opengl 0').\n"); if(doublebuf) { SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); } } else #endif if(doublebuf && (flags & SDL_HWSURFACE)) { flags |= SDL_DOUBLEBUF; } if(s_fullscreen) { int desbpp, autoscale; g_config->getOption("SDL.BitsPerPixel", &desbpp); g_config->getOption("SDL.AutoScale", &autoscale); if (autoscale) { double auto_xscale = GetXScale(xres); double auto_yscale = GetYScale(yres); double native_ratio = ((double)NWIDTH) / s_tlines; double screen_ratio = ((double)xres) / yres; int keep_ratio; g_config->getOption("SDL.KeepRatio", &keep_ratio); // Try to choose resolution if (screen_ratio < native_ratio) { // The screen is narrower than the original. Maximizing width will not clip auto_xscale = auto_yscale = GetXScale(xres); if (keep_ratio) auto_yscale = GetYScale(yres); } else { auto_yscale = auto_xscale = GetYScale(yres); if (keep_ratio) auto_xscale = GetXScale(xres); } s_exs = auto_xscale; s_eys = auto_yscale; } else { g_config->getOption("SDL.XScale", &s_exs); g_config->getOption("SDL.YScale", &s_eys); } g_config->getOption("SDL.SpecialFX", &s_eefx); #ifdef OPENGL if(!s_useOpenGL) { s_exs = (int)s_exs; s_eys = (int)s_eys; } else { desbpp = 0; } // -Video Modes Tag- if(s_sponge) { if(s_sponge == 4 || s_sponge == 5) { s_exs = s_eys = 3; } else { s_exs = s_eys = 2; } s_eefx = 0; if(s_sponge == 1 || s_sponge == 4) { desbpp = 32; } } if((s_useOpenGL && !xstretch) || !s_useOpenGL) #endif if(xres < (NWIDTH * s_exs) || s_exs <= 0.01) { FCEUD_PrintError("xscale out of bounds."); KillVideo(); return -1; } #ifdef OPENGL if((s_useOpenGL && !ystretch) || !s_useOpenGL) #endif if(yres < s_tlines * s_eys || s_eys <= 0.01) { FCEUD_PrintError("yscale out of bounds."); KillVideo(); return -1; } #ifdef OPENGL s_screen = SDL_SetVideoMode(s_useOpenGL ? s_nativeWidth : xres, s_useOpenGL ? s_nativeHeight : yres, desbpp, flags); #else s_screen = SDL_SetVideoMode(xres, yres, desbpp, flags); #endif if(!s_screen) { FCEUD_PrintError(SDL_GetError()); return -1; } } else { int desbpp; g_config->getOption("SDL.BitsPerPixel", &desbpp); g_config->getOption("SDL.XScale", &s_exs); g_config->getOption("SDL.YScale", &s_eys); g_config->getOption("SDL.SpecialFX", &s_eefx); // -Video Modes Tag- if(s_sponge) { if(s_sponge >= 4) { s_exs = s_eys = 3; } else { s_exs = s_eys = 2; } s_eefx = 0; } #ifdef OPENGL if(!s_useOpenGL) { s_exs = (int)s_exs; s_eys = (int)s_eys; } if(s_exs <= 0.01) { FCEUD_PrintError("xscale out of bounds."); KillVideo(); return -1; } if(s_eys <= 0.01) { FCEUD_PrintError("yscale out of bounds."); KillVideo(); return -1; } if(s_sponge && s_useOpenGL) { FCEUD_PrintError("scalers not compatible with openGL mode."); KillVideo(); return -1; } #endif #if defined(_GTK) && defined(SDL_VIDEO_DRIVER_X11) if(noGui == 0) { while (gtk_events_pending()) gtk_main_iteration_do(FALSE); char SDL_windowhack[128]; sprintf(SDL_windowhack, "SDL_WINDOWID=%u", (unsigned int)GDK_WINDOW_XID(gtk_widget_get_window(evbox))); SDL_putenv(SDL_windowhack); // init SDL video if (SDL_WasInit(SDL_INIT_VIDEO)) SDL_QuitSubSystem(SDL_INIT_VIDEO); if ( SDL_InitSubSystem(SDL_INIT_VIDEO) < 0 ) { fprintf(stderr, "Couldn't init SDL video: %s\n", SDL_GetError()); gtk_main_quit(); } } #endif s_screen = SDL_SetVideoMode((int)(NWIDTH * s_exs), (int)(s_tlines * s_eys), desbpp, flags); if(!s_screen) { FCEUD_PrintError(SDL_GetError()); return -1; } #ifdef _GTK if(noGui == 0) { GtkRequisition req; gtk_widget_size_request(GTK_WIDGET(MainWindow), &req); gtk_window_resize(GTK_WINDOW(MainWindow), req.width, req.height); } #endif } s_curbpp = s_screen->format->BitsPerPixel; if(!s_screen) { FCEUD_PrintError(SDL_GetError()); KillVideo(); return -1; } #if 0 // XXX soules - this would be creating a surface on the video // card, but was commented out for some reason... s_BlitBuf = SDL_CreateRGBSurface(SDL_HWSURFACE, 256, 240, s_screen->format->BitsPerPixel, s_screen->format->Rmask, s_screen->format->Gmask, s_screen->format->Bmask, 0); #endif FCEU_printf(" Video Mode: %d x %d x %d bpp %s\n", s_screen->w, s_screen->h, s_screen->format->BitsPerPixel, s_fullscreen ? "full screen" : ""); if(s_curbpp != 8 && s_curbpp != 16 && s_curbpp != 24 && s_curbpp != 32) { FCEU_printf(" Sorry, %dbpp modes are not supported by FCE Ultra. Supported bit depths are 8bpp, 16bpp, and 32bpp.\n", s_curbpp); KillVideo(); return -1; } // if the game being run has a name, set it as the window name if(gi) { if(gi->name) { SDL_WM_SetCaption((const char *)gi->name, (const char *)gi->name); } else { SDL_WM_SetCaption(FCEU_NAME_AND_VERSION,"FCE Ultra"); } } // create the surface for displaying graphical messages #ifdef LSB_FIRST s_IconSurface = SDL_CreateRGBSurfaceFrom((void *)fceu_playicon.pixel_data, 32, 32, 24, 32 * 3, 0xFF, 0xFF00, 0xFF0000, 0x00); #else s_IconSurface = SDL_CreateRGBSurfaceFrom((void *)fceu_playicon.pixel_data, 32, 32, 24, 32 * 3, 0xFF0000, 0xFF00, 0xFF, 0x00); #endif SDL_WM_SetIcon(s_IconSurface,0); s_paletterefresh = 1; // XXX soules - can't SDL do this for us? // if using more than 8bpp, initialize the conversion routines if(s_curbpp > 8) { InitBlitToHigh(s_curbpp >> 3, s_screen->format->Rmask, s_screen->format->Gmask, s_screen->format->Bmask, s_eefx, s_sponge, 0); #ifdef OPENGL if(s_useOpenGL) { int openGLip; g_config->getOption("SDL.OpenGLip", &openGLip); if(!InitOpenGL(NOFFSET, 256 - (s_clipSides ? 8 : 0), s_srendline, s_erendline + 1, s_exs, s_eys, s_eefx, openGLip, xstretch, ystretch, s_screen)) { FCEUD_PrintError("Error initializing OpenGL."); KillVideo(); return -1; } } #endif }
void EDITOR::init() { free(); // load autofire_patterns int total_patterns = 0; char nameo[2048]; strncpy(nameo, FCEU_GetPath(FCEUMKF_TASEDITOR).c_str(), 2047); strncat(nameo, patternsFilename, 2047 - strlen(nameo)); EMUFILE_FILE ifs(nameo, "rb"); if (!ifs.fail()) { std::string tempstr1, tempstr2; while (readStringFromPatternsFile(&ifs, tempstr1)) { if (readStringFromPatternsFile(&ifs, tempstr2)) { total_patterns++; // save the name patternsNames.push_back(tempstr1); // parse 2nd string to sequence of 1s and 0s patterns.resize(total_patterns); patterns[total_patterns - 1].resize(tempstr2.size()); for (int i = tempstr2.size() - 1; i >= 0; i--) { if (tempstr2[i] == autofire_patterns_flagpress) patterns[total_patterns - 1][i] = 1; else patterns[total_patterns - 1][i] = 0; } } } } else { FCEU_printf("Could not load tools\\taseditor_patterns.txt!\n"); } if (patterns.size() == 0) { FCEU_printf("Will be using default set of patterns...\n"); patterns.resize(4); patternsNames.resize(4); // Default Pattern 0: Alternating (1010...) patternsNames[0] = "Alternating (1010...)"; patterns[0].resize(2); patterns[0][0] = 1; patterns[0][1] = 0; // Default Pattern 1: Alternating at 30FPS (11001100...) patternsNames[1] = "Alternating at 30FPS (11001100...)"; patterns[1].resize(4); patterns[1][0] = 1; patterns[1][1] = 1; patterns[1][2] = 0; patterns[1][3] = 0; // Default Pattern 2: One Quarter (10001000...) patternsNames[2] = "One Quarter (10001000...)"; patterns[2].resize(4); patterns[2][0] = 1; patterns[2][1] = 0; patterns[2][2] = 0; patterns[2][3] = 0; // Default Pattern 3: Tap'n'Hold (1011111111111111111111111111111111111...) patternsNames[3] = "Tap'n'Hold (101111111...)"; patterns[3].resize(1000); patterns[3][0] = 1; patterns[3][1] = 0; for (int i = 2; i < 1000; ++i) patterns[3][i] = 1; } // reset current_pattern if it's outside the range if (taseditorConfig.currentPattern < 0 || taseditorConfig.currentPattern >= (int)patterns.size()) taseditorConfig.currentPattern = 0; taseditorWindow.updatePatternsMenu(); reset(); }
// returns true if couldn't load bool HISTORY::load(EMUFILE *is, unsigned int offset) { int i = -1; SNAPSHOT snap; BOOKMARK bookm; if (offset) { if (is->fseek(offset, SEEK_SET)) goto error; } else { reset(); return false; } // read "HISTORY" string char save_id[HISTORY_ID_LEN]; if ((int)is->fread(save_id, HISTORY_ID_LEN) < HISTORY_ID_LEN) goto error; if (!strcmp(historySkipSaveID, save_id)) { // string says to skip loading History FCEU_printf("No History in the file\n"); reset(); return false; } if (strcmp(historySaveID, save_id)) goto error; // string is not valid // delete old items snapshots.resize(historySize); bookmarkBackups.resize(historySize); currentBranchNumberBackups.resize(historySize); // read vars if (!read32le(&historyCursorPos, is)) goto error; if (!read32le(&historyTotalItems, is)) goto error; if (historyCursorPos > historyTotalItems) goto error; historyStartPos = 0; // read items int total = historyTotalItems; if (historyTotalItems > historySize) { // user can't afford that much undo levels, skip some items int num_items_to_skip = historyTotalItems - historySize; // first try to skip items over history_cursor_pos (future items), because "redo" is less important than "undo" int num_redo_items = historyTotalItems-1 - historyCursorPos; if (num_items_to_skip >= num_redo_items) { // skip all redo items historyTotalItems = historyCursorPos+1; num_items_to_skip -= num_redo_items; // and still need to skip some undo items for (i = 0; i < num_items_to_skip; ++i) { if (snap.skipLoad(is)) goto error; if (bookm.skipLoad(is)) goto error; if (is->fseek(1, SEEK_CUR)) goto error; // backup_current_branch } total -= num_items_to_skip; historyCursorPos -= num_items_to_skip; } historyTotalItems -= num_items_to_skip; } // load items for (i = 0; i < historyTotalItems; ++i) { if (snapshots[i].load(is)) goto error; if (bookmarkBackups[i].load(is)) goto error; if (is->fread(¤tBranchNumberBackups[i], 1) != 1) goto error; playback.setProgressbar(i, historyTotalItems); } // skip redo items if needed for (; i < total; ++i) { if (snap.skipLoad(is)) goto error; if (bookm.skipLoad(is)) goto error; if (is->fseek(1, SEEK_CUR)) goto error; // backup_current_branch } // everything went well // init vars undoHintPos = oldUndoHintPos = undoHintTimer = -1; oldShowUndoHint = showUndoHint = false; updateList(); redrawList(); return false; error: FCEU_printf("Error loading History\n"); reset(); return true; }