Previous 15994 Revisions Next

r9330 Wednesday 6th October, 2010 at 12:10:02 UTC by Curt Coder
[TANDY2K] Added 80186-specific input/output lines.
[src/emu/cpu/i86]i86.c i86.h
[src/mess/drivers]tandy2k.c

src/emu/cpu/i86/i86.c
r9329r9330
6666   char seg_prefix;               /* prefix segment indicator */
6767   unsigned ea;
6868   UINT16 eo; /* HJB 12/13/98 effective offset of the address (before segment is added) */
69
70   devcb_resolved_write_line   out_tmrout0_func;
71   devcb_resolved_write_line   out_tmrout1_func;
6972};
7073
7174INLINE i8086_state *get_safe_token(running_device *device)
r9329r9330
209212   cpustate->fetch_xor = 0;
210213}
211214
215static CPU_INIT( i80186 )
216{
217   i8086_state *cpustate = get_safe_token(device);
218
219   CPU_INIT_CALL(i8086);
220
221   /* resolve callbacks */
222   i80186_interface *intf = (i80186_interface *) device->baseconfig().static_config();
223
224   if (intf != NULL)
225   {
226      devcb_resolve_write_line(&cpustate->out_tmrout0_func, &intf->out_tmrout0_func, device);
227      devcb_resolve_write_line(&cpustate->out_tmrout1_func, &intf->out_tmrout1_func, device);
228   }
229}
230
212231static CPU_RESET( i8086 )
213232{
214233   i8086_state *cpustate = get_safe_token(device);
r9329r9330
266285   }
267286}
268287
288static void set_drq_line(i8086_state *cpustate, int irqline, int state)
289{
290   // TODO implement me
291}
292
293static void set_tmrin_line(i8086_state *cpustate, int irqline, int state)
294{
295   // TODO implement me
296}
297
269298/* PJB 03/05 */
270299static void set_test_line(i8086_state *cpustate, int state)
271300{
r9329r9330
501530   switch (state)
502531   {
503532      /* --- the following bits of info are set as 64-bit signed integers --- */
504      case CPUINFO_INT_INPUT_STATE + 0:            set_irq_line(cpustate, 0, info->i);            break;
533      case CPUINFO_INT_INPUT_STATE + 0:            set_irq_line(cpustate, 0, info->i);               break;
505534      case CPUINFO_INT_INPUT_STATE + INPUT_LINE_NMI:   set_irq_line(cpustate, INPUT_LINE_NMI, info->i);   break;
506535      case CPUINFO_INT_INPUT_STATE + INPUT_LINE_TEST:   set_test_line(cpustate, info->i);               break; /* PJB 03/05 */
507536   }
r9329r9330
563592
564593      /* --- the following bits of info are returned as NULL-terminated strings --- */
565594      case DEVINFO_STR_NAME:                     strcpy(info->s, "8086");            break;
566      case DEVINFO_STR_FAMILY:               strcpy(info->s, "Intel 80x86");         break;
567      case DEVINFO_STR_VERSION:               strcpy(info->s, "1.4");               break;
568      case DEVINFO_STR_SOURCE_FILE:                  strcpy(info->s, __FILE__);            break;
569      case DEVINFO_STR_CREDITS:               strcpy(info->s, "Real mode i286 emulator v1.4 by Fabrice Frances\n(initial work cpustate->based on David Hedley's pcemu)"); break;
595      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "Intel 80x86");         break;
596      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.4");               break;
597      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);            break;
598      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Real mode i286 emulator v1.4 by Fabrice Frances\n(initial work cpustate->based on David Hedley's pcemu)"); break;
570599   }
571600}
572601
r9329r9330
598627 * CPU-specific get_info/set_info
599628 **************************************************************************/
600629
630static CPU_SET_INFO( i80186 )
631{
632   i8086_state *cpustate = get_safe_token(device);
633
634   switch (state)
635   {
636      /* --- the following bits of info are set as 64-bit signed integers --- */
637      case CPUINFO_INT_INPUT_STATE + INPUT_LINE_INT0:      set_irq_line(cpustate, 0, info->i);               break;
638      case CPUINFO_INT_INPUT_STATE + INPUT_LINE_INT1:      set_irq_line(cpustate, 1, info->i);               break;
639      case CPUINFO_INT_INPUT_STATE + INPUT_LINE_INT2:      set_irq_line(cpustate, 2, info->i);               break;
640      case CPUINFO_INT_INPUT_STATE + INPUT_LINE_INT3:      set_irq_line(cpustate, 3, info->i);               break;
641      case CPUINFO_INT_INPUT_STATE + INPUT_LINE_DRQ0:      set_drq_line(cpustate, 0, info->i);               break;
642      case CPUINFO_INT_INPUT_STATE + INPUT_LINE_DRQ1:      set_drq_line(cpustate, 1, info->i);               break;
643      case CPUINFO_INT_INPUT_STATE + INPUT_LINE_TMRIN0:   set_tmrin_line(cpustate, 0, info->i);            break;
644      case CPUINFO_INT_INPUT_STATE + INPUT_LINE_TMRIN1:   set_tmrin_line(cpustate, 1, info->i);            break;
645      case CPUINFO_INT_INPUT_STATE + INPUT_LINE_NMI:      set_irq_line(cpustate, INPUT_LINE_NMI, info->i);   break;
646      case CPUINFO_INT_INPUT_STATE + INPUT_LINE_TEST:      set_test_line(cpustate, info->i);               break; /* PJB 03/05 */
647   }
648}
649
601650CPU_GET_INFO( i80186 )
602651{
603652   switch (state)
604653   {
605654      /* --- the following bits of info are returned as 64-bit signed integers --- */
606      case CPUINFO_INT_CLOCK_MULTIPLIER:            info->i = 1;                     break;
607      case CPUINFO_INT_CLOCK_DIVIDER:               info->i = 2;                     break;
655      case CPUINFO_INT_CLOCK_MULTIPLIER:            info->i = 1;                        break;
656      case CPUINFO_INT_CLOCK_DIVIDER:               info->i = 2;                        break;
608657
609658      /* --- the following bits of info are returned as pointers to data or functions --- */
610      case CPUINFO_FCT_EXECUTE:                  info->execute = CPU_EXECUTE_NAME(i80186);break;
659      case CPUINFO_FCT_SET_INFO:                  info->setinfo = CPU_SET_INFO_NAME(i80186);   break;
660      case CPUINFO_FCT_INIT:                     info->init = CPU_INIT_NAME(i80186);         break;
661      case CPUINFO_FCT_EXECUTE:                  info->execute = CPU_EXECUTE_NAME(i80186);   break;
611662
612663      /* --- the following bits of info are returned as NULL-terminated strings --- */
613      case DEVINFO_STR_NAME:                     strcpy(info->s, "80186");            break;
664      case DEVINFO_STR_NAME:                     strcpy(info->s, "80186");               break;
614665
615      default:                              CPU_GET_INFO_CALL(i8086);            break;
666      default:                              CPU_GET_INFO_CALL(i8086);               break;
616667   }
617668}
618669
src/emu/cpu/i86/i86.h
r9329r9330
55#define __I86INTF_H__
66
77
8#define INPUT_LINE_TEST 20    /* PJB 03/05 */
8#define INPUT_LINE_INT0         INPUT_LINE_IRQ0
9#define INPUT_LINE_INT1         INPUT_LINE_IRQ1
10#define INPUT_LINE_INT2         INPUT_LINE_IRQ2
11#define INPUT_LINE_INT3         INPUT_LINE_IRQ3
12#define INPUT_LINE_TEST         20    /* PJB 03/05 */
13#define INPUT_LINE_DRQ0         21
14#define INPUT_LINE_DRQ1         22
15#define INPUT_LINE_TMRIN0      23
16#define INPUT_LINE_TMRIN1      24
917
18
19typedef struct _i80186_interface i80186_interface;
20struct _i80186_interface
21{
22   devcb_write_line      out_tmrout0_func;
23   devcb_write_line      out_tmrout1_func;
24};
25#define I80186_INTERFACE(name) const i80186_interface (name) =
26
27
1028enum
1129{
1230   I8086_IP,
src/mess/drivers/tandy2k.c
r9329r9330
106106   /* FDC reset */
107107   upd765_reset_w(state->fdc, BIT(data, 5));
108108
109   /* TODO timer 0 enable */
109   /* timer 0 enable */
110   cputag_set_input_line(space->machine, I80186_TAG, INPUT_LINE_TMRIN0, BIT(data, 6));
110111
111   /* TODO timer 1 enable */
112   /* timer 1 enable */
113   cputag_set_input_line(space->machine, I80186_TAG, INPUT_LINE_TMRIN1, BIT(data, 7));
112114}
113115
114116static WRITE8_HANDLER( dma_mux_w )
r9329r9330
198200   logerror("Address Control %02x\n", data);
199201}
200202
201//static READ8_HANDLER( keyboard_x0_r )
202//{
203//  /*
204//
205//        bit     description
206//
207//        0       X0
208//        1       X1
209//        2       X2
210//        3       X3
211//        4       X4
212//        5       X5
213//        6       X6
214//        7       X7
215//
216//    */
217//
218//  tandy2k_state *state = space->machine->driver_data<tandy2k_state>();
219//
220//  UINT8 data = 0xff;
221//
222//  if (!BIT(state->keylatch,  0)) data &= input_port_read(space->machine,  "Y0");
223//  if (!BIT(state->keylatch,  1)) data &= input_port_read(space->machine,  "Y1");
224//  if (!BIT(state->keylatch,  2)) data &= input_port_read(space->machine,  "Y2");
225//  if (!BIT(state->keylatch,  3)) data &= input_port_read(space->machine,  "Y3");
226//  if (!BIT(state->keylatch,  4)) data &= input_port_read(space->machine,  "Y4");
227//  if (!BIT(state->keylatch,  5)) data &= input_port_read(space->machine,  "Y5");
228//  if (!BIT(state->keylatch,  6)) data &= input_port_read(space->machine,  "Y6");
229//  if (!BIT(state->keylatch,  7)) data &= input_port_read(space->machine,  "Y7");
230//  if (!BIT(state->keylatch,  8)) data &= input_port_read(space->machine,  "Y8");
231//  if (!BIT(state->keylatch,  9)) data &= input_port_read(space->machine,  "Y9");
232//  if (!BIT(state->keylatch, 10)) data &= input_port_read(space->machine, "Y10");
233//  if (!BIT(state->keylatch, 11)) data &= input_port_read(space->machine, "Y11");
234//
235//  return ~data;
236//}
237//
238//static WRITE8_HANDLER( keyboard_y0_w )
239//{
240//  /*
241//
242//        bit     description
243//
244//        0       Y0
245//        1       Y1
246//        2       Y2
247//        3       Y3
248//        4       Y4
249//        5       Y5
250//        6       Y6
251//        7       Y7
252//
253//    */
254//
255//  tandy2k_state *state = space->machine->driver_data<tandy2k_state>();
256//
257//  /* keyboard row select */
258//  state->keylatch = (state->keylatch & 0xff00) | data;
259//}
260//
261//static WRITE8_HANDLER( keyboard_y8_w )
262//{
263//  /*
264//
265//        bit     description
266//
267//        0       Y8
268//        1       Y9
269//        2       Y10
270//        3       Y11
271//        4       LED 2
272//        5       LED 1
273//        6
274//        7
275//
276//    */
277//
278//  tandy2k_state *state = space->machine->driver_data<tandy2k_state>();
279//
280//  /* keyboard row select */
281//  state->keylatch = ((data & 0x0f) << 8) | (state->keylatch & 0xff);
282//}
203static READ8_HANDLER( keyboard_x0_r )
204{
205  /*
283206
207        bit     description
208
209        0       X0
210        1       X1
211        2       X2
212        3       X3
213        4       X4
214        5       X5
215        6       X6
216        7       X7
217
218    */
219
220  tandy2k_state *state = space->machine->driver_data<tandy2k_state>();
221
222  UINT8 data = 0xff;
223
224  if (!BIT(state->keylatch,  0)) data &= input_port_read(space->machine,  "Y0");
225  if (!BIT(state->keylatch,  1)) data &= input_port_read(space->machine,  "Y1");
226  if (!BIT(state->keylatch,  2)) data &= input_port_read(space->machine,  "Y2");
227  if (!BIT(state->keylatch,  3)) data &= input_port_read(space->machine,  "Y3");
228  if (!BIT(state->keylatch,  4)) data &= input_port_read(space->machine,  "Y4");
229  if (!BIT(state->keylatch,  5)) data &= input_port_read(space->machine,  "Y5");
230  if (!BIT(state->keylatch,  6)) data &= input_port_read(space->machine,  "Y6");
231  if (!BIT(state->keylatch,  7)) data &= input_port_read(space->machine,  "Y7");
232  if (!BIT(state->keylatch,  8)) data &= input_port_read(space->machine,  "Y8");
233  if (!BIT(state->keylatch,  9)) data &= input_port_read(space->machine,  "Y9");
234  if (!BIT(state->keylatch, 10)) data &= input_port_read(space->machine, "Y10");
235  if (!BIT(state->keylatch, 11)) data &= input_port_read(space->machine, "Y11");
236
237  return ~data;
238}
239
240static WRITE8_HANDLER( keyboard_y0_w )
241{
242  /*
243
244        bit     description
245
246        0       Y0
247        1       Y1
248        2       Y2
249        3       Y3
250        4       Y4
251        5       Y5
252        6       Y6
253        7       Y7
254
255    */
256
257  tandy2k_state *state = space->machine->driver_data<tandy2k_state>();
258
259  /* keyboard row select */
260  state->keylatch = (state->keylatch & 0xff00) | data;
261}
262
263static WRITE8_HANDLER( keyboard_y8_w )
264{
265  /*
266
267        bit     description
268
269        0       Y8
270        1       Y9
271        2       Y10
272        3       Y11
273        4       LED 2
274        5       LED 1
275        6
276        7
277
278    */
279
280  tandy2k_state *state = space->machine->driver_data<tandy2k_state>();
281
282  /* keyboard row select */
283  state->keylatch = ((data & 0x0f) << 8) | (state->keylatch & 0xff);
284}
285
284286/* Memory Maps */
285287
286288static ADDRESS_MAP_START( tandy2k_mem, ADDRESS_SPACE_PROGRAM, 16 )
r9329r9330
319321//  AM_RANGE(0x0026e, 0x0027f) AM_DEVREADWRITE8(WD1010_TAG, wd1010_r, wd1010_w, 0x00ff)
320322ADDRESS_MAP_END
321323
322//static ADDRESS_MAP_START( keyboard_io, ADDRESS_SPACE_IO, 8 )
323//  AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_WRITE(keyboard_y0_w)
324//  AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_WRITE(keyboard_y8_w)
325//  AM_RANGE(MCS48_PORT_BUS, MCS48_PORT_BUS) AM_READ(keyboard_x0_r)
326//ADDRESS_MAP_END
324static ADDRESS_MAP_START( keyboard_io, ADDRESS_SPACE_IO, 8 )
325  AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_WRITE(keyboard_y0_w)
326  AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_WRITE(keyboard_y8_w)
327  AM_RANGE(MCS48_PORT_BUS, MCS48_PORT_BUS) AM_READ(keyboard_x0_r)
328ADDRESS_MAP_END
327329
328330/* Input Ports */
329331
r9329r9330
695697
696698static const struct pic8259_interface i8259_0_intf =
697699{
698   DEVCB_CPU_INPUT_LINE(I80186_TAG, 0)
700   DEVCB_CPU_INPUT_LINE(I80186_TAG, INPUT_LINE_INT0)
699701};
700702
701703/*
r9329r9330
713715
714716static const struct pic8259_interface i8259_1_intf =
715717{
716   /* TODO: INT1 is not implemented in the 80186 core */
717   DEVCB_CPU_INPUT_LINE(I80186_TAG, 1)
718   DEVCB_CPU_INPUT_LINE(I80186_TAG, INPUT_LINE_INT1)
718719};
719720
720721/* Floppy Configuration */
r9329r9330
726727   DEVCB_NULL,
727728   DEVCB_NULL,
728729   DEVCB_NULL,
729   FLOPPY_STANDARD_5_25_DSHD,
730   FLOPPY_STANDARD_5_25_DSQD,
730731   FLOPPY_OPTIONS_NAME(default),
731732   NULL
732733};
r9329r9330
795796/* Machine Driver */
796797
797798static MACHINE_CONFIG_START( tandy2k, tandy2k_state )
798
799799    /* basic machine hardware */
800800   MDRV_CPU_ADD(I80186_TAG, I80186, XTAL_16MHz)
801801    MDRV_CPU_PROGRAM_MAP(tandy2k_mem)
802802    MDRV_CPU_IO_MAP(tandy2k_io)
803803
804//  MDRV_CPU_ADD(I8048_TAG, I8048, 1000000) // ?
805//  MDRV_CPU_IO_MAP(keyboard_io)
804   MDRV_CPU_ADD(I8048_TAG, I8048, 1000000) // ?
805   MDRV_CPU_IO_MAP(keyboard_io)
806806
807807    MDRV_MACHINE_START(tandy2k)
808808    MDRV_MACHINE_RESET(tandy2k)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team