Skip to content

Commit

Permalink
Added (L)ME support, error trapping, new sounds.
Browse files Browse the repository at this point in the history
  • Loading branch information
krazynez committed Oct 27, 2023
1 parent 0e3061b commit 5e2ccde
Show file tree
Hide file tree
Showing 13 changed files with 322 additions and 136 deletions.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,23 @@ all: #subdirs # user kernel
$(MAKE) $@ -C libs
$(MAKE) $@ -C user
$(MAKE) $@ -C kernel
$(MAKE) $@ -C me_fix
@mkdir -p $(UMDREGIONROOT)/dist/PSP/GAME/UMD_Region_Changer || true
@cp $(UMDREGIONROOT)/user/EBOOT.PBP $(UMDREGIONROOT)/dist/PSP/GAME/UMD_Region_Changer/
@cp $(UMDREGIONROOT)/kernel/*.prx $(UMDREGIONROOT)/dist/PSP/GAME/UMD_Region_Changer/
@cp $(UMDREGIONROOT)/IDSREG.PRX $(UMDREGIONROOT)/dist/PSP/GAME/UMD_Region_Changer/
@cp $(UMDREGIONROOT)/res/matrix_new.png $(UMDREGIONROOT)/dist/PSP/GAME/UMD_Region_Changer/BG.PNG
@cp $(UMDREGIONROOT)/res/EXIT.MP3 $(UMDREGIONROOT)/dist/PSP/GAME/UMD_Region_Changer/EXIT.MP3
@cp $(UMDREGIONROOT)/res/ACCEPT.MP3 $(UMDREGIONROOT)/dist/PSP/GAME/UMD_Region_Changer/ACCEPT.MP3
@cp $(UMDREGIONROOT)/res/SELECTION.MP3 $(UMDREGIONROOT)/dist/PSP/GAME/UMD_Region_Changer/SELECTION.MP3
mkdir $(UMDREGIONROOT)/dist/SEPLUGINS || true
@cp $(UMDREGIONROOT)/me_fix/UMD_Region_Changer_ME_fix.prx $(UMDREGIONROOT)/dist/SEPLUGINS/
@cp $(UMDREGIONROOT)/me_fix/___README_FIRST____.MD $(UMDREGIONROOT)/dist/SEPLUGINS/
@echo "Build Done"

clean:
$(MAKE) $@ -C user
$(MAKE) $@ -C kernel
$(MAKE) $@ -C me_fix
@rm -rf $(UMDREGIONROOT)/dist *.zip
@find . -type f -name "*.o" -delete -o -name "*.elf" -delete -o -name "*.prx" -delete -o -name "*.PBP" -delete -o -name "*.SFO" -delete -o -name "*.a" -delete
@echo CLEAN
Expand Down
45 changes: 43 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,60 @@

3. After copying `UMD_Region_Changer` to `ms0:/PSP/GAME` make sure your UMD door is NOT closed/detected then run it.

4. If you accidently do have your UMD door closed, once the XMB is loaded you can just open and close the UMD door and the UMD will be allowed to be played.
4. If you accidentally do have your UMD door closed, once the XMB is loaded you can just open and close the UMD door and the UMD will be allowed to be played.


<p>Note:As of right now this does not support Game Categories Lite. I will be working on that to see if I can figure a way to support it. Thanks for your cooperation and patience.


### Releases

For the latest release go <a href="https://github.com/PSP-Archive/UMD_Region_Changer/releases/latest">here</a>


## Setup & Install


#### PRO Users

1. Run UMD Region Changer

2. Choose the region

3. Once XMB display insert UMD of you selected Region

4. Play and enjoy your Movie



#### (L)ME Users

<p>Reason why ME is forced to use a plugin. For some reason <code>sctrlHENLoadModuleOnReboot</code> does not play nice with ME.
I had to create a plugin that would do the equivalent that the normal EBOOT does but as a plugin for it to work on ME.
Like no joke its almost a 1:1 copy and paste of it.
<code>sctrlHENLoadModuleOnReboot</code> is slightly different than on PRO and ARK from reading the documentation for instance,
the first argument on PRO and ARK-4 is module_before, but with ME its module_after so even if it "just worked" the placement
of the patches would not correlate with what we thought was going to happen. It seems that that only works via game interaction or some sorts.
Which is very bizarre as its part of systemctrl so it should be available globally? I will be more than happy to discuss my findings
or if they are in need so some test cases. I was determined to find a way to get it working and did, not 100% ideal by all means, but it does work.</p>

1. copy `UMD_Region_Changer_ME_fix.prx` to `SEPLUGINS` located on your PSP

2. Add `ms0:/SEPLUGINS/UMD_Region_Changer_ME_fix.prx 1` to `GAME.TXT`

3. Run UMD Region Changer

4. Choose the region

5. Once XMB display insert UMD of you selected Region

6. Play and enjoy your Movie


<hr/>

<p><b>NOTE:</b> This is not persistant, if you restart your PSP the UMD Drive will default back to its original state.</p>

<p><b>NOTE:</b> This is not persistent, if you restart your PSP the UMD Drive will default back to its original state.</p>


### Credits:
Expand All @@ -37,6 +77,7 @@
<p><b><u>Others</u></b>

- PSP_Cult for providing the graphics and logo(s)/icon(s) and testing.
- Github Search with other users provided me to get ME support working, such as `qwikrazor87`'s npdrm_free repo. May he rest in peace, I truly wish you were hear to take guidance from.

</p>

Expand Down
2 changes: 2 additions & 0 deletions common/include/systemctrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ enum BootLoadFlags
BOOTLOAD_GAME = 2,
BOOTLOAD_UPDATER = 4,
BOOTLOAD_POPS = 8,
BOOTLOAD_APP = 32,
BOOTLOAD_UMDEMU = 64, /* for original NP9660 */
BOOTLOAD_MLNAPP = 128, /* for original NP9660 */
};

