@@ -781,7 +781,7 @@ void configure() {
781
781
asm_date = memRomRead32 (0x38 );
782
782
evd_setCfgBit (ED_CFG_SDRAM_ON , 1 );
783
783
784
- firm = evd_readReg (REG_VER );
784
+ firm = evd_readReg (REG_VER ); //TODO: why not just use evd_getFirmVersion()
785
785
786
786
if (streql ("ED64 SD boot" , buff , 12 ) && firm >= 0x0116 ) {
787
787
sd_mode = 1 ;
@@ -797,8 +797,13 @@ void configure() {
797
797
if (!(msg & (1 << 14 ))) {
798
798
msg |= 1 << 14 ;
799
799
evd_writeReg (REG_MAX_MSG , msg );
800
-
801
- bi_load_firmware (firmware );
800
+ if (firm == 0x0214 ) {
801
+ int fpf = dfs_open ("/firmware.bin" );
802
+ firmware = malloc ( dfs_size ( fpf ) );
803
+ dfs_read ( firmware , 1 , dfs_size ( fpf ), fpf );
804
+ dfs_close ( fpf );
805
+ bi_load_firmware (firmware );
806
+ }
802
807
803
808
sleep (1 );
804
809
evd_init ();
@@ -1342,65 +1347,66 @@ void loadrom(display_context_t disp, u8 *buff, int fast){
1342
1347
1343
1348
int backupSaveData (display_context_t disp ){
1344
1349
//backup cart-save on sd after reboot
1345
- u8 fname [32 ];
1346
- u8 found = 0 ;
1347
- int save_t ;
1350
+ u8 config_file_path [32 ];
1351
+ int save_format ;
1348
1352
1349
- sprintf (fname , "/ED64/%s/LAST.CRT" ,save_path );
1350
- uint8_t cfg_data [512 ];
1353
+ sprintf (config_file_path , "/ED64/%s/LAST.CRT" ,save_path );
1354
+ uint8_t cfg_data [512 ]; //TODO: this should be a strut
1351
1355
1352
1356
FatRecord rec_tmpf ;
1353
- found = fatFindRecord (fname , & rec_tmpf , 0 );
1354
1357
1355
- printText ("Save System - please stand by " , 3 , 4 , disp );
1358
+ printText ("Saving Last Played Game State... " , 3 , 4 , disp );
1356
1359
1357
- if (found == 0 ){
1360
+ if (fatFindRecord ( config_file_path , & rec_tmpf , 0 ) == 0 ) { //TODO: why does fatFindRecord return 0 for true?!
1358
1361
//found
1359
1362
1360
1363
//file to cfg_data buffer
1361
1364
u8 resp = 0 ;
1362
- resp = fatOpenFileByeName (fname , 0 );
1363
- resp = fatReadFile (& cfg_data , 1 );
1365
+ fatOpenFileByeName (config_file_path , 0 );
1366
+ fatReadFile (& cfg_data , 1 );
1364
1367
1365
1368
//split in save type and cart-id
1366
- save_t = cfg_data [0 ];
1369
+ save_format = cfg_data [0 ];
1367
1370
int last_cic = cfg_data [1 ];
1368
- scopy (cfg_data + 2 , rom_filename );
1371
+ scopy (cfg_data + 2 , rom_filename ); //string copy
1369
1372
1370
1373
//set savetype to 0 disable for next boot
1371
- if (save_t != 0 ){
1374
+ if (save_format != 0 ){
1372
1375
//set savetype to off
1373
1376
cfg_data [0 ]= 0 ;
1374
1377
1375
1378
u8 tmp [32 ];
1376
1379
1377
- resp = fatOpenFileByeName (fname , 1 ); //if sector is set filemode=WR writeable
1380
+ resp = fatOpenFileByeName (config_file_path , 1 ); //if sector is set filemode=WR writeable
1378
1381
1379
1382
if (debug ) {
1380
- sprintf (tmp , "fatOpenFileByeName ret= %i" ,resp );
1383
+ sprintf (tmp , "FAT_OpenFileByName returned: %i" ,resp );
1381
1384
printText (tmp , 3 , -1 , disp );
1382
1385
}
1383
1386
1384
1387
resp = fatWriteFile (& cfg_data , 1 ); //filemode must be wr
1385
1388
1386
1389
if (debug ) {
1387
- sprintf (tmp , "fatWriteFile ret=%i" ,resp );
1390
+ printText ("Disabling save for subsequent system reboots" , 3 , -1 , disp );
1391
+ sprintf (tmp , "FAT_WriteFile returned: %i" ,resp );
1388
1392
printText (tmp , 3 , -1 , disp );
1389
1393
1390
- printText ("SaveType-tag has been disabled for next boot" , 3 , -1 , disp );
1391
1394
}
1392
1395
1393
- volatile u8 save_cfg_stat = 0 ;
1394
- volatile u8 val = 0 ;
1395
- val = evd_readReg (0 );
1396
- save_cfg_stat = evd_readReg (REG_SAV_CFG );
1396
+ volatile u8 save_config_state = 0 ;
1397
+ evd_readReg (0 );
1398
+ save_config_state = evd_readReg (REG_SAV_CFG );
1397
1399
1398
- if (save_cfg_stat != 0 )
1400
+ if (save_config_state != 0 || evd_getFirmVersion () >= 0x0300 ) { //save register set or the firmware is V3
1401
+ if (save_config_state == 0 ) {//we are V3 and have had a hard reboot
1402
+ evd_writeReg (REG_SAV_CFG , 1 ); //so we need to tell the save register it still has data.
1403
+ }
1399
1404
save_reboot = 1 ;
1405
+ }
1400
1406
}
1401
1407
else {
1402
1408
if (debug )
1403
- printText ("no need to save to sd " , 3 , -1 , disp );
1409
+ printText ("Save not required. " , 3 , -1 , disp );
1404
1410
else
1405
1411
printText ("...ready" , 3 , -1 , disp );
1406
1412
@@ -1411,7 +1417,7 @@ int backupSaveData(display_context_t disp){
1411
1417
}
1412
1418
else {
1413
1419
if (debug )
1414
- printText ("last.crt not found" , 3 , -1 , disp );
1420
+ printText ("No previous ROM loaded - the file ' last.crt' was not found! " , 3 , -1 , disp );
1415
1421
else
1416
1422
printText ("...ready" , 3 , -1 , disp );
1417
1423
@@ -1424,15 +1430,15 @@ int backupSaveData(display_context_t disp){
1424
1430
1425
1431
//reset with save request
1426
1432
if (save_reboot ){
1427
- printText ("saving ..." , 3 , -1 , disp );
1428
- if ( saveTypeToSd (disp , rom_filename , save_t ) ){
1433
+ printText ("Copying RAM to SD card ..." , 3 , -1 , disp );
1434
+ if ( saveTypeToSd (disp , rom_filename , save_format ) ){
1429
1435
if (debug )
1430
- printText ("save upload done ..." , 3 , -1 , disp );
1436
+ printText ("Operation completed sucessfully ..." , 3 , -1 , disp );
1431
1437
else
1432
1438
printText ("...ready" , 3 , -1 , disp );
1433
1439
}
1434
1440
else if (debug )
1435
- printText ("not saved... " , 3 , -1 , disp );
1441
+ printText ("ERROR: the RAM was not successfully saved! " , 3 , -1 , disp );
1436
1442
}
1437
1443
else {
1438
1444
if (debug )
@@ -1835,7 +1841,7 @@ int saveTypeFromSd(display_context_t disp, char* rom_name, int stype) {
1835
1841
}
1836
1842
else {
1837
1843
printText ("no savegame found" , 3 , -1 , disp );
1838
- //todo clear memory arena
1844
+ //todo clear memory area
1839
1845
1840
1846
return 0 ;
1841
1847
}
@@ -3012,17 +3018,12 @@ int main(void) {
3012
3018
printf ("Filesystem failed to start!\n" );
3013
3019
}
3014
3020
else {
3015
- int fpf = dfs_open ("/firmware.bin" );
3016
- firmware = malloc ( dfs_size ( fpf ) );
3017
- dfs_read ( firmware , 1 , dfs_size ( fpf ), fpf );
3018
- dfs_close ( fpf );
3019
-
3020
3021
// everdrive initial function
3021
3022
configure ();
3022
3023
3023
3024
//fast boot for backup-save data
3024
3025
int sj = evd_readReg (0 );
3025
- int save_job = evd_readReg (REG_SAV_CFG );
3026
+ int save_job = evd_readReg (REG_SAV_CFG ); //TODO: or the firmware is V3
3026
3027
3027
3028
if (save_job != 0 )
3028
3029
fast_boot = 1 ;
@@ -3966,10 +3967,10 @@ int main(void) {
3966
3967
drawBoxNumber (disp ,2 );
3967
3968
display_show (disp );
3968
3969
3969
- printText ("About: " , 9 , 8 , disp );
3970
+ printText ("ALT64: v0.1.8.6.1 " , 9 , 8 , disp );
3970
3971
printText (" " , 9 , -1 , disp );
3971
- printText ("ALT64: v0.1.8.6-cheat " , 9 , -1 , disp );
3972
- printText ("by saturnu " , 9 , -1 , disp );
3972
+ printText ("by Saturnu " , 9 , -1 , disp );
3973
+ printText ("& JonesAlmighty " , 9 , -1 , disp );
3973
3974
printText (" " , 9 , -1 , disp );
3974
3975
printText ("Code engine by:" , 9 , -1 , disp );
3975
3976
printText ("Jay Oster" , 9 , -1 , disp );
0 commit comments