Skip to content

Commit

Permalink
screen draw optimalization
Browse files Browse the repository at this point in the history
  • Loading branch information
turican0 committed Apr 15, 2021
1 parent 0084a7c commit 0ec155c
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions remc2/portability/port_sdl_vga_mouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ void VGA_Blit(int /*width*/, int /*height*/, Uint8* srcBuffer) {
{
memcpy(screen->pixels, srcBuffer, screen->h * screen->w);
}
else if ((m_iOrigw * 2 == screen->w) && (m_iOrigh * 2 == screen->h)) //2x resolution
/*else if ((m_iOrigw * 2 == screen->w) && (m_iOrigh * 2 == screen->h)) //2x resolution
{
int k = 0;
int l = 0;
Expand All @@ -841,20 +841,29 @@ void VGA_Blit(int /*width*/, int /*height*/, Uint8* srcBuffer) {
k += i % 2;
l = 0;
}
}
}*/
else//any resolution
{
int k = 0;
int l = 0;
//int l = 0;
float xscale = (float)m_iOrigw / (float)screen->w;
float yscale = (float)m_iOrigh / (float)screen->h;

int tempyj[10000];
int tempyl[10000];
for (int j = 0; j < screen->h; j++)//49+1 - final size
{
//l = (int)(j * yscale);
tempyj[j]=j* screen->w;
tempyl[j]=((int)(j * yscale))* m_iOrigw;
}

for (int i = 0; i < screen->w; i++)
{
k = (int)(i * xscale);
for (int j = 0; j < screen->h; j++)//49+1 - final size
{
l = (int)(j * yscale);
((uint8_t*)screen->pixels)[i + j * screen->w] = srcBuffer[k + l * m_iOrigw];
((uint8_t*)screen->pixels)[i + tempyj[j]] = srcBuffer[k + tempyl[j]];
}
}
}
Expand Down

0 comments on commit 0ec155c

Please sign in to comment.