📄 sdllink.c
字号:
} else { glOrtho (-1, 1, -1, 1, -1, 1); } } if (Keep4_3Ratio && (cvidmode == 21)) { 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(); gl_clearwin(); Clear2xSaIBuffer(); break;#endif default: break; } } return TRUE;}unsigned int sdl_keysym_to_pc_scancode(int sym){ switch (sym) { case SDLK_ESCAPE: return 0x01; case SDLK_1: return 0x02; case SDLK_2: return 0x03; case SDLK_3: return 0x04; case SDLK_4: return 0x05; case SDLK_5: return 0x06; case SDLK_6: return 0x07; case SDLK_7: return 0x08; case SDLK_8: return 0x09; case SDLK_9: return 0x0a; case SDLK_0: return 0x0b; case SDLK_MINUS: return 0x0c; case SDLK_EQUALS: return 0x0d; case SDLK_BACKSPACE: return 0x0e; case SDLK_TAB: return 0x0f; case SDLK_q: return 0x10; case SDLK_w: return 0x11; case SDLK_e: return 0x12; case SDLK_r: return 0x13; case SDLK_t: return 0x14; case SDLK_y: return 0x15; case SDLK_u: return 0x16; case SDLK_i: return 0x17; case SDLK_o: return 0x18; case SDLK_p: return 0x19; case SDLK_LEFTBRACKET: return 0x1a; case SDLK_RIGHTBRACKET: return 0x1b; case SDLK_RETURN: return 0x1c; case SDLK_LCTRL: return 0x1d; case SDLK_a: return 0x1e; case SDLK_s: return 0x1f; case SDLK_d: return 0x20; case SDLK_f: return 0x21; case SDLK_g: return 0x22; case SDLK_h: return 0x23; case SDLK_j: return 0x24; case SDLK_k: return 0x25; case SDLK_l: return 0x26; case SDLK_SEMICOLON: return 0x27; case SDLK_QUOTE: return 0x28; case SDLK_BACKQUOTE: case SDLK_HASH: return 0x29; case SDLK_LSHIFT: return 0x2a; case SDLK_BACKSLASH: return 0x2b; case SDLK_z: return 0x2c; case SDLK_x: return 0x2d; case SDLK_c: return 0x2e; case SDLK_v: return 0x2f; case SDLK_b: return 0x30; case SDLK_n: return 0x31; case SDLK_m: return 0x32; case SDLK_COMMA: return 0x33; case SDLK_PERIOD: return 0x34; case SDLK_SLASH: return 0x35; case SDLK_RSHIFT: return 0x36; case SDLK_KP_MULTIPLY: return 0x37; case SDLK_LALT: return 0x38; case SDLK_SPACE: return 0x39; case SDLK_CAPSLOCK: return 0x3a; case SDLK_F1: return 0x3b; case SDLK_F2: return 0x3c; case SDLK_F3: return 0x3d; case SDLK_F4: return 0x3e; case SDLK_F5: return 0x3f; case SDLK_F6: return 0x40; case SDLK_F7: return 0x41; case SDLK_F8: return 0x42; case SDLK_F9: return 0x43; case SDLK_F10: return 0x44; case SDLK_NUMLOCK: return 0x45; case SDLK_SCROLLOCK: return 0x46; case SDLK_KP7: return 0x47; case SDLK_KP8: return 0x48; case SDLK_KP9: return 0x49; case SDLK_KP_MINUS: return 0x4a; case SDLK_KP4: return 0x4b; case SDLK_KP5: return 0x4c; case SDLK_KP6: return 0x4d; case SDLK_KP_PLUS: return 0x4e; case SDLK_KP1: return 0x4f; case SDLK_KP2: return 0x50; case SDLK_KP3: return 0x51; case SDLK_KP0: return 0x52; case SDLK_KP_PERIOD: return 0x53; case SDLK_F11: return 0x57; case SDLK_F12: return 0x58; case SDLK_HOME: return 0x59; case SDLK_UP: return 0x5a; case SDLK_PAGEUP: return 0x5b; case SDLK_LEFT: return 0x5c; case SDLK_RIGHT: return 0x5e; case SDLK_END: return 0x5f; case SDLK_DOWN: return 0x60; case SDLK_PAGEDOWN: return 0x61; case SDLK_INSERT: return 0x62; case SDLK_DELETE: return 0x63; } return(0x64+sym);}void ProcessKeyBuf(int scancode){ int accept = 0; int vkeyval = 0; if (((scancode >= 'A') && (scancode <= 'Z')) || ((scancode >= 'a') && (scancode <= 'z')) || (scancode == SDLK_ESCAPE) || (scancode == SDLK_SPACE) || (scancode == SDLK_BACKSPACE) || (scancode == SDLK_RETURN) || (scancode == SDLK_TAB)) { accept = 1; vkeyval = scancode; } if ((scancode >= '0') && (scancode <= '9')) { accept = 1; vkeyval = scancode; if (shiftptr) { switch (scancode) { case '1': vkeyval = '!'; break; case '2': vkeyval = '@'; break; case '3': vkeyval = '#'; break; case '4': vkeyval = '$'; break; case '5': vkeyval = '%'; break; case '6': vkeyval = '^'; break; case '7': vkeyval = '&'; break; case '8': vkeyval = '*'; break; case '9': vkeyval = '('; break; case '0': vkeyval = ')'; break; } } } if ((scancode >= SDLK_KP0) && (scancode <= SDLK_KP9)) { if (numlockptr) { accept = 1; vkeyval = scancode - SDLK_KP0 + '0'; } else { switch (scancode) { case SDLK_KP9: vkeyval = 256 + 73; accept = 1; break; case SDLK_KP8: vkeyval = 256 + 72; accept = 1; break; case SDLK_KP7: vkeyval = 256 + 71; accept = 1; break; case SDLK_KP6: vkeyval = 256 + 77; accept = 1; break; case SDLK_KP5: vkeyval = 256 + 76; accept = 1; break; case SDLK_KP4: vkeyval = 256 + 75; accept = 1; break; case SDLK_KP3: vkeyval = 256 + 81; accept = 1; break; case SDLK_KP2: vkeyval = 256 + 80; accept = 1; break; case SDLK_KP1: vkeyval = 256 + 79; accept = 1; break; } } // end no-numlock } // end testing of keypad if (!shiftptr) { switch (scancode) { case SDLK_MINUS: vkeyval = '-'; accept = 1; break; case SDLK_EQUALS: vkeyval = '='; accept = 1; break; case SDLK_LEFTBRACKET: vkeyval = '['; accept = 1; break; case SDLK_RIGHTBRACKET: vkeyval = ']'; accept = 1; break; case SDLK_SEMICOLON: vkeyval = ';'; accept = 1; break; case SDLK_COMMA: vkeyval = ','; accept = 1; break; case SDLK_PERIOD: vkeyval = '.'; accept = 1; break; case SDLK_SLASH: vkeyval = '/'; accept = 1; break; case SDLK_QUOTE: vkeyval = '`'; accept = 1; break; } } else { switch (scancode) { case SDLK_MINUS: vkeyval = '_'; accept = 1; break; case SDLK_EQUALS: vkeyval = '+'; accept = 1; break; case SDLK_LEFTBRACKET: vkeyval = '{'; accept = 1; break; case SDLK_RIGHTBRACKET: vkeyval = '}'; accept = 1; break; case SDLK_SEMICOLON: vkeyval = ':'; accept = 1; break; case SDLK_QUOTE: vkeyval = '"'; accept = 1; break; case SDLK_COMMA: vkeyval = '<'; accept = 1; break; case SDLK_PERIOD: vkeyval = '>'; accept = 1; break; case SDLK_SLASH: vkeyval = '?'; accept = 1; break; case SDLK_BACKQUOTE: vkeyval = '~'; accept = 1; break; case SDLK_BACKSLASH: vkeyval = '|'; accept = 1; break; } } switch (scancode) { case SDLK_PAGEUP: vkeyval = 256 + 73; accept = 1; break; case SDLK_UP: vkeyval = 256 + 72; accept = 1; break; case SDLK_HOME: vkeyval = 256 + 71; accept = 1; break; case SDLK_RIGHT: vkeyval = 256 + 77; accept = 1; break; case SDLK_LEFT: vkeyval = 256 + 75; accept = 1; break; case SDLK_PAGEDOWN: vkeyval = 256 + 81; accept = 1; break; case SDLK_DOWN: vkeyval = 256 + 80; accept = 1; break; case SDLK_END: vkeyval = 256 + 79; accept = 1; break; case SDLK_KP_PLUS: vkeyval = '+'; accept = 1; break; case SDLK_KP_MINUS: vkeyval = '-'; accept = 1; break; case SDLK_KP_MULTIPLY: vkeyval = '*'; accept = 1; break; case SDLK_KP_DIVIDE: vkeyval = '/'; accept = 1; break; case SDLK_KP_PERIOD: vkeyval = '.'; accept = 1; break; } if (accept) { KeyBuffer[CurKeyPos] = vkeyval; CurKeyPos++; if (CurKeyPos == 16) CurKeyPos = 0; }}BOOL InitJoystickInput(void){ int i, max_num_joysticks; int num_axes, num_buttons, num_hats, num_balls; int next_offset = 256; for (i = 0; i < 5; i++) JoystickInput[i] = NULL; // If it is possible to use SDL_NumJoysticks // before initialising SDL_INIT_JOYSTICK then // this call can be replaced with SDL_InitSubSystem SDL_InitSubSystem (SDL_INIT_JOYSTICK); max_num_joysticks = SDL_NumJoysticks(); if (!max_num_joysticks) { printf("ZSNES could not find any joysticks.\n"); SDL_QuitSubSystem(SDL_INIT_JOYSTICK); return FALSE; } SDL_JoystickEventState(SDL_ENABLE); if (max_num_joysticks > 5) max_num_joysticks = 5; for (i = 0; i < max_num_joysticks; i++) { JoystickInput[i] = SDL_JoystickOpen(i); num_axes = SDL_JoystickNumAxes(JoystickInput[i]); num_buttons = SDL_JoystickNumButtons(JoystickInput[i]); num_hats = SDL_JoystickNumHats(JoystickInput[i]); num_balls = SDL_JoystickNumBalls(JoystickInput[i]); printf("Device %i %s\n", i, SDL_JoystickName(i)); printf(" %i axis, %i buttons, %i hats, %i balls\n", num_axes, num_buttons, num_hats, num_balls); if (next_offset >= 448) { printf("Warning: Joystick won't work.\n"); continue; } AxisOffset[i] = next_offset; ButtonOffset[i] = AxisOffset[i] + num_axes * 2; HatOffset[i] = ButtonOffset[i] + num_buttons; BallOffset[i] = HatOffset[i] + num_hats * 4; next_offset = BallOffset[i] + num_balls * 4; if (next_offset > (256 + 128 + 64)) { printf("Warning: Too many buttons, axes, hats and/or Balls!\n"); printf("Warning: Joystick won't work fully.\n"); } } return TRUE;}BOOL InitInput(){ InitJoystickInput(); return TRUE;}int startgame(){ static bool ranonce = false; int status; if (!ranonce) { ranonce = true; // Start semaphore code so ZSNES multitasks nicely :) sem_sleep_rdy(); } if (sdl_state != vid_null) { if (SDL_Init(SDL_INIT_AUDIO | SDL_INIT_TIMER | SDL_INIT_VIDEO) < 0) { fprintf(stderr, "Could not initialize SDL: %s", SDL_GetError()); return FALSE; } sdl_state = vid_none; } if (sdl_state == vid_soft) { sw_end(); }#ifdef __OPENGL__ else if (sdl_state == vid_gl) { gl_end(); } SDL_Init(SDL_INIT_VIDEO); if (UseOpenGL) { status = gl_start(WindowWidth, WindowHeight, BitDepth, FullScreen); } else#endif { status = sw_start(WindowWidth, WindowHeight, BitDepth, FullScreen); } if (!status) return FALSE; sdl_state = (UseOpenGL ? vid_gl : vid_soft); return TRUE;}void Start60HZ(void){ update_ticks_pc2 = UPDATE_TICKS_UDP; if (romispal == 1) { update_ticks_pc = UPDATE_TICKS_GAMEPAL; } else { update_ticks_pc = UPDATE_TICKS_GAME; } // Restore timer data from semaphore data start = sem_GetTicks(); start2 = sem_GetTicks(); T36HZEnabled = 0; T60HZEnabled = 1;}void Stop60HZ(void){ T60HZEnabled = 0;}void Start36HZ(void){ update_ticks_pc2 = UPDATE_TICKS_UDP; update_ticks_pc = UPDATE_TICKS_GUI; // Restore timer data from semaphore data start = sem_GetTicks(); start2 = sem_GetTicks(); T60HZEnabled = 0; T36HZEnabled = 1;}void Stop36HZ(void){ T36HZEnabled = 0;}void init_hqNx(void){ DWORD color32; DWORD *p; int i, j, k, r, g, b, Y, u, v; for(i = 0, p = BitConv32Ptr; i < 65536; i++, p++) { color32=((i&0xF800)<<8)+ ((i&0x07E0)<<5)+ ((i&0x001F)<<3)+0xFF000000; *p = color32; } for (i=0; i<32; i++) for (j=0; j<64; j++) for (k=0; k<32; k++) { r = i << 3; g = j << 2; b = k << 3; Y = (r + g + b) >> 2; u = 128 + ((r - b) >> 2); v = 128 + ((-r + 2*g -b)>>3); RGBtoYUVPtr[(i << 11) + (j << 5) + k] = (Y<<16) + (u<<8) + v; }}unsigned char prevNTSCMode = 0;unsigned char changeRes = 1;unsigned char prevKeep4_3Ratio = 0;bool OGLModeCheck(){ return(cvidmode > 4);}void initwinvideo(void){ DWORD newmode = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -