⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 anytmmain.c

📁 XFLASH source code for Sony Play Station Portable (PSP).
💻 C
📖 第 1 页 / 共 3 页
字号:

		while(sceIoDread(dfd, &dir) > 0)
		{
			if(dir.d_stat.st_attr & FIO_SO_IFDIR)
			{
				if(dir.d_name[0] != '.')
				{
					build_path(next_write, write_loc, dir.d_name, 0);
					build_path(next_root, root, dir.d_name, 1);
					add_flash(next_root, next_write);
				}
			}
			else
			{
				add_file(root, write_loc, dir.d_name);
			}
		}
		sceIoDclose(dfd);
	}
}

void audioOutputLoopCallback(void* buf, unsigned int length, void *userdata) {

    sample_t* ubuf = (sample_t*) buf;
	int i;

if (samlock == 1) {
	
if (samsel == 1) {
	for (i = 0; i < 1024; i++) {
		ubuf[i].l = sndch[sam+1] + (sndch[sam]*256);
		ubuf[i].r = ubuf[i].l;
		sam++;
		sam++;

		if (sam > 38162) {
		ubuf[i].l = 0;
		ubuf[i].r = 0;
		samlock = 0;
		}
	}
}

if (samsel == 11) {
	for (i = 0; i < 1024; i++) {
		ubuf[i].l = lpcm[sam+1] + (lpcm[sam]*256);
		ubuf[i].r = ubuf[i].l;
		sam++;
		sam++;

		if (sam > 10000) {
		ubuf[i].l = 0;
		ubuf[i].r = 0;
		samlock = 0;
		}
	}
}

if (samsel == 2) {
	for (i = 0; i < 1024; i++) {
		ubuf[i].l = sndci[sam+1] + (sndci[sam]*256);
		ubuf[i].r = ubuf[i].l;
		sam++;
		sam++;

		if (sam > 9210) {
		ubuf[i].l = 0;
		ubuf[i].r = 0;
		samlock = 0;
		}
	}
}

if (samsel == 3) {
	for (i = 0; i < 1024; i++) {
		ubuf[i].l = sndcr[sam+1] + (sndcr[sam]*256);
		ubuf[i].r = ubuf[i].l;
		sam++;
		sam++;

		if (sam > 9210) {
		ubuf[i].l = 0;
		ubuf[i].r = 0;
		samlock = 0;
		}

	}
}

if (samsel == 4) {

	n = 0;
	for (i = 0; i < 256; i++) {			// playback 11025 sample
	ubuf[n].l = sndfb[sam+1] + (sndfb[sam]*256);
	ubuf[n].r = ubuf[n].l;
	n++;
	ubuf[n].l = sndfb[sam+1] + (sndfb[sam]*256);
	ubuf[n].r = ubuf[n].l;
	n++;
	ubuf[n].l = sndfb[sam+1] + (sndfb[sam]*256);
	ubuf[n].r = ubuf[n].l;
	n++;
	ubuf[n].l = sndfb[sam+1] + (sndfb[sam]*256);
	ubuf[n].r = ubuf[n].l;
	n++;
	sam++;
	sam++;

		if (sam > 16370) {
		ubuf[i].l = 0;
		ubuf[i].r = 0;
		samlock = 0;
		}


	}
}

if (samsel == 5) {
	for (i = 0; i < 1024; i++) {
		ubuf[i].l = sndgr[sam+1] + (sndgr[sam]*256);
		ubuf[i].r = ubuf[i].l;
		sam++;
		sam++;

		if (sam > 29509) {
		ubuf[i].l = 0;
		ubuf[i].r = 0;
		samlock = 0;
		}
	}
}

if (samsel == 6) {
	for (i = 0; i < 1024; i++) {
		ubuf[i].l = sndgv[sam+1] + (sndgv[sam]*256);
		ubuf[i].r = ubuf[i].l;
		sam++;
		sam++;

		if (sam > 29497) {
		ubuf[i].l = 0;
		ubuf[i].r = 0;
		samlock = 0;
		}
	}
}

if (samsel == 7) {
	for (i = 0; i < 1024; i++) {
		ubuf[i].l = sndx[sam+1] + (sndx[sam]*256);
		ubuf[i].r = ubuf[i].l;
		sam++;
		sam++;

		if (sam > 30310) {
		ubuf[i].l = 0;
		ubuf[i].r = 0;
		samlock = 0;
		}
	}
}

if (samsel == 8) {
	for (i = 0; i < 1024; i++) {
		ubuf[i].l = sndy[sam+1] + (sndy[sam]*256);
		ubuf[i].r = ubuf[i].l;
		sam++;
		sam++;

		if (sam > 6195) {
		ubuf[i].l = 0;
		ubuf[i].r = 0;
		samlock = 0;
		}
	}
}

if (samsel == 9) {

	n = 0;
	for (i = 0; i < 256; i++) {			// playback 11025 sample
	ubuf[n].r = sndfb[samt+1] + (sndfb[samt]*256);
	n++;
	ubuf[n].r = sndfb[samt+1] + (sndfb[samt]*256);
	n++;
	ubuf[n].r = sndfb[samt+1] + (sndfb[samt]*256);
	n++;
	ubuf[n].r = sndfb[samt+1] + (sndfb[samt]*256);
	n++;
	samt++;
	samt++;

		if (samt > 16370) {
		ubuf[i].r = 0;
		samlock = 0;
		}

	}

	for (i = 0; i < 1024; i++) {
		ubuf[i].l = sndcr[sam+1] + (sndcr[sam]*256);
		sam++;
		sam++;

		if (sam > 9210) {
		ubuf[i].l = 0;
		}
	}

}

if (samsel == 10) {

if (turbo == 1) {

	for (i = 0; i < 1024; i++) {
		ubuf[i].l = lpcm[sam+1] + (lpcm[sam]*256);
		ubuf[i].r = ubuf[i].l;
		sam++;
		sam++;
		sam++;
		sam++;
		sam++;
		sam++;
		sam++;
		sam++;

		if (sam > 160000) {
		ubuf[i].r = 0;
		ubuf[i].l = 0;

	if (startup == 1) {
	if (sam < 160008) {
	sam = 21;
	}
	}
	else {
	samlock = 0;
	samr = 6998;
	}

		}
	}

} // turbo
else {

if (fast == 0) {

	for (i = 0; i < 1024; i++) {
		ubuf[i].l = lpcm[sam+1] + (lpcm[sam]*256);
		ubuf[i].r = ubuf[i].l;
		sam++;
		sam++;

		if (sam > 160000) {
		ubuf[i].r = 0;
		ubuf[i].l = 0;

	if (startup == 1) {
	if (sam < 160004) {
	sam = 21;
	}
	}
	else {
	samlock = 0;
	samr = 6998;
	}

		}
	}

crbuff ++;
if (crbuff > 78) {
SceCtrlData pad;
		sceCtrlReadBufferPositive(&pad, 1);
		if (pad.Buttons & PSP_CTRL_CROSS) {
		fast = 1;
		}
		else {
		fast = 0;
		}
} // crbuff

} // fast

if (fast > 0) {

	for (i = 0; i < 1024; i++) {
		ubuf[i].l = lpcm[sam+1] + (lpcm[sam]*256);
		ubuf[i].r = ubuf[i].l;
		sam++;
		sam++;
		sam++;
		sam++;

		if (sam > 160000) {
		ubuf[i].r = 0;
		ubuf[i].l = 0;

	if (startup == 1) {
	if (sam < 160004) {
	sam = 21;
	}
	}
	else {
	samlock = 0;
	samr = 6998;
	}

		}
	}

fast ++;
if (fast > 39) {
SceCtrlData vlad;
		sceCtrlReadBufferPositive(&vlad, 1);
		if (vlad.Buttons & PSP_CTRL_CROSS) {
		turbo = 1;
		}
		else {
		turbo = 0;
		}
} // fast

} // fast

} // turbo

}

}

if (samlock == 0) {
int bbb;
	for (bbb = 0; bbb < 1024; bbb++) {
		ubuf[bbb].l = 0xFFFF;
		ubuf[bbb].r = 0xFFFF;
	}
}

if (mute == 1) {
	for (i = 0; i < 1024; i++) {
		ubuf[i].r = 0;
		ubuf[i].l = 0;
	}
}

}

