Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Rubberduckycooly
GitHub Repository: Rubberduckycooly/RSDKv5-Decompilation
Path: blob/master/RSDKv5/RSDK/Core/Link.cpp
1163 views
1
#include "RSDK/Core/RetroEngine.hpp"
2
#include "Link.hpp"
3
4
using namespace RSDK;
5
6
void *RSDK::RSDKFunctionTable[FunctionTable_Count];
7
8
#if RETRO_REV02
9
void *RSDK::APIFunctionTable[APITable_Count];
10
11
RSDK::SKU::SKUInfo RSDK::SKU::curSKU;
12
RSDK::SKU::UnknownInfo RSDK::SKU::unknownInfo;
13
#else
14
RSDK::APITableEntry RSDK::APIFunctionTable[APITABLE_COUNT];
15
int32 RSDK::APIFunctionTableCount;
16
#endif
17
18
RSDK::GameVersionInfo RSDK::gameVerInfo;
19
20
void NullFunc() {}
21
22
#define ADD_RSDK_FUNCTION(id, func) RSDKFunctionTable[id] = (void *)func;
23
#if RETRO_REV02
24
#define ADD_API_FUNCTION(id, func) APIFunctionTable[id] = (void *)func;
25
#else
26
#define ADD_API_FUNCTION(name, func) SetAPIFunction(name, (void *)func);
27
28
void SetAPIFunction(const char *name, void *ptr)
29
{
30
if (APIFunctionTableCount < APITABLE_COUNT) {
31
RETRO_HASH_MD5(hash);
32
GEN_HASH_MD5(name, hash);
33
34
for (int32 f = 0; f < APIFunctionTableCount; ++f) {
35
if (HASH_MATCH_MD5(hash, APIFunctionTable[f].hash))
36
return; // already exists, ignore this call
37
}
38
39
HASH_COPY_MD5(APIFunctionTable[APIFunctionTableCount].hash, hash);
40
APIFunctionTable[APIFunctionTableCount].ptr = ptr;
41
APIFunctionTableCount++;
42
}
43
}
44
45
void *GetAPIFunction(const char *name)
46
{
47
if (!name)
48
return NULL;
49
50
RETRO_HASH_MD5(hash);
51
GEN_HASH_MD5(name, hash);
52
53
for (int32 f = 0; f < APIFunctionTableCount; ++f) {
54
if (HASH_MATCH_MD5(hash, APIFunctionTable[f].hash))
55
return APIFunctionTable[f].ptr;
56
}
57
58
if (engine.consoleEnabled)
59
PrintLog(PRINT_POPUP, "API Function not found: %s", name);
60
61
return NULL;
62
}
63
#endif
64
65
void RSDK::SetupFunctionTables()
66
{
67
using namespace RSDK;
68
using namespace RSDK::SKU;
69
70
#if RETRO_USE_MOD_LOADER
71
if (RSDKFunctionTable[0]) {
72
InitModAPI();
73
return;
74
}
75
#endif
76
77
CalculateTrigAngles();
78
GenerateBlendLookupTable();
79
InitSystemSurfaces();
80
81
memset(RSDKFunctionTable, 0, sizeof(RSDKFunctionTable));
82
#if RETRO_REV02
83
memset(APIFunctionTable, 0, sizeof(APIFunctionTable));
84
#endif
85
86
#if RETRO_REV02
87
88
// ============================
89
// API Function Table (Rev02)
90
// ============================
91
92
// API Core
93
ADD_API_FUNCTION(APITable_GetUserLanguage, GetUserLanguage);
94
ADD_API_FUNCTION(APITable_GetConfirmButtonFlip, GetConfirmButtonFlip);
95
ADD_API_FUNCTION(APITable_ExitGame, ExitGame);
96
ADD_API_FUNCTION(APITable_LaunchManual, LaunchManual);
97
#if RETRO_REV0U
98
ADD_API_FUNCTION(APITable_GetDefaultGamepadType, GetDefaultGamepadType);
99
#endif
100
ADD_API_FUNCTION(APITable_IsOverlayEnabled, IsOverlayEnabled);
101
ADD_API_FUNCTION(APITable_CheckDLC, CheckDLC);
102
#if RETRO_VER_EGS
103
ADD_API_FUNCTION(APITable_SetupExtensionOverlay, SetupExtensionOverlay);
104
ADD_API_FUNCTION(APITable_CanShowExtensionOverlay, CanShowExtensionOverlay);
105
#endif
106
ADD_API_FUNCTION(APITable_ShowExtensionOverlay, ShowExtensionOverlay);
107
#if RETRO_VER_EGS
108
ADD_API_FUNCTION(APITable_CanShowAltExtensionOverlay, CanShowAltExtensionOverlay);
109
ADD_API_FUNCTION(APITable_ShowAltExtensionOverlay, ShowAltExtensionOverlay);
110
ADD_API_FUNCTION(APITable_GetConnectingStringID, GetConnectingStringID);
111
ADD_API_FUNCTION(APITable_ShowLimitedVideoOptions, ShowLimitedVideoOptions);
112
#endif
113
114
// Achievements
115
ADD_API_FUNCTION(APITable_UnlockAchievement, TryUnlockAchievement);
116
ADD_API_FUNCTION(APITable_GetAchievementsEnabled, GetAchievementsEnabled);
117
ADD_API_FUNCTION(APITable_SetAchievementsEnabled, SetAchievementsEnabled);
118
#if RETRO_VER_EGS
119
ADD_API_FUNCTION(APITable_CheckAchievementsEnabled, CheckAchievementsEnabled);
120
ADD_API_FUNCTION(APITable_SetAchievementNames, SetAchievementNames);
121
#endif
122
123
// Leaderboards
124
ADD_API_FUNCTION(APITable_InitLeaderboards, InitLeaderboards);
125
#if RETRO_VER_EGS
126
ADD_API_FUNCTION(APITable_CheckLeaderboardsEnabled, CheckLeaderboardsEnabled);
127
#endif
128
ADD_API_FUNCTION(APITable_FetchLeaderboard, FetchLeaderboard);
129
ADD_API_FUNCTION(APITable_TrackScore, TrackScore);
130
ADD_API_FUNCTION(APITable_GetLeaderboardsStatus, GetLeaderboardsStatus);
131
ADD_API_FUNCTION(APITable_LeaderboardEntryViewSize, LeaderboardEntryViewSize);
132
ADD_API_FUNCTION(APITable_LeaderboardEntryLoadSize, LeaderboardEntryLoadSize);
133
ADD_API_FUNCTION(APITable_LoadLeaderboardEntries, LoadLeaderboardEntries);
134
ADD_API_FUNCTION(APITable_ResetLeaderboardInfo, ResetLeaderboardInfo);
135
ADD_API_FUNCTION(APITable_ReadLeaderboardEntry, ReadLeaderboardEntry);
136
137
// Rich Presence
138
ADD_API_FUNCTION(APITable_SetPresence, SetPresence);
139
140
// Stats
141
ADD_API_FUNCTION(APITable_TryTrackStat, TryTrackStat);
142
ADD_API_FUNCTION(APITable_GetStatsEnabled, GetStatsEnabled);
143
ADD_API_FUNCTION(APITable_SetStatsEnabled, SetStatsEnabled);
144
145
// Authorization & Storage
146
ADD_API_FUNCTION(APITable_ClearPrerollErrors, ClearPrerollErrors);
147
ADD_API_FUNCTION(APITable_TryAuth, TryAuth);
148
ADD_API_FUNCTION(APITable_GetUserAuthStatus, GetUserAuthStatus);
149
ADD_API_FUNCTION(APITable_GetUsername, GetUsername);
150
ADD_API_FUNCTION(APITable_TryInitStorage, TryInitStorage);
151
ADD_API_FUNCTION(APITable_GetUserStorageStatus, GetUserStorageStatus);
152
153
// Saving
154
ADD_API_FUNCTION(APITable_GetSaveStatus, GetSaveStatus);
155
ADD_API_FUNCTION(APITable_ClearSaveStatus, ClearSaveStatus);
156
ADD_API_FUNCTION(APITable_SetSaveStatusContinue, SetSaveStatusContinue);
157
ADD_API_FUNCTION(APITable_SetSaveStatusOK, SetSaveStatusOK);
158
ADD_API_FUNCTION(APITable_SetSaveStatusForbidden, SetSaveStatusForbidden);
159
ADD_API_FUNCTION(APITable_SetSaveStatusError, SetSaveStatusError);
160
ADD_API_FUNCTION(APITable_SetUserStorageNoSave, SetUserStorageNoSave);
161
ADD_API_FUNCTION(APITable_GetUserStorageNoSave, GetUserStorageNoSave);
162
163
// User File Management
164
ADD_API_FUNCTION(APITable_LoadUserFile, TryLoadUserFile); // load user file from game dir
165
ADD_API_FUNCTION(APITable_SaveUserFile, TrySaveUserFile); // save user file to game dir
166
ADD_API_FUNCTION(APITable_DeleteUserFile, TryDeleteUserFile); // delete user file from game dir
167
168
// User DBs
169
ADD_API_FUNCTION(APITable_InitUserDB, InitUserDB);
170
ADD_API_FUNCTION(APITable_OpenUserDB, LoadUserDB);
171
ADD_API_FUNCTION(APITable_SaveUserDB, SaveUserDB);
172
ADD_API_FUNCTION(APITable_ClearUserDB, ClearUserDB);
173
ADD_API_FUNCTION(APITable_ClearAllUserDBs, ClearAllUserDBs);
174
ADD_API_FUNCTION(APITable_SetupUserDBRowSorting, SetupUserDBRowSorting);
175
ADD_API_FUNCTION(APITable_GetUserDBRowsChanged, GetUserDBRowsChanged);
176
ADD_API_FUNCTION(APITable_AddUserDBRowSortFilter, AddUserDBRowSortFilter);
177
ADD_API_FUNCTION(APITable_SortUserDBRows, SortUserDBRows);
178
ADD_API_FUNCTION(APITable_GetSortedUserDBRowCount, GetSortedUserDBRowCount);
179
ADD_API_FUNCTION(APITable_GetSortedUserDBRowID, GetSortedUserDBRowID);
180
ADD_API_FUNCTION(APITable_AddUserDBRow, AddUserDBRow);
181
ADD_API_FUNCTION(APITable_SetUserDBValue, SetUserDBValue);
182
ADD_API_FUNCTION(APITable_GetUserDBValue, GetUserDBValue);
183
ADD_API_FUNCTION(APITable_GetRowUUID, GetDBRowUUID);
184
ADD_API_FUNCTION(APITable_GetUserDBRowByID, GetUserDBRowByID);
185
ADD_API_FUNCTION(APITable_GetUserDBRowCreationTime, GetUserDBRowCreationTime);
186
ADD_API_FUNCTION(APITable_RemoveDBRow, RemoveDBRow);
187
ADD_API_FUNCTION(APITable_RemoveAllDBRows, RemoveAllDBRows);
188
#else
189
// ============================
190
// API Functions (Rev01)
191
// ============================
192
193
// API Core
194
ADD_API_FUNCTION("GetConfirmButtonFlip", GetConfirmButtonFlip);
195
// APICallback uses the sku one anyways if this isn't set, this is only needed if it needs to interact with the backend APIs
196
// ADD_API_FUNCTION("GetUserLanguage", GetUserLanguage);
197
ADD_API_FUNCTION("GetXYButtonFlip", GetXYButtonFlip);
198
ADD_API_FUNCTION("LaunchManual", LaunchManual);
199
ADD_API_FUNCTION("ExitGame", ExitGame);
200
201
// Achievements
202
ADD_API_FUNCTION("ClearAchievements", ClearAchievements);
203
ADD_API_FUNCTION("UnlockAchievement", TryUnlockAchievement);
204
205
// Leaderboards
206
// ADD_API_FUNCTION("FetchLeaderboard", FetchLeaderboard);
207
// ADD_API_FUNCTION("LeaderboardStatus", GetLeaderboardStatus);
208
// ADD_API_FUNCTION("LeaderboardEntryCount", LeaderboardEntryCount);
209
// ADD_API_FUNCTION("LeaderboardReadEntry", LeaderboardReadEntry);
210
211
// Rich Presence
212
// ADD_API_FUNCTION("SetRichPresence", SetPresence);
213
214
// Stats
215
ADD_API_FUNCTION("TrackActClear", TrackActClear);
216
ADD_API_FUNCTION("TrackTAClear", TrackTAClear);
217
ADD_API_FUNCTION("TrackEnemyDefeat", TrackEnemyDefeat);
218
ADD_API_FUNCTION("TrackGameProgress", TrackGameProgress);
219
220
// Authorization & Storage
221
// ADD_API_FUNCTION("ClearPrerollErrors", ClearPrerollErrors); // Dummy behaviour is managed by APICallback
222
// ADD_API_FUNCTION("TryAuth", TryAuth); // Dummy behaviour is managed by APICallback
223
// ADD_API_FUNCTION("GetUserAuthStatus", GetUserAuthStatus); // Dummy behaviour is managed by APICallback
224
// ADD_API_FUNCTION("TryInitStorage", TryInitStorage); // Dummy behaviour is managed by APICallback
225
// ADD_API_FUNCTION("GetStorageStatus", GetUserStorageStatus); // Dummy behaviour is managed by APICallback
226
// ADD_API_FUNCTION("GetUsername", GetUsername); // APICallback sets the dummy one anyways if this isn't set
227
228
// User File Management
229
ADD_API_FUNCTION("LoadUserFile", TryLoadUserFile);
230
ADD_API_FUNCTION("SaveUserFile", TrySaveUserFile);
231
ADD_API_FUNCTION("SaveSettingsINI", SaveSettingsINI);
232
233
// Input
234
ADD_API_FUNCTION("ControllerIDForInputID", GetInputDeviceID);
235
ADD_API_FUNCTION("MostRecentActiveControllerID", GetFilteredInputDeviceID);
236
ADD_API_FUNCTION("AssignControllerID", AssignInputSlotToDevice);
237
ADD_API_FUNCTION("ResetControllerAssignments", ResetInputSlotAssignments);
238
ADD_API_FUNCTION("InputIDIsDisconnected", InputIDIsDisconnected);
239
ADD_API_FUNCTION("GetControllerType", GetInputDeviceType);
240
ADD_API_FUNCTION("ShowSteamControllerOverlay", ShowExtensionOverlay);
241
ADD_API_FUNCTION("SetInputLEDColor", SetInputLEDColor);
242
#endif
243
244
// ============================
245
// RSDK Function Table
246
// ============================
247
248
// Registration
249
ADD_RSDK_FUNCTION(FunctionTable_RegisterGlobalVariables, RegisterGlobalVariables);
250
ADD_RSDK_FUNCTION(FunctionTable_RegisterObject, RegisterObject);
251
#if RETRO_REV02
252
ADD_RSDK_FUNCTION(FunctionTable_RegisterStaticVariables, RegisterStaticVariables);
253
#endif
254
255
// Entities & Objects
256
ADD_RSDK_FUNCTION(FunctionTable_GetActiveEntities, GetActiveEntities);
257
ADD_RSDK_FUNCTION(FunctionTable_GetAllEntities, GetAllEntities);
258
ADD_RSDK_FUNCTION(FunctionTable_BreakForeachLoop, BreakForeachLoop);
259
ADD_RSDK_FUNCTION(FunctionTable_SetEditableVar, SetEditableVar);
260
ADD_RSDK_FUNCTION(FunctionTable_GetEntity, GetEntity);
261
ADD_RSDK_FUNCTION(FunctionTable_GetEntitySlot, GetEntitySlot);
262
ADD_RSDK_FUNCTION(FunctionTable_GetEntityCount, GetEntityCount);
263
ADD_RSDK_FUNCTION(FunctionTable_GetDrawListRefSlot, GetDrawListRefSlot);
264
ADD_RSDK_FUNCTION(FunctionTable_GetDrawListRef, GetDrawListRef);
265
ADD_RSDK_FUNCTION(FunctionTable_ResetEntity, ResetEntity);
266
ADD_RSDK_FUNCTION(FunctionTable_ResetEntitySlot, ResetEntitySlot);
267
ADD_RSDK_FUNCTION(FunctionTable_CreateEntity, CreateEntity);
268
ADD_RSDK_FUNCTION(FunctionTable_CopyEntity, CopyEntity);
269
ADD_RSDK_FUNCTION(FunctionTable_CheckOnScreen, CheckOnScreen);
270
ADD_RSDK_FUNCTION(FunctionTable_CheckPosOnScreen, CheckPosOnScreen);
271
ADD_RSDK_FUNCTION(FunctionTable_AddDrawListRef, AddDrawListRef);
272
ADD_RSDK_FUNCTION(FunctionTable_SwapDrawListEntries, SwapDrawListEntries);
273
ADD_RSDK_FUNCTION(FunctionTable_SetDrawGroupProperties, SetDrawGroupProperties);
274
275
// Scene Management
276
ADD_RSDK_FUNCTION(FunctionTable_SetScene, SetScene);
277
ADD_RSDK_FUNCTION(FunctionTable_SetEngineState, SetEngineState);
278
#if RETRO_REV02
279
ADD_RSDK_FUNCTION(FunctionTable_ForceHardReset, ForceHardReset);
280
#endif
281
ADD_RSDK_FUNCTION(FunctionTable_CheckValidScene, CheckValidScene);
282
ADD_RSDK_FUNCTION(FunctionTable_CheckSceneFolder, CheckSceneFolder);
283
ADD_RSDK_FUNCTION(FunctionTable_LoadScene, LoadScene);
284
ADD_RSDK_FUNCTION(FunctionTable_FindObject, FindObject);
285
286
// Cameras
287
ADD_RSDK_FUNCTION(FunctionTable_ClearCameras, ClearCameras);
288
ADD_RSDK_FUNCTION(FunctionTable_AddCamera, AddCamera);
289
290
// API (Rev01 only)
291
#if !RETRO_REV02
292
ADD_RSDK_FUNCTION(FunctionTable_GetAPIFunction, GetAPIFunction);
293
#endif
294
295
// Window/Video Settings
296
ADD_RSDK_FUNCTION(FunctionTable_GetVideoSetting, GetVideoSetting);
297
ADD_RSDK_FUNCTION(FunctionTable_SetVideoSetting, SetVideoSetting);
298
ADD_RSDK_FUNCTION(FunctionTable_UpdateWindow, UpdateGameWindow)
299
300
// Math
301
ADD_RSDK_FUNCTION(FunctionTable_Sin1024, Sin1024);
302
ADD_RSDK_FUNCTION(FunctionTable_Cos1024, Cos1024);
303
ADD_RSDK_FUNCTION(FunctionTable_ATan1024, Tan1024);
304
ADD_RSDK_FUNCTION(FunctionTable_ASin1024, ASin1024);
305
ADD_RSDK_FUNCTION(FunctionTable_ACos1024, ACos1024);
306
ADD_RSDK_FUNCTION(FunctionTable_Sin512, Sin512);
307
ADD_RSDK_FUNCTION(FunctionTable_Cos512, Cos512);
308
ADD_RSDK_FUNCTION(FunctionTable_ATan512, Tan512);
309
ADD_RSDK_FUNCTION(FunctionTable_ASin512, ASin512);
310
ADD_RSDK_FUNCTION(FunctionTable_ACos512, ACos512);
311
ADD_RSDK_FUNCTION(FunctionTable_Sin256, Sin256);
312
ADD_RSDK_FUNCTION(FunctionTable_Cos256, Cos256);
313
ADD_RSDK_FUNCTION(FunctionTable_ATan256, Tan256);
314
ADD_RSDK_FUNCTION(FunctionTable_ASin256, ASin256);
315
ADD_RSDK_FUNCTION(FunctionTable_ACos256, ACos256);
316
ADD_RSDK_FUNCTION(FunctionTable_Rand, Rand);
317
ADD_RSDK_FUNCTION(FunctionTable_RandSeeded, RandSeeded);
318
ADD_RSDK_FUNCTION(FunctionTable_SetRandSeed, SetRandSeed);
319
ADD_RSDK_FUNCTION(FunctionTable_ATan2, ArcTanLookup);
320
321
// Matrices
322
ADD_RSDK_FUNCTION(FunctionTable_SetIdentityMatrix, SetIdentityMatrix);
323
ADD_RSDK_FUNCTION(FunctionTable_MatrixMultiply, MatrixMultiply);
324
ADD_RSDK_FUNCTION(FunctionTable_MatrixTranslateXYZ, MatrixTranslateXYZ);
325
ADD_RSDK_FUNCTION(FunctionTable_MatrixScaleXYZ, MatrixScaleXYZ);
326
ADD_RSDK_FUNCTION(FunctionTable_MatrixRotateX, MatrixRotateX);
327
ADD_RSDK_FUNCTION(FunctionTable_MatrixRotateY, MatrixRotateY);
328
ADD_RSDK_FUNCTION(FunctionTable_MatrixRotateZ, MatrixRotateZ);
329
ADD_RSDK_FUNCTION(FunctionTable_MatrixRotateXYZ, MatrixRotateXYZ);
330
ADD_RSDK_FUNCTION(FunctionTable_MatrixInverse, MatrixInverse);
331
ADD_RSDK_FUNCTION(FunctionTable_MatrixCopy, MatrixCopy);
332
333
// Strings
334
ADD_RSDK_FUNCTION(FunctionTable_InitString, InitString);
335
ADD_RSDK_FUNCTION(FunctionTable_CopyString, CopyString);
336
ADD_RSDK_FUNCTION(FunctionTable_SetString, SetString);
337
ADD_RSDK_FUNCTION(FunctionTable_AppendString, AppendString);
338
ADD_RSDK_FUNCTION(FunctionTable_AppendText, AppendText);
339
ADD_RSDK_FUNCTION(FunctionTable_LoadStringList, LoadStringList);
340
ADD_RSDK_FUNCTION(FunctionTable_SplitStringList, SplitStringList);
341
ADD_RSDK_FUNCTION(FunctionTable_GetCString, GetCString);
342
ADD_RSDK_FUNCTION(FunctionTable_CompareStrings, CompareStrings);
343
344
// Screens & Displays
345
ADD_RSDK_FUNCTION(FunctionTable_GetDisplayInfo, GetDisplayInfo);
346
ADD_RSDK_FUNCTION(FunctionTable_GetWindowSize, GetWindowSize);
347
ADD_RSDK_FUNCTION(FunctionTable_SetScreenSize, SetScreenSize);
348
ADD_RSDK_FUNCTION(FunctionTable_SetClipBounds, SetClipBounds);
349
#if RETRO_REV02
350
ADD_RSDK_FUNCTION(FunctionTable_SetScreenVertices, SetScreenVertices);
351
#endif
352
353
// Spritesheets
354
ADD_RSDK_FUNCTION(FunctionTable_LoadSpriteSheet, LoadSpriteSheet);
355
356
// Palettes & Colors
357
#if RETRO_REV02
358
ADD_RSDK_FUNCTION(FunctionTable_SetTintLookupTable, SetTintLookupTable);
359
#else
360
// cant be bothered to change the enum name lol
361
ADD_RSDK_FUNCTION(FunctionTable_SetTintLookupTable, GetTintLookupTable);
362
#endif
363
ADD_RSDK_FUNCTION(FunctionTable_SetPaletteMask, SetPaletteMask);
364
ADD_RSDK_FUNCTION(FunctionTable_SetPaletteEntry, SetPaletteEntry);
365
ADD_RSDK_FUNCTION(FunctionTable_GetPaletteEntry, GetPaletteEntry);
366
ADD_RSDK_FUNCTION(FunctionTable_SetActivePalette, SetActivePalette);
367
ADD_RSDK_FUNCTION(FunctionTable_CopyPalette, CopyPalette);
368
#if RETRO_REV02
369
ADD_RSDK_FUNCTION(FunctionTable_LoadPalette, LoadPalette);
370
#endif
371
ADD_RSDK_FUNCTION(FunctionTable_RotatePalette, RotatePalette);
372
ADD_RSDK_FUNCTION(FunctionTable_SetLimitedFade, SetPaletteFade);
373
#if RETRO_REV02
374
ADD_RSDK_FUNCTION(FunctionTable_BlendColors, BlendColors);
375
#endif
376
377
// Drawing
378
ADD_RSDK_FUNCTION(FunctionTable_DrawRect, DrawRectangle);
379
ADD_RSDK_FUNCTION(FunctionTable_DrawLine, DrawLine);
380
ADD_RSDK_FUNCTION(FunctionTable_DrawCircle, DrawCircle);
381
ADD_RSDK_FUNCTION(FunctionTable_DrawCircleOutline, DrawCircleOutline);
382
ADD_RSDK_FUNCTION(FunctionTable_DrawFace, DrawFace);
383
ADD_RSDK_FUNCTION(FunctionTable_DrawBlendedFace, DrawBlendedFace);
384
ADD_RSDK_FUNCTION(FunctionTable_DrawSprite, DrawSprite);
385
ADD_RSDK_FUNCTION(FunctionTable_DrawDeformedSprite, DrawDeformedSprite);
386
ADD_RSDK_FUNCTION(FunctionTable_DrawString, DrawString);
387
ADD_RSDK_FUNCTION(FunctionTable_DrawTile, DrawTile);
388
ADD_RSDK_FUNCTION(FunctionTable_CopyTile, CopyTile);
389
ADD_RSDK_FUNCTION(FunctionTable_DrawAniTile, DrawAniTile);
390
#if RETRO_REV0U
391
ADD_RSDK_FUNCTION(FunctionTable_DrawDynamicAniTile, DrawDynamicAniTile);
392
#endif
393
ADD_RSDK_FUNCTION(FunctionTable_FillScreen, FillScreen);
394
395
// Meshes & 3D Scenes
396
ADD_RSDK_FUNCTION(FunctionTable_LoadMesh, LoadMesh);
397
ADD_RSDK_FUNCTION(FunctionTable_Create3DScene, Create3DScene);
398
ADD_RSDK_FUNCTION(FunctionTable_Prepare3DScene, Prepare3DScene);
399
ADD_RSDK_FUNCTION(FunctionTable_SetDiffuseColor, SetDiffuseColor);
400
ADD_RSDK_FUNCTION(FunctionTable_SetDiffuseIntensity, SetDiffuseIntensity);
401
ADD_RSDK_FUNCTION(FunctionTable_SetSpecularIntensity, SetSpecularIntensity);
402
ADD_RSDK_FUNCTION(FunctionTable_AddModelToScene, AddModelToScene);
403
ADD_RSDK_FUNCTION(FunctionTable_SetModelAnimation, SetMeshAnimation);
404
ADD_RSDK_FUNCTION(FunctionTable_AddMeshFrameToScene, AddMeshFrameToScene);
405
ADD_RSDK_FUNCTION(FunctionTable_Draw3DScene, Draw3DScene);
406
407
// Sprite Animations & Frames
408
ADD_RSDK_FUNCTION(FunctionTable_LoadSpriteAnimation, LoadSpriteAnimation);
409
ADD_RSDK_FUNCTION(FunctionTable_CreateSpriteAnimation, CreateSpriteAnimation);
410
ADD_RSDK_FUNCTION(FunctionTable_SetSpriteAnimation, SetSpriteAnimation);
411
ADD_RSDK_FUNCTION(FunctionTable_EditSpriteAnimation, EditSpriteAnimation);
412
ADD_RSDK_FUNCTION(FunctionTable_SetSpriteString, SetSpriteString);
413
ADD_RSDK_FUNCTION(FunctionTable_FindSpriteAnimation, FindSpriteAnimation);
414
ADD_RSDK_FUNCTION(FunctionTable_GetFrame, GetFrame);
415
ADD_RSDK_FUNCTION(FunctionTable_GetHitbox, GetHitbox);
416
ADD_RSDK_FUNCTION(FunctionTable_GetFrameID, GetFrameID);
417
ADD_RSDK_FUNCTION(FunctionTable_GetStringWidth, GetStringWidth);
418
ADD_RSDK_FUNCTION(FunctionTable_ProcessAnimation, ProcessAnimation);
419
420
// Tile Layers
421
ADD_RSDK_FUNCTION(FunctionTable_GetTileLayerID, GetTileLayerID);
422
ADD_RSDK_FUNCTION(FunctionTable_GetTileLayer, GetTileLayer);
423
ADD_RSDK_FUNCTION(FunctionTable_GetLayerSize, GetLayerSize);
424
ADD_RSDK_FUNCTION(FunctionTable_GetTile, GetTile);
425
ADD_RSDK_FUNCTION(FunctionTable_SetTile, SetTile);
426
ADD_RSDK_FUNCTION(FunctionTable_CopyTileLayer, CopyTileLayer);
427
ADD_RSDK_FUNCTION(FunctionTable_ProcessParallax, ProcessParallax);
428
ADD_RSDK_FUNCTION(FunctionTable_GetScanlines, GetScanlines);
429
430
// Object & Tile Collisions
431
ADD_RSDK_FUNCTION(FunctionTable_CheckObjectCollisionTouch, CheckObjectCollisionTouch);
432
ADD_RSDK_FUNCTION(FunctionTable_CheckObjectCollisionCircle, CheckObjectCollisionCircle);
433
ADD_RSDK_FUNCTION(FunctionTable_CheckObjectCollisionBox, CheckObjectCollisionBox);
434
ADD_RSDK_FUNCTION(FunctionTable_CheckObjectCollisionPlatform, CheckObjectCollisionPlatform);
435
ADD_RSDK_FUNCTION(FunctionTable_ObjectTileCollision, ObjectTileCollision);
436
ADD_RSDK_FUNCTION(FunctionTable_ObjectTileGrip, ObjectTileGrip);
437
ADD_RSDK_FUNCTION(FunctionTable_ProcessObjectMovement, ProcessObjectMovement);
438
#if RETRO_REV0U
439
ADD_RSDK_FUNCTION(FunctionTable_SetupCollisionConfig, SetupCollisionConfig);
440
ADD_RSDK_FUNCTION(FunctionTable_SetPathGripSensors, SetPathGripSensors);
441
ADD_RSDK_FUNCTION(FunctionTable_FloorCollision, FloorCollision);
442
ADD_RSDK_FUNCTION(FunctionTable_LWallCollision, LWallCollision);
443
ADD_RSDK_FUNCTION(FunctionTable_RoofCollision, RoofCollision);
444
ADD_RSDK_FUNCTION(FunctionTable_RWallCollision, RWallCollision);
445
ADD_RSDK_FUNCTION(FunctionTable_FindFloorPosition, FindFloorPosition);
446
ADD_RSDK_FUNCTION(FunctionTable_FindLWallPosition, FindLWallPosition);
447
ADD_RSDK_FUNCTION(FunctionTable_FindRoofPosition, FindRoofPosition);
448
ADD_RSDK_FUNCTION(FunctionTable_FindRWallPosition, FindRWallPosition);
449
#endif
450
ADD_RSDK_FUNCTION(FunctionTable_GetTileAngle, GetTileAngle);
451
ADD_RSDK_FUNCTION(FunctionTable_SetTileAngle, SetTileAngle);
452
ADD_RSDK_FUNCTION(FunctionTable_GetTileFlags, GetTileFlags);
453
ADD_RSDK_FUNCTION(FunctionTable_SetTileFlags, SetTileFlags);
454
#if RETRO_REV0U
455
ADD_RSDK_FUNCTION(FunctionTable_CopyCollisionMask, CopyCollisionMask);
456
ADD_RSDK_FUNCTION(FunctionTable_GetCollisionInfo, GetCollisionInfo);
457
#endif
458
459
// Audio
460
ADD_RSDK_FUNCTION(FunctionTable_GetSfx, GetSfx);
461
ADD_RSDK_FUNCTION(FunctionTable_PlaySfx, PlaySfx);
462
ADD_RSDK_FUNCTION(FunctionTable_StopSfx, StopSfx);
463
ADD_RSDK_FUNCTION(FunctionTable_PlayMusic, PlayStream);
464
ADD_RSDK_FUNCTION(FunctionTable_SetChannelAttributes, SetChannelAttributes);
465
ADD_RSDK_FUNCTION(FunctionTable_StopChannel, StopChannel);
466
ADD_RSDK_FUNCTION(FunctionTable_PauseChannel, PauseChannel);
467
ADD_RSDK_FUNCTION(FunctionTable_ResumeChannel, ResumeChannel);
468
ADD_RSDK_FUNCTION(FunctionTable_SfxPlaying, SfxPlaying);
469
ADD_RSDK_FUNCTION(FunctionTable_ChannelActive, ChannelActive);
470
ADD_RSDK_FUNCTION(FunctionTable_GetChannelPos, GetChannelPos);
471
472
// Videos & "HD Images"
473
ADD_RSDK_FUNCTION(FunctionTable_LoadVideo, LoadVideo);
474
ADD_RSDK_FUNCTION(FunctionTable_LoadImage, LoadImage);
475
476
// Input
477
#if RETRO_REV02
478
ADD_RSDK_FUNCTION(FunctionTable_GetInputDeviceID, GetInputDeviceID);
479
ADD_RSDK_FUNCTION(FunctionTable_GetFilteredInputDeviceID, GetFilteredInputDeviceID);
480
ADD_RSDK_FUNCTION(FunctionTable_GetInputDeviceType, GetInputDeviceType);
481
ADD_RSDK_FUNCTION(FunctionTable_IsInputDeviceAssigned, IsInputDeviceAssigned);
482
ADD_RSDK_FUNCTION(FunctionTable_GetInputDeviceUnknown, GetInputDeviceUnknown);
483
ADD_RSDK_FUNCTION(FunctionTable_InputDeviceUnknown1, InputDeviceUnknown1);
484
ADD_RSDK_FUNCTION(FunctionTable_InputDeviceUnknown2, InputDeviceUnknown2);
485
ADD_RSDK_FUNCTION(FunctionTable_GetInputSlotUnknown, GetInputSlotUnknown);
486
ADD_RSDK_FUNCTION(FunctionTable_InputSlotUnknown1, InputSlotUnknown1);
487
ADD_RSDK_FUNCTION(FunctionTable_InputSlotUnknown2, InputSlotUnknown2);
488
ADD_RSDK_FUNCTION(FunctionTable_AssignInputSlotToDevice, AssignInputSlotToDevice);
489
ADD_RSDK_FUNCTION(FunctionTable_IsInputSlotAssigned, IsInputSlotAssigned);
490
ADD_RSDK_FUNCTION(FunctionTable_ResetInputSlotAssignments, ResetInputSlotAssignments);
491
#endif
492
#if !RETRO_REV02
493
ADD_RSDK_FUNCTION(FunctionTable_GetUnknownInputValue, GetUnknownInputValue);
494
#endif
495
496
// User File Management
497
ADD_RSDK_FUNCTION(FunctionTable_LoadUserFile, LoadUserFile); // load user file from exe dir
498
ADD_RSDK_FUNCTION(FunctionTable_SaveUserFile, SaveUserFile); // save use file to exe dir
499
500
// Printing (Rev02)
501
#if RETRO_REV02
502
ADD_RSDK_FUNCTION(FunctionTable_PrintLog, PrintLog);
503
ADD_RSDK_FUNCTION(FunctionTable_PrintText, PrintText);
504
ADD_RSDK_FUNCTION(FunctionTable_PrintString, PrintString);
505
ADD_RSDK_FUNCTION(FunctionTable_PrintUInt32, PrintUInt32);
506
ADD_RSDK_FUNCTION(FunctionTable_PrintInt32, PrintInt32);
507
ADD_RSDK_FUNCTION(FunctionTable_PrintFloat, PrintFloat);
508
ADD_RSDK_FUNCTION(FunctionTable_PrintVector2, PrintVector2);
509
ADD_RSDK_FUNCTION(FunctionTable_PrintHitbox, PrintHitbox);
510
#endif
511
512
// Editor
513
ADD_RSDK_FUNCTION(FunctionTable_SetActiveVariable, SetActiveVariable);
514
ADD_RSDK_FUNCTION(FunctionTable_AddEnumVariable, AddEnumVariable);
515
516
// Printing (Rev01)
517
#if !RETRO_REV02
518
ADD_RSDK_FUNCTION(FunctionTable_PrintMessage, PrintMessage);
519
#endif
520
521
// Debugging
522
#if RETRO_REV02
523
ADD_RSDK_FUNCTION(FunctionTable_ClearDebugValues, ClearViewableVariables);
524
ADD_RSDK_FUNCTION(FunctionTable_SetDebugValue, AddViewableVariable);
525
#endif
526
527
// v5U Extras
528
#if RETRO_REV0U
529
ADD_RSDK_FUNCTION(FunctionTable_NotifyCallback, NULL);
530
ADD_RSDK_FUNCTION(FunctionTable_SetGameFinished, SetGameFinished);
531
ADD_RSDK_FUNCTION(FunctionTable_StopAllSfx, StopAllSfx);
532
#endif
533
534
#if RETRO_USE_MOD_LOADER
535
InitModAPI();
536
#endif
537
}
538
539
#if RETRO_REV02
540
void RSDK::LinkGameLogic(void *info) { PrintLog(PRINT_POPUP, "Internal LinkGameLogic() function called, no logic will be linked"); }
541
#else
542
void RSDK::LinkGameLogic(EngineInfo info) { PrintLog(PRINT_POPUP, "Internal LinkGameLogic() function called, no logic will be linked"); }
543
#endif
544
545
#if RETRO_PLATFORM == RETRO_SWITCH
546
547
Result RSDK::Link::err = 0;
548
549
RSDK::Link::Handle RSDK::Link::dlopen(const char *path, int _flags)
550
{
551
auto mod = new DynModule();
552
553
err = dynLoadNroModule(mod, path, false);
554
if (R_FAILED(err)) {
555
return nullptr;
556
}
557
558
return mod;
559
}
560
561
void *RSDK::Link::dlsym(RSDK::Link::Handle mod, const char *name)
562
{
563
void *sym = NULL;
564
err = dynModuleLookupSymbol(mod, name, &sym);
565
if (R_FAILED(err)) {
566
return nullptr;
567
}
568
569
return sym;
570
}
571
572
int RSDK::Link::dlclose(RSDK::Link::Handle mod) { dynModuleUnload(mod); return 0; }
573
574
char *RSDK::Link::dlerror() { return nullptr; }
575
576
#endif
577
578