mirror of
https://github.com/pspdev/pspsdk.git
synced 2025-12-19 10:27:23 +00:00
Merge branch 'master' into update-gitignore
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -36,5 +36,7 @@ install-sh
|
|||||||
missing
|
missing
|
||||||
src/base/linkfile.prx
|
src/base/linkfile.prx
|
||||||
stamp-h1
|
stamp-h1
|
||||||
|
.clang-format
|
||||||
|
compile_flags.txt
|
||||||
EBOOT.PBP
|
EBOOT.PBP
|
||||||
PARAM.SFO
|
PARAM.SFO
|
||||||
|
|||||||
@@ -169,6 +169,22 @@ struct sockaddr {
|
|||||||
char sa_data[14]; /* actually longer; address value */
|
char sa_data[14]; /* actually longer; address value */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* RFC 2553: protocol-independent placeholder for socket addresses
|
||||||
|
*/
|
||||||
|
#define _SS_MAXSIZE 128
|
||||||
|
#define _SS_ALIGNSIZE (sizeof(int64_t))
|
||||||
|
#define _SS_PAD1SIZE (_SS_ALIGNSIZE - 2)
|
||||||
|
#define _SS_PAD2SIZE (_SS_MAXSIZE - 2 - _SS_PAD1SIZE - _SS_ALIGNSIZE)
|
||||||
|
|
||||||
|
struct sockaddr_storage {
|
||||||
|
uint8_t ss_len; /* address length */
|
||||||
|
sa_family_t ss_family; /* address family */
|
||||||
|
char __ss_pad1[_SS_PAD1SIZE];
|
||||||
|
int64_t __ss_align;/* force desired structure storage alignment */
|
||||||
|
char __ss_pad2[_SS_PAD2SIZE];
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Protocol families, same as address families for now.
|
* Protocol families, same as address families for now.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -77,14 +77,14 @@ struct Vertex __attribute__((aligned(16))) vertices[12*3] =
|
|||||||
|
|
||||||
int done = 0;
|
int done = 0;
|
||||||
/* Exit callback */
|
/* Exit callback */
|
||||||
int exit_callback(void)
|
int exit_callback(int arg1, int arg2, void *common)
|
||||||
{
|
{
|
||||||
done = 1;
|
done = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Callback thread */
|
/* Callback thread */
|
||||||
void CallbackThread(void *arg)
|
int CallbackThread(SceSize args, void *arg)
|
||||||
{
|
{
|
||||||
int cbid;
|
int cbid;
|
||||||
|
|
||||||
@@ -92,6 +92,7 @@ void CallbackThread(void *arg)
|
|||||||
sceKernelRegisterExitCallback(cbid);
|
sceKernelRegisterExitCallback(cbid);
|
||||||
|
|
||||||
sceKernelSleepThreadCB();
|
sceKernelSleepThreadCB();
|
||||||
|
return cbid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sets up the callback thread and returns its thread id */
|
/* Sets up the callback thread and returns its thread id */
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include <pspgu.h>
|
#include <pspgu.h>
|
||||||
#include <pspgum.h>
|
#include <pspgum.h>
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
#include "mt19937.h"
|
#include "mt19937.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -31,7 +32,7 @@
|
|||||||
|
|
||||||
float shift23=(float)(1<<23);
|
float shift23=(float)(1<<23);
|
||||||
float OOshift23=1.0f/(float)(1<<23);
|
float OOshift23=1.0f/(float)(1<<23);
|
||||||
static inline float floorf(float i)
|
inline float floorf(float i)
|
||||||
{ // return largest integer that is less than or equal to i
|
{ // return largest integer that is less than or equal to i
|
||||||
float k = (float)((int) i);
|
float k = (float)((int) i);
|
||||||
if (k <= i)
|
if (k <= i)
|
||||||
|
|||||||
@@ -60,8 +60,8 @@ int SetupCallbacks(void)
|
|||||||
|
|
||||||
|
|
||||||
// Input and Output buffers
|
// Input and Output buffers
|
||||||
char mp3Buf[16*1024] __attribute__((aligned(64)));
|
unsigned char mp3Buf[16*1024] __attribute__((aligned(64)));
|
||||||
short pcmBuf[16*(1152/2)] __attribute__((aligned(64)));
|
unsigned char pcmBuf[16*(1152/2)] __attribute__((aligned(64)));
|
||||||
|
|
||||||
|
|
||||||
// Macro to allow formatted input without having to use stdargs.h
|
// Macro to allow formatted input without having to use stdargs.h
|
||||||
@@ -87,9 +87,9 @@ void error( char* msg )
|
|||||||
|
|
||||||
int fillStreamBuffer( int fd, int handle )
|
int fillStreamBuffer( int fd, int handle )
|
||||||
{
|
{
|
||||||
char* dst;
|
unsigned char* dst;
|
||||||
int write;
|
long int write;
|
||||||
int pos;
|
long int pos;
|
||||||
// Get Info on the stream (where to fill to, how much to fill, where to fill from)
|
// Get Info on the stream (where to fill to, how much to fill, where to fill from)
|
||||||
int status = sceMp3GetInfoToAddStreamData( handle, &dst, &write, &pos);
|
int status = sceMp3GetInfoToAddStreamData( handle, &dst, &write, &pos);
|
||||||
if (status<0)
|
if (status<0)
|
||||||
@@ -208,7 +208,7 @@ int main(int argc, char *argv[])
|
|||||||
printf("PSP Mp3 Sample v1.0 by Raphael\n\n");
|
printf("PSP Mp3 Sample v1.0 by Raphael\n\n");
|
||||||
printf("Playing '%s'...\n", MP3FILE);
|
printf("Playing '%s'...\n", MP3FILE);
|
||||||
printf(" %i Hz\n", samplingRate);
|
printf(" %i Hz\n", samplingRate);
|
||||||
printf(" %i kbit/s\n", sceMp3GetBitRate( handle ));
|
printf(" %li kbit/s\n", sceMp3GetBitRate( handle ));
|
||||||
printf(" %s\n", numChannels==2?"Stereo":"Mono");
|
printf(" %s\n", numChannels==2?"Stereo":"Mono");
|
||||||
printf(" %s\n\n", loop==0?"No loop":"Loop");
|
printf(" %s\n\n", loop==0?"No loop":"Loop");
|
||||||
int playTime = samplingRate>0?numPlayed / samplingRate:0;
|
int playTime = samplingRate>0?numPlayed / samplingRate:0;
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ int ReadIPLBlockTable(void *pBlockBuf)
|
|||||||
die("can't read IPL block table!");
|
die("can't read IPL block table!");
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Found IPL block table at block %d\n", uiBlockNum);
|
printf("Found IPL block table at block %ld\n", uiBlockNum);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,28 +9,25 @@
|
|||||||
* Some small parts (c) 2005 PSPPet
|
* Some small parts (c) 2005 PSPPet
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <pspkernel.h>
|
#include <pspkernel.h>
|
||||||
#include <pspdebug.h>
|
#include <pspnet_apctl.h>
|
||||||
#include <pspsdk.h>
|
#include <pspsdk.h>
|
||||||
#include <stdlib.h>
|
#include <psputility.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <pspnet.h>
|
|
||||||
#include <pspnet_inet.h>
|
|
||||||
#include <pspnet_apctl.h>
|
|
||||||
#include <pspnet_resolver.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include <sys/select.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#define printf pspDebugScreenPrintf
|
#define printf pspDebugScreenPrintf
|
||||||
|
|
||||||
#define MODULE_NAME "NetSample"
|
#define MODULE_NAME "NetSample"
|
||||||
#define HELLO_MSG "Hello there. Type away.\r\n"
|
#define HELLO_MSG "Hello there. Type away.\r\n"
|
||||||
|
|
||||||
PSP_MODULE_INFO(MODULE_NAME, 0x1000, 1, 1);
|
PSP_MODULE_INFO(MODULE_NAME, 0, 1, 1);
|
||||||
PSP_MAIN_THREAD_ATTR(0);
|
PSP_HEAP_THRESHOLD_SIZE_KB(1024);
|
||||||
|
PSP_HEAP_SIZE_KB(-2048);
|
||||||
|
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);
|
||||||
|
PSP_MAIN_THREAD_STACK_SIZE_KB(1024);
|
||||||
|
|
||||||
/* Exit callback */
|
/* Exit callback */
|
||||||
int exit_callback(int arg1, int arg2, void *common)
|
int exit_callback(int arg1, int arg2, void *common)
|
||||||
@@ -56,9 +53,9 @@ int SetupCallbacks(void)
|
|||||||
{
|
{
|
||||||
int thid = 0;
|
int thid = 0;
|
||||||
|
|
||||||
thid = sceKernelCreateThread("update_thread", CallbackThread,
|
thid =
|
||||||
0x11, 0xFA0, PSP_THREAD_ATTR_USER, 0);
|
sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, PSP_THREAD_ATTR_USER, 0);
|
||||||
if(thid >= 0)
|
if (thid >= 0)
|
||||||
{
|
{
|
||||||
sceKernelStartThread(thid, 0, 0);
|
sceKernelStartThread(thid, 0, 0);
|
||||||
}
|
}
|
||||||
@@ -75,7 +72,7 @@ int make_socket(uint16_t port)
|
|||||||
struct sockaddr_in name;
|
struct sockaddr_in name;
|
||||||
|
|
||||||
sock = socket(PF_INET, SOCK_STREAM, 0);
|
sock = socket(PF_INET, SOCK_STREAM, 0);
|
||||||
if(sock < 0)
|
if (sock < 0)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -83,8 +80,8 @@ int make_socket(uint16_t port)
|
|||||||
name.sin_family = AF_INET;
|
name.sin_family = AF_INET;
|
||||||
name.sin_port = htons(port);
|
name.sin_port = htons(port);
|
||||||
name.sin_addr.s_addr = htonl(INADDR_ANY);
|
name.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||||
ret = bind(sock, (struct sockaddr *) &name, sizeof(name));
|
ret = bind(sock, (struct sockaddr *)&name, sizeof(name));
|
||||||
if(ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -99,7 +96,7 @@ void start_server(const char *szIpAddr)
|
|||||||
int sock;
|
int sock;
|
||||||
int new = -1;
|
int new = -1;
|
||||||
struct sockaddr_in client;
|
struct sockaddr_in client;
|
||||||
size_t size;
|
long unsigned int size;
|
||||||
int readbytes;
|
int readbytes;
|
||||||
char data[1024];
|
char data[1024];
|
||||||
fd_set set;
|
fd_set set;
|
||||||
@@ -107,14 +104,14 @@ void start_server(const char *szIpAddr)
|
|||||||
|
|
||||||
/* Create a socket for listening */
|
/* Create a socket for listening */
|
||||||
sock = make_socket(SERVER_PORT);
|
sock = make_socket(SERVER_PORT);
|
||||||
if(sock < 0)
|
if (sock < 0)
|
||||||
{
|
{
|
||||||
printf("Error creating server socket\n");
|
printf("Error creating server socket\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = listen(sock, 1);
|
ret = listen(sock, 1);
|
||||||
if(ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
printf("Error calling listen\n");
|
printf("Error calling listen\n");
|
||||||
return;
|
return;
|
||||||
@@ -126,34 +123,33 @@ void start_server(const char *szIpAddr)
|
|||||||
FD_SET(sock, &set);
|
FD_SET(sock, &set);
|
||||||
setsave = set;
|
setsave = set;
|
||||||
|
|
||||||
while(1)
|
while (1)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
set = setsave;
|
set = setsave;
|
||||||
if(select(FD_SETSIZE, &set, NULL, NULL, NULL) < 0)
|
if (select(FD_SETSIZE, &set, NULL, NULL, NULL) < 0)
|
||||||
{
|
{
|
||||||
printf("select error\n");
|
printf("select error\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < FD_SETSIZE; i++)
|
for (i = 0; i < FD_SETSIZE; i++)
|
||||||
{
|
{
|
||||||
if(FD_ISSET(i, &set))
|
if (FD_ISSET(i, &set))
|
||||||
{
|
{
|
||||||
int val = i;
|
int val = i;
|
||||||
|
|
||||||
if(val == sock)
|
if (val == sock)
|
||||||
{
|
{
|
||||||
new = accept(sock, (struct sockaddr *) &client, &size);
|
new = accept(sock, (struct sockaddr *)&client, &size);
|
||||||
if(new < 0)
|
if (new < 0)
|
||||||
{
|
{
|
||||||
printf("Error in accept %s\n", strerror(errno));
|
printf("Error in accept %s\n", strerror(errno));
|
||||||
close(sock);
|
close(sock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("New connection %d from %s:%d\n", val,
|
printf("New connection %d from %s:%d\n", val, inet_ntoa(client.sin_addr),
|
||||||
inet_ntoa(client.sin_addr),
|
|
||||||
ntohs(client.sin_port));
|
ntohs(client.sin_port));
|
||||||
|
|
||||||
write(new, HELLO_MSG, strlen(HELLO_MSG));
|
write(new, HELLO_MSG, strlen(HELLO_MSG));
|
||||||
@@ -163,7 +159,7 @@ void start_server(const char *szIpAddr)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
readbytes = read(val, data, sizeof(data));
|
readbytes = read(val, data, sizeof(data));
|
||||||
if(readbytes <= 0)
|
if (readbytes <= 0)
|
||||||
{
|
{
|
||||||
printf("Socket %d closed\n", val);
|
printf("Socket %d closed\n", val);
|
||||||
FD_CLR(val, &setsave);
|
FD_CLR(val, &setsave);
|
||||||
@@ -215,11 +211,11 @@ int connect_to_apctl(int config)
|
|||||||
break; // connected with static IP
|
break; // connected with static IP
|
||||||
|
|
||||||
// wait a little before polling again
|
// wait a little before polling again
|
||||||
sceKernelDelayThread(50*1000); // 50ms
|
sceKernelDelayThread(50 * 1000); // 50ms
|
||||||
}
|
}
|
||||||
printf(MODULE_NAME ": Connected!\n");
|
printf(MODULE_NAME ": Connected!\n");
|
||||||
|
|
||||||
if(err != 0)
|
if (err != 0)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -230,16 +226,15 @@ int connect_to_apctl(int config)
|
|||||||
int net_thread(SceSize args, void *argp)
|
int net_thread(SceSize args, void *argp)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if((err = pspSdkInetInit()))
|
if ((err = pspSdkInetInit()))
|
||||||
{
|
{
|
||||||
printf(MODULE_NAME ": Error, could not initialise the network %08X\n", err);
|
printf(MODULE_NAME ": Error, could not initialise the network %08X\n", err);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(connect_to_apctl(1))
|
if (connect_to_apctl(1))
|
||||||
{
|
{
|
||||||
// connected, get my IPADDR and run test
|
// connected, get my IPADDR and run test
|
||||||
union SceNetApctlInfo info;
|
union SceNetApctlInfo info;
|
||||||
@@ -249,12 +244,8 @@ int net_thread(SceSize args, void *argp)
|
|||||||
|
|
||||||
start_server(info.ip);
|
start_server(info.ip);
|
||||||
}
|
}
|
||||||
}
|
} while (0);
|
||||||
while(0);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Simple thread */
|
/* Simple thread */
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
@@ -262,17 +253,17 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
SetupCallbacks();
|
SetupCallbacks();
|
||||||
|
|
||||||
|
sceUtilityLoadNetModule(PSP_NET_MODULE_COMMON);
|
||||||
|
sceUtilityLoadNetModule(PSP_NET_MODULE_INET);
|
||||||
|
|
||||||
pspDebugScreenInit();
|
pspDebugScreenInit();
|
||||||
|
|
||||||
if(pspSdkLoadInetModules() < 0)
|
|
||||||
{
|
|
||||||
printf("Error, could not load inet modules\n");
|
|
||||||
sceKernelSleepThread();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Create a user thread to do the real work */
|
/* Create a user thread to do the real work */
|
||||||
thid = sceKernelCreateThread("net_thread", net_thread, 0x18, 0x10000, PSP_THREAD_ATTR_USER, NULL);
|
thid = sceKernelCreateThread("net_thread", net_thread,
|
||||||
if(thid < 0)
|
0x11, // default priority
|
||||||
|
256 * 1024, // stack size (256KB is regular default)
|
||||||
|
PSP_THREAD_ATTR_USER, NULL);
|
||||||
|
if (thid < 0)
|
||||||
{
|
{
|
||||||
printf("Error, could not create thread\n");
|
printf("Error, could not create thread\n");
|
||||||
sceKernelSleepThread();
|
sceKernelSleepThread();
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ void start_server(const char *szIpAddr)
|
|||||||
int sock;
|
int sock;
|
||||||
int new = -1;
|
int new = -1;
|
||||||
struct sockaddr_in client;
|
struct sockaddr_in client;
|
||||||
size_t size;
|
long unsigned int size;
|
||||||
int readbytes;
|
int readbytes;
|
||||||
char data[1024];
|
char data[1024];
|
||||||
fd_set set;
|
fd_set set;
|
||||||
|
|||||||
Reference in New Issue
Block a user