void audioLoopStart() {
	loop_buffer = (sample_t*) malloc(PSP_NUM_AUDIO_SAMPLES * sizeof(sample_t));
	sceKernelDelayThread(200000);	
	pspAudioSetChannelCallback(0, audioOutputLoopCallback, NULL);
}

void my_error_handler(void)
{
pspDebugScreenSetXY(18, 28);
printf("     MIKMOD LIBRARY ERROR ");
return;
}
static int AudioChannelThread(int args, void *argp)
{
  while (!done) {
  MikMod_Update();
  sceKernelDelayThread(1);
  }
  return (0);
}

extern UWORD md_mode;
extern UBYTE md_reverb;
extern UBYTE md_pansep;

int main(void) {

wc = -eqrad;

	MODULE *mf = NULL; // for mod

	int maxchan = 128;
	pspDebugScreenInit();
  
	MikMod_RegisterErrorHandler(my_error_handler);
	MikMod_RegisterAllDrivers();
	MikMod_RegisterAllLoaders();

	md_mode = DMODE_16BITS|DMODE_STEREO|DMODE_SOFT_SNDFX|DMODE_SOFT_MUSIC; 
	md_reverb = 0;
	md_pansep = 128;
  if (MikMod_Init(""))
  {
pspDebugScreenSetXY(18, 28);
printf("     MIKMOD LIBRARY ERROR ");
    pspAudioEnd();
    sceKernelExitGame();
    return 0;
  }
  
  MikMod_SetNumVoices(-1, 8);
  MikMod_EnableOutput();

  if ((mikModThreadID = sceKernelCreateThread("MikMod" ,(void*)&AudioChannelThread,0x12,0x10000,0,NULL)) > 0)
  {
    sceKernelStartThread(mikModThreadID, 0 , NULL);
  }
  else
  {
pspDebugScreenSetXY(18, 28);
printf("     MIKMOD LIBRARY ERROR ");
    pspAudioEnd();
    sceKernelExitGame();
    return 0;
  }

			//*************** X-Flash Program Starts Here ***************

	int i = 0; SceCtrlData pad;

	sceCtrlSetSamplingCycle(0);
	sceCtrlSetSamplingMode(PSP_CTRL_MODE_DIGITAL);

	sceIoUnassign("flash0:"); 
	sceIoAssign("flash0:", "lflash0:0,0", "flashfat0:", 0, NULL, 0);

	sceIoUnassign("flash1:"); 
	sceIoAssign("flash1:", "lflash1:0,1", "flashfat1:", 0, NULL, 0);

	read_settings(); //read user settings from file

	loop_buffer = NULL;
	pspAudioInit();
	audioLoopStart();

	if (settings[0x47] == 0x31){ //Check for mute sample player setting
	mute = 1;    		        //set RAM mute status if read as set
	}

	if (settings[0x44] == 0x31){ //Check for agreement status save
	agreement = 0x01;            //set RAM agreement status if read as saved
	}

	if (settings[0x45] == 0x31){ //Check for Free Space Easter Egg status save
	freespace = 0x01;            //set Free Space status if read as saved
	}

	if (settings[0x46] != 0){ 		// Check for previous free space high score
	settings[0x46] = settings[0x46] ^ 0x5f;	// simple xor unencrypt high score byte
	fshiscore = settings[0x46] * 40;	// set free space high score to that read from file
	}					//
	if (settings[0x46] == 0){ 		//
	fshiscore = 8040;			// set free space high score to default testing hi score
	}					//

	while (1) {
	if (agreement != 0x01) {     // skip disclaimer screen if already agreed

	settings[0x64] = 0x34; // set a default colour theme because file isn't written yet

	pspDebugScreenInit();
	pspDebugScreenSetTextColor(0x000A0AEE);
	pspDebugScreenSetBackColor(0x00000000);

	// English Disclaimer
	pspDebugScreenSetXY(0, 4);
	printf("                             DISCLAIMER:\n\n");
	pspDebugScreenSetTextColor(0x00EFDDCA);
	printf("           This software modifies flash memory of the PSP.\n");
	printf("           As the end user, you accept any risk associated\n");
	printf("               with the use or misuse of this software.\n");
	printf("       This software is provided without warranty of any kind.\n\n");

	printf("          Any software that performs modification of flash\n");
	printf("          files of the PSP has the potential to render the\n");
	printf("              subject PSP unit permanently inoperative.\n\n");
	printf("\n\n\n");

	// German Disclaimer
	pspDebugScreenSetTextColor(0x000A0AEE);
	printf("                       EINVERSTANDNISERKLARUNG: \n\n");
	pspDebugScreenSetTextColor(0x00EFDDCA);
	printf("            Dieses Programm schreibt Dateien in den Flash\n");
	printf("      Speicher deiner PSP, es besteht dadurch ein hohes Risiko,\n");
	printf("              dass die PSP durch eine falsche Datei o.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -