forked from DC-SWAT/DreamShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDS.pkg
More file actions
310 lines (220 loc) · 6.68 KB
/
DS.pkg
File metadata and controls
310 lines (220 loc) · 6.68 KB
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
/*
luaDS
DS functions for lua scripts
(c) SWAT
*/
$#include "ds.h"
$#include "lua/tolua.h"
$#include "mxml.h"
$#include "fs.h"
$#include "vmu.h"
$
$App_t *VoidToApp(void *ptr) {
$ return (App_t *) ptr;
$}
$
$Event_t *VoidToEvent(void *ptr) {
$ return (Event_t *) ptr;
$}
$
$Cmd_t *AddCmdLua(const char *cmd, const char *helpmsg, const char *handler);
$Event_t *AddEventLua(const char *name, int type, const char *handler);
$
module DS
{
/***************************** DreamShell Functions *************************/
uint32 GetVersion();
void SetVersion(uint32 ver);
const char *GetVersionBuildTypeString(int type);
typedef struct Item {
const char *name;
uint32 id;
ListItemType type;
void *data;
uint32 size;
} Item_t;
typedef enum {
LIST_ITEM_USERDATA = 0,
LIST_ITEM_SDL_SURFACE,
LIST_ITEM_SDL_RWOPS,
LIST_ITEM_GUI_SURFACE,
LIST_ITEM_GUI_FONT,
LIST_ITEM_GUI_WIDGET,
LIST_ITEM_MODULE,
LIST_ITEM_APP,
LIST_ITEM_EVENT,
LIST_ITEM_THREAD,
LIST_ITEM_CMD,
LIST_ITEM_LUA_LIB
} ListItemType;
Item_list_t *listMake();
void listDestroy(Item_list_t *lst, listFreeItemFunc *ifree);
uint32 listGetLastId(Item_list_t *lst);
Item_t *listAddItem(Item_list_t *lst, ListItemType type, const char *name, void *data, uint32 size);
void listRemoveItem(Item_list_t *lst, Item_t *i, listFreeItemFunc *ifree);
Item_t *listGetItemByName(Item_list_t *lst, const char *name);
Item_t *listGetItemByNameAndType(Item_list_t *lst, const char *name, ListItemType type);
Item_t *listGetItemById(Item_list_t *lst, uint32 id);
Item_t *listGetItemFirst(Item_list_t *lst);
Item_t *listGetItemNext(Item_t *i);
#define APP_STATE_OPENED 0x00000001
#define APP_STATE_LOADED 0x00000002
#define APP_STATE_READY 0x00000004
#define APP_STATE_PROCESS 0x00000008
#define APP_STATE_SLEEP 0x00000020
#define APP_STATE_WAIT_UNLOAD 0x00000040
typedef struct App {
const char fn[MAX_FN_LEN];
const char icon[MAX_FN_LEN];
const char name[64];
const char ver[32];
const char ext[64];
const char *args;
uint32 id;
uint32 state;
Item_list_t *resources;
Item_list_t *elements;
mxml_node_t *xml;
void *thd;
void *lua;
GUI_Widget *body;
} App_t;
Item_list_t *GetAppList();
App_t *GetAppById(int id);
App_t *GetAppByFileName(const char *fn);
App_t *GetAppByName(const char *name);
App_t *GetAppByExtension(const char *ext);
App_t *GetAppsByExtension(const char *ext, App_t **app_list, size_t count);
App_t *GetCurApp();
App_t *AddApp(const char *fn);
int RemoveApp(App_t *app);
int OpenApp(App_t *app, const char *args);
int CloseApp(App_t *app, int unload);
int SetAppSleep(App_t *app, int sleep);
int LoadApp(App_t *app, int build);
int UnLoadApp(App_t *app);
void UnloadAppResources(Item_list_t *lst);
int BuildAppBody(App_t *app);
int AddToAppBody(App_t *app, GUI_Widget *widget);
int RemoveFromAppBody(App_t *app, GUI_Widget *widget);
int CallAppBodyEvent(App_t *app, char *event);
void WaitApp(App_t *app);
int IsFileSupportedByApp(App_t *app, const char *filename);
char *FindXmlAttr(char *name, mxml_node_t *node, char *defValue);
void *getAppElement(App_t *app, const char *name, ListItemType type);
App_t *VoidToApp(void *ptr);
#define EVENT_STATE_ACTIVE 0
#define EVENT_STATE_SLEEP 1
#define EVENT_ACTION_RENDER 0
#define EVENT_ACTION_UPDATE 1
#define EVENT_TYPE_INPUT 0
#define EVENT_TYPE_VIDEO 1
typedef struct Event {
const char *name;
uint32 id;
void *event;
void *param;
uint16 state;
uint16 type;
} Event_t;
int InitEvents();
void ShutdownEvents();
Event_t *AddEventLua(const char *name, uint16 type, const char *event);
int RemoveEvent(Event_t *e);
int SetEventState(Event_t *e, uint16 state);
Item_list_t *GetEventList();
Event_t *GetEventById(uint32 id);
Event_t *GetEventByName(const char *name);
Event_t *VoidToEvent(void *ptr);
typedef enum {
CMD_OK = 0,
CMD_NO_ARG,
CMD_ERROR,
CMD_NOT_EXISTS
} CMD_RESULT;
typedef enum {
CMD_TYPE_INTERNAL = 0,
CMD_TYPE_ELF,
CMD_TYPE_LUA,
CMD_TYPE_DSC,
CMD_TYPE_BIN,
CMD_TYPE_UKNOWN
} CMD_TYPES;
typedef struct Cmd {
const char *command;
const char *desc;
void *handler;
} Cmd_t;
int CheckExtCmdType(const char *fn);
Cmd_t *AddCmdLua(const char *cmd, const char *helpmsg, const char *handler);
void RemoveCmd(Cmd_t *cmd);
Item_list_t *GetCmdList();
Cmd_t *GetCmdByName(const char *name);
int ToggleConsole();
int ConsoleIsVisible();
int CreateConsolePTY();
int DestroyConsolePTY();
int SearchRoot(int pass_cnt);
void vmu_draw_string(const char *str);
int flashrom_get_region_only();
int is_hacked_bios();
int is_custom_bios();
int is_no_syscalls();
int FileSize(const char *fn);
int FileExists(const char *fn);
int DirExists(const char *fn);
int PeriphExists(const char *name);
int CopyFile(const char *src_fn, const char *dest_fn, int verbose);
int CopyDirectory(const char *src_path, const char *dest_path, int verbose);
const char *relativeFilePath(char *rel, char *file);
int relativeFilePath_wb(char *buff, const char *rel, const char *file);
char *getFilePath(const char *file);
char *realpath(const char *path, char *resolved);
int mkpath(const char *path);
SDL_Surface *GetScreen();
void SetScreen(SDL_Surface *new_screen);
/* Always RGB565 */
int GetVideoMode();
void SetVideoMode(int mode);
int GetScreenWidth();
int GetScreenHeight();
void SDL_DS_SetWindow(int width, int height);
void SetScreenMode(int w, int h, float x, float y, float z);
void SDL_DS_AllocScreenTexture(SDL_Surface *screen);
void SDL_DS_FreeScreenTexture(int reset_pvr_memory);
pvr_ptr_t *GetScreenTexture();
void SetScreenTexture(pvr_ptr_t *txr);
void SetScreenOpacity(float opacity);
float GetScreenOpacity();
void SetScreenFilter(int filter);
void SetScreenVertex(float u1, float v1, float u2, float v2);
void ScreenRotate(float x, float y, float z);
void ScreenTranslate(float x, float y, float z);
void ScreenFadeIn();
void ScreenFadeOut();
void ScreenFadeStop();
void DisableScreen();
void EnableScreen();
int ScreenIsEnabled();
void ScreenChanged();
int ScreenUpdated();
void ScreenWaitUpdate();
void LockVideo();
void UnlockVideo();
int VideoIsLocked();
int VideoMustLock();
void LockInput();
void UnlockInput();
int InputIsLocked();
int InputMustLock();
void InitVideoHardware();
int InitVideo(int w, int h, int bpp);
void ShutdownVideo();
void InitVideoThread();
void ShutdownVideoThread();
void ShowLogo();
void HideLogo();
void UpdateActiveMouseCursor();
/* Ends C function definitions when using C++ */
} /* end tolua module DS */
/* Some code to be included in the generated .c file */