Author Topic: [WIP] Custom Game Settings (FF7)  (Read 92453 times)

Wutai Clan

  • *
  • Posts: 115
    • View Profile
Re: [WIP] Custom Game Settings (FF7)
« Reply #100 on: 2011-04-27 01:50:53 »
Here, this package contains three debug versions, try them all, and let me know which if any works. (Run in windowed mode for the test.)

http://www.mediafire.com/?d3apd6xwex9yc7g

Basically, I've disabled several features in each version, to try to narrow down where it's going wrong.

Here are the test descriptions.

DLL Load Test:

This test does nothing but show a messagebox, every other feature is disabled, if this doesn't work, it's a runtime\compile issue.

Console Only Test:

This test will just load the debug console, this will tell me if that's somehow causing issues. (Though it was disabled by default.)

No Logging Test:

This test will load everything, but disables all logging features, to determine whether the logging method is an issue.

---

I forgot to include the .ini file, just put this in a .txt file, and name it GameSettings.ini, if you don't still have a copy..

Code: [Select]
[Debug Console]
Enabled = true

[Infinite Item Use]
Enabled = true

[MP Regeneration Settings]
Enabled = true
Rate = 6

[Random Battle Settings]
Enabled = true
Rate = 2

[Battle Reward Multipliers]
Enabled = true
EXP = 2
GIL = 2
AP = 2
« Last Edit: 2011-04-28 02:33:17 by Wutai Clan »

Dark_Ansem

  • *
  • Posts: 320
    • View Profile
Re: [WIP] Custom Game Settings (FF7)
« Reply #101 on: 2011-04-27 07:02:02 »
will try this later. good work.

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: [WIP] Custom Game Settings (FF7)
« Reply #102 on: 2011-04-27 10:34:36 »
In other news, I think I know how to fix this sense issue...

edit.  Not so easy.  Probably going to take a lot of messing.  I know what is wrong but to fix takes a bit more work :) I will send what I have learned in PM.
« Last Edit: 2011-04-27 12:18:47 by DLPB »

TTK_86

  • *
  • Posts: 28
    • View Profile
Re: [WIP] Custom Game Settings (FF7)
« Reply #103 on: 2011-04-27 15:52:06 »
Works fine with me!  It seems that EXP and AP multiplier is a bit off, it sets too high values in game.

Wutai Clan

  • *
  • Posts: 115
    • View Profile
Re: [WIP] Custom Game Settings (FF7)
« Reply #104 on: 2011-04-27 16:02:13 »
Works fine with me!  It seems that EXP and AP multiplier is a bit off, it sets too high values in game.

Which version did you try, the one from the last page, or the debug builds from this page, it's kind of important, I need to solve the issue of it not working for some people.

About the battle rewards, yeah, I thought they seemed kinda high, the code must loop, and apply the multiplier multiple times, or the code I used doesn't work as intended, I'll try to get some debug output on original values vs. modified values for Exp\Gil\AP, to figure out what's wrong.
« Last Edit: 2011-04-27 16:35:20 by Wutai Clan »

Wutai Clan

  • *
  • Posts: 115
    • View Profile
Re: [WIP] Custom Game Settings (FF7)
« Reply #105 on: 2011-04-28 04:45:46 »
So, no one intends to try the test builds?

Then let me lay it out plainly, this only effects some users, and whether it gets fixed or not, depends on whether or not you are cooperative and help me find the cause, it's your choice, it runs great for me. I'm trying to help you out.

Here are some possible causes. (In order of highest likelihood.)

1. You are missing some required file.

