src/mess/drivers/fm7.c
| r4932 | r4933 | |
| 66 | 66 | static UINT8 break_flag; |
| 67 | 67 | static UINT8 fm7_pal[8]; |
| 68 | 68 | static UINT8 fm7_psg_regsel; |
| 69 | static UINT8 psg_data; |
| 69 | 70 | |
| 70 | 71 | /* key scancode conversion table |
| 71 | 72 | * The FM-7 expects different scancodes when shift,ctrl or graph is held, or |
| r4932 | r4933 | |
| 488 | 489 | palette_set_color(space->machine,offset,MAKE_RGB(r,g,b)); |
| 489 | 490 | fm7_pal[offset] = data & 0x07; |
| 490 | 491 | } |
| 492 | static void fm7_update_psg(running_machine* machine) |
| 493 | { |
| 494 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 491 | 495 | |
| 496 | switch(fm7_psg_regsel) |
| 497 | { |
| 498 | case 0x00: |
| 499 | // High impedance |
| 500 | break; |
| 501 | case 0x01: |
| 502 | // Data read |
| 503 | psg_data = ay8910_r(devtag_get_device(space->machine,"psg"),0); |
| 504 | break; |
| 505 | case 0x02: |
| 506 | // Data write |
| 507 | ay8910_data_w(devtag_get_device(space->machine,"psg"),0,psg_data); |
| 508 | break; |
| 509 | case 0x03: |
| 510 | // Address latch |
| 511 | ay8910_address_w(devtag_get_device(space->machine,"psg"),0,psg_data); |
| 512 | break; |
| 513 | } |
| 514 | } |
| 515 | |
| 492 | 516 | static READ8_HANDLER( fm7_psg_select_r ) |
| 493 | 517 | { |
| 494 | 518 | return 0xff; |
| r4932 | r4933 | |
| 496 | 520 | |
| 497 | 521 | static WRITE8_HANDLER( fm7_psg_select_w ) |
| 498 | 522 | { |
| 499 | | static UINT8 prev; |
| 500 | 523 | /* |
| 501 | 524 | * bit 0 = BC1 |
| 502 | 525 | * bit 1 = BDIR |
| 503 | | * |
| 504 | | * function is selected when both bits are set to 0 |
| 505 | 526 | */ |
| 506 | | if((data & 0x03) == 0x00) |
| 507 | | fm7_psg_regsel = prev & 0x03; |
| 508 | | prev = data; |
| 527 | fm7_psg_regsel = data & 0x03; |
| 528 | fm7_update_psg(space->machine); |
| 509 | 529 | } |
| 510 | 530 | |
| 511 | 531 | static READ8_HANDLER( fm7_psg_data_r ) |
| 512 | 532 | { |
| 513 | | switch(fm7_psg_regsel) |
| 514 | | { |
| 515 | | case 0x00: |
| 516 | | // High impedance |
| 517 | | return 0xff; |
| 518 | | case 0x01: |
| 519 | | // Data read |
| 520 | | return ay8910_r(devtag_get_device(space->machine,"psg"),0); |
| 521 | | case 0x02: |
| 522 | | // Data write |
| 523 | | case 0x03: |
| 524 | | // Address latch |
| 525 | | logerror("PSG: Read from data register when Data Read is not selected\n"); |
| 526 | | } |
| 527 | | return 0xff; |
| 533 | fm7_update_psg(space->machine); |
| 534 | return psg_data; |
| 528 | 535 | } |
| 529 | 536 | |
| 530 | 537 | static WRITE8_HANDLER( fm7_psg_data_w ) |
| 531 | 538 | { |
| 532 | | switch(fm7_psg_regsel) |
| 533 | | { |
| 534 | | case 0x00: |
| 535 | | // High impedance |
| 536 | | break; |
| 537 | | case 0x01: |
| 538 | | // Data read |
| 539 | | logerror("PSG: Read from data register when Data Read is not selected\n"); |
| 540 | | break; |
| 541 | | case 0x02: |
| 542 | | // Data write |
| 543 | | ay8910_data_w(devtag_get_device(space->machine,"psg"),0,data); |
| 544 | | break; |
| 545 | | case 0x03: |
| 546 | | // Address latch |
| 547 | | ay8910_address_w(devtag_get_device(space->machine,"psg"),0,data); |
| 548 | | break; |
| 549 | | } |
| 539 | psg_data = data; |
| 540 | fm7_update_psg(space->machine); |
| 550 | 541 | } |
| 551 | 542 | |
| 552 | 543 | static TIMER_CALLBACK( fm7_timer_irq ) |