Wii: vid_wii.c

Discuss programming topics for the various GPL'd game engine sources.
Post Reply
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Wii: vid_wii.c

Post by Baker »

Sometime I'll probably play around with Bigfoot's Wii build for Quakeworld (thread @ Quakeworld.nu). I think it is interesting not because it is Wii but because BigFoot made it.

Most of the engine ports are done by clueless people that have a lot of experience in the platform they are developing on, but don't have any practical experience with Quake.

And that's not Bigfoot :D

Code: Select all

/*
Copyright (C) 2008 Mark Olsen

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  

See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

#include <ogcsys.h>
#include <gccore.h>
#include <gctypes.h>

#include <stdlib.h>
#include <string.h>

#define false qfalse
#define true qtrue
#include "quakedef.h"
#include "d_local.h"
#include "input.h"
#include "keys.h"
#include "in_wii.h"
#undef false
#undef true

struct display
{
	unsigned int width;
	unsigned int height;

	void *inputdata;

	unsigned char *buffer8;
	unsigned short *buffer;

	unsigned char paly[256];
	unsigned char palcb[256];
	unsigned char palcr[256];
};

void Sys_Video_CvarInit(void)
{
}

void *Sys_Video_Open(unsigned int width, unsigned int height, unsigned int depth, int fullscreen, unsigned char *palette)
{
	struct display *d;

	d = malloc(sizeof(*d));
	if (d)
	{
		GXRModeObj *rmode;

		switch(VIDEO_GetCurrentTvMode())
		{
			case VI_NTSC:
				rmode = &TVNtsc480IntDf;
				break;

			case VI_PAL:
				rmode = &TVPal528IntDf;
				break;

			case VI_MPAL:
				rmode = &TVMpal480IntDf;
				break;

			default:
				rmode = &TVNtsc480IntDf;
				break;
		}

		d->width = rmode->fbWidth;
		d->height = rmode->xfbHeight;

		d->buffer8 = malloc(d->width * d->height);
		if (d->buffer8)
		{
			memset(d->buffer8, 0, d->width * d->height);

			d->buffer = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
			if (d->buffer)
			{
				memset(d->buffer, 0, d->width * d->height * 2);
				#if 1
				VIDEO_Configure(rmode);
				VIDEO_SetNextFramebuffer(d->buffer);
				VIDEO_SetBlack(FALSE);
				VIDEO_Flush();
				VIDEO_WaitVSync();
				#endif

				d->inputdata = Sys_Input_Init();
				if (d->inputdata)
				{
					Com_Printf("%s: %dx%d display initialised\n", __func__, d->width, d->height);

					return d;
				}

#warning Free fb
			}

			free(d->buffer8);
		}

		free(d);
	}

	return 0;
}

void Sys_Video_Close(void *display)
{
	struct display *d;

	d = display;

#warning Free fb
	free(d->buffer8);
	free(d);
}

unsigned int Sys_Video_GetNumBuffers(void *display)
{
	return 1;
}

void Sys_Video_GetEvents(void *display)
{
	struct display *d = display;

	Sys_Input_GetEvents(d->inputdata);
}
 
void Sys_Video_GetMouseMovement(void *display, int *mousex, int *mousey)
{
	struct display *d = display;

	Sys_Input_GetMouseMovement(d->inputdata, mousex, mousey);
}

void Sys_Video_Update(void *display, vrect_t * rects)
{
	struct display *d = display;
	unsigned int *dest;
	unsigned char *source;

	unsigned int startx;
	unsigned int width;
	unsigned int x;
	unsigned int y;
	unsigned int cb;
	unsigned int cr;

#if 1
	while (rects)
	{
		startx = rects->x&~1;
		width = (rects->width + (rects->x - startx) + 1)&~1;
		source = d->buffer8 + rects->y * d->width + startx;
		dest = (unsigned int *)(d->buffer + rects->y * d->width + startx);

		for(y=0;y<rects->height;y++)
		{
			for(x=0;x<width;x+=2)
			{
				cb = (d->palcb[source[x]] + d->palcb[source[x+1]])>>1;
				cr = (d->palcr[source[x]] + d->palcr[source[x+1]])>>1;

				dest[x/2] = (d->paly[source[x]]<<24)|(cb<<16)|(d->paly[source[x+1]]<<8)|cr;
			}

			source+= d->width;
			dest+= d->width/2;
		}

		rects = rects->pnext;
	}
#endif
}

void Sys_Video_GrabMouse(void *display, int dograb)
{
}

void Sys_Video_SetPalette(void *display, unsigned char *palette)
{
	struct display *d = display;
	int i;
	int r, g, b;

	for (i = 0; i < 256; i++)
	{
		r = palette[i * 3 + 0];
		g = palette[i * 3 + 1];
		b = palette[i * 3 + 2];

		d->paly[i] = (299 * r + 587 * g + 114 * b) / 1000;
		d->palcb[i] = (-16874 * r - 33126 * g + 50000 * b + 12800000) / 100000;
		d->palcr[i] = (50000 * r - 41869 * g - 8131 * b + 12800000) / 100000;
	}
}

void VID_LockBuffer()
{
}

void VID_UnlockBuffer()
{
}

void D_BeginDirectRect(int x, int y, byte *pbitmap, int width, int height)
{
}

void D_EndDirectRect(int x, int y, int width, int height)
{
}

void Sys_Video_SetWindowTitle(void *display, const char *text)
{
}

unsigned int Sys_Video_GetWidth(void *display)
{
	struct display *d;

	d = display;

	return d->width;
}

unsigned int Sys_Video_GetHeight(void *display)
{
	struct display *d;

	d = display;

	return d->height;
}

unsigned int Sys_Video_GetBytesPerRow(void *display)
{
	struct display *d;

	d = display;

	return d->width;
}

void *Sys_Video_GetBuffer(void *display)
{
	struct display *d;

	d = display;

	return d->buffer8;
}

Team Xlink
Posts: 368
Joined: Thu Jun 25, 2009 4:45 am
Location: Michigan

Post by Team Xlink »

He has done a good port.

Its nice because it is Quake World and not Quake and he did a good job on it.
r00k
Posts: 1111
Joined: Sat Nov 13, 2004 10:39 pm

Post by r00k »

dont waste your time on the psp. its a dead platform, albiet quake is a dead game in their eyes. You're mooning the handicap.

wait, what i mean is that you CAN NOT play QUAKE on the PSP as it was Meant to be played. unless its a custom mod. it just wont happen...
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Post by Baker »

r00k wrote:dont waste your time on the psp. its a dead platform, albiet quake is a dead game in their eyes. You're mooning the handicap.

wait, what i mean is that you CAN NOT play QUAKE on the PSP as it was Meant to be played. unless its a custom mod. it just wont happen...
The "Quake" engine is a gateway to many things.

If you are thinking "Quake" sure that's a proper statement.

Personally, once I saw Nexuiz I stopped thinking of the Quake engine as "Quake".

And then when I saw Kurok, I saw what a strong imagination could do with mapping tools and the Quake engine.

Quake will be the spawn of one thousand children.
Downsider
Posts: 621
Joined: Tue Sep 16, 2008 1:35 am

Post by Downsider »

Cobalt Runner plays fine on the PSP.

And it's cool.
Team Xlink
Posts: 368
Joined: Thu Jun 25, 2009 4:45 am
Location: Michigan

Post by Team Xlink »

Quake plays fine on the psp.

It is a fun game and is the best fps on the platform.
Downsider
Posts: 621
Joined: Tue Sep 16, 2008 1:35 am

Post by Downsider »

Team Xlink wrote:Quake plays fine on the psp.

It is a fun game and is the best fps on the platform.
Quake plays like ass on the PSP in multiplayer.

You'll get your ass kicked with 4 face buttons and an "analog nub".

And even in singleplayer, most of it consists of exploiting the AI because you don't have the reflexes required to play it correctly without proper controls. :lol:
drm_wayne
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: Wii: vid_wii.c

Post by drm_wayne »

sorry for bumping old topic, but does somebody still have the wii build or the sources?
the link doesnt work anymore.
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Wii: vid_wii.c

Post by Baker »

drm_wayne wrote:sorry for bumping old topic, but does somebody still have the wii build or the sources?
the link doesnt work anymore.
I would be informed not too long after that the Wii client was never made available nor the source code.

Essentially it was a private experimentation by Bigfoot.

If I recall everything correctly.

Even if not, it was a pure Quakeworld client only. This means no single player of any kind nor the possibility of such. So even if you did find it, it would be rather useless for modding unfortunately.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
drm_wayne
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: Wii: vid_wii.c

Post by drm_wayne »

Ohh, ok..

atm QUakeGX seems to be the best Quake port for the Wii, but is has some limits like the odd vectriceslimit and no fencetextures and no skyboxes :(
Post Reply