Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3
# Touhou Community Reliant Automatic Patcher
# Scripts
#
# ----
#
"""Locates hardcoded strings in a PE file according to a stringdefs.js file and
an optional blacklist. Dumps their relative positions in stringlocs format, as
well as lists of both newly found and garbage strings in the following format:
About Locale Emulator and the concept of locale emulation itself

I came across this program a while ago myself, and was just as amazed by its premise. I looked at the source code, and saw lots of involved low-level NT kernel voodoo I don't understand, instead of the code I tend to use to solve this kind of problem. Truly, this must be an amazing piece of software, I thought... until I tested it with th135 and noticed that it rendered the Music Room text as exactly the same garbage you see when running the game without any locale emulation. Yeah, it did display 東方心綺楼 in the title bar and correctly referenced the 御首頂戴帳 folder, but overall I'd consider this to be a worse alternative to AppLocale.

So I did some research, and it turns out that this thing merely implements the bare minimum of functionality necessary (namely, changing the system ANSI code page in memory) to purportedly keep games from crashing. Anything just a bit more involved

[NekoProject21]
clk_mult=32
DIPswtch=3e f3 7b
ExMemory=1
SampleHz=44100
Latencys=200
SNDboard=6
volume_F=28
volume_S=16
volume_A=28
2014-05-22 19:23 <Nmlgc> http://thpatch.net/wiki/Th10/Images << Yes! Someone *understands* Touhou Patch Center, and started this on their own! <3
2014-05-22 19:24 <Nazeo Aelko Nezen> o:
2014-05-22 19:24 <Nazeo Aelko Nezen> Yaaaay~
2014-05-22 19:27 <Nmlgc> Nazeo, we'll be doing the same image uploading procedure used for 14.3 with the rest of the games over the course of next week.
2014-05-22 19:28 <Nazeo Aelko Nezen> Sounds good!
2014-05-22 19:35 <Nmlgc> ... which means that I have to get the warning for English images up.
2014-05-22 19:35 <Nazeo Aelko Nezen> Warning?
2014-05-22 19:36 <Nmlgc> http://thpatch.net/wiki/Template:Gensokyo.org_note << gensokyo.org, the GEMA of the Touhou community.
2014-05-22 19:39 <Nazeo Aelko Nezen> ......
2014-05-22 19:39 <Nazeo Aelko Nezen> This makes me mad on so many levels.
[01:14:14] Nmlgc: Fuck sleep. I have made a decision.
[01:14:57] Nmlgc: Nazeo, remember November 2012? When I first started work on PC-98, and tried to port the code to modern systems?
[01:15:17] Nmlgc: I am going to complete this project.
[01:16:52] BurntToast12: Are You Sure About This?
[01:16:54] Nmlgc: First, I am going to reassemble the original game back into compilable C++ code and thus open it up.
[01:17:03] BurntToast12: You Shouldn't Push Yourself Too Hard.
[01:17:45] Nmlgc: The disassembly has progressed up to a point where this is pretty much easy and enjoyable grunt work.
[01:17:58] BurntToast12: Hmm..
[01:19:56] Nmlgc: From that point on, we're going to reprogram the games themselves into a truly moddable form, all while keeping the original PC-98 flavor and spirit.
[01:20:28] BurntToast12: Wait, When Modding Pc-98, Does It Have Special Requirements?
@nmlgc
nmlgc / Response to Alcoraiden.md
Last active August 29, 2015 14:02
... or rather, the June 2014 State of Touhou Patching address.

This was written in response to [Alcoraiden's complaints about the current state of thcrap and Touhou translations] (http://www.shrinemaiden.org/forum/index.php/topic,16308.msg1101312.html#msg1101312) and quickly escalated into a full-on "state of patching address". Nazeo will probably censor this in order to better cater to the Shrinemaiden audience, but this is what I would say.


Well, how to start. Isn't this the page he is looking for? The rest should be obvious from looking at the files. Wobuffet3 figured it out, Gamer251 figured it out, and Nazeo did too.

As I said, fighters will be done after Seihou, which will be done after PC-98. And by "fighters", I mean "porting mauve's existing code for th075, th105 and th123".

Engine strings
--------------
(These are only visible in the log file. You can translate them, but you don't need to.)
./thcrap_update/src/update.c:429: log_printf("Deleting %s...\n", key);
./thcrap_update/src/update.c:434: log_printf("%s (locally changed, skipping deletion)\n", key);
./thcrap_update/src/self.c:100: "Retrieving public key from the signer certificate of %s... ", self_fn_utf8
./thcrap_update/src/self.c:183: log_printf("invalid Base64 string\n");
./thcrap_update/src/self.c:195: log_printf("couldn't create hash object\n");
./thcrap/src/inject.c:85: "Could not inject %s.\n" // %s = thcrap.dll
./thcrap/src/inject.c:87: "If you're running Windows Vista or 7, make sure that you have installed the KB2533623 update:\n"
./thcrap/src/init.c:206: log_printf("Applying %s detours to %s...\n", PROJECT_NAME_SHORT(), mod_name);
./thcrap_configure/src/select.c:198: "\t(Contact: %s)\n" // E-mail address
./readme.md:55:* The scripts in the `scripts` directory are written in [Python 3] (http://python.org/).
Repository update script (./scripts/repo_update.py):
# ...
./thcrap/src/exception.c:36: "Exception %x at 0x%08x",
./thcrap/src/exception.c:20: "Registers:\n"
./thcrap/src/inject.c:788: "Couldn't determine the entry point of %s!\n"
./thcrap/src/inject.c:790: "Seems as if %s won't work with this game on your system.\n",
./thcrap/src/mempatch.c:181: log_printf("Detouring DLL functions (%s)...\n", dll_name);
./thcrap_configure/src/configure.c:23: "Error writing to %s!\n"
./thcrap_configure/src/configure.c:24: "You probably do not have the permission to write to the current directory,\n"
./thcrap_configure/src/configure.c:25: "or the file itself is write-protected.\n",
./thcrap_configure/src/configure.c:29: log_printf("Writing is likely to fail for all further files as well.\n");
./thcrap_configure/src/configure.c:32: return Ask("Continue configuration anyway?");
@nmlgc
nmlgc / state-of-pc98-patching.md
Last active December 18, 2015 15:38
The current state of Touhou PC-98 translation patches (2013-06-18)

(also available in spoken form)

OK, let's make this a press statement kind of thing. Please copy-paste this wherever people are asking for progress, release dates or whatever.


As things are now, PC-98 translation patches won't happen before the full version release of Double Dealing Character - and even after that, it will still take a couple of months.

At this point, I myself am the only reason these patches are stalled, so if you want to flame at me, please go ahead, you have every right to do so.