This could be my fault, it could be yours, or it could be Microsofts. (Hard to tell, until we figure out what if any required DLL's are missing.)

http://www.dependencywalker.com/

To find out if you are missing something required, download that tool, and click "File", choose "Open", and select my DLL, it will tell you if you have everything required to run my DLL installed.

This link will help you use the tool. (It's really easy.)
http://www.techerator.com/2010/05/resolve-missing-dll-errors-with-dependency-walker/

If you are missing a required file, report it, so I can track down the required library, and link the installer for others to use.

2. It's possible that something about one of libs, or my code is causing the issue, I have supplied a debug package above which will tell us where the issue might be, but, that requires you to run it, and report your results. (I left instructions above, on what needs to be done, and I need the results for all three DLL files.)

3. Some stray setting in VC++, is causing it to compile in such a way, that's incompatible with certain systems for some unknown reason. (I won't know until I rule out the other possibilities, and changing settings for no good reason, is more likely to break the project for everyone, than it is to fix it for you.)

4. If you got this far, and still can't run my project. It tells me numerous things, you have all the required files, my code isn't at fault, and the VC++ IDE isn't the issue. It's voodoo magic, or God himself smiting you, because it should be working, pure witchery, no doubt about it. ;)

But seriously, it should be one of the first three options, the test I've provided, will take no more than 10 minutes to complete.

It's up to you, these are the possible causes, I've given you the tools to help solve the issue, but I can't make you do anything.
« Last Edit: 2011-04-28 04:49:57 by Wutai Clan »

TTK_86

  • *
  • Posts: 28
    • View Profile
Re: [WIP] Custom Game Settings (FF7)
« Reply #106 on: 2011-04-28 07:28:07 »
It was the one from page 4, and i have unmodified ff7.exe

I'll try those test builds later today.

Wutai Clan

  • *
  • Posts: 115
    • View Profile
Re: [WIP] Custom Game Settings (FF7)
« Reply #107 on: 2011-04-28 07:53:03 »
It was the one from page 4, and i have unmodified ff7.exe

I'll try those test builds later today.

If the one on page 4 worked for you, then you don't have to worry about this, this is only for people that can't run the regular build. (On page 4.)

Thanks though. :)

-------

Finally got around to testing GetCharacterData, and trying to decode it's return value.

Slot 0 = 0x00DBA498
Slot 1 = 0x00DBA8D8
Slot 2 = 0x00DBAD18

These were already known values(to me anyways.), I need to figure out where to go next, and I should be able to start getting the stats, etc,.

---

Edit: I don't know, I've tried various things to get the data out of those, I've cast the data to arrays in every way I could think of, it never seems to be correct.

I used inline ASM, and accessed the values like that, and it does return data, but, it doesn't seem to relate to the info found on the wiki. (ie, I checked the indexes, using exact byte counts listed to store the values, and it was all wrong.)

NFITC1, can you shed some light on this, that is the stats, etc, correct? It should be the same as the character map on the wiki, right?
« Last Edit: 2011-04-29 09:09:35 by Wutai Clan »

dziugo

  • *
  • Posts: 1470
    • View Profile
    • A new copy of FF7 thanks to Salk. Pack (zip/rar/etc) your saved game before sending it to me.
Re: [WIP] Custom Game Settings (FF7)
« Reply #108 on: 2011-04-29 15:55:02 »
One tip - character records are 132bytes (0x84) long in the savemap - check if it's actually a savemap you're looking at (IIRC, savemap address for FF7 Save begins with 0x00DBxxxx, but don't remember the exact number). Savemap is the best place to modify data.

Wutai Clan

  • *
  • Posts: 115
    • View Profile
Re: [WIP] Custom Game Settings (FF7)
« Reply #109 on: 2011-04-29 16:37:47 »
One tip - character records are 132bytes (0x84) long in the savemap - check if it's actually a savemap you're looking at (IIRC, savemap address for FF7 Save begins with 0x00DBxxxx, but don't remember the exact number). Savemap is the best place to modify data.

Thanks. :)

I'm thinking the data isn't an array, but a bunch of loose globals, and those are the starting indexes for the character records. So, I should be able to check the next byte after each one, and get the character ID. (I think that was the first byte of character record(ID), I'll have to double check the wiki, to see what order the data is in.)

I'll check it out here in a bit, I gotta get woke up.

----

Well, the data I'm getting seems to be character data, so I was right about it being loose globals, however, the wiki has it listed in a very different order. (Which doesn't mean the wiki is wrong, it just means it gets sorted different in the save.)

Here is the order I'm finding it in..

ID (Maybe, it was a 0 with Cloud, I'll have to test it out..)
Strength
Vitality
Magic
Spirit
Dexterity
Luck
Attack
Defense
Magic Attack
Magic Defense
Current HP
Max HP
Current MP
Max MP
Unknown = 0 // Don't think they are sources used..
Unknown = 0 // SAA
Etc.. (There are several unknowns, then it get's kind of weird, perhaps equipment\materia data, etc,.)

I'll have to keep checking the values, to get the rest. (I know these are correct, I've already tried modifying them, and the stats change.)

--

I know this, this game has too many representations of the same data, I think I'm going to map them all to the same globals once I decode the game enough to do so. (Relics from the PSX version no doubt.)

What I can do, is create a C++ module, that has variable representations of all the games data, then anytime the game accesses a value, point it at my new module(and the appropriate value), that way all the data get's handled uniformly, and only by one variable. (And will always stay in synch, and be easier to work with.)
« Last Edit: 2011-04-29 18:29:12 by Wutai Clan »

nfitc1

  • *
  • Posts: 3011
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: [WIP] Custom Game Settings (FF7)
« Reply #110 on: 2011-04-29 20:06:56 »
I hope I'm able to clear some of this up because I think I know what you're talking about.

There are two sets of character data.

One is part of the save map which is always kept in memory at 0xDBFD38 and is identical in form to the savemap on the wiki.

The second is what I call Active Party Data. This is what battles use to do their manipulation of and stuff. That starts at 0xDBA498 and has three entries of 1088 bytes. My notes has it following this structure:

Char ID
Level
Attack (Str + Str Bonus)
Defense (see above)
Magic (see above)
MDef (see above)
Speed (see above)
Luck (see above)
word: Temp_Attack (Attack + weapon strength; can be halved in the battle arena)
word: Temp_Def (Like above)
word: MagicAtk ( just Magic stat )
word: MagicDef (just Spirit stat without MDef fix )
word: HP
word: MHP
word: MP
word: MMP
word: Limit (looks like limitbar value)
word: Unknown
word: Counter Attack Command
word: Counter Attack Chance
...
+0x3C: OR'd with 0x418 when recalculating stats; unknown effect
...
+0x44: Statuses that can be inflicted by attacking
...
+0x4C: Battle Command Menu. Structure of six bytes and sixteen entries
..
+0x108: Enabled Magics: eight bytes * 56 magics (magic index, MP cost, ?, ?, ?, ?, ?, ?)
+0x2C8: Might be enabled Summons: eight bytes * 16 summons.
+0x348: Some other command-related thing: eight bytes * 24 entries
+0x408: I believe this is the first 11 bytes of equipped weapon data the character is using. This will prevent the necessity of continually checking the weapon part of the KERNEL for everything. Follows weapon data from wiki. Only cares about status attack (0x40D) and accuracy (0x410)
+0x418: Status Defenses?
+0x41C: byte list of four statuses to increase ( four bytes )
+0x420: amount to increase those stats by (four bytes)
+0x424 - 0x440: unused?

That's what I have. There's lots of blanks there that I don't know. Rarely does the game point at these address individually. Most of the time it gets the head of the map, increases it by formationID * 440h, then adds the amount it wants to look for. The map's offset is loaded LOTS of times and I don't have the time to look through them all.

Wutai Clan

  • *
  • Posts: 115
    • View Profile
Re: [WIP] Custom Game Settings (FF7)
« Reply #111 on: 2011-04-29 23:04:09 »
I hope I'm able to clear some of this up because I think I know what you're talking about.

There are two sets of character data.

One is part of the save map which is always kept in memory at 0xDBFD38 and is identical in form to the savemap on the wiki.

The second is what I call Active Party Data. This is what battles use to do their manipulation of and stuff. That starts at 0xDBA498 and has three entries of 1088 bytes. My notes has it following this structure:

Char ID
Level
Attack (Str + Str Bonus)
Defense (see above)
Magic (see above)
MDef (see above)
Speed (see above)
Luck (see above)
word: Temp_Attack (Attack + weapon strength; can be halved in the battle arena)
word: Temp_Def (Like above)
word: MagicAtk ( just Magic stat )
word: MagicDef (just Spirit stat without MDef fix )
word: HP
word: MHP
word: MP
word: MMP
word: Limit (looks like limitbar value)
word: Unknown
word: Counter Attack Command
word: Counter Attack Chance
...
+0x3C: OR'd with 0x418 when recalculating stats; unknown effect
...
+0x44: Statuses that can be inflicted by attacking
...
+0x4C: Battle Command Menu. Structure of six bytes and sixteen entries
..
+0x108: Enabled Magics: eight bytes * 56 magics (magic index, MP cost, ?, ?, ?, ?, ?, ?)
+0x2C8: Might be enabled Summons: eight bytes * 16 summons.
+0x348: Some other command-related thing: eight bytes * 24 entries
+0x408: I believe this is the first 11 bytes of equipped weapon data the character is using. This will prevent the necessity of continually checking the weapon part of the KERNEL for everything. Follows weapon data from wiki. Only cares about status attack (0x40D) and accuracy (0x410)
+0x418: Status Defenses?
+0x41C: byte list of four statuses to increase ( four bytes )
+0x420: amount to increase those stats by (four bytes)
+0x424 - 0x440: unused?

That's what I have. There's lots of blanks there that I don't know. Rarely does the game point at these address individually. Most of the time it gets the head of the map, increases it by formationID * 440h, then adds the amount it wants to look for. The map's offset is loaded LOTS of times and I don't have the time to look through them all.

That's probably what I'm looking at then. :)

As far as I can tell, the game has at least three different sets of values for managing the same data.

Savemap
World\Field
Battle

These values(Active Party Data) get loaded with the battle module, but, they pass their data into local variables, ie, if you change them in world mode, it works fine(changes in stats menu), but not in battle mode. (I was trying to make mp regen work in battle mode, since I finally found the main battle loop, and quickly found changing them had no effect.)

It works kinda like this.

1. Active Party: P1 Current MP -> Stored to local.
2. Local MP manipulated.
3. Local returned to Active Party Data MP
4. Loop

You can see the Active Party MP change during battle, but changing it yourself, seems to have no effect, since the locals(take control) and overwrite it anyways.

---

Edit: Okay, I got the random battle rate patch fixed up, it no longer breaks Chocobo Lure. I should be able to get the "Sense" materia fix implemented too. (I have a new method for patching data, that can target single lines of ASM.)

----

Edit: Alright, got those patches done, now I'm working on a camera patch, it basically gives you a real nice 3rd person view in world mode. :) The game looks much better from this perspective, you can see more details, the LOD doesn't look as bad, etc,.

Edit: Man, that camera patch was a pain, it took a lot of patching to make it work, but I think it's worth it. The only issue, is that it breaks the overhead view, the camera system is way too complicated to do it properly at this time. (After I decode it a bit more, I should be able to fix it.)

I couldn't get a screenshot, it just came out black, but, it's like a whole new game, driving the vehicles, like the buggy feels much better too. It will take a bit of testing to make sure it doesn't cause any issues, like not being able to see something you could with the original view, but it should be fine. (It will be optional anyways, so you can always turn it on\off as needed.)

Edit: Here, I had to take it in windowed mode.
http://i51.tinypic.com/kcl3yu.png
« Last Edit: 2011-05-01 03:38:28 by Wutai Clan »

Wutai Clan

  • *
  • Posts: 115
    • View Profile
Re: [WIP] Custom Game Settings (FF7)
« Reply #112 on: 2011-05-01 20:24:46 »
Did any of the Q-Gears folks write their info down?

They decoded a lot of the same stuff I'm working on to figure out the opcodes for that project, which means they knew were the functions were located in the disassembled code.

I can find this stuff again, but it's going to take forever, and it's already been done, and should be well documented, so are there any post that I've overlooked, or sources of info? (I'll keep searching the forums, but the more time I waste on stuff like this, and doing work that's already been done, the less new features I can get coded. I've decoded maybe 30 functions, out of hundreds, probably close to thousands.)

