trunk/src/mess/drivers/okean240.c
| r20860 | r20861 | |
| 61 | 61 | m_term_data(0), |
| 62 | 62 | m_j(0), |
| 63 | 63 | m_scroll(0), |
| 64 | | m_p_videoram(*this, "p_videoram"){ } |
| 64 | m_p_videoram(*this, "p_videoram"), |
| 65 | m_io_modifiers(*this, "MODIFIERS") |
| 66 | { } |
| 65 | 67 | |
| 66 | 68 | DECLARE_READ8_MEMBER(okean240_kbd_status_r); |
| 67 | 69 | DECLARE_READ8_MEMBER(okean240a_kbd_status_r); |
| r20860 | r20861 | |
| 76 | 78 | UINT8 m_j; |
| 77 | 79 | UINT8 m_scroll; |
| 78 | 80 | required_shared_ptr<UINT8> m_p_videoram; |
| 81 | virtual void machine_start(); |
| 79 | 82 | virtual void machine_reset(); |
| 80 | 83 | virtual void video_start(); |
| 81 | 84 | DECLARE_DRIVER_INIT(okean240); |
| 82 | 85 | UINT32 screen_update_okean240(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 83 | 86 | TIMER_CALLBACK_MEMBER(okean240_boot); |
| 87 | |
| 88 | protected: |
| 89 | optional_ioport m_io_modifiers; |
| 90 | ioport_port *m_io_port[11]; |
| 84 | 91 | }; |
| 85 | 92 | |
| 86 | 93 | // okean240 requires bit 4 to change |
| r20860 | r20861 | |
| 95 | 102 | // see if a key is pressed and indicate status |
| 96 | 103 | READ8_MEMBER( okean240_state::okean240a_kbd_status_r ) |
| 97 | 104 | { |
| 98 | | char kbdrow[6]; |
| 99 | 105 | UINT8 i,j; |
| 100 | 106 | |
| 101 | 107 | for (i = 0; i < 11; i++) |
| 102 | 108 | { |
| 103 | | sprintf(kbdrow,"X%X",i); |
| 104 | | j = ioport(kbdrow)->read(); |
| 109 | j = m_io_port[i]->read(); |
| 105 | 110 | if (j) |
| 106 | 111 | return (machine().rand() & 0x10) | 2; |
| 107 | 112 | } |
| r20860 | r20861 | |
| 130 | 135 | |
| 131 | 136 | READ8_MEMBER( okean240_state::okean240a_keyboard_r ) |
| 132 | 137 | { |
| 133 | | char kbdrow[6]; |
| 134 | 138 | UINT8 i,j; |
| 135 | 139 | |
| 136 | 140 | if (offset == 0) // port 40 (get a column) |
| 137 | 141 | { |
| 138 | 142 | for (i = 0; i < 11; i++) |
| 139 | 143 | { |
| 140 | | sprintf(kbdrow,"X%X",i); |
| 141 | | j = ioport(kbdrow)->read(); |
| 144 | j = m_io_port[i]->read(); |
| 142 | 145 | if (j) |
| 143 | 146 | { |
| 144 | 147 | if (j==m_j) return 0; |
| r20860 | r20861 | |
| 152 | 155 | else |
| 153 | 156 | if (offset == 1) // port 41 bits 6&7 (modifier keys), and bit 1 (test rom status bit) |
| 154 | 157 | { |
| 155 | | return (machine().rand() & 2) | ioport("MODIFIERS")->read(); |
| 158 | return (machine().rand() & 2) | m_io_modifiers->read(); |
| 156 | 159 | } |
| 157 | 160 | else // port 42 (get a row) |
| 158 | 161 | { |
| 159 | 162 | for (i = 0; i < 11; i++) |
| 160 | 163 | { |
| 161 | | sprintf(kbdrow,"X%X",i); |
| 162 | | if (ioport(kbdrow)->read() ) |
| 164 | if (m_io_port[i]->read() ) |
| 163 | 165 | return i; |
| 164 | 166 | } |
| 165 | 167 | } |
| r20860 | r20861 | |
| 362 | 364 | membank("boot")->set_entry(0); |
| 363 | 365 | } |
| 364 | 366 | |
| 367 | |
| 368 | void okean240_state::machine_start() |
| 369 | { |
| 370 | char kbdrow[6]; |
| 371 | |
| 372 | for (int i = 0; i < 11; i++) |
| 373 | { |
| 374 | sprintf(kbdrow,"X%X",i); |
| 375 | m_io_port[i] = ioport(kbdrow); |
| 376 | } |
| 377 | } |
| 378 | |
| 379 | |
| 365 | 380 | void okean240_state::machine_reset() |
| 366 | 381 | { |
| 367 | 382 | machine().scheduler().timer_set(attotime::from_usec(10), timer_expired_delegate(FUNC(okean240_state::okean240_boot),this)); |