Previous 15994 Revisions Next

r8926 Friday 27th August, 2010 at 17:34:44 UTC by Angelo Salese
[MZ-2500]: Added 3bpp PCG support, needed by BASIC disks
[src/mess/drivers]mz2500.c

src/mess/drivers/mz2500.c
r8925r8926
66
77   TODO:
88   - floppy device;
9   - graphics are really a bare minimum, this thing is very complex;
910   - keyboard inputs (needs something that actually works);
1011
1112    memory map:
r8925r8926
3940static UINT8 kanji_bank;
4041static UINT8 fdc_reverse;
4142static UINT8 key_mux;
43static UINT8 crtc_reg_index;
44static UINT8 crtc_reg[0x20];
4245
4346#define WRAM_RESET 0
4447#define IPL_RESET 1
r8925r8926
6972
7073   if(text_font_reg)
7174   {
72      for (y=0;y<25;y++)
75      for (y=0;y<25*2;y++)
7376      {
74         for (x=0;x<text_col_size;x++)
77         for (x=0;x<80/*text_col_size*/;x++)
7578         {
7679            int tile = vram[count+0x0000] & 0xff;
7780            int attr = vram[count+0x0800];
r8925r8926
8083            //int gfx_num;
8184            int color = attr & 7;
8285
83            if(gfx_sel == 0x00)
86            if(gfx_sel == 0x80 || gfx_sel == 0xc0)
87               gfx_data = memory_region(screen->machine,"kanji"); //TODO
88            else
8489               gfx_data = memory_region(screen->machine,"pcg");
85            else
86               gfx_data = memory_region(screen->machine,"kanji"); //TODO
8790
8891            tile|= tile_bank << 8;
8992
r8925r8926
9194            {
9295               for(xi=0;xi<8;xi++)
9396               {
94                  UINT8 pen;
97                  UINT8 pen_bit[3],pen;
9598
96                  pen = ((gfx_data[tile*8+yi]>>(7-xi)) & 1) ? color : 0;
99                  if(gfx_sel & 0x8)
100                  {
101                     pen_bit[0] = ((gfx_data[tile*8+yi+0x1800]>>(7-xi)) & 1) ? 4 : 0; //G
102                     pen_bit[1] = ((gfx_data[tile*8+yi+0x1000]>>(7-xi)) & 1) ? 2 : 0; //R
103                     pen_bit[2] = ((gfx_data[tile*8+yi+0x0800]>>(7-xi)) & 1) ? 1 : 0; //B
97104
105                     pen = pen_bit[0]|pen_bit[1]|pen_bit[2];
106                  }
107                  else
108                     pen = ((gfx_data[tile*8+yi]>>(7-xi)) & 1) ? color : 0;
109
98110                  *BITMAP_ADDR16(bitmap, (y*8+yi), x*8+xi) = screen->machine->pens[pen];
99111               }
100112            }
r8925r8926
117129            //int gfx_num;
118130            int color = attr & 7;
119131
120            if(gfx_sel == 0x00)
132            if(gfx_sel == 0x80 || gfx_sel == 0xc0)
133               gfx_data = memory_region(screen->machine,"kanji"); //TODO
134            else
121135               gfx_data = memory_region(screen->machine,"pcg");
122            else
123               gfx_data = memory_region(screen->machine,"kanji"); //TODO
124136
125137            tile|= tile_bank << 8;
126138
r8925r8926
202214         {
203215            UINT8 *pcg_ram = memory_region(machine, "pcg");
204216            pcg_ram[offset] = data;
205            gfx_element_mark_dirty(machine->gfx[3], (offset) >> 3);
217            if((offset & 0x1800) == 0x0000)
218               gfx_element_mark_dirty(machine->gfx[3], (offset) >> 3);
219            else
220               gfx_element_mark_dirty(machine->gfx[4], (offset & 0x7ff) >> 3);
206221         }
207222      }
208223      break;
r8925r8926
275290}
276291
277292/* 0xf4 - 0xf7 all returns vblank / hblank states */
278static READ8_HANDLER( mz2500_crtc_r )
293static READ8_HANDLER( mz2500_crtc_hvblank_r )
279294{
280295   static UINT8 vblank_bit, hblank_bit;
281296
r8925r8926
285300   return vblank_bit | hblank_bit;
286301}
287302
288static WRITE8_HANDLER( mz2500_crtc_w )
303static WRITE8_HANDLER( mz2500_txt_crtc_w )
289304{
290305   switch(offset)
291306   {
r8925r8926
447462   wd17xx_w(device, offset, data ^ fdc_reverse);
448463}
449464
465static WRITE8_HANDLER( mz2500_crtc_addr_w )
466{
467   crtc_reg_index = data & 0x1f;
468}
469
470static WRITE8_HANDLER( mz2500_crtc_data_w )
471{
472   crtc_reg[crtc_reg_index & 0x1f] = data;
473
474   popmessage("%02x",crtc_reg[0x0e]);
475}
476
450477static ADDRESS_MAP_START(mz2500_io, ADDRESS_SPACE_IO, 8)
451478   ADDRESS_MAP_GLOBAL_MASK(0xff)
452479//  AM_RANGE(0x60, 0x63) AM_WRITE(w3100a_w)
r8925r8926
462489   AM_RANGE(0xb4, 0xb4) AM_READWRITE(mz2500_bank_addr_r,mz2500_bank_addr_w)
463490   AM_RANGE(0xb5, 0xb5) AM_READWRITE(mz2500_bank_data_r,mz2500_bank_data_w)
464491//  AM_RANGE(0xb8, 0xb9) AM_READWRITE(kanji_r,kanji_w)
465//  AM_RANGE(0xbc, 0xbd) AM_READWRITE(crtc_r,crtc_w)
492   AM_RANGE(0xbc, 0xbc) AM_WRITE(mz2500_crtc_addr_w)
493   AM_RANGE(0xbd, 0xbd) AM_WRITE(mz2500_crtc_data_w)
494//   AM_RANGE(0xbc, 0xbf) AM_READ(mz2500_crtc_cg_r) //reads plane
466495   AM_RANGE(0xc6, 0xc6) AM_WRITE(mz2500_irq_sel_w)
467496   AM_RANGE(0xc7, 0xc7) AM_WRITE(mz2500_irq_data_w)
468497   AM_RANGE(0xc8, 0xc9) AM_DEVREADWRITE("ym", ym2203_r, ym2203_w)
r8925r8926
478507   AM_RANGE(0xea, 0xeb) AM_DEVREADWRITE("z80pio_1", z80pio_d_r, z80pio_d_w)
479508//  AM_RANGE(0xef, 0xef) AM_READWRITE(joystick_r,joystick_w)
480509//  AM_RANGE(0xf0, 0xf3) AM_WRITE(timer_w)
481   AM_RANGE(0xf4, 0xf7) AM_READ(mz2500_crtc_r) AM_WRITE(mz2500_crtc_w)
510   AM_RANGE(0xf4, 0xf7) AM_READ(mz2500_crtc_hvblank_r) AM_WRITE(mz2500_txt_crtc_w)
482511//  AM_RANGE(0xf8, 0xf9) AM_READWRITE(extrom_r,extrom_w)
483512ADDRESS_MAP_END
484513
r8925r8926
891920   16 * 16      /* code takes 16 times 16 bits */
892921};
893922
923static const gfx_layout mz2500_pcg_layout_1bpp =
924{
925   8, 8,
926   RGN_FRAC(1,4),
927   1,
928   { 0 },
929   { 0, 1, 2, 3, 4, 5, 6, 7 },
930   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
931   8 * 8
932};
933
934static const gfx_layout mz2500_pcg_layout_3bpp =
935{
936   8, 8,
937   RGN_FRAC(1,4),
938   3,
939   { RGN_FRAC(3,4), RGN_FRAC(2,4), RGN_FRAC(1,4) },
940   { 0, 1, 2, 3, 4, 5, 6, 7 },
941   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
942   8 * 8
943};
944
945
894946static GFXDECODE_START( mz2500 )
895947   GFXDECODE_ENTRY("kanji", 0, mz2500_cg_layout, 0, 256)
896948   GFXDECODE_ENTRY("kanji", 0x4400, mz2500_8_layout, 0, 256)   // for viewer only
897949   GFXDECODE_ENTRY("kanji", 0, mz2500_16_layout, 0, 256)      // for viewer only
898   GFXDECODE_ENTRY("pcg", 0, mz2500_cg_layout, 0, 256)
950   GFXDECODE_ENTRY("pcg", 0, mz2500_pcg_layout_1bpp, 0, 1)
951   GFXDECODE_ENTRY("pcg", 0, mz2500_pcg_layout_3bpp, 0, 1)
899952GFXDECODE_END
900953
901954static INTERRUPT_GEN( mz2500_vbl )
r8925r8926
10621115   /* video hardware */
10631116   MDRV_SCREEN_ADD("screen", RASTER)
10641117   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
1065   MDRV_SCREEN_RAW_PARAMS(XTAL_17_73447MHz/2, 568, 0, 320, 312, 0, 200)
1118   //MDRV_SCREEN_RAW_PARAMS(XTAL_17_73447MHz/2, 568, 0, 320, 312, 0, 200)
1119   MDRV_SCREEN_RAW_PARAMS(XTAL_17_73447MHz, 640+108, 0, 640, 480, 0, 400) //TODO: fix this
10661120   MDRV_PALETTE_LENGTH(0x200+4096) // TODO: it needs more than this
10671121   MDRV_PALETTE_INIT(mz2500)
10681122

Previous 15994 Revisions Next


© 1998-2018 The MESS Team