padInit(0) crashes/hangs the ps2.

Discuss the development of software, tools, libraries and anything else that helps make ps2dev happen.

Moderators: cheriff, Herben

Post Reply
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

padInit(0) crashes/hangs the ps2.

Post by Kojima »

Hey, I'm trying to get some user input into my demo, but whenever I call padInit the ps2 just freezes up.

Here's the code

Code: Select all

	printf("About to init pad. \n");
	char *padBuf = padBuf = (char *)malloc(256);
	printf("Created structure \n");
	padInit(0); 	
	printf("Called padinit.\n");
	if((padPortOpen(0, 0, padBuf)) == 0) { 
		printf("padOpenPort failed"); 
 	}
 	printf("Joypad Initialized");
And the last debug line that reaches ps2client is "Created Structure" right before padinit.


Here's my full source, it's just a slight modification of the gskit/examples/basic demo.

Code: Select all


#include "gsKit.h"
#include "dmaKit.h"
#include "malloc.h"
#include "libpad.h"

typedef char int8;
typedef short int16;
typedef int int32;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long uint64;
typedef long int64;
typedef struct int128
{
int64 lo, hi;
} int128 __attribute__((aligned(16)));
typedef struct uint128
{
uint64 lo, hi;
} uint128 __attribute__((aligned(16)));

