Previous 199869 Revisions Next

r20817 Thursday 7th February, 2013 at 21:24:43 UTC by Wilbert Pol
(MESS) pecom.c: Reduce tagmap lookups. (nw)
[src/mess/includes]pecom.h
[src/mess/machine]pecom.c

trunk/src/mess/machine/pecom.c
r20816r20817
99#include "emu.h"
1010#include "cpu/cosmac/cosmac.h"
1111#include "sound/cdp1869.h"
12#include "machine/ram.h"
1312#include "includes/pecom.h"
1413
1514TIMER_CALLBACK_MEMBER(pecom_state::reset_tick)
r20816r20817
1918
2019void pecom_state::machine_start()
2120{
21   static const char *const keynames[] = {
22      "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7",
23      "LINE8", "LINE9", "LINE10", "LINE11", "LINE12", "LINE13", "LINE14", "LINE15", "LINE16",
24      "LINE17", "LINE18", "LINE19", "LINE20", "LINE21", "LINE22", "LINE23", "LINE24","LINE25"
25   };
26
27   for ( int i = 0; i < 26; i++ )
28   {
29      m_io_ports[i] = ioport(keynames[i]);
30   }
31
2232   m_reset_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pecom_state::reset_tick),this));
2333}
2434
2535void pecom_state::machine_reset()
2636{
27   UINT8 *rom = machine().root_device().memregion(CDP1802_TAG)->base();
28   address_space &space = machine().device(CDP1802_TAG)->memory().space(AS_PROGRAM);
37   UINT8 *rom = memregion(CDP1802_TAG)->base();
38   address_space &space = m_cdp1802->space(AS_PROGRAM);
2939
3040
3141   space.unmap_write(0x0000, 0x3fff);
r20816r20817
3444   space.unmap_write(0xf800, 0xffff);
3545   space.install_read_bank (0xf000, 0xf7ff, "bank3");
3646   space.install_read_bank (0xf800, 0xffff, "bank4");
37   membank("bank1")->set_base(rom + 0x8000);
38   membank("bank2")->set_base(machine().device<ram_device>(RAM_TAG)->pointer() + 0x4000);
39   membank("bank3")->set_base(rom + 0xf000);
40   membank("bank4")->set_base(rom + 0xf800);
47   m_bank1->set_base(rom + 0x8000);
48   m_bank2->set_base(m_ram->pointer() + 0x4000);
49   m_bank3->set_base(rom + 0xf000);
50   m_bank4->set_base(rom + 0xf800);
4151
4252   m_reset = 0;
4353   m_dma = 0;
r20816r20817
6676
6777WRITE8_MEMBER(pecom_state::pecom_bank_w)
6878{
69   address_space &space2 = machine().device(CDP1802_TAG)->memory().space(AS_PROGRAM);
79   address_space &space2 = m_cdp1802->space(AS_PROGRAM);
7080   UINT8 *rom = memregion(CDP1802_TAG)->base();
71   machine().device(CDP1802_TAG)->memory().space(AS_PROGRAM).install_write_bank(0x0000, 0x3fff, "bank1");
72   membank("bank1")->set_base(machine().device<ram_device>(RAM_TAG)->pointer() + 0x0000);
81   m_cdp1802->space(AS_PROGRAM).install_write_bank(0x0000, 0x3fff, "bank1");
82   m_bank1->set_base(m_ram->pointer() + 0x0000);
7383
7484   if (data==2)
7585   {
r20816r20817
8494      space2.unmap_write(0xf800, 0xffff);
8595      space2.install_read_bank (0xf000, 0xf7ff, "bank3");
8696      space2.install_read_bank (0xf800, 0xffff, "bank4");
87      membank("bank3")->set_base(rom + 0xf000);
88      membank("bank4")->set_base(rom + 0xf800);
97      m_bank3->set_base(rom + 0xf000);
98      m_bank4->set_base(rom + 0xf800);
8999   }
90100}
91101
92102READ8_MEMBER(pecom_state::pecom_keyboard_r)
93103{
94   static const char *const keynames[] = {
95      "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7",
96      "LINE8", "LINE9", "LINE10", "LINE11", "LINE12", "LINE13", "LINE14", "LINE15", "LINE16",
97      "LINE17", "LINE18", "LINE19", "LINE20", "LINE21", "LINE22", "LINE23", "LINE24","LINE25"
98   };
99104   /*
100105      INP command BUS -> M(R(X)) BUS -> D
101106      so on each input, address is also set, 8 lower bits are used as input for keyboard
102107      Address is available on address bus during reading of value from port, and that is
103108      used to determine keyboard line reading
104109   */
105   UINT16 addr = machine().device(CDP1802_TAG)->state().state_int(COSMAC_R0 + machine().device(CDP1802_TAG)->state().state_int(COSMAC_X));
110   UINT16 addr = m_cdp1802->state_int(COSMAC_R0 + m_cdp1802->state_int(COSMAC_X));
106111   /* just in case somone is reading non existing ports */
107112   if (addr<0x7cca || addr>0x7ce3) return 0;
108   return ioport(keynames[addr - 0x7cca])->read() & 0x03;
113   return m_io_ports[addr - 0x7cca]->read() & 0x03;
109114}
110115
111116/* CDP1802 Interface */
r20816r20817
117122
118123READ_LINE_MEMBER(pecom_state::ef2_r)
119124{
120   device_t *device = machine().device(CASSETTE_TAG);
121   int shift = BIT(machine().root_device().ioport("CNT")->read(), 1);
122   double cas = dynamic_cast<cassette_image_device *>(device)->input();
125   int shift = BIT(m_io_cnt->read(), 1);
126   double cas = m_cassette->input();
123127
124128   return (cas > 0.0) | shift;
125129}
r20816r20817
148152*/
149153WRITE_LINE_MEMBER(pecom_state::pecom64_q_w)
150154{
151   device_t *device = machine().device(CASSETTE_TAG);
152   dynamic_cast<cassette_image_device *>(device)->output(state ? -1.0 : +1.0);
155   m_cassette->output(state ? -1.0 : +1.0);
153156}
154157
155158static COSMAC_SC_WRITE( pecom64_sc_w )
trunk/src/mess/includes/pecom.h
r20816r20817
33
44#include "cpu/cosmac/cosmac.h"
55#include "imagedev/cassette.h"
6#include "machine/ram.h"
67
78#define SCREEN_TAG  "screen"
89#define CDP1802_TAG "cdp1802"
r20816r20817
1415{
1516public:
1617   pecom_state(const machine_config &mconfig, device_type type, const char *tag)
17      : driver_device(mconfig, type, tag),
18         m_cdp1802(*this, CDP1802_TAG),
19         m_cdp1869(*this, CDP1869_TAG)
18      : driver_device(mconfig, type, tag)
19      , m_cdp1802(*this, CDP1802_TAG)
20      , m_cdp1869(*this, CDP1869_TAG)
21      , m_cassette(*this, CASSETTE_TAG)
22      , m_ram(*this, RAM_TAG)
23      , m_bank1(*this, "bank1")
24      , m_bank2(*this, "bank2")
25      , m_bank3(*this, "bank3")
26      , m_bank4(*this, "bank4")
27      , m_io_cnt(*this, "CNT")
2028   { }
2129
2230   required_device<cosmac_device> m_cdp1802;
r20816r20817
4553   DECLARE_READ_LINE_MEMBER(ef2_r);
4654   DECLARE_WRITE_LINE_MEMBER(pecom64_q_w);
4755   DECLARE_WRITE_LINE_MEMBER(pecom_prd_w);
56
57protected:
58   required_device<cassette_image_device> m_cassette;
59   required_device<ram_device> m_ram;
60   required_memory_bank m_bank1;
61   required_memory_bank m_bank2;
62   required_memory_bank m_bank3;
63   required_memory_bank m_bank4;
64   required_ioport m_io_cnt;
65   ioport_port *m_io_ports[26];
4866};
4967
5068/*----------- defined in machine/pecom.c -----------*/

Previous 199869 Revisions Next


© 1997-2024 The MAME Team