From 206e7778dc7e27e77fea644a6420643f70737188 Mon Sep 17 00:00:00 2001 From: "R. Belmont" Date: Fri, 14 Feb 2014 19:51:34 +0000 Subject: [PATCH] (MESS) apple3: Add save state support and initial slot hookup. [R. Belmont] --- src/mess/drivers/apple3.c | 13 ++- src/mess/includes/apple3.h | 32 ++++--- src/mess/machine/apple3.c | 182 +++++++++++++++++++++++++++++++++++++ 3 files changed, 214 insertions(+), 13 deletions(-) diff --git a/src/mess/drivers/apple3.c b/src/mess/drivers/apple3.c index a66c2d7084b..c024c941ba0 100644 --- a/src/mess/drivers/apple3.c +++ b/src/mess/drivers/apple3.c @@ -21,6 +21,8 @@ #include "formats/ap2_dsk.h" #include "machine/appldriv.h" +#include "bus/a2bus/a2cffa.h" + static ADDRESS_MAP_START( apple3_map, AS_PROGRAM, 8, apple3_state ) AM_RANGE(0x0000, 0xffff) AM_READWRITE(apple3_memory_r, apple3_memory_w) ADDRESS_MAP_END @@ -38,6 +40,10 @@ static const floppy_interface apple3_floppy_interface = NULL }; +static SLOT_INTERFACE_START(apple3_cards) + SLOT_INTERFACE("cffa2", A2BUS_CFFA2_6502) /* CFFA2000 Compact Flash for Apple II (www.dreher.net), 6502 firmware */ +SLOT_INTERFACE_END + static const struct a2bus_interface a2bus_intf = { // interrupt lines @@ -88,6 +94,10 @@ static MACHINE_CONFIG_START( apple3, apple3_state ) /* slot bus */ MCFG_A2BUS_BUS_ADD("a2bus", "maincpu", a2bus_intf) + MCFG_A2BUS_SLOT_ADD("a2bus", "sl1", apple3_cards, NULL) + MCFG_A2BUS_SLOT_ADD("a2bus", "sl2", apple3_cards, NULL) + MCFG_A2BUS_SLOT_ADD("a2bus", "sl3", apple3_cards, NULL) + MCFG_A2BUS_SLOT_ADD("a2bus", "sl4", apple3_cards, NULL) /* fdc */ MCFG_APPLEFDC_ADD("fdc", apple3_fdc_interface) @@ -293,4 +303,5 @@ ROM_START(apple3) ROM_END /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME */ -COMP( 1980, apple3, 0, 0, apple3, apple3, apple3_state, apple3, "Apple Computer", "Apple ///", 0 ) +COMP( 1980, apple3, 0, 0, apple3, apple3, apple3_state, apple3, "Apple Computer", "Apple ///", GAME_SUPPORTS_SAVE ) + diff --git a/src/mess/includes/apple3.h b/src/mess/includes/apple3.h index ed4c54c403e..eb87b5890f9 100644 --- a/src/mess/includes/apple3.h +++ b/src/mess/includes/apple3.h @@ -44,6 +44,7 @@ public: m_acia(*this, "acia"), m_fdc(*this, "fdc"), m_ay3600(*this, "ay3600"), + m_a2bus(*this, "a2bus"), m_speaker(*this, SPEAKER_TAG), m_dac(*this, DAC_TAG), m_kbspecial(*this, "keyb_special") @@ -57,22 +58,11 @@ public: required_device m_acia; required_device m_fdc; required_device m_ay3600; + required_device m_a2bus; required_device m_speaker; required_device m_dac; required_ioport m_kbspecial; - UINT32 m_flags; - UINT8 m_via_0_a; - UINT8 m_via_0_b; - UINT8 m_via_1_a; - UINT8 m_via_1_b; - int m_via_0_irq; - int m_via_1_irq; - int m_enable_mask; - offs_t m_zpa; - UINT8 m_last_n; - UINT8 *m_char_mem; - UINT32 *m_hgr_map; DECLARE_READ8_MEMBER(apple3_memory_r); DECLARE_WRITE8_MEMBER(apple3_memory_w); DECLARE_WRITE_LINE_MEMBER(apple3_sync_w); @@ -110,11 +100,29 @@ public: DECLARE_READ_LINE_MEMBER(ay3600_shift_r); DECLARE_READ_LINE_MEMBER(ay3600_control_r); DECLARE_WRITE_LINE_MEMBER(ay3600_data_ready_w); + void apple3_postload(); + + // these need to be public for now + UINT32 m_flags; + int m_enable_mask; + +private: + UINT8 m_via_0_a; + UINT8 m_via_0_b; + UINT8 m_via_1_a; + UINT8 m_via_1_b; + int m_via_0_irq; + int m_via_1_irq; + offs_t m_zpa; + UINT8 m_last_n; + UINT8 *m_char_mem; + UINT32 *m_hgr_map; bool m_sync; bool m_rom_has_been_disabled; UINT8 m_indir_opcode; int m_indir_count; + int m_cnxx_slot; UINT8 *m_bank2, *m_bank3, *m_bank4, *m_bank5, *m_bank8, *m_bank9; UINT8 *m_bank10, *m_bank11; diff --git a/src/mess/machine/apple3.c b/src/mess/machine/apple3.c index edccce47e15..5439e54a3c5 100644 --- a/src/mess/machine/apple3.c +++ b/src/mess/machine/apple3.c @@ -56,6 +56,7 @@ static void apple3_update_drives(device_t *device); READ8_MEMBER(apple3_state::apple3_c0xx_r) { UINT8 result = 0xFF; + device_a2bus_card_interface *slotdevice; switch(offset) { @@ -143,6 +144,50 @@ READ8_MEMBER(apple3_state::apple3_c0xx_r) result = 0x00; break; + case 0x90: case 0x91: case 0x92: case 0x93: + case 0x94: case 0x95: case 0x96: case 0x97: + case 0x98: case 0x99: case 0x9a: case 0x9b: + case 0x9c: case 0x9d: case 0x9e: case 0x9f: + slotdevice = m_a2bus->get_a2bus_card(1); + if (slotdevice != NULL) + { + result = slotdevice->read_c0nx(space, offset&0xf); + } + break; + + case 0xa0: case 0xa1: case 0xa2: case 0xa3: + case 0xa4: case 0xa5: case 0xa6: case 0xa7: + case 0xa8: case 0xa9: case 0xaa: case 0xab: + case 0xac: case 0xad: case 0xae: case 0xaf: + slotdevice = m_a2bus->get_a2bus_card(2); + if (slotdevice != NULL) + { + result = slotdevice->read_c0nx(space, offset&0xf); + } + break; + + case 0xb0: case 0xb1: case 0xb2: case 0xb3: + case 0xb4: case 0xb5: case 0xb6: case 0xb7: + case 0xb8: case 0xb9: case 0xba: case 0xbb: + case 0xbc: case 0xbd: case 0xbe: case 0xbf: + slotdevice = m_a2bus->get_a2bus_card(3); + if (slotdevice != NULL) + { + result = slotdevice->read_c0nx(space, offset&0xf); + } + break; + + case 0xc0: case 0xc1: case 0xc2: case 0xc3: + case 0xc4: case 0xc5: case 0xc6: case 0xc7: + case 0xc8: case 0xc9: case 0xca: case 0xcb: + case 0xcc: case 0xcd: case 0xce: case 0xcf: + slotdevice = m_a2bus->get_a2bus_card(4); + if (slotdevice != NULL) + { + result = slotdevice->read_c0nx(space, offset&0xf); + } + break; + case 0xD0: case 0xD1: case 0xD2: case 0xD3: case 0xD4: case 0xD5: case 0xD6: case 0xD7: /* external drive stuff */ @@ -179,6 +224,8 @@ READ8_MEMBER(apple3_state::apple3_c0xx_r) WRITE8_MEMBER(apple3_state::apple3_c0xx_w) { + device_a2bus_card_interface *slotdevice; + switch(offset) { case 0x10: case 0x11: case 0x12: case 0x13: @@ -212,6 +259,50 @@ WRITE8_MEMBER(apple3_state::apple3_c0xx_w) m_flags &= ~(1 << ((offset - 0x50) / 2)); break; + case 0x90: case 0x91: case 0x92: case 0x93: + case 0x94: case 0x95: case 0x96: case 0x97: + case 0x98: case 0x99: case 0x9a: case 0x9b: + case 0x9c: case 0x9d: case 0x9e: case 0x9f: + slotdevice = m_a2bus->get_a2bus_card(1); + if (slotdevice != NULL) + { + slotdevice->write_c0nx(space, offset&0xf, data); + } + break; + + case 0xa0: case 0xa1: case 0xa2: case 0xa3: + case 0xa4: case 0xa5: case 0xa6: case 0xa7: + case 0xa8: case 0xa9: case 0xaa: case 0xab: + case 0xac: case 0xad: case 0xae: case 0xaf: + slotdevice = m_a2bus->get_a2bus_card(2); + if (slotdevice != NULL) + { + slotdevice->write_c0nx(space, offset&0xf, data); + } + break; + + case 0xb0: case 0xb1: case 0xb2: case 0xb3: + case 0xb4: case 0xb5: case 0xb6: case 0xb7: + case 0xb8: case 0xb9: case 0xba: case 0xbb: + case 0xbc: case 0xbd: case 0xbe: case 0xbf: + slotdevice = m_a2bus->get_a2bus_card(3); + if (slotdevice != NULL) + { + slotdevice->write_c0nx(space, offset&0xf, data); + } + break; + + case 0xc0: case 0xc1: case 0xc2: case 0xc3: + case 0xc4: case 0xc5: case 0xc6: case 0xc7: + case 0xc8: case 0xc9: case 0xca: case 0xcb: + case 0xcc: case 0xcd: case 0xce: case 0xcf: + slotdevice = m_a2bus->get_a2bus_card(4); + if (slotdevice != NULL) + { + slotdevice->write_c0nx(space, offset&0xf, data); + } + break; + case 0xD0: case 0xD1: case 0xD2: case 0xD3: case 0xD4: case 0xD5: case 0xD6: case 0xD7: /* external drive stuff */ @@ -444,6 +535,7 @@ MACHINE_RESET_MEMBER(apple3_state,apple3) m_strobe = 0; m_lastchar = 0x0d; m_rom_has_been_disabled = false; + m_cnxx_slot = -1; } @@ -603,6 +695,32 @@ DRIVER_INIT_MEMBER(apple3_state,apple3) m_via_1->write_pb7(1); apple3_update_memory(); + + save_item(NAME(m_via_0_a)); + save_item(NAME(m_via_0_b)); + save_item(NAME(m_via_1_a)); + save_item(NAME(m_via_1_b)); + save_item(NAME(m_via_0_irq)); + save_item(NAME(m_via_1_irq)); + save_item(NAME(m_zpa)); + save_item(NAME(m_last_n)); + save_item(NAME(m_sync)); + save_item(NAME(m_rom_has_been_disabled)); + save_item(NAME(m_indir_opcode)); + save_item(NAME(m_indir_count)); + save_item(NAME(m_cnxx_slot)); + save_item(NAME(m_speaker_state)); + save_item(NAME(m_c040_time)); + save_item(NAME(m_lastchar)); + save_item(NAME(m_strobe)); + save_item(NAME(m_transchar)); + + machine().save().register_postload(save_prepost_delegate(FUNC(apple3_state::apple3_postload), this)); +} + +void apple3_state::apple3_postload() +{ + apple3_update_memory(); } READ8_MEMBER(apple3_state::apple3_memory_r) @@ -665,6 +783,21 @@ READ8_MEMBER(apple3_state::apple3_memory_r) { rv = m_bank9[offset - 0xc100]; } + else + { + /* now identify the device */ + device_a2bus_card_interface *slotdevice = m_a2bus->get_a2bus_card((offset>>8) & 0x7); + + if (slotdevice != NULL) + { + if (slotdevice->take_c800()) + { + m_cnxx_slot = ((offset>>8) & 7); + } + + return slotdevice->read_cnxx(space, offset&0xff); + } + } } else if (offset < 0xc800) { @@ -676,6 +809,23 @@ READ8_MEMBER(apple3_state::apple3_memory_r) { rv = m_bank11[offset - 0xc800]; } + else + { + if (offset == 0xcfff) + { + m_cnxx_slot = -1; + } + + if (m_cnxx_slot != -1) + { + device_a2bus_card_interface *slotdevice = m_a2bus->get_a2bus_card(m_cnxx_slot); + + if (slotdevice != NULL) + { + rv = slotdevice->read_c800(space, offset&0x7ff); + } + } + } } else if (offset < 0xf000) { @@ -782,6 +932,21 @@ WRITE8_MEMBER(apple3_state::apple3_memory_w) m_bank9[offset - 0xc100] = data; } } + else + { + /* now identify the device */ + device_a2bus_card_interface *slotdevice = m_a2bus->get_a2bus_card((offset>>8) & 0x7); + + if (slotdevice != NULL) + { + if (slotdevice->take_c800()) + { + m_cnxx_slot = ((offset>>8) & 7); + } + + slotdevice->write_cnxx(space, offset&0xff, data); + } + } } else if (offset < 0xc800) { @@ -799,6 +964,23 @@ WRITE8_MEMBER(apple3_state::apple3_memory_w) m_bank11[offset - 0xc800] = data; } } + else + { + if (offset == 0xcfff) + { + m_cnxx_slot = -1; + } + + if (m_cnxx_slot != -1) + { + device_a2bus_card_interface *slotdevice = m_a2bus->get_a2bus_card(m_cnxx_slot); + + if (slotdevice != NULL) + { + slotdevice->write_c800(space, offset&0x7ff, data); + } + } + } } else if (offset < 0xf000) {