-
Notifications
You must be signed in to change notification settings - Fork 2
/
vi_comm.h
210 lines (177 loc) · 4.21 KB
/
vi_comm.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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#ifndef __VI_COMM_H__
#define __VI_COMM_H__
/* ======================================================================== */
#ifdef ENABLE_COLOR
extern byte *gfxbuf;
#else
extern byte framebuffer[];
#define gfxbuf4 framebuffer
#endif
extern const byte pal4bit[256];
#ifdef LUMINARY
#define ROMAREA __attribute__((section(".romchunk")))
/* Some compilers are lame and align byte arrays to a word boundary. */
#define NOPAD __attribute__((aligned(1)))
#else
#define ROMAREA
#define NOPAD
#endif
void VL_Startup();
void VL_Shutdown();
void VL_WaitVBL(myint vbls);
void VW_UpdateScreen();
#ifdef LUMINARY
#define VL_SetPalette(p) do {} while(0)
#else
void VL_SetPalette(const byte *palette);
void VL_GetPalette(byte *palette);
#endif
void VL_MemToScreen(const byte *source, myint width, myint height, myint x, myint y);
void VL_ScreenSaver();
/* ======================================================================== */
#define MaxPlayers 4
#define MaxJoys 2
#define NumCodes 128
typedef int8_t ScanCode;
#define sc_None 0
#define sc_Bad 0xff
#define sc_Return 0x1c
#define sc_Enter sc_Return
#define sc_Escape 0x01
#define sc_Space 0x39
#define sc_BackSpace 0x0e
#define sc_Tab 0x0f
#define sc_Alt 0x38
#define sc_Control 0x1d
#define sc_CapsLock 0x3a
#define sc_LShift 0x2a
#define sc_RShift 0x36
#define sc_UpArrow 0x48
#define sc_DownArrow 0x50
#define sc_LeftArrow 0x4b
#define sc_RightArrow 0x4d
#define sc_Home 0x47
#define sc_End 0x4f
#define sc_PgUp 0x49
#define sc_PgDn 0x51
#define sc_Insert 0x52
#define sc_Delete 0x53
#define sc_F1 0x3b
#define sc_F2 0x3c
#define sc_F3 0x3d
#define sc_F4 0x3e
#define sc_F5 0x3f
#define sc_F6 0x40
#define sc_F7 0x41
#define sc_F8 0x42
#define sc_F9 0x43
#define sc_F10 0x44
#define sc_F11 0x57
#define sc_F12 0x59
#define sc_1 0x02
#define sc_2 0x03
#define sc_3 0x04
#define sc_4 0x05
#define sc_5 0x06
#define sc_6 0x07
#define sc_7 0x08
#define sc_8 0x09
#define sc_9 0x0a
#define sc_0 0x0b
#define sc_A 0x1e
#define sc_B 0x30
#define sc_C 0x2e
#define sc_D 0x20
#define sc_E 0x12
#define sc_F 0x21
#define sc_G 0x22
#define sc_H 0x23
#define sc_I 0x17
#define sc_J 0x24
#define sc_K 0x25
#define sc_L 0x26
#define sc_M 0x32
#define sc_N 0x31
#define sc_O 0x18
#define sc_P 0x19
#define sc_Q 0x10
#define sc_R 0x13
#define sc_S 0x1f
#define sc_T 0x14
#define sc_U 0x16
#define sc_V 0x2f
#define sc_W 0x11
#define sc_X 0x2d
#define sc_Y 0x15
#define sc_Z 0x2c
#define key_None 0
typedef enum {
ctrl_Keyboard,
#ifdef ENABLE_JOYSTICK
ctrl_Joystick,
ctrl_Joystick1 = ctrl_Joystick,
ctrl_Joystick2,
#endif
#ifdef ENABLE_MOUSE
ctrl_Mouse
#endif
} PACKED ControlType;
typedef enum {
motion_Left = -1,
motion_Up = -1,
motion_None = 0,
motion_Right = 1,
motion_Down = 1
} PACKED Motion;
typedef enum {
dir_North,
dir_NorthEast,
dir_East,
dir_SouthEast,
dir_South,
dir_SouthWest,
dir_West,
dir_NorthWest,
dir_None
} PACKED Direction;
typedef struct {
boolean button0, button1, button2, button3;
myint x, y;
Motion xaxis, yaxis;
Direction dir;
} ControlInfo;
typedef struct {
ScanCode button0, button1, upleft, up, upright,
left, right, downleft, down, downright;
} KeyboardDef;
extern uint32_t Keyboard[];
extern boolean MousePresent, JoysPresent[];
extern boolean Paused;
extern char LastASCII;
extern ScanCode LastScan;
extern unsigned long LastEventTime;
extern KeyboardDef KbdDefs;
extern ControlType Controls[MaxPlayers];
#define IN_KeyDown(code) \
((Keyboard[(code >> 5)] & (1u << (code & 31))) != 0)
extern void INL_Update();
extern void IN_Startup(), IN_Shutdown(), IN_ClearKeysDown(),
IN_ReadControl(myint,ControlInfo *),
IN_GetJoyAbs(word joy,word *xp,word *yp),
IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy),
IN_Ack();
extern boolean IN_UserInput(longword delay);
extern const char *IN_GetScanName(ScanCode);
byte IN_MouseButtons();
#ifdef ENABLE_JOYSTICK
byte IN_JoyButtons();
word INL_GetJoyButtons(word joy);
#else
#define IN_JoyButtons() 0
#endif
void IN_GetMouseDelta(myint *dx, myint *dy);
void INL_GetJoyDelta(word joy,myint *dx,myint *dy);
void IN_StartAck();
boolean IN_CheckAck();
void keyboard_handler(myint code, myint press);
#endif