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 extern void *usbd_irx
;
48 extern int size_usbd_irx
;
53 /// menu item used with this list support
57 submenu_list_t
*subMenu
;
60 static void clearIOModuleT(opl_io_module_t
*mod
) {
63 mod
->menuItem
.execCross
= NULL
;
64 mod
->menuItem
.execCircle
= NULL
;
65 mod
->menuItem
.execSquare
= NULL
;
66 mod
->menuItem
.execTriangle
= NULL
;
67 mod
->menuItem
.hints
= NULL
;
68 mod
->menuItem
.icon_id
= -1;
69 mod
->menuItem
.current
= NULL
;
70 mod
->menuItem
.submenu
= NULL
;
71 mod
->menuItem
.pagestart
= NULL
;
72 mod
->menuItem
.remindLast
= 0;
73 mod
->menuItem
.refresh
= NULL
;
74 mod
->menuItem
.text
= NULL
;
75 mod
->menuItem
.text_id
= -1;
76 mod
->menuItem
.userdata
= NULL
;
80 static void moduleCleanup(opl_io_module_t
* mod
, int exception
);
83 static int frameCounter
;
85 static char errorMessage
[255];
87 static opl_io_module_t list_support
[4];
89 void moduleUpdateMenu(int mode
, int themeChanged
) {
93 opl_io_module_t
* mod
= &list_support
[mode
];
99 menuRemoveHints(&mod
->menuItem
);
101 menuAddHint(&mod
->menuItem
, _STR_SETTINGS
, START_ICON
);
102 if (!mod
->support
->enabled
)
103 menuAddHint(&mod
->menuItem
, _STR_START_DEVICE
, CROSS_ICON
);
105 if (gUseInfoScreen
&& gTheme
->infoElems
.first
)
106 menuAddHint(&mod
->menuItem
, _STR_INFO
, CROSS_ICON
);
108 menuAddHint(&mod
->menuItem
, _STR_RUN
, CROSS_ICON
);
109 if (mod
->support
->haveCompatibilityMode
)
110 menuAddHint(&mod
->menuItem
, _STR_COMPAT_SETTINGS
, TRIANGLE_ICON
);
112 if (mod
->support
->itemRename
)
113 menuAddHint(&mod
->menuItem
, _STR_RENAME
, CIRCLE_ICON
);
114 if (mod
->support
->itemDelete
)
115 menuAddHint(&mod
->menuItem
, _STR_DELETE
, SQUARE_ICON
);
121 submenuRebuildCache(mod
->subMenu
);
124 static void itemExecCross(struct menu_item
*curMenu
) {
125 item_list_t
*support
= curMenu
->userdata
;
128 if (support
->enabled
) {
129 if (curMenu
->current
) {
130 config_set_t
* configSet
= menuLoadConfig();
131 support
->itemLaunch(curMenu
->current
->item
.id
, configSet
);
136 moduleUpdateMenu(support
->mode
, 0);
138 ioPutRequest(IO_MENU_UPDATE_DEFFERED
, &support
->mode
);
142 guiMsgBox("NULL Support object. Please report", 0, NULL
);
145 static void itemExecTriangle(struct menu_item
*curMenu
) {
146 if (!curMenu
->current
)
149 item_list_t
*support
= curMenu
->userdata
;
152 if (support
->haveCompatibilityMode
) {
153 config_set_t
* configSet
= menuLoadConfig();
154 if (guiShowCompatConfig(curMenu
->current
->item
.id
, support
, configSet
) == COMPAT_TEST
)
155 support
->itemLaunch(curMenu
->current
->item
.id
, configSet
);
159 guiMsgBox("NULL Support object. Please report", 0, NULL
);
162 static void itemExecSquare(struct menu_item
*curMenu
) {
163 if (!curMenu
->current
)
169 item_list_t
*support
= curMenu
->userdata
;
172 if (support
->itemDelete
) {
173 if (guiMsgBox(_l(_STR_DELETE_WARNING
), 1, NULL
)) {
174 support
->itemDelete(curMenu
->current
->item
.id
);
176 frameCounter
= UPDATE_FRAME_COUNT
;
178 ioPutRequest(IO_MENU_UPDATE_DEFFERED
, &support
->mode
);
183 guiMsgBox("NULL Support object. Please report", 0, NULL
);
186 static void itemExecCircle(struct menu_item
*curMenu
) {
187 if (!curMenu
->current
)
193 item_list_t
*support
= curMenu
->userdata
;
196 if (support
->itemRename
) {
197 int nameLength
= support
->itemGetNameLength(curMenu
->current
->item
.id
);
198 char newName
[nameLength
];
199 strncpy(newName
, curMenu
->current
->item
.text
, nameLength
);
200 if (guiShowKeyboard(newName
, nameLength
)) {
201 support
->itemRename(curMenu
->current
->item
.id
, newName
);
203 frameCounter
= UPDATE_FRAME_COUNT
;
205 ioPutRequest(IO_MENU_UPDATE_DEFFERED
, &support
->mode
);
210 guiMsgBox("NULL Support object. Please report", 0, NULL
);
213 static void itemExecRefresh(struct menu_item
*curMenu
) {
214 item_list_t
*support
= curMenu
->userdata
;
216 if (support
&& support
->enabled
)
217 ioPutRequest(IO_MENU_UPDATE_DEFFERED
, &support
->mode
);
220 static void initMenuForListSupport(int mode
) {
221 opl_io_module_t
* mod
= &list_support
[mode
];
222 mod
->menuItem
.icon_id
= mod
->support
->iconId
;
223 mod
->menuItem
.text
= NULL
;
224 mod
->menuItem
.text_id
= mod
->support
->textId
;
226 mod
->menuItem
.userdata
= mod
->support
;
230 mod
->menuItem
.submenu
= NULL
;
231 mod
->menuItem
.current
= NULL
;
232 mod
->menuItem
.pagestart
= NULL
;
233 mod
->menuItem
.remindLast
= 0;
235 mod
->menuItem
.refresh
= &itemExecRefresh
;
236 mod
->menuItem
.execCross
= &itemExecCross
;
237 mod
->menuItem
.execTriangle
= &itemExecTriangle
;
238 mod
->menuItem
.execSquare
= &itemExecSquare
;
239 mod
->menuItem
.execCircle
= &itemExecCircle
;
241 mod
->menuItem
.hints
= NULL
;
243 moduleUpdateMenu(mode
, 0);
245 struct gui_update_t
*mc
= guiOpCreate(GUI_OP_ADD_MENU
);
246 mc
->menu
.menu
= &mod
->menuItem
;
247 mc
->menu
.subMenu
= &mod
->subMenu
;
251 static void initSupport(item_list_t
* itemList
, int startMode
, int mode
, int force_reinit
) {
252 opl_io_module_t
* mod
= &list_support
[mode
];
254 itemList
->uip
= 1; // stop updates until we're done with init
255 mod
->support
= itemList
;
256 initMenuForListSupport(mode
);
260 if (((force_reinit
) && (startMode
&& mod
->support
->enabled
)) \
261 || (startMode
== 2 && !mod
->support
->enabled
)) {
262 // stop updates until we're done with init of the device
263 mod
->support
->uip
= 1;
264 mod
->support
->itemInit();
265 moduleUpdateMenu(mode
, 0);
266 mod
->support
->uip
= 0;
269 frameCounter
= UPDATE_FRAME_COUNT
;
271 ioPutRequest(IO_MENU_UPDATE_DEFFERED
, &mod
->support
->mode
); // can't use mode as the variable will die at end of execution
275 static void initAllSupport(int force_reinit
) {
277 initSupport(usbGetObject(0), gUSBStartMode
, USB_MODE
, force_reinit
);
280 initSupport(ethGetObject(0), gETHStartMode
, ETH_MODE
, force_reinit
||(gNetworkStartup
>= ERROR_ETH_SMB_LOGON
));
283 initSupport(hddGetObject(0), gHDDStartMode
, HDD_MODE
, force_reinit
);
286 initSupport(appGetObject(0), gAPPStartMode
, APP_MODE
, force_reinit
);
289 static void deinitAllSupport(int exception
) {
290 moduleCleanup(&list_support
[USB_MODE
], exception
);
291 moduleCleanup(&list_support
[ETH_MODE
], exception
);
292 moduleCleanup(&list_support
[HDD_MODE
], exception
);
293 moduleCleanup(&list_support
[APP_MODE
], exception
);
296 // ----------------------------------------------------------
297 // ----------------------- Updaters -------------------------
298 // ----------------------------------------------------------
299 static void updateMenuFromGameList(opl_io_module_t
* mdl
) {
300 // lock - gui has to be unused here
303 submenuDestroy(&mdl
->subMenu
);
304 mdl
->menuItem
.submenu
= NULL
;
305 mdl
->menuItem
.current
= NULL
;
306 mdl
->menuItem
.pagestart
= NULL
;
307 mdl
->menuItem
.remindLast
= 0;
309 // unlock, the rest is deferred
313 if (gRememberLastPlayed
)
314 configGetStr(configGetByType(CONFIG_LAST
), "last_played", &temp
);
316 // read the new game list
317 struct gui_update_t
*gup
= NULL
;
318 int count
= mdl
->support
->itemUpdate();
322 for (i
= 0; i
< count
; ++i
) {
324 gup
= guiOpCreate(GUI_OP_APPEND_MENU
);
326 gup
->menu
.menu
= &mdl
->menuItem
;
327 gup
->menu
.subMenu
= &mdl
->subMenu
;
329 gup
->submenu
.icon_id
= -1;
331 gup
->submenu
.text
= mdl
->support
->itemGetName(i
);
332 gup
->submenu
.text_id
= -1;
333 gup
->submenu
.selected
= 0;
335 if (gRememberLastPlayed
&& temp
&& strcmp(temp
, mdl
->support
->itemGetStartup(i
)) == 0)
336 gup
->submenu
.selected
= 1;
343 gup
= guiOpCreate(GUI_OP_SORT
);
344 gup
->menu
.menu
= &mdl
->menuItem
;
345 gup
->menu
.subMenu
= &mdl
->subMenu
;
350 void menuDeferredUpdate(void* data
) {
353 opl_io_module_t
* mod
= &list_support
[*mode
];
357 if (mod
->support
->uip
) {
358 ioPutRequest(IO_MENU_UPDATE_DEFFERED
, mode
); // we are busy, so re-post refresh for later
362 // see if we have to update
363 if (mod
->support
->itemNeedsUpdate()) {
364 mod
->support
->uip
= 1;
365 updateMenuFromGameList(mod
);
366 mod
->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
].support
->mode
);
380 if (list_support
[ETH_MODE
].support
&& list_support
[ETH_MODE
].support
->enabled
)
381 ioPutRequest(IO_MENU_UPDATE_DEFFERED
, &list_support
[ETH_MODE
].support
->mode
);
382 if (list_support
[HDD_MODE
].support
&& list_support
[HDD_MODE
].support
->enabled
)
383 ioPutRequest(IO_MENU_UPDATE_DEFFERED
, &list_support
[HDD_MODE
].support
->mode
);
384 if (list_support
[APP_MODE
].support
&& list_support
[APP_MODE
].support
->enabled
)
385 ioPutRequest(IO_MENU_UPDATE_DEFFERED
, &list_support
[APP_MODE
].support
->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 if (configGetStr(configOPL
, "eth_prefix", &temp
))
515 strncpy(gETHPrefix
, temp
, 32);
516 configGetInt(configOPL
, "remember_last", &gRememberLastPlayed
);
517 configGetInt(configOPL
, "usb_mode", &gUSBStartMode
);
518 configGetInt(configOPL
, "hdd_mode", &gHDDStartMode
);
519 configGetInt(configOPL
, "eth_mode", &gETHStartMode
);
520 configGetInt(configOPL
, "app_mode", &gAPPStartMode
);
523 applyConfig(themeID
, langID
);
530 static void _saveConfig() {
531 if (lscstatus
& CONFIG_OPL
) {
532 config_set_t
*configOPL
= configGetByType(CONFIG_OPL
);
533 configSetInt(configOPL
, "scrolling", gScrollSpeed
);
534 configSetStr(configOPL
, "theme", thmGetValue());
535 configSetStr(configOPL
, "language_text", lngGetValue());
536 configSetColor(configOPL
, "bg_color", gDefaultBgColor
);
537 configSetColor(configOPL
, "text_color", gDefaultTextColor
);
538 configSetColor(configOPL
, "ui_text_color", gDefaultUITextColor
);
539 configSetColor(configOPL
, "sel_text_color", gDefaultSelTextColor
);
540 configSetInt(configOPL
, "use_info_screen", gUseInfoScreen
);
541 configSetInt(configOPL
, "enable_coverart", gEnableArt
);
542 configSetInt(configOPL
, "wide_screen", gWideScreen
);
543 configSetInt(configOPL
, "vmode", gVMode
);
544 configSetInt(configOPL
, "vsync", gVSync
);
547 sprintf(temp
, "%d.%d.%d.%d", pc_ip
[0], pc_ip
[1], pc_ip
[2], pc_ip
[3]);
548 configSetStr(configOPL
, "pc_ip", temp
);
549 configSetInt(configOPL
, "pc_port", gPCPort
);
550 configSetStr(configOPL
, "pc_share", gPCShareName
);
551 configSetStr(configOPL
, "pc_user", gPCUserName
);
552 configSetStr(configOPL
, "pc_pass", gPCPassword
);
553 configSetStr(configOPL
, "exit_path", gExitPath
);
554 configSetInt(configOPL
, "autosort", gAutosort
);
555 configSetInt(configOPL
, "autorefresh", gAutoRefresh
);
556 configSetInt(configOPL
, "default_device", gDefaultDevice
);
557 configSetInt(configOPL
, "disable_debug", gDisableDebug
);
558 configSetInt(configOPL
, "enable_delete_rename", gEnableDandR
);
559 configSetInt(configOPL
, "hdd_spindown", gHDDSpindown
);
560 configSetInt(configOPL
, "check_usb_frag", gCheckUSBFragmentation
);
561 configSetInt(configOPL
, "usb_delay", gUSBDelay
);
562 configSetStr(configOPL
, "usb_prefix", gUSBPrefix
);
563 configSetStr(configOPL
, "eth_prefix", gETHPrefix
);
564 configSetInt(configOPL
, "remember_last", gRememberLastPlayed
);
565 configSetInt(configOPL
, "usb_mode", gUSBStartMode
);
566 configSetInt(configOPL
, "hdd_mode", gHDDStartMode
);
567 configSetInt(configOPL
, "eth_mode", gETHStartMode
);
568 configSetInt(configOPL
, "app_mode", gAPPStartMode
);
571 lscret
= configWriteMulti(lscstatus
);
575 void applyConfig(int themeID
, int langID
) {
576 infotxt
= _l(_STR_WELCOME
);
578 if (gDefaultDevice
< 0 || gDefaultDevice
> APP_MODE
)
579 gDefaultDevice
= APP_MODE
;
581 guiUpdateScrollSpeed();
582 guiUpdateScreenScale();
585 guiSetFrameHook(&menuUpdateHook
);
587 guiSetFrameHook(NULL
);
589 int changed
= rmSetMode(0);
591 // reinit the graphics...
592 thmReloadScreenExtents();
593 guiReloadScreenExtents();
596 // theme must be set after color, and lng after theme
597 changed
= thmSetGuiValue(themeID
, changed
);
599 lngSetGuiValue(langID
);
603 moduleUpdateMenu(USB_MODE
, changed
);
604 moduleUpdateMenu(ETH_MODE
, changed
);
605 moduleUpdateMenu(HDD_MODE
, changed
);
606 moduleUpdateMenu(APP_MODE
, changed
);
609 int loadConfig(int types
) {
613 guiHandleDeferedIO(&lscstatus
, _l(_STR_LOADING_SETTINGS
), IO_CUSTOM_SIMPLEACTION
, &_loadConfig
);
618 int saveConfig(int types
, int showUI
) {
622 guiHandleDeferedIO(&lscstatus
, _l(_STR_SAVING_SETTINGS
), IO_CUSTOM_SIMPLEACTION
, &_saveConfig
);
626 guiMsgBox(_l(_STR_SETTINGS_SAVED
), 0, NULL
);
628 guiMsgBox(_l(_STR_ERROR_SAVING_SETTINGS
), 0, NULL
);
634 // ----------------------------------------------------------
635 // -------------------- HD SRV Support ----------------------
636 // ----------------------------------------------------------
637 extern void *ps2dev9_irx
;
638 extern int size_ps2dev9_irx
;
640 extern void *smsutils_irx
;
641 extern int size_smsutils_irx
;
643 extern void *smstcpip_irx
;
644 extern int size_smstcpip_irx
;
646 extern void *smsmap_irx
;
647 extern int size_smsmap_irx
;
649 extern void *ps2atad_irx
;
650 extern int size_ps2atad_irx
;
652 extern void *ps2hdd_irx
;
653 extern int size_ps2hdd_irx
;
655 extern void *hdldsvr_irx
;
656 extern int size_hdldsvr_irx
;
658 void loadHdldSvr(void) {
660 static char hddarg
[] = "-o" "\0" "4" "\0" "-n" "\0" "20";
661 char ipconfig
[IPCONFIG_MAX_LEN
] __attribute__((aligned(64)));
663 // block all io ops, wait for the ones still running to finish
666 deinitAllSupport(NO_EXCEPTION
);
670 sysReset(SYS_LOAD_PAD_MODULES
);
672 int iplen
= sysSetIPConfig(ipconfig
);
674 ret
= sysLoadModuleBuffer(&ps2dev9_irx
, size_ps2dev9_irx
, 0, NULL
);
678 ret
= sysLoadModuleBuffer(&smsutils_irx
, size_smsutils_irx
, 0, NULL
);
682 ret
= sysLoadModuleBuffer(&smstcpip_irx
, size_smstcpip_irx
, 0, NULL
);
686 ret
= sysLoadModuleBuffer(&smsmap_irx
, size_smsmap_irx
, iplen
, ipconfig
);
690 ret
= sysLoadModuleBuffer(&ps2atad_irx
, size_ps2atad_irx
, 0, NULL
);
694 ret
= sysLoadModuleBuffer(&ps2hdd_irx
, size_ps2hdd_irx
, sizeof(hddarg
), hddarg
);
698 ret
= sysLoadModuleBuffer(&hdldsvr_irx
, size_hdldsvr_irx
, 0, NULL
);
709 // now ready to display some status
712 void unloadHdldSvr(void) {
715 sysReset(SYS_LOAD_MC_MODULES
| SYS_LOAD_PAD_MODULES
);
722 // reinit the input pads
729 // now start io again
732 // init all supports again
736 void handleHdlSrv() {
737 guiRenderTextScreen(_l(_STR_STARTINGHDL
));
739 // prepare for hdl, display screen with info
746 guiRenderTextScreen(_l(_STR_STOPHDL
));
748 guiRenderTextScreen(_l(_STR_RUNNINGHDL
));
754 if(getKeyOn(KEY_CIRCLE
) && terminate
== 0) {
756 } else if(getKeyOn(KEY_CROSS
) && terminate
== 1) {
758 } else if (terminate
> 0)
765 guiRenderTextScreen(_l(_STR_UNLOADHDL
));
767 // restore normal functionality again
771 // ----------------------------------------------------------
772 // --------------------- Init/Deinit ------------------------
773 // ----------------------------------------------------------
774 static void reset(void) {
775 sysReset(SYS_LOAD_MC_MODULES
| SYS_LOAD_PAD_MODULES
);
782 static void moduleCleanup(opl_io_module_t
* mod
, int exception
) {
786 if (mod
->support
->itemCleanUp
)
787 mod
->support
->itemCleanUp(exception
);
790 void shutdown(int exception
) {
800 deinitAllSupport(exception
);
804 static void setDefaults(void) {
808 clearIOModuleT(&list_support
[USB_MODE
]);
809 clearIOModuleT(&list_support
[ETH_MODE
]);
810 clearIOModuleT(&list_support
[HDD_MODE
]);
811 clearIOModuleT(&list_support
[APP_MODE
]);
813 gBaseMCDir
= "mc?:OPL";
815 ps2_ip
[0] = 192; ps2_ip
[1] = 168; ps2_ip
[2] = 0; ps2_ip
[3] = 10;
816 ps2_netmask
[0] = 255; ps2_netmask
[1] = 255; ps2_netmask
[2] = 255; ps2_netmask
[3] = 0;
817 ps2_gateway
[0] = 192; ps2_gateway
[1] = 168; ps2_gateway
[2] = 0; ps2_gateway
[3] = 1;
818 pc_ip
[0] = 192;pc_ip
[1] = 168; pc_ip
[2] = 0; pc_ip
[3] = 2;
820 strncpy(gPCShareName
, "", 32);
821 strncpy(gPCUserName
, "GUEST", 32);
822 strncpy(gPCPassword
, "", 32);
823 gNetworkStartup
= ERROR_ETH_NOT_STARTED
;
826 gIPConfigChanged
= 0;
828 strncpy(gExitPath
, "", 32);
829 gDefaultDevice
= APP_MODE
;
834 gRememberLastPlayed
= 0;
835 gCheckUSBFragmentation
= 1;
837 strncpy(gUSBPrefix
, "", 32);
838 strncpy(gETHPrefix
, "", 32);
848 gDefaultBgColor
[0] = 0x028;
849 gDefaultBgColor
[1] = 0x0c5;
850 gDefaultBgColor
[2] = 0x0f9;
852 gDefaultTextColor
[0] = 0x0ff;
853 gDefaultTextColor
[1] = 0x0ff;
854 gDefaultTextColor
[2] = 0x0ff;
856 gDefaultSelTextColor
[0] = 0x0ff;
857 gDefaultSelTextColor
[1] = 0x080;
858 gDefaultSelTextColor
[2] = 0x000;
860 gDefaultUITextColor
[0] = 0x040;
861 gDefaultUITextColor
[1] = 0x080;
862 gDefaultUITextColor
[2] = 0x040;
864 frameCounter
= UPDATE_FRAME_COUNT
;
866 gVMode
= RM_VMODE_AUTO
;
870 static void init(void) {
871 // default variable values
886 // handler for deffered menu updates
887 ioRegisterHandler(IO_MENU_UPDATE_DEFFERED
, &menuDeferredUpdate
);
889 // try to restore config
895 static void deferredInit(void) {
897 // inform GUI main init part is over
898 struct gui_update_t
*id
= guiOpCreate(GUI_INIT_DONE
);
901 if (list_support
[gDefaultDevice
].support
) {
902 id
= guiOpCreate(GUI_OP_SELECT_MENU
);
903 id
->menu
.menu
= &list_support
[gDefaultDevice
].menuItem
;
908 // --------------------- Main --------------------
909 int main(int argc
, char* argv
[])
912 PREINIT_LOG("OPL GUI start!\n");
915 int use_early_debug
= 0, exception_test
= 0;
917 for (i
=1; i
<argc
; i
++) {
918 if (!(strcmp(argv
[i
], "-use-early-debug"))) {
920 PREINIT_LOG("OPL Using early debug.\n");
922 if (!(strcmp(argv
[i
], "-test-exception"))) {
924 PREINIT_LOG("OPL Exception test requested.\n");
929 // apply kernel patches
930 sysApplyKernelPatches();
932 // reset, load modules
936 if (use_early_debug
) {
941 if (exception_test
) {
943 u32
*p
= (u32
*)0xDEADC0DE;
950 // until this point in the code is reached, only PREINIT_LOG macro should be used
953 // queue deffered init which shuts down the intro screen later
954 ioPutRequest(IO_CUSTOM_SIMPLEACTION
, &deferredInit
);