Quiero destacar que este post está orientado a la gente que tiene conocimiento sobre Programación.
No voy a explicar cómo se escribe la sintaxis de un código de fuente, ni nada por el estilo.
Voy a dejar manuales para que pueden buscar las funciones del código en dicho manual.
Deberán investigar en el código de otras personas para aprender.
Al que quiera realizar un juego de verdad, le deseo todo el éxito del mundo. Suerte!
Programar un juego de PSX no es nada sencillo.
Primero y principal necesitan tener muchas ganas y tiempo.
También es necesario saber lenguaje C/C++.
Se puede pensar que hacer un juego de Play Station 1 no tiene sentido, ya que esta consola se dejó de utilizar hace bastante tiempo. También hay que tener en cuenta que la programación no es la misma que en la PC, ya que tiene otra arquitectura distinta. Las librerías que se incorporan en la interfaz de programación no son las mismas. Existe muy poco soporte para esto.
Pero siempre existen personas locas que les gusta complicarse la vida como amí.
Así que empecemos.
Es necesario tener Windows XP de 32 bits. Y un conjunto de herramientas.
Yo se las dejo todas en una imagen de disco duro con Windows XP, que utilizarán montándola en una máquina virtual.
Instalación:
Hacer una carpeta en 'C:psyq' llamada 'vpc'.
Luego descargar las imágenes virtuales y colocarlas en la ruta 'C:psyqvpc'
Extraer los comprimidos, (Se recomienda usar 7ZIP, otros programas pueden no funcionar correctamente)
Descargar
[DOWNLOAD PSXDEV_WINXP_VPC.001] Revision 1.1
[DOWNLOAD PSXDEV_WINXP_VPC.002] Revision 1.1
[DOWNLOAD PSXDEV_WINXP_VPC.003] Revision 1.1
Luego descargar máquina virutal:
Virtual PC 2007
Instalar.
Luego de la instalación:
Click en "Nuevo..."
Click en Browse, localizar el directorio C:psyqvpc', y guardar el archivo como 'PSXDEV' (PSXDEV.VPC).
Proceder.
Elegir Windows XP. El instalador calculará y pondrá automáticamente el nivel de memoria RAM.
Aquí podrás configurar la RAM a gusto.
Deberán buscar la imagen del disco duro extraído en el directorio C:psyqvpc'.
Finalizar.
Esta imagen virtual posee todas las herramientas necesarias instaladas para poder programar un juego de PSX.
Manuales sobre las librerías
Estos manuales poseen toda la información sobre la funciones, y tipos de datos abstractos (TDA) que se encuentran en las librerías que utilizarán en el entorno de desarrollo.
También explica la arquitectura de la Play Station.
(LOS MANUALES ESTÁN DENTRO DE LA CARPETA DOCS DEL COMPRIMIDO).
Runtime Library 4.7 5.82 MB Programmer Tool Runtime Library Release 4.7 | 02/FEB/2000
Runtime Library 4.6 6.70 MB Programmer Tool Runtime Library Release 4.6 | 27/JUL/1999
Les voy a demostrar únicamente como se hace un Hola mundo.
Primero y principal, por una cuestión de organización, les recomiendo que hagan un directorio llamado "Projects" o proyectos, donde pondrán todo el trabajo.
dentro de este directorio, hacer otro llamado "hiword" o "hola mundo", etc.
crear un archivo llamado MAIN.C y otro MAKEFILE.MAK. Editar MAIN.C con un editor de texto enriquecido, como Notepad++ o Programmers Notepad, etc.
Pegar el código:
#include <stdlib.h>
#include <libgte.h>
#include <libgpu.h>
#include <libgs.h>
#define OT_LENGTH 1 // the ordertable length
#define PACKETMAX 18 // the maximum number of objects on the screen
#define SCREEN_WIDTH 320 // screen width
#define SCREEN_HEIGHT 240 // screen height (240 NTSC, 256 PAL)
GsOT myOT[2]; // ordering table header
GsOT_TAG myOT_TAG[2][1<<OT_LENGTH]; // ordering table unit
PACKET GPUPacketArea[2][PACKETMAX]; // GPU packet data
u_long _ramsize = 0x00200000; // force 2 megabytes of RAM
u_long _stacksize = 0x00004000; // force 16 kilobytes of stack
// --------
// INTEGERS
// --------
short CurrentBuffer = 0; // holds the current buffer number
// ----------
// PROTOTYPES
// ----------
void graphics(); // inits the GPU
void display(); // updates the GPU (IE: VRAM/SGRAM/framebuffer)
const DEBUG = 1; // debugging (1=on, 0=off)
// ----
// MAIN
// ----
int main()
{
graphics(); // setup the graphics (seen below)
FntLoad(960, 256); // load the font from the BIOS into the framebuffer
SetDumpFnt(FntOpen(5, 20, 320, 240, 0, 512)); // screen X,Y | max text length X,Y | autmatic background clear 0,1 | max characters
if (DEBUG) // should debug be true (equal 1)...
{
// print to the TTY stream (only visible if you're using one)
printf("nnHello Worldn" ) ;
}
while (1) // draw and display forever
{
FntPrint(" HELLO WORLDnn " ) ;
display( ) ;
}
return 0; // this will never be reached because we're in a while loop above
}
void graphics()
{
SetVideoMode(1); // PAL mode
//SetVideoMode(0); // NTSC mode
GsInitGraph(SCREEN_WIDTH, SCREEN_HEIGHT, GsINTER|GsOFSGPU, 1, 0); // set the graphics mode resolutions (GsNONINTER for NTSC, and GsINTER for PAL)
GsDefDispBuff(0, 0, 0, SCREEN_HEIGHT); // tell the GPU to draw from the top left coordinates of the framebuffer
// init the ordertables
myOT[0].length = OT_LENGTH;
myOT[1].length = OT_LENGTH;
myOT[0].org = myOT_TAG[0];
myOT[1].org = myOT_TAG[1];
// clear the ordertables
GsClearOt(0,0,&myOT[0]);
GsClearOt(0,0,&myOT[1]);
}
void display()
{
// refresh the font
FntFlush(-1);
// get the current buffer
CurrentBuffer = GsGetActiveBuff();
// setup the packet workbase
GsSetWorkBase((PACKET*)GPUPacketArea[CurrentBuffer]);
// clear the ordering table
GsClearOt(0,0, &myOT[CurrentBuffer]);
// wait for all drawing to finish
DrawSync(0);
// wait for v_blank interrupt
VSync(0);
// flip the double buffers
GsSwapDispBuff();
// clear the ordering table with a background color (R,G,B)
GsSortClear(50,50,50, &myOT[CurrentBuffer]) ;
// draw the ordering table
GsDrawOt(&myOT[CurrentBuffer]) ;
}
Como pueden ver las instrucciones son a muy bajo nivel. En la computadora uno puede hacer
cout<<"Hola Mundo"<<endl; o printf("Hola Mundo " ) ; y LISTO.
utilizando métodos y funciones de alto nivel que nos facilitan la vida, pero en el caso de la PSX no es así, juega mucho más de forma MANUAL con buffers, espacios de memoria, pila de instrucciones, etc...
Les recomiendo que utilicen programación modular, definiciones y macros. Dividiendo el código en fragmentos pequeños y mantenibles. Como dice el refrán "Divide y vencerás".
No se puede utilizar clases (Class), ya que es C, utilicen estructuras (struct, union).
Paso siguiente es compilar el código.
Abran la consola (WINDOWS + R)
deben navegar con la consola hasta el directorio donde poseen el código de fuente (archivos .C, el que acabamos de crear).
para esto deben poner en la consola: cd RUTA (Donde RUTA es la ruta es la dirección absoluta de su directorio EJ: cd C:psyqprojectshiworldsource).
Luego tipear psymake. Compilará un archivo 'MAIN.CPE' dentro de ese directorio.
Para formar el ejecutable a partir de ese archivo deben tipear
cpe2x main.cpe
Listo, ahora pueden probar el .EXE desde un emulador.
Les dejo algunos juegos con código incluído:
fly_little_bat_v0.8.zip
Código mitmw_010a_source.7z
Compilado ACA