src/mess/video/crt9212.c
| r0 | r9646 | |
| 1 | /********************************************************************** |
| 2 | |
| 3 | SMC CRT9212 Double Row Buffer (DRB) emulation |
| 4 | |
| 5 | Copyright MESS Team. |
| 6 | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | |
| 8 | **********************************************************************/ |
| 9 | |
| 10 | #include "emu.h" |
| 11 | #include "crt9212.h" |
| 12 | |
| 13 | |
| 14 | |
| 15 | //************************************************************************** |
| 16 | // MACROS / CONSTANTS |
| 17 | //************************************************************************** |
| 18 | |
| 19 | #define LOG 1 |
| 20 | |
| 21 | |
| 22 | #define REN \ |
| 23 | devcb_call_read_line(&m_in_ren_func) |
| 24 | |
| 25 | #define WEN \ |
| 26 | devcb_call_read_line(&m_in_wen_func) |
| 27 | |
| 28 | #define WEN2 \ |
| 29 | devcb_call_read_line(&m_in_wen2_func) |
| 30 | |
| 31 | #define ROF(_state) \ |
| 32 | devcb_call_write_line(&m_out_rof_func, _state); |
| 33 | |
| 34 | #define WOF(_state) \ |
| 35 | devcb_call_write_line(&m_out_wof_func, _state); |
| 36 | |
| 37 | |
| 38 | |
| 39 | //************************************************************************** |
| 40 | // GLOBAL VARIABLES |
| 41 | //************************************************************************** |
| 42 | |
| 43 | // devices |
| 44 | const device_type CRT9212 = crt9212_device_config::static_alloc_device_config; |
| 45 | |
| 46 | |
| 47 | |
| 48 | //************************************************************************** |
| 49 | // DEVICE CONFIGURATION |
| 50 | //************************************************************************** |
| 51 | |
| 52 | //------------------------------------------------- |
| 53 | // crt9212_device_config - constructor |
| 54 | //------------------------------------------------- |
| 55 | |
| 56 | crt9212_device_config::crt9212_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) |
| 57 | : device_config(mconfig, static_alloc_device_config, "SMC CRT9212", tag, owner, clock) |
| 58 | { |
| 59 | } |
| 60 | |
| 61 | |
| 62 | //------------------------------------------------- |
| 63 | // static_alloc_device_config - allocate a new |
| 64 | // configuration object |
| 65 | //------------------------------------------------- |
| 66 | |
| 67 | device_config *crt9212_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) |
| 68 | { |
| 69 | return global_alloc(crt9212_device_config(mconfig, tag, owner, clock)); |
| 70 | } |
| 71 | |
| 72 | |
| 73 | //------------------------------------------------- |
| 74 | // alloc_device - allocate a new device object |
| 75 | //------------------------------------------------- |
| 76 | |
| 77 | device_t *crt9212_device_config::alloc_device(running_machine &machine) const |
| 78 | { |
| 79 | return auto_alloc(&machine, crt9212_device(machine, *this)); |
| 80 | } |
| 81 | |
| 82 | |
| 83 | //------------------------------------------------- |
| 84 | // device_config_complete - perform any |
| 85 | // operations now that the configuration is |
| 86 | // complete |
| 87 | //------------------------------------------------- |
| 88 | |
| 89 | void crt9212_device_config::device_config_complete() |
| 90 | { |
| 91 | // inherit a copy of the static data |
| 92 | const crt9212_interface *intf = reinterpret_cast<const crt9212_interface *>(static_config()); |
| 93 | if (intf != NULL) |
| 94 | *static_cast<crt9212_interface *>(this) = *intf; |
| 95 | |
| 96 | // or initialize to defaults if none provided |
| 97 | else |
| 98 | { |
| 99 | memset(&out_rof_func, 0, sizeof(out_rof_func)); |
| 100 | memset(&out_wof_func, 0, sizeof(out_wof_func)); |
| 101 | memset(&in_ren_func, 0, sizeof(in_ren_func)); |
| 102 | memset(&in_wen_func, 0, sizeof(in_wen_func)); |
| 103 | memset(&in_wen2_func, 0, sizeof(in_wen2_func)); |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | |
| 108 | |
| 109 | //************************************************************************** |
| 110 | // INLINE HELPERS |
| 111 | //************************************************************************** |
| 112 | |
| 113 | |
| 114 | //************************************************************************** |
| 115 | // LIVE DEVICE |
| 116 | //************************************************************************** |
| 117 | |
| 118 | //------------------------------------------------- |
| 119 | // crt9212_device - constructor |
| 120 | //------------------------------------------------- |
| 121 | |
| 122 | crt9212_device::crt9212_device(running_machine &_machine, const crt9212_device_config &config) |
| 123 | : device_t(_machine, config), |
| 124 | m_config(config) |
| 125 | { |
| 126 | } |
| 127 | |
| 128 | |
| 129 | //------------------------------------------------- |
| 130 | // device_start - device-specific startup |
| 131 | //------------------------------------------------- |
| 132 | |
| 133 | void crt9212_device::device_start() |
| 134 | { |
| 135 | // resolve callbacks |
| 136 | devcb_resolve_write_line(&m_out_rof_func, &m_config.out_rof_func, this); |
| 137 | devcb_resolve_write_line(&m_out_wof_func, &m_config.out_wof_func, this); |
| 138 | devcb_resolve_read_line(&m_in_ren_func, &m_config.in_ren_func, this); |
| 139 | devcb_resolve_read_line(&m_in_wen_func, &m_config.in_wen_func, this); |
| 140 | devcb_resolve_read_line(&m_in_wen2_func, &m_config.in_wen2_func, this); |
| 141 | |
| 142 | // register for state saving |
| 143 | state_save_register_device_item(this, 0, m_input); |
| 144 | state_save_register_device_item(this, 0, m_output); |
| 145 | state_save_register_device_item(this, 0, m_buffer); |
| 146 | state_save_register_device_item(this, 0, m_rac); |
| 147 | state_save_register_device_item(this, 0, m_wac); |
| 148 | state_save_register_device_item(this, 0, m_tog); |
| 149 | state_save_register_device_item(this, 0, m_clrcnt); |
| 150 | state_save_register_device_item(this, 0, m_rclk); |
| 151 | state_save_register_device_item(this, 0, m_wclk); |
| 152 | } |
| 153 | |
| 154 | |
| 155 | //------------------------------------------------- |
| 156 | // read - buffer read |
| 157 | //------------------------------------------------- |
| 158 | |
| 159 | READ8_MEMBER( crt9212_device::read ) |
| 160 | { |
| 161 | return m_output; |
| 162 | } |
| 163 | |
| 164 | |
| 165 | //------------------------------------------------- |
| 166 | // write - buffer write |
| 167 | //------------------------------------------------- |
| 168 | |
| 169 | WRITE8_MEMBER( crt9212_device::write ) |
| 170 | { |
| 171 | m_input = data; |
| 172 | } |
| 173 | |
| 174 | |
| 175 | //------------------------------------------------- |
| 176 | // clrcnt_w - clear address counters |
| 177 | //------------------------------------------------- |
| 178 | |
| 179 | WRITE_LINE_MEMBER( crt9212_device::clrcnt_w ) |
| 180 | { |
| 181 | m_clrcnt = state; |
| 182 | } |
| 183 | |
| 184 | |
| 185 | //------------------------------------------------- |
| 186 | // tog_w - toggle buffer |
| 187 | //------------------------------------------------- |
| 188 | |
| 189 | WRITE_LINE_MEMBER( crt9212_device::tog_w ) |
| 190 | { |
| 191 | m_tog = state; |
| 192 | } |
| 193 | |
| 194 | |
| 195 | //------------------------------------------------- |
| 196 | // rclk_w - read clock |
| 197 | //------------------------------------------------- |
| 198 | |
| 199 | WRITE_LINE_MEMBER( crt9212_device::rclk_w ) |
| 200 | { |
| 201 | if (m_rclk && !state) |
| 202 | { |
| 203 | if (!m_clrcnt) |
| 204 | { |
| 205 | if (!m_tog) |
| 206 | { |
| 207 | // switch buffer |
| 208 | m_buffer = !m_buffer; |
| 209 | |
| 210 | // clear write address counter |
| 211 | m_wac = 0; |
| 212 | WOF(0); |
| 213 | } |
| 214 | else |
| 215 | { |
| 216 | // clear read address counter |
| 217 | m_rac = 0; |
| 218 | ROF(0); |
| 219 | } |
| 220 | } |
| 221 | else |
| 222 | { |
| 223 | if (REN && (m_rac < CRT9212_RAM_SIZE)) |
| 224 | { |
| 225 | // |
| 226 | m_output = m_ram[m_rac][!m_buffer]; |
| 227 | |
| 228 | // increment read address counter |
| 229 | m_rac++; |
| 230 | |
| 231 | if (m_rac == CRT9212_RAM_SIZE) |
| 232 | { |
| 233 | // set read overflow |
| 234 | ROF(1); |
| 235 | } |
| 236 | } |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | m_rclk = state; |
| 241 | } |
| 242 | |
| 243 | |
| 244 | //------------------------------------------------- |
| 245 | // wclk_w - write clock |
| 246 | //------------------------------------------------- |
| 247 | |
| 248 | WRITE_LINE_MEMBER( crt9212_device::wclk_w ) |
| 249 | { |
| 250 | if (!m_rclk && state) |
| 251 | { |
| 252 | if (WEN && WEN2 && (m_wac < CRT9212_RAM_SIZE)) |
| 253 | { |
| 254 | // |
| 255 | m_ram[m_rac][m_buffer] = m_input; |
| 256 | |
| 257 | // increment read address counter |
| 258 | m_wac++; |
| 259 | |
| 260 | if (m_wac == CRT9212_RAM_SIZE) |
| 261 | { |
| 262 | // set write overflow |
| 263 | WOF(1); |
| 264 | } |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | m_wclk = state; |
| 269 | } |
src/mess/video/crt9212.h
| r0 | r9646 | |
| 1 | /********************************************************************** |
| 2 | |
| 3 | SMC CRT9212 Double Row Buffer (DRB) emulation |
| 4 | |
| 5 | Copyright MESS Team. |
| 6 | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | |
| 8 | ********************************************************************** |
| 9 | _____ _____ |
| 10 | DIN2 1 |* \_/ | 28 DIN3 |
| 11 | DIN1 2 | | 27 _WCLK |
| 12 | DIN0 3 | | 26 _OE |
| 13 | DOUT7 4 | | 25 WEN2 |
| 14 | DOUT6 5 | | 24 WEN1 |
| 15 | DOUT5 6 | | 23 GND |
| 16 | DOUT4 7 | CRT9212 | 22 ROF |
| 17 | Vcc 8 | | 21 WOF |
| 18 | DOUT3 9 | | 20 REN |
| 19 | DOUT2 10 | | 19 _CLRCNT |
| 20 | DOUT1 11 | | 18 _TOG |
| 21 | DOUT0 12 | | 17 _RCLK |
| 22 | DIN7 13 | | 16 DIN4 |
| 23 | DIN6 14 |_____________| 15 DIN5 |
| 24 | |
| 25 | **********************************************************************/ |
| 26 | |
| 27 | #pragma once |
| 28 | |
| 29 | #ifndef __CRT9212__ |
| 30 | #define __CRT9212__ |
| 31 | |
| 32 | #include "emu.h" |
| 33 | |
| 34 | |
| 35 | |
| 36 | //************************************************************************** |
| 37 | // MACROS / CONSTANTS |
| 38 | //************************************************************************** |
| 39 | |
| 40 | const int CRT9212_RAM_SIZE = 135; |
| 41 | |
| 42 | |
| 43 | |
| 44 | //************************************************************************** |
| 45 | // INTERFACE CONFIGURATION MACROS |
| 46 | //************************************************************************** |
| 47 | |
| 48 | #define MDRV_CRT9212_ADD(_tag, _config) \ |
| 49 | MDRV_DEVICE_ADD(_tag, CRT9212, 0) \ |
| 50 | MDRV_DEVICE_CONFIG(_config) |
| 51 | |
| 52 | |
| 53 | #define CRT9212_INTERFACE(name) \ |
| 54 | const crt9212_interface (name) = |
| 55 | |
| 56 | |
| 57 | |
| 58 | //************************************************************************** |
| 59 | // TYPE DEFINITIONS |
| 60 | //************************************************************************** |
| 61 | |
| 62 | |
| 63 | // ======================> crt9212_interface |
| 64 | |
| 65 | struct crt9212_interface |
| 66 | { |
| 67 | devcb_write_line out_rof_func; |
| 68 | devcb_write_line out_wof_func; |
| 69 | devcb_read_line in_ren_func; |
| 70 | devcb_read_line in_wen_func; |
| 71 | devcb_read_line in_wen2_func; |
| 72 | }; |
| 73 | |
| 74 | |
| 75 | |
| 76 | // ======================> crt9212_device_config |
| 77 | |
| 78 | class crt9212_device_config : public device_config, |
| 79 | public crt9212_interface |
| 80 | { |
| 81 | friend class crt9212_device; |
| 82 | |
| 83 | // construction/destruction |
| 84 | crt9212_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); |
| 85 | |
| 86 | public: |
| 87 | // allocators |
| 88 | static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); |
| 89 | virtual device_t *alloc_device(running_machine &machine) const; |
| 90 | |
| 91 | protected: |
| 92 | // device_config overrides |
| 93 | virtual void device_config_complete(); |
| 94 | }; |
| 95 | |
| 96 | |
| 97 | |
| 98 | // ======================> crt9212_device |
| 99 | |
| 100 | class crt9212_device : public device_t |
| 101 | { |
| 102 | friend class crt9212_device_config; |
| 103 | |
| 104 | // construction/destruction |
| 105 | crt9212_device(running_machine &_machine, const crt9212_device_config &_config); |
| 106 | |
| 107 | public: |
| 108 | DECLARE_READ8_MEMBER( read ); |
| 109 | DECLARE_WRITE8_MEMBER( write ); |
| 110 | DECLARE_WRITE_LINE_MEMBER( clrcnt_w ); |
| 111 | DECLARE_WRITE_LINE_MEMBER( tog_w ); |
| 112 | DECLARE_WRITE_LINE_MEMBER( rclk_w ); |
| 113 | DECLARE_WRITE_LINE_MEMBER( wclk_w ); |
| 114 | |
| 115 | protected: |
| 116 | // device-level overrides |
| 117 | virtual void device_start(); |
| 118 | |
| 119 | private: |
| 120 | devcb_resolved_write_line m_out_rof_func; |
| 121 | devcb_resolved_write_line m_out_wof_func; |
| 122 | devcb_resolved_read_line m_in_ren_func; |
| 123 | devcb_resolved_read_line m_in_wen_func; |
| 124 | devcb_resolved_read_line m_in_wen2_func; |
| 125 | |
| 126 | UINT8 m_ram[CRT9212_RAM_SIZE][2]; |
| 127 | |
| 128 | UINT8 m_input; |
| 129 | UINT8 m_output; |
| 130 | |
| 131 | int m_buffer; |
| 132 | int m_rac; |
| 133 | int m_wac; |
| 134 | int m_tog; |
| 135 | int m_clrcnt; |
| 136 | int m_rclk; |
| 137 | int m_wclk; |
| 138 | |
| 139 | const crt9212_device_config &m_config; |
| 140 | }; |
| 141 | |
| 142 | |
| 143 | // device type definition |
| 144 | extern const device_type CRT9212; |
| 145 | |
| 146 | |
| 147 | |
| 148 | #endif |
src/mess/drivers/tandy2k.c
| r9645 | r9646 | |
| 39 | 39 | #include "machine/upd765.h" |
| 40 | 40 | #include "sound/speaker.h" |
| 41 | 41 | #include "video/crt9007.h" |
| 42 | #include "video/crt9212.h" |
| 42 | 43 | #include "includes/tandy2k.h" |
| 43 | 44 | |
| 44 | 45 | /* Read/Write Handlers */ |
| r9645 | r9646 | |
| 63 | 64 | UINT16 data = program->read_word(addr); |
| 64 | 65 | |
| 65 | 66 | // character |
| 66 | | // m_drb0->write(data & 0xff); |
| 67 | m_drb0->write(space, 0, data & 0xff); |
| 67 | 68 | |
| 68 | 69 | // attributes |
| 69 | | // m_drb1->write(data >> 8); |
| 70 | m_drb1->write(space, 0, data >> 8); |
| 70 | 71 | |
| 71 | 72 | return data & 0xff; |
| 72 | 73 | } |
| r9645 | r9646 | |
| 506 | 507 | } |
| 507 | 508 | } |
| 508 | 509 | */ |
| 509 | | static CRT9007_INTERFACE( crt9007_intf ) |
| 510 | static CRT9007_INTERFACE( vpac_intf ) |
| 510 | 511 | { |
| 511 | 512 | SCREEN_TAG, |
| 512 | 513 | 10, |
| r9645 | r9646 | |
| 521 | 522 | DEVCB_NULL // SLD CRT9021B U14 SLD |
| 522 | 523 | }; |
| 523 | 524 | |
| 525 | static CRT9212_INTERFACE( drb0_intf ) |
| 526 | { |
| 527 | DEVCB_NULL, // ROF |
| 528 | DEVCB_NULL, // WOF |
| 529 | DEVCB_DEVICE_LINE_MEMBER(CRT9007_TAG, crt9007_device, vlt_r), |
| 530 | DEVCB_DEVICE_LINE_MEMBER(CRT9007_TAG, crt9007_device, wben_r), |
| 531 | DEVCB_LINE_VCC |
| 532 | }; |
| 533 | |
| 534 | static CRT9212_INTERFACE( drb1_intf ) |
| 535 | { |
| 536 | DEVCB_NULL, // ROF |
| 537 | DEVCB_NULL, // WOF |
| 538 | DEVCB_DEVICE_LINE_MEMBER(CRT9007_TAG, crt9007_device, vlt_r), |
| 539 | DEVCB_DEVICE_LINE_MEMBER(CRT9007_TAG, crt9007_device, wben_r), |
| 540 | DEVCB_LINE_VCC |
| 541 | }; |
| 542 | |
| 524 | 543 | /* Intel 8251A Interface */ |
| 525 | 544 | |
| 526 | 545 | static WRITE_LINE_DEVICE_HANDLER( rxrdy_w ) |
| r9645 | r9646 | |
| 815 | 834 | MDRV_PALETTE_LENGTH(2) |
| 816 | 835 | MDRV_PALETTE_INIT(black_and_white) |
| 817 | 836 | |
| 818 | | MDRV_CRT9007_ADD(CRT9007_TAG, XTAL_16MHz*28/16, crt9007_intf, vpac_mem) |
| 837 | MDRV_CRT9007_ADD(CRT9007_TAG, XTAL_16MHz*28/16, vpac_intf, vpac_mem) |
| 838 | MDRV_CRT9212_ADD(CRT9212_0_TAG, drb0_intf) |
| 839 | MDRV_CRT9212_ADD(CRT9212_1_TAG, drb1_intf) |
| 819 | 840 | |
| 820 | 841 | /* sound hardware */ |
| 821 | 842 | MDRV_SPEAKER_STANDARD_MONO("mono") |