72 lines
1.1 KiB
C
72 lines
1.1 KiB
C
#include "util.h"
|
|
#include <gint/display.h>
|
|
#include <gint/keyboard.h>
|
|
|
|
int
|
|
sign(int x)
|
|
{
|
|
return (x > 0) - (x < 0);
|
|
}
|
|
|
|
float
|
|
absf(float x)
|
|
{
|
|
return x * (-1 + 2 * (x > 0));
|
|
}
|
|
|
|
float
|
|
minf(float x, float y)
|
|
{
|
|
return (x < y) ? (x) : (y);
|
|
}
|
|
|
|
float
|
|
maxf(float x, float y)
|
|
{
|
|
return (x > y) ? (x) : (y);
|
|
}
|
|
|
|
int
|
|
min(int x, int y)
|
|
{
|
|
return (x < y) ? (x) : (y);
|
|
}
|
|
|
|
int
|
|
max(int x, int y)
|
|
{
|
|
return (x > y) ? (x) : (y);
|
|
}
|
|
|
|
void
|
|
dputs_outline(int x, int y, int halign, int valign, const char *text)
|
|
{
|
|
int rx = 2;
|
|
while (rx-- > -1) {
|
|
int ry = 2;
|
|
while (ry-- > -1) {
|
|
dprint_opt(x + rx, y + ry, C_WHITE, C_NONE, halign,
|
|
valign, "%s", text);
|
|
}
|
|
}
|
|
dprint_opt(x, y, C_BLACK, C_NONE, halign, valign, "%s", text);
|
|
}
|
|
|
|
int
|
|
ask_confirm(char *prompt)
|
|
{
|
|
extern volatile int has_ticked;
|
|
dclear(C_BLACK);
|
|
dprint_opt(DWIDTH / 2, DHEIGHT / 2, C_WHITE, C_NONE, DTEXT_CENTER,
|
|
DTEXT_MIDDLE, "%s? EXE confirm, any other key cancel",
|
|
prompt);
|
|
dupdate();
|
|
for (;;) {
|
|
const key_event_t e = getkey();
|
|
if (e.type == KEYEV_DOWN) {
|
|
has_ticked = 0;
|
|
return e.key == KEY_EXE;
|
|
}
|
|
}
|
|
}
|