コード例 #1
0
ファイル: uxdisc.c プロジェクト: Klozz/uxcode
int uxdisc_mount() {
	if (uxdisc_mounted==true) { return false; }

	#if defined(PSP)
		int status;
		if (uxdisc_check() == true) {
			sceUmdActivate(1, "disc0:");
			status = sceUmdWaitDriveStatWithTimer(UMD_WAITFORINIT, 5000000); // 5 secs timeout.
			uxdisc_mounted = (status >= 0);
			return (uxdisc_mounted==true);
		}
		return false;
	#else
		return false;
	#endif
}
コード例 #2
0
ファイル: umd.c プロジェクト: Saner2oo2/hostcore-psp
void mountUmdImage( char * file )
{
	switch ( mode )
	{
		case MODE_UMD:
		{
			mountUmdFromFile( file, 0, 0 );
			break;
		}
		case MODE_OE_LEGACY:
		{
			mountUmdFromFile( file, 1, 1 );
			break;
		}
		case MODE_MARCH33:
		{
			setInitApitype( 0x120 );
			setInitFileName( file );
			setUmdFile( file );
			loadStartModule( "flash0:/kd/march33.prx", 0, NULL );
			loadStartModule( "flash0:/kd/isofs.prx", 0, NULL );
			break;
		}
		case MODE_NP9660:
		{
			setInitApitype( 0x120 );
			setInitFileName( file );
			setUmdFile( file );
			loadStartModule( "flash0:/kd/mgr.prx", 0, NULL );
			loadStartModule( "flash0:/kd/npdrm.prx", 0, NULL );
			loadStartModule( "flash0:/kd/galaxy.prx", 0, NULL );
			loadStartModule( "flash0:/kd/np9660.prx", 0, NULL );
			loadStartModule( "flash0:/kd/isofs.prx", 0, NULL );
			break;
		}
	}
	int stat = sceUmdCheckMedium();
	if ( stat == 0 )
	{
		log( "no media\n" );
		sceUmdWaitDriveStat( UMD_WAITFORDISC );
	}
	sceUmdActivate( 1, "disc0:" );
	sceUmdWaitDriveStat( UMD_WAITFORINIT );
}
コード例 #3
0
ファイル: main.c プロジェクト: DeadRoolz/jpcsp
int main(int argc, char *argv[])
{
    SceCtrlData pad;
    int result;
    int oldButtons = 0;
    int cbid = -1;
    int waitStatThid = -1;

    pspDebugScreenInit();
    if (argc > 0) {
        printf("Bootpath: %s\n", argv[0]);
    }

    printf("Triangle - Exit\n");
    printf("Left - sceUmdActivate\n");
    printf("Right - sceUmdDeactivate\n");
    printf("Cross - Delay CB\n");
    printf("Circle - Display umd info\n");
    printf("Square - Refer umd callback\n");
    printf("L-Trigger - IO test\n");
    printf("R-Trigger - Start/Stop wait stat test\n");

    SetupCallbacks();

    sceCtrlSetSamplingCycle(0);
    sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);

    {
        printUmdInfo();

        // result:
        // callback events are generated if we launch from iso or immediately after psplink has reset
        cbid = sceKernelCreateCallback("UMD Callback (not active)", umd_callback, (void*)0x34343434);
        result = sceUmdRegisterUMDCallBack(cbid);
        printf("sceUmdRegisterUMDCallBack result %08X\n", result);

		// Register a second UMD callback: it will overwrite the first one.
		cbid = sceKernelCreateCallback("UMD Callback", umd_callback, (void*)0x11111111);
		result = sceUmdRegisterUMDCallBack(cbid);
        printf("sceUmdRegisterUMDCallBack result %08X\n", result);
    }

    while (!done)
    {
        sceCtrlReadBufferPositive(&pad, 1); // context switch in here
        //sceCtrlPeekBufferPositive(&pad, 1); // no context switch version
        int buttonDown = (oldButtons ^ pad.Buttons) & pad.Buttons;

        if (buttonDown & PSP_CTRL_LEFT)
        {
            result = sceUmdActivate(1, "disc0:");
            printf("sceUmdActivate result %08x\n", result);
        }

        if (buttonDown & PSP_CTRL_RIGHT)
        {
            result = sceUmdDeactivate(1, "disc0:");
            printf("sceUmdDeactivate result %08x\n", result);
        }

        if (buttonDown & PSP_CTRL_CROSS)
        {
            printf("sceKernelDelayThreadCB ...\n");
            sceKernelDelayThreadCB(10000);
        }

        if (buttonDown & PSP_CTRL_CIRCLE)
        {
            printUmdInfo();
        }

        if (buttonDown & PSP_CTRL_SQUARE)
        {
            SceKernelCallbackInfo info;
            memset(&info, 0xee, sizeof(info));
            info.size = sizeof(info);
            result = sceKernelReferCallbackStatus(cbid, &info);
            printf("sceKernelReferCallbackStatus result %08x\n", result);
            printf("  size %d (%d)\n", info.size, sizeof(info));
            printf("  name '%s'\n", info.name);
            printf("  threadId %08x (%08x)\n", info.threadId, sceKernelGetThreadId());
            printf("  callback %p common %p\n", info.callback, info.common);
            printf("  notifyCount %08x\n", info.notifyCount);
            printf("  notifyArg %08x\n", info.notifyArg);
        }

        if (buttonDown & PSP_CTRL_LTRIGGER)
        {
            test_io();
        }

        if (buttonDown & PSP_CTRL_RTRIGGER)
        {
            if (waitStatThid >= 0)
            {
                printf("Cleaning up wait stat test ...\n");

                referThread(waitStatThid);

                result = sceUmdCancelWaitDriveStat();
                printf("sceUmdCancelWaitDriveStat result %08x\n", result);

                referThread(waitStatThid);

                result = sceKernelDeleteThread(waitStatThid);
                printf("sceKernelDeleteThread result %08x\n", result);

                //result = sceKernelTerminateDeleteThread(waitStatThid);
                //printf("sceKernelTerminateDeleteThread result %08x\n", result);

                waitStatThid = -1;
            }
            else
            {
                printf("Starting wait stat test ...\n");

                // test timeout:
                // Press Right (deactivate UMD)
                // Press R-Trigger:
                // - Press R-Trigger again before 3 seconds:
                //   0x800201a9 wait cancelled
                // - Or wait 3 seconds:
                //   0x800201a8 wait timeout
                struct WaitStatParams params = { 0x20, 3000000 };

                // test internal workings:
                // - (wantStat & curStat) == wantStat
                // - (wantStat & curStat) != 0 <-- looks like this is the correct one
                //struct WaitStatParams params = { 0xFF, 3000000 };

                waitStatThid = sceKernelCreateThread("WaitUMDStat", waitstat_thread, 0x20, 0x4000, 0, 0);
                printf("sceKernelCreateThread result %08x\n", waitStatThid);
                if (waitStatThid >= 0)
                {
                    result = sceKernelStartThread(waitStatThid, sizeof(params), &params);
                    printf("sceKernelStartThread result %08x\n", result);
                }
            }
        }

        if (buttonDown & PSP_CTRL_TRIANGLE)
            done = 1;

        oldButtons = pad.Buttons;
        sceDisplayWaitVblank(); // only catch callback when we press Cross (sceKernelDelayThreadCB)
        //sceDisplayWaitVblankCB(); // catch all callback events
    }

    sceKernelExitGame();
    return 0;
}