-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPCShell.cpp
313 lines (255 loc) · 5.84 KB
/
PCShell.cpp
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
#include "PCShell.h"
#include "dcshellutils.h"
#include "PCInput.h"
#include "SpideyDX.h"
#include "front.h"
#include "DXsound.h"
#include "pshell.h"
#include "PCGfx.h"
#include "shell.h"
#include <cstring>
#include "validate.h"
EXPORT Sprite2* gCursorSprite;
EXPORT i32 gShellMouseX;
EXPORT i32 gShellMouseY;
EXPORT i32 gShellMouseOffsetX;
EXPORT i32 gShellMouseOffsetY;
const i32 MOUSE_TRIGGER_COUNT = 18;
EXPORT u8 gMouseTriggerRelated[MOUSE_TRIGGER_COUNT];
const i32 ACTION_MAP_COUNT = 11;
EXPORT SActionMap gActionMaps[ACTION_MAP_COUNT];
EXPORT char gKeyNames[ACTION_MAP_COUNT][32];
EXPORT CMenu* gControllerMenu;
EXPORT CMenu* gControllerMenuTwo;
EXPORT i32 gActionMapRelated;
char* STR_KB_CONFIG = "keyboard configuration";
char* STR_JOY_CONFIG = "joystick configuration";
EXPORT i32 gShellTitleBarRelated;
// @MEDIUMTODO
u8 PCSHELL_CheckTriggers(u32,i32,i32)
{
printf("PCSHELL_CheckTriggers(uint,i32,i32)");
return (u8)0x28022025;
}
// @Ok
INLINE void PCSHELL_CoordsDCtoPC(i32* pX, i32* pY)
{
*pX = (double)*pX / 512.0 * (double)gDxResolutionX;
*pY = (double)*pY / 240.0 * (double)gDxResolutionY;
}
// @Ok
// @Matching
INLINE void PCSHELL_CoordsPCtoDC(i32* pX, i32* pY)
{
*pX = (float)(*pX * 512) / (float)gDxResolutionX;
*pY = (float)(*pY * 240) / (float)gDxResolutionY;
}
// @SMALLTODO
void PCSHELL_DoControllerConfig(bool)
{
printf("PCSHELL_DoControllerConfig(bool)");
}
// @MEDIUMTODO
void PCSHELL_DoDisplayOptions(void)
{
printf("PCSHELL_DoDisplayOptions(void)");
}
// @Ok
void PCSHELL_DrawMouseCursor(void)
{
if (!(gRenderTest & 0x10) && gCursorSprite)
{
gCursorSprite->draw(gShellMouseX, gShellMouseY, 0, 0);
}
}
// @Ok
void PCSHELL_Initialize(void)
{
if (!gCursorSprite)
{
gCursorSprite = new Sprite2("lti\\cursor.bmp", 0, 0, 0, 33);
PCINPUT_SetMouseHotspot(15, 15);
PCINPUT_SetMouseBounds(0, 0, gDxResolutionX - 32, gDxResolutionY - 32);
PCINPUT_SetMousePosition((gDxResolutionX - 32) >> 1, (gDxResolutionY - 32) >> 1);
}
PCINPUT_GetMousePosition(&gShellMouseX, &gShellMouseY);
PCSHELL_CoordsPCtoDC(&gShellMouseX, &gShellMouseY);
}
// @Ok
u8 PCSHELL_IsMouseOver(
i32 a1,
i32 a2,
i32 a3,
i32 a4)
{
i32 s1 = a1;
i32 s2 = a2;
i32 s3 = a3;
i32 s4 = a4;
if (gRenderTest & 0x10)
return 0;
PCSHELL_CoordsDCtoPC(&s1, &s2);
PCSHELL_CoordsDCtoPC(&s3, &s4);
return PCINPUT_IsMouseOver(s1, s2, s3, s4);
}
// @SMALLTODO
void PCSHELL_IsMouseOverText(char const *,i32,i32,i32)
{
printf("PCSHELL_IsMouseOverText(char const *,i32,i32,i32)");
}
// @Ok
// @Matching
i32 PCSHELL_MouseMoved(void)
{
return gShellMouseOffsetX || gShellMouseOffsetY;
}
// @Ok
// @Matching
void PCSHELL_Relax(void)
{
WinYield();
Sleep(10);
}
// @Ok
// @Matching
void PCSHELL_Shutdown(void)
{
if (gCursorSprite)
{
delete gCursorSprite;
gCursorSprite = 0;
}
}
// @Ok
u8 PCSHELL_UpdateMouse(void)
{
for (i32 i = 0;
i < MOUSE_TRIGGER_COUNT;
i++)
{
gMouseTriggerRelated[i] = 0;
}
if (!(gRenderTest & 0x10))
{
if (PCINPUT_UpdateMouse())
{
i32 oldMouseX = gShellMouseX;
i32 oldMouseY = gShellMouseY;
PCINPUT_GetMousePosition(&gShellMouseX, &gShellMouseY);
PCSHELL_CoordsPCtoDC(&gShellMouseX, &gShellMouseY);
gShellMouseOffsetX = gShellMouseX - oldMouseX;
gShellMouseOffsetY = gShellMouseY - oldMouseY;
return 1;
}
else
{
gShellMouseOffsetX = 0;
gShellMouseOffsetY = 0;
}
}
return 0;
}
// @IGNORE
void shell_optimized_func(i32, i32, i32)
{
printf("void shell_optimized_func(i32, i32, i32)");
}
// @Ok
void displayControllerScreen(void)
{
if (!gSceneRelated)
PCGfx_BeginScene(1, -1);
PShell_NormalFont();
gControllerMenu->Display();
gControllerMenuTwo->Display();
shell_optimized_func(384, 222, 0);
char *configName = STR_KB_CONFIG;
if (gActionMapRelated)
configName = STR_JOY_CONFIG;
Shell_DrawTitleBar(gShellTitleBarRelated, 25, configName, 1, 0, 150, -21, 29);
Shell_DrawBackground();
PCSHELL_DrawMouseCursor();
if (gSceneRelated)
PCGfx_EndScene(1);
}
// @NotOk
// missing last addentry
void initActionMaps(void)
{
for (
i32 i = 0;
i < ACTION_MAP_COUNT;
i++)
{
SActionMap *pMap = &gActionMaps[i];
PCINPUT_GetKeyboardMappingForAction(pMap->field_0, &pMap->field_14);
PCINPUT_GetControllerMappingForAction(pMap->field_0, &pMap->field_18);
gControllerMenu->AddEntry(pMap->field_4);
if (!gActionMapRelated)
{
if (pMap->field_14 == 0x4000)
{
gControllerMenuTwo->SetNormalColor(i, 90, 20, 6);
strcpy(gKeyNames[i], "none");
}
else
{
DXINPUT_GetKeyName(pMap->field_14, gKeyNames[i]);
}
}
else
{
if (i < 4)
{
gControllerMenu->EntryEnable(i, 0);
gControllerMenuTwo->EntryEnable(i, 0);
strcpy(gKeyNames[i], pMap->field_4);
}
else
{
if (pMap->field_18 == 0x4000)
{
gControllerMenuTwo->SetNormalColor(i, 90, 20, 6);
strcpy(gKeyNames[i], "none");
}
else
{
sprintf(gKeyNames[i], "button %i", pMap->field_18);
}
}
}
gControllerMenuTwo->AddEntry(gKeyNames[i]);
}
gControllerMenu->AddEntry("restore default settings");
//@FIXME: figure out the string
//gControllerMenuTwo->AddEntry("");
}
// @MEDIUMTODO
void processControllerScreen(void)
{
printf("processControllerScreen(void)");
}
// @Ok
// @Matching
void resetActionMaps(bool a1)
{
delete gControllerMenu;
delete gControllerMenuTwo;
gControllerMenu = new CMenu(30, 60, 1u, 256, 256, 15);
gControllerMenuTwo = new CMenu(332, 60, 1u, 256, 256, 15);
initActionMaps();
gControllerMenuTwo->scrollbar_zero = 0;
gControllerMenu->scrollbar_zero = 0;
gControllerMenu->Zoom(0);
gControllerMenuTwo->Zoom(0);
gControllerMenuTwo->mLine = a1 != 0 ? 0 : 4;
gControllerMenu->mLine = gControllerMenuTwo->mLine;
}
void validate_SActionMap(void)
{
VALIDATE_SIZE(SActionMap, 0x1C);
VALIDATE(SActionMap, field_0, 0x0);
VALIDATE(SActionMap, field_4, 0x4);
VALIDATE(SActionMap, field_14, 0x14);
VALIDATE(SActionMap, field_18, 0x18);
}