src/mess/drivers/pc9801.c
| r0 | r10336 | |
| 1 | /*************************************************************************************************** |
| 2 | |
| 3 | PC-9801 (c) 1981 NEC |
| 4 | |
| 5 | fork / rewrite from pc98.c, contents of that file will be moved to here once that things gets |
| 6 | consolidated there. |
| 7 | |
| 8 | preliminary driver by Angelo Salese |
| 9 | |
| 10 | TODO: |
| 11 | - floppy interface doesn't seem to work at all with either floppy inserted or not, missing DMA irq? |
| 12 | - proper 8251 uart hook-up on keyboard |
| 13 | - boot is too slow right now, might be due of the floppy / HDD devices |
| 14 | |
| 15 | ****************************************************************************************************/ |
| 16 | |
| 17 | #include "emu.h" |
| 18 | #include "cpu/i86/i86.h" |
| 19 | #include "machine/i8255a.h" |
| 20 | #include "machine/pit8253.h" |
| 21 | #include "machine/8237dma.h" |
| 22 | #include "machine/pic8259.h" |
| 23 | #include "machine/upd765.h" |
| 24 | #include "sound/beep.h" |
| 25 | #include "imagedev/flopdrv.h" |
| 26 | |
| 27 | //#define LOAD_2dd_BIOS //compile switch, disabled because system gives black screen otherwise |
| 28 | |
| 29 | class pc9801_state : public driver_device |
| 30 | { |
| 31 | public: |
| 32 | pc9801_state(running_machine &machine, const driver_device_config_base &config) |
| 33 | : driver_device(machine, config) { } |
| 34 | |
| 35 | UINT8 portb_tmp; |
| 36 | int dma_channel; |
| 37 | UINT8 dma_offset[2][4]; |
| 38 | UINT8 at_pages[0x10]; |
| 39 | |
| 40 | UINT8 vrtc_irq_mask; |
| 41 | UINT8 video_ff[8]; |
| 42 | UINT8 pal_clut[4]; |
| 43 | |
| 44 | UINT16 *tvram; |
| 45 | |
| 46 | UINT16 font_addr; |
| 47 | UINT8 font_line; |
| 48 | UINT16 font_lr; |
| 49 | |
| 50 | UINT8 keyb_press; |
| 51 | |
| 52 | UINT8 fdc_2dd_ctrl; |
| 53 | }; |
| 54 | |
| 55 | |
| 56 | |
| 57 | #define WIDTH40_REG 2 |
| 58 | #define MEMSW_REG 6 |
| 59 | #define DISPLAY_REG 7 |
| 60 | |
| 61 | static VIDEO_START( pc9801 ) |
| 62 | { |
| 63 | pc9801_state *state = machine->driver_data<pc9801_state>(); |
| 64 | |
| 65 | state->tvram = auto_alloc_array(machine, UINT16, 0x2000*2); |
| 66 | } |
| 67 | |
| 68 | static VIDEO_UPDATE( pc9801 ) |
| 69 | { |
| 70 | pc9801_state *state = screen->machine->driver_data<pc9801_state>(); |
| 71 | int x,y; |
| 72 | int xi,yi; |
| 73 | UINT8 *gfx_rom = screen->machine->region("chargen")->base(); |
| 74 | int x_width; |
| 75 | |
| 76 | bitmap_fill(bitmap, cliprect, screen->machine->pens[8]); |
| 77 | |
| 78 | if(state->video_ff[DISPLAY_REG] == 0) //screen is off |
| 79 | return 0; |
| 80 | |
| 81 | x_width = state->video_ff[WIDTH40_REG] ? 40 : 80; |
| 82 | |
| 83 | for(y=0;y<25;y++) |
| 84 | { |
| 85 | for(x=0;x<x_width;x++) |
| 86 | { |
| 87 | UINT8 tile,attr,pen; |
| 88 | UINT8 secret,reverse,color,u_line,v_line; |
| 89 | |
| 90 | tile = state->tvram[(x+y*x_width)*(state->video_ff[WIDTH40_REG]+1)] & 0xff; |
| 91 | attr = state->tvram[(x+y*x_width)*(state->video_ff[WIDTH40_REG]+1)+0x1000] & 0xff; |
| 92 | secret = (attr & 1) ^ 1; |
| 93 | //blink = attr & 2; |
| 94 | reverse = attr & 4; |
| 95 | u_line = attr & 8; |
| 96 | v_line = attr & 0x10; |
| 97 | color = (attr & 0xe0) >> 5; |
| 98 | |
| 99 | for(yi=0;yi<8;yi++) |
| 100 | { |
| 101 | for(xi=0;xi<8;xi++) |
| 102 | { |
| 103 | int res_x,res_y; |
| 104 | UINT8 tile_data; |
| 105 | |
| 106 | res_x = (x*8+xi)*(state->video_ff[WIDTH40_REG]+1); |
| 107 | res_y = y*8+yi; |
| 108 | |
| 109 | if((res_x)>screen->machine->primary_screen->visible_area().max_x || (res_y)>screen->machine->primary_screen->visible_area().max_y) |
| 110 | continue; |
| 111 | |
| 112 | tile_data = secret ? 0 : (gfx_rom[tile*8+yi]); |
| 113 | |
| 114 | if(reverse) { tile_data^=0xff; } |
| 115 | if(u_line && yi == 7) { tile_data = 0xff; } |
| 116 | if(v_line) { tile_data|=8; } |
| 117 | |
| 118 | pen = (tile_data >> (7-xi) & 1) ? color : 0; |
| 119 | |
| 120 | *BITMAP_ADDR16(bitmap, res_y, res_x) = screen->machine->pens[pen]; |
| 121 | if(state->video_ff[WIDTH40_REG]) |
| 122 | { |
| 123 | if((res_x+1)>screen->machine->primary_screen->visible_area().max_x || (res_y)>screen->machine->primary_screen->visible_area().max_y) |
| 124 | continue; |
| 125 | |
| 126 | *BITMAP_ADDR16(bitmap, res_y, res_x+1) = screen->machine->pens[pen]; |
| 127 | } |
| 128 | } |
| 129 | } |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | return 0; |
| 134 | } |
| 135 | |
| 136 | #if 0 |
| 137 | static READ8_HANDLER( pc9801_xx_r ) |
| 138 | { |
| 139 | if((offset & 1) == 0) |
| 140 | { |
| 141 | printf("Read to undefined port [%02x]\n",offset+0xxx); |
| 142 | return 0xff; |
| 143 | } |
| 144 | else // odd |
| 145 | { |
| 146 | printf("Read to undefined port [%02x]\n",offset+0xxx); |
| 147 | return 0xff; |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | static WRITE8_HANDLER( pc9801_xx_w ) |
| 152 | { |
| 153 | if((offset & 1) == 0) |
| 154 | { |
| 155 | printf("Write to undefined port [%02x] <- %02x\n",offset+0xxx,data); |
| 156 | } |
| 157 | else // odd |
| 158 | { |
| 159 | printf("Write to undefined port [%02x] <- %02x\n",offset+0xxx,data); |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | #endif |
| 164 | |
| 165 | static READ8_HANDLER( pc9801_00_r ) |
| 166 | { |
| 167 | if((offset & 1) == 0) |
| 168 | { |
| 169 | if(offset & 0x14) |
| 170 | printf("Read to undefined port [%02x]\n",offset+0x00); |
| 171 | else |
| 172 | return pic8259_r(space->machine->device((offset & 8) ? "pic8259_slave" : "pic8259_master"), (offset & 2) >> 1); |
| 173 | } |
| 174 | else // odd |
| 175 | { |
| 176 | return i8237_r(space->machine->device("dma8237"), (offset & 0x1e) >> 1); |
| 177 | } |
| 178 | |
| 179 | return 0xff; |
| 180 | } |
| 181 | |
| 182 | static WRITE8_HANDLER( pc9801_00_w ) |
| 183 | { |
| 184 | if((offset & 1) == 0) |
| 185 | { |
| 186 | if(offset & 0x14) |
| 187 | printf("Write to undefined port [%02x] <- %02x\n",offset+0x00,data); |
| 188 | else |
| 189 | pic8259_w(space->machine->device((offset & 8) ? "pic8259_slave" : "pic8259_master"), (offset & 2) >> 1, data); |
| 190 | } |
| 191 | else // odd |
| 192 | { |
| 193 | i8237_w(space->machine->device("dma8237"), (offset & 0x1e) >> 1, data); |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | static READ8_HANDLER( pc9801_30_r ) |
| 198 | { |
| 199 | if((offset & 1) == 0) |
| 200 | { |
| 201 | if(offset & 4) |
| 202 | printf("Read to undefined port [%02x]\n",offset+0x30); |
| 203 | else |
| 204 | printf("Read to RS-232c port [%02x]\n",offset+0x30); |
| 205 | |
| 206 | return 0xff; |
| 207 | } |
| 208 | else // odd |
| 209 | { |
| 210 | return i8255a_r(space->machine->device("ppi8255_sys"), (offset & 6) >> 1); |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | static WRITE8_HANDLER( pc9801_30_w ) |
| 215 | { |
| 216 | if((offset & 1) == 0) |
| 217 | { |
| 218 | if(offset & 4) |
| 219 | printf("Write to undefined port [%02x] %02x\n",offset+0x30,data); |
| 220 | else |
| 221 | printf("Write to RS-232c port [%02x] %02x\n",offset+0x30,data); |
| 222 | } |
| 223 | else // odd |
| 224 | { |
| 225 | i8255a_w(space->machine->device("ppi8255_sys"), (offset & 6) >> 1,data); |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | static READ8_HANDLER( pc9801_40_r ) |
| 230 | { |
| 231 | pc9801_state *state = space->machine->driver_data<pc9801_state>(); |
| 232 | |
| 233 | if((offset & 1) == 0) |
| 234 | { |
| 235 | return i8255a_r(space->machine->device("ppi8255_prn"), (offset & 6) >> 1); |
| 236 | } |
| 237 | else // odd |
| 238 | { |
| 239 | if(offset & 4) |
| 240 | printf("Read to undefined port [%02x]\n",offset+0x40); |
| 241 | else |
| 242 | { |
| 243 | //printf("Read to 8251 kbd port [%02x]\n",offset+0x40); |
| 244 | if(offset == 1) |
| 245 | { |
| 246 | UINT8 res; |
| 247 | |
| 248 | res = state->keyb_press; |
| 249 | |
| 250 | return res; |
| 251 | } |
| 252 | |
| 253 | return 0; |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | return 0xff; |
| 258 | } |
| 259 | |
| 260 | static WRITE8_HANDLER( pc9801_40_w ) |
| 261 | { |
| 262 | if((offset & 1) == 0) |
| 263 | { |
| 264 | i8255a_w(space->machine->device("ppi8255_prn"), (offset & 6) >> 1,data); |
| 265 | } |
| 266 | else // odd |
| 267 | { |
| 268 | if(offset & 4) |
| 269 | printf("Write to undefined port [%02x] <- %02x\n",offset+0x40,data); |
| 270 | //else |
| 271 | //printf("Write to 8251 kbd port [%02x] <- %02x\n",offset+0x40,data); |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | static READ8_HANDLER( pc9801_50_r ) |
| 276 | { |
| 277 | //pc9801_state *state = space->machine->driver_data<pc9801_state>(); |
| 278 | |
| 279 | if((offset & 1) == 0) |
| 280 | { |
| 281 | if(offset & 4) |
| 282 | printf("Read to undefined port [%02x]\n",offset+0x50); |
| 283 | else |
| 284 | printf("Read to NMI FF port [%02x]\n",offset+0x50); |
| 285 | |
| 286 | return 0xff; |
| 287 | } |
| 288 | else // odd |
| 289 | { |
| 290 | return i8255a_r(space->machine->device("ppi8255_fdd"), (offset & 6) >> 1); |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | static WRITE8_HANDLER( pc9801_50_w ) |
| 295 | { |
| 296 | if((offset & 1) == 0) |
| 297 | { |
| 298 | if(offset & 4) |
| 299 | printf("Write to undefined port [%02x] %02x\n",offset+0x50,data); |
| 300 | else |
| 301 | printf("Write to NMI FF port [%02x] %02x\n",offset+0x50,data); |
| 302 | } |
| 303 | else // odd |
| 304 | { |
| 305 | i8255a_w(space->machine->device("ppi8255_fdd"), (offset & 6) >> 1,data); |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | static READ8_HANDLER( pc9801_60_r ) |
| 310 | { |
| 311 | if((offset & 1) == 0) |
| 312 | { |
| 313 | UINT8 vsync = input_port_read(space->machine, "VBLANK") & 0x20; |
| 314 | |
| 315 | return 4 | vsync; // upd7220 character port |
| 316 | } |
| 317 | else // odd |
| 318 | { |
| 319 | printf("Read to undefined port [%02x]\n",offset+0x60); |
| 320 | return 0xff; |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | static WRITE8_HANDLER( pc9801_60_w ) |
| 325 | { |
| 326 | if((offset & 1) == 0) |
| 327 | { |
| 328 | // upd7220 character ports |
| 329 | } |
| 330 | else // odd |
| 331 | { |
| 332 | printf("Write to undefined port [%02x] <- %02x\n",offset+0x60,data); |
| 333 | } |
| 334 | } |
| 335 | |
| 336 | static WRITE8_HANDLER( pc9801_vrtc_mask_w ) |
| 337 | { |
| 338 | pc9801_state *state = space->machine->driver_data<pc9801_state>(); |
| 339 | |
| 340 | if((offset & 1) == 0) |
| 341 | { |
| 342 | state->vrtc_irq_mask = 1; |
| 343 | } |
| 344 | else // odd |
| 345 | { |
| 346 | printf("Write to undefined port [%02x] <- %02x\n",offset+0x64,data); |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | static WRITE8_HANDLER( pc9801_video_ff_w ) |
| 351 | { |
| 352 | pc9801_state *state = space->machine->driver_data<pc9801_state>(); |
| 353 | |
| 354 | if((offset & 1) == 0) |
| 355 | { |
| 356 | state->video_ff[(data & 0x0e) >> 1] = data & 1; |
| 357 | |
| 358 | if(0) |
| 359 | { |
| 360 | static const char *const video_ff_regnames[] = |
| 361 | { |
| 362 | "Attribute Select", // 0 |
| 363 | "Graphic", // 1 |
| 364 | "Column", // 2 |
| 365 | "Font Select", // 3 |
| 366 | "200 lines", // 4 |
| 367 | "KAC?", // 5 |
| 368 | "Memory Switch", // 6 |
| 369 | "Display ON" // 7 |
| 370 | }; |
| 371 | |
| 372 | printf("Write to video FF register %s -> %02x\n",video_ff_regnames[(data & 0x0e) >> 1],data & 1); |
| 373 | } |
| 374 | } |
| 375 | else // odd |
| 376 | { |
| 377 | printf("Write to undefined port [%02x] <- %02x\n",offset+0x68,data); |
| 378 | } |
| 379 | } |
| 380 | |
| 381 | |
| 382 | static READ8_HANDLER( pc9801_70_r ) |
| 383 | { |
| 384 | if((offset & 1) == 0) |
| 385 | { |
| 386 | printf("Read to display register [%02x]\n",offset+0x70); |
| 387 | return 0xff; |
| 388 | } |
| 389 | else // odd |
| 390 | { |
| 391 | if(offset & 0x08) |
| 392 | printf("Read to undefined port [%02x]\n",offset+0x70); |
| 393 | else |
| 394 | return pit8253_r(space->machine->device("pit8253"), (offset & 6) >> 1); |
| 395 | } |
| 396 | |
| 397 | return 0xff; |
| 398 | } |
| 399 | |
| 400 | static WRITE8_HANDLER( pc9801_70_w ) |
| 401 | { |
| 402 | if((offset & 1) == 0) |
| 403 | { |
| 404 | printf("Write to display register [%02x] %02x\n",offset+0x70,data); |
| 405 | } |
| 406 | else // odd |
| 407 | { |
| 408 | if(offset < 0x08) |
| 409 | pit8253_w(space->machine->device("pit8253"), (offset & 6) >> 1, data); |
| 410 | else |
| 411 | printf("Write to undefined port [%02x] <- %02x\n",offset+0x70,data); |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | static READ8_HANDLER( pc9801_sasi_r ) |
| 416 | { |
| 417 | if((offset & 1) == 0) |
| 418 | { |
| 419 | //printf("Read to undefined port [%02x]\n",offset+0xxx); |
| 420 | return 0; |
| 421 | } |
| 422 | else // odd |
| 423 | { |
| 424 | printf("Read to undefined port [%02x]\n",offset+0x80); |
| 425 | return 0xff; |
| 426 | } |
| 427 | } |
| 428 | |
| 429 | static WRITE8_HANDLER( pc9801_sasi_w ) |
| 430 | { |
| 431 | if((offset & 1) == 0) |
| 432 | { |
| 433 | //printf("Write to undefined port [%02x] <- %02x\n",offset+0xxx,data); |
| 434 | } |
| 435 | else // odd |
| 436 | { |
| 437 | //printf("Write to undefined port [%02x] <- %02x\n",offset+0xxx,data); |
| 438 | } |
| 439 | } |
| 440 | |
| 441 | static READ8_HANDLER( pc9801_a0_r ) |
| 442 | { |
| 443 | pc9801_state *state = space->machine->driver_data<pc9801_state>(); |
| 444 | |
| 445 | if((offset & 1) == 0) |
| 446 | { |
| 447 | switch(offset & 0xe) |
| 448 | { |
| 449 | case 0x00: |
| 450 | { |
| 451 | UINT8 vsync = input_port_read(space->machine, "VBLANK") & 0x20; |
| 452 | |
| 453 | return 4 | vsync; //upd7220 bitmap port |
| 454 | } |
| 455 | case 0x02: return 0xff; //upd7220 bitmap port |
| 456 | /* bitmap palette clut read */ |
| 457 | case 0x08: |
| 458 | case 0x0a: |
| 459 | case 0x0c: |
| 460 | case 0x0e: |
| 461 | return state->pal_clut[(offset & 0x6) >> 1]; |
| 462 | default: |
| 463 | printf("Read to undefined port [%02x]\n",offset+0xa0); |
| 464 | return 0xff; |
| 465 | } |
| 466 | } |
| 467 | else // odd |
| 468 | { |
| 469 | switch((offset & 0xe) + 1) |
| 470 | { |
| 471 | case 0x09://cg window font read |
| 472 | { |
| 473 | UINT8 *pcg = space->machine->region("pcg")->base(); |
| 474 | |
| 475 | return pcg[((state->font_addr & 0x7f7f) << 4) | state->font_lr | (state->font_line & 0x0f)]; |
| 476 | } |
| 477 | } |
| 478 | |
| 479 | printf("Read to undefined port [%02x]\n",offset+0xa0); |
| 480 | return 0xff; |
| 481 | } |
| 482 | } |
| 483 | |
| 484 | static WRITE8_HANDLER( pc9801_a0_w ) |
| 485 | { |
| 486 | pc9801_state *state = space->machine->driver_data<pc9801_state>(); |
| 487 | |
| 488 | if((offset & 1) == 0) |
| 489 | { |
| 490 | switch(offset & 0xe) |
| 491 | { |
| 492 | case 0x00: |
| 493 | case 0x02: |
| 494 | return; //upd7220 bitmap port |
| 495 | case 0x04: |
| 496 | case 0x06: |
| 497 | //if(data) |
| 498 | // printf("Warning: write to bitmap bank %02x\n",data); |
| 499 | return; |
| 500 | /* bitmap palette clut write */ |
| 501 | case 0x08: |
| 502 | case 0x0a: |
| 503 | case 0x0c: |
| 504 | case 0x0e: |
| 505 | { |
| 506 | static UINT8 pal_entry; |
| 507 | state->pal_clut[(offset & 0x6) >> 1] = data; |
| 508 | |
| 509 | /* can't be more twisted I presume ... :-/ */ |
| 510 | pal_entry = (((offset & 4) >> 1) | ((offset & 2) << 1)) >> 1; |
| 511 | pal_entry ^= 3; |
| 512 | |
| 513 | palette_set_color_rgb(space->machine, (pal_entry)|4|8, pal1bit((data & 0x2) >> 1), pal1bit((data & 4) >> 2), pal1bit((data & 1) >> 0)); |
| 514 | palette_set_color_rgb(space->machine, (pal_entry)|8, pal1bit((data & 0x20) >> 5), pal1bit((data & 0x40) >> 6), pal1bit((data & 0x10) >> 4)); |
| 515 | return; |
| 516 | } |
| 517 | default: |
| 518 | printf("Write to undefined port [%02x] <- %02x\n",offset+0xa0,data); |
| 519 | return; |
| 520 | } |
| 521 | } |
| 522 | else // odd |
| 523 | { |
| 524 | switch((offset & 0xe) + 1) |
| 525 | { |
| 526 | case 0x01: |
| 527 | state->font_addr = (data << 8) | (state->font_addr & 0xff); |
| 528 | return; |
| 529 | case 0x03: |
| 530 | state->font_addr = (data & 0xff) | (state->font_addr & 0xff00); |
| 531 | return; |
| 532 | case 0x05: |
| 533 | state->font_line = data & 0x1f; |
| 534 | state->font_lr = data & 0x20 ? 0x000 : 0x800; |
| 535 | return; |
| 536 | case 0x09: //cg window font write |
| 537 | { |
| 538 | UINT8 *pcg = space->machine->region("pcg")->base(); |
| 539 | |
| 540 | pcg[((state->font_addr & 0x7f7f) << 4) | state->font_lr | state->font_line] = data; |
| 541 | return; |
| 542 | } |
| 543 | } |
| 544 | |
| 545 | printf("Write to undefined port [%02x] <- %02x\n",offset+0xa0,data); |
| 546 | } |
| 547 | } |
| 548 | |
| 549 | static READ8_HANDLER( pc9801_fdc_2dd_r ) |
| 550 | { |
| 551 | if((offset & 1) == 0) |
| 552 | { |
| 553 | switch(offset & 6) |
| 554 | { |
| 555 | case 0: return upd765_status_r(space->machine->device("upd765_2dd"),0); |
| 556 | case 2: return upd765_data_r(space->machine->device("upd765_2dd"),0); |
| 557 | case 4: |
| 558 | if((flopimg_get_image(floppy_get_device(space->machine, 0)) == NULL) && flopimg_get_image(floppy_get_device(space->machine, 1)) == NULL) |
| 559 | return 0x6f; |
| 560 | |
| 561 | return 0x7f; |
| 562 | } |
| 563 | } |
| 564 | else |
| 565 | { |
| 566 | printf("Read to undefined port [%02x]\n",offset+0xc8); |
| 567 | return 0xff; |
| 568 | } |
| 569 | |
| 570 | return 0xff; |
| 571 | } |
| 572 | |
| 573 | static WRITE8_HANDLER( pc9801_fdc_2dd_w ) |
| 574 | { |
| 575 | pc9801_state *state = space->machine->driver_data<pc9801_state>(); |
| 576 | |
| 577 | if((offset & 1) == 0) |
| 578 | { |
| 579 | switch(offset & 6) |
| 580 | { |
| 581 | case 0: printf("Write to undefined port [%02x] <- %02x\n",offset+0xc8,data); return; |
| 582 | case 2: upd765_data_w(space->machine->device("upd765_2dd"),0,data); return; |
| 583 | case 4: |
| 584 | printf("%02x ctrl\n",data); |
| 585 | state->fdc_2dd_ctrl = data; |
| 586 | floppy_mon_w(floppy_get_device(space->machine, 0), (data & 8) ? CLEAR_LINE : ASSERT_LINE); |
| 587 | floppy_mon_w(floppy_get_device(space->machine, 1), (data & 8) ? CLEAR_LINE : ASSERT_LINE); |
| 588 | floppy_drive_set_ready_state(floppy_get_device(space->machine, 0), (data & 8), 0); |
| 589 | floppy_drive_set_ready_state(floppy_get_device(space->machine, 1), (data & 8), 0); |
| 590 | if(((state->fdc_2dd_ctrl & 0x80) == 0) && (data & 0x80)) |
| 591 | upd765_reset_w(space->machine->device("upd765_2dd"),1); |
| 592 | break; |
| 593 | } |
| 594 | } |
| 595 | else |
| 596 | { |
| 597 | printf("Write to undefined port [%02x] <- %02x\n",offset+0xc8,data); |
| 598 | } |
| 599 | } |
| 600 | |
| 601 | |
| 602 | /* TODO: banking */ |
| 603 | static READ16_HANDLER( pc9801_tvram_r ) |
| 604 | { |
| 605 | pc9801_state *state = space->machine->driver_data<pc9801_state>(); |
| 606 | |
| 607 | return state->tvram[offset] | ((offset & 0x1000) ? 0xff00 : 0x0000); |
| 608 | } |
| 609 | |
| 610 | static WRITE16_HANDLER( pc9801_tvram_w ) |
| 611 | { |
| 612 | pc9801_state *state = space->machine->driver_data<pc9801_state>(); |
| 613 | |
| 614 | if(offset < (0x3fe0/2) || state->video_ff[MEMSW_REG]) |
| 615 | COMBINE_DATA(&state->tvram[offset]); |
| 616 | } |
| 617 | |
| 618 | static ADDRESS_MAP_START( pc9801_map, ADDRESS_SPACE_PROGRAM, 16) |
| 619 | AM_RANGE(0x00000, 0x9ffff) AM_RAM //work RAM |
| 620 | AM_RANGE(0xa0000, 0xa3fff) AM_READWRITE(pc9801_tvram_r,pc9801_tvram_w) //TVRAM |
| 621 | AM_RANGE(0xa8000, 0xbffff) AM_RAM //bitmap VRAM |
| 622 | // AM_RANGE(0xcc000, 0xcdfff) AM_ROM //sound BIOS |
| 623 | #ifdef LOAD_2dd_BIOS |
| 624 | AM_RANGE(0xd6000, 0xd6fff) AM_ROM AM_REGION("fdc_bios_2dd",0) //floppy BIOS 2dd |
| 625 | #endif |
| 626 | // AM_RANGE(0xd7000, 0xd7fff) AM_ROM AM_REGION("fdc_bios_2hd",0) //floppy BIOS 2hd |
| 627 | AM_RANGE(0xe8000, 0xfffff) AM_ROM AM_REGION("ipl",0) |
| 628 | ADDRESS_MAP_END |
| 629 | |
| 630 | /* first device is even offsets, second one is odd offsets */ |
| 631 | static ADDRESS_MAP_START( pc9801_io, ADDRESS_SPACE_IO, 16) |
| 632 | AM_RANGE(0x0000, 0x001f) AM_READWRITE8(pc9801_00_r,pc9801_00_w,0xffff) // i8259 PIC (bit 3 ON slave / master) / i8237 DMA |
| 633 | // AM_RANGE(0x0020, 0x0027) RTC / DMA registers (LS244) |
| 634 | AM_RANGE(0x0030, 0x0037) AM_READWRITE8(pc9801_30_r,pc9801_30_w,0xffff) //i8251 RS232c / i8255 system port |
| 635 | AM_RANGE(0x0040, 0x0047) AM_READWRITE8(pc9801_40_r,pc9801_40_w,0xffff) //i8255 printer port / i8251 keyboard |
| 636 | AM_RANGE(0x0050, 0x0057) AM_READWRITE8(pc9801_50_r,pc9801_50_w,0xffff) // NMI FF / i8255 floppy port (2d?) |
| 637 | AM_RANGE(0x0060, 0x0063) AM_READWRITE8(pc9801_60_r,pc9801_60_w,0xffff) //upd7220 character ports / <undefined> |
| 638 | AM_RANGE(0x0064, 0x0065) AM_WRITE8(pc9801_vrtc_mask_w,0xffff) |
| 639 | AM_RANGE(0x0068, 0x0069) AM_WRITE8(pc9801_video_ff_w,0xffff) //mode FF / <undefined> |
| 640 | // AM_RANGE(0x006c, 0x006f) border color / <undefined> |
| 641 | AM_RANGE(0x0070, 0x007b) AM_READWRITE8(pc9801_70_r,pc9801_70_w,0xffff) //display registers / i8253 pit |
| 642 | AM_RANGE(0x0080, 0x0083) AM_READWRITE8(pc9801_sasi_r,pc9801_sasi_w,0xffff) //HDD SASI interface / <undefined> |
| 643 | // AM_RANGE(0x0090, 0x0097) upd765a 2hd / cmt |
| 644 | AM_RANGE(0x00a0, 0x00af) AM_READWRITE8(pc9801_a0_r,pc9801_a0_w,0xffff) //upd7220 bitmap ports / display registers |
| 645 | AM_RANGE(0x00c8, 0x00cd) AM_READWRITE8(pc9801_fdc_2dd_r,pc9801_fdc_2dd_w,0xffff) //upd765a 2dd / <undefined> |
| 646 | // AM_RANGE(0x0188, 0x018b) ym2203 opn / <undefined> |
| 647 | ADDRESS_MAP_END |
| 648 | |
| 649 | static INPUT_PORTS_START( pc9801 ) |
| 650 | PORT_START("KEY0") // 0x00 - 0x07 |
| 651 | PORT_BIT(0x01,IP_ACTIVE_HIGH,IPT_UNUSED) |
| 652 | PORT_BIT(0x02,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("1") PORT_CODE(KEYCODE_1) PORT_CHAR('1') |
| 653 | PORT_BIT(0x04,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("2") PORT_CODE(KEYCODE_2) PORT_CHAR('2') |
| 654 | PORT_BIT(0x08,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("3") PORT_CODE(KEYCODE_3) PORT_CHAR('3') |
| 655 | PORT_BIT(0x10,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("4") PORT_CODE(KEYCODE_4) PORT_CHAR('4') |
| 656 | PORT_BIT(0x20,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("5") PORT_CODE(KEYCODE_5) PORT_CHAR('5') |
| 657 | PORT_BIT(0x40,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("6") PORT_CODE(KEYCODE_6) PORT_CHAR('6') |
| 658 | PORT_BIT(0x80,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("7") PORT_CODE(KEYCODE_7) PORT_CHAR('7') |
| 659 | |
| 660 | PORT_START("KEY1") // 0x08 - 0x0f |
| 661 | PORT_BIT(0x01,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("8") PORT_CODE(KEYCODE_8) PORT_CHAR('8') |
| 662 | PORT_BIT(0x02,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("9") PORT_CODE(KEYCODE_9) PORT_CHAR('9') |
| 663 | PORT_BIT(0x04,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("0") PORT_CODE(KEYCODE_0) PORT_CHAR('0') |
| 664 | PORT_BIT(0x08,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("-") PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') |
| 665 | PORT_BIT(0x10,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("^") PORT_CHAR('^') |
| 666 | PORT_BIT(0x20,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("\xC2\xA5") |
| 667 | PORT_BIT(0x40,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("BACKSPACE") PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8) |
| 668 | PORT_BIT(0x80,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("TAB") PORT_CODE(KEYCODE_TAB) PORT_CHAR('\t') |
| 669 | |
| 670 | PORT_START("KEY2") // 0x10 - 0x17 |
| 671 | PORT_BIT(0x01,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("Q") PORT_CODE(KEYCODE_Q) PORT_CHAR('Q') |
| 672 | PORT_BIT(0x02,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("W") PORT_CODE(KEYCODE_W) PORT_CHAR('W') |
| 673 | PORT_BIT(0x04,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("E") PORT_CODE(KEYCODE_E) PORT_CHAR('E') |
| 674 | PORT_BIT(0x08,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("R") PORT_CODE(KEYCODE_R) PORT_CHAR('R') |
| 675 | PORT_BIT(0x10,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("T") PORT_CODE(KEYCODE_T) PORT_CHAR('T') |
| 676 | PORT_BIT(0x20,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("Y") PORT_CODE(KEYCODE_Y) PORT_CHAR('Y') |
| 677 | PORT_BIT(0x40,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("U") PORT_CODE(KEYCODE_U) PORT_CHAR('U') |
| 678 | PORT_BIT(0x80,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("I") PORT_CODE(KEYCODE_I) PORT_CHAR('I') |
| 679 | |
| 680 | PORT_START("KEY3") // 0x18 - 0x1f |
| 681 | PORT_BIT(0x01,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("O") PORT_CODE(KEYCODE_O) PORT_CHAR('O') |
| 682 | PORT_BIT(0x02,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("P") PORT_CODE(KEYCODE_P) PORT_CHAR('P') |
| 683 | PORT_BIT(0x04,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("@") PORT_CHAR('@') |
| 684 | PORT_BIT(0x08,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("[") PORT_CHAR('[') |
| 685 | PORT_BIT(0x10,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("RETURN") PORT_CODE(KEYCODE_ENTER) PORT_CHAR(27) |
| 686 | PORT_BIT(0x20,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("A") PORT_CODE(KEYCODE_A) PORT_CHAR('A') |
| 687 | PORT_BIT(0x40,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("S") PORT_CODE(KEYCODE_S) PORT_CHAR('S') |
| 688 | PORT_BIT(0x80,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("D") PORT_CODE(KEYCODE_D) PORT_CHAR('D') |
| 689 | |
| 690 | PORT_START("KEY4") // 0x20 - 0x27 |
| 691 | PORT_BIT(0x01,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("F") PORT_CODE(KEYCODE_F) PORT_CHAR('F') |
| 692 | PORT_BIT(0x02,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("G") PORT_CODE(KEYCODE_G) PORT_CHAR('G') |
| 693 | PORT_BIT(0x04,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("H") PORT_CODE(KEYCODE_H) PORT_CHAR('H') |
| 694 | PORT_BIT(0x08,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("J") PORT_CODE(KEYCODE_J) PORT_CHAR('J') |
| 695 | PORT_BIT(0x10,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("K") PORT_CODE(KEYCODE_K) PORT_CHAR('K') |
| 696 | PORT_BIT(0x20,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("L") PORT_CODE(KEYCODE_L) PORT_CHAR('L') |
| 697 | PORT_BIT(0x40,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(";") PORT_CHAR(';') |
| 698 | PORT_BIT(0x80,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(":") PORT_CHAR(':') |
| 699 | |
| 700 | PORT_START("KEY5") // 0x28 - 0x2f |
| 701 | PORT_BIT(0x01,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("]") PORT_CHAR(']') |
| 702 | PORT_BIT(0x02,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("Z") PORT_CODE(KEYCODE_Z) PORT_CHAR('Z') |
| 703 | PORT_BIT(0x04,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("X") PORT_CODE(KEYCODE_X) PORT_CHAR('X') |
| 704 | PORT_BIT(0x08,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("C") PORT_CODE(KEYCODE_C) PORT_CHAR('C') |
| 705 | PORT_BIT(0x10,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("V") PORT_CODE(KEYCODE_V) PORT_CHAR('V') |
| 706 | PORT_BIT(0x20,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("B") PORT_CODE(KEYCODE_B) PORT_CHAR('B') |
| 707 | PORT_BIT(0x40,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("N") PORT_CODE(KEYCODE_N) PORT_CHAR('N') |
| 708 | PORT_BIT(0x80,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("M") PORT_CODE(KEYCODE_M) PORT_CHAR('M') |
| 709 | |
| 710 | PORT_START("KEY6") // 0x30 - 0x37 |
| 711 | PORT_BIT(0x01,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(",") PORT_CHAR(',') |
| 712 | PORT_BIT(0x02,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(".") PORT_CHAR('.') |
| 713 | PORT_BIT(0x04,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("/") PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') |
| 714 | PORT_BIT(0x08,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("C") PORT_CODE(KEYCODE_C) PORT_CHAR('C') |
| 715 | PORT_BIT(0x10,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("V") PORT_CODE(KEYCODE_V) PORT_CHAR('V') |
| 716 | PORT_BIT(0x20,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("B") PORT_CODE(KEYCODE_B) PORT_CHAR('B') |
| 717 | PORT_BIT(0x40,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("N") PORT_CODE(KEYCODE_N) PORT_CHAR('N') |
| 718 | PORT_BIT(0x80,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("M") PORT_CODE(KEYCODE_M) PORT_CHAR('M') |
| 719 | |
| 720 | PORT_START("KEY7") // 0x38 - 0x3f |
| 721 | PORT_BIT(0x01,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 1-1") //PORT_CHAR(',') |
| 722 | PORT_BIT(0x02,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 1-2") //PORT_CHAR('.') |
| 723 | PORT_BIT(0x04,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 1-3") //PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') |
| 724 | PORT_BIT(0x08,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 1-4") //PORT_CODE(KEYCODE_C) PORT_CHAR('C') |
| 725 | PORT_BIT(0x10,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("SPACE") PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') |
| 726 | PORT_BIT(0x20,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 1-6") //PORT_CODE(KEYCODE_B) PORT_CHAR('B') |
| 727 | PORT_BIT(0x40,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("CLS") PORT_CODE(KEYCODE_HOME) //PORT_CHAR(' ') |
| 728 | PORT_BIT(0x80,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 1-8") //PORT_CODE(KEYCODE_M) PORT_CHAR('M') |
| 729 | |
| 730 | PORT_START("KEY8") // 0x40 - 0x47 |
| 731 | PORT_BIT(0x01,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("- (PAD)") PORT_CODE(KEYCODE_MINUS_PAD) PORT_CHAR('-') |
| 732 | PORT_BIT(0x02,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("/ (PAD)") PORT_CODE(KEYCODE_SLASH_PAD) PORT_CHAR('/') |
| 733 | PORT_BIT(0x04,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("7 (PAD)") PORT_CODE(KEYCODE_7_PAD) PORT_CHAR('7') |
| 734 | PORT_BIT(0x08,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("8 (PAD)") PORT_CODE(KEYCODE_8_PAD) PORT_CHAR('8') |
| 735 | PORT_BIT(0x10,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("9 (PAD)") PORT_CODE(KEYCODE_9_PAD) PORT_CHAR('9') |
| 736 | PORT_BIT(0x20,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("* (PAD)") PORT_CODE(KEYCODE_ASTERISK) PORT_CHAR('*') |
| 737 | PORT_BIT(0x40,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("4 (PAD)") PORT_CODE(KEYCODE_4_PAD) PORT_CHAR('4') |
| 738 | PORT_BIT(0x80,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("5 (PAD)") PORT_CODE(KEYCODE_5_PAD) PORT_CHAR('5') |
| 739 | |
| 740 | PORT_START("KEY9") // 0x48 - 0x4f |
| 741 | PORT_BIT(0x01,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("6 (PAD)") PORT_CODE(KEYCODE_6_PAD) PORT_CHAR('6') |
| 742 | PORT_BIT(0x02,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("+ (PAD)") PORT_CODE(KEYCODE_PLUS_PAD) PORT_CHAR('+') |
| 743 | PORT_BIT(0x04,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("1 (PAD)") PORT_CODE(KEYCODE_1_PAD) PORT_CHAR('1') |
| 744 | PORT_BIT(0x08,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("2 (PAD)") PORT_CODE(KEYCODE_2_PAD) PORT_CHAR('2') |
| 745 | PORT_BIT(0x10,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("3 (PAD)") PORT_CODE(KEYCODE_3_PAD) PORT_CHAR('3') |
| 746 | PORT_BIT(0x20,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("EQUAL (PAD)") PORT_CODE(KEYCODE_ENTER_PAD) PORT_CHAR('=') |
| 747 | PORT_BIT(0x40,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("0 (PAD)") PORT_CODE(KEYCODE_0_PAD) PORT_CHAR('0') |
| 748 | PORT_BIT(0x80,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(", (PAD)") PORT_CHAR(',') |
| 749 | |
| 750 | PORT_START("KEYA") // 0x50 - 0x57 |
| 751 | PORT_BIT(0x01,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(". (PAD)") PORT_CHAR('.') |
| 752 | PORT_BIT(0x02,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 2-2") //PORT_CHAR('.') |
| 753 | PORT_BIT(0x04,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 2-3") //PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') |
| 754 | PORT_BIT(0x08,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 2-4") //PORT_CODE(KEYCODE_C) PORT_CHAR('C') |
| 755 | PORT_BIT(0x10,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 2-5") //PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') |
| 756 | PORT_BIT(0x20,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 2-6") //PORT_CODE(KEYCODE_B) PORT_CHAR('B') |
| 757 | PORT_BIT(0x40,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 2-7") //PORT_CODE(KEYCODE_HOME) //PORT_CHAR(' ') |
| 758 | PORT_BIT(0x80,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 2-8") //PORT_CODE(KEYCODE_M) PORT_CHAR('M') |
| 759 | |
| 760 | PORT_START("KEYB") // 0x58 - 0x5f |
| 761 | PORT_BIT(0x01,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 3-1") //PORT_CODE(KEYCODE_C) PORT_CHAR('C') |
| 762 | PORT_BIT(0x02,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 3-2") //PORT_CHAR('.') |
| 763 | PORT_BIT(0x04,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 3-3") //PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') |
| 764 | PORT_BIT(0x08,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 3-4") //PORT_CODE(KEYCODE_C) PORT_CHAR('C') |
| 765 | PORT_BIT(0x10,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 3-5") //PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') |
| 766 | PORT_BIT(0x20,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 3-6") //PORT_CODE(KEYCODE_B) PORT_CHAR('B') |
| 767 | PORT_BIT(0x40,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 3-7") //PORT_CODE(KEYCODE_HOME) //PORT_CHAR(' ') |
| 768 | PORT_BIT(0x80,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 3-8") //PORT_CODE(KEYCODE_M) PORT_CHAR('M') |
| 769 | |
| 770 | PORT_START("KEYC") // 0x60 - 0x67 |
| 771 | PORT_BIT(0x01,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 4-1") //PORT_CODE(KEYCODE_C) PORT_CHAR('C') |
| 772 | PORT_BIT(0x02,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 4-2") //PORT_CHAR('.') |
| 773 | PORT_BIT(0x04,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("F1") PORT_CODE(KEYCODE_F1) PORT_CHAR(UCHAR_MAMEKEY(F1)) |
| 774 | PORT_BIT(0x08,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("F2") PORT_CODE(KEYCODE_F2) PORT_CHAR(UCHAR_MAMEKEY(F2)) |
| 775 | PORT_BIT(0x10,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("F3") PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F3)) |
| 776 | PORT_BIT(0x20,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("F4") PORT_CODE(KEYCODE_F4) PORT_CHAR(UCHAR_MAMEKEY(F4)) |
| 777 | PORT_BIT(0x40,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("F5") PORT_CODE(KEYCODE_F5) PORT_CHAR(UCHAR_MAMEKEY(F5)) |
| 778 | PORT_BIT(0x80,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("F6") PORT_CODE(KEYCODE_F6) PORT_CHAR(UCHAR_MAMEKEY(F6)) |
| 779 | |
| 780 | PORT_START("KEYD") // 0x68 - 0x6f |
| 781 | PORT_BIT(0x01,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("F7") PORT_CODE(KEYCODE_F7) PORT_CHAR(UCHAR_MAMEKEY(F7)) |
| 782 | PORT_BIT(0x02,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("F8") PORT_CODE(KEYCODE_F8) PORT_CHAR(UCHAR_MAMEKEY(F8)) |
| 783 | PORT_BIT(0x04,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("F9") PORT_CODE(KEYCODE_F9) PORT_CHAR(UCHAR_MAMEKEY(F9)) |
| 784 | PORT_BIT(0x08,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("F10") PORT_CODE(KEYCODE_F10) PORT_CHAR(UCHAR_MAMEKEY(F10)) |
| 785 | PORT_BIT(0x10,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 5-5") //PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') |
| 786 | PORT_BIT(0x20,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 5-6") //PORT_CODE(KEYCODE_B) PORT_CHAR('B') |
| 787 | PORT_BIT(0x40,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 5-7") //PORT_CODE(KEYCODE_HOME) //PORT_CHAR(' ') |
| 788 | PORT_BIT(0x80,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 5-8") //PORT_CODE(KEYCODE_M) PORT_CHAR('M') |
| 789 | |
| 790 | PORT_START("KEYE") // 0x70 - 0x77 |
| 791 | PORT_BIT(0x01,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("LSHIFT") PORT_CODE(KEYCODE_LSHIFT) |
| 792 | PORT_BIT(0x02,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("CAPS LOCK") PORT_CODE(KEYCODE_CAPSLOCK) PORT_TOGGLE |
| 793 | PORT_BIT(0x04,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("\xe3\x81\x8b\xe3\x81\xaa / KANA LOCK") PORT_TOGGLE |
| 794 | PORT_BIT(0x08,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 6-4") //PORT_CODE(KEYCODE_C) PORT_CHAR('C') |
| 795 | PORT_BIT(0x10,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 6-5") //PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') |
| 796 | PORT_BIT(0x20,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 6-6") //PORT_CODE(KEYCODE_B) PORT_CHAR('B') |
| 797 | PORT_BIT(0x40,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 6-7") //PORT_CODE(KEYCODE_HOME) //PORT_CHAR(' ') |
| 798 | PORT_BIT(0x80,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 6-8") //PORT_CODE(KEYCODE_M) PORT_CHAR('M') |
| 799 | |
| 800 | PORT_START("KEYF") // 0x78 - 0x7f |
| 801 | PORT_BIT(0x01,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 7-1") //PORT_CODE(KEYCODE_C) PORT_CHAR('C') |
| 802 | PORT_BIT(0x02,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 7-2") |
| 803 | PORT_BIT(0x04,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 7-3") |
| 804 | PORT_BIT(0x08,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 7-4") //PORT_CODE(KEYCODE_C) PORT_CHAR('C') |
| 805 | PORT_BIT(0x10,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 7-5") //PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') |
| 806 | PORT_BIT(0x20,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 7-6") //PORT_CODE(KEYCODE_B) PORT_CHAR('B') |
| 807 | PORT_BIT(0x40,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 7-7") //PORT_CODE(KEYCODE_HOME) //PORT_CHAR(' ') |
| 808 | PORT_BIT(0x80,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 7-8") //PORT_CODE(KEYCODE_M) PORT_CHAR('M') |
| 809 | |
| 810 | |
| 811 | PORT_START("DSW1") |
| 812 | PORT_DIPNAME( 0x04, 0x00, "Text width" ) |
| 813 | PORT_DIPSETTING( 0x04, "40 chars/line" ) |
| 814 | PORT_DIPSETTING( 0x00, "80 chars/line" ) |
| 815 | PORT_DIPNAME( 0x08, 0x00, "Text height" ) |
| 816 | PORT_DIPSETTING( 0x08, "20 lines/screen" ) |
| 817 | PORT_DIPSETTING( 0x00, "25 lines/screen" ) |
| 818 | |
| 819 | PORT_START("VBLANK") |
| 820 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_VBLANK ) |
| 821 | INPUT_PORTS_END |
| 822 | |
| 823 | static const gfx_layout charset_8x8 = |
| 824 | { |
| 825 | 8,8, |
| 826 | RGN_FRAC(1,1), |
| 827 | 1, |
| 828 | { 0 }, |
| 829 | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 830 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, |
| 831 | 8*8 |
| 832 | }; |
| 833 | |
| 834 | static const gfx_layout charset_16x16 = |
| 835 | { |
| 836 | 16,16, |
| 837 | RGN_FRAC(1,1), |
| 838 | 1, |
| 839 | { 0 }, |
| 840 | { STEP16(0,1) }, |
| 841 | { STEP16(0,16) }, |
| 842 | 16*16 |
| 843 | }; |
| 844 | |
| 845 | static GFXDECODE_START( pc9801 ) |
| 846 | GFXDECODE_ENTRY( "chargen", 0x00000, charset_8x8, 0x000, 0x01 ) |
| 847 | GFXDECODE_ENTRY( "kanji", 0x00000, charset_16x16, 0x000, 0x01 ) |
| 848 | GFXDECODE_END |
| 849 | |
| 850 | /**************************************** |
| 851 | * |
| 852 | * I8259 PIC interface |
| 853 | * |
| 854 | ****************************************/ |
| 855 | |
| 856 | /* |
| 857 | irq assignment is: |
| 858 | |
| 859 | 8259 master: |
| 860 | ir0 PIT |
| 861 | ir1 keyboard |
| 862 | ir2 vblank |
| 863 | ir3 |
| 864 | ir4 rs-232c |
| 865 | ir5 |
| 866 | ir6 |
| 867 | ir7 |
| 868 | |
| 869 | 8259 slave: |
| 870 | ir0 <connection with master 8259?> |
| 871 | ir1 |
| 872 | ir2 2dd floppy irq |
| 873 | ir3 2hd floppy irq |
| 874 | ir4 |
| 875 | ir5 |
| 876 | ir6 |
| 877 | ir7 |
| 878 | */ |
| 879 | |
| 880 | |
| 881 | static WRITE_LINE_DEVICE_HANDLER( pc9801_master_set_int_line ) |
| 882 | { |
| 883 | //printf("%02x\n",interrupt); |
| 884 | cputag_set_input_line(device->machine, "maincpu", 0, state ? HOLD_LINE : CLEAR_LINE); |
| 885 | } |
| 886 | |
| 887 | static const struct pic8259_interface pic8259_master_config = |
| 888 | { |
| 889 | DEVCB_LINE(pc9801_master_set_int_line) |
| 890 | }; |
| 891 | |
| 892 | static const struct pic8259_interface pic8259_slave_config = |
| 893 | { |
| 894 | DEVCB_DEVICE_LINE("pic8259_master", pic8259_ir7_w) //TODO: check me |
| 895 | }; |
| 896 | |
| 897 | /**************************************** |
| 898 | * |
| 899 | * I8253 PIT interface |
| 900 | * |
| 901 | ****************************************/ |
| 902 | |
| 903 | static const struct pit8253_config pit8253_config = |
| 904 | { |
| 905 | { |
| 906 | { |
| 907 | 1996800, /* heartbeat IRQ */ |
| 908 | DEVCB_NULL, |
| 909 | DEVCB_DEVICE_LINE("pic8259_master", pic8259_ir0_w) |
| 910 | }, { |
| 911 | 1996800, /* dram refresh */ |
| 912 | DEVCB_NULL, |
| 913 | DEVCB_NULL |
| 914 | }, { |
| 915 | 1996800, /* pio port c pin 4, and speaker polling enough */ |
| 916 | DEVCB_NULL, |
| 917 | DEVCB_NULL |
| 918 | } |
| 919 | } |
| 920 | }; |
| 921 | |
| 922 | /**************************************** |
| 923 | * |
| 924 | * I8237 DMA interface |
| 925 | * |
| 926 | ****************************************/ |
| 927 | |
| 928 | static WRITE_LINE_DEVICE_HANDLER( pc_dma_hrq_changed ) |
| 929 | { |
| 930 | cputag_set_input_line(device->machine, "maincpu", INPUT_LINE_HALT, state ? ASSERT_LINE : CLEAR_LINE); |
| 931 | |
| 932 | /* Assert HLDA */ |
| 933 | i8237_hlda_w( device, state ); |
| 934 | } |
| 935 | |
| 936 | |
| 937 | static READ8_HANDLER( pc_dma_read_byte ) |
| 938 | { |
| 939 | pc9801_state *state = space->machine->driver_data<pc9801_state>(); |
| 940 | offs_t page_offset = (((offs_t) state->dma_offset[0][state->dma_channel]) << 16) |
| 941 | & 0xFF0000; |
| 942 | |
| 943 | return space->read_byte(page_offset + offset); |
| 944 | } |
| 945 | |
| 946 | |
| 947 | static WRITE8_HANDLER( pc_dma_write_byte ) |
| 948 | { |
| 949 | pc9801_state *state = space->machine->driver_data<pc9801_state>(); |
| 950 | offs_t page_offset = (((offs_t) state->dma_offset[0][state->dma_channel]) << 16) |
| 951 | & 0xFF0000; |
| 952 | |
| 953 | space->write_byte(page_offset + offset, data); |
| 954 | } |
| 955 | |
| 956 | static void set_dma_channel(device_t *device, int channel, int state) |
| 957 | { |
| 958 | pc9801_state *drvstate = device->machine->driver_data<pc9801_state>(); |
| 959 | if (!state) drvstate->dma_channel = channel; |
| 960 | } |
| 961 | |
| 962 | static WRITE_LINE_DEVICE_HANDLER( pc_dack0_w ) { set_dma_channel(device, 0, state); } |
| 963 | static WRITE_LINE_DEVICE_HANDLER( pc_dack1_w ) { set_dma_channel(device, 1, state); } |
| 964 | static WRITE_LINE_DEVICE_HANDLER( pc_dack2_w ) { set_dma_channel(device, 2, state); } |
| 965 | static WRITE_LINE_DEVICE_HANDLER( pc_dack3_w ) { set_dma_channel(device, 3, state); } |
| 966 | |
| 967 | static READ8_DEVICE_HANDLER( test_r ) |
| 968 | { |
| 969 | //printf("DACK R\n"); |
| 970 | |
| 971 | return 0xff; |
| 972 | } |
| 973 | |
| 974 | static WRITE8_DEVICE_HANDLER( test_w ) |
| 975 | { |
| 976 | //printf("DACK W\n"); |
| 977 | } |
| 978 | |
| 979 | static I8237_INTERFACE( dma8237_config ) |
| 980 | { |
| 981 | DEVCB_LINE(pc_dma_hrq_changed), |
| 982 | DEVCB_NULL, |
| 983 | DEVCB_MEMORY_HANDLER("maincpu", PROGRAM, pc_dma_read_byte), |
| 984 | DEVCB_MEMORY_HANDLER("maincpu", PROGRAM, pc_dma_write_byte), |
| 985 | { DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_HANDLER(test_r) }, |
| 986 | { DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_HANDLER(test_w) }, |
| 987 | { DEVCB_LINE(pc_dack0_w), DEVCB_LINE(pc_dack1_w), DEVCB_LINE(pc_dack2_w), DEVCB_LINE(pc_dack3_w) } |
| 988 | }; |
| 989 | |
| 990 | /**************************************** |
| 991 | * |
| 992 | * PPI interfaces |
| 993 | * |
| 994 | ****************************************/ |
| 995 | |
| 996 | static READ8_DEVICE_HANDLER( ppi_sys_porta_r ) |
| 997 | { |
| 998 | /* |
| 999 | ---- x--- lines 20 (1) / 25 (0) |
| 1000 | ---- -x-- width 40 (1) / width 80 (0) |
| 1001 | ---- ---x jumps to daa00 if off? |
| 1002 | */ |
| 1003 | |
| 1004 | return 0xe3 | input_port_read(device->machine,"DSW1"); |
| 1005 | } |
| 1006 | |
| 1007 | static WRITE8_DEVICE_HANDLER( ppi_sys_portc_w ) |
| 1008 | { |
| 1009 | beep_set_state(device->machine->device("beeper"),!(data & 0x08)); |
| 1010 | } |
| 1011 | |
| 1012 | static I8255A_INTERFACE( ppi_system_intf ) |
| 1013 | { |
| 1014 | DEVCB_HANDLER(ppi_sys_porta_r), /* Port A read */ |
| 1015 | DEVCB_NULL, /* Port B read */ |
| 1016 | DEVCB_NULL, /* Port C read */ |
| 1017 | DEVCB_NULL, /* Port A write */ |
| 1018 | DEVCB_NULL, /* Port B write */ |
| 1019 | DEVCB_HANDLER(ppi_sys_portc_w) /* Port C write */ |
| 1020 | }; |
| 1021 | |
| 1022 | static I8255A_INTERFACE( ppi_printer_intf ) |
| 1023 | { |
| 1024 | DEVCB_NULL, /* Port A read */ |
| 1025 | DEVCB_NULL, /* Port B read */ |
| 1026 | DEVCB_NULL, /* Port C read */ |
| 1027 | DEVCB_NULL, /* Port A write */ |
| 1028 | DEVCB_NULL, /* Port B write */ |
| 1029 | DEVCB_NULL /* Port C write */ |
| 1030 | }; |
| 1031 | |
| 1032 | static READ8_DEVICE_HANDLER( ppi_fdd_porta_r ) |
| 1033 | { |
| 1034 | return 0xff; |
| 1035 | } |
| 1036 | |
| 1037 | static READ8_DEVICE_HANDLER( ppi_fdd_portb_r ) |
| 1038 | { |
| 1039 | return 0xff; //upd765_status_r(device->machine->device("upd765_2dd"),0); |
| 1040 | } |
| 1041 | |
| 1042 | static READ8_DEVICE_HANDLER( ppi_fdd_portc_r ) |
| 1043 | { |
| 1044 | return 0xff; //upd765_data_r(device->machine->device("upd765_2dd"),0); |
| 1045 | } |
| 1046 | |
| 1047 | static WRITE8_DEVICE_HANDLER( ppi_fdd_portc_w ) |
| 1048 | { |
| 1049 | //upd765_data_w(device->machine->device("upd765_2dd"),0,data); |
| 1050 | } |
| 1051 | |
| 1052 | static I8255A_INTERFACE( ppi_fdd_intf ) |
| 1053 | { |
| 1054 | DEVCB_HANDLER(ppi_fdd_porta_r), /* Port A read */ |
| 1055 | DEVCB_HANDLER(ppi_fdd_portb_r), /* Port B read */ |
| 1056 | DEVCB_HANDLER(ppi_fdd_portc_r), /* Port C read */ |
| 1057 | DEVCB_NULL, /* Port A write */ |
| 1058 | DEVCB_NULL, /* Port B write */ |
| 1059 | DEVCB_HANDLER(ppi_fdd_portc_w) /* Port C write */ |
| 1060 | }; |
| 1061 | |
| 1062 | /**************************************** |
| 1063 | * |
| 1064 | * UPD765 interface |
| 1065 | * |
| 1066 | ****************************************/ |
| 1067 | |
| 1068 | static WRITE_LINE_DEVICE_HANDLER( fdc_2dd_irq ) |
| 1069 | { |
| 1070 | pc9801_state *drvstate = device->machine->driver_data<pc9801_state>(); |
| 1071 | |
| 1072 | if(drvstate->fdc_2dd_ctrl & 4) |
| 1073 | { |
| 1074 | pic8259_ir2_w(device->machine->device("pic8259_slave"), state); |
| 1075 | } |
| 1076 | } |
| 1077 | |
| 1078 | static WRITE_LINE_DEVICE_HANDLER( fdc_2dd_drq ) |
| 1079 | { |
| 1080 | printf("%02x DRQ\n",state); |
| 1081 | } |
| 1082 | |
| 1083 | static const struct upd765_interface upd765_2dd_intf = |
| 1084 | { |
| 1085 | DEVCB_LINE(fdc_2dd_irq), |
| 1086 | DEVCB_LINE(fdc_2dd_drq), //DRQ, TODO |
| 1087 | NULL, |
| 1088 | UPD765_RDY_PIN_CONNECTED, |
| 1089 | {FLOPPY_0, FLOPPY_1, NULL, NULL} |
| 1090 | }; |
| 1091 | |
| 1092 | static const floppy_config pc9801_floppy_config = |
| 1093 | { |
| 1094 | DEVCB_NULL, |
| 1095 | DEVCB_NULL, |
| 1096 | DEVCB_NULL, |
| 1097 | DEVCB_NULL, |
| 1098 | DEVCB_NULL, |
| 1099 | FLOPPY_STANDARD_5_25_DSHD, |
| 1100 | FLOPPY_OPTIONS_NAME(default), |
| 1101 | NULL |
| 1102 | }; |
| 1103 | |
| 1104 | |
| 1105 | /**************************************** |
| 1106 | * |
| 1107 | * Init emulation status |
| 1108 | * |
| 1109 | ****************************************/ |
| 1110 | |
| 1111 | static PALETTE_INIT( pc9801 ) |
| 1112 | { |
| 1113 | int i; |
| 1114 | |
| 1115 | for(i=0;i<8;i++) |
| 1116 | palette_set_color_rgb(machine, i, pal1bit(i >> 1), pal1bit(i >> 2), pal1bit(i >> 0)); |
| 1117 | } |
| 1118 | |
| 1119 | static IRQ_CALLBACK(irq_callback) |
| 1120 | { |
| 1121 | int r = 0; |
| 1122 | r = pic8259_acknowledge( device->machine->device( "pic8259_slave" )); |
| 1123 | if (r==0) |
| 1124 | { |
| 1125 | r = pic8259_acknowledge( device->machine->device( "pic8259_master" )); |
| 1126 | //printf("%02x ACK\n",r); |
| 1127 | } |
| 1128 | return r; |
| 1129 | } |
| 1130 | |
| 1131 | |
| 1132 | static MACHINE_RESET(pc9801) |
| 1133 | { |
| 1134 | pc9801_state *state = machine->driver_data<pc9801_state>(); |
| 1135 | |
| 1136 | cpu_set_irq_callback(machine->device("maincpu"), irq_callback); |
| 1137 | |
| 1138 | /* this looks like to be some kind of backup ram, system will boot with green colors otherwise */ |
| 1139 | { |
| 1140 | int i; |
| 1141 | static const UINT8 default_memsw_data[0x10] = |
| 1142 | { |
| 1143 | 0xe1, 0x48, 0xe1, 0x05, 0xe1, 0x04, 0xe1, 0x00, 0xe1, 0x01, 0xe1, 0x00, 0xe1, 0x00, 0xe1, 0x00 |
| 1144 | }; |
| 1145 | |
| 1146 | for(i=0;i<0x10;i++) |
| 1147 | state->tvram[(0x3fe0/2)+i] = default_memsw_data[i]; |
| 1148 | } |
| 1149 | |
| 1150 | beep_set_frequency(machine->device("beeper"),2400); |
| 1151 | beep_set_state(machine->device("beeper"),0); |
| 1152 | |
| 1153 | /* 2dd interface ready line is ON by default */ |
| 1154 | floppy_mon_w(floppy_get_device(machine, 0), CLEAR_LINE); |
| 1155 | floppy_mon_w(floppy_get_device(machine, 1), CLEAR_LINE); |
| 1156 | floppy_drive_set_ready_state(floppy_get_device(machine, 0), (1), 0); |
| 1157 | floppy_drive_set_ready_state(floppy_get_device(machine, 1), (1), 0); |
| 1158 | } |
| 1159 | |
| 1160 | static INTERRUPT_GEN(pc9801_vrtc_irq) |
| 1161 | { |
| 1162 | pc9801_state *state = device->machine->driver_data<pc9801_state>(); |
| 1163 | |
| 1164 | if(state->vrtc_irq_mask) |
| 1165 | { |
| 1166 | pic8259_ir2_w(device->machine->device("pic8259_master"), 1); |
| 1167 | state->vrtc_irq_mask = 0; // TODO: this irq auto-masks? |
| 1168 | } |
| 1169 | } |
| 1170 | |
| 1171 | |
| 1172 | static TIMER_DEVICE_CALLBACK( keyboard_callback ) |
| 1173 | { |
| 1174 | pc9801_state *state = timer.machine->driver_data<pc9801_state>(); |
| 1175 | static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3", |
| 1176 | "KEY4", "KEY5", "KEY6", "KEY7", |
| 1177 | "KEY8", "KEY9", "KEYA", "KEYB", |
| 1178 | "KEYC", "KEYD", "KEYE", "KEYF" }; |
| 1179 | int i,port_i,scancode,prev_scancode; |
| 1180 | //UINT8 keymod = input_port_read(timer.machine,"key_modifiers") & 0x1f; |
| 1181 | scancode = 0; |
| 1182 | |
| 1183 | prev_scancode = state->keyb_press; |
| 1184 | |
| 1185 | for(port_i=0;port_i<0x10;port_i++) |
| 1186 | { |
| 1187 | for(i=0;i<8;i++) |
| 1188 | { |
| 1189 | if((input_port_read(timer.machine,keynames[port_i])>>i) & 1) |
| 1190 | { |
| 1191 | if(prev_scancode == scancode) |
| 1192 | scancode|=0x80; |
| 1193 | |
| 1194 | state->keyb_press = scancode; |
| 1195 | pic8259_ir1_w(timer.machine->device("pic8259_master"), 1); |
| 1196 | return; |
| 1197 | } |
| 1198 | scancode++; |
| 1199 | } |
| 1200 | } |
| 1201 | } |
| 1202 | |
| 1203 | static MACHINE_CONFIG_START( pc9801, pc9801_state ) |
| 1204 | MCFG_CPU_ADD("maincpu", I8086, 5000000) //unknown clock |
| 1205 | MCFG_CPU_PROGRAM_MAP(pc9801_map) |
| 1206 | MCFG_CPU_IO_MAP(pc9801_io) |
| 1207 | MCFG_CPU_VBLANK_INT("screen",pc9801_vrtc_irq) |
| 1208 | |
| 1209 | MCFG_MACHINE_RESET(pc9801) |
| 1210 | |
| 1211 | MCFG_PIT8253_ADD( "pit8253", pit8253_config ) |
| 1212 | MCFG_I8237_ADD( "dma8237", 5000000, dma8237_config ) //unknown clock |
| 1213 | MCFG_PIC8259_ADD( "pic8259_master", pic8259_master_config ) |
| 1214 | MCFG_PIC8259_ADD( "pic8259_slave", pic8259_slave_config ) |
| 1215 | MCFG_I8255A_ADD( "ppi8255_sys", ppi_system_intf ) |
| 1216 | MCFG_I8255A_ADD( "ppi8255_prn", ppi_printer_intf ) |
| 1217 | MCFG_I8255A_ADD( "ppi8255_fdd", ppi_fdd_intf ) |
| 1218 | |
| 1219 | MCFG_UPD765A_ADD("upd765_2dd", upd765_2dd_intf) |
| 1220 | MCFG_FLOPPY_4_DRIVES_ADD(pc9801_floppy_config) |
| 1221 | |
| 1222 | /* video hardware */ |
| 1223 | MCFG_SCREEN_ADD("screen", RASTER) |
| 1224 | MCFG_SCREEN_REFRESH_RATE(60) |
| 1225 | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 1226 | MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 1227 | MCFG_SCREEN_SIZE(640, 480) |
| 1228 | MCFG_SCREEN_VISIBLE_AREA(0, 640-1, 0, 200-1) |
| 1229 | MCFG_PALETTE_LENGTH(16) |
| 1230 | MCFG_PALETTE_INIT(pc9801) |
| 1231 | MCFG_GFXDECODE(pc9801) |
| 1232 | |
| 1233 | MCFG_VIDEO_START(pc9801) |
| 1234 | MCFG_VIDEO_UPDATE(pc9801) |
| 1235 | |
| 1236 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 1237 | |
| 1238 | // MCFG_SOUND_ADD("opn", YM2203, 4000000) // unknown clock / divider |
| 1239 | // MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 1240 | |
| 1241 | MCFG_SOUND_ADD("beeper", BEEP, 0) |
| 1242 | MCFG_SOUND_ROUTE(ALL_OUTPUTS,"mono",0.50) |
| 1243 | |
| 1244 | MCFG_TIMER_ADD_PERIODIC("keyboard_timer", keyboard_callback, attotime::from_hz(240/32)) |
| 1245 | MACHINE_CONFIG_END |
| 1246 | |
| 1247 | ROM_START( pc9801f ) |
| 1248 | ROM_REGION( 0x18000, "ipl", ROMREGION_ERASEFF ) |
| 1249 | ROM_LOAD16_BYTE( "urm01-02.bin", 0x00000, 0x4000, CRC(cde04615) SHA1(8f6fb587c0522af7a8131b45d13f8ae8fc60e8cd) ) |
| 1250 | ROM_LOAD16_BYTE( "urm02-02.bin", 0x00001, 0x4000, CRC(9e39b8d1) SHA1(df1f3467050a41537cb9d071e4034f0506f07eda) ) |
| 1251 | ROM_LOAD16_BYTE( "urm03-02.bin", 0x08000, 0x4000, CRC(95e79064) SHA1(c27d96949fad82aeb26e316200c15a4891e1063f) ) |
| 1252 | ROM_LOAD16_BYTE( "urm04-02.bin", 0x08001, 0x4000, CRC(e4855a53) SHA1(223f66482c77409706cfc64c214cec7237c364e9) ) |
| 1253 | ROM_LOAD16_BYTE( "urm05-02.bin", 0x10000, 0x4000, CRC(ffefec65) SHA1(106e0d920e857e59da12225a489ca2756ca405c1) ) |
| 1254 | ROM_LOAD16_BYTE( "urm06-02.bin", 0x10001, 0x4000, CRC(1147760b) SHA1(4e0299091dfd53ac7988d40c5a6775a10389faac) ) |
| 1255 | |
| 1256 | ROM_REGION( 0x8000, "fdc_bios_2dd", ROMREGION_ERASEFF ) // 2dd fdc bios, presumably bad size (should be 0x800 for each rom) |
| 1257 | ROM_LOAD16_BYTE( "urf01-01.bin", 0x00000, 0x4000, BAD_DUMP CRC(2f5ae147) SHA1(69eb264d520a8fc826310b4fce3c8323867520ee) ) |
| 1258 | ROM_LOAD16_BYTE( "urf02-01.bin", 0x00001, 0x4000, BAD_DUMP CRC(62a86928) SHA1(4160a6db096dbeff18e50cbee98f5d5c1a29e2d1) ) |
| 1259 | |
| 1260 | ROM_REGION( 0x800, "kbd_mcu", ROMREGION_ERASEFF) |
| 1261 | ROM_LOAD( "mcu.bin", 0x0000, 0x0800, NO_DUMP ) //connected thru a i8251 UART, needs decapping |
| 1262 | |
| 1263 | /* note: ROM names of following two might be swapped */ |
| 1264 | ROM_REGION( 0x0800, "chargen", 0 ) |
| 1265 | ROM_LOAD( "d23128c-17.bin", 0x00000, 0x00800, BAD_DUMP CRC(eea57180) SHA1(4aa037c684b72ad4521212928137d3369174eb1e) ) //original is a bad dump, this is taken from i386 model |
| 1266 | |
| 1267 | ROM_REGION( 0x8000, "unk_gfx", 0) |
| 1268 | ROM_LOAD("hn613128pac8.bin", 0x0000, 0x4000, NO_DUMP ) //bad dump, dunno what this is supposed to be (it's on the kanji board) |
| 1269 | |
| 1270 | ROM_REGION( 0x20000, "kanji", ROMREGION_ERASEFF ) |
| 1271 | ROM_LOAD16_BYTE( "24256c-x01.bin", 0x00000, 0x8000, CRC(28ec1375) SHA1(9d8e98e703ce0f483df17c79f7e841c5c5cd1692) ) |
| 1272 | ROM_LOAD16_BYTE( "24256c-x02.bin", 0x00001, 0x8000, CRC(90985158) SHA1(78fb106131a3f4eb054e87e00fe4f41193416d65) ) |
| 1273 | ROM_LOAD16_BYTE( "24256c-x03.bin", 0x10000, 0x8000, CRC(d4893543) SHA1(eb8c1bee0f694e1e0c145a24152222d4e444e86f) ) |
| 1274 | ROM_LOAD16_BYTE( "24256c-x04.bin", 0x10001, 0x8000, CRC(5dec0fc2) SHA1(41000da14d0805ed0801b31eb60623552e50e41c) ) |
| 1275 | |
| 1276 | ROM_REGION( 0x80000, "pcg", ROMREGION_ERASEFF ) |
| 1277 | |
| 1278 | ROM_END |
| 1279 | |
| 1280 | COMP( 1983, pc9801f, 0, 0, pc9801, pc9801, 0, "Nippon Electronic Company", "PC-9801F", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND) |