Previous 15994 Revisions Next

r4047 Friday 2nd January, 2009 at 11:28:27 UTC by Robbbert
[DAI] Fixed keyboard in Basic, bugs in tms5501 device, and soft reset.
[src/mess/drivers]dai.c
[src/mess/includes]dai.h
[src/mess/machine]dai.c tms5501.c tms5501.h

src/mess/includes/dai.h
r4046r4047
2222extern const tms5501_interface dai_tms5501_interface;
2323
2424MACHINE_START( dai );
25MACHINE_RESET( dai );
2526READ8_HANDLER( dai_io_discrete_devices_r );
2627WRITE8_HANDLER( dai_io_discrete_devices_w );
2728WRITE8_HANDLER( dai_stack_interrupt_circuit_w );
src/mess/machine/dai.c
r4046r4047
3232static const device_config *dai_tms5501;
3333
3434
35static DIRECT_UPDATE_HANDLER(dai_opbaseoverride)
36{
37   tms5501_set_pio_bit_7 (dai_tms5501, (input_port_read(space->machine, "IN8") & 0x04) ? 1:0);
38   return address;
39}
40
4135/* Memory */
4236
4337WRITE8_HANDLER( dai_stack_interrupt_circuit_w )
r4046r4047
139133   }
140134};
141135
136static TIMER_CALLBACK( dai_timer )
137{
138   tms5501_set_pio_bit_7 (dai_tms5501, (input_port_read(machine, "IN8") & 0x04) ? 1:0);
139}
140
142141MACHINE_START( dai )
143142{
144   const address_space *space = cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM );
143   dai_tms5501 = device_list_find_by_tag( machine->config->devicelist, TMS5501, "tms5501" );
145144
146   memory_set_direct_update_handler(space, dai_opbaseoverride);
147
148   memory_set_bankptr(machine, 1, mess_ram);
149145   memory_configure_bank(machine, 2, 0, 4, memory_region(machine, "main") + 0x010000, 0x1000);
146}
150147
148MACHINE_RESET( dai )
149{
150   memory_set_bankptr(machine, 1, mess_ram);
151151   timer_set(machine, attotime_zero, NULL, 0, dai_bootstrap_callback);
152
153   dai_tms5501 = device_list_find_by_tag( machine->config->devicelist, TMS5501, "tms5501" );
152   timer_pulse(machine, ATTOTIME_IN_HZ(100),NULL,0,dai_timer);   /* timer for tms5501 */
154153}
155154
156155/***************************************************************************
src/mess/machine/tms5501.c
r4046r4047
2929
3030#define DEBUG_TMS5501   0
3131
32#define LOG_TMS5501(device, message, data) do { if (DEBUG_TMS5501) logerror ("TMS5501 %s: %s %02x\n", device->tag, message, data); } while (0)
32#define LOG_TMS5501(device, message, data) do { if (DEBUG_TMS5501) printf ("\nTMS5501 %s: %s %02x", device->tag, message, data); } while (0)
3333
3434/* status register */
3535#define TMS5501_FRAME_ERROR      0x01
r4046r4047
114114   return (const tms5501_interface *) device->static_config;
115115}
116116
117static const UINT8 timer_name[] = { TMS5501_TIMER_0_INT, TMS5501_TIMER_1_INT, TMS5501_TIMER_2_INT, TMS5501_TIMER_3_INT, TMS5501_TIMER_4_INT };
117118
118119/***************************************************************************
119120    IMPLEMENTATION
r4046r4047
165166      int level = find_first_bit(current_ints);
166167      LOG_TMS5501(device, "Interrupt level", level);
167168
168      /* reseting proper bit in pending interrupts register */
169      /* resetting proper bit in pending interrupts register */
169170      tms->pending_interrupts &= ~(1<<level);
170171
171172      /* selecting  interrupt vector */
r4046r4047
200201static void tms5501_timer_decrementer(const device_config *device, UINT8 mask)
201202{
202203   tms5501_t *tms = get_token(device);
203   tms->pending_interrupts |= mask;
204
205   if ((mask != TMS5501_TIMER_4_INT) || ((mask == TMS5501_TIMER_4_INT) && (!(tms->command & TMS5501_INT_7_SELECT))))
206      tms->pending_interrupts |= mask;
207
204208   tms5501_field_interrupts(device);
205209}
206210
r4046r4047
229233
230234   if (tms->timer_counter[timer])
231235   {   /* reset clock interval */
232      timer_adjust_periodic(tms->timer[timer], double_to_attotime((double) tms->timer_counter[0] / (intf->clock_rate / 128.)), timer, double_to_attotime((double) tms->timer_counter[timer] / (intf->clock_rate / 128.)));
236      timer_adjust_periodic(tms->timer[timer], double_to_attotime((double) tms->timer_counter[0] / (intf->clock_rate / 128.)), timer_name[timer], double_to_attotime((double) tms->timer_counter[timer] / (intf->clock_rate / 128.)));
233237   }
234238   else
235239   {   /* clock interval == 0 -> no timer */
r4046r4047
356360   const tms5501_interface *intf = get_interface(device);
357361
358362   UINT8 data = 0x00;
359   switch (offset&0x000f)
363   offset &= 0x0f;
364
365   switch (offset)
360366   {
361367      case 0x00:   /* Serial input buffer */
362368         data = tms->sio_input_buffer;
r4046r4047
409415{
410416   tms5501_t *tms = get_token(device);
411417   const tms5501_interface *intf = get_interface(device);
418   offset &= 0x0f;
412419
413   switch (offset&0x000f)
420   switch (offset)
414421   {
415422      case 0x00:   /* Serial input buffer */
416423      case 0x01:   /* Keyboard input port, Page blanking signal */
r4046r4047
478485      case 0x0b:   /* Timer 2 counter */
479486      case 0x0c:   /* Timer 3 counter */
480487      case 0x0d:   /* Timer 4 counter */
481         tms->timer_counter[(offset&0x0f)-0x09] = data;
482         tms5501_timer_reload(device, (offset&0x0f)-0x09);
483         LOG_TMS5501(device, "Write timer", (offset&0x0f)-0x09);
488         offset -= 9;
489         tms->timer_counter[offset] = data;
490         tms5501_timer_reload(device, offset);
491         LOG_TMS5501(device, "Write timer", offset);
484492         LOG_TMS5501(device, "Timer counter set", data);
485493         break;
486494   }
src/mess/machine/tms5501.h
r4046r4047
2222    TYPE DEFINITIONS
2323***************************************************************************/
2424
25/* TMS5501 timer and interrupt controler */
25/* TMS5501 timer and interrupt controller */
2626typedef struct _tms5501_interface tms5501_interface;
2727struct _tms5501_interface
2828{
src/mess/drivers/dai.c
r4046r4047
189189   MDRV_QUANTUM_TIME(HZ(60))
190190
191191   MDRV_MACHINE_START( dai )
192   MDRV_MACHINE_RESET( dai )
192193
193194   MDRV_PIT8253_ADD( "pit8253", dai_pit8253_intf )
194195

Previous 15994 Revisions Next


© 1998-2018 The MESS Team