From abf86dc767b2e69e211fb608cf3d05dc0740ad51 Mon Sep 17 00:00:00 2001 From: Curt Coder Date: Fri, 22 Nov 2013 15:29:39 +0000 Subject: [PATCH] (MESS) prof80: Added a device for the MMU. [Curt Coder] --- .gitattributes | 2 + src/mess/drivers/prof80.c | 155 +++++++++++------------------------ src/mess/includes/prof80.h | 19 ++--- src/mess/machine/prof80mmu.c | 128 +++++++++++++++++++++++++++++ src/mess/machine/prof80mmu.h | 69 ++++++++++++++++ src/mess/mess.mak | 1 + 6 files changed, 256 insertions(+), 118 deletions(-) create mode 100644 src/mess/machine/prof80mmu.c create mode 100644 src/mess/machine/prof80mmu.h diff --git a/.gitattributes b/.gitattributes index af66365aff4..68ac37d221d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8103,6 +8103,8 @@ src/mess/machine/pmd85.c svneol=native#text/plain src/mess/machine/poly88.c svneol=native#text/plain src/mess/machine/pp01.c svneol=native#text/plain src/mess/machine/primo.c svneol=native#text/plain +src/mess/machine/prof80mmu.c svneol=native#text/plain +src/mess/machine/prof80mmu.h svneol=native#text/plain src/mess/machine/psion_pack.c svneol=native#text/plain src/mess/machine/psion_pack.h svneol=native#text/plain src/mess/machine/psxanalog.c svneol=native#text/plain diff --git a/src/mess/drivers/prof80.c b/src/mess/drivers/prof80.c index 8cff29f9a66..38534b515e9 100644 --- a/src/mess/drivers/prof80.c +++ b/src/mess/drivers/prof80.c @@ -15,6 +15,7 @@ TODO: + - floppy Err on A: Select - NE555 timeout is 10x too high - grip31 does not work - UNIO card (Z80-STI, Z80-SIO, 2x centronics) @@ -27,85 +28,21 @@ #include "includes/prof80.h" -//************************************************************************** -// MACROS / CONSTANTS -//************************************************************************** - -#define BLK_RAM1 0x0b -#define BLK_RAM2 0x0a -#define BLK_RAM3 0x03 -#define BLK_RAM4 0x02 -#define BLK_EPROM 0x00 - - - -//************************************************************************** -// MEMORY MANAGEMENT -//************************************************************************** - -//------------------------------------------------- -// bankswitch - -//------------------------------------------------- - -void prof80_state::bankswitch() -{ - address_space &program = m_maincpu->space(AS_PROGRAM); - UINT8 *ram = m_ram->pointer(); - UINT8 *rom = m_rom->base(); - int bank; - - for (bank = 0; bank < 16; bank++) - { - UINT16 start_addr = bank * 0x1000; - UINT16 end_addr = start_addr + 0xfff; - int block = m_init ? m_mmu[bank] : BLK_EPROM; - - switch (block) - { - case BLK_RAM1: - program.install_ram(start_addr, end_addr, ram + ((bank % 8) * 0x1000)); - break; - - case BLK_RAM2: - program.install_ram(start_addr, end_addr, ram + 0x8000 + ((bank % 8) * 0x1000)); - break; - - case BLK_RAM3: - program.install_ram(start_addr, end_addr, ram + 0x10000 + ((bank % 8) * 0x1000)); - break; - - case BLK_RAM4: - program.install_ram(start_addr, end_addr, ram + 0x18000 + ((bank % 8) * 0x1000)); - break; - - case BLK_EPROM: - program.install_rom(start_addr, end_addr, rom + ((bank % 2) * 0x1000)); - break; - - default: - program.unmap_readwrite(start_addr, end_addr); - } - - //logerror("Segment %u address %04x-%04x block %u\n", bank, start_addr, end_addr, block); - } -} - - //************************************************************************** // PERIPHERALS //************************************************************************** //------------------------------------------------- -// floppy_motor_off - +// motor - //------------------------------------------------- -void prof80_state::floppy_motor_off() +void prof80_state::motor(int mon) { - if (m_floppy0->get_device()) m_floppy0->get_device()->mon_w(1); - if (m_floppy1->get_device()) m_floppy1->get_device()->mon_w(1); + if (m_floppy0->get_device()) m_floppy0->get_device()->mon_w(mon); + if (m_floppy1->get_device()) m_floppy1->get_device()->mon_w(mon); - m_motor = 0; + m_motor = mon; } @@ -134,7 +71,12 @@ void prof80_state::ls259_w(int fa, int sa, int fb, int sb) break; case 3: // READY - m_fdc->ready_w(fa); + if (m_ready != fa) + { + m_fdc->set_ready_line_connected(!fa); + m_fdc->ready_w(!fa); + m_ready = fa; + } break; case 4: // TCK @@ -142,7 +84,7 @@ void prof80_state::ls259_w(int fa, int sa, int fb, int sb) break; case 5: // IN USE - output_set_led_value(0, fa); + //m_floppy->inuse_w(fa); break; case 6: // _MOTOR @@ -156,10 +98,7 @@ void prof80_state::ls259_w(int fa, int sa, int fb, int sb) else { // turn on floppy motor - if (m_floppy0->get_device()) m_floppy0->get_device()->mon_w(0); - if (m_floppy1->get_device()) m_floppy1->get_device()->mon_w(0); - - m_motor = 1; + motor(0); // reset floppy motor off NE555 timer timer_set(attotime::never, TIMER_ID_MOTOR); @@ -167,13 +106,18 @@ void prof80_state::ls259_w(int fa, int sa, int fb, int sb) break; case 7: // SELECT + if (m_select != fa) + { + //m_fdc->set_select_lines_connected(fa); + m_select = fa; + } break; } switch (sb) { case 0: // RESF - if (fb) m_fdc->reset(); + if (fb) m_fdc->soft_reset(); break; case 1: // MINI @@ -190,8 +134,11 @@ void prof80_state::ls259_w(int fa, int sa, int fb, int sb) case 4: // _MSTOP if (!fb) { - // immediately turn off floppy motor - synchronize(TIMER_ID_MOTOR); + // turn off floppy motor + motor(1); + + // reset floppy motor off NE555 timer + timer_set(attotime::never, TIMER_ID_MOTOR); } break; @@ -204,9 +151,7 @@ void prof80_state::ls259_w(int fa, int sa, int fb, int sb) break; case 7: // MME - //logerror("INIT %u\n", fb); - m_init = fb; - bankswitch(); + m_mmu->mme_w(fb); break; } } @@ -305,7 +250,7 @@ READ8_MEMBER( prof80_state::status2_r ) int js4 = 0, js5 = 0; // floppy motor - data |= !m_motor; + data |= m_motor; // JS4 switch (m_j4->read()) @@ -337,22 +282,6 @@ READ8_MEMBER( prof80_state::status2_r ) return data; } - -//------------------------------------------------- -// par_w - -//------------------------------------------------- - -WRITE8_MEMBER( prof80_state::par_w ) -{ - int bank = offset >> 12; - - m_mmu[bank] = data & 0x0f; - - //logerror("MMU bank %u block %u\n", bank, data & 0x0f); - - bankswitch(); -} - // UNIO /* WRITE8_MEMBER( prof80_state::unio_ctrl_w ) @@ -386,6 +315,18 @@ WRITE8_MEMBER( prof80_state::unio_ctrl_w ) //------------------------------------------------- static ADDRESS_MAP_START( prof80_mem, AS_PROGRAM, 8, prof80_state ) + AM_RANGE(0x0000, 0xffff) AM_DEVICE(MMU_TAG, prof80_mmu_device, z80_program_map) +ADDRESS_MAP_END + + +//------------------------------------------------- +// ADDRESS_MAP( prof80_mmu ) +//------------------------------------------------- + +static ADDRESS_MAP_START( prof80_mmu, AS_PROGRAM, 8, prof80_state ) + AM_RANGE(0x40000, 0x5ffff) AM_RAM + AM_RANGE(0xc0000, 0xdffff) AM_RAM + AM_RANGE(0xf0000, 0xf1fff) AM_MIRROR(0xe000) AM_ROM AM_REGION(Z80_TAG, 0) ADDRESS_MAP_END @@ -407,7 +348,7 @@ static ADDRESS_MAP_START( prof80_io, AS_IO, 8, prof80_state ) AM_RANGE(0xda, 0xda) AM_MIRROR(0xff00) AM_READ(status_r) AM_RANGE(0xdb, 0xdb) AM_MIRROR(0xff00) AM_READ(status2_r) AM_RANGE(0xdc, 0xdd) AM_MIRROR(0xff00) AM_DEVICE(UPD765_TAG, upd765a_device, map) - AM_RANGE(0xde, 0xde) AM_MIRROR(0xff01) AM_MASK(0xff00) AM_WRITE(par_w) + AM_RANGE(0xde, 0xde) AM_MIRROR(0xff01) AM_MASK(0xff00) AM_DEVWRITE(MMU_TAG, prof80_mmu_device, par_w) ADDRESS_MAP_END @@ -538,7 +479,7 @@ void prof80_state::device_timer(emu_timer &timer, device_timer_id id, int param, switch (id) { case TIMER_ID_MOTOR: - floppy_motor_off(); + motor(1); break; } } @@ -554,16 +495,13 @@ void prof80_state::machine_start() m_rtc->cs_w(1); m_rtc->oe_w(1); - // bank switch - bankswitch(); - // register for state saving save_item(NAME(m_c0)); save_item(NAME(m_c1)); save_item(NAME(m_c2)); - save_item(NAME(m_mmu)); - save_item(NAME(m_init)); - save_item(NAME(m_fdc_index)); + save_item(NAME(m_motor)); + save_item(NAME(m_ready)); + save_item(NAME(m_select)); } @@ -594,10 +532,13 @@ static MACHINE_CONFIG_START( prof80, prof80_state ) MCFG_CPU_IO_MAP(prof80_io) // devices + MCFG_PROF80_MMU_ADD(MMU_TAG, prof80_mmu) MCFG_UPD1990A_ADD(UPD1990A_TAG, XTAL_32_768kHz, NULL, NULL) - MCFG_UPD765A_ADD(UPD765_TAG, false, true) + MCFG_UPD765A_ADD(UPD765_TAG, true, true) MCFG_FLOPPY_DRIVE_ADD(UPD765_TAG ":0", prof80_floppies, "525qd", floppy_image_device::default_floppy_formats) MCFG_FLOPPY_DRIVE_ADD(UPD765_TAG ":1", prof80_floppies, "525qd", floppy_image_device::default_floppy_formats) + MCFG_FLOPPY_DRIVE_ADD(UPD765_TAG ":2", prof80_floppies, NULL, floppy_image_device::default_floppy_formats) + MCFG_FLOPPY_DRIVE_ADD(UPD765_TAG ":3", prof80_floppies, NULL, floppy_image_device::default_floppy_formats) // ECB bus MCFG_ECBBUS_ADD(Z80_TAG, ecb_intf) diff --git a/src/mess/includes/prof80.h b/src/mess/includes/prof80.h index 5dd0c36ba8f..da3efc8c0c6 100644 --- a/src/mess/includes/prof80.h +++ b/src/mess/includes/prof80.h @@ -9,6 +9,7 @@ #include "bus/ecbbus/ecbbus.h" #include "cpu/z80/z80.h" #include "cpu/z80/z80daisy.h" +#include "machine/prof80mmu.h" #include "machine/ram.h" #include "machine/rescap.h" #include "machine/serial.h" @@ -16,6 +17,7 @@ #include "machine/upd765.h" #define Z80_TAG "z1" +#define MMU_TAG "mmu" #define UPD765_TAG "z38" #define UPD1990A_TAG "z43" #define RS232_A_TAG "rs232a" @@ -35,6 +37,7 @@ public: prof80_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), m_maincpu(*this, Z80_TAG), + m_mmu(*this, MMU_TAG), m_rtc(*this, UPD1990A_TAG), m_fdc(*this, UPD765_TAG), m_ram(*this, RAM_TAG), @@ -49,6 +52,7 @@ public: { } required_device m_maincpu; + required_device m_mmu; required_device m_rtc; required_device m_fdc; required_device m_ram; @@ -64,7 +68,6 @@ public: virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); virtual void machine_start(); virtual void machine_reset(); - UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); enum { @@ -74,16 +77,9 @@ public: DECLARE_WRITE8_MEMBER( flr_w ); DECLARE_READ8_MEMBER( status_r ); DECLARE_READ8_MEMBER( status2_r ); - DECLARE_WRITE8_MEMBER( par_w ); - DECLARE_WRITE_LINE_MEMBER( floppy_index_w ); - void bankswitch(); void ls259_w(int fa, int sa, int fb, int sb); - void floppy_motor_off(); - - // memory state - UINT8 m_mmu[16]; // MMU block register - int m_init; // MMU enable + void motor(int mon); // RTC state int m_c0; @@ -91,8 +87,9 @@ public: int m_c2; // floppy state - int m_fdc_index; // floppy index hole sensor - int m_motor; // floppy motor + int m_motor; + int m_ready; + int m_select; // timers emu_timer *m_floppy_motor_off_timer; diff --git a/src/mess/machine/prof80mmu.c b/src/mess/machine/prof80mmu.c new file mode 100644 index 00000000000..1acad1a90b8 --- /dev/null +++ b/src/mess/machine/prof80mmu.c @@ -0,0 +1,128 @@ +/********************************************************************** + + Conitec PROF-80 Memory Management Unit emulation + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +**********************************************************************/ + +#include "prof80mmu.h" + + + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +const device_type PROF80_MMU = &device_creator; + + +DEVICE_ADDRESS_MAP_START( z80_program_map, 8, prof80_mmu_device ) + AM_RANGE(0x0000, 0xffff) AM_READWRITE(program_r, program_w) +ADDRESS_MAP_END + +static ADDRESS_MAP_START( program_map, AS_PROGRAM, 8, prof80_mmu_device ) +ADDRESS_MAP_END + + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// prof80_mmu_device - constructor +//------------------------------------------------- + +prof80_mmu_device::prof80_mmu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : device_t(mconfig, PROF80_MMU, "PROF80_MMU", tag, owner, clock, "prof80_mmu", __FILE__), + device_memory_interface(mconfig, *this), + m_program_space_config("program", ENDIANNESS_LITTLE, 8, 20, 0, *ADDRESS_MAP_NAME(program_map)) +{ +} + + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void prof80_mmu_device::device_start() +{ + // state saving + save_item(NAME(m_blk)); + save_item(NAME(m_enabled)); +} + + +//------------------------------------------------- +// memory_space_config - return a description of +// any address spaces owned by this device +//------------------------------------------------- + +const address_space_config *prof80_mmu_device::memory_space_config(address_spacenum spacenum) const +{ + return (spacenum == AS_PROGRAM) ? &m_program_space_config : NULL; +} + + +//------------------------------------------------- +// par_w - +//------------------------------------------------- + +WRITE8_MEMBER( prof80_mmu_device::par_w ) +{ + int bank = offset >> 12; + + m_blk[bank] = (data & 0x0f) ^ 0x0f; +} + + +//------------------------------------------------- +// mme_w - +//------------------------------------------------- + +WRITE_LINE_MEMBER( prof80_mmu_device::mme_w ) +{ + m_enabled = (state == 1); +} + + +//------------------------------------------------- +// program_r - program space read +//------------------------------------------------- + +READ8_MEMBER( prof80_mmu_device::program_r ) +{ + if (m_enabled) + { + int bank = offset >> 12; + offset |= m_blk[bank] << 16; + } + else + { + offset |= 0xf0000; + } + + return this->space(AS_PROGRAM).read_byte(offset); +} + + +//------------------------------------------------- +// program_w - program space write +//------------------------------------------------- + +WRITE8_MEMBER( prof80_mmu_device::program_w ) +{ + if (m_enabled) + { + int bank = offset >> 12; + offset |= m_blk[bank] << 16; + } + else + { + offset |= 0xf0000; + } + + this->space(AS_PROGRAM).write_byte(offset, data); +} diff --git a/src/mess/machine/prof80mmu.h b/src/mess/machine/prof80mmu.h new file mode 100644 index 00000000000..d5de2f52650 --- /dev/null +++ b/src/mess/machine/prof80mmu.h @@ -0,0 +1,69 @@ +/********************************************************************** + + Conitec PROF-80 Memory Management Unit emulation + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +**********************************************************************/ + +#pragma once + +#ifndef __PROF80_MMU__ +#define __PROF80_MMU__ + +#include "emu.h" + + + +///************************************************************************* +// INTERFACE CONFIGURATION MACROS +///************************************************************************* + +#define MCFG_PROF80_MMU_ADD(_tag, _program_map) \ + MCFG_DEVICE_ADD(_tag, PROF80_MMU, 0) \ + MCFG_DEVICE_ADDRESS_MAP(AS_PROGRAM, _program_map) + + + +///************************************************************************* +// TYPE DEFINITIONS +///************************************************************************* + +// ======================> prof80_mmu_device + +class prof80_mmu_device : public device_t, + public device_memory_interface +{ +public: + prof80_mmu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + virtual DECLARE_ADDRESS_MAP(z80_program_map, 8); + + DECLARE_WRITE8_MEMBER( par_w ); + DECLARE_WRITE_LINE_MEMBER( mme_w ); + +protected: + // device-level overrides + virtual void device_start(); + + // device_memory_interface overrides + virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const; + + DECLARE_READ8_MEMBER( program_r ); + DECLARE_WRITE8_MEMBER( program_w ); + +private: + const address_space_config m_program_space_config; + + UINT8 m_blk[16]; + bool m_enabled; +}; + + +// device type definition +extern const device_type PROF80_MMU; + + + +#endif diff --git a/src/mess/mess.mak b/src/mess/mess.mak index 5e9fd047aa3..e7a254f8fba 100644 --- a/src/mess/mess.mak +++ b/src/mess/mess.mak @@ -1119,6 +1119,7 @@ $(MESSOBJ)/concept.a: \ $(MESSOBJ)/conitec.a: \ $(MESS_DRIVERS)/prof80.o \ + $(MESS_MACHINE)/prof80mmu.o \ $(MESS_DRIVERS)/prof180x.o \ $(MESSOBJ)/cybiko.a: \