summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/m6502/m4510.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/cpu/m6502/m4510.cpp')
-rw-r--r--src/devices/cpu/m6502/m4510.cpp118
1 files changed, 88 insertions, 30 deletions
diff --git a/src/devices/cpu/m6502/m4510.cpp b/src/devices/cpu/m6502/m4510.cpp
index 9e67462e4d0..4e6f97b56e4 100644
--- a/src/devices/cpu/m6502/m4510.cpp
+++ b/src/devices/cpu/m6502/m4510.cpp
@@ -15,12 +15,15 @@
#include "m4510.h"
#include "m4510d.h"
-DEFINE_DEVICE_TYPE(M4510, m4510_device, "m4510", "CSG M4510")
+DEFINE_DEVICE_TYPE(M4510, m4510_device, "m4510", "CSG 4510")
m4510_device::m4510_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
m65ce02_device(mconfig, M4510, tag, owner, clock),
map_enable(0),
- nomap(false)
+ nomap(false),
+ read_port(*this, 0),
+ write_port(*this),
+ dir(0), port(0), drive(0)
{
program_config.m_addr_width = 20;
program_config.m_logaddr_width = 16;
@@ -28,6 +31,14 @@ m4510_device::m4510_device(const machine_config &mconfig, const char *tag, devic
sprogram_config.m_addr_width = 20;
sprogram_config.m_logaddr_width = 16;
sprogram_config.m_page_shift = 13;
+ pullup = 0x00;
+ floating = 0x00;
+}
+
+void m4510_device::set_pulls(uint8_t _pullup, uint8_t _floating)
+{
+ pullup = _pullup;
+ floating = _floating;
}
std::unique_ptr<util::disasm_interface> m4510_device::create_disassembler()
@@ -35,14 +46,21 @@ std::unique_ptr<util::disasm_interface> m4510_device::create_disassembler()
return std::make_unique<m4510_disassembler>();
}
+void m4510_device::init_port()
+{
+ save_item(NAME(pullup));
+ save_item(NAME(floating));
+ save_item(NAME(dir));
+ save_item(NAME(port));
+ save_item(NAME(drive));
+}
+
void m4510_device::device_start()
{
- if(cache_disabled)
- mintf = std::make_unique<mi_4510_nd>(this);
- else
- mintf = std::make_unique<mi_4510_normal>(this);
+ mintf = std::make_unique<mi_4510>(this);
m65ce02_device::init();
+ init_port();
save_item(NAME(map_offset));
save_item(NAME(map_enable));
@@ -54,59 +72,99 @@ void m4510_device::device_reset()
map_enable = 0;
nomap = true;
- // Wild guess, this setting makes the cpu start executing some code in the c65 driver
- //map_offset[1] = 0x2e000;
- //map_enable = 0x80;
m65ce02_device::device_reset();
+ dir = 0xff;
+ port = 0xff;
+ drive = 0xff;
+ update_port();
}
-bool m4510_device::memory_translate(int spacenum, int intention, offs_t &address)
+void m4510_device::update_port()
{
- if (spacenum == AS_PROGRAM)
- {
- address = map(address);
- }
+ drive = (port & dir) | (drive & ~dir);
+ write_port((port & dir) | (pullup & ~dir));
+}
- return true;
+uint8_t m4510_device::get_port()
+{
+ return (port & dir) | (pullup & ~dir);
}
-m4510_device::mi_4510_normal::mi_4510_normal(m4510_device *_base)
+uint8_t m4510_device::dir_r()
{
- base = _base;
+ return dir;
}
-uint8_t m4510_device::mi_4510_normal::read(uint16_t adr)
+uint8_t m4510_device::port_r()
{
- return program->read_byte(base->map(adr));
+ return ((read_port() | (floating & drive)) & ~dir) | (port & dir);
}
-uint8_t m4510_device::mi_4510_normal::read_sync(uint16_t adr)
+void m4510_device::dir_w(uint8_t data)
{
- return scache->read_byte(base->map(adr));
+ dir = data;
+ update_port();
}
-uint8_t m4510_device::mi_4510_normal::read_arg(uint16_t adr)
+void m4510_device::port_w(uint8_t data)
{
- return cache->read_byte(base->map(adr));
+ port = data;
+ update_port();
+}
+
+bool m4510_device::memory_translate(int spacenum, int intention, offs_t &address, address_space *&target_space)
+{
+ target_space = &space(spacenum);
+ if (spacenum == AS_PROGRAM)
+ {
+ address = map(address);
+ }
+
+ return true;
+}
+
+m4510_device::mi_4510::mi_4510(m4510_device *_base)
+{
+ base = _base;
}
-void m4510_device::mi_4510_normal::write(uint16_t adr, uint8_t val)
+uint8_t m4510_device::mi_4510::read(uint16_t adr)
{
- program->write_byte(base->map(adr), val);
+ uint8_t res = program.read_byte(base->map(adr));
+ if(adr == 0x0000)
+ res = base->dir_r();
+ else if(adr == 0x0001)
+ res = base->port_r();
+ return res;
}
-m4510_device::mi_4510_nd::mi_4510_nd(m4510_device *_base) : mi_4510_normal(_base)
+uint8_t m4510_device::mi_4510::read_sync(uint16_t adr)
{
+ uint8_t res = csprogram.read_byte(base->map(adr));
+ if(adr == 0x0000)
+ res = base->dir_r();
+ else if(adr == 0x0001)
+ res = base->port_r();
+ return res;
}
-uint8_t m4510_device::mi_4510_nd::read_sync(uint16_t adr)
+uint8_t m4510_device::mi_4510::read_arg(uint16_t adr)
{
- return sprogram->read_byte(base->map(adr));
+ uint8_t res = cprogram.read_byte(base->map(adr));
+ if(adr == 0x0000)
+ res = base->dir_r();
+ else if(adr == 0x0001)
+ res = base->port_r();
+ return res;
}
-uint8_t m4510_device::mi_4510_nd::read_arg(uint16_t adr)
+void m4510_device::mi_4510::write(uint16_t adr, uint8_t val)
{
- return program->read_byte(base->map(adr));
+ program.write_byte(base->map(adr), val);
+ if(adr == 0x0000)
+ base->dir_w(val);
+ else if(adr == 0x0001)
+ base->port_w(val);
}
#include "cpu/m6502/m4510.hxx"