int JapModemInit(const char *setting) { if ((JapModemArea = malloc(sizeof(JapModem))) == NULL) { Cs2Area->carttype = CART_NONE; YabSetError(YAB_ERR_CANNOTINIT, (void *)"Japanese Modem"); return 0; } return NetlinkInit(setting); }
int PERDXInit(void) { char tempstr[512]; HRESULT ret; int user_index=0; u32 i; if (PERCORE_INITIALIZED) return 0; if (FAILED((ret = DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, &IID_IDirectInput8, (LPVOID *)&lpDI8, NULL)) )) { sprintf(tempstr, "Input. DirectInput8Create error: %s - %s", DXGetErrorString8(ret), DXGetErrorDescription8(ret)); YabSetError(YAB_ERR_CANNOTINIT, tempstr); return -1; } #ifdef HAVE_XINPUT SetupForIsXInputDevice(); #endif num_devices = 0; IDirectInput8_EnumDevices(lpDI8, DI8DEVCLASS_ALL, EnumPeripheralsCallback, &user_index, DIEDFL_ATTACHEDONLY); #ifdef HAVE_XINPUT CleanupForIsXInputDevice(); #endif for (i = 0; i < num_devices; i++) { if (!dev_list[i].is_xinput_device) { if( FAILED( ret = IDirectInputDevice8_SetDataFormat(dev_list[i].lpDIDevice, &c_dfDIJoystick2 ) ) ) return -1; // Set the cooperative level to let DInput know how this device should // interact with the system and with other DInput applications. if( FAILED( ret = IDirectInputDevice8_SetCooperativeLevel( dev_list[i].lpDIDevice, DXGetWindow(), DISCL_NONEXCLUSIVE | DISCL_BACKGROUND /* DISCL_EXCLUSIVE | DISCL_FOREGROUND */ ) ) ) return -1; } } PerPortReset(); //LoadDefaultPort1A(); PERCORE_INITIALIZED = 1; return 0; }
static int SNDSDLInit(void) { //samples should be a power of 2 according to SDL-doc //so normalize it to the nearest power of 2 here u32 normSamples = 512; #if defined (_MSC_VER) && SDL_VERSION_ATLEAST(2,0,0) SDL_SetMainReady(); #endif SDL_InitSubSystem(SDL_INIT_AUDIO); // if (SDL_InitSubSystem(SDL_INIT_AUDIO) != 0); // return -1; audiofmt.freq = 44100; audiofmt.format = AUDIO_S16SYS; audiofmt.channels = 2; audiofmt.samples = (audiofmt.freq / 60) * 2; audiofmt.callback = MixAudio; audiofmt.userdata = NULL; while (normSamples < audiofmt.samples) normSamples <<= 1; audiofmt.samples = normSamples; soundlen = audiofmt.freq / 60; // 60 for NTSC or 50 for PAL. Initially assume it's going to be NTSC. soundbufsize = soundlen * NUMSOUNDBLOCKS * 2 * 2; soundvolume = SDL_MIX_MAXVOLUME; if (SDL_OpenAudio(&audiofmt, NULL) != 0) { YabSetError(YAB_ERR_SDL, (void *)SDL_GetError()); return -1; } if ((stereodata16 = (u16 *)malloc(soundbufsize)) == NULL) return -1; memset(stereodata16, 0, soundbufsize); soundpos = 0; SDL_PauseAudio(0); return 0; }
int YabLoadState(const char *filename) { FILE *fp; char id[3]; u8 endian; int headerversion, version, size, chunksize, headersize; IOCheck_struct check; u8* buf; int totalsize; int outputwidth; int outputheight; int curroutputwidth; int curroutputheight; int movieposition; int temp; u32 temp32; filename = MakeMovieStateName(filename); if (!filename) return -1; if ((fp = fopen(filename, "rb")) == NULL) return -1; headersize = 0xC; // Read signature yread(&check, (void *)id, 1, 3, fp); if (strncmp(id, "YSS", 3) != 0) { fclose(fp); return -2; } // Read header yread(&check, (void *)&endian, 1, 1, fp); yread(&check, (void *)&headerversion, 4, 1, fp); yread(&check, (void *)&size, 4, 1, fp); switch(headerversion) { case 1: /* This is the "original" version of the format */ break; case 2: /* version 2 adds video recording */ yread(&check, (void *)&framecounter, 4, 1, fp); movieposition=ftell(fp); yread(&check, (void *)&movieposition, 4, 1, fp); headersize = 0x14; break; default: /* we're trying to open a save state using a future version * of the YSS format, that won't work, sorry :) */ fclose(fp); return -3; break; } #ifdef WORDS_BIGENDIAN if (endian == 1) #else if (endian == 0) #endif { // should setup reading so it's byte-swapped YabSetError(YAB_ERR_OTHER, (void *)"Load State byteswapping not supported"); fclose(fp); return -3; } // Make sure size variable matches actual size minus header fseek(fp, 0, SEEK_END); if (size != (ftell(fp) - headersize)) { fclose(fp); return -2; } fseek(fp, headersize, SEEK_SET); // Verify version here ScspMuteAudio(SCSP_MUTE_SYSTEM); if (StateCheckRetrieveHeader(fp, "CART", &version, &chunksize) != 0) { fclose(fp); // Revert back to old state here ScspUnMuteAudio(SCSP_MUTE_SYSTEM); return -3; } CartLoadState(fp, version, chunksize); if (StateCheckRetrieveHeader(fp, "CS2 ", &version, &chunksize) != 0) { fclose(fp); // Revert back to old state here ScspUnMuteAudio(SCSP_MUTE_SYSTEM); return -3; } Cs2LoadState(fp, version, chunksize); if (StateCheckRetrieveHeader(fp, "MSH2", &version, &chunksize) != 0) { fclose(fp); // Revert back to old state here ScspUnMuteAudio(SCSP_MUTE_SYSTEM); return -3; } SH2LoadState(MSH2, fp, version, chunksize); if (StateCheckRetrieveHeader(fp, "SSH2", &version, &chunksize) != 0) { fclose(fp); // Revert back to old state here ScspUnMuteAudio(SCSP_MUTE_SYSTEM); return -3; } SH2LoadState(SSH2, fp, version, chunksize); if (StateCheckRetrieveHeader(fp, "SCSP", &version, &chunksize) != 0) { fclose(fp); // Revert back to old state here ScspUnMuteAudio(SCSP_MUTE_SYSTEM); return -3; } SoundLoadState(fp, version, chunksize); if (StateCheckRetrieveHeader(fp, "SCU ", &version, &chunksize) != 0) { fclose(fp); // Revert back to old state here ScspUnMuteAudio(SCSP_MUTE_SYSTEM); return -3; } ScuLoadState(fp, version, chunksize); if (StateCheckRetrieveHeader(fp, "SMPC", &version, &chunksize) != 0) { fclose(fp); // Revert back to old state here ScspUnMuteAudio(SCSP_MUTE_SYSTEM); return -3; } SmpcLoadState(fp, version, chunksize); if (StateCheckRetrieveHeader(fp, "VDP1", &version, &chunksize) != 0) { fclose(fp); // Revert back to old state here ScspUnMuteAudio(SCSP_MUTE_SYSTEM); return -3; } Vdp1LoadState(fp, version, chunksize); if (StateCheckRetrieveHeader(fp, "VDP2", &version, &chunksize) != 0) { fclose(fp); // Revert back to old state here ScspUnMuteAudio(SCSP_MUTE_SYSTEM); return -3; } Vdp2LoadState(fp, version, chunksize); if (StateCheckRetrieveHeader(fp, "OTHR", &version, &chunksize) != 0) { fclose(fp); // Revert back to old state here ScspUnMuteAudio(SCSP_MUTE_SYSTEM); return -3; } // Other data yread(&check, (void *)BupRam, 0x10000, 1, fp); yread(&check, (void *)HighWram, 0x100000, 1, fp); yread(&check, (void *)LowWram, 0x100000, 1, fp); yread(&check, (void *)&yabsys.DecilineCount, sizeof(int), 1, fp); yread(&check, (void *)&yabsys.LineCount, sizeof(int), 1, fp); yread(&check, (void *)&yabsys.VBlankLineCount, sizeof(int), 1, fp); yread(&check, (void *)&yabsys.MaxLineCount, sizeof(int), 1, fp); yread(&check, (void *)&temp, sizeof(int), 1, fp); yread(&check, (void *)&temp, sizeof(int), 1, fp); yread(&check, (void *)&temp32, sizeof(u32), 1, fp); yread(&check, (void *)&yabsys.CurSH2FreqType, sizeof(int), 1, fp); yread(&check, (void *)&yabsys.IsPal, sizeof(int), 1, fp); YabauseChangeTiming(yabsys.CurSH2FreqType); yabsys.UsecFrac = (temp32 << YABSYS_TIMING_BITS) * temp / 10; if (headerversion > 1) { yread(&check, (void *)&outputwidth, sizeof(outputwidth), 1, fp); yread(&check, (void *)&outputheight, sizeof(outputheight), 1, fp); totalsize=outputwidth * outputheight * sizeof(u32); if ((buf = (u8 *)malloc(totalsize)) == NULL) { return -2; } yread(&check, (void *)buf, totalsize, 1, fp); YuiSwapBuffers(); #ifdef USE_OPENGL if(VIDCore->id == VIDCORE_SOFT) glRasterPos2i(0, outputheight); if(VIDCore->id == VIDCORE_OGL) glRasterPos2i(0, outputheight/2); #endif VIDCore->GetGlSize(&curroutputwidth, &curroutputheight); #ifdef USE_OPENGL glPixelZoom((float)curroutputwidth / (float)outputwidth, ((float)curroutputheight / (float)outputheight)); glDrawPixels(outputwidth, outputheight, GL_RGBA, GL_UNSIGNED_BYTE, buf); #endif YuiSwapBuffers(); fseek(fp, movieposition, SEEK_SET); MovieReadState(fp, filename); } fclose(fp); ScspUnMuteAudio(SCSP_MUTE_SYSTEM); OSDPushMessage(OSDMSG_STATUS, 150, "STATE LOADED"); return 0; }