I'm currently working on a simple PS1 demo using Psy-Q SDK 1.12. (on Windows XP) For now, my goal is to render a red box on a white background and control it using the D-Pad. However, I keep encountering the following errors during compilation:
MAIN.C(36): PADTYPE undeclared (first use in this function)
MAIN.C(37): pad undeclared (first use in this function)
I have already tried the following steps to resolve this issue:
Included <libpad.h> in the code.
Manually defined PADTYPE and mocked the PadRead() function.
Removed all controller-related code entirely, yet the errors persist.
Here is my full main.c file for reference:
Code: Select all
#include <sys/types.h>
#include <libgte.h>
#include <libgpu.h>
#include <libetc.h>
#include <libpad.h>
#include <libgs.h> // GsOT and PACKET
#define SCREEN_W 320
#define SCREEN_H 240
int boxX = 100;
int boxY = 100;
int boxSize = 30;
#define OT_LEN 1
GsOT ot[OT_LEN];
GsOT_TAG ot_tag[1 << OT_LEN];
PACKET gp_packet[16];
DRAWENV drawEnv;
DISPENV dispEnv;
void initGraphics(void);
void drawRedBox(int x, int y, int size);
int main(void) {
initGraphics();
InitPAD(0, 0, 0, 0);
StartPAD();
ChangeClearPAD(0);
while (1) {
ClearOTagR((u_long*)ot[0].org, 1 << OT_LEN);
PADTYPE pad = PadRead(0); // Error: PADTYPE undeclared
if (!(pad & PADLup)) { boxY -= 2; if (boxY < 0) boxY = 0; }
if (!(pad & PADLdown)) { boxY += 2; if (boxY > SCREEN_H - boxSize) boxY = SCREEN_H - boxSize; }
if (!(pad & PADLleft)) { boxX -= 2; if (boxX < 0) boxX = 0; }
if (!(pad & PADLright)){ boxX += 2; if (boxX > SCREEN_W - boxSize) boxX = SCREEN_W - boxSize; }
drawRedBox(boxX, boxY, boxSize);
DrawSync(0);
VSync(0);
GsSwapDispBuff();
GsSortClear(255, 255, 255, &ot[0]); // White background
GsDrawOt(&ot[0]);
}
return 0;
}
void initGraphics(void) {
ResetGraph(0);
SetDefDrawEnv(&drawEnv, 0, 0, SCREEN_W, SCREEN_H);
SetDefDispEnv(&dispEnv, 0, 0, SCREEN_W, SCREEN_H);
drawEnv.isbg = 1;
drawEnv.r0 = 255;
drawEnv.g0 = 255;
drawEnv.b0 = 255;
PutDrawEnv(&drawEnv);
PutDispEnv(&dispEnv);
GsClearOt(0, 0, &ot[0]);
GsSetWorkBase((PACKET*)gp_packet);
GsClearWorkBase();
SetDispMask(1);
}
void drawRedBox(int x, int y, int size) {
POLY_F4* poly = (POLY_F4*)GsGetWorkBase();
GsSetWorkBase((PACKET*)((u_long)poly + sizeof(POLY_F4)));
setPolyF4(poly);
setXY4(poly, x, y, x+size, y, x, y+size, x+size, y+size);
setRGB0(poly, 255, 0, 0);
AddPrim(&ot[0], poly);
}
Additionally, here is my Makefile setup:
Code: Select all
MAIN.CPE : MAIN.OBJ
C:\PSYQ\BIN\CCPSX.EXE MAIN.OBJ -cpe MAIN.CPE -sym MAIN.SYM -map MEM.MAP C:\PSYQ\LIB\LIBETC.LIB C:\PSYQ\LIB\LIBGTE.LIB C:\PSYQ\LIB\LIBGPU.LIB C:\PSYQ\LIB\LIBPAD.LIB
MAIN.OBJ : MAIN.C
C:\PSYQ\BIN\CCPSX.EXE -c -Xo2 -G0 MAIN.C -o MAIN.OBJ
Thank you in advance for your help!