src/mess/drivers/pc6001.c
| r5917 | r5918 | |
| 1 | | /*************************************************************************** |
| 1 | /********************************************************************************* |
| 2 | 2 | |
| 3 | | NEC PC-6001 series |
| 4 | | NEC PC-6600 series |
| 3 | NEC PC-6001 series |
| 4 | NEC PC-6600 series |
| 5 | 5 | |
| 6 | | 12/05/2009 Skeleton driver. |
| 6 | preliminary driver by Angelo Salese |
| 7 | 7 | |
| 8 | | PC-6001 (1981-09): |
| 8 | TODO: |
| 9 | - Hook up tape loading, images that are floating around the net are already |
| 10 | ADC'ed, so they should be easy to implement (but not exactly faithful) |
| 11 | - Currently rewriting the video part without the MC6847 for two reasons: |
| 12 | A) the later models have a custom video chip in the place of the MC6847, |
| 13 | so this implementation will be used in the end. |
| 14 | B) It's easier to me to see what the attribute vram does since I don't |
| 15 | have any docs atm. |
| 9 | 16 | |
| 10 | | * CPU: Z80A @ 4 MHz |
| 11 | | * ROM: 16KB + 4KB (chargen) - no kanji |
| 12 | | * RAM: 16KB, it can be expanded to 32KB |
| 13 | | * Text Mode: 32x16 and 2 colors |
| 14 | | * Graphic Modes: 64x48 (9 colors), 128x192 (4 colors), 256x192 (2 colors) |
| 15 | | * Sound: BEEP + PSG - Optional Voice Synth Cart |
| 16 | | * Keyboard: JIS Keyboard with 5 function keys, control key, TAB key, |
| 17 | | HOME/CLR key, INS key, DEL key, GRAPH key, Japanese syllabary |
| 18 | | key, page key, STOP key, and cursor key (4 directions) |
| 19 | | * 1 cartslot, optional floppy drive, optional serial 232 port, 2 |
| 20 | | joystick ports |
| 17 | ================================================================================== |
| 21 | 18 | |
| 19 | PC-6001 (1981-09): |
| 22 | 20 | |
| 23 | | PC-6001 mkII (1983-07): |
| 21 | * CPU: Z80A @ 4 MHz |
| 22 | * ROM: 16KB + 4KB (chargen) - no kanji |
| 23 | * RAM: 16KB, it can be expanded to 32KB |
| 24 | * Text Mode: 32x16 and 2 colors |
| 25 | * Graphic Modes: 64x48 (9 colors), 128x192 (4 colors), 256x192 (2 colors) |
| 26 | * Sound: BEEP + PSG - Optional Voice Synth Cart |
| 27 | * Keyboard: JIS Keyboard with 5 function keys, control key, TAB key, |
| 28 | HOME/CLR key, INS key, DEL key, GRAPH key, Japanese syllabary |
| 29 | key, page key, STOP key, and cursor key (4 directions) |
| 30 | * 1 cartslot, optional floppy drive, optional serial 232 port, 2 |
| 31 | joystick ports |
| 24 | 32 | |
| 25 | | * CPU: Z80A @ 4 MHz |
| 26 | | * ROM: 32KB + 16KB (chargen) + 32KB (kanji) + 16KB (Voice Synth) |
| 27 | | * RAM: 64KB |
| 28 | | * Text Mode: same as PC-6001 with N60-BASIC; 40x20 and 15 colors with |
| 29 | | N60M-BASIC |
| 30 | | * Graphic Modes: same as PC-6001 with N60-BASIC; 80x40 (15 colors), |
| 31 | | 160x200 (15 colors), 320x200 (4 colors) with N60M-BASIC |
| 32 | | * Sound: BEEP + PSG |
| 33 | | * Keyboard: JIS Keyboard with 5 function keys, control key, TAB key, |
| 34 | | HOME/CLR key, INS key, DEL key, CAPS key, GRAPH key, Japanese |
| 35 | | syllabary key, page key, mode key, STOP key, and cursor key (4 |
| 36 | | directions) |
| 37 | | * 1 cartslot, floppy drive, optional serial 232 port, 2 joystick ports |
| 38 | 33 | |
| 34 | PC-6001 mkII (1983-07): |
| 39 | 35 | |
| 40 | | PC-6001 mkIISR (1984-12): |
| 36 | * CPU: Z80A @ 4 MHz |
| 37 | * ROM: 32KB + 16KB (chargen) + 32KB (kanji) + 16KB (Voice Synth) |
| 38 | * RAM: 64KB |
| 39 | * Text Mode: same as PC-6001 with N60-BASIC; 40x20 and 15 colors with |
| 40 | N60M-BASIC |
| 41 | * Graphic Modes: same as PC-6001 with N60-BASIC; 80x40 (15 colors), |
| 42 | 160x200 (15 colors), 320x200 (4 colors) with N60M-BASIC |
| 43 | * Sound: BEEP + PSG |
| 44 | * Keyboard: JIS Keyboard with 5 function keys, control key, TAB key, |
| 45 | HOME/CLR key, INS key, DEL key, CAPS key, GRAPH key, Japanese |
| 46 | syllabary key, page key, mode key, STOP key, and cursor key (4 |
| 47 | directions) |
| 48 | * 1 cartslot, floppy drive, optional serial 232 port, 2 joystick ports |
| 41 | 49 | |
| 42 | | * CPU: Z80A @ 3.58 MHz |
| 43 | | * ROM: 64KB + 16KB (chargen) + 32KB (kanji) + 32KB (Voice Synth) |
| 44 | | * RAM: 64KB |
| 45 | | * Text Mode: same as PC-6001/PC-6001mkII with N60-BASIC; 40x20, 40x25, |
| 46 | | 80x20, 80x25 and 15 colors with N66SR-BASIC |
| 47 | | * Graphic Modes: same as PC-6001/PC-6001mkII with N60-BASIC; 80x40 (15 colors), |
| 48 | | 320x200 (15 colors), 640x200 (15 colors) with N66SR-BASIC |
| 49 | | * Sound: BEEP + PSG + FM |
| 50 | | * Keyboard: JIS Keyboard with 5 function keys, control key, TAB key, |
| 51 | | HOME/CLR key, INS key, DEL key, CAPS key, GRAPH key, Japanese |
| 52 | | syllabary key, page key, mode key, STOP key, and cursor key (4 |
| 53 | | directions) |
| 54 | | * 1 cartslot, floppy drive, optional serial 232 port, 2 joystick ports |
| 55 | 50 | |
| 51 | PC-6001 mkIISR (1984-12): |
| 56 | 52 | |
| 53 | * CPU: Z80A @ 3.58 MHz |
| 54 | * ROM: 64KB + 16KB (chargen) + 32KB (kanji) + 32KB (Voice Synth) |
| 55 | * RAM: 64KB |
| 56 | * Text Mode: same as PC-6001/PC-6001mkII with N60-BASIC; 40x20, 40x25, |
| 57 | 80x20, 80x25 and 15 colors with N66SR-BASIC |
| 58 | * Graphic Modes: same as PC-6001/PC-6001mkII with N60-BASIC; 80x40 (15 colors), |
| 59 | 320x200 (15 colors), 640x200 (15 colors) with N66SR-BASIC |
| 60 | * Sound: BEEP + PSG + FM |
| 61 | * Keyboard: JIS Keyboard with 5 function keys, control key, TAB key, |
| 62 | HOME/CLR key, INS key, DEL key, CAPS key, GRAPH key, Japanese |
| 63 | syllabary key, page key, mode key, STOP key, and cursor key (4 |
| 64 | directions) |
| 65 | * 1 cartslot, floppy drive, optional serial 232 port, 2 joystick ports |
| 66 | |
| 67 | |
| 57 | 68 | info from http://www.geocities.jp/retro_zzz/machines/nec/6001/spc60.html |
| 58 | 69 | |
| 59 | | === |
| 70 | ================================================================================== |
| 60 | 71 | |
| 61 | 72 | irq vector 00: writes 0x00 to [$fa19] |
| 62 | 73 | irq vector 02: (A = 0, B = 0) tests ppi port c, does something with ay ports (plus more?) ;keyboard data ready, no kanji lock, no caps lock |
| r5917 | r5918 | |
| 72 | 83 | irq vector 16: tests ppi port c, writes the result to $feca. ;vblank |
| 73 | 84 | |
| 74 | 85 | |
| 75 | | ****************************************************************************/ |
| 86 | *********************************************************************************/ |
| 76 | 87 | |
| 77 | 88 | #include "driver.h" |
| 78 | 89 | #include "cpu/z80/z80.h" |
| r5917 | r5918 | |
| 86 | 97 | static UINT8 irq_vector = 0x00; |
| 87 | 98 | static UINT8 cas_switch,sys_latch; |
| 88 | 99 | |
| 100 | static VIDEO_START( pc6001 ) |
| 101 | { |
| 102 | #if 0 |
| 103 | m6847_config cfg; |
| 104 | |
| 105 | memset(&cfg, 0, sizeof(cfg)); |
| 106 | cfg.type = M6847_VERSION_M6847T1_NTSC; |
| 107 | cfg.get_attributes = pc6001_get_attributes; |
| 108 | cfg.get_video_ram = pc6001_get_video_ram; |
| 109 | cfg.get_char_rom = pc6001_get_char_rom; |
| 110 | m6847_init(machine, &cfg); |
| 111 | #endif |
| 112 | pc6001_video_ram = auto_alloc_array(machine, UINT8, 0x1000); //0x400? We'll see... |
| 113 | } |
| 114 | |
| 115 | static VIDEO_UPDATE( pc6001 ) |
| 116 | { |
| 117 | UINT8 *gfx_data = memory_region(screen->machine, "gfx1"); |
| 118 | int x,y,xi,yi; |
| 119 | int tile,attr,pen,color; |
| 120 | int fgcol; |
| 121 | |
| 122 | for(y=0;y<16;y++) |
| 123 | { |
| 124 | for(x=0;x<32;x++) |
| 125 | { |
| 126 | tile = pc6001_video_ram[(x+(y*32))+0x200]; |
| 127 | attr = pc6001_video_ram[(x+(y*32)) & 0x1ff] ; |
| 128 | |
| 129 | if(attr & 0x40) |
| 130 | { |
| 131 | pen = (tile & 0xc0) >> 6 | (attr & 2)<<1; |
| 132 | |
| 133 | for(yi=0;yi<12;yi++) |
| 134 | { |
| 135 | for(xi=0;xi<8;xi++) |
| 136 | { |
| 137 | int i; |
| 138 | i = (xi & 4)>>2; //x-axis |
| 139 | i+= (yi & 4)>>1; //y-axis 1 |
| 140 | i+= (yi & 8)>>1; //y-axis 2 |
| 141 | |
| 142 | color = ((tile >> i) & 1) ? pen+8 : 0; |
| 143 | |
| 144 | *BITMAP_ADDR16(bitmap, ((y*12+(11-yi))+24), (x*8+(7-xi))+32) = screen->machine->pens[color]; |
| 145 | } |
| 146 | } |
| 147 | } |
| 148 | else |
| 149 | { |
| 150 | for(yi=0;yi<12;yi++) |
| 151 | { |
| 152 | for(xi=0;xi<8;xi++) |
| 153 | { |
| 154 | pen = gfx_data[(tile*0x10)+yi]>>(7-xi) & 1; |
| 155 | |
| 156 | fgcol = (attr & 2) ? 2 : 7; |
| 157 | |
| 158 | if(attr & 1) |
| 159 | color = pen ? 0 : fgcol; |
| 160 | else |
| 161 | color = pen ? fgcol : 0; |
| 162 | |
| 163 | *BITMAP_ADDR16(bitmap, ((y*12+yi)+24), (x*8+xi)+32) = screen->machine->pens[color]; |
| 164 | } |
| 165 | } |
| 166 | } |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | return 0; |
| 171 | } |
| 172 | |
| 89 | 173 | static WRITE8_HANDLER ( pc6001_system_latch_w ) |
| 90 | 174 | { |
| 91 | 175 | UINT16 startaddr[] = {0xC000, 0xE000, 0x8000, 0xA000 }; |
| r5917 | r5918 | |
| 98 | 182 | sys_latch = data; |
| 99 | 183 | } |
| 100 | 184 | |
| 101 | | |
| 185 | #if 0 |
| 102 | 186 | static ATTR_CONST UINT8 pc6001_get_attributes(running_machine *machine, UINT8 c,int scanline, int pos) |
| 103 | 187 | { |
| 104 | 188 | UINT8 result = 0x00; |
| r5917 | r5918 | |
| 107 | 191 | if (val & 0x01) { |
| 108 | 192 | result |= M6847_INV; |
| 109 | 193 | } |
| 110 | | if (!(val & 0x20)) |
| 194 | if (val & 0x40) |
| 111 | 195 | result |= M6847_AG | M6847_GM1; //TODO |
| 112 | 196 | |
| 113 | 197 | result |= M6847_INTEXT; // always use external ROM |
| r5917 | r5918 | |
| 124 | 208 | UINT8 *gfx = memory_region(machine, "gfx1"); |
| 125 | 209 | return gfx[ch*16+line]; |
| 126 | 210 | } |
| 211 | #endif |
| 127 | 212 | |
| 128 | 213 | static UINT8 port_c_8255,cur_keycode; |
| 129 | 214 | |
| r5917 | r5918 | |
| 299 | 384 | return irq_vector; |
| 300 | 385 | } |
| 301 | 386 | |
| 302 | | static VIDEO_START( pc6001 ) |
| 303 | | { |
| 304 | | m6847_config cfg; |
| 305 | | |
| 306 | | memset(&cfg, 0, sizeof(cfg)); |
| 307 | | cfg.type = M6847_VERSION_M6847T1_NTSC; |
| 308 | | cfg.get_attributes = pc6001_get_attributes; |
| 309 | | cfg.get_video_ram = pc6001_get_video_ram; |
| 310 | | cfg.get_char_rom = pc6001_get_char_rom; |
| 311 | | m6847_init(machine, &cfg); |
| 312 | | } |
| 313 | | |
| 314 | | |
| 315 | 387 | static READ8_DEVICE_HANDLER (pc6001_8255_porta_r ) |
| 316 | 388 | { |
| 317 | 389 | return 0; |
| r5917 | r5918 | |
| 400 | 472 | { |
| 401 | 473 | cur_keycode = gfx_data[i++]; |
| 402 | 474 | //popmessage("%04x",i); |
| 403 | | if(i >= 1) |
| 475 | if(i >= 0x34c6) |
| 404 | 476 | { |
| 405 | 477 | i = 0; |
| 406 | 478 | cas_switch = 0; |
| r5917 | r5918 | |
| 440 | 512 | static MACHINE_RESET(pc6001) |
| 441 | 513 | { |
| 442 | 514 | port_c_8255=0; |
| 443 | | pc6001_video_ram = pc6001_ram; |
| 515 | //pc6001_video_ram = pc6001_ram; |
| 444 | 516 | |
| 445 | 517 | cpu_set_irq_callback(cputag_get_cpu(machine, "maincpu"),pc6001_irq_callback); |
| 446 | 518 | timer_pulse(machine, ATTOTIME_IN_HZ(240), NULL, 0, keyboard_callback); |
| 447 | | timer_pulse(machine, ATTOTIME_IN_HZ(100), NULL, 0, cassette_callback); |
| 519 | timer_pulse(machine, ATTOTIME_IN_HZ(160), NULL, 0, cassette_callback); |
| 448 | 520 | cas_switch = 0; |
| 449 | 521 | } |
| 450 | 522 | |
| 523 | static const rgb_t defcolors[] = |
| 524 | { |
| 525 | MAKE_RGB(0x00, 0xff, 0x00), /* GREEN */ |
| 526 | MAKE_RGB(0xff, 0xff, 0x00), /* YELLOW */ |
| 527 | MAKE_RGB(0x00, 0x00, 0xff), /* BLUE */ |
| 528 | MAKE_RGB(0xff, 0x00, 0x00), /* RED */ |
| 529 | MAKE_RGB(0xff, 0xff, 0xff), /* BUFF */ |
| 530 | MAKE_RGB(0x00, 0xff, 0xff), /* CYAN */ |
| 531 | MAKE_RGB(0xff, 0x00, 0xff), /* MAGENTA */ |
| 532 | MAKE_RGB(0xff, 0x80, 0x00) /* ORANGE */ |
| 533 | }; |
| 451 | 534 | |
| 535 | static PALETTE_INIT(pc6001) |
| 536 | { |
| 537 | int i; |
| 538 | |
| 539 | for(i=0;i<8;i++) |
| 540 | palette_set_color(machine, i+8,defcolors[i]); |
| 541 | } |
| 542 | |
| 543 | |
| 452 | 544 | static MACHINE_DRIVER_START( pc6001 ) |
| 453 | 545 | /* basic machine hardware */ |
| 454 | 546 | MDRV_CPU_ADD("maincpu",Z80, 7987200 /2) |
| r5917 | r5918 | |
| 462 | 554 | |
| 463 | 555 | /* video hardware */ |
| 464 | 556 | MDRV_SCREEN_ADD("screen", RASTER) |
| 465 | | MDRV_SCREEN_REFRESH_RATE(M6847_NTSC_FRAMES_PER_SECOND) |
| 557 | MDRV_SCREEN_REFRESH_RATE(60) |
| 466 | 558 | MDRV_VIDEO_START(pc6001) |
| 467 | | MDRV_VIDEO_UPDATE(m6847) |
| 468 | | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32) |
| 559 | MDRV_VIDEO_UPDATE(pc6001) |
| 560 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 561 | // MDRV_SCREEN_REFRESH_RATE(M6847_NTSC_FRAMES_PER_SECOND) |
| 562 | // MDRV_VIDEO_UPDATE(m6847) |
| 563 | // MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32) |
| 469 | 564 | MDRV_SCREEN_SIZE(320, 25+192+26) |
| 470 | 565 | MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239) |
| 566 | MDRV_PALETTE_LENGTH(16) |
| 567 | MDRV_PALETTE_INIT(pc6001) |
| 471 | 568 | |
| 472 | 569 | MDRV_I8255A_ADD( "ppi8255", pc6001_ppi8255_interface ) |
| 473 | 570 | /* uart */ |
| r5917 | r5918 | |
| 495 | 592 | ROM_LOAD( "cgrom60.60", 0x0000, 0x1000, CRC(b0142d32) SHA1(9570495b10af5b1785802681be94b0ea216a1e26) ) |
| 496 | 593 | |
| 497 | 594 | ROM_REGION( 0x10000, "cas", ROMREGION_ERASEFF ) |
| 498 | | // ROM_LOAD( "ax7 demo.cas", 0x0000, 0x2ef1, CRC(1) SHA1(1) ) |
| 595 | /* Load here your tape for now (and change line 475 with the length value that MESS returns) */ |
| 596 | //ROM_LOAD( "demo.cas", 0x0000, 0x34c6, CRC(1) SHA1(1) ) |
| 499 | 597 | ROM_END |
| 500 | 598 | |
| 501 | 599 | ROM_START( pc6001a ) |