src/mess/machine/apple2.c
| r15004 | r15005 | |
| 48 | 48 | static WRITE8_HANDLER ( apple2_auxram0400_w ); |
| 49 | 49 | static WRITE8_HANDLER ( apple2_auxram2000_w ); |
| 50 | 50 | |
| 51 | | static READ8_HANDLER ( apple2_c00x_r ); |
| 52 | | static READ8_HANDLER ( apple2_c01x_r ); |
| 53 | | static READ8_HANDLER ( apple2_c02x_r ); |
| 54 | | static READ8_HANDLER ( apple2_c03x_r ); |
| 55 | | static READ8_HANDLER ( apple2_c05x_r ); |
| 56 | | static READ8_HANDLER ( apple2_c06x_r ); |
| 57 | | static READ8_HANDLER ( apple2_c07x_r ); |
| 58 | | |
| 59 | | static WRITE8_HANDLER ( apple2_c00x_w ); |
| 60 | | static WRITE8_HANDLER ( apple2_c01x_w ); |
| 61 | | static WRITE8_HANDLER ( apple2_c02x_w ); |
| 62 | | static WRITE8_HANDLER ( apple2_c03x_w ); |
| 63 | | static WRITE8_HANDLER ( apple2_c05x_w ); |
| 64 | | static WRITE8_HANDLER ( apple2_c07x_w ); |
| 65 | | |
| 66 | 51 | static READ8_HANDLER ( apple2_c1xx_r ); |
| 67 | 52 | static WRITE8_HANDLER ( apple2_c1xx_w ); |
| 68 | 53 | static READ8_HANDLER ( apple2_c3xx_r ); |
| r15004 | r15005 | |
| 351 | 336 | apple2_state *state = space->machine().driver_data<apple2_state>(); |
| 352 | 337 | if(!space->debugger_access()) |
| 353 | 338 | { |
| 354 | | static const read8_space_func handlers[] = |
| 339 | static const read8_delegate handlers[] = |
| 355 | 340 | { |
| 356 | | apple2_c00x_r, |
| 357 | | apple2_c01x_r, |
| 358 | | apple2_c02x_r, |
| 359 | | apple2_c03x_r, |
| 360 | | NULL, |
| 361 | | apple2_c05x_r, |
| 362 | | apple2_c06x_r, |
| 363 | | apple2_c07x_r |
| 341 | read8_delegate(FUNC(apple2_state::apple2_c00x_r), state), |
| 342 | read8_delegate(FUNC(apple2_state::apple2_c01x_r), state), |
| 343 | read8_delegate(FUNC(apple2_state::apple2_c02x_r), state), |
| 344 | read8_delegate(FUNC(apple2_state::apple2_c03x_r), state), |
| 345 | read8_delegate(FUNC(apple2_state::apple2_c03x_r), state), // not called here, handled elsewhere |
| 346 | read8_delegate(FUNC(apple2_state::apple2_c05x_r), state), |
| 347 | read8_delegate(FUNC(apple2_state::apple2_c06x_r), state), |
| 348 | read8_delegate(FUNC(apple2_state::apple2_c07x_r), state) |
| 364 | 349 | }; |
| 365 | | UINT8 result = 0x00; |
| 366 | | int slotnum; |
| 367 | | device_a2bus_card_interface *slotdevice; |
| 368 | 350 | |
| 369 | | offset &= 0xFF; |
| 351 | offset &= 0x7F; |
| 370 | 352 | |
| 371 | | if (offset < 0x80) |
| 372 | | { |
| 373 | | /* normal handler */ |
| 374 | | if (handlers[offset / 0x10]) |
| 375 | | result = handlers[offset / 0x10](space, offset % 0x10); |
| 376 | | } |
| 377 | | else |
| 378 | | { |
| 379 | | /* slot handler; identify the slot number */ |
| 380 | | slotnum = (offset - 0x80) / 0x10; |
| 381 | | |
| 382 | | /* now identify the device */ |
| 383 | | slotdevice = state->m_a2bus->get_a2bus_card(slotnum); |
| 384 | | |
| 385 | | /* and if we can, read from the slot */ |
| 386 | | if (slotdevice != NULL) |
| 387 | | result = slotdevice->read_c0nx(*space, offset % 0x10); |
| 388 | | } |
| 389 | | return result; |
| 353 | /* normal handler */ |
| 354 | if (offset / 0x10 != 4) |
| 355 | { |
| 356 | return handlers[offset / 0x10](*space, offset % 0x10, 0); |
| 357 | } |
| 390 | 358 | } |
| 391 | 359 | |
| 392 | 360 | return 0; |
| r15004 | r15005 | |
| 397 | 365 | WRITE8_HANDLER(apple2_c0xx_w) |
| 398 | 366 | { |
| 399 | 367 | apple2_state *state = space->machine().driver_data<apple2_state>(); |
| 400 | | static const write8_space_func handlers[] = |
| 368 | static const write8_delegate handlers[] = |
| 401 | 369 | { |
| 402 | | apple2_c00x_w, |
| 403 | | apple2_c01x_w, |
| 404 | | apple2_c02x_w, |
| 405 | | apple2_c03x_w, |
| 406 | | NULL, |
| 407 | | apple2_c05x_w, |
| 408 | | NULL, |
| 409 | | apple2_c07x_w |
| 370 | write8_delegate(FUNC(apple2_state::apple2_c00x_w), state), |
| 371 | write8_delegate(FUNC(apple2_state::apple2_c01x_w), state), |
| 372 | write8_delegate(FUNC(apple2_state::apple2_c02x_w), state), |
| 373 | write8_delegate(FUNC(apple2_state::apple2_c03x_w), state), |
| 374 | write8_delegate(FUNC(apple2_state::apple2_c03x_w), state), // unused |
| 375 | write8_delegate(FUNC(apple2_state::apple2_c05x_w), state), |
| 376 | write8_delegate(FUNC(apple2_state::apple2_c05x_w), state), // unused |
| 377 | write8_delegate(FUNC(apple2_state::apple2_c07x_w), state) |
| 410 | 378 | }; |
| 411 | | int slotnum; |
| 412 | | device_a2bus_card_interface *slotdevice; |
| 413 | 379 | |
| 414 | | offset &= 0xFF; |
| 380 | offset &= 0x7F; |
| 415 | 381 | |
| 416 | | if (offset < 0x80) |
| 382 | /* normal handler */ |
| 383 | if (((offset / 0x10) != 4) && (offset / 0x10) != 6) |
| 384 | { |
| 385 | handlers[offset / 0x10](*space, offset % 0x10, data, 0); |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | READ8_HANDLER(apple2_c080_r) |
| 390 | { |
| 391 | if(!space->debugger_access()) |
| 417 | 392 | { |
| 418 | | /* normal handler */ |
| 419 | | if (handlers[offset / 0x10]) |
| 420 | | handlers[offset / 0x10](space, offset % 0x10, data); |
| 421 | | } |
| 422 | | else |
| 423 | | { |
| 424 | | /* slot handler; identify the slot number */ |
| 425 | | slotnum = (offset - 0x80) / 0x10; |
| 393 | apple2_state *state = space->machine().driver_data<apple2_state>(); |
| 394 | device_a2bus_card_interface *slotdevice; |
| 426 | 395 | |
| 427 | | /* now identify the device */ |
| 428 | | slotdevice = state->m_a2bus->get_a2bus_card(slotnum); |
| 396 | offset &= 0x7F; |
| 429 | 397 | |
| 430 | | /* and if we can, write to the slot */ |
| 431 | | if (slotdevice != NULL) |
| 432 | | slotdevice->write_c0nx(*space, offset % 0x10, data); |
| 398 | /* now identify the device */ |
| 399 | slotdevice = state->m_a2bus->get_a2bus_card(offset / 0x10); |
| 400 | |
| 401 | /* and if we can, read from the slot */ |
| 402 | if (slotdevice != NULL) |
| 403 | { |
| 404 | return slotdevice->read_c0nx(*space, offset % 0x10); |
| 405 | } |
| 433 | 406 | } |
| 407 | |
| 408 | return 0; |
| 434 | 409 | } |
| 435 | 410 | |
| 411 | |
| 412 | WRITE8_HANDLER(apple2_c080_w) |
| 413 | { |
| 414 | apple2_state *state = space->machine().driver_data<apple2_state>(); |
| 415 | device_a2bus_card_interface *slotdevice; |
| 416 | |
| 417 | offset &= 0x7F; |
| 418 | |
| 419 | /* now identify the device */ |
| 420 | slotdevice = state->m_a2bus->get_a2bus_card(offset / 0x10); |
| 421 | |
| 422 | /* and if we can, write to the slot */ |
| 423 | if (slotdevice != NULL) |
| 424 | { |
| 425 | slotdevice->write_c0nx(*space, offset % 0x10, data); |
| 426 | } |
| 427 | } |
| 428 | |
| 436 | 429 | /* returns default CnXX slotram for a slot space */ |
| 437 | 430 | INT8 apple2_slotram_r(address_space &space, int slotnum, int offset) |
| 438 | 431 | { |
| r15004 | r15005 | |
| 795 | 788 | meminfo->write_handler = apple2_c0xx_w; |
| 796 | 789 | } |
| 797 | 790 | |
| 791 | static void apple2_mem_C080(running_machine &machine, offs_t begin, offs_t end, apple2_meminfo *meminfo) |
| 792 | { |
| 793 | meminfo->read_handler = apple2_c080_r; |
| 794 | meminfo->write_handler = apple2_c080_w; |
| 795 | } |
| 796 | |
| 798 | 797 | static void apple2_mem_CFFF(running_machine &machine, offs_t begin, offs_t end, apple2_meminfo *meminfo) |
| 799 | 798 | { |
| 800 | 799 | meminfo->read_handler = apple2_cfff_r; |
| r15004 | r15005 | |
| 931 | 930 | { 0x0800, 0x1FFF, apple2_mem_0800, A2MEM_DUAL }, |
| 932 | 931 | { 0x2000, 0x3FFF, apple2_mem_2000, A2MEM_DUAL }, |
| 933 | 932 | { 0x4000, 0xBFFF, apple2_mem_4000, A2MEM_DUAL }, |
| 934 | | { 0xC000, 0xC0FF, apple2_mem_C000, A2MEM_IO }, |
| 933 | { 0xC000, 0xC07F, apple2_mem_C000, A2MEM_IO }, |
| 934 | { 0xC080, 0xC0FF, apple2_mem_C080, A2MEM_IO }, |
| 935 | 935 | { 0xC100, 0xC2FF, apple2_mem_Cx00, A2MEM_MONO }, |
| 936 | 936 | { 0xC300, 0xC3FF, apple2_mem_C300, A2MEM_MONO }, |
| 937 | 937 | { 0xC400, 0xC7FF, apple2_mem_Cx00, A2MEM_MONO }, |
| r15004 | r15005 | |
| 1204 | 1204 | apple2_c00x_r |
| 1205 | 1205 | ***************************************************************************/ |
| 1206 | 1206 | |
| 1207 | | READ8_HANDLER ( apple2_c00x_r ) |
| 1207 | READ8_MEMBER ( apple2_state::apple2_c00x_r ) |
| 1208 | 1208 | { |
| 1209 | 1209 | UINT8 result = 0; |
| 1210 | 1210 | |
| 1211 | | if(!space->debugger_access()) |
| 1211 | if(!space.debugger_access()) |
| 1212 | 1212 | { |
| 1213 | 1213 | /* Read the keyboard data and strobe */ |
| 1214 | 1214 | g_profiler.start(PROFILER_C00X); |
| 1215 | | result = AY3600_keydata_strobe_r(space->machine()); |
| 1215 | result = AY3600_keydata_strobe_r(space.machine()); |
| 1216 | 1216 | g_profiler.stop(); |
| 1217 | 1217 | } |
| 1218 | 1218 | |
| r15004 | r15005 | |
| 1244 | 1244 | C00F ALTCHARSETON - use alt character set |
| 1245 | 1245 | ***************************************************************************/ |
| 1246 | 1246 | |
| 1247 | | WRITE8_HANDLER ( apple2_c00x_w ) |
| 1247 | WRITE8_MEMBER ( apple2_state::apple2_c00x_w ) |
| 1248 | 1248 | { |
| 1249 | 1249 | UINT32 mask; |
| 1250 | 1250 | |
| 1251 | 1251 | mask = 1 << (offset / 2); |
| 1252 | | apple2_setvar(space->machine(), (offset & 1) ? mask : 0, mask); |
| 1252 | apple2_setvar(space.machine(), (offset & 1) ? mask : 0, mask); |
| 1253 | 1253 | } |
| 1254 | 1254 | |
| 1255 | 1255 | |
| r15004 | r15005 | |
| 1258 | 1258 | apple2_c01x_r |
| 1259 | 1259 | ***************************************************************************/ |
| 1260 | 1260 | |
| 1261 | | READ8_HANDLER ( apple2_c01x_r ) |
| 1261 | READ8_MEMBER( apple2_state::apple2_c01x_r ) |
| 1262 | 1262 | { |
| 1263 | | apple2_state *state = space->machine().driver_data<apple2_state>(); |
| 1264 | | UINT8 result = apple2_getfloatingbusvalue(space->machine()) & 0x7F; |
| 1263 | UINT8 result = apple2_getfloatingbusvalue(space.machine()) & 0x7F; |
| 1265 | 1264 | |
| 1266 | | if(!space->debugger_access()) |
| 1265 | if(!space.debugger_access()) |
| 1267 | 1266 | { |
| 1268 | 1267 | g_profiler.start(PROFILER_C01X); |
| 1269 | 1268 | |
| 1270 | 1269 | LOG(("a2 softswitch_r: %04x\n", offset + 0xc010)); |
| 1271 | 1270 | switch (offset) |
| 1272 | 1271 | { |
| 1273 | | case 0x00: result |= AY3600_anykey_clearstrobe_r(space->machine()); break; |
| 1274 | | case 0x01: result |= (state->m_flags & VAR_LCRAM2) ? 0x80 : 0x00; break; |
| 1275 | | case 0x02: result |= (state->m_flags & VAR_LCRAM) ? 0x80 : 0x00; break; |
| 1276 | | case 0x03: result |= (state->m_flags & VAR_RAMRD) ? 0x80 : 0x00; break; |
| 1277 | | case 0x04: result |= (state->m_flags & VAR_RAMWRT) ? 0x80 : 0x00; break; |
| 1278 | | case 0x05: result |= (state->m_flags & VAR_INTCXROM) ? 0x80 : 0x00; break; |
| 1279 | | case 0x06: result |= (state->m_flags & VAR_ALTZP) ? 0x80 : 0x00; break; |
| 1280 | | case 0x07: result |= (state->m_flags & VAR_SLOTC3ROM) ? 0x80 : 0x00; break; |
| 1281 | | case 0x08: result |= (state->m_flags & VAR_80STORE) ? 0x80 : 0x00; break; |
| 1282 | | case 0x09: result |= !space->machine().primary_screen->vblank() ? 0x80 : 0x00; break; |
| 1283 | | case 0x0A: result |= (state->m_flags & VAR_TEXT) ? 0x80 : 0x00; break; |
| 1284 | | case 0x0B: result |= (state->m_flags & VAR_MIXED) ? 0x80 : 0x00; break; |
| 1285 | | case 0x0C: result |= (state->m_flags & VAR_PAGE2) ? 0x80 : 0x00; break; |
| 1286 | | case 0x0D: result |= (state->m_flags & VAR_HIRES) ? 0x80 : 0x00; break; |
| 1287 | | case 0x0E: result |= (state->m_flags & VAR_ALTCHARSET) ? 0x80 : 0x00; break; |
| 1288 | | case 0x0F: result |= (state->m_flags & VAR_80COL) ? 0x80 : 0x00; break; |
| 1272 | case 0x00: result |= AY3600_anykey_clearstrobe_r(space.machine()); break; |
| 1273 | case 0x01: result |= (m_flags & VAR_LCRAM2) ? 0x80 : 0x00; break; |
| 1274 | case 0x02: result |= (m_flags & VAR_LCRAM) ? 0x80 : 0x00; break; |
| 1275 | case 0x03: result |= (m_flags & VAR_RAMRD) ? 0x80 : 0x00; break; |
| 1276 | case 0x04: result |= (m_flags & VAR_RAMWRT) ? 0x80 : 0x00; break; |
| 1277 | case 0x05: result |= (m_flags & VAR_INTCXROM) ? 0x80 : 0x00; break; |
| 1278 | case 0x06: result |= (m_flags & VAR_ALTZP) ? 0x80 : 0x00; break; |
| 1279 | case 0x07: result |= (m_flags & VAR_SLOTC3ROM) ? 0x80 : 0x00; break; |
| 1280 | case 0x08: result |= (m_flags & VAR_80STORE) ? 0x80 : 0x00; break; |
| 1281 | case 0x09: result |= !space.machine().primary_screen->vblank() ? 0x80 : 0x00; break; |
| 1282 | case 0x0A: result |= (m_flags & VAR_TEXT) ? 0x80 : 0x00; break; |
| 1283 | case 0x0B: result |= (m_flags & VAR_MIXED) ? 0x80 : 0x00; break; |
| 1284 | case 0x0C: result |= (m_flags & VAR_PAGE2) ? 0x80 : 0x00; break; |
| 1285 | case 0x0D: result |= (m_flags & VAR_HIRES) ? 0x80 : 0x00; break; |
| 1286 | case 0x0E: result |= (m_flags & VAR_ALTCHARSET) ? 0x80 : 0x00; break; |
| 1287 | case 0x0F: result |= (m_flags & VAR_80COL) ? 0x80 : 0x00; break; |
| 1289 | 1288 | } |
| 1290 | 1289 | |
| 1291 | 1290 | g_profiler.stop(); |
| r15004 | r15005 | |
| 1300 | 1299 | apple2_c01x_w |
| 1301 | 1300 | ***************************************************************************/ |
| 1302 | 1301 | |
| 1303 | | WRITE8_HANDLER( apple2_c01x_w ) |
| 1302 | WRITE8_MEMBER( apple2_state::apple2_c01x_w ) |
| 1304 | 1303 | { |
| 1305 | 1304 | /* Clear the keyboard strobe - ignore the returned results */ |
| 1306 | 1305 | g_profiler.start(PROFILER_C01X); |
| 1307 | | AY3600_anykey_clearstrobe_r(space->machine()); |
| 1306 | AY3600_anykey_clearstrobe_r(space.machine()); |
| 1308 | 1307 | g_profiler.stop(); |
| 1309 | 1308 | } |
| 1310 | 1309 | |
| r15004 | r15005 | |
| 1314 | 1313 | apple2_c02x_r |
| 1315 | 1314 | ***************************************************************************/ |
| 1316 | 1315 | |
| 1317 | | READ8_HANDLER( apple2_c02x_r ) |
| 1316 | READ8_MEMBER( apple2_state::apple2_c02x_r ) |
| 1318 | 1317 | { |
| 1319 | | if(!space->debugger_access()) |
| 1318 | if(!space.debugger_access()) |
| 1320 | 1319 | { |
| 1321 | | apple2_c02x_w(space, offset, 0); |
| 1320 | apple2_c02x_w(space, offset, 0, 0); |
| 1322 | 1321 | } |
| 1323 | | return apple2_getfloatingbusvalue(space->machine()); |
| 1322 | return apple2_getfloatingbusvalue(space.machine()); |
| 1324 | 1323 | } |
| 1325 | 1324 | |
| 1326 | 1325 | |
| r15004 | r15005 | |
| 1329 | 1328 | apple2_c02x_w |
| 1330 | 1329 | ***************************************************************************/ |
| 1331 | 1330 | |
| 1332 | | WRITE8_HANDLER( apple2_c02x_w ) |
| 1331 | WRITE8_MEMBER( apple2_state::apple2_c02x_w ) |
| 1333 | 1332 | { |
| 1334 | | apple2_state *state = space->machine().driver_data<apple2_state>(); |
| 1335 | 1333 | switch(offset) |
| 1336 | 1334 | { |
| 1337 | 1335 | case 0x08: |
| 1338 | | apple2_setvar(space->machine(), (state->m_flags & VAR_ROMSWITCH) ^ VAR_ROMSWITCH, VAR_ROMSWITCH); |
| 1336 | apple2_setvar(space.machine(), (m_flags & VAR_ROMSWITCH) ^ VAR_ROMSWITCH, VAR_ROMSWITCH); |
| 1339 | 1337 | break; |
| 1340 | 1338 | } |
| 1341 | 1339 | } |
| r15004 | r15005 | |
| 1346 | 1344 | apple2_c03x_r |
| 1347 | 1345 | ***************************************************************************/ |
| 1348 | 1346 | |
| 1349 | | READ8_HANDLER ( apple2_c03x_r ) |
| 1347 | READ8_MEMBER ( apple2_state::apple2_c03x_r ) |
| 1350 | 1348 | { |
| 1351 | | apple2_state *state = space->machine().driver_data<apple2_state>(); |
| 1352 | | if(!space->debugger_access()) |
| 1349 | if(!space.debugger_access()) |
| 1353 | 1350 | { |
| 1354 | 1351 | if (!offset) |
| 1355 | 1352 | { |
| 1356 | | device_t *speaker_device = space->machine().device("a2speaker"); |
| 1353 | device_t *speaker_device = space.machine().device("a2speaker"); |
| 1357 | 1354 | |
| 1358 | | if (state->m_a2_speaker_state == 1) |
| 1355 | if (m_a2_speaker_state == 1) |
| 1359 | 1356 | { |
| 1360 | | state->m_a2_speaker_state = 0; |
| 1357 | m_a2_speaker_state = 0; |
| 1361 | 1358 | } |
| 1362 | 1359 | else |
| 1363 | 1360 | { |
| 1364 | | state->m_a2_speaker_state = 1; |
| 1361 | m_a2_speaker_state = 1; |
| 1365 | 1362 | } |
| 1366 | | speaker_level_w(speaker_device, state->m_a2_speaker_state); |
| 1363 | speaker_level_w(speaker_device, m_a2_speaker_state); |
| 1367 | 1364 | } |
| 1368 | 1365 | } |
| 1369 | | return apple2_getfloatingbusvalue(space->machine()); |
| 1366 | return apple2_getfloatingbusvalue(space.machine()); |
| 1370 | 1367 | } |
| 1371 | 1368 | |
| 1372 | 1369 | |
| r15004 | r15005 | |
| 1375 | 1372 | apple2_c03x_w |
| 1376 | 1373 | ***************************************************************************/ |
| 1377 | 1374 | |
| 1378 | | WRITE8_HANDLER ( apple2_c03x_w ) |
| 1375 | WRITE8_MEMBER ( apple2_state::apple2_c03x_w ) |
| 1379 | 1376 | { |
| 1380 | | apple2_c03x_r(space, offset); |
| 1377 | apple2_c03x_r(space, offset, 0); |
| 1381 | 1378 | } |
| 1382 | 1379 | |
| 1383 | 1380 | |
| r15004 | r15005 | |
| 1386 | 1383 | apple2_c05x_r |
| 1387 | 1384 | ***************************************************************************/ |
| 1388 | 1385 | |
| 1389 | | READ8_HANDLER ( apple2_c05x_r ) |
| 1386 | READ8_MEMBER ( apple2_state::apple2_c05x_r ) |
| 1390 | 1387 | { |
| 1391 | | if(!space->debugger_access()) |
| 1388 | if(!space.debugger_access()) |
| 1392 | 1389 | { |
| 1393 | 1390 | UINT32 mask; |
| 1394 | 1391 | |
| r15004 | r15005 | |
| 1399 | 1396 | } |
| 1400 | 1397 | |
| 1401 | 1398 | mask = 0x100 << (offset / 2); |
| 1402 | | apple2_setvar(space->machine(), (offset & 1) ? mask : 0, mask); |
| 1399 | apple2_setvar(space.machine(), (offset & 1) ? mask : 0, mask); |
| 1403 | 1400 | } |
| 1404 | | return apple2_getfloatingbusvalue(space->machine()); |
| 1401 | return apple2_getfloatingbusvalue(space.machine()); |
| 1405 | 1402 | } |
| 1406 | 1403 | |
| 1407 | 1404 | |
| r15004 | r15005 | |
| 1410 | 1407 | apple2_c05x_w |
| 1411 | 1408 | ***************************************************************************/ |
| 1412 | 1409 | |
| 1413 | | WRITE8_HANDLER ( apple2_c05x_w ) |
| 1410 | WRITE8_MEMBER ( apple2_state::apple2_c05x_w ) |
| 1414 | 1411 | { |
| 1415 | | apple2_c05x_r(space, offset); |
| 1412 | apple2_c05x_r(space, offset, 0); |
| 1416 | 1413 | } |
| 1417 | 1414 | |
| 1418 | 1415 | |
| r15004 | r15005 | |
| 1426 | 1423 | return machine.device<cassette_image_device>(CASSETTE_TAG); |
| 1427 | 1424 | } |
| 1428 | 1425 | |
| 1429 | | READ8_HANDLER ( apple2_c06x_r ) |
| 1426 | READ8_MEMBER ( apple2_state::apple2_c06x_r ) |
| 1430 | 1427 | { |
| 1431 | | apple2_state *state = space->machine().driver_data<apple2_state>(); |
| 1432 | 1428 | int result = 0; |
| 1433 | | if(!space->debugger_access()) |
| 1429 | if(!space.debugger_access()) |
| 1434 | 1430 | { |
| 1435 | 1431 | switch (offset & 0x0F) |
| 1436 | 1432 | { |
| 1437 | 1433 | case 0x00: |
| 1438 | 1434 | /* Cassette input */ |
| 1439 | 1435 | { |
| 1440 | | cassette_image_device *dev = cassette_device_image(space->machine()); |
| 1436 | cassette_image_device *dev = cassette_device_image(space.machine()); |
| 1441 | 1437 | |
| 1442 | 1438 | if (dev) |
| 1443 | 1439 | { |
| r15004 | r15005 | |
| 1451 | 1447 | break; |
| 1452 | 1448 | case 0x01: |
| 1453 | 1449 | /* Open-Apple/Joystick button 0 */ |
| 1454 | | result = apple2_pressed_specialkey(space->machine(), SPECIALKEY_BUTTON0); |
| 1450 | result = apple2_pressed_specialkey(space.machine(), SPECIALKEY_BUTTON0); |
| 1455 | 1451 | break; |
| 1456 | 1452 | case 0x02: |
| 1457 | 1453 | /* Closed-Apple/Joystick button 1 */ |
| 1458 | | result = apple2_pressed_specialkey(space->machine(), SPECIALKEY_BUTTON1); |
| 1454 | result = apple2_pressed_specialkey(space.machine(), SPECIALKEY_BUTTON1); |
| 1459 | 1455 | break; |
| 1460 | 1456 | case 0x03: |
| 1461 | 1457 | /* Joystick button 2. Later revision motherboards connected this to SHIFT also */ |
| 1462 | | result = apple2_pressed_specialkey(space->machine(), SPECIALKEY_BUTTON2); |
| 1458 | result = apple2_pressed_specialkey(space.machine(), SPECIALKEY_BUTTON2); |
| 1463 | 1459 | break; |
| 1464 | 1460 | case 0x04: |
| 1465 | 1461 | /* X Joystick 1 axis */ |
| 1466 | | result = space->machine().time().as_double() < state->m_joystick_x1_time; |
| 1462 | result = space.machine().time().as_double() < m_joystick_x1_time; |
| 1467 | 1463 | break; |
| 1468 | 1464 | case 0x05: |
| 1469 | 1465 | /* Y Joystick 1 axis */ |
| 1470 | | result = space->machine().time().as_double() < state->m_joystick_y1_time; |
| 1466 | result = space.machine().time().as_double() < m_joystick_y1_time; |
| 1471 | 1467 | break; |
| 1472 | 1468 | case 0x06: |
| 1473 | 1469 | /* X Joystick 2 axis */ |
| 1474 | | result = space->machine().time().as_double() < state->m_joystick_x2_time; |
| 1470 | result = space.machine().time().as_double() < m_joystick_x2_time; |
| 1475 | 1471 | break; |
| 1476 | 1472 | case 0x07: |
| 1477 | 1473 | /* Y Joystick 2 axis */ |
| 1478 | | result = space->machine().time().as_double() < state->m_joystick_y2_time; |
| 1474 | result = space.machine().time().as_double() < m_joystick_y2_time; |
| 1479 | 1475 | break; |
| 1480 | 1476 | default: |
| 1481 | 1477 | /* c060 Empty Cassette head read |
| 1482 | 1478 | * and any other non joystick c06 port returns this according to applewin |
| 1483 | 1479 | */ |
| 1484 | | return apple2_getfloatingbusvalue(space->machine()); |
| 1480 | return apple2_getfloatingbusvalue(space.machine()); |
| 1485 | 1481 | } |
| 1486 | 1482 | } |
| 1487 | 1483 | return result ? 0x80 : 0x00; |
| r15004 | r15005 | |
| 1493 | 1489 | apple2_c07x_r |
| 1494 | 1490 | ***************************************************************************/ |
| 1495 | 1491 | |
| 1496 | | READ8_HANDLER ( apple2_c07x_r ) |
| 1492 | READ8_MEMBER ( apple2_state::apple2_c07x_r ) |
| 1497 | 1493 | { |
| 1498 | | apple2_state *state = space->machine().driver_data<apple2_state>(); |
| 1499 | | if(!space->debugger_access()) |
| 1494 | if(!space.debugger_access()) |
| 1500 | 1495 | { |
| 1501 | 1496 | double x_calibration = attotime::from_usec(12).as_double(); |
| 1502 | 1497 | double y_calibration = attotime::from_usec(13).as_double(); |
| 1503 | 1498 | |
| 1504 | 1499 | if (offset == 0) |
| 1505 | 1500 | { |
| 1506 | | state->m_joystick_x1_time = space->machine().time().as_double() + x_calibration * input_port_read(space->machine(), "joystick_1_x"); |
| 1507 | | state->m_joystick_y1_time = space->machine().time().as_double() + y_calibration * input_port_read(space->machine(), "joystick_1_y"); |
| 1508 | | state->m_joystick_x2_time = space->machine().time().as_double() + x_calibration * input_port_read(space->machine(), "joystick_2_x"); |
| 1509 | | state->m_joystick_y2_time = space->machine().time().as_double() + y_calibration * input_port_read(space->machine(), "joystick_2_y"); |
| 1501 | m_joystick_x1_time = space.machine().time().as_double() + x_calibration * input_port_read(space.machine(), "joystick_1_x"); |
| 1502 | m_joystick_y1_time = space.machine().time().as_double() + y_calibration * input_port_read(space.machine(), "joystick_1_y"); |
| 1503 | m_joystick_x2_time = space.machine().time().as_double() + x_calibration * input_port_read(space.machine(), "joystick_2_x"); |
| 1504 | m_joystick_y2_time = space.machine().time().as_double() + y_calibration * input_port_read(space.machine(), "joystick_2_y"); |
| 1510 | 1505 | } |
| 1511 | 1506 | } |
| 1512 | 1507 | return 0; |
| r15004 | r15005 | |
| 1518 | 1513 | apple2_c07x_w |
| 1519 | 1514 | ***************************************************************************/ |
| 1520 | 1515 | |
| 1521 | | WRITE8_HANDLER ( apple2_c07x_w ) |
| 1516 | WRITE8_MEMBER ( apple2_state::apple2_c07x_w ) |
| 1522 | 1517 | { |
| 1523 | | apple2_c07x_r(space, offset); |
| 1518 | apple2_c07x_r(space, offset, 0); |
| 1524 | 1519 | } |
| 1525 | 1520 | |
| 1526 | 1521 | |