uint64 MakeRgb(int r,int g,int b)
{
	return &#40;&#40;uint64&#41;&#40;r&#41; <<0&#41; | &#40;&#40;uint64&#41;&#40;g&#41; << 8&#41; | &#40;&#40;uint64&#41;&#40;b&#41; << 16&#41;;
&#125;

uint64 MakeRgba&#40;int r,int g,int b,int a&#41;
&#123;
		return &#40;&#40;uint64&#41;&#40;r&#41; <<0&#41; | &#40;&#40;uint64&#41;&#40;g&#41; << 8&#41; | &#40;&#40;uint64&#41;&#40;b&#41; << 16&#41; | &#40;&#40;uint64&#41;&#40;a&#41; << 32&#41;;
&#125;





int main&#40;void&#41;
&#123;
	u64 White, Black, Red, Green, Blue, BlueTrans, RedTrans, GreenTrans, WhiteTrans;
//	GSGLOBAL *gsGlobal = gsKit_init_global&#40;GS_MODE_VGA_640_60&#41;; // VGA 640x480@60Hz

//	GSGLOBAL *gsGlobal = gsKit_init_global&#40;GS_MODE_DTV_480P&#41;; // HTDV 480P
//	GSGLOBAL *gsGlobal = gsKit_init_global&#40;GS_MODE_DTV_720P&#41;; // HTDV 720P
//	GSGLOBAL *gsGlobal = gsKit_init_global&#40;GS_MODE_DTV_1080I&#41;; // HDTV 1080I Full Buffers
//	GSGLOBAL *gsGlobal = gsKit_init_global&#40;GS_MODE_DTV_1080I_I&#41;; // HDTV 1080I Half Buffers
	SifInitRpc&#40;0&#41;; 
	
	printf&#40;"About to init pad. \n"&#41;;
	char *padBuf = padBuf = &#40;char *&#41;malloc&#40;256&#41;;
	printf&#40;"Created structure \n"&#41;;
	padInit&#40;0&#41;; 	
	printf&#40;"Called padinit.\n"&#41;;
	if&#40;&#40;padPortOpen&#40;0, 0, padBuf&#41;&#41; == 0&#41; &#123; 
		printf&#40;"padOpenPort failed"&#41;; 
 	&#125;
 	printf&#40;"Joypad Initialized"&#41;;

	
	
	

	GSGLOBAL *gsGlobal = gsKit_init_global&#40;GS_MODE_PAL&#41;; // Full Buffers
//	GSGLOBAL *gsGlobal = gsKit_init_global&#40;GS_MODE_PAL_I&#41;; // NTSC Half Buffers

//	GSGLOBAL *gsGlobal = gsKit_init_global&#40;GS_MODE_NTSC&#41;; // NTSC Full Buffers
//	GSGLOBAL *gsGlobal = gsKit_init_global&#40;GS_MODE_NTSC_I&#41;; // NTSC Half Buffers

	// You can use these to turn off Z/Double Buffering. They are on by default.
	// gsGlobal->DoubleBuffering = GS_SETTING_OFF;
	// gsGlobal->ZBuffering = GS_SETTING_OFF;

	// This makes things look marginally better in half-buffer mode...
	// however on some CRT and all LCD, it makes a really horrible screen shake.
	// Uncomment this to disable it. &#40;It is on by default&#41;
	// gsGlobal->DoSubOffset = GS_SETTING_OFF;	

	gsGlobal->PrimAlphaEnable = GS_SETTING_ON;	
	
	float x = 10;
	float y = 10;
	float width = 150;
	float height = 150;

	float VHeight;

	VHeight = gsGlobal->Height;

	float *LineStrip;
	float *LineStripPtr;
	float *TriStrip;
	float *TriStripPtr;
	float *TriFanPtr;
	float *TriFan;

	LineStripPtr = LineStrip = malloc&#40;12 * sizeof&#40;float&#41;&#41;;
	*LineStrip++ = 75;	// Segment 1 X
	*LineStrip++ = 250;	// Segment 1 Y
	*LineStrip++ = 125;	// Segment 2 X
	*LineStrip++ = 290;	// Segment 2 Y
	*LineStrip++ = 100;	// Segment 3 X
	*LineStrip++ = 350;	// Segment 3 Y
	*LineStrip++ = 50;	// Segment 4 X
	*LineStrip++ = 350;	// Segment 4 Y
	*LineStrip++ = 25;	// Segment 6 X
	*LineStrip++ = 290;	// Segment 6 X
	*LineStrip++ = 75;	// Segment 6 Y
	*LineStrip++ = 250;	// Segment 6 Y

	TriStripPtr = TriStrip = malloc&#40;12 * sizeof&#40;float&#41;&#41;;
	*TriStrip++ = 550;
	*TriStrip++ = 100;
	*TriStrip++ = 525;
	*TriStrip++ = 125;
	*TriStrip++ = 575;
	*TriStrip++ = 125;
	*TriStrip++ = 550;
	*TriStrip++ = 150;
	*TriStrip++ = 600;
	*TriStrip++ = 150;
	*TriStrip++ = 575;
	*TriStrip++ = 175;
	
	TriFanPtr = TriFan = malloc&#40;16 * sizeof&#40;float&#41;&#41;;
	*TriFan++ = 300;
	*TriFan++ = 100;
	*TriFan++ = 225;
	*TriFan++ = 100;
	*TriFan++ = 235;
	*TriFan++ = 75;
	*TriFan++ = 265;
	*TriFan++ = 40;
	*TriFan++ = 300;
	*TriFan++ = 25;
	*TriFan++ = 335;
	*TriFan++ = 40;
	*TriFan++ = 365;
	*TriFan++ = 75;
	*TriFan++ = 375;
	*TriFan++ = 100;
	
	dmaKit_init&#40;D_CTRL_RELE_OFF, D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC,
		    D_CTRL_STD_OFF, D_CTRL_RCYC_8&#41;;

	// Initialize the DMAC
	dmaKit_chan_init&#40;DMA_CHANNEL_GIF&#41;;
	dmaKit_chan_init&#40;DMA_CHANNEL_FROMSPR&#41;;
	dmaKit_chan_init&#40;DMA_CHANNEL_TOSPR&#41;;

	White = GS_SETREG_RGBAQ&#40;0xFF,0xFF,0xFF,0x00,0x00&#41;;
	Black = GS_SETREG_RGBAQ&#40;0x00,0x00,0x00,0x00,0x00&#41;;
	Red = GS_SETREG_RGBAQ&#40;0xFF,0x00,0x00,0x00,0x00&#41;;
	Green = GS_SETREG_RGBAQ&#40;0x00,0xFF,0x00,0x00,0x00&#41;;
	Blue = GS_SETREG_RGBAQ&#40;0x00,0x00,0xFF,0x00,0x00&#41;;

	BlueTrans = GS_SETREG_RGBAQ&#40;0x00,0x00,0xFF,0x40,0x00&#41;;
	RedTrans = GS_SETREG_RGBAQ&#40;0xFF,0x00,0x00,0x60,0x00&#41;;
	GreenTrans = GS_SETREG_RGBAQ&#40;0x00,0xFF,0x00,0x50,0x00&#41;;
	WhiteTrans = GS_SETREG_RGBAQ&#40;0xFF,0xFF,0xFF,0x50,0x00&#41;;

	gsKit_init_screen&#40;gsGlobal&#41;;

	gsKit_mode_switch&#40;gsGlobal, GS_PERSISTENT&#41;;

	gsKit_clear&#40;gsGlobal, White&#41;;

	gsKit_set_test&#40;gsGlobal, GS_ZTEST_OFF&#41;;

	gsKit_prim_line_strip&#40;gsGlobal, LineStripPtr, 6, 1, Black&#41;;

	gsKit_prim_triangle_strip&#40;gsGlobal, TriStripPtr, 6, 1, Red&#41;;

	gsKit_prim_line&#40;gsGlobal, 525.0f, 125.0f, 575.0f, 125.0f, 1, Black&#41;;
	gsKit_prim_line&#40;gsGlobal, 550.0f, 150.0f, 600.0f, 100.0f, 1, Black&#41;;

	gsKit_prim_point&#40;gsGlobal, 575.0f, 75.0f, 1, Black&#41;;
	gsKit_prim_point&#40;gsGlobal, 600.0f, 100.0f, 1, Black&#41;;
	gsKit_prim_point&#40;gsGlobal, 625.0f, 125.0f, 1, Black&#41;;

	gsKit_prim_quad&#40;gsGlobal, 150.0f, 150.0f, 
				   150.0f, 400.0f,
				   450.0f, 150.0f,
				   450.0f, 400.0f, 2, Green&#41;;

	gsKit_set_test&#40;gsGlobal, GS_ZTEST_ON&#41;;

	gsKit_prim_triangle_fan&#40;gsGlobal, TriFanPtr, 8, 5, Black&#41;;

	gsKit_prim_quad_gouraud&#40;gsGlobal, 500.0f, 250.0f, 
					   500.0f, 350.0f, 
					   600.0f, 250.0f,
					   600.0f, 350.0f, 2,
					   Red, Green, Blue, Black&#41;;

	gsKit_prim_triangle_gouraud&#40;gsGlobal, 280.0f, 200.0f,
					       280.0f, 350.0f,
					       180.0f, 350.0f, 5, 
					       Blue, Red, White&#41;;

	gsKit_prim_triangle&#40;gsGlobal, 300.0f, 200.0f, 300.0f, 350.0f, 400.0f, 350.0f, 3, Red&#41;;

	gsKit_prim_sprite&#40;gsGlobal, 400.0f, 100.0f, 500.0f, 200.0f, 5, Red&#41;;

	gsKit_mode_switch&#40;gsGlobal, GS_ONESHOT&#41;;

	while&#40;1&#41;
	&#123;
		gsKit_clear&#40;gsGlobal,MakeRgb&#40;0,0,0&#41;&#41;;
		if&#40; y <= 10  && &#40;x + width&#41; < &#40;gsGlobal->Width - 10&#41;&#41;
			x+=1;
		else if&#40; &#40;y + height&#41;  <  &#40;VHeight - 10&#41; && &#40;x + width&#41; >= &#40;gsGlobal->Width - 10&#41; &#41;
			y+=1;		
		else if&#40; &#40;y + height&#41; >=  &#40;VHeight - 10&#41; && x > 10 &#41;
			x-=1;
		else if&#40; y > 10 && x <= 10 &#41;
			y-=1;

	//	gsKit_prim_sprite&#40;gsGlobal, x, y, x + width, y + height, 4, MakeRgb&#40;255,0,0&#41;&#41;;
		
		gsKit_prim_sprite&#40;gsGlobal,20,20,140,140,4,MakeRgba&#40;255,255,128,255&#41;&#41;;
		// RedTrans must be a oneshot for proper blending!
		gsKit_prim_sprite&#40;gsGlobal, 100.0f, 100.0f, 200.0f, 200.0f, 5, MakeRgba&#40;128,128,128,128&#41;&#41;;

		gsKit_queue_exec&#40;gsGlobal&#41;;

		// Flip before exec to take advantage of DMA execution double buffering.
		gsKit_sync_flip&#40;gsGlobal&#41;;

	&#125;
	
	return 0;
&#125;

Any idea why it's freezing? Could it be cos I'm using a slightly older version of ps2link?(I think)
User avatar
evilo
Posts: 230
Joined: Thu Apr 22, 2004 8:40 pm
Contact:

Post by evilo »

Make sure that you link with the rigth lib.

If you use PADMAN (Irx in rom), you must link with -lpad

If you use XPADMAN (Irx in rom), you must link with -lpadx

[EDIT]
While reviewing your code, it seems that you miss some init stuff :)

