trunk/src/mame/drivers/cd32.c
| r20556 | r20557 | |
| 203 | 203 | static UINT16 handle_joystick_potgor(running_machine &machine, UINT16 potgor) |
| 204 | 204 | { |
| 205 | 205 | cd32_state *state = machine.driver_data<cd32_state>(); |
| 206 | | static const char *const player_portname[] = { "P2", "P1" }; |
| 206 | ioport_port * player_portname[] = { state->m_p2_port, state->m_p1_port }; |
| 207 | 207 | int i; |
| 208 | 208 | |
| 209 | 209 | for (i = 0; i < 2; i++) |
| r20556 | r20557 | |
| 224 | 224 | /* shift at 1 == return one, >1 = return button states */ |
| 225 | 225 | if (state->m_cd32_shifter[i] == 0) |
| 226 | 226 | potgor &= ~p9dat; /* shift at zero == return zero */ |
| 227 | | if (state->m_cd32_shifter[i] >= 2 && (state->ioport(player_portname[i])->read() & (1 << (state->m_cd32_shifter[i] - 2)))) |
| 227 | if (state->m_cd32_shifter[i] >= 2 && ((player_portname[i])->read() & (1 << (state->m_cd32_shifter[i] - 2)))) |
| 228 | 228 | potgor &= ~p9dat; |
| 229 | 229 | } |
| 230 | 230 | return potgor; |
| r20556 | r20557 | |
| 1252 | 1252 | { |
| 1253 | 1253 | cd32_state *state = machine.driver_data<cd32_state>(); |
| 1254 | 1254 | |
| 1255 | | if (machine.device("maincpu")->safe_pc() < state->m_chip_ram.bytes()) |
| 1255 | if (state->m_maincpu->pc() < state->m_chip_ram.bytes()) |
| 1256 | 1256 | { |
| 1257 | 1257 | //(*state->m_chip_ram_w)(0x051c02, 0x0000); |
| 1258 | 1258 | |
| 1259 | | UINT32 r_A5 = machine.device("maincpu")->state().state_int(M68K_A5); |
| 1259 | UINT32 r_A5 = state->m_maincpu->state_int(M68K_A5); |
| 1260 | 1260 | (*state->m_chip_ram_w)(state, r_A5 - 0x7ebe, 0x0000); |
| 1261 | 1261 | } |
| 1262 | 1262 | } |
| r20556 | r20557 | |
| 1271 | 1271 | { |
| 1272 | 1272 | cd32_state *state = machine.driver_data<cd32_state>(); |
| 1273 | 1273 | |
| 1274 | | if (machine.device("maincpu")->safe_pc() < state->m_chip_ram.bytes()) |
| 1274 | if (state->m_maincpu->pc() < state->m_chip_ram.bytes()) |
| 1275 | 1275 | { |
| 1276 | 1276 | //amiga_chip_ram_w8(state, 0x002907, 0x00); |
| 1277 | 1277 | |
| 1278 | | UINT32 r_A5 = machine.device("maincpu")->state().state_int(M68K_A5); |
| 1278 | UINT32 r_A5 = state->m_maincpu->state_int(M68K_A5); |
| 1279 | 1279 | UINT32 r_A2 = ((*state->m_chip_ram_r)(state, r_A5 - 0x7f00 + 0) << 16) | ((*state->m_chip_ram_r)(state, r_A5 - 0x7f00 + 2)); |
| 1280 | 1280 | amiga_chip_ram_w8(state, r_A2 + 0x1f, 0x00); |
| 1281 | 1281 | } |
| r20556 | r20557 | |
| 1291 | 1291 | { |
| 1292 | 1292 | cd32_state *state = machine.driver_data<cd32_state>(); |
| 1293 | 1293 | |
| 1294 | | if (machine.device("maincpu")->safe_pc() < state->m_chip_ram.bytes()) |
| 1294 | if (state->m_maincpu->pc() < state->m_chip_ram.bytes()) |
| 1295 | 1295 | { |
| 1296 | 1296 | //amiga_chip_ram_w8(state, 0x001e1b, 0x00); |
| 1297 | 1297 | |
| 1298 | | UINT32 r_A5 = machine.device("maincpu")->state().state_int(M68K_A5); |
| 1298 | UINT32 r_A5 = state->m_maincpu->state_int(M68K_A5); |
| 1299 | 1299 | UINT32 r_A2 = ((*state->m_chip_ram_r)(state, r_A5 - 0x7fe0 + 0) << 16) | ((*state->m_chip_ram_r)(state, r_A5 - 0x7fe0 + 2)); |
| 1300 | 1300 | amiga_chip_ram_w8(state, r_A2 + 0x13, 0x00); |
| 1301 | 1301 | } |
| r20556 | r20557 | |
| 1312 | 1312 | { |
| 1313 | 1313 | cd32_state *state = machine.driver_data<cd32_state>(); |
| 1314 | 1314 | |
| 1315 | | if (machine.device("maincpu")->safe_pc() < state->m_chip_ram.bytes()) |
| 1315 | if (state->m_maincpu->pc() < state->m_chip_ram.bytes()) |
| 1316 | 1316 | { |
| 1317 | 1317 | //amiga_chip_ram_w8(state, 0x046107, 0x00); |
| 1318 | 1318 | |
| 1319 | | UINT32 r_A5 = machine.device("maincpu")->state().state_int(M68K_A5); |
| 1319 | UINT32 r_A5 = state->m_maincpu->state_int(M68K_A5); |
| 1320 | 1320 | UINT32 r_A2 = ((*state->m_chip_ram_r)(state, r_A5 - 0x7fdc + 0) << 16) | ((*state->m_chip_ram_r)(state, r_A5 - 0x7fdc + 2)); |
| 1321 | 1321 | amiga_chip_ram_w8(state, r_A2 + 0x17, 0x00); |
| 1322 | 1322 | } |
| r20556 | r20557 | |
| 1332 | 1332 | { |
| 1333 | 1333 | cd32_state *state = machine.driver_data<cd32_state>(); |
| 1334 | 1334 | |
| 1335 | | if (machine.device("maincpu")->safe_pc() < state->m_chip_ram.bytes()) |
| 1335 | if (state->m_maincpu->pc() < state->m_chip_ram.bytes()) |
| 1336 | 1336 | { |
| 1337 | 1337 | //amiga_chip_ram_w8(state, 0x00281c, 0x00); |
| 1338 | 1338 | |
| 1339 | | UINT32 r_A5 = machine.device("maincpu")->state().state_int(M68K_A5); |
| 1339 | UINT32 r_A5 = state->m_maincpu->state_int(M68K_A5); |
| 1340 | 1340 | UINT32 r_A2 = ((*state->m_chip_ram_r)(state, r_A5 - 0x7fa2 + 0) << 16) | ((*state->m_chip_ram_r)(state, r_A5 - 0x7fa2 + 2)); |
| 1341 | 1341 | amiga_chip_ram_w8(state, r_A2 + 0x24, 0x00); |
| 1342 | 1342 | } |
| r20556 | r20557 | |
| 1352 | 1352 | { |
| 1353 | 1353 | cd32_state *state = machine.driver_data<cd32_state>(); |
| 1354 | 1354 | |
| 1355 | | if (machine.device("maincpu")->safe_pc() < state->m_chip_ram.bytes()) |
| 1355 | if (state->m_maincpu->pc() < state->m_chip_ram.bytes()) |
| 1356 | 1356 | { |
| 1357 | 1357 | //(*state->m_chip_ram_w)(0x04bfa0, 0x0000); |
| 1358 | 1358 | |
| 1359 | | UINT32 r_A5 = machine.device("maincpu")->state().state_int(M68K_A5); |
| 1359 | UINT32 r_A5 = state->m_maincpu->state_int(M68K_A5); |
| 1360 | 1360 | (*state->m_chip_ram_w)(state, r_A5 - 0x7ed8, 0x0000); |
| 1361 | 1361 | } |
| 1362 | 1362 | } |
| r20556 | r20557 | |
| 1371 | 1371 | { |
| 1372 | 1372 | cd32_state *state = machine.driver_data<cd32_state>(); |
| 1373 | 1373 | |
| 1374 | | if (machine.device("maincpu")->safe_pc() < state->m_chip_ram.bytes()) |
| 1374 | if (state->m_maincpu->pc() < state->m_chip_ram.bytes()) |
| 1375 | 1375 | { |
| 1376 | 1376 | //amiga_chip_ram_w8(state, 0x044f7e, 0x00); |
| 1377 | 1377 | |
| 1378 | | UINT32 r_A5 = machine.device("maincpu")->state().state_int(M68K_A5); |
| 1378 | UINT32 r_A5 = state->m_maincpu->state_int(M68K_A5); |
| 1379 | 1379 | amiga_chip_ram_w8(state, r_A5 - 0x7eca, 0x00); |
| 1380 | 1380 | } |
| 1381 | 1381 | } |
trunk/src/mame/machine/amiga.c
| r20556 | r20557 | |
| 11 | 11 | #include "emu.h" |
| 12 | 12 | #include "includes/amiga.h" |
| 13 | 13 | #include "cpu/m68000/m68000.h" |
| 14 | | #include "machine/6526cia.h" |
| 15 | | #include "machine/amigafdc.h" |
| 16 | 14 | |
| 15 | |
| 17 | 16 | /************************************* |
| 18 | 17 | * |
| 19 | 18 | * Debugging |
| r20556 | r20557 | |
| 266 | 265 | logerror("Executed RESET at PC=%06x\n", space.device().safe_pc()); |
| 267 | 266 | |
| 268 | 267 | /* Initialize the various chips */ |
| 269 | | device->machine().device("cia_0")->reset(); |
| 270 | | device->machine().device("cia_1")->reset(); |
| 268 | state->m_cia_0->reset(); |
| 269 | state->m_cia_1->reset(); |
| 271 | 270 | custom_reset(device->machine()); |
| 272 | 271 | autoconfig_reset(device->machine()); |
| 273 | 272 | |
| r20556 | r20557 | |
| 286 | 285 | MACHINE_RESET_MEMBER(amiga_state,amiga) |
| 287 | 286 | { |
| 288 | 287 | /* set m68k reset function */ |
| 289 | | m68k_set_reset_callback(machine().device("maincpu"), amiga_m68k_reset); |
| 288 | m68k_set_reset_callback(m_maincpu, amiga_m68k_reset); |
| 290 | 289 | |
| 291 | | amiga_m68k_reset(machine().device("maincpu")); |
| 290 | amiga_m68k_reset(m_maincpu); |
| 292 | 291 | |
| 293 | 292 | /* call the system-specific callback */ |
| 294 | 293 | if (m_intf->reset_callback) |
| r20556 | r20557 | |
| 309 | 308 | TIMER_CALLBACK_MEMBER(amiga_state::scanline_callback) |
| 310 | 309 | { |
| 311 | 310 | int scanline = param; |
| 312 | | device_t *cia_0 = machine().device("cia_0"); |
| 313 | | device_t *cia_1 = machine().device("cia_1"); |
| 314 | 311 | |
| 315 | 312 | /* on the first scanline, we do some extra bookkeeping */ |
| 316 | 313 | if (scanline == 0) |
| 317 | 314 | { |
| 318 | 315 | /* signal VBLANK IRQ */ |
| 319 | | amiga_custom_w(machine().device("maincpu")->memory().space(AS_PROGRAM), REG_INTREQ, 0x8000 | INTENA_VERTB, 0xffff); |
| 316 | amiga_custom_w(m_maincpu->space(AS_PROGRAM), REG_INTREQ, 0x8000 | INTENA_VERTB, 0xffff); |
| 320 | 317 | |
| 321 | 318 | /* clock the first CIA TOD */ |
| 322 | | mos6526_tod_w(cia_0, 1); |
| 319 | mos6526_tod_w(m_cia_0, 1); |
| 323 | 320 | |
| 324 | 321 | /* call the system-specific callback */ |
| 325 | 322 | if (m_intf->scanline0_callback != NULL) |
| r20556 | r20557 | |
| 327 | 324 | } |
| 328 | 325 | |
| 329 | 326 | /* on every scanline, clock the second CIA TOD */ |
| 330 | | mos6526_tod_w(cia_1, 1); |
| 327 | mos6526_tod_w(m_cia_0, 1); |
| 331 | 328 | |
| 332 | 329 | /* render up to this scanline */ |
| 333 | 330 | if (!machine().primary_screen->update_partial(scanline)) |
| r20556 | r20557 | |
| 369 | 366 | if (CUSTOM_REG(REG_INTENA) & 0x4000) |
| 370 | 367 | { |
| 371 | 368 | /* Serial transmit buffer empty, disk block finished, software interrupts */ |
| 372 | | machine.device("maincpu")->execute().set_input_line(1, ints & 0x0007 ? ASSERT_LINE : CLEAR_LINE); |
| 369 | state->m_maincpu->set_input_line(1, ints & 0x0007 ? ASSERT_LINE : CLEAR_LINE); |
| 373 | 370 | |
| 374 | 371 | /* I/O ports and timer interrupts */ |
| 375 | | machine.device("maincpu")->execute().set_input_line(2, ints & 0x0008 ? ASSERT_LINE : CLEAR_LINE); |
| 372 | state->m_maincpu->set_input_line(2, ints & 0x0008 ? ASSERT_LINE : CLEAR_LINE); |
| 376 | 373 | |
| 377 | 374 | /* Copper, VBLANK, blitter interrupts */ |
| 378 | | machine.device("maincpu")->execute().set_input_line(3, ints & 0x0070 ? ASSERT_LINE : CLEAR_LINE); |
| 375 | state->m_maincpu->set_input_line(3, ints & 0x0070 ? ASSERT_LINE : CLEAR_LINE); |
| 379 | 376 | |
| 380 | 377 | /* Audio interrupts */ |
| 381 | | machine.device("maincpu")->execute().set_input_line(4, ints & 0x0780 ? ASSERT_LINE : CLEAR_LINE); |
| 378 | state->m_maincpu->set_input_line(4, ints & 0x0780 ? ASSERT_LINE : CLEAR_LINE); |
| 382 | 379 | |
| 383 | 380 | /* Serial receive buffer full, disk sync match */ |
| 384 | | machine.device("maincpu")->execute().set_input_line(5, ints & 0x1800 ? ASSERT_LINE : CLEAR_LINE); |
| 381 | state->m_maincpu->set_input_line(5, ints & 0x1800 ? ASSERT_LINE : CLEAR_LINE); |
| 385 | 382 | |
| 386 | 383 | /* External interrupts */ |
| 387 | | machine.device("maincpu")->execute().set_input_line(6, ints & 0x2000 ? ASSERT_LINE : CLEAR_LINE); |
| 384 | state->m_maincpu->set_input_line(6, ints & 0x2000 ? ASSERT_LINE : CLEAR_LINE); |
| 388 | 385 | } |
| 389 | 386 | else |
| 390 | 387 | { |
| 391 | | machine.device("maincpu")->execute().set_input_line(1, CLEAR_LINE); |
| 392 | | machine.device("maincpu")->execute().set_input_line(2, CLEAR_LINE); |
| 393 | | machine.device("maincpu")->execute().set_input_line(3, CLEAR_LINE); |
| 394 | | machine.device("maincpu")->execute().set_input_line(4, CLEAR_LINE); |
| 395 | | machine.device("maincpu")->execute().set_input_line(5, CLEAR_LINE); |
| 396 | | machine.device("maincpu")->execute().set_input_line(6, CLEAR_LINE); |
| 388 | state->m_maincpu->set_input_line(1, CLEAR_LINE); |
| 389 | state->m_maincpu->set_input_line(2, CLEAR_LINE); |
| 390 | state->m_maincpu->set_input_line(3, CLEAR_LINE); |
| 391 | state->m_maincpu->set_input_line(4, CLEAR_LINE); |
| 392 | state->m_maincpu->set_input_line(5, CLEAR_LINE); |
| 393 | state->m_maincpu->set_input_line(6, CLEAR_LINE); |
| 397 | 394 | } |
| 398 | 395 | } |
| 399 | 396 | |
| r20556 | r20557 | |
| 935 | 932 | CUSTOM_REG(REG_DMACON) &= ~0x4000; |
| 936 | 933 | |
| 937 | 934 | /* signal an interrupt */ |
| 938 | | amiga_custom_w(machine().device("maincpu")->memory().space(AS_PROGRAM), REG_INTREQ, 0x8000 | INTENA_BLIT, 0xffff); |
| 935 | amiga_custom_w(m_maincpu->space(AS_PROGRAM), REG_INTREQ, 0x8000 | INTENA_BLIT, 0xffff); |
| 939 | 936 | |
| 940 | 937 | /* reset the blitter timer */ |
| 941 | 938 | m_blitter_timer->reset( ); |
| r20556 | r20557 | |
| 1016 | 1013 | |
| 1017 | 1014 | READ16_HANDLER( amiga_cia_r ) |
| 1018 | 1015 | { |
| 1016 | amiga_state *state = space.machine().driver_data<amiga_state>(); |
| 1019 | 1017 | UINT8 data; |
| 1020 | 1018 | int shift; |
| 1021 | 1019 | device_t *cia; |
| r20556 | r20557 | |
| 1023 | 1021 | /* offsets 0000-07ff reference CIA B, and are accessed via the MSB */ |
| 1024 | 1022 | if ((offset & 0x0800) == 0) |
| 1025 | 1023 | { |
| 1026 | | cia = space.machine().device("cia_1"); |
| 1024 | cia = state->m_cia_1; |
| 1027 | 1025 | shift = 8; |
| 1028 | 1026 | } |
| 1029 | 1027 | |
| 1030 | 1028 | /* offsets 0800-0fff reference CIA A, and are accessed via the LSB */ |
| 1031 | 1029 | else |
| 1032 | 1030 | { |
| 1033 | | cia = space.machine().device("cia_0"); |
| 1031 | cia = state->m_cia_0; |
| 1034 | 1032 | shift = 0; |
| 1035 | 1033 | } |
| 1036 | 1034 | |
| r20556 | r20557 | |
| 1053 | 1051 | |
| 1054 | 1052 | WRITE16_HANDLER( amiga_cia_w ) |
| 1055 | 1053 | { |
| 1054 | amiga_state *state = space.machine().driver_data<amiga_state>(); |
| 1056 | 1055 | device_t *cia; |
| 1057 | 1056 | |
| 1058 | 1057 | if (LOG_CIA) |
| r20556 | r20557 | |
| 1063 | 1062 | { |
| 1064 | 1063 | if (!ACCESSING_BITS_8_15) |
| 1065 | 1064 | return; |
| 1066 | | cia = space.machine().device("cia_1"); |
| 1065 | cia = state->m_cia_1; |
| 1067 | 1066 | data >>= 8; |
| 1068 | 1067 | } |
| 1069 | 1068 | |
| r20556 | r20557 | |
| 1072 | 1071 | { |
| 1073 | 1072 | if (!ACCESSING_BITS_0_7) |
| 1074 | 1073 | return; |
| 1075 | | cia = space.machine().device("cia_0"); |
| 1074 | cia = state->m_cia_0; |
| 1076 | 1075 | data &= 0xff; |
| 1077 | 1076 | } |
| 1078 | 1077 | |
| r20556 | r20557 | |
| 1090 | 1089 | |
| 1091 | 1090 | void amiga_cia_0_irq(device_t *device, int state) |
| 1092 | 1091 | { |
| 1093 | | amiga_custom_w(device->machine().device("maincpu")->memory().space(AS_PROGRAM), REG_INTREQ, (state ? 0x8000 : 0x0000) | INTENA_PORTS, 0xffff); |
| 1092 | amiga_state *sta = device->machine().driver_data<amiga_state>(); |
| 1093 | |
| 1094 | amiga_custom_w(sta->m_maincpu->space(AS_PROGRAM), REG_INTREQ, (state ? 0x8000 : 0x0000) | INTENA_PORTS, 0xffff); |
| 1094 | 1095 | } |
| 1095 | 1096 | |
| 1096 | 1097 | |
| 1097 | 1098 | void amiga_cia_1_irq(device_t *device, int state) |
| 1098 | 1099 | { |
| 1099 | | amiga_custom_w(device->machine().device("maincpu")->memory().space(AS_PROGRAM), REG_INTREQ, (state ? 0x8000 : 0x0000) | INTENA_EXTER, 0xffff); |
| 1100 | amiga_state *sta = device->machine().driver_data<amiga_state>(); |
| 1101 | |
| 1102 | amiga_custom_w(sta->m_maincpu->space(AS_PROGRAM), REG_INTREQ, (state ? 0x8000 : 0x0000) | INTENA_EXTER, 0xffff); |
| 1100 | 1103 | } |
| 1101 | 1104 | |
| 1102 | 1105 | |
| r20556 | r20557 | |
| 1110 | 1113 | static void custom_reset(running_machine &machine) |
| 1111 | 1114 | { |
| 1112 | 1115 | amiga_state *state = machine.driver_data<amiga_state>(); |
| 1113 | | int clock = machine.device("maincpu")->unscaled_clock(); |
| 1116 | int clock = state->m_maincpu->unscaled_clock(); |
| 1114 | 1117 | UINT16 vidmode = (clock == AMIGA_68000_NTSC_CLOCK || clock == AMIGA_68EC020_NTSC_CLOCK ) ? 0x1000 : 0x0000; /* NTSC or PAL? */ |
| 1115 | 1118 | |
| 1116 | 1119 | CUSTOM_REG(REG_DDFSTRT) = 0x18; |
| r20556 | r20557 | |
| 1178 | 1181 | case REG_JOY0DAT: |
| 1179 | 1182 | if (state->m_intf->joy0dat_r != NULL) |
| 1180 | 1183 | return (*state->m_intf->joy0dat_r)(space.machine()); |
| 1181 | | return state->ioport("JOY0DAT")->read_safe(0xffff); |
| 1182 | 1184 | |
| 1185 | if (state->m_joy0dat_port) return state->m_joy0dat_port->read(); |
| 1186 | else return 0xffff; |
| 1187 | |
| 1183 | 1188 | case REG_JOY1DAT: |
| 1184 | 1189 | if (state->m_intf->joy1dat_r != NULL) |
| 1185 | 1190 | return (*state->m_intf->joy1dat_r)(space.machine()); |
| 1186 | | return state->ioport("JOY1DAT")->read_safe(0xffff); |
| 1191 | |
| 1192 | if (state->m_joy1dat_port) return state->m_joy1dat_port->read(); |
| 1193 | else return 0xffff; |
| 1187 | 1194 | |
| 1188 | 1195 | case REG_POTGOR: |
| 1189 | | return state->ioport("POTGO")->read_safe(0x5500); |
| 1196 | if (state->m_potgo_port) return state->m_potgo_port->read(); |
| 1197 | else return 0x5500; |
| 1190 | 1198 | |
| 1191 | 1199 | case REG_POT0DAT: |
| 1192 | | return state->ioport("POT0DAT")->read_safe(0x0000); |
| 1200 | if (state->m_pot0dat_port) return state->m_pot0dat_port->read(); |
| 1201 | else return 0x0000; |
| 1193 | 1202 | |
| 1194 | 1203 | case REG_POT1DAT: |
| 1195 | | return state->ioport("POT1DAT")->read_safe(0x0000); |
| 1204 | if (state->m_pot1dat_port) return state->m_pot1dat_port->read(); |
| 1205 | else return 0x0000; |
| 1196 | 1206 | |
| 1197 | 1207 | case REG_DSKBYTR: |
| 1198 | | return space.machine().device<amiga_fdc>("fdc")->dskbytr_r(); |
| 1208 | return state->m_fdc->dskbytr_r(); |
| 1199 | 1209 | |
| 1200 | 1210 | case REG_INTENAR: |
| 1201 | 1211 | return CUSTOM_REG(REG_INTENA); |
| r20556 | r20557 | |
| 1220 | 1230 | return CUSTOM_REG(REG_DENISEID); |
| 1221 | 1231 | |
| 1222 | 1232 | case REG_DSKPTH: |
| 1223 | | return space.machine().device<amiga_fdc>("fdc")->dskpth_r(); |
| 1233 | return state->m_fdc->dskpth_r(); |
| 1224 | 1234 | |
| 1225 | 1235 | case REG_DSKPTL: |
| 1226 | | return space.machine().device<amiga_fdc>("fdc")->dskptl_r(); |
| 1236 | return state->m_fdc->dskptl_r(); |
| 1227 | 1237 | |
| 1228 | 1238 | case REG_ADKCONR: |
| 1229 | | return space.machine().device<amiga_fdc>("fdc")->adkcon_r(); |
| 1239 | return state->m_fdc->adkcon_r(); |
| 1230 | 1240 | |
| 1231 | 1241 | case REG_DSKDATR: |
| 1232 | 1242 | popmessage("DSKDAT R, contact MESSdev"); |
| r20556 | r20557 | |
| 1255 | 1265 | CUSTOM_REG(REG_SERDATR) |= 0x3000; |
| 1256 | 1266 | |
| 1257 | 1267 | /* signal an interrupt */ |
| 1258 | | amiga_custom_w(machine().device("maincpu")->memory().space(AS_PROGRAM), REG_INTREQ, 0x8000 | INTENA_TBE, 0xffff); |
| 1268 | amiga_custom_w(state->m_maincpu->space(AS_PROGRAM), REG_INTREQ, 0x8000 | INTENA_TBE, 0xffff); |
| 1259 | 1269 | } |
| 1260 | 1270 | |
| 1261 | 1271 | |
| 1262 | 1272 | WRITE16_HANDLER( amiga_custom_w ) |
| 1263 | 1273 | { |
| 1264 | 1274 | amiga_state *state = space.machine().driver_data<amiga_state>(); |
| 1265 | | device_t *cia_0; |
| 1266 | | device_t *cia_1; |
| 1267 | 1275 | UINT16 temp; |
| 1268 | 1276 | offset &= 0xff; |
| 1269 | 1277 | |
| r20556 | r20557 | |
| 1284 | 1292 | break; |
| 1285 | 1293 | |
| 1286 | 1294 | case REG_DSKSYNC: |
| 1287 | | space.machine().device<amiga_fdc>("fdc")->dsksync_w(data); |
| 1295 | state->m_fdc->dsksync_w(data); |
| 1288 | 1296 | break; |
| 1289 | 1297 | |
| 1290 | 1298 | case REG_DSKPTH: |
| 1291 | | space.machine().device<amiga_fdc>("fdc")->dskpth_w(data); |
| 1299 | state->m_fdc->dskpth_w(data); |
| 1292 | 1300 | break; |
| 1293 | 1301 | |
| 1294 | 1302 | case REG_DSKPTL: |
| 1295 | | space.machine().device<amiga_fdc>("fdc")->dskptl_w(data); |
| 1303 | state->m_fdc->dskptl_w(data); |
| 1296 | 1304 | break; |
| 1297 | 1305 | |
| 1298 | 1306 | case REG_DSKLEN: |
| 1299 | | space.machine().device<amiga_fdc>("fdc")->dsklen_w(data); |
| 1307 | state->m_fdc->dsklen_w(data); |
| 1300 | 1308 | break; |
| 1301 | 1309 | |
| 1302 | 1310 | case REG_POTGO: |
| r20556 | r20557 | |
| 1399 | 1407 | /* bits BBUSY (14) and BZERO (13) are read-only */ |
| 1400 | 1408 | data &= 0x9fff; |
| 1401 | 1409 | data = (data & 0x8000) ? (CUSTOM_REG(offset) | (data & 0x7fff)) : (CUSTOM_REG(offset) & ~(data & 0x7fff)); |
| 1402 | | space.machine().device<amiga_fdc>("fdc")->dmacon_set(data); |
| 1410 | state->m_fdc->dmacon_set(data); |
| 1403 | 1411 | |
| 1404 | 1412 | /* if 'blitter-nasty' has been turned on and we have a blit pending, reschedule it */ |
| 1405 | 1413 | if ( ( data & 0x400 ) && ( CUSTOM_REG(REG_DMACON) & 0x4000 ) ) |
| r20556 | r20557 | |
| 1426 | 1434 | CUSTOM_REG(REG_SERDATR) &= ~0x8000; |
| 1427 | 1435 | |
| 1428 | 1436 | data = (data & 0x8000) ? (CUSTOM_REG(offset) | (data & 0x7fff)) : (CUSTOM_REG(offset) & ~(data & 0x7fff)); |
| 1429 | | cia_0 = space.machine().device("cia_0"); |
| 1430 | | cia_1 = space.machine().device("cia_1"); |
| 1431 | | if ( mos6526_irq_r( cia_0 ) ) data |= INTENA_PORTS; |
| 1432 | | if ( mos6526_irq_r( cia_1 ) ) data |= INTENA_EXTER; |
| 1437 | if ( mos6526_irq_r( state->m_cia_0 ) ) data |= INTENA_PORTS; |
| 1438 | if ( mos6526_irq_r( state->m_cia_1 ) ) data |= INTENA_EXTER; |
| 1433 | 1439 | CUSTOM_REG(offset) = data; |
| 1434 | 1440 | |
| 1435 | 1441 | if ( temp & 0x8000 ) /* if we're generating irq's, delay a bit */ |
| 1436 | | state->m_irq_timer->adjust( space.machine().device<cpu_device>("maincpu")->cycles_to_attotime( AMIGA_IRQ_DELAY_CYCLES )); |
| 1442 | state->m_irq_timer->adjust( state->m_maincpu->cycles_to_attotime( AMIGA_IRQ_DELAY_CYCLES )); |
| 1437 | 1443 | else /* if we're clearing irq's, process right away */ |
| 1438 | 1444 | update_irqs(space.machine()); |
| 1439 | 1445 | break; |
| r20556 | r20557 | |
| 1441 | 1447 | case REG_ADKCON: |
| 1442 | 1448 | amiga_audio_update(state->m_sound_device); |
| 1443 | 1449 | data = (data & 0x8000) ? (CUSTOM_REG(offset) | (data & 0x7fff)) : (CUSTOM_REG(offset) & ~(data & 0x7fff)); |
| 1444 | | space.machine().device<amiga_fdc>("fdc")->adkcon_set(data); |
| 1450 | state->m_fdc->adkcon_set(data); |
| 1445 | 1451 | break; |
| 1446 | 1452 | |
| 1447 | 1453 | case REG_AUD0LCL: case REG_AUD0LCH: case REG_AUD0LEN: case REG_AUD0PER: case REG_AUD0VOL: |
| r20556 | r20557 | |
| 1519 | 1525 | void amiga_serial_in_w(running_machine &machine, UINT16 data) |
| 1520 | 1526 | { |
| 1521 | 1527 | amiga_state *state = machine.driver_data<amiga_state>(); |
| 1522 | | address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM); |
| 1528 | address_space &space = state->m_maincpu->space(AS_PROGRAM); |
| 1523 | 1529 | int mask = (CUSTOM_REG(REG_SERPER) & 0x8000) ? 0x1ff : 0xff; |
| 1524 | 1530 | |
| 1525 | 1531 | /* copy the data to the low 8 bits of SERDATR and set RBF */ |
| r20556 | r20557 | |
| 1542 | 1548 | { |
| 1543 | 1549 | amiga_state *state = machine.driver_data<amiga_state>(); |
| 1544 | 1550 | UINT32 divisor = (CUSTOM_REG(REG_SERPER) & 0x7fff) + 1; |
| 1545 | | UINT32 baud = machine.device("maincpu")->unscaled_clock() / 2 / divisor; |
| 1551 | UINT32 baud = state->m_maincpu->unscaled_clock() / 2 / divisor; |
| 1546 | 1552 | UINT32 numbits = 2 + ((CUSTOM_REG(REG_SERPER) & 0x8000) ? 9 : 8); |
| 1547 | 1553 | return attotime::from_hz(baud) * numbits; |
| 1548 | 1554 | } |