-
Notifications
You must be signed in to change notification settings - Fork 52
/
main.c
2580 lines (2390 loc) · 88.3 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//---------------------------------------------------------------------------
// File name: main.c
//---------------------------------------------------------------------------
#include "launchelf.h"
#ifdef SMB
#include "SMB_test.h"
#include "ps2smb.h"
#endif
extern u8 iomanx_irx[];
extern int size_iomanx_irx;
extern u8 filexio_irx[];
extern int size_filexio_irx;
extern u8 ps2dev9_irx[];
extern int size_ps2dev9_irx;
extern u8 ps2ip_irx[];
extern int size_ps2ip_irx;
extern u8 netman_irx[];
extern int size_netman_irx;
extern u8 ps2smap_irx[];
extern int size_ps2smap_irx;
extern u8 ps2host_irx[];
extern int size_ps2host_irx;
#ifdef SMB
extern u8 smbman_irx[];
extern int size_smbman_irx;
#endif
extern u8 vmc_fs_irx[];
extern int size_vmc_fs_irx;
extern u8 ps2ftpd_irx[];
extern int size_ps2ftpd_irx;
extern u8 ps2atad_irx[];
extern int size_ps2atad_irx;
extern u8 ps2hdd_irx[];
extern int size_ps2hdd_irx;
extern u8 ps2fs_irx[];
extern int size_ps2fs_irx;
extern u8 poweroff_irx[];
extern int size_poweroff_irx;
extern u8 loader_elf;
extern int size_loader_elf;
extern u8 ps2netfs_irx[];
extern int size_ps2netfs_irx;
extern u8 iopmod_irx[];
extern int size_iopmod_irx;
extern u8 usbd_irx[];
extern int size_usbd_irx;
extern u8 bdm_irx[];
extern int size_bdm_irx;
extern u8 bdmfs_fatfs_irx[];
extern int size_bdmfs_fatfs_irx;
extern u8 usbmass_bd_irx[];
extern int size_usbmass_bd_irx;
extern u8 cdfs_irx[];
extern int size_cdfs_irx;
extern u8 ps2kbd_irx[];
extern int size_ps2kbd_irx;
extern u8 hdl_info_irx[];
extern int size_hdl_info_irx;
extern u8 mcman_irx[];
extern int size_mcman_irx;
extern u8 mcserv_irx[];
extern int size_mcserv_irx;
#ifdef SIO_DEBUG
extern u8 sior_irx[];
extern int size_sior_irx;
#endif
extern u8 allowdvdv_irx[];
extern int size_allowdvdv_irx;
extern u8 dvrdrv_irx[];
extern int size_dvrdrv_irx;
extern u8 dvrfile_irx[];
extern int size_dvrfile_irx;
//#define DEBUG
#ifdef DEBUG
#define dbgprintf(args...) scr_printf(args)
#define dbginit_scr() init_scr()
#else
#define dbgprintf(args...) \
do { \
} while (0)
#define dbginit_scr() \
do { \
} while (0)
#endif
enum {
BUTTON,
DPAD
};
int TV_mode;
int selected = 0;
int timeout = 0, prev_timeout = 1;
int init_delay = 0, prev_init_delay = 1;
int mode = BUTTON;
int user_acted = 0; /* Set when commands given, to break timeout */
char LaunchElfDir[MAX_PATH], mainMsg[MAX_PATH * 2];
char CNF[MAX_NAME];
int numCNF = 0;
int maxCNF;
int swapKeys;
int GUI_active;
u64 WaitTime;
u64 CurrTime;
u64 init_delay_start;
u64 timeout_start;
#define IPCONF_MAX_LEN (3 * 16)
char if_conf[IPCONF_MAX_LEN];
int if_conf_len;
char ip[16] = "192.168.0.10";
char netmask[16] = "255.255.255.0";
char gw[16] = "192.168.0.1";
char netConfig[IPCONF_MAX_LEN + 128]; // Adjust size as needed
// State of module collections
static u8 have_NetModules = 0;
static u8 have_HDD_modules = 0;
static u8 have_DVRP_HDD_modules = 0;
// State of Uncheckable Modules (invalid header)
static u8 have_cdvd = 0;
static u8 have_usbd = 0;
static u8 have_usb_mass = 0;
static u8 have_ps2smap = 0;
static u8 have_ps2host = 0;
static u8 have_ps2ftpd = 0;
static u8 have_ps2kbd = 0;
static u8 have_hdl_info = 0;
// State of Checkable Modules (valid header)
static u8 have_poweroff = 0;
static u8 have_ps2dev9 = 0;
static u8 have_netman = 0;
static u8 have_ps2ip = 0;
static u8 have_ps2atad = 0;
static u8 have_ps2hdd = 0;
static u8 have_ps2fs = 0;
static u8 have_ps2netfs = 0;
static u8 have_smbman = 0;
static u8 have_vmc_fs = 0;
static u8 have_dvrdrv = 0;
static u8 have_dvrfile = 0;
// State of whether DEV9 was successfully loaded or not.
static u8 ps2dev9_loaded = 0;
// State of whether the UI has been initialized.
// Use this to determine whether code that loads a device's driver(s) can print onto the screen.
static u8 is_early_init = 1;
static int menu_LK[SETTING_LK_BTN_COUNT]; // holds RunElf index for each valid main menu entry
static u8 done_setupPowerOff = 0;
static u8 ps2kbd_opened = 0;
static int boot_argc;
static char *boot_argv[8];
static char boot_path[MAX_PATH];
// Variables for SYSTEM.CNF processing
int BootDiscType = 0;
char SystemCnf_BOOT[MAX_PATH];
char SystemCnf_BOOT2[MAX_PATH];
char SystemCnf_VER[10]; // Arbitrary. Real value should always be shorter
char SystemCnf_VMODE[10]; // Arbitrary, same deal. As yet unused
char default_ESR_path[] = "mc:/BOOT/ESR.ELF";
char default_OSDSYS_path[30];
char ROMVER_data[16]; // 16 byte file read from rom0:ROMVER at init
char rough_region; // E==Europe, A==US, I==Japan, H==Asia, C==China
int cdmode; // Last detected disc type
int old_cdmode; // used for disc change detection
int uLE_cdmode; // used for smart disc detection
#define SCECdESRDVD_0 0x15 // ESR-patched DVD, as seen without ESR driver active
#define SCECdESRDVD_1 0x16 // ESR-patched DVD, as seen with ESR driver active
typedef struct
{
int type;
char name[16];
} DiscType;
DiscType DiscTypes[] = {
{SCECdNODISC, "!"},
{SCECdDETCT, "??"},
{SCECdDETCTCD, "CD ?"},
{SCECdDETCTDVDS, "DVD-SL ?"},
{SCECdDETCTDVDD, "DVD-DL ?"},
{SCECdUNKNOWN, "Unknown"},
{SCECdPSCD, "PS1 CD"},
{SCECdPSCDDA, "PS1 CDDA"},
{SCECdPS2CD, "PS2 CD"},
{SCECdPS2CDDA, "PS2 CDDA"},
{SCECdPS2DVD, "PS2 DVD"},
{SCECdESRDVD_0, "ESR DVD (off)"},
{SCECdESRDVD_1, "ESR DVD (on)"},
{SCECdCDDA, "Audio CD"},
{SCECdDVDV, "Video DVD"},
{SCECdIllegalMedia, "Unsupported"},
{0x00, ""} // end of list
}; // ends DiscTypes array
// Static function declarations
static int PrintRow(int row_f, const char *text_p);
static int PrintPos(int row_f, int column, const char *text_p);
static void Show_About_uLE(void);
static void getIpConfig(void);
static void setLaunchKeys(void);
static int drawMainScreen(void);
static int drawMainScreen2(int TV_mode);
static void delay(int count);
static void initsbv_patches(void);
static void load_ps2dev9(void);
static void load_ps2ip(void);
static void load_ps2atad(void);
#ifdef SMB
static void load_smbman(void);
#endif
static void ShowDebugInfo(void);
static void load_ps2ftpd(void);
static void load_ps2netfs(void);
static void loadBasicModules(void);
static void loadCdModules(void);
static int loadExternalFile(const char *argPath, void **fileBaseP, int *fileSizeP);
static int loadExternalModule(const char *modPath, void *defBase, int defSize);
static void loadUsbDModule(void);
static void loadUsbModules(void);
static void loadKbdModules(void);
static void closeAllAndPoweroff(void);
static void poweroffHandler(int i);
static void setupPowerOff(void);
static void loadNetModules(void);
static void startKbd(void);
static int scanSystemCnf(const char *name, const char *value);
static int readSystemCnf(void);
static void ShowFont(void);
static void Validate_CNF_Path(void);
static void Set_CNF_Path(void);
static int reloadConfig(void);
static void decConfig(void);
static void incConfig(void);
static int exists(char *path);
static void CleanUp(void);
static void Execute(const char *pathin);
static void Reset(void);
static void InitializeBootExecPath();
//---------------------------------------------------------------------------
// executable code
//---------------------------------------------------------------------------
// Function to print a text row to the 'gs' screen
//------------------------------
static int PrintRow(int row_f, const char *text_p)
{
static int row;
int x = (Menu_start_x + 4);
int y;
if (row_f >= 0)
row = row_f;
y = (Menu_start_y + FONT_HEIGHT * row++);
printXY(text_p, x, y, setting->color[COLOR_TEXT], TRUE, 0);
return row;
}
//------------------------------
// endfunc PrintRow
//---------------------------------------------------------------------------
// Function to print a text row with text positioning
//------------------------------
static int PrintPos(int row_f, int column, const char *text_p)
{
static int row;
int x = (Menu_start_x + 4 + column * FONT_WIDTH);
int y;
if (row_f >= 0)
row = row_f;
y = (Menu_start_y + FONT_HEIGHT * row++);
printXY(text_p, x, y, setting->color[COLOR_TEXT], TRUE, 0);
return row;
}
//------------------------------
// endfunc PrintPos
//---------------------------------------------------------------------------
// Function to show a screen with program credits ("About uLE")
//------------------------------
static void Show_About_uLE(void)
{
char TextRow[256];
int event, post_event = 0;
int hpos = 16;
event = 1; // event = initial entry
//----- Start of event loop -----
while (1) {
// Pad response section
waitAnyPadReady();
if (readpad() && new_pad) {
if (setting->GUI_skin[0]) {
GUI_active = 1;
loadSkin(BACKGROUND_PIC, 0, 0);
}
break;
}
// Display section
if (event || post_event) { // NB: We need to update two frame buffers per event
clrScr(setting->color[COLOR_BACKGR]);
sprintf(TextRow, "About wLaunchELF %s %s", ULE_VERSION, ULE_VERDATE);
PrintPos(03, hpos, TextRow);
sprintf(TextRow, " commit: %s", GIT_HASH);
PrintPos(04, hpos, TextRow);
PrintPos(05, hpos, "Project maintainers:");
PrintPos(-1, hpos, " sp193");
PrintPos(-1, hpos, " AKuHAK");
PrintPos(-1, hpos, "");
PrintPos(-1, hpos, "uLaunchELF Project maintainers:");
PrintPos(-1, hpos, " Eric Price (aka: 'E P')");
PrintPos(-1, hpos, " Ronald Andersson (aka: 'dlanor')");
PrintPos(-1, hpos, "");
PrintPos(-1, hpos, "Other contributors:");
PrintPos(-1, hpos, " Polo35, radad, Drakonite, sincro");
PrintPos(-1, hpos, " kthu, Slam-Tilt, chip, pixel, Hermes");
PrintPos(-1, hpos, " and others in the PS2Dev community");
PrintPos(-1, hpos, "");
PrintPos(-1, hpos, "Main release site:");
PrintPos(-1, hpos, " \"https://github.com/ps2homebrew/wLaunchELF/releases\"");
PrintPos(-1, hpos, "");
PrintPos(-1, hpos, "Ancestral project: LaunchELF v3.41");
PrintPos(-1, hpos, "Created by: Mirakichi");
} // ends if(event||post_event)
drawScr();
post_event = event;
event = 0;
}
// ends while
//----- End of event loop -----
}
//------------------------------
// endfunc Show_About_uLE
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Parse network configuration from IPCONFIG.DAT
// Now completely rewritten to fix some problems
//------------------------------
static void getIpConfig(void)
{
int fd;
int i;
int len;
char buf[IPCONF_MAX_LEN];
char path[MAX_PATH];
if (genFixPath("uLE:/IPCONFIG.DAT", path) >= 0)
fd = genOpen(path, O_RDONLY);
else
fd = -1;
if (fd >= 0) {
bzero(buf, IPCONF_MAX_LEN);
len = genRead(fd, buf, IPCONF_MAX_LEN - 1); // Save a byte for termination
genClose(fd);
}
if ((fd >= 0) && (len > 0)) {
char c;
buf[len] = '\0'; // Ensure string termination, regardless of file content
for (i = 0; ((c = buf[i]) != '\0'); i++) // Clear out spaces and any CR/LF
if ((c == ' ') || (c == '\r') || (c == '\n'))
buf[i] = '\0';
memcpy(ip, buf, sizeof(ip) - 1);
ip[sizeof(ip) - 1] = 0;
i = strlen(ip) + 1;
memcpy(netmask, buf + i, sizeof(netmask) - 1);
netmask[sizeof(netmask) - 1] = 0;
i += strlen(netmask) + 1;
memcpy(gw, buf + i, sizeof(gw) - 1);
gw[sizeof(gw) - 1] = 0;
}
bzero(if_conf, IPCONF_MAX_LEN);
memcpy(if_conf, ip, sizeof(ip));
i = strlen(ip) + 1;
memcpy(if_conf + i, netmask, sizeof(netmask));
i += strlen(netmask) + 1;
memcpy(if_conf + i, gw, sizeof(gw));
i += strlen(gw) + 1;
if_conf_len = i;
sprintf(netConfig, "%s: %-15s %-15s %-15s", LNG(Net_Config), ip, netmask, gw);
}
//------------------------------
// endfunc getIpConfig
//---------------------------------------------------------------------------
static void setLaunchKeys(void)
{
if (!setting->LK_Flag[SETTING_LK_SELECT])
strcpy(setting->LK_Path[SETTING_LK_SELECT], setting->Misc_Configure);
if ((maxCNF > 1) && !setting->LK_Flag[SETTING_LK_LEFT])
strcpy(setting->LK_Path[SETTING_LK_LEFT], setting->Misc_Load_CNFprev);
if ((maxCNF > 1) && !setting->LK_Flag[SETTING_LK_RIGHT])
strcpy(setting->LK_Path[SETTING_LK_RIGHT], setting->Misc_Load_CNFnext);
}
//------------------------------
// endfunc setLaunchKeys()
//---------------------------------------------------------------------------
static int drawMainScreen(void)
{
int nElfs = 0;
int i;
int x, y;
u64 color;
char c[MAX_PATH + 8], f[MAX_PATH];
char *p;
setLaunchKeys();
clrScr(setting->color[COLOR_BACKGR]);
x = Menu_start_x;
y = Menu_start_y;
c[0] = 0;
if (init_delay)
sprintf(c, "%s: %d", LNG(Init_Delay), init_delay / 1000);
else if (setting->LK_Path[SETTING_LK_AUTO][0]) {
if (!user_acted)
sprintf(c, "%s: %d", LNG(TIMEOUT), timeout / 1000);
else
sprintf(c, "%s: %s", LNG(TIMEOUT), LNG(Halted));
}
if (c[0]) {
printXY(c, x, y, setting->color[COLOR_TEXT], TRUE, 0);
y += FONT_HEIGHT * 2;
}
for (i = 0; i < SETTING_LK_BTN_COUNT; i++) {
if ((setting->LK_Path[i][0]) && ((i <= SETTING_LK_SELECT) || (maxCNF > 1) || setting->LK_Flag[i])) {
menu_LK[nElfs] = i; // memorize RunElf index for this menu entry
switch (i) {
case SETTING_LK_AUTO:
strcpy(c, "Default: ");
break;
case SETTING_LK_CIRCLE:
strcpy(c, " \xFF"
"0: ");
break;
case SETTING_LK_CROSS:
strcpy(c, " \xFF"
"1: ");
break;
case SETTING_LK_SQUARE:
strcpy(c, " \xFF"
"2: ");
break;
case SETTING_LK_TRIANGLE:
strcpy(c, " \xFF"
"3: ");
break;
case SETTING_LK_L1:
strcpy(c, " L1: ");
break;
case SETTING_LK_R1:
strcpy(c, " R1: ");
break;
case SETTING_LK_L2:
strcpy(c, " L2: ");
break;
case SETTING_LK_R2:
strcpy(c, " R2: ");
break;
case SETTING_LK_L3:
strcpy(c, " L3: ");
break;
case SETTING_LK_R3:
strcpy(c, " R3: ");
break;
case SETTING_LK_START:
strcpy(c, " START: ");
break;
case SETTING_LK_SELECT:
strcpy(c, " SELECT: ");
break;
case SETTING_LK_LEFT:
sprintf(c, "%s: ", LNG(LEFT));
break;
case SETTING_LK_RIGHT:
sprintf(c, "%s: ", LNG(RIGHT));
break;
} // ends switch
if (setting->Show_Titles) // Show Launch Titles ?
strcpy(f, setting->LK_Title[i]);
else
f[0] = '\0';
if (!f[0]) { // No title present, or allowed ?
if (setting->Hide_Paths) { // Hide full path ?
if ((p = strrchr(setting->LK_Path[i], '/'))) // found delimiter ?
strcpy(f, p + 1);
else // No delimiter !
strcpy(f, setting->LK_Path[i]);
if ((p = strrchr(f, '.')))
*p = 0;
} else { // Show full path !
strcpy(f, setting->LK_Path[i]);
}
} // ends clause for No title
if (nElfs++ == selected && mode == DPAD)
color = setting->color[COLOR_SELECT];
else
color = setting->color[COLOR_TEXT];
int len = (strlen(LNG(LEFT)) + 2 > strlen(LNG(RIGHT)) + 2) ?
strlen(LNG(LEFT)) + 2 :
strlen(LNG(RIGHT)) + 2;
if (i == SETTING_LK_LEFT) { // LEFT
if (strlen(LNG(RIGHT)) + 2 > strlen(LNG(LEFT)) + 2)
printXY(c, x + (strlen(LNG(RIGHT)) + 2 > 9 ? ((strlen(LNG(RIGHT)) + 2) - (strlen(LNG(LEFT)) + 2)) * FONT_WIDTH : (9 - (strlen(LNG(LEFT)) + 2)) * FONT_WIDTH),
y, color, TRUE, 0);
else
printXY(c, x + (strlen(LNG(LEFT)) + 2 > 9 ? 0 : (9 - (strlen(LNG(LEFT)) + 2)) * FONT_WIDTH),
y, color, TRUE, 0);
} else if (i == SETTING_LK_RIGHT) { // RIGHT
if (strlen(LNG(LEFT)) + 2 > strlen(LNG(RIGHT)) + 2)
printXY(c, x + (strlen(LNG(LEFT)) + 2 > 9 ? ((strlen(LNG(LEFT)) + 2) - (strlen(LNG(RIGHT)) + 2)) * FONT_WIDTH : (9 - (strlen(LNG(RIGHT)) + 2)) * FONT_WIDTH),
y, color, TRUE, 0);
else
printXY(c, x + (strlen(LNG(RIGHT)) + 2 > 9 ? 0 : (9 - (strlen(LNG(RIGHT)) + 2)) * FONT_WIDTH),
y, color, TRUE, 0);
} else
printXY(c, x + (len > 9 ? (len - 9) * FONT_WIDTH : 0), y, color, TRUE, 0);
printXY(f, x + (len > 9 ? len * FONT_WIDTH : 9 * FONT_WIDTH), y, color, TRUE, 0);
y += FONT_HEIGHT;
} // ends clause for defined LK_Path[i] valid for menu
} // ends for
if (mode == BUTTON)
sprintf(c, "%s!", LNG(PUSH_ANY_BUTTON_or_DPAD));
else {
if (swapKeys)
sprintf(c, "\xFF"
"1:%s \xFF"
"0:%s",
LNG(OK), LNG(Cancel));
else
sprintf(c, "\xFF"
"0:%s \xFF"
"1:%s",
LNG(OK), LNG(Cancel));
}
setScrTmp(mainMsg, c);
return nElfs;
}
//------------------------------
// endfunc drawMainScreen
//---------------------------------------------------------------------------
static int drawMainScreen2(int TV_mode)
{
int nElfs = 0;
int i;
int x, y, xo_config = 0, yo_config = 0, yo_first = 0, yo_step = 0;
u64 color;
char c[MAX_PATH + 8], f[MAX_PATH];
char *p;
setLaunchKeys();
clrScr(setting->color[COLOR_BACKGR]);
x = Menu_start_x;
y = Menu_start_y;
if (init_delay)
sprintf(c, "%s: %d", LNG(Delay), init_delay / 1000);
else if (setting->LK_Path[SETTING_LK_AUTO][0]) {
if (!user_acted)
sprintf(c, "%s: %d", LNG(TIMEOUT), timeout / 1000);
else
sprintf(c, "%s: %s", LNG(TIMEOUT), LNG(Halt));
}
if (TV_mode == TV_mode_PAL) {
printXY(c, x + 448, y + FONT_HEIGHT + 6, setting->color[COLOR_TEXT], TRUE, 0);
y += FONT_HEIGHT + 5;
yo_first = 5;
yo_step = FONT_HEIGHT * 2;
yo_config = -92;
xo_config = 370;
} else if (TV_mode == TV_mode_NTSC) {
printXY(c, x + 448, y + FONT_HEIGHT - 5, setting->color[COLOR_TEXT], TRUE, 0);
y += FONT_HEIGHT - 3;
yo_first = 3;
yo_step = FONT_HEIGHT * 2 - 4;
yo_config = -80;
xo_config = 360;
} else { // TV_mode == TV_mode_VGA
printXY(c, x + 448, y + FONT_HEIGHT - 5, setting->color[COLOR_TEXT], TRUE, 0);
y += FONT_HEIGHT - 3;
yo_first = 3;
yo_step = FONT_HEIGHT * 2 - 4;
yo_config = -80;
xo_config = 360;
}
for (i = 0; i < SETTING_LK_BTN_COUNT; i++) {
if ((setting->LK_Path[i][0]) && ((i <= SETTING_LK_SELECT) || (maxCNF > 1) || setting->LK_Flag[i])) {
menu_LK[nElfs] = i; // memorize RunElf index for this menu entry
if (setting->Show_Titles) // Show Launch Titles ?
strcpy(f, setting->LK_Title[i]);
else
f[0] = '\0';
if (!f[0]) { // No title present, or allowed ?
if (setting->Hide_Paths) { // Hide full path ?
if ((p = strrchr(setting->LK_Path[i], '/'))) // found delimiter ?
strcpy(f, p + 1);
else // No delimiter !
strcpy(f, setting->LK_Path[i]);
if ((p = strrchr(f, '.')))
*p = 0;
} else { // Show full path !
strcpy(f, setting->LK_Path[i]);
}
} // ends clause for No title
if (nElfs++ == selected && mode == DPAD)
color = setting->color[COLOR_SELECT];
else
color = setting->color[COLOR_TEXT];
int len = (strlen(LNG(LEFT)) + 2 > strlen(LNG(RIGHT)) + 2) ?
strlen(LNG(LEFT)) + 2 :
strlen(LNG(RIGHT)) + 2;
if (i == SETTING_LK_AUTO)
printXY(f, x + (len > 9 ? len * FONT_WIDTH : 9 * FONT_WIDTH) + 20, y, color, TRUE, 0);
else if (i == SETTING_LK_SELECT)
printXY(f, x + (len > 9 ? len * FONT_WIDTH : 9 * FONT_WIDTH) + xo_config, y, color, TRUE, 0);
else if (i == SETTING_LK_LEFT)
printXY(f, x + (len > 9 ? len * FONT_WIDTH : 9 * FONT_WIDTH) + xo_config, y, color, TRUE, 0);
else if (i == SETTING_LK_RIGHT)
printXY(f, x + (len > 9 ? len * FONT_WIDTH : 9 * FONT_WIDTH) + xo_config, y, color, TRUE, 0);
else
printXY(f, x + (len > 9 ? len * FONT_WIDTH : 9 * FONT_WIDTH) + 10, y, color, TRUE, 0);
} // ends clause for defined LK_Path[i] valid for menu
y += yo_step;
if (i == SETTING_LK_AUTO)
y += yo_first;
else if (i == SETTING_LK_START)
y += yo_config;
} // ends for
c[0] = '\0'; // dummy tooltip string (Tooltip unused for GUI menu)
setScrTmp(mainMsg, c);
return nElfs;
}
//------------------------------
// endfunc drawMainScreen2
//---------------------------------------------------------------------------
static void delay(int count)
{
int i;
for (i = 0; i < count; i++) {
int ret;
ret = 0x01000000;
while (ret--)
asm("nop\nnop\nnop\nnop");
}
}
//------------------------------
// endfunc delay
//---------------------------------------------------------------------------
static void initsbv_patches(void)
{
dbgprintf("Init MrBrown sbv_patches\n");
sbv_patch_enable_lmb();
sbv_patch_disable_prefix_check();
}
//------------------------------
// endfunc initsbv_patches
//---------------------------------------------------------------------------
static void load_ps2dev9(void)
{
int rcode;
if (!have_ps2dev9) {
int ret;
ret = SifExecModuleBuffer(ps2dev9_irx, size_ps2dev9_irx, 0, NULL, &rcode);
ps2dev9_loaded = (ret >= 0 && rcode == 0); // DEV9.IRX must have successfully loaded and returned RESIDENT END.
have_ps2dev9 = 1;
}
}
//------------------------------
// endfunc load_ps2dev9
//---------------------------------------------------------------------------
static void load_ps2ip(void)
{
int ret;
load_ps2dev9();
if (!have_netman) {
SifExecModuleBuffer(netman_irx, size_netman_irx, 0, NULL, &ret);
have_netman = 1;
}
if (!have_ps2smap) {
SifExecModuleBuffer(ps2smap_irx, size_ps2smap_irx,
if_conf_len, &if_conf[0], &ret);
have_ps2smap = 1;
}
if (!have_ps2ip) {
SifExecModuleBuffer(ps2ip_irx, size_ps2ip_irx, 0, NULL, &ret);
have_ps2ip = 1;
}
}
//------------------------------
// endfunc load_ps2ip
//---------------------------------------------------------------------------
static void load_ps2atad(void)
{
int ret;
load_ps2dev9();
if (!have_ps2atad) {
SifExecModuleBuffer(ps2atad_irx, size_ps2atad_irx, 0, NULL, &ret);
have_ps2atad = 1;
}
if (!have_ps2hdd) {
static char hddarg[] = "-o"
"\0"
"4"
"\0"
"-n"
"\0"
"20";
SifExecModuleBuffer(ps2hdd_irx, size_ps2hdd_irx, sizeof(hddarg), hddarg, &ret);
have_ps2hdd = 1;
}
if (!have_ps2fs) {
static char pfsarg[] = "-m"
"\0"
"4"
"\0"
"-o"
"\0"
"10"
"\0"
"-n"
"\0"
"40";
SifExecModuleBuffer(ps2fs_irx, size_ps2fs_irx, sizeof(pfsarg), pfsarg, &ret);
have_ps2fs = 1;
}
}
//------------------------------
// endfunc load_ps2atad
//---------------------------------------------------------------------------
void load_ps2host(void)
{
int ret;
setupPowerOff(); // resolves the stall out when opening host: from LaunchELF's FileBrowser
load_ps2ip();
if (!have_ps2host) {
SifExecModuleBuffer(ps2host_irx, size_ps2host_irx, 0, NULL, &ret);
have_ps2host = 1;
}
}
//------------------------------
// endfunc load_ps2host
//---------------------------------------------------------------------------
#ifdef SMB
static void load_smbman(void)
{
int ret;
setupPowerOff(); // resolves stall out when opening smb: FileBrowser
load_ps2ip();
if (!have_smbman) {
SifExecModuleBuffer(smbman_irx, size_smbman_irx, 0, NULL, &ret);
have_smbman = 1;
}
}
//------------------------------
// endfunc load_smbman
//---------------------------------------------------------------------------
#include "SMB_test.c"
#endif
static void load_ps2dvr(void)
{
int ret;
load_ps2atad();
if (!is_early_init) // Do not draw any text before the UI is initialized.
drawMsg("Loading dvrdrv");
if (!have_dvrdrv) {
SifExecModuleBuffer(dvrdrv_irx, size_dvrdrv_irx, 0, NULL, &ret);
have_dvrdrv = 1;
}
if (!is_early_init) // Do not draw any text before the UI is initialized.
drawMsg("Loading dvrfile");
if (!have_dvrfile) {
SifExecModuleBuffer(dvrfile_irx, size_dvrfile_irx, 0, NULL, &ret);
have_dvrfile = 1;
}
}
//------------------------------
// endfunc load_ps2dvr
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Function to show a screen with debugging info
//------------------------------
static void ShowDebugInfo(void)
{
char TextRow[2048];
int i, event, post_event = 0;
#ifdef SMB
int row;
load_smbman();
loadSMBCNF("mc0:/SYS-CONF/SMB.CNF");
smbCurrentServer = 0;
#endif
event = 1; // event = initial entry
//----- Start of event loop -----
while (1) {
// Pad response section
waitAnyPadReady();
if (readpad() && new_pad) {
#ifdef SMB
event |= 2;
if (new_pad & PAD_CIRCLE) {
if (smbCurrentServer + 1 < smbServerListCount)
smbCurrentServer++;
else
smbCurrentServer = 0;
} else if (new_pad & PAD_CROSS) {
if (smbCurrentServer > 0)
smbCurrentServer--;
else
smbCurrentServer = smbServerListCount - 1;
} else if (new_pad & PAD_SQUARE) {
smbLogon_Server(smbCurrentServer);
} else if (new_pad & PAD_TRIANGLE) {
smbServerList[smbCurrentServer].Server_Logon_f = 0;
} else
#endif
{
if (setting->GUI_skin[0]) {
GUI_active = 1;
loadSkin(BACKGROUND_PIC, 0, 0);
}
break;
}
}
// Display section
if (event || post_event) { // NB: We need to update two frame buffers per event
clrScr(setting->color[COLOR_BACKGR]);
PrintRow(0, "Debug Info Screen:");
sprintf(TextRow, "rom0:ROMVER == \"%s\"", ROMVER_data);
PrintRow(2, TextRow);
sprintf(TextRow, "argc == %d", boot_argc);
PrintRow(4, TextRow);
for (i = 0; (i < boot_argc) && (i < 8); i++) {
sprintf(TextRow, "argv[%d] == \"%s\"", i, boot_argv[i]);
PrintRow(-1, TextRow);
}
sprintf(TextRow, "boot_path == \"%s\"", boot_path);
PrintRow(-1, TextRow);
sprintf(TextRow, "LaunchElfDir == \"%s\"", LaunchElfDir);
#ifndef SMB
PrintRow(-1, TextRow);
#else
row = PrintRow(-1, TextRow);
int si = smbCurrentServer;
sprintf(TextRow, "Server Index = %d of %d", si, smbServerListCount);
PrintRow(row + 1, TextRow);
sprintf(TextRow, "Server_IP = %s", smbServerList[si].Server_IP);
PrintRow(-1, TextRow);
sprintf(TextRow, "Server_Port = %d", smbServerList[si].Server_Port);
PrintRow(-1, TextRow);
sprintf(TextRow, "Username = %s", smbServerList[si].Username);
PrintRow(-1, TextRow);
sprintf(TextRow, "Password = %s", smbServerList[si].Password);
PrintRow(-1, TextRow);
sprintf(TextRow, "PasswordType = %d", smbServerList[si].PasswordType);
PrintRow(-1, TextRow);
sprintf(TextRow, "PassHash_f = %d", smbServerList[si].PassHash_f);
PrintRow(-1, TextRow);
sprintf(TextRow, "Server_Logon_f = %d", smbServerList[si].Server_Logon_f);
PrintRow(-1, TextRow);
sprintf(TextRow, "Server_FBID = %s", smbServerList[si].Server_FBID);
PrintRow(-1, TextRow);
sprintf(TextRow, "\xFF"
"0 Index++ \xFF"
"1 Index-- \xFF"
"2 Logon \xFF"
"3 Forget Logon");
PrintRow(-1, TextRow);
#endif
} // ends if(event||post_event)
drawScr();
post_event = event;
event = 0;
}
// ends while
//----- End of event loop -----
}
//------------------------------
// endfunc ShowDebugInfo
//---------------------------------------------------------------------------
void load_vmc_fs(void)
{
int ret;
if (!have_vmc_fs) {
SifExecModuleBuffer(vmc_fs_irx, size_vmc_fs_irx, 0, NULL, &ret);
have_vmc_fs = 1;
}
}
//------------------------------
// endfunc load_vmc_fs
//---------------------------------------------------------------------------
static void load_ps2ftpd(void)
{
int ret;
int arglen;
char *arg_p;
arg_p = "-anonymous";
arglen = strlen(arg_p);
load_ps2ip();
if (!have_ps2ftpd) {
SifExecModuleBuffer(ps2ftpd_irx, size_ps2ftpd_irx, arglen, arg_p, &ret);
have_ps2ftpd = 1;
}
}
//------------------------------
// endfunc load_ps2ftpd
//---------------------------------------------------------------------------
static void load_ps2netfs(void)
{
int ret;
load_ps2ip();
if (!have_ps2netfs) {
SifExecModuleBuffer(ps2netfs_irx, size_ps2netfs_irx, 0, NULL, &ret);
have_ps2netfs = 1;
}
}
//------------------------------
// endfunc load_ps2netfs
//---------------------------------------------------------------------------
static void loadBasicModules(void)
{
int ret;
SifExecModuleBuffer(iomanx_irx, size_iomanx_irx, 0, NULL, &ret);
SifExecModuleBuffer(filexio_irx, size_filexio_irx, 0, NULL, &ret);
SifExecModuleBuffer(allowdvdv_irx, size_allowdvdv_irx, 0, NULL, &ret); // unlocks cdvd for reading on psx dvr
SifLoadModule("rom0:SIO2MAN", 0, NULL);
#ifdef SIO_DEBUG
int id;
// I call this just after SIO2MAN have been loaded
sio_init(38400, 0, 0, 0, 0);
DPRINTF("Hello from EE SIO!\n");
SIOR_Init(0x20);
id = SifExecModuleBuffer(sior_irx, size_sior_irx, 0, NULL, &ret);
scr_printf("\t sior id=%d _start ret=%d\n", id, ret);
DPRINTF("sior id=%d _start ret=%d\n", id, ret);
#endif
SifExecModuleBuffer(mcman_irx, size_mcman_irx, 0, NULL, &ret); // Home
// SifLoadModule("rom0:MCMAN", 0, NULL); //Sony
SifExecModuleBuffer(mcserv_irx, size_mcserv_irx, 0, NULL, &ret); // Home
// SifLoadModule("rom0:MCSERV", 0, NULL); //Sony
SifLoadModule("rom0:PADMAN", 0, NULL);
}
//------------------------------
// endfunc loadBasicModules
//---------------------------------------------------------------------------
static void loadCdModules(void)
{
int ret;
if (!have_cdvd) {
sceCdInit(SCECdINoD); // SCECdINoD init without check for a disc. Reduces risk of a lockup if the drive is in a erroneous state.
SifExecModuleBuffer(cdfs_irx, size_cdfs_irx, 0, NULL, &ret);
have_cdvd = 1;
}
}