Code: Select all

SifLoadModule&#40;"rom0&#58;SIO2MAN", 0, NULL&#41;;
SifLoadModule&#40;"rom0&#58;PADMAN", 0, NULL&#41;;
this will load the PADMAN irx from rom, as you need it if you use the pad.

Check the pad examples in the sdk for proper usage :
\ps2sdk\samples\rpc\pad\pad.c

[EDIT2]

also, this is wrong :

Code: Select all

char *padBuf = padBuf = &#40;char *&#41;malloc&#40;256&#41;; 
padBuf must be 64 aligned, so it's better to use :

Code: Select all

static char padBuf&#91;256&#93; __attribute__&#40;&#40;aligned&#40;64&#41;&#41;&#41;;
or if you need dynamic allocation

Code: Select all

char *padBuf = &#40;char *&#41;memalign&#40;64, 256&#41;; 
SSpeare
Posts: 63
Joined: Tue May 23, 2006 11:45 pm
Contact:

Post by SSpeare »

What evilo said...

and, you should make sure you are booting the latest version of ps2link (1.46 I think?) because older versions have issues with xpadman and other issues in general.
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

Post by Kojima »

Thanks for the quick reply, I'll give it a go now.

Edit - Didn't see the pad examples, bah been waiting four hours for the site to come back online and i had an example there all along. PC Folder Names 1 - 0 Kojima.

