From bf0a78ee1180b4e0a1249e79a1bde7e1b5686e9c Mon Sep 17 00:00:00 2001 From: root Date: Thu, 2 Jun 2016 14:47:36 -0400 Subject: [PATCH] Okay, all the patches *seem* to work now. Regionfree was wrong before --- doc/bytecode.md | 5 +++++ external/loader/source/patcher.c | 2 +- patch/Makefile | 2 +- patch/regionfree.pco | 3 ++- source/interp.c | 14 ++++++++++++-- 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/doc/bytecode.md b/doc/bytecode.md index e9747cc..0e018fc 100644 --- a/doc/bytecode.md +++ b/doc/bytecode.md @@ -126,3 +126,8 @@ title : 2 + <count> * 8 bytes : 0x0A How many titleIDs to read. <title> : 8 * <count> bytes List of titleIDs as u64. + +next : 1 byte : 0xFF + Resets state to default, and changes the base of code to the next instruction. + This opcode is not meant to be used directly - it's emitted when generating + caches. diff --git a/external/loader/source/patcher.c b/external/loader/source/patcher.c index ca98da6..8a72b2b 100644 --- a/external/loader/source/patcher.c +++ b/external/loader/source/patcher.c @@ -362,7 +362,7 @@ patch_text(u64 progId, u8* text, u32 size, u32 orig_size) execb(PATH_PATCHES "/errdisp.vco", progId, text, orig_size); execb(PATH_PATCHES "/friends_ver.vco", progId, text, orig_size); execb(PATH_PATCHES "/mset_str.vco", progId, text, orig_size); - execb(PATH_PATCHES "/ns_force_menu.vco", progId, text, orig_size); +// execb(PATH_PATCHES "/ns_force_menu.vco", progId, text, orig_size); execb(PATH_PATCHES "/regionfree.vco", progId, text, orig_size); execb(PATH_PATCHES "/secinfo_sigs.vco", progId, text, orig_size); execb(PATH_PATCHES "/ro_sigs.vco", progId, text, orig_size); diff --git a/patch/Makefile b/patch/Makefile index b705764..06a98db 100644 --- a/patch/Makefile +++ b/patch/Makefile @@ -1,5 +1,5 @@ .PHONY: all -all: $(patsubst %.pco, %.vco, $(wildcard *.pco)) +all: clean $(patsubst %.pco, %.vco, $(wildcard *.pco)) mkdir -p ../out/corbenik/bin cp *.vco ../out/corbenik/bin/ diff --git a/patch/regionfree.pco b/patch/regionfree.pco index 25f3e73..0badc5d 100644 --- a/patch/regionfree.pco +++ b/patch/regionfree.pco @@ -7,6 +7,7 @@ # Status: needs loader find 000055E30110A0E3 + # 16 -back 11 +back 10 set 0100A0E31EFF2FE1 diff --git a/source/interp.c b/source/interp.c index 70e183a..462d265 100644 --- a/source/interp.c +++ b/source/interp.c @@ -19,6 +19,7 @@ #define OP_REWIND 0x08 #define OP_AND 0x09 #define OP_TITLE 0x0A +#define OP_NEXT 0xFF #ifdef LOADER #define log(a) logstr(a) @@ -245,6 +246,14 @@ int exec_bytecode(uint8_t* bytecode, uint32_t len, int debug) { } code += *(code-1); break; + case OP_NEXT: + bytecode = code + 1; + set_mode = 3; + current_mode = &modes[set_mode]; + offset = 0; + test_was_false = 0; + code = bytecode; + break; case OP_TITLE: if (debug) log("title\n"); @@ -360,7 +369,7 @@ int execb(char* filename) { } if (!apply) { - // Not meant for us. Not an error, though. + // Not meant for us. return 0; } @@ -390,6 +399,7 @@ int execb(char* filename) { if (patch->titles != 0) { // Not an error, per se, but it means this patch is meant for loader, not us. // Patches intended for use during boot will always be applied to zero titles. + // We should generate a cache for loader in a file intended for titleid. return 0; } @@ -398,5 +408,5 @@ int execb(char* filename) { patch_mem = (uint8_t*)patch + sizeof(struct system_patch) + (patch->depends * 8) + (patch->titles * 8); patch_len = patch->size; #endif - return exec_bytecode(patch_mem, patch_len, 1); + return exec_bytecode(patch_mem, patch_len, 0); } -- 2.39.5