CopySprite

From WikiPrizm
Revision as of 23:51, 12 January 2013 by KermMartian (talk | contribs) (Created page with "== Synopsis == Copy a 16-bit sprite/image to the VRAM buffer. === Definition === <nowiki>void CopySprite(color_t* sprite, int x, int y, int width, int height) { color_t* ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Synopsis

Copy a 16-bit sprite/image to the VRAM buffer.

Definition

void CopySprite(color_t* sprite, int x, int y, int width, int height) {
   color_t* VRAM = (color_t*)GetVRAMAddress();
   VRAM += LCD_WIDTH_PX*y + x;
   for(int j=y; j<y+height; j++) {
      for(int i=x; i<x+width; i++) {
         *(VRAM++) = *(sprite++);
      }
      VRAM += LCD_WIDTH_PX-width;
   }
} 

Inputs

  • color_t* sprite: The sprite data (from SourceCoder?)
  • int x: X-coordinate of top-left of sprite
  • int y: Y-coordinate of top-left of sprite
  • int width: Width of sprite, in pixels
  • int height: Height of sprite, in pixels

Outputs

Sprite drawn to VRAM

Comments

SourceCoder can be used to convert .png, .bmp, and .gif images to arrays that you can use with this routine.