Implement I_ReadScreenTransposed

This commit is contained in:
Lactozilla 2023-11-28 15:28:50 -03:00
parent fd1ee9002d
commit b048f6b6ff
6 changed files with 41 additions and 4 deletions

View file

@ -87,6 +87,11 @@ void I_ReadScreen(UINT8 *scr)
(void)scr;
}
void I_ReadScreenTransposed(UINT8 *scr)
{
(void)scr;
}
void I_BeginRead(void){}
void I_EndRead(void){}

View file

@ -75,6 +75,11 @@ void I_ReadScreen(UINT8 *scr)
(void)scr;
}
void I_ReadScreenTransposed(UINT8 *scr)
{
(void)scr;
}
void I_BeginRead(void){}
void I_EndRead(void){}

View file

@ -143,6 +143,14 @@ void I_WaitVBL(INT32 count);
*/
void I_ReadScreen(UINT8 *scr);
/** \brief The I_ReadScreenTransposed function
\param scr buffer to copy screen to
\return void
*/
void I_ReadScreenTransposed(UINT8 *scr);
/** \brief Start disk icon
*/
void I_BeginRead(void);

View file

@ -565,7 +565,7 @@ static void GIF_framewrite(void)
// blit to temp screen
if (rendermode == render_soft)
I_ReadScreen(movie_screen);
I_ReadScreenTransposed(movie_screen);
#ifdef HWRENDER
else if (rendermode == render_opengl)
{
@ -594,7 +594,7 @@ static void GIF_framewrite(void)
// Copy the first frame into the movie screen
// OpenGL already does the same above.
if (gif_frames == 0 && rendermode == render_soft)
I_ReadScreen(movie_screen);
I_ReadScreenTransposed(movie_screen);
movie_screen = screens[0];
}

View file

@ -1280,7 +1280,7 @@ void M_SaveFrame(void)
{
// munge planar buffer to linear
linear = screens[2];
I_ReadScreen(linear);
I_ReadScreenTransposed(linear);
}
#ifdef HWRENDER
else
@ -1590,7 +1590,7 @@ void M_DoScreenShot(void)
{
// munge planar buffer to linear
linear = screens[2];
I_ReadScreen(linear);
I_ReadScreenTransposed(linear);
}
if (!freename)

View file

@ -1306,6 +1306,25 @@ void I_ReadScreen(UINT8 *scr)
vid.rowbytes, vid.rowbytes);
}
//
// I_ReadScreenTransposed
// The screen buffers in SRB2 are transposed, meaning they are ordered by columns instead of rows.
// This function copies the buffer transposed so that it's arranged by rows, for things that expect the buffer to be that way.
//
void I_ReadScreenTransposed(UINT8 *scr)
{
if (rendermode != render_soft)
I_Error("I_ReadScreenTransposed: called while in non-software mode");
UINT8 *buffer = screens[0];
size_t dest_rowbytes = vid.width * vid.bpp;
for (int y = 0; y < vid.height; y++)
for (int x = 0; x < vid.width; x++)
scr[(y * dest_rowbytes) + x] = buffer[(x * vid.rowbytes) + y];
}
//
// I_SetPalette
//