3 Licenced under Academic Free License version 3.0
4 Review OpenUsbLd README & LICENSE files for further details.
7 #include "include/usbld.h"
8 #include "include/ioman.h"
9 #include "include/gui.h"
10 #include "include/renderman.h"
11 #include "include/lang.h"
12 #include "include/themes.h"
13 #include "include/textures.h"
14 #include "include/pad.h"
15 #include "include/texcache.h"
16 #include "include/dia.h"
17 #include "include/dialogs.h"
18 #include "include/menusys.h"
19 #include "include/system.h"
20 #include "include/debug.h"
21 #include "include/config.h"
23 #include "include/usbsupport.h"
24 #include "include/ethsupport.h"
25 #include "include/hddsupport.h"
26 #include "include/appsupport.h"
33 #define LOG_INIT() sio_init(38400, 0, 0, 0, 0)
34 #define LOG_ENABLE() do { } while(0)
37 #define LOG_INIT() do { } while(0)
38 #define LOG_ENABLE() ioPutRequest(IO_CUSTOM_SIMPLEACTION, &debugSetActive)
40 #define LOG_INIT() do { } while(0)
41 #define LOG_ENABLE() do { } while(0)
45 #define UPDATE_FRAME_COUNT 250
47 #define IO_MENU_UPDATE_DEFFERED 2
49 extern void *usbd_irx
;
50 extern int size_usbd_irx
;
55 /// menu item used with this list support
59 submenu_list_t
*subMenu
;
62 static void clearIOModuleT(opl_io_module_t
*mod
) {
65 mod
->menuItem
.execCross
= NULL
;
66 mod
->menuItem
.execCircle
= NULL
;
67 mod
->menuItem
.execSquare
= NULL
;
68 mod
->menuItem
.execTriangle
= NULL
;
69 mod
->menuItem
.hints
= NULL
;
70 mod
->menuItem
.icon_id
= -1;
71 mod
->menuItem
.current
= NULL
;
72 mod
->menuItem
.submenu
= NULL
;
73 mod
->menuItem
.pagestart
= NULL
;
74 mod
->menuItem
.remindLast
= 0;
75 mod
->menuItem
.refresh
= NULL
;
76 mod
->menuItem
.text
= NULL
;
77 mod
->menuItem
.text_id
= -1;
78 mod
->menuItem
.userdata
= NULL
;
82 static void moduleCleanup(opl_io_module_t
* mod
, int exception
);
85 static int frameCounter
;
87 static char errorMessage
[255];
89 static opl_io_module_t list_support
[4];
91 void moduleUpdateMenu(int mode
, int themeChanged
) {
95 opl_io_module_t
* mod
= &list_support
[mode
];
101 menuRemoveHints(&mod
->menuItem
);
103 menuAddHint(&mod
->menuItem
, _STR_SETTINGS
, START_ICON
);
104 if (!mod
->support
->enabled
)
105 menuAddHint(&mod
->menuItem
, _STR_START_DEVICE
, CROSS_ICON
);
107 if (gUseInfoScreen
&& gTheme
->infoElems
.first
)
108 menuAddHint(&mod
->menuItem
, _STR_INFO
, CROSS_ICON
);
110 menuAddHint(&mod
->menuItem
, _STR_RUN
, CROSS_ICON
);
111 if (mod
->support
->haveCompatibilityMode
)
112 menuAddHint(&mod
->menuItem
, _STR_COMPAT_SETTINGS
, TRIANGLE_ICON
);
114 if (mod
->support
->itemRename
)
115 menuAddHint(&mod
->menuItem
, _STR_RENAME
, CIRCLE_ICON
);
116 if (mod
->support
->itemDelete
)
117 menuAddHint(&mod
->menuItem
, _STR_DELETE
, SQUARE_ICON
);
123 submenuRebuildCache(mod
->subMenu
);
126 static void itemExecCross(struct menu_item
*curMenu
) {
127 item_list_t
*support
= curMenu
->userdata
;
130 if (support
->enabled
) {
131 if (curMenu
->current
) {
132 config_set_t
* configSet
= menuLoadConfig();
133 support
->itemLaunch(curMenu
->current
->item
.id
, configSet
);
138 moduleUpdateMenu(support
->mode
, 0);
140 ioPutRequest(IO_MENU_UPDATE_DEFFERED
, &list_support
[support
->mode
]);
144 guiMsgBox("NULL Support object. Please report", 0, NULL
);
147 static void itemExecTriangle(struct menu_item
*curMenu
) {
148 if (!curMenu
->current
)
151 item_list_t
*support
= curMenu
->userdata
;
154 if (support
->haveCompatibilityMode
) {
155 config_set_t
* configSet
= menuLoadConfig();
156 if (guiShowCompatConfig(curMenu
->current
->item
.id
, support
, configSet
) == COMPAT_TEST
)
157 support
->itemLaunch(curMenu
->current
->item
.id
, configSet
);
161 guiMsgBox("NULL Support object. Please report", 0, NULL
);
164 static void itemExecSquare(struct menu_item
*curMenu
) {
165 if (!curMenu
->current
)
171 item_list_t
*support
= curMenu
->userdata
;
174 if (support
->itemDelete
) {
175 if (guiMsgBox(_l(_STR_DELETE_WARNING
), 1, NULL
)) {
176 support
->itemDelete(curMenu
->current
->item
.id
);
178 frameCounter
= UPDATE_FRAME_COUNT
;
180 ioPutRequest(IO_MENU_UPDATE_DEFFERED
, &list_support
[support
->mode
]);
185 guiMsgBox("NULL Support object. Please report", 0, NULL
);
188 static void itemExecCircle(struct menu_item
*curMenu
) {
189 if (!curMenu
->current
)
195 item_list_t
*support
= curMenu
->userdata
;
198 if (support
->itemRename
) {
199 int nameLength
= support
->itemGetNameLength(curMenu
->current
->item
.id
);
200 char newName
[nameLength
];
201 strncpy(newName
, curMenu
->current
->item
.text
, nameLength
);
202 if (guiShowKeyboard(newName
, nameLength
)) {
203 support
->itemRename(curMenu
->current
->item
.id
, newName
);
205 frameCounter
= UPDATE_FRAME_COUNT
;
207 ioPutRequest(IO_MENU_UPDATE_DEFFERED
, &list_support
[support
->mode
]);
212 guiMsgBox("NULL Support object. Please report", 0, NULL
);
215 static void itemExecRefresh(struct menu_item
*curMenu
) {
216 item_list_t
*support
= curMenu
->userdata
;
218 if (support
&& support
->enabled
)
219 ioPutRequest(IO_MENU_UPDATE_DEFFERED
, &list_support
[support
->mode
]);
222 static void initMenuForListSupport(int mode
) {
223 opl_io_module_t
* item
= &list_support
[mode
];
224 item
->menuItem
.icon_id
= item
->support
->iconId
;
225 item
->menuItem
.text
= NULL
;
226 item
->menuItem
.text_id
= item
->support
->textId
;
228 item
->menuItem
.userdata
= item
->support
;
230 item
->subMenu
= NULL
;
232 item
->menuItem
.submenu
= NULL
;
233 item
->menuItem
.current
= NULL
;
234 item
->menuItem
.pagestart
= NULL
;
235 item
->menuItem
.remindLast
= 0;
237 item
->menuItem
.refresh
= &itemExecRefresh
;
238 item
->menuItem
.execCross
= &itemExecCross
;
239 item
->menuItem
.execTriangle
= &itemExecTriangle
;
240 item
->menuItem
.execSquare
= &itemExecSquare
;
241 item
->menuItem
.execCircle
= &itemExecCircle
;
243 item
->menuItem
.hints
= NULL
;
245 moduleUpdateMenu(mode
, 0);
247 struct gui_update_t
*mc
= guiOpCreate(GUI_OP_ADD_MENU
);
248 mc
->menu
.menu
= &item
->menuItem
;
249 mc
->menu
.subMenu
= &item
->subMenu
;
253 static void initSupport(item_list_t
* itemList
, int startMode
, int mode
, int force_reinit
) {
254 if (!list_support
[mode
].support
) {
255 itemList
->uip
= 1; // stop updates until we're done with init
256 list_support
[mode
].support
= itemList
;
257 initMenuForListSupport(mode
);
261 if (((force_reinit
) && (startMode
&& list_support
[mode
].support
->enabled
)) \
262 || (startMode
== 2 && !list_support
[mode
].support
->enabled
)) {
263 // stop updates until we're done with init of the device
264 list_support
[mode
].support
->uip
= 1;
265 list_support
[mode
].support
->itemInit();
266 moduleUpdateMenu(mode
, 0);
267 list_support
[mode
].support
->uip
= 0;
270 frameCounter
= UPDATE_FRAME_COUNT
;
272 ioPutRequest(IO_MENU_UPDATE_DEFFERED
, &list_support
[mode
]);
276 static void initAllSupport(int force_reinit
) {
278 initSupport(usbGetObject(0), gUSBStartMode
, USB_MODE
, force_reinit
);
281 initSupport(ethGetObject(0), gETHStartMode
, ETH_MODE
, force_reinit
||(gNetworkStartup
>= ERROR_ETH_SMB_LOGON
));
284 initSupport(hddGetObject(0), gHDDStartMode
, HDD_MODE
, force_reinit
);
287 initSupport(appGetObject(0), gAPPStartMode
, APP_MODE
, force_reinit
);
290 static void deinitAllSupport(int exception
) {
291 moduleCleanup(&list_support
[USB_MODE
], exception
);
292 moduleCleanup(&list_support
[ETH_MODE
], exception
);
293 moduleCleanup(&list_support
[HDD_MODE
], exception
);
294 moduleCleanup(&list_support
[APP_MODE
], exception
);
297 // ----------------------------------------------------------
298 // ----------------------- Updaters -------------------------
299 // ----------------------------------------------------------
300 static void updateMenuFromGameList(opl_io_module_t
* mdl
) {
301 // lock - gui has to be unused here
304 submenuDestroy(&mdl
->subMenu
);
305 mdl
->menuItem
.submenu
= NULL
;
306 mdl
->menuItem
.current
= NULL
;
307 mdl
->menuItem
.pagestart
= NULL
;
308 mdl
->menuItem
.remindLast
= 0;
310 // unlock, the rest is deferred
314 if (gRememberLastPlayed
)
315 configGetStr(configGetByType(CONFIG_LAST
), "last_played", &temp
);
317 // read the new game list
318 struct gui_update_t
*gup
= NULL
;
319 int count
= mdl
->support
->itemUpdate();
323 for (i
= 0; i
< count
; ++i
) {
325 gup
= guiOpCreate(GUI_OP_APPEND_MENU
);
327 gup
->menu
.menu
= &mdl
->menuItem
;
328 gup
->menu
.subMenu
= &mdl
->subMenu
;
330 gup
->submenu
.icon_id
= -1;
332 gup
->submenu
.text
= mdl
->support
->itemGetName(i
);
333 gup
->submenu
.text_id
= -1;
334 gup
->submenu
.selected
= 0;
336 if (gRememberLastPlayed
&& temp
&& strcmp(temp
, mdl
->support
->itemGetStartup(i
)) == 0)
337 gup
->submenu
.selected
= 1;
344 gup
= guiOpCreate(GUI_OP_SORT
);
345 gup
->menu
.menu
= &mdl
->menuItem
;
346 gup
->menu
.subMenu
= &mdl
->subMenu
;
351 static void menuDeferredUpdate(void* data
) {
352 opl_io_module_t
* mdl
= data
;
357 if (mdl
->support
->uip
)
360 // see if we have to update
361 if (mdl
->support
->itemNeedsUpdate()) {
362 mdl
->support
->uip
= 1;
364 updateMenuFromGameList(mdl
);
366 mdl
->support
->uip
= 0;
370 static void menuUpdateHook() {
371 // if timer exceeds some threshold, schedule updates of the available input sources
374 if (frameCounter
> UPDATE_FRAME_COUNT
) {
377 // schedule updates of all the list handlers
378 if (list_support
[USB_MODE
].support
&& list_support
[USB_MODE
].support
->enabled
)
379 ioPutRequest(IO_MENU_UPDATE_DEFFERED
, &list_support
[USB_MODE
]);
380 if (list_support
[ETH_MODE
].support
&& list_support
[ETH_MODE
].support
->enabled
)
381 ioPutRequest(IO_MENU_UPDATE_DEFFERED
, &list_support
[ETH_MODE
]);
382 if (list_support
[HDD_MODE
].support
&& list_support
[HDD_MODE
].support
->enabled
)
383 ioPutRequest(IO_MENU_UPDATE_DEFFERED
, &list_support
[HDD_MODE
]);
384 if (list_support
[APP_MODE
].support
&& list_support
[APP_MODE
].support
->enabled
)
385 ioPutRequest(IO_MENU_UPDATE_DEFFERED
, &list_support
[APP_MODE
]);
389 static void errorMessageHook() {
390 guiMsgBox(errorMessage
, 0, NULL
);
392 // reset the original frame hook
395 guiSetFrameHook(&menuUpdateHook
);
397 guiSetFrameHook(NULL
);
400 void setErrorMessage(int strId
, int error
) {
401 snprintf(errorMessage
, 255, _l(strId
), error
);
402 guiSetFrameHook(&errorMessageHook
);
405 // ----------------------------------------------------------
406 // ------------------ Configuration handling ----------------
407 // ----------------------------------------------------------
409 static int lscstatus
= CONFIG_ALL
;
410 static int lscret
= 0;
412 static int tryAlternateDevice(int types
) {
418 if (usbFindPartition(path
, "conf_opl.cfg")) {
421 value
= configReadMulti(types
);
422 config_set_t
*configOPL
= configGetByType(CONFIG_OPL
);
423 configSetInt(configOPL
, "usb_mode", 2);
429 sprintf(path
, "pfs0:conf_opl.cfg");
430 value
= fioOpen(path
, O_RDONLY
);
435 value
= configReadMulti(types
);
436 config_set_t
*configOPL
= configGetByType(CONFIG_OPL
);
437 configSetInt(configOPL
, "hdd_mode", 2);
441 if (sysCheckMC() < 0) { // We don't want to get users into alternate mode for their very first launch of OPL (i.e no config file at all, but still want to save on MC)
442 // set config path to either mass or hdd, to prepare the saving of a new config
443 value
= fioDopen("mass0:");
447 configInit("mass0:");
458 static void _loadConfig() {
459 int result
= configReadMulti(lscstatus
);
461 if (lscstatus
& CONFIG_OPL
) {
462 int themeID
= -1, langID
= -1;
464 if (!(result
& CONFIG_OPL
)) {
465 result
= tryAlternateDevice(lscstatus
);
468 if (result
& CONFIG_OPL
) {
469 config_set_t
*configOPL
= configGetByType(CONFIG_OPL
);
472 configGetInt(configOPL
, "scrolling", &gScrollSpeed
);
473 configGetColor(configOPL
, "bg_color", gDefaultBgColor
);
474 configGetColor(configOPL
, "text_color", gDefaultTextColor
);
475 configGetColor(configOPL
, "ui_text_color", gDefaultUITextColor
);
476 configGetColor(configOPL
, "sel_text_color", gDefaultSelTextColor
);
477 configGetInt(configOPL
, "use_info_screen", &gUseInfoScreen
);
478 configGetInt(configOPL
, "enable_coverart", &gEnableArt
);
479 configGetInt(configOPL
, "wide_screen", &gWideScreen
);
480 configGetInt(configOPL
, "vsync", &gVSync
);
481 configGetInt(configOPL
, "vmode", &gVMode
);
484 if (configGetStr(configOPL
, "theme", &temp
))
485 themeID
= thmFindGuiID(temp
);
487 if (configGetStr(configOPL
, "language_text", &temp
))
488 langID
= lngFindGuiID(temp
);
490 if (configGetStr(configOPL
, "pc_ip", &temp
))
491 sscanf(temp
, "%d.%d.%d.%d", &pc_ip
[0], &pc_ip
[1], &pc_ip
[2], &pc_ip
[3]);
493 configGetInt(configOPL
, "pc_port", &gPCPort
);
495 if (configGetStr(configOPL
, "pc_share", &temp
))
496 strncpy(gPCShareName
, temp
, 32);
497 if (configGetStr(configOPL
, "pc_user", &temp
))
498 strncpy(gPCUserName
, temp
, 32);
499 if (configGetStr(configOPL
, "pc_pass", &temp
))
500 strncpy(gPCPassword
, temp
, 32);
501 if (configGetStr(configOPL
, "exit_path", &temp
))
502 strncpy(gExitPath
, temp
, 32);
504 configGetInt(configOPL
, "autosort", &gAutosort
);
505 configGetInt(configOPL
, "autorefresh", &gAutoRefresh
);
506 configGetInt(configOPL
, "default_device", &gDefaultDevice
);
507 configGetInt(configOPL
, "disable_debug", &gDisableDebug
);
508 configGetInt(configOPL
, "enable_delete_rename", &gEnableDandR
);
509 configGetInt(configOPL
, "hdd_spindown", &gHDDSpindown
);
510 configGetInt(configOPL
, "check_usb_frag", &gCheckUSBFragmentation
);
511 configGetInt(configOPL
, "usb_delay", &gUSBDelay
);
512 if (configGetStr(configOPL
, "usb_prefix", &temp
))
513 strncpy(gUSBPrefix
, temp
, 32);
514 configGetInt(configOPL
, "remember_last", &gRememberLastPlayed
);
515 configGetInt(configOPL
, "usb_mode", &gUSBStartMode
);
516 configGetInt(configOPL
, "hdd_mode", &gHDDStartMode
);
517 configGetInt(configOPL
, "eth_mode", &gETHStartMode
);
518 configGetInt(configOPL
, "app_mode", &gAPPStartMode
);
521 applyConfig(themeID
, langID
);
528 static void _saveConfig() {
529 if (lscstatus
& CONFIG_OPL
) {
530 config_set_t
*configOPL
= configGetByType(CONFIG_OPL
);
531 configSetInt(configOPL
, "scrolling", gScrollSpeed
);
532 configSetStr(configOPL
, "theme", thmGetValue());
533 configSetStr(configOPL
, "language_text", lngGetValue());
534 configSetColor(configOPL
, "bg_color", gDefaultBgColor
);
535 configSetColor(configOPL
, "text_color", gDefaultTextColor
);
536 configSetColor(configOPL
, "ui_text_color", gDefaultUITextColor
);
537 configSetColor(configOPL
, "sel_text_color", gDefaultSelTextColor
);
538 configSetInt(configOPL
, "use_info_screen", gUseInfoScreen
);
539 configSetInt(configOPL
, "enable_coverart", gEnableArt
);
540 configSetInt(configOPL
, "wide_screen", gWideScreen
);
541 configSetInt(configOPL
, "vmode", gVMode
);
542 configSetInt(configOPL
, "vsync", gVSync
);
545 sprintf(temp
, "%d.%d.%d.%d", pc_ip
[0], pc_ip
[1], pc_ip
[2], pc_ip
[3]);
546 configSetStr(configOPL
, "pc_ip", temp
);
547 configSetInt(configOPL
, "pc_port", gPCPort
);
548 configSetStr(configOPL
, "pc_share", gPCShareName
);
549 configSetStr(configOPL
, "pc_user", gPCUserName
);
550 configSetStr(configOPL
, "pc_pass", gPCPassword
);
551 configSetStr(configOPL
, "exit_path", gExitPath
);
552 configSetInt(configOPL
, "autosort", gAutosort
);
553 configSetInt(configOPL
, "autorefresh", gAutoRefresh
);
554 configSetInt(configOPL
, "default_device", gDefaultDevice
);
555 configSetInt(configOPL
, "disable_debug", gDisableDebug
);
556 configSetInt(configOPL
, "enable_delete_rename", gEnableDandR
);
557 configSetInt(configOPL
, "hdd_spindown", gHDDSpindown
);
558 configSetInt(configOPL
, "check_usb_frag", gCheckUSBFragmentation
);
559 configSetInt(configOPL
, "usb_delay", gUSBDelay
);
560 configSetStr(configOPL
, "usb_prefix", gUSBPrefix
);
561 configSetInt(configOPL
, "remember_last", gRememberLastPlayed
);
562 configSetInt(configOPL
, "usb_mode", gUSBStartMode
);
563 configSetInt(configOPL
, "hdd_mode", gHDDStartMode
);
564 configSetInt(configOPL
, "eth_mode", gETHStartMode
);
565 configSetInt(configOPL
, "app_mode", gAPPStartMode
);
568 lscret
= configWriteMulti(lscstatus
);
572 void applyConfig(int themeID
, int langID
) {
573 infotxt
= _l(_STR_WELCOME
);
575 if (gDefaultDevice
< 0 || gDefaultDevice
> APP_MODE
)
576 gDefaultDevice
= APP_MODE
;
578 guiUpdateScrollSpeed();
579 guiUpdateScreenScale();
581 int changed
= rmSetMode(0);
583 // reinit the graphics...
584 thmReloadScreenExtents();
585 guiReloadScreenExtents();
588 // theme must be set after color, and lng after theme
589 changed
= thmSetGuiValue(themeID
, changed
);
591 lngSetGuiValue(langID
);
595 moduleUpdateMenu(USB_MODE
, changed
);
596 moduleUpdateMenu(ETH_MODE
, changed
);
597 moduleUpdateMenu(HDD_MODE
, changed
);
598 moduleUpdateMenu(APP_MODE
, changed
);
601 guiSetFrameHook(&menuUpdateHook
);
603 guiSetFrameHook(NULL
);
606 int loadConfig(int types
) {
610 guiHandleDeferedIO(&lscstatus
, _l(_STR_LOADING_SETTINGS
), IO_CUSTOM_SIMPLEACTION
, &_loadConfig
);
615 int saveConfig(int types
, int showUI
) {
619 guiHandleDeferedIO(&lscstatus
, _l(_STR_SAVING_SETTINGS
), IO_CUSTOM_SIMPLEACTION
, &_saveConfig
);
623 guiMsgBox(_l(_STR_SETTINGS_SAVED
), 0, NULL
);
625 guiMsgBox(_l(_STR_ERROR_SAVING_SETTINGS
), 0, NULL
);
631 // ----------------------------------------------------------
632 // -------------------- HD SRV Support ----------------------
633 // ----------------------------------------------------------
634 extern void *ps2dev9_irx
;
635 extern int size_ps2dev9_irx
;
637 extern void *smsutils_irx
;
638 extern int size_smsutils_irx
;
640 extern void *smstcpip_irx
;
641 extern int size_smstcpip_irx
;
643 extern void *smsmap_irx
;
644 extern int size_smsmap_irx
;
646 extern void *ps2atad_irx
;
647 extern int size_ps2atad_irx
;
649 extern void *ps2hdd_irx
;
650 extern int size_ps2hdd_irx
;
652 extern void *hdldsvr_irx
;
653 extern int size_hdldsvr_irx
;
655 void loadHdldSvr(void) {
657 static char hddarg
[] = "-o" "\0" "4" "\0" "-n" "\0" "20";
658 char ipconfig
[IPCONFIG_MAX_LEN
] __attribute__((aligned(64)));
660 // block all io ops, wait for the ones still running to finish
663 deinitAllSupport(NO_EXCEPTION
);
667 sysReset(SYS_LOAD_PAD_MODULES
);
669 int iplen
= sysSetIPConfig(ipconfig
);
671 ret
= sysLoadModuleBuffer(&ps2dev9_irx
, size_ps2dev9_irx
, 0, NULL
);
675 ret
= sysLoadModuleBuffer(&smsutils_irx
, size_smsutils_irx
, 0, NULL
);
679 ret
= sysLoadModuleBuffer(&smstcpip_irx
, size_smstcpip_irx
, 0, NULL
);
683 ret
= sysLoadModuleBuffer(&smsmap_irx
, size_smsmap_irx
, iplen
, ipconfig
);
687 ret
= sysLoadModuleBuffer(&ps2atad_irx
, size_ps2atad_irx
, 0, NULL
);
691 ret
= sysLoadModuleBuffer(&ps2hdd_irx
, size_ps2hdd_irx
, sizeof(hddarg
), hddarg
);
695 ret
= sysLoadModuleBuffer(&hdldsvr_irx
, size_hdldsvr_irx
, 0, NULL
);
706 // now ready to display some status
709 void unloadHdldSvr(void) {
712 sysReset(SYS_LOAD_MC_MODULES
| SYS_LOAD_PAD_MODULES
);
719 // reinit the input pads
726 // now start io again
729 // init all supports again
733 void handleHdlSrv() {
734 guiRenderTextScreen(_l(_STR_STARTINGHDL
));
736 // prepare for hdl, display screen with info
743 guiRenderTextScreen(_l(_STR_STOPHDL
));
745 guiRenderTextScreen(_l(_STR_RUNNINGHDL
));
751 if(getKeyOn(KEY_CIRCLE
) && terminate
== 0) {
753 } else if(getKeyOn(KEY_CROSS
) && terminate
== 1) {
755 } else if (terminate
> 0)
762 guiRenderTextScreen(_l(_STR_UNLOADHDL
));
764 // restore normal functionality again
768 // ----------------------------------------------------------
769 // --------------------- Init/Deinit ------------------------
770 // ----------------------------------------------------------
771 static void reset(void) {
772 sysReset(SYS_LOAD_MC_MODULES
| SYS_LOAD_PAD_MODULES
);
779 static void moduleCleanup(opl_io_module_t
* mod
, int exception
) {
783 if (mod
->support
->itemCleanUp
)
784 mod
->support
->itemCleanUp(exception
);
787 void shutdown(int exception
) {
797 deinitAllSupport(exception
);
801 static void setDefaults(void) {
805 clearIOModuleT(&list_support
[USB_MODE
]);
806 clearIOModuleT(&list_support
[ETH_MODE
]);
807 clearIOModuleT(&list_support
[HDD_MODE
]);
808 clearIOModuleT(&list_support
[APP_MODE
]);
810 gBaseMCDir
= "mc?:OPL";
812 ps2_ip
[0] = 192; ps2_ip
[1] = 168; ps2_ip
[2] = 0; ps2_ip
[3] = 10;
813 ps2_netmask
[0] = 255; ps2_netmask
[1] = 255; ps2_netmask
[2] = 255; ps2_netmask
[3] = 0;
814 ps2_gateway
[0] = 192; ps2_gateway
[1] = 168; ps2_gateway
[2] = 0; ps2_gateway
[3] = 1;
815 pc_ip
[0] = 192;pc_ip
[1] = 168; pc_ip
[2] = 0; pc_ip
[3] = 2;
817 strncpy(gPCShareName
, "PS2SMB", 32);
818 strncpy(gPCUserName
, "GUEST", 32);
819 strncpy(gPCPassword
, "", 32);
820 gNetworkStartup
= ERROR_ETH_NOT_STARTED
;
823 gIPConfigChanged
= 0;
825 strncpy(gExitPath
, "", 32);
826 gDefaultDevice
= APP_MODE
;
831 gRememberLastPlayed
= 0;
832 gCheckUSBFragmentation
= 1;
834 strncpy(gUSBPrefix
, "", 32);
844 gDefaultBgColor
[0] = 0x028;
845 gDefaultBgColor
[1] = 0x0c5;
846 gDefaultBgColor
[2] = 0x0f9;
848 gDefaultTextColor
[0] = 0x0ff;
849 gDefaultTextColor
[1] = 0x0ff;
850 gDefaultTextColor
[2] = 0x0ff;
852 gDefaultSelTextColor
[0] = 0x0ff;
853 gDefaultSelTextColor
[1] = 0x080;
854 gDefaultSelTextColor
[2] = 0x000;
856 gDefaultUITextColor
[0] = 0x040;
857 gDefaultUITextColor
[1] = 0x080;
858 gDefaultUITextColor
[2] = 0x040;
860 frameCounter
= UPDATE_FRAME_COUNT
;
862 gVMode
= RM_VMODE_AUTO
;
866 static void init(void) {
867 // default variable values
882 // handler for deffered menu updates
883 ioRegisterHandler(IO_MENU_UPDATE_DEFFERED
, &menuDeferredUpdate
);
885 // try to restore config
891 static void deferredInit(void) {
893 // inform GUI main init part is over
894 struct gui_update_t
*id
= guiOpCreate(GUI_INIT_DONE
);
897 if (list_support
[gDefaultDevice
].support
) {
898 id
= guiOpCreate(GUI_OP_SELECT_MENU
);
899 id
->menu
.menu
= &list_support
[gDefaultDevice
].menuItem
;
904 // --------------------- Main --------------------
905 int main(int argc
, char* argv
[])
908 PREINIT_LOG("OPL GUI start!\n");
911 int use_early_debug
= 0, exception_test
= 0;
913 for (i
=1; i
<argc
; i
++) {
914 if (!(strcmp(argv
[i
], "-use-early-debug"))) {
916 PREINIT_LOG("Using early debug.\n");
918 if (!(strcmp(argv
[i
], "-test-exception"))) {
920 PREINIT_LOG("Exception test requested.\n");
925 // apply kernel patches
926 sysApplyKernelPatches();
928 // reset, load modules
932 if (use_early_debug
) {
937 if (exception_test
) {
939 u32
*p
= (u32
*)0xDEADC0DE;
946 // until this point in the code is reached, only PREINIT_LOG macro should be used
949 // queue deffered init which shuts down the intro screen later
950 ioPutRequest(IO_CUSTOM_SIMPLEACTION
, &deferredInit
);