src/mess/drivers/pc6001.c
| r8756 | r8757 | |
| 12 | 12 | it's not worth the effort... |
| 13 | 13 | - Identify and hook-up the FDC device, apparently PC-6001 and PC-6600 doesn't even use the same thing; |
| 14 | 14 | - PC-6600: mon r-0 type games doesn't seem to work at all on this version? |
| 15 | - PC-6001SR: get it to boot, also implement MK-2 compatibility mode (it changes the memory map to behave like the older versions) |
| 15 | 16 | - Currently rewriting the video part without the MC6847 for two reasons: |
| 16 | 17 | A) the later models have a custom video chip in the place of the MC6847, |
| 17 | 18 | so this implementation will be used in the end. |
| r8756 | r8757 | |
| 146 | 147 | static UINT8 bank_r0,bank_r1,gfx_bank_on,bank_w,bank_opt; |
| 147 | 148 | static UINT8 timer_irq_mask2, timer_irq_vector; |
| 148 | 149 | static UINT32 cgrom_bank_addr; |
| 150 | /* PC6001SR specific */ |
| 151 | static UINT8 sr_video_mode; |
| 149 | 152 | |
| 150 | 153 | #define IRQ_LOG (0) |
| 151 | 154 | |
| r8756 | r8757 | |
| 536 | 539 | int xi,yi,pen,fgcol,bgcol,color; |
| 537 | 540 | UINT8 *gfx_data = memory_region(screen->machine, "gfx1"); |
| 538 | 541 | |
| 539 | | for(y=0;y<20;y++) |
| 542 | |
| 543 | if(sr_video_mode & 8) // text mode |
| 540 | 544 | { |
| 541 | | for(x=0;x<40;x++) |
| 545 | for(y=0;y<20;y++) |
| 542 | 546 | { |
| 543 | | tile = pc6001_video_ram[(x+(y*40))*2+0]; |
| 544 | | attr = pc6001_video_ram[(x+(y*40))*2+1]; |
| 545 | | tile+= ((attr & 0x80) << 1); |
| 547 | for(x=0;x<40;x++) |
| 548 | { |
| 549 | tile = pc6001_video_ram[(x+(y*40))*2+0]; |
| 550 | attr = pc6001_video_ram[(x+(y*40))*2+1]; |
| 551 | tile+= ((attr & 0x80) << 1); |
| 546 | 552 | |
| 547 | | for(yi=0;yi<12;yi++) |
| 548 | | { |
| 549 | | for(xi=0;xi<8;xi++) |
| 553 | for(yi=0;yi<12;yi++) |
| 550 | 554 | { |
| 551 | | pen = gfx_data[(tile*0x10)+yi]>>(7-xi) & 1; |
| 555 | for(xi=0;xi<8;xi++) |
| 556 | { |
| 557 | pen = gfx_data[(tile*0x10)+yi]>>(7-xi) & 1; |
| 552 | 558 | |
| 553 | | fgcol = (attr & 0x0f) + 0x10; |
| 554 | | bgcol = ((attr & 0x70) >> 4) + 0x10 + ((bgcol_bank & 2) << 2); |
| 559 | fgcol = (attr & 0x0f) + 0x10; |
| 560 | bgcol = ((attr & 0x70) >> 4) + 0x10 + ((bgcol_bank & 2) << 2); |
| 555 | 561 | |
| 556 | | color = pen ? fgcol : bgcol; |
| 562 | color = pen ? fgcol : bgcol; |
| 557 | 563 | |
| 558 | | if ((x*8+xi) <= screen->visible_area().max_x && (y*12+yi) <= screen->visible_area().max_y) |
| 559 | | *BITMAP_ADDR16(bitmap, ((y*12+yi)), (x*8+xi)) = screen->machine->pens[color]; |
| 564 | if ((x*8+xi) <= screen->visible_area().max_x && (y*12+yi) <= screen->visible_area().max_y) |
| 565 | *BITMAP_ADDR16(bitmap, ((y*12+yi)), (x*8+xi)) = screen->machine->pens[color]; |
| 566 | } |
| 560 | 567 | } |
| 561 | 568 | } |
| 562 | 569 | } |
| 563 | 570 | } |
| 571 | else //4bpp bitmap mode (TODO) |
| 572 | { |
| 573 | int count; |
| 564 | 574 | |
| 575 | count = 0; |
| 576 | |
| 577 | for(y=0;y<200;y+=2) |
| 578 | { |
| 579 | for(x=0;x<320;x+=4) |
| 580 | { |
| 581 | color = pc6001_video_ram[count] & 0x0f; |
| 582 | |
| 583 | if ((x+0) <= screen->visible_area().max_x && (y+0) <= screen->visible_area().max_y) |
| 584 | *BITMAP_ADDR16(bitmap, (y+0), (x+0)) = screen->machine->pens[color+0x10]; |
| 585 | |
| 586 | color = (pc6001_video_ram[count] & 0xf0) >> 4; |
| 587 | |
| 588 | if ((x+1) <= screen->visible_area().max_x && (y+0) <= screen->visible_area().max_y) |
| 589 | *BITMAP_ADDR16(bitmap, (y+0), (x+1)) = screen->machine->pens[color+0x10]; |
| 590 | |
| 591 | color = pc6001_video_ram[count+1] & 0x0f; |
| 592 | |
| 593 | if ((x+2) <= screen->visible_area().max_x && (y+0) <= screen->visible_area().max_y) |
| 594 | *BITMAP_ADDR16(bitmap, (y+0), (x+2)) = screen->machine->pens[color+0x10]; |
| 595 | |
| 596 | color = (pc6001_video_ram[count+1] & 0xf0) >> 4; |
| 597 | |
| 598 | if ((x+3) <= screen->visible_area().max_x && (y+0) <= screen->visible_area().max_y) |
| 599 | *BITMAP_ADDR16(bitmap, (y+0), (x+3)) = screen->machine->pens[color+0x10]; |
| 600 | |
| 601 | color = pc6001_video_ram[count+2] & 0x0f; |
| 602 | |
| 603 | if ((x+0) <= screen->visible_area().max_x && (y+1) <= screen->visible_area().max_y) |
| 604 | *BITMAP_ADDR16(bitmap, (y+1), (x+0)) = screen->machine->pens[color+0x10]; |
| 605 | |
| 606 | color = (pc6001_video_ram[count+2] & 0xf0) >> 4; |
| 607 | |
| 608 | if ((x+1) <= screen->visible_area().max_x && (y+1) <= screen->visible_area().max_y) |
| 609 | *BITMAP_ADDR16(bitmap, (y+1), (x+1)) = screen->machine->pens[color+0x10]; |
| 610 | |
| 611 | color = pc6001_video_ram[count+3] & 0x0f; |
| 612 | |
| 613 | if ((x+2) <= screen->visible_area().max_x && (y+1) <= screen->visible_area().max_y) |
| 614 | *BITMAP_ADDR16(bitmap, (y+1), (x+2)) = screen->machine->pens[color+0x10]; |
| 615 | |
| 616 | color = (pc6001_video_ram[count+3] & 0xf0) >> 4; |
| 617 | |
| 618 | if ((x+3) <= screen->visible_area().max_x && (y+1) <= screen->visible_area().max_y) |
| 619 | *BITMAP_ADDR16(bitmap, (y+1), (x+3)) = screen->machine->pens[color+0x10]; |
| 620 | |
| 621 | |
| 622 | count+=4; |
| 623 | } |
| 624 | } |
| 625 | } |
| 626 | |
| 565 | 627 | return 0; |
| 566 | 628 | } |
| 567 | 629 | |
| r8756 | r8757 | |
| 1337 | 1399 | ROM[offset+(SR_EXRAM0(bank_num))] = data; \ |
| 1338 | 1400 | } \ |
| 1339 | 1401 | |
| 1340 | | |
| 1341 | 1402 | static WRITE8_HANDLER( sr_work_ram0_w ) { SR_WRAM_BANK_W(0); } |
| 1342 | 1403 | static WRITE8_HANDLER( sr_work_ram1_w ) { SR_WRAM_BANK_W(1); } |
| 1343 | 1404 | static WRITE8_HANDLER( sr_work_ram2_w ) { SR_WRAM_BANK_W(2); } |
| r8756 | r8757 | |
| 1349 | 1410 | |
| 1350 | 1411 | static WRITE8_HANDLER( pc6001sr_mode_w ) |
| 1351 | 1412 | { |
| 1413 | sr_video_mode = data; |
| 1414 | |
| 1352 | 1415 | if(data & 1) |
| 1353 | 1416 | assert("PC-6001SR in Mk-2 compatibility mode not yet supported!\n"); |
| 1354 | 1417 | } |
| r8756 | r8757 | |
| 1360 | 1423 | pc6001_video_ram = work_ram + 0x70000 + ((data & 0x0f)*0x1000); |
| 1361 | 1424 | } |
| 1362 | 1425 | |
| 1426 | static WRITE8_HANDLER ( pc6001sr_system_latch_w ) |
| 1427 | { |
| 1428 | if((!(sys_latch & 8)) && data & 0x8) //PLAY tape cmd |
| 1429 | { |
| 1430 | cas_switch = 1; |
| 1431 | //cassette_change_state(space->machine->device("cass" ),CASSETTE_MOTOR_ENABLED,CASSETTE_MASK_MOTOR); |
| 1432 | //cassette_change_state(space->machine->device("cass" ),CASSETTE_PLAY,CASSETTE_MASK_UISTATE); |
| 1433 | } |
| 1434 | if((sys_latch & 8) && ((data & 0x8) == 0)) //STOP tape cmd |
| 1435 | { |
| 1436 | cas_switch = 0; |
| 1437 | //cassette_change_state(space->machine->device("cass" ),CASSETTE_MOTOR_DISABLED,CASSETTE_MASK_MOTOR); |
| 1438 | //cassette_change_state(space->machine->device("cass" ),CASSETTE_STOPPED,CASSETTE_MASK_UISTATE); |
| 1439 | //irq_vector = 0x00; |
| 1440 | //cputag_set_input_line(space->machine,"maincpu", 0, ASSERT_LINE); |
| 1441 | } |
| 1442 | |
| 1443 | sys_latch = data; |
| 1444 | |
| 1445 | timer_irq_mask = data & 1; |
| 1446 | //vram_bank_change(space->machine,(ex_vram_bank & 0x06) | ((sys_latch & 0x06) << 4)); |
| 1447 | |
| 1448 | //printf("%02x B0\n",data); |
| 1449 | } |
| 1450 | |
| 1451 | static WRITE8_DEVICE_HANDLER(necsr_ppi8255_w) |
| 1452 | { |
| 1453 | if (offset==3) |
| 1454 | { |
| 1455 | if(data & 1) |
| 1456 | port_c_8255 |= 1<<((data>>1)&0x07); |
| 1457 | else |
| 1458 | port_c_8255 &= ~(1<<((data>>1)&0x07)); |
| 1459 | |
| 1460 | switch(data) { |
| 1461 | case 0x08: port_c_8255 |= 0x88; break; |
| 1462 | case 0x09: port_c_8255 &= 0xf7; break; |
| 1463 | case 0x0c: port_c_8255 |= 0x28; break; |
| 1464 | case 0x0d: port_c_8255 &= 0xf7; break; |
| 1465 | default: break; |
| 1466 | } |
| 1467 | |
| 1468 | port_c_8255 |= 0xa8; |
| 1469 | |
| 1470 | if(0) |
| 1471 | { |
| 1472 | UINT8 *gfx_data = memory_region(device->machine, "gfx1"); |
| 1473 | UINT8 *ext_rom = memory_region(device->machine, "cart_img"); |
| 1474 | |
| 1475 | //printf("%02x\n",data); |
| 1476 | |
| 1477 | if((data & 0x0f) == 0x05) |
| 1478 | memory_set_bankptr(device->machine, "bank1", &ext_rom[0x2000]); |
| 1479 | if((data & 0x0f) == 0x04) |
| 1480 | memory_set_bankptr(device->machine, "bank1", &gfx_data[0]); |
| 1481 | } |
| 1482 | } |
| 1483 | i8255a_w(device,offset,data); |
| 1484 | } |
| 1485 | |
| 1486 | |
| 1363 | 1487 | static ADDRESS_MAP_START(pc6001sr_map, ADDRESS_SPACE_PROGRAM, 8) |
| 1364 | 1488 | ADDRESS_MAP_UNMAP_HIGH |
| 1365 | 1489 | AM_RANGE(0x0000, 0x1fff) AM_ROMBANK("bank1") AM_WRITE(sr_work_ram0_w) |
| r8756 | r8757 | |
| 1380 | 1504 | AM_RANGE(0x80, 0x80) AM_DEVREADWRITE("uart", msm8251_data_r,msm8251_data_w) |
| 1381 | 1505 | AM_RANGE(0x81, 0x81) AM_DEVREADWRITE("uart", msm8251_status_r,msm8251_control_w) |
| 1382 | 1506 | |
| 1383 | | AM_RANGE(0x90, 0x93) AM_MIRROR(0x0c) AM_DEVREADWRITE("ppi8255", nec_ppi8255_r, necmk2_ppi8255_w) |
| 1507 | AM_RANGE(0x90, 0x93) AM_MIRROR(0x0c) AM_DEVREADWRITE("ppi8255", nec_ppi8255_r, necsr_ppi8255_w) |
| 1384 | 1508 | |
| 1385 | 1509 | AM_RANGE(0xa0, 0xa0) AM_MIRROR(0x0c) AM_DEVWRITE("ay8910", ay8910_address_w) |
| 1386 | 1510 | AM_RANGE(0xa1, 0xa1) AM_MIRROR(0x0c) AM_DEVWRITE("ay8910", ay8910_data_w) |
| 1387 | 1511 | AM_RANGE(0xa2, 0xa2) AM_MIRROR(0x0c) AM_DEVREAD("ay8910", ay8910_r) |
| 1388 | 1512 | AM_RANGE(0xa3, 0xa3) AM_MIRROR(0x0c) AM_NOP |
| 1389 | 1513 | |
| 1390 | | AM_RANGE(0xb0, 0xb0) AM_WRITE(pc6001m2_system_latch_w) |
| 1514 | AM_RANGE(0xb0, 0xb0) AM_WRITE(pc6001sr_system_latch_w) |
| 1391 | 1515 | /* these are disk related */ |
| 1392 | 1516 | // AM_RANGE(0xb1 |
| 1393 | 1517 | // AM_RANGE(0xb2 |
| r8756 | r8757 | |
| 1569 | 1693 | cpu_set_input_line(device, 0, ASSERT_LINE); |
| 1570 | 1694 | } |
| 1571 | 1695 | |
| 1696 | static INTERRUPT_GEN( pc6001sr_interrupt ) |
| 1697 | { |
| 1698 | static UINT8 kludge; |
| 1699 | |
| 1700 | kludge^= 1; |
| 1701 | |
| 1702 | cur_keycode = check_joy_press(device->machine); |
| 1703 | if(IRQ_LOG) printf("VRTC IRQ called 0x16\n"); |
| 1704 | irq_vector = (kludge) ? 0x22 : 0x16; |
| 1705 | cpu_set_input_line(device, 0, ASSERT_LINE); |
| 1706 | } |
| 1707 | |
| 1572 | 1708 | static IRQ_CALLBACK ( pc6001_irq_callback ) |
| 1573 | 1709 | { |
| 1574 | 1710 | cpu_set_input_line(device, 0, CLEAR_LINE); |
| r8756 | r8757 | |
| 2110 | 2246 | MDRV_CPU_REPLACE("maincpu", Z80, XTAL_3_579545MHz) //*Yes*, PC-6001 SR Z80 CPU is actually slower than older models |
| 2111 | 2247 | MDRV_CPU_PROGRAM_MAP(pc6001sr_map) |
| 2112 | 2248 | MDRV_CPU_IO_MAP(pc6001sr_io) |
| 2113 | | MDRV_CPU_VBLANK_INT("screen", pc6001_interrupt) |
| 2249 | MDRV_CPU_VBLANK_INT("screen", pc6001sr_interrupt) |
| 2114 | 2250 | MACHINE_DRIVER_END |
| 2115 | 2251 | |
| 2116 | 2252 | /* ROM definition */ |