コード例 #1
0
ファイル: loader.c プロジェクト: dyzz/hdldumb
int
main (int argc,
      char *argv [])
{
  SifInitRpc (0);

  init_scr ();
  scr_printf (APP_NAME "-" VERSION "\n");

  /* decide whether to load TCP/IP or it is already loaded */
  SifExitIopHeap ();
  SifLoadFileExit ();
  SifExitRpc ();

  SifIopReset (NULL /* "rom0:UDNL rom0:EELOADCNF" */, 0);
  while (SifIopSync ())
    ;
  SifInitRpc (0);

  if (load_modules () == 0)
    {
      scr_printf ("Ready\n");
    }
  else
    scr_printf ("Failed to load\n");

  /* our job is done; IOP would handle the rest */
  SleepThread ();

  return (0);
}
コード例 #2
0
ファイル: cmdHandler.c プロジェクト: ps2dev/ps2link
int cmdHandlerInit(void)
{
    iop_thread_t thread;
    int pid;
    int ret;

    dbgprintf("IOP cmd: Starting thread\n");

    SifInitRpc(0);
    SetPowerButtonHandler(cmdPowerOff, NULL);

    thread.attr = 0x02000000;
    thread.option = 0;
    thread.thread = (void *)cmdThread;
    thread.stacksize = 0x800;
    thread.priority = 60; //0x1e;

    pid = CreateThread(&thread);
    if (pid >= 0) {
        ret = StartThread(pid, 0);
        if (ret < 0) {
            dbgprintf("IOP cmd: Could not start thread\n");
        }
    }
    else {
        dbgprintf("IOP cmd: Could not create thread\n");
    }
    return 0;
}
コード例 #3
0
ファイル: fileXio_iop.c プロジェクト: AKuHAK2/ps2sdk
void fileXio_Thread(void* param)
{
	int OldState;

	printf("fileXio: fileXio RPC Server v1.00\nCopyright (c) 2003 adresd\n");
	#ifdef DEBUG
		printf("fileXio: RPC Initialize\n");
	#endif

	SifInitRpc(0);

	RWBufferSize=DEFAULT_RWSIZE;
	CpuSuspendIntr(&OldState);
	rwbuf = AllocSysMemory(ALLOC_FIRST, RWBufferSize, NULL);
	CpuResumeIntr(OldState);
	if (rwbuf == NULL)
	{
		#ifdef DEBUG
  			printf("Failed to allocate memory for RW buffer!\n");
		#endif

		SleepThread();
	}

	SifSetRpcQueue(&qd, GetThreadId());
	SifRegisterRpc(&sd0, FILEXIO_IRX, &fileXio_rpc_server, fileXio_rpc_buffer, NULL, NULL, &qd);
	SifRpcLoop(&qd);
}
コード例 #4
0
ファイル: ntpbserver.c プロジェクト: effection/ps2rd
//-------------------------------------------------------------------------
int _start(int argc, char** argv)
{
	iop_sema_t smp;

	SifInitRpc(0);
#ifdef _NETLOG
	// init netlog
	netlog_init(0, SERVER_UDP_PORT);
	netlog_send("hello from debugger.irx\n");
#endif
	// Starting ntpbserver Remote Procedure Call server
	start_RPC_server();

	// Starting server thread
	start_ServerThread();

	smp.attr = 1;
	smp.initial = 1;
	smp.max = 1;
	smp.option = 0;
	ntpbserver_io_sema = CreateSema(&smp);

	smp.attr = 1;
	smp.initial = 0; // this sema is initialised to 0 !
	smp.max = 1;
	smp.option = 0;
	ntpbserver_cmd_sema = CreateSema(&smp);

	return MODULE_RESIDENT_END;
}
コード例 #5
0
ファイル: libcdvd.c プロジェクト: przemekh/ps2sdk
s32 sceCdSearchFile(sceCdlFILE * file, const char *name)
{
	s32 i;

	sceCdSemaInit();
	if (PollSema(nCmdSemaId) != nCmdSemaId)
		return 0;
	nCmdNum = CD_SERVER_SEARCHFILE;
	ReferThreadStatus(sceCdThreadId, &sceCdThreadParam);
	if (sceCdSync(1)) {
		SignalSema(nCmdSemaId);
		return 0;
	}
	SifInitRpc(0);
	if (bindSearchFile < 0) {
		while (1) {
			if (SifBindRpc(&clientSearchFile, CD_SERVER_SEARCHFILE, 0) < 0) {
				if (sceCdDebug > 0)
					printf("libsceCdvd bind err sceCdSearchFile\n");
			}
			if (clientSearchFile.server != 0)
				break;

			i = 0x10000;
			while (i--);
		}
		bindSearchFile = 0;
	}

	strncpy(searchFileSendBuff.name, name, 255);
	searchFileSendBuff.name[255] = '\0';
	searchFileSendBuff.dest = &searchFileSendBuff;

	if (sceCdDebug > 0)
		printf("ee call cmd search %s\n", searchFileSendBuff.name);
	if (SifCallRpc(&clientSearchFile, 0, 0, &searchFileSendBuff, sizeof(SearchFilePkt), nCmdRecvBuff, 4, 0, 0) < 0) {
		SignalSema(nCmdSemaId);
		return 0;
	}

	memcpy(file, UNCACHED_SEG(&searchFileSendBuff), 32);

	if (sceCdDebug > 0) {
		printf("search name %s\n", file->name);
		printf("search size %d\n", file->size);
		printf("search loc lnn %d\n", file->lsn);
		printf("search loc date %02X %02X %02X %02X %02X %02X %02X %02X\n",
		       file->date[0], file->date[1], file->date[2], file->date[3],
		       file->date[4], file->date[5], file->date[6], file->date[7]);
		printf("search loc date %02d %02d %02d %02d %02d %02d %02d %02d\n",
		       file->date[0], file->date[1], file->date[2], file->date[3],
		       file->date[4], file->date[5], file->date[6], file->date[7]);
	}

	SignalSema(nCmdSemaId);
//	return 1;
	return *(s32*)UNCACHED_SEG(nCmdRecvBuff);
}
コード例 #6
0
ファイル: rpc_server.c プロジェクト: scuriumk/ps2sdk
/** RPC listener thread
    @param arg   not used

    This is the main RPC thread. Nothing fancy here.
*/
static void rpc_server_thread(void *arg)
{
	SifInitRpc(0);

	printf("audsrv: creating rpc server\n");

	SifSetRpcQueue(&qd, GetThreadId());
	SifRegisterRpc(&sd0, AUDSRV_IRX, (void *)rpc_command, rpc_buffer, 0, 0, &qd);
	SifRpcLoop(&qd);
}
コード例 #7
0
ファイル: iopcontrol.c プロジェクト: EvertonSilva/ps2sdk
int SifIopReboot(const char* filename)
{
	char param_str[RESET_ARG_MAX+1];
	int param_size;

	if ((filename != NULL) && (*filename != '\0'))
	{
		param_size = strlen( filename ) + 11;

		if(param_size > RESET_ARG_MAX)
		{
//			printf("too long parameter '%s'\n", filename);
			return -1;
		}
	}

	SifInitRpc(0);

	if ((filename != NULL) && (*filename != '\0'))
	{
		strncpy(param_str, "rom0:UDNL ", 10);
	}
	else
	{
		strncpy(param_str, "rom0:UDNL", 9);
	}

	if ((filename != NULL) && (*filename != '\0'))
	{
		strncpy(&param_str[10], filename, strlen(filename));
	}

	SifIopReset(param_str, 0);
	while(!SifIopSync());

	SifInitRpc(0);

	FlushCache(0);
	FlushCache(2);

	return 0;
}
コード例 #8
0
ファイル: nprintf.c プロジェクト: AzagraMac/PS2_SDK
/*! \brief naplink compatbile RPC handler thread.
 *  \ingroup fakehost 
 *
 *  \param  arg Startup parameters.
 */
