Previous 199869 Revisions Next

r20333 Saturday 19th January, 2013 at 05:14:37 UTC by David Haywood
vboy - optimize a bit, eg bound high ingame (nw)
[src/mess/drivers]vboy.c

trunk/src/mess/drivers/vboy.c
r20332r20333
184184   DECLARE_WRITE32_MEMBER(sram_w);
185185
186186   void put_obj(bitmap_ind16 &bitmap, const rectangle &cliprect, int x, int y, UINT16 code, bool flipx, bool flipy, UINT8 pal);
187   void put_char(int x, int y, UINT16 code, bool flipx, bool flipy, UINT8 pal);
188187   void fill_ovr_char(UINT16 code, bool flipx, bool flipy, UINT8 pal);
189   void fill_bg_map(int num, UINT16 scx, UINT16 scy);
188   INT8 get_bg_map_pixel(int num, int xpos, int ypos);
190189   void draw_bg_map(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT16 param_base, int mode, int gx, int gp, int gy, int mx, int mp, int my,int h, int w,
191                                 UINT16 x_mask, UINT16 y_mask, UINT8 ovr, bool right);
190                                 UINT16 x_mask, UINT16 y_mask, UINT8 ovr, bool right, int bg_map_num);
192191   void draw_affine_map(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT16 param_base, int gx, int gp, int gy, int h, int w,
193                                    UINT16 x_mask, UINT16 y_mask, UINT8 ovr, bool right);
192                                    UINT16 x_mask, UINT16 y_mask, UINT8 ovr, bool right, int bg_map_num);
194193   UINT8 display_world(int num, bitmap_ind16 &bitmap, const rectangle &cliprect, bool right, int &cur_spt);
195194   void m_set_brightness(void);
196195   virtual void machine_start();
r20332r20333
259258   }
260259}
261260
262void vboy_state::put_char(int x, int y, UINT16 code, bool flipx, bool flipy, UINT8 pal)
263{
264   UINT16 data;
265   UINT8 yi, xi, dat;
266   int col;
267261
268   for (yi = 0; yi < 8; yi++)
269   {
270      if (!flipy)
271            data = READ_FONT(code * 8 + yi);
272      else
273            data = READ_FONT(code * 8 + (7-yi));
274262
275      for (xi = 0; xi < 8; xi++)
276      {
277         int res_x,res_y;
278
279         if (!flipx)
280            dat = ((data >> (xi << 1)) & 0x03);
281         else
282            dat = ((data >> ((7-xi) << 1)) & 0x03);
283
284         res_x = x + xi;
285         res_y = y + yi;
286
287         col = (pal >> (dat*2)) & 3;
288
289         if(dat == 0)
290            col = -1;
291
292         WRITE_BG_TEMPDRAW_MAP(res_y*0x1000+res_x, col);
293      }
294   }
295}
296
297263void vboy_state::fill_ovr_char(UINT16 code, bool flipx, bool flipy, UINT8 pal)
298264{
299265   UINT16 data;
r20332r20333
324290   }
325291}
326292
327void vboy_state::fill_bg_map(int num, UINT16 scx, UINT16 scy)
293INT8 vboy_state::get_bg_map_pixel(int num, int xpos, int ypos)
328294{
329295   int x, y;
330296   UINT8 stepx, stepy;
331297
298   y = ypos >>3;
299   x = xpos >>3;
300
332301   // Fill background map
333   for (y = 0; y < scy; y++)
302//   for (y = 0; y < scy; y++)
334303   {
335      for (x = 0; x < scx; x++)
304//      for (x = 0; x < scx; x++)
336305      {
337306         stepx = (x & 0x1c0) >> 6;
338307         stepy = ((y & 0x1c0) >> 6) * (stepx+1);
339308         UINT16 val = READ_BGMAP((x & 0x3f) + (64 * (y & 0x3f)) + ((num + stepx + stepy) * 0x1000));
340         put_char(x * 8, y * 8, val & 0x7ff, BIT(val,13), BIT(val,12), m_vip_regs.GPLT[(val >> 14) & 3]);
309         int flipx = BIT(val,13);
310         int flipy = BIT(val,12);
311         int pal = m_vip_regs.GPLT[(val >> 14) & 3];
312         int code = val & 0x7ff;
313
314         //put_char(x * 8, y * 8, , , , );
315         {
316            UINT16 data;
317            UINT8 yi, xi, dat;
318            int col;
319
320         //   for (yi = 0; yi < 8; yi++)
321            yi = ypos & 7;
322
323            {
324               if (!flipy)
325                     data = READ_FONT(code * 8 + yi);
326               else
327                     data = READ_FONT(code * 8 + (7-yi));
328
329               //for (xi = 0; xi < 8; xi++)
330               xi = xpos & 7;
331               {
332                  //int res_x,res_y;
333
334                  if (!flipx)
335                     dat = ((data >> (xi << 1)) & 0x03);
336                  else
337                     dat = ((data >> ((7-xi) << 1)) & 0x03);
338
339                  //res_x = x + xi;
340                  //res_y = y + yi;
341
342                  col = (pal >> (dat*2)) & 3;
343
344                  if(dat == 0)
345                     col = -1;
346
347                  return col;
348                  //WRITE_BG_TEMPDRAW_MAP(res_y*0x1000+res_x, col);
349               }
350            }
351         }
352
341353      }
342354   }
343355}
344356
345357void vboy_state::draw_bg_map(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT16 param_base, int mode, int gx, int gp, int gy, int mx, int mp, int my, int h, int w,
346                                       UINT16 x_mask, UINT16 y_mask, UINT8 ovr, bool right)
358                                       UINT16 x_mask, UINT16 y_mask, UINT8 ovr, bool right, int bg_map_num)
347359{
348360   int x,y;
349361
r20332r20333
371383         }
372384         else
373385         {
374            pix = READ_BG_TEMPDRAW_MAP((src_y & y_mask)*0x1000+(src_x & x_mask));
386            pix = get_bg_map_pixel(bg_map_num, src_x & x_mask, src_y & y_mask);
375387         }
376388
377389         if(pix != -1)
r20332r20333
382394}
383395
384396void vboy_state::draw_affine_map(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT16 param_base, int gx, int gp, int gy, int h, int w,
385                                          UINT16 x_mask, UINT16 y_mask, UINT8 ovr, bool right)
397                                          UINT16 x_mask, UINT16 y_mask, UINT8 ovr, bool right, int bg_map_num)
386398{
387399   int x,y;
388400
r20332r20333
414426         }
415427         else
416428         {
417            pix = READ_BG_TEMPDRAW_MAP((src_y & y_mask)*0x1000+(src_x & x_mask));
429            pix = get_bg_map_pixel(bg_map_num, src_x & x_mask, src_y & y_mask);
418430         }
419431
420432         if(pix != -1)
r20332r20333
470482
471483      if (lon && (!right))
472484      {
473         fill_bg_map(bg_map_num, scx, scy);
474         draw_bg_map(bitmap, cliprect, param_base, mode, gx, gp, gy, mx, mp, my, h,w, scx*8-1, scy*8-1, ovr, right);
485         //fill_bg_map(bg_map_num, scx, scy);
486         draw_bg_map(bitmap, cliprect, param_base, mode, gx, gp, gy, mx, mp, my, h,w, scx*8-1, scy*8-1, ovr, right, bg_map_num);
475487      }
476488
477489      if (ron && (right))
478490      {
479         fill_bg_map(bg_map_num, scx, scy);
480         draw_bg_map(bitmap, cliprect, param_base, mode, gx, gp, gy, mx, mp, my, h,w, scx*8-1, scy*8-1, ovr, right);
491         //fill_bg_map(bg_map_num, scx, scy);
492         draw_bg_map(bitmap, cliprect, param_base, mode, gx, gp, gy, mx, mp, my, h,w, scx*8-1, scy*8-1, ovr, right, bg_map_num);
481493      }
482494   }
483495   else if (mode==2) // Affine Mode
r20332r20333
487499
488500      if (lon && (!right))
489501      {
490         fill_bg_map(bg_map_num, scx, scy);
491         draw_affine_map(bitmap, cliprect, param_base, gx, gp, gy, h,w, scx*8-1, scy*8-1, ovr, right);
502         //fill_bg_map(bg_map_num, scx, scy);
503         draw_affine_map(bitmap, cliprect, param_base, gx, gp, gy, h,w, scx*8-1, scy*8-1, ovr, right, bg_map_num);
492504      }
493505
494506      if (ron && (right))
495507      {
496         fill_bg_map(bg_map_num, scx, scy);
497         draw_affine_map(bitmap, cliprect, param_base, gx, gp, gy, h,w, scx*8-1, scy*8-1, ovr, right);
508         //fill_bg_map(bg_map_num, scx, scy);
509         draw_affine_map(bitmap, cliprect, param_base, gx, gp, gy, h,w, scx*8-1, scy*8-1, ovr, right, bg_map_num);
498510      }
499511   }
500512   else if (mode==3) // OBJ Mode

Previous 199869 Revisions Next


© 1997-2024 The MAME Team