Edit 2 - Works fine now, thanks.
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

Post by Kojima »

Are there any examples for the pressure sensitive buttons?

I can probably work it out from the headers files but it'll be nice to have something to work from.
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

Post by Kojima »

Ah run into a bit of trouble. I have joypad reading going ok based on the joypad demo, but it appears to be a ButtonHit type of usage not buttonDown.

Code: Select all


void ReadPad&#40;&#41;
&#123;
	int ret;
	int port = 0,slot =0;
	
	ret = padRead&#40;port, slot, &buttons&#41;;	
	if &#40;ret != 0&#41; &#123;
            paddata = 0xffff ^ buttons.btns;
                
            new_pad = paddata & ~old_pad;
            old_pad = paddata;
                
            // Directions
            if&#40;new_pad & PAD_LEFT&#41; &#123;
                printf&#40;"LEFT\n"&#41;;
            &#125;
            if&#40;new_pad & PAD_DOWN&#41; &#123;
                printf&#40;"DOWN\n"&#41;;
            &#125;
            if&#40;new_pad & PAD_RIGHT&#41; &#123;
                printf&#40;"RIGHT\n"&#41;;
            &#125;
            if&#40;new_pad & PAD_UP&#41; &#123;
                printf&#40;"UP\n"&#41;;
            &#125;
            if&#40;new_pad & PAD_START&#41; &#123;
                printf&#40;"START\n"&#41;;
            &#125;
            if&#40;new_pad & PAD_R3&#41; &#123;
                printf&#40;"R3\n"&#41;;
            &#125;
            if&#40;new_pad & PAD_L3&#41; &#123;
                printf&#40;"L3\n"&#41;;
            &#125;
            if&#40;new_pad & PAD_SELECT&#41; &#123;
                printf&#40;"SELECT\n"&#41;;
            &#125;
            if&#40;new_pad & PAD_SQUARE&#41; &#123;
                printf&#40;"SQUARE\n"&#41;;
            &#125;
            if&#40;new_pad & PAD_CROSS&#41; &#123;
              
                printf&#40;"CROSS - Enter press mode\n"&#41;;
            &#125;
            if&#40;new_pad & PAD_CIRCLE&#41; &#123;
             
                printf&#40;"CIRCLE - Exit press mode\n"&#41;;
            &#125;
            if&#40;new_pad & PAD_TRIANGLE&#41; &#123;
                // Check for the reason below..
                printf&#40;"TRIANGLE &#40;press mode disabled, see code&#41;\n"&#41;;
            &#125;
            if&#40;new_pad & PAD_R1&#41; &#123;
          
                printf&#40;"R1 - Start little engine\n"&#41;;
            &#125;
            if&#40;new_pad & PAD_L1&#41; &#123;
                     
                printf&#40;"L1 - Stop little engine\n"&#41;;
            &#125;
            if&#40;new_pad & PAD_R2&#41; &#123;
                printf&#40;"R2\n"&#41;;
            &#125;
            if&#40;new_pad & PAD_L2&#41; &#123;
                printf&#40;"L2\n"&#41;;
            &#125;
         
        &#125; 
&#125;
So my question is, is there a way to check if a button is being pushed, or is there a counterpart to the above that indicates when the button has been released?
User avatar
Drakonite
Site Admin
Posts: 990
Joined: Sat Jan 17, 2004 1:30 am
Contact:

