Created
January 7, 2017 17:22
-
-
Save seth10/ab66994cee36a8ee1b68a58a7e542f92 to your computer and use it in GitHub Desktop.
A different idea for helper drawing method in GBA graphics mode 4 that won't work
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void drawPixel_mode4(int x, int y, u8 color) | |
{ | |
u16 *here = (REG_DISPCNT & BACKBUFFER ? VideoBuffer : BackBuffer) + x%(SCREEN_WIDTH/2) + y*(SCREEN_WIDTH/2); | |
*here = color + (*here & 0xFF00); | |
} | |
void drawRect_mode4(int x, int y, int w, int h, u8 c) | |
{ | |
u16 *currentBackBuffer = REG_DISPCNT & BACKBUFFER ? VideoBuffer : BackBuffer; | |
int ix, iy; | |
for (ix = x/2; ix < (x+w)/2; ix++) | |
for (iy = y; iy < y+h; iy++) | |
(currentBackBuffer)[ ix%(SCREEN_WIDTH/2) + iy*(SCREEN_WIDTH/2) ] = c + (c<<8); | |
if ((x+w)%2 == 1) // odd width, draw last single-pixel line (ix < (x+w)/2 in the previous loop truncated) | |
for (iy = y; iy < y+h; iy++) | |
drawPixel_mode4(x+w+1, iy, c); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment