src/mess/drivers/pc6001.c
| r8741 | r8742 | |
| 124 | 124 | static UINT8 *pc6001_video_ram; |
| 125 | 125 | static UINT8 irq_vector = 0x00; |
| 126 | 126 | static UINT8 cas_switch,sys_latch; |
| 127 | static UINT8 timer_irq_mask; |
| 127 | 128 | static UINT32 cas_offset; |
| 128 | 129 | static UINT32 cas_maxsize; |
| 130 | static emu_timer *timer_irq_timer; |
| 131 | static UINT16 timer_hz_div; |
| 129 | 132 | /* PC6001mk2 specific */ |
| 130 | 133 | static UINT8 ex_vram_bank, bgcol_bank,exgfx_text_mode,exgfx_bitmap_mode,exgfx_2bpp_mode; |
| 131 | 134 | static UINT8 bank_r0,bank_r1,gfx_bank_on,bank_w,bank_opt; |
| 135 | static UINT8 timer_irq_mask2, timer_irq_vector; |
| 132 | 136 | |
| 133 | 137 | //#define CAS_LENGTH 0x1655 |
| 134 | 138 | |
| r8741 | r8742 | |
| 505 | 509 | } |
| 506 | 510 | |
| 507 | 511 | sys_latch = data; |
| 512 | timer_irq_mask = data & 1; |
| 508 | 513 | //printf("%02x\n",data); |
| 509 | 514 | } |
| 510 | 515 | |
| r8741 | r8742 | |
| 600 | 605 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 601 | 606 | AM_RANGE(0x80, 0x80) AM_DEVREADWRITE("uart", msm8251_data_r,msm8251_data_w) |
| 602 | 607 | AM_RANGE(0x81, 0x81) AM_DEVREADWRITE("uart", msm8251_status_r,msm8251_control_w) |
| 603 | | AM_RANGE(0x90, 0x93) AM_DEVREADWRITE("ppi8255", nec_ppi8255_r, nec_ppi8255_w) |
| 604 | | AM_RANGE(0xa0, 0xa0) AM_DEVWRITE("ay8910", ay8910_address_w) |
| 605 | | AM_RANGE(0xa1, 0xa1) AM_DEVWRITE("ay8910", ay8910_data_w) |
| 606 | | AM_RANGE(0xa2, 0xa2) AM_DEVREAD("ay8910", ay8910_r) |
| 607 | | AM_RANGE(0xb0, 0xb0) AM_WRITE(pc6001_system_latch_w) |
| 608 | AM_RANGE(0x90, 0x93) AM_MIRROR(0x0c) AM_DEVREADWRITE("ppi8255", nec_ppi8255_r, nec_ppi8255_w) |
| 609 | AM_RANGE(0xa0, 0xa0) AM_MIRROR(0x0c) AM_DEVWRITE("ay8910", ay8910_address_w) |
| 610 | AM_RANGE(0xa1, 0xa1) AM_MIRROR(0x0c) AM_DEVWRITE("ay8910", ay8910_data_w) |
| 611 | AM_RANGE(0xa2, 0xa2) AM_MIRROR(0x0c) AM_DEVREAD("ay8910", ay8910_r) |
| 612 | AM_RANGE(0xa3, 0xa3) AM_MIRROR(0x0c) AM_WRITENOP |
| 613 | AM_RANGE(0xb0, 0xb0) AM_MIRROR(0x0f) AM_WRITE(pc6001_system_latch_w) |
| 614 | AM_RANGE(0xd0, 0xd3) AM_MIRROR(0x0c) AM_NOP // disk device |
| 608 | 615 | ADDRESS_MAP_END |
| 609 | 616 | |
| 610 | 617 | /* |
| r8741 | r8742 | |
| 954 | 961 | } |
| 955 | 962 | |
| 956 | 963 | sys_latch = data; |
| 964 | timer_irq_mask = data & 1; |
| 957 | 965 | vram_bank_change(space->machine,(ex_vram_bank & 0x06) | ((sys_latch & 0x06) << 4)); |
| 958 | 966 | |
| 959 | 967 | //printf("%02x B0\n",data); |
| r8741 | r8742 | |
| 998 | 1006 | bgcol_bank = (data & 7); |
| 999 | 1007 | } |
| 1000 | 1008 | |
| 1001 | | /* this is a voice status flag, used by Chrith no Ainotabidachi (FIXME: identify and hook-up this voice synth chip) */ |
| 1002 | | static READ8_HANDLER( voice_status_r ) |
| 1009 | /* voice synth is a NEC uPD7752 sound chip (currently unemulated) */ |
| 1010 | static READ8_HANDLER( upd7752_reg_r ) |
| 1003 | 1011 | { |
| 1004 | | //x--- ---- status (1) not ready |
| 1005 | | //-x-- ---- writes some presumably wrong data |
| 1006 | | //---x ---- enables voice ROM, gives small time to fire an irq there |
| 1007 | | return 0x00; |
| 1012 | switch(offset & 3) |
| 1013 | { |
| 1014 | //[0x00]: status register |
| 1015 | //x--- ---- BSY busy status (1) processing (0) stopped |
| 1016 | //-x-- ---- REQ audio parameter (1) input request (0) prohibited (???) |
| 1017 | //--x- ---- ~INT / EXT message data (1) Outside (0) Inside |
| 1018 | //---x ---- ERR error flag |
| 1019 | case 0x00: return 0x60; |
| 1020 | //[0x02]: port 0xe2 latch? |
| 1021 | case 0x02: return 0xff; |
| 1022 | //[0x03]: port 0xe3 latch? |
| 1023 | case 0x03: return 0xff; |
| 1024 | } |
| 1025 | return 0xff; |
| 1008 | 1026 | } |
| 1009 | 1027 | |
| 1028 | static WRITE8_HANDLER( upd7752_reg_w ) |
| 1029 | { |
| 1030 | switch(offset & 3) |
| 1031 | { |
| 1032 | // [0x00]: audio parameter transfer |
| 1033 | |
| 1034 | // [0x02]: mode set |
| 1035 | // ---- -x-- Frame periodic analysis (0) 10 ms / frame (1) 20 ms / frame |
| 1036 | // ---- --xx Utterance (tempo?) speed |
| 1037 | // 00 : NORMAL SPEED |
| 1038 | // 01 : SLOW SPEED |
| 1039 | // 10 : FAST SPEED |
| 1040 | // 11 : Setting prohibited |
| 1041 | |
| 1042 | // case 0x02: |
| 1043 | |
| 1044 | // case 0x03: command set |
| 1045 | } |
| 1046 | } |
| 1047 | |
| 1048 | static WRITE8_HANDLER( pc6001m2_0xf3_w ) |
| 1049 | { |
| 1050 | /* |
| 1051 | x--- ---- M1 (?) wait setting |
| 1052 | -x-- ---- ROM wait setting |
| 1053 | --x- ---- RAM wait setting |
| 1054 | ---x ---- custom irq 2 address output |
| 1055 | ---- x--- custom irq 1 address output |
| 1056 | ---- -x-- timer irq mask 2 (mirror?) |
| 1057 | ---- --x- custom irq 2 mask |
| 1058 | ---- ---x custom irq 1 mask |
| 1059 | */ |
| 1060 | timer_irq_mask2 = data & 4; |
| 1061 | } |
| 1062 | |
| 1063 | static TIMER_CALLBACK(audio_callback) |
| 1064 | { |
| 1065 | if(cas_switch == 0 && ((timer_irq_mask == 0) || (timer_irq_mask2 == 0))) |
| 1066 | { |
| 1067 | irq_vector = timer_irq_vector; |
| 1068 | cputag_set_input_line(machine,"maincpu", 0, ASSERT_LINE); |
| 1069 | } |
| 1070 | } |
| 1071 | |
| 1072 | |
| 1073 | static WRITE8_HANDLER( pc6001m2_timer_adj_w ) |
| 1074 | { |
| 1075 | timer_hz_div = data; |
| 1076 | attotime period = ATTOTIME_IN_HZ((487.5*4)/(timer_hz_div+1)); |
| 1077 | timer_adjust_periodic(timer_irq_timer, period, 0, period); |
| 1078 | } |
| 1079 | |
| 1080 | static WRITE8_HANDLER( pc6001m2_timer_irqv_w ) |
| 1081 | { |
| 1082 | timer_irq_vector = data; |
| 1083 | } |
| 1084 | |
| 1010 | 1085 | static ADDRESS_MAP_START(pc6001m2_map, ADDRESS_SPACE_PROGRAM, 8) |
| 1011 | 1086 | ADDRESS_MAP_UNMAP_HIGH |
| 1012 | 1087 | AM_RANGE(0x0000, 0x1fff) AM_ROMBANK("bank1") AM_WRITE(work_ram0_w) |
| r8741 | r8742 | |
| 1024 | 1099 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 1025 | 1100 | AM_RANGE(0x80, 0x80) AM_DEVREADWRITE("uart", msm8251_data_r,msm8251_data_w) |
| 1026 | 1101 | AM_RANGE(0x81, 0x81) AM_DEVREADWRITE("uart", msm8251_status_r,msm8251_control_w) |
| 1027 | | AM_RANGE(0x90, 0x93) AM_DEVREADWRITE("ppi8255", nec_ppi8255_r, necmk2_ppi8255_w) |
| 1028 | | AM_RANGE(0xa0, 0xa0) AM_DEVWRITE("ay8910", ay8910_address_w) |
| 1029 | | AM_RANGE(0xa1, 0xa1) AM_DEVWRITE("ay8910", ay8910_data_w) |
| 1030 | | AM_RANGE(0xa2, 0xa2) AM_DEVREAD("ay8910", ay8910_r) |
| 1031 | | AM_RANGE(0xb0, 0xb0) AM_WRITE(pc6001m2_system_latch_w) |
| 1102 | |
| 1103 | AM_RANGE(0x90, 0x93) AM_MIRROR(0x0c) AM_DEVREADWRITE("ppi8255", nec_ppi8255_r, necmk2_ppi8255_w) |
| 1104 | |
| 1105 | AM_RANGE(0xa0, 0xa0) AM_MIRROR(0x0c) AM_DEVWRITE("ay8910", ay8910_address_w) |
| 1106 | AM_RANGE(0xa1, 0xa1) AM_MIRROR(0x0c) AM_DEVWRITE("ay8910", ay8910_data_w) |
| 1107 | AM_RANGE(0xa2, 0xa2) AM_MIRROR(0x0c) AM_DEVREAD("ay8910", ay8910_r) |
| 1108 | AM_RANGE(0xa3, 0xa3) AM_MIRROR(0x0c) AM_NOP |
| 1109 | |
| 1110 | AM_RANGE(0xb0, 0xb0) AM_MIRROR(0x0f) AM_WRITE(pc6001m2_system_latch_w) |
| 1111 | |
| 1032 | 1112 | AM_RANGE(0xc0, 0xc0) AM_WRITE(pc6001m2_col_bank_w) |
| 1033 | 1113 | AM_RANGE(0xc1, 0xc1) AM_WRITE(pc6001m2_vram_bank_w) |
| 1034 | 1114 | AM_RANGE(0xc2, 0xc2) AM_WRITE(pc6001m2_opt_bank_w) |
| 1035 | | /* 0xe0 / 0xe3 is clearly voice synth related */ |
| 1036 | | AM_RANGE(0xe0, 0xe0) AM_READ(voice_status_r) //AM_WRITE(adpcm_w) |
| 1037 | 1115 | |
| 1116 | AM_RANGE(0xd0, 0xd3) AM_MIRROR(0x0c) AM_NOP // disk device |
| 1117 | |
| 1118 | AM_RANGE(0xe0, 0xe3) AM_MIRROR(0x0c) AM_READWRITE(upd7752_reg_r,upd7752_reg_w) |
| 1119 | |
| 1038 | 1120 | AM_RANGE(0xf0, 0xf0) AM_WRITE(pc6001m2_bank_r0_w) |
| 1039 | 1121 | AM_RANGE(0xf1, 0xf1) AM_WRITE(pc6001m2_bank_r1_w) |
| 1040 | 1122 | AM_RANGE(0xf2, 0xf2) AM_WRITE(pc6001m2_bank_w0_w) |
| 1041 | | AM_RANGE(0xf3, 0xf3) AM_WRITENOP // Chrith writes there on the intro screens, 0xc2 then 0xc7 |
| 1123 | AM_RANGE(0xf3, 0xf3) AM_WRITE(pc6001m2_0xf3_w) |
| 1124 | // AM_RANGE(0xf4 |
| 1125 | // AM_RANGE(0xf5 |
| 1126 | AM_RANGE(0xf6, 0xf6) AM_WRITE(pc6001m2_timer_adj_w) |
| 1127 | AM_RANGE(0xf7, 0xf7) AM_WRITE(pc6001m2_timer_irqv_w) |
| 1042 | 1128 | ADDRESS_MAP_END |
| 1043 | 1129 | |
| 1044 | 1130 | /* Input ports */ |
| r8741 | r8742 | |
| 1367 | 1453 | } |
| 1368 | 1454 | } |
| 1369 | 1455 | |
| 1370 | | static TIMER_CALLBACK(audio_callback) |
| 1371 | | { |
| 1372 | | if(cas_switch == 0) |
| 1373 | | { |
| 1374 | | irq_vector = 0x06; |
| 1375 | | cputag_set_input_line(machine,"maincpu", 0, ASSERT_LINE); |
| 1376 | | } |
| 1377 | | } |
| 1378 | | |
| 1379 | 1456 | static TIMER_CALLBACK(keyboard_callback) |
| 1380 | 1457 | { |
| 1381 | 1458 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| r8741 | r8742 | |
| 1410 | 1487 | |
| 1411 | 1488 | static MACHINE_START(pc6001) |
| 1412 | 1489 | { |
| 1413 | | /* TODO: accurate timing on these (especially for the first one) */ |
| 1414 | | timer_pulse(machine, ATTOTIME_IN_HZ(540), NULL, 0, audio_callback); |
| 1490 | /* TODO: accurate timing on these */ |
| 1415 | 1491 | timer_pulse(machine, ATTOTIME_IN_HZ(250), NULL, 0, keyboard_callback); |
| 1416 | 1492 | timer_pulse(machine, ATTOTIME_IN_HZ(160/4), NULL, 0, cassette_callback); |
| 1493 | |
| 1494 | timer_hz_div = 3; |
| 1495 | { |
| 1496 | attotime period = ATTOTIME_IN_HZ((487.5*4)/(timer_hz_div+1)); |
| 1497 | timer_irq_timer = timer_alloc(machine, audio_callback, NULL); |
| 1498 | timer_adjust_periodic(timer_irq_timer, period, 0, period); |
| 1499 | } |
| 1417 | 1500 | } |
| 1418 | 1501 | |
| 1419 | 1502 | static MACHINE_RESET(pc6001) |
| r8741 | r8742 | |
| 1424 | 1507 | cpu_set_irq_callback(machine->device("maincpu"),pc6001_irq_callback); |
| 1425 | 1508 | cas_switch = 0; |
| 1426 | 1509 | cas_offset = 0; |
| 1510 | timer_irq_mask = 1; |
| 1511 | timer_irq_mask2 = 1; |
| 1512 | timer_irq_vector = 0x06; // actually vector is fixed in plain PC-6001 |
| 1513 | timer_hz_div = 3; |
| 1427 | 1514 | } |
| 1428 | 1515 | |
| 1429 | 1516 | static MACHINE_RESET(pc6001m2) |
| r8741 | r8742 | |
| 1452 | 1539 | bank_w = 0x55; //write to work ram |
| 1453 | 1540 | gfx_bank_on = 0; |
| 1454 | 1541 | } |
| 1542 | |
| 1543 | timer_irq_mask = 1; |
| 1544 | timer_irq_mask2 = 1; |
| 1545 | timer_irq_vector = 0x06; |
| 1455 | 1546 | } |
| 1456 | 1547 | |
| 1457 | 1548 | static const rgb_t defcolors[] = |
| r8741 | r8742 | |
| 1569 | 1660 | |
| 1570 | 1661 | static MACHINE_DRIVER_START( pc6001 ) |
| 1571 | 1662 | /* basic machine hardware */ |
| 1572 | | MDRV_CPU_ADD("maincpu",Z80, 7987200 / 4) |
| 1663 | MDRV_CPU_ADD("maincpu",Z80, 7987200 / 2) // ~4 Mhz |
| 1573 | 1664 | MDRV_CPU_PROGRAM_MAP(pc6001_map) |
| 1574 | 1665 | MDRV_CPU_IO_MAP(pc6001_io) |
| 1575 | 1666 | MDRV_CPU_VBLANK_INT("screen", pc6001_interrupt) |
| r8741 | r8742 | |
| 1642 | 1733 | MDRV_IMPORT_FROM(pc6001m2) |
| 1643 | 1734 | |
| 1644 | 1735 | /* basic machine hardware */ |
| 1645 | | MDRV_CPU_REPLACE("maincpu", Z80, XTAL_3_579545MHz) |
| 1736 | MDRV_CPU_REPLACE("maincpu", Z80, XTAL_3_579545MHz) //*Yes*, PC-6001 SR Z80 CPU is actually slower than older models |
| 1646 | 1737 | MACHINE_DRIVER_END |
| 1647 | 1738 | |
| 1648 | 1739 | /* ROM definition */ |