netdialog problem

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
pspflashsystem
Posts: 31
Joined: Mon Mar 24, 2008 12:31 am

netdialog problem

Post by pspflashsystem »

Hello everyone,
I have a problem with tne netdialog.c: I can't compile it...
Here the netdialog.c:

Code: Select all

/*
 * PSP Software Development Kit - http://www.pspdev.org
 * -----------------------------------------------------------------------
 * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
 *
 * main.c - Net dialog sample for connecting to an access point
 *
 * For OE firmwares, this sample must be run under the 3.xx kernel.
 *
 * Copyright (c) 2007 David Perry (Insert_Witty_Name)
 *
 */

#include <pspkernel.h>
#include <pspdisplay.h>
#include <string.h>
#include <math.h>
#include <psputility.h>
#include <pspgu.h>
#include <pspgum.h>
#include <pspsdk.h>
#include <pspnet.h>
#include <pspnet_inet.h>
#include <pspnet_apctl.h>

/*
#if _PSP_FW_VERSION >= 200
PSP_MODULE_INFO&#40;"Net Dialog Sample", 0, 1, 1&#41;;
#else
PSP_MODULE_INFO&#40;"Net Dialog Sample", 0x1000, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;0&#41;;
#endif
*/

static int running = 1;

/* Exit callback */
int exit_callback&#40;int arg1, int arg2, void *common&#41;
&#123;
	quit&#40;&#41;;
	return 0;
&#125;

/* Callback thread */
int CallbackThread&#40;SceSize args, void *argp&#41;
&#123;
	int cbid;
	cbid = sceKernelCreateCallback&#40;"Exit Callback", exit_callback, NULL&#41;;
	sceKernelRegisterExitCallback&#40;cbid&#41;;
	sceKernelSleepThreadCB&#40;&#41;;
	
	return 0;
&#125;

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks&#40;void&#41;
&#123;
	int thid = 0;
	thid = sceKernelCreateThread&#40;"update_thread", CallbackThread, 0x11, 0xFA0, PSP_THREAD_ATTR_USER, 0&#41;;

	if &#40;thid >= 0&#41;
		sceKernelStartThread&#40;thid, 0, 0&#41;;

	return thid;
&#125;

/* Graphics stuff, based on cube sample */
static unsigned int __attribute__&#40;&#40;aligned&#40;16&#41;&#41;&#41; list&#91;262144&#93;;

/*
struct Vertex
&#123;
	unsigned int color;
	float x,y,z;
&#125;;

struct Vertex __attribute__&#40;&#40;aligned&#40;16&#41;&#41;&#41; vertices&#91;12*3&#93; =
&#123;
    	&#123;0xff7f0000,-1,-1, 1&#125;, // 0
    	&#123;0xff7f0000,-1, 1, 1&#125;, // 4
    	&#123;0xff7f0000, 1, 1, 1&#125;, // 5

    	&#123;0xff7f0000,-1,-1, 1&#125;, // 0
    	&#123;0xff7f0000, 1, 1, 1&#125;, // 5
    	&#123;0xff7f0000, 1,-1, 1&#125;, // 1

    	&#123;0xff7f0000,-1,-1,-1&#125;, // 3
    	&#123;0xff7f0000, 1,-1,-1&#125;, // 2
    	&#123;0xff7f0000, 1, 1,-1&#125;, // 6

    	&#123;0xff7f0000,-1,-1,-1&#125;, // 3
    	&#123;0xff7f0000, 1, 1,-1&#125;, // 6
    	&#123;0xff7f0000,-1, 1,-1&#125;, // 7

    	&#123;0xff007f00, 1,-1,-1&#125;, // 0
    	&#123;0xff007f00, 1,-1, 1&#125;, // 3
    	&#123;0xff007f00, 1, 1, 1&#125;, // 7

    	&#123;0xff007f00, 1,-1,-1&#125;, // 0
    	&#123;0xff007f00, 1, 1, 1&#125;, // 7
    	&#123;0xff007f00, 1, 1,-1&#125;, // 4

    	&#123;0xff007f00,-1,-1,-1&#125;, // 0
    	&#123;0xff007f00,-1, 1,-1&#125;, // 3
    	&#123;0xff007f00,-1, 1, 1&#125;, // 7

    	&#123;0xff007f00,-1,-1,-1&#125;, // 0
    	&#123;0xff007f00,-1, 1, 1&#125;, // 7
    	&#123;0xff007f00,-1,-1, 1&#125;, // 4

    	&#123;0xff00007f,-1, 1,-1&#125;, // 0
    	&#123;0xff00007f, 1, 1,-1&#125;, // 1
    	&#123;0xff00007f, 1, 1, 1&#125;, // 2

    	&#123;0xff00007f,-1, 1,-1&#125;, // 0
    	&#123;0xff00007f, 1, 1, 1&#125;, // 2
    	&#123;0xff00007f,-1, 1, 1&#125;, // 3

    	&#123;0xff00007f,-1,-1,-1&#125;, // 4
    	&#123;0xff00007f,-1,-1, 1&#125;, // 7
    	&#123;0xff00007f, 1,-1, 1&#125;, // 6

    	&#123;0xff00007f,-1,-1,-1&#125;, // 4
    	&#123;0xff00007f, 1,-1, 1&#125;, // 6
    	&#123;0xff00007f, 1,-1,-1&#125;, // 5
&#125;;
*/

