📄 sdllink.c
字号:
init_hqNx(); if ((CurMode != cvidmode) || (prevNTSCMode != NTSCFilter) || (changeRes) || (prevKeep4_3Ratio != Keep4_3Ratio)) { CurMode = cvidmode; newmode = 1; WindowWidth = 256; WindowHeight = 224; prevNTSCMode = NTSCFilter; changeRes = 0; prevKeep4_3Ratio = Keep4_3Ratio; FullScreen = GUIWFVID[cvidmode];#ifdef __OPENGL__ UseOpenGL = 0; if (OGLModeCheck()) UseOpenGL = 1; if ((cvidmode == 20) || (cvidmode == 21) || (cvidmode == 22)) { SetHQx(CustomResX,CustomResY); SetHiresOpt(CustomResX,CustomResY); }#else if (OGLModeCheck()) cvidmode = 2; // set it to the default 512x448 W#endif switch (cvidmode) { default: case 0: case 1: WindowWidth = 256; WindowHeight = 224; break; case 2: case 3: case 6: if (NTSCFilter) { WindowWidth = 602; WindowHeight = 446; } else { WindowWidth = 512; WindowHeight = 448; } break; case 4: case 7: case 8: WindowWidth = 640; WindowHeight = 480; break; case 9: WindowWidth = 640; WindowHeight = 560; break; case 10: WindowWidth = 768; WindowHeight = 672; break; case 11: case 12: WindowWidth = 800; WindowHeight = 600; break; case 13: WindowWidth = 896; WindowHeight = 784; break; case 14: case 15: WindowWidth = 1024; WindowHeight = 768; break; case 16: WindowWidth = 1024; WindowHeight = 896; break; case 17: WindowWidth = 1280; WindowHeight = 960; break; case 18: WindowWidth = 1280; WindowHeight = 1024; break; case 19: WindowWidth = 1600; WindowHeight = 1200; break; case 20: // Variable ODR case 21: // Variable ODS case 22: // Custom Res WindowWidth = CustomResX; WindowHeight = CustomResY; break; } adjustMouseXScale(); adjustMouseYScale(); } if (startgame() != TRUE) { /* Exit zsnes if SDL could not be initialized */ if (sdl_state == vid_null) exit(0); else return; } if (newmode == 1) { #ifdef __OPENGL__ if(OGLModeCheck()) { surface = SDL_SetVideoMode(WindowWidth, WindowHeight, BitDepth, surface->flags); adjustMouseXScale(); adjustMouseYScale(); glViewport(0,0, WindowWidth, WindowHeight); glMatrixMode(GL_PROJECTION); glLoadIdentity(); if (cvidmode == 20) { if (224*WindowWidth > 256*WindowHeight && WindowHeight) { glOrtho (- ((float) 224*WindowWidth)/((float) 256*WindowHeight), ((float) 224*WindowWidth)/((float) 256*WindowHeight), -1, 1, -1, 1); } else if (224*WindowWidth < 256*WindowHeight && WindowWidth) { glOrtho (-1, 1,- ((float) 256*WindowHeight)/((float) 224*WindowWidth), ((float) 256*WindowHeight)/((float) 224*WindowWidth), -1, 1); } else { glOrtho (-1, 1, -1, 1, -1, 1); } } if (Keep4_3Ratio && ((cvidmode == 21)||(cvidmode == 22))) { if (3*WindowWidth > 4*WindowHeight && WindowHeight) { glOrtho (- ((float) 3*WindowWidth)/((float) 4*WindowHeight), ((float) 3*WindowWidth)/((float) 4*WindowHeight), -1, 1, -1, 1); } else if (3*WindowWidth < 4*WindowHeight && WindowWidth) { glOrtho (-1, 1,- ((float) 4*WindowHeight)/((float) 3*WindowWidth), ((float) 4*WindowHeight)/((float) 3*WindowWidth), -1, 1); } else { glOrtho (-1, 1, -1, 1, -1, 1); } } glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glDisable(GL_DEPTH_TEST); glFlush(); } #endif clearwin(); } if (FirstVid == 1) { FirstVid = 0; InitSound(); InitInput(); } if (((PrevStereoSound != StereoSound) || (PrevSoundQuality != SoundQuality))) { InitSound(); }}void CheckTimers(void){ //QueryPerformanceCounter((LARGE_INTEGER*)&end2); end2 = sem_GetTicks(); while ((end2 - start2) >= update_ticks_pc2) { start2 += update_ticks_pc2; } if (T60HZEnabled) { //QueryPerformanceCounter((LARGE_INTEGER*)&end); end = sem_GetTicks(); while ((end - start) >= update_ticks_pc) { Game60hzcall(); SDL_SemPost(sem_frames); start += update_ticks_pc; } } if (T36HZEnabled) { //QueryPerformanceCounter((LARGE_INTEGER*)&end); end = sem_GetTicks(); while ((end - start) >= update_ticks_pc) { GUI36hzcall(); start += update_ticks_pc; } }}void sem_sleep(void){ end = update_ticks_pc - (sem_GetTicks() - start) - .2f; if (end>0.f) SDL_SemWaitTimeout(sem_frames, (int)end);}static SDL_Thread *sem_threadid = NULL;static int sem_threadrun;int sem_thread(void *param){ while (sem_threadrun) { if (T60HZEnabled) { SDL_SemPost(sem_frames); usleep(romispal ? 2000 : 1000); } else usleep(20000); } return(0);}void sem_sleep_rdy(void){ if (sem_frames) return; sem_frames = SDL_CreateSemaphore(0); sem_threadrun = 1; sem_threadid = SDL_CreateThread(sem_thread, 0);}void sem_sleep_die(void){ if (sem_threadid) { sem_threadrun = 0; SDL_WaitThread(sem_threadid, NULL); sem_threadid = NULL; } if (sem_frames) { SDL_DestroySemaphore(sem_frames); sem_frames = NULL; }}void UpdateVFrame(void){ //Quick fix for GUI CPU usage if (GUIOn || GUIOn2 || EMUPause) { usleep(6000); } CheckTimers(); Main_Proc(); if (sound_sdl) { SoundWrite_sdl(); }}void clearwin(){ /* If we're vid_null and we get here, there's a problem */ /* elsewhere - DDOI */ if (sdl_state == vid_none) return;#ifdef __OPENGL__ if (UseOpenGL) gl_clearwin(); else#endif sw_clearwin();}void drawscreenwin(void){#ifdef __LIBAO__ extern bool RawDumpInProgress; if (!sound_sdl && !GUIOn2 && !GUIOn && !EMUPause && !RawDumpInProgress) { SoundWrite_ao(); }#endif /* Just in case - DDOI */ if (sdl_state == vid_none) return;#ifdef __OPENGL__ if (UseOpenGL) gl_drawwin(); else#endif sw_drawwin();}void UnloadSDL(){ DeinitSound(); sem_sleep_die(); // Shutdown semaphore if (sdl_state == vid_soft) { sw_end(); }#ifdef __OPENGL__ else if (sdl_state == vid_gl) { gl_end(); }#endif if (sdl_state != vid_null) { SDL_WM_GrabInput(SDL_GRAB_OFF); // probably redundant SDL_FreeSurface(surface); } SDL_QuitSubSystem(SDL_INIT_JOYSTICK); SDL_QuitSubSystem(SDL_INIT_VIDEO); SDL_Quit();}int GetMouseX(void){ return ((int) MouseX);}int GetMouseY(void){ return ((int) MouseY);}int GetMouseMoveX(void){ // InputRead(); //SDL_GetRelativeMouseState(&MouseMove2X, NULL); SDL_GetRelativeMouseState(&MouseMove2X, &MouseMove2Y); return (MouseMove2X);}int GetMouseMoveY(void){ return (MouseMove2Y);}int GetMouseButton(void){ return ((int) MouseButton);}void SetMouseMinX(int MinX){ MouseMinX = MinX; adjustMouseXScale();}void SetMouseMaxX(int MaxX){ MouseMaxX = MaxX; adjustMouseXScale();}void SetMouseMinY(int MinY){ MouseMinY = MinY; adjustMouseYScale();}void SetMouseMaxY(int MaxY){ MouseMaxY = MaxY; adjustMouseYScale();}void SetMouseX(int X){ MouseX = X;}void SetMouseY(int Y){ MouseY = Y;}/* evul, maybe should use something other than constructor method */void __attribute__ ((stdcall, constructor)) sem_StartTicks(){ gettimeofday(&sem_start, NULL);}float sem_GetTicks(){ struct timeval now; float ticks; gettimeofday(&now, NULL); ticks=((float)(now.tv_sec-sem_start.tv_sec))*1000.f+((float)(now.tv_usec-sem_start.tv_usec))*.001f; return(ticks);}void LaunchBrowser(char *browser, char *url){ char *const arglist[] = { browser, url, 0 }; execvp(browser, arglist);}void LaunchURL(char *url){ if (safe_fork(0, 0)) //If fork failed, or we are the parent { MouseX = 0; MouseY = 0; return; } //We are now the child proccess //If any of these LaunchBrowser() calls return that means it failed and we should try the next one LaunchBrowser("mozilla", url); LaunchBrowser("mozilla-firefox", url); LaunchBrowser("firefox", url); LaunchBrowser("konqueror", url); LaunchBrowser("opera", url); LaunchBrowser("lynx", url); LaunchBrowser("links", url); _exit(0); //All browser launches failed, oh well}void ZsnesPage(){ LaunchURL("http://www.zsnes.com/");}void DocsPage(){ LaunchURL("http://zsnes-docs.sourceforge.net/");}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -