(MESS) apple3: now using the cycle-accurate floppy emulation. [R. Belmont]

This commit is contained in:
R. Belmont 2014-07-04 01:44:26 +00:00
parent dee629429b
commit 13a2f1ec0b
5 changed files with 48 additions and 109 deletions

View File

@ -341,14 +341,14 @@ UINT64 wozfdc_device::time_to_cycles(const attotime &tm)
// Clock is falling edges of the ~2Mhz clock
// The 1021800 must be the controlling 6502's speed
UINT64 cycles = tm.as_ticks(1021800*2*2);
UINT64 cycles = tm.as_ticks(clock()*2);
cycles = (cycles+1) >> 1;
return cycles;
}
attotime wozfdc_device::cycles_to_time(UINT64 cycles)
{
return attotime::from_ticks(cycles*2+1, 1021800*2*2);
return attotime::from_ticks(cycles*2+1, clock()*2);
}
void wozfdc_device::lss_start()

View File

@ -612,6 +612,8 @@ bool a2_16sect_format::load(io_generic *io, UINT32 form_factor, floppy_image *im
int offset = 0;
static const unsigned char pascal_block1[4] = { 0x08, 0xa5, 0x0f, 0x29 };
static const unsigned char dos33_block1[4] = { 0xa2, 0x02, 0x8e, 0x52 };
static const unsigned char sos_block1[4] = { 0xc9, 0x20, 0xf0, 0x3e };
static const unsigned char a3a2emul_block1[6] = { 0x8d, 0xd0, 0x03, 0x4c, 0xc7, 0xa4 };
io_generic_read(io, sector_data, fpos, 256*16);
@ -621,11 +623,20 @@ bool a2_16sect_format::load(io_generic *io, UINT32 form_factor, floppy_image *im
if (!memcmp("PRODOS", &sector_data[0x103], 6))
{
m_prodos_order = true;
} // check SOS boot block
else if (!memcmp("SOS BOOT", &sector_data[0x3], 8))
} // check for ProDOS order SOS disk
else if (!memcmp(sos_block1, &sector_data[0x100], 4))
{
m_prodos_order = true;
} // check Apple II Pascal
} // check for Apple III A2 emulator disk in ProDOS order
else if (!memcmp(a3a2emul_block1, &sector_data[0x100], 6))
{
m_prodos_order = true;
} // check for PCPI Applicard software in ProDOS order
else if (!memcmp("COPYRIGHT (C) 1979, DIGITAL RESEARCH", &sector_data[0x118], 36))
{
printf("PCPI detected\n");
m_prodos_order = true;
} // check Apple II Pascal
else if (!memcmp("SYSTEM.APPLE", &sector_data[0xd7], 12))
{
// Pascal discs can still be DOS order.
@ -795,7 +806,6 @@ bool a2_16sect_format::save(io_generic *io, floppy_image *image)
hb = 0;
if(hb == 4) {
printf("hb = 4\n");
UINT8 h[11];
for(int i=0; i<11; i++)
h[i] = gb(buf, ts, pos, wrap);

View File

@ -18,9 +18,7 @@
#include "bus/rs232/rs232.h"
#include "includes/apple3.h"
#include "includes/apple2.h"
#include "imagedev/flopdrv.h"
#include "formats/ap2_dsk.h"
#include "machine/appldriv.h"
#include "bus/a2bus/a2cffa.h"
#include "bus/a2bus/a2applicard.h"
@ -29,18 +27,18 @@ 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
static const floppy_interface apple3_floppy_interface =
{
FLOPPY_STANDARD_5_25_DSHD,
LEGACY_FLOPPY_OPTIONS_NAME(apple2),
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("applicard", A2BUS_APPLICARD) /* PCPI Applicard */
SLOT_INTERFACE_END
static SLOT_INTERFACE_START( a3_floppies )
SLOT_INTERFACE( "525", FLOPPY_525_SD )
SLOT_INTERFACE_END
FLOPPY_FORMATS_MEMBER( apple3_state::floppy_formats )
FLOPPY_A216S_FORMAT, FLOPPY_RWTS18_FORMAT
FLOPPY_FORMATS_END
static MACHINE_CONFIG_START( apple3, apple3_state )
/* basic machine hardware */
@ -94,8 +92,11 @@ static MACHINE_CONFIG_START( apple3, apple3_state )
MCFG_A2BUS_SLOT_ADD("a2bus", "sl4", apple3_cards, NULL)
/* fdc */
MCFG_APPLEFDC_ADD("fdc", apple3_fdc_interface)
MCFG_LEGACY_FLOPPY_APPLE_4_DRIVES_ADD(apple3_floppy_interface,1,4)
MCFG_DEVICE_ADD("fdc", APPLEIII_FDC, 1021800*2)
MCFG_FLOPPY_DRIVE_ADD("0", a3_floppies, "525", apple3_state::floppy_formats)
MCFG_FLOPPY_DRIVE_ADD("1", a3_floppies, "525", apple3_state::floppy_formats)
MCFG_FLOPPY_DRIVE_ADD("2", a3_floppies, "525", apple3_state::floppy_formats)
MCFG_FLOPPY_DRIVE_ADD("3", a3_floppies, "525", apple3_state::floppy_formats)
/* acia */
MCFG_DEVICE_ADD("acia", MOS6551, 0)

View File

@ -13,13 +13,15 @@
#include "includes/apple2.h"
#include "machine/ram.h"
#include "bus/a2bus/a2bus.h"
#include "machine/applefdc.h"
#include "machine/mos6551.h"
#include "machine/6522via.h"
#include "machine/kb3600.h"
#include "machine/mm58167.h"
#include "sound/speaker.h"
#include "sound/dac.h"
#include "machine/wozfdc.h"
#include "imagedev/floppy.h"
#include "formats/flopimg.h"
#define VAR_VM0 0x0001
#define VAR_VM1 0x0002
@ -56,7 +58,11 @@ public:
m_joy2x(*this, "joy_2_x"),
m_joy2y(*this, "joy_2_y"),
m_joybuttons(*this, "joy_buttons"),
m_pdltimer(*this, "pdltimer")
m_pdltimer(*this, "pdltimer"),
floppy0(*this, "0"),
floppy1(*this, "1"),
floppy2(*this, "2"),
floppy3(*this, "3")
{
}
@ -65,7 +71,7 @@ public:
required_device<via6522_device> m_via_0;
required_device<via6522_device> m_via_1;
required_device<mos6551_device> m_acia;
required_device<applefdc_base_device> m_fdc;
required_device<appleiii_fdc> m_fdc;
required_device<ay3600_device> m_ay3600;
required_device<a2bus_device> m_a2bus;
required_device<mm58167_device> m_rtc;
@ -75,6 +81,10 @@ public:
required_device<palette_device> m_palette;
required_ioport m_joy1x, m_joy1y, m_joy2x, m_joy2y, m_joybuttons;
required_device<timer_device> m_pdltimer;
required_device<floppy_connector> floppy0;
required_device<floppy_connector> floppy1;
required_device<floppy_connector> floppy2;
required_device<floppy_connector> floppy3;
DECLARE_READ8_MEMBER(apple3_memory_r);
DECLARE_WRITE8_MEMBER(apple3_memory_w);
@ -117,6 +127,7 @@ public:
void apple3_postload();
TIMER_DEVICE_CALLBACK_MEMBER(paddle_timer);
void pdl_handler(int offset);
DECLARE_FLOPPY_FORMATS( floppy_formats );
// these need to be public for now
UINT32 m_flags;
@ -153,9 +164,4 @@ private:
int m_pdl_charge;
};
/*----------- defined in machine/apple3.c -----------*/
extern const applefdc_interface apple3_fdc_interface;
#endif /* APPLE3_H_ */

View File

@ -45,10 +45,6 @@
#include "emu.h"
#include "includes/apple3.h"
#include "includes/apple2.h"
#include "machine/applefdc.h"
#include "machine/appldriv.h"
static void apple3_update_drives(device_t *device);
#define LOG_MEMORY 1
#define LOG_INDXADDR 1
@ -240,11 +236,7 @@ READ8_MEMBER(apple3_state::apple3_c0xx_r)
case 0xD0: case 0xD1: case 0xD2: case 0xD3:
case 0xD4: case 0xD5: case 0xD6: case 0xD7:
/* external drive stuff */
if (offset & 1)
m_flags |= VAR_EXTA0 << ((offset - 0xD0) / 2);
else
m_flags &= ~(VAR_EXTA0 << ((offset - 0xD0) / 2));
apple3_update_drives(machine().device("fdc"));
m_fdc->read_c0dx(space, offset&0xf);
result = 0x00;
break;
@ -256,7 +248,7 @@ READ8_MEMBER(apple3_state::apple3_c0xx_r)
case 0xE4: case 0xE5: case 0xE6: case 0xE7:
case 0xE8: case 0xE9: case 0xEA: case 0xEB:
case 0xEC: case 0xED: case 0xEE: case 0xEF:
result = m_fdc->read(offset);
result = m_fdc->read(space, offset&0xf);
break;
case 0xF0:
@ -381,11 +373,7 @@ WRITE8_MEMBER(apple3_state::apple3_c0xx_w)
case 0xD0: case 0xD1: case 0xD2: case 0xD3:
case 0xD4: case 0xD5: case 0xD6: case 0xD7:
/* external drive stuff */
if (offset & 1)
m_flags |= VAR_EXTA0 << ((offset - 0xD0) / 2);
else
m_flags &= ~(VAR_EXTA0 << ((offset - 0xD0) / 2));
apple3_update_drives(machine().device("fdc"));
m_fdc->write_c0dx(space, offset&0xf, data);
break;
case 0xDB:
@ -396,7 +384,7 @@ WRITE8_MEMBER(apple3_state::apple3_c0xx_w)
case 0xE4: case 0xE5: case 0xE6: case 0xE7:
case 0xE8: case 0xE9: case 0xEA: case 0xEB:
case 0xEC: case 0xED: case 0xEE: case 0xEF:
m_fdc->write(offset, data);
m_fdc->write(space, offset&0xf, data);
break;
case 0xF0:
@ -412,25 +400,6 @@ TIMER_DEVICE_CALLBACK_MEMBER(apple3_state::apple3_interrupt)
{
m_via_1->write_cb1(machine().first_screen()->vblank());
m_via_1->write_cb2(machine().first_screen()->vblank());
// check reset
if (m_kbspecial->read() & 0x80) // reset is pressed
{
// control-reset?
if (m_kbspecial->read() & 0x08)
{
m_maincpu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
m_maincpu->set_input_line(INPUT_LINE_RESET, CLEAR_LINE);
}
else // plain reset is an NMI, if it's allowed
{
if (m_via_0_a & ENV_NMIENABLE)
{
m_maincpu->set_input_line(m6502_device::NMI_LINE, ASSERT_LINE);
m_maincpu->set_input_line(m6502_device::NMI_LINE, CLEAR_LINE);
}
}
}
}
UINT8 *apple3_state::apple3_bankaddr(UINT16 bank, offs_t offset)
@ -641,6 +610,8 @@ MACHINE_RESET_MEMBER(apple3_state,apple3)
m_cnxx_slot = -1;
m_analog_sel = 0;
m_ramp_active = false;
m_fdc->set_floppies_4(floppy0, floppy1, floppy2, floppy3);
}
@ -670,58 +641,9 @@ UINT8 *apple3_state::apple3_get_indexed_addr(offs_t offset)
return result;
}
static void apple3_update_drives(device_t *device)
{
apple3_state *state = device->machine().driver_data<apple3_state>();
int enable_mask = 0x00;
if (state->m_enable_mask & 0x01)
enable_mask |= 0x01;
if (state->m_enable_mask & 0x02)
{
switch(state->m_flags & (VAR_EXTA0 | VAR_EXTA1))
{
case VAR_EXTA0:
enable_mask |= 0x02;
break;
case VAR_EXTA1:
enable_mask |= 0x04;
break;
case VAR_EXTA1|VAR_EXTA0:
enable_mask |= 0x08;
break;
}
}
apple525_set_enable_lines(device,enable_mask);
}
static void apple3_set_enable_lines(device_t *device,int enable_mask)
{
apple3_state *state = device->machine().driver_data<apple3_state>();
state->m_enable_mask = enable_mask;
apple3_update_drives(device);
}
const applefdc_interface apple3_fdc_interface =
{
apple525_set_lines,
apple3_set_enable_lines,
apple525_read_data,
apple525_write_data
};
DRIVER_INIT_MEMBER(apple3_state,apple3)
{
m_enable_mask = 0;
apple3_update_drives(machine().device("fdc"));
m_flags = 0;
m_acia_irq = 0;