Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rotate n relocate #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions doomgeneric/doomgeneric.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "doomgeneric.h"

uint32_t* DG_ScreenBuffer = 0;
uint32_t* DG_ScreenBuffer = NULL;

void M_FindResponseFile(void);
void D_DoomMain (void);
Expand All @@ -18,10 +18,13 @@ void doomgeneric_Create(int argc, char **argv)

M_FindResponseFile();

DG_ScreenBuffer = malloc(DOOMGENERIC_RESX * DOOMGENERIC_RESY * 4);

DG_Init();

if(NULL == DG_ScreenBuffer)
{
DG_ScreenBuffer = malloc(DOOMGENERIC_RESX * DOOMGENERIC_RESY * 4);
}

D_DoomMain ();
}

38 changes: 35 additions & 3 deletions doomgeneric/i_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ rcsid[] = "$Id: i_x.c,v 1.6 1997/02/03 22:45:10 b1 Exp $";
#include <sys/types.h>

//#define CMAP256
//#define ROTATE_SCREENBUFFER // Needs testing at resolution > 320 * 200

struct FB_BitField
{
Expand All @@ -74,6 +75,7 @@ struct FB_ScreenInfo
static struct FB_ScreenInfo s_Fb;
int fb_scaling = 1;
int usemouse = 0;
static int free_videoBuffer = 0;

struct color {
uint32_t b:8;
Expand Down Expand Up @@ -126,6 +128,8 @@ typedef struct

static uint16_t rgb565_palette[256];

byte videoBufferLineOut[DOOMGENERIC_RESX * sizeof(uint32_t)];

void cmap_to_rgb565(uint16_t * out, uint8_t * in, int in_pixels)
{
int i, j;
Expand Down Expand Up @@ -219,7 +223,11 @@ void I_InitGraphics (void)


/* Allocate screen to draw to */
I_VideoBuffer = (byte*)Z_Malloc (SCREENWIDTH * SCREENHEIGHT, PU_STATIC, NULL); // For DOOM to draw on
if (NULL == I_VideoBuffer)
{
I_VideoBuffer = (byte*)Z_Malloc (SCREENWIDTH * SCREENHEIGHT, PU_STATIC, NULL); // For DOOM to draw on
free_videoBuffer = 1;
}

screenvisible = true;

Expand All @@ -229,7 +237,10 @@ void I_InitGraphics (void)

void I_ShutdownGraphics (void)
{
Z_Free (I_VideoBuffer);
if(free_videoBuffer)
{
Z_Free (I_VideoBuffer);
}
}

void I_StartFrame (void)
Expand Down Expand Up @@ -267,7 +278,11 @@ void I_FinishUpdate (void)

/* DRAW SCREEN */
line_in = (unsigned char *) I_VideoBuffer;
#ifndef ROTATE_SCREENBUFFER
line_out = (unsigned char *) DG_ScreenBuffer;
#else
line_out = (unsigned char *) &videoBufferLineOut[0];
#endif

y = SCREENHEIGHT;

Expand All @@ -276,6 +291,8 @@ void I_FinishUpdate (void)
int i;
for (i = 0; i < fb_scaling; i++) {
line_out += x_offset;

#ifndef ROTATE_SCREENBUFFER
#ifdef CMAP256
for (fb_scaling == 1) {
memcpy(line_out, line_in, SCREENWIDTH); /* fb_width is bigger than Doom SCREENWIDTH... */
Expand All @@ -285,9 +302,24 @@ void I_FinishUpdate (void)
#else
//cmap_to_rgb565((void*)line_out, (void*)line_in, SCREENWIDTH);
cmap_to_fb((void*)line_out, (void*)line_in, SCREENWIDTH);
#endif
#endif /* CMAP256 */

#else
cmap_to_fb((void*)videoBufferLineOut, (void*)line_in, SCREENWIDTH);
#endif /* ROTATE_SCREENBUFFER */
line_out += (SCREENWIDTH * fb_scaling * (s_Fb.bits_per_pixel/8)) + x_offset_end;
}

#ifdef ROTATE_SCREENBUFFER
for(int m = 0, n = y;
m < sizeof(videoBufferLineOut);
m+=(s_Fb.bits_per_pixel/8), n+=DOOMGENERIC_RESY)
{
uint32_t * pixelIn = &videoBufferLineOut[m];
uint32_t * pixelOut = &DG_ScreenBuffer[n];
*pixelOut = *pixelIn;
}
#endif /* ROTATE_SCREENBUFFER */
line_in += SCREENWIDTH;
}

Expand Down