Btw, did anyone see my last post, I hacked the world view camera, there is a screenshot. I thought it was pretty cool, no one else?

obesebear

  • *
  • Posts: 1389
    • View Profile
Re: [WIP] Custom Game Settings (FF7)
« Reply #113 on: 2011-05-01 20:43:22 »
I think Kranmer recently did something similar to the world map camera.  But if my memory serves me correctly he was only able to adjust the level of zoom.  Is that what you can do, or can you actually move yours around?

Also, this seems obvious, but check the QGears forum for information.

Wutai Clan

  • *
  • Posts: 115
    • View Profile
Re: [WIP] Custom Game Settings (FF7)
« Reply #114 on: 2011-05-01 20:47:48 »
I think Kranmer recently did something similar to the world map camera.  But if my memory serves me correctly he was only able to adjust the level of zoom.  Is that what you can do, or can you actually move yours around?

Also, this seems obvious, but check the QGears forum for information.

I can adjust it however I want, zoom\angle\etc. /snip

---

Edit: Decoding is going to be slow now that I've got most the easy stuff located. I've got a few tricks up my sleeve thanks to MHS, but, I expect the next few days to yield little in the way of results, going to be spending most of my time decoding, trying to find some of the more elusive stuff.

I've been trying to nail down a general flow for a number of systems. For example, I found\decoded part of the damage formulas.

