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 (C) 2005 Sumire Kinoshita
// Copyright (C) 2005 Weltall
//
// 0.4.5-r1 (2005/7/13)
// - ¥Õ¥¡¡¼¥¹¥È¥ê¥ê¡¼¥¹¡£
//
// ===========================================================================
#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>
// ===========================================================================
//
// ¥Þ¥¯¥í¤ÎÄêµÁ¡£
//
// ===========================================================================
// ¥â¥¸¥å¡¼¥ë̾ : sexypsf
// ¥â¥¸¥å¡¼¥ë°À : ̵¤·
// ¥Ð¡¼¥¸¥ç¥ó : 0.1
PSP_MODULE_INFO("sexypsf", 0, 0, 1);
// ¥¹¥ì¥Ã¥É°À : ¥æ¡¼¥¶¡¼¥â¡¼¥É / VFPU ¥¢¥¯¥»¥¹Í¸ú
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
#define MAX_ENTRY 1024 // ºÇÂç¥Õ¥¡¥¤¥ë¿ô¡£
#define MAX_PATH 1024 // ºÇÂç¥Õ¥¡¥¤¥ë̾¡£
#define SAMPLE_COUNT PSP_AUDIO_SAMPLE_ALIGN(1024) // ¥Ö¥í¥Ã¥¯¤¢¤¿¤ê¤Î¥µ¥ó¥×¥ë¿ô¡£
#define SAMPLE_SIZE (SAMPLE_COUNT * 4) // ¥Ö¥í¥Ã¥¯¤¢¤¿¤ê¤Î¥Ð¥¤¥È¿ô¡£
#define BUFFER_COUNT 8 // ¥Ð¥Ã¥Õ¥¡¤Î¸Ä¿ô¡£
#define BUFFER_SIZE (SAMPLE_SIZE * 64) // ¥Ð¥Ã¥Õ¥¡¤Î¥Ð¥¤¥È¿ô¡£
// ===========================================================================
//
// ÎóµóÂΤÎÄêµÁ¡£
//
// ===========================================================================
// ¥·¡¼¥ó¤ò¼¨¤¹ÎóµóÂΡ£
enum {
SCENE_DUMMY = 0,
SCENE_FILER, // ¥Õ¥¡¥¤¥ëÁªÂò¡£
SCENE_PLAY // ±éÁÕ¡£
};
// ===========================================================================
//
// ÊÑ¿ô¤ÎÄêµÁ¡£
//
// ===========================================================================
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[BUFFER_COUNT][BUFFER_SIZE]; // ¥µ¥¦¥ó¥É¥Ð¥Ã¥Õ¥¡¡£
static u8 sound_buffer_ready[BUFFER_COUNT]; // ¥µ¥¦¥ó¥É¥Ð¥Ã¥Õ¥¡¤¬Ëþ¤¿¤µ¤ì¤Æ¤¤¤ë¤«¼¨¤¹¥Õ¥é¥°¡£
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[MAX_PATH]; // ¸½ºß¤Î PSF ¥Õ¥¡¥¤¥ë¤Î¥Ñ¥¹¡£
static char current_directory[MAX_PATH]; // ¸½ºß¤Î¥Ç¥£¥ì¥¯¥È¥ê¡£
static SceIoDirent current_dirents[MAX_ENTRY]; // ¸½ºß¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Î¥Õ¥¡¥¤¥ë°ìÍ÷¡£
static int current_dirents_count; // ¸½ºß¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Î¥Õ¥¡¥¤¥ë¿ô¡£
u8 enable_reverb; // ¥ê¥Ð¡¼¥Ö¤Î͸ú / ̵¸ú¥Õ¥é¥°¡£../spu/spu.c ¤è¤ê»²¾È¤µ¤ì¤ë¡£
int thread_paused = 0;
// ===========================================================================
//
// ´Ø¿ô¤ÎÄêµÁ¡£
//
// ===========================================================================
// ---------------------------------------------------------------------------
// audio_thread
//
// ¥ª¡¼¥Ç¥£¥ª¥¹¥ì¥Ã¥É¡£
//
// °ú¿ô :
// args : ̤»ÈÍÑ¡£
// argp : ̤»ÈÍÑ¡£
//
// Ìá¤êÃÍ :
// ¾ï¤Ë 0¡£
// ---------------------------------------------------------------------------
static int audio_thread(SceSize args, void *argp)
{
int audio_handle; // ¥ª¡¼¥Ç¥£¥ª¥Á¥ã¥ó¥Í¥ë¤Î¥Ï¥ó¥É¥ë¡£
// ¥ª¡¼¥Ç¥£¥ª¥Á¥ã¥ó¥Í¥ë¤Î¼èÆÀ¡£
audio_handle = sceAudioChReserve(
PSP_AUDIO_NEXT_CHANNEL, SAMPLE_COUNT, PSP_AUDIO_FORMAT_STEREO);
// ¥¹¥ì¥Ã¥É¤Î½ªÎ»¥Õ¥é¥°¤¬Î©¤Ä¤Þ¤Ç¥ë¡¼¥×¡£
while(!audio_thread_exit_flag)
{
// ¥¦¥§¥¤¥È¡£(10 ms)
sceKernelDelayThread(10000);
// Âоݥµ¥¦¥ó¥É¥Ð¥Ã¥Õ¥¡¤¬Ëþ¤¿¤µ¤ì¤ë¤Þ¤ÇÂԤġ£
if(!sound_buffer_ready[sound_read_index]) {
continue;
}
// Âоݥµ¥¦¥ó¥É¥Ð¥Ã¥Õ¥¡¤«¤é 1 ¥Ö¥í¥Ã¥¯Ê¬½ÐÎϤ¹¤ë¡£
sceAudioOutputPannedBlocking(
audio_handle, PSP_AUDIO_VOLUME_MAX, PSP_AUDIO_VOLUME_MAX,
&sound_buffer[sound_read_index][sound_read_offset]);
// Æɤ߹þ¤ß¥ª¥Õ¥»¥Ã¥È¤ò¿Ê¤á¤ë¡£
sound_read_offset += SAMPLE_SIZE;
// Âоݥµ¥¦¥ó¥É¥Ð¥Ã¥Õ¥¡¤«¤éÁ´¤Æ½ÐÎϤ¬ºÑ¤ó¤À¤«¡©
if(sound_read_offset >= BUFFER_SIZE) {
// ¼¡¤Î¥µ¥¦¥ó¥É¥Ð¥Ã¥Õ¥¡¤ò»²¾È¤¹¤ë¤è¤¦¤ËÀÚ¤êÂؤ¨¤ë¡£
sound_buffer_ready[sound_read_index] = 0;
sound_read_index++;
sound_read_offset = 0;
// ºÇ¸å¤Î¥µ¥¦¥ó¥É¥Ð¥Ã¥Õ¥¡¤Ë㤷¤¿¤«¡©
if(sound_read_index >= BUFFER_COUNT) {
// ºÇ½é¤Î¥µ¥¦¥ó¥É¥Ð¥Ã¥Õ¥¡¤ò»²¾È¤¹¤ë¤è¤¦¤ËÀÚ¤êÂؤ¨¤ë¡£
sound_read_index = 0;
}
}
}
// ̵²»¤Î¥Ö¥í¥Ã¥¯¤ò½ÐÎϤ¹¤ë¡£¼¡²óºÆÀ¸»þ¤Î¥×¥Á¥Î¥¤¥ºËÉ»ßÍÑ¡£
sceAudioOutputPannedBlocking(audio_handle, 0, 0, sound_buffer[0]);
// ¥ª¡¼¥Ç¥£¥ª¥Á¥ã¥ó¥Í¥ë¤Î²òÊü¡£
sceAudioChRelease(audio_handle);
// ¥¹¥ì¥Ã¥É¤Î½ªÎ»¡£
sceKernelExitThread(0);
// Àµ¾ï½ªÎ»¡£
return 0;
}
// ---------------------------------------------------------------------------
// sexy_thread
//
// ¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó¥¹¥ì¥Ã¥É¡£
//
// °ú¿ô :
// args : ̤»ÈÍÑ¡£
// argp : ̤»ÈÍÑ¡£
//
// Ìá¤êÃÍ :
// ¾ï¤Ë 0¡£
// ---------------------------------------------------------------------------
static int sexy_thread(SceSize args, void *argp)
{
// Æ°ºî¥¯¥í¥Ã¥¯¤ò 333MHz ¤ËÊѹ¹¡£
scePowerSetClockFrequency(333, 333, 166);
// ¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó³«»Ï¡£sexy_stop() ¤¬¸Æ¤Ð¤ì¤ë¤Þ¤ÇÌá¤é¤Ê¤¤¡£
// ¥µ¥ó¥×¥ë¤¬À¸À®¤µ¤ì¤¿»þÅÀ¤Ç sexyd_update() ¤¬¸Æ¤Ð¤ì¤ë¡£
sexy_execute();
// Æ°ºî¥¯¥í¥Ã¥¯¤ò 222MHz ¤ËÊѹ¹¡£
scePowerSetClockFrequency(222, 222, 111);
// ¥¹¥ì¥Ã¥É¤Î½ªÎ»¡£
sceKernelExitThread(0);
// Àµ¾ï½ªÎ»¡£
return 0;
}
// ---------------------------------------------------------------------------
// sexyd_update
//
// ¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó¤Ç¥µ¥ó¥×¥ë¤¬À¸À®¤µ¤ì¤¿¤é¸Æ¤Ð¤ì¤ë´Ø¿ô¡£
//
// °ú¿ô :
// buffer : À¸À®¤µ¤ì¤¿¥µ¥ó¥×¥ë¡£(44100 Hz / 16 bit / Stereo)
// length : buffer ¤Î¥Ð¥¤¥È¿ô¡£
//
// Ìá¤êÃÍ :
// ̵¤·¡£
// ---------------------------------------------------------------------------
void sexyd_update(u8 *buffer, int length)
{
int buffer_free_length; // ÂоݥХåե¡¤Î»Ä¤ê¥µ¥¤¥º¡£
// Âоݥµ¥¦¥ó¥É¥Ð¥Ã¥Õ¥¡¤¬¶õ¤Ë¤Ê¤ë¤Þ¤ÇÂԤġ£
do
{
// ¥¦¥§¥¤¥È¡£(0.01 ms)
sceKernelDelayThread(10);
// ¥¹¥ì¥Ã¥É¤Î½ªÎ»¥Õ¥é¥°¤¬Î©¤Ã¤Æ¤¤¤ë¤«¡©
if(sexy_thread_exit_flag) {
// ¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó¤òÄä»ß¤µ¤»¤ë¡£
sexy_stop();
// Àµ¾ï½ªÎ»¡£
return;
}
next:;
} while(sound_buffer_ready[sound_write_index]);
// ÂоݥХåե¡¤Î»Ä¤ê¥µ¥¤¥º¤ò·×»»¤¹¤ë¡£
buffer_free_length = BUFFER_SIZE - sound_write_offset;
// ÂоݥХåե¡¤ËÁ´¤Æ¤Î¥µ¥ó¥×¥ë¤ò½ñ¤¹þ¤á¤ë¤«¡©
if(buffer_free_length >= length) {
// ÂоݥХåե¡¤ËÁ´¤Æ¤Î¥µ¥ó¥×¥ë¤ò½ñ¤¹þ¤à¡£
memcpy(&sound_buffer[sound_write_index][sound_write_offset], buffer, length);
// ½ñ¤¹þ¤ß¥ª¥Õ¥»¥Ã¥È¤ò¿Ê¤á¤ë¡£
sound_write_offset += length;
} else {
// ÂоݥХåե¡¤Î»Ä¤ê¥µ¥¤¥ºÊ¬¤À¤±¥µ¥ó¥×¥ë¤ò½ñ¤¹þ¤à¡£
memcpy(&sound_buffer[sound_write_index][sound_write_offset], buffer, buffer_free_length);
// ½ñ¤¹þ¤ó¤Àʬ¤À¤±¥µ¥ó¥×¥ë¤Î¥Ð¥Ã¥Õ¥¡¥Ý¥¤¥ó¥¿¤È¥µ¥¤¥º¤òÄ´À°¤¹¤ë¡£
buffer += buffer_free_length;
length -= buffer_free_length;
// ¼¡¤Î¥µ¥¦¥ó¥É¥Ð¥Ã¥Õ¥¡¤ò»²¾È¤¹¤ë¤è¤¦¤ËÀÚ¤êÂؤ¨¤ë¡£
sound_buffer_ready[sound_write_index] = 1;
sound_write_index++;
sound_write_offset = 0;
// ºÇ¸å¤Î¥µ¥¦¥ó¥É¥Ð¥Ã¥Õ¥¡¤Ë㤷¤¿¤«¡©
if(sound_write_index >= BUFFER_COUNT) {
// ºÇ½é¤Î¥µ¥¦¥ó¥É¥Ð¥Ã¥Õ¥¡¤ò»²¾È¤¹¤ë¤è¤¦¤ËÀÚ¤êÂؤ¨¤ë¡£
sound_write_index = 0;
}
// »Ä¤ê¤Î¥µ¥ó¥×¥ë¤ò½ñ¤¹þ¤à¤¿¤á¤Ë¡¢¼¡¤Î¥µ¥¦¥ó¥É¥Ð¥Ã¥Õ¥¡¤¬¶õ¤Ë¤Ê¤ë¤Î¤òÂԤġ£
goto next;
}
}
// ---------------------------------------------------------------------------
// psf_play
//
// PSF ¥Õ¥¡¥¤¥ë¤Î±éÁÕ³«»Ï¡£
//
// °ú¿ô :
// ̵¤·¡£
//
// Ìá¤êÃÍ :
// À®¸ù»þ¤Ï 0¡¢¤½¤ì°Ê³°¤Ï -1¡£
// ---------------------------------------------------------------------------
static int psf_play()
{
int i; // ÈÆÍÑÊÑ¿ô¡£
thread_paused = 0;
// PSF ¤ÎÆɤ߹þ¤ß¡£
psf_info = sexy_load(current_psf_path);
// PSFINFO ¹½Â¤ÂΤÏ͸ú¤«¡©
if(psf_info) {
// ¥µ¥¦¥ó¥É¥Ð¥Ã¥Õ¥¡¤Î½é´ü²½¡£
for(i = 0; i < BUFFER_COUNT; i++)
{
memset(sound_buffer[i], 0, BUFFER_SIZE);
sound_buffer_ready[i] = 0;
}
// ¥µ¥¦¥ó¥É¥Ð¥Ã¥Õ¥¡¤ÎÆɤ߽ñ¤¥¤¥ó¥Ç¥Ã¥¯¥¹ / ¥ª¥Õ¥»¥Ã¥È¤Î½é´ü²½¡£
sound_read_index = 0;
sound_read_offset = 0;
sound_write_index = 0;
sound_write_offset = 0;
// ¥ª¡¼¥Ç¥£¥ª¥¹¥ì¥Ã¥É¤ÎÀ¸À®¤È³«»Ï¡£
audio_thread_id = sceKernelCreateThread("audio_thread", audio_thread, 18, 65536, 0, 0);
audio_thread_exit_flag = 0;
sceKernelStartThread(audio_thread_id, 0, 0);
// ¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó¥¹¥ì¥Ã¥É¤ÎÀ¸À®¤È³«»Ï¡£
sexy_thread_id = sceKernelCreateThread("sexy_thread", sexy_thread, 32, 65536, 0, 0);
sexy_thread_exit_flag = 0;
sceKernelStartThread(sexy_thread_id, 0, 0);
// Àµ¾ï½ªÎ»¡£
return 0;
} else {
// ¥¨¥é¡¼½ªÎ»¡£
return -1;
}
}
// ---------------------------------------------------------------------------
// psf_stop
//
// PSF ¥Õ¥¡¥¤¥ë¤Î±éÁÕÄä»ß¡£
//
// °ú¿ô :
// ̵¤·¡£
//
// Ìá¤êÃÍ :
// ̵¤·¡£
// ---------------------------------------------------------------------------
static void psf_stop()
{
// PSFINFO ¹½Â¤ÂΤÏ͸ú¤«¡©
if(thread_paused == 1)
{
scePowerSetCpuClockFrequency(333);
scePowerSetBusClockFrequency(166);
sceKernelResumeThread(sexy_thread_id);
sceKernelResumeThread(audio_thread_id);
// printf_line(1,"unpaused");
thread_paused = 0;
}
if(psf_info) {
// ¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó¥¹¥ì¥Ã¥É¤ÎÄä»ß¤ÈÇË´þ¡£
sexy_thread_exit_flag = 1;
sceKernelWaitThreadEnd(sexy_thread_id, 0);
sceKernelDeleteThread(sexy_thread_id);
// ¥ª¡¼¥Ç¥£¥ª¥¹¥ì¥Ã¥É¤ÎÄä»ß¤ÈÇË´þ¡£
audio_thread_exit_flag = 1;
sceKernelWaitThreadEnd(audio_thread_id, 0);
sceKernelDeleteThread(audio_thread_id);
// PSFINFO ¹½Â¤ÂΤÎÇË´þ¡£
sexy_freepsfinfo(psf_info);
psf_info = 0;
thread_paused = 0;
}
}
// ---------------------------------------------------------------------------
// set_dirents
//
// ¥Ç¥£¥ì¥¯¥È¥ê°ìÍ÷¤Î¼èÆÀ¡£
//
// °ú¿ô :
// ̵¤·¡£
//
// Ìá¤êÃÍ :
// À®¸ù»þ¤Ï 0¡¢¤½¤ì°Ê³°¤Ï -1¡£
// ---------------------------------------------------------------------------
static int set_dirents()
{
SceUID uid; // ¥Ç¥£¥ì¥¯¥È¥ê¥¨¥ó¥È¥ê¤Î ID¡£
SceIoDirent dirent; // ¥ï¡¼¥¯ÍѤΠSceIoDirent¡£
char *extention; // ¥Õ¥¡¥¤¥ë¤Î³ÈÄ¥»Ò¤Ø¤Î¥Ý¥¤¥ó¥¿¡£
int r; // ÈÆÍÑÊÑ¿ô¡£
// ¥Ç¥£¥ì¥¯¥È¥ê¥¨¥ó¥È¥ê¤Î¼èÆÀ¡£
uid = sceIoDopen(current_directory);
// ¥Ç¥£¥ì¥¯¥È¥ê¥¨¥ó¥È¥ê¤¬Ìµ¸ú¤«¡©
if(uid < 0) {
// ¥¨¥é¡¼½ªÎ»¡£
return -1;
}
// ¥Õ¥¡¥¤¥ë°ìÍ÷¤Î¼èÆÀ¡£
for(current_dirents_count = 0; current_dirents_count < MAX_ENTRY;)
{
// ¥ï¡¼¥¯¤ò½é´ü²½¡£½é´ü²½¤·¤Ê¤±¤ì¤Ð sceIoDread ¤¬¥Õ¥ê¡¼¥º¤¹¤ë¡£
memset(&dirent, 0, sizeof(SceIoDirent));
// ¥¨¥ó¥È¥ê¾ðÊó¤ò¥ï¡¼¥¯¤ØÆɤ߹þ¤ß¡£
r = sceIoDread(uid, &dirent);
// ¥Ç¥£¥ì¥¯¥È¥ê¤«¡©
if(FIO_SO_ISDIR(dirent.d_stat.st_attr)) {
// ¥¨¥ó¥È¥ê¾ðÊó¤ò¥ï¡¼¥¯¤«¤é¸½ºß¤Î¥Ç¥£¥ì¥¯¥È¥ê°ìÍ÷¤Ø¥³¥Ô¡¼¡£
memcpy(¤t_dirents[current_dirents_count], &dirent, sizeof(SceIoDirent));
// ¸½ºß¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Î¥Õ¥¡¥¤¥ë¿ô¤ò¥¤¥ó¥¯¥ê¥á¥ó¥È¡£
current_dirents_count++;
} else {
// ¥Õ¥¡¥¤¥ë̾¤«¤é³ÈÄ¥»Ò¤ò¼è¤ê½Ð¤¹¡£
extention = strrchr(dirent.d_name, '.');
// ³ÈÄ¥»Ò¤¬Â¸ºß¤¹¤ë¤«¡©
if(extention) {
// ¥µ¥Ý¡¼¥È¤¹¤ë³ÈÄ¥»Ò¤«¡©
if(!stricmp(extention, ".psf") || !stricmp(extention, ".psf1") || !stricmp(extention, ".minipsf")) {
// ¥¨¥ó¥È¥ê¾ðÊó¤ò¥ï¡¼¥¯¤«¤é¸½ºß¤Î¥Ç¥£¥ì¥¯¥È¥ê°ìÍ÷¤Ø¥³¥Ô¡¼¡£
memcpy(¤t_dirents[current_dirents_count], &dirent, sizeof(SceIoDirent));
// ¸½ºß¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Î¥Õ¥¡¥¤¥ë¿ô¤ò¥¤¥ó¥¯¥ê¥á¥ó¥È¡£
current_dirents_count++;
}
}
}
// ºÇ¸å¤Î¥¨¥ó¥È¥ê¤«¡©
if(r <= 0) {
break;
}
}
// ¥Ç¥£¥ì¥¯¥È¥ê¥¨¥ó¥È¥ê¤Î²òÊü¡£
sceIoDclose(uid);
// Àµ¾ï½ªÎ»¡£
return 0;
}
// ---------------------------------------------------------------------------
// printf_line
//
// »ØÄê¹Ô¤ËÂФ¹¤ë¥Õ¥©¡¼¥Þ¥Ã¥ÈºÑ¤ßʸ»úÎó¤Îɽ¼¨¡£
//
// °ú¿ô :
// y : ¹Ô¿ô¡£
// format : ¥Õ¥©¡¼¥Þ¥Ã¥Èʸ»úÎó¡£
// ... : ¥Õ¥©¡¼¥Þ¥Ã¥È°ú¿ô¡£
//
// Ìá¤êÃÍ :
// ̵¤·¡£
// ---------------------------------------------------------------------------
static void printf_line(int y, char *format, ...)
{
va_list options; // ¼è¤ê½Ð¤·¤¿²ÄÊÑĹ°ú¿ô¡£
char buffer[68]; // ʸ»úÎóÍѥХåե¡¡£68 ¤Ï 1 ¹Ô¤Ëɽ¼¨²Äǽ¤Êʸ»ú¿ô¡£
int r; // ÈÆÍÑÊÑ¿ô¡£
// ²ÄÊÑĹ°ú¿ô¤ò¼è¤ê½Ð¤¹¡£
va_start(options, format);
// ¥Õ¥©¡¼¥Þ¥Ã¥ÈºÑ¤ßʸ»úÎó¤òÆÀ¤ë¡£
r = vsnprintf(buffer, 68, format, options);
// ¥Õ¥©¡¼¥Þ¥Ã¥ÈºÑ¤ßʸ»úÎó¤Ï 68 ʸ»ú¤òĶ¤¨¤Æ¤¤¤Ê¤¤¤«¡©
if(r >= 0) {
// »Ä¤Ã¤¿Éôʬ¤ò¥¹¥Ú¡¼¥¹¤ÇËä¤á¤ë¡£
memset(&buffer[r], ' ', 68 - r);
// ¥¿¡¼¥ß¥Í¡¼¥È¤¹¤ë¡£
buffer[67] = '\0';
}
// ¥«¡¼¥½¥ë°ÌÃÖ¤òÀßÄꤹ¤ë¡£
pspDebugScreenSetXY(0, y);
// ¥Õ¥©¡¼¥Þ¥Ã¥ÈºÑ¤ßʸ»úÎó¤òɽ¼¨¤¹¤ë¡£
pspDebugScreenPrintf(buffer);
}
// ---------------------------------------------------------------------------
// filer_draw
//
// ¥Õ¥¡¥¤¥ëÁªÂò²èÌ̤Îɽ¼¨¡£¡£
//
// °ú¿ô :
// ̵¤·¡£
//
// Ìá¤êÃÍ :
// ̵¤·¡£
// ---------------------------------------------------------------------------
static void filer_draw()
{
int i, j; // ÈÆÍÑÊÑ¿ô¡£
// ¥Õ¥¡¥¤¥ëÁªÂò²èÌ̤Îɽ¼¨¡£
printf_line(0, current_directory);
printf_line(1, "===== File selector ===============================================");
for(i = 2; i < 32; i++)
{
// ¥Õ¥¡¥¤¥ë°ìÍ÷¤ËÂФ¹¤ë¥¤¥ó¥Ç¥Ã¥¯¥¹¤òµá¤á¤ë¡£
j = i - 2 + filer_scene_index;
// ¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤¹¤ë¤«¡©
if(j < current_dirents_count) {
printf_line(i, "%s %s%s",
// ¤³¤Î¥Õ¥¡¥¤¥ë¤¬ÁªÂò¤µ¤ì¤Æ¤¤¤ë¤Ê¤é¤Ð¡¢¥«¡¼¥½¥ë¤òÉղá£
(j == filer_scene_select) ? ">" : " ",
// ¥Õ¥¡¥¤¥ë̾¡£
current_dirents[j].d_name,
// ¥Ç¥£¥ì¥¯¥È¥ê¤Ç¤¢¤ì¤Ð¡¢ËöÈø¤Ë¥»¥Ñ¥ì¡¼¥¿¤òÉղá£
FIO_SO_ISDIR(current_dirents[j].d_stat.st_attr) ? "/" : ""
);
} else {
// ¶õÇò¹Ô¤òɽ¼¨¡£
printf_line(i, "");
}
}
printf_line(32, "===================================================================");
printf_line(33, "Cursor = Move / Circle = Play / Triangle = Toggle reverb |%s|",
// ¥ê¥Ð¡¼¥Ö¤¬Í¸ú¤«¤É¤¦¤«¼¨¤¹¥¤¥ó¥¸¥±¡¼¥¿¡£
enable_reverb ? "R" : " "
);
}
// ---------------------------------------------------------------------------
// play_draw
//
// ±éÁÕ²èÌ̤Îɽ¼¨¡£¡£
//
// °ú¿ô :
// ̵¤·¡£
//
// Ìá¤êÃÍ :
// ̵¤·¡£
// ---------------------------------------------------------------------------
static void play_draw()
{
int i; // ÈÆÍÑÊÑ¿ô¡£
// ±éÁÕ²èÌ̤Îɽ¼¨¡£
printf_line( 0, current_dirents[filer_scene_select].d_name);
if(thread_paused == 1)
printf_line( 1, "===== PSF information ===============================PAUSED========");
else
printf_line( 1, "===== PSF information =============================================");
printf_line( 2, "Game : %s", psf_info->game ? psf_info->game : "");
printf_line( 3, "Title : %s", psf_info->title ? psf_info->title : "");
printf_line( 4, "Artist : %s", psf_info->artist ? psf_info->artist : "");
printf_line( 5, "Year : %s", psf_info->year ? psf_info->year : "");
printf_line( 6, "Genre : %s", psf_info->genre ? psf_info->genre : "");
printf_line( 7, "PSF by : %s", psf_info->psfby ? psf_info->psfby : "");
printf_line( 8, "Copyright : %s", psf_info->copyright ? psf_info->copyright : "");
for(i = 9; i < 32; i++)
{
// ¶õÇò¹Ô¤òɽ¼¨¡£
printf_line(i, "");
}
printf_line(32, "===================================================================");
printf_line(33, "Cross = Stop / Triangle = Toggle reverb |%s|",
// ¥ê¥Ð¡¼¥Ö¤¬Í¸ú¤«¤É¤¦¤«¼¨¤¹¥¤¥ó¥¸¥±¡¼¥¿¡£
enable_reverb ? "R" : " "
);
}
// ---------------------------------------------------------------------------
// filer_scene
//
// ¥Õ¥¡¥¤¥ëÁªÂò²èÌ̤Υ롼¥×½èÍý¡£
//
// °ú¿ô :
// buttons : ²¡¤µ¤ì¤Æ¤¤¤ë¥Ü¥¿¥ó¡£
//
// Ìá¤êÃÍ :
// ̵¤·¡£
// ---------------------------------------------------------------------------
static void filer_scene(int buttons)
{
int i; // ÈÆÍÑÊÑ¿ô¡£
// ¥«¡¼¥½¥ë¥Ü¥¿¥ó¤¬²¡¤µ¤ì¤¿¤«¡©
if(buttons & (PSP_CTRL_UP | PSP_CTRL_RIGHT | PSP_CTRL_DOWN | PSP_CTRL_LEFT)) {
// ¥«¡¼¥½¥ë¥Ü¥¿¥ó¤ÎÊý¸þ¤Ë±þ¤¸¤¿°ÜÆ°Î̤òµá¤á¤ë¡£
if(buttons & PSP_CTRL_UP) {
// 1 ¥¤¥ó¥Ç¥Ã¥¯¥¹Á°¤Ø°ÜÆ°¡£
i = -1;
} else if(buttons & PSP_CTRL_RIGHT) {
// 10 ¥¤¥ó¥Ç¥Ã¥¯¥¹¼¡¤Ø°ÜÆ°¡£
i = 10;
} else if(buttons & PSP_CTRL_DOWN) {
// 1 ¥¤¥ó¥Ç¥Ã¥¯¥¹¼¡¤Ø°ÜÆ°¡£
i = 1;
} else {
// 10 ¥¤¥ó¥Ç¥Ã¥¯¥¹Á°¤Ø°ÜÆ°¡£
i = -10;
}
// ÁªÂò¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò°ÜÆ°¤µ¤»¤ë¡£
filer_scene_select += i;
// ÁªÂò¥¤¥ó¥Ç¥Ã¥¯¥¹¤¬¥Õ¥¡¥¤¥ë¿ô¤ÈƱ¤¸¤«Â礤¯¤Ê¤Ã¤¿¤«¡©
if(filer_scene_select >= current_dirents_count) {
// ÁªÂò¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò¥¯¥ê¥Ã¥×¤¹¤ë¡£
filer_scene_select = current_dirents_count - 1;
// ÁªÂò¥¤¥ó¥Ç¥Ã¥¯¥¹¤¬ 0 ¤è¤ê¾®¤µ¤¯¤Ê¤Ã¤¿¤«¡©
} else if(filer_scene_select < 0) {
// ÁªÂò¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò¥¯¥ê¥Ã¥×¤¹¤ë¡£
filer_scene_select = 0;
}
// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹¤¬ÁªÂò¥¤¥ó¥Ç¥Ã¥¯¥¹¤è¤êÂ礤¯¤Ê¤Ã¤¿¤«¡©
if(filer_scene_index > filer_scene_select) {
// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò°ÜÆ°¤µ¤»¤ë¡£
filer_scene_index += i;
// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹¤¬ 0 ¤è¤ê¾®¤µ¤¯¤Ê¤Ã¤¿¤«¡©
if(filer_scene_index < 0) {
// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò¥¯¥ê¥Ã¥×¤¹¤ë¡£
filer_scene_index = 0;
}
// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹ + 30 ¤¬ÁªÂò¥¤¥ó¥Ç¥Ã¥¯¥¹¤ÈƱ¤¸¤«¾®¤µ¤¯¤Ê¤Ã¤¿¤«¡©
} else if(filer_scene_index + 30 <= filer_scene_select) {
// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò°ÜÆ°¤µ¤»¤ë¡£
filer_scene_index += i;
// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹ + 30 ¤¬¥Õ¥¡¥¤¥ë¿ô¤ÈƱ¤¸¤«Â礤¯¤Ê¤Ã¤¿¤«¡©
if(filer_scene_index + 30 >= current_dirents_count) {
// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò¥¯¥ê¥Ã¥×¤¹¤ë¡£
filer_scene_index = current_dirents_count - 30;
}
}
// ²èÌ̤ò¹¹¿·¤¹¤ë¡£
filer_draw();
// ¡û¥Ü¥¿¥ó¤¬²¡¤µ¤ì¤¿¤«¡©
} else if(buttons & PSP_CTRL_CIRCLE) {
// ¥Ç¥£¥ì¥¯¥È¥ê¤«¡©
if(FIO_SO_ISDIR(current_dirents[filer_scene_select].d_stat.st_attr)) {
// ¥Ç¥£¥ì¥¯¥È¥ê̾¤Î 1 ¥Ð¥¤¥ÈÌܤ¬¥É¥Ã¥È¤«¡©
if(current_dirents[filer_scene_select].d_name[0] == '.') {
// ¥Ç¥£¥ì¥¯¥È¥ê̾¤Î 2 ¥Ð¥¤¥ÈÌܤ¬¥É¥Ã¥È¤«¡©
if(current_dirents[filer_scene_select].d_name[1] == '.') {
// ¸½ºß¤Î¥Ç¥£¥ì¥¯¥È¥ê¤òÊѹ¹¤¹¤ë¡£(¿Æ¥Ç¥£¥ì¥¯¥È¥ê¤Ø)
current_directory[strlen(current_directory) - 1] = '\0';
*(strrchr(current_directory, '/') + 1) = '\0';
}
} else {
// ¸½ºß¤Î¥Ç¥£¥ì¥¯¥È¥ê¤òÊѹ¹¤¹¤ë¡£(̾Á°¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Ø)
strcat(current_directory, current_dirents[filer_scene_select].d_name);
strcat(current_directory, "/");
}
// ¥Ç¥£¥ì¥¯¥È¥ê°ìÍ÷¤ò¹¹¿·¤¹¤ë¡£
set_dirents();
// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò½é´ü²½¡£
filer_scene_index = 0;
// ÁªÂò¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò½é´ü²½¡£
filer_scene_select = 0;
// ²èÌ̤ò¹¹¿·¤¹¤ë¡£
filer_draw();
} else {
// PSF ¥Õ¥¡¥¤¥ë¤Î¥Ñ¥¹¤òÀ¸À®¤¹¤ë¡£
strcpy(current_psf_path, current_directory);
strcat(current_psf_path, current_dirents[filer_scene_select].d_name);
// ±éÁÕ¤ò³«»Ï¤¹¤ë¡£Àµ¾ï¤Ë³«»Ï¤µ¤ì¤¿¤«¡©
if(psf_play() >= 0) {
// ¸½ºß¤Î¥·¡¼¥ó¤ò¡Ö±éÁաפËÀßÄê¡£
current_scene = SCENE_PLAY;
// ²èÌ̤ò¹¹¿·¤¹¤ë¡£
play_draw();
}
}
// ¢¤¥Ü¥¿¥ó¤¬²¡¤µ¤ì¤¿¤«¡©
} else if(buttons & PSP_CTRL_TRIANGLE) {
// ¥ê¥Ð¡¼¥Ö¤Î͸ú / ̵¸ú¤òÀÚ¤êÂؤ¨¤ë¡£
enable_reverb ^= 1;
// ²èÌ̤ò¹¹¿·¤¹¤ë¡£
filer_draw();
}
}
// ---------------------------------------------------------------------------
// filer_scene_remote
//
// ¥Õ¥¡¥¤¥ëÁªÂò²èÌ̤Υ롼¥×½èÍý¡£
//
// °ú¿ô :
// buttons : ²¡¤µ¤ì¤Æ¤¤¤ë¥Ü¥¿¥ó¡£
//
// Ìá¤êÃÍ :
// ̵¤·¡£
// ---------------------------------------------------------------------------
static void filer_scene_remote(u32 buttons)
{
#define PSP_HPRM_VOL_UP_DOWN 0x30
int i; // ÈÆÍÑÊÑ¿ô¡£
// ¥«¡¼¥½¥ë¥Ü¥¿¥ó¤¬²¡¤µ¤ì¤¿¤«¡©
if(buttons & (PSP_HPRM_FORWARD | PSP_HPRM_BACK)) {
// ¥«¡¼¥½¥ë¥Ü¥¿¥ó¤ÎÊý¸þ¤Ë±þ¤¸¤¿°ÜÆ°Î̤òµá¤á¤ë¡£
if(buttons & PSP_HPRM_BACK) {
// 1 ¥¤¥ó¥Ç¥Ã¥¯¥¹Á°¤Ø°ÜÆ°¡£
i = -1;
} else if(buttons & PSP_HPRM_FORWARD) {
// 1 ¥¤¥ó¥Ç¥Ã¥¯¥¹¼¡¤Ø°ÜÆ°¡£
i = 1;
}
// ÁªÂò¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò°ÜÆ°¤µ¤»¤ë¡£
filer_scene_select += i;
// ÁªÂò¥¤¥ó¥Ç¥Ã¥¯¥¹¤¬¥Õ¥¡¥¤¥ë¿ô¤ÈƱ¤¸¤«Â礤¯¤Ê¤Ã¤¿¤«¡©
if(filer_scene_select >= current_dirents_count) {
// ÁªÂò¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò¥¯¥ê¥Ã¥×¤¹¤ë¡£
filer_scene_select = current_dirents_count - 1;
// ÁªÂò¥¤¥ó¥Ç¥Ã¥¯¥¹¤¬ 0 ¤è¤ê¾®¤µ¤¯¤Ê¤Ã¤¿¤«¡©
} else if(filer_scene_select < 0) {
// ÁªÂò¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò¥¯¥ê¥Ã¥×¤¹¤ë¡£
filer_scene_select = 0;
}
// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹¤¬ÁªÂò¥¤¥ó¥Ç¥Ã¥¯¥¹¤è¤êÂ礤¯¤Ê¤Ã¤¿¤«¡©
if(filer_scene_index > filer_scene_select) {
// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò°ÜÆ°¤µ¤»¤ë¡£
filer_scene_index += i;
// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹¤¬ 0 ¤è¤ê¾®¤µ¤¯¤Ê¤Ã¤¿¤«¡©
if(filer_scene_index < 0) {
// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò¥¯¥ê¥Ã¥×¤¹¤ë¡£
filer_scene_index = 0;
}
// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹ + 30 ¤¬ÁªÂò¥¤¥ó¥Ç¥Ã¥¯¥¹¤ÈƱ¤¸¤«¾®¤µ¤¯¤Ê¤Ã¤¿¤«¡©
} else if(filer_scene_index + 30 <= filer_scene_select) {
// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò°ÜÆ°¤µ¤»¤ë¡£
filer_scene_index += i;
// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹ + 30 ¤¬¥Õ¥¡¥¤¥ë¿ô¤ÈƱ¤¸¤«Â礤¯¤Ê¤Ã¤¿¤«¡©
if(filer_scene_index + 30 >= current_dirents_count) {
// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò¥¯¥ê¥Ã¥×¤¹¤ë¡£
filer_scene_index = current_dirents_count - 30;
}
}
// ²èÌ̤ò¹¹¿·¤¹¤ë¡£
filer_draw();
// ¡û¥Ü¥¿¥ó¤¬²¡¤µ¤ì¤¿¤«¡©
} else if(buttons & PSP_HPRM_PLAYPAUSE) {
// ¥Ç¥£¥ì¥¯¥È¥ê¤«¡©
if(FIO_SO_ISDIR(current_dirents[filer_scene_select].d_stat.st_attr)) {
// ¥Ç¥£¥ì¥¯¥È¥ê̾¤Î 1 ¥Ð¥¤¥ÈÌܤ¬¥É¥Ã¥È¤«¡©
if(current_dirents[filer_scene_select].d_name[0] == '.') {
// ¥Ç¥£¥ì¥¯¥È¥ê̾¤Î 2 ¥Ð¥¤¥ÈÌܤ¬¥É¥Ã¥È¤«¡©
if(current_dirents[filer_scene_select].d_name[1] == '.') {
// ¸½ºß¤Î¥Ç¥£¥ì¥¯¥È¥ê¤òÊѹ¹¤¹¤ë¡£(¿Æ¥Ç¥£¥ì¥¯¥È¥ê¤Ø)
current_directory[strlen(current_directory) - 1] = '\0';
*(strrchr(current_directory, '/') + 1) = '\0';
}
} else {
// ¸½ºß¤Î¥Ç¥£¥ì¥¯¥È¥ê¤òÊѹ¹¤¹¤ë¡£(̾Á°¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Ø)
strcat(current_directory, current_dirents[filer_scene_select].d_name);
strcat(current_directory, "/");
}
// ¥Ç¥£¥ì¥¯¥È¥ê°ìÍ÷¤ò¹¹¿·¤¹¤ë¡£
set_dirents();
// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò½é´ü²½¡£
filer_scene_index = 0;
// ÁªÂò¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò½é´ü²½¡£
filer_scene_select = 0;
// ²èÌ̤ò¹¹¿·¤¹¤ë¡£
filer_draw();
} else {
// PSF ¥Õ¥¡¥¤¥ë¤Î¥Ñ¥¹¤òÀ¸À®¤¹¤ë¡£
strcpy(current_psf_path, current_directory);
strcat(current_psf_path, current_dirents[filer_scene_select].d_name);
// ±éÁÕ¤ò³«»Ï¤¹¤ë¡£Àµ¾ï¤Ë³«»Ï¤µ¤ì¤¿¤«¡©
if(psf_play() >= 0) {
// ¸½ºß¤Î¥·¡¼¥ó¤ò¡Ö±éÁաפËÀßÄê¡£
current_scene = SCENE_PLAY;
// ²èÌ̤ò¹¹¿·¤¹¤ë¡£
play_draw();
}
}
// ¢¤¥Ü¥¿¥ó¤¬²¡¤µ¤ì¤¿¤«¡©
} else if(buttons & PSP_HPRM_VOL_UP_DOWN) {
// ¥ê¥Ð¡¼¥Ö¤Î͸ú / ̵¸ú¤òÀÚ¤êÂؤ¨¤ë¡£
enable_reverb ^= 1;
// ²èÌ̤ò¹¹¿·¤¹¤ë¡£
filer_draw();
}
}
// ---------------------------------------------------------------------------
// play_scene
//
// ±éÁÕ²èÌ̤Υ롼¥×½èÍý¡£
//
// °ú¿ô :
// buttons : ²¡¤µ¤ì¤Æ¤¤¤ë¥Ü¥¿¥ó¡£
//
// Ìá¤êÃÍ :
// ̵¤·¡£
// ---------------------------------------------------------------------------
static void play_scene(int buttons)
{
// ¡û¥Ü¥¿¥ó¤¬²¡¤µ¤ì¤¿¤«¡©
if(buttons & PSP_CTRL_CROSS) {
// ±éÁÕ¤òÄä»ß¤¹¤ë¡£
psf_stop();
// ¸½ºß¤Î¥·¡¼¥ó¤ò¡Ö¥Õ¥¡¥¤¥ëÁªÂò¡×¤ËÀßÄê¡£
current_scene = SCENE_FILER;
// ²èÌ̤ò¹¹¿·¤¹¤ë¡£
filer_draw();
// ¢¤¥Ü¥¿¥ó¤¬²¡¤µ¤ì¤¿¤«¡©
} else if(buttons & PSP_CTRL_SQUARE)
//printf_line(0,"r:%d", scePowerGetCpuClockFrequencyInt());
printf_line(0,"cpu:%d bus:%d", scePowerGetCpuClockFrequencyInt(),scePowerGetBusClockFrequencyInt());
else if(buttons & PSP_CTRL_TRIANGLE) {
// ¥ê¥Ð¡¼¥Ö¤Î͸ú / ̵¸ú¤òÀÚ¤êÂؤ¨¤ë¡£
enable_reverb ^= 1;
// ²èÌ̤ò¹¹¿·¤¹¤ë¡£
play_draw();
} else if(buttons & PSP_CTRL_LTRIGGER) {
filer_scene_select--;
if(filer_scene_select < 2)
{
filer_scene_select = 2;
}
else
{
psf_stop();
strcpy(current_psf_path, current_directory);
strcat(current_psf_path, current_dirents[filer_scene_select].d_name);
if(filer_scene_index > filer_scene_select) {
filer_scene_index -= 1;
if(filer_scene_index < 0)
{
filer_scene_index = 0;
}
}
// ±éÁÕ¤ò³«»Ï¤¹¤ë¡£Àµ¾ï¤Ë³«»Ï¤µ¤ì¤¿¤«¡©
if(psf_play() >= 0) {
// ¸½ºß¤Î¥·¡¼¥ó¤ò¡Ö±éÁաפËÀßÄê¡£
current_scene = SCENE_PLAY;
// ²èÌ̤ò¹¹¿·¤¹¤ë¡£
play_draw();
}
}
} else if(buttons & PSP_CTRL_RTRIGGER) {
filer_scene_select++;
if(filer_scene_select >= current_dirents_count)
{
filer_scene_select = current_dirents_count - 1;
}
else
{
psf_stop();
strcpy(current_psf_path, current_directory);
strcat(current_psf_path, current_dirents[filer_scene_select].d_name);
if(filer_scene_index < filer_scene_select) {
filer_scene_index += 1;
}
// ±éÁÕ¤ò³«»Ï¤¹¤ë¡£Àµ¾ï¤Ë³«»Ï¤µ¤ì¤¿¤«¡©
if(psf_play() >= 0) {
// ¸½ºß¤Î¥·¡¼¥ó¤ò¡Ö±éÁաפËÀßÄê¡£
current_scene = SCENE_PLAY;
// ²èÌ̤ò¹¹¿·¤¹¤ë¡£
play_draw();
}
}
} else if(buttons & PSP_CTRL_CIRCLE) {
if(thread_paused == 0)
{
sceKernelSuspendThread(sexy_thread_id);
sceKernelSuspendThread(audio_thread_id);
// printf_line(1,"paused");
scePowerSetCpuClockFrequency(33);
scePowerSetBusClockFrequency(33);
thread_paused = 1;
}
else if(thread_paused == 1)
{
scePowerSetCpuClockFrequency(333);
scePowerSetBusClockFrequency(166);
sceKernelResumeThread(sexy_thread_id);
sceKernelResumeThread(audio_thread_id);
// printf_line(1,"unpaused");
thread_paused = 0;
}
play_draw();
}
}
// ---------------------------------------------------------------------------
// play_scene_remote
//
// ±éÁÕ²èÌ̤Υ롼¥×½èÍý¡£
//
// °ú¿ô :
// buttons : ²¡¤µ¤ì¤Æ¤¤¤ë¥Ü¥¿¥ó¡£
//
// Ìá¤êÃÍ :
// ̵¤·¡£
// ---------------------------------------------------------------------------
static void play_scene_remote(u32 buttons)
{
#define PSP_HPRM_VOL_UP_DOWN 0x30
// ¡û¥Ü¥¿¥ó¤¬²¡¤µ¤ì¤¿¤«¡©
if(buttons & PSP_HPRM_PLAYPAUSE) {
//printf_line(2,"thread:%d", thread_paused);
if(thread_paused == 0)
{
sceKernelSuspendThread(sexy_thread_id);
sceKernelSuspendThread(audio_thread_id);
scePowerSetCpuClockFrequency(33);
scePowerSetBusClockFrequency(33);
// printf_line(1,"paused");
thread_paused = 1;
}
else if(thread_paused == 1)
{
scePowerSetCpuClockFrequency(333);
scePowerSetBusClockFrequency(166);
sceKernelResumeThread(sexy_thread_id);
sceKernelResumeThread(audio_thread_id);
// printf_line(1,"unpaused");
thread_paused = 0;
}
printf_line(0," "); // <-- HACK_THERE
play_draw(); // <-- it crash here if the hack above is not present
/*// ±éÁÕ¤òÄä»ß¤¹¤ë¡£
psf_stop();
// ¸½ºß¤Î¥·¡¼¥ó¤ò¡Ö¥Õ¥¡¥¤¥ëÁªÂò¡×¤ËÀßÄê¡£
current_scene = SCENE_FILER;
// ²èÌ̤ò¹¹¿·¤¹¤ë¡£
filer_draw();
// ¢¤¥Ü¥¿¥ó¤¬²¡¤µ¤ì¤¿¤«¡©*/
} else if(buttons == 48) {//& PSP_HPRM_VOL_UP_DOWN) {
// ¥ê¥Ð¡¼¥Ö¤Î͸ú / ̵¸ú¤òÀÚ¤êÂؤ¨¤ë¡£
enable_reverb ^= 1;
// ²èÌ̤ò¹¹¿·¤¹¤ë¡£
play_draw();
} else if(buttons & PSP_HPRM_FORWARD) {
filer_scene_select++;
if(filer_scene_select >= current_dirents_count)
{
filer_scene_select = current_dirents_count - 1;
}
else
{
psf_stop();
strcpy(current_psf_path, current_directory);
strcat(current_psf_path, current_dirents[filer_scene_select].d_name);
if(filer_scene_index < filer_scene_select) {
filer_scene_index += 1;
}
// ±éÁÕ¤ò³«»Ï¤¹¤ë¡£Àµ¾ï¤Ë³«»Ï¤µ¤ì¤¿¤«¡©
if(psf_play() >= 0) {
// ¸½ºß¤Î¥·¡¼¥ó¤ò¡Ö±éÁաפËÀßÄê¡£
current_scene = SCENE_PLAY;
// ²èÌ̤ò¹¹¿·¤¹¤ë¡£
play_draw();
}
}
} else if(buttons & PSP_HPRM_BACK) {
filer_scene_select--;
if(filer_scene_select < 2)
{
filer_scene_select = 2;
}
else
{
psf_stop();
strcpy(current_psf_path, current_directory);
strcat(current_psf_path, current_dirents[filer_scene_select].d_name);
if(filer_scene_index > filer_scene_select) {
filer_scene_index -= 1;
if(filer_scene_index < 0)
{
filer_scene_index = 0;
}
}
// ±éÁÕ¤ò³«»Ï¤¹¤ë¡£Àµ¾ï¤Ë³«»Ï¤µ¤ì¤¿¤«¡©
if(psf_play() >= 0) {
// ¸½ºß¤Î¥·¡¼¥ó¤ò¡Ö±éÁաפËÀßÄê¡£
current_scene = SCENE_PLAY;
// ²èÌ̤ò¹¹¿·¤¹¤ë¡£
play_draw();
}
}
}
}
// ---------------------------------------------------------------------------
// exit_callback
//
// ½ªÎ»¥³¡¼¥ë¥Ð¥Ã¥¯¡£
//
// °ú¿ô :
// ̵¤·¡£
//
// Ìá¤êÃÍ :
// ¾ï¤Ë 0¡£
// ---------------------------------------------------------------------------
static int exit_callback()
{
// ±éÁÕ¤ÎÄä»ß¡£
psf_stop();
// ¥½¥Õ¥È¥¦¥§¥¢¤Î½ªÎ»¡£
sceKernelExitGame();
// Àµ¾ï½ªÎ»¡£
return 0;
}
// ---------------------------------------------------------------------------
// power_callback
//
// ÅŸ»¥³¡¼¥ë¥Ð¥Ã¥¯¡£
//
// °ú¿ô :
// unknown : ̤»ÈÍÑ¡£
// powerInfo : ̤»ÈÍÑ¡£
//
// Ìá¤êÃÍ :
// ̵¤·¡£
// ---------------------------------------------------------------------------
static void power_callback(int unknown, int powerInfo)
{
}
// ---------------------------------------------------------------------------
// callback_thread
//
// ÄÌÃÎ¥¹¥ì¥Ã¥É¡£
//
// °ú¿ô :
// args : ̤»ÈÍÑ¡£
// argp : ̤»ÈÍÑ¡£
//
// Ìá¤êÃÍ :
// ¾ï¤Ë 0¡£
// ---------------------------------------------------------------------------
static int callback_thread(SceSize args, void *argp)
{
int exit_callback_id; // ½ªÎ»¥³¡¼¥ë¥Ð¥Ã¥¯¤Î ID¡£
int power_callback_id; // ÅŸ»¥³¡¼¥ë¥Ð¥Ã¥¯¤Î ID¡£
// ½ªÎ»¥³¡¼¥ë¥Ð¥Ã¥¯¤ÎÀ¸À®¤ÈÅÐÏ¿¡£
exit_callback_id = sceKernelCreateCallback("Exit Callback", exit_callback, 0);
sceKernelRegisterExitCallback(exit_callback_id);
// ÅŸ»¥³¡¼¥ë¥Ð¥Ã¥¯¤ÎÀ¸À®¤ÈÅÐÏ¿¡£
power_callback_id = sceKernelCreateCallback("Power Callback", power_callback, 0);
scePowerRegisterCallback(0, power_callback_id);
// ¥¹¥ì¥Ã¥É¤ò¥¹¥ê¡¼¥×¤¹¤ë¡£
sceKernelSleepThreadCB();
// Àµ¾ï½ªÎ»¡£
return 0;
}
// ---------------------------------------------------------------------------
// main
//
// ¥á¥¤¥ó¡£
//
// °ú¿ô :
// argc : ̤»ÈÍÑ¡£
// argv : ̤»ÈÍÑ¡£
//
// Ìá¤êÃÍ :
// ¾ï¤Ë 0¡£
// ---------------------------------------------------------------------------
int main(int argc, char *argv[])
{
int callback_thread_id; // ÄÌÃÎ¥¹¥ì¥Ã¥É¤Î ID¡£
SceCtrlData ctrl_data; // ¥³¥ó¥È¥í¡¼¥é¡¼¤Î¾õÂÖ¡£
int buttons_prev; // Á°²ó¤Î¥Ü¥¿¥ó¤Î¾õÂÖ¡£
u32 remoteButtons, remoteButtonsOld = 0;
// ÄÌÃÎ¥¹¥ì¥Ã¥É¤ÎÀ¸À®¤È³«»Ï¡£
callback_thread_id = sceKernelCreateThread("update_thread", callback_thread, 17, 4000, 0, 0);
sceKernelStartThread(callback_thread_id, 0, 0);
// ¥Ç¥Ð¥Ã¥°¥¹¥¯¥ê¡¼¥ó¤Î½é´ü²½¡£
pspDebugScreenInit();
// ¥³¥ó¥È¥í¡¼¥é¡¼¤Î¥µ¥ó¥×¥ê¥ó¥°¥µ¥¤¥¯¥ë¤È¥â¡¼¥É¤ÎÀßÄê¡£
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingCycle(PSP_CTRL_MODE_DIGITAL);
// PSFINFO ¹½Â¤ÂΤνé´ü²½¡£
psf_info = 0;
// ¥ê¥Ð¡¼¥Ö¤ò̵¸ú¤Ë¤¹¤ë¡£
enable_reverb = 0;
// Á°²ó¤Î¥Ü¥¿¥ó¤Î¾õÂÖ¤ò½é´ü²½¡£
buttons_prev = 0;
// ¸½ºß¤Î¥·¡¼¥ó¤ò¡Ö¥Õ¥¡¥¤¥ëÁªÂò¡×¤ËÀßÄê¡£
current_scene = SCENE_FILER;
// ¸½ºß¤Î¥Ç¥£¥ì¥¯¥È¥ê¤ò¡Öms0:/¡×¤ËÀßÄê¡£
strcpy(current_directory, "ms0:/");
// ¥Ç¥£¥ì¥¯¥È¥ê°ìÍ÷¤ò¹¹¿·¤¹¤ë¡£
set_dirents();
// ɽ¼¨¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò½é´ü²½¡£
filer_scene_index = 0;
// ÁªÂò¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò½é´ü²½¡£
filer_scene_select = 0;
// ²èÌ̤ò¹¹¿·¤¹¤ë¡£
filer_draw();
// ¥á¥¤¥ó¥ë¡¼¥×¡£
while(1)
{
// ¥¦¥§¥¤¥È¡£(100 ms)
sceKernelDelayThread(100000);
// ¥³¥ó¥È¥í¡¼¥é¡¼¤Î¾õÂÖ¤ò¼èÆÀ¡£
sceCtrlReadBufferPositive(&ctrl_data, 1);
// Á°²ó¤È²¡¤µ¤ì¤Æ¤¤¤ë¥Ü¥¿¥ó¤Î¾õÂÖ¤¬Æ±¤¸¤«¡©
if(ctrl_data.Buttons == buttons_prev) {
// ¥«¡¼¥½¥ë¥Ü¥¿¥ó°Ê³°¤Ï²¡¤µ¤ì¤Æ¤¤¤Ê¤¤¤â¤Î¤È¤¹¤ë¡£
ctrl_data.Buttons &= (PSP_CTRL_UP | PSP_CTRL_RIGHT | PSP_CTRL_DOWN | PSP_CTRL_LEFT);
} else {
// ¸½ºß¤Î¥Ü¥¿¥ó¤Î¾õÂÖ¤òÊݸ¤¹¤ë¡£
buttons_prev = ctrl_data.Buttons;
}
// ¸½ºß¤Î¥·¡¼¥ó¤Ë±þ¤¸¤¿´Ø¿ô¤ò¸Æ¤Ó½Ð¤¹¡£
switch(current_scene)
{
case SCENE_FILER:
{ // ¥Õ¥¡¥¤¥ëÁªÂò¡£
filer_scene(ctrl_data.Buttons);
remoteButtonsOld = remoteButtons;
sceHprmPeekCurrentKey(&remoteButtons);
// printf_line(0,"r:%d", remoteButtons);
if (remoteButtons != remoteButtonsOld && !(remoteButtons & PSP_HPRM_HOLD))
{
filer_scene_remote(remoteButtons);
}
break;
}
case SCENE_PLAY:
{
// ±éÁÕ¡£
play_scene(ctrl_data.Buttons);
//if (sceHprmIsRemoteExist > 0)
//{
remoteButtonsOld = remoteButtons;
sceHprmPeekCurrentKey(&remoteButtons);
// printf_line(0,"r:%d", remoteButtons);
if (remoteButtons != remoteButtonsOld && !(remoteButtons & PSP_HPRM_HOLD))
{
play_scene_remote(remoteButtons);
// printf_line(0,"r:%d", remoteButtons);
}
//}
}
}
}
// Àµ¾ï½ªÎ»¡£
return 0;
}