Previous 15994 Revisions Next

r13315 Sunday 20th November, 2011 at 19:00:04 UTC by Sandro Ronco
kc: fixed cassette loading. (no whatsnew)
[src/mess/drivers]kc.c
[src/mess/includes]kc.h
[src/mess/machine]kc.c

src/mess/machine/kc.c
r13314r13315
216216    active when the cassette motor is on.
217217*/
218218
219void kc_state::update_cassette(int state)
220{
221   int astb = (state & m_ardy) ? 0 : 1;
219222
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}
221230
222/* this timer is used to update the cassette */
223/* this is the current state of the cassette motor */
224/* ardy output from pio */
231static TIMER_CALLBACK(kc_cassette_oneshot_timer)
232{
233   kc_state *state = machine.driver_data<kc_state>();
225234
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
226242static TIMER_CALLBACK(kc_cassette_timer_callback)
227243{
228244   kc_state *state = machine.driver_data<kc_state>();
229245
230   /* the cassette data is linked to /astb input of the pio. */
246   // read cassette data
231247   int bit = (state->m_cassette->input() > 0.0038) ? 1 : 0;
232248
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   }
235256}
236257
237258void kc_state::cassette_set_motor(int motor_state)
r13314r13315
767788void kc_state::machine_start()
768789{
769790   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));
770792
771793   // kc85 has a 50 Hz input to the ctc channel 2 and 3
772794   // channel 2 this controls the video colour flash
src/mess/includes/kc.h
r13314r13315
1818#include "machine/z80pio.h"
1919#include "machine/ram.h"
2020#include "machine/kc_keyb.h"
21#include "machine/rescap.h"
2122#include "cpu/z80/z80daisy.h"
2223#include "sound/speaker.h"
2324#include "sound/wave.h"
r13314r13315
4445#define KC85_SCREEN_WIDTH 320
4546#define KC85_SCREEN_HEIGHT 256
4647
48// cassette input polling frequency
49#define KC_CASSETTE_TIMER_FREQUENCY attotime::from_hz(44100)
4750
51
4852class kc_state : public driver_device
4953{
5054public:
r13314r13315
107111   DECLARE_WRITE_LINE_MEMBER( keyboard_cb );
108112
109113   // cassette
114   void update_cassette(int state);
110115   void cassette_set_motor(int motor_state);
111116
112117   // speaker
r13314r13315
118123   // driver state
119124   UINT8 *            m_ram_base;
120125   int             m_pio_data[2];
121   emu_timer *         m_cassette_timer;
122126   int               m_high_resolution;
123127   UINT8            m_ardy;
124128   UINT8            m_brdy;
r13314r13315
129133   int               m_k1_line;
130134   UINT8            m_speaker_level;
131135
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
132142   kcexp_slot_device *   m_expansions[3];
133143};
134144
src/mess/drivers/kc.c
r13314r13315
125125   MCFG_CPU_CONFIG(kc85_daisy_chain)
126126   MCFG_QUANTUM_TIME(attotime::from_hz(60))
127127
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 )
130130
131131   /* video hardware */
132132   MCFG_SCREEN_ADD("screen", RASTER)
r13314r13315
178178   MCFG_CPU_CONFIG(kc85_daisy_chain)
179179   MCFG_QUANTUM_TIME(attotime::from_hz(60))
180180
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 )
183183
184184   /* video hardware */
185185   MCFG_SCREEN_ADD("screen", RASTER)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team