Page 1 of 1

C Programming Issues(Psy-Q SDK 1.12: Controller and Graphics Issues)

Posted: January 19th, 2025, 12:10 am
by icerlermis_tuzluk
Hi,
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
I suspect the issue might be caused by something outside of the controller-related code, so I have included my full main.c file for review. If there's anything wrong elsewhere in the code or with the Psy-Q SDK setup, please let me know.

Thank you in advance for your help! 😊

Re: C Programming Issues(Psy-Q SDK 1.12: Controller and Graphics Issues)

Posted: January 19th, 2025, 7:39 am
by MasterLink
In your other post regarding /projects/redbox/ALL, your PADTYPE code was different. It was "PADTYPE p = PadRead(0);" then, and now it's "PADTYPE pad = PadRead(0);"

First, did you fix the first issue? If so, what was the issue? You deleted it without providing information that could help others. Second, why the change, were you getting the same error with the old code?

(I had to cross reference your old code here: https://www.technopat.net/sosyal/konu/k ... r.3608644/ where you still have the original question up.)

(To date, I've not written any PSX executables that use a controller so I haven't run into this personally yet, anything I've done are just demos and tests, no interactivity.)

Re: C Programming Issues(Psy-Q SDK 1.12: Controller and Graphics Issues)

Posted: January 19th, 2025, 12:31 pm
by nocash
Removing line 36 and still getting the same error in line 36 makes no sense.
Or only makes sense if you don't know how to edit the source code, and save the changes.

Re: C Programming Issues(Psy-Q SDK 1.12: Controller and Graphics Issues)

Posted: January 20th, 2025, 3:57 am
by icerlermis_tuzluk
nocash wrote: ↑January 19th, 2025, 12:31 pm Removing line 36 and still getting the same error in line 36 makes no sense.
Or only makes sense if you don't know how to edit the source code, and save the changes.
I removed line 36 for testing to see if the issue was there, but it wasn't (when I removed the code, I got a different error). I'm trying to solve it with the help of GPT-4o, but it's not working. Right now, I just need help.

Re: C Programming Issues(Psy-Q SDK 1.12: Controller and Graphics Issues)

Posted: January 20th, 2025, 6:00 am
by david4599
The issue here is that "PADTYPE" is not defined anywhere in your code or any header file in the include folder of the PsyQ SDK. Actually, I saw this type defined only in the PSn00bSDK which is another SDK, different from PsyQ:
https://github.com/Lameguy64/PSn00bSDK/ ... ain.c#L245

The correct type to use is "u_long" according to the examples of the PsyQ SDK like Psyq\psx\sample\graphics\BG\BGSAMPLE\MAIN.C.

Code: Select all

u_long pad = PadRead(0);
Also, where did you find "Psy-Q SDK 1.12"? To my knowledge, there isn't such a 1.12 version of the SDK available. It's usually 4.6 or 4.7.

Re: C Programming Issues(Psy-Q SDK 1.12: Controller and Graphics Issues)

Posted: January 20th, 2025, 6:55 am
by MasterLink
david4599 wrote: ↑January 20th, 2025, 6:00 am Also, where did you find "Psy-Q SDK 1.12"? To my knowledge, there isn't such a 1.12 version of the SDK available. It's usually 4.6 or 4.7.
I wonder if they are referring to psymake itself, as someone did release 1.12 here some years back on a post.

Re: C Programming Issues(Psy-Q SDK 1.12: Controller and Graphics Issues)

Posted: January 20th, 2025, 7:13 am
by david4599
Indeed, that makes sense.

Re: C Programming Issues(Psy-Q SDK 1.12: Controller and Graphics Issues)

Posted: January 20th, 2025, 7:29 am
by icerlermis_tuzluk
Sorry, it was my stupidity; it was the psymake version.