forked from Freakler/vita-AdrenalineEasyInstaller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
2551 lines (1998 loc) · 94.8 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
#include "main.h"
#include "init.h"
#include "file.h"
#include "sqlite-3.6.23.1/sqlite3.h"
/** Notes & TODO
* - remove PS1 official games from installer list
* - figure out how to update database manually so no more rebooting (would fix next bulletpoint too)
* - add warning for PSTV + USB Stick users
* - Addon-Installer?!
* -
* - clean up & and learn how to code properly
**/
/*
To add a new release:
- put files in new folder in [files/releases/xxxxxxx]
& add them in makefile
- add entry in "files_menu" (main.c)
- adjust version in [main.h] and [livearea/template.xml]
- add EasyInstaller changelog to [livearea/changeinfo.xml]
- add Adrenaline changelog to [files/updatehistory.txt]
*/
/** Changelog
* v1.15
* - updated for Adrenaline-5.1
*
* v1.14
* - updated for Adrenaline-5
* - removed ms0:ISO/video/ folder creation
*
* v1.13
* - updated for Adrenaline-4.2
*
* v1.12
* - adjustments due to latest tai/config.txt location change
*
* v1.11
* - updated for Adrenaline-4.1
* - added unsafe hombrew check
*
* v1.10
* - updated for Adrenaline-4
* - added option to delete SaveStates
*
* v1.09
* - updated for Adrenaline-3.1
*
* v1.08
* - updated for Adrenaline-3 fix
* - removed resetting of installed flash files when up/downgrading as its not needed
*
* v1.07
* - added all releases of Adrenaline to choose from
* - restructured the menu because of all new options
* - you can now up/downgrade without rebooting (with same basegame)
* - the used basegame for Adrenaline will show up green in selection menu
* - added Advanced LiveArea Theming Option (app.db)
* - added view Adrenaline Update-History as option
* - added firmware check warning for future hacks
* - added check for valid 661.PBP file (if not it will be deleted)
* - added check for existing PBOOTs in basegames
* - added check for changeinfo.xml installation
* - typical CFW files & folders will now be created automatically
* - added option to display taiHEN config.txt
* - added option to reload taiHEN config.txt
* - adjusted Bubble Name and livearea
* - removed blocking of PSButton again
* - removed unnecessary files & code
*
* v1.061
* - updated for Adrenaline-2
*
* v1.05
* - added 6.61 Update file download progress indicator
* - added update history info to livearea
* - while installing the Home button is now blocked
* - fixed a bug with wrongly formatted tai-config files
*
* v1.04
* - added PSP names in selection menu
* - changed method to update database (addressed to bugs reported)
* - added another safety dialog before actually installing Adrenaline
* - added more message screens
* - added option to install a small basegame (thx to CelesteBlue for the files)
* - added option to delete adrenaline flash files
* - added option to delete 661 Update file
* - bugs fixed
*
* v1.03
* - merged additional checks by Yoti
* - added automatic 661.PBP downloading
* - livearea template adjustments
* - adjusted debug text length for theme installing
* - code cleaned & bugs fixed
* -
*
* v1.02
* - bugs fixed
*
* Thanks to TheFloW, Team Molecule, gdljjrod, SMOKE and all others
*/
/// Main Menu /////////////
Menu recovery_menu[] = {
//*title //type //*function //*arg //*arg2 //*message
{"1. Adrenaline eCustomFirmware ➡", MENU_BLOCKED, installer_options, "", "", "* Install / uninstall / up- & downgrade the Adrenaline eCustomFirmware" },
{"2. LiveArea theming ➡", MENU_BLOCKED, theme_options, "", "", "* Access theming options menu" },
{"3. Advanced options ➡", MENU_ACTIVE, more_options, "", "", "* Access advanced options menu" },
{"4. View Adrenaline Update-History", MENU_ACTIVE, option_show_changelogfile, "", "", "* View the Adrenaline update-History (aka Changelog)" },
{"5. Exit", MENU_EXIT, NULL, "", "", "* Exit MLT EasyInstaller" },
{NULL,0,"","",""}
};
Menu installer_menu[] = {
//*title //type //*function //*arg //*arg2 //*message
{"Install the latest Adrenaline eCFW release", MENU_ACTIVE, draw_psp_games, "latest", "ux0:adrenaline", "* Install the latest Adrenaline eCFW release to a Basegame of your choice" },
{"Manually update/downgrade Adrenaline", MENU_ACTIVE, files_option, "", "", "* Select any Adrenaline release & up or downgrade it easily" },
{"Uninstall Adrenaline eCFW completely", MENU_BLOCKED, uninstall_adrenaline, "", "", "* Remove the Adrenaline eCustomFirmware from this device" },
{"Cancel", MENU_EXIT, draw_psp_games, "", "", "" },
{NULL,0,"","",""}
};
Menu files_menu[] = {
//*title //type //*function //*arg //*arg2 //*message
{"2017-06-21 : adrenaline_v5.1.zip" , MENU_ACTIVE , draw_psp_games ,"adrenaline_v5.1" , "ux0:adrenaline" , "" },
{"2017-06-05 : adrenaline_v5.zip" , MENU_ACTIVE , draw_psp_games ,"adrenaline_v5" , "ux0:adrenaline" , "" },
{"2017-06-03 : adrenaline_v4.2.zip" , MENU_ACTIVE , draw_psp_games ,"adrenaline_v4.2" , "ux0:adrenaline" , "" },
{"2017-05-25 : adrenaline_v4.1.zip" , MENU_ACTIVE , draw_psp_games ,"adrenaline_v4.1" , "ux0:adrenaline" , "" },
{"2017-04-18 : adrenaline_v4.zip" , MENU_ACTIVE , draw_psp_games ,"adrenaline_v4" , "ux0:adrenaline" , "" },
{"2017-04-17 : adrenaline_v3.1.zip" , MENU_ACTIVE , draw_psp_games ,"adrenaline_v3.1" , "ux0:adrenaline" , "" },
{"2017-04-16 : adrenaline_v3_fix.zip" , MENU_ACTIVE , draw_psp_games ,"adrenaline_v3_fix", "ux0:adrenaline" , "" },
{"2017-04-15 : adrenaline_v3.zip" , MENU_ACTIVE , draw_psp_games ,"adrenaline_v3" , "ux0:adrenaline" , "" },
{"2017-04-02 : adrenaline_v2.zip" , MENU_ACTIVE , draw_psp_games ,"adrenaline_v2" , "ux0:adrenaline" , "" },
{"2016-11-18 : adrenaline_fix2.zip" , MENU_ACTIVE , draw_psp_games ,"adrenaline_fix2" , "ux0:pspemu/adrenaline" , "" },
{"2016-11-17 : adrenaline.zip" , MENU_ACTIVE , draw_psp_games ,"adrenaline" , "ux0:pspemu/adrenaline" , "" },
//{"Cancel" , MENU_EXIT , draw_psp_games ,"0" , "" , "" },
{NULL,0,"","",""}
};
Menu theme_menu[] = {
//*title //type //*function //*arg //*arg2 //*message
{"Add Custom LiveArea Theme" , MENU_BLOCKED , install_theme ,"" , "" , "* Add a custom LiveArea Theme & Icon (reboot required)" },
{"Restore LiveArea" , MENU_BLOCKED , uninstall_theme ,"" , "" , "* Remove the custom Theme and restore the default look (reboot required)" },
{"Add Style & Text frames to LiveArea" , MENU_BLOCKED , install_sqlite_theme ,"" , "" , "* Add Style & Text frames to the LiveArea Screen (no reboot required)" },
{"Remove Style & Text frames from LiveArea" , MENU_BLOCKED , uninstall_sqlite_theme ,"" , "" , "* Remove Style & Text frames from the LiveArea (no reboot required)" },
{"Cancel" , MENU_EXIT , NULL ,"" , "" , "" },
{NULL,0,"","",""}
};
Menu more_menu[] = {
//*title //type //*function //*arg //*arg2 //*message
{"Install a small PSP Basegame if needed" , MENU_BLOCKED , install_pspgame ,"" , "" , "" },
{"Delete installed Adrenaline flash files" , MENU_BLOCKED , option_delete_flash ,"" , "" , "" },
{"Delete 661.PBP update file" , MENU_BLOCKED , option_delete_pbp ,"" , "" , "" },
{"Delete all Adrenaline SaveStates" , MENU_BLOCKED , option_delete_savestates ,"" , "" , "" },
{"Display taiHENkaku config.txt file" , MENU_ACTIVE , option_show_taiconfig ,"" , "" , "" },
//{"testing stuff" , MENU_ACTIVE , option_test ,"" , "" , "" },
{"★ Reload taiHENkaku config" , MENU_ACTIVE , option_reloadTaiConfig ,"" , "" , "" },
{"★ Rebuild Database" , MENU_ACTIVE , option_rebuildDatabase ,"" , "" , "" },
{"★ Update Database" , MENU_ACTIVE , option_updateDatabase ,"" , "" , "" },
//{"Reboot System" , MENU_ACTIVE , option_reboot ,"" , "" , "" },
{"Cancel" , MENU_EXIT , NULL ,"" , "" , "" },
{NULL,0,"","",""}
};
int system_check() {
psvDebugScreenInit();
printf("MLT EasyInstaller v%s\n", VERSION);
printf("-------------------\n\n\n");
// Some system checks first ///////////////////////////////////////////////////////////////////////////////////////////////
/// Unsafe Hombrew check
if ( checkUnsafeHomebrew() ) {
print_color("\n!! It seems you haven't enabled unsafe hombrews. !!\n\n\n", YELLOW);
if (SCE_CTRL_ENTER == SCE_CTRL_CROSS) printf("Press X to open the HENkaku settings or O to exit..\n\n");
else printf("Press O to open the HENkaku settings or X to exit..\n\n");
while (1) {
readPad();
if (pressed_buttons & SCE_CTRL_CANCEL) sceKernelExitProcess(0);
if (pressed_buttons & SCE_CTRL_ENTER) {
sceAppMgrLaunchAppByUri(0x20000, "settings_dlg:"); //launch flag 0x40000 | open flag 0x20000
sceKernelExitProcess(0);
}
}
}
/// Model Check
printf("Model = ");
if ( vshSblAimgrIsVITA() == 1 ) printf("Vita\n\n");
else printf("PlayStationTV\n\n");
/// Enter Button check
printf("Enter Button = ");
if ( SCE_CTRL_ENTER == SCE_CTRL_CROSS ) printf("X\n\n");
else printf("O\n\n");
/// Firmware Check
printf("Firmware = ");
sprintf(buffer, "%s", getRealFirmwareVersion(0));
printf("%s\n\n", buffer);
if ( strcmp(buffer, "0x03600000") != 0 ) { //if a firmware different to 3.60 is detected there will be a warning
print_color("!! This firmware version may not be supported !!\n\n", YELLOW);
if (SCE_CTRL_ENTER == SCE_CTRL_CROSS) printf("Press X to continue anyways or O to exit..\n\n");
else printf("Press O to continue anyways or X to exit..\n\n");
while (1) {
readPad();
if (pressed_buttons & SCE_CTRL_CANCEL) sceKernelExitProcess(0);
if (pressed_buttons & SCE_CTRL_ENTER) break;
}
}
/// Write changeinfo.xml for Livearea manually. (Does vpk promoting not feature this? [https://www.vitadevwiki.com/index.php?title=File:PKGdirstruct.png] Deleteing the bubble will delete patch/xxx though)
sprintf(buffer, "ux0:patch/%s/sce_sys/changeinfo/changeinfo.xml", TITLEID);
if ( doesFileExist(buffer) ) {
if ( getFileSize(buffer) < getFileSize("app0:sce_sys/changeinfo/changeinfo.xml") ) { //overwrite only when there is a newer (bigger) file
goto install_xml;
} else {
printf("Changeinfo.xml is ");
print_color("up-to-date!\n\n", GREEN);
}
} else {
install_xml:
printf("Writing changeinfo.xml.. ");
if ( writeChangeinfo(TITLEID) ) print_color("OK\n\n", GREEN);
else print_color("Error\n\n", RED);
}
printf("\n");
// Now the Adrenaline needed checks ///////////////////////////////////////////////////////////////////////////////////////////////
/// taiHENkaku check -> If not found the Installer won't start
printf("Checking for taiHENkaku.. ");
if ( doesFileExist(TAI_CONFIG) ) {
print_color("OK\n\n", GREEN);
} else {
if ( doesFileExist("ur0:tai/config.txt") ) {
sprintf(TAI_CONFIG, "ur0:tai/config.txt");
print_color("OK\n\n", GREEN);
} else {
print_color("Nothing found!!\n\n\n", RED);
print_color("\n!!! Please (re)install taiHENkaku first and try again!!!\n\n", RED);
goto error_exit;
}
}
/// checking Device Activation (needed for PSP games to run -> Adrenaline to run)
printf("Checking for tm0:npdrm/act.dat file.. ");
if (doesFileExist("tm0:npdrm/act.dat")) print_color("OK\n\n", GREEN);
else {
print_color("Not found!!\n\n", RED);
print_color("\n!!! You must activate your Vita first!!!\n\n", RED);
goto error_exit;
}
/// checking for installed PSP Content
printf("Checking for PSP content in /PSP/GAME/.. ");
gamesfound = check_for_psp_content("ux0:pspemu/PSP/GAME/"); //storing globally for later
if ( gamesfound > 0 ) { //there is PSP content installed
print_color("OK ", GREEN);
printf("%i Game(s)\n\n", gamesfound );
recovery_menu[0].type = MENU_ACTIVE; //since there are pspgames we can install adrenaline -> activate the option
/// Check for DEFAULT_BASEGAME already installed
sprintf(buffer, "ux0:pspemu/PSP/GAME/%s", DEFAULT_BASEGAME);
if ( doesDirExist(buffer) == 0 ) {
more_menu[0].type = MENU_ACTIVE; //activate PSP basegame installer
}
} else { //No content at all
print_color("No content!\n\n", YELLOW);
more_menu[0].type = MENU_ACTIVE; //activate PSP basegame installer
}
/// Are there Adrenaline prx files in the default folder
sprintf(buffer, "%s/adrenaline.skprx", ADR_FOLDER);
printf("Checking for installed Adrenaline prx files.. ");
if ( doesFileExist(buffer) ) {
print_color("OK\n\n", GREEN);
ADR_PRX_INSTL = 1;
} else {
///checking here for the old Adrenaline installation
if ( doesFileExist("ux0:pspemu/adrenaline/adrenaline.skprx") ) {
sprintf(ADR_FOLDER, "ux0:pspemu/adrenaline"); // <-- the default ADR_FOLDER is switched here if an old installation is found
print_color("OK\n\n", GREEN);
ADR_PRX_INSTL = 1;
} else {
print_color("Not found!\n\n", YELLOW);
}
}
/// read version file if existing (only there if installed via this installer)
sprintf(buffer, "%s/version", ADR_FOLDER);
if ( doesFileExist(buffer) ) {
sprintf(ADR_VERSION, "%s", read_installed_adrenaline_version(buffer) ); // <-- ADR_VERSION is set here if file was found in ADR_FOLDER
}
/// Adrenaline installed to a PSP game in tai-config check?? ------- TODO (there could still be an ux0:pspemu/adr.. entry that wont be deleted automatically)
printf("Checking ux0:tai/config.txt for adrenaline.. ");
get_id_of_psp_game_that_adrenaline_is_installed_to(TAI_CONFIG, ADR_FOLDER);
if ( PSP_GAME_ID[0] != '\0' ) { //a config installation was found!!
printf("%s\n\n", PSP_GAME_ID);
if ( ADR_PRX_INSTL ) { //if the prxs are installed we can continue with the checks..
/// Does the game still exist though?!
sprintf(buffer, "ux0:pspemu/PSP/GAME/%s/EBOOT.PBP", PSP_GAME_ID);
printf("Checking for /PSP/GAME/%s.. ", PSP_GAME_ID);
if ( !doesFileExist(buffer) ) { //game was deleted -> means everything in config is a leftover and wrong
print_color("Not found!\n\n", RED);
/// the game was deleted but adrenaline was still installed to it in the tai config.. clean up
printf("Deleting old installation for %s.. ", PSP_GAME_ID);
if ( delete_adrenaline_from_config(TAI_CONFIG, ADR_FOLDER, PSP_GAME_ID) == 0 ) print_color("OK\n\n", GREEN);
else print_color("Error\n\n", RED);
/// also delete adrenaline prx files although it doesn't matter
sprintf(buffer, "%s/adrenaline.skprx", ADR_FOLDER);
sceIoRemove(buffer);
sprintf(buffer, "%s/adrenaline.suprx", ADR_FOLDER);
sceIoRemove(buffer);
PSP_GAME_ID[0] = 0; //clear it to continue
} else { //installed to config and the game does exist
print_color("OK\n\n", GREEN);
ADR_INSTALLED = 1; // <-- ADR_INSTALLED can now be set to 1 because everything needed is there and works
}
} else { //..if not we can delete from the config and don't have to care about the basgame aso
/// delete from the config as the files aren't even installed
printf("Removing old entry in ux0:tai/config.txt.. ");
int ret = delete_adrenaline_from_config(TAI_CONFIG, ADR_FOLDER, PSP_GAME_ID);
if ( ret == 0 ) print_color("OK\n\n", GREEN);
else print_color("ERROR\n\n", YELLOW);
PSP_GAME_ID[0] = 0; //clear it to continue
}
} else { //No Adrenaline stuff found in tai Confg.txt
print_color("Not found!\n\n", YELLOW);
}
// Now the Adrenaline semi-needed checks (for stuff in the EasyInstaller itself) ///////////////////////////////////////////////////////////////////////
/// check for Adrenaline flash files
printf("Checking for installed Adrenaline flash files.. ");
sprintf(buffer, "%s/flash0", ADR_FOLDER);
if ( doesDirExist(buffer) ) {
print_color("OK\n\n", GREEN);
more_menu[1].type = MENU_ACTIVE; //activate "Delete flash files"
} else {
print_color("Not found!\n\n", YELLOW);
}
/// check for 661.PBP
sprintf(buffer, "%s/661.PBP", ADR_FOLDER);
printf("Checking for %s.. ", buffer);
if ( doesFileExist(buffer) ) {
/// check for correct/complete/valid update file
if ( getFileSize(buffer) == UPDATE_SIZE ) {
more_menu[2].type = MENU_ACTIVE; //activate "Delete Update PBP"
print_color("OK\n\n", GREEN);
} else {
print_color("Wrong Size! Deleting..\n\n", RED);
sceIoRemove(buffer);
}
} else {
print_color("Not found!\n\n", YELLOW);
}
/// check for Adrenaline savestates
//printf("Checking for installed Adrenaline flash files.. ");
if ( doesDirExist("ux0:pspemu/PSP/SAVESTATE") ) {
//print_color("OK\n\n", GREEN);
more_menu[3].type = MENU_ACTIVE; //activate
} else {
//print_color("Not found!\n\n", YELLOW);
}
///check for sqlite theme installing activate or not
sprintf(buffer, "ur0:appmeta/%s/temp", PSP_GAME_ID);
if ( doesDirExist(buffer) ) {
theme_menu[3].type = MENU_ACTIVE; //activate "Uninstall Theme sqlite"
} else {
///check if the livearea folder exists. Otherwise the games livearea needs to be opened once
sprintf(buffer, "ur0:appmeta/%s/livearea", PSP_GAME_ID);
if ( doesDirExist(buffer) ) {
theme_menu[2].type = MENU_ACTIVE; //activate "Install Theme sqlite"
}
}
// And finally : Activating or Blocking more options depending on the checks /////////////////////////////////////////////////////////////////////////
if ( ADR_INSTALLED ) {
installer_menu[2].type = MENU_ACTIVE; //activate "Uninstall Adrenaline" option
recovery_menu[1].type = MENU_ACTIVE; //activate "Theme Menu"
/// check for theme backup file (means a livearea theme must be installed if found)
sprintf(buffer, "ur0:appmeta/%s/icon0_.dds", PSP_GAME_ID);
if ( doesFileExist(buffer) ) theme_menu[1].type = MENU_ACTIVE; //file found -> activate "Uninstall Theme" option
else theme_menu[0].type = MENU_ACTIVE; //not found -> activate "Install Theme" option
/// check if currently installed version is also the newest available
if ( strcmp(ADR_VERSION, files_menu[0].arg ) == 0 )
installer_menu[0].type = MENU_BLOCKED; //block "Install newest Adrenaline" option if is already newest
}
printf("\n\nDone! Starting..");
if ( debug ) sceKernelDelayThread(5000 * 1000); // 5 sec delay
return 1;
error_exit: /// If the important checks fail you will end up here and the Installer will exit
if (SCE_CTRL_ENTER == SCE_CTRL_CROSS) printf("Press X to exit...\n\n");
else printf("Press O to exit...\n\n");
while (1) {
readPad();
if (pressed_buttons & SCE_CTRL_ENTER) break;
}
return 0;
}
void recovery_draw_main() {
int options = 0; //available options
int selection = 0; //selected option
int running = 1; //loop variable
int toption = 0; //the option on top when there are more options than showoptions
int showoptions = 5; //the number of options that should be displayed at once [5 by Default]
int i, x, y, z;
/// calculate number of options
while(recovery_menu[options].title != NULL) options++;
/// Error handling
if ( showoptions > options ) showoptions = options; //Adjust showoptions (there can't be more "showoptions" than "options" itself)
/// set cursor to first active option
while(recovery_menu[selection].type == MENU_BLOCKED) selection += 1;
while (running) {
readPad();
vita2d_start_drawing();
vita2d_clear_screen();
/// "Debug" messages
if ( debug ) {
vita2d_pgf_draw_textf(pgf, 640, 100, GREY, 1.0f, "options = %i", options);
vita2d_pgf_draw_textf(pgf, 640, 125, GREY, 1.0f, "selection = %i", selection);
vita2d_pgf_draw_textf(pgf, 640, 150, GREY, 1.0f, "toption = %i", toption);
vita2d_pgf_draw_textf(pgf, 640, 175, GREY, 1.0f, "showoptions = %i", showoptions);
vita2d_pgf_draw_textf(pgf, 600, 250, GREY, TEXT_SIZE, "PSP_GAME_ID = %s", PSP_GAME_ID);
vita2d_pgf_draw_textf(pgf, 600, 275, GREY, TEXT_SIZE, "gamesfound = %i", gamesfound);
vita2d_pgf_draw_textf(pgf, 550, 325, GREY, TEXT_SIZE, "ADR_FOLDER = %s", ADR_FOLDER);
vita2d_pgf_draw_textf(pgf, 550, 350, GREY, TEXT_SIZE, "ADR_VERSION = %s", ADR_VERSION);
vita2d_pgf_draw_textf(pgf, 550, 375, GREY, TEXT_SIZE, "ADR_INSTALLED = %i", ADR_INSTALLED);
vita2d_pgf_draw_textf(pgf, 550, 400, GREY, TEXT_SIZE, "ADR_PRX_INSTL = %i", ADR_PRX_INSTL);
vita2d_draw_line(0, 70, 960, 70, GREY); //top line
vita2d_draw_line(0, 410, 960, 410, GREY); //bot line
vita2d_draw_line(100, 0, 100, 544, GREY); //left line
vita2d_draw_line(860, 0, 860, 544, GREY); //right line
}
/// draw the Title
vita2d_pgf_draw_text(pgf, SCREEN_WIDTH/2-(vita2d_pgf_text_width(pgf, TEXT_SIZE_BIG, MAIN_TITLE)/2), 40, text_color, TEXT_SIZE_BIG, MAIN_TITLE);
vita2d_pgf_draw_textf(pgf, SCREEN_WIDTH/2+(vita2d_pgf_text_width(pgf, TEXT_SIZE_BIG, MAIN_TITLE)/2), 40, GREY, TEXT_SIZE, " v%s", VERSION);
/// draw the Menu
x = 125; //horizontal start of options (text)
y = 110; //vertical start of options (text)
z = 70; //spacing
if ( selection < toption ) toption = selection; //for scrolling up with selection
for(i=toption; i < showoptions+toption; i++, y += z) {
if ( i == selection ) { //draw active selection
vita2d_draw_rectangle(x-25, y-40, 760, 60, menu_active_color); //background
vita2d_pgf_draw_textf(pgf, x, y, menu_text_active_color, TEXT_SIZE_BIG, "%s", recovery_menu[selection].title);
vita2d_pgf_draw_textf(pgf, x, 465, text_color, TEXT_SIZE, "%s", recovery_menu[selection].message); //message
} else { //draw all other inactive options
if ( recovery_menu[i].type == MENU_BLOCKED ) { //when blocked adjust color
vita2d_pgf_draw_textf(pgf, x, y, menu_text_inactive_color, TEXT_SIZE_BIG, "%s", recovery_menu[i].title);
} else { //none-blocked
vita2d_pgf_draw_textf(pgf, x, y, text_color, TEXT_SIZE_BIG, "%s", recovery_menu[i].title);
}
}
}
/// draw Button Controls
x = 15; //horizontal start
y = 525; //vertical start
z = 25; //spacing
vita2d_draw_texture(button_enter, x, y-17);
vita2d_pgf_draw_text(pgf, x+26, y, WHITE, TEXT_SIZE, "Enter");
x += 26+vita2d_pgf_text_width(pgf, TEXT_SIZE, "Enter")+z;
vita2d_draw_texture(button_pad, x, y-17);
vita2d_pgf_draw_text(pgf, x+26, y, WHITE, TEXT_SIZE, "Navigate");
x += 26+vita2d_pgf_text_width(pgf, TEXT_SIZE, "Navigate")+z;
/// Button Input //////////////////////////////////////////////////////////////////////////////////
/// Navigation UP
if ( hold_buttons & SCE_CTRL_UP) {
if ( selection <= 0 ) {
selection = options-1;
toption = options-showoptions; //scroll
} else selection -= 1;
while ( recovery_menu[selection].type == MENU_BLOCKED ) {
if ( selection <= 0 ) {
selection = options-1;
toption = options-showoptions; //scroll
} else selection -= 1;
if ( toption > 1 ) { //scroll
if ( selection == 1 ) toption--;
}
}
if ( toption > 1 ) { //scroll
if ( selection == 1 ) toption--;
}
}
/// Navigation DOWN
if ( hold_buttons & SCE_CTRL_DOWN) {
if ( showoptions == 1 ) { //handling 1 option only
if ( selection >= options-1 ) selection = 0;
else selection += 1;
while ( recovery_menu[selection].type == MENU_BLOCKED ) {
if ( selection >= options-1 ) selection = 0;
else selection += 1;
}
toption = selection;
} else {
if ( selection >= options-1 ) selection = 0;
else {
selection += 1;
if ( toption+showoptions < options ) { //scroll
if ( selection == toption+showoptions-1 ) toption++;
}
}
while ( recovery_menu[selection].type == MENU_BLOCKED ) {
if ( selection >= options-1 ) selection = 0;
else {
selection += 1;
if ( toption+showoptions < options ) { //scroll
if ( selection == toption+showoptions-1 ) toption++;
}
}
}
if ( toption+showoptions < options ) { //scroll
if ( selection == toption+showoptions-1 ) toption++;
}
}
}
/// "Ultra-Secret-Debug-Info" Combo
if (hold_buttons & SCE_CTRL_LEFT && hold_buttons & SCE_CTRL_LTRIGGER && hold_buttons & SCE_CTRL_RTRIGGER && hold_buttons & SCE_CTRL_START) {
if ( debug ) debug = 0;
else debug = 1;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////
void (* function)();
if ( recovery_menu[selection].type == MENU_ACTIVE ) {
if (pressed_buttons & SCE_CTRL_ENTER) {
vita2d_end_drawing();
vita2d_swap_buffers();
sceDisplayWaitVblankStart();
function = (void *)(recovery_menu[selection].function);
function();
vita2d_start_drawing();
vita2d_clear_screen();
}
} else if ( recovery_menu[selection].type == MENU_EXIT ) {
if (pressed_buttons & SCE_CTRL_ENTER) running = 0;
}
vita2d_end_drawing();
vita2d_swap_buffers();
sceDisplayWaitVblankStart();
}
}
void *uninstall_adrenaline() {
sprintf(buffer, "Everything in \"%s/\" will be deleted!", ADR_FOLDER);
int ret = recovery_draw_dialog(MAIN_TITLE, "Do you really want to continue uninstalling Adrenaline?", buffer);
if ( ret ) {
closeVita2DLib(); //shutdown Vita2dLib
//lock_psbutton();
uninstall_adrenaline_files(PSP_GAME_ID);
}
return 0;
}
void *draw_psp_games(char *arg, char *arg2) {
int options = gamesfound;
int selection = 0; //selected option number
int running = 1; //loop variable
int toption = 0; //the option on top when there are more options than showoptions
int showoptions = 5; //the number of options that should be displayed at once [5 by Default]
int i, x, y, z;
if( strcmp(arg, "latest") == 0 ) { //set to latest adrenaline version
arg = files_menu[0].arg; //name
arg2 = files_menu[0].arg2; //folder
}
if ( showoptions > options ) showoptions = options; //error adjust showoptions (there can't be more "showoptions" than "options" itself)
while (running) {
readPad();
vita2d_start_drawing();
vita2d_clear_screen();
/// Draw the Title
vita2d_pgf_draw_text(pgf, SCREEN_WIDTH/2-(vita2d_pgf_text_width(pgf, TEXT_SIZE_BIG, "Select a basegame")/2), 40, text_color, TEXT_SIZE_BIG, "Select a basegame");
/// "Debug" Messages
if ( debug ) {
vita2d_pgf_draw_textf(pgf, 640, 100, GREY, TEXT_SIZE, "options = %i", options);
vita2d_pgf_draw_textf(pgf, 640, 125, GREY, TEXT_SIZE, "selection = %i", selection);
vita2d_pgf_draw_textf(pgf, 640, 150, GREY, TEXT_SIZE, "toption = %i", toption);
vita2d_pgf_draw_textf(pgf, 640, 175, GREY, TEXT_SIZE, "showoptions = %i", showoptions);
vita2d_pgf_draw_textf(pgf, 640, 225, GREY, TEXT_SIZE, "arg = %s", arg);
vita2d_pgf_draw_textf(pgf, 640, 250, GREY, TEXT_SIZE, "arg2 = %s", arg2);
vita2d_draw_line(0, 70, 960, 70, GREY); //top line
vita2d_draw_line(0, 410, 960, 410, GREY); //bot line
vita2d_draw_line(100, 0, 100, 544, GREY); //left line
vita2d_draw_line(860, 0, 860, 544, GREY); //right line
}
/// Draw the Menu
x = 125; //horizontal start of options (text)
y = 110; //vertical start of options (text)
z = 70; //spacing
if ( selection < toption ) toption = selection; //scrolling up with selection
for(i=toption; i < showoptions+toption; i++, y += z) {
if ( i == selection ) { //draw active selection
vita2d_draw_rectangle(x-25, y-40, 760, 60, menu_active_color); //background
if ( strcmp(PSP_GAME_ID, content_array[selection].titleID ) == 0 ) { //make the basegame which is used for adrenaline colored
vita2d_pgf_draw_textf(pgf, x, y, menu_text_basegame, TEXT_SIZE_BIG, "%s - %s", content_array[selection].titleID, content_array[selection].title);
} else {
vita2d_pgf_draw_textf(pgf, x, y, menu_text_active_color, TEXT_SIZE_BIG, "%s - %s", content_array[selection].titleID, content_array[selection].title);
}
} else { //draw all other options
if ( strcmp(PSP_GAME_ID, content_array[i].titleID ) == 0 ) { //make the basegame which is used for adrenaline colored
vita2d_pgf_draw_textf(pgf, x, y, menu_text_basegame, TEXT_SIZE_BIG, "%s - %s", content_array[i].titleID, content_array[i].title);
} else {
vita2d_pgf_draw_textf(pgf, x, y, text_color, TEXT_SIZE_BIG, "%s - %s", content_array[i].titleID, content_array[i].title);
}
}
}
/// Button Controls
x = 15; //horizontal start
y = 525; //vertical start
z = 25; //spacing
vita2d_draw_texture(button_enter, x, y-17);
vita2d_pgf_draw_text(pgf, x+26, y, WHITE, TEXT_SIZE, "Enter");
x += 26+vita2d_pgf_text_width(pgf, TEXT_SIZE, "Enter")+z;
vita2d_draw_texture(button_cancel, x, y-17);
vita2d_pgf_draw_text(pgf, x+26, y, WHITE, TEXT_SIZE, "Cancel");
x += 26+vita2d_pgf_text_width(pgf, TEXT_SIZE, "Cancel")+z;
vita2d_draw_texture(button_pad, x, y-17);
vita2d_pgf_draw_text(pgf, x+26, y, WHITE, TEXT_SIZE, "Navigate");
x += 26+vita2d_pgf_text_width(pgf, TEXT_SIZE, "Navigate")+z;
/// Button Input //////////////////////////////////////////////////////////////////////////////////
if ( hold_buttons & SCE_CTRL_UP) {
if ( selection <= 0 ) {
selection = options-1;
toption = options-showoptions; //scroll
} else selection -= 1;
if ( toption > 1 ) { //scroll
if ( selection == 1 ) toption--;
}
}
if ( hold_buttons & SCE_CTRL_DOWN) {
if ( showoptions == 1 ) { //hadnling 1 option only
if ( selection >= options-1 ) selection = 0;
else selection += 1;
toption = selection;
} else {
if ( selection >= options-1 ) selection = 0;
else {
selection += 1;
if ( toption+showoptions < options ) { //scroll
if ( selection == toption+showoptions-1 ) toption++;
}
}
if ( toption+showoptions < options ) { //scroll
if ( selection == toption+showoptions-1 ) toption++;
}
}
}
if ( pressed_buttons & SCE_CTRL_CANCEL) running = 0; //back
if ( pressed_buttons & SCE_CTRL_ENTER) { //install
vita2d_end_drawing();
vita2d_swap_buffers();
sceDisplayWaitVblankStart();
int ret;
sprintf(buffer, "ux0:pspemu/PSP/GAME/%s/PBOOT.PBP", content_array[selection].titleID);
if ( doesFileExist(buffer) ) { /// existing PBOOT check
sprintf(buffer, "This game already got a \"%s\" PBOOT.PBP installed!", getEbootTitle(buffer) );
ret = recovery_draw_dialog(MAIN_TITLE, buffer, "Continue anyway and overwrite it?");
if ( ret ) goto install;
} else {
ret = recovery_draw_dialog(MAIN_TITLE, content_array[selection].title, "Do you really want to continue installing to this Game?");
if ( ret ) {
install:
closeVita2DLib(); //shutdown Vita2dLib
//lock_psbutton();
if ( ADR_INSTALLED ) { // if adrenaline is fully installed already
if ( strcmp(arg2, ADR_FOLDER ) == 0 ) {
change_adrenaline_files(content_array[selection].titleID, arg, arg2, 0); //simply update files (no reboot)
} else { // paths are different -> delete old stuff -> flag 1
change_adrenaline_files(content_array[selection].titleID, arg, arg2, 1); //
}
} else {
install_adrenaline_files(content_array[selection].titleID, arg); //full install + reboot
}
}
}
}
vita2d_end_drawing();
vita2d_swap_buffers();
sceDisplayWaitVblankStart();
}
return 0;
}
void *files_option(char *arg) {
recovery_draw_submenu(files_menu, "Select Adrenaline Release", arg);
return 0;
}
void *installer_options(char *arg) {
recovery_draw_submenu(installer_menu, MAIN_TITLE, arg);
return 0;
}
void *theme_options(char *arg) {
recovery_draw_submenu(theme_menu, "Theming Options (optional)", arg);
return 0;
}
void *install_theme() {
int ret = recovery_draw_dialog(MAIN_TITLE, "Do you really want to continue installing the theme?", "A reboot will be required!");
if ( ret ) {
closeVita2DLib(); //shutdown Vita2dLib
//lock_psbutton();
install_theme_files(PSP_GAME_ID);
}
return 0;
}
void *uninstall_theme() {
int ret = recovery_draw_dialog(MAIN_TITLE, "Do you really want to restore the original livearea theme?", "A reboot will be required!");
if ( ret ) {
closeVita2DLib(); //shutdown Vita2dLib
//lock_psbutton();
uninstall_theme_files(PSP_GAME_ID);
}
return 0;
}
void *install_sqlite_theme() {
int ret = recovery_draw_dialog(MAIN_TITLE, "Do you really want to continue installing?", "");
if ( ret ) {
recovery_draw_statusmessage(MAIN_TITLE, "Installing.. Please wait..");
ret = add_livearea_style(PSP_GAME_ID);
if ( ret ) { //successfull
theme_menu[3].type = MENU_ACTIVE;
theme_menu[2].type = MENU_BLOCKED;
recovery_draw_message(MAIN_TITLE, "The LiveArea has been modified successfully!", "Okay");
} else {
recovery_draw_message(MAIN_TITLE, "An error occured!", "Okay");
}
}
return 0;
}
void *uninstall_sqlite_theme() {
int ret = recovery_draw_dialog(MAIN_TITLE, "Do you really want to remove the LiveArea frames?", "");
if ( ret ) {
recovery_draw_statusmessage(MAIN_TITLE, "Removing.. Please wait..");
ret = remove_livearea_style(PSP_GAME_ID);
if ( ret ) { //successfull
theme_menu[2].type = MENU_ACTIVE;
theme_menu[3].type = MENU_BLOCKED;
recovery_draw_message(MAIN_TITLE, "The LiveArea has been restored successfully!", "Okay");
} else {
recovery_draw_message(MAIN_TITLE, "An error occured!", "Okay");
}
}
return 0;
}
void *more_options(char *arg) {
recovery_draw_submenu(more_menu, "Advanced Options", arg);
return 0;
}
/// installs a small basegame
void *install_pspgame() {
int ret = recovery_draw_dialog(MAIN_TITLE, "Do you really want to continue installing a PSP Game?", "After that you will be able to install Adrenaline to it!");
if ( ret ) {
closeVita2DLib(); //shutdown Vita2dLib
//lock_psbutton();
install_psp_basegame();
}
return 0;
}
/// This will delete the adrenaline flash files
int *option_delete_flash() {
int ret = recovery_draw_dialog(MAIN_TITLE, "Do you really want to delete the flash files?","");
if ( ret ) {
recovery_draw_statusmessage(MAIN_TITLE, "Deleting flash files.. Please wait.."); //needs error catching TODO
sprintf(buffer, "%s/adrenaline.bin", ADR_FOLDER);
sceIoRemove(buffer);
sprintf(buffer, "%s/flash0", ADR_FOLDER);
removePath(buffer);
sprintf(buffer, "%s/flash1", ADR_FOLDER);
removePath(buffer);
recovery_draw_message(MAIN_TITLE, "The flash files were deleted successfully!", "Okay");
more_menu[1].type = MENU_BLOCKED; //deactivate again
}
return 0;
}
/// This will delete 661.PBP in ADR_FOLDER
int *option_delete_pbp() {
int ret = recovery_draw_dialog(MAIN_TITLE, "Do you really want to delete the 6.61 Update file?", "This will save you about 32MB of diskspace.");
if ( ret ) {
recovery_draw_statusmessage(MAIN_TITLE, "Deleting.. Please wait..");
sprintf(buffer, "%s/661.PBP", ADR_FOLDER);
ret = sceIoRemove(buffer);
if ( ret < 0 ) {
recovery_draw_message(MAIN_TITLE, "An error occured!", "Okay");
} else {
recovery_draw_message(MAIN_TITLE, "The Update file has been deleted!", "Okay");
more_menu[2].type = MENU_BLOCKED; //deactivate again
}
}
return 0;
}
/// This will delete the savestates folder
int *option_delete_savestates() {
int ret = recovery_draw_dialog(MAIN_TITLE, "Do you really want to delete all your SaveStates?", "(ux0:pspemu/PSP/SAVESTATE/)");
if ( ret ) {
recovery_draw_statusmessage(MAIN_TITLE, "Deleting.. Please wait..");
ret = removePath("ux0:pspemu/PSP/SAVESTATE");
if ( ret == 1 ) {
recovery_draw_message(MAIN_TITLE, "All SaveStates have been deleted!", "Okay");
more_menu[3].type = MENU_BLOCKED; //deactivate again
} else {
recovery_draw_message(MAIN_TITLE, "An error occured!", "Okay");
}
}
return 0;
}
int *option_show_changelogfile() {
recovery_draw_textfile("Adrenaline Update-History", "app0:files/updatehistory.txt");
return 0;
}
int *option_show_taiconfig() {
recovery_draw_textfile(TAI_CONFIG, TAI_CONFIG);
return 0;
}
//for testing purposes only
int option_test() {
closeVita2DLib(); //shutdown Vita2dLib
psvDebugScreenInit();
psvDebugScreenClear(BLACK);
/**int res;
int ret;
int state;
printf("trying to promote backup folder\n-------------------------------\n\n");
/// loadScePaf
uint32_t ptr[0x100] = { 0 };
ptr[0] = 0;
ptr[1] = (uint32_t)&ptr[0];
uint32_t scepaf_argp[] = { 0x400000, 0xEA60, 0x40000, 0, 0 };
sceSysmoduleLoadModuleInternalWithArg(0x80000008, sizeof(scepaf_argp), scepaf_argp, ptr);
/// Backup Promote
ret = sceSysmoduleLoadModuleInternal(SCE_SYSMODULE_PROMOTER_UTIL); //
printf("sceSysmoduleLoadModuleInternal: 0x%x\n", ret); //0x8002D003 -> SCE_KERNEL_ERROR_MODULEMGR_NO_LIB
ret = scePromoterUtilityInit();
printf("scePromoterUtilityInit: 0x%x\n", ret);
printf("\n\n");