src/mess/drivers/fmtowns.c
| r5937 | r5938 | |
| 83 | 83 | static UINT8 nmi_mask; |
| 84 | 84 | static UINT8 compat_mode; |
| 85 | 85 | static UINT8 towns_system_port; |
| 86 | static UINT32 towns_ankcg_enable; |
| 87 | static UINT32 towns_mainmem_enable; |
| 88 | static UINT32 towns_ram_enable; |
| 86 | 89 | static UINT32* towns_vram; |
| 87 | 90 | static UINT32* towns_cmos; |
| 88 | | static UINT32* towns_gfxvram; |
| 89 | | static UINT32* towns_txtvram; |
| 91 | static UINT8* towns_gfxvram; |
| 92 | static UINT8* towns_txtvram; |
| 93 | static UINT8 towns_vram_wplane; |
| 94 | static UINT8 towns_vram_rplane; |
| 95 | static UINT8 towns_palette_select; |
| 96 | static UINT8 towns_palette_r[256]; |
| 97 | static UINT8 towns_palette_g[256]; |
| 98 | static UINT8 towns_palette_b[256]; |
| 99 | static UINT8 towns_degipal[8]; |
| 90 | 100 | |
| 101 | static void towns_update_video_banks(const address_space* space); |
| 102 | |
| 91 | 103 | static READ8_HANDLER(towns_system_r) |
| 92 | 104 | { |
| 93 | 105 | switch(offset) |
| r5937 | r5938 | |
| 209 | 221 | logerror("VID: wrote 0x%02x to port %04x\n",data,offset+0x5c8); |
| 210 | 222 | } |
| 211 | 223 | |
| 224 | /* Video/CRTC |
| 225 | * |
| 226 | * 0xfd90 - palette colour select |
| 227 | * 0xfd92/4/6 - BRG value |
| 228 | * 0xfd98-9f - degipal(?) |
| 229 | */ |
| 212 | 230 | static READ8_HANDLER(towns_video_fd90_r) |
| 213 | 231 | { |
| 214 | | logerror("VID: read port %04x\n",offset+0xfd90); |
| 232 | switch(offset) |
| 233 | { |
| 234 | case 0x00: |
| 235 | return towns_palette_select; |
| 236 | case 0x02: |
| 237 | return towns_palette_r[towns_palette_select]; |
| 238 | case 0x04: |
| 239 | return towns_palette_g[towns_palette_select]; |
| 240 | case 0x06: |
| 241 | return towns_palette_b[towns_palette_select]; |
| 242 | case 0x08: |
| 243 | case 0x09: |
| 244 | case 0x0a: |
| 245 | case 0x0b: |
| 246 | case 0x0c: |
| 247 | case 0x0d: |
| 248 | case 0x0e: |
| 249 | case 0x0f: |
| 250 | return towns_degipal[offset-0x08]; |
| 251 | } |
| 252 | // logerror("VID: read port %04x\n",offset+0xfd90); |
| 215 | 253 | return 0x00; |
| 216 | 254 | } |
| 217 | 255 | |
| 218 | 256 | static WRITE8_HANDLER(towns_video_fd90_w) |
| 219 | 257 | { |
| 220 | | logerror("VID: wrote 0x%02x to port %04x\n",data,offset+0xfd90); |
| 258 | switch(offset) |
| 259 | { |
| 260 | case 0x00: |
| 261 | towns_palette_select = data; |
| 262 | break; |
| 263 | case 0x02: |
| 264 | towns_palette_r[towns_palette_select] = data; |
| 265 | break; |
| 266 | case 0x04: |
| 267 | towns_palette_g[towns_palette_select] = data; |
| 268 | break; |
| 269 | case 0x06: |
| 270 | towns_palette_b[towns_palette_select] = data; |
| 271 | break; |
| 272 | case 0x08: |
| 273 | case 0x09: |
| 274 | case 0x0a: |
| 275 | case 0x0b: |
| 276 | case 0x0c: |
| 277 | case 0x0d: |
| 278 | case 0x0e: |
| 279 | case 0x0f: |
| 280 | towns_degipal[offset-0x08] = data; |
| 281 | break; |
| 282 | } |
| 283 | // logerror("VID: wrote 0x%02x to port %04x\n",data,offset+0xfd90); |
| 221 | 284 | } |
| 222 | 285 | |
| 223 | | static READ8_HANDLER(towns_video_ff81_r) |
| 224 | | { |
| 225 | | logerror("VID: read port ff81\n"); |
| 226 | | return 0x00; |
| 227 | | } |
| 228 | | |
| 229 | | static WRITE8_HANDLER(towns_video_ff81_w) |
| 230 | | { |
| 231 | | logerror("VID: wrote 0x%02x to port ff81\n",data); |
| 232 | | } |
| 233 | | |
| 234 | 286 | static READ8_HANDLER(towns_keyboard_r) |
| 235 | 287 | { |
| 236 | 288 | logerror("KB: read offset %02x\n",offset); |
| r5937 | r5938 | |
| 268 | 320 | if(ACCESSING_BITS_0_7) |
| 269 | 321 | { |
| 270 | 322 | logerror("SYS: read RAM size port\n"); |
| 271 | | return 0x06; // 6MB is standard for the Marty |
| 323 | return 0x08; // 6MB is standard for the Marty |
| 272 | 324 | } |
| 273 | 325 | break; |
| 274 | 326 | case 0x01: |
| r5937 | r5938 | |
| 334 | 386 | COMBINE_DATA(towns_cmos+offset); |
| 335 | 387 | } |
| 336 | 388 | |
| 389 | static WRITE8_HANDLER( towns_gfx_w ) |
| 390 | { |
| 391 | if(towns_mainmem_enable != 0) |
| 392 | { |
| 393 | mess_ram[offset+0xc0000] = data; |
| 394 | return; |
| 395 | } |
| 396 | if(towns_vram_wplane & 0x01) |
| 397 | towns_gfxvram[offset] = data; |
| 398 | if(towns_vram_wplane & 0x02) |
| 399 | towns_gfxvram[offset + 0x8000] = data; |
| 400 | if(towns_vram_wplane & 0x04) |
| 401 | towns_gfxvram[offset + 0x10000] = data; |
| 402 | if(towns_vram_wplane & 0x08) |
| 403 | towns_gfxvram[offset + 0x18000] = data; |
| 404 | } |
| 405 | |
| 406 | static READ8_HANDLER( towns_video_cff80_r ) |
| 407 | { |
| 408 | if(towns_mainmem_enable != 0) |
| 409 | return mess_ram[offset+0xcff80]; |
| 410 | |
| 411 | switch(offset) |
| 412 | { |
| 413 | case 0x01: // read/write plane select (bit 0-3 write, bit 6-7 read) |
| 414 | return ((towns_vram_rplane << 6) & 0xc0) | towns_vram_wplane; |
| 415 | case 0x19: // ANK CG ROM |
| 416 | if(towns_ankcg_enable != 0) |
| 417 | return 0x01; |
| 418 | else |
| 419 | return 0x00; |
| 420 | default: |
| 421 | logerror("VGA: read from invalid or unimplemented memory-mapped port %05x\n",0xcff80+offset*4); |
| 422 | } |
| 423 | |
| 424 | return 0; |
| 425 | } |
| 426 | |
| 427 | static WRITE8_HANDLER( towns_video_cff80_w ) |
| 428 | { |
| 429 | if(towns_mainmem_enable != 0) |
| 430 | { |
| 431 | mess_ram[offset+0xcff80] = data; |
| 432 | return; |
| 433 | } |
| 434 | |
| 435 | switch(offset) |
| 436 | { |
| 437 | case 0x01: // read/write plane select (bit 0-3 write, bit 6-7 read) |
| 438 | towns_vram_wplane = data & 0x0f; |
| 439 | towns_vram_rplane = (data & 0xc0) >> 6; |
| 440 | towns_update_video_banks(space); |
| 441 | logerror("VGA: VRAM wplane select = 0x%02x\n",towns_vram_wplane); |
| 442 | break; |
| 443 | case 0x19: // ANK CG ROM |
| 444 | towns_ankcg_enable = data & 0x00000100; |
| 445 | towns_update_video_banks(space); |
| 446 | break; |
| 447 | default: |
| 448 | logerror("VGA: write %08x to invalid or unimplemented memory-mapped port %05x\n",data,0xcff80+offset); |
| 449 | } |
| 450 | } |
| 451 | |
| 452 | static void towns_update_video_banks(const address_space* space) |
| 453 | { |
| 454 | UINT8* ROM; |
| 455 | |
| 456 | if(towns_mainmem_enable != 0) // first MB is RAM |
| 457 | { |
| 458 | memory_set_bankptr(space->machine,1,mess_ram+0xc0000); |
| 459 | memory_set_bankptr(space->machine,2,mess_ram+0xc8000); |
| 460 | memory_set_bankptr(space->machine,3,mess_ram+0xc9000); |
| 461 | memory_set_bankptr(space->machine,4,mess_ram+0xca000); |
| 462 | memory_set_bankptr(space->machine,5,mess_ram+0xca000); |
| 463 | memory_set_bankptr(space->machine,10,mess_ram+0xca800); |
| 464 | memory_set_bankptr(space->machine,6,mess_ram+0xcb000); |
| 465 | memory_set_bankptr(space->machine,7,mess_ram+0xcb000); |
| 466 | memory_set_bankptr(space->machine,8,mess_ram+0xcc000); |
| 467 | memory_set_bankptr(space->machine,11,mess_ram+0xf8000); |
| 468 | memory_set_bankptr(space->machine,12,mess_ram+0xf8000); |
| 469 | return; |
| 470 | } |
| 471 | else // enable I/O ports and VRAM |
| 472 | { |
| 473 | ROM = memory_region(space->machine,"user"); |
| 474 | |
| 475 | memory_set_bankptr(space->machine,1,towns_gfxvram+(towns_vram_rplane*0x8000)); |
| 476 | memory_set_bankptr(space->machine,2,towns_txtvram); |
| 477 | memory_set_bankptr(space->machine,3,mess_ram+0xc9000); |
| 478 | if(towns_ankcg_enable == 0) |
| 479 | memory_set_bankptr(space->machine,4,ROM+0x180000+0x3d000); // ANK CG 8x8 |
| 480 | else |
| 481 | memory_set_bankptr(space->machine,4,towns_txtvram+0x2000); |
| 482 | memory_set_bankptr(space->machine,5,towns_txtvram+0x2000); |
| 483 | memory_set_bankptr(space->machine,10,mess_ram+0xca800); |
| 484 | if(towns_ankcg_enable == 0) |
| 485 | memory_set_bankptr(space->machine,6,ROM+0x180000+0x3d800); // ANK CG 8x16 |
| 486 | else |
| 487 | memory_set_bankptr(space->machine,6,mess_ram+0xcb000); |
| 488 | memory_set_bankptr(space->machine,7,mess_ram+0xcb000); |
| 489 | memory_set_bankptr(space->machine,8,mess_ram+0xcc000); |
| 490 | memory_set_bankptr(space->machine,11,ROM+0x238000); |
| 491 | memory_set_bankptr(space->machine,12,mess_ram+0xf8000); |
| 492 | return; |
| 493 | } |
| 494 | } |
| 495 | |
| 337 | 496 | static READ8_HANDLER( towns_sys480_r ) |
| 338 | 497 | { |
| 339 | 498 | if(towns_system_port & 0x02) |
| r5937 | r5938 | |
| 345 | 504 | static WRITE8_HANDLER( towns_sys480_w ) |
| 346 | 505 | { |
| 347 | 506 | towns_system_port = data; |
| 507 | towns_ram_enable = data & 0x02; |
| 508 | towns_update_video_banks(space); |
| 348 | 509 | } |
| 349 | 510 | |
| 511 | static WRITE32_HANDLER( towns_video_404_w ) |
| 512 | { |
| 513 | if(ACCESSING_BITS_0_7) |
| 514 | { |
| 515 | towns_mainmem_enable = data & 0x80; |
| 516 | towns_update_video_banks(space); |
| 517 | } |
| 518 | } |
| 519 | |
| 520 | static READ32_HANDLER( towns_video_404_r ) |
| 521 | { |
| 522 | if(towns_mainmem_enable != 0) |
| 523 | return 0x00000080; |
| 524 | |
| 525 | return 0; |
| 526 | } |
| 527 | |
| 528 | static READ8_HANDLER(towns_video_ff81_r) |
| 529 | { |
| 530 | return ((towns_vram_rplane << 6) & 0xc0) | towns_vram_wplane; |
| 531 | } |
| 532 | |
| 533 | static WRITE8_HANDLER(towns_video_ff81_w) |
| 534 | { |
| 535 | towns_vram_wplane = data & 0x0f; |
| 536 | towns_vram_rplane = (data & 0xc0) >> 6; |
| 537 | towns_update_video_banks(space); |
| 538 | logerror("VGA: VRAM wplane select (I/O) = 0x%02x\n",towns_vram_wplane); |
| 539 | } |
| 540 | |
| 350 | 541 | static ADDRESS_MAP_START(towns_mem, ADDRESS_SPACE_PROGRAM, 32) |
| 351 | 542 | // memory map based on FM-Towns/Bochs (Bochs modified to emulate the FM-Towns) |
| 352 | 543 | // may not be (and probably is not) correct |
| 353 | 544 | AM_RANGE(0x00000000, 0x000bffff) AM_RAM |
| 354 | | AM_RANGE(0x000c0000, 0x000c7fff) AM_RAM AM_BASE(&towns_gfxvram) // GVRAM |
| 355 | | AM_RANGE(0x000c8000, 0x000cffff) AM_RAM AM_BASE(&towns_txtvram) // TVRAM |
| 356 | | // AM_RANGE(0x000ca000, 0x000cafff) AM_RAM AM_BASE(&towns_txtvram) // TVRAM |
| 545 | AM_RANGE(0x000c0000, 0x000c7fff) AM_READ(SMH_BANK(1)) |
| 546 | AM_RANGE(0x000c0000, 0x000c7fff) AM_WRITE8(towns_gfx_w,0xffffffff) |
| 547 | AM_RANGE(0x000c8000, 0x000c8fff) AM_READWRITE(SMH_BANK(2),SMH_BANK(2)) |
| 548 | AM_RANGE(0x000c9000, 0x000c9fff) AM_READWRITE(SMH_BANK(3),SMH_BANK(3)) |
| 549 | AM_RANGE(0x000ca000, 0x000ca7ff) AM_READWRITE(SMH_BANK(4),SMH_BANK(5)) |
| 550 | AM_RANGE(0x000ca800, 0x000cafff) AM_READWRITE(SMH_BANK(10),SMH_BANK(10)) |
| 551 | AM_RANGE(0x000cb000, 0x000cbfff) AM_READWRITE(SMH_BANK(6),SMH_BANK(7)) |
| 552 | AM_RANGE(0x000cc000, 0x000cff7f) AM_READWRITE(SMH_BANK(8),SMH_BANK(8)) |
| 553 | AM_RANGE(0x000cff80, 0x000cffff) AM_READWRITE8(towns_video_cff80_r,towns_video_cff80_w,0xffffffff) |
| 357 | 554 | AM_RANGE(0x000d0000, 0x000d7fff) AM_RAM |
| 358 | 555 | AM_RANGE(0x000d8000, 0x000d9fff) AM_READWRITE(towns_cmos_r,towns_cmos_w) // CMOS? RAM |
| 359 | | AM_RANGE(0x000da000, 0x000effff) AM_RAM |
| 360 | | AM_RANGE(0x000f0000, 0x000f7fff) AM_RAM |
| 361 | | AM_RANGE(0x000f8000, 0x000fffff) AM_RAM AM_REGION("user",0x238000) // BOOT (SYSTEM) ROM |
| 556 | AM_RANGE(0x000da000, 0x000effff) AM_RAM //READWRITE(SMH_BANK(11),SMH_BANK(11)) |
| 557 | AM_RANGE(0x000f0000, 0x000f7fff) AM_RAM //READWRITE(SMH_BANK(12),SMH_BANK(12)) |
| 558 | AM_RANGE(0x000f8000, 0x000fffff) AM_READWRITE(SMH_BANK(11),SMH_BANK(12)) |
| 362 | 559 | AM_RANGE(0x00100000, 0x005fffff) AM_RAM // some extra RAM - seems to be needed to boot |
| 363 | 560 | AM_RANGE(0x80000000, 0x8003ffff) AM_RAM AM_MIRROR(0x1c0000) AM_BASE(&towns_vram) // VRAM |
| 364 | 561 | AM_RANGE(0x81000000, 0x8101ffff) AM_RAM // Sprite RAM |
| r5937 | r5938 | |
| 387 | 584 | AM_RANGE(0x0200,0x020f) AM_READWRITE8(towns_floppy_r, towns_floppy_w, 0xffffffff) |
| 388 | 585 | // CRTC / Video |
| 389 | 586 | AM_RANGE(0x0400,0x0403) AM_NOP // R/O (0x400) |
| 390 | | AM_RANGE(0x0404,0x0407) AM_NOP // R/W (0x404) |
| 587 | AM_RANGE(0x0404,0x0407) AM_READWRITE(towns_video_404_r, towns_video_404_w) // R/W (0x404) |
| 391 | 588 | AM_RANGE(0x0440,0x045f) AM_READWRITE8(towns_video_440_r, towns_video_440_w, 0xffffffff) |
| 392 | 589 | // System port |
| 393 | 590 | AM_RANGE(0x0480,0x0483) AM_READWRITE8(towns_sys480_r,towns_sys480_w,0xff000000) // R/W (0x480) |
| r5937 | r5938 | |
| 426 | 623 | { |
| 427 | 624 | towns_vram = auto_alloc_array(machine,UINT32,0x20000); |
| 428 | 625 | towns_cmos = auto_alloc_array(machine,UINT32,0x2000/(sizeof(UINT32))); |
| 429 | | towns_gfxvram = auto_alloc_array(machine,UINT32,0x8000/(sizeof(UINT32))); |
| 430 | | towns_txtvram = auto_alloc_array(machine,UINT32,0x8000/(sizeof(UINT32))); |
| 626 | towns_gfxvram = auto_alloc_array(machine,UINT8,0x200000); |
| 627 | towns_txtvram = auto_alloc_array(machine,UINT8,0x8000); |
| 431 | 628 | } |
| 432 | 629 | |
| 433 | 630 | static MACHINE_RESET( towns ) |
| r5937 | r5938 | |
| 435 | 632 | ftimer = 0x00; |
| 436 | 633 | nmi_mask = 0x00; |
| 437 | 634 | compat_mode = 0x00; |
| 635 | towns_ankcg_enable = 0x00; |
| 636 | towns_mainmem_enable = 0x00; |
| 637 | towns_ram_enable = 0x00; |
| 638 | towns_update_video_banks(cpu_get_address_space(cputag_get_cpu(machine,"maincpu"),ADDRESS_SPACE_PROGRAM)); |
| 639 | towns_vram_wplane = 0x00; |
| 438 | 640 | } |
| 439 | 641 | |
| 440 | 642 | static VIDEO_START( towns ) |
| r5937 | r5938 | |
| 444 | 646 | static VIDEO_UPDATE( towns ) |
| 445 | 647 | { |
| 446 | 648 | int x,y; |
| 447 | | int pixel = 0; |
| 649 | UINT8 dat1,dat2,dat3,dat4; |
| 650 | int bit; |
| 651 | UINT8 colour; |
| 448 | 652 | |
| 449 | 653 | for(y=0;y<480;y++) |
| 450 | 654 | { |
| 451 | 655 | for(x=0;x<640;x++) |
| 452 | 656 | { |
| 453 | | *BITMAP_ADDR32(bitmap,y,x) = towns_vram[pixel++]; |
| 454 | | if(pixel >= 0x20000) |
| 455 | | pixel = 0; |
| 657 | bit = 7 - (x & 0x07); |
| 658 | dat1 = towns_gfxvram[(x/8) + (y*0x50)]; |
| 659 | dat2 = towns_gfxvram[(x/8) + (y*0x50) + 0x8000]; |
| 660 | dat3 = towns_gfxvram[(x/8) + (y*0x50) + 0x10000]; |
| 661 | dat4 = towns_gfxvram[(x/8) + (y*0x50) + 0x18000]; |
| 662 | colour = (dat1 & (1 << bit) ? 8 : 0) |
| 663 | | (dat2 & (1 << bit) ? 4 : 0) |
| 664 | | (dat3 & (1 << bit) ? 2 : 0) |
| 665 | | (dat4 & (1 << bit) ? 1 : 0); |
| 666 | *BITMAP_ADDR32(bitmap,y,x) = |
| 667 | (towns_palette_r[colour] << 16) |
| 668 | | (towns_palette_g[colour] << 8) |
| 669 | | (towns_palette_b[colour]); |
| 456 | 670 | } |
| 457 | 671 | } |
| 458 | 672 | |
| r5937 | r5938 | |
| 488 | 702 | NULL |
| 489 | 703 | }; |
| 490 | 704 | |
| 705 | static SYSTEM_CONFIG_START(towns) |
| 706 | CONFIG_RAM_DEFAULT(0x6000000) // 6MB will do to start, standard amount for the Marty |
| 707 | SYSTEM_CONFIG_END |
| 708 | |
| 491 | 709 | static MACHINE_DRIVER_START( towns ) |
| 492 | 710 | /* basic machine hardware */ |
| 493 | 711 | MDRV_CPU_ADD("maincpu",I386, 16000000) |
| r5937 | r5938 | |
| 551 | 769 | /* Driver */ |
| 552 | 770 | |
| 553 | 771 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME FLAGS */ |
| 554 | | COMP( 1989, fmtowns, 0, 0, towns, towns, towns, 0, "Fujitsu", "FM-Towns", GAME_NOT_WORKING) |
| 555 | | COMP( 1989, fmtownsa, fmtowns, 0, towns, towns, towns, 0, "Fujitsu", "FM-Towns (alternate)", GAME_NOT_WORKING) |
| 556 | | CONS( 1993, fmtmarty, 0, 0, towns, towns, towns, 0, "Fujitsu", "FM-Towns Marty", GAME_NOT_WORKING) |
| 772 | COMP( 1989, fmtowns, 0, 0, towns, towns, towns, towns, "Fujitsu", "FM-Towns", GAME_NOT_WORKING) |
| 773 | COMP( 1989, fmtownsa, fmtowns, 0, towns, towns, towns, towns, "Fujitsu", "FM-Towns (alternate)", GAME_NOT_WORKING) |
| 774 | CONS( 1993, fmtmarty, 0, 0, towns, towns, towns, towns, "Fujitsu", "FM-Towns Marty", GAME_NOT_WORKING) |
| 557 | 775 | |