Universal multiregioniser

antime

Extra Hard Mid Boss
After writing this post I started thinking about the subject and came to the conclusion that not only does it seem possible to make an universal converter, but in fact it looks very simple to do as well.

As I wrote, the problem with adding region codes is that you have to make room for the new strings. The key to this problem lies in the contents of the sys_init file (see Sega's devkits). This is a piece of code that is specified to be included after the region strings. Since the number of strings varies, the position of the code will vary, meaning it can be run from any position in memory. The code is also large enough that three region strings can fit into the same space, plus a bit extra.

The next problem is where to put this code? If we move it upwards in memory there's always the chance that it will conflict with the game's own code. Not very likely if we put it at the very end of the IP, but we're not interested in even a 99% solution here. The answer to that is embarrasingly simple: move it downwards instead.

In the IP there are several fields that are purely informational and are not checked in any way at runtime. The sys_init code is 128 bytes long, and we need two more bytes to jump back to the start of the AIP. The "Compatible Peripherals" and "Game Title" fields add up to 128 bytes together, which is almost enough. Immediately before the peripheral field there is a 6-byte field simply marked "Space", which could supply the last two missing bytes. This last field may be a mistranslation of "Reserved" (which should be filled with zero), but I'm willing to bet it's simply ignored in all production hardware. In order to reach the relocated code a jump instruction should be added after the last region string. There is plenty of room to do that even when adding three region strings.

Thoughts, comments? I'd be especially interested in hearing CyberWarriorX's opinion, should he grace us by his presence. The Panzer Dragoon Saga patch I made relocated the sys_init code and worked without problems, so I believe at least the principle is sound.
 
As I wrote, the problem with adding region codes is that you have to make room for the new strings. The key to this problem lies in the contents of the sys_init file (see Sega's devkits). This is a piece of code that is specified to be included after the region strings. Since the number of strings varies, the position of the code will vary, meaning it can be run from any position in memory. The code is also large enough that three region strings can fit into the same space, plus a bit extra.


The problem with that philosophy is that not all games used the same code. Just for the heck of it I took a look at Farland Saga's ip, and it actually makes several static address function calls in the sys_init area to the sys_init area.

Cyber Warrior X
 
Bang goes that idea then. Could you send me a copy of the game's IP, as it is different from everything I've looked at so far.
 
Back
Top