-
Notifications
You must be signed in to change notification settings - Fork 1
/
drv.h
169 lines (152 loc) · 4.32 KB
/
drv.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
#include <stdint.h>
#ifndef DRV_H_SENTINEL
#define DRV_H_SENTINEL
/* convenience pseudo-functions */
#define drv_event_gettype(x) (x & 0x7F00)
#define drv_event_getval(x) (x & 0x00FF)
/* define input device types */
enum DRV_INPUT_DEVICE {
DRV_INPUT_KEYBOARD = 0x1000,
DRV_INPUT_JOYSTICK = 0x2000
};
/* define categories of input events */
enum DRV_INPUT_TYPE {
DRV_INPUT_NONE = 0x0000,
DRV_INPUT_KEYDOWN = 0x0100,
DRV_INPUT_KEYUP = 0x0200,
DRV_INPUT_JOYDOWN = 0x0300,
DRV_INPUT_JOYUP = 0x0400,
DRV_INPUT_JOYAXDOWN = 0x0500,
DRV_INPUT_JOYAXUP = 0x0600,
DRV_INPUT_QUIT = 0x0700
};
/* define input events */
enum DRV_INPUT_KEY {
DRV_INPUT_JOY_1,
DRV_INPUT_JOY_2,
DRV_INPUT_JOY_3,
DRV_INPUT_JOY_4,
DRV_INPUT_JOY_5,
DRV_INPUT_JOY_6,
DRV_INPUT_JOY_7,
DRV_INPUT_JOY_8,
DRV_INPUT_JOY_9,
DRV_INPUT_JOY_10,
DRV_INPUT_JOY_11,
DRV_INPUT_JOY_12,
DRV_INPUT_JOY_13,
DRV_INP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PUT_KEY_A,
DRV_INPUT_KEY_B,
DRV_INPUT_KEY_C,
DRV_INPUT_KEY_D,
DRV_INPUT_KEY_E,
DRV_INPUT_KEY_F,
DRV_INPUT_KEY_G,
DRV_INPUT_KEY_H,
DRV_INPUT_KEY_I,
DRV_INPUT_KEY_J,
DRV_INPUT_KEY_K,
DRV_INPUT_KEY_L,
DRV_INPUT_KEY_M,
DRV_INPUT_KEY_N,
DRV_INPUT_KEY_O,
DRV_INPUT_KEY_P,
DRV_INPUT_KEY_Q,
DRV_INPUT_KEY_R,
DRV_INPUT_KEY_S,
DRV_INPUT_KEY_T,
DRV_INPUT_KEY_U,
DRV_INPUT_KEY_V,
DRV_INPUT_KEY_W,
DRV_INPUT_KEY_X,
DRV_INPUT_KEY_Y,
DRV_INPUT_KEY_Z
};
/* initialization of the I/O subsystem. This is called by zBoy once, when the
* emulator starts. screenwidth and screenheight must contain the size of
* requested virtual screen, joyid is either the id of the joystick that have
* to be polled (0..x) or -1 if no joystick support is required. */
int drv_init(int screenwidth, int screenheight, int joyid);
/* sets the window's title to a custom string */
void drv_setwintitle(char *title);
/* returns the next input event in queue */
int drv_keypoll(void);
/* loads a palette of colors into zBoy. *palette must be an array of at least
* 256 color values written in 32bits each as RGB triplets */
int drv_loadpal(uint32_t *palette);
/* returns a monotonously increasing counter that increases by 1 every
* milisecond */
unsigned long drv_getticks(void);
/* waits for ms miliseconds */
void drv_delay(int ms);
/* draws a pixel of 'color' color at location [x,y] in zBoy's memory buffer.
* color is an index of the palette. the position [0,0] is located at the
* upper left corner of the virtual screen */
void drv_putpixel(int x, int y, int color);
/* renders the screen from the memory buffer into the actual screen */
// void drv_refreshscreen(void);
/* deinitialize the I/O subsystem. this is called just before zBoy quits */
int drv_close(void);
/* provides a directory for storing user files, guaranteed to be writeable.
* *dir must point to a valid area that will be filled with a null-terminated
* string containing the save directory. maxlen is the number of bytes
* available in *dir */
void drv_getsavedir(char *dir, int maxlen);
#endif