Post by Drakonite »

Uhm... The pad example shows how to do pressure sensitive stuff...
Shoot Pixels Not People!
Makeshift Development
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

Post by Kojima »

Not unless it's that new invisible code I've been hearing about it doesn't.
User avatar
Drakonite
Site Admin
Posts: 990
Joined: Sat Jan 17, 2004 1:30 am
Contact:

Post by Drakonite »

...try running the sample and pressing cross, then pressing triangle...
Shoot Pixels Not People!
Makeshift Development
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

Post by Kojima »

I see it now. Was a bit cryptic without running the demo.
User avatar
Drakonite
Site Admin
Posts: 990
Joined: Sat Jan 17, 2004 1:30 am
Contact:

Post by Drakonite »

Nice invible code eh? ;)
kojima wrote:So my question is, is there a way to check if a button is being pushed, or is there a counterpart to the above that indicates when the button has been released?
I was going to explain how this all works.. but you can just figure it out.. to be nice, here is a quick example for catching button releases (though you should really be trapping button presses...)

Change:

Code: Select all

            paddata = 0xffff ^ buttons.btns;

            new_pad = paddata & ~old_pad;
            old_pad = paddata;
to:

Code: Select all

            old_pad = paddata;
            paddata = 0xffff ^ buttons.btns;
            new_pad = paddata & ~old_pad;
            pad_release = ~paddata & old_pad;
You'll also need to define pad_release where you define old_pad (same type). Then you can just use pad_release the same way new_pad is being used to detect when buttons are released... Though really, it's not that useful IMO. Typically you either just want to know if the pad was just pressed (new_pad) or if it is in an up or down state (paddata).
Shoot Pixels Not People!
Makeshift Development
SSpeare
Posts: 63
Joined: Tue May 23, 2006 11:45 pm
Contact:

Post by SSpeare »

To test whether a button is down or up just look at paddata instead of new_pad. Pressure sensitivitly is handled differently and is included in the sample, as mentioned before.
User avatar
Drakonite
Site Admin
Posts: 990
Joined: Sat Jan 17, 2004 1:30 am
Contact:

Post by Drakonite »

Oh, heh. I misread a bit. I thought you ONLY wanted to know how to detect a button's release... I didn't realize you were asking only as a backup to how to see if a button is in up or down state :)
Shoot Pixels Not People!
Makeshift Development
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

Post by Kojima »

Hah so you *are* only human afterall :)

Thanks both of ya, I get it now, now i can get back to Pong And Chong,
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

Post by Kojima »

Should this work or is a problem being caused by my older version of ps2link? I'm trying to read the amount a button is being pushed down by.

I call padEnterPressMode(0,0); straight initializing the joypad.

Code: Select all

void ReadPad&#40;&#41;
&#123;
	int ret;
	int port = 0,slot =0;
	but_square=0;
	but_triangle=0;
	but_circle=0;
	but_cross=0;
	but_l1=0;
	but_l2=0;
	but_r1=0;
	but_r2=0;
	but_select=0;
	but_start=0;
	but_l3=0;
	but_r3=0;
	
	ret = padRead&#40;port, slot, &buttons&#41;;	
	if &#40;ret != 0&#41; &#123;
            paddata = 0xffff ^ buttons.btns;
                
            new_pad = paddata;//'paddata & ~old_pad;
            old_pad = paddata;
                             
            // Directions
            if&#40;new_pad & PAD_LEFT&#41; &#123;
                joy_hx = -1;
            &#125;
            if&#40;new_pad & PAD_DOWN&#41; &#123;
                joy_hy = 1;
            &#125;
            if&#40;new_pad & PAD_RIGHT&#41; &#123;
                joy_hx = 1;
            &#125;
            if&#40;new_pad & PAD_UP&#41; &#123;
                joy_hy = 1;
            &#125;
            if&#40;new_pad & PAD_START&#41; &#123;
                but_start = 1;
            &#125;
            if&#40;new_pad & PAD_R3&#41; &#123;
                but_r3 = 1;
            &#125;
            if&#40;new_pad & PAD_L3&#41; &#123;
                but_l3 = 1;
            &#125;
            if&#40;new_pad & PAD_SELECT&#41; &#123;
             		but_select = 1; 
             &#125;
            if&#40;new_pad & PAD_SQUARE&#41; &#123;
                but_square = 1;
            &#125;
            if&#40;new_pad & PAD_CROSS&#41; &#123;
              
                but_cross = 1;
            &#125;
            if&#40;new_pad & PAD_CIRCLE&#41; &#123;
             
                but_circle = 1;
            &#125;
            if&#40;new_pad & PAD_TRIANGLE&#41; &#123;
                but_triangle = 1;
            &#125;
            if&#40;new_pad & PAD_R1&#41; &#123;
          
                but_r1 = 1;
            &#125;
            if&#40;new_pad & PAD_L1&#41; &#123;
                     
                but_l1 = 1;
            &#125;
            if&#40;new_pad & PAD_R2&#41; &#123;
                but_r2 = 1;
            &#125;
            if&#40;new_pad & PAD_L2&#41; &#123;
                but_l2 = 1;
            &#125;
            but_crossp = buttons.cross_p;
            but_squarep = buttons.square_p;
            but_circlep = buttons.circle_p;
            but_trianglep = buttons.triangle_p;
            but_l1p = buttons.l1_p;
            but_r1p = buttons.r1_p;
            but_l2p = buttons.l2_p;
            but_r2p = buttons.r2_p;
      			joy_hx -= buttons.left_p;
      			joy_hx += buttons.right_p;
      			joy_hy -= buttons.up_p;
      			joy_hy += buttons.down_p;
      			               
        &#125; 