#ifdef __cplusplus
Expand Down
9 changes: 6 additions & 3 deletions kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ endif

CXXFLAGS = $(CFLAGS) -fno-execeptions -fno-rtti
ASFLAGS = $(CFLAGS)
LDFLAGS = -nostartfiles

INCDIR = $(UMDREGIONROOT)/common/include ./include

INCDIR = ./include

PSP_FW_VERSION = 660
BUILD_PRX = 1
Expand All @@ -19,9 +21,10 @@ OBJS = main.o
USE_KERNEL_LIBC=1
USE_KERNEL_LIBS=1

INCDIR = $(UMDREGIONROOT)/common/include ./include

LIBS = -lc -lpspsystemctrl_kernel


LIBS = -lpspsystemctrl_kernel -lpspdisplay

LIBDIR=$(UMDREGIONROOT)/libs

Expand Down
1 change: 1 addition & 0 deletions kernel/exports.exp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ PSP_BEGIN_EXPORTS

PSP_EXPORT_START(syslib, 0, 0x8000)
PSP_EXPORT_FUNC_HASH(module_start)
PSP_EXPORT_FUNC_HASH(module_stop)
PSP_EXPORT_VAR_HASH(module_info)
PSP_EXPORT_END

Expand Down
70 changes: 32 additions & 38 deletions kernel/main.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <pspkernel.h>
#include <pspsdk.h>
#include <pspinit.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspinit.h>

#include <model.h>
#include <kern_common.h>
Expand All @@ -15,7 +15,7 @@
#define NOP 0
#define JUMP(f) (0x08000000 | (((unsigned int)(f) >> 2) & 0x03ffffff))

PSP_MODULE_INFO("UMDREGION_Module", 0x3007, 1, 5);
PSP_MODULE_INFO("UMDREGION_Module", 0x3007, 1, 6);

STMOD_HANDLER previous;

Expand Down Expand Up @@ -137,38 +137,7 @@ unsigned int find_Import_ByNID(SceModule2 * pMod, char * library, unsigned int n
return 0;
}

void PSPOnModuleStart(SceModule2 * mod){


if(strcmp(mod->modname, "sceUmdMan_driver") == 0) {
patch_umd_idslookup(mod);
goto flush;
}

if (strcmp(mod->modname, "vsh_module") == 0){
patch_vsh_region_check(mod);
goto flush;
}

if (strcmp(mod->modname, "impose_plugin_module") == 0){
SceUID kthreadID = sceKernelCreateThread( "umd_region_change", &patch_umd_thread, 1, 0x20000, PSP_THREAD_ATTR_VFPU, NULL);
if (kthreadID >= 0){
// start thread and wait for it to end
sceKernelStartThread(kthreadID, 0, NULL);
}
goto flush;

}

flush:
flushCache();

// Forward to previous Handler
if(previous)
previous(mod);
else
return NULL;
}