From what I can see so far, it works something like this.. (Rough draft formula. This was a monster attacking me, btw,.)

Base Attack = 12 // Monster base damage?
Attack Multiplier(?) = 25 // Weapon? Stat? (Not sure where this value came from.)
Damage = 300

// Not sure how it calculated this part, but the value 240 is correct.
Damage / Defense Factor = 240 // Final Damage

I found the rest(or a lot of it.), but I haven't decoded it at all yet. (The above can be modified by several factors\functions, so it may be a real pain to fully decode. There were about ten functions called, and no telling how many branching functions could be called based on different factors, etc,. Special materia factors, equipment bonuses, etc,. ?)
« Last Edit: 2011-05-02 10:22:27 by Wutai Clan »

Aali

  • *
  • Posts: 1196
    • View Profile
Re: [WIP] Custom Game Settings (FF7)
« Reply #115 on: 2011-05-02 10:22:42 »
Akaris work and most (if not all) of Q-Gears is based on the PSX version.

The call table for field script opcodes is at 0x9055A0.

Wutai Clan

  • *
  • Posts: 115
    • View Profile
Re: [WIP] Custom Game Settings (FF7)
« Reply #116 on: 2011-05-02 10:40:31 »
Akaris work and most (if not all) of Q-Gears is based on the PSX version.

The call table for field script opcodes is at 0x9055A0.

I found that, but honestly, don't know what to do with it?

Any tips?

(My guess, is that it's a structure, based on how it looked, but that's about all I know about it so far. Too tired to think about it, I'm going to bed, I'll mess with it some more after I get some sleep.)
« Last Edit: 2011-05-02 11:06:02 by Wutai Clan »

nfitc1

  • *
  • Posts: 3011
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: [WIP] Custom Game Settings (FF7)
« Reply #117 on: 2011-05-02 12:17:11 »
That's probably what I'm looking at then. :)

As far as I can tell, the game has at least three different sets of values for managing the same data.

Savemap
World\Field
Battle

Where's that located? I've been looking for that for a while now.

Wutai Clan

  • *
  • Posts: 115
    • View Profile
