Posted By: wraggster
New Space Invaders Emulator for the Gamecube and Nintendo Wii from Softdev:
Midway Space Invaders Emulator
A libOGC example.
softdev April 2007
Introduction
============
This is a very simple machine to emulate. I hope this shows the basic
principles of emulation, and in particular, how to do it on GameCube
with libOGC.
The target audience is people interested in how an emulator works, and
those who are interested in how to do the basic functions on GameCube.
The Emulator
============
The emulator code is almost completely contained in mwsi.c
Memory, port I/O etc are all in there.
You will need to acquire the Mame romset for this. It should
contain invaders.e, invaders.f, invaders.g and invaders.h
Each ROM image is exactly 2Kb in size.
Create a directory on your SD, called Invaders. Copy the four
ROM images to there.
Unpack the samples.7z provided to the same directory.
You're now ready to see how the emulator looks.
Joy Buttons.
A = Fire
START = Insert Coin
X = One Player
Y = Two Players (alternating)
Z = Tilt
Left/Right = Go on ... guess
Support Functions
=================
In the support subdirectory, you'll find the source of the GameCube support
functions. Here is a brief description of how to use them in your own
projects.
gx_supp.c
Before using the GX functions, you need to supply a Graphic Mode object, a
couple of framebuffers and a double buffer switch. For now, they should be
named as follows;
extern u32 whichfb; /*** Double buffer switch ***/
extern u32 *xfb[2]; /*** Video buffer pointers ***/
extern GXRModeObj *vmode; /*** Graphic Mode Object ***/
These are setup in main.c, before calling the GX routines.
void GX_Start(int width, int height, int haspect, int vaspect)
To use GX_Start, you need to know the width and height of your output display
and the aspect. The aspect values are calculated as 80x60 equals 4:3.
An example, this emulator needs an aspect of 224/256, or 44H, 50V.
Your display width and height MUST be divisible by 4. The GX scaler uses
RGB565 colours, in Nintendo tiles of 4x4.
void GX_Render(int width, int height, u8 * buffer, int pitch)
GX_Render will scale your output to fit the TV screen in the aspect you chose
previously with GX_Start.
Although the pitch is double the width in the example, this may not always be
the case, so it's here for completeness.
sd_supp.c
int SDH_FindEntry(u8 * srcdir, u8 * searchentry, u8 * foundentry, u32 * size)
This is an SDCard helper function. Specifically, it helps you overcome the
users who aren't sure what upper and lower case mean (Mouse Jockeys Mostly )
int SDH_LoadFile(u8 * filename, u8 * buffer, int length)
This function is a simple way to load an entire file, or part of a file to
a memory buffer.
audio_supp.c
Although there are no generic functions for audio, every emulator is a little
different, it should give you enough of an idea of how to use audio on the
GameCube.
Credits
=======
Z80 C Core - Juergen Buchmueller
libOGC - shagkur
Where to next ?
===============
Those of you who find this stuff interesting will be pleased to know that this
board supports around another 30 or so games, with minor modifications between
each. A new goal perhaps ??
Enjoy - hope this all helps you in some way.
GPL
===
This project is released under the GNU Public Licence v2.
A copy of this document is in the docs directory. Please ensure that you
distribute this document with any derived sources.
Download and Give Feedback Via Comments