src/mess/drivers/fm7.c
| r4931 | r4932 | |
| 65 | 65 | static UINT16 vram_offset; |
| 66 | 66 | static UINT8 break_flag; |
| 67 | 67 | static UINT8 fm7_pal[8]; |
| 68 | static UINT8 fm7_psg_regsel; |
| 68 | 69 | |
| 69 | 70 | /* key scancode conversion table |
| 70 | 71 | * The FM-7 expects different scancodes when shift,ctrl or graph is held, or |
| r4931 | r4932 | |
| 216 | 217 | return ret; |
| 217 | 218 | } |
| 218 | 219 | |
| 219 | | READ8_HANDLER( mainmem_r ) |
| 220 | | { |
| 221 | | UINT8* RAM = memory_region(space->machine,"maincpu"); |
| 222 | | |
| 223 | | return RAM[offset]; |
| 224 | | } |
| 225 | | |
| 226 | | WRITE8_HANDLER( mainmem_w ) |
| 227 | | { |
| 228 | | UINT8* RAM = memory_region(space->machine,"maincpu"); |
| 229 | | |
| 230 | | RAM[offset] = data; |
| 231 | | } |
| 232 | | |
| 233 | 220 | READ8_HANDLER( vector_r ) |
| 234 | 221 | { |
| 235 | 222 | UINT8* RAM = memory_region(space->machine,"maincpu"); |
| r4931 | r4932 | |
| 502 | 489 | fm7_pal[offset] = data & 0x07; |
| 503 | 490 | } |
| 504 | 491 | |
| 492 | static READ8_HANDLER( fm7_psg_select_r ) |
| 493 | { |
| 494 | return 0xff; |
| 495 | } |
| 496 | |
| 497 | static WRITE8_HANDLER( fm7_psg_select_w ) |
| 498 | { |
| 499 | static UINT8 prev; |
| 500 | /* |
| 501 | * bit 0 = BC1 |
| 502 | * bit 1 = BDIR |
| 503 | * |
| 504 | * function is selected when both bits are set to 0 |
| 505 | */ |
| 506 | if((data & 0x03) == 0x00) |
| 507 | fm7_psg_regsel = prev & 0x03; |
| 508 | prev = data; |
| 509 | } |
| 510 | |
| 511 | static READ8_HANDLER( fm7_psg_data_r ) |
| 512 | { |
| 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; |
| 528 | } |
| 529 | |
| 530 | static WRITE8_HANDLER( fm7_psg_data_w ) |
| 531 | { |
| 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 | } |
| 550 | } |
| 551 | |
| 505 | 552 | static TIMER_CALLBACK( fm7_timer_irq ) |
| 506 | 553 | { |
| 507 | 554 | if(irq_mask & IRQ_FLAG_TIMER) |
| r4931 | r4932 | |
| 597 | 644 | */ |
| 598 | 645 | // The FM-7 has only 64kB RAM, so we'll worry about banking when we do the later models |
| 599 | 646 | static ADDRESS_MAP_START( fm7_mem, ADDRESS_SPACE_PROGRAM, 8 ) |
| 600 | | AM_RANGE(0x0000,0x7fff) AM_READWRITE(mainmem_r,mainmem_w) |
| 647 | AM_RANGE(0x0000,0x7fff) AM_RAM |
| 601 | 648 | AM_RANGE(0x8000,0xfbff) AM_RAMBANK(1) // also F-BASIC ROM, when enabled |
| 602 | 649 | AM_RANGE(0xfc00,0xfc7f) AM_RAM |
| 603 | 650 | AM_RANGE(0xfc80,0xfcff) AM_READWRITE(shared_r,shared_w) // shared RAM with sub-CPU |
| r4931 | r4932 | |
| 608 | 655 | AM_RANGE(0xfd04,0xfd04) AM_READ(fm7_fd04_r) |
| 609 | 656 | AM_RANGE(0xfd05,0xfd05) AM_READWRITE(fm7_subintf_r,fm7_subintf_w) |
| 610 | 657 | AM_RANGE(0xfd07,0xfd07) AM_RAM |
| 611 | | AM_RANGE(0xfd0d,0xfd0d) AM_DEVWRITE("psg",ay8910_address_w) |
| 612 | | AM_RANGE(0xfd0e,0xfd0e) AM_DEVREADWRITE("psg",ay8910_r,ay8910_data_w) |
| 658 | AM_RANGE(0xfd0d,0xfd0d) AM_READWRITE(fm7_psg_select_r,fm7_psg_select_w) |
| 659 | AM_RANGE(0xfd0e,0xfd0e) AM_READWRITE(fm7_psg_data_r, fm7_psg_data_w) |
| 613 | 660 | AM_RANGE(0xfd0f,0xfd0f) AM_READWRITE(fm7_rom_en_r,fm7_rom_en_w) |
| 614 | 661 | AM_RANGE(0xfd18,0xfd1f) AM_READWRITE(fm7_fdc_r,fm7_fdc_w) |
| 615 | 662 | AM_RANGE(0xfd24,0xfd2b) AM_RAM |
| r4931 | r4932 | |
| 807 | 854 | key_repeat = 70; // 70ms on FM-7 |
| 808 | 855 | vram_offset = 0x0000; |
| 809 | 856 | break_flag = 0; |
| 857 | fm7_psg_regsel = 0; |
| 810 | 858 | } |
| 811 | 859 | |
| 812 | 860 | static VIDEO_START( fm7 ) |