forked from cyxx/blues
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sys.h
71 lines (59 loc) · 2.03 KB
/
sys.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
#ifndef SYS_H__
#define SYS_H__
#include "intern.h"
#define INPUT_DIRECTION_LEFT (1 << 0)
#define INPUT_DIRECTION_RIGHT (1 << 1)
#define INPUT_DIRECTION_UP (1 << 2)
#define INPUT_DIRECTION_DOWN (1 << 3)
#define SYS_AUDIO_FREQ 22050
#define RENDER_SPR_GAME 0 /* player sprites */
#define RENDER_SPR_LEVEL 1 /* level sprites */
#define RENDER_SPR_FG 2 /* foreground tiles */
#define RENDER_SPR_COUNT 3
struct input_t {
uint8_t direction;
bool quit;
bool space;
bool jump;
bool digit1, digit2, digit3;
};
typedef void (*sys_audio_cb)(void *, uint8_t *data, int len);
struct sys_rect_t {
int x, y;
int w, h;
};
enum sys_transition_e {
TRANSITION_SQUARE,
TRANSITION_CURTAIN
};
struct sys_t {
struct input_t input;
void (*init)();
void (*fini)();
void (*set_screen_size)(int w, int h, const char *caption, int scale, const char *filter, bool fullscreen);
void (*set_screen_palette)(const uint8_t *colors, int offset, int count, int depth);
void (*set_palette_amiga)(const uint16_t *colors, int offset);
void (*set_copper_bars)(const uint16_t *data);
void (*set_palette_color)(int i, const uint8_t *colors);
void (*fade_in_palette)();
void (*fade_out_palette)();
void (*copy_bitmap)(const uint8_t *p, int w, int h);
void (*update_screen)();
void (*shake_screen)(int dx, int dy);
void (*transition_screen)(enum sys_transition_e type, bool open);
void (*process_events)();
void (*sleep)(int duration);
uint32_t (*get_timestamp)();
void (*start_audio)(sys_audio_cb callback, void *param);
void (*stop_audio)();
void (*lock_audio)();
void (*unlock_audio)();
void (*render_load_sprites)(int spr_type, int count, const struct sys_rect_t *r, const uint8_t *data, int w, int h, uint8_t color_key, bool update_pal);
void (*render_unload_sprites)(int spr_type);
void (*render_add_sprite)(int spr_type, int frame, int x, int y, int xflip);
void (*render_clear_sprites)();
void (*render_set_sprites_clipping_rect)(int x, int y, int w, int h);
void (*print_log)(FILE *fp, const char *s);
};
extern struct sys_t g_sys;
#endif /* SYS_H__ */