1// This file is part of SmallBASIC
2//
3// Copyright(C) 2001-2019 Chris Warren-Smith.
4//
5// This program is distributed under the terms of the GPL v2.0 or later
6// Download the GNU Public License (GPL) from www.gnu.org
7//
8
9#ifndef UTILS_H
10#define UTILS_H
11
12#ifndef MAX
13#define MAX(a,b) (((int)a<(int)b) ? (b) : (a))
14#endif
15#ifndef MIN
16#define MIN(a,b) (((int)a>(int)b) ? (b) : (a))
17#endif
18
19#define DEFAULT_FOREGROUND 0xa1a1a1
20#define DEFAULT_BACKGROUND 0x1f1c1f
21#define HANDLE_SCREEN_BUFFER HANDLE_SCREEN
22#define USER_MESSAGE_EXIT 1000
23
24#define OUTSIDE_RECT(px, py, x, y, w, h) \
25 (px < (x) || py < (y) || px > ((x)+(w)) || py > ((y)+(h)))
26
27#if defined(_ANDROID)
28 #include <android/log.h>
29 #define deviceLog(...) __android_log_print(ANDROID_LOG_INFO, \
30 "smallbasic", __VA_ARGS__)
31#elif defined(_SDL) || defined(_FLTK)
32 void appLog(const char *format, ...);
33 #define deviceLog(...) appLog(__VA_ARGS__)
34#endif
35
36#if defined(_DEBUG)
37 #define trace(...) deviceLog(__VA_ARGS__)
38#else
39 #define trace(...)
40#endif
41
42#define logEntered() trace("%s entered (%s %d)", \
43 __FUNCTION__, __FILE__, __LINE__);
44#define logLeaving() trace("%s leaving (%s %d)", \
45 __FUNCTION__, __FILE__, __LINE__);
46
47#define C_LINKAGE_BEGIN extern "C" {
48#define C_LINKAGE_END }
49
50#endif
51
52