Re: [WIP] Custom Game Settings (FF7)
« Reply #118 on: 2011-05-02 19:12:13 »
Where's that located? I've been looking for that for a while now.

Starts here. [0x00DBA498] - (Returned by GetCharacterData[0])

That's just an index(structure), the next byte is ID, followed by Level, etc, but it doesn't follow the savemap exactly.

nfitc1

  • *
  • Posts: 3011
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: [WIP] Custom Game Settings (FF7)
« Reply #119 on: 2011-05-02 20:02:46 »
Starts here. [0x00DBA498] - (Returned by GetCharacterData[0])

That's just an index(structure), the next byte is ID, followed by Level, etc, but it doesn't follow the savemap exactly.

...That was the battle structure I was just telling you about. What, then, do you have as the Battle stat location?

Wutai Clan

  • *
  • Posts: 115
    • View Profile
Re: [WIP] Custom Game Settings (FF7)
« Reply #120 on: 2011-05-02 20:23:07 »
...That was the battle structure I was just telling you about. What, then, do you have as the Battle stat location?

The values you said were the active party, seems to do just that(world\field), the other characters don't seem to be calculated except for in the savemap. For battle, it passes the active party data into local variables. (Within the battle loop functions)

Though, I haven't fully decoded it, there could be more going on, or I could be misreading what's happening.

I just figured out how to find the opcodes, you basically, take an opcode.

MPu\IncreaseMP = 0x45
Opcode Structure = 0x009055A0

(0x45 x 4) + 0x009055A0 = 0x009056B4 [MPu\IncreaseMP]

That's the position in the OPCODE structure, the function is actually located here. [0x0061F801]

Btw, that function isn't directly usable, it uses local variables, and calls IncreaseMP[0x006CBBBF]..
« Last Edit: 2011-05-02 20:36:30 by Wutai Clan »

dziugo

  • *
  • Posts: 1470
    • View Profile
    • A new copy of FF7 thanks to Salk. Pack (zip/rar/etc) your saved game before sending it to me.
Re: [WIP] Custom Game Settings (FF7)
« Reply #121 on: 2011-05-02 20:52:59 »
I just figured out how to find the opcodes, you basically, take an opcode.

MPu\IncreaseMP = 0x45
Opcode Structure = 0x009055A0

(0x45 x 4) + 0x009055A0 = 0x009056B4 [MPu\IncreaseMP]

(...)

