trunk/src/mess/drivers/d6800.c
| r22702 | r22703 | |
| 92 | 92 | required_ioport m_io_shift; |
| 93 | 93 | private: |
| 94 | 94 | UINT8 m_rtc; |
| 95 | | bool m_screen_on; |
| 95 | bool m_ca1; |
| 96 | bool m_ca2; |
| 97 | bool m_cb1; |
| 98 | bool m_cb2; |
| 99 | UINT8 m_cass_data[3]; |
| 96 | 100 | UINT8 m_portb; |
| 97 | 101 | virtual void machine_start(); |
| 98 | 102 | virtual void machine_reset(); |
| r22702 | r22703 | |
| 188 | 192 | |
| 189 | 193 | for (x = 0; x < 8; x++) |
| 190 | 194 | { |
| 191 | | if (m_screen_on) |
| 195 | if (m_cb2) |
| 192 | 196 | gfx = m_videoram[ x | (y<<3)]; |
| 193 | 197 | |
| 194 | 198 | *p++ = BIT(gfx, 7); |
| r22702 | r22703 | |
| 214 | 218 | m_rtc = 0; |
| 215 | 219 | |
| 216 | 220 | UINT8 data = m_io_x0->read() & m_io_x1->read() & m_io_x2->read() & m_io_x3->read(); |
| 217 | | m_pia->ca1_w( (data == 255) ? 0 : 1); |
| 218 | | data = m_io_shift->read(); |
| 219 | | m_pia->ca2_w( data ); |
| 220 | | m_pia->cb1_w((m_rtc) ? 1 : 0); |
| 221 | m_ca1 = (data == 255) ? 0 : 1; |
| 222 | m_ca2 = (bool)m_io_shift->read(); |
| 223 | m_cb1 = (m_rtc) ? 1 : 0; |
| 224 | |
| 225 | m_pia->ca1_w(m_ca1); |
| 226 | m_pia->ca2_w(m_ca2); |
| 227 | m_pia->cb1_w(m_cb1); |
| 228 | |
| 229 | /* cassette - turn 1200/2400Hz to a bit */ |
| 230 | m_cass_data[1]++; |
| 231 | UINT8 cass_ws = (m_cass->input() > +0.03) ? 1 : 0; |
| 232 | |
| 233 | if (cass_ws != m_cass_data[0]) |
| 234 | { |
| 235 | m_cass_data[0] = cass_ws; |
| 236 | m_cass_data[2] = ((m_cass_data[1] < 12) ? 0 : 128); |
| 237 | m_cass_data[1] = 0; |
| 238 | } |
| 221 | 239 | } |
| 222 | 240 | |
| 223 | 241 | |
| 224 | 242 | READ_LINE_MEMBER( d6800_state::d6800_rtc_pulse ) |
| 225 | 243 | { |
| 226 | | return (m_rtc) ? 1 : 0; |
| 244 | return m_cb1; |
| 227 | 245 | } |
| 228 | 246 | |
| 229 | 247 | READ_LINE_MEMBER( d6800_state::d6800_keydown_r ) |
| 230 | 248 | { |
| 231 | | UINT8 data = m_io_x0->read() & m_io_x1->read() & m_io_x2->read() & m_io_x3->read(); |
| 232 | | |
| 233 | | return (data == 255) ? 0 : 1; |
| 249 | return m_ca1; |
| 234 | 250 | } |
| 235 | 251 | |
| 236 | 252 | READ_LINE_MEMBER( d6800_state::d6800_fn_key_r ) |
| 237 | 253 | { |
| 238 | | return m_io_shift->read(); |
| 254 | return m_ca2; |
| 239 | 255 | } |
| 240 | 256 | |
| 241 | 257 | WRITE_LINE_MEMBER( d6800_state::d6800_screen_w ) |
| 242 | 258 | { |
| 243 | | m_screen_on = state; |
| 259 | m_cb2 = state; |
| 244 | 260 | } |
| 245 | 261 | |
| 246 | 262 | READ8_MEMBER( d6800_state::d6800_cassette_r ) |
| r22702 | r22703 | |
| 252 | 268 | knows if the tone is 1200 or 2400 Hz. Input to PIA is bit 7. |
| 253 | 269 | */ |
| 254 | 270 | |
| 255 | | return ((m_cass->input() > 0.03) ? 1 : 0) | m_portb; |
| 271 | return m_cass_data[2] | m_portb; |
| 256 | 272 | } |
| 257 | 273 | |
| 258 | 274 | WRITE8_MEMBER( d6800_state::d6800_cassette_w ) |
| r22702 | r22703 | |
| 266 | 282 | |
| 267 | 283 | m_cass->output(BIT(data, 0) ? -1.0 : +1.0); |
| 268 | 284 | m_beeper->set_frequency(BIT(data, 0) ? 2400 : 1200); |
| 269 | | m_beeper->set_state(BIT(data, 6) & m_screen_on); |
| 285 | m_beeper->set_state(BIT(data, 6) & m_cb2); |
| 270 | 286 | |
| 271 | | m_portb = data; |
| 287 | m_portb = data & 0x7f; |
| 272 | 288 | } |
| 273 | 289 | |
| 274 | 290 | READ8_MEMBER( d6800_state::d6800_keyboard_r ) |
| r22702 | r22703 | |
| 329 | 345 | { |
| 330 | 346 | m_beeper->set_state(0); |
| 331 | 347 | m_rtc = 0; |
| 348 | m_cass_data[0] = 0; |
| 349 | m_cass_data[1] = 0; |
| 350 | m_cass_data[2] = 128; |
| 332 | 351 | } |
| 333 | 352 | |
| 334 | 353 | /* Machine Drivers */ |