Skip to content

Commit

Permalink
soundless ps1 on vita standalone
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseAaronLopezGarcia committed Jul 23, 2023
1 parent 2bcfbbf commit 4a64abf
Show file tree
Hide file tree
Showing 52 changed files with 1,783 additions and 6,068 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ SUBDIRS = libs \
extras/menus/xMenu \
extras/menus/advancedvsh \
extras/menus/provsh \
extras/modules/peops \
extras/modules/xmbctrl \
extras/modules/usbdevice \
extras/modules/idsregeneration
Expand Down Expand Up @@ -97,7 +98,10 @@ copy-bin:
$(Q)cp extras/modules/idsregeneration/idsregeneration.prx dist/ARK_01234/IDSREG.PRX # idsregeneration
$(Q)cp extras/modules/usbdevice/usbdevice.prx dist/ARK_01234/USBDEV.PRX # USB Device Driver
$(Q)cp extras/installer/EBOOT.PBP dist/PSP/ARK_Full_Installer # Full installer
$(Q)cp extras/modules/peops/peops.prx dist/ARK_01234/PS1SPU.PRX
$(Q)cp contrib/UPDATER.TXT dist/ARK_01234/
$(Q)cp contrib/PSP/popsman.prx dist/ARK_01234/POPSMAN.PRX
$(Q)cp contrib/PSP/pops_01g.prx dist/ARK_01234/POPS.PRX
$(Q)cp -r extras/menus/arkMenu/themes dist/
$(Q)rm -rf dist/themes/translations
$(Q)cp contrib/README.TXT dist/
Expand Down Expand Up @@ -178,6 +182,7 @@ clean:
$(Q)$(MAKE) $@ -C extras/menus/advancedvsh
$(Q)$(MAKE) $@ -C extras/menus/provsh
$(Q)$(MAKE) $@ -C extras/menus/xMenu
$(Q)$(MAKE) $@ -C extras/modules/peops
$(Q)$(MAKE) $@ -C extras/modules/xmbctrl
$(Q)$(MAKE) $@ -C extras/modules/usbdevice
$(Q)$(MAKE) $@ -C extras/modules/ipl_update
Expand Down
10 changes: 10 additions & 0 deletions common/include/systemctrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ unsigned int sctrlModuleTextAddr(char * modname);
// Load Execute Module via Kernel Internal Function
int sctrlKernelLoadExecVSHWithApitype(int apitype, const char * file, struct SceKernelLoadExecVSHParam * param);

/**
* Restart the vsh.
*
* @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL
*
* @returns < 0 on some errors.
*
*/
int sctrlKernelExitVSH(struct SceKernelLoadExecVSHParam *param);

// Register Prologue Module Start Handler
STMOD_HANDLER sctrlHENSetStartModuleHandler(STMOD_HANDLER new_handler);

Expand Down
2 changes: 1 addition & 1 deletion core/compat/vita/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ USE_KERNEL_LIBS=1

LIBDIR = $(ARKROOT)/libs
LDFLAGS = -nostartfiles
LIBS = -lpspsemaphore -lpspsystemctrl_kernel
LIBS = -lpspsemaphore -lpspsystemctrl_kernel -lgraphics -lcolordebugger

PSP_FW_VERSION = 660

Expand Down
33 changes: 16 additions & 17 deletions core/compat/vita/popspatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ extern ARKConfig* ark_config;

// SPU Status
static int running = 0;
static int spu_plugin = -1; // spu thread UID

// SPU Background Thread
int spuThread(SceSize args, void * argp)
Expand Down Expand Up @@ -58,7 +57,7 @@ void _sceMeAudio_DE630CD2(void * loopCore, void * stack)

// Flush Cache
// flushCache();

// Elevate Permission Level
unsigned int k1 = pspSdkSetK1(0);
int thid = sceKernelCreateThread("SPUThread", spuThread, 0x10, 32 * 1024, 0, NULL);
Expand Down Expand Up @@ -91,13 +90,13 @@ static int myKernelLoadModule(char * fname, int flag, void * opt)
strcat(path, "PS1SPU.PRX");
result = sceKernelLoadModule(path, 0, NULL);

spu_plugin = result; // remember spu plugin UID

static char g_DiscID[32];
u16 paramType = 0;
u32 paramLength = sizeof(g_DiscID);
sctrlGetInitPARAM("DISC_ID", &paramType, &paramLength, g_DiscID);
startResult = sceKernelStartModule(result, strlen(g_DiscID) + 1, g_DiscID, &status, NULL);
if (result >= 0){
static char g_DiscID[32];
u16 paramType = 0;
u32 paramLength = sizeof(g_DiscID);
sctrlGetInitPARAM("DISC_ID", &paramType, &paramLength, g_DiscID);
startResult = sceKernelStartModule(result, strlen(g_DiscID) + 1, g_DiscID, &status, NULL);
}

