Strange crash problem, resolved with a printf (long code)

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

Moderators: cheriff, TyRaNiD

Post Reply
weltall
Posts: 310
Joined: Fri Feb 20, 2004 1:56 am
Contact:

Strange crash problem, resolved with a printf (long code)

Post by weltall »

I'm modifying a sexypsf port by yaneurao by adding some function, but i have a strange problem:
I use the same function with some modifications for psp keypad and psp remote but the remote one if i don't add a printf after having changed the psp clock and before calling another function filling a third printf_line function of variables, it just freeze and shout down the psp.
here the code (it's long)
search for "// <-- HACK_THERE" to find where is the problem

Code: Select all

// ===========================================================================
//
// sexypsf for PSP
// Copyright &#40;C&#41; 2005 Sumire Kinoshita
// Copyright &#40;C&#41; 2005 Weltall
//
// 0.4.5-r1 &#40;2005/7/13&#41;
//   - ¥Õ¥¡¡¼¥¹¥È¥ê¥ê¡¼¥¹¡£
//
// ===========================================================================

#include <pspkernel.h>
#include <pspthreadman.h>
#include <psppower.h>
#include <pspctrl.h>
#include <pspaudio.h>
#include <pspdebug.h>
#include <psphprm.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#define _SPSF_TYPES_H__
#include <driver.h>

// ===========================================================================
//
// ¥Þ¥¯¥í¤ÎÄêµÁ¡£
//
// ===========================================================================

// ¥â¥¸¥å¡¼¥ë̾   &#58; sexypsf
// ¥â¥¸¥å¡¼¥ë°À­ &#58; ̵¤·
// ¥Ð¡¼¥¸¥ç¥ó     &#58; 0.1
PSP_MODULE_INFO&#40;"sexypsf", 0, 0, 1&#41;;

// ¥¹¥ì¥Ã¥É°À­ &#58; ¥æ¡¼¥¶¡¼¥â¡¼¥É / VFPU ¥¢¥¯¥»¥¹Í­¸ú
PSP_MAIN_THREAD_ATTR&#40;THREAD_ATTR_USER | THREAD_ATTR_VFPU&#41;;

#define MAX_ENTRY 1024 // ºÇÂç¥Õ¥¡¥¤¥ë¿ô¡£
#define MAX_PATH  1024 // ºÇÂç¥Õ¥¡¥¤¥ë̾¡£

#define SAMPLE_COUNT PSP_AUDIO_SAMPLE_ALIGN&#40;1024&#41; // ¥Ö¥í¥Ã¥¯¤¢¤¿¤ê¤Î¥µ¥ó¥×¥ë¿ô¡£
#define SAMPLE_SIZE  &#40;SAMPLE_COUNT * 4&#41;           // ¥Ö¥í¥Ã¥¯¤¢¤¿¤ê¤Î¥Ð¥¤¥È¿ô¡£
#define BUFFER_COUNT 8                            // ¥Ð¥Ã¥Õ¥¡¤Î¸Ä¿ô¡£
#define BUFFER_SIZE  &#40;SAMPLE_SIZE * 64&#41;           // ¥Ð¥Ã¥Õ¥¡¤Î¥Ð¥¤¥È¿ô¡£

// ===========================================================================
//
// ÎóµóÂΤÎÄêµÁ¡£
//
// ===========================================================================

// ¥·¡¼¥ó¤ò¼¨¤¹ÎóµóÂΡ£
enum &#123;
	SCENE_DUMMY = 0,
	SCENE_FILER, // ¥Õ¥¡¥¤¥ëÁªÂò¡£
	SCENE_PLAY   // ±éÁÕ¡£
&#125;;

// ===========================================================================
//
// ÊÑ¿ô¤ÎÄêµÁ¡£
//
// ===========================================================================

static int audio_thread_id;       // ¥ª¡¼¥Ç¥£¥ª¥¹¥ì¥Ã¥É¤Î ID¡£
static u8 audio_thread_exit_flag; // ¥ª¡¼¥Ç¥£¥ª¥¹¥ì¥Ã¥É¤Î½ªÎ»¥Õ¥é¥°¡£
static int sexy_thread_id;        // ¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó¥¹¥ì¥Ã¥É¤Î ID¡£
static u8 sexy_thread_exit_flag;  // ¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó¥¹¥ì¥Ã¥É¤Î½ªÎ»¥Õ¥é¥°¡£

static u8 sound_buffer&#91;BUFFER_COUNT&#93;&#91;BUFFER_SIZE&#93;; // ¥µ¥¦¥ó¥É¥Ð¥Ã¥Õ¥¡¡£
static u8 sound_buffer_ready&#91;BUFFER_COUNT&#93;;        // ¥µ¥¦¥ó¥É¥Ð¥Ã¥Õ¥¡¤¬Ëþ¤¿¤µ¤ì¤Æ¤¤¤ë¤«¼¨¤¹¥Õ¥é¥°¡£
static u8 sound_read_index;                        // ¥µ¥¦¥ó¥É¥Ð¥Ã¥Õ¥¡¤ÎÆɤ߹þ¤ß¥¤¥ó¥Ç¥Ã¥¯¥¹¡£
static u32 sound_read_offset;                      // ¥µ¥¦¥ó¥É¥Ð¥Ã¥Õ¥¡¤ÎÆɤ߹þ¤ß¥ª¥Õ¥»¥Ã¥È¡£
static u8 sound_write_index;                       // ¥µ¥¦¥ó¥É¥Ð¥Ã¥Õ¥¡¤Î½ñ¤­¹þ¤ß¥¤¥ó¥Ç¥Ã¥¯¥¹¡£
static u32 sound_write_offset;                     // ¥µ¥¦¥ó¥É¥Ð¥Ã¥Õ¥¡¤Î½ñ¤­¹þ¤ß¥ª¥Õ¥»¥Ã¥È¡£

static int current_scene;      // ¸½ºß¤Î¥·¡¼¥ó¡£
static int filer_scene_index;  // ¥Õ¥¡¥¤¥ëÁªÂò²èÌ̤Îɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹¡£
static int filer_scene_select; // ¥Õ¥¡¥¤¥ëÁªÂò²èÌ̤ÎÁªÂò¥¤¥ó¥Ç¥Ã¥¯¥¹¡£

static PSFINFO *psf_info;               // PSFINFO ¹½Â¤ÂΡ£
static char current_psf_path&#91;MAX_PATH&#93;; // ¸½ºß¤Î PSF ¥Õ¥¡¥¤¥ë¤Î¥Ñ¥¹¡£

static char current_directory&#91;MAX_PATH&#93;;       // ¸½ºß¤Î¥Ç¥£¥ì¥¯¥È¥ê¡£
static SceIoDirent current_dirents&#91;MAX_ENTRY&#93;; // ¸½ºß¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Î¥Õ¥¡¥¤¥ë°ìÍ÷¡£
static int current_dirents_count;              // ¸½ºß¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Î¥Õ¥¡¥¤¥ë¿ô¡£

u8 enable_reverb; // ¥ê¥Ð¡¼¥Ö¤ÎÍ­¸ú / ̵¸ú¥Õ¥é¥°¡£../spu/spu.c ¤è¤ê»²¾È¤µ¤ì¤ë¡£
int thread_paused = 0;

// ===========================================================================
//
// ´Ø¿ô¤ÎÄêµÁ¡£
//
// ===========================================================================

// ---------------------------------------------------------------------------
// audio_thread
//
// ¥ª¡¼¥Ç¥£¥ª¥¹¥ì¥Ã¥É¡£
//
// °ú¿ô &#58;
//   args &#58; ̤»ÈÍÑ¡£
//   argp &#58; ̤»ÈÍÑ¡£
//
// Ìá¤êÃÍ &#58;
//   ¾ï¤Ë 0¡£
// ---------------------------------------------------------------------------
static int audio_thread&#40;SceSize args, void *argp&#41;
&#123;
	int audio_handle; // ¥ª¡¼¥Ç¥£¥ª¥Á¥ã¥ó¥Í¥ë¤Î¥Ï¥ó¥É¥ë¡£
	
	// ¥ª¡¼¥Ç¥£¥ª¥Á¥ã¥ó¥Í¥ë¤Î¼èÆÀ¡£
	audio_handle = sceAudioChReserve&#40;
		PSP_AUDIO_NEXT_CHANNEL, SAMPLE_COUNT, PSP_AUDIO_FORMAT_STEREO&#41;;
	
	// ¥¹¥ì¥Ã¥É¤Î½ªÎ»¥Õ¥é¥°¤¬Î©¤Ä¤Þ¤Ç¥ë¡¼¥×¡£
	while&#40;!audio_thread_exit_flag&#41;
	&#123;
		// ¥¦¥§¥¤¥È¡£&#40;10 ms&#41;
		sceKernelDelayThread&#40;10000&#41;;
		
		// Âоݥµ¥¦¥ó¥É¥Ð¥Ã¥Õ¥¡¤¬Ëþ¤¿¤µ¤ì¤ë¤Þ¤ÇÂԤġ£
		if&#40;!sound_buffer_ready&#91;sound_read_index&#93;&#41; &#123;
			continue;
		&#125;
		
		// Âоݥµ¥¦¥ó¥É¥Ð¥Ã¥Õ¥¡¤«¤é 1 ¥Ö¥í¥Ã¥¯Ê¬½ÐÎϤ¹¤ë¡£
		sceAudioOutputPannedBlocking&#40;
			audio_handle, PSP_AUDIO_VOLUME_MAX, PSP_AUDIO_VOLUME_MAX,
			&sound_buffer&#91;sound_read_index&#93;&#91;sound_read_offset&#93;&#41;;
		
		// Æɤ߹þ¤ß¥ª¥Õ¥»¥Ã¥È¤ò¿Ê¤á¤ë¡£
		sound_read_offset += SAMPLE_SIZE;
		
		// Âоݥµ¥¦¥ó¥É¥Ð¥Ã¥Õ¥¡¤«¤éÁ´¤Æ½ÐÎϤ¬ºÑ¤ó¤À¤«¡©
		if&#40;sound_read_offset >= BUFFER_SIZE&#41; &#123;
			// ¼¡¤Î¥µ¥¦¥ó¥É¥Ð¥Ã¥Õ¥¡¤ò»²¾È¤¹¤ë¤è¤¦¤ËÀÚ¤êÂؤ¨¤ë¡£
			sound_buffer_ready&#91;sound_read_index&#93; = 0;
			sound_read_index++;
			sound_read_offset = 0;
			
			// ºÇ¸å¤Î¥µ¥¦¥ó¥É¥Ð¥Ã¥Õ¥¡¤Ë㤷¤¿¤«¡©
			if&#40;sound_read_index >= BUFFER_COUNT&#41; &#123;
				// ºÇ½é¤Î¥µ¥¦¥ó¥É¥Ð¥Ã¥Õ¥¡¤ò»²¾È¤¹¤ë¤è¤¦¤ËÀÚ¤êÂؤ¨¤ë¡£
				sound_read_index = 0;
			&#125;
		&#125;
	&#125;
	
	// ̵²»¤Î¥Ö¥í¥Ã¥¯¤ò½ÐÎϤ¹¤ë¡£¼¡²óºÆÀ¸»þ¤Î¥×¥Á¥Î¥¤¥ºËÉ»ßÍÑ¡£
	sceAudioOutputPannedBlocking&#40;audio_handle, 0, 0, sound_buffer&#91;0&#93;&#41;;
	
	// ¥ª¡¼¥Ç¥£¥ª¥Á¥ã¥ó¥Í¥ë¤Î²òÊü¡£
	sceAudioChRelease&#40;audio_handle&#41;;
	
	// ¥¹¥ì¥Ã¥É¤Î½ªÎ»¡£
	sceKernelExitThread&#40;0&#41;;
	
	// Àµ¾ï½ªÎ»¡£
	return 0;
&#125;

// ---------------------------------------------------------------------------
// sexy_thread
//
// ¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó¥¹¥ì¥Ã¥É¡£
//
// °ú¿ô &#58;
//   args &#58; ̤»ÈÍÑ¡£
//   argp &#58; ̤»ÈÍÑ¡£
//
// Ìá¤êÃÍ &#58;
//   ¾ï¤Ë 0¡£
// ---------------------------------------------------------------------------
static int sexy_thread&#40;SceSize args, void *argp&#41;
&#123;
	// Æ°ºî¥¯¥í¥Ã¥¯¤ò 333MHz ¤ËÊѹ¹¡£
	scePowerSetClockFrequency&#40;333, 333, 166&#41;;


	
	// ¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó³«»Ï¡£sexy_stop&#40;&#41; ¤¬¸Æ¤Ð¤ì¤ë¤Þ¤ÇÌá¤é¤Ê¤¤¡£
	// ¥µ¥ó¥×¥ë¤¬À¸À®¤µ¤ì¤¿»þÅÀ¤Ç sexyd_update&#40;&#41; ¤¬¸Æ¤Ð¤ì¤ë¡£
	sexy_execute&#40;&#41;;
	
	// Æ°ºî¥¯¥í¥Ã¥¯¤ò 222MHz ¤ËÊѹ¹¡£
	scePowerSetClockFrequency&#40;222, 222, 111&#41;;

	
	// ¥¹¥ì¥Ã¥É¤Î½ªÎ»¡£
	sceKernelExitThread&#40;0&#41;;
	
	// Àµ¾ï½ªÎ»¡£
	return 0;
&#125;

// ---------------------------------------------------------------------------
// sexyd_update
//
// ¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó¤Ç¥µ¥ó¥×¥ë¤¬À¸À®¤µ¤ì¤¿¤é¸Æ¤Ð¤ì¤ë´Ø¿ô¡£
//
// °ú¿ô &#58;
//   buffer &#58; À¸À®¤µ¤ì¤¿¥µ¥ó¥×¥ë¡£&#40;44100 Hz / 16 bit / Stereo&#41;
//   length &#58; buffer ¤Î¥Ð¥¤¥È¿ô¡£
//
// Ìá¤êÃÍ &#58;
//   ̵¤·¡£
// ---------------------------------------------------------------------------
void sexyd_update&#40;u8 *buffer, int length&#41;
&#123;
	int buffer_free_length; // ÂоݥХåե¡¤Î»Ä¤ê¥µ¥¤¥º¡£
	
	// Âоݥµ¥¦¥ó¥É¥Ð¥Ã¥Õ¥¡¤¬¶õ¤Ë¤Ê¤ë¤Þ¤ÇÂԤġ£
	do
	&#123;
		// ¥¦¥§¥¤¥È¡£&#40;0.01 ms&#41;
		sceKernelDelayThread&#40;10&#41;;
		
		// ¥¹¥ì¥Ã¥É¤Î½ªÎ»¥Õ¥é¥°¤¬Î©¤Ã¤Æ¤¤¤ë¤«¡©
		if&#40;sexy_thread_exit_flag&#41; &#123;
			// ¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó¤òÄä»ß¤µ¤»¤ë¡£
			sexy_stop&#40;&#41;;
			// Àµ¾ï½ªÎ»¡£
			return;
		&#125;
		
next&#58;;
	&#125; while&#40;sound_buffer_ready&#91;sound_write_index&#93;&#41;;
	
	// ÂоݥХåե¡¤Î»Ä¤ê¥µ¥¤¥º¤ò·×»»¤¹¤ë¡£
	buffer_free_length = BUFFER_SIZE - sound_write_offset;
	
	// ÂоݥХåե¡¤ËÁ´¤Æ¤Î¥µ¥ó¥×¥ë¤ò½ñ¤­¹þ¤á¤ë¤«¡©
	if&#40;buffer_free_length >= length&#41; &#123;
		// ÂоݥХåե¡¤ËÁ´¤Æ¤Î¥µ¥ó¥×¥ë¤ò½ñ¤­¹þ¤à¡£
		memcpy&#40;&sound_buffer&#91;sound_write_index&#93;&#91;sound_write_offset&#93;, buffer, length&#41;;
		
		// ½ñ¤­¹þ¤ß¥ª¥Õ¥»¥Ã¥È¤ò¿Ê¤á¤ë¡£
		sound_write_offset += length;
	&#125; else &#123;
		// ÂоݥХåե¡¤Î»Ä¤ê¥µ¥¤¥ºÊ¬¤À¤±¥µ¥ó¥×¥ë¤ò½ñ¤­¹þ¤à¡£
		memcpy&#40;&sound_buffer&#91;sound_write_index&#93;&#91;sound_write_offset&#93;, buffer, buffer_free_length&#41;;
		
		// ½ñ¤­¹þ¤ó¤Àʬ¤À¤±¥µ¥ó¥×¥ë¤Î¥Ð¥Ã¥Õ¥¡¥Ý¥¤¥ó¥¿¤È¥µ¥¤¥º¤òÄ´À°¤¹¤ë¡£
		buffer += buffer_free_length;
		length -= buffer_free_length;
		
		// ¼¡¤Î¥µ¥¦¥ó¥É¥Ð¥Ã¥Õ¥¡¤ò»²¾È¤¹¤ë¤è¤¦¤ËÀÚ¤êÂؤ¨¤ë¡£
		sound_buffer_ready&#91;sound_write_index&#93; = 1;
		sound_write_index++;
		sound_write_offset = 0;
		
		// ºÇ¸å¤Î¥µ¥¦¥ó¥É¥Ð¥Ã¥Õ¥¡¤Ë㤷¤¿¤«¡©
		if&#40;sound_write_index >= BUFFER_COUNT&#41; &#123;
			// ºÇ½é¤Î¥µ¥¦¥ó¥É¥Ð¥Ã¥Õ¥¡¤ò»²¾È¤¹¤ë¤è¤¦¤ËÀÚ¤êÂؤ¨¤ë¡£
			sound_write_index = 0;
		&#125;
		
		// »Ä¤ê¤Î¥µ¥ó¥×¥ë¤ò½ñ¤­¹þ¤à¤¿¤á¤Ë¡¢¼¡¤Î¥µ¥¦¥ó¥É¥Ð¥Ã¥Õ¥¡¤¬¶õ¤Ë¤Ê¤ë¤Î¤òÂԤġ£
		goto next;
	&#125;
&#125;

// ---------------------------------------------------------------------------
// psf_play
//
// PSF ¥Õ¥¡¥¤¥ë¤Î±éÁÕ³«»Ï¡£
//
// °ú¿ô &#58;
//   ̵¤·¡£
//
// Ìá¤êÃÍ &#58;
//   À®¸ù»þ¤Ï 0¡¢¤½¤ì°Ê³°¤Ï -1¡£
// ---------------------------------------------------------------------------
static int psf_play&#40;&#41;
&#123;
	int i; // ÈÆÍÑÊÑ¿ô¡£
	thread_paused = 0;
	// PSF ¤ÎÆɤ߹þ¤ß¡£
	psf_info = sexy_load&#40;current_psf_path&#41;;
	
	// PSFINFO ¹½Â¤ÂΤÏÍ­¸ú¤«¡©
	if&#40;psf_info&#41; &#123;
		// ¥µ¥¦¥ó¥É¥Ð¥Ã¥Õ¥¡¤Î½é´ü²½¡£
		for&#40;i = 0; i < BUFFER_COUNT; i++&#41;
		&#123;
			memset&#40;sound_buffer&#91;i&#93;, 0, BUFFER_SIZE&#41;;
			sound_buffer_ready&#91;i&#93; = 0;
		&#125;
		
		// ¥µ¥¦¥ó¥É¥Ð¥Ã¥Õ¥¡¤ÎÆɤ߽ñ¤­¥¤¥ó¥Ç¥Ã¥¯¥¹ / ¥ª¥Õ¥»¥Ã¥È¤Î½é´ü²½¡£
		sound_read_index   = 0;
		sound_read_offset  = 0;
		sound_write_index  = 0;
		sound_write_offset = 0;
		
		// ¥ª¡¼¥Ç¥£¥ª¥¹¥ì¥Ã¥É¤ÎÀ¸À®¤È³«»Ï¡£
		audio_thread_id = sceKernelCreateThread&#40;"audio_thread", audio_thread, 18, 65536, 0, 0&#41;;
		audio_thread_exit_flag = 0;
		sceKernelStartThread&#40;audio_thread_id, 0, 0&#41;;
		
		// ¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó¥¹¥ì¥Ã¥É¤ÎÀ¸À®¤È³«»Ï¡£
		sexy_thread_id = sceKernelCreateThread&#40;"sexy_thread", sexy_thread, 32, 65536, 0, 0&#41;;
		sexy_thread_exit_flag  = 0;
		sceKernelStartThread&#40;sexy_thread_id, 0, 0&#41;;
		
		// Àµ¾ï½ªÎ»¡£
		return 0;
	&#125; else &#123;
		// ¥¨¥é¡¼½ªÎ»¡£
		return -1;
	&#125;
&#125;

// ---------------------------------------------------------------------------
// psf_stop
//
// PSF ¥Õ¥¡¥¤¥ë¤Î±éÁÕÄä»ß¡£
//
// °ú¿ô &#58;
//   ̵¤·¡£
//
// Ìá¤êÃÍ &#58;
//   ̵¤·¡£
// ---------------------------------------------------------------------------
static void psf_stop&#40;&#41;
&#123;
	// PSFINFO ¹½Â¤ÂΤÏÍ­¸ú¤«¡©
	if&#40;thread_paused == 1&#41;
		&#123;
			scePowerSetCpuClockFrequency&#40;333&#41;;
			scePowerSetBusClockFrequency&#40;166&#41;;
			sceKernelResumeThread&#40;sexy_thread_id&#41;;
			sceKernelResumeThread&#40;audio_thread_id&#41;;
			//	printf_line&#40;1,"unpaused"&#41;;
			thread_paused = 0;
		&#125;
	if&#40;psf_info&#41; &#123;
		// ¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó¥¹¥ì¥Ã¥É¤ÎÄä»ß¤ÈÇË´þ¡£
		sexy_thread_exit_flag = 1;
		sceKernelWaitThreadEnd&#40;sexy_thread_id, 0&#41;;
		sceKernelDeleteThread&#40;sexy_thread_id&#41;;
		
		// ¥ª¡¼¥Ç¥£¥ª¥¹¥ì¥Ã¥É¤ÎÄä»ß¤ÈÇË´þ¡£
		audio_thread_exit_flag = 1;
		sceKernelWaitThreadEnd&#40;audio_thread_id, 0&#41;;
		sceKernelDeleteThread&#40;audio_thread_id&#41;;
		
		// PSFINFO ¹½Â¤ÂΤÎÇË´þ¡£
		sexy_freepsfinfo&#40;psf_info&#41;;
		psf_info = 0;
		thread_paused = 0;

	&#125;
&#125;

// ---------------------------------------------------------------------------
// set_dirents
//
// ¥Ç¥£¥ì¥¯¥È¥ê°ìÍ÷¤Î¼èÆÀ¡£
//
// °ú¿ô &#58;
//   ̵¤·¡£
//
// Ìá¤êÃÍ &#58;
//   À®¸ù»þ¤Ï 0¡¢¤½¤ì°Ê³°¤Ï -1¡£
// ---------------------------------------------------------------------------
static int set_dirents&#40;&#41;
&#123;
	SceUID uid;         // ¥Ç¥£¥ì¥¯¥È¥ê¥¨¥ó¥È¥ê¤Î ID¡£
	SceIoDirent dirent; // ¥ï¡¼¥¯ÍѤΠSceIoDirent¡£
	char *extention;    // ¥Õ¥¡¥¤¥ë¤Î³ÈÄ¥»Ò¤Ø¤Î¥Ý¥¤¥ó¥¿¡£
	int r;              // ÈÆÍÑÊÑ¿ô¡£

	// ¥Ç¥£¥ì¥¯¥È¥ê¥¨¥ó¥È¥ê¤Î¼èÆÀ¡£
	uid = sceIoDopen&#40;current_directory&#41;;
	
	// ¥Ç¥£¥ì¥¯¥È¥ê¥¨¥ó¥È¥ê¤¬Ìµ¸ú¤«¡©
	if&#40;uid < 0&#41; &#123;
		// ¥¨¥é¡¼½ªÎ»¡£
		return -1;
	&#125;
	
	// ¥Õ¥¡¥¤¥ë°ìÍ÷¤Î¼èÆÀ¡£
	for&#40;current_dirents_count = 0; current_dirents_count < MAX_ENTRY;&#41;
	&#123;
		// ¥ï¡¼¥¯¤ò½é´ü²½¡£½é´ü²½¤·¤Ê¤±¤ì¤Ð sceIoDread ¤¬¥Õ¥ê¡¼¥º¤¹¤ë¡£
		memset&#40;&dirent, 0, sizeof&#40;SceIoDirent&#41;&#41;;
		
		// ¥¨¥ó¥È¥ê¾ðÊó¤ò¥ï¡¼¥¯¤ØÆɤ߹þ¤ß¡£
		r = sceIoDread&#40;uid, &dirent&#41;;
		
		// ¥Ç¥£¥ì¥¯¥È¥ê¤«¡©
		if&#40;FIO_SO_ISDIR&#40;dirent.d_stat.st_attr&#41;&#41; &#123;
			// ¥¨¥ó¥È¥ê¾ðÊó¤ò¥ï¡¼¥¯¤«¤é¸½ºß¤Î¥Ç¥£¥ì¥¯¥È¥ê°ìÍ÷¤Ø¥³¥Ô¡¼¡£
			memcpy&#40;&current_dirents&#91;current_dirents_count&#93;, &dirent, sizeof&#40;SceIoDirent&#41;&#41;;
			
			// ¸½ºß¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Î¥Õ¥¡¥¤¥ë¿ô¤ò¥¤¥ó¥¯¥ê¥á¥ó¥È¡£
			current_dirents_count++;
		&#125; else &#123;
			// ¥Õ¥¡¥¤¥ë̾¤«¤é³ÈÄ¥»Ò¤ò¼è¤ê½Ð¤¹¡£
			extention = strrchr&#40;dirent.d_name, '.'&#41;;
			
			// ³ÈÄ¥»Ò¤¬Â¸ºß¤¹¤ë¤«¡©
			if&#40;extention&#41; &#123;
				// ¥µ¥Ý¡¼¥È¤¹¤ë³ÈÄ¥»Ò¤«¡©
				if&#40;!stricmp&#40;extention, ".psf"&#41; || !stricmp&#40;extention, ".psf1"&#41; || !stricmp&#40;extention, ".minipsf"&#41;&#41; &#123;
					// ¥¨¥ó¥È¥ê¾ðÊó¤ò¥ï¡¼¥¯¤«¤é¸½ºß¤Î¥Ç¥£¥ì¥¯¥È¥ê°ìÍ÷¤Ø¥³¥Ô¡¼¡£
					memcpy&#40;&current_dirents&#91;current_dirents_count&#93;, &dirent, sizeof&#40;SceIoDirent&#41;&#41;;
					
					// ¸½ºß¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Î¥Õ¥¡¥¤¥ë¿ô¤ò¥¤¥ó¥¯¥ê¥á¥ó¥È¡£
					current_dirents_count++;
				&#125;
			&#125;
		&#125;
		
		// ºÇ¸å¤Î¥¨¥ó¥È¥ê¤«¡©
		if&#40;r <= 0&#41; &#123;
			break;
		&#125;
	&#125;
	
	// ¥Ç¥£¥ì¥¯¥È¥ê¥¨¥ó¥È¥ê¤Î²òÊü¡£
	sceIoDclose&#40;uid&#41;;
	
	// Àµ¾ï½ªÎ»¡£
	return 0;
&#125;

// ---------------------------------------------------------------------------
// printf_line
//
// »ØÄê¹Ô¤ËÂФ¹¤ë¥Õ¥©¡¼¥Þ¥Ã¥ÈºÑ¤ßʸ»úÎó¤Îɽ¼¨¡£
//
// °ú¿ô &#58;
//   y      &#58; ¹Ô¿ô¡£
//   format &#58; ¥Õ¥©¡¼¥Þ¥Ã¥Èʸ»úÎó¡£
//   ...    &#58; ¥Õ¥©¡¼¥Þ¥Ã¥È°ú¿ô¡£
//
// Ìá¤êÃÍ &#58;
//   ̵¤·¡£
// ---------------------------------------------------------------------------
static void printf_line&#40;int y, char *format, ...&#41;
&#123;
	va_list options; // ¼è¤ê½Ð¤·¤¿²ÄÊÑĹ°ú¿ô¡£
	char buffer&#91;68&#93;; // ʸ»úÎóÍѥХåե¡¡£68 ¤Ï 1 ¹Ô¤Ëɽ¼¨²Äǽ¤Êʸ»ú¿ô¡£
	int r;           // ÈÆÍÑÊÑ¿ô¡£
	
	// ²ÄÊÑĹ°ú¿ô¤ò¼è¤ê½Ð¤¹¡£
	va_start&#40;options, format&#41;;
	
	// ¥Õ¥©¡¼¥Þ¥Ã¥ÈºÑ¤ßʸ»úÎó¤òÆÀ¤ë¡£
	r = vsnprintf&#40;buffer, 68, format, options&#41;;
	
	// ¥Õ¥©¡¼¥Þ¥Ã¥ÈºÑ¤ßʸ»úÎó¤Ï 68 ʸ»ú¤òĶ¤¨¤Æ¤¤¤Ê¤¤¤«¡©
	if&#40;r >= 0&#41; &#123;
		// »Ä¤Ã¤¿Éôʬ¤ò¥¹¥Ú¡¼¥¹¤ÇËä¤á¤ë¡£
		memset&#40;&buffer&#91;r&#93;, ' ', 68 - r&#41;;
		
		// ¥¿¡¼¥ß¥Í¡¼¥È¤¹¤ë¡£
		buffer&#91;67&#93; = '\0';
	&#125;
	
	// ¥«¡¼¥½¥ë°ÌÃÖ¤òÀßÄꤹ¤ë¡£
	pspDebugScreenSetXY&#40;0, y&#41;;
	
	// ¥Õ¥©¡¼¥Þ¥Ã¥ÈºÑ¤ßʸ»úÎó¤òɽ¼¨¤¹¤ë¡£
	pspDebugScreenPrintf&#40;buffer&#41;;
&#125;

// ---------------------------------------------------------------------------
// filer_draw
//
// ¥Õ¥¡¥¤¥ëÁªÂò²èÌ̤Îɽ¼¨¡£¡£
//
// °ú¿ô &#58;
//   ̵¤·¡£
//
// Ìá¤êÃÍ &#58;
//   ̵¤·¡£
// ---------------------------------------------------------------------------
static void filer_draw&#40;&#41;
&#123;
	int i, j; // ÈÆÍÑÊÑ¿ô¡£
	
	// ¥Õ¥¡¥¤¥ëÁªÂò²èÌ̤Îɽ¼¨¡£
	printf_line&#40;0, current_directory&#41;;
	printf_line&#40;1, "===== File selector ==============================================="&#41;;
	
	for&#40;i = 2; i < 32; i++&#41;
	&#123;
		// ¥Õ¥¡¥¤¥ë°ìÍ÷¤ËÂФ¹¤ë¥¤¥ó¥Ç¥Ã¥¯¥¹¤òµá¤á¤ë¡£
		j = i - 2 + filer_scene_index;
		
		// ¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤¹¤ë¤«¡©
		if&#40;j < current_dirents_count&#41; &#123;
			printf_line&#40;i, "%s %s%s",
				// ¤³¤Î¥Õ¥¡¥¤¥ë¤¬ÁªÂò¤µ¤ì¤Æ¤¤¤ë¤Ê¤é¤Ð¡¢¥«¡¼¥½¥ë¤òÉղá£
				&#40;j == filer_scene_select&#41; ? ">" &#58; " ",
				// ¥Õ¥¡¥¤¥ë̾¡£
				current_dirents&#91;j&#93;.d_name,
				// ¥Ç¥£¥ì¥¯¥È¥ê¤Ç¤¢¤ì¤Ð¡¢ËöÈø¤Ë¥»¥Ñ¥ì¡¼¥¿¤òÉղá£
				FIO_SO_ISDIR&#40;current_dirents&#91;j&#93;.d_stat.st_attr&#41; ? "/" &#58; ""
			&#41;;
		&#125; else &#123;
			// ¶õÇò¹Ô¤òɽ¼¨¡£
			printf_line&#40;i, ""&#41;;
		&#125;
	&#125;
	
	printf_line&#40;32, "==================================================================="&#41;;
	printf_line&#40;33, "Cursor = Move / Circle = Play / Triangle = Toggle reverb        |%s|",
		// ¥ê¥Ð¡¼¥Ö¤¬Í­¸ú¤«¤É¤¦¤«¼¨¤¹¥¤¥ó¥¸¥±¡¼¥¿¡£
		enable_reverb ? "R" &#58; " "
	&#41;;
&#125;

// ---------------------------------------------------------------------------
// play_draw
//
// ±éÁÕ²èÌ̤Îɽ¼¨¡£¡£
//
// °ú¿ô &#58;
//   ̵¤·¡£
//
// Ìá¤êÃÍ &#58;
//   ̵¤·¡£
// ---------------------------------------------------------------------------
static void play_draw&#40;&#41;
&#123;
	int i; // ÈÆÍÑÊÑ¿ô¡£
	
	// ±éÁÕ²èÌ̤Îɽ¼¨¡£
	printf_line&#40; 0, current_dirents&#91;filer_scene_select&#93;.d_name&#41;;
	if&#40;thread_paused == 1&#41;
	printf_line&#40; 1, "===== PSF information ===============================PAUSED========"&#41;;
	else
	printf_line&#40; 1, "===== PSF information ============================================="&#41;;
	printf_line&#40; 2, "Game      &#58; %s", psf_info->game      ? psf_info->game      &#58; ""&#41;;
	printf_line&#40; 3, "Title     &#58; %s", psf_info->title     ? psf_info->title     &#58; ""&#41;;
	printf_line&#40; 4, "Artist    &#58; %s", psf_info->artist    ? psf_info->artist    &#58; ""&#41;;
	printf_line&#40; 5, "Year      &#58; %s", psf_info->year      ? psf_info->year      &#58; ""&#41;;
	printf_line&#40; 6, "Genre     &#58; %s", psf_info->genre     ? psf_info->genre     &#58; ""&#41;;
	printf_line&#40; 7, "PSF by    &#58; %s", psf_info->psfby     ? psf_info->psfby     &#58; ""&#41;;
	printf_line&#40; 8, "Copyright &#58; %s", psf_info->copyright ? psf_info->copyright &#58; ""&#41;;
	
	for&#40;i = 9; i < 32; i++&#41;
	&#123;
		// ¶õÇò¹Ô¤òɽ¼¨¡£
		printf_line&#40;i, ""&#41;;
	&#125;
	
	printf_line&#40;32, "==================================================================="&#41;;
	printf_line&#40;33, "Cross = Stop / Triangle = Toggle reverb                        |%s|",
		// ¥ê¥Ð¡¼¥Ö¤¬Í­¸ú¤«¤É¤¦¤«¼¨¤¹¥¤¥ó¥¸¥±¡¼¥¿¡£
		enable_reverb ? "R" &#58; " "
	&#41;;
&#125;

// ---------------------------------------------------------------------------
// filer_scene
//
// ¥Õ¥¡¥¤¥ëÁªÂò²èÌ̤Υ롼¥×½èÍý¡£
//
// °ú¿ô &#58;
//   buttons &#58; ²¡¤µ¤ì¤Æ¤¤¤ë¥Ü¥¿¥ó¡£
//
// Ìá¤êÃÍ &#58;
//   ̵¤·¡£
// ---------------------------------------------------------------------------
static void filer_scene&#40;int buttons&#41;
&#123;
	int i; // ÈÆÍÑÊÑ¿ô¡£
	
	// ¥«¡¼¥½¥ë¥Ü¥¿¥ó¤¬²¡¤µ¤ì¤¿¤«¡©
	if&#40;buttons & &#40;PSP_CTRL_UP | PSP_CTRL_RIGHT | PSP_CTRL_DOWN | PSP_CTRL_LEFT&#41;&#41; &#123;
		// ¥«¡¼¥½¥ë¥Ü¥¿¥ó¤ÎÊý¸þ¤Ë±þ¤¸¤¿°ÜÆ°Î̤òµá¤á¤ë¡£
		if&#40;buttons & PSP_CTRL_UP&#41; &#123;
			// 1 ¥¤¥ó¥Ç¥Ã¥¯¥¹Á°¤Ø°ÜÆ°¡£
			i = -1;
		&#125; else if&#40;buttons & PSP_CTRL_RIGHT&#41; &#123;
			// 10 ¥¤¥ó¥Ç¥Ã¥¯¥¹¼¡¤Ø°ÜÆ°¡£
			i = 10;
		&#125; else if&#40;buttons & PSP_CTRL_DOWN&#41; &#123;
			// 1 ¥¤¥ó¥Ç¥Ã¥¯¥¹¼¡¤Ø°ÜÆ°¡£
			i = 1;
		&#125; else &#123;
			// 10 ¥¤¥ó¥Ç¥Ã¥¯¥¹Á°¤Ø°ÜÆ°¡£
			i = -10;
		&#125;
		
		// ÁªÂò¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò°ÜÆ°¤µ¤»¤ë¡£
		filer_scene_select += i;
		
		// ÁªÂò¥¤¥ó¥Ç¥Ã¥¯¥¹¤¬¥Õ¥¡¥¤¥ë¿ô¤ÈƱ¤¸¤«Â礭¤¯¤Ê¤Ã¤¿¤«¡©
		if&#40;filer_scene_select >= current_dirents_count&#41; &#123;
			// ÁªÂò¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò¥¯¥ê¥Ã¥×¤¹¤ë¡£
			filer_scene_select = current_dirents_count - 1;
		// ÁªÂò¥¤¥ó¥Ç¥Ã¥¯¥¹¤¬ 0 ¤è¤ê¾®¤µ¤¯¤Ê¤Ã¤¿¤«¡©
		&#125; else if&#40;filer_scene_select < 0&#41; &#123;
			// ÁªÂò¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò¥¯¥ê¥Ã¥×¤¹¤ë¡£
			filer_scene_select = 0;
		&#125;
		
		// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹¤¬ÁªÂò¥¤¥ó¥Ç¥Ã¥¯¥¹¤è¤êÂ礭¤¯¤Ê¤Ã¤¿¤«¡©
		if&#40;filer_scene_index > filer_scene_select&#41; &#123;
			// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò°ÜÆ°¤µ¤»¤ë¡£
			filer_scene_index += i;
			
			// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹¤¬ 0 ¤è¤ê¾®¤µ¤¯¤Ê¤Ã¤¿¤«¡©
			if&#40;filer_scene_index < 0&#41; &#123;
				// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò¥¯¥ê¥Ã¥×¤¹¤ë¡£
				filer_scene_index = 0;
			&#125;
		// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹ + 30 ¤¬ÁªÂò¥¤¥ó¥Ç¥Ã¥¯¥¹¤ÈƱ¤¸¤«¾®¤µ¤¯¤Ê¤Ã¤¿¤«¡©
		&#125; else if&#40;filer_scene_index + 30 <= filer_scene_select&#41; &#123;
			// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò°ÜÆ°¤µ¤»¤ë¡£
			filer_scene_index += i;
			
			// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹ + 30 ¤¬¥Õ¥¡¥¤¥ë¿ô¤ÈƱ¤¸¤«Â礭¤¯¤Ê¤Ã¤¿¤«¡©
			if&#40;filer_scene_index + 30 >= current_dirents_count&#41; &#123;
				// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò¥¯¥ê¥Ã¥×¤¹¤ë¡£
				filer_scene_index = current_dirents_count - 30;
			&#125;
		&#125;
		
		// ²èÌ̤ò¹¹¿·¤¹¤ë¡£
		filer_draw&#40;&#41;;
	// ¡û¥Ü¥¿¥ó¤¬²¡¤µ¤ì¤¿¤«¡©
	&#125; else if&#40;buttons & PSP_CTRL_CIRCLE&#41; &#123;
		// ¥Ç¥£¥ì¥¯¥È¥ê¤«¡©
		if&#40;FIO_SO_ISDIR&#40;current_dirents&#91;filer_scene_select&#93;.d_stat.st_attr&#41;&#41; &#123;
			// ¥Ç¥£¥ì¥¯¥È¥ê̾¤Î 1 ¥Ð¥¤¥ÈÌܤ¬¥É¥Ã¥È¤«¡©
			if&#40;current_dirents&#91;filer_scene_select&#93;.d_name&#91;0&#93; == '.'&#41; &#123;
				// ¥Ç¥£¥ì¥¯¥È¥ê̾¤Î 2 ¥Ð¥¤¥ÈÌܤ¬¥É¥Ã¥È¤«¡©
				if&#40;current_dirents&#91;filer_scene_select&#93;.d_name&#91;1&#93; == '.'&#41; &#123;
					// ¸½ºß¤Î¥Ç¥£¥ì¥¯¥È¥ê¤òÊѹ¹¤¹¤ë¡£&#40;¿Æ¥Ç¥£¥ì¥¯¥È¥ê¤Ø&#41;
					current_directory&#91;strlen&#40;current_directory&#41; - 1&#93; = '\0';
					*&#40;strrchr&#40;current_directory, '/'&#41; + 1&#41; = '\0';
				&#125;
			&#125; else &#123;
				// ¸½ºß¤Î¥Ç¥£¥ì¥¯¥È¥ê¤òÊѹ¹¤¹¤ë¡£&#40;̾Á°¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Ø&#41;
				strcat&#40;current_directory, current_dirents&#91;filer_scene_select&#93;.d_name&#41;;
				strcat&#40;current_directory, "/"&#41;;
			&#125;
			
			// ¥Ç¥£¥ì¥¯¥È¥ê°ìÍ÷¤ò¹¹¿·¤¹¤ë¡£
			set_dirents&#40;&#41;;
			// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò½é´ü²½¡£
			filer_scene_index  = 0;
			// ÁªÂò¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò½é´ü²½¡£
			filer_scene_select = 0;
			// ²èÌ̤ò¹¹¿·¤¹¤ë¡£
			filer_draw&#40;&#41;;
		&#125; else &#123;
			// PSF ¥Õ¥¡¥¤¥ë¤Î¥Ñ¥¹¤òÀ¸À®¤¹¤ë¡£
			strcpy&#40;current_psf_path, current_directory&#41;;
			strcat&#40;current_psf_path, current_dirents&#91;filer_scene_select&#93;.d_name&#41;;
			
			// ±éÁÕ¤ò³«»Ï¤¹¤ë¡£Àµ¾ï¤Ë³«»Ï¤µ¤ì¤¿¤«¡©
			if&#40;psf_play&#40;&#41; >= 0&#41; &#123;
				// ¸½ºß¤Î¥·¡¼¥ó¤ò¡Ö±éÁաפËÀßÄê¡£
				current_scene = SCENE_PLAY;
				// ²èÌ̤ò¹¹¿·¤¹¤ë¡£
				play_draw&#40;&#41;;
			&#125;
		&#125;
	// ¢¤¥Ü¥¿¥ó¤¬²¡¤µ¤ì¤¿¤«¡©
	&#125; else if&#40;buttons & PSP_CTRL_TRIANGLE&#41; &#123;
		// ¥ê¥Ð¡¼¥Ö¤ÎÍ­¸ú / ̵¸ú¤òÀÚ¤êÂؤ¨¤ë¡£
		enable_reverb ^= 1;
		// ²èÌ̤ò¹¹¿·¤¹¤ë¡£
		filer_draw&#40;&#41;;
	&#125;
&#125;

// ---------------------------------------------------------------------------
// filer_scene_remote
//
// ¥Õ¥¡¥¤¥ëÁªÂò²èÌ̤Υ롼¥×½èÍý¡£
//
// °ú¿ô &#58;
//   buttons &#58; ²¡¤µ¤ì¤Æ¤¤¤ë¥Ü¥¿¥ó¡£
//
// Ìá¤êÃÍ &#58;
//   ̵¤·¡£
// ---------------------------------------------------------------------------
static void filer_scene_remote&#40;u32 buttons&#41;
&#123;
	#define PSP_HPRM_VOL_UP_DOWN 0x30
	int i; // ÈÆÍÑÊÑ¿ô¡£
	
	// ¥«¡¼¥½¥ë¥Ü¥¿¥ó¤¬²¡¤µ¤ì¤¿¤«¡©
	if&#40;buttons & &#40;PSP_HPRM_FORWARD | PSP_HPRM_BACK&#41;&#41; &#123;
		// ¥«¡¼¥½¥ë¥Ü¥¿¥ó¤ÎÊý¸þ¤Ë±þ¤¸¤¿°ÜÆ°Î̤òµá¤á¤ë¡£
		if&#40;buttons & PSP_HPRM_BACK&#41; &#123;
			// 1 ¥¤¥ó¥Ç¥Ã¥¯¥¹Á°¤Ø°ÜÆ°¡£
			i = -1;
		&#125; else if&#40;buttons & PSP_HPRM_FORWARD&#41; &#123;
			// 1 ¥¤¥ó¥Ç¥Ã¥¯¥¹¼¡¤Ø°ÜÆ°¡£
			i = 1;
		&#125;
		
		// ÁªÂò¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò°ÜÆ°¤µ¤»¤ë¡£
		filer_scene_select += i;
		
		// ÁªÂò¥¤¥ó¥Ç¥Ã¥¯¥¹¤¬¥Õ¥¡¥¤¥ë¿ô¤ÈƱ¤¸¤«Â礭¤¯¤Ê¤Ã¤¿¤«¡©
		if&#40;filer_scene_select >= current_dirents_count&#41; &#123;
			// ÁªÂò¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò¥¯¥ê¥Ã¥×¤¹¤ë¡£
			filer_scene_select = current_dirents_count - 1;
		// ÁªÂò¥¤¥ó¥Ç¥Ã¥¯¥¹¤¬ 0 ¤è¤ê¾®¤µ¤¯¤Ê¤Ã¤¿¤«¡©
		&#125; else if&#40;filer_scene_select < 0&#41; &#123;
			// ÁªÂò¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò¥¯¥ê¥Ã¥×¤¹¤ë¡£
			filer_scene_select = 0;
		&#125;
		
		// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹¤¬ÁªÂò¥¤¥ó¥Ç¥Ã¥¯¥¹¤è¤êÂ礭¤¯¤Ê¤Ã¤¿¤«¡©
		if&#40;filer_scene_index > filer_scene_select&#41; &#123;
			// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò°ÜÆ°¤µ¤»¤ë¡£
			filer_scene_index += i;
			
			// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹¤¬ 0 ¤è¤ê¾®¤µ¤¯¤Ê¤Ã¤¿¤«¡©
			if&#40;filer_scene_index < 0&#41; &#123;
				// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò¥¯¥ê¥Ã¥×¤¹¤ë¡£
				filer_scene_index = 0;
			&#125;
		// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹ + 30 ¤¬ÁªÂò¥¤¥ó¥Ç¥Ã¥¯¥¹¤ÈƱ¤¸¤«¾®¤µ¤¯¤Ê¤Ã¤¿¤«¡©
		&#125; else if&#40;filer_scene_index + 30 <= filer_scene_select&#41; &#123;
			// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò°ÜÆ°¤µ¤»¤ë¡£
			filer_scene_index += i;
			
			// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹ + 30 ¤¬¥Õ¥¡¥¤¥ë¿ô¤ÈƱ¤¸¤«Â礭¤¯¤Ê¤Ã¤¿¤«¡©
			if&#40;filer_scene_index + 30 >= current_dirents_count&#41; &#123;
				// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò¥¯¥ê¥Ã¥×¤¹¤ë¡£
				filer_scene_index = current_dirents_count - 30;
			&#125;
		&#125;
		
		// ²èÌ̤ò¹¹¿·¤¹¤ë¡£
		filer_draw&#40;&#41;;
	// ¡û¥Ü¥¿¥ó¤¬²¡¤µ¤ì¤¿¤«¡©
	&#125; else if&#40;buttons & PSP_HPRM_PLAYPAUSE&#41; &#123;
		// ¥Ç¥£¥ì¥¯¥È¥ê¤«¡©
		if&#40;FIO_SO_ISDIR&#40;current_dirents&#91;filer_scene_select&#93;.d_stat.st_attr&#41;&#41; &#123;
			// ¥Ç¥£¥ì¥¯¥È¥ê̾¤Î 1 ¥Ð¥¤¥ÈÌܤ¬¥É¥Ã¥È¤«¡©
			if&#40;current_dirents&#91;filer_scene_select&#93;.d_name&#91;0&#93; == '.'&#41; &#123;
				// ¥Ç¥£¥ì¥¯¥È¥ê̾¤Î 2 ¥Ð¥¤¥ÈÌܤ¬¥É¥Ã¥È¤«¡©
				if&#40;current_dirents&#91;filer_scene_select&#93;.d_name&#91;1&#93; == '.'&#41; &#123;
					// ¸½ºß¤Î¥Ç¥£¥ì¥¯¥È¥ê¤òÊѹ¹¤¹¤ë¡£&#40;¿Æ¥Ç¥£¥ì¥¯¥È¥ê¤Ø&#41;
					current_directory&#91;strlen&#40;current_directory&#41; - 1&#93; = '\0';
					*&#40;strrchr&#40;current_directory, '/'&#41; + 1&#41; = '\0';
				&#125;
			&#125; else &#123;
				// ¸½ºß¤Î¥Ç¥£¥ì¥¯¥È¥ê¤òÊѹ¹¤¹¤ë¡£&#40;̾Á°¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Ø&#41;
				strcat&#40;current_directory, current_dirents&#91;filer_scene_select&#93;.d_name&#41;;
				strcat&#40;current_directory, "/"&#41;;
			&#125;
			
			// ¥Ç¥£¥ì¥¯¥È¥ê°ìÍ÷¤ò¹¹¿·¤¹¤ë¡£
			set_dirents&#40;&#41;;
			// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò½é´ü²½¡£
			filer_scene_index  = 0;
			// ÁªÂò¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò½é´ü²½¡£
			filer_scene_select = 0;
			// ²èÌ̤ò¹¹¿·¤¹¤ë¡£
			filer_draw&#40;&#41;;
		&#125; else &#123;
			// PSF ¥Õ¥¡¥¤¥ë¤Î¥Ñ¥¹¤òÀ¸À®¤¹¤ë¡£
			strcpy&#40;current_psf_path, current_directory&#41;;
			strcat&#40;current_psf_path, current_dirents&#91;filer_scene_select&#93;.d_name&#41;;
			
			// ±éÁÕ¤ò³«»Ï¤¹¤ë¡£Àµ¾ï¤Ë³«»Ï¤µ¤ì¤¿¤«¡©
			if&#40;psf_play&#40;&#41; >= 0&#41; &#123;
				// ¸½ºß¤Î¥·¡¼¥ó¤ò¡Ö±éÁաפËÀßÄê¡£
				current_scene = SCENE_PLAY;
				// ²èÌ̤ò¹¹¿·¤¹¤ë¡£
				play_draw&#40;&#41;;
			&#125;
		&#125;
	// ¢¤¥Ü¥¿¥ó¤¬²¡¤µ¤ì¤¿¤«¡©
	&#125; else if&#40;buttons & PSP_HPRM_VOL_UP_DOWN&#41; &#123;
		// ¥ê¥Ð¡¼¥Ö¤ÎÍ­¸ú / ̵¸ú¤òÀÚ¤êÂؤ¨¤ë¡£
		enable_reverb ^= 1;
		// ²èÌ̤ò¹¹¿·¤¹¤ë¡£
		filer_draw&#40;&#41;;
	&#125;
&#125;

// ---------------------------------------------------------------------------
// play_scene
//
// ±éÁÕ²èÌ̤Υ롼¥×½èÍý¡£
//
// °ú¿ô &#58;
//   buttons &#58; ²¡¤µ¤ì¤Æ¤¤¤ë¥Ü¥¿¥ó¡£
//
// Ìá¤êÃÍ &#58;
//   ̵¤·¡£
// ---------------------------------------------------------------------------
static void play_scene&#40;int buttons&#41;
&#123;
	// ¡û¥Ü¥¿¥ó¤¬²¡¤µ¤ì¤¿¤«¡©
	if&#40;buttons & PSP_CTRL_CROSS&#41; &#123;
		// ±éÁÕ¤òÄä»ß¤¹¤ë¡£
		psf_stop&#40;&#41;;
		// ¸½ºß¤Î¥·¡¼¥ó¤ò¡Ö¥Õ¥¡¥¤¥ëÁªÂò¡×¤ËÀßÄê¡£
		current_scene = SCENE_FILER;
		// ²èÌ̤ò¹¹¿·¤¹¤ë¡£
		filer_draw&#40;&#41;;
	// ¢¤¥Ü¥¿¥ó¤¬²¡¤µ¤ì¤¿¤«¡©
	&#125; else if&#40;buttons & PSP_CTRL_SQUARE&#41;
		//printf_line&#40;0,"r&#58;%d", scePowerGetCpuClockFrequencyInt&#40;&#41;&#41;;
		printf_line&#40;0,"cpu&#58;%d bus&#58;%d", scePowerGetCpuClockFrequencyInt&#40;&#41;,scePowerGetBusClockFrequencyInt&#40;&#41;&#41;;
	else if&#40;buttons & PSP_CTRL_TRIANGLE&#41; &#123;
		// ¥ê¥Ð¡¼¥Ö¤ÎÍ­¸ú / ̵¸ú¤òÀÚ¤êÂؤ¨¤ë¡£
		enable_reverb ^= 1;
		// ²èÌ̤ò¹¹¿·¤¹¤ë¡£
		play_draw&#40;&#41;;
	&#125; else if&#40;buttons & PSP_CTRL_LTRIGGER&#41; &#123;
		filer_scene_select--;
		if&#40;filer_scene_select < 2&#41;
		&#123;
			filer_scene_select = 2;
		&#125;
		else
		&#123;
			psf_stop&#40;&#41;;
			strcpy&#40;current_psf_path, current_directory&#41;;
			strcat&#40;current_psf_path, current_dirents&#91;filer_scene_select&#93;.d_name&#41;;
			if&#40;filer_scene_index > filer_scene_select&#41; &#123;
			filer_scene_index -= 1;

				if&#40;filer_scene_index < 0&#41; 
				&#123;
					filer_scene_index = 0;
				&#125;
			&#125;
			// ±éÁÕ¤ò³«»Ï¤¹¤ë¡£Àµ¾ï¤Ë³«»Ï¤µ¤ì¤¿¤«¡©
			if&#40;psf_play&#40;&#41; >= 0&#41; &#123;
				// ¸½ºß¤Î¥·¡¼¥ó¤ò¡Ö±éÁաפËÀßÄê¡£
				current_scene = SCENE_PLAY;
				// ²èÌ̤ò¹¹¿·¤¹¤ë¡£
				play_draw&#40;&#41;;
			&#125;
		&#125;
	&#125; else if&#40;buttons & PSP_CTRL_RTRIGGER&#41; &#123;
			filer_scene_select++;
			if&#40;filer_scene_select >= current_dirents_count&#41;
			&#123;
				filer_scene_select = current_dirents_count - 1;
			&#125;
			else
			&#123;
			psf_stop&#40;&#41;;
			strcpy&#40;current_psf_path, current_directory&#41;;
			strcat&#40;current_psf_path, current_dirents&#91;filer_scene_select&#93;.d_name&#41;;
			if&#40;filer_scene_index < filer_scene_select&#41; &#123;
			filer_scene_index += 1;	
			&#125;
			// ±éÁÕ¤ò³«»Ï¤¹¤ë¡£Àµ¾ï¤Ë³«»Ï¤µ¤ì¤¿¤«¡©
			if&#40;psf_play&#40;&#41; >= 0&#41; &#123;
				// ¸½ºß¤Î¥·¡¼¥ó¤ò¡Ö±éÁաפËÀßÄê¡£
				current_scene = SCENE_PLAY;
				// ²èÌ̤ò¹¹¿·¤¹¤ë¡£
				play_draw&#40;&#41;;
			
				&#125;
			&#125;
		
	&#125; else if&#40;buttons & PSP_CTRL_CIRCLE&#41; &#123;
		if&#40;thread_paused == 0&#41;
		&#123;
			sceKernelSuspendThread&#40;sexy_thread_id&#41;;
			sceKernelSuspendThread&#40;audio_thread_id&#41;;
		//	printf_line&#40;1,"paused"&#41;;
			scePowerSetCpuClockFrequency&#40;33&#41;;
			scePowerSetBusClockFrequency&#40;33&#41;;
			thread_paused = 1;

		&#125;
		else if&#40;thread_paused == 1&#41;
		&#123;
			scePowerSetCpuClockFrequency&#40;333&#41;;
			scePowerSetBusClockFrequency&#40;166&#41;;
			sceKernelResumeThread&#40;sexy_thread_id&#41;;
			sceKernelResumeThread&#40;audio_thread_id&#41;;
		//	printf_line&#40;1,"unpaused"&#41;;
			thread_paused = 0;
		&#125;
		play_draw&#40;&#41;;
	&#125;

&#125;

// ---------------------------------------------------------------------------
// play_scene_remote
//
// ±éÁÕ²èÌ̤Υ롼¥×½èÍý¡£
//
// °ú¿ô &#58;
//   buttons &#58; ²¡¤µ¤ì¤Æ¤¤¤ë¥Ü¥¿¥ó¡£
//
// Ìá¤êÃÍ &#58;
//   ̵¤·¡£
// ---------------------------------------------------------------------------
static void play_scene_remote&#40;u32 buttons&#41;
&#123;
#define PSP_HPRM_VOL_UP_DOWN 0x30
	// ¡û¥Ü¥¿¥ó¤¬²¡¤µ¤ì¤¿¤«¡©
	if&#40;buttons & PSP_HPRM_PLAYPAUSE&#41; &#123;
		//printf_line&#40;2,"thread&#58;%d", thread_paused&#41;;
		if&#40;thread_paused == 0&#41;
		&#123;
			sceKernelSuspendThread&#40;sexy_thread_id&#41;;
			sceKernelSuspendThread&#40;audio_thread_id&#41;;
			
			scePowerSetCpuClockFrequency&#40;33&#41;;
			scePowerSetBusClockFrequency&#40;33&#41;;
		//	printf_line&#40;1,"paused"&#41;;
			thread_paused = 1;

		&#125;
		else if&#40;thread_paused == 1&#41;
		&#123;
			scePowerSetCpuClockFrequency&#40;333&#41;;
			scePowerSetBusClockFrequency&#40;166&#41;;
			sceKernelResumeThread&#40;sexy_thread_id&#41;;
			sceKernelResumeThread&#40;audio_thread_id&#41;;
		//	printf_line&#40;1,"unpaused"&#41;;
			thread_paused = 0;
		&#125;
			printf_line&#40;0," "&#41;; // <-- HACK_THERE

		play_draw&#40;&#41;; // <-- it crash here if the hack above is not present
		/*// ±éÁÕ¤òÄä»ß¤¹¤ë¡£
		psf_stop&#40;&#41;;
		// ¸½ºß¤Î¥·¡¼¥ó¤ò¡Ö¥Õ¥¡¥¤¥ëÁªÂò¡×¤ËÀßÄê¡£
		current_scene = SCENE_FILER;
		// ²èÌ̤ò¹¹¿·¤¹¤ë¡£
		filer_draw&#40;&#41;;
	// ¢¤¥Ü¥¿¥ó¤¬²¡¤µ¤ì¤¿¤«¡©*/
	&#125; else if&#40;buttons == 48&#41; &#123;//& PSP_HPRM_VOL_UP_DOWN&#41; &#123;
				// ¥ê¥Ð¡¼¥Ö¤ÎÍ­¸ú / ̵¸ú¤òÀÚ¤êÂؤ¨¤ë¡£
		enable_reverb ^= 1;
		// ²èÌ̤ò¹¹¿·¤¹¤ë¡£
		play_draw&#40;&#41;;
		
	&#125;	else if&#40;buttons & PSP_HPRM_FORWARD&#41; &#123;
			filer_scene_select++;
			if&#40;filer_scene_select >= current_dirents_count&#41;
			&#123;
				filer_scene_select = current_dirents_count - 1;
			&#125;
			else
			&#123;
			psf_stop&#40;&#41;;
			strcpy&#40;current_psf_path, current_directory&#41;;
			strcat&#40;current_psf_path, current_dirents&#91;filer_scene_select&#93;.d_name&#41;;
			if&#40;filer_scene_index < filer_scene_select&#41; &#123;
			filer_scene_index += 1;		
			&#125;
			// ±éÁÕ¤ò³«»Ï¤¹¤ë¡£Àµ¾ï¤Ë³«»Ï¤µ¤ì¤¿¤«¡©
			if&#40;psf_play&#40;&#41; >= 0&#41; &#123;
				// ¸½ºß¤Î¥·¡¼¥ó¤ò¡Ö±éÁաפËÀßÄê¡£
				current_scene = SCENE_PLAY;
				// ²èÌ̤ò¹¹¿·¤¹¤ë¡£
				play_draw&#40;&#41;;
			
			&#125;
			&#125;
		
	&#125; else if&#40;buttons & PSP_HPRM_BACK&#41; &#123;
		filer_scene_select--;
		if&#40;filer_scene_select < 2&#41;
		&#123;
			filer_scene_select = 2;
		&#125;
		else
		&#123;
			psf_stop&#40;&#41;;
			strcpy&#40;current_psf_path, current_directory&#41;;
			strcat&#40;current_psf_path, current_dirents&#91;filer_scene_select&#93;.d_name&#41;;
			if&#40;filer_scene_index > filer_scene_select&#41; &#123;

				filer_scene_index -= 1;
			
				if&#40;filer_scene_index < 0&#41; 
				&#123;

					filer_scene_index = 0;
				&#125;
			&#125;
			// ±éÁÕ¤ò³«»Ï¤¹¤ë¡£Àµ¾ï¤Ë³«»Ï¤µ¤ì¤¿¤«¡©
			if&#40;psf_play&#40;&#41; >= 0&#41; &#123;
				// ¸½ºß¤Î¥·¡¼¥ó¤ò¡Ö±éÁաפËÀßÄê¡£
				current_scene = SCENE_PLAY;
				// ²èÌ̤ò¹¹¿·¤¹¤ë¡£
				play_draw&#40;&#41;;
			&#125;
		&#125;
	&#125;
&#125;

// ---------------------------------------------------------------------------
// exit_callback
//
// ½ªÎ»¥³¡¼¥ë¥Ð¥Ã¥¯¡£
//
// °ú¿ô &#58;
//   ̵¤·¡£
//
// Ìá¤êÃÍ &#58;
//   ¾ï¤Ë 0¡£
// ---------------------------------------------------------------------------
static int exit_callback&#40;&#41;
&#123;
	// ±éÁÕ¤ÎÄä»ß¡£
	psf_stop&#40;&#41;;
	
	// ¥½¥Õ¥È¥¦¥§¥¢¤Î½ªÎ»¡£
	sceKernelExitGame&#40;&#41;;
	
	// Àµ¾ï½ªÎ»¡£
	return 0;
&#125;

// ---------------------------------------------------------------------------
// power_callback
//
// ÅŸ»¥³¡¼¥ë¥Ð¥Ã¥¯¡£
//
// °ú¿ô &#58;
//   unknown   &#58; ̤»ÈÍÑ¡£
//   powerInfo &#58; ̤»ÈÍÑ¡£
//
// Ìá¤êÃÍ &#58;
//   ̵¤·¡£
// ---------------------------------------------------------------------------
static void power_callback&#40;int unknown, int powerInfo&#41;
&#123;
&#125;

// ---------------------------------------------------------------------------
// callback_thread
//
// ÄÌÃÎ¥¹¥ì¥Ã¥É¡£
//
// °ú¿ô &#58;
//   args &#58; ̤»ÈÍÑ¡£
//   argp &#58; ̤»ÈÍÑ¡£
//
// Ìá¤êÃÍ &#58;
//   ¾ï¤Ë 0¡£
// ---------------------------------------------------------------------------
static int callback_thread&#40;SceSize args, void *argp&#41;
&#123;
	int exit_callback_id;  // ½ªÎ»¥³¡¼¥ë¥Ð¥Ã¥¯¤Î ID¡£
	int power_callback_id; // ÅŸ»¥³¡¼¥ë¥Ð¥Ã¥¯¤Î ID¡£
	
	// ½ªÎ»¥³¡¼¥ë¥Ð¥Ã¥¯¤ÎÀ¸À®¤ÈÅÐÏ¿¡£
	exit_callback_id = sceKernelCreateCallback&#40;"Exit Callback", exit_callback, 0&#41;;
	sceKernelRegisterExitCallback&#40;exit_callback_id&#41;;
	
	// ÅŸ»¥³¡¼¥ë¥Ð¥Ã¥¯¤ÎÀ¸À®¤ÈÅÐÏ¿¡£
	power_callback_id = sceKernelCreateCallback&#40;"Power Callback", power_callback, 0&#41;;
	scePowerRegisterCallback&#40;0, power_callback_id&#41;;
	
	// ¥¹¥ì¥Ã¥É¤ò¥¹¥ê¡¼¥×¤¹¤ë¡£
	sceKernelSleepThreadCB&#40;&#41;;
	
	// Àµ¾ï½ªÎ»¡£
	return 0;
&#125;

// ---------------------------------------------------------------------------
// main
//
// ¥á¥¤¥ó¡£
//
// °ú¿ô &#58;
//   argc &#58; ̤»ÈÍÑ¡£
//   argv &#58; ̤»ÈÍÑ¡£
//
// Ìá¤êÃÍ &#58;
//   ¾ï¤Ë 0¡£
// ---------------------------------------------------------------------------
int main&#40;int argc, char *argv&#91;&#93;&#41;
&#123;
	int callback_thread_id; // ÄÌÃÎ¥¹¥ì¥Ã¥É¤Î ID¡£
	SceCtrlData ctrl_data;  // ¥³¥ó¥È¥í¡¼¥é¡¼¤Î¾õÂÖ¡£
	int buttons_prev;       // Á°²ó¤Î¥Ü¥¿¥ó¤Î¾õÂÖ¡£
	u32 remoteButtons, remoteButtonsOld = 0;
	
	// ÄÌÃÎ¥¹¥ì¥Ã¥É¤ÎÀ¸À®¤È³«»Ï¡£
	callback_thread_id = sceKernelCreateThread&#40;"update_thread", callback_thread, 17, 4000, 0, 0&#41;;
	sceKernelStartThread&#40;callback_thread_id, 0, 0&#41;;
	
	// ¥Ç¥Ð¥Ã¥°¥¹¥¯¥ê¡¼¥ó¤Î½é´ü²½¡£
	pspDebugScreenInit&#40;&#41;;
	
	// ¥³¥ó¥È¥í¡¼¥é¡¼¤Î¥µ¥ó¥×¥ê¥ó¥°¥µ¥¤¥¯¥ë¤È¥â¡¼¥É¤ÎÀßÄê¡£
	sceCtrlSetSamplingCycle&#40;0&#41;;
	sceCtrlSetSamplingCycle&#40;PSP_CTRL_MODE_DIGITAL&#41;;
	
	// PSFINFO ¹½Â¤ÂΤνé´ü²½¡£
	psf_info      = 0;
	// ¥ê¥Ð¡¼¥Ö¤ò̵¸ú¤Ë¤¹¤ë¡£
	enable_reverb = 0;
	// Á°²ó¤Î¥Ü¥¿¥ó¤Î¾õÂÖ¤ò½é´ü²½¡£
	buttons_prev  = 0;
	
	// ¸½ºß¤Î¥·¡¼¥ó¤ò¡Ö¥Õ¥¡¥¤¥ëÁªÂò¡×¤ËÀßÄê¡£
	current_scene = SCENE_FILER;
	// ¸½ºß¤Î¥Ç¥£¥ì¥¯¥È¥ê¤ò¡Öms0&#58;/¡×¤ËÀßÄê¡£
	strcpy&#40;current_directory, "ms0&#58;/"&#41;;
	// ¥Ç¥£¥ì¥¯¥È¥ê°ìÍ÷¤ò¹¹¿·¤¹¤ë¡£
	set_dirents&#40;&#41;;
	// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò½é´ü²½¡£
	filer_scene_index  = 0;
	// ÁªÂò¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò½é´ü²½¡£
	filer_scene_select = 0;
	// ²èÌ̤ò¹¹¿·¤¹¤ë¡£
	filer_draw&#40;&#41;;
	
	// ¥á¥¤¥ó¥ë¡¼¥×¡£
	while&#40;1&#41;
	&#123;

		// ¥¦¥§¥¤¥È¡£&#40;100 ms&#41;
		sceKernelDelayThread&#40;100000&#41;;
		
		// ¥³¥ó¥È¥í¡¼¥é¡¼¤Î¾õÂÖ¤ò¼èÆÀ¡£
		sceCtrlReadBufferPositive&#40;&ctrl_data, 1&#41;;
		
		// Á°²ó¤È²¡¤µ¤ì¤Æ¤¤¤ë¥Ü¥¿¥ó¤Î¾õÂÖ¤¬Æ±¤¸¤«¡©
		if&#40;ctrl_data.Buttons == buttons_prev&#41; &#123;
			// ¥«¡¼¥½¥ë¥Ü¥¿¥ó°Ê³°¤Ï²¡¤µ¤ì¤Æ¤¤¤Ê¤¤¤â¤Î¤È¤¹¤ë¡£
			ctrl_data.Buttons &= &#40;PSP_CTRL_UP | PSP_CTRL_RIGHT | PSP_CTRL_DOWN | PSP_CTRL_LEFT&#41;;
		&#125; else &#123;
			// ¸½ºß¤Î¥Ü¥¿¥ó¤Î¾õÂÖ¤òÊݸ¤¹¤ë¡£
			buttons_prev = ctrl_data.Buttons;
		&#125;
		
		// ¸½ºß¤Î¥·¡¼¥ó¤Ë±þ¤¸¤¿´Ø¿ô¤ò¸Æ¤Ó½Ð¤¹¡£
		switch&#40;current_scene&#41;
		&#123;
		case SCENE_FILER&#58;
			&#123;	// ¥Õ¥¡¥¤¥ëÁªÂò¡£
			filer_scene&#40;ctrl_data.Buttons&#41;;
				remoteButtonsOld = remoteButtons;
				sceHprmPeekCurrentKey&#40;&remoteButtons&#41;;
			//	printf_line&#40;0,"r&#58;%d", remoteButtons&#41;;
				if &#40;remoteButtons != remoteButtonsOld && !&#40;remoteButtons & PSP_HPRM_HOLD&#41;&#41;
				&#123;
					filer_scene_remote&#40;remoteButtons&#41;;
				&#125;
			break;
			&#125;
		case SCENE_PLAY&#58;
			&#123;
			// ±éÁÕ¡£
			play_scene&#40;ctrl_data.Buttons&#41;;
			//if &#40;sceHprmIsRemoteExist > 0&#41;
			//&#123;
				remoteButtonsOld = remoteButtons;
				sceHprmPeekCurrentKey&#40;&remoteButtons&#41;;
			//	printf_line&#40;0,"r&#58;%d", remoteButtons&#41;;
				if &#40;remoteButtons != remoteButtonsOld && !&#40;remoteButtons & PSP_HPRM_HOLD&#41;&#41;
				&#123;
					play_scene_remote&#40;remoteButtons&#41;;
			//		printf_line&#40;0,"r&#58;%d", remoteButtons&#41;;
			
				&#125;
			//&#125;
			&#125;
		&#125;
	&#125;
	
	// Àµ¾ï½ªÎ»¡£
	return 0;
&#125;
weltall
Posts: 310
Joined: Fri Feb 20, 2004 1:56 am
Contact:

Post by weltall »

i added this to the top of the source and now it doesn't anymore crash even without the hack...
PSP_MODULE_INFO("sexypsf", 0x1000, 0, 1);
__attribute__ ((constructor))
void loaderInit()
{
pspKernelSetKernelPC();
pspSdkInstallNoDeviceCheckPatch();
pspDebugInstallErrorHandler(NULL);

}
memon
Posts: 63
Joined: Mon Oct 03, 2005 10:51 pm

Post by memon »

I had similar problem a couple of nights a go. Maybe related.

I was trying to add exception handler to a program which was derived from the cube sample. After few mistakes like not having the 0x1000 flag in the module info the program still froze when I got executed.

The final remedy was to add -O2 to the compiler flags. I don't have deeper knowledge how the innards of the SDK or the compiler works, but solved hte problem for me.

The same bug can be reproduced using the USB sample by omitting the O2 flag. The cwd sample crashes too, but in slightly different way.
Post Reply