src/mess/drivers/mz2500.c
| r8961 | r8962 | |
| 8 | 8 | - 4096 color mode; |
| 9 | 9 | - Kanji text is cutted in half when font_size is 1, different data used? |
| 10 | 10 | (check Back to the Future); |
| 11 | | - check how crtc really changes the screen resolution; |
| 12 | | - Add cg latch read; |
| 13 | 11 | - Implement unlatched ROMs (Phone and Dictionary); |
| 12 | - Find real CRTC registers |
| 14 | 13 | - Implement external ROM hook-up; |
| 15 | 14 | - FDC loading without the IPLPRO doesn't work at all, why? |
| 16 | 15 | - reverse / blanking tvram attributes; |
| 16 | - clean-ups! ^^' |
| 17 | 17 | |
| 18 | 18 | per-game/program specific TODO: |
| 19 | | - (Koei Simulation War Game): title screen background is grey when it should be black; |
| 20 | | - (Mahjong): white on configurations,same as above? |
| 21 | 19 | - (Renju): hangs on the "presents" screen; |
| 22 | 20 | - (Xtal Soft - The Prince of Darkness): dies on IPLPRO loading, presumably a wd17xx core bug; |
| 23 | 21 | - (Sound Gal): dies with bad code, another wd17xx core bug; |
| 24 | 22 | - Basic: vertical scrolling returns wrap-around that shouldn't wrap; |
| 23 | - Basic: loading has an alignment bug with the bitmap |
| 25 | 24 | - (K2): doesn't seem to work, there was a "Disk I/O error" msg before; |
| 26 | 25 | - LayDock: hangs by reading the FDC status and expecting it to become 0x81; |
| 27 | 26 | - Mappy: TVRAM layer is double x sized than it should be; |
| r8961 | r8962 | |
| 30 | 29 | - Multiplan: hangs after you set the RTC; |
| 31 | 30 | - Murder Club: has lots of CG artifacts; |
| 32 | 31 | - Penguin Kun Wars: has a bug with window effects ("Push space or trigger" msg on the bottom"), needs investigation; |
| 33 | | - Personal CP/M: black screen, writes bit 7 to i/o port 0xde |
| 34 | 32 | - Relics: doesn't boot, bad dump? |
| 35 | 33 | - Super MZ Demo 1: Hangs at the logo "roar". |
| 36 | 34 | - Telephone Soft: shows garbage with the CG layer; |
| 37 | 35 | - The Black Onyx: hangs at the title screen, background should also animate; |
| 36 | - The Tower of Druaga: has a small priority/layer clearance bug at the digital / analog screen select; |
| 38 | 37 | - Xevious: has issues with the window effects, it should actually be applied on TV layer and not CG. |
| 39 | 38 | - Ys 3: crashes if you try to load it with different DSW settings |
| 40 | 39 | |
| r8961 | r8962 | |
| 77 | 76 | static UINT8 cg_mask; |
| 78 | 77 | static UINT8 wid_40; |
| 79 | 78 | static UINT16 cg_vs,cg_ve,cg_hs,cg_he; //CG window parameters |
| 79 | static UINT8 cg_latch[4]; |
| 80 | 80 | |
| 81 | 81 | #define WRAM_RESET 0 |
| 82 | 82 | #define IPL_RESET 1 |
| r8961 | r8962 | |
| 310 | 310 | draw_40x25(machine,bitmap,cliprect,0,base_addr); |
| 311 | 311 | draw_40x25(machine,bitmap,cliprect,1,base_addr); |
| 312 | 312 | break; |
| 313 | | default: popmessage("%02x %02x %02x",tv_mode & 3,text_reg[1],text_reg[2]); break; |
| 313 | //default: popmessage("%02x %02x %02x",tv_mode & 3,text_reg[1],text_reg[2]); break; |
| 314 | 314 | } |
| 315 | 315 | } |
| 316 | 316 | } |
| r8961 | r8962 | |
| 455 | 455 | return 0; |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | static UINT8 mz2500_cg_latch_compare(void) |
| 459 | { |
| 460 | UINT8 compare_val = cg_reg[0x07] & 0xf; |
| 461 | UINT8 pix_val; |
| 462 | UINT8 res; |
| 463 | UINT16 i; |
| 464 | res = 0; |
| 465 | |
| 466 | for(i=1;i<0x100;i<<=1) |
| 467 | { |
| 468 | pix_val = ((cg_latch[0] & i) ? 1 : 0) | ((cg_latch[1] & i) ? 2 : 0) | ((cg_latch[2] & i) ? 4 : 0) | ((cg_latch[3] & i) ? 8 : 0); |
| 469 | if(pix_val == compare_val) |
| 470 | res|=i; |
| 471 | } |
| 472 | |
| 473 | return res; |
| 474 | } |
| 475 | |
| 458 | 476 | static UINT8 mz2500_ram_read(running_machine *machine, UINT16 offset, UINT8 bank_num) |
| 459 | 477 | { |
| 460 | 478 | UINT8 *ram = memory_region(machine, "maincpu"); |
| r8961 | r8962 | |
| 462 | 480 | |
| 463 | 481 | switch(cur_bank) |
| 464 | 482 | { |
| 483 | case 0x30: |
| 484 | case 0x31: |
| 485 | case 0x32: |
| 486 | case 0x33: |
| 487 | { |
| 488 | // READ MODIFY WRITE |
| 489 | if(cg_reg[0x0e] == 0x3) |
| 490 | { |
| 491 | // ... |
| 492 | } |
| 493 | else |
| 494 | { |
| 495 | int plane; |
| 496 | cg_latch[0] = ram[offset+((cur_bank & 3)*0x2000)+0x40000]; //B |
| 497 | cg_latch[1] = ram[offset+((cur_bank & 3)*0x2000)+0x44000]; //R |
| 498 | cg_latch[2] = ram[offset+((cur_bank & 3)*0x2000)+0x48000]; //G |
| 499 | cg_latch[3] = ram[offset+((cur_bank & 3)*0x2000)+0x4c000]; //I |
| 500 | plane = cg_reg[0x07] & 3; |
| 501 | |
| 502 | if(cg_reg[0x07] & 0x10) |
| 503 | return mz2500_cg_latch_compare(); |
| 504 | else |
| 505 | return cg_latch[plane]; |
| 506 | } |
| 507 | } |
| 508 | break; |
| 465 | 509 | case 0x39: |
| 466 | 510 | { |
| 467 | 511 | if(kanji_bank & 0x80) //kanji ROM |
| r8961 | r8962 | |
| 666 | 710 | } |
| 667 | 711 | |
| 668 | 712 | /* |
| 669 | | [0] ---x ---- line height (0) 16 (1) 20 |
| 670 | | [0] ---- xx-- 40 column mode (0) 64 colors (1) screen 1 (2) screen 2 (3) screen 1 + screen 2 |
| 671 | | [1] xxxx xxxx TV map offset low address value |
| 672 | | [2] ---- -xxx TV map offset high address value |
| 713 | TVRAM / CRTC registers |
| 673 | 714 | |
| 674 | | [9] ---- xxxx vertical scrolling shift position |
| 715 | [0x00] ---x ---- line height (0) 16 (1) 20 |
| 716 | [0x00] ---- xx-- 40 column mode (0) 64 colors (1) screen 1 (2) screen 2 (3) screen 1 + screen 2 |
| 717 | [0x00] ---- --x- (related to the transparent pen) |
| 718 | [0x01] xxxx xxxx TV map offset low address value |
| 719 | [0x02] ---- -xxx TV map offset high address value |
| 720 | [0x03] xxxx xxxx CRTC vertical start register |
| 721 | |
| 722 | [0x05] xxxx xxxx CRTC vertical end register |
| 723 | |
| 724 | [0x07] -xxx xxxx CRTC horizontal start register |
| 725 | [0x08] -xxx xxxx CRTC horizontal end register |
| 726 | [0x09] ---- xxxx vertical scrolling shift position |
| 727 | [0x0a] --GG RRBB 256 color mode |
| 728 | [0x0b] -r-- ---- Back plane red gradient |
| 729 | [0x0b] ---- -b-- Back plane blue gradient |
| 730 | [0x0b] ---- ---i Back plane i gradient |
| 731 | [0x0c] ---- ---g Back plane green gradient |
| 675 | 732 | */ |
| 676 | 733 | |
| 677 | 734 | static UINT8 pal_256_param(int index, int param) |
| r8961 | r8962 | |
| 696 | 753 | case 0: text_reg_index = data; break; |
| 697 | 754 | case 1: |
| 698 | 755 | text_reg[text_reg_index] = data; |
| 699 | | //printf("[%02x] %02x\n",text_reg_index,data); |
| 756 | #if 0 |
| 757 | //printf("[%02x] <- %02x\n",text_reg_index,data); |
| 758 | popmessage("(%02x %02x) (%02x %02x %02x %02x) (%02x %02x %02x) (%02x %02x %02x %02x)" |
| 759 | ,text_reg[0] & ~0x1e,text_reg[3] |
| 760 | ,text_reg[4],text_reg[5],text_reg[6],text_reg[7] |
| 761 | ,text_reg[8],text_reg[10],text_reg[11] |
| 762 | ,text_reg[12],text_reg[13],text_reg[14],text_reg[15]); |
| 700 | 763 | |
| 764 | #endif |
| 765 | //popmessage("%d %02x %d %02x %d %d",text_reg[3],text_reg[4],text_reg[5],text_reg[6],text_reg[7]*8,text_reg[8]*8); |
| 766 | |
| 701 | 767 | if(text_reg_index == 0x0a) // set 256 color palette |
| 702 | 768 | { |
| 703 | 769 | int i,r,g,b; |
| r8961 | r8962 | |
| 841 | 907 | AM_RANGE(0xe000, 0xffff) AM_READWRITE(bank7_r,bank7_w) |
| 842 | 908 | ADDRESS_MAP_END |
| 843 | 909 | |
| 844 | | #if 0 |
| 845 | | static READ8_HANDLER( kludge_r ) |
| 846 | | { |
| 847 | | return 0xff; //mame_rand(space->machine); |
| 848 | | } |
| 849 | | #endif |
| 850 | | |
| 851 | 910 | static UINT32 rom_index; |
| 852 | 911 | static UINT8 hrom_index,lrom_index; |
| 853 | 912 | |
| r8961 | r8962 | |
| 904 | 963 | wd17xx_w(device, offset, data ^ fdc_reverse); |
| 905 | 964 | } |
| 906 | 965 | |
| 907 | | /* |
| 908 | | "GDE" CRTC registers |
| 966 | static READ8_HANDLER( mz2500_bplane_latch_r ) |
| 967 | { |
| 968 | if(cg_reg[7] & 0x10) |
| 969 | return mz2500_cg_latch_compare(); |
| 970 | else |
| 971 | return cg_latch[0]; |
| 972 | } |
| 909 | 973 | |
| 910 | | 0x05: clear bitmap buffer register |
| 911 | 974 | |
| 912 | | 0x08: screen res vertical start lo reg |
| 913 | | 0x09: screen res vertical start hi reg (upper 1 bit) |
| 914 | | 0x0a: screen res vertical end lo reg |
| 915 | | 0x0b: screen res vertical end hi reg (upper 1 bit) |
| 916 | | 0x0c: screen res horizontal start reg (7 bits, val x 8) |
| 917 | | 0x0d: screen res horizontal end reg (7 bits, val x 8) |
| 918 | | 0x0e: screen size reg |
| 919 | | |
| 920 | | */ |
| 921 | | |
| 922 | 975 | static READ8_HANDLER( mz2500_rplane_latch_r ) |
| 923 | 976 | { |
| 924 | 977 | if(cg_reg[0x07] & 0x10) |
| r8961 | r8962 | |
| 931 | 984 | return vblank_bit; |
| 932 | 985 | } |
| 933 | 986 | else |
| 934 | | return 0xff; |
| 987 | return cg_latch[1]; |
| 935 | 988 | } |
| 936 | 989 | |
| 990 | static READ8_HANDLER( mz2500_gplane_latch_r ) |
| 991 | { |
| 992 | return cg_latch[2]; |
| 993 | } |
| 994 | |
| 995 | static READ8_HANDLER( mz2500_iplane_latch_r ) |
| 996 | { |
| 997 | return cg_latch[3]; |
| 998 | } |
| 999 | |
| 1000 | /* |
| 1001 | "GDE" CRTC registers |
| 1002 | |
| 1003 | 0x00: CG B - Replace / Pset register data mask |
| 1004 | 0x01: CG R - Replace / Pset register data mask |
| 1005 | 0x02: CG G - Replace / Pset register data mask |
| 1006 | 0x03: CG I - Replace / Pset register data mask |
| 1007 | 0x04: CG Replace / Pset active pixel |
| 1008 | 0x05: CG Replace / Pset mode register |
| 1009 | 0x06: CG Replace data register |
| 1010 | 0x07: compare CG buffer register |
| 1011 | 0x08: CG window vertical start lo reg |
| 1012 | 0x09: CG window vertical start hi reg (upper 1 bit) |
| 1013 | 0x0a: CG window vertical end lo reg |
| 1014 | 0x0b: CG window vertical end hi reg (upper 1 bit) |
| 1015 | 0x0c: CG window horizontal start reg (7 bits, val x 8) |
| 1016 | 0x0d: CG window horizontal end reg (7 bits, val x 8) |
| 1017 | 0x0e: CG mode |
| 1018 | 0x0f: vertical scroll shift (---- xxxx) |
| 1019 | 0x10: CG map base lo reg |
| 1020 | 0x11: CG map base hi reg |
| 1021 | 0x12: CG layer 0 end address lo reg |
| 1022 | 0x13: CG layer 0 end address hi reg |
| 1023 | 0x14: CG layer 1 start address lo reg |
| 1024 | 0x15: CG layer 1 start address hi reg |
| 1025 | 0x16: CG layer 1 y pixel start lo reg |
| 1026 | 0x17: CG layer 1 y pixel start hi reg |
| 1027 | 0x18: CG color masking |
| 1028 | */ |
| 1029 | |
| 937 | 1030 | static WRITE8_HANDLER( mz2500_cg_addr_w ) |
| 938 | 1031 | { |
| 939 | 1032 | cg_reg_index = data; |
| r8961 | r8962 | |
| 977 | 1070 | } |
| 978 | 1071 | } |
| 979 | 1072 | |
| 980 | | if(cg_reg_index & 0x80) //enable auto-inc |
| 981 | | cg_reg_index = (cg_reg_index & 0xfc) | ((cg_reg_index + 1) & 0x03); |
| 982 | | |
| 983 | 1073 | { |
| 984 | 1074 | rectangle visarea; |
| 985 | 1075 | static int x_size,y_size; |
| r8961 | r8962 | |
| 1004 | 1094 | |
| 1005 | 1095 | space->machine->primary_screen->configure(720, 480, visarea, space->machine->primary_screen->frame_period().attoseconds); //TODO |
| 1006 | 1096 | } |
| 1097 | |
| 1098 | if(cg_reg_index & 0x80) //enable auto-inc |
| 1099 | cg_reg_index = (cg_reg_index & 0xfc) | ((cg_reg_index + 1) & 0x03); |
| 1007 | 1100 | } |
| 1008 | 1101 | |
| 1009 | 1102 | static WRITE8_HANDLER( timer_w ) |
| r8961 | r8962 | |
| 1053 | 1146 | joy_mode = data; |
| 1054 | 1147 | } |
| 1055 | 1148 | |
| 1149 | static UINT16 kanji_index; |
| 1056 | 1150 | |
| 1151 | static READ8_HANDLER( mz2500_kanji_r ) |
| 1152 | { |
| 1153 | UINT8 *knj2_rom = memory_region(space->machine, "kanji2"); |
| 1154 | |
| 1155 | printf("Read from kanji 2 ROM\n"); |
| 1156 | |
| 1157 | return knj2_rom[(kanji_index << 1) | (offset & 1)]; |
| 1158 | } |
| 1159 | |
| 1160 | static WRITE8_HANDLER( mz2500_kanji_w ) |
| 1161 | { |
| 1162 | (offset & 1) ? (kanji_index = (data << 8) | (kanji_index & 0xff)) : (kanji_index = (data & 0xff) | (kanji_index & 0xff00)); |
| 1163 | } |
| 1164 | |
| 1165 | |
| 1057 | 1166 | static ADDRESS_MAP_START(mz2500_io, ADDRESS_SPACE_IO, 8) |
| 1058 | 1167 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 1059 | 1168 | // AM_RANGE(0x60, 0x63) AM_WRITE(w3100a_w) |
| r8961 | r8962 | |
| 1068 | 1177 | // AM_RANGE(0xb0, 0xb3) AM_READWRITE(sio_r,sio_w) |
| 1069 | 1178 | AM_RANGE(0xb4, 0xb4) AM_READWRITE(mz2500_bank_addr_r,mz2500_bank_addr_w) |
| 1070 | 1179 | AM_RANGE(0xb5, 0xb5) AM_READWRITE(mz2500_bank_data_r,mz2500_bank_data_w) |
| 1071 | | // AM_RANGE(0xb8, 0xb9) AM_READWRITE(kanji_r,kanji_w) |
| 1072 | | AM_RANGE(0xbc, 0xbc) AM_WRITE(mz2500_cg_addr_w) |
| 1180 | AM_RANGE(0xb8, 0xb9) AM_READWRITE(mz2500_kanji_r,mz2500_kanji_w) |
| 1181 | AM_RANGE(0xbc, 0xbc) AM_READ(mz2500_bplane_latch_r) AM_WRITE(mz2500_cg_addr_w) |
| 1073 | 1182 | AM_RANGE(0xbd, 0xbd) AM_READ(mz2500_rplane_latch_r) AM_WRITE(mz2500_cg_data_w) |
| 1074 | | // AM_RANGE(0xbc, 0xbf) AM_READ(mz2500_crtc_cg_r) //reads plane |
| 1183 | AM_RANGE(0xbe, 0xbe) AM_READ(mz2500_gplane_latch_r) |
| 1184 | AM_RANGE(0xbf, 0xbf) AM_READ(mz2500_iplane_latch_r) |
| 1075 | 1185 | AM_RANGE(0xc6, 0xc6) AM_WRITE(mz2500_irq_sel_w) |
| 1076 | 1186 | AM_RANGE(0xc7, 0xc7) AM_WRITE(mz2500_irq_data_w) |
| 1077 | 1187 | AM_RANGE(0xc8, 0xc9) AM_DEVREADWRITE("ym", ym2203_r, ym2203_w) |
| r8961 | r8962 | |
| 1632 | 1742 | ROM_REGION( 0x40000, "kanji", 0 ) |
| 1633 | 1743 | ROM_LOAD( "kanji.rom", 0x0000, 0x40000, CRC(dd426767) SHA1(cc8fae0cd1736bc11c110e1c84d3f620c5e35b80) ) |
| 1634 | 1744 | |
| 1745 | ROM_REGION( 0x20000, "kanji2", 0 ) |
| 1746 | ROM_LOAD( "kanji2.rom", 0x0000, 0x20000, CRC(eaaf20c9) SHA1(771c4d559b5241390215edee798f3bce169d418c) ) |
| 1747 | |
| 1635 | 1748 | ROM_REGION( 0x40000, "dictionary", 0 ) |
| 1636 | 1749 | ROM_LOAD( "dict.rom", 0x00000, 0x40000, CRC(aa957c2b) SHA1(19a5ba85055f048a84ed4e8d471aaff70fcf0374) ) |
| 1637 | 1750 | |