#ifdef DEBUG
printk("%s: fname %s load 0x%08X, start 0x%08X -> 0x%08X\r\n", __func__, path, result, startResult, status);
Expand All @@ -108,20 +107,20 @@ static int myKernelLoadModule(char * fname, int flag, void * opt)
strcat(path, "POPS.PRX");
result = sceKernelLoadModule(path, flag, opt);

if (result<0) result = sceKernelLoadModule("flash0:/kd/pops_660.prx", flag, opt); // load pops modules from injected flash0
if (result<0) result = sceKernelLoadModule(fname, flag, opt); // passthrough
//if (result<0) result = sceKernelLoadModule("flash0:/kd/pops_660.prx", flag, opt); // load pops modules from injected flash0
//if (result<0) result = sceKernelLoadModule(fname, flag, opt); // passthrough

#ifdef DEBUG
printk("%s: fname %s flag 0x%08X -> 0x%08X\r\n", __func__, fname, flag, result);
#endif

//PRTSTR1("Load result: %p", result);
sceKernelDelayThread(3000000);
//sceKernelDelayThread(3000000);

return result;
}

void patchVitaPopsman(SceModule2* mod){
void patchPspPopsman(SceModule2* mod){
u32 text_addr = mod->text_addr;
u32 top_addr = text_addr + mod->text_size;

Expand All @@ -138,6 +137,7 @@ void patchVitaPopsman(SceModule2* mod){
_sw(LI_V0(0), text_addr + 0x35AC + 4);
_sw(JR_RA, text_addr + 0x31EC);
_sw(LI_V0(0), text_addr + 0x31EC + 4);

// Coldbird hacks
_sw(JR_RA, text_addr + 0x0000342C);
_sw(LI_V0(0), text_addr + 0x0000342C + 4);
Expand All @@ -148,11 +148,10 @@ void patchVitaPopsman(SceModule2* mod){
_sw(JAL(myKernelLoadModule), text_addr + 0x00001EE0);
}

void patchVitaPopsSpu(SceModule2 * mod)
void patchPspPopsSpu(SceModule2 * mod)
{
// Fetch Text Address
unsigned int text_addr = mod->text_addr;
// Replace Media Engine SPU Background Thread Starter
//if (spu_plugin<0) // don't patch pops if spu plugin loaded
hookImportByNID(mod, "sceMeAudio", 0xDE630CD2, _sceMeAudio_DE630CD2);
}
int res = hookImportByNID(mod, "sceMeAudio", 0xDE630CD2, _sceMeAudio_DE630CD2);
}
81 changes: 74 additions & 7 deletions core/compat/vita/syspatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ extern void exitLauncher();

extern SEConfig* se_config;

int (* DisplaySetFrameBuf)(void*, int, int, int) = NULL;

KernelFunctions _ktbl = { // for vita flash patcher
.KernelDcacheInvalidateRange = &sceKernelDcacheInvalidateRange,
.KernelIcacheInvalidateAll = &sceKernelIcacheInvalidateAll,
Expand Down Expand Up @@ -132,13 +134,31 @@ int sceAudioOutput2ReleaseFixed(){
return _sceAudioOutput2Release();
}

static void breakPoint(){
_sw(0x44000000, 0xBC800100);
colorDebug(0xFF00);
_sw(0, 0);
}

void ARKVitaOnModuleStart(SceModule2 * mod){

// System fully booted Status
static int booted = 0;

patchFileManagerImports(mod);

patchGameInfoGetter(mod);

if (strcmp(mod->modname, "sceThreadMan") == 0){
_sw(JAL(breakPoint), mod->text_addr+0x00017930);
goto flush;
}

if(strcmp(mod->modname, "sceDisplay_Service") == 0) {
DisplaySetFrameBuf = (void*)sctrlHENFindFunction("sceDisplay_Service", "sceDisplay", 0x289D82FE);
goto flush;
}

// Patch sceKernelExitGame Syscalls
if(strcmp(mod->modname, "sceLoadExec") == 0)
{
Expand All @@ -155,22 +175,21 @@ void ARKVitaOnModuleStart(SceModule2 * mod){
goto flush;
}

/*
// Patch Vita Popsman
// Patch PSP Popsman
if (strcmp(mod->modname, "scePops_Manager") == 0){
patchVitaPopsman(mod);
patchPspPopsman(mod);
// Hook scePopsManExitVSHKernel
sctrlHENPatchSyscall((void *)sctrlHENFindFunction("scePops_Manager", "scePopsMan", 0x0090B2C8), K_EXTRACT_IMPORT(exitLauncher));
//sctrlHENPatchSyscall((void *)sctrlHENFindFunction("scePops_Manager", "scePopsMan", 0x0090B2C8), K_EXTRACT_IMPORT(exitLauncher));
goto flush;
}

// Patch POPS SPU
// Patch PSP POPS SPU
if (strcmp(mod->modname, "pops") == 0)
{
patchVitaPopsSpu(mod);
//breakPoint();
patchPspPopsSpu(mod);
goto flush;
}
*/

// VLF Module Patches
if(strcmp(mod->modname, "VLF_Module") == 0)
Expand Down Expand Up @@ -224,10 +243,58 @@ void ARKVitaOnModuleStart(SceModule2 * mod){
if(previous) previous(mod);
}

int (*prev_start)(int modid, SceSize argsize, void * argp, int * modstatus, SceKernelSMOption * opt) = NULL;
int StartModuleHandler(int modid, SceSize argsize, void * argp, int * modstatus, SceKernelSMOption * opt){

SceModule2* mod = (SceModule2*) sceKernelFindModuleByUID(modid);

/*
if (DisplaySetFrameBuf){
static int screen_init = 0;
if (!screen_init){
initScreen(DisplaySetFrameBuf);
screen_init = 1;
}
cls();
PRTSTR1("mod: %s", mod->modname);
}
*/

struct {
char* name;
char* path;
} pops_files[] = {
{"scePops_Manager", "POPSMAN.PRX"},
{"sceMediaSync", "MEDIASYNC.PRX"},
};

for (int i=0; i < sizeof(pops_files)/sizeof(pops_files[0]); i++){
if (strcmp(mod->modname, pops_files[i].name) == 0){
char path[ARK_PATH_SIZE];
strcpy(path, ark_config->arkpath);
strcat(path, pops_files[i].path);
SceIoStat stat;
int res = sceIoGetstat(path, &stat);
if (res>=0){
sceKernelUnloadModule(modid);
modid = sceKernelLoadModule(path, 0, NULL);
return sceKernelStartModule(modid, argsize, argp, modstatus, opt);
}
}
}

// forward to previous or default StartModule
if (prev_start) return prev_start(modid, argsize, argp, modstatus, opt);
return -1;
}

void PROVitaSysPatch(){
SceModule2* mod = NULL;
// filesystem patches
initFileSystem();
// patch loadexec to use inferno for UMD drive emulation (needed for some homebrews to load)
patchLoadExecUMDemu();

// Register custom start module
prev_start = sctrlSetStartModuleExtra(StartModuleHandler);
}
27 changes: 25 additions & 2 deletions core/compat/vitapops/syspatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ int kermitSendRequestLog(void* a0, int a1, int a2, int a3, int a4, void* a5){

if (!logging){
logging = 1;
sprintf(tmp, "mode: %d, cmd: %d\n", a1, a2);
sprintf(tmp, "sceKermitSendRequest - mode: %d, cmd: %d\n", a1, a2);
int fd = sceIoOpen("ms0:/kermit.log", PSP_O_WRONLY|PSP_O_APPEND|PSP_O_CREAT, 0777);
sceIoWrite(fd, tmp, strlen(tmp));
sceIoClose(fd);
Expand All @@ -312,13 +312,33 @@ int kermitSendRequestLog(void* a0, int a1, int a2, int a3, int a4, void* a5){
return sceKermitSendRequest(a0, a1, a2, a3, a4, a5);
}

int (*sceKermitPeripheral_driver_8C7903E7)() = NULL;
int sceKermitPeripheral_driver_log(void* a0, int a1, int a2, int a3, int a4, void* a5, u32 a6, u32 a7){

static volatile int logging = 0;
static char tmp[64];

//if (a1 == 9 && a2 == 1042) return 0;

if (!logging){
logging = 1;
sprintf(tmp, "sceKermitPeripheral_driver_8C7903E7 - mode: %d, cmd: %d\n", a1, a2);
int fd = sceIoOpen("ms0:/kermit.log", PSP_O_WRONLY|PSP_O_APPEND|PSP_O_CREAT, 0777);
sceIoWrite(fd, tmp, strlen(tmp));
sceIoClose(fd);
logging = 0;
}

return sceKermitPeripheral_driver_8C7903E7(a0, a1, a2, a3, a4, a5, a6, a7);
}

void ARKVitaPopsOnModuleStart(SceModule2 * mod){

static int booted = 0;

/*
if (strcmp(mod->modname, "sceIOFileManager") != 0 && strcmp(mod->modname, "sceKermitMsfs_driver") != 0){
hookImportByNID(mod, "sceKermit_driver", 0x36666181, kermitSendRequestLog);
}
*/

Expand Down Expand Up @@ -358,6 +378,9 @@ void ARKVitaPopsOnModuleStart(SceModule2 * mod){
*/

if (strcmp(mod->modname, "scePops_Manager") == 0){
sceKermitPeripheral_driver_8C7903E7 = sctrlHENFindFunction("sceKermitPeripheral_Driver", "sceKermitPeripheral_driver", 0x8C7903E7);
hookImportByNID(mod, "sceKermitPeripheral_driver", 0x36666181, sceKermitPeripheral_driver_log);
hookImportByNID(mod, "sceKermit_driver", 0x36666181, kermitSendRequestLog);
patchPopsMan(mod);
goto flush;
}
Expand Down
Loading

0 comments on commit 4a64abf

Please sign in to comment.