Add support for /arcade folder, and MRA xml decoding

* round trip xml launch

* roms load

* removed debug

* added binary data and changed rom format

* changed hex format

* fixed bug

* added structure and start/length

* removed base64 support

* removed base64 support

* fixed parsing bugs

* fixed hex parse bug

* fixed parser

* fixing paths

* fixed rbf parser

* fixed initialization bug

* fixed extension removal for when there are multiple extension options

* fixed core path and cleaned up filelength

* added md5 checks to arcade roms

* fixed rbf search

* added error support

* Simplify error checking code

* fixed arcade error message pop up

* fixed bug in part zip initialization

* removed dtdt

* don't load second rom0 if first works

* fixed directory problem

* added more comments

* added / to zip path

* fixed / bug, truncate mame zip error message

* fixed scrolling RBF

* fixed scrolling name and error message

* added code to remove _date in scrolling text

* remove redundant /
This commit is contained in:
Alan Steremberg
2019-12-11 08:33:27 -08:00
committed by sorgelig
parent aedb73aa12
commit d981092caa
16 changed files with 1313 additions and 54 deletions

View File

@@ -12,6 +12,8 @@
#include <sys/mman.h>
#include "lib/lodepng/lodepng.h"
#include "md5.h"
#include "hardware.h"
#include "osd.h"
#include "user_io.h"
@@ -691,16 +693,26 @@ int user_io_is_dualsdr()
return dual_sdr;
}
void user_io_init(const char *path)
void user_io_init(const char *path, const char *xml)
{
char *name;
static char mainpath[512];
core_name[0] = 0;
disable_osd = 0;
// we need to set the directory to where the XML file (MRA) is
// not the RBF. The RBF will be in arcade, which the user shouldn't
// browse
if (strlen(xml)) {
//printf("USER_IO_INIT got XML: [%s] [%s]\n",path,xml);
strcpy(core_path, getFullPath(xml));
} else {
strcpy(core_path, path);
}
//printf("USER_IO_INIT core_path: [%s] \n",core_path);
memset(sd_image, 0, sizeof(sd_image));
strcpy(core_path, path);
core_type = (fpga_core_id() & 0xFF);
fio_size = fpga_get_fio_size();
io_ver = fpga_get_io_version();
@@ -857,6 +869,14 @@ void user_io_init(const char *path)
if (user_io_use_cheats()) cheats_init("", user_io_get_file_crc());
}
/* AJS -- NOT SURE THIS IS THE BEST PLACE */
if (strlen(xml)) {
//sprintf(mainpath, "%s/%s", user_io_get_core_path(), xml);
printf("USER_IO_INIT got XML: [%s]\n",xml);
//printf("USER_IO_INIT got XML: [%s]\n",mainpath);
arcade_send_rom(getFullPath(xml));
}
if (is_cpc_core())
{
for (int m = 0; m < 3; m++)
@@ -1579,6 +1599,101 @@ static void check_status_change()
}
}
#define DEBUG_ROM_BINARY 0
#if DEBUG_ROM_BINARY
FILE *rombinary;
#endif
int user_io_file_tx_start(const char *name,unsigned char index)
{
// set index byte (0=bios rom, 1-n=OSD entry index)
user_io_set_index(index);
int len = strlen(name);
const char *p = name + len - 4;
EnableFpga();
spi8(UIO_FILE_INFO);
spi_w(toupper(p[0]) << 8 | toupper(p[1]));
spi_w(toupper(p[2]) << 8 | toupper(p[3]));
DisableFpga();
// prepare transmission of new file
EnableFpga();
spi8(UIO_FILE_TX);
spi8(0xff);
DisableFpga();
file_crc = 0;
#if DEBUG_ROM_BINARY
rombinary=fopen("/media/fat/this.rom","wb");
#endif
return 1;
}
int user_io_file_tx_body(const uint8_t *buf,uint16_t chunk,struct MD5Context *md5context)
{
printf(".");
EnableFpga();
spi8(UIO_FILE_TX_DAT);
spi_write(buf, chunk, fio_size);
DisableFpga();
file_crc = crc32(file_crc, buf ,chunk );
if (md5context) MD5Update (md5context, buf,chunk);
#if DEBUG_ROM_BINARY
fwrite(buf,1,chunk,rombinary);
#endif
return 1;
}
int user_io_file_tx_body_filepart(const char *name,int start, int len,struct MD5Context *md5context)
{
char mute=0;
fileTYPE f = {};
static uint8_t buf[4096];
if (!FileOpen(&f, name, mute)) return 0;
if (start) FileSeek(&f, start, SEEK_SET);
unsigned long bytes2send = f.size;
if (len>0 && len < bytes2send) bytes2send=len;
/* transmit the entire file using one transfer */
printf("Selected file %s with %lu bytes to send \n", name, bytes2send);
while (bytes2send)
{
printf(".");
uint16_t chunk = (bytes2send > sizeof(buf)) ? sizeof(buf) : bytes2send;
FileReadAdv(&f, buf, chunk);
user_io_file_tx_body(buf,chunk,md5context);
bytes2send -= chunk;
}
return 1;
}
int user_io_file_tx_finish()
{
// check if core requests some change while downloading
check_status_change();
printf("\n");
printf("CRC32: %08X\n", file_crc);
#if DEBUG_ROM_BINARY
fclose(rombinary);
#endif
// signal end of transmission
EnableFpga();
spi8(UIO_FILE_TX);
spi8(0x00);
DisableFpga();
printf("\n");
return 1;
}
static char pchar[] = { 0x8C, 0x8F, 0x7F };
#define PROGRESS_CNT 28