static void napThread(void *arg)
{
    int pid;

    SifInitRpc(0);
    pid = GetThreadId();
    SifSetRpcQueue(&queue, pid);
    SifRegisterRpc(&server, RPC_NPM_USER, naplinkRpcHandler,
                   rpc_buffer, 0, 0, &queue);
    SifRpcLoop(&queue);  // Never exits
    ExitDeleteThread();
}
コード例 #9
0
ファイル: file.c プロジェクト: AzagraMac/PS2_SDK
void Reset()
{
	SifIopReset("rom0:UDNL rom0:EELOADCNF",0);
	while (SifIopSync()) ;
	fioExit();
	SifExitIopHeap();
	SifLoadFileExit();
	SifExitRpc();
	SifExitCmd();
	EI;
	SifInitRpc(0);
	FlushCache(0);
	FlushCache(2);
}
コード例 #10
0
ファイル: echo.c プロジェクト: israfilistek/ps2sdk
int main(int argc, char *argv[])
{
    SifInitRpc(0);

    SifLoadModule("host:ps2ips.irx", 0, NULL);

    if(ps2ip_init() < 0) {
        printf("ERROR: ps2ip_init falied!\n");
        SleepThread();
    }

    serverThread();
    return 0;
}
コード例 #11
0
ファイル: jpg.c プロジェクト: AzagraMac/PS2_SDK
int main() {
	jpgData *jpg;

	SifInitRpc(0);
    
    printf("start\n");

	dmaKit_init(D_CTRL_RELE_ON, D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC,
		    D_CTRL_STD_OFF, D_CTRL_RCYC_8, 1 << DMA_CHANNEL_GIF);

	// Initialize the DMAC
	dmaKit_chan_init(DMA_CHANNEL_GIF);

	gsGlobal = gsKit_init_global(GS_MODE_NTSC);
	gsGlobal->PSM = GS_PSM_CT24;
	gsKit_init_screen(gsGlobal);


	printf("display raw jpeg\n");
	jpg = jpgOpenRAW(jpegtest, sizeof(jpegtest));
	if (jpg == NULL) {
		printf("error opening raw jpeg\n");
	} else {
		displayjpeg(jpg);
	}

	printf("display cdrom0:\\TEST.JPG;1\n");
	jpg = jpgOpen("cdrom0:\\TEST.JPG;1");
	if (jpg == NULL) {
		printf("error opening cdrom0:\\TEST.JPG;1\n");
	} else {
		displayjpeg(jpg);
	}

	printf("display host0:testorig.jpg\n");
	jpg = jpgOpen("host0:testorig.jpg");
	if (jpg == NULL) {
		printf("error opening host0:testorig.jpg\n");
	} else {
		displayjpeg(jpg);
	}

	printf("create screenshot file host0:screen.jpg\n");
	//ps2_screenshot_jpg("host0:screen.jpg", 0, 640, 480, GS_PSM_CT32);
    jpgScreenshot("host0:screen.jpg", gsGlobal->CurrentPointer,
                             gsGlobal->Width, gsGlobal->Height, gsGlobal->PSM);

	return 0;
}
コード例 #12
0
ファイル: prof.c プロジェクト: AKuHAK2/ps2sdk
int main()
{
	int i;

	SifInitRpc(0);

	for (i=0; i<10; i++)
	{
		loops_10_times();
	}

	sleeping_beauty();

	return 0;
}
コード例 #13
0
ファイル: hello.c プロジェクト: EvertonSilva/ps2sdk
int main()
{   
   SifInitRpc(0); 
/*
   init_scr();
   scr_printf("Hello, world!\n"); // hello world in the screen
*/
   printf("Hello, world!\n");
   nprintf("Hello, again, from Naplink RPC!\n");
   
   sio_init(115200, 0, 0, 0, 0);
   sio_printf("Hello from EE SIO!\n");

   /* Return to the bootloader or PS2 browser. */
   return 0;
}
コード例 #14
0
ファイル: eeload.c プロジェクト: madnessw/thesnow
void __attribute__((noreturn)) eeload_start() {
	void (*entry)();
	__puts("EELOAD start\n");

	__printf("about to SifInitRpc(0)\n");
	SifInitRpc(0);
    __printf("done rpc\n");

	entry = (void (*)())loadElfFile("INTRO");
	entry();

	entry = (void (*)())loadElfFile("LOADER");
	entry();

	for (;;);
}
コード例 #15
0
ファイル: main.c プロジェクト: shorti006/CN-Cheat
int main(void)
{
	SifInitRpc(0);
	init_scr();
	
	//LoadIRX();
	initalise();
	if (remove("mc0:/cheat.bin") < 0)
	{
		scr_printf("	Could not delete mc0:/cheat.bin");
	}
	scr_printf("	CN-CHEAT!\n");
	StartMenu();

	return 0;
}
コード例 #16
0
ファイル: ps2cam_rpc.c プロジェクト: AzagraMac/PS2_SDK
int PS2CamInit(int mode)
{
	// unsigned int	i;
	int				ret=0;
	int				*buf;
	int				timeout;

	if(CamInited)return 0;
	
	SifInitRpc(0);

	timeout = 100000;

	while (((ret = SifBindRpc(&cdata, PS2_CAM_RPC_ID, 0)) >= 0) && (cdata.server == NULL))
		nopdelay();
	
	nopdelay();
		
	
	
	if (ret < 0)return ret;
		


	buf		= (int *)&data[0];
	buf[0]	= mode;

	printf("bind done\n");

	SifCallRpc(&cdata, PS2CAM_RPC_INITIALIZE, 0, (void*)(&data[0]),4,(void*)(&data[0]),4,0,0);
	nopdelay();

	CamInited = 1;
	
printf("init done\n");


	compSema.init_count = 1;
	compSema.max_count = 1;
	compSema.option = 0;
	sem = CreateSema(&compSema);

printf("sema done\n");

	return buf[0];
}
コード例 #17
0
ファイル: sys_ps2.c プロジェクト: joshdekock/jim-ps2ware
int main (int argc, char **argv)
{
	static quakeparms_t    parms;
	float  time, oldtime, newtime;

	signal(SIGFPE, SIG_IGN);
	SifInitRpc(0);
	LoadModules();
/*
	if(mcInit(MC_TYPE_MC) < 0) 
	{
		printf("Failed to initialise memcard\n");
		SleepThread();
	}
*/
	inithandle();
	
	parms.memsize = 24*1024*1024;
	parms.membase = malloc (parms.memsize);
	parms.basedir = ".";

	COM_InitArgv (argc, argv);

	parms.argc = com_argc;
	parms.argv = com_argv;

	printf ("Host_Init\n");
	Host_Init (&parms);
	
	start_ps2_timer();
	
	oldtime = Sys_FloatTime () - 0.1;
    while (1)
    {
// find time spent rendering last frame
        newtime = Sys_FloatTime ();
        time = newtime - oldtime;

		oldtime = newtime;

        Host_Frame (time);
    }
	stop_ps2_timer();
	
	return 0;
}
コード例 #18
0
ファイル: sdl_main.c プロジェクト: dirsors/ps2sdk-ports
int main(int argc, char *argv[])
{
#ifdef PS2SDL_ENABLE_MTAP
	smod_mod_info_t info;
	if(smod_get_mod_by_name("sio2man",&info)!=0)
	{
		printf("PS2SDL: sio2man detected, resetting iop\n");
		cdInit(CDVD_INIT_EXIT);
		SifExitIopHeap();
		SifLoadFileExit();
		SifExitRpc();

		SifIopReset("rom0:UDNL rom0:EELOADCNF", 0);
		while (SifIopSync()) ;
	}
#endif
	SifInitRpc(0); 
	return(SDL_main(argc, argv));
}
コード例 #19
0
ファイル: fileio.c プロジェクト: AzagraMac/PS2_SDK
int fioInit()
{
	int res;
	ee_sema_t compSema;
	static int _rb_count = 0;

	if(_rb_count != _iop_reboot_count)
	{
	    _rb_count = _iop_reboot_count;

	    if (_fio_completion_sema >= 0)
	    {
	        DeleteSema(_fio_completion_sema);
            }

	    memset(&_fio_cd, 0, sizeof _fio_cd);
	    _fio_init = 0;
	}

        if (_fio_init)
		return 0;

	SifInitRpc(0);

	while (((res = SifBindRpc(&_fio_cd, 0x80000001, 0)) >= 0) &&
			(_fio_cd.server == NULL))
		nopdelay();

	if (res < 0)
		return res;

	compSema.init_count = 1;
	compSema.max_count = 1;
	compSema.option = 0;
	_fio_completion_sema = CreateSema(&compSema);
	if (_fio_completion_sema < 0)
		return -E_LIB_SEMA_CREATE;

	_fio_init = 1;
	_fio_block_mode = FIO_WAIT;

	return 0;
}
コード例 #20
0
ファイル: libcdvd.c プロジェクト: przemekh/ps2sdk
s32 sceCdDiskReady(s32 mode)
{
	s32 i;

	if (sceCdDebug > 0)
		printf("DiskReady 0\n");

	sceCdSemaInit();
	if (PollSema(sCmdSemaId) != sCmdSemaId)
		return SCECdNotReady;
	if (sceCdSyncS(1)) {
		SignalSema(sCmdSemaId);
		return SCECdNotReady;
	}

	SifInitRpc(0);
	if (bindDiskReady < 0) {
		while (1) {
			if (SifBindRpc(&clientDiskReady, CD_SERVER_DISKREADY, 0) < 0) {
				if (sceCdDebug > 0)
					printf("LibsceCdvd bind err CdDiskReady\n");
			}
			if (clientDiskReady.server != 0)
				break;

			i = 0x10000;
			while (i--);
		}
	}
	bindDiskReady = 0;
	diskReadyMode = mode;

	if (SifCallRpc(&clientDiskReady, 0, 0, &diskReadyMode, 4, sCmdRecvBuff, 4, 0, 0) < 0) {
		SignalSema(sCmdSemaId);
		return 6;
	}
	if (sceCdDebug > 0)
		printf("DiskReady ended\n");

	SignalSema(sCmdSemaId);
	return *(s32 *) UNCACHED_SEG(sCmdRecvBuff);
}
コード例 #21
0
ファイル: libcdvd.c プロジェクト: przemekh/ps2sdk
s32 sceCdInit(s32 mode)
{
	s32 i;

	if (sceCdSyncS(1))
		return 0;
	SifInitRpc(0);
	sceCdThreadId = GetThreadId();
	bindSearchFile = -1;
	bindNCmd = -1;
	bindSCmd = -1;
	bindDiskReady = -1;
	bindInit = -1;

	while (1) {
		if (SifBindRpc(&clientInit, CD_SERVER_INIT, 0) < 0) {
			if (sceCdDebug > 0)
				printf("LibsceCdvd bind err CD_Init\n");
		} else if (clientInit.server != 0)
			break;

		i = 0x10000;
		while (i--);
	}

	bindInit = 0;
	initMode = mode;
	if (SifCallRpc(&clientInit, 0, 0, &initMode, 4, 0, 0, 0, 0) < 0)
		return 0;
	if (mode == SCECdEXIT) {
		if (sceCdDebug > 0)
			printf("LibsceCdvd Exit\n");
		sceCdSemaExit();
		nCmdSemaId = -1;
		sCmdSemaId = -1;
		callbackSemaId = -1;
	} else {
		sceCdSemaInit();
	}

	return 1;
}
コード例 #22
0
ファイル: runner.c プロジェクト: AKuHAK2/ps2sdk
int main(int argc, char *argv[])
{
	test_suite suite;

	#ifdef _EE
	SifInitRpc(0);
	#endif

	/* initialize test suite */
	init_testsuite(&suite);

	/* add all tests to this suite */
	libc_add_tests(&suite);
	time_add_tests(&suite);

	/* run all tests */
	run_testsuite(&suite);

	return 0;
}
コード例 #23
0
ファイル: main_ps2.c プロジェクト: AzagraMac/PS2_SDK
//------------------------------------------------------------------------
int init(void)
{
	SifInitRpc(0);

	memset(&ctx, 0, sizeof(DGLcontext));

	ctx.ScreenWidth		= 512;
	ctx.ScreenHeight	= 256;
	ctx.ScreenDepth		= 32;
	ctx.ScreenBuffers	= 2;
	ctx.ZDepth			= 32;
	ctx.VSync			= GL_TRUE;

	if(*((char *)0x1FC80000 - 0xAE) == 'E')
		ctx.ps2VidType	= PS2_PAL;
	else
		ctx.ps2VidType	= PS2_NTSC;

	ctx.ps2VidInterlace	= PS2_NONINTERLACED;
	ctx.ps2VidFrame		= PS2_FRAME;

	return(dglInit(&ctx));
}
コード例 #24
0
ファイル: CDSwap.cpp プロジェクト: MrSiir/PS2-Keylauncher
/////////////////////////////////////////////////////////////////////
// reboot IOP
/////////////////////////////////////////////////////////////////////
void CD_Reset(int mode)
{

if(mode==1) SifIopReset("rom0:UDNL rom0:EELOADCNF",0); // normal
else
	{fioOpen("cdrom0:\\SYSTEM.CNF;1",1); // hacking in the night... `_Ž. Prepare 
	SifIopReset("rom0:UDNL cdrom0:\\SYSTEM.CNF;1", 0); // three point!!
	}
   while (SifIopSync()) ;
   
fioExit();
SifExitIopHeap();
SifLoadFileExit();
SifExitRpc();
SifExitCmd();
EI();

SifInitRpc(0);

FlushCache(0);
FlushCache(2);
	

}
コード例 #25
0
ファイル: platform_ps2.c プロジェクト: Ryunam/RetroArch
static void frontend_ps2_init(void *data)
{
   char cwd[FILENAME_MAX];
   int bootDeviceID;

   SifInitRpc(0);
#if !defined(DEBUG)
   /* Comment this line if you don't wanna debug the output */
   while(!SifIopReset(NULL, 0)){};
#endif

   while(!SifIopSync()){};
   SifInitRpc(0);
   sbv_patch_enable_lmb();

   /* I/O Files */
   SifExecModuleBuffer(&iomanX_irx, size_iomanX_irx, 0, NULL, NULL);
   SifExecModuleBuffer(&fileXio_irx, size_fileXio_irx, 0, NULL, NULL);
   SifExecModuleBuffer(&freesio2_irx, size_freesio2_irx, 0, NULL, NULL);

   /* Memory Card */
   SifExecModuleBuffer(&mcman_irx, size_mcman_irx, 0, NULL, NULL);
   SifExecModuleBuffer(&mcserv_irx, size_mcserv_irx, 0, NULL, NULL);

   /* Controllers */
   SifExecModuleBuffer(&freemtap_irx, size_freemtap_irx, 0, NULL, NULL);
   SifExecModuleBuffer(&freepad_irx, size_freepad_irx, 0, NULL, NULL);

   /* USB */
   SifExecModuleBuffer(&usbd_irx, size_usbd_irx, 0, NULL, NULL);
   SifExecModuleBuffer(&usbhdfsd_irx, size_usbhdfsd_irx, 0, NULL, NULL);

   /* Audio */
   SifExecModuleBuffer(&freesd_irx, size_freesd_irx, 0, NULL, NULL);
   SifExecModuleBuffer(&audsrv_irx, size_audsrv_irx, 0, NULL, NULL);

   /* CDVD */
   SifExecModuleBuffer(&cdvd_irx, size_cdvd_irx, 0, NULL, NULL);

   if (mcInit(MC_TYPE_XMC)) {
      RARCH_ERR("mcInit library not initalizated\n");
   }

   /* Initializes audsrv library */
   if (audsrv_init()) {
      RARCH_ERR("audsrv library not initalizated\n");
   }

   /* Initializes pad libraries
      Must be init with 0 as parameter*/
   if (mtapInit() != 1) {
      RARCH_ERR("mtapInit library not initalizated\n");
   }
   if (padInit(0) != 1) {
      RARCH_ERR("padInit library not initalizated\n");
   }
   if (mtapPortOpen(0) != 1) {
      RARCH_ERR("mtapPortOpen library not initalizated\n");
   }

   /* Initializes CDVD library */
   /* SCECdINoD init without check for a disc. Reduces risk of a lockup if the drive is in a erroneous state. */
   sceCdInit(SCECdINoD);
   if (CDVD_Init() != 1) {
      RARCH_ERR("CDVD_Init library not initalizated\n");
   }

   _init_ps2_io();

   /* Prepare device */
   getcwd(cwd, sizeof(cwd));
   bootDeviceID=getBootDeviceID(cwd);
   waitUntilDeviceIsReady(bootDeviceID);

#if defined(HAVE_FILE_LOGGER)
   retro_main_log_file_init("retroarch.log");
   verbosity_enable();
#endif
}
コード例 #26
0
ファイル: playwav.c プロジェクト: AKuHAK2/ps2sdk
int main(int argc, char **argv)
{
	int ret;
	int played;
	int err;
	char chunk[2048];
	FILE *wav;
	struct audsrv_fmt_t format;

	SifInitRpc(0);

	printf("sample: kicking IRXs\n");
	ret = SifLoadModule("rom0:LIBSD", 0, NULL);
	printf("libsd loadmodule %d\n", ret);

	printf("sample: loading audsrv\n");
	ret = SifLoadModule("host:audsrv.irx", 0, NULL);
	printf("audsrv loadmodule %d\n", ret);

	ret = audsrv_init();
	if (ret != 0)
	{
		printf("sample: failed to initialize audsrv\n");
		printf("audsrv returned error string: %s\n", audsrv_get_error_string());
		return 1;
	}

	format.bits = 16;
	format.freq = 22050;
	format.channels = 2;
	err = audsrv_set_format(&format);
	printf("set format returned %d\n", err);
	printf("audsrv returned error string: %s\n", audsrv_get_error_string());

	audsrv_set_volume(MAX_VOLUME);

	wav = fopen("host:song_22k.wav", "rb");
	if (wav == NULL)
	{
		printf("failed to open wav file\n");
		audsrv_quit();
		return 1;
	}

	fseek(wav, 0x30, SEEK_SET);

	printf("starting play loop\n");
	played = 0;
	while (1)
	{
		ret = fread(chunk, 1, sizeof(chunk), wav);
		if (ret > 0)
		{
			audsrv_wait_audio(ret);
			audsrv_play_audio(chunk, ret);
		}

		if (ret < sizeof(chunk))
		{
			/* no more data */
			break;
		}

		played++;
		if (played % 8 == 0)
		{
			printf(".");
		}

		if (played == 512) break;
	}

	fclose(wav);

	printf("sample: stopping audsrv\n");
	audsrv_quit();

	printf("sample: ended\n");
	return 0;
}
コード例 #27
0
ファイル: libmc.c プロジェクト: sp193/ps2sdk
// init memcard lib
//
// args:	MC_TYPE_MC  = use MCSERV/MCMAN
//			MC_TYPE_XMC = use XMCSERV/XMCMAN
// returns:	0   = successful
//			< 0 = error
int mcInit(int type)
{
	int ret=0;
	static int _rb_count = 0;

	if(_rb_count != _iop_reboot_count)
	{
		_rb_count = _iop_reboot_count;
		mcReset();
	}

	if(g_mclibInited)
		return -1;

	SifInitRpc(0);

	// set which modules to use
	g_mcType = type;

	// bind to mc rpc on iop
	do
	{
		if((ret=SifBindRpc(&g_cdata, 0x80000400, 0)) < 0)
		{
			#ifdef MC_DEBUG
				printf("libmc: bind error\n");
			#endif

			return ret;
		}
		if(g_cdata.server == NULL)
			nopdelay();
	}
	while (g_cdata.server == NULL);

	// for some reason calling this init sif function with 'mcserv' makes all other
	// functions not work properly. although NOT calling it means that detecting
	// whether or not cards are formatted doesnt seem to work :P
	if(g_mcType == MC_TYPE_MC)
	{
#ifdef MC_DEBUG
		printf("libmc: using MCMAN & MCSERV\n");

#endif
		g_descParam.offset=0xFFFFFF27;

		// call init function
		if((ret = SifCallRpc(&g_cdata, mcRpcCmd[g_mcType][MC_RPCCMD_INIT], 0, &g_descParam, sizeof(g_descParam), g_rdata, 4, NULL, NULL))>=0)
		{
			ret = *(s32*)g_rdata;
		}
		else{
			// init error
#ifdef MC_DEBUG
			printf("libmc: initialisation error\n");
#endif
			g_mclibInited = 0;
			return *(s32*)g_rdata - 100;
		}
	}
	else if(g_mcType == MC_TYPE_XMC)
	{
#ifdef MC_DEBUG
		printf("libmc: using XMCMAN & XMCSERV\n");
#endif

		// call init function
		if((ret = SifCallRpc(&g_cdata, mcRpcCmd[g_mcType][MC_RPCCMD_INIT], 0, &g_descParam, sizeof(g_descParam), g_rdata, 12, NULL, NULL)) < 0)
		{
			// init error
#ifdef MC_DEBUG
			printf("libmc: initialisation error\n");
#endif
			g_mclibInited = 0;
			return ret - 100;
		}

		// check if old version of mcserv loaded
		if(*(s32*)UNCACHED_SEG(g_rdata+4) < 0x205)
		{
#ifdef MC_DEBUG
			printf("libmc: mcserv is too old (%x)\n", *(s32*)UNCACHED_SEG(g_rdata+4));
#endif
			g_mclibInited = 0;
			return -120;
		}

		// check if old version of mcman loaded
		if(*(s32*)UNCACHED_SEG(g_rdata+8) < 0x206)
		{
#ifdef MC_DEBUG
			printf("libmc: mcman is too old (%x)\n", *(s32*)UNCACHED_SEG(g_rdata+8));
#endif
			g_mclibInited = 0;
			return -121;
		}
		ret = *(s32*)UNCACHED_SEG(g_rdata+0);
	}

	// successfully inited
	g_mclibInited = 1;
	g_currentCmd = 0;
	return ret;
}
コード例 #28
0
ファイル: playadpcm.c プロジェクト: AzagraMac/PS2_SDK
int main(int argc, char **argv)
{
	int i, ret;
	FILE* adpcm;
	audsrv_adpcm_t sample;
	int size;
	u8* buffer;

	SifInitRpc(0); 

	printf("sample: kicking IRXs\n");
	ret = SifLoadModule("rom0:LIBSD", 0, NULL);
	printf("libsd loadmodule %d\n", ret);

	printf("sample: loading audsrv\n");
	ret = SifLoadModule("host:audsrv.irx", 0, NULL);
	printf("audsrv loadmodule %d\n", ret);

	ret = audsrv_init();
	if (ret != 0)
	{
		printf("sample: failed to initialize audsrv\n");
		printf("audsrv returned error string: %s\n", audsrv_get_error_string());
		return 1;
	}

	adpcm = fopen("host:evillaugh.adp", "rb");

	if (adpcm == NULL)
	{
		printf("failed to open adpcm file\n");
		audsrv_quit();
		return 1;
	}

	fseek(adpcm, 0, SEEK_END);
	size = ftell(adpcm);
	fseek(adpcm, 0, SEEK_SET);

	buffer = malloc(size);

	fread(buffer, 1, size, adpcm);
	fclose(adpcm);

	printf("playing sample..\n");

	audsrv_adpcm_init();
	audsrv_set_volume(MAX_VOLUME);
	audsrv_load_adpcm(&sample, buffer, size);
	audsrv_play_adpcm(&sample);

	/* Uncomment to hear two samples played simultaenously
	for (i=0; i<100; i++)
	{
		nopdelay();
	}

	audsrv_play_adpcm(&sample);
	*/

	printf("sample played..\n");

	free(buffer);

	while (1);
	return 0;
}
コード例 #29
0
ファイル: init.c プロジェクト: AKuHAK/Fceumm-PS2
void InitPS2()
{
    int i, sometime;
    static char hddarg[] = "-o" "\0" "4" "\0" "-n" "\0" "20";
    static char pfsarg[] = "-m" "\0" "4" "\0" "-o" "\0" "10" "\0" "-n" "\0" "40";

    SifInitRpc(0);
    // Reset IOP borrowed from uLaunchelf
    while (!SifIopReset(NULL, 0)){};
    while (!SifIopSync()){};
    SifInitRpc(0);

    sbv_patch_enable_lmb();

    SifExecModuleBuffer(&iomanX_irx, size_iomanX_irx, 0, NULL, NULL);
    SifExecModuleBuffer(&fileXio_irx, size_fileXio_irx, 0, NULL, NULL);
    SifExecModuleBuffer(&freesio2_irx, size_freesio2_irx, 0, NULL, NULL);

 /* SifLoadModule("rom0:XSIO2MAN", 0, NULL);
    SifLoadModule("rom0:XMCMAN", 0, NULL);
    SifLoadModule("rom0:XMCSERV", 0, NULL);
    SifLoadModule("rom0:XMTAPMAN", 0, NULL);
    SifLoadModule("rom0:XPADMAN", 0, NULL); */

    SifExecModuleBuffer(&mcman_irx, size_mcman_irx, 0, NULL, NULL);
    SifExecModuleBuffer(&mcserv_irx, size_mcserv_irx, 0, NULL, NULL);
    SifExecModuleBuffer(&freemtap_irx, size_freemtap_irx, 0, NULL, NULL);
    SifExecModuleBuffer(&freepad_irx, size_freepad_irx, 0, NULL, NULL);

#ifdef SOUND_ON
    SifExecModuleBuffer(&freesd_irx, size_freesd_irx, 0, NULL, NULL);
    SifExecModuleBuffer(&audsrv_irx, size_audsrv_irx, 0, NULL, NULL);
#endif
    SifExecModuleBuffer(&SMSUTILS_irx, size_SMSUTILS_irx, 0, NULL, NULL);
    SifExecModuleBuffer(&usbd_irx, size_usbd_irx, 0, NULL, NULL);
    SifExecModuleBuffer(&usbhdfsd_irx, size_usbhdfsd_irx, 0, NULL, NULL);
    for (i = 0; i < 3; i++) { // Taken from ulaunchelf
        sometime = 0x01000000;
        while (sometime--) asm("nop\nnop\nnop\nnop");
    }

    SifExecModuleBuffer(&poweroff_irx, size_poweroff_irx, 0, NULL, NULL);
    SifExecModuleBuffer(&ps2dev9_irx, size_ps2dev9_irx, 0, NULL, NULL);
    SifExecModuleBuffer(&ps2atad_irx, size_ps2atad_irx, 0, NULL, NULL);
    SifExecModuleBuffer(&ps2hdd_irx, size_ps2hdd_irx, sizeof(hddarg), hddarg, NULL);
    SifExecModuleBuffer(&ps2fs_irx, size_ps2fs_irx, sizeof(pfsarg), pfsarg, NULL);

    mcInit(MC_TYPE_XMC);

#ifdef CDSUPPORT
    SifExecModuleBuffer(&cdvd_irx, size_cdvd_irx, 0, NULL, NULL);
    cdInit(CDVD_INIT_INIT);
    CDVD_Init();
#endif

#ifdef SOUND_ON
    audsrv_init();
#endif

    mtapInit();
    padInit(0);
    mtapPortOpen(0);
}
コード例 #30
0
ファイル: mc_example.c プロジェクト: AKuHAK2/ps2sdk
int main() {

	int fd, ret;
	int i;

	// Initialise
	SifInitRpc(0);
	LoadModules();
#ifdef TYPE_MC
	if(mcInit(MC_TYPE_MC) < 0) {
		printf("Failed to initialise memcard server!\n");
		SleepThread();
	}
#else
	if(mcInit(MC_TYPE_XMC) < 0) {
		printf("Failed to initialise memcard server!\n");
		SleepThread();
	}
#endif

	printf("\nMemory card library example code - by Sjeep\n\n");

	// int mcGetInfo(int port, int slot, int* type, int* free, int* format);
	//
	// mcGetInfo retrieves memcard state info, such as the memcard type, free blocks and
	// the format status.
	//
	// mcGetInfo is passed pointers to three variables, which are filled upon completion
	// of the getinfo rpc command. The mcGetInfo return values are as follows:
	//
	//  0 : The same memory card has been connected since the last mcGetInfo call.
	// -1 : Switched to a formatted memory card.
	// -2 : Switched to an unformatted memory card.
	// -10 or less : The memory card could not be detected.
	//
	// NOTE: With the MCMAN/MCSERV, *format is always returned as 0 regardless of if
	//       if the memcard is formatted or not.

	// Since this is the first call, -1 should be returned.
	mcGetInfo(0, 0, &mc_Type, &mc_Free, &mc_Format);
	mcSync(0, NULL, &ret);
	printf("mcGetInfo returned %d\n",ret);
	printf("Type: %d Free: %d Format: %d\n\n", mc_Type, mc_Free, mc_Format);

	// Assuming that the same memory card is connected, this should return 0
	mcGetInfo(0,0,&mc_Type,&mc_Free,&mc_Format);
	mcSync(0, NULL, &ret);
	printf("mcGetInfo returned %d\n",ret);
	printf("Type: %d Free: %d Format: %d\n\n", mc_Type, mc_Free, mc_Format);

	// int mcGetDir(int port, int slot, char *name, unsigned mode, int maxent, mcTable* table);
	//
	// mcGetDir retrieves the directory structure of a specific path on the memory card.
	//
	// The filename is relative to the root of the memory card. Wildcards such as '*' and '?'
	// may be used. "maxent" is the maximum number of mcTable elements your array specified
	// by "table" can hold. The mc_getdir return values are as follows:
	//
	// 0 or more : The number of file entries that were obtained.
	// -2 : The memory card is unformatted
	// -4 : A non-existant path was specified in the "name" parameter
	// -10 or less : The memory card could not be detected.

	mcGetDir(0, 0, "/*", 0, ARRAY_ENTRIES - 10, mcDir);
	mcSync(0, NULL, &ret);
	printf("mcGetDir returned %d\n\nListing of root directory on memory card:\n\n", ret);

	for(i=0; i < ret; i++)
	{
		if(mcDir[i].attrFile & MC_ATTR_SUBDIR)
			printf("[DIR] %s\n", mcDir[i].name);
		else
			printf("%s - %d bytes\n", mcDir[i].name, mcDir[i].fileSizeByte);
	}

	// Check if existing save is present
	fd = fioOpen("mc0:PS2DEV/icon.sys", O_RDONLY);
	if(fd <= 0) {

		printf("\nNo previous save exists, creating...\n");

		if((ret = CreateSave()) < 0) {

			printf("Failed to create save! Errorno: %d\n",ret);
			SleepThread();
		}

	} else {

		printf("\nPrevious save exists, listing directory\n\n");

		ret = mcGetDir(0, 0, "/PS2DEV/*", 0, ARRAY_ENTRIES, mcDir);
		printf("mcGetDir returned %d\n\n", ret);

		for(i=0; i < ret; i++)
		{
			if(mcDir[i].attrFile & MC_ATTR_SUBDIR)
				printf("[DIR] %s\n", mcDir[i].name);
			else
				printf("%s - %d bytes\n", mcDir[i].name, mcDir[i].fileSizeByte);
		}
	}

	// Return to the browser, so you can see the PS2Dev icon :)
	SifExitRpc();
	return 0;
}