This reverts commit a967525cafbe17b2f64cc427ed588228098745dc.
... | ... |
@@ -44,6 +44,12 @@ static Device *devsystem, *devscreen, *devmouse, *devctrl, *devaudio0, *devconso |
44 | 44 |
static Uint8 zoom = 1; |
45 | 45 |
static Uint32 *ppu_screen, stdin_event, audio0_event; |
46 | 46 |
|
47 |
+static int |
|
48 |
+clamp(int val, int min, int max) |
|
49 |
+{ |
|
50 |
+ return (val >= min) ? (val <= max) ? val : max : min; |
|
51 |
+} |
|
52 |
+ |
|
47 | 53 |
static int |
48 | 54 |
error(char *msg, const char *err) |
49 | 55 |
{ |
... | ... |
@@ -98,7 +104,7 @@ set_window_size(SDL_Window *window, int w, int h) |
98 | 104 |
static void |
99 | 105 |
set_zoom(Uint8 scale) |
100 | 106 |
{ |
101 |
- zoom = SDL_clamp(scale, 1, 3); |
|
107 |
+ zoom = clamp(scale, 1, 3); |
|
102 | 108 |
set_window_size(gWindow, (ppu.width + PAD * 2) * zoom, (ppu.height + PAD * 2) * zoom); |
103 | 109 |
} |
104 | 110 |
|
... | ... |
@@ -194,8 +200,8 @@ static void |
194 | 200 |
domouse(SDL_Event *event) |
195 | 201 |
{ |
196 | 202 |
Uint8 flag = 0x00; |
197 |
- Uint16 x = SDL_clamp(event->motion.x - PAD, 0, ppu.width - 1); |
|
198 |
- Uint16 y = SDL_clamp(event->motion.y - PAD, 0, ppu.height - 1); |
|
203 |
+ Uint16 x = clamp(event->motion.x - PAD, 0, ppu.width - 1); |
|
204 |
+ Uint16 y = clamp(event->motion.y - PAD, 0, ppu.height - 1); |
|
199 | 205 |
if(event->type == SDL_MOUSEWHEEL) { |
200 | 206 |
devmouse->dat[7] = event->wheel.y; |
201 | 207 |
return; |
... | ... |
@@ -532,7 +538,7 @@ run(Uxn *u) |
532 | 538 |
redraw(u); |
533 | 539 |
if(!BENCH) { |
534 | 540 |
elapsed = (SDL_GetPerformanceCounter() - begin) / (double)SDL_GetPerformanceFrequency() * 1000.0f; |
535 |
- SDL_Delay(SDL_clamp(16.666f - elapsed, 0, 1000)); |
|
541 |
+ SDL_Delay(clamp(16.666f - elapsed, 0, 1000)); |
|
536 | 542 |
} |
537 | 543 |
} |
538 | 544 |
return error("Run", "Ended."); |