A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd
at master 159 lines 4.3 kB view raw
1// Emacs style mode select -*- C++ -*- 2//----------------------------------------------------------------------------- 3// 4// $Id$ 5// 6// Copyright (C) 1993-1996 by id Software, Inc. 7// 8// This program is free software; you can redistribute it and/or 9// modify it under the terms of the GNU General Public License 10// as published by the Free Software Foundation; either version 2 11// of the License, or (at your option) any later version. 12// 13// This program is distributed in the hope that it will be useful, 14// but WITHOUT ANY WARRANTY; without even the implied warranty of 15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16// GNU General Public License for more details. 17// 18// $Log: i_system.c,v $ 19// Revision 1.9 2006-04-15 22:08:36 kkurbjun 20// Slight code cleanups, fixed sound parameter - now it saves. Old configurations will be reset. 21// 22// Revision 1.8 2006-04-14 21:07:55 kkurbjun 23// Start of profiling support for doom. 24// 25// Revision 1.7 2006-04-04 11:16:44 dave 26// Correct the #ifdef logic for timer_unregister() and add a comment describing why we need to surround the use of the user timer with #ifdefs 27// 28// Revision 1.6 2006-04-03 17:32:46 dave 29// Clean up the (incorrect) #ifdef spaghetti for the timer. We now have a user timer on the ipods, so we use it. 30// 31// Revision 1.5 2006-04-03 17:11:42 kkurbjun 32// Finishing touches 33// 34// Revision 1.4 2006-04-03 17:00:56 dave 35// Doom can't use the user timer at the same time as using the grayscale lib. 36// 37// Revision 1.3 2006-04-02 12:45:29 amiconn 38// Use TIMER_FREQ for timers in plugins. Fixes timer speed on iPod. 39// 40// Revision 1.2 2006-04-02 01:52:44 kkurbjun 41// Update adds prboom's high resolution support, also makes the scaling for platforms w/ resolution less then 320x200 much nicer. IDoom's lookup table code has been removed. Also fixed a pallete bug. Some graphic errors are present in menu and status bar. Also updates some headers and output formatting. 42// 43// Revision 1.1 2006-03-28 15:44:01 dave 44// Patch #2969 - Doom! Currently only working on the H300. 45// 46// 47// DESCRIPTION: 48// 49//----------------------------------------------------------------------------- 50 51#include "doomdef.h" 52#include "m_misc.h" 53#include "i_video.h" 54#include "i_sound.h" 55 56#include "d_net.h" 57#include "g_game.h" 58#include "z_zone.h" 59 60#ifdef __GNUG__ 61#pragma implementation "i_system.h" 62#endif 63#include "i_system.h" 64 65#include "rockmacros.h" 66 67// 68// I_GetTime 69// returns time in 1/70th second tics 70// 71 72/* NOTE: 73 74 The user timer is used to generate a 70Hz tick for Doom. But it 75 is unavailable for the greyscale targets (it's used by the greyscale 76 lib) and is not implemented in the simulator - so we have to 77 approximate it using current_tick. 78*/ 79#if defined(HAVE_LCD_COLOR) && !defined(SIMULATOR) && !defined(RB_PROFILE) 80volatile unsigned int doomtimer=0; 81 82void doomtime(void) 83{ 84 doomtimer++; 85} 86#endif 87 88int I_GetTime (void) 89{ 90#if defined(HAVE_LCD_COLOR) && !defined(SIMULATOR) && !defined(RB_PROFILE) 91 return doomtimer; 92#else 93#if HZ==100 94 return ((7*(*rb->current_tick))/20); 95#else 96 #error FIX - I assumed HZ was 100 97#endif 98#endif 99} 100 101// 102// I_Init 103// 104 105// I was looking into this and comparing the speed versus Prboom 106// Turns out they are running the game much slower then I thought the game was 107// played. This explains why run was unusable other then through straight stretches 108// The game is much slower now (in terms of game speed). 109void I_Init (void) 110{ 111#if defined(HAVE_LCD_COLOR) && !defined(SIMULATOR) && !defined(RB_PROFILE) 112 rb->timer_register(1, NULL, TIMER_FREQ/TICRATE, doomtime IF_COP(, CPU)); 113#endif 114 I_InitSound(); 115} 116 117// 118// I_Quit 119// 120 121void I_Quit (void) 122{ 123 I_ShutdownSound(); 124 I_ShutdownMusic(); 125 I_ShutdownGraphics(); 126#if defined(HAVE_LCD_COLOR) && !defined(SIMULATOR) && !defined(RB_PROFILE) 127 rb->timer_unregister(); 128#endif 129 doomexit=1; 130} 131 132void I_WaitVBL(int count) 133{ 134 rb->sleep(count); 135} 136 137// 138// I_Error 139// 140extern boolean demorecording; 141 142void I_Error (char *error, ...) 143{ 144 char p_buf[50]; 145 va_list ap; 146 147 va_start(ap, error); 148 vsnprintf(p_buf,sizeof(p_buf), error, ap); 149 va_end(ap); 150 151 printf("%s\n",p_buf); 152 153 // Shutdown. Here might be other errors. 154 if (demorecording) 155 G_CheckDemoStatus(); 156 157 I_Quit(); 158 rb->sleep(HZ*2); 159}