CPUUpdateRenderBuffers(false);
void sdlPollEvents(){  SDL_Event event;  while(SDL_PollEvent(&event)) {    switch(event.type) {    case SDL_ACTIVEEVENT:      if(pauseWhenInactive && (event.active.state & SDL_APPINPUTFOCUS)) {        active = event.active.gain;        if(active) {          if(!paused) {            if(emulating)              soundResume();          }        } else {          wasPaused = true;          if(pauseWhenInactive) {            if(emulating)              soundPause();          }                    memset(delta,255,sizeof(delta));        }      }      break;    case SDL_MOUSEMOTION:    case SDL_MOUSEBUTTONUP:    case SDL_MOUSEBUTTONDOWN:      if(fullscreen) {        SDL_ShowCursor(SDL_ENABLE);        mouseCounter = 120;      }      break;    case SDL_JOYHATMOTION:      sdlUpdateJoyHat(event.jhat.which,                      event.jhat.hat,                      event.jhat.value);      break;    case SDL_JOYBUTTONDOWN:    case SDL_JOYBUTTONUP:      sdlUpdateJoyButton(event.jbutton.which,                         event.jbutton.button,                         event.jbutton.state == SDL_PRESSED);      break;    case SDL_JOYAXISMOTION:      sdlUpdateJoyAxis(event.jaxis.which,                       event.jaxis.axis,                       event.jaxis.value);      break;    case SDL_KEYDOWN:      sdlUpdateKey(event.key.keysym.sym, true);      break;    case SDL_KEYUP:      switch(event.key.keysym.sym) {      case SDLK_r:        if(!(event.key.keysym.mod & MOD_NOCTRL) &&           (event.key.keysym.mod & KMOD_CTRL)) {          if(emulating) {            emuReset();            systemScreenMessage("Reset");          }        }        break;      case SDLK_p:        if(!(event.key.keysym.mod & MOD_NOCTRL) &&           (event.key.keysym.mod & KMOD_CTRL)) {          paused = !paused;          SDL_PauseAudio(paused);          if(paused)            wasPaused = true;        }        break;      case SDLK_ESCAPE:        emulating = 0;        break;      case SDLK_f:        if(!(event.key.keysym.mod & MOD_NOCTRL) &&           (event.key.keysym.mod & KMOD_CTRL)) {          int flags = 0;          fullscreen = !fullscreen;          if(fullscreen)            flags |= SDL_FULLSCREEN;          SDL_SetVideoMode(destWidth, destHeight, systemColorDepth, flags);          //          if(SDL_WM_ToggleFullScreen(surface))          //            fullscreen = !fullscreen;        }        break;      case SDLK_F11:        if(dbgMain != debuggerMain) {          if(armState) {            armNextPC -= 4;            reg[15].I -= 4;          } else {            armNextPC -= 2;            reg[15].I -= 2;          }        }        debugger = true;        break;      case SDLK_F1:      case SDLK_F2:      case SDLK_F3:      case SDLK_F4:      case SDLK_F5:      case SDLK_F6:      case SDLK_F7:      case SDLK_F8:      case SDLK_F9:      case SDLK_F10:        if(!(event.key.keysym.mod & MOD_NOSHIFT) &&           (event.key.keysym.mod & KMOD_SHIFT)) {          sdlWriteState(event.key.keysym.sym-SDLK_F1);        } else if(!(event.key.keysym.mod & MOD_KEYS)) {          sdlReadState(event.key.keysym.sym-SDLK_F1);        }        break;      case SDLK_1:      case SDLK_2:      case SDLK_3:      case SDLK_4:        if(!(event.key.keysym.mod & MOD_NOALT) &&           (event.key.keysym.mod & KMOD_ALT)) {          char *disableMessages[4] =             { "autofire A disabled",              "autofire B disabled",              "autofire R disabled",              "autofire L disabled"};          char *enableMessages[4] =             { "autofire A",              "autofire B",              "autofire R",              "autofire L"};          int mask = 1 << (event.key.keysym.sym - SDLK_1);    if(event.key.keysym.sym > SDLK_2)      mask <<= 6;          if(autoFire & mask) {            autoFire &= ~mask;            systemScreenMessage(disableMessages[event.key.keysym.sym - SDLK_1]);          } else {            autoFire |= mask;            systemScreenMessage(enableMessages[event.key.keysym.sym - SDLK_1]);          }        } if(!(event.key.keysym.mod & MOD_NOCTRL) &&             (event.key.keysym.mod & KMOD_CTRL)) {          int mask = 0x0100 << (event.key.keysym.sym - SDLK_1);          layerSettings ^= mask;          layerEnable = DISPCNT & layerSettings;        }        break;      case SDLK_5:      case SDLK_6:      case SDLK_7:      case SDLK_8:        if(!(event.key.keysym.mod & MOD_NOCTRL) &&           (event.key.keysym.mod & KMOD_CTRL)) {          int mask = 0x0100 << (event.key.keysym.sym - SDLK_1);          layerSettings ^= mask;          layerEnable = DISPCNT & layerSettings;        }        break;      case SDLK_n:        if(!(event.key.keysym.mod & MOD_NOCTRL) &&           (event.key.keysym.mod & KMOD_CTRL)) {          if(paused)            paused = false;          pauseNextFrame = true;        }        break;      }      sdlUpdateKey(event.key.keysym.sym, false);      break;    }  }}