Daily Archives: 2018-04-01

VoCore2 + DOOM Port

[embedyt] https://www.youtube.com/watch?v=homxYyDKVis[/embedyt]

I spend around 10 hours finish this, looks like it is pretty easy to port exists project to using VoCore2 display.

First checkout source code from git@github.com:Vonger/Doom.git, thanks for its contributor jeffdoggett, other DOOM source code I can not even compile 🙂

Only need to change one file /Doom/Source/i_video.c

//
// DESCRIPTION:
//	DOOM graphics stuff for VoCore2 Display, OpenWrt.
//  based on i_video.c.
//
//-----------------------------------------------------------------------------

#include "includes.h"
#include "libvodisp.h"

unsigned int SCREENWIDTH = 320;
unsigned int SCREENHEIGHT = 200;
unsigned int ORIGSCREENWIDTH = 320;
unsigned int ORIGSCREENHEIGHT = 200;

union pixel {
    struct _rgb {
        unsigned char red;
        unsigned char green;
        unsigned char blue;
    }rgb;
    unsigned int full:24;
};
static union pixel palette_table[256];
static byte *framebuffer;

void I_InitGraphics (void)
{
    framebuffer = malloc(800 * 480 * 3);
    memset(framebuffer, 0, 800 * 480 * 3);

    vodisp_connect();
}

void I_ShutdownGraphics(void)
{
    vodisp_disconnect();
}

void I_SetPalette (byte* palette)
{
    unsigned int colour = 0;
    do {
        palette_table[colour].rgb.blue   = gammatable[usegamma][*palette++];
        palette_table[colour].rgb.green = gammatable[usegamma][*palette++];
        palette_table[colour].rgb.red  = gammatable[usegamma][*palette++];
    } while (++colour < 256);
}

void I_FinishUpdate (void)
{
    byte *src = screens[0], *dst = framebuffer;
    int i, j, pos;

    for (j = 0; j < SCREENHEIGHT; j++) {
        pos = j * 480 * 3;
        for (i = 0; i < SCREENWIDTH; i++)
            *(unsigned int *)(dst + pos + i * 3) = palette_table[*src++].full;
    }

    vodisp_write_frame(framebuffer);
}

void I_ReadScreen (byte* scr)
{
    memcpy(scr, screens[0], SCREENWIDTH * SCREENHEIGHT);
}

void I_InitKeyboard (void)
{
}

void I_UpdateNoBlit (void)
{
}

void I_SetScreenSize (void)
{
}

void I_SetWindowName (const char * title)
{
}

void I_StartFrame (void)
{
}

void I_StartTic (void)
{
}

Here is necessary library and Makefile, you might need to modify.

Download: http://vonger.cn/misc/vocore2/doom.openwrt.tar.xz, uncompress and put it in /Doom/Source then compile.