src/mess/drivers/x1.c
| r5513 | r5514 | |
| 6 | 6 | |
| 7 | 7 | TODO: |
| 8 | 8 | - Understand how keyboard works and decap/dump the keyboard MCU if possible; |
| 9 | | - Hook-up image formats; |
| 10 | | - Video part is bare minimum, chances are that's probably a tilemap/bitmap nightmare; |
| 11 | | - Sort out / redump the gfx roms; |
| 9 | - Hook-up .d88 and .tap image formats (.rom too?); |
| 10 | - Sort out / redump the BIOS gfx roms; |
| 12 | 11 | - Fix the interrupts (uses IM 2) |
| 12 | - Add multiple FDC drive support; |
| 13 | - clean-ups! |
| 14 | - There are various unclear video things, these are: |
| 15 | - how layer clearance works? Dragon Buster relies on it |
| 16 | - fg tilemap colors are wrong, the Shanghai "hit any key" msg must be blue with white |
| 17 | background; |
| 18 | - I bet there's a PCG reset address tied to some bit, find it; |
| 19 | - Add the extended gfx hookup; |
| 20 | - (anything else?) |
| 13 | 21 | |
| 14 | 22 | per-game specific TODO: |
| 15 | | - 177 / Dragon Buster: fix the keyboard flags otherwise these doesn't boot; |
| 16 | | - Dragon Buster: Maybe the pcg tilemap uses scrolling and priorities are wrong; |
| 23 | - 177 / Dragon Buster / (many others): fix the keyboard obf flag otherwise these doesn't boot; |
| 17 | 24 | - Shanghai: tests the ay8910 read regs, mouse/joystick perhaps? |
| 18 | 25 | - Gaia/Space Harrier: Hits the FDC drive assert, the latter boots but has heavy emulation |
| 19 | 26 | video/logic problems; |
| 27 | - "alpha": Apparently does use the DMA feature (writes z80 code?), investigate; |
| 20 | 28 | |
| 21 | 29 | Notes: |
| 22 | 30 | - An interesting feature of the Sharp X-1 is the extended i/o bank. When the ppi port c bit 5 |
| r5513 | r5514 | |
| 137 | 145 | static UINT8 hres_320,io_switch,io_sys; |
| 138 | 146 | static UINT8 io_bank_mode; |
| 139 | 147 | static UINT8 *gfx_bitmap_ram; |
| 148 | static UINT16 pcg_index[3]; |
| 140 | 149 | |
| 141 | 150 | |
| 142 | 151 | static VIDEO_START( x1 ) |
| r5513 | r5514 | |
| 154 | 163 | |
| 155 | 164 | bitmap_fill(bitmap, cliprect, 0); |
| 156 | 165 | |
| 166 | for (y=0;y<25;y++) |
| 157 | 167 | { |
| 168 | for (x=0;x<40*w;x++) |
| 169 | { |
| 170 | int tile = videoram[x+(y*40*w)]; |
| 171 | int color = colorram[x+(y*40*w)] & 0x1f; |
| 172 | int width = (colorram[x+(y*40*w)] & 0x80)>>7; |
| 173 | int height = (colorram[x+(y*40*w)] & 0x40)>>6; |
| 174 | int pcg_bank = (colorram[x+(y*40*w)] & 0x20)>>4; |
| 175 | int region = (width+(height<<1)) & 3; |
| 176 | |
| 177 | if(pcg_bank) { region+= 4; } |
| 178 | |
| 179 | if(color & 0x8) continue; |
| 180 | |
| 181 | drawgfx_opaque(bitmap,cliprect,screen->machine->gfx[region],tile,color,0,0,(x/(width+1))*8*(width+1),(y/(height+1))*8*(height+1)); |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | { |
| 158 | 186 | int count,xi,yi; |
| 159 | 187 | int pen_r,pen_g,pen_b,color; |
| 160 | 188 | int yi_size; |
| r5513 | r5514 | |
| 175 | 203 | pen_g = (gfx_bitmap_ram[count+0x8000]>>(7-xi)) & 1; |
| 176 | 204 | pen_b = (gfx_bitmap_ram[count+0x0000]>>(7-xi)) & 1; |
| 177 | 205 | |
| 178 | | color = pen_r<<2 | pen_g<<1 | pen_b<<0; |
| 206 | color = pen_r<<1 | pen_g<<2 | pen_b<<0; |
| 179 | 207 | |
| 208 | if(color == 0) |
| 209 | continue; |
| 210 | |
| 180 | 211 | if(w == 1) |
| 181 | 212 | { |
| 182 | 213 | if(yi & 1) |
| r5513 | r5514 | |
| 210 | 241 | int region = (width+(height<<1)) & 3; |
| 211 | 242 | |
| 212 | 243 | if(pcg_bank) { region+= 4; } |
| 213 | | else if(tile == 0) continue; //<- correct? |
| 214 | 244 | |
| 215 | | if(color & 0x38) |
| 216 | | drawgfx_opaque(bitmap,cliprect,screen->machine->gfx[region],tile,color,0,0,(x/(width+1))*8*(width+1),(y/(height+1))*8*(height+1)); |
| 217 | | else |
| 218 | | drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[region],tile,color,0,0,(x/(width+1))*8*(width+1),(y/(height+1))*8*(height+1),0); |
| 245 | if(!(color & 0x8)) continue; |
| 246 | |
| 247 | drawgfx_opaque(bitmap,cliprect,screen->machine->gfx[region],tile,color,0,0,(x/(width+1))*8*(width+1),(y/(height+1))*8*(height+1)); |
| 219 | 248 | } |
| 220 | 249 | } |
| 221 | | |
| 222 | 250 | return 0; |
| 223 | 251 | } |
| 224 | 252 | |
| r5513 | r5514 | |
| 452 | 480 | |
| 453 | 481 | static WRITE8_HANDLER( x1_dma_w ) |
| 454 | 482 | { |
| 455 | | if(data) |
| 456 | | fatalerror("Data written to the DMA space"); |
| 483 | printf("%02x %02x\n",offset,data); |
| 484 | //if(data) |
| 485 | // fatalerror("Data written to the DMA space"); |
| 457 | 486 | } |
| 458 | 487 | |
| 459 | 488 | static WRITE8_HANDLER( x1_pcg_w ) |
| 460 | 489 | { |
| 461 | 490 | int addr,pcg_offset; |
| 462 | | static int pcg_index[3]; |
| 463 | 491 | UINT8 *PCG_RAM = memory_region(space->machine, "pcg"); |
| 464 | 492 | |
| 465 | 493 | addr = (offset & 0x300) >> 8; |
| r5513 | r5514 | |
| 527 | 555 | // else if(offset >= 0x0e80 && offset <= 0x0e82) { x1_kanji_w(space->machine, offset-0xe80,data); } |
| 528 | 556 | else if(offset >= 0x0ff8 && offset <= 0x0fff) { x1_fdc_w(space, offset-0xff8,data); } |
| 529 | 557 | else if(offset >= 0x1000 && offset <= 0x10ff) { x1_pal_b_w(space, 0,data); } |
| 530 | | else if(offset >= 0x1100 && offset <= 0x11ff) { x1_pal_g_w(space, 0,data); } |
| 531 | | else if(offset >= 0x1200 && offset <= 0x12ff) { x1_pal_r_w(space, 0,data); } |
| 558 | else if(offset >= 0x1100 && offset <= 0x11ff) { x1_pal_r_w(space, 0,data); } |
| 559 | else if(offset >= 0x1200 && offset <= 0x12ff) { x1_pal_g_w(space, 0,data); } |
| 532 | 560 | // else if(offset >= 0x1300 && offset <= 0x13ff) { x1_ply_w(space->machine, 0,data; } |
| 533 | 561 | else if(offset >= 0x1400 && offset <= 0x17ff) { x1_pcg_w(space, offset-0x1400,data); } |
| 534 | 562 | else if(offset == 0x1800 ) { mc6845_address_w(devtag_get_device(space->machine, "crtc"), 0,data); } |
| r5513 | r5514 | |
| 613 | 641 | 8,8, |
| 614 | 642 | RGN_FRAC(1,3), |
| 615 | 643 | 3, |
| 616 | | { RGN_FRAC(1,3),RGN_FRAC(2,3),RGN_FRAC(0,3) }, |
| 644 | { RGN_FRAC(2,3),RGN_FRAC(1,3),RGN_FRAC(0,3) }, |
| 617 | 645 | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 618 | 646 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, |
| 619 | 647 | 8*8 |
| r5513 | r5514 | |
| 624 | 652 | 16,8, |
| 625 | 653 | RGN_FRAC(1,3), |
| 626 | 654 | 3, |
| 627 | | { RGN_FRAC(1,3),RGN_FRAC(2,3),RGN_FRAC(0,3) }, |
| 655 | { RGN_FRAC(2,3),RGN_FRAC(1,3),RGN_FRAC(0,3) }, |
| 628 | 656 | { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7 }, |
| 629 | 657 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, |
| 630 | 658 | 8*8 |
| r5513 | r5514 | |
| 635 | 663 | 8,16, |
| 636 | 664 | RGN_FRAC(1,3), |
| 637 | 665 | 3, |
| 638 | | { RGN_FRAC(1,3),RGN_FRAC(2,3),RGN_FRAC(0,3) }, |
| 666 | { RGN_FRAC(2,3),RGN_FRAC(1,3),RGN_FRAC(0,3) }, |
| 639 | 667 | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 640 | 668 | { 0*8, 0*8, 1*8, 1*8, 2*8, 2*8, 3*8, 3*8, 4*8, 4*8, 5*8, 5*8, 6*8, 6*8, 7*8, 7*8 }, |
| 641 | 669 | 8*8 |
| r5513 | r5514 | |
| 646 | 674 | 16,16, |
| 647 | 675 | RGN_FRAC(1,3), |
| 648 | 676 | 3, |
| 649 | | { RGN_FRAC(1,3),RGN_FRAC(2,3),RGN_FRAC(0,3) }, |
| 677 | { RGN_FRAC(2,3),RGN_FRAC(1,3),RGN_FRAC(0,3) }, |
| 650 | 678 | { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7 }, |
| 651 | 679 | { 0*8, 0*8, 1*8, 1*8, 2*8, 2*8, 3*8, 3*8, 4*8, 4*8, 5*8, 5*8, 6*8, 6*8, 7*8, 7*8 }, |
| 652 | 680 | 8*8 |
| r5513 | r5514 | |
| 669 | 697 | GFXDECODE_ENTRY( "cgrom", 0x00000, x1_chars_8wx8, 0, 0x40 ) |
| 670 | 698 | GFXDECODE_ENTRY( "cgrom", 0x00000, x1_chars_8x8w, 0, 0x40 ) |
| 671 | 699 | GFXDECODE_ENTRY( "cgrom", 0x00000, x1_chars_8wx8w, 0, 0x40 ) |
| 672 | | GFXDECODE_ENTRY( "pcg", 0x00000, x1_pcg_8x8, 0x80, 1 ) |
| 673 | | GFXDECODE_ENTRY( "pcg", 0x00000, x1_pcg_8wx8, 0x80, 1 ) |
| 674 | | GFXDECODE_ENTRY( "pcg", 0x00000, x1_pcg_8x8w, 0x80, 1 ) |
| 675 | | GFXDECODE_ENTRY( "pcg", 0x00000, x1_pcg_8wx8w, 0x80, 1 ) |
| 700 | GFXDECODE_ENTRY( "pcg", 0x00000, x1_pcg_8x8, 0x100, 1 ) |
| 701 | GFXDECODE_ENTRY( "pcg", 0x00000, x1_pcg_8wx8, 0x100, 1 ) |
| 702 | GFXDECODE_ENTRY( "pcg", 0x00000, x1_pcg_8x8w, 0x100, 1 ) |
| 703 | GFXDECODE_ENTRY( "pcg", 0x00000, x1_pcg_8wx8w, 0x100, 1 ) |
| 676 | 704 | GFXDECODE_ENTRY( "cgrom", 0x01800, x1_chars_16x16, 0, 0x40 ) //only x1turboz uses this so far |
| 677 | 705 | GFXDECODE_ENTRY( "kanji", 0x27000, x1_chars_16x16, 0, 0x40 ) //needs to be checked when the ROM will be redumped |
| 678 | 706 | GFXDECODE_END |
| r5513 | r5514 | |
| 684 | 712 | for(i=0;i<0x300;i++) |
| 685 | 713 | palette_set_color(machine, i,MAKE_RGB(0x00,0x00,0x00)); |
| 686 | 714 | |
| 687 | | for (i = 0; i < 64; i++) //text mode colors |
| 715 | for (i = 0; i < 0x20; i++) |
| 688 | 716 | { |
| 689 | | palette_set_color_rgb(machine, 2*i+1, pal1bit(i >> 2), pal1bit(i >> 1), pal1bit(i >> 0)); |
| 690 | | palette_set_color_rgb(machine, 2*i+0, pal1bit(i >> 5), pal1bit(i >> 4), pal1bit(i >> 3)); |
| 717 | rgb_t color; |
| 718 | |
| 719 | if (i & 0x01) |
| 720 | color = MAKE_RGB(pal1bit(i >> 3), pal1bit(i >> 2), pal1bit(i >> 1)); |
| 721 | else |
| 722 | color = (i & 0x10) ? RGB_WHITE : RGB_BLACK; |
| 723 | |
| 724 | palette_set_color(machine, i, color); |
| 691 | 725 | } |
| 692 | 726 | |
| 693 | 727 | /* TODO: fix this */ |
| 694 | 728 | for(i=0;i<8;i++) |
| 695 | | palette_set_color_rgb(machine, i+0x80, pal1bit(i >> 2), pal1bit(i >> 1), pal1bit(i >> 0)); |
| 729 | palette_set_color_rgb(machine, i+0x100, pal1bit(i >> 2), pal1bit(i >> 1), pal1bit(i >> 0)); |
| 696 | 730 | } |
| 697 | 731 | |
| 698 | 732 | static READ8_DEVICE_HANDLER( x1_porta_r ) |
| 699 | 733 | { |
| 700 | | //printf("PPI Port A read\n"); |
| 734 | printf("PPI Port A read\n"); |
| 701 | 735 | return 0xff; |
| 702 | 736 | } |
| 703 | 737 | |
| r5513 | r5514 | |
| 1041 | 1075 | } |
| 1042 | 1076 | |
| 1043 | 1077 | io_bank_mode = 0; |
| 1078 | pcg_index[0] = pcg_index[1] = pcg_index[2] = 0; |
| 1044 | 1079 | } |
| 1045 | 1080 | |
| 1046 | 1081 | static void ctc0_interrupt(const device_config *device, int state) |