trunk/src/mess/machine/pecom.c
| r20816 | r20817 | |
| 9 | 9 | #include "emu.h" |
| 10 | 10 | #include "cpu/cosmac/cosmac.h" |
| 11 | 11 | #include "sound/cdp1869.h" |
| 12 | | #include "machine/ram.h" |
| 13 | 12 | #include "includes/pecom.h" |
| 14 | 13 | |
| 15 | 14 | TIMER_CALLBACK_MEMBER(pecom_state::reset_tick) |
| r20816 | r20817 | |
| 19 | 18 | |
| 20 | 19 | void pecom_state::machine_start() |
| 21 | 20 | { |
| 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 | |
| 22 | 32 | m_reset_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pecom_state::reset_tick),this)); |
| 23 | 33 | } |
| 24 | 34 | |
| 25 | 35 | void pecom_state::machine_reset() |
| 26 | 36 | { |
| 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); |
| 29 | 39 | |
| 30 | 40 | |
| 31 | 41 | space.unmap_write(0x0000, 0x3fff); |
| r20816 | r20817 | |
| 34 | 44 | space.unmap_write(0xf800, 0xffff); |
| 35 | 45 | space.install_read_bank (0xf000, 0xf7ff, "bank3"); |
| 36 | 46 | 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); |
| 41 | 51 | |
| 42 | 52 | m_reset = 0; |
| 43 | 53 | m_dma = 0; |
| r20816 | r20817 | |
| 66 | 76 | |
| 67 | 77 | WRITE8_MEMBER(pecom_state::pecom_bank_w) |
| 68 | 78 | { |
| 69 | | address_space &space2 = machine().device(CDP1802_TAG)->memory().space(AS_PROGRAM); |
| 79 | address_space &space2 = m_cdp1802->space(AS_PROGRAM); |
| 70 | 80 | 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); |
| 73 | 83 | |
| 74 | 84 | if (data==2) |
| 75 | 85 | { |
| r20816 | r20817 | |
| 84 | 94 | space2.unmap_write(0xf800, 0xffff); |
| 85 | 95 | space2.install_read_bank (0xf000, 0xf7ff, "bank3"); |
| 86 | 96 | 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); |
| 89 | 99 | } |
| 90 | 100 | } |
| 91 | 101 | |
| 92 | 102 | READ8_MEMBER(pecom_state::pecom_keyboard_r) |
| 93 | 103 | { |
| 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 | | }; |
| 99 | 104 | /* |
| 100 | 105 | INP command BUS -> M(R(X)) BUS -> D |
| 101 | 106 | so on each input, address is also set, 8 lower bits are used as input for keyboard |
| 102 | 107 | Address is available on address bus during reading of value from port, and that is |
| 103 | 108 | used to determine keyboard line reading |
| 104 | 109 | */ |
| 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)); |
| 106 | 111 | /* just in case somone is reading non existing ports */ |
| 107 | 112 | if (addr<0x7cca || addr>0x7ce3) return 0; |
| 108 | | return ioport(keynames[addr - 0x7cca])->read() & 0x03; |
| 113 | return m_io_ports[addr - 0x7cca]->read() & 0x03; |
| 109 | 114 | } |
| 110 | 115 | |
| 111 | 116 | /* CDP1802 Interface */ |
| r20816 | r20817 | |
| 117 | 122 | |
| 118 | 123 | READ_LINE_MEMBER(pecom_state::ef2_r) |
| 119 | 124 | { |
| 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(); |
| 123 | 127 | |
| 124 | 128 | return (cas > 0.0) | shift; |
| 125 | 129 | } |
| r20816 | r20817 | |
| 148 | 152 | */ |
| 149 | 153 | WRITE_LINE_MEMBER(pecom_state::pecom64_q_w) |
| 150 | 154 | { |
| 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); |
| 153 | 156 | } |
| 154 | 157 | |
| 155 | 158 | static COSMAC_SC_WRITE( pecom64_sc_w ) |
trunk/src/mess/includes/pecom.h
| r20816 | r20817 | |
| 3 | 3 | |
| 4 | 4 | #include "cpu/cosmac/cosmac.h" |
| 5 | 5 | #include "imagedev/cassette.h" |
| 6 | #include "machine/ram.h" |
| 6 | 7 | |
| 7 | 8 | #define SCREEN_TAG "screen" |
| 8 | 9 | #define CDP1802_TAG "cdp1802" |
| r20816 | r20817 | |
| 14 | 15 | { |
| 15 | 16 | public: |
| 16 | 17 | 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") |
| 20 | 28 | { } |
| 21 | 29 | |
| 22 | 30 | required_device<cosmac_device> m_cdp1802; |
| r20816 | r20817 | |
| 45 | 53 | DECLARE_READ_LINE_MEMBER(ef2_r); |
| 46 | 54 | DECLARE_WRITE_LINE_MEMBER(pecom64_q_w); |
| 47 | 55 | DECLARE_WRITE_LINE_MEMBER(pecom_prd_w); |
| 56 | |
| 57 | protected: |
| 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]; |
| 48 | 66 | }; |
| 49 | 67 | |
| 50 | 68 | /*----------- defined in machine/pecom.c -----------*/ |