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

Author Topic: Game Data?  (Read 4011 times)

Pal

  • Jr. Member
  • **
  • Posts: 6
    • View Profile
Game Data?
« on: July 16, 2013, 01:51:50 am »
Hey guys, I've searched for about three hours now and experimented for about an hour on trying to get somewhere but I just don't quite understand what I'm supposed to do or I don't understand how to use the program (at least I think the program is meant to be utilized that way).

So here is my question, how exactly do I view the game data found on a GBA ROM? By game data I mean things like damage formulas, stats, functions, etc. I'm not sure where that's located, but if my three hours of research has gotten me anywhere I think it might be in the game script? If so I have a bunch of follow up questions.

First of all how do I get the game's script, secondly how do I read the scripts if it's not in ASCII, then how do I go about using pointer values to find said data. I also understand that there are different forms of compression and I'd need some way of working out what decompression program and format to use, and I understand hexadecimal values however that's as much as I understand, I don't know why a certain string is associated to X thing or w/e.

If anyone can help me understand all of this it would be greatly appreciated.

Klarth

  • Sr. Member
  • ****
  • Posts: 495
    • View Profile
Re: Game Data?
« Reply #1 on: July 16, 2013, 02:05:07 am »
Damage formulas are directly coded into the game, so you will need to learn programming (assembly) and debugging techniques to do this.  Which is a very, very high hurdle if you're a beginner without programming experience.

Stats may be slightly easier, but still generally requires assembly and debugging experience.

For damage formulas and stats, I'd suggest that you look at a game that already has that information publicly available and see if you can figure out how to find that data yourself.

The game script is the text displayed in the game, such as when you talk to a character in an RPG.  I don't think you want this, but if you do, then let us know.

Pal

  • Jr. Member
  • **
  • Posts: 6
    • View Profile
Re: Game Data?
« Reply #2 on: July 16, 2013, 02:25:49 am »
I do have some experience with programming, I tried to design a game using a program called game maker using programming language. It was okay I had some problem making a smooth animation from jumping since the sprites I used were from Megaman and they had a complicated jumping animation.

But I don't think it'll be too hard to understand debugging from that.

I can try with Pokemon, but I'm not entirely sure how to get the stuff coded from the game.

FAST6191

  • Hero Member
  • *****
  • Posts: 3089
    • View Profile
Re: Game Data?
« Reply #3 on: July 16, 2013, 04:44:44 am »
Pokemon is quite a hard game to hack if you are not otherwise familiar with ROM hacking. Fortunately for those wishing to hack pokemon games they usually have lots of very high level tools to change things.

Similarly game maker to assembly is quite a leap (game maker is an odd setup as far as programming things goes).

The other stuff Klarth already took.

Also as the word came up scripting as it applies to pokemon is dealing more with most others would recognise as game events, certainly posts like "I need help with scripting", "scripter wanted" and such like will be for that. To that end if you do go exploring the pokemon hacking world then be aware of this wording change.

Game text scripts then.

Games can be in ASCII and several GBA ones are. ASCII and 8 bit stuff is not that useful for Japanese though (thousands of characters is more than the 256 options afforded by having 8 bits per character*) so some games will use other formats including known ones like unicode, EUC-jp and shiftJIS though this is more common on the DS.
*there are annoying workarounds that some games have used over the years but let us not go there at the moment as they are not common on the GBA and more modern systems.

Custom character mappings then.
You can find these in all sorts of ways, if working on an English or other language that uses the Roman character set you can use a relative searcher. Beyond this there are all sorts of programming, statistical, hackery and other tricks to find it right up to actually just debugging the program. I cover a few in my WIP docs for the GBA and DS http://www.romhacking.net/forum/index.php?topic=14708.0

Once you have the mapping you put it into a table file (for the most part a small text file that lists the custom encodings and what they convert as). At this point you can load it into a hex editor that supports tables or a program that supports tables (aka a script dumper).
There are several of each and though certain non hacking tools will have a tiny measure of support for custom encodings if you are not finding it in http://www.romhacking.net/utilities/ or a site like this one you will likely not get far.

