src/mess/drivers/newbrain.c
| r3032 | r3033 | |
| 57 | 57 | |
| 58 | 58 | */ |
| 59 | 59 | |
| 60 | | static int acia_irq; |
| 61 | 60 | static UINT8 acia_rxd = 1, acia_txd = 1; |
| 62 | 61 | |
| 63 | 62 | static const device_config *cassette_device_image(int index) |
| r3032 | r3033 | |
| 72 | 71 | #define NEWBRAIN_ENRG1_CTS 0x10 |
| 73 | 72 | #define NEWBRAIN_ENRG1_DO 0x20 |
| 74 | 73 | #define NEWBRAIN_ENRG1_PO 0x80 |
| 74 | #define NEWBRAIN_ENRG1_UST_BIT_1_MASK 0x30 |
| 75 | #define NEWBRAIN_ENRG1_UST_BIT_0_MASK 0xc0 |
| 75 | 76 | |
| 76 | 77 | static WRITE8_HANDLER( enrg1_w ) |
| 77 | 78 | { |
| r3032 | r3033 | |
| 92 | 93 | |
| 93 | 94 | newbrain_state *state = machine->driver_data; |
| 94 | 95 | |
| 96 | //logerror("ENRG1: %02x\n", data); |
| 97 | |
| 95 | 98 | state->enrg1 = data; |
| 96 | 99 | } |
| 97 | 100 | |
| r3032 | r3033 | |
| 123 | 126 | |
| 124 | 127 | bit signal description |
| 125 | 128 | |
| 126 | | 0 |
| 127 | | 1 |
| 128 | | 2 mains present |
| 129 | | 3 user status |
| 130 | | 4 user interrupt |
| 131 | | 5 clock interrupt |
| 132 | | 6 ACIA interrupt |
| 129 | 0 variable |
| 130 | 1 variable |
| 131 | 2 MNS mains present |
| 132 | 3 _USRINT0 user status |
| 133 | 4 _USRINT user interrupt |
| 134 | 5 _CLKINT clock interrupt |
| 135 | 6 _ACINT ACIA interrupt |
| 133 | 136 | 7 _COPINT COP interrupt |
| 134 | 137 | |
| 135 | 138 | */ |
| 136 | 139 | |
| 137 | 140 | newbrain_state *state = machine->driver_data; |
| 138 | 141 | |
| 139 | | UINT8 data = (state->copint << 7) | (state->aciaint << 6) | (state->clkint << 5) | (state->userint << 4) | 0x04; |
| 142 | UINT8 data = (state->copint << 7) | (state->aciaint << 6) | (state->clkint << 5) | (state->userint << 4); |
| 140 | 143 | |
| 141 | | switch (state->enrg1 >> 6) |
| 144 | switch ((state->enrg1 & NEWBRAIN_ENRG1_UST_BIT_0_MASK) >> 6) |
| 142 | 145 | { |
| 143 | 146 | case 0: |
| 144 | 147 | // excess, 1=24, 0=4 |
| r3032 | r3033 | |
| 165 | 168 | break; |
| 166 | 169 | } |
| 167 | 170 | |
| 168 | | switch (state->enrg1 >> 4) |
| 171 | switch ((state->enrg1 & NEWBRAIN_ENRG1_UST_BIT_1_MASK) >> 4) |
| 169 | 172 | { |
| 170 | 173 | case 0: |
| 171 | 174 | // PWRUP, if set indicates that power is supplied to Z80 and memory |
| r3032 | r3033 | |
| 320 | 323 | |
| 321 | 324 | */ |
| 322 | 325 | |
| 323 | | // _Z80INT = ((_CLK | _CLKINT) & _COPINT) |
| 324 | | //cpunum_set_input_line(machine, 0, INPUT_LINE_IRQ0, BIT(data, 0) ? HOLD_LINE : CLEAR_LINE); |
| 325 | | |
| 326 | 326 | newbrain_state *state = machine->driver_data; |
| 327 | 327 | |
| 328 | cpunum_set_input_line(machine, 0, INPUT_LINE_IRQ0, BIT(data, 0) ? HOLD_LINE : CLEAR_LINE); |
| 329 | |
| 328 | 330 | state->copint = BIT(data, 0); |
| 329 | 331 | |
| 330 | 332 | /* tape motor enable */ |
| r3032 | r3033 | |
| 721 | 723 | |
| 722 | 724 | */ |
| 723 | 725 | |
| 724 | | return acia_irq << 6; |
| 726 | newbrain_state *state = machine->driver_data; |
| 727 | |
| 728 | return (state->copint << 7) | (state->aciaint << 6) | (state->clkint << 5) | (state->userint << 4) | (state->userint0 << 3) | (state->pwrup) << 1; |
| 725 | 729 | } |
| 726 | 730 | |
| 727 | 731 | static READ8_HANDLER( ei_st1_r ) |
| r3032 | r3033 | |
| 743 | 747 | |
| 744 | 748 | newbrain_state *state = machine->driver_data; |
| 745 | 749 | |
| 746 | | return (state->tvcnsl << 6); |
| 750 | return (state->tvcnsl << 6) | 0x10 | 0x08 | 0x04; |
| 747 | 751 | } |
| 748 | 752 | |
| 749 | 753 | static READ8_HANDLER( ei_st2_r ) |
| r3032 | r3033 | |
| 873 | 877 | AM_RANGE(0x03, 0x03) AM_MIRROR(0xffc0) AM_WRITE(user_w) |
| 874 | 878 | AM_RANGE(0x04, 0x04) AM_MIRROR(0xffc0) AM_READWRITE(clclk_r, clclk_w) |
| 875 | 879 | AM_RANGE(0x06, 0x06) AM_MIRROR(0xffc0) AM_READWRITE(cop_r, cop_w) |
| 876 | | AM_RANGE(0x07, 0x07) AM_MIRROR(0xffc0) AM_WRITE(a_enrg1_w) |
| 880 | AM_RANGE(0x07, 0x07) AM_MIRROR(0xffc0) AM_WRITE(enrg1_w) |
| 877 | 881 | AM_RANGE(0x08, 0x09) AM_MIRROR(0xffc2) AM_READWRITE(tvl_r, tvl_w) |
| 878 | 882 | AM_RANGE(0x0c, 0x0c) AM_MIRROR(0xffc3) AM_WRITE(tvctl_w) |
| 879 | 883 | AM_RANGE(0x14, 0x14) AM_MIRROR(0xffc0) AM_READ(ust_r) |
| r3032 | r3033 | |
| 1045 | 1049 | |
| 1046 | 1050 | static void acia_interrupt(int state) |
| 1047 | 1051 | { |
| 1048 | | acia_irq = state; |
| 1052 | newbrain_state *driver_state = Machine->driver_data; |
| 1053 | |
| 1054 | driver_state->aciaint = state; |
| 1049 | 1055 | } |
| 1050 | 1056 | |
| 1051 | 1057 | static const struct acia6850_interface newbrain_acia_intf = |
| r3032 | r3033 | |
| 1083 | 1089 | NULL /* ZC/TO2 callback */ |
| 1084 | 1090 | }; |
| 1085 | 1091 | |
| 1092 | INLINE int get_reset_t(void) |
| 1093 | { |
| 1094 | return RES_K(220) * CAP_U(10) * 1000; // t = R128 * C125 = 2.2s |
| 1095 | } |
| 1096 | |
| 1086 | 1097 | static TIMER_CALLBACK( reset_tick ) |
| 1087 | 1098 | { |
| 1088 | 1099 | cpunum_set_input_line(machine, 0, INPUT_LINE_RESET, CLEAR_LINE); |
| 1089 | 1100 | cpunum_set_input_line(machine, 1, INPUT_LINE_RESET, CLEAR_LINE); |
| 1090 | 1101 | } |
| 1091 | 1102 | |
| 1103 | INLINE int get_pwrup_t(void) |
| 1104 | { |
| 1105 | return RES_K(560) * CAP_U(10) * 1000; // t = R129 * C127 = 5.6s |
| 1106 | } |
| 1107 | |
| 1092 | 1108 | static TIMER_CALLBACK( pwrup_tick ) |
| 1093 | 1109 | { |
| 1094 | 1110 | newbrain_state *state = machine->driver_data; |
| 1095 | 1111 | int bank; |
| 1096 | 1112 | |
| 1097 | | state->pwrup = 0; |
| 1113 | state->pwrup = 1; |
| 1098 | 1114 | |
| 1099 | 1115 | for (bank = 1; bank < 9; bank++) |
| 1100 | 1116 | { |
| r3032 | r3033 | |
| 1103 | 1119 | } |
| 1104 | 1120 | } |
| 1105 | 1121 | |
| 1106 | | INLINE int get_reset_t(void) |
| 1107 | | { |
| 1108 | | return RES_K(220) * CAP_U(10) * 1000; // t = R128 * C125 |
| 1109 | | } |
| 1110 | | |
| 1111 | | INLINE int get_pwrup_t(void) |
| 1112 | | { |
| 1113 | | return RES_K(560) * CAP_U(10) * 1000; // t = R129 * C127 |
| 1114 | | } |
| 1115 | | |
| 1116 | 1122 | static MACHINE_START( newbrain ) |
| 1117 | 1123 | { |
| 1118 | 1124 | newbrain_state *state = machine->driver_data; |
| r3032 | r3033 | |
| 1135 | 1141 | /* allocate reset timer */ |
| 1136 | 1142 | |
| 1137 | 1143 | state->reset_timer = timer_alloc(reset_tick, NULL); |
| 1144 | timer_adjust_oneshot(state->reset_timer, ATTOTIME_IN_USEC(get_reset_t()), 0); |
| 1138 | 1145 | |
| 1139 | 1146 | /* allocate power up timer */ |
| 1140 | | |
| 1147 | |
| 1141 | 1148 | state->pwrup_timer = timer_alloc(pwrup_tick, NULL); |
| 1142 | | timer_adjust_oneshot(state->reset_timer, ATTOTIME_IN_MSEC(get_pwrup_t()), 0); |
| 1143 | | state->pwrup = 1; |
| 1149 | timer_adjust_oneshot(state->pwrup_timer, ATTOTIME_IN_USEC(get_pwrup_t()), 0); |
| 1150 | state->pwrup = 0; |
| 1144 | 1151 | |
| 1145 | 1152 | /* initialize variables */ |
| 1146 | 1153 | |
| r3032 | r3033 | |
| 1165 | 1172 | timer_adjust_oneshot(state->reset_timer, ATTOTIME_IN_MSEC(get_reset_t()), 0); |
| 1166 | 1173 | } |
| 1167 | 1174 | |
| 1168 | | static const struct z80_irq_daisy_chain newbrain_daisy_chain[] = |
| 1169 | | { |
| 1170 | | { z80ctc_reset, z80ctc_irq_state, z80ctc_irq_ack, z80ctc_irq_reti, 0 }, |
| 1171 | | { 0, 0, 0, 0, -1 } |
| 1172 | | }; |
| 1173 | | |
| 1174 | 1175 | static INTERRUPT_GEN( newbrain_interrupt ) |
| 1175 | 1176 | { |
| 1176 | 1177 | newbrain_state *state = machine->driver_data; |
| 1177 | 1178 | |
| 1178 | | if (state->enrg1 & NEWBRAIN_ENRG1_CLK) |
| 1179 | if (!(state->enrg1 & NEWBRAIN_ENRG1_CLK)) |
| 1179 | 1180 | { |
| 1180 | 1181 | cpunum_set_input_line(machine, 0, INPUT_LINE_IRQ0, HOLD_LINE); |
| 1181 | 1182 | |
| r3032 | r3033 | |
| 1326 | 1327 | ROM_END |
| 1327 | 1328 | |
| 1328 | 1329 | ROM_START( newbraia ) |
| 1330 | ROM_REGION( 0x10000, "main", 0 ) |
| 1329 | 1331 | ROM_SYSTEM_BIOS( 0, "rom20", "ROM 2.0" ) |
| 1330 | 1332 | ROMX_LOAD( "aben20.rom", 0xa000, 0x2000, CRC(3d76d0c8) SHA1(753b4530a518ad832e4b81c4e5430355ba3f62e0), ROM_BIOS(1) ) |
| 1331 | 1333 | ROMX_LOAD( "cd20tci.rom", 0xc000, 0x4000, CRC(f65b2350) SHA1(1ada7fbf207809537ec1ffb69808524300622ada), ROM_BIOS(1) ) |