Previous 15994 Revisions Next

r8699 Tuesday 3rd August, 2010 at 21:12:01 UTC by Angelo Salese
[PC-6001]: cleaned up video emulation a little, splitted pc6001 and pc6001m2 video emulations, made text colors more accurate for the former
[src/mess/drivers]pc6001.c

src/mess/drivers/pc6001.c
r8698r8699
126126   pc6001_video_ram = auto_alloc_array(machine, UINT8, 0x2000); //0x400? We'll see...
127127}
128128
129static VIDEO_UPDATE( pc6001 )
129static void draw_bitmap_1bpp(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,int attr)
130130{
131   UINT8 *gfx_data = memory_region(screen->machine, "gfx1");
132   int x,y,xi,yi;
133   int tile,attr,pen,color;
134   int fgcol;
131   int x,y,xi;
132   int fgcol,color;
135133
136   attr = pc6001_video_ram[0];
134   fgcol = (attr & 2) ? 7 : 2;
137135
138   if(attr & 0x80) // gfx mode
136   for(y=0;y<192;y++)
139137   {
140      if(attr & 0x10) // 256x192x1 mode (FIXME: might be a different trigger)
138      for(x=0;x<32;x++)
141139      {
142         fgcol = (attr & 2) ? 7 : 2;
140         int tile = pc6001_video_ram[(x+(y*32))+0x200];
143141
144         for(y=0;y<192;y++)
142         for(xi=0;xi<8;xi++)
145143         {
146            for(x=0;x<32;x++)
144            color = ((tile)>>(7-xi) & 1) ? fgcol : 0;
145
146            *BITMAP_ADDR16(bitmap, (y+24), (x*8+xi)+32) = machine->pens[color];
147         }
148      }
149   }
150}
151
152static void draw_bitmap_2bpp(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect, int attr)
153{
154   int color,x,y,xi,yi;
155
156   int shrink_x = 2*4;
157   int shrink_y = (attr & 8) ? 1 : 2;
158   int w = (shrink_x == 8) ? 32 : 16;
159   int col_bank = ((attr & 2)<<1);
160
161   for(y=0;y<(192/shrink_y);y++)
162   {
163      for(x=0;x<w;x++)
164      {
165         int tile = pc6001_video_ram[(x+(y*32))+0x200];
166
167         for(yi=0;yi<shrink_y;yi++)
168         {
169            for(xi=0;xi<shrink_x;xi++)
147170            {
148               tile = pc6001_video_ram[(x+(y*32))+0x200];
171               int i;
172               i = (shrink_x == 8) ? (xi & 0x06) : (xi & 0x0c)>>1;
173               color = ((tile >> i) & 3)+8;
174               color+= col_bank;
149175
150               for(xi=0;xi<8;xi++)
151               {
152                  color = ((tile)>>(7-xi) & 1) ? fgcol : 0;
153
154                  *BITMAP_ADDR16(bitmap, (y+24), (x*8+xi)+32) = screen->machine->pens[color];
155               }
176               *BITMAP_ADDR16(bitmap, ((y*shrink_y+yi)+24), (x*shrink_x+((shrink_x-1)-xi))+32) = machine->pens[color];
156177            }
157178         }
158179      }
159      else // 128x192x2 mode
180   }
181}
182
183static void draw_tile_3bpp(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,int x,int y,int tile,int attr)
184{
185   int color,pen,xi,yi;
186
187   if(attr & 0x10) //2x2 squares on a single cell
188      pen = (tile & 0x70)>>4;
189   else //2x3
190      pen = (tile & 0xc0) >> 6 | (attr & 2)<<1;
191
192   for(yi=0;yi<12;yi++)
193   {
194      for(xi=0;xi<8;xi++)
160195      {
161         int shrink_x = 2*4;
162         int shrink_y = (attr & 8) ? 1 : 2;
163         int w = (shrink_x == 8) ? 32 : 16;
164         int col_bank = ((attr & 2)<<1);
196         int i;
197         i = (xi & 4)>>2; //x-axis
198         if(attr & 0x10) //2x2
199         {
200            i+= (yi >= 6) ? 2 : 0; //y-axis
201         }
202         else //2x3
203         {
204            i+= (yi & 4)>>1; //y-axis 1
205            i+= (yi & 8)>>1; //y-axis 2
206         }
165207
166         for(y=0;y<(192/shrink_y);y++)
208         color = ((tile >> i) & 1) ? pen+8 : 0;
209
210         *BITMAP_ADDR16(bitmap, ((y*12+(11-yi))+24), (x*8+(7-xi))+32) = machine->pens[color];
211      }
212   }
213}
214
215static void draw_tile_text(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,int x,int y,int tile,int attr,int has_mc6847)
216{
217   int xi,yi,pen,fgcol,color;
218   UINT8 *gfx_data = memory_region(machine, "gfx1");
219
220   for(yi=0;yi<12;yi++)
221   {
222      for(xi=0;xi<8;xi++)
223      {
224         pen = gfx_data[(tile*0x10)+yi]>>(7-xi) & 1;
225
226         if(has_mc6847)
167227         {
168            for(x=0;x<w;x++)
169            {
170               tile = pc6001_video_ram[(x+(y*32))+0x200];
228            fgcol = (attr & 2) ? 0x12 : 0x10;
171229
172               for(yi=0;yi<shrink_y;yi++)
173               {
174                  for(xi=0;xi<shrink_x;xi++)
175                  {
176                     int i;
177                     i = (shrink_x == 8) ? (xi & 0x06) : (xi & 0x0c)>>1;
178                     color = ((tile >> i) & 3)+8;
179                     color+= col_bank;
230            if(attr & 1)
231               color = pen ? (fgcol+0) : (fgcol+1);
232            else
233               color = pen ? (fgcol+1) : (fgcol+0);
180234
181                     *BITMAP_ADDR16(bitmap, ((y*shrink_y+yi)+24), (x*shrink_x+((shrink_x-1)-xi))+32) = screen->machine->pens[color];
182                  }
183               }
184            }
185235         }
236         else
237         {
238            fgcol = (attr & 2) ? 2 : 7;
239
240            if(attr & 1)
241               color = pen ? 0 : fgcol;
242            else
243               color = pen ? fgcol : 0;
244         }
245
246         *BITMAP_ADDR16(bitmap, ((y*12+yi)+24), (x*8+xi)+32) = machine->pens[color];
186247      }
187248   }
249}
250
251static void pc6001_screen_draw(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect, int has_mc6847)
252{
253   int x,y;
254   int tile,attr;
255
256   attr = pc6001_video_ram[0];
257
258   if(attr & 0x80) // gfx mode
259   {
260      if(attr & 0x10) // 256x192x1 mode (FIXME: might be a different trigger)
261      {
262         draw_bitmap_1bpp(machine,bitmap,cliprect,attr);
263      }
264      else // 128x192x2 mode
265      {
266         draw_bitmap_2bpp(machine,bitmap,cliprect,attr);
267      }
268   }
188269   else // text mode
189270   {
190271      for(y=0;y<16;y++)
r8698r8699
196277
197278            if(attr & 0x40)
198279            {
199               if(attr & 0x10) //2x2 squares on a single cell
200                  pen = (tile & 0x70)>>4;
201               else //2x3
202                  pen = (tile & 0xc0) >> 6 | (attr & 2)<<1;
203
204               for(yi=0;yi<12;yi++)
205               {
206                  for(xi=0;xi<8;xi++)
207                  {
208                     int i;
209                     i = (xi & 4)>>2; //x-axis
210                     if(attr & 0x10) //2x2
211                     {
212                        i+= (yi >= 6) ? 2 : 0; //y-axis
213                     }
214                     else //2x3
215                     {
216                        i+= (yi & 4)>>1; //y-axis 1
217                        i+= (yi & 8)>>1; //y-axis 2
218                     }
219
220                     color = ((tile >> i) & 1) ? pen+8 : 0;
221
222                     *BITMAP_ADDR16(bitmap, ((y*12+(11-yi))+24), (x*8+(7-xi))+32) = screen->machine->pens[color];
223                  }
224               }
280               draw_tile_3bpp(machine,bitmap,cliprect,x,y,tile,attr);
225281            }
226282            else
227283            {
228               for(yi=0;yi<12;yi++)
229               {
230                  for(xi=0;xi<8;xi++)
231                  {
232                     pen = gfx_data[(tile*0x10)+yi]>>(7-xi) & 1;
233
234                     fgcol = (attr & 2) ? 2 : 7;
235
236                     if(attr & 1)
237                        color = pen ? 0 : fgcol;
238                     else
239                        color = pen ? fgcol : 0;
240
241                     *BITMAP_ADDR16(bitmap, ((y*12+yi)+24), (x*8+xi)+32) = screen->machine->pens[color];
242                  }
243               }
284               draw_tile_text(machine,bitmap,cliprect,x,y,tile,attr,has_mc6847);
244285            }
245286         }
246287      }
247288   }
289}
248290
291static VIDEO_UPDATE( pc6001 )
292{
293   pc6001_screen_draw(screen->machine,bitmap,cliprect,1);
294
249295   return 0;
250296}
251297
298static VIDEO_UPDATE( pc6001m2 )
299{
300   pc6001_screen_draw(screen->machine,bitmap,cliprect,0);
301
302   return 0;
303}
304
252305static WRITE8_HANDLER ( pc6001_system_latch_w )
253306{
254307   UINT16 startaddr[] = {0xC000, 0xE000, 0x8000, 0xA000 };
r8698r8699
353406
354407static ADDRESS_MAP_START(pc6001_map, ADDRESS_SPACE_PROGRAM, 8)
355408   ADDRESS_MAP_UNMAP_HIGH
356   AM_RANGE(0x0000, 0x3fff) AM_ROM
409   AM_RANGE(0x0000, 0x3fff) AM_ROM AM_WRITENOP
357410   AM_RANGE(0x4000, 0x5fff) AM_ROM AM_REGION("cart_img",0)
358411   AM_RANGE(0x6000, 0x7fff) AM_ROMBANK("bank1")
359412   AM_RANGE(0x8000, 0xffff) AM_RAM AM_BASE(&pc6001_ram)
r8698r8699
667720
668721static WRITE8_DEVICE_HANDLER (pc6001_8255_portb_w )
669722{
670//  printf("pc6001_8255_portb_w %02x\n",data);
723   //printf("pc6001_8255_portb_w %02x\n",data);
671724}
672725
673726static WRITE8_DEVICE_HANDLER (pc6001_8255_portc_w )
674727{
675//  printf("pc6001_8255_portc_w %02x\n",data);
728   //printf("pc6001_8255_portc_w %02x\n",data);
676729}
677730
678731static READ8_DEVICE_HANDLER (pc6001_8255_portc_r )
r8698r8699
866919   MAKE_RGB(0xff, 0xff, 0xff),   /* BUFF */
867920   MAKE_RGB(0x00, 0xff, 0xff),   /* CYAN */
868921   MAKE_RGB(0xff, 0x00, 0xff),   /* MAGENTA */
869   MAKE_RGB(0xff, 0x80, 0x00)   /* ORANGE */
922   MAKE_RGB(0xff, 0x80, 0x00),   /* ORANGE */
923
924   /* MC6847 specific */
925   MAKE_RGB(0x00, 0x40, 0x00),   /* ALPHANUMERIC DARK GREEN */
926   MAKE_RGB(0x00, 0xff, 0x00),   /* ALPHANUMERIC BRIGHT GREEN */
927   MAKE_RGB(0x40, 0x10, 0x00),   /* ALPHANUMERIC DARK ORANGE */
928   MAKE_RGB(0xff, 0xc4, 0x18)   /* ALPHANUMERIC BRIGHT ORANGE */
929
870930};
871931
872932static PALETTE_INIT(pc6001)
873933{
874934   int i;
875935
876   for(i=0;i<8;i++)
936   for(i=0;i<8+4;i++)
877937      palette_set_color(machine, i+8,defcolors[i]);
878938}
879939
r8698r8699
923983//  MDRV_VIDEO_UPDATE(m6847)
924984//  MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
925985   MDRV_SCREEN_SIZE(320, 25+192+26)
926   MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239)
927   MDRV_PALETTE_LENGTH(16)
986   MDRV_SCREEN_VISIBLE_AREA(0, 319, 0, 239)
987   MDRV_PALETTE_LENGTH(16+4)
928988   MDRV_PALETTE_INIT(pc6001)
929989
930990   MDRV_I8255A_ADD( "ppi8255", pc6001_ppi8255_interface )
r8698r8699
9551015
9561016   MDRV_MACHINE_RESET(pc6001m2)
9571017
1018   MDRV_VIDEO_UPDATE(pc6001m2)
1019
9581020   /* basic machine hardware */
9591021   MDRV_CPU_MODIFY("maincpu")
9601022   MDRV_CPU_PROGRAM_MAP(pc6001m2_map)
r8698r8699
9641026static MACHINE_DRIVER_START( pc6001sr )
9651027   MDRV_IMPORT_FROM(pc6001)
9661028
1029   MDRV_VIDEO_UPDATE(pc6001m2)
1030
9671031   /* basic machine hardware */
9681032   MDRV_CPU_REPLACE("maincpu", Z80, XTAL_3_579545MHz)
9691033   MDRV_CPU_PROGRAM_MAP(pc6001m2_map)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team