Amiga Bootblock Reader bootblock brainfile.xml support

This commit is contained in:
Toni Wilen 2020-09-22 19:39:49 +03:00
parent fe3abbc725
commit 7484fc9dd9
7 changed files with 5498 additions and 9 deletions

145
disk.cpp
View File

@ -55,6 +55,7 @@ int disk_debug_track = -1;
#include "fsdb.h" #include "fsdb.h"
#include "statusline.h" #include "statusline.h"
#include "rommgr.h" #include "rommgr.h"
#include "tinyxml2.h"
#undef CATWEASEL #undef CATWEASEL
@ -1138,7 +1139,7 @@ static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const TCHAR
drive_image_free (drv); drive_image_free (drv);
if (!fake) if (!fake)
DISK_examine_image(p, dnum, &disk_info_data); DISK_examine_image(p, dnum, &disk_info_data, false);
DISK_validate_filename (p, fname_in, outname, 1, &drv->wrprot, &drv->crc32, &drv->diskfile); DISK_validate_filename (p, fname_in, outname, 1, &drv->wrprot, &drv->crc32, &drv->diskfile);
drv->forcedwrprot = forcedwriteprotect; drv->forcedwrprot = forcedwriteprotect;
if (drv->forcedwrprot) if (drv->forcedwrprot)
@ -4407,7 +4408,141 @@ static void load_track (int num, int cyl, int side, int *sectable)
drv->buffered_cyl = -1; drv->buffered_cyl = -1;
} }
int DISK_examine_image (struct uae_prefs *p, int num, struct diskinfo *di) using namespace tinyxml2;
static bool abr_loaded;
static tinyxml2::XMLDocument abr_xml[2];
static TCHAR* abr_files[] = { _T("brainfile.xml"), _T("catlist.xml"), NULL };
static void abrcheck(struct diskinfo *di)
{
TCHAR path[MAX_DPATH];
if (!abr_loaded) {
bool error = false;
for (int i = 0; abr_files[i] && !error; i++) {
get_plugin_path(path, sizeof(path) / sizeof(TCHAR), _T("abr"));
_tcscat(path, abr_files[i]);
FILE *f = _tfopen(path, _T("rb"));
if (f) {
tinyxml2::XMLError err = abr_xml[i].LoadFile(f);
if (err != XML_SUCCESS) {
write_log(_T("failed to parse '%s': %d\n"), path, err);
error = true;
}
fclose(f);
} else {
error = true;
}
}
if (!error) {
abr_loaded = true;
}
}
if (!abr_loaded)
return;
tinyxml2::XMLElement *detectedelementcrc32 = NULL;
tinyxml2::XMLElement *detectedelementrecog = NULL;
tinyxml2::XMLElement *e = abr_xml[0].FirstChildElement("Bootblocks");
if (e) {
e = e->FirstChildElement("Bootblock");
if (e) {
do {
tinyxml2::XMLElement *ercrc = e->FirstChildElement("CRC");
if (ercrc) {
const char *n_crc32 = ercrc->GetText();
if (strlen(n_crc32) == 8) {
char *endptr;
uae_u32 crc32 = strtol(n_crc32, &endptr, 16);
if (di->bootblockcrc32 == crc32) {
detectedelementcrc32 = e;
}
}
}
tinyxml2::XMLElement *er = e->FirstChildElement("Recog");
if (er) {
const char *tr = er->GetText();
bool detected = false;
while (tr) {
int offset = atoi(tr);
if (offset < 0 || offset > 1023)
break;
tr = strchr(tr, ',');
if (!tr || !tr[1])
break;
tr++;
int val = atoi(tr);
if (val < 0 || val > 255)
break;
if (di->bootblock[offset] != val)
break;
tr = strchr(tr, ',');
if (!tr) {
detected = true;
} else {
tr++;
}
}
if (detected) {
detectedelementrecog = e;
}
}
e = e->NextSiblingElement();
} while (e && !detectedelementcrc32);
if (detectedelementcrc32 != NULL || detectedelementrecog != NULL) {
if (detectedelementcrc32) {
e = detectedelementcrc32;
} else {
e = detectedelementrecog;
}
tinyxml2::XMLElement *e_name = e->FirstChildElement("Name");
if (e_name) {
const char *n_name = e_name->GetText();
if (n_name) {
TCHAR *s = au(n_name);
_tcscpy(di->bootblockinfo, s);
xfree(s);
}
}
tinyxml2::XMLElement *e_class = e->FirstChildElement("Class");
if (e_class) {
const char *t_class = e_class->GetText();
if (t_class) {
tinyxml2::XMLElement *ecats = abr_xml[1].FirstChildElement("Categories");
if (ecats) {
tinyxml2::XMLElement *ecat = ecats->FirstChildElement("Category");
if (ecat) {
do {
tinyxml2::XMLElement *ecatr = ecat->FirstChildElement("abbrev");
if (ecatr) {
const char *catabbr = ecatr->GetText();
if (!strcmp(catabbr, t_class)) {
tinyxml2::XMLElement *ecatn = ecat->FirstChildElement("Name");
if (ecatn) {
const char *n_catname = ecatn->GetText();
if (n_catname) {
TCHAR *s = au(n_catname);
_tcscpy(di->bootblockclass, s);
xfree(s);
break;
}
}
}
}
ecat = ecat->NextSiblingElement();
} while (ecat);
}
}
return;
}
}
}
}
}
}
int DISK_examine_image (struct uae_prefs *p, int num, struct diskinfo *di, bool deepcheck)
{ {
int drvsec; int drvsec;
int ret, i; int ret, i;
@ -4430,7 +4565,7 @@ int DISK_examine_image (struct uae_prefs *p, int num, struct diskinfo *di)
side = oldside; side = oldside;
return 1; return 1;
} }
di->crc32 = zfile_crc32 (drv->diskfile); di->imagecrc32 = zfile_crc32 (drv->diskfile);
di->unreadable = false; di->unreadable = false;
decode_buffer (drv->bigmfmbuf, drv->cyl, 11, drv->ddhd, drv->filetype, &drvsec, sectable, 1); decode_buffer (drv->bigmfmbuf, drv->cyl, 11, drv->ddhd, drv->filetype, &drvsec, sectable, 1);
di->hd = drv->ddhd == 2; di->hd = drv->ddhd == 2;
@ -4457,6 +4592,10 @@ int DISK_examine_image (struct uae_prefs *p, int num, struct diskinfo *di)
crc++; crc++;
crc += v; crc += v;
} }
di->bootblockcrc32 = get_crc32(di->bootblock, 1024);
if (deepcheck) {
abrcheck(di);
}
if (dos == 0x4b49434b) { /* KICK */ if (dos == 0x4b49434b) { /* KICK */
ret = 10; ret = 10;
goto end; goto end;

View File

@ -19,6 +19,10 @@ struct bltinfo {
int vblitsize, hblitsize; int vblitsize, hblitsize;
int bltamod, bltbmod, bltcmod, bltdmod; int bltamod, bltbmod, bltcmod, bltdmod;
int got_cycle; int got_cycle;
int nasty_cnt, wait_nasty;
int blitter_nasty, blit_interrupt;
// blitter is active and D may write to visible bitplane addresses
int blitter_dangerous_bpl;
}; };
extern enum blitter_states { extern enum blitter_states {
@ -27,8 +31,6 @@ extern enum blitter_states {
extern struct bltinfo blt_info; extern struct bltinfo blt_info;
extern int blitter_nasty, blit_interrupt, blitter_dangerous_bpl;
extern void check_is_blit_dangerous (uaecptr *bplpt, int planes, int words); extern void check_is_blit_dangerous (uaecptr *bplpt, int planes, int words);
extern uae_u16 bltsize; extern uae_u16 bltsize;
@ -41,7 +43,6 @@ extern int blit_singlechannel;
extern void maybe_blit (int, int); extern void maybe_blit (int, int);
extern void reset_blit (int); extern void reset_blit (int);
extern int blitnasty (void); extern int blitnasty (void);
extern int blitnnasty (int);
extern void blitter_handler (uae_u32); extern void blitter_handler (uae_u32);
extern void build_blitfilltable (void); extern void build_blitfilltable (void);
extern void do_blitter (int, int, uaecptr); extern void do_blitter (int, int, uaecptr);

View File

@ -27,6 +27,8 @@
#define MAXVPOS_LINES_OCS 512 #define MAXVPOS_LINES_OCS 512
#define HPOS_SHIFT 3 #define HPOS_SHIFT 3
#define BLIT_NASTY_CPU_STEAL_CYCLE_COUNT 4
uae_u32 get_copper_address (int copno); uae_u32 get_copper_address (int copno);
extern int custom_init (void); extern int custom_init (void);

2380
include/tinyxml2.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -2633,14 +2633,15 @@ static void infofloppy (HWND hDlg, int n)
TCHAR tmp2[MAX_DPATH], tmp1[MAX_DPATH]; TCHAR tmp2[MAX_DPATH], tmp1[MAX_DPATH];
TCHAR text[20000]; TCHAR text[20000];
DISK_examine_image (&workprefs, n, &di); DISK_examine_image (&workprefs, n, &di, true);
DISK_validate_filename(&workprefs, workprefs.floppyslots[n].df, tmp1, 0, NULL, NULL, NULL); DISK_validate_filename(&workprefs, workprefs.floppyslots[n].df, tmp1, 0, NULL, NULL, NULL);
_stprintf (tmp2, _stprintf (tmp2,
_T("'%s'\r\nDisk readable: %s\r\nCRC32: %08X\r\nBoot block checksum valid: %s\r\nBoot block type: %s\r\n"), _T("'%s'\r\nDisk readable: %s\r\nDisk CRC32: %08X\r\nBoot block CRC32: %08X\r\nBoot block checksum valid: %s\r\nBoot block type: %s\r\n"),
tmp1, tmp1,
di.unreadable ? _T("No") : _T("Yes"), di.unreadable ? _T("No") : _T("Yes"),
di.crc32, di.imagecrc32,
di.bootblockcrc32,
di.bb_crc_valid ? _T("Yes") : _T("No"), di.bb_crc_valid ? _T("Yes") : _T("No"),
di.bootblocktype == 0 ? _T("Custom") : (di.bootblocktype == 1 ? _T("Standard 1.x") : _T("Standard 2.x+")) di.bootblocktype == 0 ? _T("Custom") : (di.bootblocktype == 1 ? _T("Standard 1.x") : _T("Standard 2.x+"))
); );
@ -2651,6 +2652,20 @@ static void infofloppy (HWND hDlg, int n)
_tcscat (text, tmp2); _tcscat (text, tmp2);
} }
_tcscat (text, _T("\r\n")); _tcscat (text, _T("\r\n"));
if (di.bootblockinfo[0]) {
_tcscat(text, _T("Amiga Bootblock Reader database detected:\r\n"));
_tcscat(text, _T("Name: '"));
_tcscat(text, di.bootblockinfo);
_tcscat(text, _T("'"));
_tcscat(text, _T("\r\n"));
if (di.bootblockclass[0]) {
_tcscat(text, _T("Class: '"));
_tcscat(text, di.bootblockclass);
_tcscat(text, _T("'"));
_tcscat(text, _T("\r\n"));
}
_tcscat(text, _T("\r\n"));
}
int w = 32; int w = 32;
for (int i = 0; i < 1024; i += w) { for (int i = 0; i < 1024; i += w) {

View File

@ -995,6 +995,7 @@
<ClCompile Include="..\..\support\time.cpp" /> <ClCompile Include="..\..\support\time.cpp" />
<ClCompile Include="..\..\tabletlibrary.cpp" /> <ClCompile Include="..\..\tabletlibrary.cpp" />
<ClCompile Include="..\..\test_card.cpp" /> <ClCompile Include="..\..\test_card.cpp" />
<ClCompile Include="..\..\tinyxml2.cpp" />
<ClCompile Include="..\..\uaenative.cpp" /> <ClCompile Include="..\..\uaenative.cpp" />
<ClCompile Include="..\..\vm.cpp" /> <ClCompile Include="..\..\vm.cpp" />
<ClCompile Include="..\..\x86.cpp" /> <ClCompile Include="..\..\x86.cpp" />

2951
tinyxml2.cpp Normal file

File diff suppressed because it is too large Load Diff