Expand Down Expand Up @@ -317,12 +286,13 @@ int sctrlArkReplaceUmdKeys(){
// load and start idsRegeneration module
// ms0:/PSP/GAME/UMD_Region_Changer/
char path[UMD_REGION_PATH_SIZE];
strcpy(path, UMD_REGION_PATH);
strcpy(path, UMD_REGION_PATH);
strcat(path, "IDSREG.PRX");


SceUID modid = sceKernelLoadModule(path, 0, NULL);
if (modid >= 0){
res = sceKernelStartModule(modid, strlen(path) + 1, path, NULL, NULL);
res = sceKernelStartModule(modid, strlen(path)+1, path, NULL, NULL);
if (res < 0){
goto fake_ids_end;
}
Expand Down Expand Up @@ -350,8 +320,6 @@ int sctrlArkReplaceUmdKeys(){
if (res < 0) goto fake_ids_end;

// initialize idsRegeneration with hardware info and new region
//
//
res = idsRegenerationSetup(tachyon, baryon, pommel, mb, fuseid, region_num, NULL);
if (res < 0) goto fake_ids_end;

Expand Down Expand Up @@ -404,10 +372,36 @@ int patch_umd_thread(SceSize args, void *argp){
return 0;
}

int PSPOnModuleStart(SceModule2 * mod){

if(strcmp(mod->modname, "sceUmdMan_driver") == 0) {
patch_umd_idslookup(mod);
flushCache();
}

if (strcmp(mod->modname, "vsh_module") == 0){
patch_vsh_region_check(mod);
flushCache();
}

if (strcmp(mod->modname, "impose_plugin_module") == 0){
SceUID kthreadID = sceKernelCreateThread( "umd_region_change", &patch_umd_thread, 1, 0x20000, PSP_THREAD_ATTR_VFPU, NULL);
if (kthreadID >= 0){
// start thread and wait for it to end
sceKernelStartThread(kthreadID, 0, NULL);
}
flushCache();

}

int module_start(SceSize args, void *argp) {

// Forward to previous Handler
if(previous) previous(mod);
else return 0;
}


int module_start(SceSize args, void *argp) {
previous = sctrlHENSetStartModuleHandler(PSPOnModuleStart);
return 0;
}
Expand Down
29 changes: 29 additions & 0 deletions me_fix/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
TARGET = UMD_Region_Changer_ME_fix
CFLAGS = -Wall -O2 -G0
ifdef DEBUG
CFLAGS += -DDEBUG=$(DEBUG)
endif

LDFLAGS += -mno-crt0 -nostartfiles
CXXFLAGS = $(CFLAGS) -fno-execeptions -fno-rtti
ASFLAGS = $(CFLAGS)

PSP_FW_VERSION = 660
BUILD_PRX = 1

PRX_EXPORTS = exports.exp

OBJS = main.o

USE_KERNEL_LIBC=1
USE_KERNEL_LIBS=1


INCDIR = $(UMDREGIONROOT)/common/include ./include
LIBDIR=$(UMDREGIONROOT)/libs

LIBS = -lc -lcolordebugger -lpspsystemctrl_kernel -lpspkubridge


PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build_prx.mak
4 changes: 4 additions & 0 deletions me_fix/___README_FIRST____.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
USE ONLY FOR (L)ME


!!!!!!!!!! DO NOT USE ON PRO !!!!!!!!!!!
10 changes: 10 additions & 0 deletions me_fix/exports.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Define the exports for the prx
PSP_BEGIN_EXPORTS

PSP_EXPORT_START(syslib, 0, 0x8000)
PSP_EXPORT_FUNC_HASH(module_start)
PSP_EXPORT_FUNC_HASH(module_stop)
PSP_EXPORT_VAR_HASH(module_info)
PSP_EXPORT_END

PSP_END_EXPORTS
Loading

0 comments on commit 5e2ccde

Please sign in to comment.