Previous 15994 Revisions Next

r8930 Saturday 28th August, 2010 at 15:43:45 UTC by Angelo Salese
[MZ-2500]: Added preliminary 16 color CG screen and joystick inputs, making Excite Bike the first working game of the system
[src/mess/drivers]mz2500.c

src/mess/drivers/mz2500.c
r8929r8930
124124
125125   count = 0x70000;
126126
127   if(tv_mode != 1)
128      popmessage("%02x",tv_mode);
127//   if(tv_mode != 1)
128//   popmessage("%02x %02x %02x",tv_mode,text_reg[1],text_reg[2]);
129129
130130   for (y=0;y<25;y++)
131131   {
r8929r8930
230230   #endif
231231}
232232
233static void draw_cg16_screen(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
234{
235   static UINT32 count;
236   UINT8 *vram = memory_region(machine, "maincpu");
237   UINT8 pen,pen_bit[4];
238   int x,y,xi;
239
240   count = 0x40000;
241
242   for(y=0;y<200;y++)
243   {
244      for(x=0;x<320;x+=8)
245      {
246         for(xi=0;xi<8;xi++)
247         {
248            pen_bit[0] = (vram[count+0x0000]>>(xi)) & 1 ? 1 : 0;
249            pen_bit[1] = (vram[count+0x4000]>>(xi)) & 1 ? 2 : 0;
250            pen_bit[2] = (vram[count+0x8000]>>(xi)) & 1 ? 4 : 0;
251            pen_bit[3] = (vram[count+0xc000]>>(xi)) & 1 ? 0 : 8; //FIXME: this should be swapped
252
253            pen = pen_bit[0]|pen_bit[1]|pen_bit[2]|pen_bit[3];
254
255            if(pen != 8)
256               *BITMAP_ADDR16(bitmap, y, x+xi) = machine->pens[pen+0x200];
257         }
258         count++;
259      }
260   }
261}
262
233263static void draw_cg256_screen(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
234264{
235265   static UINT32 count;
r8929r8930
258288static VIDEO_UPDATE( mz2500 )
259289{
260290   if(pal_select)
291   {
261292      draw_tv_screen(screen->machine,bitmap,cliprect);
293      draw_cg16_screen(screen->machine,bitmap,cliprect);
294   }
262295   else //4096 mode colors
263296   {
264297      // ...
r8929r8930
649682
650683static WRITE8_HANDLER( mz2500_crtc_data_w )
651684{
652
653685   crtc_reg[crtc_reg_index & 0x1f] = data;
654686
655687   if((crtc_reg_index & 0x1f) == 0x08) //accessing VS LO reg clears VS HI reg
r8929r8930
658690   if((crtc_reg_index & 0x1f) == 0x0a) //accessing VE LO reg clears VE HI reg
659691      crtc_reg[0x0b] = 0;
660692
693   if((crtc_reg_index & 0x1f) == 0x05) //clear bitmap buffer
694   {
695      UINT32 i;
696      UINT8 *vram = memory_region(space->machine, "maincpu");
697
698      /* TODO: this isn't yet 100% accurate */
699      if(crtc_reg[0x05] & 1)
700      {
701         for(i=0;i<0x4000;i++)
702            vram[i+0x40000] = 0x00; //clear B
703      }
704      if(crtc_reg[0x05] & 2)
705      {
706         for(i=0;i<0x4000;i++)
707            vram[i+0x44000] = 0x00; //clear R
708      }
709      if(crtc_reg[0x05] & 4)
710      {
711         for(i=0;i<0x4000;i++)
712            vram[i+0x48000] = 0x00; //clear G
713      }
714      if(crtc_reg[0x05] & 8)
715      {
716         for(i=0;i<0x4000;i++)
717            vram[i+0x4c000] = 0x00; //clear I
718      }
719   }
720
661721   if(crtc_reg_index & 0x80) //enable auto-inc
662722      crtc_reg_index = (crtc_reg_index & 0xfc) | ((crtc_reg_index + 1) & 0x03);
663723
r8929r8930
701761   pit8253_gate1_w(pit8253, 1);
702762}
703763
764static UINT8 joy_mode;
765
766static READ8_HANDLER( mz2500_joystick_r )
767{
768   static UINT8 res,dir_en,in_r;
769
770   res = 0xff;
771   in_r = ~input_port_read(space->machine,"JOY");
772
773   if(joy_mode & 0x40)
774   {
775      if(!(joy_mode & 0x04)) res &= ~0x20;
776      if(!(joy_mode & 0x08)) res &= ~0x10;
777      dir_en = (joy_mode & 0x20) ? 0 : 1;
778   }
779   else
780   {
781      if(!(joy_mode & 0x01)) res &= ~0x20;
782      if(!(joy_mode & 0x02)) res &= ~0x10;
783      dir_en = (joy_mode & 0x10) ? 0 : 1;
784   }
785
786   if(dir_en)
787      res &= (~((in_r) & 0x0f));
788
789   res &= (~((in_r) & 0x30));
790
791   return res;
792}
793
794static WRITE8_HANDLER( mz2500_joystick_w )
795{
796   joy_mode = data;
797}
798
704799static ADDRESS_MAP_START(mz2500_io, ADDRESS_SPACE_IO, 8)
705800   ADDRESS_MAP_GLOBAL_MASK(0xff)
706801//  AM_RANGE(0x60, 0x63) AM_WRITE(w3100a_w)
r8929r8930
732827    AM_RANGE(0xe4, 0xe7) AM_DEVREADWRITE("pit", pit8253_r, pit8253_w)
733828   AM_RANGE(0xe8, 0xe9) AM_DEVREADWRITE("z80pio_1", z80pio_c_r, z80pio_c_w)
734829   AM_RANGE(0xea, 0xeb) AM_DEVREADWRITE("z80pio_1", z80pio_d_r, z80pio_d_w)
735//  AM_RANGE(0xef, 0xef) AM_READWRITE(joystick_r,joystick_w)
830   AM_RANGE(0xef, 0xef) AM_READWRITE(mz2500_joystick_r,mz2500_joystick_w)
736831    AM_RANGE(0xf0, 0xf3) AM_WRITE(timer_w)
737832   AM_RANGE(0xf4, 0xf7) AM_READ(mz2500_crtc_hvblank_r) AM_WRITE(mz2500_tv_crtc_w)
738833//  AM_RANGE(0xf8, 0xf9) AM_READWRITE(extrom_r,extrom_w)
r8929r8930
10781173   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
10791174   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
10801175   PORT_DIPSETTING(    0x80, DEF_STR( On ) )
1176
1177   PORT_START("JOY")
1178   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY
1179   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY
1180   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY
1181   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY
1182   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
1183   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
1184   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED )
1185   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
10811186INPUT_PORTS_END
10821187
10831188static void mz2500_reset(UINT8 type)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team