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
, &mode
);
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
)
360 // see if we have to update
361 if (mod
->support
->itemNeedsUpdate()) {
362 mod
->support
->uip
= 1;
363 updateMenuFromGameList(mod
);
364 mod
->support
->uip
= 0;
368 static void menuUpdateHook() {
369 // if timer exceeds some threshold, schedule updates of the available input sources
372 if (frameCounter
> UPDATE_FRAME_COUNT
) {
375 // schedule updates of all the list handlers
376 if (list_support
[USB_MODE
].support
&& list_support
[USB_MODE
].support
->enabled
)
377 ioPutRequest(IO_MENU_UPDATE_DEFFERED
, &list_support
[USB_MODE
].support
->mode
);
378 if (list_support
[ETH_MODE
].support
&& list_support
[ETH_MODE
].support
->enabled
)
379 ioPutRequest(IO_MENU_UPDATE_DEFFERED
, &list_support
[ETH_MODE
].support
->mode
);
380 if (list_support
[HDD_MODE
].support
&& list_support
[HDD_MODE
].support
->enabled
)
381 ioPutRequest(IO_MENU_UPDATE_DEFFERED
, &list_support
[HDD_MODE
].support
->mode
);
382 if (list_support
[APP_MODE
].support
&& list_support
[APP_MODE
].support
->enabled
)
383 ioPutRequest(IO_MENU_UPDATE_DEFFERED
, &list_support
[APP_MODE
].support
->mode
);
387 static void errorMessageHook() {
388 guiMsgBox(errorMessage
, 0, NULL
);
390 // reset the original frame hook
393 guiSetFrameHook(&menuUpdateHook
);
395 guiSetFrameHook(NULL
);
398 void setErrorMessage(int strId
, int error
) {
399 snprintf(errorMessage
, 255, _l(strId
), error
);
400 guiSetFrameHook(&errorMessageHook
);
403 // ----------------------------------------------------------
404 // ------------------ Configuration handling ----------------
405 // ----------------------------------------------------------
407 static int lscstatus
= CONFIG_ALL
;
408 static int lscret
= 0;
410 static int tryAlternateDevice(int types
) {
416 if (usbFindPartition(path
, "conf_opl.cfg")) {
419 value
= configReadMulti(types
);
420 config_set_t
*configOPL
= configGetByType(CONFIG_OPL
);
421 configSetInt(configOPL
, "usb_mode", 2);
427 sprintf(path
, "pfs0:conf_opl.cfg");
428 value
= fioOpen(path
, O_RDONLY
);
433 value
= configReadMulti(types
);
434 config_set_t
*configOPL
= configGetByType(CONFIG_OPL
);
435 configSetInt(configOPL
, "hdd_mode", 2);
439 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)
440 // set config path to either mass or hdd, to prepare the saving of a new config
441 value
= fioDopen("mass0:");
445 configInit("mass0:");
456 static void _loadConfig() {
457 int result
= configReadMulti(lscstatus
);
459 if (lscstatus
& CONFIG_OPL
) {
460 int themeID
= -1, langID
= -1;
462 if (!(result
& CONFIG_OPL
)) {
463 result
= tryAlternateDevice(lscstatus
);
466 if (result
& CONFIG_OPL
) {
467 config_set_t
*configOPL
= configGetByType(CONFIG_OPL
);
470 configGetInt(configOPL
, "scrolling", &gScrollSpeed
);
471 configGetColor(configOPL
, "bg_color", gDefaultBgColor
);
472 configGetColor(configOPL
, "text_color", gDefaultTextColor
);
473 configGetColor(configOPL
, "ui_text_color", gDefaultUITextColor
);
474 configGetColor(configOPL
, "sel_text_color", gDefaultSelTextColor
);
475 configGetInt(configOPL
, "use_info_screen", &gUseInfoScreen
);
476 configGetInt(configOPL
, "enable_coverart", &gEnableArt
);
477 configGetInt(configOPL
, "wide_screen", &gWideScreen
);
478 configGetInt(configOPL
, "vsync", &gVSync
);
479 configGetInt(configOPL
, "vmode", &gVMode
);
482 if (configGetStr(configOPL
, "theme", &temp
))
483 themeID
= thmFindGuiID(temp
);
485 if (configGetStr(configOPL
, "language_text", &temp
))
486 langID
= lngFindGuiID(temp
);
488 if (configGetStr(configOPL
, "pc_ip", &temp
))
489 sscanf(temp
, "%d.%d.%d.%d", &pc_ip
[0], &pc_ip
[1], &pc_ip
[2], &pc_ip
[3]);
491 configGetInt(configOPL
, "pc_port", &gPCPort
);
493 if (configGetStr(configOPL
, "pc_share", &temp
))
494 strncpy(gPCShareName
, temp
, 32);
495 if (configGetStr(configOPL
, "pc_user", &temp
))
496 strncpy(gPCUserName
, temp
, 32);
497 if (configGetStr(configOPL
, "pc_pass", &temp
))
498 strncpy(gPCPassword
, temp
, 32);
499 if (configGetStr(configOPL
, "exit_path", &temp
))
500 strncpy(gExitPath
, temp
, 32);
502 configGetInt(configOPL
, "autosort", &gAutosort
);
503 configGetInt(configOPL
, "autorefresh", &gAutoRefresh
);
504 configGetInt(configOPL
, "default_device", &gDefaultDevice
);
505 configGetInt(configOPL
, "disable_debug", &gDisableDebug
);
506 configGetInt(configOPL
, "enable_delete_rename", &gEnableDandR
);
507 configGetInt(configOPL
, "hdd_spindown", &gHDDSpindown
);
508 configGetInt(configOPL
, "check_usb_frag", &gCheckUSBFragmentation
);
509 configGetInt(configOPL
, "usb_delay", &gUSBDelay
);
510 if (configGetStr(configOPL
, "usb_prefix", &temp
))
511 strncpy(gUSBPrefix
, temp
, 32);
512 if (configGetStr(configOPL
, "eth_prefix", &temp
))
513 strncpy(gETHPrefix
, 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 configSetStr(configOPL
, "eth_prefix", gETHPrefix
);
562 configSetInt(configOPL
, "remember_last", gRememberLastPlayed
);
563 configSetInt(configOPL
, "usb_mode", gUSBStartMode
);
564 configSetInt(configOPL
, "hdd_mode", gHDDStartMode
);
565 configSetInt(configOPL
, "eth_mode", gETHStartMode
);
566 configSetInt(configOPL
, "app_mode", gAPPStartMode
);
569 lscret
= configWriteMulti(lscstatus
);
573 void applyConfig(int themeID
, int langID
) {
574 infotxt
= _l(_STR_WELCOME
);
576 if (gDefaultDevice
< 0 || gDefaultDevice
> APP_MODE
)
577 gDefaultDevice
= APP_MODE
;
579 guiUpdateScrollSpeed();
580 guiUpdateScreenScale();
583 guiSetFrameHook(&menuUpdateHook
);
585 guiSetFrameHook(NULL
);
587 int changed
= rmSetMode(0);
589 // reinit the graphics...
590 thmReloadScreenExtents();
591 guiReloadScreenExtents();
594 // theme must be set after color, and lng after theme
595 changed
= thmSetGuiValue(themeID
, changed
);
597 lngSetGuiValue(langID
);
601 moduleUpdateMenu(USB_MODE
, changed
);
602 moduleUpdateMenu(ETH_MODE
, changed
);
603 moduleUpdateMenu(HDD_MODE
, changed
);
604 moduleUpdateMenu(APP_MODE
, changed
);
607 int loadConfig(int types
) {
611 guiHandleDeferedIO(&lscstatus
, _l(_STR_LOADING_SETTINGS
), IO_CUSTOM_SIMPLEACTION
, &_loadConfig
);
616 int saveConfig(int types
, int showUI
) {
620 guiHandleDeferedIO(&lscstatus
, _l(_STR_SAVING_SETTINGS
), IO_CUSTOM_SIMPLEACTION
, &_saveConfig
);
624 guiMsgBox(_l(_STR_SETTINGS_SAVED
), 0, NULL
);
626 guiMsgBox(_l(_STR_ERROR_SAVING_SETTINGS
), 0, NULL
);
632 // ----------------------------------------------------------
633 // -------------------- HD SRV Support ----------------------
634 // ----------------------------------------------------------
635 extern void *ps2dev9_irx
;
636 extern int size_ps2dev9_irx
;
638 extern void *smsutils_irx
;
639 extern int size_smsutils_irx
;
641 extern void *smstcpip_irx
;
642 extern int size_smstcpip_irx
;
644 extern void *smsmap_irx
;
645 extern int size_smsmap_irx
;
647 extern void *ps2atad_irx
;
648 extern int size_ps2atad_irx
;
650 extern void *ps2hdd_irx
;
651 extern int size_ps2hdd_irx
;
653 extern void *hdldsvr_irx
;
654 extern int size_hdldsvr_irx
;
656 void loadHdldSvr(void) {
658 static char hddarg
[] = "-o" "\0" "4" "\0" "-n" "\0" "20";
659 char ipconfig
[IPCONFIG_MAX_LEN
] __attribute__((aligned(64)));
661 // block all io ops, wait for the ones still running to finish
664 deinitAllSupport(NO_EXCEPTION
);
668 sysReset(SYS_LOAD_PAD_MODULES
);
670 int iplen
= sysSetIPConfig(ipconfig
);
672 ret
= sysLoadModuleBuffer(&ps2dev9_irx
, size_ps2dev9_irx
, 0, NULL
);
676 ret
= sysLoadModuleBuffer(&smsutils_irx
, size_smsutils_irx
, 0, NULL
);
680 ret
= sysLoadModuleBuffer(&smstcpip_irx
, size_smstcpip_irx
, 0, NULL
);
684 ret
= sysLoadModuleBuffer(&smsmap_irx
, size_smsmap_irx
, iplen
, ipconfig
);
688 ret
= sysLoadModuleBuffer(&ps2atad_irx
, size_ps2atad_irx
, 0, NULL
);
692 ret
= sysLoadModuleBuffer(&ps2hdd_irx
, size_ps2hdd_irx
, sizeof(hddarg
), hddarg
);
696 ret
= sysLoadModuleBuffer(&hdldsvr_irx
, size_hdldsvr_irx
, 0, NULL
);
707 // now ready to display some status
710 void unloadHdldSvr(void) {
713 sysReset(SYS_LOAD_MC_MODULES
| SYS_LOAD_PAD_MODULES
);
720 // reinit the input pads
727 // now start io again
730 // init all supports again
734 void handleHdlSrv() {
735 guiRenderTextScreen(_l(_STR_STARTINGHDL
));
737 // prepare for hdl, display screen with info
744 guiRenderTextScreen(_l(_STR_STOPHDL
));
746 guiRenderTextScreen(_l(_STR_RUNNINGHDL
));
752 if(getKeyOn(KEY_CIRCLE
) && terminate
== 0) {
754 } else if(getKeyOn(KEY_CROSS
) && terminate
== 1) {
756 } else if (terminate
> 0)
763 guiRenderTextScreen(_l(_STR_UNLOADHDL
));
765 // restore normal functionality again
769 // ----------------------------------------------------------
770 // --------------------- Init/Deinit ------------------------
771 // ----------------------------------------------------------
772 static void reset(void) {
773 sysReset(SYS_LOAD_MC_MODULES
| SYS_LOAD_PAD_MODULES
);
780 static void moduleCleanup(opl_io_module_t
* mod
, int exception
) {
784 if (mod
->support
->itemCleanUp
)
785 mod
->support
->itemCleanUp(exception
);
788 void shutdown(int exception
) {
798 deinitAllSupport(exception
);
802 static void setDefaults(void) {
806 clearIOModuleT(&list_support
[USB_MODE
]);
807 clearIOModuleT(&list_support
[ETH_MODE
]);
808 clearIOModuleT(&list_support
[HDD_MODE
]);
809 clearIOModuleT(&list_support
[APP_MODE
]);
811 gBaseMCDir
= "mc?:OPL";
813 ps2_ip
[0] = 192; ps2_ip
[1] = 168; ps2_ip
[2] = 0; ps2_ip
[3] = 10;
814 ps2_netmask
[0] = 255; ps2_netmask
[1] = 255; ps2_netmask
[2] = 255; ps2_netmask
[3] = 0;
815 ps2_gateway
[0] = 192; ps2_gateway
[1] = 168; ps2_gateway
[2] = 0; ps2_gateway
[3] = 1;
816 pc_ip
[0] = 192;pc_ip
[1] = 168; pc_ip
[2] = 0; pc_ip
[3] = 2;
818 strncpy(gPCShareName
, "", 32);
819 strncpy(gPCUserName
, "GUEST", 32);
820 strncpy(gPCPassword
, "", 32);
821 gNetworkStartup
= ERROR_ETH_NOT_STARTED
;
824 gIPConfigChanged
= 0;
826 strncpy(gExitPath
, "", 32);
827 gDefaultDevice
= APP_MODE
;
832 gRememberLastPlayed
= 0;
833 gCheckUSBFragmentation
= 1;
835 strncpy(gUSBPrefix
, "", 32);
836 strncpy(gETHPrefix
, "", 32);
846 gDefaultBgColor
[0] = 0x028;
847 gDefaultBgColor
[1] = 0x0c5;
848 gDefaultBgColor
[2] = 0x0f9;
850 gDefaultTextColor
[0] = 0x0ff;
851 gDefaultTextColor
[1] = 0x0ff;
852 gDefaultTextColor
[2] = 0x0ff;
854 gDefaultSelTextColor
[0] = 0x0ff;
855 gDefaultSelTextColor
[1] = 0x080;
856 gDefaultSelTextColor
[2] = 0x000;
858 gDefaultUITextColor
[0] = 0x040;
859 gDefaultUITextColor
[1] = 0x080;
860 gDefaultUITextColor
[2] = 0x040;
862 frameCounter
= UPDATE_FRAME_COUNT
;
864 gVMode
= RM_VMODE_AUTO
;
868 static void init(void) {
869 // default variable values
884 // handler for deffered menu updates
885 ioRegisterHandler(IO_MENU_UPDATE_DEFFERED
, &menuDeferredUpdate
);
887 // try to restore config
893 static void deferredInit(void) {
895 // inform GUI main init part is over
896 struct gui_update_t
*id
= guiOpCreate(GUI_INIT_DONE
);
899 if (list_support
[gDefaultDevice
].support
) {
900 id
= guiOpCreate(GUI_OP_SELECT_MENU
);
901 id
->menu
.menu
= &list_support
[gDefaultDevice
].menuItem
;
906 // --------------------- Main --------------------
907 int main(int argc
, char* argv
[])
910 PREINIT_LOG("OPL GUI start!\n");
913 int use_early_debug
= 0, exception_test
= 0;
915 for (i
=1; i
<argc
; i
++) {
916 if (!(strcmp(argv
[i
], "-use-early-debug"))) {
918 PREINIT_LOG("Using early debug.\n");
920 if (!(strcmp(argv
[i
], "-test-exception"))) {
922 PREINIT_LOG("Exception test requested.\n");
927 // apply kernel patches
928 sysApplyKernelPatches();
930 // reset, load modules
934 if (use_early_debug
) {
939 if (exception_test
) {
941 u32
*p
= (u32
*)0xDEADC0DE;
948 // until this point in the code is reached, only PREINIT_LOG macro should be used
951 // queue deffered init which shuts down the intro screen later
952 ioPutRequest(IO_CUSTOM_SIMPLEACTION
, &deferredInit
);