&#125;
I then use this to print out the cross buttons pressure value as the demo does,

Code: Select all

printf&#40;"Cross&#58; %d \n",but_crossp&#41;;
but it's always zero. The rest works, all buttons register so the padman module appears to have loaded ok.

Edit - And the pressure senstive buttons on the hat work fine, so it's just the err...action buttons.
Last edited by Kojima on Sat Jul 01, 2006 4:19 am, edited 1 time in total.
User avatar
Drakonite
Site Admin
Posts: 990
Joined: Sat Jan 17, 2004 1:30 am
Contact:

Post by Drakonite »

Code: Select all

            paddata = 0xffff ^ buttons.btns;
                
            new_pad = paddata;//'paddata & ~old_pad;
            old_pad = paddata;

Don't do that. Leave it how it was. (Or optionally put the 'old_pad = paddata' before the 'paddata =' line)
If you want to check the up/down state, just check against paddata. Don't screw with how new_pad is generated, as it'll just get ugly ;P

As I said before.. check against paddata to get the up/down state. Check against new_pad to check if a button was just pressed.

There isn't enough code there to figure out what is wrong. Chances are your init is screwed up.
Shoot Pixels Not People!
Makeshift Development
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

Post by Kojima »

As for oldpad new pad ; it's just a piece of test code while I learn the ropes. Once i know what i need to know to begin writing proper i'll be switching to C++(if it's not buggy, havn't tried it yet) and using classes/enums/etc up the ying-yang.

edit - it's working for all buttons now, dunno how i fixed it. luck virus.
Last edited by Kojima on Sat Jul 01, 2006 4:27 am, edited 1 time in total.
User avatar
Drakonite
Site Admin
Posts: 990
Joined: Sat Jan 17, 2004 1:30 am
Contact:

Post by Drakonite »

Sounds painful.
Shoot Pixels Not People!
Makeshift Development
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

Post by Kojima »

oh well just do what you normally do. ban it. :)
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

Post by Kojima »

well C lasted long, got about ten minutes into the game proper before I needed C++, so I made the switch.
But now a wierd error occurs. well it's not new, C *warned* me about it, but C++ goes a step further and calls it a critical error.

it says SifInitRpc() and SifLoadModule() are undeclared.
I've just spent 10 mins searching for the definition/header file but can't find it.
Is it just incompatible with the C++ version?(Hence sounds painful?)
SSpeare
Posts: 63
Joined: Tue May 23, 2006 11:45 pm
Contact:

Post by SSpeare »

$ grep -R SifInitRpc *
common/include/sifrpc.h:void SifInitRpc(int mode);

#include <sifrpc.h>

Come on Kojima!

You could also just write the prototype yourself at the top of the C++ or C file. As long as it gets linked properly then it will resolve properly.

Don't forget to put

extern "C" {
}

around any C prototypes or definitions that you are using from C++. Otherwise C++ will mangle the function names differently than C and you will get linker errors.
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

Post by Kojima »

Edit - Ok got it compiling, but now, when I run the app instead of reseting res etc, the two quads i draw are offseted into the middle of the screen and the ps2link console output stays on the screen. totally unsable.
Anyone run into this before?

-Edit- I deleted the init screen function in rush to get it working in C++.........
Post Reply