~ubuntu-branches/ubuntu/lucid/sdlmame/lucid

« back to all changes in this revision

Viewing changes to src/emu/machine/z80ctc.c

  • Committer: Bazaar Package Importer
  • Author(s): Cesare Falco
  • Date: 2009-11-03 17:10:15 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20091103171015-6hop4ory5lxnumpn
Tags: 0.135-0ubuntu1
* New upstream release - Closes (LP: #403212)
* debian/watch: unstable releases are no longer detected
* mame.ini: added the cheat subdirectories to cheatpath so zipped
  cheatfiles will be searched too
* renamed crsshair subdirectory to crosshair to reflect upstream change
* mame.ini: renamed references to crosshair subdirectory (see above)

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
typedef struct _ctc_channel ctc_channel;
76
76
struct _ctc_channel
77
77
{
78
 
        write8_device_func      zc;                                     /* zero crossing callbacks */
 
78
        devcb_resolved_write_line       zc;                     /* zero crossing callbacks */
 
79
 
79
80
        UINT8                           notimer;                        /* no timer masks */
80
81
        UINT16                          mode;                           /* current mode */
81
82
        UINT16                          tconst;                         /* time constant */
89
90
typedef struct _z80ctc z80ctc;
90
91
struct _z80ctc
91
92
{
 
93
        devcb_resolved_write_line intr;                 /* interrupt callback */
 
94
 
92
95
        UINT8                           vector;                         /* interrupt vector */
93
96
        attotime                        period16;                       /* 16/system clock */
94
97
        attotime                        period256;                      /* 256/system clock */
95
 
        void (*intr)(const device_config *device, int which);   /* interrupt callback */
96
98
        ctc_channel                     channel[4];                     /* data for each channel */
97
99
};
98
100
 
129
131
static void interrupt_check(const device_config *device)
130
132
{
131
133
        z80ctc *ctc = get_safe_token(device);
 
134
        int state = (z80ctc_irq_state(device) & Z80_DAISY_INT) ? ASSERT_LINE : CLEAR_LINE;
132
135
 
133
 
        /* if we have a callback, update it with the current state */
134
 
        if (ctc->intr != NULL)
135
 
                (*ctc->intr)(device, (z80ctc_irq_state(device) & Z80_DAISY_INT) ? ASSERT_LINE : CLEAR_LINE);
 
136
        devcb_call_write_line(&ctc->intr, state);
136
137
}
137
138
 
138
 
 
139
139
static TIMER_CALLBACK( timercallback )
140
140
{
141
141
        const device_config *device = (const device_config *)ptr;
151
151
        }
152
152
 
153
153
        /* generate the clock pulse */
154
 
        if (channel->zc != NULL)
155
 
        {
156
 
                (*channel->zc)(device, 0, 1);
157
 
                (*channel->zc)(device, 0, 0);
158
 
        }
 
154
        devcb_call_write_line(&channel->zc, 1);
 
155
        devcb_call_write_line(&channel->zc, 0);
159
156
 
160
157
        /* reset the down counter */
161
158
        channel->down = channel->tconst;
317
314
    EXTERNAL TRIGGERS
318
315
***************************************************************************/
319
316
 
320
 
void z80ctc_trg_w(const device_config *device, int ch, UINT8 data)
 
317
static void z80ctc_trg_w(const device_config *device, int ch, UINT8 data)
321
318
{
322
319
        z80ctc *ctc = get_safe_token(device);
323
320
        ctc_channel *channel = &ctc->channel[ch];
370
367
                }
371
368
        }
372
369
}
373
 
WRITE8_DEVICE_HANDLER( z80ctc_trg0_w ) { z80ctc_trg_w(device, 0, data); }
374
 
WRITE8_DEVICE_HANDLER( z80ctc_trg1_w ) { z80ctc_trg_w(device, 1, data); }
375
 
WRITE8_DEVICE_HANDLER( z80ctc_trg2_w ) { z80ctc_trg_w(device, 2, data); }
376
 
WRITE8_DEVICE_HANDLER( z80ctc_trg3_w ) { z80ctc_trg_w(device, 3, data); }
 
370
WRITE_LINE_DEVICE_HANDLER( z80ctc_trg0_w ) { z80ctc_trg_w(device, 0, state); }
 
371
WRITE_LINE_DEVICE_HANDLER( z80ctc_trg1_w ) { z80ctc_trg_w(device, 1, state); }
 
372
WRITE_LINE_DEVICE_HANDLER( z80ctc_trg2_w ) { z80ctc_trg_w(device, 2, state); }
 
373
WRITE_LINE_DEVICE_HANDLER( z80ctc_trg3_w ) { z80ctc_trg_w(device, 3, state); }
377
374
 
378
375
 
379
376
 
475
472
                channel->notimer = (intf->notimer >> ch) & 1;
476
473
                channel->timer = timer_alloc(device->machine, timercallback, ptr);
477
474
        }
478
 
        ctc->intr = intf->intr;
479
 
        ctc->channel[0].zc = intf->zc0;
480
 
        ctc->channel[1].zc = intf->zc1;
481
 
        ctc->channel[2].zc = intf->zc2;
482
 
        ctc->channel[3].zc = NULL;
 
475
 
 
476
        /* resolve callbacks */
 
477
        devcb_resolve_write_line(&ctc->intr, &intf->intr, device);
 
478
        devcb_resolve_write_line(&ctc->channel[0].zc, &intf->zc0, device);
 
479
        devcb_resolve_write_line(&ctc->channel[1].zc, &intf->zc1, device);
 
480
        devcb_resolve_write_line(&ctc->channel[2].zc, &intf->zc2, device);
483
481
 
484
482
        /* register for save states */
485
483
    state_save_register_device_item(device, 0, ctc->vector);