#define BUF_WIDTH &#40;512&#41;
#define SCR_WIDTH &#40;480&#41;
#define SCR_HEIGHT &#40;272&#41;
#define PIXEL_SIZE &#40;4&#41;
#define FRAME_SIZE &#40;BUF_WIDTH * SCR_HEIGHT * PIXEL_SIZE&#41;
#define ZBUF_SIZE &#40;BUF_WIDTH SCR_HEIGHT * 2&#41;

static void setupGu&#40;&#41;
&#123;
    	sceGuInit&#40;&#41;;

    	sceGuStart&#40;GU_DIRECT,list&#41;;
    	sceGuDrawBuffer&#40;GU_PSM_8888,&#40;void*&#41;0,BUF_WIDTH&#41;;
    	sceGuDispBuffer&#40;SCR_WIDTH,SCR_HEIGHT,&#40;void*&#41;0x88000,BUF_WIDTH&#41;;
    	sceGuDepthBuffer&#40;&#40;void*&#41;0x110000,BUF_WIDTH&#41;;
    	sceGuOffset&#40;2048 - &#40;SCR_WIDTH/2&#41;,2048 - &#40;SCR_HEIGHT/2&#41;&#41;;
    	sceGuViewport&#40;2048,2048,SCR_WIDTH,SCR_HEIGHT&#41;;
    	sceGuDepthRange&#40;0xc350,0x2710&#41;;
    	sceGuScissor&#40;0,0,SCR_WIDTH,SCR_HEIGHT&#41;;
    	sceGuEnable&#40;GU_SCISSOR_TEST&#41;;
    	sceGuDepthFunc&#40;GU_GEQUAL&#41;;
    	sceGuEnable&#40;GU_DEPTH_TEST&#41;;
    	sceGuFrontFace&#40;GU_CW&#41;;
    	sceGuShadeModel&#40;GU_SMOOTH&#41;;
    	sceGuEnable&#40;GU_CULL_FACE&#41;;
    	sceGuEnable&#40;GU_CLIP_PLANES&#41;;
    	sceGuFinish&#40;&#41;;
    	sceGuSync&#40;0,0&#41;;

    	sceDisplayWaitVblankStart&#40;&#41;;
    	sceGuDisplay&#40;GU_TRUE&#41;;
&#125;

static void drawStuff&#40;void&#41;
&#123;
	static int val = 0;

	sceGuStart&#40;GU_DIRECT, list&#41;;

	sceGuClearColor&#40;0xff554433&#41;;
	sceGuClearDepth&#40;0&#41;;
	sceGuClear&#40;GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT&#41;;

	sceGumMatrixMode&#40;GU_PROJECTION&#41;;
	sceGumLoadIdentity&#40;&#41;;
	sceGumPerspective&#40;75.0f,16.0f/9.0f,0.5f,1000.0f&#41;;
	   
	sceGumMatrixMode&#40;GU_VIEW&#41;;
	sceGumLoadIdentity&#40;&#41;;
	
	sceGumMatrixMode&#40;GU_MODEL&#41;;
	sceGumLoadIdentity&#40;&#41;;
	    
	ScePspFVector3 pos = &#123; 0, 0, -5.0f &#125;;
	ScePspFVector3 rot = &#123; val * 0.79f * &#40;M_PI/180.0f&#41;, val * 0.98f * &#40;M_PI/180.0f&#41;, val * 1.32f * &#40;M_PI/180.0f&#41; &#125;;
	sceGumTranslate&#40;&pos&#41;;
	sceGumRotateXYZ&#40;&rot&#41;;

	//sceGumDrawArray&#40;GU_TRIANGLES, GU_COLOR_8888|GU_VERTEX_32BITF|GU_TRANSFORM_3D, 12*3, 0, vertices&#41;;

	sceGuFinish&#40;&#41;;
	sceGuSync&#40;0,0&#41;;
	
	val++;
&#125;

