Skip to content

Commit

Permalink
New machines promoted to WORKING
Browse files Browse the repository at this point in the history
- Apple IIc Plus [R. Belmont, M. Guidero, Leon Bottou]

Only the first 3.5" drive works right now and there are no 5.25" drives and no accelerator yet.
  • Loading branch information
rb6502 committed Jul 28, 2018
1 parent 3dc8ca2 commit 31aaae7
Show file tree
Hide file tree
Showing 2 changed files with 152 additions and 38 deletions.
3 changes: 2 additions & 1 deletion src/devices/machine/applefdc.h
Expand Up @@ -72,6 +72,8 @@ class applefdc_base_device : public device_t
// accessor
uint8_t get_lines();

virtual void device_reset() override;

protected:
enum applefdc_t
{
Expand All @@ -85,7 +87,6 @@ class applefdc_base_device : public device_t

// device-level overrides
virtual void device_start() override;
virtual void device_reset() override;
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;

// other protecteds
Expand Down
187 changes: 150 additions & 37 deletions src/mame/drivers/apple2e.cpp
Expand Up @@ -171,7 +171,7 @@ Address bus A0-A11 is Y0-Y11
#define A2_UPPERBANK_TAG "inhbank"
#define IIC_ACIA1_TAG "acia1"
#define IIC_ACIA2_TAG "acia2"
#define IICP_IWM_TAG "iwm"
#define IICP_IWM_TAG "fdc"
#define LASER128_UDC_TAG "l128udc"
#define PRINTER_PORT_TAG "printer"
#define MODEM_PORT_TAG "modem"
Expand Down Expand Up @@ -393,6 +393,9 @@ class apple2e_state : public driver_device
void r2000bank_map(address_map &map);
void r4000bank_map(address_map &map);
void spectred_keyb_map(address_map &map);

bool m_35sel, m_hdsel, m_intdrive;

private:
int m_speaker_state;
int m_cassette_state, m_cassette_out;
Expand Down Expand Up @@ -435,6 +438,9 @@ class apple2e_state : public driver_device
uint8_t m_migram[0x800];
uint16_t m_migpage;

bool m_zipunlocked;
int m_zipstage;

uint8_t *m_ram_ptr, *m_rom_ptr, *m_cec_ptr;
int m_ram_size;

Expand Down Expand Up @@ -486,21 +492,36 @@ class apple2e_state : public driver_device

uint8_t apple2e_state::mig_r(uint16_t offset)
{
//printf("mig_r @ %x\n", offset + 0xc00);
// MIG RAM window
if (offset < 0x20)
if ((offset >= 0x200) && (offset < 0x220))
{
return m_migram[m_migpage + offset];
}

// increment MIG RAM window
if (offset == 0x20)
// increment MIG RAM window and return previous value
if ((offset >= 0x220) && (offset < 0x240))
{
uint8_t rv = m_migram[m_migpage + offset];
m_migpage += 0x20;
m_migpage &= 0x7ff; // make sure we wrap
m_migpage &= 0x7ff;
return rv;
}

if ((offset >= 0x240) && (offset < 0x260))
{
m_hdsel = false;
sony_set_sel_line(m_iicpiwm, 0);
}

if ((offset >= 0x260) && (offset < 0x280))
{
m_hdsel = true;
sony_set_sel_line(m_iicpiwm, 0x80);
}

// reset MIG RAM window
if (offset == 0xa0)
if (offset == 0x2a0)
{
m_migpage = 0;
}
Expand All @@ -510,22 +531,58 @@ uint8_t apple2e_state::mig_r(uint16_t offset)

void apple2e_state::mig_w(uint16_t offset, uint8_t data)
{
//printf("mig_w %x @ %x\n", data, offset + 0xc00);

if (offset == 0x40)
{
m_iicpiwm->device_reset();
return;
}

if ((offset >= 0x80) && (offset < 0xa0))
{
//printf("MIG: enable internal drive on d2\n");
m_intdrive = true;
return;
}

if ((offset >= 0xc0) && (offset < 0xe0))
{
//printf("MIG: disable internal drive\n");
m_intdrive = false;
return;
}

// MIG RAM window
if (offset < 0x20)
if ((offset >= 0x200) && (offset < 0x220))
{
m_migram[m_migpage + offset] = data;
return;
}

// increment MIG RAM window
if (offset == 0x20)
// increment MIG RAM window, but write value at old location first
if ((offset >= 0x220) && (offset < 0x240))
{
m_migram[m_migpage + offset] = data;
m_migpage += 0x20;
m_migpage &= 0x7ff; // make sure we wrap
return;
}

if ((offset >= 0x240) && (offset < 0x260))
{
m_35sel = false;
return;
}

if ((offset >= 0x260) && (offset < 0x280))
{
m_35sel = true;
return;
}

// reset MIG RAM window
if (offset == 0xa0)
if (offset == 0x2a0)
{
m_migpage = 0;
}
Expand Down Expand Up @@ -853,6 +910,11 @@ void apple2e_state::machine_start()
save_item(NAME(m_mockingboard4c));
save_item(NAME(m_intc8rom));
save_item(NAME(m_cec_bank));
save_item(NAME(m_35sel));
save_item(NAME(m_hdsel));
save_item(NAME(m_intdrive));
save_item(NAME(m_zipunlocked));
save_item(NAME(m_zipstage));
}

void apple2e_state::machine_reset()
Expand All @@ -875,6 +937,8 @@ void apple2e_state::machine_reset()
m_mockingboard4c = false;
m_intc8rom = false;
m_cec_bank = 0;
m_zipunlocked = false;
m_zipstage = 0;

// IIe prefers INTCXROM default to off, IIc has it always on
if (m_rom_ptr[0x3bc0] == 0x00)
Expand Down Expand Up @@ -1391,6 +1455,14 @@ void apple2e_state::do_io(address_space &space, int offset, bool is_iic)
m_romswitch = !m_romswitch;
update_slotrom_banks();

// MIG is reset when ROMSWITCH turns off
if ((m_isiicplus) && !(m_romswitch))
{
m_migpage = 0;
m_intdrive = false;
m_35sel = false;
}

// if LC is not enabled
if (!m_lcram)
{
Expand Down Expand Up @@ -1986,6 +2058,34 @@ WRITE8_MEMBER(apple2e_state::c000_iic_w)
m_strobe = 0;
break;

case 0x5a: // IIC+ accelerator unlock
if (m_isiicplus)
{
if (data == 0x5a)
{
m_zipstage++;
if (m_zipstage == 4)
{
m_zipunlocked = true;
}
}
else if (data == 0xa5)
{
// put settings into effect and lock
m_zipunlocked = false;
m_zipstage = 0;
}
else
{
// disable acceleration and lock
m_zipunlocked = false;
m_zipstage = 0;
}
}
break;

case 0x5b:

case 0x78:
case 0x79:
m_vbl = false;
Expand Down Expand Up @@ -2113,6 +2213,11 @@ READ8_MEMBER(apple2e_state::c080_r)
}
else
{
if ((m_isiicplus) && (slot == 6))
{
return m_iicpiwm->read(offset % 0x10);
}

if (m_slotdevice[slot] != nullptr)
{
return m_slotdevice[slot]->read_c0nx(offset % 0x10);
Expand Down Expand Up @@ -2143,6 +2248,12 @@ WRITE8_MEMBER(apple2e_state::c080_w)
}
else
{
if ((m_isiicplus) && (slot == 6))
{
m_iicpiwm->write(offset % 0x10, data);
return;
}

if (m_slotdevice[slot] != nullptr)
{
m_slotdevice[slot]->write_c0nx(offset % 0x10, data);
Expand Down Expand Up @@ -2291,11 +2402,6 @@ READ8_MEMBER(apple2e_state::c400_cec_bank_r) { return m_rom_ptr[0x4400 + offset

READ8_MEMBER(apple2e_state::c800_r)
{
if ((m_isiicplus) && (m_romswitch) && (offset >= 0x600) && (offset < 0x700))
{
return mig_r(offset-0x600);
}

if ((offset == 0x7ff) && !machine().side_effects_disabled())
{
m_cnxx_slot = CNXX_UNCLAIMED;
Expand All @@ -2313,11 +2419,6 @@ READ8_MEMBER(apple2e_state::c800_r)

READ8_MEMBER(apple2e_state::c800_int_r)
{
if ((m_isiicplus) && (m_romswitch) && (offset >= 0x600) && (offset < 0x700))
{
return mig_r(offset-0x600);
}

if ((offset == 0x7ff) && !machine().side_effects_disabled())
{
m_cnxx_slot = CNXX_UNCLAIMED;
Expand All @@ -2335,9 +2436,9 @@ READ8_MEMBER(apple2e_state::c800_int_r)

READ8_MEMBER(apple2e_state::c800_b2_int_r)
{
if ((m_isiicplus) && (m_romswitch) && (offset >= 0x600) && (offset < 0x700))
if ((m_isiicplus) && (m_romswitch) && (((offset >= 0x400) && (offset < 0x500)) || ((offset >= 0x600) && (offset < 0x700))))
{
return mig_r(offset-0x600);
return mig_r(offset-0x400);
}

if ((offset == 0x7ff) && !machine().side_effects_disabled())
Expand All @@ -2352,9 +2453,9 @@ READ8_MEMBER(apple2e_state::c800_b2_int_r)

WRITE8_MEMBER(apple2e_state::c800_w)
{
if ((m_isiicplus) && (m_romswitch) && (offset >= 0x600) && (offset < 0x700))
if ((m_isiicplus) && (m_romswitch) && (((offset >= 0x400) && (offset < 0x500)) || ((offset >= 0x600) && (offset < 0x700))))
{
mig_w(offset-0x600, data);
mig_w(offset-0x400, data);
return;
}

Expand Down Expand Up @@ -2400,22 +2501,11 @@ WRITE8_MEMBER(apple2e_state::inh_w)

READ8_MEMBER(apple2e_state::lc_romswitch_r)
{
if ((offset >= 0xc00) && (offset < 0xd00))
{
return mig_r(offset-0xc00);
}

return m_rom_ptr[0x5000 + offset];
}

WRITE8_MEMBER(apple2e_state::lc_romswitch_w)
{
if ((offset >= 0xc00) && (offset < 0xd00))
{
mig_w(offset-0xc00, data);
return;
}

lc_w(space, offset, data);
}

Expand Down Expand Up @@ -4126,10 +4216,26 @@ MACHINE_CONFIG_START(apple2e_state::apple2c)
MCFG_RAM_EXTRA_OPTIONS("128K")
MACHINE_CONFIG_END

static void apple2cp_set_enable_lines(device_t *device,int enable_mask)
{
apple2e_state *state = device->machine().driver_data<apple2e_state>();

// printf("set_enable_lines: 35sel %d int %d enable_mask %d\n", state->m_35sel, state->m_intdrive, enable_mask);

if ((state->m_35sel) && (state->m_intdrive) && (enable_mask == 2))
{
sony_set_enable_lines(device, 1);
}
else
{
sony_set_enable_lines(device, 0);
}
}

const applefdc_interface a2cp_interface =
{
sony_set_lines, /* set_lines */
sony_set_enable_lines, /* set_enable_lines */
apple2cp_set_enable_lines, /* set_enable_lines */

sony_read_data, /* read_data */
sony_write_data, /* write_data */
Expand All @@ -4145,10 +4251,17 @@ static const floppy_interface apple2cp_floppy35_floppy_interface =

MACHINE_CONFIG_START(apple2e_state::apple2cp)
apple2c(config);
MCFG_DEVICE_REPLACE("maincpu", M65C02, 1021800) /* close to actual CPU frequency of 1.020484 MHz */
MCFG_DEVICE_PROGRAM_MAP(apple2c_memexp_map)

MCFG_DEVICE_REMOVE("sl4")
MCFG_DEVICE_REMOVE("sl6")
MCFG_IWM_ADD(IICP_IWM_TAG, a2cp_interface)
MCFG_LEGACY_FLOPPY_SONY_2_DRIVES_ADD(apple2cp_floppy35_floppy_interface)

MCFG_RAM_MODIFY(RAM_TAG)
MCFG_RAM_DEFAULT_SIZE("128K")
MCFG_RAM_EXTRA_OPTIONS("128K, 384K, 640K, 896K, 1152K")
MACHINE_CONFIG_END

MACHINE_CONFIG_START(apple2e_state::apple2c_iwm)
Expand Down Expand Up @@ -4553,4 +4666,4 @@ COMP( 1985, apple2c0, apple2c, 0, apple2c_iwm, apple2c, apple2e_state,
COMP( 1986, apple2c3, apple2c, 0, apple2c_mem, apple2c, apple2e_state, empty_init, "Apple Computer", "Apple //c (Original Memory Expansion)", MACHINE_SUPPORTS_SAVE )
COMP( 1986, apple2c4, apple2c, 0, apple2c_mem, apple2c, apple2e_state, empty_init, "Apple Computer", "Apple //c (rev 4)", MACHINE_SUPPORTS_SAVE )
COMP( 1987, ceci, 0, apple2, ceci, ceci, apple2e_state, empty_init, "Shaanxi Province Computer Factory", "China Education Computer I", MACHINE_SUPPORTS_SAVE )
COMP( 1988, apple2cp, apple2c, 0, apple2cp, apple2c, apple2e_state, empty_init, "Apple Computer", "Apple //c Plus", MACHINE_NOT_WORKING | MACHINE_SUPPORTS_SAVE )
COMP( 1988, apple2cp, apple2c, 0, apple2cp, apple2c, apple2e_state, empty_init, "Apple Computer", "Apple //c Plus", MACHINE_SUPPORTS_SAVE )

0 comments on commit 31aaae7

Please sign in to comment.