src/mess/drivers/x1.c
| r5559 | r5560 | |
| 165 | 165 | UINT8 gfx_bank; |
| 166 | 166 | UINT8 pcg_mode; |
| 167 | 167 | }scrn_reg; |
| 168 | static UINT8 pcg_write_addr; |
| 168 | 169 | |
| 170 | |
| 171 | /************************************* |
| 172 | * |
| 173 | * Video Functions |
| 174 | * |
| 175 | *************************************/ |
| 176 | |
| 169 | 177 | static VIDEO_START( x1 ) |
| 170 | 178 | { |
| 171 | 179 | colorram = auto_alloc_array(machine, UINT8, 0x1000); |
| r5559 | r5560 | |
| 307 | 315 | { |
| 308 | 316 | } |
| 309 | 317 | |
| 318 | /************************************* |
| 319 | * |
| 320 | * Keyboard MCU simulation |
| 321 | * |
| 322 | *************************************/ |
| 323 | |
| 310 | 324 | static UINT8 sub_cmd,sub_val,key_flag; |
| 325 | static UINT8 sub_cmd_length; |
| 311 | 326 | |
| 312 | | /* |
| 313 | | Keyboard MCU simulation |
| 314 | | */ |
| 315 | | |
| 316 | 327 | static UINT8 check_keyboard_press(running_machine *machine) |
| 317 | 328 | { |
| 318 | 329 | const char* portnames[3] = { "key1","key2","key3" }; |
| r5559 | r5560 | |
| 337 | 348 | return 0; |
| 338 | 349 | } |
| 339 | 350 | |
| 340 | | static UINT8 sub_cmd_length; |
| 341 | | |
| 342 | 351 | static READ8_HANDLER( sub_io_r ) |
| 343 | 352 | { |
| 344 | 353 | if(sub_obf) |
| r5559 | r5560 | |
| 407 | 416 | sub_obf = (sub_cmd_length) ? 0x00 : 0x20; |
| 408 | 417 | } |
| 409 | 418 | |
| 419 | /************************************* |
| 420 | * |
| 421 | * ROM Image / Banking Handling |
| 422 | * |
| 423 | *************************************/ |
| 424 | |
| 410 | 425 | static UINT8 rom_index[3]; |
| 411 | 426 | |
| 412 | 427 | static READ8_HANDLER( x1_rom_r ) |
| r5559 | r5560 | |
| 444 | 459 | ROM[0x10000+offset] = data; |
| 445 | 460 | } |
| 446 | 461 | |
| 447 | | /* |
| 448 | | FDC is a MB8877A, wd17XX compatible |
| 449 | | */ |
| 450 | 462 | |
| 463 | /************************************* |
| 464 | * |
| 465 | * MB8877A FDC (wd17XX compatible) |
| 466 | * |
| 467 | *************************************/ |
| 468 | |
| 451 | 469 | //static UINT8 fdc_irq_flag; |
| 452 | 470 | //static UINT8 fdc_drq_flag; |
| 453 | 471 | //static UINT8 fdc_side; |
| r5559 | r5560 | |
| 519 | 537 | wd17xx_data_w(dev,offset,data); |
| 520 | 538 | break; |
| 521 | 539 | case 0x0ffc: |
| 522 | | /* data & 3 = disk drive, TODO */ |
| 523 | | //if(data & 3) |
| 524 | | // fatalerror("FDC: Using more than 1 floppy disk drive!"); |
| 525 | 540 | wd17xx_set_drive(dev,data & 3); |
| 526 | 541 | floppy_drive_set_motor_state(image_from_devtype_and_index(space->machine, IO_FLOPPY, data & 3), data & 0x80); |
| 527 | 542 | floppy_drive_set_ready_state(image_from_devtype_and_index(space->machine, IO_FLOPPY, data & 3), data & 0x80,0); |
| r5559 | r5560 | |
| 541 | 556 | NULL |
| 542 | 557 | }; |
| 543 | 558 | |
| 544 | | /* for bitmap mode */ |
| 545 | | static UINT8 x_b,x_g,x_r; |
| 559 | /************************************* |
| 560 | * |
| 561 | * Programmable Character Generator |
| 562 | * |
| 563 | *************************************/ |
| 546 | 564 | |
| 547 | | static void set_current_palette(running_machine *machine) |
| 548 | | { |
| 549 | | UINT8 addr,r,g,b; |
| 550 | | |
| 551 | | for(addr=0;addr<8;addr++) |
| 552 | | { |
| 553 | | r = ((x_r)>>(addr)) & 1; |
| 554 | | g = ((x_g)>>(addr)) & 1; |
| 555 | | b = ((x_b)>>(addr)) & 1; |
| 556 | | |
| 557 | | palette_set_color_rgb(machine, addr+0x100, pal1bit(r), pal1bit(g), pal1bit(b)); |
| 558 | | } |
| 559 | | } |
| 560 | | |
| 561 | | static WRITE8_HANDLER( x1_pal_r_w ) { x_r = data; set_current_palette(space->machine); } |
| 562 | | static WRITE8_HANDLER( x1_pal_g_w ) { x_g = data; set_current_palette(space->machine); } |
| 563 | | static WRITE8_HANDLER( x1_pal_b_w ) { x_b = data; set_current_palette(space->machine); } |
| 564 | | |
| 565 | | static WRITE8_HANDLER( x1_dma_w ) |
| 566 | | { |
| 567 | | printf("%02x %02x\n",offset,data); |
| 568 | | //if(data) |
| 569 | | // fatalerror("Data written to the DMA space"); |
| 570 | | } |
| 571 | | |
| 572 | 565 | /* TODO: apparently this is for the alternative PCG mode */ |
| 573 | 566 | #if 0 |
| 574 | 567 | static UINT16 check_pcg_addr(running_machine *machine) |
| r5559 | r5560 | |
| 582 | 575 | } |
| 583 | 576 | #endif |
| 584 | 577 | |
| 585 | | static UINT8 pcg_write_addr; |
| 586 | | |
| 587 | 578 | static READ8_HANDLER( x1_pcg_r ) |
| 588 | 579 | { |
| 589 | 580 | #if 0 |
| r5559 | r5560 | |
| 656 | 647 | } |
| 657 | 648 | } |
| 658 | 649 | |
| 659 | | static READ8_HANDLER( x1_clr_r ) |
| 650 | /************************************* |
| 651 | * |
| 652 | * Other Video-related functions |
| 653 | * |
| 654 | *************************************/ |
| 655 | |
| 656 | /* for bitmap mode */ |
| 657 | static UINT8 x_b,x_g,x_r; |
| 658 | |
| 659 | static void set_current_palette(running_machine *machine) |
| 660 | 660 | { |
| 661 | UINT8 addr,r,g,b; |
| 661 | 662 | |
| 662 | | return 0xff; |
| 663 | for(addr=0;addr<8;addr++) |
| 664 | { |
| 665 | r = ((x_r)>>(addr)) & 1; |
| 666 | g = ((x_g)>>(addr)) & 1; |
| 667 | b = ((x_b)>>(addr)) & 1; |
| 668 | |
| 669 | palette_set_color_rgb(machine, addr+0x100, pal1bit(r), pal1bit(g), pal1bit(b)); |
| 670 | } |
| 663 | 671 | } |
| 664 | 672 | |
| 673 | static WRITE8_HANDLER( x1_pal_r_w ) { x_r = data; set_current_palette(space->machine); } |
| 674 | static WRITE8_HANDLER( x1_pal_g_w ) { x_g = data; set_current_palette(space->machine); } |
| 675 | static WRITE8_HANDLER( x1_pal_b_w ) { x_b = data; set_current_palette(space->machine); } |
| 676 | |
| 665 | 677 | static WRITE8_HANDLER( x1_ex_gfxram_w ) |
| 666 | 678 | { |
| 667 | 679 | static UINT8 ex_mask; |
| r5559 | r5560 | |
| 707 | 719 | } |
| 708 | 720 | } |
| 709 | 721 | |
| 722 | static WRITE8_HANDLER( x1_dma_w ) |
| 723 | { |
| 724 | printf("%02x %02x\n",offset,data); |
| 725 | //if(data) |
| 726 | // fatalerror("Data written to the DMA space"); |
| 727 | } |
| 728 | |
| 729 | |
| 730 | /************************************* |
| 731 | * |
| 732 | * Memory maps |
| 733 | * |
| 734 | *************************************/ |
| 735 | |
| 710 | 736 | static READ8_HANDLER( x1_io_r ) |
| 711 | 737 | { |
| 712 | 738 | io_bank_mode = 0; //any read disables the extended mode. |
| 713 | 739 | |
| 714 | | if(offset == 0x0000) { return x1_clr_r(space, 0); } |
| 715 | | else if(offset >= 0x0704 && offset <= 0x0707) { return z80ctc_r(devtag_get_device(space->machine, "ctc"), offset-0x0704); } |
| 740 | if(offset >= 0x0704 && offset <= 0x0707) { return z80ctc_r(devtag_get_device(space->machine, "ctc"), offset-0x0704); } |
| 716 | 741 | else if(offset == 0x0e03) { return x1_rom_r(space, 0); } |
| 717 | 742 | else if(offset >= 0x0ff8 && offset <= 0x0fff) { return x1_fdc_r(space, offset-0xff8); } |
| 718 | 743 | else if(offset >= 0x1400 && offset <= 0x17ff) { return x1_pcg_r(space, offset-0x1400); } |
| r5559 | r5560 | |
| 771 | 796 | { |
| 772 | 797 | io_bank_mode = 0; //any read disables the extended mode. |
| 773 | 798 | |
| 774 | | if(offset == 0x0000) { return x1_clr_r(space, 0); } |
| 775 | | else if(offset == 0x0700 || offset == 0x0701) { return ym2151_r(devtag_get_device(space->machine, "ym"), offset-0x0700); } |
| 799 | if(offset == 0x0700 || offset == 0x0701) { return ym2151_r(devtag_get_device(space->machine, "ym"), offset-0x0700); } |
| 776 | 800 | else if(offset >= 0x0704 && offset <= 0x0707) { return z80ctc_r(devtag_get_device(space->machine, "ctc"), offset-0x0704); } |
| 777 | 801 | else if(offset == 0x0e03) { return x1_rom_r(space, 0); } |
| 778 | 802 | else if(offset >= 0x0ff8 && offset <= 0x0fff) { return x1_fdc_r(space, offset-0xff8); } |
| r5559 | r5560 | |
| 846 | 870 | AM_RANGE(0x0000, 0xffff) AM_READWRITE(x1turbo_io_r, x1turbo_io_w) |
| 847 | 871 | ADDRESS_MAP_END |
| 848 | 872 | |
| 849 | | static const gfx_layout x1_chars_8x8 = |
| 850 | | { |
| 851 | | 8,8, |
| 852 | | RGN_FRAC(1,1), |
| 853 | | 1, |
| 854 | | { 0 }, |
| 855 | | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 856 | | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, |
| 857 | | 8*8 |
| 858 | | }; |
| 873 | /************************************* |
| 874 | * |
| 875 | * PPI8255 |
| 876 | * |
| 877 | *************************************/ |
| 859 | 878 | |
| 860 | | static const gfx_layout x1_chars_8wx8 = |
| 861 | | { |
| 862 | | 16,8, |
| 863 | | RGN_FRAC(1,1), |
| 864 | | 1, |
| 865 | | { 0 }, |
| 866 | | { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7 }, |
| 867 | | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, |
| 868 | | 8*8 |
| 869 | | }; |
| 870 | | |
| 871 | | static const gfx_layout x1_chars_8x8w = |
| 872 | | { |
| 873 | | 8,16, |
| 874 | | RGN_FRAC(1,1), |
| 875 | | 1, |
| 876 | | { 0 }, |
| 877 | | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 878 | | { 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 }, |
| 879 | | 8*8 |
| 880 | | }; |
| 881 | | |
| 882 | | static const gfx_layout x1_chars_8wx8w = |
| 883 | | { |
| 884 | | 16,16, |
| 885 | | RGN_FRAC(1,1), |
| 886 | | 1, |
| 887 | | { 0 }, |
| 888 | | { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7 }, |
| 889 | | { 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 }, |
| 890 | | 8*8 |
| 891 | | }; |
| 892 | | |
| 893 | | static const gfx_layout x1_pcg_8x8 = |
| 894 | | { |
| 895 | | 8,8, |
| 896 | | RGN_FRAC(1,3), |
| 897 | | 3, |
| 898 | | { RGN_FRAC(2,3),RGN_FRAC(1,3),RGN_FRAC(0,3) }, |
| 899 | | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 900 | | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, |
| 901 | | 8*8 |
| 902 | | }; |
| 903 | | |
| 904 | | static const gfx_layout x1_pcg_8wx8 = |
| 905 | | { |
| 906 | | 16,8, |
| 907 | | RGN_FRAC(1,3), |
| 908 | | 3, |
| 909 | | { RGN_FRAC(2,3),RGN_FRAC(1,3),RGN_FRAC(0,3) }, |
| 910 | | { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7 }, |
| 911 | | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, |
| 912 | | 8*8 |
| 913 | | }; |
| 914 | | |
| 915 | | static const gfx_layout x1_pcg_8x8w = |
| 916 | | { |
| 917 | | 8,16, |
| 918 | | RGN_FRAC(1,3), |
| 919 | | 3, |
| 920 | | { RGN_FRAC(2,3),RGN_FRAC(1,3),RGN_FRAC(0,3) }, |
| 921 | | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 922 | | { 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 }, |
| 923 | | 8*8 |
| 924 | | }; |
| 925 | | |
| 926 | | static const gfx_layout x1_pcg_8wx8w = |
| 927 | | { |
| 928 | | 16,16, |
| 929 | | RGN_FRAC(1,3), |
| 930 | | 3, |
| 931 | | { RGN_FRAC(2,3),RGN_FRAC(1,3),RGN_FRAC(0,3) }, |
| 932 | | { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7 }, |
| 933 | | { 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 }, |
| 934 | | 8*8 |
| 935 | | }; |
| 936 | | |
| 937 | | static const gfx_layout x1_chars_16x16 = |
| 938 | | { |
| 939 | | 16,16, |
| 940 | | RGN_FRAC(1,1), |
| 941 | | 1, |
| 942 | | { 0 }, |
| 943 | | { 0, 1, 2, 3, 4, 5, 6, 7,8,9,10,11,12,13,14,15 }, |
| 944 | | { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16,8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16 }, |
| 945 | | 16*16 |
| 946 | | }; |
| 947 | | |
| 948 | | /* TODO: separe the different x1 decodings accordingly */ |
| 949 | | static GFXDECODE_START( x1 ) |
| 950 | | /* decoded for debugging purpose, they will be nuked in the end */ |
| 951 | | GFXDECODE_ENTRY( "cgrom", 0x00000, x1_chars_8x8, 0x200, 0x20 ) |
| 952 | | GFXDECODE_ENTRY( "cgrom", 0x00000, x1_chars_8wx8, 0x200, 0x20 ) |
| 953 | | GFXDECODE_ENTRY( "cgrom", 0x00000, x1_chars_8x8w, 0x200, 0x20 ) |
| 954 | | GFXDECODE_ENTRY( "cgrom", 0x00000, x1_chars_8wx8w, 0x200, 0x20 ) |
| 955 | | GFXDECODE_ENTRY( "pcg", 0x00000, x1_pcg_8x8, 0x100, 1 ) |
| 956 | | GFXDECODE_ENTRY( "pcg", 0x00000, x1_pcg_8wx8, 0x100, 1 ) |
| 957 | | GFXDECODE_ENTRY( "pcg", 0x00000, x1_pcg_8x8w, 0x100, 1 ) |
| 958 | | GFXDECODE_ENTRY( "pcg", 0x00000, x1_pcg_8wx8w, 0x100, 1 ) |
| 959 | | GFXDECODE_ENTRY( "cgrom", 0x01800, x1_chars_16x16, 0, 0x20 ) //only x1turboz uses this so far |
| 960 | | GFXDECODE_ENTRY( "kanji", 0x27000, x1_chars_16x16, 0, 0x20 ) //needs to be checked when the ROM will be redumped |
| 961 | | GFXDECODE_END |
| 962 | | |
| 963 | | static PALETTE_INIT(x1) |
| 964 | | { |
| 965 | | int i; |
| 966 | | |
| 967 | | for(i=0;i<0x300;i++) |
| 968 | | palette_set_color(machine, i,MAKE_RGB(0x00,0x00,0x00)); |
| 969 | | |
| 970 | | for (i = 0x200; i < 0x220; i++) |
| 971 | | { |
| 972 | | UINT8 r,g,b; |
| 973 | | |
| 974 | | if(i & 0x01) |
| 975 | | { |
| 976 | | r = ((i >> 3) & 1) ? 0xff : 0x00; |
| 977 | | g = ((i >> 2) & 1) ? 0xff : 0x00; |
| 978 | | b = ((i >> 1) & 1) ? 0xff : 0x00; |
| 979 | | } |
| 980 | | else { r = g = b = 0x00; } |
| 981 | | |
| 982 | | if(i & 0x10) { r^=0xff; g^=0xff; b^=0xff; } |
| 983 | | |
| 984 | | palette_set_color_rgb(machine, i, r,g,b); |
| 985 | | } |
| 986 | | |
| 987 | | /* TODO: fix this */ |
| 988 | | for(i=0;i<8;i++) |
| 989 | | { |
| 990 | | palette_set_color_rgb(machine, i+0x000, pal1bit(i >> 2), pal1bit(i >> 1), pal1bit(i >> 0)); |
| 991 | | palette_set_color_rgb(machine, i+0x100, pal1bit(i >> 2), pal1bit(i >> 1), pal1bit(i >> 0)); |
| 992 | | } |
| 993 | | } |
| 994 | | |
| 995 | 879 | static READ8_DEVICE_HANDLER( x1_porta_r ) |
| 996 | 880 | { |
| 997 | 881 | printf("PPI Port A read\n"); |
| r5559 | r5560 | |
| 1039 | 923 | |
| 1040 | 924 | static WRITE8_DEVICE_HANDLER( x1_portc_w ) |
| 1041 | 925 | { |
| 1042 | | //printf("PPI Port C write %02x\n",data); |
| 1043 | 926 | hres_320 = data & 0x40; |
| 1044 | 927 | |
| 1045 | | // if(hres_320 && data & 0x20 && io_switch & 0x20 && (data & 0xa0) != 0) |
| 1046 | | |
| 1047 | 928 | if(((data & 0x20) == 0) && (io_switch & 0x20)) |
| 1048 | 929 | io_bank_mode = 1; |
| 1049 | 930 | |
| 1050 | 931 | io_switch = data & 0x20; |
| 1051 | 932 | io_sys = data & 0xff; |
| 1052 | | |
| 1053 | | //if(io_sys_state != io_sys) |
| 1054 | | // io_sys_state = io_sys; |
| 1055 | 933 | } |
| 1056 | 934 | |
| 1057 | 935 | static const ppi8255_interface ppi8255_intf = |
| r5559 | r5560 | |
| 1078 | 956 | NULL /* update address callback */ |
| 1079 | 957 | }; |
| 1080 | 958 | |
| 1081 | | /* Input ports */ |
| 959 | /************************************* |
| 960 | * |
| 961 | * Inputs |
| 962 | * |
| 963 | *************************************/ |
| 964 | |
| 1082 | 965 | static INPUT_PORTS_START( x1 ) |
| 1083 | 966 | PORT_START("SYSTEM") |
| 1084 | 967 | PORT_DIPNAME( 0x01, 0x01, "SYSTEM" ) |
| r5559 | r5560 | |
| 1311 | 1194 | #endif |
| 1312 | 1195 | INPUT_PORTS_END |
| 1313 | 1196 | |
| 1314 | | static MACHINE_RESET( x1 ) |
| 1197 | /************************************* |
| 1198 | * |
| 1199 | * GFX decoding |
| 1200 | * |
| 1201 | *************************************/ |
| 1202 | |
| 1203 | static const gfx_layout x1_chars_8x8 = |
| 1315 | 1204 | { |
| 1316 | | UINT8 *ROM = memory_region(machine, "maincpu"); |
| 1317 | | UINT8 *PCG_RAM = memory_region(machine, "pcg"); |
| 1318 | | int i; |
| 1205 | 8,8, |
| 1206 | RGN_FRAC(1,1), |
| 1207 | 1, |
| 1208 | { 0 }, |
| 1209 | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 1210 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, |
| 1211 | 8*8 |
| 1212 | }; |
| 1319 | 1213 | |
| 1320 | | memory_set_bankptr(machine, 1, &ROM[0x00000]); |
| 1214 | static const gfx_layout x1_chars_8wx8 = |
| 1215 | { |
| 1216 | 16,8, |
| 1217 | RGN_FRAC(1,1), |
| 1218 | 1, |
| 1219 | { 0 }, |
| 1220 | { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7 }, |
| 1221 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, |
| 1222 | 8*8 |
| 1223 | }; |
| 1321 | 1224 | |
| 1322 | | memset(gfx_bitmap_ram,0x00,0xc000*2); |
| 1225 | static const gfx_layout x1_chars_8x8w = |
| 1226 | { |
| 1227 | 8,16, |
| 1228 | RGN_FRAC(1,1), |
| 1229 | 1, |
| 1230 | { 0 }, |
| 1231 | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 1232 | { 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 }, |
| 1233 | 8*8 |
| 1234 | }; |
| 1323 | 1235 | |
| 1324 | | for(i=0;i<0x1800;i++) |
| 1325 | | { |
| 1326 | | PCG_RAM[i] = 0; |
| 1327 | | } |
| 1236 | static const gfx_layout x1_chars_8wx8w = |
| 1237 | { |
| 1238 | 16,16, |
| 1239 | RGN_FRAC(1,1), |
| 1240 | 1, |
| 1241 | { 0 }, |
| 1242 | { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7 }, |
| 1243 | { 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 }, |
| 1244 | 8*8 |
| 1245 | }; |
| 1328 | 1246 | |
| 1329 | | for(i=0;i<0x0400;i++) |
| 1330 | | { |
| 1331 | | gfx_element_mark_dirty(machine->gfx[4], i); |
| 1332 | | gfx_element_mark_dirty(machine->gfx[5], i); |
| 1333 | | gfx_element_mark_dirty(machine->gfx[6], i); |
| 1334 | | gfx_element_mark_dirty(machine->gfx[7], i); |
| 1335 | | } |
| 1247 | static const gfx_layout x1_pcg_8x8 = |
| 1248 | { |
| 1249 | 8,8, |
| 1250 | RGN_FRAC(1,3), |
| 1251 | 3, |
| 1252 | { RGN_FRAC(2,3),RGN_FRAC(1,3),RGN_FRAC(0,3) }, |
| 1253 | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 1254 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, |
| 1255 | 8*8 |
| 1256 | }; |
| 1336 | 1257 | |
| 1337 | | io_bank_mode = 0; |
| 1338 | | pcg_index[0] = pcg_index[1] = pcg_index[2] = 0; |
| 1339 | | } |
| 1258 | static const gfx_layout x1_pcg_8wx8 = |
| 1259 | { |
| 1260 | 16,8, |
| 1261 | RGN_FRAC(1,3), |
| 1262 | 3, |
| 1263 | { RGN_FRAC(2,3),RGN_FRAC(1,3),RGN_FRAC(0,3) }, |
| 1264 | { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7 }, |
| 1265 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, |
| 1266 | 8*8 |
| 1267 | }; |
| 1340 | 1268 | |
| 1269 | static const gfx_layout x1_pcg_8x8w = |
| 1270 | { |
| 1271 | 8,16, |
| 1272 | RGN_FRAC(1,3), |
| 1273 | 3, |
| 1274 | { RGN_FRAC(2,3),RGN_FRAC(1,3),RGN_FRAC(0,3) }, |
| 1275 | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 1276 | { 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 }, |
| 1277 | 8*8 |
| 1278 | }; |
| 1279 | |
| 1280 | static const gfx_layout x1_pcg_8wx8w = |
| 1281 | { |
| 1282 | 16,16, |
| 1283 | RGN_FRAC(1,3), |
| 1284 | 3, |
| 1285 | { RGN_FRAC(2,3),RGN_FRAC(1,3),RGN_FRAC(0,3) }, |
| 1286 | { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7 }, |
| 1287 | { 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 }, |
| 1288 | 8*8 |
| 1289 | }; |
| 1290 | |
| 1291 | static const gfx_layout x1_chars_16x16 = |
| 1292 | { |
| 1293 | 16,16, |
| 1294 | RGN_FRAC(1,1), |
| 1295 | 1, |
| 1296 | { 0 }, |
| 1297 | { 0, 1, 2, 3, 4, 5, 6, 7,8,9,10,11,12,13,14,15 }, |
| 1298 | { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16,8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16 }, |
| 1299 | 16*16 |
| 1300 | }; |
| 1301 | |
| 1302 | /* decoded for debugging purpose, this will be nuked in the end... */ |
| 1303 | static GFXDECODE_START( x1 ) |
| 1304 | GFXDECODE_ENTRY( "cgrom", 0x00000, x1_chars_8x8, 0x200, 0x20 ) |
| 1305 | GFXDECODE_ENTRY( "cgrom", 0x00000, x1_chars_8wx8, 0x200, 0x20 ) |
| 1306 | GFXDECODE_ENTRY( "cgrom", 0x00000, x1_chars_8x8w, 0x200, 0x20 ) |
| 1307 | GFXDECODE_ENTRY( "cgrom", 0x00000, x1_chars_8wx8w, 0x200, 0x20 ) |
| 1308 | GFXDECODE_ENTRY( "pcg", 0x00000, x1_pcg_8x8, 0x100, 1 ) |
| 1309 | GFXDECODE_ENTRY( "pcg", 0x00000, x1_pcg_8wx8, 0x100, 1 ) |
| 1310 | GFXDECODE_ENTRY( "pcg", 0x00000, x1_pcg_8x8w, 0x100, 1 ) |
| 1311 | GFXDECODE_ENTRY( "pcg", 0x00000, x1_pcg_8wx8w, 0x100, 1 ) |
| 1312 | GFXDECODE_ENTRY( "cgrom", 0x01800, x1_chars_16x16, 0, 0x20 ) //only x1turboz uses this so far |
| 1313 | GFXDECODE_ENTRY( "kanji", 0x27000, x1_chars_16x16, 0, 0x20 ) //needs to be checked when the ROM will be redumped |
| 1314 | GFXDECODE_END |
| 1315 | |
| 1316 | /************************************* |
| 1317 | * |
| 1318 | * CTC |
| 1319 | * |
| 1320 | *************************************/ |
| 1321 | |
| 1341 | 1322 | static void ctc0_interrupt(const device_config *device, int state) |
| 1342 | 1323 | { |
| 1343 | 1324 | //cputag_set_input_line(device->machine, "maincpu", 0, state); |
| r5559 | r5560 | |
| 1353 | 1334 | 0, // ZC/TO2 callback |
| 1354 | 1335 | }; |
| 1355 | 1336 | |
| 1337 | /************************************* |
| 1338 | * |
| 1339 | * Sound HW Config |
| 1340 | * |
| 1341 | *************************************/ |
| 1342 | |
| 1356 | 1343 | static const ay8910_interface ay8910_config = |
| 1357 | 1344 | { |
| 1358 | 1345 | AY8910_LEGACY_OUTPUT, |
| r5559 | r5560 | |
| 1363 | 1350 | DEVCB_NULL |
| 1364 | 1351 | }; |
| 1365 | 1352 | |
| 1353 | // (ym-2151 handler here) |
| 1354 | |
| 1355 | /************************************* |
| 1356 | * |
| 1357 | * Machine Functions |
| 1358 | * |
| 1359 | *************************************/ |
| 1360 | |
| 1366 | 1361 | static INTERRUPT_GEN( x1_vbl ) |
| 1367 | 1362 | { |
| 1368 | 1363 | // pcg_reset = 1; |
| 1369 | 1364 | } |
| 1370 | 1365 | |
| 1366 | static MACHINE_RESET( x1 ) |
| 1367 | { |
| 1368 | UINT8 *ROM = memory_region(machine, "maincpu"); |
| 1369 | UINT8 *PCG_RAM = memory_region(machine, "pcg"); |
| 1370 | int i; |
| 1371 | |
| 1372 | memory_set_bankptr(machine, 1, &ROM[0x00000]); |
| 1373 | |
| 1374 | memset(gfx_bitmap_ram,0x00,0xc000*2); |
| 1375 | |
| 1376 | for(i=0;i<0x1800;i++) |
| 1377 | { |
| 1378 | PCG_RAM[i] = 0; |
| 1379 | } |
| 1380 | |
| 1381 | for(i=0;i<0x0400;i++) |
| 1382 | { |
| 1383 | gfx_element_mark_dirty(machine->gfx[4], i); |
| 1384 | gfx_element_mark_dirty(machine->gfx[5], i); |
| 1385 | gfx_element_mark_dirty(machine->gfx[6], i); |
| 1386 | gfx_element_mark_dirty(machine->gfx[7], i); |
| 1387 | } |
| 1388 | |
| 1389 | io_bank_mode = 0; |
| 1390 | pcg_index[0] = pcg_index[1] = pcg_index[2] = 0; |
| 1391 | } |
| 1392 | |
| 1393 | static PALETTE_INIT(x1) |
| 1394 | { |
| 1395 | int i; |
| 1396 | |
| 1397 | for(i=0;i<0x300;i++) |
| 1398 | palette_set_color(machine, i,MAKE_RGB(0x00,0x00,0x00)); |
| 1399 | |
| 1400 | for (i = 0x200; i < 0x220; i++) |
| 1401 | { |
| 1402 | UINT8 r,g,b; |
| 1403 | |
| 1404 | if(i & 0x01) |
| 1405 | { |
| 1406 | r = ((i >> 3) & 1) ? 0xff : 0x00; |
| 1407 | g = ((i >> 2) & 1) ? 0xff : 0x00; |
| 1408 | b = ((i >> 1) & 1) ? 0xff : 0x00; |
| 1409 | } |
| 1410 | else { r = g = b = 0x00; } |
| 1411 | |
| 1412 | if(i & 0x10) { r^=0xff; g^=0xff; b^=0xff; } |
| 1413 | |
| 1414 | palette_set_color_rgb(machine, i, r,g,b); |
| 1415 | } |
| 1416 | |
| 1417 | /* TODO: fix this */ |
| 1418 | for(i=0;i<8;i++) |
| 1419 | { |
| 1420 | palette_set_color_rgb(machine, i+0x000, pal1bit(i >> 2), pal1bit(i >> 1), pal1bit(i >> 0)); |
| 1421 | palette_set_color_rgb(machine, i+0x100, pal1bit(i >> 2), pal1bit(i >> 1), pal1bit(i >> 0)); |
| 1422 | } |
| 1423 | } |
| 1424 | |
| 1371 | 1425 | static MACHINE_DRIVER_START( x1 ) |
| 1372 | 1426 | /* basic machine hardware */ |
| 1373 | 1427 | MDRV_CPU_ADD("maincpu", Z80, XTAL_4MHz) |
| r5559 | r5560 | |
| 1419 | 1473 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 1420 | 1474 | MACHINE_DRIVER_END |
| 1421 | 1475 | |
| 1476 | /************************************* |
| 1477 | * |
| 1478 | * Image Load Functions |
| 1479 | * |
| 1480 | *************************************/ |
| 1481 | |
| 1422 | 1482 | static DEVICE_IMAGE_LOAD( x1_floppy ) |
| 1423 | 1483 | { |
| 1424 | 1484 | const char *ext; |
| r5559 | r5560 | |
| 1478 | 1538 | CONFIG_DEVICE(x1_floppy_getinfo) |
| 1479 | 1539 | SYSTEM_CONFIG_END |
| 1480 | 1540 | |
| 1481 | | /* ROM definition */ |
| 1482 | | ROM_START( x1 ) |
| 1541 | /************************************* |
| 1542 | * |
| 1543 | * ROM definitions |
| 1544 | * |
| 1545 | *************************************/ |
| 1546 | |
| 1547 | ROM_START( x1 ) |
| 1483 | 1548 | ROM_REGION( 0x20000, "maincpu", ROMREGION_ERASEFF ) |
| 1484 | 1549 | ROM_SYSTEM_BIOS( 0, "default", "X1 IPL" ) |
| 1485 | 1550 | ROMX_LOAD( "ipl.x1", 0x0000, 0x1000, CRC(7b28d9de) SHA1(c4db9a6e99873808c8022afd1c50fef556a8b44d), ROM_BIOS(1) ) |
| r5559 | r5560 | |
| 1572 | 1637 | ROM_END |
| 1573 | 1638 | |
| 1574 | 1639 | |
| 1575 | | /* Driver */ |
| 1576 | 1640 | |
| 1577 | 1641 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME FLAGS */ |
| 1578 | 1642 | COMP( 1982, x1, 0, 0, x1, x1, 0, x1, "Sharp", "X1 (CZ-800C)", GAME_NOT_WORKING) |