src/mess/machine/kc.c
| r13314 | r13315 | |
| 216 | 216 | active when the cassette motor is on. |
| 217 | 217 | */ |
| 218 | 218 | |
| 219 | void kc_state::update_cassette(int state) |
| 220 | { |
| 221 | int astb = (state & m_ardy) ? 0 : 1; |
| 219 | 222 | |
| 220 | | #define KC_CASSETTE_TIMER_FREQUENCY attotime::from_hz(4800) |
| 223 | // if state is changed updates the /ASTB line |
| 224 | if (m_astb ^ astb) |
| 225 | { |
| 226 | z80pio_astb_w(m_z80pio, astb); |
| 227 | m_astb = astb; |
| 228 | } |
| 229 | } |
| 221 | 230 | |
| 222 | | /* this timer is used to update the cassette */ |
| 223 | | /* this is the current state of the cassette motor */ |
| 224 | | /* ardy output from pio */ |
| 231 | static TIMER_CALLBACK(kc_cassette_oneshot_timer) |
| 232 | { |
| 233 | kc_state *state = machine.driver_data<kc_state>(); |
| 225 | 234 | |
| 235 | state->update_cassette(0); |
| 236 | |
| 237 | state->m_cassette_oneshot_timer->reset(); |
| 238 | } |
| 239 | |
| 240 | // timer used for polling data from cassette input |
| 241 | // enabled only when cassette motor is on |
| 226 | 242 | static TIMER_CALLBACK(kc_cassette_timer_callback) |
| 227 | 243 | { |
| 228 | 244 | kc_state *state = machine.driver_data<kc_state>(); |
| 229 | 245 | |
| 230 | | /* the cassette data is linked to /astb input of the pio. */ |
| 246 | // read cassette data |
| 231 | 247 | int bit = (state->m_cassette->input() > 0.0038) ? 1 : 0; |
| 232 | 248 | |
| 233 | | /* update astb with bit */ |
| 234 | | z80pio_astb_w(state->m_z80pio, bit & state->m_ardy); |
| 249 | // generates a pulse when the cassette input changes state |
| 250 | if (bit ^ state->m_cassette_in) |
| 251 | { |
| 252 | state->update_cassette(1); |
| 253 | state->m_cassette_in = bit; |
| 254 | state->m_cassette_oneshot_timer->adjust(attotime::from_double(TIME_OF_74LS123(RES_K(10), CAP_N(1)))); |
| 255 | } |
| 235 | 256 | } |
| 236 | 257 | |
| 237 | 258 | void kc_state::cassette_set_motor(int motor_state) |
| r13314 | r13315 | |
| 767 | 788 | void kc_state::machine_start() |
| 768 | 789 | { |
| 769 | 790 | m_cassette_timer = machine().scheduler().timer_alloc(FUNC(kc_cassette_timer_callback)); |
| 791 | m_cassette_oneshot_timer = machine().scheduler().timer_alloc(FUNC(kc_cassette_oneshot_timer)); |
| 770 | 792 | |
| 771 | 793 | // kc85 has a 50 Hz input to the ctc channel 2 and 3 |
| 772 | 794 | // channel 2 this controls the video colour flash |
src/mess/includes/kc.h
| r13314 | r13315 | |
| 18 | 18 | #include "machine/z80pio.h" |
| 19 | 19 | #include "machine/ram.h" |
| 20 | 20 | #include "machine/kc_keyb.h" |
| 21 | #include "machine/rescap.h" |
| 21 | 22 | #include "cpu/z80/z80daisy.h" |
| 22 | 23 | #include "sound/speaker.h" |
| 23 | 24 | #include "sound/wave.h" |
| r13314 | r13315 | |
| 44 | 45 | #define KC85_SCREEN_WIDTH 320 |
| 45 | 46 | #define KC85_SCREEN_HEIGHT 256 |
| 46 | 47 | |
| 48 | // cassette input polling frequency |
| 49 | #define KC_CASSETTE_TIMER_FREQUENCY attotime::from_hz(44100) |
| 47 | 50 | |
| 51 | |
| 48 | 52 | class kc_state : public driver_device |
| 49 | 53 | { |
| 50 | 54 | public: |
| r13314 | r13315 | |
| 107 | 111 | DECLARE_WRITE_LINE_MEMBER( keyboard_cb ); |
| 108 | 112 | |
| 109 | 113 | // cassette |
| 114 | void update_cassette(int state); |
| 110 | 115 | void cassette_set_motor(int motor_state); |
| 111 | 116 | |
| 112 | 117 | // speaker |
| r13314 | r13315 | |
| 118 | 123 | // driver state |
| 119 | 124 | UINT8 * m_ram_base; |
| 120 | 125 | int m_pio_data[2]; |
| 121 | | emu_timer * m_cassette_timer; |
| 122 | 126 | int m_high_resolution; |
| 123 | 127 | UINT8 m_ardy; |
| 124 | 128 | UINT8 m_brdy; |
| r13314 | r13315 | |
| 129 | 133 | int m_k1_line; |
| 130 | 134 | UINT8 m_speaker_level; |
| 131 | 135 | |
| 136 | // cassette |
| 137 | emu_timer * m_cassette_timer; |
| 138 | emu_timer * m_cassette_oneshot_timer; |
| 139 | int m_astb; |
| 140 | int m_cassette_in; |
| 141 | |
| 132 | 142 | kcexp_slot_device * m_expansions[3]; |
| 133 | 143 | }; |
| 134 | 144 | |
src/mess/drivers/kc.c
| r13314 | r13315 | |
| 125 | 125 | MCFG_CPU_CONFIG(kc85_daisy_chain) |
| 126 | 126 | MCFG_QUANTUM_TIME(attotime::from_hz(60)) |
| 127 | 127 | |
| 128 | | MCFG_Z80PIO_ADD( "z80pio", 1379310.344828, kc85_pio_intf ) |
| 129 | | MCFG_Z80CTC_ADD( "z80ctc", 1379310.344828, kc85_ctc_intf ) |
| 128 | MCFG_Z80PIO_ADD( "z80pio", KC85_3_CLOCK, kc85_pio_intf ) |
| 129 | MCFG_Z80CTC_ADD( "z80ctc", KC85_3_CLOCK, kc85_ctc_intf ) |
| 130 | 130 | |
| 131 | 131 | /* video hardware */ |
| 132 | 132 | MCFG_SCREEN_ADD("screen", RASTER) |
| r13314 | r13315 | |
| 178 | 178 | MCFG_CPU_CONFIG(kc85_daisy_chain) |
| 179 | 179 | MCFG_QUANTUM_TIME(attotime::from_hz(60)) |
| 180 | 180 | |
| 181 | | MCFG_Z80PIO_ADD( "z80pio", 1379310.344828, kc85_pio_intf ) |
| 182 | | MCFG_Z80CTC_ADD( "z80ctc", 1379310.344828, kc85_ctc_intf ) |
| 181 | MCFG_Z80PIO_ADD( "z80pio", KC85_4_CLOCK, kc85_pio_intf ) |
| 182 | MCFG_Z80CTC_ADD( "z80ctc", KC85_4_CLOCK, kc85_ctc_intf ) |
| 183 | 183 | |
| 184 | 184 | /* video hardware */ |
| 185 | 185 | MCFG_SCREEN_ADD("screen", RASTER) |