Previous 199869 Revisions Next

r20285 Tuesday 15th January, 2013 at 22:43:08 UTC by Angelo Salese
Cleaned up Sharp MZ-2500 driver
[src/mess/drivers]mz2500.c x1.c

trunk/src/mess/drivers/mz2500.c
r20284r20285
6464public:
6565   mz2500_state(const machine_config &mconfig, device_type type, const char *tag)
6666      : driver_device(mconfig, type, tag),
67         m_rtc(*this, RP5C15_TAG)
67      m_maincpu(*this, "maincpu"),
68      m_rtc(*this, RP5C15_TAG)
6869   { }
6970
71   required_device<cpu_device> m_maincpu;
7072   required_device<rp5c15_device> m_rtc;
7173
74   UINT8 *m_main_ram;
75   UINT8 *m_ipl_rom;
76   UINT8 *m_kanji_rom;
77   UINT8 *m_kanji2_rom;
78   UINT8 *m_pcg_ram;
79   UINT8 *m_emm_ram;
80   UINT8 *m_dic_rom;
81   UINT8 *m_phone_rom;
82   UINT8 *m_iplpro_rom;
83
7284   UINT8 m_bank_val[8];
7385   UINT8 m_bank_addr;
7486   UINT8 m_irq_sel;
r20284r20285
162174   UINT8 mz2500_cg_latch_compare();
163175   UINT8 mz2500_ram_read(UINT16 offset, UINT8 bank_num);
164176   void mz2500_ram_write(UINT16 offset, UINT8 data, UINT8 bank_num);
177   virtual void machine_start();
165178   virtual void machine_reset();
166179   virtual void video_start();
167180   virtual void palette_init();
r20284r20285
182195   DECLARE_WRITE8_MEMBER(opn_porta_w);
183196   DECLARE_WRITE_LINE_MEMBER(pit8253_clk0_irq);
184197   DECLARE_WRITE_LINE_MEMBER(mz2500_rtc_alarm_irq);
198
199   void draw_80x25(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect,UINT16 map_addr);
200   void draw_40x25(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect,int plane,UINT16 map_addr);
201   void draw_cg4_screen(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect,int pri);
202   void draw_cg16_screen(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect,int plane,int x_size,int pri);
203   void draw_cg256_screen(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect,int plane,int pri);
204   void draw_tv_screen(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect);
205   void draw_cg_screen(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect,int pri);
206
185207};
186208
187209
r20284r20285
237259      bitmap.pix16(y, x) = machine.pens[pen];
238260}
239261
240static void draw_80x25(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect,UINT16 map_addr)
262void mz2500_state::draw_80x25(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect,UINT16 map_addr)
241263{
242   mz2500_state *state = machine.driver_data<mz2500_state>();
243   UINT8 *vram = machine.root_device().memregion("maincpu")->base();
264   UINT8 *vram = m_main_ram; // TODO
244265   int x,y,count,xi,yi;
245266   UINT8 *gfx_data;
246267   UINT8 y_step;
r20284r20285
249270
250271   count = (map_addr & 0x7ff);
251272
252   y_step = (state->m_text_font_reg) ? 1 : 2;
253   y_height = (state->m_text_reg[0] & 0x10) ? 10 : 8;
254   s_y = state->m_text_reg[9] & 0xf;
273   y_step = (m_text_font_reg) ? 1 : 2;
274   y_height = (m_text_reg[0] & 0x10) ? 10 : 8;
275   s_y = m_text_reg[9] & 0xf;
255276
256277   for (y=0;y<26*y_step;y+=y_step)
257278   {
r20284r20285
265286         int inv_col = (attr & 0x40) >> 6;
266287
267288         if(gfx_sel & 8) // Xevious, PCG 8 colors have priority above kanji roms
268            gfx_data = machine.root_device().memregion("pcg")->base();
289            gfx_data = m_pcg_ram;
269290         else if(gfx_sel == 0x80)
270291         {
271            gfx_data = state->memregion("kanji")->base();
292            gfx_data = m_kanji_rom;
272293            tile|= tile_bank << 8;
273294            if(y_step == 2)
274295               tile &= 0x3ffe;
275296         }
276297         else if(gfx_sel == 0xc0)
277298         {
278            gfx_data = machine.root_device().memregion("kanji")->base();
299            gfx_data = m_kanji_rom;
279300            tile|= (tile_bank << 8);
280301            if(y_step == 2)
281302               tile &= 0x3ffe;
r20284r20285
283304         }
284305         else
285306         {
286            gfx_data = machine.root_device().memregion("pcg")->base();
307            gfx_data = m_pcg_ram;
287308         }
288309
289310         for(yi=0;yi<8*y_step;yi++)
r20284r20285
291312            for(xi=0;xi<8;xi++)
292313            {
293314               UINT8 pen_bit[3],pen;
294
295315               int res_x,res_y;
296316
297317               res_x = x*8+xi;
298318               res_y = y*y_height+yi-s_y;
299319
300320               /* check TV window boundaries */
301               if(res_x < state->m_tv_hs || res_x >= state->m_tv_he || res_y < state->m_tv_vs || res_y >= state->m_tv_ve)
321               if(res_x < m_tv_hs || res_x >= m_tv_he || res_y < m_tv_vs || res_y >= m_tv_ve)
302322                  continue;
303323
304324               if(gfx_sel & 0x8)
r20284r20285
317337               if(pen)
318338               {
319339                  if((res_y) >= 0 && (res_y) < 200*y_step)
320                     mz2500_draw_pixel(machine,bitmap,res_x,res_y,pen+(state->m_pal_select ? 0x00 : 0x10),0,0);
340                     mz2500_draw_pixel(machine,bitmap,res_x,res_y,pen+(m_pal_select ? 0x00 : 0x10),0,0);
321341               }
322342            }
323343         }
r20284r20285
328348   }
329349}
330350
331static void draw_40x25(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect,int plane,UINT16 map_addr)
351void mz2500_state::draw_40x25(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect,int plane,UINT16 map_addr)
332352{
333   mz2500_state *state = machine.driver_data<mz2500_state>();
334   UINT8 *vram = machine.root_device().memregion("maincpu")->base();
353   UINT8 *vram = m_main_ram; // TODO
335354   int x,y,count,xi,yi;
336355   UINT8 *gfx_data;
337356   UINT8 y_step;
r20284r20285
340359
341360   count = (((plane * 0x400) + map_addr) & 0x7ff);
342361
343   y_step = (state->m_text_font_reg) ? 1 : 2;
344   y_height = (state->m_text_reg[0] & 0x10) ? 10 : 8;
345   s_y = state->m_text_reg[9] & 0xf;
362   y_step = (m_text_font_reg) ? 1 : 2;
363   y_height = (m_text_reg[0] & 0x10) ? 10 : 8;
364   s_y = m_text_reg[9] & 0xf;
346365
347366   for (y=0;y<26*y_step;y+=y_step)
348367   {
r20284r20285
357376         int inv_col = (attr & 0x40) >> 6;
358377
359378         if(gfx_sel & 8) // Xevious, PCG 8 colors have priority above kanji roms
360            gfx_data = machine.root_device().memregion("pcg")->base();
379            gfx_data = m_pcg_ram;
361380         else if(gfx_sel == 0x80)
362381         {
363            gfx_data = state->memregion("kanji")->base();
382            gfx_data = m_kanji_rom;
364383            tile|= tile_bank << 8;
365384            if(y_step == 2)
366385               tile &= 0x3ffe;
367386         }
368387         else if(gfx_sel == 0xc0)
369388         {
370            gfx_data = machine.root_device().memregion("kanji")->base();
389            gfx_data = m_kanji_rom;
371390            tile|= (tile_bank << 8);
372391            if(y_step == 2)
373392               tile &= 0x3ffe;
r20284r20285
375394         }
376395         else
377396         {
378            gfx_data = machine.root_device().memregion("pcg")->base();
397            gfx_data = m_pcg_ram;
379398         }
380399
381400         for(yi=0;yi<8*y_step;yi++)
r20284r20285
389408               res_y = y*y_height+yi-s_y;
390409
391410               /* check TV window boundaries */
392               if(res_x < state->m_tv_hs || res_x >= state->m_tv_he || res_y < state->m_tv_vs || res_y >= state->m_tv_ve)
411               if(res_x < m_tv_hs || res_x >= m_tv_he || res_y < m_tv_vs || res_y >= m_tv_ve)
393412                  continue;
394413
395414               if(gfx_sel & 0x8)
r20284r20285
408427               if(pen)
409428               {
410429                  if((res_y) >= 0 && (res_y) < 200*y_step)
411                     mz2500_draw_pixel(machine,bitmap,res_x,res_y,pen+(state->m_pal_select ? 0x00 : 0x10),state->m_scr_x_size == 640,0);
430                     mz2500_draw_pixel(machine,bitmap,res_x,res_y,pen+(m_pal_select ? 0x00 : 0x10),m_scr_x_size == 640,0);
412431               }
413432            }
414433         }
r20284r20285
419438   }
420439}
421440
422static void draw_cg4_screen(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect,int pri)
441void mz2500_state::draw_cg4_screen(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect,int pri)
423442{
424   mz2500_state *state = machine.driver_data<mz2500_state>();
425443   UINT32 count;
426   UINT8 *vram = state->memregion("maincpu")->base();
444   UINT8 *vram = m_main_ram; // TODO
427445   UINT8 pen,pen_bit[2];
428446   int x,y,xi,pen_i;
429447   int res_x,res_y;
r20284r20285
440458            res_y = y;
441459
442460            /* check window boundaries */
443            //if(res_x < state->m_cg_hs || res_x >= state->m_cg_he || res_y < state->m_cg_vs || res_y >= state->m_cg_ve)
461            //if(res_x < m_cg_hs || res_x >= m_cg_he || res_y < m_cg_vs || res_y >= m_cg_ve)
444462            //  continue;
445463
446464            /* TODO: very preliminary, just Yukar K2 uses this so far*/
r20284r20285
452470               pen |= pen_bit[pen_i];
453471
454472            {
455               //if(pri == ((state->m_clut256[pen] & 0x100) >> 8))
473               //if(pri == ((m_clut256[pen] & 0x100) >> 8))
456474               mz2500_draw_pixel(machine,bitmap,res_x,res_y,pen,0,0);
457475            }
458476         }
r20284r20285
461479   }
462480}
463481
464static void draw_cg16_screen(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect,int plane,int x_size,int pri)
482void mz2500_state::draw_cg16_screen(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect,int plane,int x_size,int pri)
465483{
466   mz2500_state *state = machine.driver_data<mz2500_state>();
467484   UINT32 count;
468   UINT8 *vram = state->memregion("maincpu")->base();
485   UINT8 *vram = m_main_ram; //TODO
469486   UINT8 pen,pen_bit[4];
470487   int x,y,xi,pen_i;
471488   UINT32 wa_reg;
r20284r20285
477494
478495   base_mask = (x_size == 640) ? 0x3f : 0x1f;
479496
480   count = (state->m_cg_reg[0x10]) | ((state->m_cg_reg[0x11] & base_mask) << 8);
481   wa_reg = (state->m_cg_reg[0x12]) | ((state->m_cg_reg[0x13] & base_mask) << 8);
497   count = (m_cg_reg[0x10]) | ((m_cg_reg[0x11] & base_mask) << 8);
498   wa_reg = (m_cg_reg[0x12]) | ((m_cg_reg[0x13] & base_mask) << 8);
482499   /* TODO: layer 2 scrolling */
483   s_x = (state->m_cg_reg[0x0f] & 0xf);
484   cg_interlace = state->m_text_font_reg ? 1 : 2;
485   pen_mask = (state->m_cg_reg[0x18] >> ((plane & 1) * 4)) & 0x0f;
500   s_x = (m_cg_reg[0x0f] & 0xf);
501   cg_interlace = m_text_font_reg ? 1 : 2;
502   pen_mask = (m_cg_reg[0x18] >> ((plane & 1) * 4)) & 0x0f;
486503
487//  popmessage("%d %d %d %d",state->m_cg_hs,state->m_cg_he,state->m_cg_vs,state->m_cg_ve);
504//  popmessage("%d %d %d %d",m_cg_hs,m_cg_he,m_cg_vs,m_cg_ve);
488505
489506   for(y=0;y<200;y++)
490507   {
r20284r20285
496513            res_y = y;
497514
498515            /* check window boundaries */
499            if(res_x < state->m_cg_hs || res_x >= state->m_cg_he || res_y < state->m_cg_vs || res_y >= state->m_cg_ve)
516            if(res_x < m_cg_hs || res_x >= m_cg_he || res_y < m_cg_vs || res_y >= m_cg_ve)
500517               continue;
501518
502519            pen_bit[0] = (vram[count+0x40000+((plane & 1) * 0x2000)+(((plane & 2)>>1) * 0x10000)]>>(xi)) & 1 ? (pen_mask & 0x01) : 0; //B
r20284r20285
508525            for(pen_i=0;pen_i<4;pen_i++)
509526               pen |= pen_bit[pen_i];
510527
511            if(pri == ((state->m_clut16[pen] & 0x10) >> 4) && state->m_clut16[pen] != 0x00 && pen_mask) //correct?
512               mz2500_draw_pixel(machine,bitmap,res_x,res_y,(state->m_clut16[pen] & 0x0f)+0x10,(x_size == 320 && state->m_scr_x_size == 640),cg_interlace == 2);
528            if(pri == ((m_clut16[pen] & 0x10) >> 4) && m_clut16[pen] != 0x00 && pen_mask) //correct?
529               mz2500_draw_pixel(machine,bitmap,res_x,res_y,(m_clut16[pen] & 0x0f)+0x10,(x_size == 320 && m_scr_x_size == 640),cg_interlace == 2);
513530         }
514531         count++;
515532         count&=((base_mask<<8) | 0xff);
r20284r20285
519536   }
520537}
521538
522static void draw_cg256_screen(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect,int plane,int pri)
539void mz2500_state::draw_cg256_screen(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect,int plane,int pri)
523540{
524   mz2500_state *state = machine.driver_data<mz2500_state>();
525541   UINT32 count;
526   UINT8 *vram = state->memregion("maincpu")->base();
542   UINT8 *vram = m_main_ram;
527543   UINT8 pen,pen_bit[8];
528544   int x,y,xi,pen_i;
529545   UINT32 wa_reg;
r20284r20285
534550
535551   base_mask = 0x3f; //no x_size == 640
536552
537   count = (state->m_cg_reg[0x10]) | ((state->m_cg_reg[0x11] & base_mask) << 8);
538   wa_reg = (state->m_cg_reg[0x12]) | ((state->m_cg_reg[0x13] & base_mask) << 8);
553   count = (m_cg_reg[0x10]) | ((m_cg_reg[0x11] & base_mask) << 8);
554   wa_reg = (m_cg_reg[0x12]) | ((m_cg_reg[0x13] & base_mask) << 8);
539555   /* TODO: layer 2 scrolling */
540   s_x = (state->m_cg_reg[0x0f] & 0xf);
541   cg_interlace = state->m_text_font_reg ? 1 : 2;
556   s_x = (m_cg_reg[0x0f] & 0xf);
557   cg_interlace = m_text_font_reg ? 1 : 2;
542558
543559   for(y=0;y<200;y++)
544560   {
r20284r20285
550566            res_y = y;
551567
552568            /* check window boundaries */
553            if(res_x < state->m_cg_hs || res_x >= state->m_cg_he || res_y < state->m_cg_vs || res_y >= state->m_cg_ve)
569            if(res_x < m_cg_hs || res_x >= m_cg_he || res_y < m_cg_vs || res_y >= m_cg_ve)
554570               continue;
555571
556            pen_bit[0] = (vram[count + 0x40000 + (((plane & 2)>>1) * 0x10000) + 0x2000]>>(xi)) & 1 ? (state->m_cg_reg[0x18] & 0x10) : 0; // B1
557            pen_bit[1] = (vram[count + 0x40000 + (((plane & 2)>>1) * 0x10000) + 0x0000]>>(xi)) & 1 ? (state->m_cg_reg[0x18] & 0x01) : 0; // B0
558            pen_bit[2] = (vram[count + 0x40000 + (((plane & 2)>>1) * 0x10000) + 0x6000]>>(xi)) & 1 ? (state->m_cg_reg[0x18] & 0x20) : 0; // R1
559            pen_bit[3] = (vram[count + 0x40000 + (((plane & 2)>>1) * 0x10000) + 0x4000]>>(xi)) & 1 ? (state->m_cg_reg[0x18] & 0x02) : 0; // R0
560            pen_bit[4] = (vram[count + 0x40000 + (((plane & 2)>>1) * 0x10000) + 0xa000]>>(xi)) & 1 ? (state->m_cg_reg[0x18] & 0x40) : 0; // G1
561            pen_bit[5] = (vram[count + 0x40000 + (((plane & 2)>>1) * 0x10000) + 0x8000]>>(xi)) & 1 ? (state->m_cg_reg[0x18] & 0x04) : 0; // G0
562            pen_bit[6] = (vram[count + 0x40000 + (((plane & 2)>>1) * 0x10000) + 0xe000]>>(xi)) & 1 ? (state->m_cg_reg[0x18] & 0x80) : 0; // I1
563            pen_bit[7] = (vram[count + 0x40000 + (((plane & 2)>>1) * 0x10000) + 0xc000]>>(xi)) & 1 ? (state->m_cg_reg[0x18] & 0x08) : 0; // I0
572            pen_bit[0] = (vram[count + 0x40000 + (((plane & 2)>>1) * 0x10000) + 0x2000]>>(xi)) & 1 ? (m_cg_reg[0x18] & 0x10) : 0; // B1
573            pen_bit[1] = (vram[count + 0x40000 + (((plane & 2)>>1) * 0x10000) + 0x0000]>>(xi)) & 1 ? (m_cg_reg[0x18] & 0x01) : 0; // B0
574            pen_bit[2] = (vram[count + 0x40000 + (((plane & 2)>>1) * 0x10000) + 0x6000]>>(xi)) & 1 ? (m_cg_reg[0x18] & 0x20) : 0; // R1
575            pen_bit[3] = (vram[count + 0x40000 + (((plane & 2)>>1) * 0x10000) + 0x4000]>>(xi)) & 1 ? (m_cg_reg[0x18] & 0x02) : 0; // R0
576            pen_bit[4] = (vram[count + 0x40000 + (((plane & 2)>>1) * 0x10000) + 0xa000]>>(xi)) & 1 ? (m_cg_reg[0x18] & 0x40) : 0; // G1
577            pen_bit[5] = (vram[count + 0x40000 + (((plane & 2)>>1) * 0x10000) + 0x8000]>>(xi)) & 1 ? (m_cg_reg[0x18] & 0x04) : 0; // G0
578            pen_bit[6] = (vram[count + 0x40000 + (((plane & 2)>>1) * 0x10000) + 0xe000]>>(xi)) & 1 ? (m_cg_reg[0x18] & 0x80) : 0; // I1
579            pen_bit[7] = (vram[count + 0x40000 + (((plane & 2)>>1) * 0x10000) + 0xc000]>>(xi)) & 1 ? (m_cg_reg[0x18] & 0x08) : 0; // I0
564580
565581            pen = 0;
566582            for(pen_i=0;pen_i<8;pen_i++)
567583               pen |= pen_bit[pen_i];
568584
569            if(pri == ((state->m_clut256[pen] & 0x100) >> 8))
570               mz2500_draw_pixel(machine,bitmap,res_x,res_y,(state->m_clut256[pen] & 0xff)+0x100,state->m_scr_x_size == 640,cg_interlace == 2);
585            if(pri == ((m_clut256[pen] & 0x100) >> 8))
586               mz2500_draw_pixel(machine,bitmap,res_x,res_y,(m_clut256[pen] & 0xff)+0x100,m_scr_x_size == 640,cg_interlace == 2);
571587         }
572588         count++;
573589         count&=((base_mask<<8) | 0xff);
r20284r20285
577593   }
578594}
579595
580static void draw_tv_screen(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect)
596void mz2500_state::draw_tv_screen(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect)
581597{
582   mz2500_state *state = machine.driver_data<mz2500_state>();
583598   UINT16 base_addr;
584599
585   base_addr = state->m_text_reg[1] | ((state->m_text_reg[2] & 0x7) << 8);
600   base_addr = m_text_reg[1] | ((m_text_reg[2] & 0x7) << 8);
586601
587//  popmessage("%02x",state->m_clut16[0]);
588//  popmessage("%d %d %d %d",state->m_tv_hs,(state->m_tv_he),state->m_tv_vs,(state->m_tv_ve));
602//  popmessage("%02x",m_clut16[0]);
603//  popmessage("%d %d %d %d",m_tv_hs,(m_tv_he),m_tv_vs,(m_tv_ve));
589604
590   if(state->m_text_col_size)
605   if(m_text_col_size)
591606      draw_80x25(machine,bitmap,cliprect,base_addr);
592607   else
593608   {
594609      int tv_mode;
595610
596      tv_mode = state->m_text_reg[0] >> 2;
611      tv_mode = m_text_reg[0] >> 2;
597612
598613      switch(tv_mode & 3)
599614      {
r20284r20285
610625            draw_40x25(machine,bitmap,cliprect,1,base_addr);
611626            draw_40x25(machine,bitmap,cliprect,0,base_addr);
612627            break;
613         //default: popmessage("%02x %02x %02x",tv_mode & 3,state->m_text_reg[1],state->m_text_reg[2]); break;
628         //default: popmessage("%02x %02x %02x",tv_mode & 3,m_text_reg[1],m_text_reg[2]); break;
614629      }
615630   }
616631}
617632
618static void draw_cg_screen(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect,int pri)
633void mz2500_state::draw_cg_screen(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect,int pri)
619634{
620   mz2500_state *state = machine.driver_data<mz2500_state>();
621   //popmessage("%02x %02x",state->m_cg_reg[0x0e],state->m_cg_reg[0x18]);
635   //popmessage("%02x %02x",m_cg_reg[0x0e],m_cg_reg[0x18]);
622636
623   switch(state->m_cg_reg[0x0e])
637   switch(m_cg_reg[0x0e])
624638   {
625639      case 0x00:
626640         break;
r20284r20285
645659         draw_cg16_screen(machine,bitmap,cliprect,2,640,pri);
646660         break;
647661      default:
648         popmessage("Unsupported CG mode %02x, contact MESS dev",state->m_cg_reg[0x0e]);
662         popmessage("Unsupported CG mode %02x, contact MESS dev",m_cg_reg[0x0e]);
649663         break;
650664   }
651665}
r20284r20285
757771
758772UINT8 mz2500_state::mz2500_ram_read(UINT16 offset, UINT8 bank_num)
759773{
760   UINT8 *ram = memregion("maincpu")->base();
774   UINT8 *ram = m_main_ram; // TODO
761775   UINT8 cur_bank = m_bank_val[bank_num];
762776
763777   switch(cur_bank)
r20284r20285
791805      case 0x39:
792806      {
793807         if(m_kanji_bank & 0x80) //kanji ROM
794         {
795            UINT8 *knj_rom = memregion("kanji")->base();
796
797            return knj_rom[(offset & 0x7ff)+((m_kanji_bank & 0x7f)*0x800)];
798         }
808            return m_kanji_rom[(offset & 0x7ff)+((m_kanji_bank & 0x7f)*0x800)];
799809         else //PCG RAM
800         {
801            UINT8 *pcg_ram = memregion("pcg")->base();
802
803            return pcg_ram[offset];
804         }
810            return m_pcg_ram[offset];
805811      }
806812      break;
807813      case 0x3a:
808814      {
809         UINT8 *dic_rom = memregion("dictionary")->base();
810
811         return dic_rom[(offset & 0x1fff) + ((m_dic_bank & 0x1f)*0x2000)];
815         return m_dic_rom[(offset & 0x1fff) + ((m_dic_bank & 0x1f)*0x2000)];
812816      }
813817      break;
814818      case 0x3c:
r20284r20285
816820      case 0x3e:
817821      case 0x3f:
818822      {
819         UINT8 *phone_rom = memregion("phone")->base();
820
821         return phone_rom[offset+(cur_bank & 3)*0x2000];
823         return m_phone_rom[offset+(cur_bank & 3)*0x2000];
822824      }
823825      break;
824826      default: return ram[offset+cur_bank*0x2000];
r20284r20285
829831
830832void mz2500_state::mz2500_ram_write(UINT16 offset, UINT8 data, UINT8 bank_num)
831833{
832   UINT8 *ram = memregion("maincpu")->base();
834   UINT8 *ram = m_main_ram; // TODO
833835   UINT8 cur_bank = m_bank_val[bank_num];
834836
835837//  if(cur_bank >= 0x30 && cur_bank <= 0x33)
r20284r20285
922924         }
923925         else //PCG RAM
924926         {
925            UINT8 *pcg_ram = memregion("pcg")->base();
926            pcg_ram[offset] = data;
927            if((offset & 0x1800) == 0x0000)
928               machine().gfx[3]->mark_dirty((offset) >> 3);
929            else
930               machine().gfx[4]->mark_dirty((offset & 0x7ff) >> 3);
927            m_pcg_ram[offset] = data;
928            //if((offset & 0x1800) == 0x0000)
929            //   machine().gfx[3]->mark_dirty((offset) >> 3);
930            //else
931            //   machine().gfx[4]->mark_dirty((offset & 0x7ff) >> 3);
931932         }
932933         break;
933934      }
r20284r20285
991992
992993WRITE8_MEMBER(mz2500_state::mz2500_bank_data_w)
993994{
994//  UINT8 *ROM = memregion("maincpu")->base();
995995//  static const char *const bank_name[] = { "bank0", "bank1", "bank2", "bank3", "bank4", "bank5", "bank6", "bank7" };
996996
997997   m_bank_val[m_bank_addr] = data & 0x3f;
r20284r20285
999999//  if((data*2) >= 0x70)
10001000//  printf("%s %02x\n",bank_name[m_bank_addr],m_bank_val[m_bank_addr]*2);
10011001
1002//  membank(bank_name[m_bank_addr])->set_base(&ROM[m_bank_val[m_bank_addr]*0x2000]);
1002//  membank(bank_name[m_bank_addr])->set_base(&m_main_ram[m_bank_val[m_bank_addr]*0x2000]);
10031003
10041004   m_bank_addr++;
10051005   m_bank_addr&=7;
r20284r20285
12311231
12321232READ8_MEMBER(mz2500_state::mz2500_rom_r)
12331233{
1234   UINT8 *rom = memregion("rom")->base();
1235   UINT8 res;
1234   m_lrom_index = (m_maincpu->state_int(Z80_B));
12361235
1237   m_lrom_index = (machine().device("maincpu")->state().state_int(Z80_B));
1238
12391236   m_rom_index = (m_rom_index & 0xffff00) | (m_lrom_index & 0xff);
12401237
1241   res = rom[m_rom_index];
1242
1243   return res;
1238   return m_iplpro_rom[m_rom_index];
12441239}
12451240
12461241WRITE8_MEMBER(mz2500_state::mz2500_rom_w)
12471242{
1248   m_hrom_index = (machine().device("maincpu")->state().state_int(Z80_B));
1243   m_hrom_index = (m_maincpu->state_int(Z80_B));
12491244
12501245   m_rom_index = (data << 8) | (m_rom_index & 0x0000ff) | ((m_hrom_index & 0xff)<<16);
12511246   //printf("%02x\n",data);
r20284r20285
12571252   UINT8 pal_index;
12581253   UINT8 pal_entry;
12591254
1260   pal_index = machine().device("maincpu")->state().state_int(Z80_B);
1255   pal_index = m_maincpu->state_int(Z80_B);
12611256   pal_entry = (pal_index & 0x1e) >> 1;
12621257
12631258   if(pal_index & 1)
r20284r20285
13641359   if((m_cg_reg_index & 0x1f) == 0x05 && (m_cg_reg[0x05] & 0xc0) == 0x80) //clear bitmap buffer
13651360   {
13661361      UINT32 i;
1367      UINT8 *vram = memregion("maincpu")->base();
1362      UINT8 *vram = m_main_ram; // TODO
13681363      UINT32 layer_bank;
13691364
13701365      layer_bank = (m_cg_reg[0x0e] & 0x80) ? 0x10000 : 0x00000;
r20284r20285
14501445
14511446READ8_MEMBER(mz2500_state::mz2500_kanji_r)
14521447{
1453   UINT8 *knj2_rom = memregion("kanji2")->base();
1454
14551448   printf("Read from kanji 2 ROM\n");
14561449
1457   return knj2_rom[(m_kanji_index << 1) | (offset & 1)];
1450   return m_kanji2_rom[(m_kanji_index << 1) | (offset & 1)];
14581451}
14591452
14601453WRITE8_MEMBER(mz2500_state::mz2500_kanji_w)
r20284r20285
14641457
14651458READ8_MEMBER(mz2500_state::rp5c15_8_r)
14661459{
1467   UINT8 rtc_index = (machine().device("maincpu")->state().state_int(Z80_B));
1460   UINT8 rtc_index = (m_maincpu->state_int(Z80_B));
14681461
14691462   return m_rtc->read(space, rtc_index);
14701463}
14711464
14721465WRITE8_MEMBER(mz2500_state::rp5c15_8_w)
14731466{
1474   UINT8 rtc_index = (machine().device("maincpu")->state().state_int(Z80_B));
1467   UINT8 rtc_index = (m_maincpu->state_int(Z80_B));
14751468
14761469   m_rtc->write(space, rtc_index, data);
14771470}
r20284r20285
14791472
14801473READ8_MEMBER(mz2500_state::mz2500_emm_data_r)
14811474{
1482   UINT8 *emm_ram = memregion("emm")->base();
14831475   UINT8 emm_lo_index;
14841476
1485   emm_lo_index = (machine().device("maincpu")->state().state_int(Z80_B));
1477   emm_lo_index = (m_maincpu->state_int(Z80_B));
14861478
14871479   m_emm_offset = (m_emm_offset & 0xffff00) | (emm_lo_index & 0xff);
14881480
14891481   if(m_emm_offset < 0x100000) //emm max size
1490      return emm_ram[m_emm_offset];
1482      return m_emm_ram[m_emm_offset];
14911483
14921484   return 0xff;
14931485}
r20284r20285
14961488{
14971489   UINT8 emm_hi_index;
14981490
1499   emm_hi_index = (machine().device("maincpu")->state().state_int(Z80_B));
1491   emm_hi_index = (m_maincpu->state_int(Z80_B));
15001492
15011493   m_emm_offset = ((emm_hi_index & 0xff) << 16) | ((data & 0xff) << 8) | (m_emm_offset & 0xff);
15021494}
15031495
15041496WRITE8_MEMBER(mz2500_state::mz2500_emm_data_w)
15051497{
1506   UINT8 *emm_ram = memregion("emm")->base();
15071498   UINT8 emm_lo_index;
15081499
1509   emm_lo_index = (machine().device("maincpu")->state().state_int(Z80_B));
1500   emm_lo_index = (m_maincpu->state_int(Z80_B));
15101501
15111502   m_emm_offset = (m_emm_offset & 0xffff00) | (emm_lo_index & 0xff);
15121503
15131504   if(m_emm_offset < 0x100000) //emm max size
1514      emm_ram[m_emm_offset] = data;
1505      m_emm_ram[m_emm_offset] = data;
15151506}
15161507
15171508static ADDRESS_MAP_START(mz2500_io, AS_IO, 8, mz2500_state )
r20284r20285
17391730      state->m_bank_val[i] = bank_reset_val[type][i];
17401731}
17411732
1733static const gfx_layout mz2500_pcg_layout_1bpp =
1734{
1735   8, 8,
1736   0x100,
1737   1,
1738   { 0 },
1739   { 0, 1, 2, 3, 4, 5, 6, 7 },
1740   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
1741   8 * 8
1742};
1743
1744static const gfx_layout mz2500_pcg_layout_3bpp =
1745{
1746   8, 8,
1747   0x100,
1748   3,
1749   { RGN_FRAC(3,4), RGN_FRAC(2,4), RGN_FRAC(1,4) },
1750   { 0, 1, 2, 3, 4, 5, 6, 7 },
1751   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
1752   8 * 8
1753};
1754
1755void mz2500_state::machine_start()
1756{
1757   /* TODO: main RAM actually needs to be splitted */
1758   m_main_ram = auto_alloc_array_clear(machine(), UINT8, 0x80000);
1759   m_pcg_ram = auto_alloc_array_clear(machine(), UINT8, 0x2000);
1760   m_ipl_rom = memregion("ipl")->base();
1761   m_kanji_rom = memregion("kanji")->base();
1762   m_kanji2_rom = memregion("kanji2")->base();
1763   m_emm_ram = auto_alloc_array_clear(machine(), UINT8, 0x100000);
1764   m_dic_rom = memregion("dictionary")->base();
1765   m_phone_rom = memregion("phone")->base();
1766   m_iplpro_rom = memregion("iplpro")->base();
1767
1768   state_save_register_global_pointer(machine(), m_main_ram, 0x80000);
1769   state_save_register_global_pointer(machine(), m_pcg_ram, 0x2000);
1770   state_save_register_global_pointer(machine(), m_emm_ram, 0x100000);
1771
1772   /* TODO: gfx[4] crashes as per now */
1773//   machine().gfx[3] = auto_alloc(machine(), gfx_element(machine(), mz2500_pcg_layout_1bpp, (UINT8 *)m_pcg_ram, 0x10, 0));
1774//   machine().gfx[4] = auto_alloc(machine(), gfx_element(machine(), mz2500_pcg_layout_3bpp, (UINT8 *)m_pcg_ram, 4, 0));
1775}
1776
17421777void mz2500_state::machine_reset()
17431778{
1744   UINT8 *RAM = machine().root_device().memregion("maincpu")->base();
1745   UINT8 *IPL = memregion("ipl")->base();
17461779   UINT32 i;
17471780
17481781   mz2500_reset(this, IPL_RESET);
r20284r20285
17551788   /* copy IPL to its natural bank ROM/RAM position */
17561789   for(i=0;i<0x8000;i++)
17571790   {
1758      //RAM[i] = IPL[i];
1759      RAM[i+0x68000] = IPL[i];
1791      //m_main_ram[i] = IPL[i];
1792      m_main_ram[i+0x68000] = m_ipl_rom[i];
17601793   }
17611794
17621795   /* clear CG RAM */
17631796   for(i=0;i<0x20000;i++)
1764      RAM[i+0x40000] = 0x00;
1797      m_main_ram[i+0x40000] = 0x00;
17651798
17661799   /* disable IRQ */
17671800   for(i=0;i<4;i++)
r20284r20285
18111844   16 * 16     /* code takes 16 times 16 bits */
18121845};
18131846
1814static const gfx_layout mz2500_pcg_layout_1bpp =
1815{
1816   8, 8,
1817   RGN_FRAC(1,4),
1818   1,
1819   { 0 },
1820   { 0, 1, 2, 3, 4, 5, 6, 7 },
1821   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
1822   8 * 8
1823};
1824
1825static const gfx_layout mz2500_pcg_layout_3bpp =
1826{
1827   8, 8,
1828   RGN_FRAC(1,4),
1829   3,
1830   { RGN_FRAC(3,4), RGN_FRAC(2,4), RGN_FRAC(1,4) },
1831   { 0, 1, 2, 3, 4, 5, 6, 7 },
1832   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
1833   8 * 8
1834};
1835
18361847/* these are just for viewer sake, actually they aren't used in drawing routines */
18371848static GFXDECODE_START( mz2500 )
18381849   GFXDECODE_ENTRY("kanji", 0, mz2500_cg_layout, 0, 256)
18391850   GFXDECODE_ENTRY("kanji", 0x4400, mz2500_8_layout, 0, 256)
18401851   GFXDECODE_ENTRY("kanji", 0, mz2500_16_layout, 0, 256)
1841   GFXDECODE_ENTRY("pcg", 0, mz2500_pcg_layout_1bpp, 0, 0x10)
1842   GFXDECODE_ENTRY("pcg", 0, mz2500_pcg_layout_3bpp, 0, 4)
1852//   GFXDECODE_ENTRY("pcg", 0, mz2500_pcg_layout_1bpp, 0, 0x10)
1853//   GFXDECODE_ENTRY("pcg", 0, mz2500_pcg_layout_3bpp, 0, 4)
18431854GFXDECODE_END
18441855
18451856INTERRUPT_GEN_MEMBER(mz2500_state::mz2500_vbl)
r20284r20285
18971908   {
18981909      mz2500_reset(this, WRAM_RESET);
18991910      /* correct? */
1900      machine().device("maincpu")->execute().set_input_line(INPUT_LINE_RESET, PULSE_LINE);
1911      m_maincpu->set_input_line(INPUT_LINE_RESET, PULSE_LINE);
19011912   }
19021913
19031914   /* bit 2 is speaker */
r20284r20285
20602071WRITE_LINE_MEMBER(mz2500_state::pit8253_clk0_irq)
20612072{
20622073   if(m_irq_mask[1]/* && state & 1*/)
2063      machine().device("maincpu")->execute().set_input_line_and_vector(0, HOLD_LINE,m_irq_vector[1]);
2074      m_maincpu->set_input_line_and_vector(0, HOLD_LINE,m_irq_vector[1]);
20642075}
20652076
20662077static const struct pit8253_config mz2500_pit8253_intf =
r20284r20285
20882099{
20892100   /* TODO: doesn't work yet */
20902101//  if(m_irq_mask[3] && state & 1)
2091//      device.device("maincpu")->execute().set_input_line_and_vector(0, HOLD_LINE,drvm_irq_vector[3]);
2102//      m_maincpu->set_input_line_and_vector(0, HOLD_LINE,drvm_irq_vector[3]);
20922103}
20932104
20942105static RP5C15_INTERFACE( rtc_intf )
r20284r20285
21522163
21532164/* ROM definition */
21542165ROM_START( mz2500 )
2155   ROM_REGION( 0x80000, "maincpu", ROMREGION_ERASEFF )
2156
2157   ROM_REGION( 0x2000, "pcg", ROMREGION_ERASE00 )
2158
2159   ROM_REGION( 0x100000, "emm", ROMREGION_ERASEFF )
2160
21612166   ROM_REGION( 0x08000, "ipl", 0 )
21622167   ROM_LOAD( "ipl.rom", 0x00000, 0x8000, CRC(7a659f20) SHA1(ccb3cfdf461feea9db8d8d3a8815f7e345d274f7) )
21632168
r20284r20285
21742179   ROM_REGION( 0x40000, "dictionary", 0 )
21752180   ROM_LOAD( "dict.rom", 0x00000, 0x40000, CRC(aa957c2b) SHA1(19a5ba85055f048a84ed4e8d471aaff70fcf0374) )
21762181
2177   ROM_REGION( 0x8000, "rom", ROMREGION_ERASEFF ) //iplpro
2182   ROM_REGION( 0x8000, "iplpro", ROMREGION_ERASEFF )
21782183   ROM_LOAD( "sasi.rom", 0x00000, 0x8000, CRC(a7bf39ce) SHA1(3f4a237fc4f34bac6fe2bbda4ce4d16d42400081) )
21792184
21802185   ROM_REGION( 0x8000, "phone", ROMREGION_ERASEFF )
r20284r20285
21822187ROM_END
21832188
21842189ROM_START( mz2520 )
2185   ROM_REGION( 0x80000, "maincpu", ROMREGION_ERASEFF )
2186
2187   ROM_REGION( 0x2000, "pcg", ROMREGION_ERASE00 )
2188
2189   ROM_REGION( 0x100000, "emm", ROMREGION_ERASEFF )
2190
21912190   ROM_REGION( 0x08000, "ipl", 0 )
21922191   ROM_LOAD( "ipl2520.rom", 0x00000, 0x8000, CRC(0a126eb2) SHA1(faf71236b3ad82d30184adea951d43d10ced663d) )
21932192
r20284r20285
22042203   ROM_REGION( 0x40000, "dictionary", 0 )
22052204   ROM_LOAD( "dict.rom", 0x00000, 0x40000, CRC(aa957c2b) SHA1(19a5ba85055f048a84ed4e8d471aaff70fcf0374) )
22062205
2207   ROM_REGION( 0x8000, "rom", ROMREGION_ERASEFF ) //iplpro
2206   ROM_REGION( 0x8000, "iplpro", ROMREGION_ERASEFF )
22082207   ROM_LOAD( "sasi.rom", 0x00000, 0x8000, CRC(a7bf39ce) SHA1(3f4a237fc4f34bac6fe2bbda4ce4d16d42400081) )
22092208
22102209   ROM_REGION( 0x8000, "phone", ROMREGION_ERASEFF )
trunk/src/mess/drivers/x1.c
r20284r20285
276276/* adjust tile index when we are under double height condition */
277277UINT8 x1_state::check_prev_height(running_machine &machine,int x,int y,int x_size)
278278{
279   x1_state *state = machine.driver_data<x1_state>();
280   UINT8 prev_tile = state->m_tvram[(x+((y-1)*x_size)+mc6845_start_addr) & 0x7ff];
281   UINT8 cur_tile = state->m_tvram[(x+(y*x_size)+mc6845_start_addr) & 0x7ff];
282   UINT8 prev_attr = state->m_avram[(x+((y-1)*x_size)+mc6845_start_addr) & 0x7ff];
283   UINT8 cur_attr = state->m_avram[(x+(y*x_size)+mc6845_start_addr) & 0x7ff];
279   UINT8 prev_tile = m_tvram[(x+((y-1)*x_size)+mc6845_start_addr) & 0x7ff];
280   UINT8 cur_tile = m_tvram[(x+(y*x_size)+mc6845_start_addr) & 0x7ff];
281   UINT8 prev_attr = m_avram[(x+((y-1)*x_size)+mc6845_start_addr) & 0x7ff];
282   UINT8 cur_attr = m_avram[(x+(y*x_size)+mc6845_start_addr) & 0x7ff];
284283
285284   if(prev_tile == cur_tile && prev_attr == cur_attr)
286285      return 8;
r20284r20285
291290/* Exoa II - Warroid: if double height isn't enabled on the first tile of the line then double height is disabled on everything else. */
292291UINT8 x1_state::check_line_valid_height(running_machine &machine,int y,int x_size,int height)
293292{
294   x1_state *state = machine.driver_data<x1_state>();
295   UINT8 line_attr = state->m_avram[(0+(y*x_size)+mc6845_start_addr) & 0x7ff];
293   UINT8 line_attr = m_avram[(0+(y*x_size)+mc6845_start_addr) & 0x7ff];
296294
297295   if((line_attr & 0x40) == 0)
298296      return 0;

Previous 199869 Revisions Next


© 1997-2024 The MAME Team