1 | #ifndef LAUNCHELF_H
|
---|
2 | #define LAUNCHELF_H
|
---|
3 |
|
---|
4 | #define ULE_VERSION "v4.40h"
|
---|
5 | #define ULE_VERDATE "2010.02.12"
|
---|
6 |
|
---|
7 | #include <stdio.h>
|
---|
8 | #include <tamtypes.h>
|
---|
9 | #include <sifcmd.h>
|
---|
10 | #include <kernel.h>
|
---|
11 | #include <sifrpc.h>
|
---|
12 | #include <loadfile.h>
|
---|
13 | #include <string.h>
|
---|
14 | #include <malloc.h>
|
---|
15 | #include <libhdd.h>
|
---|
16 | #include <libmc.h>
|
---|
17 | #include <libpad.h>
|
---|
18 | #include <fileio.h>
|
---|
19 | #include <sys/stat.h>
|
---|
20 | #include <iopheap.h>
|
---|
21 | #include <errno.h>
|
---|
22 | #include <fileXio_rpc.h>
|
---|
23 | #include <iopcontrol.h>
|
---|
24 | #include <stdarg.h>
|
---|
25 | #include <sbv_patches.h>
|
---|
26 | #include <slib.h>
|
---|
27 | #include <smem.h>
|
---|
28 | #include <smod.h>
|
---|
29 | #include <sys/fcntl.h>
|
---|
30 | #include <debug.h>
|
---|
31 | #include <gsKit.h>
|
---|
32 | #include <dmaKit.h>
|
---|
33 | #include <cdvd_rpc.h>
|
---|
34 | #include "cd.h"
|
---|
35 | //#include "mass_rpc.h" //disused in switch to usbhdfsd
|
---|
36 | #include "iopmod_name.h"
|
---|
37 | #include <libjpg.h>
|
---|
38 | #include <libkbd.h>
|
---|
39 | #include <floatlib.h>
|
---|
40 | #include "hdl_rpc.h"
|
---|
41 |
|
---|
42 | #define TRUE 1
|
---|
43 | #define FALSE 0
|
---|
44 |
|
---|
45 | enum { // cnfmode values for getFilePath in browsing for configurable file paths
|
---|
46 | NON_CNF = 0, // Normal browser mode, not configuration mode
|
---|
47 | LK_ELF_CNF, // Normal ELF choice for launch keys
|
---|
48 | USBD_IRX_CNF, // USBD.IRX choice for startup
|
---|
49 | SKIN_CNF, // Skin JPG choice
|
---|
50 | GUI_SKIN_CNF, // GUI Skin JPG choice
|
---|
51 | USBKBD_IRX_CNF, // USB keyboard IRX choice (only PS2SDK)
|
---|
52 | KBDMAP_FILE_CNF, // USB keyboard mapping table choice
|
---|
53 | CNF_PATH_CNF, // CNF Path override choice
|
---|
54 | TEXT_CNF, // No restriction choice
|
---|
55 | DIR_CNF, // Directory choice
|
---|
56 | JPG_CNF, // Jpg viewer choice
|
---|
57 | USBMASS_IRX_CNF, // USB_MASS.IRX choice for startup
|
---|
58 | LANG_CNF, // Language file choice
|
---|
59 | FONT_CNF, // Font file choice ( .fnt )
|
---|
60 | SAVE_CNF, // Generic Save choice (with or without selected file)
|
---|
61 | CNFMODE_CNT // Total number of cnfmode values defined
|
---|
62 | };
|
---|
63 |
|
---|
64 | enum
|
---|
65 | {
|
---|
66 | SCREEN_MARGIN = 16,
|
---|
67 | FONT_WIDTH = 8,
|
---|
68 | FONT_HEIGHT = 16,
|
---|
69 | LINE_THICKNESS = 3,
|
---|
70 |
|
---|
71 | MAX_NAME = 256,
|
---|
72 | MAX_PATH = 1025,
|
---|
73 | MAX_ENTRY = 2048,
|
---|
74 | MAX_PARTITIONS=500,
|
---|
75 | MAX_MENU_TITLE = 40,
|
---|
76 | MAX_ELF_TITLE = 72,
|
---|
77 | MAX_TEXT_LINE = 80
|
---|
78 | };
|
---|
79 |
|
---|
80 | typedef struct
|
---|
81 | {
|
---|
82 | char CNF_Path[MAX_PATH];
|
---|
83 | char LK_Path[16][MAX_PATH];
|
---|
84 | char LK_Title[16][MAX_ELF_TITLE];
|
---|
85 | int LK_Flag[16];
|
---|
86 | char Misc[64];
|
---|
87 | char Misc_PS2Disc[64];
|
---|
88 | char Misc_FileBrowser[64];
|
---|
89 | char Misc_PS2Browser[64];
|
---|
90 | char Misc_PS2Net[64];
|
---|
91 | char Misc_PS2PowerOff[64];
|
---|
92 | char Misc_HddManager[64];
|
---|
93 | char Misc_TextEditor[64];
|
---|
94 | char Misc_JpgViewer[64];
|
---|
95 | char Misc_Configure[64];
|
---|
96 | char Misc_Load_CNFprev[64];
|
---|
97 | char Misc_Load_CNFnext[64];
|
---|
98 | char Misc_Set_CNF_Path[64];
|
---|
99 | char Misc_Load_CNF[64];
|
---|
100 | char Misc_ShowFont[64];
|
---|
101 | char Misc_Debug_Info[64];
|
---|
102 | char Misc_About_uLE[64];
|
---|
103 | char usbd_file[MAX_PATH];
|
---|
104 | char usbkbd_file[MAX_PATH];
|
---|
105 | char usbmass_file[MAX_PATH];
|
---|
106 | char kbdmap_file[MAX_PATH];
|
---|
107 | char skin[MAX_PATH];
|
---|
108 | char GUI_skin[MAX_PATH];
|
---|
109 | char Menu_Title[MAX_MENU_TITLE+1];
|
---|
110 | char lang_file[MAX_PATH];
|
---|
111 | char font_file[MAX_PATH];
|
---|
112 | int Menu_Frame;
|
---|
113 | int Show_Menu;
|
---|
114 | int timeout;
|
---|
115 | int Hide_Paths;
|
---|
116 | u64 color[8];
|
---|
117 | int screen_x;
|
---|
118 | int screen_y;
|
---|
119 | int discControl;
|
---|
120 | int interlace;
|
---|
121 | int resetIOP;
|
---|
122 | int numCNF;
|
---|
123 | int swapKeys;
|
---|
124 | int HOSTwrite;
|
---|
125 | int Brightness;
|
---|
126 | int TV_mode;
|
---|
127 | int Popup_Opaque;
|
---|
128 | int Init_Delay;
|
---|
129 | int usbkbd_used;
|
---|
130 | int Show_Titles;
|
---|
131 | int PathPad_Lock;
|
---|
132 | int JpgView_Timer;
|
---|
133 | int JpgView_Trans;
|
---|
134 | int JpgView_Full;
|
---|
135 | int PSU_HugeNames;
|
---|
136 | int PSU_DateNames;
|
---|
137 | int PSU_NoOverwrite;
|
---|
138 | int FB_NoIcons;
|
---|
139 | } SETTING;
|
---|
140 |
|
---|
141 | typedef struct
|
---|
142 | {
|
---|
143 | int ip[4];
|
---|
144 | int nm[4];
|
---|
145 | int gw[4];
|
---|
146 | } data_ip_struct;
|
---|
147 |
|
---|
148 | extern char LaunchElfDir[MAX_PATH], LastDir[MAX_NAME];
|
---|
149 |
|
---|
150 | /* main.c */
|
---|
151 | extern int TV_mode;
|
---|
152 | extern int swapKeys;
|
---|
153 | extern int GUI_active;// Skin and Main Skin switch
|
---|
154 | extern CdvdDiscType_t cdmode; //Last detected disc type
|
---|
155 |
|
---|
156 | void load_vmcfs(void);
|
---|
157 | void load_ps2host(void);
|
---|
158 | void loadCdModules(void);
|
---|
159 | void loadUsbModules(void);
|
---|
160 | void loadHddModules(void);
|
---|
161 | void loadHdlInfoModule(void);
|
---|
162 | void setupPowerOff(void);
|
---|
163 | int uLE_related(char *pathout, char *pathin);
|
---|
164 | int uLE_detect_TV_mode();
|
---|
165 | int exists(char *path);
|
---|
166 | int uLE_cdDiscValid(void);
|
---|
167 | int uLE_cdStop(void);
|
---|
168 |
|
---|
169 | /* elf.c */
|
---|
170 | int checkELFheader(char *filename);
|
---|
171 | void RunLoaderElf(char *filename, char *);
|
---|
172 |
|
---|
173 | /* draw.c */
|
---|
174 | #define BACKGROUND_PIC 0
|
---|
175 | #define PREVIEW_PIC 1
|
---|
176 | #define JPG_PIC 2
|
---|
177 | #define THUMB_PIC 3
|
---|
178 | #define PREVIEW_GUI 4
|
---|
179 |
|
---|
180 | #define FOLDER 0
|
---|
181 | #define WARNING 1
|
---|
182 |
|
---|
183 | unsigned char icon_folder[1024];
|
---|
184 | unsigned char icon_warning[1024];
|
---|
185 |
|
---|
186 | extern GSGLOBAL *gsGlobal;
|
---|
187 | extern GSTEXTURE TexSkin, TexPreview, TexPicture, TexThumb[MAX_ENTRY], TexIcon[2];
|
---|
188 | extern int testskin, testsetskin, testjpg, testthumb;
|
---|
189 | extern float PicWidth, PicHeight, PicW, PicH, PicCoeff;
|
---|
190 | extern int SCREEN_WIDTH;
|
---|
191 | extern int SCREEN_HEIGHT;
|
---|
192 | extern int SCREEN_X;
|
---|
193 | extern int SCREEN_Y;
|
---|
194 | extern int Menu_start_x;
|
---|
195 | extern int Menu_title_y;
|
---|
196 | extern int Menu_message_y;
|
---|
197 | extern int Frame_start_y;
|
---|
198 | extern int Menu_start_y;
|
---|
199 | extern int Menu_end_y;
|
---|
200 | extern int Frame_end_y;
|
---|
201 | extern int Menu_tooltip_y;
|
---|
202 | extern u64 BrightColor;
|
---|
203 | extern int PicRotate, FullScreen;
|
---|
204 | extern u8 FontBuffer[256*16];
|
---|
205 |
|
---|
206 | void setScrTmp(const char *msg0, const char *msg1);
|
---|
207 | void drawSprite( u64 color, int x1, int y1, int x2, int y2 );
|
---|
208 | void drawPopSprite( u64 color, int x1, int y1, int x2, int y2 );
|
---|
209 | void drawOpSprite( u64 color, int x1, int y1, int x2, int y2 );
|
---|
210 | void drawMsg(const char *msg);
|
---|
211 | void drawLastMsg(void);
|
---|
212 | void setupGS(int gs_vmode);
|
---|
213 | void updateScreenMode(int adapt_XY);
|
---|
214 | void clrScr(u64 color);
|
---|
215 | void setBrightness(int Brightness);
|
---|
216 | void loadSkin(int Picture, char *Path, int ThumbNum);
|
---|
217 | void drawScr(void);
|
---|
218 | void drawFrame(int x1, int y1, int x2, int y2, u64 color);
|
---|
219 | void drawChar(unsigned int c, int x, int y, u64 colour);
|
---|
220 | int printXY(const unsigned char *s, int x, int y, u64 colour, int draw, int space);
|
---|
221 | int printXY_sjis(const unsigned char *s, int x, int y, u64 colour, int);
|
---|
222 | u8 *transcpy_sjis(u8 *d, u8 *s);
|
---|
223 | void loadIcon(void);
|
---|
224 | int loadFont(char *path_arg);
|
---|
225 | //Comment out WriteFont_C when not used (also requires patch in draw.c)
|
---|
226 | //int WriteFont_C(char *pathname);
|
---|
227 |
|
---|
228 | /* pad.c */
|
---|
229 | #define PAD_R3_V0 0x010000
|
---|
230 | #define PAD_R3_V1 0x020000
|
---|
231 | #define PAD_R3_H0 0x040000
|
---|
232 | #define PAD_R3_H1 0x080000
|
---|
233 | #define PAD_L3_V0 0x100000
|
---|
234 | #define PAD_L3_V1 0x200000
|
---|
235 | #define PAD_L3_H0 0x400000
|
---|
236 | #define PAD_L3_H1 0x800000
|
---|
237 |
|
---|
238 | extern u32 joy_value;
|
---|
239 | extern u32 new_pad;
|
---|
240 | int setupPad(void);
|
---|
241 | int readpad(void);
|
---|
242 | int readpad_no_KB(void);
|
---|
243 | int readpad_noRepeat(void);
|
---|
244 | void waitPadReady(int port, int slot);
|
---|
245 | void waitAnyPadReady(void);
|
---|
246 |
|
---|
247 | /* config.c */
|
---|
248 | #define TV_mode_AUTO 0
|
---|
249 | #define TV_mode_NTSC 1
|
---|
250 | #define TV_mode_PAL 2
|
---|
251 |
|
---|
252 | extern char PathPad[30][MAX_PATH];
|
---|
253 | extern SETTING *setting;
|
---|
254 | void initConfig(void);
|
---|
255 | int loadConfig(char *, char *); //0==OK, -1==load failed
|
---|
256 | void config(char *, char *);
|
---|
257 | int get_CNF_string(unsigned char **CNF_p_p,
|
---|
258 | unsigned char **name_p_p,
|
---|
259 | unsigned char **value_p_p); //main CNF name,value parser
|
---|
260 | unsigned char *preloadCNF(char *path); //loads file into RAM it allocates
|
---|
261 |
|
---|
262 | /* filer.c */
|
---|
263 | typedef struct{
|
---|
264 | char name[MAX_NAME];
|
---|
265 | char title[32*2+1];
|
---|
266 | mcTable stats;
|
---|
267 | } FILEINFO;
|
---|
268 |
|
---|
269 | #define MOUNT_LIMIT 4
|
---|
270 | extern char mountedParty[MOUNT_LIMIT][MAX_NAME];
|
---|
271 | extern int latestMount;
|
---|
272 | extern int vmcMounted[2];
|
---|
273 | extern int vmc_PartyIndex[2]; //PFS index for each VMC, unless -1
|
---|
274 | extern int Party_vmcIndex[MOUNT_LIMIT]; //VMC index for each PFS, unless -1
|
---|
275 | extern int nparties; //Clearing this causes FileBrowser to refresh party list
|
---|
276 | extern unsigned char *elisaFnt;
|
---|
277 | char *PathPad_menu(const char *path);
|
---|
278 | int getFilePath(char *out, const int cnfmode);
|
---|
279 | void initHOST(void);
|
---|
280 | char *makeHostPath(char *dp, char*sp);
|
---|
281 | int ynDialog(const char *message);
|
---|
282 | void nonDialog(char *message);
|
---|
283 | int keyboard(char *out, int max);
|
---|
284 | void genInit(void);
|
---|
285 | void genLimObjName(char *uLE_path, int reserve);
|
---|
286 | int genFixPath(char *uLE_path, char *gen_path);
|
---|
287 | int genOpen(char *path, int mode);
|
---|
288 | int genLseek(int fd, int where, int how);
|
---|
289 | int genRead(int fd, void *buf, int size);
|
---|
290 | int genWrite(int fd, void *buf, int size);
|
---|
291 | int genClose(int fd);
|
---|
292 | int genDopen(char *path);
|
---|
293 | int genDclose(int fd);
|
---|
294 | int genRemove(char *path);
|
---|
295 | int genRmdir(char *path);
|
---|
296 | int mountParty(const char *party);
|
---|
297 | void unmountParty(int party_ix);
|
---|
298 | void unmountAll(void);
|
---|
299 | int setFileList(const char *path, const char *ext, FILEINFO *files, int cnfmode);
|
---|
300 |
|
---|
301 | /* hdd.c */
|
---|
302 | void DebugDisp(char *Message);
|
---|
303 | void hddManager(void);
|
---|
304 |
|
---|
305 | /* editor.c */
|
---|
306 | void TextEditor(void);
|
---|
307 |
|
---|
308 | /* timer.c */
|
---|
309 | extern u64 WaitTime;
|
---|
310 | extern u64 CurrTime;
|
---|
311 |
|
---|
312 | void TimerInit(void);
|
---|
313 | u64 Timer(void);
|
---|
314 | void TimerEnd(void);
|
---|
315 |
|
---|
316 | /* jpgviewer.c */
|
---|
317 | void JpgViewer(void);
|
---|
318 |
|
---|
319 | /* lang.c */
|
---|
320 | typedef struct Language{
|
---|
321 | u8* String;
|
---|
322 | } Language;
|
---|
323 |
|
---|
324 | enum {
|
---|
325 | #define lang(id, name, value) LANG_##name,
|
---|
326 | #include "lang.h"
|
---|
327 | #undef lang
|
---|
328 | LANG_COUNT
|
---|
329 | };
|
---|
330 |
|
---|
331 | #define LNG(name) Lang_String[LANG_##name].String
|
---|
332 | #define LNG_DEF(name) Lang_Default[LANG_##name].String
|
---|
333 |
|
---|
334 | extern Language Lang_String[];
|
---|
335 | extern Language Lang_Default[];
|
---|
336 | extern Language *External_Lang_Buffer;
|
---|
337 |
|
---|
338 | void Init_Default_Language(void);
|
---|
339 | void Load_External_Language(void);
|
---|
340 |
|
---|
341 | /* font_uLE.c */
|
---|
342 |
|
---|
343 | extern unsigned char font_uLE[];
|
---|
344 | enum {
|
---|
345 | //0x100-0x109 are 5 double width characters for D-Pad buttons, which are accessed as:
|
---|
346 | //"ÿ0"==Circle "ÿ1"==Cross "ÿ2"==Square "ÿ3"==Triangle "ÿ4"==filled Square
|
---|
347 | RIGHT_CUR = 0x10A, //Triangle pointing left, for use to the right of an item
|
---|
348 | LEFT_CUR = 0x10B, //Triangle pointing right, for use to the left of an item
|
---|
349 | UP_ARROW = 0x10C, //Arrow pointing up
|
---|
350 | DN_ARROW = 0x10D, //Arrow pointing up
|
---|
351 | LT_ARROW = 0x10E, //Arrow pointing up
|
---|
352 | RT_ARROW = 0x10F, //Arrow pointing up
|
---|
353 | TEXT_CUR = 0x110, //Vertical bar, for use between two text characters
|
---|
354 | UL_ARROW = 0x111, //Arrow pointing up and to the left, from a vertical start.
|
---|
355 | BR_SPLIT = 0x112, //Splits rectangle from BL to TR with BR portion filled
|
---|
356 | BL_SPLIT = 0x113, //Splits rectangle from TL to BR with BL portion filled
|
---|
357 | //0x114-0x11B are 4 double width characters for D-Pad buttons, which are accessed as:
|
---|
358 | //"ÿ:"==Right "ÿ;"==Down "ÿ<"==Left "ÿ="==Up
|
---|
359 | //0x11C-0x123 are 4 doubled characters used as normal/marked folder/file icons
|
---|
360 | ICON_FOLDER = 0x11C,
|
---|
361 | ICON_M_FOLDER = 0x11E,
|
---|
362 | ICON_FILE = 0x120,
|
---|
363 | ICON_M_FILE = 0x122,
|
---|
364 | FONT_COUNT= 0x124 //Total number of characters in font
|
---|
365 | };
|
---|
366 |
|
---|
367 | /* makeicon.c */
|
---|
368 | int make_icon(char* icontext,char* filename);
|
---|
369 | int make_iconsys(char* title,char* iconname, char* filename);
|
---|
370 |
|
---|
371 |
|
---|
372 | //vmcfs definitions
|
---|
373 |
|
---|
374 | // The devctl commands: 0x56 == V, 0x4D == M, 0x43 == C, 0x01, 0x02, ... == command number.
|
---|
375 | #define DEVCTL_VMCFS_CLEAN 0x564D4301 // Set as free all fat cluster corresponding to a none existing object. ( Object are just marked as none existing but not removed from fat table when rmdir or remove fonctions are call. This allow to recover a deleted file. )
|
---|
376 | #define DEVCTL_VMCFS_CKFREE 0x564D4302 // Check free space available on vmc.
|
---|
377 |
|
---|
378 | // The ioctl commands: 0x56 == V, 0x4D == M, 0x43 == C, 0x01, 0x02, ... == command number.
|
---|
379 | #define IOCTL_VMCFS_RECOVER 0x564D4303 // Recover an object marked as none existing. ( data must be a valid path to an object in vmc file )
|
---|
380 |
|
---|
381 | // Vmc format enum
|
---|
382 | typedef enum {
|
---|
383 | FORMAT_FULL,
|
---|
384 | FORMAT_FAST
|
---|
385 | } Vmc_Format_Enum;
|
---|
386 |
|
---|
387 |
|
---|
388 | // chkesr_rpc.c
|
---|
389 | extern int chkesr_rpc_Init(void);
|
---|
390 | extern int Check_ESR_Disc(void);
|
---|
391 |
|
---|
392 | //USB_mass definitions for multiple drive usage
|
---|
393 |
|
---|
394 | #define USB_MASS_MAX_DRIVES 10
|
---|
395 |
|
---|
396 | extern char USB_mass_ix[10];
|
---|
397 | extern int USB_mass_max_drives;
|
---|
398 | extern u64 USB_mass_scan_time;
|
---|
399 | extern int USB_mass_scanned;
|
---|
400 | extern int USB_mass_loaded; //0==none, 1==internal, 2==external
|
---|
401 |
|
---|
402 | #endif
|
---|