Pointers. Do as they imply and merely point the way to something else. On the GBA they are usually quite simple and as the GBA cart is mainly found at 08000000 through 09FFFFFF (mainly 08 and that allows for 16 megabytes and most GBA games are 16 megabytes or less) you get a lot of 08?????? where the ?????? is the location in the game. In practice the value for a pointer to part of the game as 00123456 will read 5634 1208 courtesy of byte flipping/endianess (ARM processors and indeed most that are not X86 family will do it this way).

That is a vastly simplified version of it though as the GBA cart is also found at several other locations in the GBA memory (seldom used and theoretically you could do a search for 5634 12 and it would also work), things could be transported to main memory (especially if compression is involved) and things could be using far more complex pointers/pointer maths (would be odd but not unheard of).



Pal

  • Jr. Member
  • **
  • Posts: 6
    • View Profile
Re: Game Data?
« Reply #4 on: July 16, 2013, 05:54:01 am »
Alright, well that is a load of information.

Do you mind explaining what mapping is?

But basically in the game I'm trying to work out, there is a function of combining things to get a specific character, and you could link up with another game and combine four things so that both parties receive the same specific character, so these combinations should be stored somewhere and can be called whenever X combination is used. How do I / would I go about finding the entire storage of the data? Similarly that logic should apply for the stats of a character, and would that include things like the stat growth of a character and when the stats stop growing etc. Would finding the storage of a character's stats be the same as the storage for combinations. Then lastly there are the formulas used for battle mechanics.

Those are the three things that I mainly want to find in the game, I'm not looking to change anything I just want to see and document these things for research purposes. If I can tear the game down completely then that would be great but if I can only do those three things then I would be happy.

FAST6191

  • Hero Member
  • *****
  • Posts: 3089
    • View Profile
Re: Game Data?
« Reply #5 on: July 16, 2013, 07:08:13 am »
Mapping is a general computer term that covers a few of things. I should also note there is a term that governs a lot of NES hacking called mappers which are hardware chips on NES carts that change mapping of various things.

It roughly translates as what a given number or address corresponds to in a given context.

The GBA cart maps to 08000000 and goes on to 09FFFFFF would be a valid phrase.
Likewise "in ASCII the space character maps to 20 hex" is also a valid phrase.

The context thing is all important in ROM hacking for there are only two positions for a bit to be in (1 or 0) and it depends entirely upon where it is in relation to the overall program as to what it means to the operations going on. This is where you also get a lot of entry points for a lot of hacking for if you can get a game to jump into what it actually a text area and have it trying to decode it as instructions then all sorts of fun things happen, that is a different discussion for another day though.

As for what you described there are hundreds of possible methods by which to achieve it.
For my money they fall into three or possibly four classes
1) Just add a random number. Surprisingly common actually (*shakes fist shining force games*).
2) Hardcoded progression in the code. Usually straight mathematical combo. I should also note things like health = constitution * level type formulas.
3) External level chart. http://www.pipian.com/ierukana/hacking/ds_evos.html is something for some DS entries into pokemon.

They are not exclusive and you can mix and match a bit between all three if you want. Indeed 2 and 3 get mixed so often it might as well be the fourth option and that is before you consider things like external multipliers (see stuff like ev training in pokemon). Likewise just add random can also mean here is a number, now randomly distribute it among the stats.

How you would set about it. Following on from above it can be all sorts of methods. For as annoying as 3) was though I hope you have this for it is 1 or 2 then you can face the people coding it doing less than stellar coding and you having to hunt down a one off function used for that* (though if you can get to that point and repeat it several times it is probably not so bad).

*I see this quite often for "game critical" items.

"battle mechanics"
As in what enemy attacks when and what attack they use?

Pal

  • Jr. Member
  • **
  • Posts: 6
    • View Profile
Re: Game Data?
« Reply #6 on: July 16, 2013, 07:36:15 am »
Ah okay thanks for describing mapping.

