Author Topic: Game engine oddities...  (Read 3656 times)

EthanSilver

  • Lunatic Programmer
  • Got squid, will travel.
    • Ethan Silver's Junkpile - Hacks and translation patches
Game engine oddities...
« on: January 28, 2013, 05:08:17 PM »
I figured I'd share some of my findings reverse-engineering the games' engines. There's a handful of odd things sitting around and I figure this could be useful to someone. There's a bonus if you stick around for the whole rant. ...Or scroll down past it, I guess. Hrm. Looks like we're on the honor system, people!

To sum it up, the majority of the things I'll post about are the result of one game being built on top of an earlier one and old code being left behind. I'll be glad to share more detailed notes about these if anyone decides to work on some neat hack or patch. Every offset listed here is based on the latest english-patched version of the games.



Cherry System in IN

See anything wrong with this picture?

The cherry system from PCB is still in IN. However, much of the code has been scrubbed clean and the actual system itself no longer seems usable. A few bits of text have been left over in some text routines though, even though the text ID never comes up.

The above screenshot was made by swapping the "full power mode" text ID with the cherry text ID. The code which selects this starts at 00438AEF. The strings are loaded as follows:
Code: [Select]
00438BAA push 004B4F98 ; "Supernatural Border!!"
00438C0A push 004B4F84 ; "CherryPoint Max!"
00438C7A push 004B4F70 ; "Border Bonus %7d"



IN's Phantasm Mode

What about this picture? See anything unusual in it?

The Phantasm mode from PCB was left over when IN was written. There is no stage data connecting to it though. Adding a phantasm stage wouldn't be impossible but it would involve some pretty intensive menu screen hacks as there wouldn't be any way of selecting it. But there's definitely support for a 6th "difficulty" and corresponding data.

Playing the game like this doesn't really feel any different than playing on lunatic (though I just did a single suicide-run of stage 1 so I dunno what the rest of the game behaves like). Note that the time orbs are screwed up - the game is using "stage 2, easy"'s data. There's no "Phantasm" icon either - it's been replaced by "Last Word" - so there's that too.



Hint System in SA/UFO
The games following MoF were all built on top of one-another. As late as UFO, there are still references to it. The hint system is still very largely intact and even contains explicit references to MoF ("Touhou Fuujinroku Hint File" and such). The code is obviously not connected up to anything anymore but it looks usable.

00424CC0 writes a hint file.
00424240 reads a hint file.

It seems like it would be possible to hook this code back up to something (several functions make calls to them already based on a condition that, I'm guessing, is never triggered - simply setting the required value doesn't seem to work so it's probably a bit more "disconnected" from the main code than that). But personally I never found the hint system to be any useful (if anything it's distracting), so... I haven't really bothered to look into it. ;)



A useless UFO factoid!
Did you know it actually takes 5 life/bomb fragments to get an extra one? However, the game will make the first life fragment and all bomb fragments count for 2 so it still comes out 4 life fragments / 3 bomb fragments. The reason behind this seems to be so the same display could be used for the both of them without having to create a "quarters" version and a "thirds" version of the little star icon - like this, everything is over 5 and only a "fifths" version of the little star is required.

The life fragment code looks like this...
Code: [Select]
00422D40 add [eax+5c], ecx ; add "ecx" life fragments
00422D43 cmp dword ptr [eax+5c], 05 ; compare to 5
00422D47 jnge 00422D55
...

The calling code looks like this...
Code: [Select]
426BAD cmp dword ptr [004B0C9C], 00 ; do we have 0 life fragments?
426BB4 mov eax, 004B0C40 ; load up the player object
426BB9 mov ecx, 02 ; load up 2 in ecx
426BBE je 00426BC5 ; oh hey, out-of-order instructions! Anyway. If we have 0 life fragments, skip the next line
426BC0 mov ecx, 01 ; replace ecx's value with 1
426BC5 call 00422D30 ; the life fragment function

As for bombs fragments, it's just...
Code: [Select]
00422E20 add dword ptr [eax+64], 02 ; +2 fragments
00422E24 cmp dword ptr [eax+64], 05 ; compare to 5
00422E28 jnge 00422E66
...

Note that fragments are rounded off, so after 3 bomb fragments (3 x 2) the fragments counter would contain 0, not 1.

Now next time you get into a discussion with someone over UFO's extra life/bomb mechanics, you'll have something to put them in their place. :)



Aaaaand, that's it for now. So, for sticking around until the end (or for skipping right to the end without reading any of it - "bah!" to you good sir! ;P ), as promised, here's an autobomb patch for UFO and one for TD. Just stick the contents of the zip in the same folder the game is in and run it. Enjoy!
« Last Edit: April 20, 2013, 04:17:40 AM by EthanSilver »


Latest works
The Strongest