-
Notifications
You must be signed in to change notification settings - Fork 20
/
spec.h
170 lines (125 loc) · 3.12 KB
/
spec.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#ifndef SPEC_H
#define SPEC_H
void DBG(const char* str);
struct MODAL
{
virtual ~MODAL() {}
virtual int Run() = 0;
};
extern MODAL* modal;
int terminal_init(int argc, char* argv[], int* dw, int* dh);
void terminal_done();
void terminal_loop();
struct CON_OUTPUT
{
int w,h;
char* buf;
char* color;
void* arr;
};
void free_con_output(CON_OUTPUT* screen);
void resize_con_output(CON_OUTPUT* s, int _w, int _h, char t); // not specialized!
void get_terminal_wh(int* dw, int* dh);
int screen_write(CON_OUTPUT* screen, int dw, int dh, int sx, int sy, int sw, int sh);
#define CON_INPUT_KBD 0x0001
#define CON_INPUT_FOC 0x0002
#define CON_INPUT_UNK 0xFFFF
#define CON_INPUT_TCH_BEGIN 0x0003
#define CON_INPUT_TCH_MOVE 0x0004
#define CON_INPUT_TCH_END 0x0005
// non-ascii key mappings
// BUT: bkspc=8, tab=9, esc=27, enter=13
#define KBD_LT 1
#define KBD_RT 2
#define KBD_UP 3
#define KBD_DN 4
#define KBD_DEL 5
#define KBD_INS 6
#define KBD_HOM 14
#define KBD_END 15
#define KBD_PUP 16
#define KBD_PDN 17
struct CON_INPUT
{
int EventType;
union
{
struct
{
bool bKeyDown;
struct
{
char AsciiChar;
} uChar;
} KeyEvent;
struct
{
bool bSetFocus;
} FocusEvent;
struct
{
int x,y;
int id;
} TouchEvent;
} Event;
};
void vsync_wait();
void sleep_ms(int ms);
unsigned int get_time();
bool get_input_len( int* r);
bool spec_read_input( CON_INPUT* ir, int n, int* r);
bool read_input( CON_INPUT* ir, int n, int* r);
bool has_key_releases();
#ifndef WIN
#define sprintf_s(dst,size,...) sprintf(dst,__VA_ARGS__)
#define sscanf_s(src,fmt,...) sscanf(src,fmt,__VA_ARGS__)
#define _strdup(str) strdup(str)
#define strcpy_s(dst,size,src) strcpy(dst,src)
int fopen_s(FILE** f, const char* path, const char* mode);
#endif
#ifdef DOS
float sqrtf(float f);
float logf(float f);
float floorf(float f);
float sinf(float f);
float cosf(float f);
float expf(float f);
float powf(float f, float n);
#endif
#define ABS(a) ((a)<0 ? -(a):(a))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
void write_fs();
const char* conf_path();
const char* record_path();
const char* shot_path();
struct HISCORE
{
int ofs;
int siz;
int tot;
char id[16]; // returned from post
char buf[65*55]; // cols=55 (fixed), rows=65 (max)
};
// initializes asyc data exchange
void post_hiscore();
void get_hiscore(int ofs, const char* id);
// updates hiscore if got fresh data & returns true if nothing is pending
// should be called on every frame, before accessing hiscore structure
bool update_hiscore();
void app_exit();
// SOUND
void init_sound(); // impl. by spec
void pull_sound(int chn, int frq, short* buffer, int samples);
void load_player();
void set_gain(int mo3, int sfx); // impl. by spec
void lock_player();
void unlock_player();
int get_sfx_ids(unsigned int idarr[96]);
short* get_sfx_sample(unsigned int id, int* len);
// BY SPEC!
bool play_sfx(unsigned int id, void** voice, bool loop, int vol, int pan);
bool stop_sfx(int fade); // stop all sfx
bool stop_sfx(void* voice, int fade); // returns false if given voice is already stopped
bool set_sfx_params(void* voice, int vol, int pan);
#endif