/* ================== SCR_ModalMessage Displays a text string in the center of the screen and waits for a Y or N keypress. ================== */ int SCR_ModalMessage (char *text) { scr_notifystring = text; // draw a fresh screen scr_fullupdate = 0; scr_drawdialog = true; SCR_UpdateScreen (); #if !defined (__APPLE__) && !defined (MACOSX) scr_drawdialog = false; #endif /* !__APPLE__ && !MACOSX */ S_ClearBuffer (); // so dma doesn't loop current sound do { key_count = -1; // wait for a key down and up Sys_SendKeyEvents (); } while (key_lastpress != 'y' && key_lastpress != 'n' && key_lastpress != K_ESCAPE); #if defined (__APPLE__) || defined (MACOSX) scr_drawdialog = false; #endif /* __APPLE__ || MACOSX */ scr_fullupdate = 0; SCR_UpdateScreen (); return key_lastpress == 'y'; }
/* ================== S_StopAllSounds ================== */ void S_StopAllSounds(void) { int i; if (!sound_started) return; // clear all the playsounds memset(s_playsounds, 0, sizeof(s_playsounds)); s_freeplays.next = s_freeplays.prev = &s_freeplays; s_pendingplays.next = s_pendingplays.prev = &s_pendingplays; for (i=0 ; i<MAX_PLAYSOUNDS ; i++) { s_playsounds[i].prev = &s_freeplays; s_playsounds[i].next = s_freeplays.next; s_playsounds[i].prev->next = &s_playsounds[i]; s_playsounds[i].next->prev = &s_playsounds[i]; } // clear all the channels memset(channels, 0, sizeof(channels)); #ifdef OGG_SUPPORT // Stop background track // Com_DPrintf ("S_StopAllSounds: calling S_StopBackgroundTrack\n"); // debug S_StopBackgroundTrack (); // Knightmare added #endif S_ClearBuffer (); }
// // VID_ChangeVideoMode // intended only as a callback for VID_Restart_f // static void VID_ChangeVideoMode (int newmode) { int stat, temp; if (!screen) return; temp = scr_disabled_for_loading; scr_disabled_for_loading = true; CDAudio_Pause (); MIDI_Pause (MIDI_ALWAYS_PAUSE); S_ClearBuffer (); stat = VID_SetMode (newmode, vid_curpal); if (!stat) { if (vid_modenum == newmode) Sys_Error ("Couldn't set video mode: %s", SDL_GetError()); // failed setting mode, probably due to insufficient // memory. go back to previous mode. Cvar_SetValue ("vid_mode", vid_modenum); stat = VID_SetMode (vid_modenum, vid_curpal); if (!stat) Sys_Error ("Couldn't set video mode: %s", SDL_GetError()); } CDAudio_Resume (); MIDI_Pause (MIDI_ALWAYS_RESUME); scr_disabled_for_loading = temp; }
// new proc by S.A., called by alt-return key binding. void VID_Toggle (void) { static qboolean vid_toggle_works = true; S_ClearBuffer (); if (!vid_toggle_works) goto vrestart; if (SDL_WM_ToggleFullScreen(draw_context) == 1) { Sbar_Changed (); // Sbar seems to need refreshing modestate = draw_context->flags & SDL_FULLSCREEN ? MS_FULLSCREEN : MS_WINDOWED; VID_SyncCvars(); // update mouse grab if (key_dest == key_console || key_dest == key_menu) { if (modestate == MS_WINDOWED) IN_Deactivate(true); else if (modestate == MS_FULLSCREEN) IN_Activate(); } } else { vid_toggle_works = false; Con_DPrintf ("SDL_WM_ToggleFullScreen failed, attempting VID_Restart\n"); vrestart: Cvar_SetQuick (&vid_fullscreen, draw_context-> flags & SDL_FULLSCREEN ? "0" : "1"); Cbuf_AddText ("vid_restart\n"); } }
/* ================== S_StopAllSounds ================== */ void S_StopAllSounds(void) { int i; if (!sound_started) return; // clear all the playsounds memset(s_playsounds, 0, sizeof(s_playsounds)); s_freeplays.next = s_freeplays.prev = &s_freeplays; s_pendingplays.next = s_pendingplays.prev = &s_pendingplays; for (i=0 ; i<MAX_PLAYSOUNDS ; i++) { s_playsounds[i].prev = &s_freeplays; s_playsounds[i].next = s_freeplays.next; s_playsounds[i].prev->next = &s_playsounds[i]; s_playsounds[i].next->prev = &s_playsounds[i]; } #ifdef USE_OPENAL if (alSound) ALSnd_StopAllSounds(); #endif // clear all the channels memset(channels, 0, sizeof(channels)); S_ClearBuffer (); }
/* ================== SCR_ModalMessage Displays a text string in the center of the screen and waits for a Y or N keypress. ================== */ int SCR_ModalMessage (char *text) { if (cls.state == ca_dedicated) return true; scr_notifystring = text; // draw a fresh screen scr_fullupdate = 0; scr_drawdialog = true; SCR_UpdateScreen (); scr_drawdialog = false; S_ClearBuffer (); // so dma doesn't loop current sound do { key_count = -1; // wait for a key down and up Sys_SendKeyEvents (); } while (key_lastpress != 'y' && key_lastpress != 'n' && key_lastpress != K_ESCAPE); scr_fullupdate = 0; SCR_UpdateScreen (); return key_lastpress == 'y'; }
void S_UnblockSound (void) { if (!sound_started || !snd_blocked) return; if (snd_blocked == 1) /* --snd_blocked == 0 */ { snd_blocked = 0; SNDDMA_UnblockSound(); S_ClearBuffer (); } }
void S_BlockSound (void) { /* FIXME: do we really need the blocking at the * driver level? */ if (sound_started && snd_blocked == 0) /* ++snd_blocked == 1 */ { snd_blocked = 1; S_ClearBuffer (); if (shm) SNDDMA_BlockSound(); } }
void S_StopAllSounds(qboolean clear) { int i; if (!sound_started) return; total_channels = MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS; // no statics for (i=0 ; i<MAX_CHANNELS ; i++) if (channels[i].sfx) channels[i].sfx = NULL; memset(channels, 0, MAX_CHANNELS * sizeof(channel_t)); if (clear) S_ClearBuffer (); }
/* ================== SCR_ModalMessage Displays a text string in the center of the screen and waits for a Y or N keypress. ================== */ int SCR_ModalMessage (const char *text, float timeout) //johnfitz -- timeout { double time1, time2; //johnfitz -- timeout int lastkey, lastchar; if (cls.state == ca_dedicated) return true; scr_notifystring = text; // draw a fresh screen scr_drawdialog = true; SCR_UpdateScreen (); scr_drawdialog = false; S_ClearBuffer (); // so dma doesn't loop current sound time1 = Sys_DoubleTime () + timeout; //johnfitz -- timeout time2 = 0.0f; //johnfitz -- timeout Key_BeginInputGrab (); do { Sys_SendKeyEvents (); Key_GetGrabbedInput (&lastkey, &lastchar); Sys_Sleep (16); if (timeout) time2 = Sys_DoubleTime (); //johnfitz -- zero timeout means wait forever. } while (lastchar != 'y' && lastchar != 'Y' && lastchar != 'n' && lastchar != 'N' && lastkey != K_ESCAPE && lastkey != K_ABUTTON && lastkey != K_BBUTTON && time2 <= time1); Key_EndInputGrab (); // SCR_UpdateScreen (); //johnfitz -- commented out //johnfitz -- timeout if (time2 > time1) return false; //johnfitz return (lastchar == 'y' || lastchar == 'Y' || lastkey == K_ABUTTON); }
/* ================== SCR_ModalMessage Displays a text string in the center of the screen and waits for a Y or N keypress. ================== */ int SCR_ModalMessage (const char *text, float timeout) //johnfitz -- timeout { double time1, time2; //johnfitz -- timeout if (cls.state == ca_dedicated) return true; scr_notifystring = text; // draw a fresh screen scr_drawdialog = true; SCR_UpdateScreen (); scr_drawdialog = false; S_ClearBuffer (); // so dma doesn't loop current sound time1 = Sys_DoubleTime () + timeout; //johnfitz -- timeout time2 = 0.0f; //johnfitz -- timeout do { key_count = -1; // wait for a key down and up Sys_SendKeyEvents (); Sys_Sleep(16); if (timeout) time2 = Sys_DoubleTime (); //johnfitz -- zero timeout means wait forever. } while (key_lastpress != 'y' && key_lastpress != 'n' && key_lastpress != K_ESCAPE && time2 <= time1); // make sure we don't ignore the next keypress if (key_count < 0) key_count = 0; // SCR_UpdateScreen (); //johnfitz -- commented out //johnfitz -- timeout if (time2 > time1) return false; //johnfitz return key_lastpress == 'y'; }
/* Displays a text string in the center of the screen and waits for a Y or N keypress. */ int SCR_ModalMessage (char *text, float timeout) //johnfitz -- timeout { double time1, time2; //johnfitz -- timeout if (cls.state == ca_dedicated) return true; scr_notifystring = text; // draw a fresh screen bDrawDialog = true; Video_Frame(); bDrawDialog = false; S_ClearBuffer (); // so dma doesn't loop current sound time1 = System_DoubleTime () + timeout; //johnfitz -- timeout time2 = 0.0f; //johnfitz -- timeout do { key_count = -1; // wait for a key down and up Input_Frame(); if (timeout) time2 = System_DoubleTime (); //johnfitz -- zero timeout means wait forever. } while( key_lastpress != 'y' && key_lastpress != 'n' && key_lastpress != K_ESCAPE && time2 <= time1); // SCR_UpdateScreen (); //johnfitz -- commented out //johnfitz -- timeout if (time2 > time1) return false; //johnfitz return key_lastpress == 'y'; }
void VID_ToggleFullscreen (void) { int is_fullscreen; if (!fs_toggle_works) return; if (!num_fmodes) return; if (!screen) return; S_ClearBuffer (); if ( SDL_WM_ToggleFullScreen(screen) > 0 ) { is_fullscreen = (screen->flags & SDL_FULLSCREEN) ? 1 : 0; Cvar_SetValue("vid_config_fscr", is_fullscreen); modestate = (is_fullscreen) ? MS_FULLDIB : MS_WINDOWED; if (is_fullscreen) { // activate mouse in fullscreen mode // in_sdl.c handles other non-moused cases if (menu_disabled_mouse) IN_ActivateMouse(); } else { // windowed mode: // deactivate mouse if we are in menus if (menu_disabled_mouse) IN_DeactivateMouse(); } // update the video menu option vid_menu_fs = (modestate != MS_WINDOWED); } else { fs_toggle_works = false; Con_Printf ("SDL_WM_ToggleFullScreen failed\n"); } }
void S_StopAllSounds_f() { if (!sound_started) return; // clear all the playsounds memset(s_playsounds, 0, sizeof(s_playsounds)); s_freeplays.next = s_freeplays.prev = &s_freeplays; s_pendingplays.next = s_pendingplays.prev = &s_pendingplays; for (int i = 0; i < MAX_PLAYSOUNDS; i++) { s_playsounds[i].prev = &s_freeplays; s_playsounds[i].next = s_freeplays.next; s_playsounds[i].prev->next = &s_playsounds[i]; s_playsounds[i].next->prev = &s_playsounds[i]; } // clear all the channels memset(channels, 0, sizeof(channels)); S_ClearBuffer(); }
/* ================== SCR_ModalMessage Displays a text string in the center of the screen and waits for a Y or N keypress. ================== */ int SCR_ModalMessage (char *text) { if (cls.state == ca_dedicated) return true; scr_notifystring = text; // draw a fresh screen scr_fullupdate = 0; scr_drawdialog = true; SCR_UpdateScreen (); scr_drawdialog = false; S_ClearBuffer (); // so dma doesn't loop current sound // Wait for keys to be released. while (keydown['y'] || keydown['n'] || keydown[K_JOY1] || keydown[K_JOY2]) { key_count = INT_MIN; Sys_SendKeyEvents(); IN_Commands(); } // Wait for keys to be pressed. while (!keydown['y'] && !keydown['n'] && !keydown[K_JOY1] && !keydown[K_JOY2]) { key_count = INT_MIN; Sys_SendKeyEvents(); IN_Commands(); } key_count = 0; scr_fullupdate = 0; SCR_UpdateScreen (); return (key_lastpress == 'y') || (key_lastpress == K_JOY1); }
/* ==================== PR_ExecuteProgram ==================== */ void PR_ExecuteProgram (func_t fnum) { eval_t *a, *b, *c; int s; dstatement_t *st; dfunction_t *f, *newf; int runaway; int i; edict_t *ed; int exitdepth; eval_t *ptr; // 2001-09-14 Enhanced BuiltIn Function System (EBFS) by Maddes start char *funcname; char *remaphint; // 2001-09-14 Enhanced BuiltIn Function System (EBFS) by Maddes end if (!fnum || fnum >= progs->numfunctions) { if (pr_global_struct->self) ED_Print (PROG_TO_EDICT(pr_global_struct->self)); Host_Error ("PR_ExecuteProgram: NULL function"); } f = &pr_functions[fnum]; runaway = RUNAWAY; //was 100000; pr_trace = false; // make a stack frame exitdepth = pr_depth; s = PR_EnterFunction (f); while (1) { s++; // next statement pr_xstatement = s; pr_xfunction->profile++; st = &pr_statements[s]; a = (eval_t *)&pr_globals[st->a]; b = (eval_t *)&pr_globals[st->b]; c = (eval_t *)&pr_globals[st->c]; if (!--runaway) PR_RunError ("runaway loop error"); if (runaway < RUNAWAY - RUNAWAY_STEP + 1 && runaway % RUNAWAY_STEP == 0) { Con_Printf ("PR_ExecuteProgram: runaway loop %d\n", runaway / RUNAWAY_STEP); SCR_UpdateScreen (); // Force screen update S_ClearBuffer (); // Avoid looping sounds } if (pr_trace) PR_PrintStatement (st); switch (st->op) { case OP_ADD_F: c->_float = a->_float + b->_float; break; case OP_ADD_V: c->vector[0] = a->vector[0] + b->vector[0]; c->vector[1] = a->vector[1] + b->vector[1]; c->vector[2] = a->vector[2] + b->vector[2]; break; case OP_SUB_F: c->_float = a->_float - b->_float; break; case OP_SUB_V: c->vector[0] = a->vector[0] - b->vector[0]; c->vector[1] = a->vector[1] - b->vector[1]; c->vector[2] = a->vector[2] - b->vector[2]; break; case OP_MUL_F: c->_float = a->_float * b->_float; break; case OP_MUL_V: c->_float = a->vector[0]*b->vector[0] + a->vector[1]*b->vector[1] + a->vector[2]*b->vector[2]; break; case OP_MUL_FV: c->vector[0] = a->_float * b->vector[0]; c->vector[1] = a->_float * b->vector[1]; c->vector[2] = a->_float * b->vector[2]; break; case OP_MUL_VF: c->vector[0] = b->_float * a->vector[0]; c->vector[1] = b->_float * a->vector[1]; c->vector[2] = b->_float * a->vector[2]; break; case OP_DIV_F: c->_float = a->_float / b->_float; break; case OP_BITAND: c->_float = (int)a->_float & (int)b->_float; break; case OP_BITOR: c->_float = (int)a->_float | (int)b->_float; break; case OP_GE: c->_float = a->_float >= b->_float; break; case OP_LE: c->_float = a->_float <= b->_float; break; case OP_GT: c->_float = a->_float > b->_float; break; case OP_LT: c->_float = a->_float < b->_float; break; case OP_AND: c->_float = a->_float && b->_float; break; case OP_OR: c->_float = a->_float || b->_float; break; case OP_NOT_F: c->_float = !a->_float; break; case OP_NOT_V: c->_float = !a->vector[0] && !a->vector[1] && !a->vector[2]; break; case OP_NOT_S: c->_float = !a->string || !pr_strings[a->string]; break; case OP_NOT_FNC: c->_float = !a->function; break; case OP_NOT_ENT: c->_float = (PROG_TO_EDICT(a->edict) == sv.edicts); break; case OP_EQ_F: c->_float = a->_float == b->_float; break; case OP_EQ_V: c->_float = (a->vector[0] == b->vector[0]) && (a->vector[1] == b->vector[1]) && (a->vector[2] == b->vector[2]); break; case OP_EQ_S: c->_float = !strcmp(pr_strings+a->string,pr_strings+b->string); break; case OP_EQ_E: c->_float = a->_int == b->_int; break; case OP_EQ_FNC: c->_float = a->function == b->function; break; case OP_NE_F: c->_float = a->_float != b->_float; break; case OP_NE_V: c->_float = (a->vector[0] != b->vector[0]) || (a->vector[1] != b->vector[1]) || (a->vector[2] != b->vector[2]); break; case OP_NE_S: c->_float = strcmp(pr_strings+a->string,pr_strings+b->string); break; case OP_NE_E: c->_float = a->_int != b->_int; break; case OP_NE_FNC: c->_float = a->function != b->function; break; //================== case OP_STORE_F: case OP_STORE_ENT: case OP_STORE_FLD: // integers case OP_STORE_S: case OP_STORE_FNC: // pointers b->_int = a->_int; break; case OP_STORE_V: b->vector[0] = a->vector[0]; b->vector[1] = a->vector[1]; b->vector[2] = a->vector[2]; break; case OP_STOREP_F: case OP_STOREP_ENT: case OP_STOREP_FLD: // integers case OP_STOREP_S: case OP_STOREP_FNC: // pointers ptr = (eval_t *)((byte *)sv.edicts + b->_int); ptr->_int = a->_int; break; case OP_STOREP_V: ptr = (eval_t *)((byte *)sv.edicts + b->_int); ptr->vector[0] = a->vector[0]; ptr->vector[1] = a->vector[1]; ptr->vector[2] = a->vector[2]; break; case OP_ADDRESS: ed = PROG_TO_EDICT(a->edict); #ifdef PARANOID NUM_FOR_EDICT(ed); // make sure it's in range #endif if (ed == (edict_t *)sv.edicts && sv.state == ss_active) PR_RunError ("assignment to world entity"); c->_int = (byte *)((int *)&ed->v + b->_int) - (byte *)sv.edicts; break; case OP_LOAD_F: case OP_LOAD_FLD: case OP_LOAD_ENT: case OP_LOAD_S: case OP_LOAD_FNC: ed = PROG_TO_EDICT(a->edict); #ifdef PARANOID NUM_FOR_EDICT(ed); // make sure it's in range #endif a = (eval_t *)((int *)&ed->v + b->_int); c->_int = a->_int; break; case OP_LOAD_V: ed = PROG_TO_EDICT(a->edict); #ifdef PARANOID NUM_FOR_EDICT(ed); // make sure it's in range #endif a = (eval_t *)((int *)&ed->v + b->_int); c->vector[0] = a->vector[0]; c->vector[1] = a->vector[1]; c->vector[2] = a->vector[2]; break; //================== case OP_IFNOT: if (!a->_int) s += st->b - 1; // offset the s++ break; case OP_IF: if (a->_int) s += st->b - 1; // offset the s++ break; case OP_GOTO: s += st->a - 1; // offset the s++ break; case OP_CALL0: case OP_CALL1: case OP_CALL2: case OP_CALL3: case OP_CALL4: case OP_CALL5: case OP_CALL6: case OP_CALL7: case OP_CALL8: pr_argc = st->op - OP_CALL0; if (!a->function) PR_RunError ("NULL function"); newf = &pr_functions[a->function]; if (newf->first_statement < 0) { // negative statements are built in functions i = -newf->first_statement; // 2001-09-14 Enhanced BuiltIn Function System (EBFS) by Maddes start if ( (i >= pr_numbuiltins)||(pr_builtins[i] == pr_ebfs_builtins[0].function) ) { funcname = pr_strings + newf->s_name; if (pr_builtin_remap.value) { remaphint = NULL; } else { remaphint = "Try \"builtin remapping\" by setting PR_BUILTIN_REMAP to 1\n"; } PR_RunError ("Bad builtin call number %i for %s\n", i, funcname, remaphint); } // 2001-09-14 Enhanced BuiltIn Function System (EBFS) by Maddes end pr_builtins[i] (); break; } s = PR_EnterFunction (newf); break; case OP_DONE: case OP_RETURN: pr_globals[OFS_RETURN] = pr_globals[st->a]; pr_globals[OFS_RETURN+1] = pr_globals[st->a+1]; pr_globals[OFS_RETURN+2] = pr_globals[st->a+2]; s = PR_LeaveFunction (); if (pr_depth == exitdepth) return; // all done break; case OP_STATE: ed = PROG_TO_EDICT(pr_global_struct->self); #ifdef FPS_20 ed->v.nextthink = pr_global_struct->time + 0.05; #else ed->v.nextthink = pr_global_struct->time + 0.1; #endif if (a->_float != ed->v.frame) { ed->v.frame = a->_float; } ed->v.think = b->function; break; default: PR_RunError ("Bad opcode %i", st->op); } } }
/* =========== IN_ProcessEvents =========== */ void IN_ProcessEvents (void) { // handle the mouse state when windowed if that's changed if (!vidmode_fullscreen) { if ( key_dest == key_game && !mouse_grab_active && vid_activewindow ) // if ( key_dest != key_console && !mouse_grab_active && vid_activewindow ) { IN_GrabMouse (); } else if ( key_dest != key_game && mouse_grab_active ) // else if ( key_dest == key_console && mouse_grab_active ) { IN_UngrabMouse (); } } // getting and handle events { XEvent x_event; static qboolean active = true; if (!x_disp) return; while (XPending(x_disp)) { XNextEvent(x_disp, &x_event); switch (x_event.type) { case KeyPress: // key pressed case KeyRelease: // key released Key_Event(XLateKey(&x_event.xkey), x_event.type == KeyPress); break; case MotionNotify: // mouse moved if (mouse_grab_active) { if (dga_mouse_active) { mouse_x += (float)x_event.xmotion.x_root; mouse_y += (float)x_event.xmotion.y_root; } else { mouse_x = (float)x_event.xmotion.x - (float)(vid.width / 2); mouse_y = (float)x_event.xmotion.y - (float)(vid.height / 2); if (mouse_x || mouse_y) // do warp { // move the mouse to the window center again XWarpPointer(x_disp, None, x_win, 0, 0, 0, 0, vid.width / 2, vid.height / 2); } } } break; case ButtonPress: // mouse button pressed case ButtonRelease: // mouse button released switch (x_event.xbutton.button) { case 1: Key_Event (K_MOUSE1, x_event.type == ButtonPress); break; case 2: Key_Event (K_MOUSE3, x_event.type == ButtonPress); break; case 3: Key_Event (K_MOUSE2, x_event.type == ButtonPress); break; case 4: Key_Event (K_MWHEELUP, x_event.type == ButtonPress); break; case 5: Key_Event (K_MWHEELDOWN, x_event.type == ButtonPress); break; case 6: Key_Event (K_MOUSE4, x_event.type == ButtonPress); break; case 7: Key_Event (K_MOUSE5, x_event.type == ButtonPress); break; case 8: Key_Event (K_MOUSE6, x_event.type == ButtonPress); break; case 9: Key_Event (K_MOUSE7, x_event.type == ButtonPress); break; case 10: Key_Event (K_MOUSE8, x_event.type == ButtonPress); break; } break; case CreateNotify: // window created window_x = x_event.xcreatewindow.x; window_y = x_event.xcreatewindow.y; window_width = x_event.xcreatewindow.width; window_height = x_event.xcreatewindow.height; break; case ConfigureNotify: // window changed size/location window_x = x_event.xconfigure.x; window_y = x_event.xconfigure.y; window_width = x_event.xconfigure.width; window_height = x_event.xconfigure.height; // check for resize if (!vidmode_fullscreen) { if (window_width < 320) window_width = 320; if (window_height < 200) window_height = 200; vid.width = window_width; vid.height = window_height; vid.conwidth = vid.width; vid.conheight = vid.height; vid.recalc_refdef = true; // force a surface cache flush } break; case DestroyNotify: // window has been destroyed Sys_Quit (0); break; case ClientMessage: // window manager messages if ((x_event.xclient.format == 32) && ((unsigned int)x_event.xclient.data.l[0] == wm_delete_window_atom)) Sys_Quit (0); break; case MapNotify: // window restored case UnmapNotify: // window iconified/rolledup/whatever vid_hiddenwindow = (x_event.type == UnmapNotify); case FocusIn: // window is now the input focus case FocusOut: // window is no longer the input focus switch (x_event.xfocus.mode) { case NotifyNormal: case NotifyGrab: case NotifyUngrab: vid_activewindow = (x_event.type == FocusIn); break; } if(vidmode_fullscreen) { if(x_event.type == MapNotify) { // set our video mode XF86VidModeSwitchToMode(x_disp, scrnum, &game_vidmode); // move the viewport to top left XF86VidModeSetViewPort(x_disp, scrnum, 0, 0); } else if(x_event.type == UnmapNotify) { // set our video mode XF86VidModeSwitchToMode(x_disp, scrnum, &init_vidmode); } } else //if (!vidmode_fullscreen) { // enable/disable sound, set/restore gamma and grab/ungrab keyb // on focus gain/loss if (vid_activewindow && !vid_hiddenwindow && !active) { S_UnblockSound (); S_ClearBuffer (); VID_Gamma_Set (); IN_GrabKeyboard(); active = true; } else if (active) { S_BlockSound (); S_ClearBuffer (); VID_Gamma_Restore (); IN_UngrabKeyboard(); active = false; } } // fix the leftover Alt from any Alt-Tab or the like that switched us away Key_ClearStates (); break; case EnterNotify: // mouse entered window case LeaveNotify: // mouse left window vid_notifywindow = (x_event.type == EnterNotify); break; } } } }
/* ============ S_Update Called once each time through the main loop ============ */ void S_Update(vec3_t origin, vec3_t forward, vec3_t right, vec3_t up) { int i; int total; channel_t *ch; channel_t *combine; if (!sound_started) return; // if the laoding plaque is up, clear everything // out to make sure we aren't looping a dirty // dma buffer while loading if (cls.disable_screen) { S_ClearBuffer (); return; } // rebuild scale tables if volume is modified if (s_volume->modified) S_InitScaletable (); VectorCopy(origin, listener_origin); VectorCopy(forward, listener_forward); VectorCopy(right, listener_right); VectorCopy(up, listener_up); combine = NULL; // update spatialization for dynamic sounds ch = channels; for (i=0 ; i<MAX_CHANNELS; i++, ch++) { if (!ch->sfx) continue; if (ch->autosound) { // autosounds are regenerated fresh each frame memset (ch, 0, sizeof(*ch)); continue; } S_Spatialize(ch); // respatialize channel if (!ch->leftvol && !ch->rightvol) { memset (ch, 0, sizeof(*ch)); continue; } } // add loopsounds S_AddLoopSounds (); // // debugging output // if (s_show->value) { total = 0; ch = channels; for (i=0 ; i<MAX_CHANNELS; i++, ch++) if (ch->sfx && (ch->leftvol || ch->rightvol) ) { Com_Printf ("%3i %3i %s\n", ch->leftvol, ch->rightvol, ch->sfx->name); total++; } Com_Printf ("----(%i)---- painted: %i\n", total, paintedtime); } #ifdef OGG_SUPPORT // Com_DPrintf ("S_Update: calling S_UpdateBackgroundTrack\n"); // debug S_UpdateBackgroundTrack (); // Knightmare added #endif // mix some sound S_Update_(); }