ide->rom = xcalloc(uae_u8, ide->rom_size);
memset(ide->rom, 0xff, ide->rom_size);
ide->rom_mask = ide->rom_size - 1;
- struct zfile *z = read_device_from_romconfig(rc, roms);
- if (z) {
- for (int i = 0; i < 16; i++) {
- uae_u8 b = autoconfig[i];
- ew(ide, i * 4, b);
- }
- int size = zfile_fread(ide->rom, 1, ide->rom_size, z);
- zfile_fclose(z);
+
+ load_rom_rc(rc, roms, ide->rom_size, 0, ide->rom, ide->rom_size, LOADROM_FILL);
+ for (int i = 0; i < 16; i++) {
+ uae_u8 b = autoconfig[i];
+ ew(ide, i * 4, b);
}
return ide->bank;
}
memset(ide->rom, 0xff, ide->rom_size);
memset(ide->acmemory, 0xff, sizeof ide->acmemory);
ide->rom_mask = ide->rom_size - 1;
- struct zfile *z = read_device_from_romconfig(rc, roms);
- if (z) {
- int len = zfile_size(z);
- for (int i = 0; i < 32768; i++) {
- uae_u8 b;
- zfile_fread(&b, 1, 1, z);
- ide->rom[i * 2 + 0] = b;
- ide->rom[i * 2 + 1] = 0xff;
- }
- zfile_fclose(z);
- ide->subtype = rc->subtype;
- if (rc && rc->autoboot_disabled)
- memcpy(ide->acmemory, ide->rom + 0x100, sizeof ide->acmemory);
- else
- memcpy(ide->acmemory, ide->rom + 0x000, sizeof ide->acmemory);
- }
+
+ load_rom_rc(rc, roms, 32768, 0, ide->rom, 65536, LOADROM_EVENONLY_ODDONE | LOADROM_FILL);
+ ide->subtype = rc->subtype;
+ if (rc && rc->autoboot_disabled)
+ memcpy(ide->acmemory, ide->rom + 0x100, sizeof ide->acmemory);
+ else
+ memcpy(ide->acmemory, ide->rom + 0x000, sizeof ide->acmemory);
+
// init SCSI part
ncr_masoboshi_autoconfig_init(rc);
return ide->bank;
memset(ide->rom, 0xff, ide->rom_size);
ide->rom_mask = ide->rom_size - 1;
if (!rc->autoboot_disabled) {
- struct zfile *z = read_device_from_romconfig(rc, roms);
- if (z) {
- for (int i = 0; i < 16384; i++) {
- uae_u8 b;
- zfile_fread(&b, 1, 1, z);
- ide->rom[i * 2 + 0] = b;
- ide->rom[i * 2 + 1] = 0xff;
- }
- zfile_fclose(z);
- }
+ load_rom_rc(rc, roms, 16384, 0, ide->rom, 32768, LOADROM_EVENONLY_ODDONE | LOADROM_FILL);
}
for (int i = 0; i < 16; i++) {
uae_u8 b = adide_autoconfig[i];
ide->rom = xcalloc(uae_u8, ide->rom_size);
memset(ide->rom, 0xff, ide->rom_size);
ide->rom_mask = ide->rom_size - 1;
- struct zfile *z = read_device_from_romconfig(rc, roms);
- if (z) {
- if (!rc->autoboot_disabled)
- zfile_fseek(z, 16384, SEEK_SET);
- for (int i = 0; i < 16384; i++) {
- uae_u8 b;
- zfile_fread(&b, 1, 1, z);
- ide->rom[i * 2 + 0] = b;
- ide->rom[i * 2 + 1] = 0xff;
- }
- zfile_fclose(z);
- memcpy(ide->acmemory, ide->rom, sizeof ide->acmemory);
- }
+ load_rom_rc(rc, roms, 16384, !rc->autoboot_disabled ? 16384 : 0, ide->rom, 32768, LOADROM_EVENONLY_ODDONE | LOADROM_FILL);
+ memcpy(ide->acmemory, ide->rom, sizeof ide->acmemory);
return ide->bank;
}
#define ROMTYPE_CB_CSPPC 0x0004000e
#define ROMTYPE_CB_BLIZPPC 0x0004000f
#define ROMTYPE_CB_GOLEM030 0x00040010
+#define ROMTYPE_CB_ACA500 0x00040011
#define ROMTYPE_FREEZER 0x00080000
#define ROMTYPE_AR 0x00080001
extern void romlist_clear (void);
extern struct zfile *read_rom (struct romdata *rd);
extern struct zfile *read_rom_name (const TCHAR *filename);
-extern struct zfile *read_device_from_romconfig(struct romconfig *rc, int *roms);
+extern struct zfile *read_device_from_romconfig(struct romconfig *rc, const int *roms);
extern int load_keyring (struct uae_prefs *p, const TCHAR *path);
extern uae_u8 *target_load_keyfile (struct uae_prefs *p, const TCHAR *path, int *size, TCHAR *name);
struct boardromconfig *get_device_rom_new(struct uae_prefs *p, int romtype, int devnum, int *index);
void clear_device_rom(struct uae_prefs *p, int romtype, int devnum);
struct boardromconfig *get_boardromconfig(struct uae_prefs *p, int romtype, int *index);
+
+#define LOADROM_FILL 1
+#define LOADROM_EVENONLY 2
+#define LOADROM_EVENONLY_ODDONE ((255 << 16) | LOADROM_EVENONLY)
+#define LOADROM_ONEFILL 4
+#define LOADROM_ZEROFILL 8
+#define LOADROM_ODDFILL(x) ((x << 16) | LOADROM_EVENONLY)
+bool load_rom_rc(struct romconfig *rc, const int *roms, int maxfilesize, int fileoffset, uae_u8 *rom, int maxromsize, int flags);
\ No newline at end of file
return NULL;
}
-#define NEXT_ROM_ID 137
+#define NEXT_ROM_ID 138
static struct romheader romheaders[] = {
{ _T("Freezer Cartridges"), 1 },
0, 0, 0, 0, 0, 0, NULL, _T("blizzardppc_040.rom") },
{ _T("Blizzard PPC 68060"), 0, 0, 0, 0, _T("BPPC\0"), 524288, 100, 0, 0, ROMTYPE_CB_BLIZPPC, 0, 0, NULL,
0, 0, 0, 0, 0, 0, NULL, _T("blizzardppc_060.rom") },
+ { _T("ACA 500"), 0, 0, 0, 0, _T("ACA500\0"), 524288, 137, 0, 0, ROMTYPE_CB_ACA500, 0, 0, NULL,
+ 0, 0, 0, 0, 0, 0, NULL, _T("menu500.aca") },
{ _T("Picasso IV"), 7, 4, 7, 4, _T("PIV\0"), 131072, 91, 0, 0, ROMTYPE_PIV, 0, 0, NULL,
0xa8133e7e, 0xcafafb91,0x6f16b9f3,0xec9b49aa,0x4b40eb4e,0xeceb5b5b },
return NULL;
}
-struct zfile *read_device_from_romconfig(struct romconfig *rc, int *roms)
+struct zfile *read_device_from_romconfig(struct romconfig *rc, const int *roms)
{
if (!_tcsicmp(rc->romfile, _T(":NOROM")))
return NULL;
}
}
return NULL;
+}
+
+bool load_rom_rc(struct romconfig *rc, const int *roms, int maxfilesize, int fileoffset, uae_u8 *rom, int maxromsize, int flags)
+{
+ if (flags & LOADROM_ONEFILL)
+ memset(rom, 0xff, maxromsize);
+ if (flags & LOADROM_ZEROFILL)
+ memset(rom, 0x00, maxromsize);
+ struct zfile *f = read_device_from_romconfig(rc, roms);
+ if (!f)
+ return false;
+ zfile_fseek(f, fileoffset, SEEK_SET);
+ int cnt = 0;
+ int pos = 0;
+ bool eof = false;
+ while (cnt < maxromsize && cnt < maxfilesize && pos < maxromsize) {
+ uae_u8 b = 0xff;
+ if (!eof) {
+ if (!zfile_fread(&b, 1, 1, f))
+ eof = true;
+ }
+ if (eof) {
+ int bitcnt = 0;
+ for (int i = 1; i < maxromsize; i <<= 1) {
+ if (cnt & i)
+ bitcnt++;
+ }
+ if (bitcnt == 1)
+ break;
+ }
+
+ rom[pos] = b;
+ if (flags & LOADROM_EVENONLY) {
+ rom[pos + 1] = (flags >> 16) & 0xff;
+ pos += 2;
+ } else {
+ pos += 1;
+ }
+ cnt++;
+ }
+ zfile_fclose(f);
+ int posend = pos;
+ if (!(flags & LOADROM_FILL))
+ return true;
+ int oldpos = 0;
+ while (pos < maxromsize) {
+ rom[pos] = rom[oldpos];
+ oldpos++;
+ pos++;
+ if (oldpos >= posend)
+ oldpos = 0;
+ }
+ return true;
}
\ No newline at end of file
struct zfile *z = NULL;
scsi->subtype = rc->subtype;
if (!rc->autoboot_disabled && scsi->subtype != 3) {
- struct zfile *z = read_device_from_romconfig(rc, roms);
for (int i = 0; i < 16; i++) {
uae_u8 b = ert->subtypes[rc->subtype].autoconfig[i];
ew(scsi, i * 4, b);
}
- if (z) {
- int i;
- for (i = 0; i < 16384; i++) {
- uae_u8 b;
- if (!zfile_fread(&b, 1, 1, z))
- break;
- scsi->rom[i * 2 + 0] = b;
- }
- if (i < 16384) {
- int ii = 0;
- while (i < 16384) {
- scsi->rom[i * 2 + 0] = scsi->rom[ii * 2 + 0];
- i++;
- ii++;
- }
- }
- zfile_fclose(z);
- }
+ load_rom_rc(rc, roms, 16384, 0, scsi->rom, 32768, LOADROM_EVENONLY_ODDONE | LOADROM_FILL);
}
return scsi->bank;
}
scsi->intena = true;
- struct zfile *z = NULL;
- if (!rc->autoboot_disabled) {
- struct zfile *z = read_device_from_romconfig(rc, roms);
- if (z) {
- if (rc->autoboot_disabled)
- zfile_fseek(z, 8192, SEEK_SET);
- for (int i = 0; i < 8192; i++) {
- uae_u8 b;
- zfile_fread(&b, 1, 1, z);
- if (i < sizeof scsi->acmemory)
- scsi->acmemory[i] = b;
- scsi->rom[i] = b;
- }
- zfile_fclose(z);
- }
- }
+ load_rom_rc(rc, roms, 8192, rc->autoboot_disabled ? 8192 : 0, scsi->rom, 8192, 0);
+ memcpy(scsi->acmemory, scsi->rom, sizeof scsi->acmemory);
+
return scsi->bank;
}
roms[0] = 127;
roms[1] = -1;
- struct zfile *z = read_device_from_romconfig(rc, roms);
- if (z) {
- zfile_fread(scsi->rom, 1, 32768, z);
- zfile_fclose(z);
- }
+
+ load_rom_rc(rc, roms, 32768, 0, scsi->rom, 32768, 0);
map_banks(scsi->bank, 0xf10000 >> 16, 1, 0);
map_banks(scsi->bank, 0xeb0000 >> 16, 1, 0);
struct zfile *z = NULL;
if (!rc->autoboot_disabled) {
- struct zfile *z = read_device_from_romconfig(rc, roms);
- if (z) {
- for (int i = 0; i < 32768; i++) {
- uae_u8 b;
- zfile_fread(&b, 1, 1, z);
- if (i < sizeof scsi->acmemory)
- scsi->acmemory[i] = b;
- scsi->rom[i] = b;
- }
- zfile_fclose(z);
- }
+ load_rom_rc(rc, roms, 32768, 0, scsi->rom, 32768, 0);
+ memcpy(scsi->acmemory, scsi->rom, sizeof scsi->acmemory);
}
return scsi->bank;
}
roms[0] = 131;
roms[1] = -1;
- struct zfile *z = read_device_from_romconfig(rc, roms);
- if (z) {
- for (int i = 0; i < 32768; i++) {
- uae_u8 b;
- zfile_fread(&b, 1, 1, z);
- scsi->rom[i * 2] = b;
- }
- zfile_fclose(z);
- memcpy(scsi->acmemory, scsi->rom + 0x200 * 2, sizeof scsi->acmemory);
- }
+ load_rom_rc(rc, roms, 32768, 0, scsi->rom, 32768, LOADROM_EVENONLY_ODDONE);
+ memcpy(scsi->acmemory, scsi->rom + 0x200 * 2, sizeof scsi->acmemory);
return scsi->bank;
}
scsi->rscsi.use_ack = true;
- struct zfile *z = read_device_from_romconfig(rc, roms);
- if (z) {
- for (int i = 0; i < 16384; i++) {
- uae_u8 b;
- zfile_fread(&b, 1, 1, z);
- scsi->rom[i * 2] = b;
- }
- zfile_fclose(z);
- memcpy(scsi->acmemory, scsi->rom, sizeof scsi->acmemory);
- }
+ load_rom_rc(rc, roms, 16384, 0, scsi->rom, 32768, LOADROM_EVENONLY_ODDONE | LOADROM_FILL);
+ memcpy(scsi->acmemory, scsi->rom, sizeof scsi->acmemory);
return scsi->bank;
}
scsi->databuffer_size = 1024;
scsi->databufferptr = xcalloc(uae_u8, scsi->databuffer_size);
- struct zfile *z = read_device_from_romconfig(rc, roms);
- if (z) {
- for (int i = 0; i < 4096; i++) {
- uae_u8 b;
- zfile_fread(&b, 1, 1, z);
- scsi->rom[i * 2] = b;
- }
- zfile_fclose(z);
- }
+ load_rom_rc(rc, roms, 4096, 0, scsi->rom, 32768, LOADROM_EVENONLY_ODDONE | LOADROM_FILL);
return scsi->bank;
}
roms[0] = 132;
roms[1] = -1;
- struct zfile *z = read_device_from_romconfig(rc, roms);
- if (z) {
- for (int i = 0; i < 32768; i++) {
- uae_u8 b;
- zfile_fread(&b, 1, 1, z);
- scsi->rom[i * 2] = b;
- }
- zfile_fclose(z);
- memcpy(scsi->acmemory, scsi->rom, sizeof scsi->acmemory);
- }
+ load_rom_rc(rc, roms, 32768, 0, scsi->rom, 65536, LOADROM_EVENONLY_ODDONE | LOADROM_FILL);
+ memcpy(scsi->acmemory, scsi->rom, sizeof scsi->acmemory);
return scsi->bank;
}