Previous 199869 Revisions Next

r17775 Monday 10th September, 2012 at 07:07:21 UTC by Aaron Giles
Slightly less abusive gfx_element hacking in atarimo, fixing
memory corruptions.
[src/mame/video]atarimo.c

trunk/src/mame/video/atarimo.c
r17774r17775
3434   running_machine &machine() const { return m_machine; }
3535
3636   UINT32            gfxchanged;         /* true if the gfx info has changed */
37   gfx_element *      gfxelement[MAX_GFX_ELEMENTS]; /* local copy of graphics elements */
3837   int               gfxgranularity[MAX_GFX_ELEMENTS];
3938
4039   bitmap_ind16         *bitmap;         /* temporary bitmap to render to */
r17774r17775
235234
236235INLINE void init_gfxelement(atarimo_data *mo, int idx)
237236{
238   mo->gfxelement[idx] = auto_alloc(mo->machine(), gfx_element(mo->machine()));
239   memcpy(mo->gfxelement[idx], mo->machine().gfx[idx], sizeof(*mo->gfxelement[idx]));
240   mo->gfxgranularity[idx] = mo->gfxelement[idx]->granularity();
241   mo->gfxelement[idx]->set_granularity(1);
242   mo->gfxelement[idx]->set_colorbase(0);
243   mo->gfxelement[idx]->set_colors(65536);
237   mo->gfxgranularity[idx] = mo->machine().gfx[idx]->granularity();
244238}
245239
246240
r17774r17775
742736static int mo_render_object(atarimo_data *mo, const atarimo_entry *entry, const rectangle &cliprect)
743737{
744738   int gfxindex = mo->gfxlookup[EXTRACT_DATA(entry, mo->gfxmask)];
745   gfx_element *gfx = mo->gfxelement[gfxindex];
739   gfx_element *gfx = mo->machine().gfx[gfxindex];
746740   bitmap_ind16 &bitmap = *mo->bitmap;
747741   int x, y, sx, sy;
748742
743int save_granularity = gfx->granularity();
744int save_colorbase = gfx->colorbase();
745int save_colors = gfx->colors();
746gfx->set_granularity(1);
747gfx->set_colorbase(0);
748gfx->set_colors(65536);
749
749750   /* extract data from the various words */
750751   int code = mo->codelookup[EXTRACT_DATA(entry, mo->codemask)] | (EXTRACT_DATA(entry, mo->codehighmask) << mo->codehighshift);
751752   int color = mo->colorlookup[EXTRACT_DATA(entry, mo->colormask)];
r17774r17775
810811   /* is this one special? */
811812   if (mo->specialmask.mask != 0 && EXTRACT_DATA(entry, mo->specialmask) == mo->specialvalue)
812813   {
814      int result = 0;
813815      if (mo->specialcb)
814         return (*mo->specialcb)(bitmap, cliprect, code, color, xpos, ypos, NULL);
815      return 0;
816         result = (*mo->specialcb)(bitmap, cliprect, code, color, xpos, ypos, NULL);
817
818gfx->set_granularity(save_granularity);
819gfx->set_colorbase(save_colorbase);
820gfx->set_colors(save_colors);
821
822      return result;
816823   }
817824
818825   /* adjust for h flip */
r17774r17775
904911      }
905912   }
906913
914gfx->set_granularity(save_granularity);
915gfx->set_colorbase(save_colorbase);
916gfx->set_colors(save_colors);
917
907918   return rendered;
908919}
909920

Previous 199869 Revisions Next


© 1997-2024 The MAME Team