int netDialog&#40;&#41;
&#123;
	int done = 0;

   	pspUtilityNetconfData data;

	memset&#40;&data, 0, sizeof&#40;data&#41;&#41;;
	data.base.size = sizeof&#40;data&#41;;
	data.base.language = PSP_SYSTEMPARAM_LANGUAGE_ENGLISH;
	data.base.buttonSwap = PSP_UTILITY_ACCEPT_CROSS;
	data.base.graphicsThread = 17;
	data.base.accessThread = 19;
	data.base.fontThread = 18;
	data.base.soundThread = 16;
	data.action = PSP_NETCONF_ACTION_CONNECTAP;
	
	struct pspUtilityNetconfAdhoc adhocparam;
	memset&#40;&adhocparam, 0, sizeof&#40;adhocparam&#41;&#41;;
	data.adhocparam = &adhocparam;

	sceUtilityNetconfInitStart&#40;&data&#41;;
	
	while&#40;running&#41;
	&#123;
		drawStuff&#40;&#41;;

		switch&#40;sceUtilityNetconfGetStatus&#40;&#41;&#41;
		&#123;
			case PSP_UTILITY_DIALOG_NONE&#58;
				break;

			case PSP_UTILITY_DIALOG_VISIBLE&#58;
				sceUtilityNetconfUpdate&#40;1&#41;;
				break;

			case PSP_UTILITY_DIALOG_QUIT&#58;
				sceUtilityNetconfShutdownStart&#40;&#41;;
				break;
				
			case PSP_UTILITY_DIALOG_FINISHED&#58;
				done = 1;
				break;

			default&#58;
				break;
		&#125;

		sceDisplayWaitVblankStart&#40;&#41;;
		sceGuSwapBuffers&#40;&#41;;
		
		if&#40;done&#41;
			break;
	&#125;
	
	return 1;
&#125;

void netInit&#40;void&#41;
&#123;
	sceNetInit&#40;128*1024, 42, 4*1024, 42, 4*1024&#41;;
	
	sceNetInetInit&#40;&#41;;
	
	sceNetApctlInit&#40;0x8000, 48&#41;;
&#125;

void netTerm&#40;void&#41;
&#123;
	sceNetApctlTerm&#40;&#41;;
	
	sceNetInetTerm&#40;&#41;;
	
	sceNetTerm&#40;&#41;;
&#125;

int user_thread&#40;SceSize args, void *argp&#41;
&#123;
	netInit&#40;&#41;;
	
	SetupCallbacks&#40;&#41;;
	
	setupGu&#40;&#41;;

	netDialog&#40;&#41;;
	
	netTerm&#40;&#41;;
	
	return 0;
&#125;


int main&#40;int argc, char *argv&#91;&#93;&#41;
&#123;
	#if _PSP_FW_VERSION >= 200
	sceUtilityLoadNetModule&#40;PSP_NET_MODULE_COMMON&#41;;

	sceUtilityLoadNetModule&#40;PSP_NET_MODULE_INET&#41;;
	
	netInit&#40;&#41;;
	
	SetupCallbacks&#40;&#41;;
	
	setupGu&#40;&#41;;

	netDialog&#40;&#41;;
	
	netTerm&#40;&#41;;

	#else

	pspSdkLoadInetModules&#40;&#41;;

	SceUID thid = sceKernelCreateThread&#40;"user_thread", user_thread, 0x18, 0x10000, PSP_THREAD_ATTR_USER, NULL&#41;;

	sceKernelStartThread&#40;thid, 0, NULL&#41;;
	
	sceKernelWaitThreadEnd&#40;thid, 0&#41;;
	#endif
	
	sceKernelExitGame&#40;&#41;;

	return 0;
&#125;
And here the makefile:

Code: Select all

TARGET = net
OBJS = netdialog.o

PSP_FW_VERSION = 371

INCDIR = 
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $&#40;CFLAGS&#41; -fno-exceptions -fno-rtti
ASFLAGS = $&#40;CFLAGS&#41;
PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
PSPBIN = $&#40;PSPSDK&#41;/../bin


LIBDIR =

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = net

LIBDIR =
LDFLAGS =
STDLIBS= -lc -lSDL_image -lSDL_gfx -lSDL_ttf -lpng -ljpeg -lSDL -lcurl -lfreetype
LIBS=$&#40;STDLIBS&#41;-lpspwlan -lpsputility -lpspgum -lpspgu -lm -lpspnet -lpspkernel -lpspnet_inet -lpspnet_apctl

include $&#40;PSPSDK&#41;/lib/build.mak
Here a screenshot of the problem:
Image

Thank you ^^
I'm apologize for my bad English because I am French :)

.::pspflashsystem::.
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

Looks like your pre-compiled toolchain is an old version before I added the netdialog sample (and all the backend stuff that goes with it).
pspflashsystem
Posts: 31
Joined: Mon Mar 24, 2008 12:31 am

Post by pspflashsystem »

Ok thank you Insert_witty_name..
i will install the latest toolchain^^
I'm apologize for my bad English because I am French :)

.::pspflashsystem::.
Post Reply