News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: Script insertion question  (Read 4497 times)

Quirino

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
Script insertion question
« on: April 09, 2014, 05:34:29 am »
I'm trying to get a bit more familiar with Rom Hacking in General. I read the dictionary on the site and came across this:

Quote
Script Insertion

After the Script has been dumped and translated the text must be reinserted into the ROM. This is usually more difficult than the extraction because the size of the script has most likely changed.

This is a bit confusing to me, however. As I know there are many (generic) programs out there that handle script dumping/insertion. I was wondering, how do those programs insert scripts that differ in length from the original scripts? Specifically programs that were designed for one rom. What are the most common ways of inserting scripts that are longer than the original ones?

For NES Rom Hacking in particular, what are the ways to store a larger script in a game? The ways I know of is utilizing unused rom space (filled with 00 and FF mainly), DTE/MTE and Rom Expansion. Do those script inserter programs use any of these ways to insert a script that's longer than the dumped script?
Fire Emblem translation romhacking topic:
http://www.romhacking.net/forum/index.php/topic,10647.0.html

henke37

  • Hero Member
  • *****
  • Posts: 643
    • View Profile
Re: Script insertion question
« Reply #1 on: April 09, 2014, 06:57:52 am »
Insertion programs can be told to use those tricks yes. But they still require manual configuration to know what to do.

FAST6191

  • Hero Member
  • *****
  • Posts: 3089
    • View Profile
Re: Script insertion question
« Reply #2 on: April 09, 2014, 09:07:33 am »
Generic script insertion programs tend to be either a) useless or at least very specific or b) complex enough to almost be programming languages unto themselves.

The generic programs rely on the hacker to know how to insert them.

The "one ROM"/game specific programs all vary. Typically I find the hackers that made them found a bunch of free space and noted it all for the program to use as well as the pointer format the script in question might use. ROM expansion varies from system to system -- for the NES it usually falls under the umbrella of mapper change (though you might get away with some window/page changes) and is arguably one of the hardest hacks in ROM hacking, for the GBA it involves putting a bunch of 00/FF on the end of the ROM and if you go beyond 16 megs (limit is 32, most games do not get to 16 megs) then you have a tiny quirk (your addresses start with 09 or equivalents for one of the later mirrors) and finally for the DS and many filesystem using devices it amounts "press rebuild on my filesystem handling tool", save perhaps for some archive formats which end up more like the GBA or if you encounter memory issues.

I would not put it past a game specific program to have a DTE/MTE option or to have a mapper change option built into it, we certainly have programs to scan a script and determine the best candidates for DTE/MTE. I can not recall a program that does it right now but I have seen a few hacker notes/if you want to translate this game into another language guides that have such things included.

Beyond that I would say the most common method is to play editor on your newly edited/translated script to trim it down.

Gideon Zhi

  • Discord Staff
  • Hero Member
  • *****
  • Posts: 3532
    • View Profile
    • Aeon Genesis
Re: Script insertion question
« Reply #3 on: April 09, 2014, 01:29:55 pm »
For NES Rom Hacking in particular, what are the ways to store a larger script in a game? The ways I know of is utilizing unused rom space (filled with 00 and FF mainly), DTE/MTE and Rom Expansion. Do those script inserter programs use any of these ways to insert a script that's longer than the dumped script?

Atlas will do this for you - or, at least, it will help you change the lengths of the strings in question. With NES games especially you're usually restricted to text fitting within a specific bank size, and expanding beyond that can be difficult, certainly moreso than on the SNES. But if you have extra space at the end of the bank Atlas will let you utilize that. It will also fully optimize your script for space at insertion time if you have any DTE or dictionary in your table file; it'll always look for the most space-efficient match and insert that.

For changing string length, you want to look up information about pointers. I'm not sure what the latest greatest pointer document is, but I personally cut my teeth on The Mad Hacker's Guide to NES Pointers. It's really old/crusty/out-of-date and a lot of the explanations for what's what are technically incorrect/misleading, but it should provide a reasonably decent base. Once you understand what pointers are, how to change them, and how they help with the insertion process, we can work on fixing the misconceptions that the document may have given you. Or you could pick a different document, if anyone can suggest something better.

BlackDog61

  • Hero Member
  • *****
  • Posts: 784
    • View Profile
    • Super Robot Wars A Portable translation thread
