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
) {
415 config_set_t
*configOPL
= configGetByType(CONFIG_OPL
);
419 if (usbFindPartition(path
, "conf_opl.cfg")) {
422 value
= configReadMulti(types
);
423 configSetInt(configOPL
, "usb_mode", 2);
429 sprintf(path
, "pfs0:conf_opl.cfg");
430 value
= fioOpen(path
, O_RDONLY
);
435 value
= configReadMulti(types
);
436 configSetInt(configOPL
, "hdd_mode", 2);
440 if (sysCheckMC() < 0) { // We don't want to get users into alternate mode for their very first of OPL (i.e no config file at all, but still want to save on MC)
441 // set config path to either mass or hdd, to prepare the saving of a new config
442 value
= fioDopen("mass0:");
446 configInit("mass0:");
457 static void _loadConfig() {
458 int result
= configReadMulti(lscstatus
);
460 if (lscstatus
& CONFIG_OPL
) {
461 int themeID
= -1, langID
= -1;
463 if (!(result
& CONFIG_OPL
)) {
464 result
= tryAlternateDevice(lscstatus
);
467 if (result
& CONFIG_OPL
) {
468 config_set_t
*configOPL
= configGetByType(CONFIG_OPL
);
471 configGetInt(configOPL
, "scrolling", &gScrollSpeed
);
472 configGetColor(configOPL
, "bg_color", gDefaultBgColor
);
473 configGetColor(configOPL
, "text_color", gDefaultTextColor
);
474 configGetColor(configOPL
, "ui_text_color", gDefaultUITextColor
);
475 configGetColor(configOPL
, "sel_text_color", gDefaultSelTextColor
);
476 configGetInt(configOPL
, "use_info_screen", &gUseInfoScreen
);
477 configGetInt(configOPL
, "enable_coverart", &gEnableArt
);
478 configGetInt(configOPL
, "wide_screen", &gWideScreen
);
480 if (configGetStr(configOPL
, "theme", &temp
))
481 themeID
= thmFindGuiID(temp
);
483 if (configGetStr(configOPL
, "language_text", &temp
))
484 langID
= lngFindGuiID(temp
);
486 if (configGetStr(configOPL
, "pc_ip", &temp
))
487 sscanf(temp
, "%d.%d.%d.%d", &pc_ip
[0], &pc_ip
[1], &pc_ip
[2], &pc_ip
[3]);
489 configGetInt(configOPL
, "pc_port", &gPCPort
);
491 if (configGetStr(configOPL
, "pc_share", &temp
))
492 strncpy(gPCShareName
, temp
, 32);
493 if (configGetStr(configOPL
, "pc_user", &temp
))
494 strncpy(gPCUserName
, temp
, 32);
495 if (configGetStr(configOPL
, "pc_pass", &temp
))
496 strncpy(gPCPassword
, temp
, 32);
497 if (configGetStr(configOPL
, "exit_path", &temp
))
498 strncpy(gExitPath
, temp
, 32);
500 configGetInt(configOPL
, "autosort", &gAutosort
);
501 configGetInt(configOPL
, "autorefresh", &gAutoRefresh
);
502 configGetInt(configOPL
, "default_device", &gDefaultDevice
);
503 configGetInt(configOPL
, "disable_debug", &gDisableDebug
);
504 configGetInt(configOPL
, "enable_delete_rename", &gEnableDandR
);
505 configGetInt(configOPL
, "hdd_spindown", &gHDDSpindown
);
506 configGetInt(configOPL
, "check_usb_frag", &gCheckUSBFragmentation
);
507 configGetInt(configOPL
, "usb_delay", &gUSBDelay
);
508 if (configGetStr(configOPL
, "usb_prefix", &temp
))
509 strncpy(gUSBPrefix
, temp
, 32);
510 configGetInt(configOPL
, "remember_last", &gRememberLastPlayed
);
511 configGetInt(configOPL
, "usb_mode", &gUSBStartMode
);
512 configGetInt(configOPL
, "hdd_mode", &gHDDStartMode
);
513 configGetInt(configOPL
, "eth_mode", &gETHStartMode
);
514 configGetInt(configOPL
, "app_mode", &gAPPStartMode
);
517 applyConfig(themeID
, langID
, gVMode
, gVSync
);
524 static void _saveConfig() {
525 if (lscstatus
& CONFIG_OPL
) {
526 config_set_t
*configOPL
= configGetByType(CONFIG_OPL
);
527 configSetInt(configOPL
, "scrolling", gScrollSpeed
);
528 configSetStr(configOPL
, "theme", thmGetValue());
529 configSetStr(configOPL
, "language_text", lngGetValue());
530 configSetColor(configOPL
, "bg_color", gDefaultBgColor
);
531 configSetColor(configOPL
, "text_color", gDefaultTextColor
);
532 configSetColor(configOPL
, "ui_text_color", gDefaultUITextColor
);
533 configSetColor(configOPL
, "sel_text_color", gDefaultSelTextColor
);
534 configSetInt(configOPL
, "use_info_screen", gUseInfoScreen
);
535 configSetInt(configOPL
, "enable_coverart", gEnableArt
);
536 configSetInt(configOPL
, "wide_screen", gWideScreen
);
539 sprintf(temp
, "%d.%d.%d.%d", pc_ip
[0], pc_ip
[1], pc_ip
[2], pc_ip
[3]);
540 configSetStr(configOPL
, "pc_ip", temp
);
541 configSetInt(configOPL
, "pc_port", gPCPort
);
542 configSetStr(configOPL
, "pc_share", gPCShareName
);
543 configSetStr(configOPL
, "pc_user", gPCUserName
);
544 configSetStr(configOPL
, "pc_pass", gPCPassword
);
545 configSetStr(configOPL
, "exit_path", gExitPath
);
546 configSetInt(configOPL
, "autosort", gAutosort
);
547 configSetInt(configOPL
, "autorefresh", gAutoRefresh
);
548 configSetInt(configOPL
, "default_device", gDefaultDevice
);
549 configSetInt(configOPL
, "disable_debug", gDisableDebug
);
550 configSetInt(configOPL
, "enable_delete_rename", gEnableDandR
);
551 configSetInt(configOPL
, "hdd_spindown", gHDDSpindown
);
552 configSetInt(configOPL
, "check_usb_frag", gCheckUSBFragmentation
);
553 configSetInt(configOPL
, "usb_delay", gUSBDelay
);
554 configSetStr(configOPL
, "usb_prefix", gUSBPrefix
);
555 configSetInt(configOPL
, "remember_last", gRememberLastPlayed
);
556 configSetInt(configOPL
, "usb_mode", gUSBStartMode
);
557 configSetInt(configOPL
, "hdd_mode", gHDDStartMode
);
558 configSetInt(configOPL
, "eth_mode", gETHStartMode
);
559 configSetInt(configOPL
, "app_mode", gAPPStartMode
);
562 lscret
= configWriteMulti(lscstatus
);
566 void applyConfig(int themeID
, int langID
, int newVMode
, int newVSync
) {
567 infotxt
= _l(_STR_WELCOME
);
569 if (gDefaultDevice
< 0 || gDefaultDevice
> APP_MODE
)
570 gDefaultDevice
= APP_MODE
;
572 guiUpdateScrollSpeed();
573 guiUpdateScreenScale();
575 // we don't want to set the vmode without a reason...
576 int changed
= (gVMode
!= newVMode
|| gVSync
!= newVSync
);
578 // reinit the graphics...
581 rmSetMode(gVSync
, gVMode
);
583 thmReloadScreenExtents();
584 guiReloadScreenExtents();
586 // also propagate to vmode cfg
587 config_set_t
* configVMode
= configGetByType(CONFIG_VMODE
);
589 configSetInt(configVMode
, "vmode", newVMode
);
590 configSetInt(configVMode
, "vsync", newVSync
);
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 guiSetFrameHook(&menuUpdateHook
);
609 guiSetFrameHook(NULL
);
612 int loadConfig(int types
) {
616 guiHandleDeferedIO(&lscstatus
, _l(_STR_LOADING_SETTINGS
), IO_CUSTOM_SIMPLEACTION
, &_loadConfig
);
621 int saveConfig(int types
, int showUI
) {
625 guiHandleDeferedIO(&lscstatus
, _l(_STR_SAVING_SETTINGS
), IO_CUSTOM_SIMPLEACTION
, &_saveConfig
);
629 guiMsgBox(_l(_STR_SETTINGS_SAVED
), 0, NULL
);
631 guiMsgBox(_l(_STR_ERROR_SAVING_SETTINGS
), 0, NULL
);
637 // ----------------------------------------------------------
638 // -------------------- HD SRV Support ----------------------
639 // ----------------------------------------------------------
640 extern void *ps2dev9_irx
;
641 extern int size_ps2dev9_irx
;
643 extern void *smsutils_irx
;
644 extern int size_smsutils_irx
;
646 extern void *smstcpip_irx
;
647 extern int size_smstcpip_irx
;
649 extern void *smsmap_irx
;
650 extern int size_smsmap_irx
;
652 extern void *ps2atad_irx
;
653 extern int size_ps2atad_irx
;
655 extern void *ps2hdd_irx
;
656 extern int size_ps2hdd_irx
;
658 extern void *hdldsvr_irx
;
659 extern int size_hdldsvr_irx
;
661 void loadHdldSvr(void) {
663 static char hddarg
[] = "-o" "\0" "4" "\0" "-n" "\0" "20";
664 char ipconfig
[IPCONFIG_MAX_LEN
] __attribute__((aligned(64)));
666 // block all io ops, wait for the ones still running to finish
669 deinitAllSupport(NO_EXCEPTION
);
673 sysReset(SYS_LOAD_PAD_MODULES
);
675 int iplen
= sysSetIPConfig(ipconfig
);
677 ret
= sysLoadModuleBuffer(&ps2dev9_irx
, size_ps2dev9_irx
, 0, NULL
);
681 ret
= sysLoadModuleBuffer(&smsutils_irx
, size_smsutils_irx
, 0, NULL
);
685 ret
= sysLoadModuleBuffer(&smstcpip_irx
, size_smstcpip_irx
, 0, NULL
);
689 ret
= sysLoadModuleBuffer(&smsmap_irx
, size_smsmap_irx
, iplen
, ipconfig
);
693 ret
= sysLoadModuleBuffer(&ps2atad_irx
, size_ps2atad_irx
, 0, NULL
);
697 ret
= sysLoadModuleBuffer(&ps2hdd_irx
, size_ps2hdd_irx
, sizeof(hddarg
), hddarg
);
701 ret
= sysLoadModuleBuffer(&hdldsvr_irx
, size_hdldsvr_irx
, 0, NULL
);
712 // now ready to display some status
715 void unloadHdldSvr(void) {
718 sysReset(SYS_LOAD_MC_MODULES
| SYS_LOAD_PAD_MODULES
);
725 // reinit the input pads
732 // now start io again
735 // init all supports again
739 void handleHdlSrv() {
740 guiRenderTextScreen(_l(_STR_STARTINGHDL
));
742 // prepare for hdl, display screen with info
749 guiRenderTextScreen(_l(_STR_STOPHDL
));
751 guiRenderTextScreen(_l(_STR_RUNNINGHDL
));
757 if(getKeyOn(KEY_CIRCLE
) && terminate
== 0) {
759 } else if(getKeyOn(KEY_CROSS
) && terminate
== 1) {
761 } else if (terminate
> 0)
768 guiRenderTextScreen(_l(_STR_UNLOADHDL
));
770 // restore normal functionality again
774 // ----------------------------------------------------------
775 // --------------------- Init/Deinit ------------------------
776 // ----------------------------------------------------------
777 static void reset(void) {
778 sysReset(SYS_LOAD_MC_MODULES
| SYS_LOAD_PAD_MODULES
);
785 static void moduleCleanup(opl_io_module_t
* mod
, int exception
) {
789 if (mod
->support
->itemCleanUp
)
790 mod
->support
->itemCleanUp(exception
);
793 void shutdown(int exception
) {
803 deinitAllSupport(exception
);
807 static void setDefaults(void) {
811 clearIOModuleT(&list_support
[USB_MODE
]);
812 clearIOModuleT(&list_support
[ETH_MODE
]);
813 clearIOModuleT(&list_support
[HDD_MODE
]);
814 clearIOModuleT(&list_support
[APP_MODE
]);
816 gBaseMCDir
= "mc?:OPL";
818 ps2_ip
[0] = 192; ps2_ip
[1] = 168; ps2_ip
[2] = 0; ps2_ip
[3] = 10;
819 ps2_netmask
[0] = 255; ps2_netmask
[1] = 255; ps2_netmask
[2] = 255; ps2_netmask
[3] = 0;
820 ps2_gateway
[0] = 192; ps2_gateway
[1] = 168; ps2_gateway
[2] = 0; ps2_gateway
[3] = 1;
821 pc_ip
[0] = 192;pc_ip
[1] = 168; pc_ip
[2] = 0; pc_ip
[3] = 2;
823 strncpy(gPCShareName
, "PS2SMB", 32);
824 strncpy(gPCUserName
, "GUEST", 32);
825 strncpy(gPCPassword
, "", 32);
826 gNetworkStartup
= ERROR_ETH_NOT_STARTED
;
829 gIPConfigChanged
= 0;
831 strncpy(gExitPath
, "", 32);
832 gDefaultDevice
= APP_MODE
;
837 gRememberLastPlayed
= 0;
838 gCheckUSBFragmentation
= 1;
840 strncpy(gUSBPrefix
, "", 32);
850 gDefaultBgColor
[0] = 0x028;
851 gDefaultBgColor
[1] = 0x0c5;
852 gDefaultBgColor
[2] = 0x0f9;
854 gDefaultTextColor
[0] = 0x0ff;
855 gDefaultTextColor
[1] = 0x0ff;
856 gDefaultTextColor
[2] = 0x0ff;
858 gDefaultSelTextColor
[0] = 0x0ff;
859 gDefaultSelTextColor
[1] = 0x080;
860 gDefaultSelTextColor
[2] = 0x000;
862 gDefaultUITextColor
[0] = 0x040;
863 gDefaultUITextColor
[1] = 0x080;
864 gDefaultUITextColor
[2] = 0x040;
866 frameCounter
= UPDATE_FRAME_COUNT
;
868 gVMode
= RM_VMODE_AUTO
;
873 config_set_t
* configVMode
= configGetByType(CONFIG_VMODE
);
876 if (configRead(configVMode
) == CONFIG_VMODE
) {
877 if (!configGetInt(configVMode
, "vsync", &gVSync
))
880 if (!configGetInt(configVMode
, "vmode", &gVMode
))
881 gVMode
= RM_VMODE_AUTO
;
885 rmInit(gVSync
, gVMode
);
888 static void init(void) {
889 // default variable values
895 // Loads the vmode config from MCs, then sets the vmode
906 // handler for deffered menu updates
907 ioRegisterHandler(IO_MENU_UPDATE_DEFFERED
, &menuDeferredUpdate
);
909 // try to restore config
915 static void deferredInit(void) {
917 // inform GUI main init part is over
918 struct gui_update_t
*id
= guiOpCreate(GUI_INIT_DONE
);
921 if (list_support
[gDefaultDevice
].support
) {
922 id
= guiOpCreate(GUI_OP_SELECT_MENU
);
923 id
->menu
.menu
= &list_support
[gDefaultDevice
].menuItem
;
928 // --------------------- Main --------------------
929 int main(int argc
, char* argv
[])
932 PREINIT_LOG("OPL GUI start!\n");
935 int use_early_debug
= 0, exception_test
= 0;
937 for (i
=1; i
<argc
; i
++) {
938 if (!(strcmp(argv
[i
], "-use-early-debug"))) {
940 PREINIT_LOG("Using early debug.\n");
942 if (!(strcmp(argv
[i
], "-test-exception"))) {
944 PREINIT_LOG("Exception test requested.\n");
949 // apply kernel patches
950 sysApplyKernelPatches();
952 // reset, load modules
956 if (use_early_debug
) {
961 if (exception_test
) {
963 u32
*p
= (u32
*)0xDEADC0DE;
970 // until this point in the code is reached, only PREINIT_LOG macro should be used
973 // queue deffered init which shuts down the intro screen later
974 ioPutRequest(IO_CUSTOM_SIMPLEACTION
, &deferredInit
);