Fixes, tweaks, cleanup.
This commit is contained in:
@@ -64,6 +64,7 @@
|
||||
<ClCompile Include="lib\libco\arm.c" />
|
||||
<ClCompile Include="lib\libco\libco.c" />
|
||||
<ClCompile Include="lib\lodepng\lodepng.cpp" />
|
||||
<ClCompile Include="lib\md5\md5.c" />
|
||||
<ClCompile Include="lib\miniz\miniz.c" />
|
||||
<ClCompile Include="lib\miniz\miniz_tdef.c" />
|
||||
<ClCompile Include="lib\miniz\miniz_tinfl.c" />
|
||||
@@ -74,6 +75,8 @@
|
||||
<ClCompile Include="scaler.cpp" />
|
||||
<ClCompile Include="scheduler.cpp" />
|
||||
<ClCompile Include="spi.cpp" />
|
||||
<ClCompile Include="support\arcade\buffer.cpp" />
|
||||
<ClCompile Include="support\arcade\romutils.cpp" />
|
||||
<ClCompile Include="support\archie\archie.cpp" />
|
||||
<ClCompile Include="support\megacd\cdd.cpp" />
|
||||
<ClCompile Include="support\megacd\megacd.cpp" />
|
||||
@@ -115,6 +118,7 @@
|
||||
<ClInclude Include="lib\libco\libco.h" />
|
||||
<ClInclude Include="lib\libco\settings.h" />
|
||||
<ClInclude Include="lib\lodepng\lodepng.h" />
|
||||
<ClInclude Include="lib\md5\md5.h" />
|
||||
<ClInclude Include="lib\miniz\miniz.h" />
|
||||
<ClInclude Include="lib\miniz\miniz_common.h" />
|
||||
<ClInclude Include="lib\miniz\miniz_tdef.h" />
|
||||
@@ -127,6 +131,8 @@
|
||||
<ClInclude Include="scheduler.h" />
|
||||
<ClInclude Include="spi.h" />
|
||||
<ClInclude Include="support.h" />
|
||||
<ClInclude Include="support\arcade\buffer.h" />
|
||||
<ClInclude Include="support\arcade\romutils.h" />
|
||||
<ClInclude Include="support\archie\archie.h" />
|
||||
<ClInclude Include="support\megacd\megacd.h" />
|
||||
<ClInclude Include="support\minimig\minimig_boot.h" />
|
||||
|
||||
@@ -21,6 +21,27 @@
|
||||
<Filter Include="Source Files\miniz">
|
||||
<UniqueIdentifier>{83fcb534-f976-4615-bdeb-ba80fb510f9a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\md5">
|
||||
<UniqueIdentifier>{478f0e62-2042-41ff-8b48-b48e6b5aed88}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\md5">
|
||||
<UniqueIdentifier>{30fe8838-348b-4aa5-b517-93cae495ce86}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\support">
|
||||
<UniqueIdentifier>{e440dc55-22b0-40b2-887d-dfd701749ea0}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\support">
|
||||
<UniqueIdentifier>{095305c7-e04b-4f03-b8d8-db2d888b449c}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\imlib">
|
||||
<UniqueIdentifier>{a5ee9c49-ce79-4665-8a6e-751bd82eff23}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\lodpng">
|
||||
<UniqueIdentifier>{f72c7b7a-09fd-4c2f-a8cb-14e1077e8acb}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\lodepng">
|
||||
<UniqueIdentifier>{9e138a0b-53c4-4ae8-a59b-6b7bf2dcc01b}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="build.sh" />
|
||||
@@ -73,36 +94,6 @@
|
||||
<ClCompile Include="user_io.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="support\archie\archie.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="support\minimig\minimig_boot.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="support\minimig\minimig_config.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="support\minimig\minimig_fdd.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="support\minimig\minimig_hdd.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="support\sharpmz\sharpmz.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="support\st\st_ikbd.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="support\st\st_tos.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="support\x86\x86.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="support\snes\snes.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="lib\libco\arm.c">
|
||||
<Filter>Source Files\libco</Filter>
|
||||
</ClCompile>
|
||||
@@ -133,26 +124,65 @@
|
||||
<ClCompile Include="cheats.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="lib\lodepng\lodepng.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="scaler.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="video.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="support\neogeo\loader.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="joymapping.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="lib\md5\md5.c">
|
||||
<Filter>Source Files\md5</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="lib\lodepng\lodepng.cpp">
|
||||
<Filter>Source Files\lodepng</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="support\archie\archie.cpp">
|
||||
<Filter>Source Files\support</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="support\megacd\cdd.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
<Filter>Source Files\support</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="support\neogeo\loader.cpp">
|
||||
<Filter>Source Files\support</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="support\megacd\megacd.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
<Filter>Source Files\support</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="support\minimig\minimig_boot.cpp">
|
||||
<Filter>Source Files\support</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="support\minimig\minimig_config.cpp">
|
||||
<Filter>Source Files\support</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="support\minimig\minimig_fdd.cpp">
|
||||
<Filter>Source Files\support</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="support\minimig\minimig_hdd.cpp">
|
||||
<Filter>Source Files\support</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="support\sharpmz\sharpmz.cpp">
|
||||
<Filter>Source Files\support</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="support\snes\snes.cpp">
|
||||
<Filter>Source Files\support</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="support\st\st_ikbd.cpp">
|
||||
<Filter>Source Files\support</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="support\st\st_tos.cpp">
|
||||
<Filter>Source Files\support</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="support\x86\x86.cpp">
|
||||
<Filter>Source Files\support</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="support\arcade\buffer.cpp">
|
||||
<Filter>Source Files\support</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="support\arcade\romutils.cpp">
|
||||
<Filter>Source Files\support</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -216,48 +246,12 @@
|
||||
<ClInclude Include="spi.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="support.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="sxmlc.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="user_io.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="support\archie\archie.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="support\minimig\minimig_boot.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="support\minimig\minimig_config.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="support\minimig\minimig_fdd.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="support\minimig\minimig_hdd.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="support\minimig\minimig_hdd_internal.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="support\sharpmz\sharpmz.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="support\st\st_ikbd.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="support\st\st_tos.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="support\x86\x86.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="support\snes\snes.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="lib\libco\libco.h">
|
||||
<Filter>Header Files\libco</Filter>
|
||||
</ClInclude>
|
||||
@@ -288,26 +282,71 @@
|
||||
<ClInclude Include="cheats.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="lib\lodepng\lodepng.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="scaler.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="video.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="lib\imlib2\Imlib2.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="support\neogeo\loader.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="joymapping.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="lib\md5\md5.h">
|
||||
<Filter>Header Files\md5</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="support\archie\archie.h">
|
||||
<Filter>Header Files\support</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="lib\imlib2\Imlib2.h">
|
||||
<Filter>Header Files\imlib</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="support\neogeo\loader.h">
|
||||
<Filter>Header Files\support</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="support\st\st_ikbd.h">
|
||||
<Filter>Header Files\support</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="support\st\st_tos.h">
|
||||
<Filter>Header Files\support</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="support.h">
|
||||
<Filter>Header Files\support</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="lib\lodepng\lodepng.h">
|
||||
<Filter>Header Files\lodpng</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="support\minimig\minimig_boot.h">
|
||||
<Filter>Header Files\support</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="support\minimig\minimig_config.h">
|
||||
<Filter>Header Files\support</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="support\minimig\minimig_fdd.h">
|
||||
<Filter>Header Files\support</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="support\minimig\minimig_hdd.h">
|
||||
<Filter>Header Files\support</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="support\minimig\minimig_hdd_internal.h">
|
||||
<Filter>Header Files\support</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="support\x86\x86.h">
|
||||
<Filter>Header Files\support</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="support\snes\snes.h">
|
||||
<Filter>Header Files\support</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="support\sharpmz\sharpmz.h">
|
||||
<Filter>Header Files\support</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="support\megacd\megacd.h">
|
||||
<Filter>Header Files</Filter>
|
||||
<Filter>Header Files\support</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="support\arcade\romutils.h">
|
||||
<Filter>Header Files\support</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="support\arcade\buffer.h">
|
||||
<Filter>Header Files\support</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -528,8 +528,8 @@ int fpga_load_rbf(const char *name, const char *cfg, const char *xml)
|
||||
}
|
||||
}
|
||||
close(rbf);
|
||||
app_restart(!strcasecmp(name, "menu.rbf") ? "menu.rbf" : path,xml);
|
||||
|
||||
app_restart(!strcasecmp(name, "menu.rbf") ? "menu.rbf" : path, xml);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -651,10 +651,7 @@ void app_restart(const char *path, const char *xml)
|
||||
|
||||
char *appname = getappname();
|
||||
printf("restarting the %s\n", appname);
|
||||
if (xml)
|
||||
execl(appname, appname, path, xml,NULL);
|
||||
else
|
||||
execl(appname, appname, path, NULL);
|
||||
execl(appname, appname, path, xml, NULL);
|
||||
|
||||
printf("Something went wrong. Rebooting...\n");
|
||||
reboot(0);
|
||||
|
||||
@@ -137,7 +137,7 @@ MD5Update(ctx, buf, len)
|
||||
}
|
||||
|
||||
/*
|
||||
* Final wrapup - pad to 64-byte boundary with the bit pattern
|
||||
* Final wrapup - pad to 64-byte boundary with the bit pattern
|
||||
* 1 0* (64-bit count of bits processed, MSB-first)
|
||||
*/
|
||||
void
|
||||
@@ -181,7 +181,7 @@ MD5Final(digest, ctx)
|
||||
putu32(ctx->buf[1], digest + 4);
|
||||
putu32(ctx->buf[2], digest + 8);
|
||||
putu32(ctx->buf[3], digest + 12);
|
||||
memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
|
||||
memset(ctx, 0, sizeof(struct MD5Context)); /* In case it's sensitive */
|
||||
}
|
||||
|
||||
#ifndef ASM_MD5
|
||||
|
||||
3
main.cpp
3
main.cpp
@@ -57,6 +57,7 @@ int main(int argc, char *argv[])
|
||||
printf("Version %s\n\n", version + 5);
|
||||
|
||||
if (argc > 1) printf("Core path: %s\n", argv[1]);
|
||||
if (argc > 2) printf("XML path: %s\n", argv[2]);
|
||||
|
||||
if (!is_fpga_ready(1))
|
||||
{
|
||||
@@ -66,7 +67,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
FindStorage();
|
||||
user_io_init((argc > 1) ? argv[1] : "",(argc > 2) ? argv[2] : "");
|
||||
user_io_init((argc > 1) ? argv[1] : "",(argc > 2) ? argv[2] : NULL);
|
||||
|
||||
#ifdef USE_SCHEDULER
|
||||
scheduler_init();
|
||||
|
||||
122
menu.cpp
122
menu.cpp
@@ -168,7 +168,7 @@ static uint32_t menustate = MENU_NONE1;
|
||||
static uint32_t parentstate;
|
||||
static uint32_t menusub = 0;
|
||||
static uint32_t menusub_last = 0; //for when we allocate it dynamically and need to know last row
|
||||
static uint32_t menumask = 0; // Used to determine which rows are selectable...
|
||||
static uint64_t menumask = 0; // Used to determine which rows are selectable...
|
||||
static uint32_t menu_timer = 0;
|
||||
|
||||
extern const char *version;
|
||||
@@ -1003,12 +1003,12 @@ void HandleUI(void)
|
||||
{
|
||||
if (down)
|
||||
{
|
||||
if((menumask >= ((uint32_t)1 << (menusub + 1)))) // Any active entries left?
|
||||
if((menumask >= ((uint64_t)1 << (menusub + 1)))) // Any active entries left?
|
||||
{
|
||||
do
|
||||
{
|
||||
menusub++;
|
||||
} while ((menumask & ((uint32_t)1 << menusub)) == 0);
|
||||
} while ((menumask & ((uint64_t)1 << menusub)) == 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1025,14 +1025,14 @@ void HandleUI(void)
|
||||
do
|
||||
{
|
||||
--menusub;
|
||||
} while ((menumask & ((uint32_t)1 << menusub)) == 0);
|
||||
} while ((menumask & ((uint64_t)1 << menusub)) == 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
do
|
||||
{
|
||||
menusub++;
|
||||
} while ((menumask & ((uint32_t)(~0) << (menusub + 1))) != 0); // jump to last item
|
||||
} while ((menumask & ((uint64_t)(~0) << (menusub + 1))) != 0); // jump to last item
|
||||
}
|
||||
menustate = parentstate;
|
||||
}
|
||||
@@ -4481,21 +4481,16 @@ void HandleUI(void)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!strcasecmp(".mra",&(SelectedRBF[strlen(SelectedRBF) - 4])))
|
||||
|
||||
if (!strcasecmp(".mra",&(SelectedRBF[strlen(SelectedRBF) - 4])))
|
||||
{
|
||||
char rbfname[4096];
|
||||
char rbfpath[4096];
|
||||
fprintf(stderr,"MRA FILE LOADED - write code\n");
|
||||
// find the RBF file from the XML
|
||||
arcade_scan_xml_for_rbf(getFullPath(SelectedRBF),rbfname);
|
||||
fprintf(stderr,"MRA SelectedRBF: [%s]\n",SelectedRBF);
|
||||
fprintf(stderr,"MRA rbf: [%s]\n",rbfname);
|
||||
sprintf(rbfpath,"arcade/%s",rbfname);
|
||||
fpga_load_rbf(getFullPath(rbfpath),NULL,SelectedRBF);
|
||||
arcade_load(getFullPath(SelectedRBF));
|
||||
}
|
||||
else
|
||||
// close OSD now as the new core may not even have one
|
||||
{
|
||||
fpga_load_rbf(SelectedRBF);
|
||||
}
|
||||
break;
|
||||
|
||||
case MENU_CORE_FILE_SELECTED2:
|
||||
@@ -4612,7 +4607,7 @@ void open_joystick_setup()
|
||||
|
||||
/*
|
||||
* CalculateFileNameLengthWithoutExtension
|
||||
*
|
||||
*
|
||||
* This function takes a filename and length, and returns
|
||||
* the length. It will remove the .rbf or .mra from the length
|
||||
* based on the fs_pFileExt global
|
||||
@@ -4620,69 +4615,68 @@ void open_joystick_setup()
|
||||
* If the fs_pFileExt has multiple extensions, it will look through
|
||||
* each to try to find a match.
|
||||
*/
|
||||
int CalculateFileNameLengthWithoutExtension(char *name,char *possibleextensions)
|
||||
int CalculateFileNameLengthWithoutExtension(char *name, char *possibleextensions)
|
||||
{
|
||||
|
||||
char *ext = possibleextensions;
|
||||
int found=0;
|
||||
int found = 0;
|
||||
/* the default length is the whole string */
|
||||
int len = strlen(name);
|
||||
/* find the extension on the end of the name*/
|
||||
char *fext = strrchr(name, '.');
|
||||
char *fext = strrchr(name, '.');
|
||||
/* we want to push past the period - and just have rbf instead of .rbf*/
|
||||
if (fext) fext++;
|
||||
if (fext) fext++;
|
||||
|
||||
/* walk through each extension and see if it matches */
|
||||
while (!found && *ext && fext)
|
||||
{
|
||||
char e[4];
|
||||
memcpy(e, ext, 3);
|
||||
if (e[2] == ' ')
|
||||
{
|
||||
e[2] = 0;
|
||||
if (e[1] == ' ') e[1] = 0;
|
||||
}
|
||||
while (!found && *ext && fext)
|
||||
{
|
||||
char e[4];
|
||||
memcpy(e, ext, 3);
|
||||
if (e[2] == ' ')
|
||||
{
|
||||
e[2] = 0;
|
||||
if (e[1] == ' ') e[1] = 0;
|
||||
}
|
||||
|
||||
e[3] = 0;
|
||||
found = 1;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
if (e[i] == '*') break;
|
||||
if (e[i] == '?' && fext[i]) continue;
|
||||
e[3] = 0;
|
||||
found = 1;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
if (e[i] == '*') break;
|
||||
if (e[i] == '?' && fext[i]) continue;
|
||||
|
||||
if (tolower(e[i]) != tolower(fext[i])) found = 0;
|
||||
if (tolower(e[i]) != tolower(fext[i])) found = 0;
|
||||
|
||||
if (!e[i] || !found) break;
|
||||
}
|
||||
if (found) break;
|
||||
if (!e[i] || !found) break;
|
||||
}
|
||||
if (found) break;
|
||||
|
||||
if (strlen(ext) < 3) break;
|
||||
ext += 3;
|
||||
}
|
||||
if (strlen(ext) < 3) break;
|
||||
ext += 3;
|
||||
}
|
||||
|
||||
/* if we haven't found a match, then the answer is the full length of the string */
|
||||
if (!found) return len;
|
||||
/* if we haven't found a match, then the answer is the full length of the string */
|
||||
if (!found) return len;
|
||||
|
||||
/* we have a match, now we need to handle extensions that are less than 3 characters */
|
||||
char e[5];
|
||||
memcpy(e + 1, ext, 3);
|
||||
/* 0x20 is a space in ascii*/
|
||||
if (e[3] == 0x20)
|
||||
{
|
||||
e[3] = 0;
|
||||
if (e[2] == 0x20)
|
||||
{
|
||||
e[2] = 0;
|
||||
}
|
||||
}
|
||||
e[0] = '.';
|
||||
e[4] = 0;
|
||||
int l = strlen(e);
|
||||
/* we have a match, now we need to handle extensions that are less than 3 characters */
|
||||
char e[5];
|
||||
memcpy(e + 1, ext, 3);
|
||||
/* 0x20 is a space in ascii*/
|
||||
if (e[3] == 0x20)
|
||||
{
|
||||
e[3] = 0;
|
||||
if (e[2] == 0x20)
|
||||
{
|
||||
e[2] = 0;
|
||||
}
|
||||
}
|
||||
e[0] = '.';
|
||||
e[4] = 0;
|
||||
int l = strlen(e);
|
||||
|
||||
if ((len>l) && !strncasecmp(name + len - l, e, l)) len -= l;
|
||||
if ((len > l) && !strncasecmp(name + len - l, e, l)) len -= l;
|
||||
|
||||
//printf("len: %d l: %d str[%s] e[%s] ext[%s]\n",len,l,name,e,ext);
|
||||
return len;
|
||||
//printf("len: %d l: %d str[%s] e[%s] ext[%s]\n",len,l,name,e,ext);
|
||||
return len;
|
||||
|
||||
}
|
||||
|
||||
@@ -4718,8 +4712,6 @@ void ScrollLongName(void)
|
||||
ScrollText(flist_iSelectedEntry()-flist_iFirstEntry(), flist_SelectedItem()->altname, 0, len, max_len, 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void PrintFileName(char *name, int row, int maxinv)
|
||||
{
|
||||
int len;
|
||||
|
||||
@@ -10,77 +10,77 @@
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
// Function buffer_init
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// This function will return a struct with the values it needs before it
|
||||
// can be used with buffer_append. The default "expand_length" is
|
||||
//
|
||||
// can be used with buffer_append. The default "expand_length" is
|
||||
//
|
||||
// Parameters:
|
||||
//
|
||||
// initial_size (IN) This parameter will preallocate the buffer with this
|
||||
//
|
||||
// initial_size (IN) This parameter will preallocate the buffer with this
|
||||
// size in bytes.
|
||||
//
|
||||
//
|
||||
// Returns:
|
||||
//
|
||||
//
|
||||
// returns a struct, or NULL on error
|
||||
//
|
||||
//
|
||||
// Error Definitions:
|
||||
//
|
||||
//
|
||||
// NULL = Couldn't create the structure
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
buffer_data * buffer_init(unsigned int initial_size) {
|
||||
|
||||
buffer_data * buffer = NULL;
|
||||
|
||||
// only allow max initial size of SIZE_MAX
|
||||
if (initial_size > 65535) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// malloc the space for a pointer to a buffer_data
|
||||
buffer = (buffer_data *)malloc(sizeof(buffer_data));
|
||||
if (buffer == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// fill the struct up
|
||||
buffer->expand_length = initial_size;
|
||||
buffer->capacity = initial_size;
|
||||
buffer->length = 0;
|
||||
|
||||
// allocate the buffer space
|
||||
buffer->content = (char *)malloc(sizeof(char) * initial_size);
|
||||
buffer->content[0]=0;
|
||||
if (buffer->content == NULL) {
|
||||
// can't allocate the buffer, therefore we need to clean everything up
|
||||
free(buffer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// return a pointer to our buffer_data structure
|
||||
return buffer;
|
||||
buffer_data * buffer = NULL;
|
||||
|
||||
// only allow max initial size of SIZE_MAX
|
||||
if (initial_size > 65535) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// malloc the space for a pointer to a buffer_data
|
||||
buffer = (buffer_data *)malloc(sizeof(buffer_data));
|
||||
if (buffer == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// fill the struct up
|
||||
buffer->expand_length = initial_size;
|
||||
buffer->capacity = initial_size;
|
||||
buffer->length = 0;
|
||||
|
||||
// allocate the buffer space
|
||||
buffer->content = (char *)malloc(sizeof(char) * initial_size);
|
||||
buffer->content[0] = 0;
|
||||
if (buffer->content == NULL) {
|
||||
// can't allocate the buffer, therefore we need to clean everything up
|
||||
free(buffer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// return a pointer to our buffer_data structure
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
// Function buffer_append
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// This function will take data and append it into a buffer in the struct
|
||||
// given. It will growing as required (or as allowed by realloc) by the
|
||||
// length desired in the structure element "expand_length" plus the length
|
||||
// of the data being appended. If additional expansion is not desired, you
|
||||
// length desired in the structure element "expand_length" plus the length
|
||||
// of the data being appended. If additional expansion is not desired, you
|
||||
// can set the struct element "expand_length" to zero.
|
||||
//
|
||||
//
|
||||
// Parameters:
|
||||
//
|
||||
//
|
||||
// buffer_data (IN/OUT) This parameter is a struct (mapped below) to
|
||||
// keep track of the internal buffer and its working parameters.
|
||||
//
|
||||
@@ -94,74 +94,74 @@ buffer_data * buffer_init(unsigned int initial_size) {
|
||||
//
|
||||
// append_data (IN) This parameter is a const char * that is the data
|
||||
// to be appended.
|
||||
//
|
||||
//
|
||||
// Returns:
|
||||
//
|
||||
//
|
||||
// This function will return the amount of bytes appended. If the
|
||||
// return value is <= 0 there was an error.
|
||||
//
|
||||
//
|
||||
// Error Definitions:
|
||||
//
|
||||
//
|
||||
// -1 = No data was given to append
|
||||
// -2 = Additional space could not be allocated for the buffer.
|
||||
//
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int buffer_append(buffer_data * buffer, const char * append_data) {
|
||||
|
||||
// ensure there IS something to append..
|
||||
const unsigned int append_len = strlen(append_data);
|
||||
if (append_len < 1) {
|
||||
return -1;
|
||||
}
|
||||
// ensure there IS something to append..
|
||||
const unsigned int append_len = strlen(append_data);
|
||||
if (append_len < 1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// is there enough space, or should we reallocate memory?
|
||||
if (buffer->length + append_len > buffer->capacity) {
|
||||
// is there enough space, or should we reallocate memory?
|
||||
if (buffer->length + append_len > buffer->capacity) {
|
||||
|
||||
const unsigned int realloc_size =
|
||||
buffer->capacity + append_len + buffer->expand_length;
|
||||
|
||||
// allocate the new buffer
|
||||
char *new_buffer = (char *)realloc(buffer->content, realloc_size);
|
||||
|
||||
// resize success..
|
||||
if (new_buffer == NULL) {
|
||||
return -2;
|
||||
}
|
||||
const unsigned int realloc_size =
|
||||
buffer->capacity + append_len + buffer->expand_length;
|
||||
|
||||
// copy the data to append into the new content buffer
|
||||
strcat(new_buffer, append_data);
|
||||
|
||||
// update the struct with the new values
|
||||
buffer->content = new_buffer; // new buffer content
|
||||
buffer->capacity = realloc_size; // add the amount to expand beyond our initial needs
|
||||
buffer->length = buffer->length + append_len;
|
||||
|
||||
} else {
|
||||
// append the string
|
||||
strcat(buffer->content, append_data);
|
||||
}
|
||||
// allocate the new buffer
|
||||
char *new_buffer = (char *)realloc(buffer->content, realloc_size);
|
||||
|
||||
// update the buffer length
|
||||
buffer->length += append_len;
|
||||
|
||||
// return the amount appended
|
||||
return append_len;
|
||||
// resize success..
|
||||
if (new_buffer == NULL) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
// copy the data to append into the new content buffer
|
||||
strcat(new_buffer, append_data);
|
||||
|
||||
// update the struct with the new values
|
||||
buffer->content = new_buffer; // new buffer content
|
||||
buffer->capacity = realloc_size; // add the amount to expand beyond our initial needs
|
||||
buffer->length = buffer->length + append_len;
|
||||
|
||||
}
|
||||
else {
|
||||
// append the string
|
||||
strcat(buffer->content, append_data);
|
||||
}
|
||||
|
||||
// update the buffer length
|
||||
buffer->length += append_len;
|
||||
|
||||
// return the amount appended
|
||||
return append_len;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
// Function buffer_destroy
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// This function will destroy the inner buffer and reset all of the data
|
||||
// if the struct was dynamically allocated, it is expected that you will
|
||||
// take care of freeing the data.
|
||||
//
|
||||
//
|
||||
// Parameters:
|
||||
//
|
||||
//
|
||||
// buffer_data (IN) This parameter is a struct (mapped below) to
|
||||
// keep track of the internal buffer and its working parameters.
|
||||
//
|
||||
@@ -173,23 +173,22 @@ int buffer_append(buffer_data * buffer, const char * append_data) {
|
||||
// } buffer_data;
|
||||
//
|
||||
// Returns:
|
||||
//
|
||||
//
|
||||
// returns nothing
|
||||
//
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void buffer_destroy(buffer_data * buffer) {
|
||||
|
||||
// only work with valid data..
|
||||
if (buffer != NULL) {
|
||||
|
||||
// if the content is not null, free it.
|
||||
if (buffer->content != NULL) {
|
||||
free(buffer->content);
|
||||
}
|
||||
|
||||
// free the buffer
|
||||
free(buffer);
|
||||
}
|
||||
// only work with valid data..
|
||||
if (buffer != NULL) {
|
||||
|
||||
// if the content is not null, free it.
|
||||
if (buffer->content != NULL) {
|
||||
free(buffer->content);
|
||||
}
|
||||
|
||||
// free the buffer
|
||||
free(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef STRING_UTILS_H_
|
||||
#define STRING_UTILS_H_
|
||||
#ifndef BUFFER_H_
|
||||
#define BUFFER_H_
|
||||
|
||||
typedef struct {
|
||||
unsigned int length;
|
||||
@@ -12,4 +12,4 @@ buffer_data * buffer_init(const unsigned int initial_size);
|
||||
int buffer_append(buffer_data *buffer, const char *append_data);
|
||||
void buffer_destroy(buffer_data * buffer);
|
||||
|
||||
#endif // STRING_UTILS_H_
|
||||
#endif
|
||||
|
||||
@@ -3,18 +3,88 @@
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
#include <ctype.h>
|
||||
|
||||
|
||||
#include "sxmlc.h"
|
||||
|
||||
#include "../../sxmlc.h"
|
||||
#include "../../user_io.h"
|
||||
#include "../../file_io.h"
|
||||
#include "../../menu.h"
|
||||
#include "../../fpga_io.h"
|
||||
#include "../../lib/md5/md5.h"
|
||||
|
||||
#include "buffer.h"
|
||||
|
||||
#define DEBUG_ROM_BINARY 0
|
||||
#if DEBUG_ROM_BINARY
|
||||
FILE *rombinary;
|
||||
#endif
|
||||
|
||||
static int file_tx_start(unsigned char index)
|
||||
{
|
||||
// set index byte (0=bios rom, 1-n=OSD entry index)
|
||||
user_io_set_index(index);
|
||||
|
||||
// prepare transmission of new file
|
||||
user_io_set_download(1);
|
||||
|
||||
#if DEBUG_ROM_BINARY
|
||||
rombinary = fopen("/media/fat/this.rom", "wb");
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int file_tx_body(const uint8_t *buf, uint16_t chunk, struct MD5Context *md5context)
|
||||
{
|
||||
EnableFpga();
|
||||
spi8(UIO_FILE_TX_DAT);
|
||||
|
||||
spi_write(buf, chunk, user_io_get_width());
|
||||
DisableFpga();
|
||||
|
||||
if (md5context) MD5Update(md5context, buf, chunk);
|
||||
#if DEBUG_ROM_BINARY
|
||||
fwrite(buf, 1, chunk, rombinary);
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int 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 < (int)bytes2send) bytes2send = len;
|
||||
/* transmit the entire file using one transfer */
|
||||
printf("Selected file %s with %lu bytes to send \n", name, bytes2send);
|
||||
while (bytes2send)
|
||||
{
|
||||
uint16_t chunk = (bytes2send > sizeof(buf)) ? sizeof(buf) : bytes2send;
|
||||
|
||||
FileReadAdv(&f, buf, chunk);
|
||||
file_tx_body(buf, chunk, md5context);
|
||||
|
||||
bytes2send -= chunk;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int file_tx_finish()
|
||||
{
|
||||
printf("\n");
|
||||
#if DEBUG_ROM_BINARY
|
||||
fclose(rombinary);
|
||||
#endif
|
||||
|
||||
// signal end of transmission
|
||||
user_io_set_download(0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#include "md5.h"
|
||||
/*
|
||||
* adapted from https://gist.github.com/xsleonard/7341172
|
||||
*
|
||||
@@ -32,44 +102,35 @@
|
||||
* */
|
||||
unsigned char* hexstr_to_char(const char* hexstr, size_t *out_len)
|
||||
{
|
||||
size_t len = strlen(hexstr);
|
||||
unsigned char* chrs = (unsigned char*)malloc((len+1) * sizeof(*chrs));
|
||||
int dest=0;
|
||||
// point to the beginning of the array
|
||||
const char *ptr = hexstr;
|
||||
while (*ptr) {
|
||||
// check to see if we have a space
|
||||
while (*ptr=='\n' || *ptr=='\r' || *ptr==' ' || *ptr=='\t' || *ptr==9 /*horiz tab*/) ptr++;
|
||||
if (*ptr==0) break;
|
||||
size_t len = strlen(hexstr);
|
||||
unsigned char* chrs = (unsigned char*)malloc((len + 1) * sizeof(*chrs));
|
||||
int dest = 0;
|
||||
// point to the beginning of the array
|
||||
const char *ptr = hexstr;
|
||||
while (*ptr) {
|
||||
// check to see if we have a space
|
||||
while (*ptr == '\n' || *ptr == '\r' || *ptr == ' ' || *ptr == '\t' || *ptr == 9 /*horiz tab*/) ptr++;
|
||||
if (*ptr == 0) break;
|
||||
|
||||
// pull two characters off
|
||||
int val1= (*ptr % 32 + 9) % 25 * 16;
|
||||
ptr++;
|
||||
/* check to odd numbers of characters*/
|
||||
if (*ptr==0) {
|
||||
int val= (ptr[-1] % 32 + 9) % 25;
|
||||
chrs[dest++] = val;
|
||||
break;
|
||||
}
|
||||
int val2= (*ptr % 32 + 9) % 25;
|
||||
ptr++;
|
||||
chrs[dest++] = val1+val2;
|
||||
}
|
||||
chrs[dest]=0;
|
||||
*out_len = dest; /* dest is 0 based, so we don't need to subtract 1*/
|
||||
return chrs;
|
||||
// pull two characters off
|
||||
int val1 = (*ptr % 32 + 9) % 25 * 16;
|
||||
ptr++;
|
||||
/* check to odd numbers of characters*/
|
||||
if (*ptr == 0) {
|
||||
int val = (ptr[-1] % 32 + 9) % 25;
|
||||
chrs[dest++] = val;
|
||||
break;
|
||||
}
|
||||
int val2 = (*ptr % 32 + 9) % 25;
|
||||
ptr++;
|
||||
chrs[dest++] = val1 + val2;
|
||||
}
|
||||
chrs[dest] = 0;
|
||||
*out_len = dest; /* dest is 0 based, so we don't need to subtract 1*/
|
||||
return chrs;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
user_io.h:int user_io_file_tx_start(const char *name,unsigned char index=0);
|
||||
user_io.h:int user_io_file_tx_body(const uint8_t *buf,uint16_t chunk);
|
||||
user_io.h:int user_io_file_tx_body_filepart(const char *name,int start=0, int len=0);
|
||||
user_io.h:int user_io_file_tx_finish();
|
||||
*/
|
||||
|
||||
|
||||
#define kBigTextSize 4096
|
||||
#define kBigTextSize 1024
|
||||
struct arc_struct {
|
||||
char md5[kBigTextSize];
|
||||
char zipname[kBigTextSize];
|
||||
@@ -84,7 +145,7 @@ struct arc_struct {
|
||||
int insiderom;
|
||||
int validrom0;
|
||||
buffer_data *data;
|
||||
struct MD5Context context;
|
||||
struct MD5Context context;
|
||||
};
|
||||
|
||||
char global_error_msg[kBigTextSize];
|
||||
@@ -100,100 +161,98 @@ char global_error_msg[kBigTextSize];
|
||||
static int xml_send_rom(XMLEvent evt, const XMLNode* node, SXML_CHAR* text, const int n, SAX_Data* sd)
|
||||
{
|
||||
struct arc_struct *arc_info = (struct arc_struct *)sd->user;
|
||||
(void)(sd);
|
||||
(void)(sd);
|
||||
|
||||
switch (evt)
|
||||
{
|
||||
case XML_EVENT_START_NODE:
|
||||
switch (evt)
|
||||
{
|
||||
case XML_EVENT_START_NODE:
|
||||
|
||||
/* initialization */
|
||||
|
||||
|
||||
// initialize things for each tag (node):
|
||||
buffer_destroy(arc_info->data);
|
||||
arc_info->data=buffer_init(kBigTextSize);
|
||||
arc_info->partname[0]=0;
|
||||
arc_info->offset=0;
|
||||
arc_info->length=-1;
|
||||
arc_info->repeat=1;
|
||||
arc_info->data = buffer_init(kBigTextSize);
|
||||
arc_info->partname[0] = 0;
|
||||
arc_info->offset = 0;
|
||||
arc_info->length = -1;
|
||||
arc_info->repeat = 1;
|
||||
|
||||
/* on the beginning of a rom tag, we need to reset the state*/
|
||||
if (!strcasecmp(node->tag,"rom"))
|
||||
if (!strcasecmp(node->tag, "rom"))
|
||||
{
|
||||
arc_info->insiderom=1;
|
||||
arc_info->romname[0]=0;
|
||||
arc_info->romindex=0;
|
||||
arc_info->md5[0]=0;
|
||||
MD5Init (&arc_info->context);
|
||||
arc_info->insiderom = 1;
|
||||
arc_info->romname[0] = 0;
|
||||
arc_info->romindex = 0;
|
||||
arc_info->md5[0] = 0;
|
||||
MD5Init(&arc_info->context);
|
||||
}
|
||||
|
||||
// for each part tag, we clear the partzipname since it is optional and may not appear in the part tag
|
||||
if (!strcasecmp(node->tag,"part"))
|
||||
arc_info->partzipname[0]=0;
|
||||
if (!strcasecmp(node->tag, "part"))
|
||||
arc_info->partzipname[0] = 0;
|
||||
|
||||
|
||||
//printf("XML_EVENT_START_NODE: tag [%s]\n",node->tag);
|
||||
// walk the attributes and save them in the data structure as appropriate
|
||||
for (int i = 0; i < node->n_attributes; i++)
|
||||
{
|
||||
//printf("attribute %d name [%s] value [%s]\n",i,node->attributes[i].name,node->attributes[i].value);
|
||||
if (!strcasecmp(node->attributes[i].name,"zip") && !strcasecmp(node->tag,"rom"))
|
||||
{
|
||||
strcpy(arc_info->zipname,node->attributes[i].value);
|
||||
}
|
||||
if (!strcasecmp(node->attributes[i].name,"name") && !strcasecmp(node->tag,"rom"))
|
||||
{
|
||||
strcpy(arc_info->romname,node->attributes[i].value);
|
||||
}
|
||||
if (!strcasecmp(node->attributes[i].name,"md5") && !strcasecmp(node->tag,"rom"))
|
||||
{
|
||||
strcpy(arc_info->md5,node->attributes[i].value);
|
||||
}
|
||||
if (!strcasecmp(node->attributes[i].name,"index") && !strcasecmp(node->tag,"rom"))
|
||||
{
|
||||
arc_info->romindex=atoi(node->attributes[i].value);
|
||||
}
|
||||
/* these only exist if we are inside the rom tag, and in a part tag*/
|
||||
if (arc_info->insiderom) {
|
||||
if (!strcasecmp(node->attributes[i].name,"zip") && !strcasecmp(node->tag,"part"))
|
||||
{
|
||||
strcpy(arc_info->partzipname,node->attributes[i].value);
|
||||
}
|
||||
if (!strcasecmp(node->attributes[i].name,"name") && !strcasecmp(node->tag,"part"))
|
||||
{
|
||||
strcpy(arc_info->partname,node->attributes[i].value);
|
||||
}
|
||||
if (!strcasecmp(node->attributes[i].name,"offset") && !strcasecmp(node->tag,"part"))
|
||||
{
|
||||
arc_info->offset=atoi(node->attributes[i].value);
|
||||
}
|
||||
if (!strcasecmp(node->attributes[i].name,"length") && !strcasecmp(node->tag,"part"))
|
||||
{
|
||||
arc_info->length=atoi(node->attributes[i].value);
|
||||
}
|
||||
if (!strcasecmp(node->attributes[i].name,"repeat") && !strcasecmp(node->tag,"part"))
|
||||
{
|
||||
arc_info->repeat=atoi(node->attributes[i].value);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < node->n_attributes; i++)
|
||||
{
|
||||
//printf("attribute %d name [%s] value [%s]\n",i,node->attributes[i].name,node->attributes[i].value);
|
||||
if (!strcasecmp(node->attributes[i].name, "zip") && !strcasecmp(node->tag, "rom"))
|
||||
{
|
||||
strcpy(arc_info->zipname, node->attributes[i].value);
|
||||
}
|
||||
if (!strcasecmp(node->attributes[i].name, "name") && !strcasecmp(node->tag, "rom"))
|
||||
{
|
||||
strcpy(arc_info->romname, node->attributes[i].value);
|
||||
}
|
||||
if (!strcasecmp(node->attributes[i].name, "md5") && !strcasecmp(node->tag, "rom"))
|
||||
{
|
||||
strcpy(arc_info->md5, node->attributes[i].value);
|
||||
}
|
||||
if (!strcasecmp(node->attributes[i].name, "index") && !strcasecmp(node->tag, "rom"))
|
||||
{
|
||||
arc_info->romindex = atoi(node->attributes[i].value);
|
||||
}
|
||||
/* these only exist if we are inside the rom tag, and in a part tag*/
|
||||
if (arc_info->insiderom) {
|
||||
if (!strcasecmp(node->attributes[i].name, "zip") && !strcasecmp(node->tag, "part"))
|
||||
{
|
||||
strcpy(arc_info->partzipname, node->attributes[i].value);
|
||||
}
|
||||
if (!strcasecmp(node->attributes[i].name, "name") && !strcasecmp(node->tag, "part"))
|
||||
{
|
||||
strcpy(arc_info->partname, node->attributes[i].value);
|
||||
}
|
||||
if (!strcasecmp(node->attributes[i].name, "offset") && !strcasecmp(node->tag, "part"))
|
||||
{
|
||||
arc_info->offset = atoi(node->attributes[i].value);
|
||||
}
|
||||
if (!strcasecmp(node->attributes[i].name, "length") && !strcasecmp(node->tag, "part"))
|
||||
{
|
||||
arc_info->length = atoi(node->attributes[i].value);
|
||||
}
|
||||
if (!strcasecmp(node->attributes[i].name, "repeat") && !strcasecmp(node->tag, "part"))
|
||||
{
|
||||
arc_info->repeat = atoi(node->attributes[i].value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* at the beginning of each rom - tell the user_io to start a new message */
|
||||
if (!strcasecmp(node->tag,"rom"))
|
||||
if (!strcasecmp(node->tag, "rom"))
|
||||
{
|
||||
|
||||
// clear an error message if we have a second rom0
|
||||
// this is kind of a problem - you will never see the
|
||||
// error from the first rom0?
|
||||
//
|
||||
if (arc_info->romindex==0 && strlen(arc_info->zipname))
|
||||
arc_info->error_msg[0]=0;
|
||||
// clear an error message if we have a second rom0
|
||||
// this is kind of a problem - you will never see the
|
||||
// error from the first rom0?
|
||||
//
|
||||
if (arc_info->romindex == 0 && strlen(arc_info->zipname))
|
||||
arc_info->error_msg[0] = 0;
|
||||
|
||||
user_io_file_tx_start(arc_info->romname,arc_info->romindex);
|
||||
file_tx_start(arc_info->romindex);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case XML_EVENT_TEXT:
|
||||
case XML_EVENT_TEXT:
|
||||
/* the text node is the data between tags, ie: <part>this text</part>
|
||||
*
|
||||
* the buffer_append is part of a buffer library that will realloc automatically
|
||||
@@ -201,67 +260,68 @@ static int xml_send_rom(XMLEvent evt, const XMLNode* node, SXML_CHAR* text, cons
|
||||
buffer_append(arc_info->data, text);
|
||||
//printf("XML_EVENT_TEXT: text [%s]\n",text);
|
||||
break;
|
||||
case XML_EVENT_END_NODE:
|
||||
|
||||
case XML_EVENT_END_NODE:
|
||||
//printf("XML_EVENT_END_NODE: tag [%s]\n",node->tag );
|
||||
|
||||
|
||||
// At the end of a rom node (when it is closed) we need to calculate hash values and clean up
|
||||
if (!strcasecmp(node->tag,"rom")) {
|
||||
if (arc_info->insiderom)
|
||||
if (!strcasecmp(node->tag, "rom")) {
|
||||
if (arc_info->insiderom)
|
||||
{
|
||||
unsigned char checksum[16];
|
||||
int checksumsame=1;
|
||||
char *md5=arc_info->md5;
|
||||
user_io_file_tx_finish();
|
||||
MD5Final (checksum, &arc_info->context);
|
||||
printf("md5[%s]\n",arc_info->md5);
|
||||
unsigned char checksum[16];
|
||||
int checksumsame = 1;
|
||||
char *md5 = arc_info->md5;
|
||||
file_tx_finish();
|
||||
MD5Final(checksum, &arc_info->context);
|
||||
printf("md5[%s]\n", arc_info->md5);
|
||||
printf("md5-calc[");
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
char hex[10];
|
||||
snprintf(hex,10,"%02x", (unsigned int) checksum[i]);
|
||||
printf ("%02x", (unsigned int) checksum[i]);
|
||||
if (md5[0]!=hex[0] || md5[1]!=hex[1]) {
|
||||
checksumsame=0;
|
||||
snprintf(hex, 10, "%02x", (unsigned int)checksum[i]);
|
||||
printf("%02x", (unsigned int)checksum[i]);
|
||||
if (md5[0] != hex[0] || md5[1] != hex[1]) {
|
||||
checksumsame = 0;
|
||||
}
|
||||
md5+=2;
|
||||
}
|
||||
printf ("]\n");
|
||||
if (checksumsame==0)
|
||||
md5 += 2;
|
||||
}
|
||||
printf("]\n");
|
||||
if (checksumsame == 0)
|
||||
{
|
||||
printf("mismatch\n");
|
||||
if (!strlen(arc_info->error_msg))
|
||||
snprintf(arc_info->error_msg,kBigTextSize,"md5 mismatch for rom %d",arc_info->romindex);
|
||||
snprintf(arc_info->error_msg, kBigTextSize, "md5 mismatch for rom %d", arc_info->romindex);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
// this code sets the validerom0 and clears the message
|
||||
// if a rom with index 0 has a correct md5. It supresses
|
||||
// if a rom with index 0 has a correct md5. It supresses
|
||||
// sending any further rom0 messages
|
||||
if (arc_info->romindex==0)
|
||||
if (arc_info->romindex == 0)
|
||||
{
|
||||
arc_info->validrom0=1;
|
||||
arc_info->error_msg[0]=0;
|
||||
arc_info->validrom0 = 1;
|
||||
arc_info->error_msg[0] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
arc_info->insiderom=0;
|
||||
arc_info->insiderom = 0;
|
||||
}
|
||||
|
||||
// At the end of a part node, send the rom part if we are inside a rom tag
|
||||
//int user_io_file_tx_body_filepart(const char *name,int start, int len)
|
||||
if (!strcasecmp(node->tag,"part") && arc_info->insiderom)
|
||||
if (!strcasecmp(node->tag, "part") && arc_info->insiderom)
|
||||
{
|
||||
// suppress rom0 if we already sent a valid one
|
||||
// this is useful for merged rom sets - if the first one was valid, use it
|
||||
// the second might not be
|
||||
if (arc_info->romindex==0 && arc_info->validrom0==1)
|
||||
if (arc_info->romindex == 0 && arc_info->validrom0 == 1)
|
||||
break;
|
||||
char fname[kBigTextSize*2+16];
|
||||
int start,length,repeat;
|
||||
repeat=arc_info->repeat;
|
||||
start=arc_info->offset;
|
||||
length=0;
|
||||
if (arc_info->length>0) length = arc_info->length;
|
||||
char fname[kBigTextSize * 2 + 16];
|
||||
int start, length, repeat;
|
||||
repeat = arc_info->repeat;
|
||||
start = arc_info->offset;
|
||||
length = 0;
|
||||
if (arc_info->length > 0) length = arc_info->length;
|
||||
//printf("partname[%s]\n",arc_info->partname);
|
||||
//printf("zipname [%s]\n",arc_info->zipname);
|
||||
//printf("offset[%d]\n",arc_info->offset);
|
||||
@@ -270,207 +330,216 @@ static int xml_send_rom(XMLEvent evt, const XMLNode* node, SXML_CHAR* text, cons
|
||||
//
|
||||
if (strlen(arc_info->partzipname))
|
||||
{
|
||||
if (arc_info->partzipname[0]=='/')
|
||||
sprintf(fname,"arcade%s/%s",arc_info->partzipname,arc_info->partname);
|
||||
if (arc_info->partzipname[0] == '/')
|
||||
sprintf(fname, "arcade%s/%s", arc_info->partzipname, arc_info->partname);
|
||||
else
|
||||
sprintf(fname,"arcade/mame/%s/%s",arc_info->partzipname,arc_info->partname);
|
||||
sprintf(fname, "arcade/mame/%s/%s", arc_info->partzipname, arc_info->partname);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (arc_info->zipname[0]=='/')
|
||||
sprintf(fname,"arcade%s/%s",arc_info->zipname,arc_info->partname);
|
||||
if (arc_info->zipname[0] == '/')
|
||||
sprintf(fname, "arcade%s/%s", arc_info->zipname, arc_info->partname);
|
||||
else
|
||||
sprintf(fname,"arcade/mame/%s/%s",arc_info->zipname,arc_info->partname);
|
||||
sprintf(fname, "arcade/mame/%s/%s", arc_info->zipname, arc_info->partname);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//user_io_file_tx_body_filepart(getFullPath(fname),0,0);
|
||||
if (strlen(arc_info->partname)) {
|
||||
printf("user_io_file_tx_body_filepart(const char *name[%s],int start[%d], int len[%d])\n",fname,start,length);
|
||||
for (int i=0;i<repeat;i++) {
|
||||
int result=user_io_file_tx_body_filepart(fname,start,length,&arc_info->context);
|
||||
printf("user_io_file_tx_body_filepart(const char *name[%s],int start[%d], int len[%d])\n", fname, start, length);
|
||||
for (int i = 0; i < repeat; i++) {
|
||||
int result = file_tx_body_filepart(fname, start, length, &arc_info->context);
|
||||
// we should check file not found error for the zip
|
||||
if (result==0)
|
||||
if (result == 0)
|
||||
{
|
||||
int skip=0;
|
||||
if (!strncasecmp(fname,"arcade/mame/",strlen("arcade/mame/")))
|
||||
skip=strlen("arcade/mame/");
|
||||
printf("%s does not exist\n",fname);
|
||||
snprintf(arc_info->error_msg,kBigTextSize,"%s\n"
|
||||
"\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\n"
|
||||
"File Not Found",fname+skip);
|
||||
int skip = 0;
|
||||
if (!strncasecmp(fname, "arcade/mame/", strlen("arcade/mame/")))
|
||||
skip = strlen("arcade/mame/");
|
||||
printf("%s does not exist\n", fname);
|
||||
snprintf(arc_info->error_msg, kBigTextSize, "%s\n"
|
||||
"\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\n"
|
||||
"File Not Found", fname + skip);
|
||||
}
|
||||
}
|
||||
}
|
||||
else // we have binary data?
|
||||
{
|
||||
//printf("we have bin.hex data [%s]\n",arc_info->data->content);
|
||||
size_t len=0;
|
||||
unsigned char* binary=hexstr_to_char(arc_info->data->content,&len);
|
||||
//printf("len %d:\n",len);
|
||||
//for (size_t i=0;i<len;i++) {
|
||||
// printf(" %d ",binary[i]);
|
||||
//}
|
||||
//printf("\n");
|
||||
for (int i=0;i<repeat;i++) {
|
||||
user_io_file_tx_body(binary,len,&arc_info->context);
|
||||
}
|
||||
if (binary) free(binary);
|
||||
//printf("we have bin.hex data [%s]\n",arc_info->data->content);
|
||||
size_t len = 0;
|
||||
unsigned char* binary = hexstr_to_char(arc_info->data->content, &len);
|
||||
//printf("len %d:\n",len);
|
||||
//for (size_t i=0;i<len;i++) {
|
||||
// printf(" %d ",binary[i]);
|
||||
//}
|
||||
//printf("\n");
|
||||
for (int i = 0; i < repeat; i++) {
|
||||
file_tx_body(binary, len, &arc_info->context);
|
||||
}
|
||||
if (binary) free(binary);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case XML_EVENT_ERROR:
|
||||
printf("XML parse: %s: ERROR %d\n", text, n);
|
||||
snprintf(arc_info->error_msg,kBigTextSize,"XML parse: %s: ERROR %d\n", text, n);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
case XML_EVENT_ERROR:
|
||||
printf("XML parse: %s: ERROR %d\n", text, n);
|
||||
snprintf(arc_info->error_msg, kBigTextSize, "XML parse: %s: ERROR %d\n", text, n);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int xml_scan_rbf(XMLEvent evt, const XMLNode* node, SXML_CHAR* text, const int n, SAX_Data* sd)
|
||||
{
|
||||
static int insiderbf=0;
|
||||
static int insiderbf = 0;
|
||||
char bigtext[kBigTextSize];
|
||||
char *rbf = (char *)sd->user;
|
||||
|
||||
switch (evt)
|
||||
{
|
||||
case XML_EVENT_START_NODE:
|
||||
bigtext[0]=0;
|
||||
if (!strcasecmp(node->tag,"rbf")) {
|
||||
insiderbf=1;
|
||||
switch (evt)
|
||||
{
|
||||
case XML_EVENT_START_NODE:
|
||||
bigtext[0] = 0;
|
||||
if (!strcasecmp(node->tag, "rbf")) {
|
||||
insiderbf = 1;
|
||||
}
|
||||
printf("XML_EVENT_START_NODE: tag [%s]\n", node->tag);
|
||||
for (int i = 0; i < node->n_attributes; i++)
|
||||
{
|
||||
printf("attribute %d name [%s] value [%s]\n", i, node->attributes[i].name, node->attributes[i].value);
|
||||
}
|
||||
printf("XML_EVENT_START_NODE: tag [%s]\n",node->tag);
|
||||
for (int i = 0; i < node->n_attributes; i++)
|
||||
{
|
||||
printf("attribute %d name [%s] value [%s]\n",i,node->attributes[i].name,node->attributes[i].value);
|
||||
}
|
||||
|
||||
break;
|
||||
case XML_EVENT_TEXT:
|
||||
break;
|
||||
case XML_EVENT_TEXT:
|
||||
if (insiderbf) {
|
||||
strncat(bigtext,text,kBigTextSize-strlen(bigtext)-1);
|
||||
printf("XML_EVENT_TEXT: text [%s]\n",text);
|
||||
strncat(bigtext, text, kBigTextSize - strlen(bigtext) - 1);
|
||||
printf("XML_EVENT_TEXT: text [%s]\n", text);
|
||||
}
|
||||
break;
|
||||
case XML_EVENT_END_NODE:
|
||||
if (!strcasecmp(node->tag,"rbf"))
|
||||
case XML_EVENT_END_NODE:
|
||||
if (!strcasecmp(node->tag, "rbf"))
|
||||
{
|
||||
insiderbf=0;
|
||||
insiderbf = 0;
|
||||
//printf("bigtext [%s]\n",bigtext);
|
||||
strncpy(rbf,bigtext,kBigTextSize);
|
||||
strncpy(rbf, bigtext, kBigTextSize);
|
||||
//printf("got rbf tag [%s]\n",rbf);
|
||||
}
|
||||
printf("XML_EVENT_END_NODE: tag [%s]\n",node->tag );
|
||||
break;
|
||||
printf("XML_EVENT_END_NODE: tag [%s]\n", node->tag);
|
||||
break;
|
||||
|
||||
case XML_EVENT_ERROR:
|
||||
printf("XML parse: %s: ERROR %d\n", text, n);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
case XML_EVENT_ERROR:
|
||||
printf("XML parse: %s: ERROR %d\n", text, n);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int arcade_send_rom(const char *xml)
|
||||
{
|
||||
SAX_Callbacks sax;
|
||||
SAX_Callbacks_init(&sax);
|
||||
SAX_Callbacks sax;
|
||||
SAX_Callbacks_init(&sax);
|
||||
|
||||
sax.all_event = xml_send_rom;
|
||||
sax.all_event = xml_send_rom;
|
||||
|
||||
// create the structure we use for the XML parser
|
||||
struct arc_struct arc_info;
|
||||
arc_info.data=buffer_init(kBigTextSize);
|
||||
arc_info.error_msg[0]=0;
|
||||
arc_info.validrom0=0;
|
||||
arc_info.data = buffer_init(kBigTextSize);
|
||||
arc_info.error_msg[0] = 0;
|
||||
arc_info.validrom0 = 0;
|
||||
|
||||
// parse
|
||||
XMLDoc_parse_file_SAX(xml, &sax, &arc_info);
|
||||
if (arc_info.validrom0==0 && strlen(arc_info.error_msg))
|
||||
XMLDoc_parse_file_SAX(xml, &sax, &arc_info);
|
||||
if (arc_info.validrom0 == 0 && strlen(arc_info.error_msg))
|
||||
{
|
||||
strcpy(global_error_msg,arc_info.error_msg);
|
||||
printf("arcade_send_rom: pretty error: [%s]\n",global_error_msg);
|
||||
strcpy(global_error_msg, arc_info.error_msg);
|
||||
printf("arcade_send_rom: pretty error: [%s]\n", global_error_msg);
|
||||
}
|
||||
buffer_destroy(arc_info.data);
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CheckArcadeError(void)
|
||||
int arcade_check_error(void)
|
||||
{
|
||||
if (global_error_msg[0]!=0) {
|
||||
printf("ERROR: [%s]\n",global_error_msg);
|
||||
Info(global_error_msg,1000*30);
|
||||
global_error_msg[0]=0;
|
||||
if (global_error_msg[0] != 0) {
|
||||
printf("ERROR: [%s]\n", global_error_msg);
|
||||
Info(global_error_msg, 1000 * 30);
|
||||
global_error_msg[0] = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int arcade_scan_xml_for_rbf(const char *xml,char *rbfname)
|
||||
int arcade_load(const char *xml)
|
||||
{
|
||||
char rbfname_fragment[kBigTextSize];
|
||||
rbfname_fragment[0]=0;
|
||||
rbfname[0]=0;
|
||||
SAX_Callbacks sax;
|
||||
SAX_Callbacks_init(&sax);
|
||||
MenuHide();
|
||||
|
||||
sax.all_event = xml_scan_rbf;
|
||||
XMLDoc_parse_file_SAX(xml, &sax, rbfname_fragment);
|
||||
strcpy(rbfname,rbfname_fragment);
|
||||
char rbfname[kBigTextSize];
|
||||
char xmlname[kBigTextSize];
|
||||
|
||||
//printf("arcade_scan_xml_for_rbf [%s]\n",xml);
|
||||
strcpy(xmlname, xml);
|
||||
|
||||
rbfname[0] = 0;
|
||||
SAX_Callbacks sax;
|
||||
SAX_Callbacks_init(&sax);
|
||||
|
||||
sax.all_event = xml_scan_rbf;
|
||||
XMLDoc_parse_file_SAX(xmlname, &sax, rbfname);
|
||||
|
||||
printf("arcade_scan_xml_for_rbf [%s]\n", xmlname);
|
||||
/* once we have the rbfname fragment from the MRA xml file
|
||||
* search the arcade folder for the match */
|
||||
struct dirent *entry;
|
||||
DIR *dir=NULL;
|
||||
struct dirent *entry;
|
||||
DIR *dir = NULL;
|
||||
//printf("opendir(%s)\n",getFullPath("arcade"));
|
||||
if (!(dir = opendir(getFullPath("arcade"))))
|
||||
{
|
||||
if (!(dir = opendir(getFullPath("arcade"))))
|
||||
{
|
||||
printf("arcade directory not found\n");
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
while ((entry = readdir(dir)) != NULL) {
|
||||
if (entry->d_type == DT_DIR) {
|
||||
}
|
||||
else {
|
||||
int found = 0;
|
||||
int len;
|
||||
while ((entry = readdir(dir)) != NULL)
|
||||
{
|
||||
if (entry->d_type != DT_DIR)
|
||||
{
|
||||
char newstring[kBigTextSize];
|
||||
//printf("entry name: %s\n",entry->d_name);
|
||||
snprintf(newstring,kBigTextSize,"Arcade-%s_",rbfname_fragment);
|
||||
if (!strncasecmp(newstring,entry->d_name,strlen(newstring))) {
|
||||
closedir(dir);
|
||||
strcpy(rbfname,entry->d_name);
|
||||
return 0;
|
||||
|
||||
}
|
||||
snprintf(newstring,kBigTextSize,"%s_",rbfname_fragment);
|
||||
if (!strncasecmp(newstring,entry->d_name,strlen(newstring))) {
|
||||
closedir(dir);
|
||||
strcpy(rbfname,entry->d_name);
|
||||
return 0;
|
||||
}
|
||||
snprintf(newstring,kBigTextSize,"%s.",rbfname_fragment);
|
||||
if (!strncasecmp(newstring,entry->d_name,strlen(newstring))) {
|
||||
closedir(dir);
|
||||
strcpy(rbfname,entry->d_name);
|
||||
return 0;
|
||||
snprintf(newstring, kBigTextSize, "Arcade-%s", rbfname);
|
||||
len = strlen(newstring);
|
||||
if (!strncasecmp(newstring, entry->d_name, len) && (entry->d_name[len] == '.' || entry->d_name[len] == '_'))
|
||||
{
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
snprintf(newstring, kBigTextSize, "%s", rbfname);
|
||||
len = strlen(newstring);
|
||||
if (!strncasecmp(newstring, entry->d_name, len) && (entry->d_name[len] == '.' || entry->d_name[len] == '_'))
|
||||
{
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dir) closedir(dir);
|
||||
strcpy(rbfname,rbfname_fragment);
|
||||
return 0;
|
||||
if (found) sprintf(rbfname, "%s/arcade/%s", getRootDir(), entry->d_name);
|
||||
closedir(dir);
|
||||
|
||||
if (found)
|
||||
{
|
||||
printf("MRA: %s, RBF: %s\n", xmlname, rbfname);
|
||||
fpga_load_rbf(rbfname, NULL, xmlname);
|
||||
}
|
||||
else
|
||||
{
|
||||
Info("No core found!");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#include "../../file_io.h"
|
||||
#ifndef ROMUTILS_H_
|
||||
#define ROMUTILS_H_
|
||||
|
||||
int arcade_send_rom(const char *xml);
|
||||
int arcade_scan_xml_for_rbf(const char *xml,char *rbfname);
|
||||
int CheckArcadeError(void);
|
||||
int arcade_load(const char *xml);
|
||||
int arcade_check_error(void);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1955,7 +1955,7 @@ int sharpmz_default_ui_state(void)
|
||||
//
|
||||
void sharpmz_ui(int idleState, int idle2State, int systemState, int selectFile,
|
||||
uint32_t *parentstate, uint32_t *menustate, uint32_t *menusub, uint32_t *menusub_last,
|
||||
uint32_t *menumask, char *selectedPath, const char **helptext, char *helptext_custom,
|
||||
uint64_t *menumask, char *selectedPath, const char **helptext, char *helptext_custom,
|
||||
uint32_t *fs_ExtLen, uint32_t *fs_Options, uint32_t *fs_MenuSelect, uint32_t *fs_MenuCancel,
|
||||
char *fs_pFileExt,
|
||||
unsigned char menu, unsigned char select, unsigned char up, unsigned char down,
|
||||
|
||||
@@ -457,7 +457,7 @@ void sharpmz_select_file(const char*, unsigned char, char *, c
|
||||
int sharpmz_default_ui_state(void);
|
||||
void sharpmz_ui(int idleState, int idle2State, int systemState, int selectFile,
|
||||
uint32_t *parentstate, uint32_t *menustate, uint32_t *menusub, uint32_t *menusub_last,
|
||||
uint32_t *menumask, char *selectedPath, const char **helptext, char *helptext_custom,
|
||||
uint64_t *menumask, char *selectedPath, const char **helptext, char *helptext_custom,
|
||||
uint32_t *fs_ExtLen, uint32_t *fs_Options, uint32_t *fs_MenuSelect, uint32_t *fs_MenuCancel,
|
||||
char *fs_pFileExt,
|
||||
unsigned char menu, unsigned char select, unsigned char up, unsigned char down,
|
||||
|
||||
122
user_io.cpp
122
user_io.cpp
@@ -693,6 +693,11 @@ int user_io_is_dualsdr()
|
||||
return dual_sdr;
|
||||
}
|
||||
|
||||
int user_io_get_width()
|
||||
{
|
||||
return fio_size;
|
||||
}
|
||||
|
||||
void user_io_init(const char *path, const char *xml)
|
||||
{
|
||||
char *name;
|
||||
@@ -703,13 +708,7 @@ void user_io_init(const char *path, const char *xml)
|
||||
// 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);
|
||||
strcpy(core_path, xml ? xml : path);
|
||||
|
||||
memset(sd_image, 0, sizeof(sd_image));
|
||||
|
||||
@@ -825,7 +824,11 @@ void user_io_init(const char *path, const char *xml)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_minimig())
|
||||
if (xml)
|
||||
{
|
||||
arcade_send_rom(xml);
|
||||
}
|
||||
else if (is_minimig())
|
||||
{
|
||||
puts("Identified Minimig V2 core");
|
||||
BootInit();
|
||||
@@ -869,14 +872,6 @@ void user_io_init(const char *path, const char *xml)
|
||||
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++)
|
||||
@@ -1599,101 +1594,6 @@ 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
|
||||
|
||||
@@ -210,12 +210,7 @@ void user_io_read_confstr();
|
||||
char *user_io_get_confstr(int index);
|
||||
uint32_t user_io_8bit_set_status(uint32_t, uint32_t, int ex = 0);
|
||||
int user_io_file_tx(const char* name, unsigned char index = 0, char opensave = 0, char mute = 0, char composite = 0);
|
||||
|
||||
int user_io_file_tx_start(const char *name,unsigned char index=0);
|
||||
int user_io_file_tx_body(const uint8_t *buf,uint16_t chunk,struct MD5Context *md5context=NULL);
|
||||
int user_io_file_tx_body_filepart(const char *name,int start=0, int len=0,struct MD5Context *md5context=NULL);
|
||||
int user_io_file_tx_finish();
|
||||
|
||||
int user_io_get_width();
|
||||
|
||||
uint32_t user_io_get_file_crc();
|
||||
int user_io_file_mount(char *name, unsigned char index = 0, char pre = 0);
|
||||
|
||||
Reference in New Issue
Block a user