mirror of
https://github.com/parasyte/alt64
synced 2025-02-28 17:31:47 -05:00
commit
cbe96f4183
113
src/main.c
113
src/main.c
@ -49,6 +49,12 @@
|
|||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
#include "cic.h"
|
#include "cic.h"
|
||||||
|
|
||||||
|
#ifdef ED64PLUS
|
||||||
|
#define ED64_FIRMWARE_PATH "ED64P"
|
||||||
|
#else
|
||||||
|
#define ED64_FIRMWARE_PATH "ED64"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef USE_TRUETYPE
|
#ifdef USE_TRUETYPE
|
||||||
#define STB_TRUETYPE_IMPLEMENTATION
|
#define STB_TRUETYPE_IMPLEMENTATION
|
||||||
#include "stb_truetype.h"
|
#include "stb_truetype.h"
|
||||||
@ -142,7 +148,6 @@ u16 cursor_history_pos = 0;
|
|||||||
|
|
||||||
u8 empty = 0;
|
u8 empty = 0;
|
||||||
int mp3playing = 0;
|
int mp3playing = 0;
|
||||||
u8 gb_load_y = 0;
|
|
||||||
|
|
||||||
FATFS *fs;
|
FATFS *fs;
|
||||||
|
|
||||||
@ -1015,7 +1020,7 @@ void romInfoScreen(display_context_t disp, u8 *buff, int silent)
|
|||||||
|
|
||||||
sprite_t *n64cover;
|
sprite_t *n64cover;
|
||||||
|
|
||||||
sprintf(box_path, "/ED64/boxart/lowres/%c%c.png", headerdata[0x3C], headerdata[0x3D]);
|
sprintf(box_path, "/"ED64_FIRMWARE_PATH"/boxart/lowres/%c%c.png", headerdata[0x3C], headerdata[0x3D]);
|
||||||
|
|
||||||
FILINFO fnoba;
|
FILINFO fnoba;
|
||||||
result = f_stat (box_path, &fnoba);
|
result = f_stat (box_path, &fnoba);
|
||||||
@ -1023,7 +1028,7 @@ void romInfoScreen(display_context_t disp, u8 *buff, int silent)
|
|||||||
if (result != FR_OK)
|
if (result != FR_OK)
|
||||||
{
|
{
|
||||||
//not found
|
//not found
|
||||||
sprintf(box_path, "/ED64/boxart/lowres/00.png");
|
sprintf(box_path, "/"ED64_FIRMWARE_PATH"/boxart/lowres/00.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
n64cover = loadPng(box_path);
|
n64cover = loadPng(box_path);
|
||||||
@ -1084,12 +1089,12 @@ void loadgbrom(display_context_t disp, u8 *buff)
|
|||||||
FRESULT fr;
|
FRESULT fr;
|
||||||
FILINFO fno;
|
FILINFO fno;
|
||||||
|
|
||||||
fr = f_stat("/ED64/gblite.z64", &fno);
|
fr = f_stat("/"ED64_FIRMWARE_PATH"/gblite.z64", &fno);
|
||||||
if (fr == FR_OK)
|
if (fr == FR_OK)
|
||||||
{
|
{
|
||||||
TCHAR gb_sram_file[64];
|
TCHAR gb_sram_file[64];
|
||||||
|
|
||||||
sprintf(gb_sram_file, "/ED64/%s/gblite.SRM", save_path);
|
sprintf(gb_sram_file, "/"ED64_FIRMWARE_PATH"/%s/gblite.SRM", save_path);
|
||||||
|
|
||||||
FRESULT result;
|
FRESULT result;
|
||||||
FIL file;
|
FIL file;
|
||||||
@ -1119,7 +1124,7 @@ void loadgbrom(display_context_t disp, u8 *buff)
|
|||||||
sprintf(rom_filename, "gblite");
|
sprintf(rom_filename, "gblite");
|
||||||
gbload = 1;
|
gbload = 1;
|
||||||
|
|
||||||
loadrom(disp, "/ED64/gblite.z64", 1);
|
loadrom(disp, "/"ED64_FIRMWARE_PATH"/gblite.z64", 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1154,7 +1159,7 @@ void loadmsx2rom(display_context_t disp, TCHAR *rom_path)
|
|||||||
FRESULT result;
|
FRESULT result;
|
||||||
FIL file;
|
FIL file;
|
||||||
UINT bytesread;
|
UINT bytesread;
|
||||||
result = f_open(&file, "/ED64/ultraMSX2.z64", FA_READ);
|
result = f_open(&file, "/"ED64_FIRMWARE_PATH"/ultraMSX2.z64", FA_READ);
|
||||||
|
|
||||||
if (result == FR_OK)
|
if (result == FR_OK)
|
||||||
{
|
{
|
||||||
@ -1225,7 +1230,7 @@ void loadggrom(display_context_t disp, TCHAR *rom_path) //TODO: this could be me
|
|||||||
FRESULT result;
|
FRESULT result;
|
||||||
FIL file;
|
FIL file;
|
||||||
UINT bytesread;
|
UINT bytesread;
|
||||||
result = f_open(&file, "/ED64/UltraSMS.z64", FA_READ);
|
result = f_open(&file, "/"ED64_FIRMWARE_PATH"/UltraSMS.z64", FA_READ);
|
||||||
|
|
||||||
if (result == FR_OK)
|
if (result == FR_OK)
|
||||||
{
|
{
|
||||||
@ -1267,29 +1272,12 @@ void loadggrom(display_context_t disp, TCHAR *rom_path) //TODO: this could be me
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void rom_load_y(void)
|
|
||||||
{
|
|
||||||
FRESULT fr;
|
|
||||||
FILINFO fno;
|
|
||||||
|
|
||||||
u8 gb_sram_file[64];
|
|
||||||
u8 gb_sram_file2[64];
|
|
||||||
sprintf(gb_sram_file, "%c%c%c%c%c%c%c", 'O', 'S', '6', '4', 'P', '/', 'O');
|
|
||||||
sprintf(gb_sram_file2, "%s%c%c%c%c%c%c%c%c", gb_sram_file, 'S', '6', '4', 'P', '.', 'v', '6', '4');
|
|
||||||
|
|
||||||
fr = f_stat(gb_sram_file2, &fno);
|
|
||||||
if (fr == FR_OK)
|
|
||||||
{
|
|
||||||
gb_load_y = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void loadnesrom(display_context_t disp, TCHAR *rom_path)
|
void loadnesrom(display_context_t disp, TCHAR *rom_path)
|
||||||
{
|
{
|
||||||
FRESULT result;
|
FRESULT result;
|
||||||
FIL emufile;
|
FIL emufile;
|
||||||
UINT emubytesread;
|
UINT emubytesread;
|
||||||
result = f_open(&emufile, "/ED64/neon64bu.rom", FA_READ);
|
result = f_open(&emufile, "/"ED64_FIRMWARE_PATH"/neon64bu.rom", FA_READ);
|
||||||
|
|
||||||
if (result == FR_OK)
|
if (result == FR_OK)
|
||||||
{
|
{
|
||||||
@ -1522,7 +1510,7 @@ int backupSaveData(display_context_t disp)
|
|||||||
{
|
{
|
||||||
//backup cart-save on sd after reboot
|
//backup cart-save on sd after reboot
|
||||||
TCHAR config_file_path[32];
|
TCHAR config_file_path[32];
|
||||||
sprintf(config_file_path, "/ED64/%s/LASTROM.CFG", save_path);
|
sprintf(config_file_path, "/"ED64_FIRMWARE_PATH"/%s/LASTROM.CFG", save_path);
|
||||||
|
|
||||||
u8 save_format;
|
u8 save_format;
|
||||||
u8 cfg_data[2]; //TODO: this should be a strut?
|
u8 cfg_data[2]; //TODO: this should be a strut?
|
||||||
@ -1628,13 +1616,12 @@ int backupSaveData(display_context_t disp)
|
|||||||
//write a cart-save from a file to the fpga/cart
|
//write a cart-save from a file to the fpga/cart
|
||||||
int saveTypeFromSd(display_context_t disp, char *rom_name, int stype)
|
int saveTypeFromSd(display_context_t disp, char *rom_name, int stype)
|
||||||
{
|
{
|
||||||
rom_load_y();
|
|
||||||
TRACE(disp, rom_filename);
|
TRACE(disp, rom_filename);
|
||||||
TCHAR fname[256] = {0};
|
TCHAR fname[256] = {0};
|
||||||
sprintf(fname, "/ED64/%s/%s.%s", save_path, rom_name, saveTypeToExtension(stype, ext_type));
|
sprintf(fname, "/"ED64_FIRMWARE_PATH"/%s/%s.%s", save_path, rom_name, saveTypeToExtension(stype, ext_type));
|
||||||
|
|
||||||
TCHAR fname1[50] = {0};
|
TCHAR fname1[50] = {0};
|
||||||
sprintf(fname1, "/ED64/%s/", save_path);
|
sprintf(fname1, "/"ED64_FIRMWARE_PATH"/%s/", save_path);
|
||||||
printText(fname1, 3, -1, disp);
|
printText(fname1, 3, -1, disp);
|
||||||
TCHAR fname2[50] = {0};
|
TCHAR fname2[50] = {0};
|
||||||
sprintf(fname2, "%s.%s", rom_name, saveTypeToExtension(stype, ext_type));
|
sprintf(fname2, "%s.%s", rom_name, saveTypeToExtension(stype, ext_type));
|
||||||
@ -1699,28 +1686,24 @@ int saveTypeFromSd(display_context_t disp, char *rom_name, int stype)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gb_load_y != 1)
|
if (pushSaveToCart(stype, cartsave_data))
|
||||||
{
|
{
|
||||||
if (pushSaveToCart(stype, cartsave_data))
|
printText("transferred save data...", 3, -1, disp);
|
||||||
{
|
}
|
||||||
printText("transferred save data...", 3, -1, disp);
|
else
|
||||||
}
|
{
|
||||||
else
|
printText("error transfering save data", 3, -1, disp);
|
||||||
{
|
}
|
||||||
printText("error transfering save data", 3, -1, disp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int saveTypeToSd(display_context_t disp, char *rom_name, int stype)
|
int saveTypeToSd(display_context_t disp, char *rom_name, int stype)
|
||||||
{
|
{
|
||||||
rom_load_y();
|
|
||||||
//after reset create new savefile
|
//after reset create new savefile
|
||||||
TCHAR fname[256]; //TODO: change filename buffers to 256!!!
|
TCHAR fname[256]; //TODO: change filename buffers to 256!!!
|
||||||
|
|
||||||
sprintf(fname, "/ED64/%s/%s.%s", save_path, rom_name, saveTypeToExtension(stype, ext_type));
|
sprintf(fname, "/"ED64_FIRMWARE_PATH"/%s/%s.%s", save_path, rom_name, saveTypeToExtension(stype, ext_type));
|
||||||
|
|
||||||
int size = saveTypeToSize(stype); // int byte
|
int size = saveTypeToSize(stype); // int byte
|
||||||
TRACEF(disp, "size for save=%i", size);
|
TRACEF(disp, "size for save=%i", size);
|
||||||
@ -1742,18 +1725,14 @@ int saveTypeToSd(display_context_t disp, char *rom_name, int stype)
|
|||||||
printText("Transfering save data...", 3, -1, disp);
|
printText("Transfering save data...", 3, -1, disp);
|
||||||
if (getSaveFromCart(stype, cartsave_data))
|
if (getSaveFromCart(stype, cartsave_data))
|
||||||
{
|
{
|
||||||
//write to file
|
UINT bw;
|
||||||
if (gb_load_y != 1)
|
result = f_write (
|
||||||
{
|
&file, /* [IN] Pointer to the file object structure */
|
||||||
UINT bw;
|
cartsave_data, /* [IN] Pointer to the data to be written */
|
||||||
result = f_write (
|
size, /* [IN] Number of bytes to write */
|
||||||
&file, /* [IN] Pointer to the file object structure */
|
&bw /* [OUT] Pointer to the variable to return number of bytes written */
|
||||||
cartsave_data, /* [IN] Pointer to the data to be written */
|
);
|
||||||
size, /* [IN] Number of bytes to write */
|
f_close(&file);
|
||||||
&bw /* [OUT] Pointer to the variable to return number of bytes written */
|
|
||||||
);
|
|
||||||
f_close(&file);
|
|
||||||
}
|
|
||||||
|
|
||||||
printText("RAM area copied to SD card.", 3, -1, disp);
|
printText("RAM area copied to SD card.", 3, -1, disp);
|
||||||
return 1;
|
return 1;
|
||||||
@ -1775,7 +1754,7 @@ int saveTypeToSd(display_context_t disp, char *rom_name, int stype)
|
|||||||
int readConfigFile(void)
|
int readConfigFile(void)
|
||||||
{
|
{
|
||||||
TCHAR filename[32];
|
TCHAR filename[32];
|
||||||
sprintf(filename, "/ED64/ALT64.INI");
|
sprintf(filename, "/"ED64_FIRMWARE_PATH"/ALT64.INI");
|
||||||
|
|
||||||
FRESULT result;
|
FRESULT result;
|
||||||
FIL file;
|
FIL file;
|
||||||
@ -1878,7 +1857,7 @@ void readSDcard(display_context_t disp, char *directory)
|
|||||||
// u8 cresp = 0;
|
// u8 cresp = 0;
|
||||||
|
|
||||||
// //load the directory-entry
|
// //load the directory-entry
|
||||||
// cresp = fatLoadDirByName("/ED64/CFG");
|
// cresp = fatLoadDirByName("/"ED64_FIRMWARE_PATH"/CFG");
|
||||||
|
|
||||||
// int dsize = dir->size;
|
// int dsize = dir->size;
|
||||||
// char colorlist[dsize][256];
|
// char colorlist[dsize][256];
|
||||||
@ -1892,7 +1871,7 @@ void readSDcard(display_context_t disp, char *directory)
|
|||||||
// u8 rom_cfg_file[128];
|
// u8 rom_cfg_file[128];
|
||||||
|
|
||||||
// //set rom_cfg
|
// //set rom_cfg
|
||||||
// sprintf(rom_cfg_file, "/ED64/CFG/%s", frec->name);
|
// sprintf(rom_cfg_file, "/"ED64_FIRMWARE_PATH"/CFG/%s", frec->name);
|
||||||
|
|
||||||
// static uint8_t cfg_file_data[512] = {0};
|
// static uint8_t cfg_file_data[512] = {0};
|
||||||
|
|
||||||
@ -2222,7 +2201,7 @@ void bootRom(display_context_t disp, int silent)
|
|||||||
TCHAR cfg_file[32];
|
TCHAR cfg_file[32];
|
||||||
|
|
||||||
//set cfg file with last loaded cart info and save-type
|
//set cfg file with last loaded cart info and save-type
|
||||||
sprintf(cfg_file, "/ED64/%s/LASTROM.CFG", save_path);
|
sprintf(cfg_file, "/"ED64_FIRMWARE_PATH"/%s/LASTROM.CFG", save_path);
|
||||||
|
|
||||||
FRESULT result;
|
FRESULT result;
|
||||||
FIL file;
|
FIL file;
|
||||||
@ -2267,7 +2246,7 @@ void bootRom(display_context_t disp, int silent)
|
|||||||
printText("try to load cheat-file...", 3, -1, disp);
|
printText("try to load cheat-file...", 3, -1, disp);
|
||||||
|
|
||||||
char cheat_filename[64];
|
char cheat_filename[64];
|
||||||
sprintf(cheat_filename, "/ED64/CHEATS/%s.yml", rom_filename);
|
sprintf(cheat_filename, "/"ED64_FIRMWARE_PATH"/CHEATS/%s.yml", rom_filename);
|
||||||
|
|
||||||
int ok = readCheatFile(cheat_filename, cheat_lists);
|
int ok = readCheatFile(cheat_filename, cheat_lists);
|
||||||
if (ok == 0)
|
if (ok == 0)
|
||||||
@ -2405,7 +2384,7 @@ void readRomConfig(display_context_t disp, char *short_filename, char *full_file
|
|||||||
TCHAR cfg_filename[256];
|
TCHAR cfg_filename[256];
|
||||||
sprintf(rom_filename, "%s", short_filename);
|
sprintf(rom_filename, "%s", short_filename);
|
||||||
rom_filename[strlen(rom_filename) - 4] = '\0'; // cut extension
|
rom_filename[strlen(rom_filename) - 4] = '\0'; // cut extension
|
||||||
sprintf(cfg_filename, "/ED64/CFG/%s.CFG", rom_filename);
|
sprintf(cfg_filename, "/"ED64_FIRMWARE_PATH"/CFG/%s.CFG", rom_filename);
|
||||||
|
|
||||||
uint8_t rom_cfg_data[512];
|
uint8_t rom_cfg_data[512];
|
||||||
|
|
||||||
@ -2606,7 +2585,7 @@ void drawToplistBox(display_context_t disp, int line)
|
|||||||
|
|
||||||
if (line == 0)
|
if (line == 0)
|
||||||
{
|
{
|
||||||
char* path = "/ED64/CFG";
|
char* path = "/"ED64_FIRMWARE_PATH"/CFG";
|
||||||
|
|
||||||
FRESULT res;
|
FRESULT res;
|
||||||
DIR dir;
|
DIR dir;
|
||||||
@ -3110,7 +3089,7 @@ void loadFile(display_context_t disp)
|
|||||||
{
|
{
|
||||||
FRESULT result;
|
FRESULT result;
|
||||||
FIL file;
|
FIL file;
|
||||||
result = f_open(&file, "/ED64/LASTROM.CFG", FA_WRITE | FA_CREATE_ALWAYS);
|
result = f_open(&file, "/"ED64_FIRMWARE_PATH"/LASTROM.CFG", FA_WRITE | FA_CREATE_ALWAYS);
|
||||||
if (result == FR_OK)
|
if (result == FR_OK)
|
||||||
{
|
{
|
||||||
f_puts (
|
f_puts (
|
||||||
@ -3469,7 +3448,7 @@ void handleInput(display_context_t disp, sprite_t *contr)
|
|||||||
FRESULT result;
|
FRESULT result;
|
||||||
FIL file;
|
FIL file;
|
||||||
UINT bytesread;
|
UINT bytesread;
|
||||||
result = f_open(&file, "/ED64/LASTROM.CFG", FA_READ);
|
result = f_open(&file, "/"ED64_FIRMWARE_PATH"/LASTROM.CFG", FA_READ);
|
||||||
|
|
||||||
if (result == FR_OK)
|
if (result == FR_OK)
|
||||||
{
|
{
|
||||||
@ -4028,7 +4007,7 @@ void handleInput(display_context_t disp, sprite_t *contr)
|
|||||||
* /ED64
|
* /ED64
|
||||||
*
|
*
|
||||||
* cursor=SAVE
|
* cursor=SAVE
|
||||||
* /ED64/SAVE
|
* /"ED64_FIRMWARE_PATH"/SAVE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (strcmp(pwd, "/") == 0)
|
if (strcmp(pwd, "/") == 0)
|
||||||
@ -4094,7 +4073,7 @@ void handleInput(display_context_t disp, sprite_t *contr)
|
|||||||
u8 resp = 0;
|
u8 resp = 0;
|
||||||
|
|
||||||
//set rom_cfg
|
//set rom_cfg
|
||||||
sprintf(rom_cfg_file, "/ED64/CFG/%s.CFG", rom_filename);
|
sprintf(rom_cfg_file, "/"ED64_FIRMWARE_PATH"/CFG/%s.CFG", rom_filename);
|
||||||
|
|
||||||
|
|
||||||
FRESULT result;
|
FRESULT result;
|
||||||
@ -4416,7 +4395,7 @@ int main(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
char background_path[64];
|
char background_path[64];
|
||||||
sprintf(background_path, "/ED64/wallpaper/%s", background_image);
|
sprintf(background_path, "/"ED64_FIRMWARE_PATH"/wallpaper/%s", background_image);
|
||||||
|
|
||||||
FRESULT fr;
|
FRESULT fr;
|
||||||
FILINFO fno;
|
FILINFO fno;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user