diff --git a/.gitattributes b/.gitattributes index 45871203078..721c3fe3a0d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -26,6 +26,7 @@ hash/adam_cart.xml svneol=native#text/xml hash/adam_cass.xml svneol=native#text/xml hash/adam_flop.xml svneol=native#text/xml hash/advision.xml svneol=native#text/xml +hash/aim65_cart.xml svneol=native#text/xml hash/alice32.xml svneol=native#text/xml hash/alice90.xml svneol=native#text/xml hash/amiga1000_flop.xml svneol=native#text/xml diff --git a/hash/aim65_cart.xml b/hash/aim65_cart.xml new file mode 100644 index 00000000000..59498663592 --- /dev/null +++ b/hash/aim65_cart.xml @@ -0,0 +1,92 @@ + + + + + + + + Assembler + 197? + <unknown> + + + + + + + + + + + AIM 65 BASIC v1.1 + 1978 + Microsoft + + + + + + + + + + + + + + + AIM 65 FORTH v1.3 + 197? + <unknown> + + + + + + + + + + + + + + + Mathpack + 197? + <unknown> + + + + + + + + + + AIM 65 PL/65 v1.0 + 1978 + Rockwell + + + + + + + + + + + + + + diff --git a/src/mess/drivers/aim65.c b/src/mess/drivers/aim65.c index b4f2cafd520..e09f935cb0c 100644 --- a/src/mess/drivers/aim65.c +++ b/src/mess/drivers/aim65.c @@ -255,6 +255,87 @@ const dl1416_interface aim65_ds5_intf = MACHINE DRIVERS ***************************************************************************/ +struct aim_cart_range +{ + const char *tag; + int offset; +}; + +static const struct aim_cart_range aim_cart_table[] = +{ + { ":z24", 0xd000 }, + { ":z25", 0xc000 }, + { ":z26", 0xb000 }, + { 0 } +}; + +DEVICE_IMAGE_LOAD_MEMBER( aim65_state, aim65_cart ) +{ + UINT32 size; + UINT8 *temp_copy; + const struct aim_cart_range *aim_cart = &aim_cart_table[0], *this_cart; + + /* First, determine where this cart has to be loaded */ + while (aim_cart->tag) + { + if (strcmp(aim_cart->tag, image.device().tag()) == 0) + break; + + aim_cart++; + } + + this_cart = aim_cart; + + if (!this_cart->tag) + { + astring errmsg; + errmsg.printf("Tag '%s' could not be found", image.device().tag()); + image.seterror(IMAGE_ERROR_UNSPECIFIED, errmsg.cstr()); + return IMAGE_INIT_FAIL; + } + + if (image.software_entry() == NULL) + { + size = image.length(); + temp_copy = auto_alloc_array(machine(), UINT8, size); + + if (size > 0x1000) + { + image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size"); + auto_free(machine(), temp_copy); + return IMAGE_INIT_FAIL; + } + + if (image.fread(temp_copy, size) != size) + { + image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unable to fully read from file"); + auto_free(machine(), temp_copy); + return IMAGE_INIT_FAIL; + } + } + else + { + if (image.get_software_region(this_cart->tag + 1) == NULL) + { + astring errmsg; + errmsg.printf("Attempted to load file with wrong extension\nCartslot '%s' only accepts files with '.%s' extension", + this_cart->tag, this_cart->tag + 1); + image.seterror(IMAGE_ERROR_UNSPECIFIED, errmsg.cstr()); + return IMAGE_INIT_FAIL; + } + + size = image.get_software_region_length(this_cart->tag + 1); + temp_copy = auto_alloc_array(machine(), UINT8, size); + memcpy(temp_copy, image.get_software_region(this_cart->tag + 1), size); + } + + memcpy(memregion("maincpu")->base() + this_cart->offset, temp_copy, size); + + auto_free(machine(), temp_copy); + + return IMAGE_INIT_PASS; +} + static MACHINE_CONFIG_START( aim65, aim65_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M6502, AIM65_CLOCK) /* 1 MHz */ @@ -284,20 +365,31 @@ static MACHINE_CONFIG_START( aim65, aim65_state ) MCFG_CASSETTE_ADD( "cassette", aim65_1_cassette_interface ) MCFG_CASSETTE_ADD( "cassette2", aim65_2_cassette_interface ) - MCFG_CARTSLOT_ADD("cart1") + MCFG_CARTSLOT_ADD("z26") MCFG_CARTSLOT_EXTENSION_LIST("z26") + MCFG_CARTSLOT_INTERFACE("aim65_cart") + MCFG_CARTSLOT_LOAD(aim65_state, aim65_cart) MCFG_CARTSLOT_NOT_MANDATORY - MCFG_CARTSLOT_ADD("cart2") + + MCFG_CARTSLOT_ADD("z25") MCFG_CARTSLOT_EXTENSION_LIST("z25") + MCFG_CARTSLOT_INTERFACE("aim65_cart") + MCFG_CARTSLOT_LOAD(aim65_state, aim65_cart) MCFG_CARTSLOT_NOT_MANDATORY - MCFG_CARTSLOT_ADD("cart3") + + MCFG_CARTSLOT_ADD("z24") MCFG_CARTSLOT_EXTENSION_LIST("z24") + MCFG_CARTSLOT_INTERFACE("aim65_cart") MCFG_CARTSLOT_NOT_MANDATORY + MCFG_CARTSLOT_LOAD(aim65_state, aim65_cart) /* internal ram */ MCFG_RAM_ADD(RAM_TAG) MCFG_RAM_DEFAULT_SIZE("4K") MCFG_RAM_EXTRA_OPTIONS("1K,2K,3K") + + /* Software lists */ + MCFG_SOFTWARE_LIST_ADD("cart_list","aim65_cart") MACHINE_CONFIG_END @@ -307,9 +399,6 @@ MACHINE_CONFIG_END ROM_START( aim65 ) ROM_REGION(0x10000, "maincpu", 0) - ROM_CART_LOAD("cart1", 0xb000, 0x1000, ROM_OPTIONAL) - ROM_CART_LOAD("cart2", 0xc000, 0x1000, ROM_OPTIONAL) - ROM_CART_LOAD("cart3", 0xd000, 0x1000, ROM_OPTIONAL) ROM_SYSTEM_BIOS(0, "aim65", "Rockwell AIM-65") ROMX_LOAD("aim65mon.z23", 0xe000, 0x1000, CRC(90e44afe) SHA1(78e38601edf6bfc787b58750555a636b0cf74c5c), ROM_BIOS(1)) ROMX_LOAD("aim65mon.z22", 0xf000, 0x1000, CRC(d01914b0) SHA1(e5b5ddd4cd43cce073a718ee4ba5221f2bc84eaf), ROM_BIOS(1)) diff --git a/src/mess/includes/aim65.h b/src/mess/includes/aim65.h index 37237085385..990db865e72 100644 --- a/src/mess/includes/aim65.h +++ b/src/mess/includes/aim65.h @@ -67,6 +67,8 @@ public: DECLARE_WRITE16_MEMBER(aim65_update_ds3); DECLARE_WRITE16_MEMBER(aim65_update_ds4); DECLARE_WRITE16_MEMBER(aim65_update_ds5); + + DECLARE_DEVICE_IMAGE_LOAD_MEMBER(aim65_cart); };