That 0x9055A0 (argh... address that's been burned into my memory...) is a base for all Script Op handlers. When a game gets an Opcode, it calculates the offset where a pointer to that function is stored (in a fashion: 0x9055A0 + Opcode << 2), and just calls it.
2 pages back. You're saying that you don't want to discover things on your own if it's already decoded, and asking for people to step in and share, and then you just do it on your own anyway? Why bother asking...

Wutai Clan

  • *
  • Posts: 115
    • View Profile
Re: [WIP] Custom Game Settings (FF7)
« Reply #122 on: 2011-05-02 21:31:56 »
2 pages back. You're saying that you don't want to discover things on your own if it's already decoded, and asking for people to step in and share, and then you just do it on your own anyway? Why bother asking...

When did I say that?

I asked for help in my very first post, and I accepted help, and integrated values NFITC1 told me about. But I also said I would decode what I have to.

I will discover things on my own if I have to, but I'd rather not do work, that's already been done.

As for why I would go ahead and do it on my own, that's because I'm working on a project, I want to accomplish my goals, not sit around and wait for answers that might come.

Your answer was wrong, maybe shift left 2 equals 4, but why tell me answers in a format the game doesn't use? The game explicitly says eax * 4, not << 2... That's why I didn't use your info, it didn't match up with anything I was seeing. (And since we're bringing up 2 pages ago, you KNEW I had trouble understanding bit shifts, so why intentionally change a simple multiplication formula to use a bit shift?)

So try being less fancy, and being more correct, and someone might trust\use your data.

---

How hard is this.

Formula:
OPCODEBASE + (OPCODE * 4) = OPCODE LOCATION

Example:
0x009055A0 + (0x45 * 4) = 0x009056B4

Using fancy formulas doesn't make you look smarter, and it only serves to confuse people.

I understood the bit shift with AddItems, because the game uses that formula, I could see it, and knew what you were talking about. (ie, It didn't require me to go out and learn binary to decode your answer. Decoding the game is enough work, I don't need\want to decode your answers as well, so I ignore anything you say that doesn't match up with the actual code.)
« Last Edit: 2011-05-02 22:10:01 by Wutai Clan »

dziugo

  • *
  • Posts: 1470
    • View Profile
    • A new copy of FF7 thanks to Salk. Pack (zip/rar/etc) your saved game before sending it to me.
Re: [WIP] Custom Game Settings (FF7)
« Reply #123 on: 2011-05-02 22:09:29 »
Ok, so from the top:
When did I say that?
Here.

I asked for help in my very first post, and I accepted help, and integrated values NFITC1 told me about. But I also said I would decode what I have to.

I will discover things on my own if I have to, but I'd rather not do work, that's already been done.

As for why I would go ahead and do it on my own, that's because I'm working on a project, I want to accomplish my goals, not sit around and wait for answers that might come.
Nothing wrong with doing things on your own. That's for sure.

Your answer was wrong (...)
No it wasn't.

(...) maybe shift right 2 equals 4
... shift left, but yes, it does equal *4. Of course it does.

(...) but why tell me answers in a format the game doesn't use?
FF7 (for PC) was written in C++, and "<<" is a C/C++ operator explicitly convertable to SAL/SHL, also...

The game explicitly says eax * 4, not << 2...
No it doesn't. That's what your debugger/disassembler shows to you. The machine code actually says 0x9055A0 + EAX SHL 2. That's how the CPU will compute it.

That's why I didn't use your info, it didn't match up with anything I was seeing. (And since we're bringing up 2 pages ago, you KNEW I had trouble understanding bit shifts, so intentionally change a simple multiplication formula to use a bit shift?)
YES. That's exactly what I did - I intentionally used a bit shift operator. But if I didn't - you'd still get an answer with an array of function pointers.

So try being less fancy, and being more correct, and someone might trust your data.
I stand correct. And << is actually pretty important operator.

I'm not your enemy, just wanted to make sure that you understood the shifting thing. In the source code, it looked something like this:
Code: [Select]
...
fieldOpcodesPointer[scriptOpcode](args)
...
Still, no *4 in here - that's because compiler is smart enough to know that a function pointer in a 32bit app is 32bit long, so the whole array has a 4-byte alignment. Multiplications are actually pretty slow - in oppose to bit-shifts. That's also a reason why you'd see some unreferenced 1-byte field between other, larger structs  - the alignment is important and the game speeds up when the addresses are 4-byte divisable and the CPU can do just "address + eax << 2".

//---

I understood the bit shift with AddItems, because the game uses that formula, I could see it, and knew what you were talking about. (ie, It didn't require me to go out and learn binary to decode your answer. Decoding the game is enough work, I don't need\want to decode your answers as well, so I ignore anything you say that doesn't match up with the actual code.)
That's why I hate .NET/Java. It spoils people.
« Last Edit: 2011-05-02 22:16:19 by dziugo »

Wutai Clan

  • *
  • Posts: 115
    • View Profile
Re: [WIP] Custom Game Settings (FF7)
« Reply #124 on: 2011-05-02 22:14:46 »
That's what your debugger showed you.

It looks like this in my debugger..

Call Near DWORD PTR [EAX*4+9055A0]

Your debugger sucks, it's a structure, this is how structures are used in ASM.

--

I'm not spoiled, bit shifts are ASM math optimizations, even most C++ users never use them directly, it has nothing to do with C#.
« Last Edit: 2011-05-02 22:56:12 by Wutai Clan »