Re: Script insertion question
« Reply #4 on: April 09, 2014, 02:44:54 pm »
and finally for the DS and many filesystem using devices it amounts "press rebuild on my filesystem handling tool", save perhaps for some archive formats which end up more like the GBA or if you encounter memory issues.

To add to this, on the PSP (and maybe other disk-based systems), you can generally indeed find a program that rebuilds a file structure for you (and an ISO from a file structure) but you can run into addressing issues that are specific to a game, if the game does not use the OS's system calls to load some disk chunks (files) but instead refers to them with an offset on the disk directly. Which means that, when you increase the size of a file, the offsets have to be edited. (Some people incorrectly call this "LBA protection" for the PSP.) As my mentor says - "more fun" issues in these cases...

Not a problem for the NES, though. ;)

Gideon Zhi

  • Discord Staff
  • Hero Member
  • *****
  • Posts: 3532
    • View Profile
    • Aeon Genesis
Re: Script insertion question
« Reply #5 on: April 09, 2014, 03:40:46 pm »
Not a problem for the NES, though. ;)

It kind of is, though. You can think of those disk blocks in the same way you think of NES rom banks, except that with the NES you can't exceed the end of the block/bank without a fair bit of extra assembly code, and it's nontrivial to bolt more of them onto the game.

Pennywise

  • Hero Member
  • *****
  • Posts: 2357
  • I'm curious
    • View Profile
    • Yojimbo's Translations
Re: Script insertion question
« Reply #6 on: April 09, 2014, 04:14:42 pm »
To properly hack the NES, you need specific knowledge. ROM bank limits are generally trivial to overcome, but the process is very much game/mapper specific.

FAST6191

  • Hero Member
  • *****
  • Posts: 3089
    • View Profile
Re: Script insertion question
« Reply #7 on: April 09, 2014, 05:01:19 pm »
To add to this, on the PSP (and maybe other disk-based systems), you can generally indeed find a program that rebuilds a file structure for you (and an ISO from a file structure) but you can run into addressing issues that are specific to a game, if the game does not use the OS's system calls to load some disk chunks (files) but instead refers to them with an offset on the disk directly. Which means that, when you increase the size of a file, the offsets have to be edited. (Some people incorrectly call this "LBA protection" for the PSP.) As my mentor says - "more fun" issues in these cases...

Not a problem for the NES, though. ;)

There are PSP games that use raw addressing outside the ISO filesystem? It is common enough on the PS2 and not unheard of on the PS1 (where it usually gets termed LBA addressing or something like that, probably where the name originated) but I had not heard it was the case on the PSP, give or take some of the binary stuff.

Scio

  • Full Member
  • ***
  • Posts: 155
    • View Profile
Re: Script insertion question
« Reply #8 on: April 09, 2014, 08:22:08 pm »
Wouldn't using RAW addressing be a problem because the games also have the PSN versions, which are downloadable?

Gemini

  • Hero Member
  • *****
  • Posts: 2026
  • 時を越えよう、そして彼女の元に戻ろう
    • View Profile
    • Apple of Eden
Re: Script insertion question
« Reply #9 on: April 10, 2014, 06:42:46 am »
The addressing would still be virtual rather than raw.
I am the lord, you all know my name, now. I got it all: cash, money, and fame.

BlackDog61

  • Hero Member
  • *****
  • Posts: 784
    • View Profile
    • Super Robot Wars A Portable translation thread
Re: Script insertion question
« Reply #10 on: April 11, 2014, 02:25:07 pm »
There are PSP games that use raw addressing outside the ISO filesystem? It is common enough on the PS2 and not unheard of on the PS1 (where it usually gets termed LBA addressing or something like that, probably where the name originated) but I had not heard it was the case on the PSP, give or take some of the binary stuff.

To second Gemini's statement: I have only experience with a single game, which uses OS calls to create a virtual file out of raw offsets in the ISO. (Ex: sound + image data have been packed together in a single file, maybe for the sake of making things harder for us?) So opening the file is not efficient because the file itself is too big, but the game mounts a chunk of memory as a file through standard OS calls.
(The game is Super Robot Taisen A(dvance) Portable. You can mark it as such. ;))
A way to see this happen is to de-ISO the file structure (through UMDGen, standard stuff) and to try to open the main directory to launch the game (from ppsspp). If it starts, then you don't have this problem. If it doesn't start, then the game does not use only the files, but also the offsets in the ISO.
Again, I'm just rehashing stuff I was explained by a good guy. ;) Don't credit me for that.