Um I don't think it would be the first option as each creation process for X character always gives the same stats. I could potentially be 2, it might be 3 as well, yeah this game doesn't have external multipliers like Pokemon as they always achieve the same end stat regardless of what battles they undergo. They also have a level cap where they no longer gain any stats afterwards.

Would it be easier if I had GameShark codes that could alter the outcome of the creation process regardless of what was used?

Um just like damage formula and ability formula, and like resistances and weaknesses, etc. Action sets would be nice to work out but I don't know how easy or difficult that would be.

Zoinkity

  • Hero Member
  • *****
  • Posts: 565
    • View Profile
Re: Game Data?
« Reply #7 on: July 16, 2013, 09:52:49 am »
That's one that wasn't covered.  You can use cheat codes to shortcut finding data you're looking for.  They only work one of two ways:
1) Game Genies (unless things changed recently) replace data in a ROM with different data, usually as it's loaded.
2) Action Replays/Game Sharks alter RAM, so they could be changing a wide range of things.
The handy part about this is even if the code isn't specificly what you want, you can usually work backward from there.

As an example, take the code that changes the outcome of the combination. It isn't what you want, but the code is writing the RAM address set by the code you want to trace.  You have a few options here:
1) You can search for that address itself, which may or may not work and could give you multiple hits.
2) You can use a debugger, set a break-on-write breakpoint at that RAM address, then wait for the game to write to it.  When the breakpoint is set off you can look at the code that came before the write to see how they do the combination.  Worst case, this was copying the value from someplace else and you'll have to use several breaks to get back to the source.

So yes, if you had a GS code for setting that, so long as it doesn't do anything weird you could totally backtrace it. 

Pal

  • Jr. Member
  • **
  • Posts: 6
    • View Profile
Re: Game Data?
« Reply #8 on: July 16, 2013, 11:49:20 pm »
Ah sick thanks for all the help, I'll start leaning about debugging and tracing first then, just to confirm this would still work under the context of a linked game correct? Since you can connect with another game to combine four, I can still debug both emulators to have the break-on-write while I have the GS code for both / one?

FAST6191

  • Hero Member
  • *****
  • Posts: 3089
    • View Profile
Re: Game Data?
« Reply #9 on: July 17, 2013, 05:12:41 am »
Two things might get in the way

GS codes troubling timing. Such things did happen a bit but this is more limited to hardware and not emulation which does not have inject a code handler into the game.

The debug grade emulators. I must admit I have not looked at the likes of MESS or Mednafen in some time here and these days if I am looking for a debugging grade emulator for older systems I usually end up there.
Still there are three most people would consider

VBA-SDL-h
http://labmaster.bios.net.nz/vba-sdl-h/
Nice guide from the docs section of this site
http://www.romhacking.net/documents/361/

no$gba
http://nocash.emubase.de/gba-dev.htm
This is a paid tool but it is very nice.

BoycottAdvance
Site went some time back but still available from
http://filetrip.net/gba-downloads/emulators/download-boycottadvance-028-windows-f28912.html
Nowhere near as good an emulator as VBA or no$gba but is free and more GUI happy for its limited debugging abilities.

The trouble is the vanilla VBA pointedly never included emulator link support and it was added in a fork (in this case VBAlink). VBA-sdl-h is not a fork of that fork. no$gba should have some measure of link support but I have never tried actively debugging link stuff with it.

There is a unification project (indeed it is probably the only fork/version under active development right now) which you can see http://vba-m.com/ though I am not sure how far its debugging abilities have been taken (VBA-SDL-h is somewhat slower/more resource hungry so it tends to get sidelined a bit in the unification project).

All that said the link stuff is pretty touchy about timing on occasion so having it halt thanks to your breakpoint might not do.

Pal

  • Jr. Member
  • **
  • Posts: 6
    • View Profile
Re: Game Data?
« Reply #10 on: July 17, 2013, 06:08:06 am »
Ah okay fair enough, well hopefully the combinations requiring four materials are next to two material combinations. I mean if I familiarize myself with the way the two material combinations are set up finding 8855 four material combinations shouldn't be hard :P.

Thanks for all the help FAST6191