Previous 15994 Revisions Next

r8962 Monday 30th August, 2010 at 20:45:43 UTC by Angelo Salese
[MZ-2500]: Various fixes, fixes booting in PCP/M
[src/mess/drivers]mz2500.c

src/mess/drivers/mz2500.c
r8961r8962
88   - 4096 color mode;
99   - Kanji text is cutted in half when font_size is 1, different data used?
1010     (check Back to the Future);
11   - check how crtc really changes the screen resolution;
12   - Add cg latch read;
1311   - Implement unlatched ROMs (Phone and Dictionary);
12   - Find real CRTC registers
1413   - Implement external ROM hook-up;
1514   - FDC loading without the IPLPRO doesn't work at all, why?
1615   - reverse / blanking tvram attributes;
16   - clean-ups! ^^'
1717
1818    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?
2119   - (Renju): hangs on the "presents" screen;
2220   - (Xtal Soft - The Prince of Darkness): dies on IPLPRO loading, presumably a wd17xx core bug;
2321   - (Sound Gal): dies with bad code, another wd17xx core bug;
2422   - Basic: vertical scrolling returns wrap-around that shouldn't wrap;
23   - Basic: loading has an alignment bug with the bitmap
2524   - (K2): doesn't seem to work, there was a "Disk I/O error" msg before;
2625   - LayDock: hangs by reading the FDC status and expecting it to become 0x81;
2726   - Mappy: TVRAM layer is double x sized than it should be;
r8961r8962
3029   - Multiplan: hangs after you set the RTC;
3130   - Murder Club: has lots of CG artifacts;
3231   - 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
3432   - Relics: doesn't boot, bad dump?
3533   - Super MZ Demo 1: Hangs at the logo "roar".
3634   - Telephone Soft: shows garbage with the CG layer;
3735   - 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;
3837   - Xevious: has issues with the window effects, it should actually be applied on TV layer and not CG.
3938   - Ys 3: crashes if you try to load it with different DSW settings
4039
r8961r8962
7776static UINT8 cg_mask;
7877static UINT8 wid_40;
7978static UINT16 cg_vs,cg_ve,cg_hs,cg_he; //CG window parameters
79static UINT8 cg_latch[4];
8080
8181#define WRAM_RESET 0
8282#define IPL_RESET 1
r8961r8962
310310            draw_40x25(machine,bitmap,cliprect,0,base_addr);
311311            draw_40x25(machine,bitmap,cliprect,1,base_addr);
312312            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;
314314      }
315315   }
316316}
r8961r8962
455455    return 0;
456456}
457457
458static 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
458476static UINT8 mz2500_ram_read(running_machine *machine, UINT16 offset, UINT8 bank_num)
459477{
460478   UINT8 *ram = memory_region(machine, "maincpu");
r8961r8962
462480
463481   switch(cur_bank)
464482   {
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;
465509      case 0x39:
466510      {
467511         if(kanji_bank & 0x80) //kanji ROM
r8961r8962
666710}
667711
668712/*
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
713TVRAM / CRTC registers
673714
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
675732*/
676733
677734static UINT8 pal_256_param(int index, int param)
r8961r8962
696753      case 0: text_reg_index = data; break;
697754      case 1:
698755         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]);
700763
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
701767         if(text_reg_index == 0x0a) // set 256 color palette
702768         {
703769            int i,r,g,b;
r8961r8962
841907   AM_RANGE(0xe000, 0xffff) AM_READWRITE(bank7_r,bank7_w)
842908ADDRESS_MAP_END
843909
844#if 0
845static READ8_HANDLER( kludge_r )
846{
847   return 0xff; //mame_rand(space->machine);
848}
849#endif
850
851910static UINT32 rom_index;
852911static UINT8 hrom_index,lrom_index;
853912
r8961r8962
904963   wd17xx_w(device, offset, data ^ fdc_reverse);
905964}
906965
907/*
908"GDE" CRTC registers
966static 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}
909973
9100x05: clear bitmap buffer register
911974
9120x08: screen res vertical start lo reg
9130x09: screen res vertical start hi reg (upper 1 bit)
9140x0a: screen res vertical end lo reg
9150x0b: screen res vertical end hi reg (upper 1 bit)
9160x0c: screen res horizontal start reg (7 bits, val x 8)
9170x0d: screen res horizontal end reg (7 bits, val x 8)
9180x0e: screen size reg
919
920*/
921
922975static READ8_HANDLER( mz2500_rplane_latch_r )
923976{
924977   if(cg_reg[0x07] & 0x10)
r8961r8962
931984      return vblank_bit;
932985   }
933986   else
934      return 0xff;
987      return cg_latch[1];
935988}
936989
990static READ8_HANDLER( mz2500_gplane_latch_r )
991{
992   return cg_latch[2];
993}
994
995static READ8_HANDLER( mz2500_iplane_latch_r )
996{
997   return cg_latch[3];
998}
999
1000/*
1001"GDE" CRTC registers
1002
10030x00: CG B - Replace / Pset register data mask
10040x01: CG R - Replace / Pset register data mask
10050x02: CG G - Replace / Pset register data mask
10060x03: CG I - Replace / Pset register data mask
10070x04: CG Replace / Pset active pixel
10080x05: CG Replace / Pset mode register
10090x06: CG Replace data register
10100x07: compare CG buffer register
10110x08: CG window vertical start lo reg
10120x09: CG window vertical start hi reg (upper 1 bit)
10130x0a: CG window vertical end lo reg
10140x0b: CG window vertical end hi reg (upper 1 bit)
10150x0c: CG window horizontal start reg (7 bits, val x 8)
10160x0d: CG window horizontal end reg (7 bits, val x 8)
10170x0e: CG mode
10180x0f: vertical scroll shift (---- xxxx)
10190x10: CG map base lo reg
10200x11: CG map base hi reg
10210x12: CG layer 0 end address lo reg
10220x13: CG layer 0 end address hi reg
10230x14: CG layer 1 start address lo reg
10240x15: CG layer 1 start address hi reg
10250x16: CG layer 1 y pixel start lo reg
10260x17: CG layer 1 y pixel start hi reg
10270x18: CG color masking
1028*/
1029
9371030static WRITE8_HANDLER( mz2500_cg_addr_w )
9381031{
9391032   cg_reg_index = data;
r8961r8962
9771070      }
9781071   }
9791072
980   if(cg_reg_index & 0x80) //enable auto-inc
981      cg_reg_index = (cg_reg_index & 0xfc) | ((cg_reg_index + 1) & 0x03);
982
9831073   {
9841074      rectangle visarea;
9851075      static int x_size,y_size;
r8961r8962
10041094
10051095      space->machine->primary_screen->configure(720, 480, visarea, space->machine->primary_screen->frame_period().attoseconds); //TODO
10061096   }
1097
1098   if(cg_reg_index & 0x80) //enable auto-inc
1099      cg_reg_index = (cg_reg_index & 0xfc) | ((cg_reg_index + 1) & 0x03);
10071100}
10081101
10091102static WRITE8_HANDLER( timer_w )
r8961r8962
10531146   joy_mode = data;
10541147}
10551148
1149static UINT16 kanji_index;
10561150
1151static 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
1160static 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
10571166static ADDRESS_MAP_START(mz2500_io, ADDRESS_SPACE_IO, 8)
10581167   ADDRESS_MAP_GLOBAL_MASK(0xff)
10591168//  AM_RANGE(0x60, 0x63) AM_WRITE(w3100a_w)
r8961r8962
10681177//  AM_RANGE(0xb0, 0xb3) AM_READWRITE(sio_r,sio_w)
10691178   AM_RANGE(0xb4, 0xb4) AM_READWRITE(mz2500_bank_addr_r,mz2500_bank_addr_w)
10701179   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)
10731182   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)
10751185   AM_RANGE(0xc6, 0xc6) AM_WRITE(mz2500_irq_sel_w)
10761186   AM_RANGE(0xc7, 0xc7) AM_WRITE(mz2500_irq_data_w)
10771187   AM_RANGE(0xc8, 0xc9) AM_DEVREADWRITE("ym", ym2203_r, ym2203_w)
r8961r8962
16321742   ROM_REGION( 0x40000, "kanji", 0 )
16331743   ROM_LOAD( "kanji.rom", 0x0000, 0x40000, CRC(dd426767) SHA1(cc8fae0cd1736bc11c110e1c84d3f620c5e35b80) )
16341744
1745   ROM_REGION( 0x20000, "kanji2", 0 )
1746   ROM_LOAD( "kanji2.rom", 0x0000, 0x20000, CRC(eaaf20c9) SHA1(771c4d559b5241390215edee798f3bce169d418c) )
1747
16351748   ROM_REGION( 0x40000, "dictionary", 0 )
16361749   ROM_LOAD( "dict.rom", 0x00000, 0x40000, CRC(aa957c2b) SHA1(19a5ba85055f048a84ed4e8d471aaff70fcf0374) )
16371750

Previous 15994 Revisions Next


© 1998-2018 The MESS Team