Forum

Wii: vid_wii.c

Discuss programming topics for the various GPL'd game engine sources.

Moderator: InsideQC Admins

Wii: vid_wii.c

Postby Baker » Fri Dec 25, 2009 6:24 pm

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;
}

User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby Team Xlink » Sun Dec 27, 2009 2:50 am

He has done a good port.

Its nice because it is Quake World and not Quake and he did a good job on it.
Team Xlink
 
Posts: 368
Joined: Thu Jun 25, 2009 4:45 am
Location: Michigan

Postby r00k » Sun Dec 27, 2009 6:47 am

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...
r00k
 
Posts: 1110
Joined: Sat Nov 13, 2004 10:39 pm

Postby Baker » Sun Dec 27, 2009 12:09 pm

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.
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby Downsider » Sun Dec 27, 2009 3:03 pm

Cobalt Runner plays fine on the PSP.

And it's cool.
User avatar
Downsider
 
Posts: 621
Joined: Tue Sep 16, 2008 1:35 am

Postby Team Xlink » Sun Dec 27, 2009 5:02 pm

Quake plays fine on the psp.

It is a fun game and is the best fps on the platform.
Team Xlink
 
Posts: 368
Joined: Thu Jun 25, 2009 4:45 am
Location: Michigan

Postby Downsider » Mon Dec 28, 2009 1:32 am

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:
User avatar
Downsider
 
Posts: 621
Joined: Tue Sep 16, 2008 1:35 am

Re: Wii: vid_wii.c

Postby drm_wayne » Thu Apr 05, 2012 5:28 pm

sorry for bumping old topic, but does somebody still have the wii build or the sources?
the link doesnt work anymore.
User avatar
drm_wayne
 
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: Wii: vid_wii.c

Postby Baker » Fri Apr 06, 2012 2:39 am

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 ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Wii: vid_wii.c

Postby drm_wayne » Fri Apr 06, 2012 3:16 pm

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 :(
User avatar
drm_wayne
 
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm


Return to Engine Programming

Who is online

Users browsing this forum: No registered users and 1 guest