Code: Select all
u_long OT[2][OTlen]
Code: Select all
long Otz;
long p;
long flag;char primbuff[2][32768]; // double primitive buffer of length 32768 * 8 = 262.144 bits / 32,768 Kbytes
char *nextpri = primbuff[0]; // pointer to the next primitive in primbuff. Initially, points to the first bit of primbuff[0]
....
...
...
Otz = RotTransPers3(&Vertexpos[0],&Vertexpos[1],&Vertexpos[2],(long*)&f3->x0,(long*)&f3->x1,(long*)&f3->x2,&p,&flag);
rotate.vz += 4; // Apply rotation on Z-axis. On PSX, the Z-axis is pointing away from the screen.
addPrim(OT[db][8], &f3); // add poly to the Ordering table
nextpri += sizeof(POLY_F3); // increment nextpri address with size of a POLY_F4 struct
Code: Select all
#include <sys/types.h>
#include <stdio.h>
#include <libgte.h>
#include <libetc.h>
#include <libgpu.h>
#include <libapi.h>
#define VMODE 0
#define SCREENX 320
#define SCREENY 240
#define OTlen 9
int db;
DRAWENV drawenv[2];
DISPENV dispenv[2];
long printid1;
long printid2;
MATRIX transm;
char primbuff[2][32768]; // double primitive buffer of length 32768 * 8 = 262.144 bits / 32,768 Kbytes
char *nextpri = primbuff[0]; // pointer to the next primitive in primbuff. Initially, points to the first bit of primbuff[0]
SVECTOR rotate = {0,0,0};
SVECTOR Vertexpos[4];
u_long OT[2][OTlen];
long Otz;
long p;
long flag;
VECTOR MovVector;
VECTOR ScaleVector;
void init(){
//RESET GPU AND ENABLE INTERRUPTS
ResetGraph(VMODE);
//SET DISP AND DRAW ENV
SetDefDispEnv(&dispenv[0],0,0,SCREENX,SCREENY); //upper frame buffer
SetDefDrawEnv(&drawenv[1],0,240,SCREENX,SCREENY); //bottom frame buffer
SetDefDrawEnv(&drawenv[0],0,0,SCREENX,SCREENY);// upper frame buffer
SetDefDispEnv(&dispenv[1],0,240,SCREENX,SCREENY); //upper frame buffer
setRGB0(&drawenv[0], 49, 177, 255); // Set the first DRAWENV primitive's color
setRGB0(&drawenv[1], 49, 177, 255); // Set the second "
drawenv[0].isbg = 1;
drawenv[1].isbg = 1;
PutDispEnv(&dispenv[0]); // Set disp env for first time
PutDrawEnv(&drawenv[0]); // Set draw env for first time
db = 0;
// initialize font and font cords in display
FntLoad(960,0);
printid1 = FntOpen(10,200,100,100,0,100);
printid2 = FntOpen(25,25,100,100,0,100);
}
void display(){
DrawSync(0);
VSync(0);
PutDispEnv(&dispenv[db]);
PutDrawEnv(&drawenv[db]);
DrawOTag(&OT[db][OTlen - 1]);
db = !db;
nextpri = primbuff[db];
SetDispMask(1);
}
int main(){
POLY_F3 *f3;
SetPolyF3(f3); /*initialize primitive*/
setRGB0(f3, 0, 0, 255); /*R,G,B = 0, 0, 255*/
Vertexpos[0] = (SVECTOR){f3->x0,f3->y0,0};
Vertexpos[1] = (SVECTOR){f3->x1,f3->y1,0};
Vertexpos[2] = (SVECTOR){f3->x2,f3->y2,0};
MovVector.vx = 0;
MovVector.vy = 0;
MovVector.vz = 0;
ScaleVector.vx = 0;
ScaleVector.vy = 0;
ScaleVector.vz = 0;
init();
setXY3(f3, SCREENX/2, SCREENY/2, 100, 0, 0, 100);
while(1){
f3 = (POLY_F3*)nextpri;
ClearOTag(OT[db],OTlen);
RotMatrix(&rotate,&transm);
TransMatrix(&transm, &MovVector);
ScaleMatrix(&transm,&ScaleVector);
SetTransMatrix(&transm);
SetRotMatrix(&transm);
if(VMODE==0){
FntPrint(printid1,"NTSC MODE");
}
else{
FntPrint(printid1,"PAL MODE");
}
Otz = RotTransPers3(&Vertexpos[0],&Vertexpos[1],&Vertexpos[2],(long*)&f3->x0,(long*)&f3->x1,(long*)&f3->x2,&p,&flag);
rotate.vz += 4; // Apply rotation on Z-axis. On PSX, the Z-axis is pointing away from the screen.
addPrim(OT[db][8], &f3); // add poly to the Ordering table
nextpri += sizeof(POLY_F3); // increment nextpri address with size of a POLY_F4 struct
FntPrint(printid2,"MADE BY ABDESSALAM");
FntFlush(printid1);
FntFlush(printid2);
display();
}
}