commit 0adf593
chld
·
2026-10-27 23:25:26 +0000 UTC
parent 5c10572
remove set_*() functions causing compiler errors
1 files changed,
+9,
-157
M
uxn.c
M
uxn.c
+9,
-157
1@@ -307,7 +307,6 @@ static SDL_Surface*screen;
2 static Uint8 layers=0;
3 static Uint8 palet=7;
4 static Uint8 touch_mode=0;
5-static SDL_cond*stdin_cond;
6 static Uint8 screencompat=0x03;
7 // static int randomfd=-1;
8
9@@ -328,6 +327,7 @@ static Uint16 joy_sensitivity=8192;
10 static Uint8 debugger=0;
11 static Uint16 breakpoint=0;
12 static Uint16 break_pc=0x0100;
13+static Uint32 last_tick = 0;
14 static Uint8 debug_op=0;
15
16 static void debug(int i) {
17@@ -1306,7 +1306,14 @@ static inline int select_joystick(Uint8 n) {
18 static int run_screen(void) {
19 SDL_Event e;
20 int i,j,k;
21-
22+ last_tick = SDL_GetTicks();
23+ while (1) {
24+ /* poll timer */
25+ Uint32 now = SDL_GetTicks();
26+ if (now - last_tick >= timer_rate) {
27+ last_tick = now;
28+ if (!paused) run(GET16(device[2].d));
29+ }
30
31 while(SDL_WaitEvent(&e)) {
32 switch(e.type) {
33@@ -1418,7 +1425,6 @@ static int run_screen(void) {
34 device[1].d[7]=0;
35 }
36 run(GET16(device[1].d));
37- SDL_CondBroadcast(stdin_cond);
38 break;
39 case SDL_JOYAXISMOTION:
40 if(!joy_axis_mode) break;
41@@ -1469,160 +1475,6 @@ static int run_screen(void) {
42 return 0;
43 }
44
45-static int stdin_thread_fn(void*unused) {
46- int c;
47- SDL_Event e;
48- SDL_mutex*mut=SDL_CreateMutex();
49- SDL_LockMutex(mut);
50- e.type=SDL_USEREVENT+1;
51- e.user.data1=0;
52- while((c=fgetc(inf))>=0) {
53- e.user.code=c;
54- while(SDL_PushEvent(&e)) SDL_CondWaitTimeout(stdin_cond,mut,timer_rate?:10);
55- }
56- if(use_extension) {
57- e.user.code=0;
58- e.user.data1="";
59- while(SDL_PushEvent(&e)) SDL_CondWaitTimeout(stdin_cond,mut,timer_rate?:10);
60- }
61- return 0;
62-}
63-
64-static void set_datetime(char*s) {
65- int i=2;
66- if(*s=='@') {
67- struct tm r;
68- time_t t=strtoll(s+1,0,10);
69- if(use_utc) gmtime_r(&t,&r); else localtime_r(&t,&r);
70- PUT16(device[12].d,r.tm_year+1900);
71- device[12].d[2]=r.tm_mon;
72- device[12].d[3]=r.tm_mday;
73- device[12].d[4]=r.tm_hour;
74- device[12].d[5]=r.tm_min;
75- device[12].d[6]=r.tm_sec;
76- device[12].d[7]=r.tm_wday;
77- PUT16(device[12].d+8,r.tm_yday);
78- device[12].d[10]=r.tm_isdst;
79- } else {
80- i=strtol(s,&s,10);
81- PUT16(device[12].d,i);
82- if(*s) s++;
83- i=2;
84- while(*s && i<15) {
85- device[12].d[i++]=strtol(s,&s,10);
86- if(*s) s++;
87- }
88- }
89-}
90-
91-static void set_audio(char*s) {
92- int i;
93- audio_option=calloc(sizeof(Sint32),26);
94- if(!audio_option) err(1,"Allocation failed");
95- audio_option['b'-'a']=2048;
96- audio_option['c'-'a']=2;
97- audio_option['r'-'a']=44100;
98- audio_option['v'-'a']=273;
99- while(*s && *s!='.') {
100- if(*s<'a' && *s>'z') err(1,"Invalid audio option");
101- audio_option[*s-'a']=strtol(s+1,&s,10);
102- }
103- audiospec.freq=audio_option['r'-'a'];
104- audiospec.channels=audio_option['c'-'a'];
105- audiospec.samples=audio_option['b'-'a'];
106- audiospec.format=AUDIO_S16SYS;
107- audiospec.callback=audio_callback;
108- for(i=3;i<7;i++) {
109- device[i].aux=calloc(1,sizeof(UxnAudio));
110- if(!device[i].aux) err(1,"Allocation failed");
111- device[i].out=audio_out;
112- }
113- if(!audio_option['e'-'a']) audio_option['e'-'a']=audio_option['r'-'a']/15;
114-}
115-
116-static void set_joystick(char*s) {
117- int c,i,n;
118- SDL_Joystick*j;
119- if(*s=='?') {
120- if(SDL_Init(SDL_INIT_JOYSTICK|SDL_INIT_NOPARACHUTE)) err(1,"Cannot initialize SDL");
121- atexit(SDL_Quit);
122- if(s[1]) {
123- j=SDL_JoystickOpen(i=strtol(s+1,0,10));
124- if(!j) err(1,"Cannot open joystick");
125- printf("Opened Joystick %d\n",i);
126- printf("Name: %s\n",SDL_JoystickName(i));
127- printf("Axes: %d\n",SDL_JoystickNumAxes(j));
128- printf("Buttons: %d\n",SDL_JoystickNumButtons(j));
129- printf("Hats: %d\n",SDL_JoystickNumHats(j));
130- printf("Balls: %d\n",SDL_JoystickNumBalls(j));
131- SDL_JoystickClose(j);
132- } else {
133- n=SDL_NumJoysticks();
134- for(i=0;i<n;i++) printf("%d: %s\n",i,SDL_JoystickName(i));
135- }
136- exit(0);
137- return;
138- }
139- n=0;
140- while(*s) {
141- if(*s>='0' && *s<='9') {
142- if(n&~3) err(1,"Too many players");
143- joy_player[n]=strtol(s,&s,10);
144- joy_mask|=1<<n;
145- } else if(*s==',') {
146- s++;
147- n++;
148- } else {
149- break;
150- }
151- }
152- if(*s=='/') ++s; else err(1,"Improper joystick setting");
153- while(*s) {
154- c=*s++;
155- n=strtol(s,&s,10);
156- switch(c) {
157- case 'A': joy_button_map[n&0x7F]|=0x01; break;
158- case 'B': joy_button_map[n&0x7F]|=0x02; break;
159- case 'D': joy_button_map[n&0x7F]|=0x20; break;
160- case 'H': joy_hat=n; joy_hat_mode=6; break;
161- case 'h': joy_hat=n; joy_hat_mode=4; break;
162- case 'I': joy_hat=n; joy_hat_mode=5; break;
163- case 'i': joy_hat=n; joy_hat_mode=7; break;
164- case 'L': joy_button_map[n&0x7F]|=0x40; break;
165- case 'R': joy_button_map[n&0x7F]|=0x80; break;
166- case 'S': joy_button_map[n&0x7F]|=0x04; break;
167- case 'T': joy_button_map[n&0x7F]|=0x08; break;
168- case 'U': joy_button_map[n&0x7F]|=0x10; break;
169- case 'X': joy_axis_x=n; joy_axis_mode|=1; break;
170- case 'Y': joy_axis_y=n; joy_axis_mode|=2; break;
171- case 's': joy_sensitivity=n; break;
172- case 'x': joy_axis_x=n; joy_axis_mode|=4; break;
173- case 'y': joy_axis_y=n; joy_axis_mode|=8; break;
174- default: err(1,"Improper joystick setting");
175- }
176- }
177-}
178-
179-static void set_palette(char*s) {
180- int p=palet<<3;
181- FILE*f=fmemopen(s,strlen(s),"r");
182- if(!f) err(1,"Error with fmemopen during parsing command-line arguments");
183- while(p<64 && fscanf(f,"%2hhX%2hhX%2hhX",&colors[p].r,&colors[p].g,&colors[p].b)) {
184- p++;
185- fscanf(f,"%*[, ]");
186- }
187- fclose(f);
188-}
189-
190-static void set_full_screen_size(void) {
191- SDL_Rect**m=SDL_ListModes(0,scrflags);
192- int i;
193- if(!m || m==(SDL_Rect**)(-1) || !*m) err(1,"Cannot determine size to use for full screen mode");
194- /* default_width=m[0]->w/zoom;
195- default_height=m[0]->h/zoom;
196- */
197-}
198-
199 int main(int argc, char **argv)
200 {
201 int i;