mirror of
https://github.com/holub/mame
synced 2025-10-05 08:41:31 +03:00
(MESS) pecom.c: Reduce tagmap lookups. (nw)
This commit is contained in:
parent
9d41aec482
commit
b84b7a1e63
@ -3,6 +3,7 @@
|
||||
|
||||
#include "cpu/cosmac/cosmac.h"
|
||||
#include "imagedev/cassette.h"
|
||||
#include "machine/ram.h"
|
||||
|
||||
#define SCREEN_TAG "screen"
|
||||
#define CDP1802_TAG "cdp1802"
|
||||
@ -14,9 +15,16 @@ class pecom_state : public driver_device
|
||||
{
|
||||
public:
|
||||
pecom_state(const machine_config &mconfig, device_type type, const char *tag)
|
||||
: driver_device(mconfig, type, tag),
|
||||
m_cdp1802(*this, CDP1802_TAG),
|
||||
m_cdp1869(*this, CDP1869_TAG)
|
||||
: driver_device(mconfig, type, tag)
|
||||
, m_cdp1802(*this, CDP1802_TAG)
|
||||
, m_cdp1869(*this, CDP1869_TAG)
|
||||
, m_cassette(*this, CASSETTE_TAG)
|
||||
, m_ram(*this, RAM_TAG)
|
||||
, m_bank1(*this, "bank1")
|
||||
, m_bank2(*this, "bank2")
|
||||
, m_bank3(*this, "bank3")
|
||||
, m_bank4(*this, "bank4")
|
||||
, m_io_cnt(*this, "CNT")
|
||||
{ }
|
||||
|
||||
required_device<cosmac_device> m_cdp1802;
|
||||
@ -45,6 +53,16 @@ public:
|
||||
DECLARE_READ_LINE_MEMBER(ef2_r);
|
||||
DECLARE_WRITE_LINE_MEMBER(pecom64_q_w);
|
||||
DECLARE_WRITE_LINE_MEMBER(pecom_prd_w);
|
||||
|
||||
protected:
|
||||
required_device<cassette_image_device> m_cassette;
|
||||
required_device<ram_device> m_ram;
|
||||
required_memory_bank m_bank1;
|
||||
required_memory_bank m_bank2;
|
||||
required_memory_bank m_bank3;
|
||||
required_memory_bank m_bank4;
|
||||
required_ioport m_io_cnt;
|
||||
ioport_port *m_io_ports[26];
|
||||
};
|
||||
|
||||
/*----------- defined in machine/pecom.c -----------*/
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "emu.h"
|
||||
#include "cpu/cosmac/cosmac.h"
|
||||
#include "sound/cdp1869.h"
|
||||
#include "machine/ram.h"
|
||||
#include "includes/pecom.h"
|
||||
|
||||
TIMER_CALLBACK_MEMBER(pecom_state::reset_tick)
|
||||
@ -19,13 +18,24 @@ TIMER_CALLBACK_MEMBER(pecom_state::reset_tick)
|
||||
|
||||
void pecom_state::machine_start()
|
||||
{
|
||||
static const char *const keynames[] = {
|
||||
"LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7",
|
||||
"LINE8", "LINE9", "LINE10", "LINE11", "LINE12", "LINE13", "LINE14", "LINE15", "LINE16",
|
||||
"LINE17", "LINE18", "LINE19", "LINE20", "LINE21", "LINE22", "LINE23", "LINE24","LINE25"
|
||||
};
|
||||
|
||||
for ( int i = 0; i < 26; i++ )
|
||||
{
|
||||
m_io_ports[i] = ioport(keynames[i]);
|
||||
}
|
||||
|
||||
m_reset_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pecom_state::reset_tick),this));
|
||||
}
|
||||
|
||||
void pecom_state::machine_reset()
|
||||
{
|
||||
UINT8 *rom = machine().root_device().memregion(CDP1802_TAG)->base();
|
||||
address_space &space = machine().device(CDP1802_TAG)->memory().space(AS_PROGRAM);
|
||||
UINT8 *rom = memregion(CDP1802_TAG)->base();
|
||||
address_space &space = m_cdp1802->space(AS_PROGRAM);
|
||||
|
||||
|
||||
space.unmap_write(0x0000, 0x3fff);
|
||||
@ -34,10 +44,10 @@ void pecom_state::machine_reset()
|
||||
space.unmap_write(0xf800, 0xffff);
|
||||
space.install_read_bank (0xf000, 0xf7ff, "bank3");
|
||||
space.install_read_bank (0xf800, 0xffff, "bank4");
|
||||
membank("bank1")->set_base(rom + 0x8000);
|
||||
membank("bank2")->set_base(machine().device<ram_device>(RAM_TAG)->pointer() + 0x4000);
|
||||
membank("bank3")->set_base(rom + 0xf000);
|
||||
membank("bank4")->set_base(rom + 0xf800);
|
||||
m_bank1->set_base(rom + 0x8000);
|
||||
m_bank2->set_base(m_ram->pointer() + 0x4000);
|
||||
m_bank3->set_base(rom + 0xf000);
|
||||
m_bank4->set_base(rom + 0xf800);
|
||||
|
||||
m_reset = 0;
|
||||
m_dma = 0;
|
||||
@ -66,10 +76,10 @@ WRITE8_MEMBER(pecom_state::pecom_cdp1869_pageram_w)
|
||||
|
||||
WRITE8_MEMBER(pecom_state::pecom_bank_w)
|
||||
{
|
||||
address_space &space2 = machine().device(CDP1802_TAG)->memory().space(AS_PROGRAM);
|
||||
address_space &space2 = m_cdp1802->space(AS_PROGRAM);
|
||||
UINT8 *rom = memregion(CDP1802_TAG)->base();
|
||||
machine().device(CDP1802_TAG)->memory().space(AS_PROGRAM).install_write_bank(0x0000, 0x3fff, "bank1");
|
||||
membank("bank1")->set_base(machine().device<ram_device>(RAM_TAG)->pointer() + 0x0000);
|
||||
m_cdp1802->space(AS_PROGRAM).install_write_bank(0x0000, 0x3fff, "bank1");
|
||||
m_bank1->set_base(m_ram->pointer() + 0x0000);
|
||||
|
||||
if (data==2)
|
||||
{
|
||||
@ -84,28 +94,23 @@ WRITE8_MEMBER(pecom_state::pecom_bank_w)
|
||||
space2.unmap_write(0xf800, 0xffff);
|
||||
space2.install_read_bank (0xf000, 0xf7ff, "bank3");
|
||||
space2.install_read_bank (0xf800, 0xffff, "bank4");
|
||||
membank("bank3")->set_base(rom + 0xf000);
|
||||
membank("bank4")->set_base(rom + 0xf800);
|
||||
m_bank3->set_base(rom + 0xf000);
|
||||
m_bank4->set_base(rom + 0xf800);
|
||||
}
|
||||
}
|
||||
|
||||
READ8_MEMBER(pecom_state::pecom_keyboard_r)
|
||||
{
|
||||
static const char *const keynames[] = {
|
||||
"LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7",
|
||||
"LINE8", "LINE9", "LINE10", "LINE11", "LINE12", "LINE13", "LINE14", "LINE15", "LINE16",
|
||||
"LINE17", "LINE18", "LINE19", "LINE20", "LINE21", "LINE22", "LINE23", "LINE24","LINE25"
|
||||
};
|
||||
/*
|
||||
INP command BUS -> M(R(X)) BUS -> D
|
||||
so on each input, address is also set, 8 lower bits are used as input for keyboard
|
||||
Address is available on address bus during reading of value from port, and that is
|
||||
used to determine keyboard line reading
|
||||
*/
|
||||
UINT16 addr = machine().device(CDP1802_TAG)->state().state_int(COSMAC_R0 + machine().device(CDP1802_TAG)->state().state_int(COSMAC_X));
|
||||
UINT16 addr = m_cdp1802->state_int(COSMAC_R0 + m_cdp1802->state_int(COSMAC_X));
|
||||
/* just in case somone is reading non existing ports */
|
||||
if (addr<0x7cca || addr>0x7ce3) return 0;
|
||||
return ioport(keynames[addr - 0x7cca])->read() & 0x03;
|
||||
return m_io_ports[addr - 0x7cca]->read() & 0x03;
|
||||
}
|
||||
|
||||
/* CDP1802 Interface */
|
||||
@ -117,9 +122,8 @@ READ_LINE_MEMBER(pecom_state::clear_r)
|
||||
|
||||
READ_LINE_MEMBER(pecom_state::ef2_r)
|
||||
{
|
||||
device_t *device = machine().device(CASSETTE_TAG);
|
||||
int shift = BIT(machine().root_device().ioport("CNT")->read(), 1);
|
||||
double cas = dynamic_cast<cassette_image_device *>(device)->input();
|
||||
int shift = BIT(m_io_cnt->read(), 1);
|
||||
double cas = m_cassette->input();
|
||||
|
||||
return (cas > 0.0) | shift;
|
||||
}
|
||||
@ -148,8 +152,7 @@ static COSMAC_EF_READ( pecom64_ef_r )
|
||||
*/
|
||||
WRITE_LINE_MEMBER(pecom_state::pecom64_q_w)
|
||||
{
|
||||
device_t *device = machine().device(CASSETTE_TAG);
|
||||
dynamic_cast<cassette_image_device *>(device)->output(state ? -1.0 : +1.0);
|
||||
m_cassette->output(state ? -1.0 : +1.0);
|
||||
}
|
||||
|
||||
static COSMAC_SC_WRITE( pecom64_sc_w )
|
||||
|
Loading…
Reference in New Issue
Block a user