src/mess/machine/ay3600.c
| r10150 | r10151 | |
| 256 | 256 | } |
| 257 | 257 | }; |
| 258 | 258 | |
| 259 | | static unsigned int *ay3600_keys; |
| 260 | | |
| 261 | 259 | static UINT8 keycode; |
| 262 | | static UINT8 keycode_unmodified; |
| 263 | 260 | static UINT8 keywaiting; |
| 264 | | static UINT8 keystilldown; |
| 265 | | static UINT8 keymodreg; |
| 266 | 261 | |
| 267 | 262 | #define A2_KEY_NORMAL 0 |
| 268 | 263 | #define A2_KEY_CONTROL 1 |
| r10150 | r10151 | |
| 321 | 316 | |
| 322 | 317 | int AY3600_init(running_machine *machine) |
| 323 | 318 | { |
| 319 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 324 | 320 | /* Init the key remapping table */ |
| 325 | | ay3600_keys = auto_alloc_array_clear(machine, unsigned int, AY3600_KEYS_LENGTH); |
| 321 | state->ay3600_keys = auto_alloc_array_clear(machine, unsigned int, AY3600_KEYS_LENGTH); |
| 326 | 322 | |
| 327 | 323 | /* We poll the keyboard periodically to scan the keys. This is |
| 328 | 324 | actually consistent with how the AY-3600 keyboard controller works. */ |
| r10150 | r10151 | |
| 333 | 329 | |
| 334 | 330 | keywaiting = 0; |
| 335 | 331 | keycode = 0; |
| 336 | | keystilldown = 0; |
| 337 | | keymodreg = A2_KEYMOD_CAPSLOCK; // caps lock on |
| 332 | state->keystilldown = 0; |
| 333 | state->keymodreg = A2_KEYMOD_CAPSLOCK; // caps lock on |
| 338 | 334 | |
| 339 | | inputx_setup_natural_keyboard(AY3600_keyboard_queue_chars, |
| 335 | state->last_key = 0xff; /* necessary for special repeat key behaviour */ |
| 336 | state->last_key_unmodified = 0xff; /* necessary for special repeat key behaviour */ |
| 337 | state->time_until_repeat = MAGIC_KEY_REPEAT_NUMBER; |
| 338 | |
| 339 | inputx_setup_natural_keyboard( |
| 340 | AY3600_keyboard_queue_chars, |
| 340 | 341 | AY3600_keyboard_accept_char, |
| 341 | 342 | NULL); |
| 342 | 343 | |
| r10150 | r10151 | |
| 351 | 352 | |
| 352 | 353 | static TIMER_CALLBACK(AY3600_poll) |
| 353 | 354 | { |
| 355 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 354 | 356 | int switchkey; /* Normal, Shift, Control, or both */ |
| 355 | 357 | int port, num_ports, bit, data; |
| 356 | 358 | int any_key_pressed = 0; /* Have we pressed a key? True/False */ |
| r10150 | r10151 | |
| 358 | 360 | int curkey; |
| 359 | 361 | int curkey_unmodified; |
| 360 | 362 | |
| 361 | | static int reset_flag = 0; |
| 362 | | static int last_key = 0xff; /* necessary for special repeat key behaviour */ |
| 363 | | static int last_key_unmodified = 0xff; /* necessary for special repeat key behaviour */ |
| 364 | 363 | |
| 365 | | static unsigned int time_until_repeat = MAGIC_KEY_REPEAT_NUMBER; |
| 366 | | |
| 367 | 364 | static const char *const portnames[] = { |
| 368 | 365 | "keyb_0", "keyb_1", "keyb_2", "keyb_3", "keyb_4", "keyb_5", "keyb_6", |
| 369 | 366 | "keypad_1", "keypad_2" |
| r10150 | r10151 | |
| 373 | 370 | |
| 374 | 371 | /* only repeat keys on a 2/2+ if special REPT key is pressed */ |
| 375 | 372 | if (a2_has_repeat(machine)) |
| 376 | | time_until_repeat = input_port_read(machine, "keyb_repeat") & 0x01 ? 0 : ~0; |
| 373 | state->time_until_repeat = input_port_read(machine, "keyb_repeat") & 0x01 ? 0 : ~0; |
| 377 | 374 | |
| 378 | 375 | /* check caps lock and set LED here */ |
| 379 | 376 | if (apple2_pressed_specialkey(machine, SPECIALKEY_CAPSLOCK)) |
| 380 | 377 | { |
| 381 | 378 | caps_lock = 1; |
| 382 | 379 | set_led_status(machine,1,1); |
| 383 | | keymodreg |= A2_KEYMOD_CAPSLOCK; |
| 380 | state->keymodreg |= A2_KEYMOD_CAPSLOCK; |
| 384 | 381 | } |
| 385 | 382 | else |
| 386 | 383 | { |
| 387 | 384 | caps_lock = 0; |
| 388 | 385 | set_led_status(machine,1,0); |
| 389 | | keymodreg &= ~A2_KEYMOD_CAPSLOCK; |
| 386 | state->keymodreg &= ~A2_KEYMOD_CAPSLOCK; |
| 390 | 387 | } |
| 391 | 388 | |
| 392 | 389 | switchkey = A2_KEY_NORMAL; |
| r10150 | r10151 | |
| 395 | 392 | if (apple2_pressed_specialkey(machine, SPECIALKEY_SHIFT)) |
| 396 | 393 | { |
| 397 | 394 | switchkey |= A2_KEY_SHIFT; |
| 398 | | keymodreg |= A2_KEYMOD_SHIFT; |
| 395 | state->keymodreg |= A2_KEYMOD_SHIFT; |
| 399 | 396 | } |
| 400 | 397 | else |
| 401 | 398 | { |
| 402 | | keymodreg &= ~A2_KEYMOD_SHIFT; |
| 399 | state->keymodreg &= ~A2_KEYMOD_SHIFT; |
| 403 | 400 | } |
| 404 | 401 | |
| 405 | 402 | /* control key check - only one control key on the left side on the Apple */ |
| 406 | 403 | if (apple2_pressed_specialkey(machine, SPECIALKEY_CONTROL)) |
| 407 | 404 | { |
| 408 | 405 | switchkey |= A2_KEY_CONTROL; |
| 409 | | keymodreg |= A2_KEYMOD_CONTROL; |
| 406 | state->keymodreg |= A2_KEYMOD_CONTROL; |
| 410 | 407 | } |
| 411 | 408 | else |
| 412 | 409 | { |
| 413 | | keymodreg &= ~A2_KEYMOD_CONTROL; |
| 410 | state->keymodreg &= ~A2_KEYMOD_CONTROL; |
| 414 | 411 | } |
| 415 | 412 | |
| 416 | 413 | /* apple key check */ |
| 417 | 414 | if (apple2_pressed_specialkey(machine, SPECIALKEY_BUTTON0)) |
| 418 | 415 | { |
| 419 | | keymodreg |= A2_KEYMOD_COMMAND; |
| 416 | state->keymodreg |= A2_KEYMOD_COMMAND; |
| 420 | 417 | } |
| 421 | 418 | else |
| 422 | 419 | { |
| 423 | | keymodreg &= ~A2_KEYMOD_COMMAND; |
| 420 | state->keymodreg &= ~A2_KEYMOD_COMMAND; |
| 424 | 421 | } |
| 425 | 422 | |
| 426 | 423 | /* option key check */ |
| 427 | 424 | if (apple2_pressed_specialkey(machine, SPECIALKEY_BUTTON1)) |
| 428 | 425 | { |
| 429 | | keymodreg |= A2_KEYMOD_OPTION; |
| 426 | state->keymodreg |= A2_KEYMOD_OPTION; |
| 430 | 427 | } |
| 431 | 428 | else |
| 432 | 429 | { |
| 433 | | keymodreg &= ~A2_KEYMOD_OPTION; |
| 430 | state->keymodreg &= ~A2_KEYMOD_OPTION; |
| 434 | 431 | } |
| 435 | 432 | |
| 436 | 433 | /* reset key check */ |
| 437 | 434 | if (apple2_pressed_specialkey(machine, SPECIALKEY_RESET) && |
| 438 | 435 | (a2_no_ctrl_reset(machine) || switchkey & A2_KEY_CONTROL)) |
| 439 | 436 | { |
| 440 | | if (!reset_flag) |
| 437 | if (!state->reset_flag) |
| 441 | 438 | { |
| 442 | | reset_flag = 1; |
| 439 | state->reset_flag = 1; |
| 443 | 440 | /* using PULSE_LINE does not allow us to press and hold key */ |
| 444 | 441 | cputag_set_input_line(machine, "maincpu", INPUT_LINE_RESET, ASSERT_LINE); |
| 445 | 442 | } |
| 446 | 443 | return; |
| 447 | 444 | } |
| 448 | | if (reset_flag) |
| 445 | if (state->reset_flag) |
| 449 | 446 | { |
| 450 | | reset_flag = 0; |
| 447 | state->reset_flag = 0; |
| 451 | 448 | cputag_set_input_line(machine, "maincpu", INPUT_LINE_RESET, CLEAR_LINE); |
| 452 | 449 | machine->schedule_soft_reset(); |
| 453 | 450 | } |
| r10150 | r10151 | |
| 455 | 452 | /* run through real keys and see what's being pressed */ |
| 456 | 453 | num_ports = a2_has_keypad(machine) ? 9 : 7; |
| 457 | 454 | |
| 458 | | keymodreg &= ~A2_KEYMOD_KEYPAD; |
| 455 | state->keymodreg &= ~A2_KEYMOD_KEYPAD; |
| 459 | 456 | |
| 460 | 457 | for (port = 0; port < num_ports; port++) |
| 461 | 458 | { |
| r10150 | r10151 | |
| 479 | 476 | |
| 480 | 477 | if (port == 8) |
| 481 | 478 | { |
| 482 | | keymodreg |= A2_KEYMOD_KEYPAD; |
| 479 | state->keymodreg |= A2_KEYMOD_KEYPAD; |
| 483 | 480 | } |
| 484 | 481 | |
| 485 | 482 | /* prevent overflow */ |
| 486 | | if (ay3600_keys[port*8+bit] < 65000) |
| 487 | | ay3600_keys[port*8+bit]++; |
| 483 | if (state->ay3600_keys[port*8+bit] < 65000) |
| 484 | state->ay3600_keys[port*8+bit]++; |
| 488 | 485 | |
| 489 | 486 | /* on every key press, reset the time until repeat and the key to repeat */ |
| 490 | | if ((ay3600_keys[port*8+bit] == 1) && (curkey_unmodified != last_key_unmodified)) |
| 487 | if ((state->ay3600_keys[port*8+bit] == 1) && (curkey_unmodified != state->last_key_unmodified)) |
| 491 | 488 | { |
| 492 | | time_until_repeat = MAGIC_KEY_REPEAT_NUMBER; |
| 493 | | last_key = curkey; |
| 494 | | last_key_unmodified = curkey_unmodified; |
| 489 | state->time_until_repeat = MAGIC_KEY_REPEAT_NUMBER; |
| 490 | state->last_key = curkey; |
| 491 | state->last_key_unmodified = curkey_unmodified; |
| 495 | 492 | } |
| 496 | 493 | } |
| 497 | 494 | else |
| 498 | 495 | { |
| 499 | | ay3600_keys[port*8+bit] = 0; |
| 496 | state->ay3600_keys[port*8+bit] = 0; |
| 500 | 497 | } |
| 501 | 498 | } |
| 502 | 499 | } |
| 503 | 500 | |
| 504 | | keymodreg &= ~A2_KEYMOD_REPEAT; |
| 501 | state->keymodreg &= ~A2_KEYMOD_REPEAT; |
| 505 | 502 | |
| 506 | 503 | if (!any_key_pressed) |
| 507 | 504 | { |
| 508 | 505 | /* If no keys have been pressed, reset the repeat time and return */ |
| 509 | | time_until_repeat = MAGIC_KEY_REPEAT_NUMBER; |
| 510 | | last_key = 0xff; |
| 511 | | last_key_unmodified = 0xff; |
| 506 | state->time_until_repeat = MAGIC_KEY_REPEAT_NUMBER; |
| 507 | state->last_key = 0xff; |
| 508 | state->last_key_unmodified = 0xff; |
| 512 | 509 | } |
| 513 | 510 | else |
| 514 | 511 | { |
| 515 | 512 | /* Otherwise, count down the repeat time */ |
| 516 | | if (time_until_repeat > 0) |
| 517 | | time_until_repeat--; |
| 513 | if (state->time_until_repeat > 0) |
| 514 | state->time_until_repeat--; |
| 518 | 515 | |
| 519 | 516 | /* Even if a key has been released, repeat it if it was the last key pressed */ |
| 520 | 517 | /* If we should output a key, set the appropriate Apple II data lines */ |
| 521 | | if (time_until_repeat == 0 || |
| 522 | | time_until_repeat == MAGIC_KEY_REPEAT_NUMBER-1) |
| 518 | if (state->time_until_repeat == 0 || |
| 519 | state->time_until_repeat == MAGIC_KEY_REPEAT_NUMBER-1) |
| 523 | 520 | { |
| 524 | 521 | keywaiting = 1; |
| 525 | | keycode = last_key; |
| 526 | | keycode_unmodified = last_key_unmodified; |
| 527 | | keymodreg |= A2_KEYMOD_REPEAT; |
| 522 | keycode = state->last_key; |
| 523 | state->keycode_unmodified = state->last_key_unmodified; |
| 524 | state->keymodreg |= A2_KEYMOD_REPEAT; |
| 528 | 525 | } |
| 529 | 526 | } |
| 530 | | keystilldown = (last_key_unmodified == keycode_unmodified); |
| 527 | state->keystilldown = (state->last_key_unmodified == state->keycode_unmodified); |
| 531 | 528 | } |
| 532 | 529 | |
| 533 | 530 | |
| r10150 | r10151 | |
| 536 | 533 | AY3600_keydata_strobe_r ($C00x) |
| 537 | 534 | ***************************************************************************/ |
| 538 | 535 | |
| 539 | | int AY3600_keydata_strobe_r(void) |
| 536 | int AY3600_keydata_strobe_r(running_machine *machine) |
| 540 | 537 | { |
| 541 | 538 | int rc; |
| 542 | 539 | rc = keycode | (keywaiting ? 0x80 : 0x00); |
| r10150 | r10151 | |
| 550 | 547 | AY3600_anykey_clearstrobe_r ($C01x) |
| 551 | 548 | ***************************************************************************/ |
| 552 | 549 | |
| 553 | | int AY3600_anykey_clearstrobe_r(void) |
| 550 | int AY3600_anykey_clearstrobe_r(running_machine *machine) |
| 554 | 551 | { |
| 552 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 555 | 553 | int rc; |
| 556 | 554 | keywaiting = 0; |
| 557 | | rc = keycode | (keystilldown ? 0x80 : 0x00); |
| 555 | rc = keycode | (state->keystilldown ? 0x80 : 0x00); |
| 558 | 556 | LOG(("AY3600_anykey_clearstrobe_r(): rc=0x%02x\n", rc)); |
| 559 | 557 | return rc; |
| 560 | 558 | } |
| r10150 | r10151 | |
| 564 | 562 | AY3600_keymod_r ($C025 - IIgs only) |
| 565 | 563 | ***************************************************************************/ |
| 566 | 564 | |
| 567 | | int AY3600_keymod_r(void) |
| 565 | int AY3600_keymod_r(running_machine *machine) |
| 568 | 566 | { |
| 569 | | return keymodreg; |
| 567 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 568 | return state->keymodreg; |
| 570 | 569 | } |
| 571 | 570 | |
| 572 | 571 | /*************************************************************************** |
src/mess/machine/apple2gs.c
| r10150 | r10151 | |
| 922 | 922 | break; |
| 923 | 923 | |
| 924 | 924 | case 0x22: /* C022 - TBCOLOR */ |
| 925 | | result = (apple2_get_fgcolor() << 4) |
| 926 | | | apple2_get_bgcolor(); |
| 925 | result = (state->fgcolor << 4) | state->bgcolor; |
| 927 | 926 | break; |
| 928 | 927 | |
| 929 | 928 | case 0x23: /* C023 - VGCINT */ |
| r10150 | r10151 | |
| 935 | 934 | break; |
| 936 | 935 | |
| 937 | 936 | case 0x25: /* C025 - KEYMODREG */ |
| 938 | | result = AY3600_keymod_r(); |
| 937 | result = AY3600_keymod_r(space->machine); |
| 939 | 938 | break; |
| 940 | 939 | |
| 941 | 940 | case 0x26: /* C026 - DATAREG */ |
| r10150 | r10151 | |
| 976 | 975 | break; |
| 977 | 976 | |
| 978 | 977 | case 0x31: /* C031 - DISKREG */ |
| 979 | | result = apple2_iwm_getdiskreg(); |
| 978 | result = apple2_iwm_getdiskreg(space->machine); |
| 980 | 979 | break; |
| 981 | 980 | |
| 982 | 981 | case 0x33: /* C033 - CLOCKDATA */ |
| r10150 | r10151 | |
| 1019 | 1018 | break; |
| 1020 | 1019 | |
| 1021 | 1020 | case 0x68: /* C068 - STATEREG */ |
| 1022 | | result = ((apple2_flags & VAR_ALTZP) ? 0x80 : 0x00) |
| 1023 | | | ((apple2_flags & VAR_PAGE2) ? 0x40 : 0x00) |
| 1024 | | | ((apple2_flags & VAR_RAMRD) ? 0x20 : 0x00) |
| 1025 | | | ((apple2_flags & VAR_RAMWRT) ? 0x10 : 0x00) |
| 1026 | | | ((apple2_flags & VAR_LCRAM) ? 0x00 : 0x08) |
| 1027 | | | ((apple2_flags & VAR_LCRAM2) ? 0x04 : 0x00) |
| 1028 | | | ((apple2_flags & VAR_INTCXROM)? 0x01 : 0x00); |
| 1021 | result = ((state->flags & VAR_ALTZP) ? 0x80 : 0x00) |
| 1022 | | ((state->flags & VAR_PAGE2) ? 0x40 : 0x00) |
| 1023 | | ((state->flags & VAR_RAMRD) ? 0x20 : 0x00) |
| 1024 | | ((state->flags & VAR_RAMWRT) ? 0x10 : 0x00) |
| 1025 | | ((state->flags & VAR_LCRAM) ? 0x00 : 0x08) |
| 1026 | | ((state->flags & VAR_LCRAM2) ? 0x04 : 0x00) |
| 1027 | | ((state->flags & VAR_INTCXROM)? 0x01 : 0x00); |
| 1029 | 1028 | break; |
| 1030 | 1029 | |
| 1031 | 1030 | case 0x71: case 0x72: case 0x73: |
| r10150 | r10151 | |
| 1065 | 1064 | switch(offset) |
| 1066 | 1065 | { |
| 1067 | 1066 | case 0x22: /* C022 - TBCOLOR */ |
| 1068 | | apple2_set_fgcolor((data >> 4) & 0x0F); |
| 1069 | | apple2_set_bgcolor((data >> 0) & 0x0F); |
| 1067 | state->fgcolor = (data >> 4) & 0x0F; |
| 1068 | state->bgcolor = (data >> 0) & 0x0F; |
| 1070 | 1069 | break; |
| 1071 | 1070 | |
| 1072 | 1071 | case 0x23: /* C023 - VGCINT */ |
| r10150 | r10151 | |
| 1284 | 1283 | |
| 1285 | 1284 | static void apple2gs_mem_000000(running_machine *machine,offs_t begin, offs_t end, apple2_meminfo *meminfo) |
| 1286 | 1285 | { |
| 1287 | | meminfo->read_mem = (apple2_flags & VAR_ALTZP) ? 0x010000 : 0x000000; |
| 1288 | | meminfo->write_mem = (apple2_flags & VAR_ALTZP) ? 0x010000 : 0x000000; |
| 1286 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 1287 | meminfo->read_mem = (state->flags & VAR_ALTZP) ? 0x010000 : 0x000000; |
| 1288 | meminfo->write_mem = (state->flags & VAR_ALTZP) ? 0x010000 : 0x000000; |
| 1289 | 1289 | } |
| 1290 | 1290 | |
| 1291 | 1291 | static void apple2gs_mem_000200(running_machine *machine,offs_t begin, offs_t end, apple2_meminfo *meminfo) |
| 1292 | 1292 | { |
| 1293 | | meminfo->read_mem = (apple2_flags & VAR_RAMRD) ? 0x010200 : 0x000200; |
| 1294 | | meminfo->write_mem = (apple2_flags & VAR_RAMWRT) ? 0x010200 : 0x000200; |
| 1293 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 1294 | meminfo->read_mem = (state->flags & VAR_RAMRD) ? 0x010200 : 0x000200; |
| 1295 | meminfo->write_mem = (state->flags & VAR_RAMWRT) ? 0x010200 : 0x000200; |
| 1295 | 1296 | } |
| 1296 | 1297 | |
| 1297 | 1298 | static void apple2gs_mem_000400(running_machine *machine,offs_t begin, offs_t end, apple2_meminfo *meminfo) |
| 1298 | 1299 | { |
| 1299 | | if (apple2_flags & VAR_80STORE) |
| 1300 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 1301 | if (state->flags & VAR_80STORE) |
| 1300 | 1302 | { |
| 1301 | | meminfo->read_mem = (apple2_flags & VAR_PAGE2) ? 0x010400 : 0x000400; |
| 1302 | | meminfo->write_mem = (apple2_flags & VAR_PAGE2) ? 0x010400 : 0x000400; |
| 1303 | | meminfo->write_handler = (apple2_flags & VAR_PAGE2) ? apple2gs_aux0400_w : apple2gs_main0400_w; |
| 1303 | meminfo->read_mem = (state->flags & VAR_PAGE2) ? 0x010400 : 0x000400; |
| 1304 | meminfo->write_mem = (state->flags & VAR_PAGE2) ? 0x010400 : 0x000400; |
| 1305 | meminfo->write_handler = (state->flags & VAR_PAGE2) ? apple2gs_aux0400_w : apple2gs_main0400_w; |
| 1304 | 1306 | } |
| 1305 | 1307 | else |
| 1306 | 1308 | { |
| 1307 | | meminfo->read_mem = (apple2_flags & VAR_RAMRD) ? 0x010400 : 0x000400; |
| 1308 | | meminfo->write_mem = (apple2_flags & VAR_RAMWRT) ? 0x010400 : 0x000400; |
| 1309 | | meminfo->write_handler = (apple2_flags & VAR_RAMWRT) ? apple2gs_aux0400_w : apple2gs_main0400_w; |
| 1309 | meminfo->read_mem = (state->flags & VAR_RAMRD) ? 0x010400 : 0x000400; |
| 1310 | meminfo->write_mem = (state->flags & VAR_RAMWRT) ? 0x010400 : 0x000400; |
| 1311 | meminfo->write_handler = (state->flags & VAR_RAMWRT) ? apple2gs_aux0400_w : apple2gs_main0400_w; |
| 1310 | 1312 | } |
| 1311 | 1313 | } |
| 1312 | 1314 | |
| 1313 | 1315 | static void apple2gs_mem_000800(running_machine *machine,offs_t begin, offs_t end, apple2_meminfo *meminfo) |
| 1314 | 1316 | { |
| 1315 | | meminfo->read_mem = (apple2_flags & VAR_RAMRD) ? 0x010800 : 0x000800; |
| 1316 | | meminfo->write_mem = (apple2_flags & VAR_RAMWRT) ? 0x010800 : 0x000800; |
| 1317 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 1318 | meminfo->read_mem = (state->flags & VAR_RAMRD) ? 0x010800 : 0x000800; |
| 1319 | meminfo->write_mem = (state->flags & VAR_RAMWRT) ? 0x010800 : 0x000800; |
| 1317 | 1320 | } |
| 1318 | 1321 | |
| 1319 | 1322 | static void apple2gs_mem_002000(running_machine *machine,offs_t begin, offs_t end, apple2_meminfo *meminfo) |
| 1320 | 1323 | { |
| 1321 | | if ((apple2_flags & (VAR_80STORE|VAR_HIRES)) == (VAR_80STORE|VAR_HIRES)) |
| 1324 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 1325 | if ((state->flags & (VAR_80STORE|VAR_HIRES)) == (VAR_80STORE|VAR_HIRES)) |
| 1322 | 1326 | { |
| 1323 | | meminfo->read_mem = (apple2_flags & VAR_PAGE2) ? 0x012000 : 0x002000; |
| 1324 | | meminfo->write_mem = (apple2_flags & VAR_PAGE2) ? 0x012000 : 0x002000; |
| 1325 | | meminfo->write_handler = (apple2_flags & VAR_PAGE2) ? apple2gs_aux2000_w : apple2gs_main2000_w; |
| 1327 | meminfo->read_mem = (state->flags & VAR_PAGE2) ? 0x012000 : 0x002000; |
| 1328 | meminfo->write_mem = (state->flags & VAR_PAGE2) ? 0x012000 : 0x002000; |
| 1329 | meminfo->write_handler = (state->flags & VAR_PAGE2) ? apple2gs_aux2000_w : apple2gs_main2000_w; |
| 1326 | 1330 | } |
| 1327 | 1331 | else |
| 1328 | 1332 | { |
| 1329 | | meminfo->read_mem = (apple2_flags & VAR_RAMRD) ? 0x012000 : 0x002000; |
| 1330 | | meminfo->write_mem = (apple2_flags & VAR_RAMWRT) ? 0x012000 : 0x002000; |
| 1331 | | meminfo->write_handler = (apple2_flags & VAR_RAMWRT) ? apple2gs_aux2000_w : apple2gs_main2000_w; |
| 1333 | meminfo->read_mem = (state->flags & VAR_RAMRD) ? 0x012000 : 0x002000; |
| 1334 | meminfo->write_mem = (state->flags & VAR_RAMWRT) ? 0x012000 : 0x002000; |
| 1335 | meminfo->write_handler = (state->flags & VAR_RAMWRT) ? apple2gs_aux2000_w : apple2gs_main2000_w; |
| 1332 | 1336 | } |
| 1333 | 1337 | } |
| 1334 | 1338 | |
| 1335 | 1339 | static void apple2gs_mem_004000(running_machine *machine,offs_t begin, offs_t end, apple2_meminfo *meminfo) |
| 1336 | 1340 | { |
| 1337 | | meminfo->read_mem = (apple2_flags & VAR_RAMRD) ? 0x014000 : 0x004000; |
| 1338 | | meminfo->write_handler = (apple2_flags & VAR_RAMWRT) ? apple2gs_aux4000_w : apple2gs_main4000_w; |
| 1341 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 1342 | meminfo->read_mem = (state->flags & VAR_RAMRD) ? 0x014000 : 0x004000; |
| 1343 | meminfo->write_handler = (state->flags & VAR_RAMWRT) ? apple2gs_aux4000_w : apple2gs_main4000_w; |
| 1339 | 1344 | } |
| 1340 | 1345 | |
| 1341 | 1346 | static void apple2gs_mem_xxD000(running_machine *machine,apple2_meminfo *meminfo, UINT32 lcmem) |
| 1342 | 1347 | { |
| 1343 | | if (apple2_flags & VAR_LCRAM) |
| 1348 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 1349 | if (state->flags & VAR_LCRAM) |
| 1344 | 1350 | { |
| 1345 | | if (apple2_flags & VAR_LCRAM2) |
| 1351 | if (state->flags & VAR_LCRAM2) |
| 1346 | 1352 | meminfo->read_mem = lcmem | 0x00C000; |
| 1347 | 1353 | else |
| 1348 | 1354 | meminfo->read_mem = lcmem | 0x00D000; |
| r10150 | r10151 | |
| 1352 | 1358 | meminfo->read_mem = 0x03D000 | APPLE2_MEM_ROM; |
| 1353 | 1359 | } |
| 1354 | 1360 | |
| 1355 | | if (apple2_flags & VAR_LCWRITE) |
| 1361 | if (state->flags & VAR_LCWRITE) |
| 1356 | 1362 | { |
| 1357 | | if (apple2_flags & VAR_LCRAM2) |
| 1363 | if (state->flags & VAR_LCRAM2) |
| 1358 | 1364 | meminfo->write_mem = lcmem | 0x00C000; |
| 1359 | 1365 | else |
| 1360 | 1366 | meminfo->write_mem = lcmem | 0x00D000; |
| r10150 | r10151 | |
| 1367 | 1373 | |
| 1368 | 1374 | static void apple2gs_mem_xxE000(running_machine *machine,apple2_meminfo *meminfo, UINT32 lcmem) |
| 1369 | 1375 | { |
| 1370 | | if (apple2_flags & VAR_LCRAM) |
| 1376 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 1377 | if (state->flags & VAR_LCRAM) |
| 1371 | 1378 | meminfo->read_mem = lcmem | 0x00E000; |
| 1372 | 1379 | else |
| 1373 | 1380 | meminfo->read_mem = 0x03E000 | APPLE2_MEM_ROM; |
| 1374 | 1381 | |
| 1375 | | if (apple2_flags & VAR_LCWRITE) |
| 1382 | if (state->flags & VAR_LCWRITE) |
| 1376 | 1383 | meminfo->write_mem = lcmem | 0x00E000; |
| 1377 | 1384 | else |
| 1378 | 1385 | meminfo->write_mem = APPLE2_MEM_FLOATING; |
| r10150 | r10151 | |
| 1383 | 1390 | apple2gs_state *state = machine->driver_data<apple2gs_state>(); |
| 1384 | 1391 | if (state->shadow & 0x40) |
| 1385 | 1392 | { |
| 1386 | | meminfo->read_mem = (apple2_flags & VAR_RAMRD) ? 0x01D000 : 0x00D000; |
| 1387 | | meminfo->write_mem = (apple2_flags & VAR_RAMWRT) ? 0x01D000 : 0x00D000; |
| 1393 | meminfo->read_mem = (state->flags & VAR_RAMRD) ? 0x01D000 : 0x00D000; |
| 1394 | meminfo->write_mem = (state->flags & VAR_RAMWRT) ? 0x01D000 : 0x00D000; |
| 1388 | 1395 | } |
| 1389 | 1396 | else |
| 1390 | 1397 | { |
| 1391 | | apple2gs_mem_xxD000(machine,meminfo, (apple2_flags & VAR_ALTZP) ? 0x010000 : 0x000000); |
| 1398 | apple2gs_mem_xxD000(machine,meminfo, (state->flags & VAR_ALTZP) ? 0x010000 : 0x000000); |
| 1392 | 1399 | } |
| 1393 | 1400 | } |
| 1394 | 1401 | |
| r10150 | r10151 | |
| 1397 | 1404 | apple2gs_state *state = machine->driver_data<apple2gs_state>(); |
| 1398 | 1405 | if (state->shadow & 0x40) |
| 1399 | 1406 | { |
| 1400 | | meminfo->read_mem = (apple2_flags & VAR_RAMRD) ? 0x01E000 : 0x00E000; |
| 1401 | | meminfo->write_mem = (apple2_flags & VAR_RAMWRT) ? 0x01E000 : 0x00E000; |
| 1407 | meminfo->read_mem = (state->flags & VAR_RAMRD) ? 0x01E000 : 0x00E000; |
| 1408 | meminfo->write_mem = (state->flags & VAR_RAMWRT) ? 0x01E000 : 0x00E000; |
| 1402 | 1409 | } |
| 1403 | 1410 | else |
| 1404 | 1411 | { |
| 1405 | | apple2gs_mem_xxE000(machine,meminfo, (apple2_flags & VAR_ALTZP) ? 0x010000 : 0x000000); |
| 1412 | apple2gs_mem_xxE000(machine,meminfo, (state->flags & VAR_ALTZP) ? 0x010000 : 0x000000); |
| 1406 | 1413 | } |
| 1407 | 1414 | } |
| 1408 | 1415 | |
src/mess/machine/apple2.c
| r10150 | r10151 | |
| 40 | 40 | #define PROFILER_A2INT PROFILER_USER2 |
| 41 | 41 | |
| 42 | 42 | /* softswitch */ |
| 43 | | UINT32 apple2_flags; |
| 44 | 43 | |
| 45 | 44 | /* before the softswitch is changed, these are applied */ |
| 46 | | static UINT32 a2_mask; |
| 47 | | static UINT32 a2_set; |
| 48 | 45 | |
| 49 | | INT32 a2_cnxx_slot; |
| 50 | 46 | |
| 51 | 47 | /* local */ |
| 52 | | static int a2_speaker_state; |
| 53 | 48 | |
| 54 | | static double joystick_x1_time; |
| 55 | | static double joystick_y1_time; |
| 56 | | static double joystick_x2_time; |
| 57 | | static double joystick_y2_time; |
| 58 | 49 | |
| 59 | 50 | static WRITE8_HANDLER ( apple2_mainram0400_w ); |
| 60 | 51 | static WRITE8_HANDLER ( apple2_mainram2000_w ); |
| r10150 | r10151 | |
| 90 | 81 | * New Apple II memory manager |
| 91 | 82 | * ----------------------------------------------------------------------- */ |
| 92 | 83 | |
| 93 | | static apple2_memmap_config apple2_mem_config; |
| 94 | | static apple2_meminfo *apple2_current_meminfo; |
| 95 | 84 | |
| 96 | 85 | |
| 97 | 86 | static READ8_HANDLER(read_floatingbus) |
| r10150 | r10151 | |
| 103 | 92 | |
| 104 | 93 | void apple2_setup_memory(running_machine *machine, const apple2_memmap_config *config) |
| 105 | 94 | { |
| 106 | | apple2_mem_config = *config; |
| 107 | | apple2_current_meminfo = NULL; |
| 95 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 96 | state->mem_config = *config; |
| 97 | state->current_meminfo = NULL; |
| 108 | 98 | apple2_update_memory(machine); |
| 109 | 99 | } |
| 110 | 100 | |
| r10150 | r10151 | |
| 112 | 102 | |
| 113 | 103 | void apple2_update_memory(running_machine *machine) |
| 114 | 104 | { |
| 105 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 115 | 106 | address_space* space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 116 | 107 | int i, bank; |
| 117 | 108 | char rbank[10], wbank[10]; |
| r10150 | r10151 | |
| 126 | 117 | int wh_nop = 0; |
| 127 | 118 | |
| 128 | 119 | /* need to build list of current info? */ |
| 129 | | if (!apple2_current_meminfo) |
| 120 | if (!state->current_meminfo) |
| 130 | 121 | { |
| 131 | | for (i = 0; apple2_mem_config.memmap[i].end; i++) |
| 122 | for (i = 0; state->mem_config.memmap[i].end; i++) |
| 132 | 123 | ; |
| 133 | | apple2_current_meminfo = auto_alloc_array(machine, apple2_meminfo, i); |
| 124 | state->current_meminfo = auto_alloc_array(machine, apple2_meminfo, i); |
| 134 | 125 | full_update = 1; |
| 135 | 126 | } |
| 136 | 127 | |
| r10150 | r10151 | |
| 141 | 132 | slot_ram = (slot_length > 0) ? &rom[rom_length] : NULL; |
| 142 | 133 | |
| 143 | 134 | /* loop through the entire memory map */ |
| 144 | | bank = apple2_mem_config.first_bank; |
| 145 | | for (i = 0; apple2_mem_config.memmap[i].get_meminfo; i++) |
| 135 | bank = state->mem_config.first_bank; |
| 136 | for (i = 0; state->mem_config.memmap[i].get_meminfo; i++) |
| 146 | 137 | { |
| 147 | 138 | /* retrieve information on this entry */ |
| 148 | 139 | memset(&meminfo, 0, sizeof(meminfo)); |
| 149 | | apple2_mem_config.memmap[i].get_meminfo(machine, apple2_mem_config.memmap[i].begin, apple2_mem_config.memmap[i].end, &meminfo); |
| 140 | state->mem_config.memmap[i].get_meminfo(machine, state->mem_config.memmap[i].begin, state->mem_config.memmap[i].end, &meminfo); |
| 150 | 141 | |
| 151 | | bank_disposition = apple2_mem_config.memmap[i].bank_disposition; |
| 142 | bank_disposition = state->mem_config.memmap[i].bank_disposition; |
| 152 | 143 | |
| 153 | 144 | /* do we need to memory reading? */ |
| 154 | 145 | if (full_update |
| 155 | | || (meminfo.read_mem != apple2_current_meminfo[i].read_mem) |
| 156 | | || (meminfo.read_handler != apple2_current_meminfo[i].read_handler)) |
| 146 | || (meminfo.read_mem != state->current_meminfo[i].read_mem) |
| 147 | || (meminfo.read_handler != state->current_meminfo[i].read_handler)) |
| 157 | 148 | { |
| 158 | 149 | rbase = NULL; |
| 159 | 150 | sprintf(rbank,"bank%d",bank); |
| 160 | | begin = apple2_mem_config.memmap[i].begin; |
| 161 | | end_r = apple2_mem_config.memmap[i].end; |
| 151 | begin = state->mem_config.memmap[i].begin; |
| 152 | end_r = state->mem_config.memmap[i].end; |
| 162 | 153 | rh = NULL; |
| 163 | 154 | |
| 164 | 155 | LOG(("apple2_update_memory(): Updating RD {%06X..%06X} [#%02d] --> %08X\n", |
| r10150 | r10151 | |
| 178 | 169 | else if ((meminfo.read_mem & 0xC0000000) == APPLE2_MEM_AUX) |
| 179 | 170 | { |
| 180 | 171 | /* auxillary memory */ |
| 181 | | assert(apple2_mem_config.auxmem); |
| 172 | assert(state->mem_config.auxmem); |
| 182 | 173 | offset = meminfo.read_mem & APPLE2_MEM_MASK; |
| 183 | | rbase = &apple2_mem_config.auxmem[offset]; |
| 174 | rbase = &state->mem_config.auxmem[offset]; |
| 184 | 175 | } |
| 185 | 176 | else if ((meminfo.read_mem & 0xC0000000) == APPLE2_MEM_SLOT) |
| 186 | 177 | { |
| r10150 | r10151 | |
| 220 | 211 | } |
| 221 | 212 | |
| 222 | 213 | /* did we 'go past the end?' */ |
| 223 | | if (end_r < apple2_mem_config.memmap[i].end) |
| 224 | | memory_nop_read(space, end_r + 1, apple2_mem_config.memmap[i].end, 0, 0); |
| 214 | if (end_r < state->mem_config.memmap[i].end) |
| 215 | memory_nop_read(space, end_r + 1, state->mem_config.memmap[i].end, 0, 0); |
| 225 | 216 | |
| 226 | 217 | /* set the memory bank */ |
| 227 | 218 | if (rbase) |
| r10150 | r10151 | |
| 230 | 221 | } |
| 231 | 222 | |
| 232 | 223 | /* record the current settings */ |
| 233 | | apple2_current_meminfo[i].read_mem = meminfo.read_mem; |
| 234 | | apple2_current_meminfo[i].read_handler = meminfo.read_handler; |
| 224 | state->current_meminfo[i].read_mem = meminfo.read_mem; |
| 225 | state->current_meminfo[i].read_handler = meminfo.read_handler; |
| 235 | 226 | } |
| 236 | 227 | |
| 237 | 228 | /* do we need to memory writing? */ |
| 238 | 229 | if (full_update |
| 239 | | || (meminfo.write_mem != apple2_current_meminfo[i].write_mem) |
| 240 | | || (meminfo.write_handler != apple2_current_meminfo[i].write_handler)) |
| 230 | || (meminfo.write_mem != state->current_meminfo[i].write_mem) |
| 231 | || (meminfo.write_handler != state->current_meminfo[i].write_handler)) |
| 241 | 232 | { |
| 242 | 233 | wbase = NULL; |
| 243 | 234 | if (bank_disposition == A2MEM_MONO) |
| 244 | 235 | sprintf(wbank,"bank%d",bank); |
| 245 | 236 | else if (bank_disposition == A2MEM_DUAL) |
| 246 | 237 | sprintf(wbank,"bank%d",bank+1); |
| 247 | | begin = apple2_mem_config.memmap[i].begin; |
| 248 | | end_w = apple2_mem_config.memmap[i].end; |
| 238 | begin = state->mem_config.memmap[i].begin; |
| 239 | end_w = state->mem_config.memmap[i].end; |
| 249 | 240 | wh = NULL; |
| 250 | 241 | |
| 251 | 242 | LOG(("apple2_update_memory(): Updating WR {%06X..%06X} [#%02d] --> %08X\n", |
| r10150 | r10151 | |
| 260 | 251 | else if ((meminfo.write_mem & 0xC0000000) == APPLE2_MEM_AUX) |
| 261 | 252 | { |
| 262 | 253 | /* auxillary memory */ |
| 263 | | assert(apple2_mem_config.auxmem); |
| 254 | assert(state->mem_config.auxmem); |
| 264 | 255 | offset = meminfo.write_mem & APPLE2_MEM_MASK; |
| 265 | | wbase = &apple2_mem_config.auxmem[offset]; |
| 256 | wbase = &state->mem_config.auxmem[offset]; |
| 266 | 257 | } |
| 267 | 258 | else if ((meminfo.write_mem & 0xC0000000) == APPLE2_MEM_SLOT) |
| 268 | 259 | { |
| r10150 | r10151 | |
| 308 | 299 | } |
| 309 | 300 | |
| 310 | 301 | /* did we 'go past the end?' */ |
| 311 | | if (end_w < apple2_mem_config.memmap[i].end) |
| 312 | | memory_nop_write(space, end_w + 1, apple2_mem_config.memmap[i].end, 0, 0); |
| 302 | if (end_w < state->mem_config.memmap[i].end) |
| 303 | memory_nop_write(space, end_w + 1, state->mem_config.memmap[i].end, 0, 0); |
| 313 | 304 | |
| 314 | 305 | /* set the memory bank */ |
| 315 | 306 | if (wbase) |
| r10150 | r10151 | |
| 318 | 309 | } |
| 319 | 310 | |
| 320 | 311 | /* record the current settings */ |
| 321 | | apple2_current_meminfo[i].write_mem = meminfo.write_mem; |
| 322 | | apple2_current_meminfo[i].write_handler = meminfo.write_handler; |
| 312 | state->current_meminfo[i].write_mem = meminfo.write_mem; |
| 313 | state->current_meminfo[i].write_handler = meminfo.write_handler; |
| 323 | 314 | } |
| 324 | 315 | bank += bank_disposition; |
| 325 | 316 | } |
| r10150 | r10151 | |
| 340 | 331 | |
| 341 | 332 | READ8_HANDLER(apple2_c0xx_r) |
| 342 | 333 | { |
| 334 | apple2_state *state = space->machine->driver_data<apple2_state>(); |
| 343 | 335 | if(!space->debugger_access()) |
| 344 | 336 | { |
| 345 | 337 | static const read8_space_func handlers[] = |
| r10150 | r10151 | |
| 361 | 353 | |
| 362 | 354 | if (offset < 0x80) |
| 363 | 355 | { |
| 364 | | if (a2_cnxx_slot != -1) |
| 356 | if (state->a2_cnxx_slot != -1) |
| 365 | 357 | { |
| 366 | | a2_cnxx_slot = -1; |
| 358 | state->a2_cnxx_slot = -1; |
| 367 | 359 | apple2_update_memory(space->machine); |
| 368 | 360 | } |
| 369 | 361 | |
| r10150 | r10151 | |
| 393 | 385 | |
| 394 | 386 | WRITE8_HANDLER(apple2_c0xx_w) |
| 395 | 387 | { |
| 388 | apple2_state *state = space->machine->driver_data<apple2_state>(); |
| 396 | 389 | static const write8_space_func handlers[] = |
| 397 | 390 | { |
| 398 | 391 | apple2_c00x_w, |
| r10150 | r10151 | |
| 411 | 404 | |
| 412 | 405 | if (offset < 0x80) |
| 413 | 406 | { |
| 414 | | if (a2_cnxx_slot != -1) |
| 407 | if (state->a2_cnxx_slot != -1) |
| 415 | 408 | { |
| 416 | | a2_cnxx_slot = -1; |
| 409 | state->a2_cnxx_slot = -1; |
| 417 | 410 | apple2_update_memory(space->machine); |
| 418 | 411 | } |
| 419 | 412 | |
| r10150 | r10151 | |
| 438 | 431 | /* returns default CnXX slotram for a slot space */ |
| 439 | 432 | INT8 apple2_slotram_r(running_machine *machine, int slotnum, int offset) |
| 440 | 433 | { |
| 434 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 441 | 435 | UINT8 *rom, *slot_ram; |
| 442 | 436 | UINT32 rom_length, slot_length; |
| 443 | 437 | |
| r10150 | r10151 | |
| 449 | 443 | |
| 450 | 444 | if (slot_ram) |
| 451 | 445 | { |
| 452 | | if (a2_cnxx_slot == -1) |
| 446 | if (state->a2_cnxx_slot == -1) |
| 453 | 447 | { |
| 454 | | a2_cnxx_slot = slotnum; |
| 448 | state->a2_cnxx_slot = slotnum; |
| 455 | 449 | apple2_update_memory(machine); |
| 456 | 450 | } |
| 457 | 451 | |
| r10150 | r10151 | |
| 464 | 458 | |
| 465 | 459 | static READ8_HANDLER( apple2_c1xx_r ) |
| 466 | 460 | { |
| 461 | apple2_state *state = space->machine->driver_data<apple2_state>(); |
| 467 | 462 | int slotnum; |
| 468 | 463 | device_t *slotdevice; |
| 469 | 464 | |
| 470 | 465 | slotnum = ((offset>>8) & 0xf) + 1; |
| 471 | 466 | slotdevice = apple2_slot(space->machine, slotnum); |
| 472 | 467 | |
| 473 | | if (a2_cnxx_slot == -1) |
| 468 | if (state->a2_cnxx_slot == -1) |
| 474 | 469 | { |
| 475 | | a2_cnxx_slot = slotnum; |
| 470 | state->a2_cnxx_slot = slotnum; |
| 476 | 471 | apple2_update_memory(space->machine); |
| 477 | 472 | } |
| 478 | 473 | |
| r10150 | r10151 | |
| 519 | 514 | |
| 520 | 515 | static READ8_HANDLER( apple2_c4xx_r ) |
| 521 | 516 | { |
| 517 | apple2_state *state = space->machine->driver_data<apple2_state>(); |
| 522 | 518 | int slotnum; |
| 523 | 519 | device_t *slotdevice; |
| 524 | 520 | |
| 525 | 521 | slotnum = ((offset>>8) & 0xf) + 4; |
| 526 | 522 | slotdevice = apple2_slot(space->machine, slotnum); |
| 527 | 523 | |
| 528 | | if (a2_cnxx_slot == -1) |
| 524 | if (state->a2_cnxx_slot == -1) |
| 529 | 525 | { |
| 530 | | a2_cnxx_slot = slotnum; |
| 526 | state->a2_cnxx_slot = slotnum; |
| 531 | 527 | apple2_update_memory(space->machine); |
| 532 | 528 | } |
| 533 | 529 | |
| r10150 | r10151 | |
| 547 | 543 | |
| 548 | 544 | static WRITE8_HANDLER ( apple2_c4xx_w ) |
| 549 | 545 | { |
| 546 | apple2_state *state = space->machine->driver_data<apple2_state>(); |
| 550 | 547 | int slotnum; |
| 551 | 548 | device_t *slotdevice; |
| 552 | 549 | UINT8 *rom, *slot_ram; |
| r10150 | r10151 | |
| 561 | 558 | slotnum = ((offset>>8) & 0xf) + 4; |
| 562 | 559 | slotdevice = apple2_slot(space->machine, slotnum); |
| 563 | 560 | |
| 564 | | if (a2_cnxx_slot == -1) |
| 561 | if (state->a2_cnxx_slot == -1) |
| 565 | 562 | { |
| 566 | | a2_cnxx_slot = slotnum; |
| 563 | state->a2_cnxx_slot = slotnum; |
| 567 | 564 | apple2_update_memory(space->machine); |
| 568 | 565 | } |
| 569 | 566 | |
| r10150 | r10151 | |
| 580 | 577 | |
| 581 | 578 | static READ8_HANDLER(apple2_cfff_r) |
| 582 | 579 | { |
| 580 | apple2_state *state = space->machine->driver_data<apple2_state>(); |
| 583 | 581 | // debugger guard |
| 584 | 582 | if(!space->debugger_access()) |
| 585 | 583 | { |
| 586 | | a2_cnxx_slot = -1; |
| 584 | state->a2_cnxx_slot = -1; |
| 587 | 585 | apple2_update_memory(space->machine); |
| 588 | 586 | } |
| 589 | 587 | |
| r10150 | r10151 | |
| 592 | 590 | |
| 593 | 591 | static WRITE8_HANDLER(apple2_cfff_w) |
| 594 | 592 | { |
| 595 | | a2_cnxx_slot = -1; |
| 593 | apple2_state *state = space->machine->driver_data<apple2_state>(); |
| 594 | state->a2_cnxx_slot = -1; |
| 596 | 595 | apple2_update_memory(space->machine); |
| 597 | 596 | } |
| 598 | 597 | |
| 599 | 598 | static READ8_HANDLER ( apple2_c800_r ) |
| 600 | 599 | { |
| 600 | apple2_state *state = space->machine->driver_data<apple2_state>(); |
| 601 | 601 | device_t *slotdevice; |
| 602 | 602 | |
| 603 | | slotdevice = apple2_slot(space->machine, a2_cnxx_slot); |
| 603 | slotdevice = apple2_slot(space->machine, state->a2_cnxx_slot); |
| 604 | 604 | |
| 605 | 605 | if (slotdevice != NULL) |
| 606 | 606 | { |
| r10150 | r10151 | |
| 612 | 612 | |
| 613 | 613 | static WRITE8_HANDLER ( apple2_c800_w ) |
| 614 | 614 | { |
| 615 | apple2_state *state = space->machine->driver_data<apple2_state>(); |
| 615 | 616 | device_t *slotdevice; |
| 616 | 617 | |
| 617 | | slotdevice = apple2_slot(space->machine, a2_cnxx_slot); |
| 618 | slotdevice = apple2_slot(space->machine, state->a2_cnxx_slot); |
| 618 | 619 | |
| 619 | 620 | if (slotdevice != NULL) |
| 620 | 621 | { |
| r10150 | r10151 | |
| 624 | 625 | |
| 625 | 626 | static READ8_HANDLER ( apple2_ce00_r ) |
| 626 | 627 | { |
| 628 | apple2_state *state = space->machine->driver_data<apple2_state>(); |
| 627 | 629 | device_t *slotdevice; |
| 628 | 630 | |
| 629 | | slotdevice = apple2_slot(space->machine, a2_cnxx_slot); |
| 631 | slotdevice = apple2_slot(space->machine, state->a2_cnxx_slot); |
| 630 | 632 | |
| 631 | 633 | if (slotdevice != NULL) |
| 632 | 634 | { |
| r10150 | r10151 | |
| 638 | 640 | |
| 639 | 641 | static WRITE8_HANDLER ( apple2_ce00_w ) |
| 640 | 642 | { |
| 641 | | device_t *slotdevice; |
| 643 | apple2_state *state = space->machine->driver_data<apple2_state>(); |
| 644 | device_t *slotdevice; |
| 642 | 645 | |
| 643 | | slotdevice = apple2_slot(space->machine, a2_cnxx_slot); |
| 646 | slotdevice = apple2_slot(space->machine, state->a2_cnxx_slot); |
| 644 | 647 | |
| 645 | 648 | if (slotdevice != NULL) |
| 646 | 649 | { |
| r10150 | r10151 | |
| 650 | 653 | |
| 651 | 654 | static void apple2_mem_0000(running_machine *machine, offs_t begin, offs_t end, apple2_meminfo *meminfo) |
| 652 | 655 | { |
| 653 | | meminfo->read_mem = (apple2_flags & VAR_ALTZP) ? 0x010000 : 0x000000; |
| 654 | | meminfo->write_mem = (apple2_flags & VAR_ALTZP) ? 0x010000 : 0x000000; |
| 656 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 657 | meminfo->read_mem = (state->flags & VAR_ALTZP) ? 0x010000 : 0x000000; |
| 658 | meminfo->write_mem = (state->flags & VAR_ALTZP) ? 0x010000 : 0x000000; |
| 655 | 659 | } |
| 656 | 660 | |
| 657 | 661 | static void apple2_mem_0200(running_machine *machine, offs_t begin, offs_t end, apple2_meminfo *meminfo) |
| 658 | 662 | { |
| 659 | | meminfo->read_mem = (apple2_flags & VAR_RAMRD) ? 0x010200 : 0x000200; |
| 660 | | meminfo->write_mem = (apple2_flags & VAR_RAMWRT) ? 0x010200 : 0x000200; |
| 663 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 664 | meminfo->read_mem = (state->flags & VAR_RAMRD) ? 0x010200 : 0x000200; |
| 665 | meminfo->write_mem = (state->flags & VAR_RAMWRT) ? 0x010200 : 0x000200; |
| 661 | 666 | } |
| 662 | 667 | |
| 663 | 668 | static void apple2_mem_0400(running_machine *machine, offs_t begin, offs_t end, apple2_meminfo *meminfo) |
| 664 | 669 | { |
| 665 | | if (apple2_flags & VAR_80STORE) |
| 670 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 671 | if (state->flags & VAR_80STORE) |
| 666 | 672 | { |
| 667 | | meminfo->read_mem = (apple2_flags & VAR_PAGE2) ? 0x010400 : 0x000400; |
| 668 | | meminfo->write_mem = (apple2_flags & VAR_PAGE2) ? 0x010400 : 0x000400; |
| 669 | | meminfo->write_handler = (apple2_flags & VAR_PAGE2) ? apple2_auxram0400_w : apple2_mainram0400_w; |
| 673 | meminfo->read_mem = (state->flags & VAR_PAGE2) ? 0x010400 : 0x000400; |
| 674 | meminfo->write_mem = (state->flags & VAR_PAGE2) ? 0x010400 : 0x000400; |
| 675 | meminfo->write_handler = (state->flags & VAR_PAGE2) ? apple2_auxram0400_w : apple2_mainram0400_w; |
| 670 | 676 | } |
| 671 | 677 | else |
| 672 | 678 | { |
| 673 | | meminfo->read_mem = (apple2_flags & VAR_RAMRD) ? 0x010400 : 0x000400; |
| 674 | | meminfo->write_mem = (apple2_flags & VAR_RAMWRT) ? 0x010400 : 0x000400; |
| 675 | | meminfo->write_handler = (apple2_flags & VAR_RAMWRT) ? apple2_auxram0400_w : apple2_mainram0400_w; |
| 679 | meminfo->read_mem = (state->flags & VAR_RAMRD) ? 0x010400 : 0x000400; |
| 680 | meminfo->write_mem = (state->flags & VAR_RAMWRT) ? 0x010400 : 0x000400; |
| 681 | meminfo->write_handler = (state->flags & VAR_RAMWRT) ? apple2_auxram0400_w : apple2_mainram0400_w; |
| 676 | 682 | } |
| 677 | 683 | } |
| 678 | 684 | |
| 679 | 685 | static void apple2_mem_0800(running_machine *machine, offs_t begin, offs_t end, apple2_meminfo *meminfo) |
| 680 | 686 | { |
| 681 | | meminfo->read_mem = (apple2_flags & VAR_RAMRD) ? 0x010800 : 0x000800; |
| 682 | | meminfo->write_mem = (apple2_flags & VAR_RAMWRT) ? 0x010800 : 0x000800; |
| 687 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 688 | meminfo->read_mem = (state->flags & VAR_RAMRD) ? 0x010800 : 0x000800; |
| 689 | meminfo->write_mem = (state->flags & VAR_RAMWRT) ? 0x010800 : 0x000800; |
| 683 | 690 | } |
| 684 | 691 | |
| 685 | 692 | static void apple2_mem_2000(running_machine *machine, offs_t begin, offs_t end, apple2_meminfo *meminfo) |
| 686 | 693 | { |
| 687 | | if ((apple2_flags & (VAR_80STORE|VAR_HIRES)) == (VAR_80STORE|VAR_HIRES)) |
| 694 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 695 | if ((state->flags & (VAR_80STORE|VAR_HIRES)) == (VAR_80STORE|VAR_HIRES)) |
| 688 | 696 | { |
| 689 | | meminfo->read_mem = (apple2_flags & VAR_PAGE2) ? 0x012000 : 0x002000; |
| 690 | | meminfo->write_mem = (apple2_flags & VAR_PAGE2) ? 0x012000 : 0x002000; |
| 691 | | meminfo->write_handler = (apple2_flags & VAR_PAGE2) ? apple2_auxram2000_w : apple2_mainram2000_w; |
| 697 | meminfo->read_mem = (state->flags & VAR_PAGE2) ? 0x012000 : 0x002000; |
| 698 | meminfo->write_mem = (state->flags & VAR_PAGE2) ? 0x012000 : 0x002000; |
| 699 | meminfo->write_handler = (state->flags & VAR_PAGE2) ? apple2_auxram2000_w : apple2_mainram2000_w; |
| 692 | 700 | } |
| 693 | 701 | else |
| 694 | 702 | { |
| 695 | | meminfo->read_mem = (apple2_flags & VAR_RAMRD) ? 0x012000 : 0x002000; |
| 696 | | meminfo->write_mem = (apple2_flags & VAR_RAMWRT) ? 0x012000 : 0x002000; |
| 697 | | meminfo->write_handler = (apple2_flags & VAR_RAMWRT) ? apple2_auxram2000_w : apple2_mainram2000_w; |
| 703 | meminfo->read_mem = (state->flags & VAR_RAMRD) ? 0x012000 : 0x002000; |
| 704 | meminfo->write_mem = (state->flags & VAR_RAMWRT) ? 0x012000 : 0x002000; |
| 705 | meminfo->write_handler = (state->flags & VAR_RAMWRT) ? apple2_auxram2000_w : apple2_mainram2000_w; |
| 698 | 706 | } |
| 699 | 707 | } |
| 700 | 708 | |
| 701 | 709 | static void apple2_mem_4000(running_machine *machine, offs_t begin, offs_t end, apple2_meminfo *meminfo) |
| 702 | 710 | { |
| 703 | | meminfo->read_mem = (apple2_flags & VAR_RAMRD) ? 0x014000 : 0x004000; |
| 704 | | meminfo->write_mem = (apple2_flags & VAR_RAMWRT) ? 0x014000 : 0x004000; |
| 711 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 712 | meminfo->read_mem = (state->flags & VAR_RAMRD) ? 0x014000 : 0x004000; |
| 713 | meminfo->write_mem = (state->flags & VAR_RAMWRT) ? 0x014000 : 0x004000; |
| 705 | 714 | } |
| 706 | 715 | |
| 707 | 716 | static void apple2_mem_C000(running_machine *machine, offs_t begin, offs_t end, apple2_meminfo *meminfo) |
| r10150 | r10151 | |
| 718 | 727 | |
| 719 | 728 | static void apple2_mem_Cx00(running_machine *machine, offs_t begin, offs_t end, apple2_meminfo *meminfo) |
| 720 | 729 | { |
| 721 | | if (apple2_flags & VAR_INTCXROM) |
| 730 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 731 | if (state->flags & VAR_INTCXROM) |
| 722 | 732 | { |
| 723 | | meminfo->read_mem = (begin & 0x0FFF) | (apple2_flags & VAR_ROMSWITCH ? 0x4000 : 0x0000) | APPLE2_MEM_ROM; |
| 733 | meminfo->read_mem = (begin & 0x0FFF) | (state->flags & VAR_ROMSWITCH ? 0x4000 : 0x0000) | APPLE2_MEM_ROM; |
| 724 | 734 | meminfo->write_mem = APPLE2_MEM_FLOATING; |
| 725 | 735 | } |
| 726 | 736 | else |
| r10150 | r10151 | |
| 732 | 742 | |
| 733 | 743 | static void apple2_mem_C300(running_machine *machine, offs_t begin, offs_t end, apple2_meminfo *meminfo) |
| 734 | 744 | { |
| 735 | | if ((apple2_flags & (VAR_INTCXROM|VAR_SLOTC3ROM)) != VAR_SLOTC3ROM) |
| 745 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 746 | if ((state->flags & (VAR_INTCXROM|VAR_SLOTC3ROM)) != VAR_SLOTC3ROM) |
| 736 | 747 | { |
| 737 | | meminfo->read_mem = (begin & 0x0FFF) | (apple2_flags & VAR_ROMSWITCH ? 0x4000 : 0x0000) | APPLE2_MEM_ROM; |
| 748 | meminfo->read_mem = (begin & 0x0FFF) | (state->flags & VAR_ROMSWITCH ? 0x4000 : 0x0000) | APPLE2_MEM_ROM; |
| 738 | 749 | meminfo->write_mem = APPLE2_MEM_FLOATING; |
| 739 | 750 | } |
| 740 | 751 | else |
| r10150 | r10151 | |
| 746 | 757 | |
| 747 | 758 | static void apple2_mem_C800(running_machine *machine, offs_t begin, offs_t end, apple2_meminfo *meminfo) |
| 748 | 759 | { |
| 749 | | if (a2_cnxx_slot == -1) |
| 760 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 761 | if (state->a2_cnxx_slot == -1) |
| 750 | 762 | { |
| 751 | | meminfo->read_mem = (begin & 0x0FFF) | (apple2_flags & VAR_ROMSWITCH ? 0x4000 : 0x0000) | APPLE2_MEM_ROM; |
| 763 | meminfo->read_mem = (begin & 0x0FFF) | (state->flags & VAR_ROMSWITCH ? 0x4000 : 0x0000) | APPLE2_MEM_ROM; |
| 752 | 764 | meminfo->write_mem = APPLE2_MEM_FLOATING; |
| 753 | 765 | } |
| 754 | 766 | else |
| r10150 | r10151 | |
| 760 | 772 | |
| 761 | 773 | static void apple2_mem_CE00(running_machine *machine, offs_t begin, offs_t end, apple2_meminfo *meminfo) |
| 762 | 774 | { |
| 763 | | if ((apple2_flags & VAR_ROMSWITCH) && !strcmp(machine->gamedrv->name, "apple2cp")) |
| 775 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 776 | if ((state->flags & VAR_ROMSWITCH) && !strcmp(machine->gamedrv->name, "apple2cp")) |
| 764 | 777 | { |
| 765 | 778 | meminfo->read_mem = APPLE2_MEM_AUX; |
| 766 | 779 | meminfo->write_mem = APPLE2_MEM_AUX; |
| 767 | 780 | } |
| 768 | 781 | else |
| 769 | 782 | { |
| 770 | | if (a2_cnxx_slot == -1) |
| 783 | if (state->a2_cnxx_slot == -1) |
| 771 | 784 | { |
| 772 | | meminfo->read_mem = (begin & 0x0FFF) | (apple2_flags & VAR_ROMSWITCH ? 0x4000 : 0x0000) | APPLE2_MEM_ROM; |
| 785 | meminfo->read_mem = (begin & 0x0FFF) | (state->flags & VAR_ROMSWITCH ? 0x4000 : 0x0000) | APPLE2_MEM_ROM; |
| 773 | 786 | meminfo->write_mem = APPLE2_MEM_FLOATING; |
| 774 | 787 | } |
| 775 | 788 | else |
| r10150 | r10151 | |
| 782 | 795 | |
| 783 | 796 | static void apple2_mem_D000(running_machine *machine, offs_t begin, offs_t end, apple2_meminfo *meminfo) |
| 784 | 797 | { |
| 785 | | if (apple2_flags & VAR_LCRAM) |
| 798 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 799 | if (state->flags & VAR_LCRAM) |
| 786 | 800 | { |
| 787 | | if (apple2_flags & VAR_LCRAM2) |
| 788 | | meminfo->read_mem = (apple2_flags & VAR_ALTZP) ? 0x01C000 : 0x00C000; |
| 801 | if (state->flags & VAR_LCRAM2) |
| 802 | meminfo->read_mem = (state->flags & VAR_ALTZP) ? 0x01C000 : 0x00C000; |
| 789 | 803 | else |
| 790 | | meminfo->read_mem = (apple2_flags & VAR_ALTZP) ? 0x01D000 : 0x00D000; |
| 804 | meminfo->read_mem = (state->flags & VAR_ALTZP) ? 0x01D000 : 0x00D000; |
| 791 | 805 | } |
| 792 | 806 | else |
| 793 | 807 | { |
| 794 | | meminfo->read_mem = (apple2_flags & VAR_ROMSWITCH) ? 0x005000 : 0x001000; |
| 808 | meminfo->read_mem = (state->flags & VAR_ROMSWITCH) ? 0x005000 : 0x001000; |
| 795 | 809 | meminfo->read_mem |= APPLE2_MEM_ROM; |
| 796 | 810 | } |
| 797 | 811 | |
| 798 | | if (apple2_flags & VAR_LCWRITE) |
| 812 | if (state->flags & VAR_LCWRITE) |
| 799 | 813 | { |
| 800 | | if (apple2_flags & VAR_LCRAM2) |
| 801 | | meminfo->write_mem = (apple2_flags & VAR_ALTZP) ? 0x01C000 : 0x00C000; |
| 814 | if (state->flags & VAR_LCRAM2) |
| 815 | meminfo->write_mem = (state->flags & VAR_ALTZP) ? 0x01C000 : 0x00C000; |
| 802 | 816 | else |
| 803 | | meminfo->write_mem = (apple2_flags & VAR_ALTZP) ? 0x01D000 : 0x00D000; |
| 817 | meminfo->write_mem = (state->flags & VAR_ALTZP) ? 0x01D000 : 0x00D000; |
| 804 | 818 | } |
| 805 | 819 | else |
| 806 | 820 | { |
| r10150 | r10151 | |
| 810 | 824 | |
| 811 | 825 | static void apple2_mem_E000(running_machine *machine, offs_t begin, offs_t end, apple2_meminfo *meminfo) |
| 812 | 826 | { |
| 813 | | if (apple2_flags & VAR_LCRAM) |
| 827 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 828 | if (state->flags & VAR_LCRAM) |
| 814 | 829 | { |
| 815 | | meminfo->read_mem = (apple2_flags & VAR_ALTZP) ? 0x01E000 : 0x00E000; |
| 830 | meminfo->read_mem = (state->flags & VAR_ALTZP) ? 0x01E000 : 0x00E000; |
| 816 | 831 | } |
| 817 | 832 | else |
| 818 | 833 | { |
| 819 | | meminfo->read_mem = (apple2_flags & VAR_ROMSWITCH) ? 0x006000 : 0x002000; |
| 834 | meminfo->read_mem = (state->flags & VAR_ROMSWITCH) ? 0x006000 : 0x002000; |
| 820 | 835 | meminfo->read_mem |= APPLE2_MEM_ROM; |
| 821 | 836 | } |
| 822 | 837 | |
| 823 | | if (apple2_flags & VAR_LCWRITE) |
| 838 | if (state->flags & VAR_LCWRITE) |
| 824 | 839 | { |
| 825 | | meminfo->write_mem = (apple2_flags & VAR_ALTZP) ? 0x01E000 : 0x00E000; |
| 840 | meminfo->write_mem = (state->flags & VAR_ALTZP) ? 0x01E000 : 0x00E000; |
| 826 | 841 | } |
| 827 | 842 | else |
| 828 | 843 | { |
| r10150 | r10151 | |
| 856 | 871 | |
| 857 | 872 | void apple2_setvar(running_machine *machine, UINT32 val, UINT32 mask) |
| 858 | 873 | { |
| 874 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 859 | 875 | LOG(("apple2_setvar(): val=0x%06x mask=0x%06x pc=0x%04x\n", val, mask, |
| 860 | 876 | (unsigned int) cpu_get_reg(machine->device("maincpu"), STATE_GENPC))); |
| 861 | 877 | |
| 862 | 878 | assert((val & mask) == val); |
| 863 | 879 | |
| 864 | 880 | /* apply mask and set */ |
| 865 | | val &= a2_mask; |
| 866 | | val |= a2_set; |
| 881 | val &= state->a2_mask; |
| 882 | val |= state->a2_set; |
| 867 | 883 | |
| 868 | 884 | /* change the softswitch */ |
| 869 | | apple2_flags &= ~mask; |
| 870 | | apple2_flags |= val; |
| 885 | state->flags &= ~mask; |
| 886 | state->flags |= val; |
| 871 | 887 | |
| 872 | 888 | apple2_update_memory(machine); |
| 873 | 889 | } |
| r10150 | r10151 | |
| 883 | 899 | |
| 884 | 900 | UINT8 apple2_getfloatingbusvalue(running_machine *machine) |
| 885 | 901 | { |
| 902 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 886 | 903 | enum |
| 887 | 904 | { |
| 888 | 905 | // scanner types |
| r10150 | r10151 | |
| 920 | 937 | |
| 921 | 938 | // machine state switches |
| 922 | 939 | // |
| 923 | | Hires = (apple2_flags & VAR_HIRES) ? 1 : 0; |
| 924 | | Mixed = (apple2_flags & VAR_MIXED) ? 1 : 0; |
| 925 | | Page2 = (apple2_flags & VAR_PAGE2) ? 1 : 0; |
| 926 | | _80Store = (apple2_flags & VAR_80STORE) ? 1 : 0; |
| 940 | Hires = (state->flags & VAR_HIRES) ? 1 : 0; |
| 941 | Mixed = (state->flags & VAR_MIXED) ? 1 : 0; |
| 942 | Page2 = (state->flags & VAR_PAGE2) ? 1 : 0; |
| 943 | _80Store = (state->flags & VAR_80STORE) ? 1 : 0; |
| 927 | 944 | |
| 928 | 945 | // calculate video parameters according to display standard |
| 929 | 946 | // |
| r10150 | r10151 | |
| 1029 | 1046 | |
| 1030 | 1047 | static void apple2_reset(running_machine &machine) |
| 1031 | 1048 | { |
| 1049 | apple2_state *state = machine.driver_data<apple2_state>(); |
| 1032 | 1050 | int need_intcxrom; |
| 1033 | 1051 | |
| 1034 | 1052 | need_intcxrom = !strcmp(machine.gamedrv->name, "apple2c") |
| r10150 | r10151 | |
| 1046 | 1064 | apple2_setvar(&machine, VAR_LCWRITE|VAR_LCRAM2, VAR_LCWRITE | VAR_LCRAM | VAR_LCRAM2); |
| 1047 | 1065 | } |
| 1048 | 1066 | |
| 1049 | | a2_speaker_state = 0; |
| 1067 | state->a2_speaker_state = 0; |
| 1050 | 1068 | |
| 1051 | | joystick_x1_time = joystick_y1_time = 0; |
| 1052 | | joystick_x2_time = joystick_y2_time = 0; |
| 1069 | state->joystick_x1_time = state->joystick_y1_time = 0; |
| 1070 | state->joystick_x2_time = state->joystick_y2_time = 0; |
| 1053 | 1071 | } |
| 1054 | 1072 | |
| 1055 | 1073 | |
| r10150 | r10151 | |
| 1129 | 1147 | { |
| 1130 | 1148 | /* Read the keyboard data and strobe */ |
| 1131 | 1149 | g_profiler.start(PROFILER_C00X); |
| 1132 | | result = AY3600_keydata_strobe_r(); |
| 1150 | result = AY3600_keydata_strobe_r(space->machine); |
| 1133 | 1151 | g_profiler.stop(); |
| 1134 | 1152 | } |
| 1135 | 1153 | |
| r10150 | r10151 | |
| 1174 | 1192 | |
| 1175 | 1193 | READ8_HANDLER ( apple2_c01x_r ) |
| 1176 | 1194 | { |
| 1195 | apple2_state *state = space->machine->driver_data<apple2_state>(); |
| 1177 | 1196 | UINT8 result = apple2_getfloatingbusvalue(space->machine) & 0x7F; |
| 1178 | 1197 | |
| 1179 | 1198 | if(!space->debugger_access()) |
| r10150 | r10151 | |
| 1183 | 1202 | LOG(("a2 softswitch_r: %04x\n", offset + 0xc010)); |
| 1184 | 1203 | switch (offset) |
| 1185 | 1204 | { |
| 1186 | | case 0x00: result |= AY3600_anykey_clearstrobe_r(); break; |
| 1187 | | case 0x01: result |= (apple2_flags & VAR_LCRAM2) ? 0x80 : 0x00; break; |
| 1188 | | case 0x02: result |= (apple2_flags & VAR_LCRAM) ? 0x80 : 0x00; break; |
| 1189 | | case 0x03: result |= (apple2_flags & VAR_RAMRD) ? 0x80 : 0x00; break; |
| 1190 | | case 0x04: result |= (apple2_flags & VAR_RAMWRT) ? 0x80 : 0x00; break; |
| 1191 | | case 0x05: result |= (apple2_flags & VAR_INTCXROM) ? 0x80 : 0x00; break; |
| 1192 | | case 0x06: result |= (apple2_flags & VAR_ALTZP) ? 0x80 : 0x00; break; |
| 1193 | | case 0x07: result |= (apple2_flags & VAR_SLOTC3ROM) ? 0x80 : 0x00; break; |
| 1194 | | case 0x08: result |= (apple2_flags & VAR_80STORE) ? 0x80 : 0x00; break; |
| 1205 | case 0x00: result |= AY3600_anykey_clearstrobe_r(space->machine); break; |
| 1206 | case 0x01: result |= (state->flags & VAR_LCRAM2) ? 0x80 : 0x00; break; |
| 1207 | case 0x02: result |= (state->flags & VAR_LCRAM) ? 0x80 : 0x00; break; |
| 1208 | case 0x03: result |= (state->flags & VAR_RAMRD) ? 0x80 : 0x00; break; |
| 1209 | case 0x04: result |= (state->flags & VAR_RAMWRT) ? 0x80 : 0x00; break; |
| 1210 | case 0x05: result |= (state->flags & VAR_INTCXROM) ? 0x80 : 0x00; break; |
| 1211 | case 0x06: result |= (state->flags & VAR_ALTZP) ? 0x80 : 0x00; break; |
| 1212 | case 0x07: result |= (state->flags & VAR_SLOTC3ROM) ? 0x80 : 0x00; break; |
| 1213 | case 0x08: result |= (state->flags & VAR_80STORE) ? 0x80 : 0x00; break; |
| 1195 | 1214 | case 0x09: result |= !space->machine->primary_screen->vblank() ? 0x80 : 0x00; break; |
| 1196 | | case 0x0A: result |= (apple2_flags & VAR_TEXT) ? 0x80 : 0x00; break; |
| 1197 | | case 0x0B: result |= (apple2_flags & VAR_MIXED) ? 0x80 : 0x00; break; |
| 1198 | | case 0x0C: result |= (apple2_flags & VAR_PAGE2) ? 0x80 : 0x00; break; |
| 1199 | | case 0x0D: result |= (apple2_flags & VAR_HIRES) ? 0x80 : 0x00; break; |
| 1200 | | case 0x0E: result |= (apple2_flags & VAR_ALTCHARSET) ? 0x80 : 0x00; break; |
| 1201 | | case 0x0F: result |= (apple2_flags & VAR_80COL) ? 0x80 : 0x00; break; |
| 1215 | case 0x0A: result |= (state->flags & VAR_TEXT) ? 0x80 : 0x00; break; |
| 1216 | case 0x0B: result |= (state->flags & VAR_MIXED) ? 0x80 : 0x00; break; |
| 1217 | case 0x0C: result |= (state->flags & VAR_PAGE2) ? 0x80 : 0x00; break; |
| 1218 | case 0x0D: result |= (state->flags & VAR_HIRES) ? 0x80 : 0x00; break; |
| 1219 | case 0x0E: result |= (state->flags & VAR_ALTCHARSET) ? 0x80 : 0x00; break; |
| 1220 | case 0x0F: result |= (state->flags & VAR_80COL) ? 0x80 : 0x00; break; |
| 1202 | 1221 | } |
| 1203 | 1222 | |
| 1204 | 1223 | g_profiler.stop(); |
| r10150 | r10151 | |
| 1217 | 1236 | { |
| 1218 | 1237 | /* Clear the keyboard strobe - ignore the returned results */ |
| 1219 | 1238 | g_profiler.start(PROFILER_C01X); |
| 1220 | | AY3600_anykey_clearstrobe_r(); |
| 1239 | AY3600_anykey_clearstrobe_r(space->machine); |
| 1221 | 1240 | g_profiler.stop(); |
| 1222 | 1241 | } |
| 1223 | 1242 | |
| r10150 | r10151 | |
| 1244 | 1263 | |
| 1245 | 1264 | WRITE8_HANDLER( apple2_c02x_w ) |
| 1246 | 1265 | { |
| 1266 | apple2_state *state = space->machine->driver_data<apple2_state>(); |
| 1247 | 1267 | switch(offset) |
| 1248 | 1268 | { |
| 1249 | 1269 | case 0x08: |
| 1250 | | apple2_setvar(space->machine, (apple2_flags & VAR_ROMSWITCH) ^ VAR_ROMSWITCH, VAR_ROMSWITCH); |
| 1270 | apple2_setvar(space->machine, (state->flags & VAR_ROMSWITCH) ^ VAR_ROMSWITCH, VAR_ROMSWITCH); |
| 1251 | 1271 | break; |
| 1252 | 1272 | } |
| 1253 | 1273 | } |
| r10150 | r10151 | |
| 1260 | 1280 | |
| 1261 | 1281 | READ8_HANDLER ( apple2_c03x_r ) |
| 1262 | 1282 | { |
| 1283 | apple2_state *state = space->machine->driver_data<apple2_state>(); |
| 1263 | 1284 | if(!space->debugger_access()) |
| 1264 | 1285 | { |
| 1265 | 1286 | if (!offset) |
| 1266 | 1287 | { |
| 1267 | 1288 | device_t *speaker_device = space->machine->device("a2speaker"); |
| 1268 | 1289 | |
| 1269 | | if (a2_speaker_state == 1) |
| 1290 | if (state->a2_speaker_state == 1) |
| 1270 | 1291 | { |
| 1271 | | a2_speaker_state = 0; |
| 1292 | state->a2_speaker_state = 0; |
| 1272 | 1293 | } |
| 1273 | 1294 | else |
| 1274 | 1295 | { |
| 1275 | | a2_speaker_state = 1; |
| 1296 | state->a2_speaker_state = 1; |
| 1276 | 1297 | } |
| 1277 | | speaker_level_w(speaker_device, a2_speaker_state); |
| 1298 | speaker_level_w(speaker_device, state->a2_speaker_state); |
| 1278 | 1299 | } |
| 1279 | 1300 | } |
| 1280 | 1301 | return apple2_getfloatingbusvalue(space->machine); |
| r10150 | r10151 | |
| 1339 | 1360 | |
| 1340 | 1361 | READ8_HANDLER ( apple2_c06x_r ) |
| 1341 | 1362 | { |
| 1363 | apple2_state *state = space->machine->driver_data<apple2_state>(); |
| 1342 | 1364 | int result = 0; |
| 1343 | 1365 | if(!space->debugger_access()) |
| 1344 | 1366 | { |
| r10150 | r10151 | |
| 1362 | 1384 | break; |
| 1363 | 1385 | case 0x04: |
| 1364 | 1386 | /* X Joystick 1 axis */ |
| 1365 | | result = attotime_to_double(timer_get_time(space->machine)) < joystick_x1_time; |
| 1387 | result = attotime_to_double(timer_get_time(space->machine)) < state->joystick_x1_time; |
| 1366 | 1388 | break; |
| 1367 | 1389 | case 0x05: |
| 1368 | 1390 | /* Y Joystick 1 axis */ |
| 1369 | | result = attotime_to_double(timer_get_time(space->machine)) < joystick_y1_time; |
| 1391 | result = attotime_to_double(timer_get_time(space->machine)) < state->joystick_y1_time; |
| 1370 | 1392 | break; |
| 1371 | 1393 | case 0x06: |
| 1372 | 1394 | /* X Joystick 2 axis */ |
| 1373 | | result = attotime_to_double(timer_get_time(space->machine)) < joystick_x2_time; |
| 1395 | result = attotime_to_double(timer_get_time(space->machine)) < state->joystick_x2_time; |
| 1374 | 1396 | break; |
| 1375 | 1397 | case 0x07: |
| 1376 | 1398 | /* Y Joystick 2 axis */ |
| 1377 | | result = attotime_to_double(timer_get_time(space->machine)) < joystick_y2_time; |
| 1399 | result = attotime_to_double(timer_get_time(space->machine)) < state->joystick_y2_time; |
| 1378 | 1400 | break; |
| 1379 | 1401 | default: |
| 1380 | 1402 | /* c060 Empty Cassette head read |
| r10150 | r10151 | |
| 1394 | 1416 | |
| 1395 | 1417 | READ8_HANDLER ( apple2_c07x_r ) |
| 1396 | 1418 | { |
| 1419 | apple2_state *state = space->machine->driver_data<apple2_state>(); |
| 1397 | 1420 | if(!space->debugger_access()) |
| 1398 | 1421 | { |
| 1399 | 1422 | double x_calibration = attotime_to_double(ATTOTIME_IN_USEC(12)); |
| r10150 | r10151 | |
| 1401 | 1424 | |
| 1402 | 1425 | if (offset == 0) |
| 1403 | 1426 | { |
| 1404 | | joystick_x1_time = attotime_to_double(timer_get_time(space->machine)) + x_calibration * input_port_read(space->machine, "joystick_1_x"); |
| 1405 | | joystick_y1_time = attotime_to_double(timer_get_time(space->machine)) + y_calibration * input_port_read(space->machine, "joystick_1_y"); |
| 1406 | | joystick_x2_time = attotime_to_double(timer_get_time(space->machine)) + x_calibration * input_port_read(space->machine, "joystick_2_x"); |
| 1407 | | joystick_y2_time = attotime_to_double(timer_get_time(space->machine)) + y_calibration * input_port_read(space->machine, "joystick_2_y"); |
| 1427 | state->joystick_x1_time = attotime_to_double(timer_get_time(space->machine)) + x_calibration * input_port_read(space->machine, "joystick_1_x"); |
| 1428 | state->joystick_y1_time = attotime_to_double(timer_get_time(space->machine)) + y_calibration * input_port_read(space->machine, "joystick_1_y"); |
| 1429 | state->joystick_x2_time = attotime_to_double(timer_get_time(space->machine)) + x_calibration * input_port_read(space->machine, "joystick_2_x"); |
| 1430 | state->joystick_y2_time = attotime_to_double(timer_get_time(space->machine)) + y_calibration * input_port_read(space->machine, "joystick_2_y"); |
| 1408 | 1431 | } |
| 1409 | 1432 | } |
| 1410 | 1433 | return 0; |
| r10150 | r10151 | |
| 1427 | 1450 | * Floppy disk controller |
| 1428 | 1451 | * ----------------------------------------------------------------------- */ |
| 1429 | 1452 | |
| 1430 | | static int apple2_fdc_diskreg; |
| 1431 | 1453 | |
| 1432 | 1454 | static int apple2_fdc_has_35(running_machine *machine) |
| 1433 | 1455 | { |
| r10150 | r10151 | |
| 1441 | 1463 | |
| 1442 | 1464 | static void apple2_fdc_set_lines(device_t *device, UINT8 lines) |
| 1443 | 1465 | { |
| 1444 | | if (apple2_fdc_diskreg & 0x40) |
| 1466 | apple2_state *state = device->machine->driver_data<apple2_state>(); |
| 1467 | if (state->fdc_diskreg & 0x40) |
| 1445 | 1468 | { |
| 1446 | 1469 | if (apple2_fdc_has_35(device->machine)) |
| 1447 | 1470 | { |
| r10150 | r10151 | |
| 1463 | 1486 | |
| 1464 | 1487 | static void apple2_fdc_set_enable_lines(device_t *device,int enable_mask) |
| 1465 | 1488 | { |
| 1489 | apple2_state *state = device->machine->driver_data<apple2_state>(); |
| 1466 | 1490 | int slot5_enable_mask = 0; |
| 1467 | 1491 | int slot6_enable_mask = 0; |
| 1468 | 1492 | |
| 1469 | | if (apple2_fdc_diskreg & 0x40) |
| 1493 | if (state->fdc_diskreg & 0x40) |
| 1470 | 1494 | slot5_enable_mask = enable_mask; |
| 1471 | 1495 | else |
| 1472 | 1496 | slot6_enable_mask = enable_mask; |
| r10150 | r10151 | |
| 1488 | 1512 | |
| 1489 | 1513 | static UINT8 apple2_fdc_read_data(device_t *device) |
| 1490 | 1514 | { |
| 1515 | apple2_state *state = device->machine->driver_data<apple2_state>(); |
| 1491 | 1516 | UINT8 result = 0x00; |
| 1492 | 1517 | |
| 1493 | | if (apple2_fdc_diskreg & 0x40) |
| 1518 | if (state->fdc_diskreg & 0x40) |
| 1494 | 1519 | { |
| 1495 | 1520 | if (apple2_fdc_has_35(device->machine)) |
| 1496 | 1521 | { |
| r10150 | r10151 | |
| 1513 | 1538 | |
| 1514 | 1539 | static void apple2_fdc_write_data(device_t *device, UINT8 data) |
| 1515 | 1540 | { |
| 1516 | | if (apple2_fdc_diskreg & 0x40) |
| 1541 | apple2_state *state = device->machine->driver_data<apple2_state>(); |
| 1542 | if (state->fdc_diskreg & 0x40) |
| 1517 | 1543 | { |
| 1518 | 1544 | if (apple2_fdc_has_35(device->machine)) |
| 1519 | 1545 | { |
| r10150 | r10151 | |
| 1535 | 1561 | |
| 1536 | 1562 | static int apple2_fdc_read_status(device_t *device) |
| 1537 | 1563 | { |
| 1564 | apple2_state *state = device->machine->driver_data<apple2_state>(); |
| 1538 | 1565 | int result = 0; |
| 1539 | 1566 | |
| 1540 | | if (apple2_fdc_diskreg & 0x40) |
| 1567 | if (state->fdc_diskreg & 0x40) |
| 1541 | 1568 | { |
| 1542 | 1569 | if (apple2_fdc_has_35(device->machine)) |
| 1543 | 1570 | { |
| r10150 | r10151 | |
| 1560 | 1587 | |
| 1561 | 1588 | void apple2_iwm_setdiskreg(running_machine *machine, UINT8 data) |
| 1562 | 1589 | { |
| 1563 | | apple2_fdc_diskreg = data & 0xC0; |
| 1590 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 1591 | state->fdc_diskreg = data & 0xC0; |
| 1564 | 1592 | if (apple2_fdc_has_35(machine)) |
| 1565 | | sony_set_sel_line( machine->device("fdc"),apple2_fdc_diskreg & 0x80); |
| 1593 | sony_set_sel_line( machine->device("fdc"),state->fdc_diskreg & 0x80); |
| 1566 | 1594 | } |
| 1567 | 1595 | |
| 1568 | 1596 | |
| 1569 | 1597 | |
| 1570 | | UINT8 apple2_iwm_getdiskreg(void) |
| 1598 | UINT8 apple2_iwm_getdiskreg(running_machine *machine) |
| 1571 | 1599 | { |
| 1572 | | return apple2_fdc_diskreg; |
| 1600 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 1601 | return state->fdc_diskreg; |
| 1573 | 1602 | } |
| 1574 | 1603 | |
| 1575 | 1604 | |
| r10150 | r10151 | |
| 1593 | 1622 | |
| 1594 | 1623 | void apple2_init_common(running_machine *machine) |
| 1595 | 1624 | { |
| 1596 | | apple2_flags = 0; |
| 1597 | | apple2_fdc_diskreg = 0; |
| 1625 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 1626 | state->flags = 0; |
| 1627 | state->fdc_diskreg = 0; |
| 1598 | 1628 | |
| 1599 | 1629 | AY3600_init(machine); |
| 1600 | 1630 | machine->add_notifier(MACHINE_NOTIFY_RESET, apple2_reset); |
| 1601 | 1631 | |
| 1602 | 1632 | /* state save registers */ |
| 1603 | | state_save_register_global(machine, apple2_flags); |
| 1633 | state_save_register_global(machine, state->flags); |
| 1604 | 1634 | state_save_register_postload(machine, apple2_update_memory_postload, NULL); |
| 1605 | 1635 | |
| 1606 | 1636 | /* --------------------------------------------- * |
| 1607 | 1637 | * set up the softswitch mask/set * |
| 1608 | 1638 | * --------------------------------------------- */ |
| 1609 | | a2_mask = ~0; |
| 1610 | | a2_set = 0; |
| 1639 | state->a2_mask = ~0; |
| 1640 | state->a2_set = 0; |
| 1611 | 1641 | |
| 1612 | 1642 | /* disable VAR_ROMSWITCH if the ROM is only 16k */ |
| 1613 | 1643 | if (machine->region("maincpu")->bytes() < 0x8000) |
| 1614 | | a2_mask &= ~VAR_ROMSWITCH; |
| 1644 | state->a2_mask &= ~VAR_ROMSWITCH; |
| 1615 | 1645 | |
| 1616 | 1646 | if (ram_get_size(machine->device(RAM_TAG)) <= 64*1024) |
| 1617 | | a2_mask &= ~(VAR_RAMRD | VAR_RAMWRT | VAR_80STORE | VAR_ALTZP | VAR_80COL); |
| 1647 | state->a2_mask &= ~(VAR_RAMRD | VAR_RAMWRT | VAR_80STORE | VAR_ALTZP | VAR_80COL); |
| 1618 | 1648 | } |
| 1619 | 1649 | |
| 1620 | 1650 | |
src/mess/video/apple2.c
| r10150 | r10151 | |
| 11 | 11 | |
| 12 | 12 | /***************************************************************************/ |
| 13 | 13 | |
| 14 | | static const UINT8 *a2_videoram; |
| 15 | | static UINT32 a2_videomask; |
| 16 | | static UINT32 old_a2; |
| 17 | | static int fgcolor, bgcolor, flash; |
| 18 | | static int alt_charset_value; |
| 19 | | static UINT16 *hires_artifact_map; |
| 20 | | static UINT16 *dhires_artifact_map; |
| 21 | 14 | |
| 22 | 15 | #define BLACK 0 |
| 23 | 16 | #define DKRED 1 |
| r10150 | r10151 | |
| 48 | 41 | register |
| 49 | 42 | -------------------------------------------------*/ |
| 50 | 43 | |
| 51 | | INLINE UINT32 effective_a2(void) |
| 44 | INLINE UINT32 effective_a2(apple2_state *state) |
| 52 | 45 | { |
| 53 | | return apple2_flags & a2_videomask; |
| 46 | return state->flags & state->a2_videomask; |
| 54 | 47 | } |
| 55 | 48 | |
| 56 | 49 | |
| r10150 | r10151 | |
| 96 | 89 | textual character |
| 97 | 90 | -------------------------------------------------*/ |
| 98 | 91 | |
| 99 | | INLINE void apple2_plot_text_character(bitmap_t *bitmap, int xpos, int ypos, int xscale, UINT32 code, |
| 92 | INLINE void apple2_plot_text_character(running_machine *machine, bitmap_t *bitmap, int xpos, int ypos, int xscale, UINT32 code, |
| 100 | 93 | const UINT8 *textgfx_data, UINT32 textgfx_datalen, UINT32 my_a2) |
| 101 | 94 | { |
| 95 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 102 | 96 | int x, y, i; |
| 103 | | int fg = fgcolor; |
| 104 | | int bg = bgcolor; |
| 97 | int fg = state->fgcolor; |
| 98 | int bg = state->bgcolor; |
| 105 | 99 | const UINT8 *chardata; |
| 106 | 100 | UINT16 color; |
| 107 | 101 | |
| 108 | 102 | if (my_a2 & VAR_ALTCHARSET) |
| 109 | 103 | { |
| 110 | 104 | /* we're using an alternate charset */ |
| 111 | | code |= alt_charset_value; |
| 105 | code |= state->alt_charset_value; |
| 112 | 106 | } |
| 113 | | else if (flash && (code >= 0x40) && (code <= 0x7f)) |
| 107 | else if (state->flash && (code >= 0x40) && (code <= 0x7f)) |
| 114 | 108 | { |
| 115 | 109 | /* we're flashing; swap */ |
| 116 | 110 | i = fg; |
| r10150 | r10151 | |
| 145 | 139 | |
| 146 | 140 | static void apple2_text_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int page, int beginrow, int endrow) |
| 147 | 141 | { |
| 142 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 148 | 143 | int row, col; |
| 149 | 144 | UINT32 start_address = (page ? 0x0800 : 0x0400); |
| 150 | 145 | UINT32 address; |
| 151 | 146 | const UINT8 *textgfx_data = machine->region("gfx1")->base(); |
| 152 | 147 | UINT32 textgfx_datalen = machine->region("gfx1")->bytes(); |
| 153 | | UINT32 my_a2 = effective_a2(); |
| 148 | UINT32 my_a2 = effective_a2(state); |
| 154 | 149 | |
| 155 | 150 | /* perform adjustments */ |
| 156 | 151 | adjust_begin_and_end_row(cliprect, &beginrow, &endrow); |
| r10150 | r10151 | |
| 164 | 159 | |
| 165 | 160 | if (my_a2 & VAR_80COL) |
| 166 | 161 | { |
| 167 | | apple2_plot_text_character(bitmap, col * 14 + 0, row, 1, a2_videoram[address + 0x10000], |
| 162 | apple2_plot_text_character(machine, bitmap, col * 14 + 0, row, 1, state->a2_videoram[address + 0x10000], |
| 168 | 163 | textgfx_data, textgfx_datalen, my_a2); |
| 169 | | apple2_plot_text_character(bitmap, col * 14 + 7, row, 1, a2_videoram[address + 0x00000], |
| 164 | apple2_plot_text_character(machine, bitmap, col * 14 + 7, row, 1, state->a2_videoram[address + 0x00000], |
| 170 | 165 | textgfx_data, textgfx_datalen, my_a2); |
| 171 | 166 | } |
| 172 | 167 | else |
| 173 | 168 | { |
| 174 | | apple2_plot_text_character(bitmap, col * 14, row, 2, a2_videoram[address], |
| 169 | apple2_plot_text_character(machine, bitmap, col * 14, row, 2, state->a2_videoram[address], |
| 175 | 170 | textgfx_data, textgfx_datalen, my_a2); |
| 176 | 171 | } |
| 177 | 172 | } |
| r10150 | r10151 | |
| 185 | 180 | |
| 186 | 181 | static void apple2_lores_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int page, int beginrow, int endrow) |
| 187 | 182 | { |
| 183 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 188 | 184 | int row, col, y, x; |
| 189 | 185 | UINT8 code; |
| 190 | 186 | UINT32 start_address = (page ? 0x0800 : 0x0400); |
| r10150 | r10151 | |
| 201 | 197 | address = start_address + compute_video_address(col, row / 8); |
| 202 | 198 | |
| 203 | 199 | /* perform the lookup */ |
| 204 | | code = a2_videoram[address]; |
| 200 | code = state->a2_videoram[address]; |
| 205 | 201 | |
| 206 | 202 | /* and now draw */ |
| 207 | 203 | for (y = 0; y < 4; y++) |
| r10150 | r10151 | |
| 219 | 215 | } |
| 220 | 216 | |
| 221 | 217 | |
| 222 | | /*------------------------------------------------- |
| 223 | | apple2_set_fgcolor |
| 224 | | -------------------------------------------------*/ |
| 225 | | |
| 226 | | void apple2_set_fgcolor(int color) |
| 227 | | { |
| 228 | | fgcolor = color; |
| 229 | | } |
| 230 | | |
| 231 | | |
| 232 | | /*------------------------------------------------- |
| 233 | | apple2_set_bgcolor |
| 234 | | -------------------------------------------------*/ |
| 235 | | |
| 236 | | void apple2_set_bgcolor(int color) |
| 237 | | { |
| 238 | | bgcolor = color; |
| 239 | | } |
| 240 | | |
| 241 | | |
| 242 | | /*------------------------------------------------- |
| 243 | | apple2_get_fgcolor |
| 244 | | -------------------------------------------------*/ |
| 245 | | |
| 246 | | int apple2_get_fgcolor(void) |
| 247 | | { |
| 248 | | return fgcolor; |
| 249 | | } |
| 250 | | |
| 251 | | |
| 252 | | /*------------------------------------------------- |
| 253 | | apple2_get_bgcolor |
| 254 | | -------------------------------------------------*/ |
| 255 | | |
| 256 | | int apple2_get_bgcolor(void) |
| 257 | | { |
| 258 | | return bgcolor; |
| 259 | | } |
| 260 | | |
| 261 | | |
| 262 | | |
| 263 | 218 | /*************************************************************************** |
| 264 | 219 | HIGH RESOLUTION GRAPHICS |
| 265 | 220 | ***************************************************************************/ |
| 266 | 221 | |
| 267 | 222 | static void apple2_hires_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int page, int beginrow, int endrow) |
| 268 | 223 | { |
| 224 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 269 | 225 | const UINT8 *vram; |
| 270 | 226 | int row, col, b; |
| 271 | 227 | int offset; |
| r10150 | r10151 | |
| 284 | 240 | if (endrow < beginrow) |
| 285 | 241 | return; |
| 286 | 242 | |
| 287 | | vram = a2_videoram + (page ? 0x4000 : 0x2000); |
| 288 | | columns = ((effective_a2() & (VAR_DHIRES|VAR_80COL)) == (VAR_DHIRES|VAR_80COL)) ? 80 : 40; |
| 243 | vram = state->a2_videoram + (page ? 0x4000 : 0x2000); |
| 244 | columns = ((effective_a2(state) & (VAR_DHIRES|VAR_80COL)) == (VAR_DHIRES|VAR_80COL)) ? 80 : 40; |
| 289 | 245 | |
| 290 | 246 | vram_row[0] = 0; |
| 291 | 247 | vram_row[columns + 1] = 0; |
| r10150 | r10151 | |
| 324 | 280 | switch(columns) |
| 325 | 281 | { |
| 326 | 282 | case 40: |
| 327 | | artifact_map_ptr = &hires_artifact_map[((vram_row[col+1] & 0x80) >> 7) * 16]; |
| 283 | artifact_map_ptr = &state->hires_artifact_map[((vram_row[col+1] & 0x80) >> 7) * 16]; |
| 328 | 284 | for (b = 0; b < 7; b++) |
| 329 | 285 | { |
| 330 | 286 | v = artifact_map_ptr[((w >> (b + 7-1)) & 0x07) | (((b ^ col) & 0x01) << 3)]; |
| r10150 | r10151 | |
| 336 | 292 | case 80: |
| 337 | 293 | for (b = 0; b < 7; b++) |
| 338 | 294 | { |
| 339 | | v = dhires_artifact_map[((((w >> (b + 7-1)) & 0x0F) * 0x11) >> (((2-(col*7+b))) & 0x03)) & 0x0F]; |
| 295 | v = state->dhires_artifact_map[((((w >> (b + 7-1)) & 0x0F) * 0x11) >> (((2-(col*7+b))) & 0x03)) & 0x0F]; |
| 340 | 296 | *(p++) = v; |
| 341 | 297 | } |
| 342 | 298 | break; |
| r10150 | r10151 | |
| 357 | 313 | |
| 358 | 314 | void apple2_video_start(running_machine *machine, const UINT8 *vram, size_t vram_size, UINT32 ignored_softswitches, int hires_modulo) |
| 359 | 315 | { |
| 316 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 360 | 317 | int i, j; |
| 361 | 318 | UINT16 c; |
| 362 | 319 | UINT8 *apple2_font; |
| r10150 | r10151 | |
| 375 | 332 | PURPLE, LTBLUE, PINK, WHITE |
| 376 | 333 | }; |
| 377 | 334 | |
| 378 | | fgcolor = 15; |
| 379 | | bgcolor = 0; |
| 380 | | flash = 0; |
| 335 | state->fgcolor = 15; |
| 336 | state->bgcolor = 0; |
| 337 | state->flash = 0; |
| 381 | 338 | apple2_font = machine->region("gfx1")->base(); |
| 382 | | alt_charset_value = machine->region("gfx1")->bytes() / 16; |
| 383 | | a2_videoram = vram; |
| 339 | state->alt_charset_value = machine->region("gfx1")->bytes() / 16; |
| 340 | state->a2_videoram = vram; |
| 384 | 341 | |
| 385 | 342 | /* 2^3 dependent pixels * 2 color sets * 2 offsets */ |
| 386 | | hires_artifact_map = auto_alloc_array(machine, UINT16, 8 * 2 * 2); |
| 343 | state->hires_artifact_map = auto_alloc_array(machine, UINT16, 8 * 2 * 2); |
| 387 | 344 | |
| 388 | 345 | /* 2^4 dependent pixels */ |
| 389 | | dhires_artifact_map = auto_alloc_array(machine, UINT16, 16); |
| 346 | state->dhires_artifact_map = auto_alloc_array(machine, UINT16, 16); |
| 390 | 347 | |
| 391 | 348 | /* build hires artifact map */ |
| 392 | 349 | for (i = 0; i < 8; i++) |
| r10150 | r10151 | |
| 407 | 364 | else |
| 408 | 365 | c = 0; |
| 409 | 366 | } |
| 410 | | hires_artifact_map[ 0 + j*8 + i] = hires_artifact_color_table[(c + 0) % hires_modulo]; |
| 411 | | hires_artifact_map[16 + j*8 + i] = hires_artifact_color_table[(c + 4) % hires_modulo]; |
| 367 | state->hires_artifact_map[ 0 + j*8 + i] = hires_artifact_color_table[(c + 0) % hires_modulo]; |
| 368 | state->hires_artifact_map[16 + j*8 + i] = hires_artifact_color_table[(c + 4) % hires_modulo]; |
| 412 | 369 | } |
| 413 | 370 | } |
| 414 | 371 | |
| r10150 | r10151 | |
| 440 | 397 | /* build double hires artifact map */ |
| 441 | 398 | for (i = 0; i < 16; i++) |
| 442 | 399 | { |
| 443 | | dhires_artifact_map[i] = dhires_artifact_color_table[i]; |
| 400 | state->dhires_artifact_map[i] = dhires_artifact_color_table[i]; |
| 444 | 401 | } |
| 445 | 402 | |
| 446 | | memset(&old_a2, 0, sizeof(old_a2)); |
| 447 | | a2_videomask = ~ignored_softswitches; |
| 403 | memset(&state->old_a2, 0, sizeof(state->old_a2)); |
| 404 | state->a2_videomask = ~ignored_softswitches; |
| 448 | 405 | } |
| 449 | 406 | |
| 450 | 407 | |
| 451 | 408 | |
| 452 | 409 | VIDEO_START( apple2 ) |
| 453 | 410 | { |
| 411 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 454 | 412 | apple2_video_start(machine, ram_get_ptr(machine->device(RAM_TAG)), ram_get_size(machine->device(RAM_TAG)), VAR_80COL | VAR_ALTCHARSET | VAR_DHIRES, 4); |
| 455 | 413 | |
| 456 | 414 | /* hack to fix the colors on apple2/apple2p */ |
| 457 | | fgcolor = 0; |
| 458 | | bgcolor = 15; |
| 415 | state->fgcolor = 0; |
| 416 | state->bgcolor = 15; |
| 459 | 417 | } |
| 460 | 418 | |
| 461 | 419 | |
| 462 | 420 | VIDEO_START( apple2p ) |
| 463 | 421 | { |
| 422 | apple2_state *state = machine->driver_data<apple2_state>(); |
| 464 | 423 | apple2_video_start(machine, ram_get_ptr(machine->device(RAM_TAG)), ram_get_size(machine->device(RAM_TAG)), VAR_80COL | VAR_ALTCHARSET | VAR_DHIRES, 8); |
| 465 | 424 | |
| 466 | 425 | /* hack to fix the colors on apple2/apple2p */ |
| 467 | | fgcolor = 0; |
| 468 | | bgcolor = 15; |
| 426 | state->fgcolor = 0; |
| 427 | state->bgcolor = 15; |
| 469 | 428 | } |
| 470 | 429 | |
| 471 | 430 | |
| r10150 | r10151 | |
| 477 | 436 | |
| 478 | 437 | VIDEO_UPDATE( apple2 ) |
| 479 | 438 | { |
| 439 | apple2_state *state = screen->machine->driver_data<apple2_state>(); |
| 480 | 440 | int page; |
| 481 | 441 | UINT32 new_a2; |
| 482 | 442 | running_machine *machine = screen->machine; |
| 483 | 443 | |
| 484 | | /* calculate the flash value */ |
| 485 | | flash = (attotime_mul(timer_get_time(screen->machine), 4).seconds & 1) ? 1 : 0; |
| 444 | /* calculate the state->flash value */ |
| 445 | state->flash = (attotime_mul(timer_get_time(screen->machine), 4).seconds & 1) ? 1 : 0; |
| 486 | 446 | |
| 487 | 447 | /* read out relevant softswitch variables; to see what has changed */ |
| 488 | | new_a2 = effective_a2(); |
| 448 | new_a2 = effective_a2(state); |
| 489 | 449 | if (new_a2 & VAR_80STORE) |
| 490 | 450 | new_a2 &= ~VAR_PAGE2; |
| 491 | 451 | new_a2 &= VAR_TEXT | VAR_MIXED | VAR_HIRES | VAR_DHIRES | VAR_80COL | VAR_PAGE2 | VAR_ALTCHARSET; |
| 492 | 452 | |
| 493 | | if (ALWAYS_REFRESH || (new_a2 != old_a2)) |
| 453 | if (ALWAYS_REFRESH || (new_a2 != state->old_a2)) |
| 494 | 454 | { |
| 495 | | old_a2 = new_a2; |
| 455 | state->old_a2 = new_a2; |
| 496 | 456 | } |
| 497 | 457 | |
| 498 | 458 | /* choose which page to use */ |
| 499 | 459 | page = (new_a2 & VAR_PAGE2) ? 1 : 0; |
| 500 | 460 | |
| 501 | 461 | /* choose the video mode to draw */ |
| 502 | | if (effective_a2() & VAR_TEXT) |
| 462 | if (effective_a2(state) & VAR_TEXT) |
| 503 | 463 | { |
| 504 | 464 | /* text screen */ |
| 505 | 465 | apple2_text_draw(machine, bitmap, cliprect, page, 0, 191); |
| 506 | 466 | } |
| 507 | | else if ((effective_a2() & VAR_HIRES) && (effective_a2() & VAR_MIXED)) |
| 467 | else if ((effective_a2(state) & VAR_HIRES) && (effective_a2(state) & VAR_MIXED)) |
| 508 | 468 | { |
| 509 | 469 | /* hi-res on top; text at bottom */ |
| 510 | 470 | apple2_hires_draw(machine, bitmap, cliprect, page, 0, 159); |
| 511 | 471 | apple2_text_draw(machine, bitmap, cliprect, page, 160, 191); |
| 512 | 472 | } |
| 513 | | else if (effective_a2() & VAR_HIRES) |
| 473 | else if (effective_a2(state) & VAR_HIRES) |
| 514 | 474 | { |
| 515 | 475 | /* hi-res screen */ |
| 516 | 476 | apple2_hires_draw(machine, bitmap, cliprect, page, 0, 191); |
| 517 | 477 | } |
| 518 | | else if (effective_a2() & VAR_MIXED) |
| 478 | else if (effective_a2(state) & VAR_MIXED) |
| 519 | 479 | { |
| 520 | 480 | /* lo-res on top; text at bottom */ |
| 521 | 481 | apple2_lores_draw(machine, bitmap, cliprect, page, 0, 159); |
src/mess/drivers/mephisto.c
| r10150 | r10151 | |
| 61 | 61 | |
| 62 | 62 | #include "machine/mboard.h" |
| 63 | 63 | |
| 64 | | static UINT8 lcd_shift_counter; |
| 65 | | static UINT8 led_status; |
| 66 | | static UINT8 *mephisto_ram; |
| 67 | | static UINT8 led7; |
| 68 | 64 | |
| 65 | class mephisto_state : public driver_device |
| 66 | { |
| 67 | public: |
| 68 | mephisto_state(running_machine &machine, const driver_device_config_base &config) |
| 69 | : driver_device(machine, config) { } |
| 70 | |
| 71 | UINT8 lcd_shift_counter; |
| 72 | UINT8 led_status; |
| 73 | UINT8 *ram; |
| 74 | UINT8 led7; |
| 75 | }; |
| 76 | |
| 77 | |
| 78 | |
| 69 | 79 | static WRITE8_HANDLER ( write_lcd ) |
| 70 | 80 | { |
| 71 | | if (led7==0)output_set_digit_value(lcd_shift_counter,data); // 0x109 MM IV // 0x040 MM V |
| 81 | mephisto_state *state = space->machine->driver_data<mephisto_state>(); |
| 82 | if (state->led7==0)output_set_digit_value(state->lcd_shift_counter,data); // 0x109 MM IV // 0x040 MM V |
| 72 | 83 | |
| 73 | | //output_set_digit_value(lcd_shift_counter,data ^ mephisto_ram[0x165]); // 0x109 MM IV // 0x040 MM V |
| 74 | | lcd_shift_counter--; |
| 75 | | lcd_shift_counter&=3; |
| 84 | //output_set_digit_value(state->lcd_shift_counter,data ^ state->ram[0x165]); // 0x109 MM IV // 0x040 MM V |
| 85 | state->lcd_shift_counter--; |
| 86 | state->lcd_shift_counter&=3; |
| 76 | 87 | } |
| 77 | 88 | |
| 78 | 89 | static READ8_HANDLER(read_keys) |
| 79 | 90 | { |
| 91 | mephisto_state *state = space->machine->driver_data<mephisto_state>(); |
| 80 | 92 | UINT8 data; |
| 81 | 93 | static const char *const keynames[2][8] = |
| 82 | 94 | { |
| r10150 | r10151 | |
| 85 | 97 | }; |
| 86 | 98 | |
| 87 | 99 | data = 0xff; |
| 88 | | if (((led_status & 0x80) == 0x00)) |
| 100 | if (((state->led_status & 0x80) == 0x00)) |
| 89 | 101 | data=input_port_read(space->machine, keynames[0][offset]); |
| 90 | 102 | else |
| 91 | 103 | data=input_port_read(space->machine, keynames[1][offset]); |
| 92 | 104 | |
| 93 | | logerror("Keyboard Port = %s Data = %d\n ", ((led_status & 0x80) == 0x00) ? keynames[0][offset] : keynames[1][offset], data); |
| 105 | logerror("Keyboard Port = %s Data = %d\n ", ((state->led_status & 0x80) == 0x00) ? keynames[0][offset] : keynames[1][offset], data); |
| 94 | 106 | return data | 0x7f; |
| 95 | 107 | } |
| 96 | 108 | |
| 97 | 109 | static WRITE8_HANDLER ( write_led ) |
| 98 | 110 | { |
| 111 | mephisto_state *state = space->machine->driver_data<mephisto_state>(); |
| 99 | 112 | UINT8 LED_offset=100; |
| 100 | 113 | data &= 0x80; |
| 101 | 114 | |
| 102 | | if (data==0)led_status &= 255-(1<<offset) ; else led_status|=1<<offset; |
| 103 | | if (offset<6)output_set_led_value(LED_offset+offset, led_status&1<<offset?1:0); |
| 104 | | if (offset==7) led7=data& 0x80 ? 0x00 :0xff; |
| 115 | if (data==0)state->led_status &= 255-(1<<offset) ; else state->led_status|=1<<offset; |
| 116 | if (offset<6)output_set_led_value(LED_offset+offset, state->led_status&1<<offset?1:0); |
| 117 | if (offset==7) state->led7=data& 0x80 ? 0x00 :0xff; |
| 105 | 118 | logerror("LEDs Offset = %d Data = %d\n",offset,data); |
| 106 | 119 | } |
| 107 | 120 | |
| 108 | 121 | static WRITE8_HANDLER ( write_led_mm2 ) |
| 109 | 122 | { |
| 123 | mephisto_state *state = space->machine->driver_data<mephisto_state>(); |
| 110 | 124 | |
| 111 | 125 | UINT8 LED_offset=100; |
| 112 | 126 | data &= 0x80; |
| 113 | 127 | |
| 114 | 128 | if (data==0) |
| 115 | | led_status &= 255-(1<<offset); |
| 129 | state->led_status &= 255-(1<<offset); |
| 116 | 130 | else |
| 117 | | led_status|=1<<offset; |
| 131 | state->led_status|=1<<offset; |
| 118 | 132 | |
| 119 | 133 | if (offset<6) |
| 120 | | output_set_led_value(LED_offset+offset, led_status&1<<offset?1:0); |
| 134 | output_set_led_value(LED_offset+offset, state->led_status&1<<offset?1:0); |
| 121 | 135 | |
| 122 | 136 | if (offset==7) |
| 123 | | led7= data & 0x80 ? 0xff :0x00; //MM2 |
| 137 | state->led7= data & 0x80 ? 0xff :0x00; //MM2 |
| 124 | 138 | |
| 125 | 139 | } |
| 126 | 140 | |
| 127 | 141 | static ADDRESS_MAP_START(rebel5_mem , ADDRESS_SPACE_PROGRAM, 8) |
| 128 | | AM_RANGE( 0x0000, 0x1fff) AM_RAM // AM_BASE(&mephisto_ram)// |
| 142 | AM_RANGE( 0x0000, 0x1fff) AM_RAM // AM_BASE_MEMBER(mephisto_state, ram)// |
| 129 | 143 | AM_RANGE( 0x5000, 0x5000) AM_WRITE( write_lcd ) |
| 130 | 144 | AM_RANGE( 0x3000, 0x3007) AM_READ( read_keys ) // Rebel 5.0 |
| 131 | 145 | AM_RANGE( 0x2000, 0x2007) AM_WRITE( write_led ) // Status LEDs+ buzzer |
| r10150 | r10151 | |
| 137 | 151 | |
| 138 | 152 | |
| 139 | 153 | static ADDRESS_MAP_START(mephisto_mem , ADDRESS_SPACE_PROGRAM, 8) |
| 140 | | AM_RANGE( 0x0000, 0x1fff) AM_RAM AM_BASE(&mephisto_ram )// |
| 154 | AM_RANGE( 0x0000, 0x1fff) AM_RAM AM_BASE_MEMBER(mephisto_state, ram )// |
| 141 | 155 | AM_RANGE( 0x2000, 0x2000) AM_WRITE( write_lcd ) |
| 142 | 156 | AM_RANGE( 0x2c00, 0x2c07) AM_READ( read_keys ) |
| 143 | 157 | AM_RANGE( 0x3400, 0x3407) AM_WRITE( write_led ) // Status LEDs+ buzzer |
| r10150 | r10151 | |
| 150 | 164 | ADDRESS_MAP_END |
| 151 | 165 | |
| 152 | 166 | static ADDRESS_MAP_START(mm2_mem , ADDRESS_SPACE_PROGRAM, 8) |
| 153 | | AM_RANGE( 0x0000, 0x0fff) AM_RAM AM_BASE(&mephisto_ram ) |
| 167 | AM_RANGE( 0x0000, 0x0fff) AM_RAM AM_BASE_MEMBER(mephisto_state, ram ) |
| 154 | 168 | AM_RANGE( 0x2800, 0x2800) AM_WRITE( write_lcd ) |
| 155 | 169 | AM_RANGE( 0x1800, 0x1807) AM_READ( read_keys ) |
| 156 | 170 | AM_RANGE( 0x1000, 0x1007) AM_WRITE( write_led_mm2 ) //Status LEDs |
| r10150 | r10151 | |
| 304 | 318 | |
| 305 | 319 | static TIMER_CALLBACK( update_nmi ) |
| 306 | 320 | { |
| 321 | mephisto_state *state = machine->driver_data<mephisto_state>(); |
| 307 | 322 | device_t *speaker = machine->device("beep"); |
| 308 | 323 | cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI,PULSE_LINE); |
| 309 | | // dac_data_w(0,led_status&64?128:0); |
| 310 | | beep_set_state(speaker,led_status&64?1:0); |
| 324 | // dac_data_w(0,state->led_status&64?128:0); |
| 325 | beep_set_state(speaker,state->led_status&64?1:0); |
| 311 | 326 | } |
| 312 | 327 | |
| 313 | 328 | static TIMER_CALLBACK( update_irq ) //only mm2 |
| 314 | 329 | { |
| 330 | mephisto_state *state = machine->driver_data<mephisto_state>(); |
| 315 | 331 | device_t *speaker = machine->device("beep"); |
| 316 | 332 | |
| 317 | 333 | cputag_set_input_line(machine, "maincpu", M6502_IRQ_LINE, ASSERT_LINE); |
| 318 | 334 | cputag_set_input_line(machine, "maincpu", M6502_IRQ_LINE, CLEAR_LINE); |
| 319 | 335 | |
| 320 | | beep_set_state(speaker,led_status&64?1:0); |
| 336 | beep_set_state(speaker,state->led_status&64?1:0); |
| 321 | 337 | } |
| 322 | 338 | static MACHINE_START( mephisto ) |
| 323 | 339 | { |
| 324 | | lcd_shift_counter=3; |
| 340 | mephisto_state *state = machine->driver_data<mephisto_state>(); |
| 341 | state->lcd_shift_counter=3; |
| 325 | 342 | |
| 326 | 343 | timer_pulse(machine, ATTOTIME_IN_HZ(600), NULL, 0, update_nmi); |
| 327 | 344 | timer_pulse(machine, ATTOTIME_IN_HZ(100), NULL, 0, mboard_update_artwork); |
| r10150 | r10151 | |
| 331 | 348 | |
| 332 | 349 | static MACHINE_START( mm2 ) |
| 333 | 350 | { |
| 334 | | lcd_shift_counter=3; |
| 335 | | led7=0xff; |
| 351 | mephisto_state *state = machine->driver_data<mephisto_state>(); |
| 352 | state->lcd_shift_counter=3; |
| 353 | state->led7=0xff; |
| 336 | 354 | |
| 337 | 355 | timer_pulse(machine, ATTOTIME_IN_HZ(450), NULL, 0, update_irq); |
| 338 | 356 | timer_pulse(machine, ATTOTIME_IN_HZ(100), NULL, 0, mboard_update_artwork); |
| r10150 | r10151 | |
| 343 | 361 | |
| 344 | 362 | static MACHINE_RESET( mephisto ) |
| 345 | 363 | { |
| 346 | | lcd_shift_counter = 3; |
| 364 | mephisto_state *state = machine->driver_data<mephisto_state>(); |
| 365 | state->lcd_shift_counter = 3; |
| 347 | 366 | |
| 348 | 367 | mboard_set_border_pieces(); |
| 349 | 368 | mboard_set_board(); |
| r10150 | r10151 | |
| 363 | 382 | } |
| 364 | 383 | |
| 365 | 384 | |
| 366 | | static MACHINE_CONFIG_START( mephisto, driver_device ) |
| 385 | static MACHINE_CONFIG_START( mephisto, mephisto_state ) |
| 367 | 386 | /* basic machine hardware */ |
| 368 | | MCFG_CPU_ADD("maincpu",M65C02,4915200) /* 65C02 */ |
| 387 | MCFG_CPU_ADD("maincpu",M65C02,4915200) /* 65C02 */ |
| 369 | 388 | MCFG_CPU_PROGRAM_MAP(mephisto_mem) |
| 370 | 389 | MCFG_QUANTUM_TIME(HZ(60)) |
| 371 | 390 | MCFG_MACHINE_START( mephisto ) |
| r10150 | r10151 | |
| 434 | 453 | |
| 435 | 454 | static DRIVER_INIT( mephisto ) |
| 436 | 455 | { |
| 437 | | lcd_shift_counter = 3; |
| 456 | mephisto_state *state = machine->driver_data<mephisto_state>(); |
| 457 | state->lcd_shift_counter = 3; |
| 438 | 458 | } |
| 439 | 459 | |
| 440 | 460 | /*************************************************************************** |
src/mess/drivers/polgar.c
| r10150 | r10151 | |
| 44 | 44 | #include "machine/mboard.h" |
| 45 | 45 | #include "rendlay.h" |
| 46 | 46 | |
| 47 | |
| 48 | class polgar_state : public driver_device |
| 49 | { |
| 50 | public: |
| 51 | polgar_state(running_machine &machine, const driver_device_config_base &config) |
| 52 | : driver_device(machine, config) { } |
| 53 | |
| 54 | UINT8 led_status; |
| 55 | UINT8 lcd_char; |
| 56 | UINT8 led7; |
| 57 | UINT8 latch_data; |
| 58 | }; |
| 59 | |
| 60 | |
| 47 | 61 | //static UINT8 lcd_shift_counter; |
| 48 | | static UINT8 led_status; |
| 49 | | static UINT8 lcd_char=0; |
| 50 | 62 | // static UINT8 *milano_ram; |
| 51 | | static UINT8 led7; |
| 52 | 63 | |
| 53 | 64 | static const int value[4] = {0x80,0x81,0x00,0x01}; |
| 54 | 65 | |
| 55 | | static UINT8 latch_data; |
| 56 | 66 | |
| 57 | 67 | static const hd44780_interface polgar_display = |
| 58 | 68 | { |
| 59 | | 2, // number of lines |
| 60 | | 16, // chars for line |
| 61 | | NULL // custom display layout |
| 69 | 2, // number of lines |
| 70 | 16, // chars for line |
| 71 | NULL // custom display layout |
| 62 | 72 | }; |
| 63 | 73 | |
| 64 | 74 | |
| 65 | 75 | static WRITE8_HANDLER ( write_io ) |
| 66 | 76 | { |
| 67 | | int i; |
| 68 | | hd44780_device * hd44780 = space->machine->device<hd44780_device>("hd44780"); |
| 69 | | device_t *speaker = space->machine->device("beep"); |
| 77 | polgar_state *state = space->machine->driver_data<polgar_state>(); |
| 78 | int i; |
| 79 | hd44780_device * hd44780 = space->machine->device<hd44780_device>("hd44780"); |
| 80 | device_t *speaker = space->machine->device("beep"); |
| 70 | 81 | |
| 71 | | if (BIT(data,1)) { |
| 72 | | if (BIT(data,0)) { |
| 73 | | hd44780->data_write(128, lcd_char); |
| 74 | | } else { |
| 75 | | hd44780->control_write(128, lcd_char); |
| 82 | if (BIT(data,1)) { |
| 83 | if (BIT(data,0)) { |
| 84 | hd44780->data_write(128, state->lcd_char); |
| 85 | } else { |
| 86 | hd44780->control_write(128, state->lcd_char); |
| 87 | } |
| 76 | 88 | } |
| 77 | | } |
| 78 | 89 | |
| 79 | | if (BIT(data,2) || BIT(data,3)) beep_set_state(speaker,1); else beep_set_state(speaker,0); |
| 90 | if (BIT(data,2) || BIT(data,3)) beep_set_state(speaker,1); else beep_set_state(speaker,0); |
| 80 | 91 | |
| 81 | | if (BIT(data,7) && BIT(data, 4)) |
| 92 | if (BIT(data,7) && BIT(data, 4)) |
| 82 | 93 | { |
| 83 | 94 | for (i=0;i<8;i++) |
| 84 | | output_set_led_value(i,!BIT(latch_data,i)); |
| 95 | output_set_led_value(i,!BIT(state->latch_data,i)); |
| 85 | 96 | } |
| 86 | | if (BIT(data,6) && BIT(data,5)) |
| 97 | if (BIT(data,6) && BIT(data,5)) |
| 87 | 98 | { |
| 88 | 99 | for (i=0;i<8;i++) |
| 89 | | output_set_led_value(10+i,!BIT(latch_data,7-i)); |
| 100 | output_set_led_value(10+i,!BIT(state->latch_data,7-i)); |
| 90 | 101 | } |
| 91 | 102 | |
| 92 | 103 | //logerror("LCD Status Data = %d\n",data); |
| r10150 | r10151 | |
| 96 | 107 | |
| 97 | 108 | static WRITE8_HANDLER ( write_lcd ) |
| 98 | 109 | { |
| 110 | polgar_state *state = space->machine->driver_data<polgar_state>(); |
| 99 | 111 | |
| 100 | | lcd_char=data; |
| 112 | state->lcd_char=data; |
| 101 | 113 | |
| 102 | | //logerror("LCD Data = %d [%c]\n",data,(data&0xff)); |
| 114 | //logerror("LCD Data = %d [%c]\n",data,(data&0xff)); |
| 103 | 115 | |
| 104 | 116 | } |
| 105 | 117 | |
| 106 | 118 | |
| 107 | 119 | static WRITE8_HANDLER ( write_board ) |
| 108 | 120 | { |
| 109 | | latch_data=data; |
| 121 | polgar_state *state = space->machine->driver_data<polgar_state>(); |
| 122 | state->latch_data=data; |
| 110 | 123 | } |
| 111 | 124 | |
| 112 | 125 | |
| 113 | 126 | static WRITE8_HANDLER ( milano_write_led ) |
| 114 | 127 | { |
| 115 | 128 | UINT8 LED_offset=100; |
| 116 | | if (data==0xff) output_set_led_value(LED_offset+offset,1); |
| 129 | if (data==0xff) |
| 130 | output_set_led_value(LED_offset+offset,1); |
| 117 | 131 | else |
| 118 | 132 | output_set_led_value(LED_offset+offset,0); |
| 119 | 133 | |
| r10150 | r10151 | |
| 122 | 136 | |
| 123 | 137 | static WRITE8_HANDLER ( write_led ) |
| 124 | 138 | { |
| 139 | polgar_state *state = space->machine->driver_data<polgar_state>(); |
| 125 | 140 | UINT8 LED_offset=100; |
| 126 | 141 | data &= 0x80; |
| 127 | 142 | |
| 128 | | if (data==0)led_status &= 255-(1<<offset) ; else led_status|=1<<offset; |
| 129 | | if (offset<6)output_set_led_value(LED_offset+offset, led_status&1<<offset?1:0); |
| 130 | | if (offset==7) led7=data& 0x80 ? 0x00 :0xff; |
| 143 | if (data==0)state->led_status &= 255-(1<<offset) ; else state->led_status|=1<<offset; |
| 144 | if (offset<6)output_set_led_value(LED_offset+offset, state->led_status&1<<offset?1:0); |
| 145 | if (offset==7) state->led7=data& 0x80 ? 0x00 :0xff; |
| 131 | 146 | logerror("LEDs Offset = %d Data = %d\n",offset,data); |
| 132 | 147 | } |
| 133 | 148 | |
| 134 | | /*static WRITE8_HANDLER ( write_led ) |
| 149 | #if 0 |
| 150 | static WRITE8_HANDLER ( write_led ) |
| 135 | 151 | { |
| 152 | polgar_state *state = space->machine->driver_data<polgar_state>(); |
| 136 | 153 | UINT8 LED_offset=100; |
| 137 | | if (data==0xff) output_set_led_value(LED_offset+offset,1); |
| 154 | if (data==0xff) |
| 155 | output_set_led_value(LED_offset+offset,1); |
| 138 | 156 | else |
| 139 | 157 | output_set_led_value(LED_offset+offset,0); |
| 140 | | if (data==0)led_status &= 255-(1<<offset) ; else led_status|=1<<offset; |
| 141 | | if (offset<6)output_set_led_value(LED_offset+offset, led_status&1<<offset?1:0); |
| 142 | | if (offset==7) led7=data& 0x80 ? 0x00 :0xff; |
| 158 | if (data==0)state->led_status &= 255-(1<<offset) ; else state->led_status|=1<<offset; |
| 159 | if (offset<6)output_set_led_value(LED_offset+offset, state->led_status&1<<offset?1:0); |
| 160 | if (offset==7) state->led7=data& 0x80 ? 0x00 :0xff; |
| 143 | 161 | |
| 144 | 162 | |
| 145 | 163 | logerror("LEDs Offset = %d Data = %d\n",offset,data); |
| 146 | 164 | } |
| 147 | | */ |
| 165 | #endif |
| 166 | |
| 148 | 167 | static READ8_HANDLER(read_board) |
| 149 | 168 | { |
| 150 | 169 | UINT8 data; |
| 151 | | data=input_port_read(space->machine, "KEY1_8"); |
| 152 | | logerror("Keydata Data = %d\n ",data); |
| 153 | | return data; |
| 170 | data=input_port_read(space->machine, "KEY1_8"); |
| 171 | logerror("Keydata Data = %d\n ",data); |
| 172 | return data; |
| 154 | 173 | } |
| 155 | 174 | |
| 156 | 175 | static READ8_HANDLER(read_keys) |
| 157 | 176 | { |
| 177 | //polgar_state *state = space->machine->driver_data<polgar_state>(); |
| 158 | 178 | UINT8 data; |
| 159 | 179 | static const char *const keynames[2][8] = |
| 160 | 180 | { |
| r10150 | r10151 | |
| 163 | 183 | }; |
| 164 | 184 | |
| 165 | 185 | data = 0xff; |
| 166 | | /* |
| 167 | | if (((led_status & 0x80) == 0x00)) |
| 186 | #if 0 |
| 187 | if (((state->led_status & 0x80) == 0x00)) |
| 168 | 188 | data=input_port_read(space->machine, keynames[0][offset]); |
| 169 | 189 | else |
| 170 | 190 | data=input_port_read(space->machine, keynames[1][offset]); |
| 171 | | */ |
| 172 | | data=input_port_read(space->machine, keynames[0][offset]); |
| 173 | | // logerror("Keyboard Port = %s Data = %d\n ", ((led_status & 0x80) == 0x00) ? keynames[0][offset] : keynames[1][offset], data); |
| 191 | #endif |
| 192 | data=input_port_read(space->machine, keynames[0][offset]); |
| 193 | // logerror("Keyboard Port = %s Data = %d\n ", ((state->led_status & 0x80) == 0x00) ? keynames[0][offset] : keynames[1][offset], data); |
| 174 | 194 | return data | 0x7f; |
| 175 | 195 | } |
| 176 | 196 | |
| r10150 | r10151 | |
| 183 | 203 | |
| 184 | 204 | static VIDEO_UPDATE( polgar ) |
| 185 | 205 | { |
| 186 | | hd44780_device * hd44780 = screen->machine->device<hd44780_device>("hd44780"); |
| 187 | | return hd44780->video_update( bitmap, cliprect ); |
| 206 | hd44780_device * hd44780 = screen->machine->device<hd44780_device>("hd44780"); |
| 207 | return hd44780->video_update( bitmap, cliprect ); |
| 188 | 208 | } |
| 189 | 209 | |
| 190 | 210 | static PALETTE_INIT( polgar ) |
| 191 | 211 | { |
| 192 | | // palette_set_color(machine, 0, MAKE_RGB(138, 146, 148)); |
| 212 | //palette_set_color(machine, 0, MAKE_RGB(138, 146, 148)); |
| 193 | 213 | palette_set_color(machine, 0, MAKE_RGB(195, 201, 200)); |
| 194 | | palette_set_color(machine, 1, MAKE_RGB(40, 30, 30)); |
| 214 | palette_set_color(machine, 1, MAKE_RGB(40, 30, 30)); |
| 195 | 215 | } |
| 196 | 216 | |
| 197 | 217 | |
| 198 | 218 | static const gfx_layout polgar_charlayout = |
| 199 | 219 | { |
| 200 | | 5, 8, /* 5 x 8 characters */ |
| 201 | | 256, /* 256 characters */ |
| 202 | | 1, /* 1 bits per pixel */ |
| 203 | | { 0 }, /* no bitplanes */ |
| 204 | | { 3, 4, 5, 6, 7}, |
| 205 | | { 0, 8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8}, |
| 206 | | 8*8 /* 8 bytes */ |
| 220 | 5, 8, /* 5 x 8 characters */ |
| 221 | 256, /* 256 characters */ |
| 222 | 1, /* 1 bits per pixel */ |
| 223 | { 0 }, /* no bitplanes */ |
| 224 | { 3, 4, 5, 6, 7}, |
| 225 | { 0, 8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8}, |
| 226 | 8*8 /* 8 bytes */ |
| 207 | 227 | }; |
| 208 | 228 | |
| 209 | 229 | static GFXDECODE_START( polgar ) |
| 210 | | GFXDECODE_ENTRY( "hd44780", 0x0000, polgar_charlayout, 0, 1 ) |
| 230 | GFXDECODE_ENTRY( "hd44780", 0x0000, polgar_charlayout, 0, 1 ) |
| 211 | 231 | GFXDECODE_END |
| 212 | 232 | |
| 213 | 233 | |
| r10150 | r10151 | |
| 219 | 239 | AM_RANGE( 0x3400, 0x3405) AM_WRITE( write_led) // Function LEDs 3400 TRN 3401 |
| 220 | 240 | AM_RANGE( 0x2c00, 0x2c07) AM_READ( read_keys) // CL Key |
| 221 | 241 | AM_RANGE( 0x2004, 0x2004) AM_WRITE( write_io) // LCD Instr. Reg + Beeper |
| 222 | | AM_RANGE( 0x2000, 0x2000) AM_WRITE( write_lcd) // LCD Char Reg. |
| 242 | AM_RANGE( 0x2000, 0x2000) AM_WRITE( write_lcd) // LCD Char Reg. |
| 223 | 243 | AM_RANGE( 0x4000, 0xffff) AM_ROM |
| 224 | 244 | ADDRESS_MAP_END |
| 225 | 245 | |
| r10150 | r10151 | |
| 360 | 380 | |
| 361 | 381 | static TIMER_CALLBACK( update_nmi ) |
| 362 | 382 | { |
| 363 | | // device_t *speaker = machine->device("beep"); |
| 383 | //polgar_state *state = machine->driver_data<polgar_state>(); |
| 384 | // running_device *speaker = machine->device("beep"); |
| 364 | 385 | cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI,PULSE_LINE); |
| 365 | 386 | // cputag_set_input_line(machine, "maincpu", M6502_IRQ_LINE, CLEAR_LINE); |
| 366 | | // dac_data_w(0,led_status&64?128:0); |
| 367 | | // beep_set_state(speaker,led_status&64?1:0); |
| 387 | // dac_data_w(0,state->led_status&64?128:0); |
| 388 | // beep_set_state(speaker,state->led_status&64?1:0); |
| 368 | 389 | } |
| 369 | 390 | |
| 370 | 391 | |
| r10150 | r10151 | |
| 385 | 406 | } |
| 386 | 407 | |
| 387 | 408 | |
| 388 | | static MACHINE_CONFIG_START( polgar, driver_device ) |
| 409 | static MACHINE_CONFIG_START( polgar, polgar_state ) |
| 389 | 410 | /* basic machine hardware */ |
| 390 | | MCFG_CPU_ADD("maincpu",M65C02,4915200) /* 65C02 */ |
| 411 | MCFG_CPU_ADD("maincpu",M65C02,4915200) /* 65C02 */ |
| 391 | 412 | MCFG_CPU_PROGRAM_MAP(polgar_mem) |
| 392 | 413 | MCFG_QUANTUM_TIME(HZ(60)) |
| 393 | 414 | MCFG_MACHINE_START( polgar ) |
| 394 | 415 | MCFG_MACHINE_RESET( polgar ) |
| 395 | 416 | |
| 396 | 417 | /* video hardware */ |
| 397 | | // MCFG_DEFAULT_LAYOUT(layout_milano) |
| 398 | | MCFG_SCREEN_ADD("screen", LCD) |
| 418 | // MCFG_DEFAULT_LAYOUT(layout_milano) |
| 419 | MCFG_SCREEN_ADD("screen", LCD) |
| 399 | 420 | MCFG_SCREEN_REFRESH_RATE(50) |
| 400 | 421 | MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 401 | 422 | MCFG_SCREEN_SIZE(100, 20) |
| r10150 | r10151 | |
| 407 | 428 | |
| 408 | 429 | MCFG_HD44780_ADD("hd44780", polgar_display) |
| 409 | 430 | |
| 410 | | MCFG_VIDEO_START(polgar) |
| 411 | | MCFG_VIDEO_UPDATE(polgar) |
| 431 | MCFG_VIDEO_START(polgar) |
| 432 | MCFG_VIDEO_UPDATE(polgar) |
| 412 | 433 | |
| 413 | 434 | |
| 414 | | // MCFG_DEFAULT_LAYOUT(layout_van16) |
| 415 | | MCFG_DEFAULT_LAYOUT(layout_lcd) |
| 435 | //MCFG_DEFAULT_LAYOUT(layout_van16) |
| 436 | MCFG_DEFAULT_LAYOUT(layout_lcd) |
| 416 | 437 | |
| 417 | 438 | |
| 418 | 439 | /* sound hardware */ |
| r10150 | r10151 | |
| 423 | 444 | |
| 424 | 445 | static MACHINE_CONFIG_DERIVED( milano, polgar ) |
| 425 | 446 | /* basic machine hardware */ |
| 426 | | // MCFG_IMPORT_FROM( polgar ) |
| 447 | // MCFG_IMPORT_FROM( polgar ) |
| 427 | 448 | MCFG_CPU_MODIFY("maincpu") |
| 428 | 449 | MCFG_CPU_PROGRAM_MAP(milano_mem) |
| 429 | 450 | //beep_set_frequency(0, 4000); |
| r10150 | r10151 | |
| 433 | 454 | ROM_REGION(0x10000,"maincpu",0) |
| 434 | 455 | ROM_LOAD("milano.bin", 0x0000, 0x10000, CRC(0e9c8fe1) SHA1(e9176f42d86fe57e382185c703c7eff7e63ca711)) |
| 435 | 456 | ROM_REGION( 0x0860, "hd44780", ROMREGION_ERASE ) |
| 436 | | ROM_LOAD( "44780a00.bin", 0x0000, 0x0860, BAD_DUMP CRC(3a89024c) SHA1(5a87b68422a916d1b37b5be1f7ad0b3fb3af5a8d)) |
| 457 | ROM_LOAD( "44780a00.bin", 0x0000, 0x0860, BAD_DUMP CRC(3a89024c) SHA1(5a87b68422a916d1b37b5be1f7ad0b3fb3af5a8d)) |
| 437 | 458 | ROM_END |
| 438 | 459 | |
| 439 | 460 | |
| r10150 | r10151 | |
| 442 | 463 | ROM_REGION(0x10000,"maincpu",0) |
| 443 | 464 | ROM_LOAD("polgar.bin", 0x0000, 0x10000, CRC(88d55c0f) SHA1(e86d088ec3ac68deaf90f6b3b97e3e31b1515913)) |
| 444 | 465 | ROM_REGION( 0x0860, "hd44780", ROMREGION_ERASE ) |
| 445 | | ROM_LOAD( "44780a00.bin", 0x0000, 0x0860, BAD_DUMP CRC(3a89024c) SHA1(5a87b68422a916d1b37b5be1f7ad0b3fb3af5a8d)) |
| 466 | ROM_LOAD( "44780a00.bin", 0x0000, 0x0860, BAD_DUMP CRC(3a89024c) SHA1(5a87b68422a916d1b37b5be1f7ad0b3fb3af5a8d)) |
| 446 | 467 | ROM_END |
| 447 | 468 | |
| 448 | 469 | |
| 449 | 470 | static DRIVER_INIT( polgar ) |
| 450 | 471 | { |
| 451 | | led_status=0; |
| 472 | polgar_state *state = machine->driver_data<polgar_state>(); |
| 473 | state->led_status=0; |
| 452 | 474 | } |
| 453 | 475 | |
| 454 | 476 | /*************************************************************************** |