Previous 15994 Revisions Next

r4169 Tuesday 20th January, 2009 at 12:22:22 UTC by Curt Coder
[NEWBRAIN] Fixed memory banking, added Z80CTC interface.
[src/mess/drivers]newbrain.c
[src/mess/includes]newbrain.h

src/mess/includes/newbrain.h
r4168r4169
99#define DAC0808_TAG         "461"
1010#define Z80CTC_TAG         "458"
1111#define FDC_Z80_TAG         "416"
12#define NEC765AC_TAG      "418"
12#define NEC765_TAG         "418"
1313
1414#define NEWBRAIN_VIDEO_RV         0x01
1515#define NEWBRAIN_VIDEO_FS         0x02
r4168r4169
6565   /* timers */
6666   emu_timer *reset_timer;   /* power on reset timer */
6767   emu_timer *pwrup_timer;   /* power up timer */
68
69   /* devices */
70   const device_config *mc6850;
71   const device_config *z80ctc;
72   const device_config *nec765;
6873};
6974
7075/* ---------- defined in video/newbrain.c ---------- */
src/mess/drivers/newbrain.c
r4168r4169
176176   {
177177   case 0:
178178      // PWRUP, if set indicates that power is supplied to Z80 and memory
179      if (!state->pwrup)
179      if (state->pwrup)
180180      {
181181         data |= 0x02;
182182      }
r4168r4169
329329
330330   newbrain_state *state = space->machine->driver_data;
331331
332   cpu_set_input_line(space->machine->cpu[0], INPUT_LINE_IRQ0, BIT(data, 0) ? HOLD_LINE : CLEAR_LINE);
332   cputag_set_input_line(space->machine, Z80_TAG, INPUT_LINE_IRQ0, BIT(data, 0) ? HOLD_LINE : CLEAR_LINE);
333333
334334   state->copint = BIT(data, 0);
335335
r4168r4169
543543
544544static WRITE8_HANDLER( fdc_auxiliary_w )
545545{
546   device_config *fdc = (device_config*)devtag_get_device(space->machine, NEC765A, "nec765");
547546   /*
548547
549548      bit      description
r4168r4169
559558
560559   */
561560
561   newbrain_state *state = space->machine->driver_data;
562
562563   floppy_drive_set_motor_state(image_from_devtype_and_index(space->machine, IO_FLOPPY, 0), BIT(data, 0));
563564   floppy_drive_set_ready_state(image_from_devtype_and_index(space->machine, IO_FLOPPY, 0), 1, 0);
564565
565   nec765_set_reset_state(fdc, BIT(data, 1));
566   nec765_set_reset_state(state->nec765, BIT(data, 1));
566567
567   nec765_set_tc_state(fdc, BIT(data, 2));
568   nec765_set_tc_state(state->nec765, BIT(data, 2));
568569}
569570
570571static READ8_HANDLER( fdc_control_r )
r4168r4169
730731
731732   newbrain_state *state = space->machine->driver_data;
732733
733   return (state->copint << 7) | (state->aciaint << 6) | (state->clkint << 5) | (state->userint << 4) | (state->userint0 << 3) | (state->pwrup) << 1;
734   return (state->copint << 7) | (state->aciaint << 6) | (state->clkint << 5) | (state->userint << 4) | (state->userint0 << 3) | (state->pwrup) << 1 | 0x01;
734735}
735736
736737static READ8_HANDLER( ei_st1_r )
r4168r4169
901902   AM_RANGE(0x15, 0x15) AM_MIRROR(0xff00) AM_READ(ei_st1_r)
902903   AM_RANGE(0x16, 0x16) AM_MIRROR(0xff00) AM_READ(ei_st2_r)
903904   AM_RANGE(0x17, 0x17) AM_MIRROR(0xff00) AM_READWRITE(ei_usbs_r, ei_usbs_w)
904   AM_RANGE(0x18, 0x18) AM_MIRROR(0xff00) AM_DEVREADWRITE(ACIA6850, "acia_0", acia6850_stat_r, acia6850_ctrl_w)
905   AM_RANGE(0x19, 0x19) AM_MIRROR(0xff00) AM_DEVREADWRITE(ACIA6850, "acia_0", acia6850_data_r, acia6850_data_w)
906   AM_RANGE(0x1c, 0x1f) AM_MIRROR(0xff00) AM_DEVREADWRITE(Z80CTC, "z80ctc", z80ctc_r, z80ctc_w)
905   AM_RANGE(0x18, 0x18) AM_MIRROR(0xff00) AM_DEVREADWRITE(ACIA6850, MC6850_TAG, acia6850_stat_r, acia6850_ctrl_w)
906   AM_RANGE(0x19, 0x19) AM_MIRROR(0xff00) AM_DEVREADWRITE(ACIA6850, MC6850_TAG, acia6850_data_r, acia6850_data_w)
907   AM_RANGE(0x1c, 0x1f) AM_MIRROR(0xff00) AM_DEVREADWRITE(Z80CTC, Z80CTC_TAG, z80ctc_r, z80ctc_w)
907908   AM_RANGE(0xff, 0xff) AM_MIRROR(0xff00) AM_MASK(0xff00) AM_WRITE(ei_paging_w)
908909ADDRESS_MAP_END
909910
r4168r4169
920921   AM_RANGE(0x14, 0x14) AM_MIRROR(0xffc0) AM_READ(ust_r)
921922   AM_RANGE(0x15, 0x15) AM_MIRROR(0xffc2) AM_READ(user_r)
922923   AM_RANGE(0x16, 0x16) AM_MIRROR(0xffc0) AM_READ(ust2_r)
923   AM_RANGE(0x18, 0x18) AM_MIRROR(0xffc0) AM_DEVREADWRITE(ACIA6850, "acia_0", acia6850_stat_r, acia6850_ctrl_w)
924   AM_RANGE(0x19, 0x19) AM_MIRROR(0xffc0) AM_DEVREADWRITE(ACIA6850, "acia_0", acia6850_data_r, acia6850_data_w)
925   AM_RANGE(0x1c, 0x1c) AM_MIRROR(0xffc0) AM_DEVREADWRITE(Z80CTC, "z80ctc", z80ctc_r, z80ctc_w)
924   AM_RANGE(0x18, 0x18) AM_MIRROR(0xffc0) AM_DEVREADWRITE(ACIA6850, MC6850_TAG, acia6850_stat_r, acia6850_ctrl_w)
925   AM_RANGE(0x19, 0x19) AM_MIRROR(0xffc0) AM_DEVREADWRITE(ACIA6850, MC6850_TAG, acia6850_data_r, acia6850_data_w)
926   AM_RANGE(0x1c, 0x1c) AM_MIRROR(0xffc0) AM_DEVREADWRITE(Z80CTC, Z80CTC_TAG, z80ctc_r, z80ctc_w)
926927ADDRESS_MAP_END
927928
928929static ADDRESS_MAP_START( newbrain_a_io_map, ADDRESS_SPACE_IO, 8 )
r4168r4169
949950   AM_RANGE(0x0c, 0x0c) AM_MIRROR(0xffc3) AM_WRITE(tvctl_w)
950951   AM_RANGE(0x14, 0x14) AM_MIRROR(0xffc0) AM_READ(ust_r)
951952   AM_RANGE(0x15, 0x15) AM_MIRROR(0xffc2) AM_READ(user_r)
952   AM_RANGE(0x18, 0x18) AM_MIRROR(0xffc0) AM_DEVREADWRITE(ACIA6850, "acia_0", acia6850_stat_r, acia6850_ctrl_w)
953   AM_RANGE(0x19, 0x19) AM_MIRROR(0xffc0) AM_DEVREADWRITE(ACIA6850, "acia_0", acia6850_data_r, acia6850_data_w)
954   AM_RANGE(0x1c, 0x1c) AM_MIRROR(0xffc0) AM_DEVREADWRITE(Z80CTC, "z80ctc", z80ctc_r, z80ctc_w)
953   AM_RANGE(0x18, 0x18) AM_MIRROR(0xffc0) AM_DEVREADWRITE(ACIA6850, MC6850_TAG, acia6850_stat_r, acia6850_ctrl_w)
954   AM_RANGE(0x19, 0x19) AM_MIRROR(0xffc0) AM_DEVREADWRITE(ACIA6850, MC6850_TAG, acia6850_data_r, acia6850_data_w)
955   AM_RANGE(0x1c, 0x1c) AM_MIRROR(0xffc0) AM_DEVREADWRITE(Z80CTC, Z80CTC_TAG, z80ctc_r, z80ctc_w)
955956ADDRESS_MAP_END
956957
957958static ADDRESS_MAP_START( newbrain_cop_io_map, ADDRESS_SPACE_IO, 8 )
r4168r4169
972973static ADDRESS_MAP_START( newbrain_fdc_io_map, ADDRESS_SPACE_IO, 8 )
973974   ADDRESS_MAP_UNMAP_HIGH
974975   ADDRESS_MAP_GLOBAL_MASK(0xff)
975   AM_RANGE(0x00, 0x00) AM_DEVREAD( NEC765A, "nec765", nec765_status_r)
976   AM_RANGE(0x01, 0x01) AM_DEVREADWRITE( NEC765A, "nec765", nec765_data_r, nec765_data_w)
976   AM_RANGE(0x00, 0x00) AM_DEVREAD(NEC765A, NEC765_TAG, nec765_status_r)
977   AM_RANGE(0x01, 0x01) AM_DEVREADWRITE(NEC765A, NEC765_TAG, nec765_data_r, nec765_data_w)
977978   AM_RANGE(0x20, 0x20) AM_WRITE(fdc_auxiliary_w)
978979   AM_RANGE(0x40, 0x40) AM_READ(fdc_control_r)
979980ADDRESS_MAP_END
r4168r4169
10891090
10901091static const acia6850_interface newbrain_acia_intf =
10911092{
1092   500000, // ???
1093   500000, // ???
1093   0,
1094   0,
10941095   &acia_rxd,
10951096   &acia_txd,
10961097   NULL,
r4168r4169
11141115   NEC765_RDY_PIN_NOT_CONNECTED
11151116};
11161117
1118static WRITE8_DEVICE_HANDLER( ctc_z0_w )
1119{
1120   newbrain_state *state = device->machine->driver_data;
1121
1122   /* connected to the ACIA receive clock */
1123   if (data) acia_rx_clock_in(state->mc6850);
1124}
1125
1126static WRITE8_DEVICE_HANDLER( ctc_z1_w )
1127{
1128   newbrain_state *state = device->machine->driver_data;
1129
1130   /* connected to the ACIA transmit clock */
1131   if (data) acia_tx_clock_in(state->mc6850);
1132}
1133
1134static WRITE8_DEVICE_HANDLER( ctc_z2_w )
1135{
1136   newbrain_state *state = device->machine->driver_data;
1137
1138   /* connected to CTC channel 0/1 clock inputs */
1139   z80ctc_trg_w(state->z80ctc, 0, data);
1140   z80ctc_trg_w(state->z80ctc, 1, data);
1141}
1142
11171143static const z80ctc_interface newbrain_ctc_intf =
11181144{
11191145   0,                    /* timer disables */
11201146   NULL,                 /* interrupt handler */
1121   NULL,               /* ZC/TO0 callback */
1122   NULL,                   /* ZC/TO1 callback */
1123   NULL               /* ZC/TO2 callback */
1147   ctc_z0_w,            /* ZC/TO0 callback */
1148   ctc_z1_w,                /* ZC/TO1 callback */
1149   ctc_z2_w            /* ZC/TO2 callback */
11241150};
11251151
1152static TIMER_DEVICE_CALLBACK( ctc_c2_tick )
1153{
1154   newbrain_state *state = timer->machine->driver_data;
1155
1156   z80ctc_trg_w(state->z80ctc, 2, 1);
1157   z80ctc_trg_w(state->z80ctc, 2, 0);
1158}
1159
11261160INLINE int get_reset_t(void)
11271161{
11281162   return RES_K(220) * CAP_U(10) * 1000; // t = R128 * C125 = 2.2s
r4168r4169
11301164
11311165static TIMER_CALLBACK( reset_tick )
11321166{
1133   cpu_set_input_line(machine->cpu[0], INPUT_LINE_RESET, CLEAR_LINE);
1134   cpu_set_input_line(machine->cpu[1], INPUT_LINE_RESET, CLEAR_LINE);
1167   cputag_set_input_line(machine, Z80_TAG, INPUT_LINE_RESET, CLEAR_LINE);
1168   cputag_set_input_line(machine, COP420_TAG, INPUT_LINE_RESET, CLEAR_LINE);
11351169}
11361170
11371171INLINE int get_pwrup_t(void)
r4168r4169
11441178   newbrain_state *state = machine->driver_data;
11451179   int bank;
11461180
1147   state->pwrup = 1;
1181   state->pwrup = 0;
11481182
11491183   for (bank = 1; bank < 9; bank++)
11501184   {
1151      memory_configure_bank(machine, bank, 0, 1, memory_region(machine, Z80_TAG) + (bank - 1) * 0x2000, 0);
1185      UINT16 bank_start = (bank - 1) * 0x2000;
1186      UINT16 bank_end = bank_start + 0x1fff;
1187
1188      if (bank < 6)
1189      {
1190         /* RAM */
1191         memory_install_readwrite8_handler(cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM), bank_start, bank_end, 0, 0, SMH_BANK(bank), SMH_BANK(bank));
1192      }
1193      else
1194      {
1195         /* ROM */
1196         memory_install_readwrite8_handler(cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM), bank_start, bank_end, 0, 0, SMH_BANK(bank), SMH_UNMAP);
1197      }
1198
1199      memory_configure_bank(machine, bank, 0, 1, memory_region(machine, Z80_TAG) + bank_start, 0);
11521200      memory_set_bank(machine, bank, 0);
11531201   }
11541202}
r4168r4169
11621210
11631211   for (bank = 1; bank < 9; bank++)
11641212   {
1213      UINT16 bank_start = (bank - 1) * 0x2000;
1214      UINT16 bank_end = bank_start + 0x1fff;
1215
1216      memory_install_readwrite8_handler(cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM), bank_start, bank_end, 0, 0, SMH_BANK(bank), SMH_UNMAP);
11651217      memory_configure_bank(machine, bank, 0, 1, memory_region(machine, Z80_TAG) + 0xe000, 0);
11661218      memory_set_bank(machine, bank, 0);
11671219   }
r4168r4169
11751227
11761228   state->pwrup_timer = timer_alloc(machine, pwrup_tick, NULL);
11771229   timer_adjust_oneshot(state->pwrup_timer, ATTOTIME_IN_USEC(get_pwrup_t()), 0);
1178   state->pwrup = 0;
1230   state->pwrup = 1;
11791231
1232   /* find devices */
1233
1234   state->z80ctc = devtag_get_device(machine, Z80CTC, Z80CTC_TAG);
1235   state->mc6850 = devtag_get_device(machine, ACIA6850, MC6850_TAG);
1236   state->nec765 = devtag_get_device(machine, NEC765A, NEC765_TAG);
1237
11801238   /* initialize variables */
11811239
11821240   state->userint = 1;
1241   state->userint0 = 1;
11831242   state->clkint = 1;
11841243   state->aciaint = 1;
11851244   state->copint = 1;
r4168r4169
11941253{
11951254   newbrain_state *state = machine->driver_data;
11961255
1197   cpu_set_input_line(machine->cpu[0], INPUT_LINE_RESET, HOLD_LINE);
1198   cpu_set_input_line(machine->cpu[1], INPUT_LINE_RESET, HOLD_LINE);
1256   cputag_set_input_line(machine, Z80_TAG, INPUT_LINE_RESET, HOLD_LINE);
1257   cputag_set_input_line(machine, COP420_TAG, INPUT_LINE_RESET, HOLD_LINE);
11991258
12001259   timer_adjust_oneshot(state->reset_timer, ATTOTIME_IN_MSEC(get_reset_t()), 0);
12011260}
r4168r4169
12061265   
12071266   if (!(state->enrg1 & NEWBRAIN_ENRG1_CLK))
12081267   {
1209      cpu_set_input_line(device->machine->cpu[0], INPUT_LINE_IRQ0, HOLD_LINE);
1268      cputag_set_input_line(device->machine, Z80_TAG, INPUT_LINE_IRQ0, HOLD_LINE);
12101269
12111270      state->clkint = 0;
12121271   }
r4168r4169
12501309   MDRV_MACHINE_START(newbrain)
12511310   MDRV_MACHINE_RESET(newbrain)
12521311
1253   MDRV_Z80CTC_ADD( "z80ctc", XTAL_16MHz/8, newbrain_ctc_intf )
1312   MDRV_Z80CTC_ADD(Z80CTC_TAG, XTAL_16MHz/8, newbrain_ctc_intf)
1313   MDRV_TIMER_ADD_PERIODIC("z80ctc_c2", ctc_c2_tick, HZ(XTAL_16MHz/4/13))
12541314
12551315   // A/D converter
12561316   MDRV_ADC0809_ADD(ADC0809_TAG, 500000, newbrain_adc0809_intf)
r4168r4169
12591319
12601320   MDRV_IMPORT_FROM(newbrain_video)
12611321
1262   MDRV_CASSETTE_ADD( "cassette1", newbrain_cassette_config )
1263   MDRV_CASSETTE_ADD( "cassette2", newbrain_cassette_config )
1322   MDRV_CASSETTE_ADD("cassette1", newbrain_cassette_config)
1323   MDRV_CASSETTE_ADD("cassette2", newbrain_cassette_config)
12641324   
12651325   /* acia */
1266   MDRV_ACIA6850_ADD("acia_0", newbrain_acia_intf)
1326   MDRV_ACIA6850_ADD(MC6850_TAG, newbrain_acia_intf)
12671327     
1268   MDRV_NEC765A_ADD("nec765", newbrain_nec765_interface)   
1328   MDRV_NEC765A_ADD(NEC765_TAG, newbrain_nec765_interface)   
12691329MACHINE_DRIVER_END
12701330
12711331static MACHINE_DRIVER_START( newbraim )
r4168r4169
12851345   MDRV_MACHINE_START(newbrain)
12861346   MDRV_MACHINE_RESET(newbrain)
12871347
1288   MDRV_Z80CTC_ADD( "z80ctc", XTAL_16MHz/8, newbrain_ctc_intf )
1348   MDRV_Z80CTC_ADD(Z80CTC_TAG, XTAL_16MHz/8, newbrain_ctc_intf)
1349   MDRV_TIMER_ADD_PERIODIC("z80ctc_c2", ctc_c2_tick, HZ(XTAL_16MHz/4/13))
12891350
12901351   // video hardware
12911352
12921353   MDRV_IMPORT_FROM(newbrain_video)
12931354
1294   MDRV_CASSETTE_ADD( "cassette1", newbrain_cassette_config )
1295   MDRV_CASSETTE_ADD( "cassette2", newbrain_cassette_config )
1355   MDRV_CASSETTE_ADD("cassette1", newbrain_cassette_config)
1356   MDRV_CASSETTE_ADD("cassette2", newbrain_cassette_config)
12961357
12971358   /* acia */
1298   MDRV_ACIA6850_ADD("acia_0", newbrain_acia_intf)
1359   MDRV_ACIA6850_ADD(MC6850_TAG, newbrain_acia_intf)
12991360MACHINE_DRIVER_END
13001361
13011362static MACHINE_DRIVER_START( newbraia )
r4168r4169
13231384   MDRV_CASSETTE_ADD( "cassette2", newbrain_cassette_config )
13241385
13251386   /* acia */
1326   MDRV_ACIA6850_ADD("acia_0", newbrain_acia_intf)
1387   MDRV_ACIA6850_ADD(MC6850_TAG, newbrain_acia_intf)
13271388MACHINE_DRIVER_END
13281389
13291390static MACHINE_DRIVER_START( newbraiv )
r4168r4169
13431404   MDRV_MACHINE_START(newbrain)
13441405   MDRV_MACHINE_RESET(newbrain)
13451406
1346   MDRV_Z80CTC_ADD( "z80ctc", XTAL_16MHz/8, newbrain_ctc_intf )
1407   MDRV_Z80CTC_ADD(Z80CTC_TAG, XTAL_16MHz/8, newbrain_ctc_intf)
13471408
13481409   // video hardware
13491410
r4168r4169
13531414   MDRV_CASSETTE_ADD( "cassette2", newbrain_cassette_config )
13541415
13551416   /* acia */
1356   MDRV_ACIA6850_ADD("acia_0", newbrain_acia_intf)
1417   MDRV_ACIA6850_ADD(MC6850_TAG, newbrain_acia_intf)
13571418MACHINE_DRIVER_END
13581419
13591420/* ROMs */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team