diff options
author | arbee <rb6502@users.noreply.github.com> | 2022-09-24 20:18:35 -0400 |
---|---|---|
committer | arbee <rb6502@users.noreply.github.com> | 2022-09-24 20:18:35 -0400 |
commit | 1651ed37c07de8659f9676b344ae52cb9fd222de (patch) | |
tree | 152a6ab2981ac8987bb8da9b019e9e807116d40d /src/devices/machine | |
parent | 7da65f10992f9bde8f83302cb4b6b8f006f77e58 (diff) |
apple2: final removal of Apple II support for the legacy floppy system. [R. Belmont]
Diffstat (limited to 'src/devices/machine')
-rw-r--r-- | src/devices/machine/appldriv.cpp | 336 | ||||
-rw-r--r-- | src/devices/machine/appldriv.h | 71 | ||||
-rw-r--r-- | src/devices/machine/applefdc.cpp | 566 | ||||
-rw-r--r-- | src/devices/machine/applefdc.h | 152 |
4 files changed, 0 insertions, 1125 deletions
diff --git a/src/devices/machine/appldriv.cpp b/src/devices/machine/appldriv.cpp deleted file mode 100644 index 194b8ccdc23..00000000000 --- a/src/devices/machine/appldriv.cpp +++ /dev/null @@ -1,336 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:R. Belmont -/********************************************************************* - - appldriv.c - - Apple 5.25" floppy drive emulation (to be interfaced with applefdc.c) - -*********************************************************************/ -#include "emu.h" -#include "appldriv.h" -#include "imagedev/flopdrv.h" -#include "formats/ap2_dsk.h" - -// our parent's device is the Disk II card (Apple II) or main driver (Mac, IIgs) -// either way, get the drive from there. -#define PARENT_FLOPPY_0 "^floppy0" -#define PARENT_FLOPPY_1 "^floppy1" -#define PARENT_FLOPPY_2 "^floppy2" -#define PARENT_FLOPPY_3 "^floppy3" - -static inline apple525_floppy_image_device *get_device(device_t *device) -{ - assert(device != nullptr); - assert(device->type() == FLOPPY_APPLE); - - return downcast<apple525_floppy_image_device *>(device); -} - -static int apple525_enable_mask = 1; - -legacy_floppy_image_device *apple525_get_subdevice(device_t *device, int drive) -{ - switch(drive) { - case 0 : return device->subdevice<legacy_floppy_image_device>(PARENT_FLOPPY_0); - case 1 : return device->subdevice<legacy_floppy_image_device>(PARENT_FLOPPY_1); - case 2 : return device->subdevice<legacy_floppy_image_device>(PARENT_FLOPPY_2); - case 3 : return device->subdevice<legacy_floppy_image_device>(PARENT_FLOPPY_3); - } - return nullptr; -} - -device_t *apple525_get_device_by_type(device_t *device, int ftype, int drive) -{ - int i; - int cnt = 0; - for (i=0;i<4;i++) { - legacy_floppy_image_device *disk = apple525_get_subdevice(device, i); - if (disk->floppy_get_drive_type()==ftype) { - if (cnt==drive) { - return disk; - } - cnt++; - } - } - return nullptr; -} - -void apple525_set_enable_lines(device_t *device, int enable_mask) -{ - apple525_enable_mask = enable_mask; -} - -/* ----------------------------------------------------------------------- */ - -static void apple525_load_current_track(device_t *image) -{ - int len; - apple525_floppy_image_device *disk; - - disk = get_device(image); - len = sizeof(disk->track_data); - - disk->floppy_drive_read_track_data_info_buffer(0, disk->track_data, &len); - disk->track_loaded = 1; - disk->track_dirty = 0; -} - -static void apple525_save_current_track(device_t *image, int unload) -{ - int len; - apple525_floppy_image_device *disk; - - disk = get_device(image); - - if (disk->track_dirty) - { - len = sizeof(disk->track_data); - disk->floppy_drive_write_track_data_info_buffer(0, disk->track_data, &len); - disk->track_dirty = 0; - } - if (unload) - disk->track_loaded = 0; -} - -static void apple525_seek_disk(apple525_floppy_image_device *img, signed int step) -{ - int track; - int pseudo_track; - apple525_floppy_image_device *disk; - - disk = get_device(img); - - apple525_save_current_track(img, false); - - track = img->floppy_drive_get_current_track(); - pseudo_track = (track * 2) + disk->tween_tracks; - - pseudo_track += step; - if (pseudo_track < 0) - pseudo_track = 0; - else if (pseudo_track/2 >= APPLE2_TRACK_COUNT) - pseudo_track = APPLE2_TRACK_COUNT*2-1; - - if (pseudo_track/2 != track) - { - img->floppy_drive_seek(pseudo_track/2 - img->floppy_drive_get_current_track()); - disk->track_loaded = 0; - } - - if (pseudo_track & 1) - disk->tween_tracks = 1; - else - disk->tween_tracks = 0; -} - -static void apple525_disk_set_lines(device_t *device,device_t *image, uint8_t new_state) -{ - apple525_floppy_image_device *cur_disk; - uint8_t old_state; - unsigned int phase; - - cur_disk = get_device(image); - - old_state = cur_disk->state; - cur_disk->state = new_state; - - if ((new_state & 0x0F) > (old_state & 0x0F)) - { - phase = 0; - switch((old_state ^ new_state) & 0x0F) - { - case 1: phase = 0; break; - case 2: phase = 1; break; - case 4: phase = 2; break; - case 8: phase = 3; break; - } - - phase -= cur_disk->floppy_drive_get_current_track() * 2; - if (cur_disk->tween_tracks) - phase--; - phase %= 4; - - switch(phase) - { - case 1: - apple525_seek_disk(cur_disk, +1); - break; - case 3: - apple525_seek_disk(cur_disk, -1); - break; - } - } -} - -int apple525_get_count(device_t *device) -{ - int cnt = 0; - if ((device->subdevice("^" FLOPPY_0)!=nullptr) && (device->subdevice<legacy_floppy_image_device>("^" FLOPPY_0)->floppy_get_drive_type() == FLOPPY_TYPE_APPLE) && (get_device(device->subdevice(PARENT_FLOPPY_0))!=nullptr)) cnt++; - if ((device->subdevice("^" FLOPPY_1)!=nullptr) && (device->subdevice<legacy_floppy_image_device>("^" FLOPPY_1)->floppy_get_drive_type() == FLOPPY_TYPE_APPLE) && (get_device(device->subdevice(PARENT_FLOPPY_1))!=nullptr)) cnt++; - if ((device->subdevice("^" FLOPPY_2)!=nullptr) && (device->subdevice<legacy_floppy_image_device>("^" FLOPPY_2)->floppy_get_drive_type() == FLOPPY_TYPE_APPLE) && (get_device(device->subdevice(PARENT_FLOPPY_2))!=nullptr)) cnt++; - if ((device->subdevice("^" FLOPPY_3)!=nullptr) && (device->subdevice<legacy_floppy_image_device>("^" FLOPPY_3)->floppy_get_drive_type() == FLOPPY_TYPE_APPLE) && (get_device(device->subdevice(PARENT_FLOPPY_3))!=nullptr)) cnt++; - - return cnt; -} - -void apple525_set_lines(device_t *device, uint8_t lines) -{ - int i, count; - device_t *image; - - count = apple525_get_count(device); - for (i = 0; i < count; i++) - { - if (apple525_enable_mask & (1 << i)) - { - image = apple525_get_device_by_type(device, FLOPPY_TYPE_APPLE, i); - if (image) - apple525_disk_set_lines(device,image, lines); - } - } -} - -/* reads/writes a byte; write_value is -1 for read only */ -static uint8_t apple525_process_byte(device_t *img, int write_value) -{ - uint8_t read_value; - apple525_floppy_image_device *disk; - int spinfract_divisor; - int spinfract_dividend; - apple525_floppy_image_device *config = get_device(img); - device_image_interface *image = dynamic_cast<device_image_interface *>(img); - - disk = get_device(img); - spinfract_dividend = config->get_dividend(); - spinfract_divisor = config->get_divisor(); - - /* no image initialized for that drive ? */ - if (!image->exists()) - return 0xFF; - - /* check the spin count if reading*/ - if (write_value < 0) - { - disk->spin_count++; - disk->spin_count %= spinfract_divisor; - if (disk->spin_count >= spinfract_dividend) - return 0x00; - } - - /* load track if need be */ - if (disk->track_loaded == 0) - apple525_load_current_track(img); - - /* perform the read */ - read_value = disk->track_data[disk->position]; - - /* perform the write, if applicable */ - if (write_value >= 0) - { - disk->track_data[disk->position] = write_value; - disk->track_dirty = 1; - } - - disk->position++; - disk->position %= std::size(disk->track_data); - - /* when writing; save the current track after every full sector write */ - if ((write_value >= 0) && ((disk->position % APPLE2_NIBBLE_SIZE) == 0)) - apple525_save_current_track(img, false); - - return read_value; -} - -static device_t *apple525_selected_image(device_t *device) -{ - int i,count; - - count = apple525_get_count(device); - - for (i = 0; i < count; i++) - { - if (apple525_enable_mask & (1 << i)) - return apple525_get_device_by_type(device, FLOPPY_TYPE_APPLE, i); - } - return nullptr; -} - -uint8_t apple525_read_data(device_t *device) -{ - device_t *image; - image = apple525_selected_image(device); - return image ? apple525_process_byte(image, -1) : 0xFF; -} - -void apple525_write_data(device_t *device,uint8_t data) -{ - device_t *image; - image = apple525_selected_image(device); - if (image) - apple525_process_byte(image, data); -} - -int apple525_read_status(device_t *device) -{ - int i, count, result = 0; - device_image_interface *image; - - count = apple525_get_count(device); - - for (i = 0; i < count; i++) - { - if (apple525_enable_mask & (1 << i)) - { - image = dynamic_cast<device_image_interface *>(apple525_get_device_by_type(device, FLOPPY_TYPE_APPLE, i)); - if (image && image->is_readonly()) - result = 1; - } - } - return result; -} - -// device type definition -DEFINE_DEVICE_TYPE(FLOPPY_APPLE, apple525_floppy_image_device, "floppy_apple", "Apple Disk II") - -//------------------------------------------------- -// apple525_floppy_image_device - constructor -//------------------------------------------------- - -apple525_floppy_image_device::apple525_floppy_image_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : legacy_floppy_image_device(mconfig, FLOPPY_APPLE, tag, owner, clock) -{ -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void apple525_floppy_image_device::device_start() -{ - legacy_floppy_image_device::device_start(); - floppy_set_type(FLOPPY_TYPE_APPLE); - - state = 0; - tween_tracks = 0; - track_loaded = 0; - track_dirty = 0; - position = 0; - spin_count = 0; - memset(track_data, 0, sizeof(track_data)); -} - -image_init_result apple525_floppy_image_device::call_load() -{ - image_init_result result = legacy_floppy_image_device::call_load(); - floppy_drive_seek(-999); - floppy_drive_seek(+35/2); - return result; -} - -void apple525_floppy_image_device::call_unload() -{ - apple525_save_current_track(this, true); - - legacy_floppy_image_device::call_unload(); -} diff --git a/src/devices/machine/appldriv.h b/src/devices/machine/appldriv.h deleted file mode 100644 index 86f7c1658bf..00000000000 --- a/src/devices/machine/appldriv.h +++ /dev/null @@ -1,71 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:R. Belmont -/********************************************************************* - - appldriv.h - - Apple 5.25" floppy drive emulation (to be interfaced with applefdc.c) - -*********************************************************************/ - -#ifndef MAME_MACHINE_APPLDRIV_H -#define MAME_MACHINE_APPLDRIV_H - -#pragma once - -#include "imagedev/flopdrv.h" -#include "formats/ap2_dsk.h" - -#define FLOPPY_0 "floppy0" -#define FLOPPY_1 "floppy1" -#define FLOPPY_2 "floppy2" -#define FLOPPY_3 "floppy3" - -void apple525_set_lines(device_t *device, uint8_t lines); -void apple525_set_enable_lines(device_t *device, int enable_mask); - -uint8_t apple525_read_data(device_t *device); -void apple525_write_data(device_t *device, uint8_t data); -int apple525_read_status(device_t *device); -int apple525_get_count(running_machine &machine); - -class apple525_floppy_image_device : public legacy_floppy_image_device -{ -public: - // construction/destruction - apple525_floppy_image_device(const machine_config &mconfig, const char *tag, device_t *owner, const floppy_interface *config, int dividend, int divisor) - : apple525_floppy_image_device(mconfig, tag, owner, (uint32_t)0) - { - set_floppy_config(config); - set_params(dividend, divisor); - } - apple525_floppy_image_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); - - virtual image_init_result call_load() override; - virtual void call_unload() override; - void set_params(int dividend, int divisor) { m_dividend = dividend; m_divisor = divisor; } - - int get_dividend() { return m_dividend; } - int get_divisor() { return m_divisor; } - - // these elements should be private, but are not yet - unsigned int state : 4; /* bits 0-3 are the phase */ - unsigned int tween_tracks : 1; - unsigned int track_loaded : 1; - unsigned int track_dirty : 1; - int position; - int spin_count; /* simulate drive spin to fool RWTS test at $BD34 */ - uint8_t track_data[APPLE2_NIBBLE_SIZE * APPLE2_SECTOR_COUNT]; - -protected: - virtual void device_start() override; - -private: - int m_dividend; - int m_divisor; -}; - -// device type definition -DECLARE_DEVICE_TYPE(FLOPPY_APPLE, apple525_floppy_image_device) - -#endif // MAME_MACHINE_APPLDRIV_H diff --git a/src/devices/machine/applefdc.cpp b/src/devices/machine/applefdc.cpp deleted file mode 100644 index 8b6c5fec524..00000000000 --- a/src/devices/machine/applefdc.cpp +++ /dev/null @@ -1,566 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Nathan Woods, Raphael Nabet, R. Belmont -/********************************************************************* - - applefdc.c - - Implementation of various Apple Floppy Disk Controllers, including - the classic Apple controller and the IWM (Integrated Woz Machine) - chip - - The IWM chip was used as the floppy disk controller for early Macs and the - Apple IIgs, and was eventually superseded by the SWIM chp. - - Nate Woods - Raphael Nabet - - Writing this code would not be possible if it weren't for the work of the - XGS and KEGS emulators which also contain IWM emulations. - - TODO - - Implement the unimplemented IWM modes - - IWM_MODE_CLOCKSPEED - - IWM_MODE_BITCELLTIME - - IWM_MODE_HANDSHAKEPROTOCOL - - IWM_MODE_LATCHMODE - - Investigate the differences between the IWM and the classic Apple II - controller more fully. It is currently unclear what are genuine - differences and what are effectively hacks that "just seem" to work. - - Figure out iwm_readenable2handshake() and iwm_enable2(); they are - hackish at best - - Support the SWIM chip - - Proper timing - - This code was originally IWM specific; we need to clean up IWMisms in - the code - - Make it faster? - - Add sound? - -*********************************************************************/ - -#include "emu.h" -#include "applefdc.h" - - -/*************************************************************************** - CONSTANTS -***************************************************************************/ - -// logging -#define LOG_APPLEFDC 0 -#define LOG_APPLEFDC_EXTRA 0 - -// mask for FDC lines -#define IWM_MOTOR 0x10 -#define IWM_DRIVE 0x20 -#define IWM_Q6 0x40 -#define IWM_Q7 0x80 - - - -/*************************************************************************** - IWM MODE - - The IWM mode has the following values: - - Bit 7 Reserved - Bit 6 Reserved - Bit 5 Reserved - Bit 4 ! Clock speed - 0=7MHz; used by Apple IIgs - 1=8MHz; used by Mac (I believe) - Bit 3 ! Bit cell time - 0=4usec/bit (used for 5.25" drives) - 1=2usec/bit (used for 3.5" drives) - Bit 2 Motor-off delay - 0=leave on for 1 sec after system turns it off - 1=turn off immediately - Bit 1 ! Handshake protocol - 0=synchronous (software supplies timing for writing data; used for 5.25" drives) - 1=asynchronous (IWM supplies timing; used for 3.5" drives) - Bit 0 ! Latch mode - 0=read data stays valid for 7usec (used for 5.25" drives) - 1=read data stays valid for full byte time (used for 3.5" drives) - - ***************************************************************************/ - -enum -{ - IWM_MODE_CLOCKSPEED = 0x10, - IWM_MODE_BITCELLTIME = 0x08, - IWM_MODE_MOTOROFFDELAY = 0x04, - IWM_MODE_HANDSHAKEPROTOCOL = 0x02, - IWM_MODE_LATCHMODE = 0x01 -}; - - - -/*************************************************************************** - BASE DEVICE -***************************************************************************/ - -//------------------------------------------------- -// ctor -//------------------------------------------------- - -applefdc_base_device::applefdc_base_device(applefdc_base_device::applefdc_t fdc_type, const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, type, tag, owner, clock), - m_type(fdc_type), - m_interface(nullptr) -{ -} - - - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void applefdc_base_device::device_start() -{ - // timer - m_motor_timer = timer_alloc(FUNC(applefdc_base_device::turn_motor_onoff), this); - - // state - m_write_byte = 0x00; - m_lines = 0x00; - m_mode = 0x1F; // default value needed by Lisa 2 - no, I don't know if it is true - m_handshake_hack = 0x00; - - // register save states - save_item(NAME(m_write_byte)); - save_item(NAME(m_lines)); - save_item(NAME(m_mode)); - save_item(NAME(m_handshake_hack)); -} - - - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void applefdc_base_device::device_reset(void) -{ - m_handshake_hack = 0x00; - m_write_byte = 0x00; - m_lines = 0x00; - m_mode = 0x1F; /* default value needed by Lisa 2 - no, I don't know if it is true */ - m_motor_timer->reset(); -} - - - -//------------------------------------------------- -// get_interface - gets the interface -//------------------------------------------------- - -const applefdc_interface *applefdc_base_device::get_interface() -{ - static const applefdc_interface dummy_interface = {nullptr, }; - - return (m_interface != nullptr) ? m_interface : &dummy_interface; -} - - - -//------------------------------------------------- -// iwm_enable2 - hackish function -//------------------------------------------------- - -int applefdc_base_device::iwm_enable2() -{ - /* R. Nabet : This function looks more like a hack than a real feature of the IWM; */ - /* it is not called from the Mac Plus driver */ - return (m_lines & APPLEFDC_PH1) && (m_lines & APPLEFDC_PH3); -} - - - -//------------------------------------------------- -// iwm_readenable2handshake - hackish function -//------------------------------------------------- - -uint8_t applefdc_base_device::iwm_readenable2handshake() -{ - /* R. Nabet : This function looks more like a hack than a real feature of the IWM; */ - /* it is not called from the Mac Plus driver */ - m_handshake_hack++; - m_handshake_hack %= 4; - return (m_handshake_hack != 0) ? 0xc0 : 0x80; -} - - - -//------------------------------------------------- -// statusreg_r - reads the status register -//------------------------------------------------- - -uint8_t applefdc_base_device::statusreg_r() -{ - uint8_t result; - int status; - const applefdc_interface *intf = get_interface(); - - /* IWM status: - * - * Bit 7 Sense input (write protect for 5.25" drive and general status line for 3.5") - * Bit 6 Reserved - * Bit 5 Drive enable (is 1 if drive is on) - * Bits 4-0 Same as IWM mode bits 4-0 - */ - - status = iwm_enable2() ? 1 : (intf->read_status ? intf->read_status(this) : 0); - - result = (status ? 0x80 : 0x00); - - if (m_type != APPLEFDC_APPLE2) - result |= (((m_lines & IWM_MOTOR) ? 1 : 0) << 5) | m_mode; - return result; -} - - - -//------------------------------------------------- -// iwm_modereg_w - changes the mode register -//------------------------------------------------- - -void applefdc_base_device::iwm_modereg_w(uint8_t data) -{ - m_mode = data & 0x1f; /* write mode register */ - - if (LOG_APPLEFDC_EXTRA) - logerror("iwm_modereg_w: iwm_mode=0x%02x\n", (unsigned) m_mode); -} - - - -//------------------------------------------------- -// read_reg - reads a register -//------------------------------------------------- - -uint8_t applefdc_base_device::read_reg(int lines) -{ - const applefdc_interface *intf = get_interface(); - uint8_t result = 0; - - switch(lines) - { - case 0: - // read data register - if ((m_type != APPLEFDC_APPLE2) && (iwm_enable2() || !(m_lines & IWM_MOTOR))) - { - result = 0xFF; - } - else - { - // Right now, this function assumes latch mode; which is always used for - // 3.5 inch drives. Eventually we should check to see if latch mode is - // off - if (LOG_APPLEFDC) - { - if ((m_mode & IWM_MODE_LATCHMODE) == 0x00) - logerror("applefdc_read_reg(): latch mode off not implemented\n"); - } - - result = (intf->read_data ? intf->read_data(this) : 0x00); - } - break; - - case IWM_Q6: - // read status register - result = statusreg_r(); - break; - - case IWM_Q7: - // Classic Apple II: Read status register - // IWM: Read handshake register - if (m_type == APPLEFDC_APPLE2) - result = statusreg_r(); - else - result = iwm_enable2() ? iwm_readenable2handshake() : 0x80; - break; - } - return result; -} - - - -//------------------------------------------------- -// write_reg - writes a register -//------------------------------------------------- - -void applefdc_base_device::write_reg(uint8_t data) -{ - const applefdc_interface *intf = get_interface(); - - switch(m_lines & (IWM_Q6 | IWM_Q7)) - { - case IWM_Q6 | IWM_Q7: - if (!(m_lines & IWM_MOTOR)) - { - iwm_modereg_w(data); - } - else if (!iwm_enable2()) - { - // Right now, this function assumes latch mode; which is always used for - // 3.5 inch drives. Eventually we should check to see if latch mode is - // off - if (LOG_APPLEFDC) - { - if ((m_mode & IWM_MODE_LATCHMODE) == 0) - logerror("applefdc_write_reg(): latch mode off not implemented\n"); - } - - if (intf->write_data != nullptr) - intf->write_data(this, data); - } - break; - } -} - - - -//------------------------------------------------- -// turn_motor_onoff - timer callback for turning -// motor on or off -//------------------------------------------------- - -TIMER_CALLBACK_MEMBER(applefdc_base_device::turn_motor_onoff) -{ - const applefdc_interface *intf = get_interface(); - int enable_lines; - - if (param) - { - m_lines |= IWM_MOTOR; - enable_lines = (m_lines & IWM_DRIVE) ? 2 : 1; - } - else - { - m_lines &= ~IWM_MOTOR; - - if (m_type == APPLEFDC_APPLE2) - enable_lines = (m_lines & IWM_DRIVE) ? 2 : 1; - else - enable_lines = 0; - } - - /* invoke callback, if present */ - if (intf->set_enable_lines != nullptr) - intf->set_enable_lines(this, enable_lines); - - if (LOG_APPLEFDC_EXTRA) - logerror("iwm_turnmotor_onoff(): Turning motor %s\n", param ? "on" : "off"); -} - - - -//------------------------------------------------- -// iwm_access -//------------------------------------------------- - -void applefdc_base_device::iwm_access(int offset) -{ - static const char *const lines[] = - { - "PH0", - "PH1", - "PH2", - "PH3", - "MOTOR", - "DRIVE", - "Q6", - "Q7" - }; - - const applefdc_interface *intf = get_interface(); - - if (offset & 1) - m_lines |= (1 << (offset >> 1)); - else - m_lines &= ~(1 << (offset >> 1)); - - if (LOG_APPLEFDC_EXTRA) - { - logerror("iwm_access(): %s line %s => %02x\n", - (offset & 1) ? "setting" : "clearing", lines[offset >> 1], m_lines); - } - - if ((offset < 0x08) && (intf->set_lines != nullptr)) - intf->set_lines(this, m_lines & 0x0f); - - switch(offset) - { - case 0x08: - /* turn off motor */ - m_motor_timer->adjust( - (m_mode & IWM_MODE_MOTOROFFDELAY) ? attotime::zero : attotime::from_seconds(1), 0); - break; - - case 0x09: - /* turn on motor */ - m_motor_timer->adjust(attotime::zero, 1); - break; - - case 0x0A: - /* turn off IWM_DRIVE */ - if ((m_lines & IWM_MOTOR) && (intf->set_enable_lines != nullptr)) - intf->set_enable_lines(this, 1); - break; - - case 0x0B: - /* turn on IWM_DRIVE */ - if ((m_lines & IWM_MOTOR) && (intf->set_enable_lines != nullptr)) - intf->set_enable_lines(this, 2); - break; - } -} - - - -//------------------------------------------------- -// read - reads a byte from the FDC -//------------------------------------------------- - -uint8_t applefdc_base_device::read(offs_t offset) -{ - const applefdc_interface *intf = get_interface(); - uint8_t result = 0; - - // normalize offset - offset &= 0xf; - - if (LOG_APPLEFDC_EXTRA) - logerror("applefdc_r: offset=%i\n", offset); - - iwm_access(offset); - - switch(m_type) - { - case APPLEFDC_APPLE2: - switch(offset) - { - case 0x0C: - if (m_lines & IWM_Q7) - { - if (intf->write_data != nullptr) - intf->write_data(this, m_write_byte); - result = 0; - } - else - result = read_reg(0); - break; - - case 0x0D: - result = read_reg(IWM_Q6); - break; - - case 0x0E: - result = read_reg(IWM_Q7); - break; - - case 0x0F: - result = read_reg(IWM_Q7 | IWM_Q6); - break; - } - break; - - case APPLEFDC_IWM: - if ((offset & 1) == 0) - result = read_reg(m_lines & (IWM_Q6 | IWM_Q7)); - break; - - case APPLEFDC_SWIM: - if ((offset & 1) == 0) - result = read_reg(m_lines & (IWM_Q6 | IWM_Q7)); - break; - } - - return result; -} - - - -//------------------------------------------------- -// write - writes a byte to the FDC -//------------------------------------------------- - -void applefdc_base_device::write(offs_t offset, uint8_t data) -{ - const applefdc_interface *intf = get_interface(); - - /* normalize offset */ - offset &= 15; - - if (LOG_APPLEFDC_EXTRA) - logerror("applefdc_w: offset=%i data=0x%02x\n", offset, data); - - iwm_access(offset); - - switch(m_type) - { - case APPLEFDC_APPLE2: - switch(offset) - { - case 0x0C: - if (m_lines & IWM_Q7) - { - if (intf->write_data != nullptr) - intf->write_data(this, m_write_byte); - } - break; - - case 0x0D: - m_write_byte = data; - break; - } - break; - - case APPLEFDC_IWM: - if (offset & 1) - write_reg(data); - break; - - case APPLEFDC_SWIM: - if (offset & 1) - write_reg(data); - break; - } -} - - - -//------------------------------------------------- -// get_lines - accessor -//------------------------------------------------- - -uint8_t applefdc_base_device::get_lines() -{ - return m_lines & 0x0f; -} - - - -/*************************************************************************** - APPLE FDC - Used on Apple II -***************************************************************************/ - -DEFINE_DEVICE_TYPE(LEGACY_APPLEFDC, applefdc_device, "apple_fdcl", "Apple FDC (legacy)") - -applefdc_device::applefdc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : applefdc_base_device(APPLEFDC_APPLE2, mconfig, LEGACY_APPLEFDC, tag, owner, clock) -{ -} - - - -/*************************************************************************** - IWM - Used on early Macs -***************************************************************************/ - -DEFINE_DEVICE_TYPE(LEGACY_IWM, legacy_iwm_device, "iwml", "Apple IWM (Integrated Woz Machine) (legacy)") - -legacy_iwm_device::legacy_iwm_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : applefdc_base_device(APPLEFDC_IWM, mconfig, LEGACY_IWM, tag, owner, clock) -{ -} diff --git a/src/devices/machine/applefdc.h b/src/devices/machine/applefdc.h deleted file mode 100644 index 80fbea87954..00000000000 --- a/src/devices/machine/applefdc.h +++ /dev/null @@ -1,152 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Nathan Woods, Raphael Nabet, R. Belmont -/********************************************************************* - - applefdc.h - - Implementation of various Apple Floppy Disk Controllers, including - the classic Apple controller and the IWM (Integrated Woz Machine) - chip - - Nate Woods - Raphael Nabet - R. Belmont - -*********************************************************************/ - -#ifndef MAME_MACHINE_APPLEFDC_H -#define MAME_MACHINE_APPLEFDC_H - -#pragma once - - - -/*************************************************************************** - CONSTANTS -***************************************************************************/ - -#define APPLEFDC_PH0 0x01 -#define APPLEFDC_PH1 0x02 -#define APPLEFDC_PH2 0x04 -#define APPLEFDC_PH3 0x08 - -DECLARE_DEVICE_TYPE(LEGACY_APPLEFDC, applefdc_device) -DECLARE_DEVICE_TYPE(LEGACY_IWM, legacy_iwm_device) - - - -/*************************************************************************** - INTERFACE -***************************************************************************/ - -struct applefdc_interface -{ - void (*set_lines)(device_t *device, uint8_t lines); - void (*set_enable_lines)(device_t *device, int enable_mask); - - uint8_t (*read_data)(device_t *device); - void (*write_data)(device_t *device, uint8_t data); - int (*read_status)(device_t *device); -}; - - - -/*************************************************************************** - BASE DEVICE -***************************************************************************/ - -class applefdc_base_device : public device_t -{ -public: - // configuration helpers - void set_config(const applefdc_interface *intrf) { m_interface = intrf; } - - // read/write handlers - virtual uint8_t read(offs_t offset); - virtual void write(offs_t offset, uint8_t data); - - // accessor - uint8_t get_lines(); - - virtual void device_reset() override; - -protected: - enum applefdc_t - { - APPLEFDC_APPLE2, /* classic Apple II disk controller (pre-IWM) */ - APPLEFDC_IWM, /* Integrated Woz Machine */ - APPLEFDC_SWIM /* Sander/Woz Integrated Machine */ - }; - - // constructor - applefdc_base_device(applefdc_t fdc_type, const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); - - // device-level overrides - virtual void device_start() override; - - // other protecteds - virtual void iwm_modereg_w(uint8_t data); - - -private: - // data that is constant for the lifetime of the emulation - emu_timer * m_motor_timer; - applefdc_t m_type; - const applefdc_interface *m_interface; - - // data that changes at emulation time - uint8_t m_write_byte; - uint8_t m_lines; /* flags from IWM_MOTOR - IWM_Q7 */ - uint8_t m_mode; /* 0-31; see above */ - uint8_t m_handshake_hack; /* not sure what this is for */ - - // functions - const applefdc_interface *get_interface(); - int iwm_enable2(); - uint8_t iwm_readenable2handshake(); - uint8_t statusreg_r(); - uint8_t read_reg(int lines); - void write_reg(uint8_t data); - TIMER_CALLBACK_MEMBER(turn_motor_onoff); - void iwm_access(int offset); -}; - - - -/*************************************************************************** - APPLE FDC - Used on Apple II -***************************************************************************/ - -class applefdc_device : public applefdc_base_device -{ -public: - applefdc_device(const machine_config &mconfig, const char *tag, device_t *owner, const applefdc_interface *intrf) - : applefdc_device(mconfig, tag, owner, (uint32_t)0) - { - set_config(intrf); - } - - applefdc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); -}; - - - -/*************************************************************************** - IWM - Used on early Macs -***************************************************************************/ - -class legacy_iwm_device : public applefdc_base_device -{ -public: - legacy_iwm_device(const machine_config &mconfig, const char *tag, device_t *owner, const applefdc_interface *intrf) - : legacy_iwm_device(mconfig, tag, owner, (uint32_t)0) - { - set_config(intrf); - } - - legacy_iwm_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - - static constexpr feature_type imperfect_features() { return feature::DISK; } -}; - -#endif // MAME_MACHINE_APPLEFDC_H |