Merge pull request #10 from networkfusion/v3support

V3support
This commit is contained in:
networkfusion 2016-09-07 15:52:39 +01:00 committed by GitHub
commit b594cd3998
2 changed files with 43 additions and 42 deletions

2
fat.c
View File

@ -658,7 +658,7 @@ u8 fatGetNextCluster(u32 *cluster) {
} }
u8 fatOpenFileByeName(u8 *name, u32 wr_sectors) { u8 fatOpenFileByeName(u8 *name, u32 wr_sectors) { //TODO: spelling mistake
//u16 i; //u16 i;
u8 resp; u8 resp;

81
menu.c
View File

@ -781,7 +781,7 @@ void configure() {
asm_date = memRomRead32(0x38); asm_date = memRomRead32(0x38);
evd_setCfgBit(ED_CFG_SDRAM_ON, 1); evd_setCfgBit(ED_CFG_SDRAM_ON, 1);
firm = evd_readReg(REG_VER); firm = evd_readReg(REG_VER); //TODO: why not just use evd_getFirmVersion()
if (streql("ED64 SD boot", buff, 12) && firm >= 0x0116) { if (streql("ED64 SD boot", buff, 12) && firm >= 0x0116) {
sd_mode = 1; sd_mode = 1;
@ -797,8 +797,13 @@ void configure() {
if (!(msg & (1 << 14))) { if (!(msg & (1 << 14))) {
msg |= 1 << 14; msg |= 1 << 14;
evd_writeReg(REG_MAX_MSG, msg); evd_writeReg(REG_MAX_MSG, msg);
if (firm == 0x0214) {
int fpf = dfs_open("/firmware.bin");
firmware = malloc( dfs_size( fpf ) );
dfs_read( firmware, 1, dfs_size( fpf ), fpf );
dfs_close( fpf );
bi_load_firmware(firmware); bi_load_firmware(firmware);
}
sleep(1); sleep(1);
evd_init(); evd_init();
@ -1342,65 +1347,66 @@ void loadrom(display_context_t disp, u8 *buff, int fast){
int backupSaveData(display_context_t disp){ int backupSaveData(display_context_t disp){
//backup cart-save on sd after reboot //backup cart-save on sd after reboot
u8 fname[32]; u8 config_file_path[32];
u8 found=0; int save_format;
int save_t;
sprintf(fname, "/ED64/%s/LAST.CRT",save_path); sprintf(config_file_path, "/ED64/%s/LAST.CRT",save_path);
uint8_t cfg_data[512]; uint8_t cfg_data[512]; //TODO: this should be a strut
FatRecord rec_tmpf; FatRecord rec_tmpf;
found = fatFindRecord(fname, &rec_tmpf, 0);
printText("Save System - please stand by", 3, 4, disp); printText("Saving Last Played Game State...", 3, 4, disp);
if(found==0){ if(fatFindRecord(config_file_path, &rec_tmpf, 0) == 0) { //TODO: why does fatFindRecord return 0 for true?!
//found //found
//file to cfg_data buffer //file to cfg_data buffer
u8 resp = 0; u8 resp = 0;
resp = fatOpenFileByeName(fname, 0); fatOpenFileByeName(config_file_path, 0);
resp = fatReadFile(&cfg_data, 1); fatReadFile(&cfg_data, 1);
//split in save type and cart-id //split in save type and cart-id
save_t=cfg_data[0]; save_format=cfg_data[0];
int last_cic=cfg_data[1]; int last_cic=cfg_data[1];
scopy(cfg_data+2, rom_filename); scopy(cfg_data+2, rom_filename); //string copy
//set savetype to 0 disable for next boot //set savetype to 0 disable for next boot
if(save_t!=0){ if(save_format!=0){
//set savetype to off //set savetype to off
cfg_data[0]=0; cfg_data[0]=0;
u8 tmp[32]; u8 tmp[32];
resp = fatOpenFileByeName(fname, 1); //if sector is set filemode=WR writeable resp = fatOpenFileByeName(config_file_path, 1); //if sector is set filemode=WR writeable
if (debug) { if (debug) {
sprintf(tmp, "fatOpenFileByeName ret=%i",resp); sprintf(tmp, "FAT_OpenFileByName returned: %i",resp);
printText(tmp, 3, -1, disp); printText(tmp, 3, -1, disp);
} }
resp = fatWriteFile(&cfg_data, 1); //filemode must be wr resp = fatWriteFile(&cfg_data, 1); //filemode must be wr
if (debug) { if (debug) {
sprintf(tmp, "fatWriteFile ret=%i",resp); printText("Disabling save for subsequent system reboots", 3, -1, disp);
sprintf(tmp, "FAT_WriteFile returned: %i",resp);
printText(tmp, 3, -1, disp); printText(tmp, 3, -1, disp);
printText("SaveType-tag has been disabled for next boot", 3, -1, disp);
} }
volatile u8 save_cfg_stat=0; volatile u8 save_config_state=0;
volatile u8 val=0; evd_readReg(0);
val = evd_readReg(0); save_config_state = evd_readReg(REG_SAV_CFG);
save_cfg_stat = evd_readReg(REG_SAV_CFG);
if(save_cfg_stat!=0) if(save_config_state!=0 || evd_getFirmVersion() >= 0x0300 ) { //save register set or the firmware is V3
if(save_config_state==0) {//we are V3 and have had a hard reboot
evd_writeReg(REG_SAV_CFG, 1); //so we need to tell the save register it still has data.
}
save_reboot=1; save_reboot=1;
} }
}
else { else {
if (debug) if (debug)
printText("no need to save to sd", 3, -1, disp); printText("Save not required.", 3, -1, disp);
else else
printText("...ready", 3, -1, disp); printText("...ready", 3, -1, disp);
@ -1411,7 +1417,7 @@ int backupSaveData(display_context_t disp){
} }
else{ else{
if (debug) if (debug)
printText("last.crt not found", 3, -1, disp); printText("No previous ROM loaded - the file 'last.crt' was not found!", 3, -1, disp);
else else
printText("...ready", 3, -1, disp); printText("...ready", 3, -1, disp);
@ -1424,15 +1430,15 @@ int backupSaveData(display_context_t disp){
//reset with save request //reset with save request
if(save_reboot){ if(save_reboot){
printText("saving...", 3, -1, disp); printText("Copying RAM to SD card...", 3, -1, disp);
if( saveTypeToSd(disp, rom_filename, save_t) ){ if( saveTypeToSd(disp, rom_filename, save_format) ){
if (debug) if (debug)
printText("save upload done...", 3, -1, disp); printText("Operation completed sucessfully...", 3, -1, disp);
else else
printText("...ready", 3, -1, disp); printText("...ready", 3, -1, disp);
} }
else if (debug) else if (debug)
printText("not saved...", 3, -1, disp); printText("ERROR: the RAM was not successfully saved!", 3, -1, disp);
} }
else { else {
if (debug) if (debug)
@ -1835,7 +1841,7 @@ int saveTypeFromSd(display_context_t disp, char* rom_name, int stype) {
} }
else{ else{
printText("no savegame found", 3, -1, disp); printText("no savegame found", 3, -1, disp);
//todo clear memory arena //todo clear memory area
return 0; return 0;
} }
@ -3012,17 +3018,12 @@ int main(void) {
printf("Filesystem failed to start!\n"); printf("Filesystem failed to start!\n");
} }
else { else {
int fpf = dfs_open("/firmware.bin");
firmware = malloc( dfs_size( fpf ) );
dfs_read( firmware, 1, dfs_size( fpf ), fpf );
dfs_close( fpf );
// everdrive initial function // everdrive initial function
configure(); configure();
//fast boot for backup-save data //fast boot for backup-save data
int sj = evd_readReg(0); int sj = evd_readReg(0);
int save_job = evd_readReg(REG_SAV_CFG); int save_job = evd_readReg(REG_SAV_CFG); //TODO: or the firmware is V3
if(save_job!=0) if(save_job!=0)
fast_boot=1; fast_boot=1;
@ -3966,10 +3967,10 @@ int main(void) {
drawBoxNumber(disp,2); drawBoxNumber(disp,2);
display_show(disp); display_show(disp);
printText("About: ", 9, 8, disp); printText("ALT64: v0.1.8.6.1", 9, 8, disp);
printText(" ", 9, -1, disp); printText(" ", 9, -1, disp);
printText("ALT64: v0.1.8.6-cheat", 9, -1, disp); printText("by Saturnu", 9, -1, disp);
printText("by saturnu", 9, -1, disp); printText("& JonesAlmighty", 9, -1, disp);
printText(" ", 9, -1, disp); printText(" ", 9, -1, disp);
printText("Code engine by:", 9, -1, disp); printText("Code engine by:", 9, -1, disp);
printText("Jay Oster", 9, -1, disp); printText("Jay Oster", 9, -1, disp);