Revert "emu: use SDL_clamp" since that function is not available in Debian's SDL.

This reverts commit a967525caf.
This commit is contained in:
Andrew Alderwick 2021-12-26 21:13:29 +00:00
parent b7453e1206
commit d9e619d8a1
1 changed files with 10 additions and 4 deletions

View File

@ -44,6 +44,12 @@ static Device *devsystem, *devscreen, *devmouse, *devctrl, *devaudio0, *devconso
static Uint8 zoom = 1;
static Uint32 *ppu_screen, stdin_event, audio0_event;
static int
clamp(int val, int min, int max)
{
return (val >= min) ? (val <= max) ? val : max : min;
}
static int
error(char *msg, const char *err)
{
@ -98,7 +104,7 @@ set_window_size(SDL_Window *window, int w, int h)
static void
set_zoom(Uint8 scale)
{
zoom = SDL_clamp(scale, 1, 3);
zoom = clamp(scale, 1, 3);
set_window_size(gWindow, (ppu.width + PAD * 2) * zoom, (ppu.height + PAD * 2) * zoom);
}
@ -194,8 +200,8 @@ static void
domouse(SDL_Event *event)
{
Uint8 flag = 0x00;
Uint16 x = SDL_clamp(event->motion.x - PAD, 0, ppu.width - 1);
Uint16 y = SDL_clamp(event->motion.y - PAD, 0, ppu.height - 1);
Uint16 x = clamp(event->motion.x - PAD, 0, ppu.width - 1);
Uint16 y = clamp(event->motion.y - PAD, 0, ppu.height - 1);
if(event->type == SDL_MOUSEWHEEL) {
devmouse->dat[7] = event->wheel.y;
return;
@ -532,7 +538,7 @@ run(Uxn *u)
redraw(u);
if(!BENCH) {
elapsed = (SDL_GetPerformanceCounter() - begin) / (double)SDL_GetPerformanceFrequency() * 1000.0f;
SDL_Delay(SDL_clamp(16.666f - elapsed, 0, 1000));
SDL_Delay(clamp(16.666f - elapsed, 0, 1000));
}
}
return error("Run", "Ended.");