// Function name: UpdateLCD
// Variables: None
// Purpose: Update the Gameboy LCD screen.
int UpdateScreen()
{
int i;
int j;
SDL_Rect plotRectangle;
for (j = 0; j < 144; j++)
{
for (i = 0; i < 160; i++)
{
plotRectangle.x = i * 3;
plotRectangle.y = j * 3;
plotRectangle.w = 3;
plotRectangle.h = 3;
switch(screenData[(j * 160) + i])
{
case 0:
{
SDL_FillRect(screen, &plotRectangle, color_white);
}
break;
case 1:
{
SDL_FillRect(screen, &plotRectangle, color_light_grey);
}
break;
case 2:
{
SDL_FillRect(screen, &plotRectangle, color_dark_grey);
}
break;
case 3:
{
SDL_FillRect(screen, &plotRectangle, color_black);
}
break;
}
}
}
SDL_Flip(screen);
return 0;
}