Author Topic: Unused/useless variables safe to use in savemap? (PSX)  (Read 27257 times)

Roden

  • *
  • Posts: 125
    • View Profile
Quite new to FF7 modding (well, just yesterday actually lol) - I'm aware of pages such as http://wiki.qhimm.com/view/FF7/Savemap and some other variable analysis: http://finalfantasy.wikia.com/wiki/User:JBed/FFVII/Variables#Variable_analysis

And was wondering if there was a general consensus on some unused variables I can safely use in my mod (and get saved)? The first link doesn't seem to have too many unknowns which is worrying! I don't need too many, but hey, the more the merrier.. I already used some at random, and I guess I can change it later while testing..

I see a lot of data like this: z_16[36] (Field Objects, Sector 7 Train Graveyard):
0x01: Train 1 Position.(mds7st2)
0x02: Train 2 Position.(mds7st2)
0x04: Train 3 Position.(mds7st2)
0x08:
0x10:
0x20:
0x40:
0x80:
Does that mean I can use 0x08, 0x10 etc for anything I want? I guess for example BIT ON/OFF function in Makou Reactor? Or am I on completely wrong track here? :P

And is there a way to quickly see what variable an offset in the wiki is referring to in a program like Makou Reactor - I see for example (0x0BA8)    1 byte  (Tifa's current love points) is listed as variable 1:4 in the program. And in the wiki its in the fourth row, but whats the formula in regards to 0x0BA8? Or do I manually go to that area and look at the scripts?

Thanks! :)

sithlord48

  • *
  • Posts: 1632
  • Dark Lord of the Savegame
    • View Profile
    • Blackchocobo
Re: Unused/useless variables safe to use in savemap? (PSX)
« Reply #1 on: 2014-10-23 12:52:43 »
just because its not shown on the save map does not mean its unused. there are some spots that we know are unused but you have to check the documensts. becareful if you set some things the game may crash at some points or one very specific one. you can use the unused var under the test tab in black chocobo to compair slots to see what changes when testing to make it a bit easier to spot.

please see: http://blackchocobo.sourceforge.net/wiki/index.php?title=Savemap

for a more updated savemap. (i have not updated the qhimm one in abit)

and https://drive.google.com/file/d/0BxqH9L8_QubjV0EwTnJmbGlKdmc
for some of my notes that are not on the savemap . i have other notes that finish off all the used field vars for items (most of the notes focus on items not progression)

as for the offsets they are not as stright foward as you might think 1/2 are the same address one bank is used for 8bit access the other for 16bit access. (all the field used banks have this dualility) some blocks addressed by the field are not saved.

you can also view the fielditemlist from ff7tk for all offsets and bits

https://github.com/sithlord48/ff7tk/blob/master/data/FF7FieldItemList.h

you should also look at FF7Save struct
  https://github.com/sithlord48/ff7tk/blob/master/data/FF7Save_Types.h

there might also be some more hints located in FF7Save.cpp as well since some of the "unused" data (z_#) is accessed outside the struct.

Roden

  • *
  • Posts: 125
    • View Profile
Re: Unused/useless variables safe to use in savemap? (PSX)
« Reply #2 on: 2014-10-23 16:33:40 »
just because its not shown on the save map does not mean its unused. there are some spots that we know are unused but you have to check the documensts. becareful if you set some things the game may crash at some points or one very specific one. you can use the unused var under the test tab in black chocobo to compair slots to see what changes when testing to make it a bit easier to spot.

please see: http://blackchocobo.sourceforge.net/wiki/index.php?title=Savemap

for a more updated savemap. (i have not updated the qhimm one in abit)

and https://drive.google.com/file/d/0BxqH9L8_QubjV0EwTnJmbGlKdmc
for some of my notes that are not on the savemap . i have other notes that finish off all the used field vars for items (most of the notes focus on items not progression)

as for the offsets they are not as stright foward as you might think 1/2 are the same address one bank is used for 8bit access the other for 16bit access. (all the field used banks have this dualility) some blocks addressed by the field are not saved.

you can also view the fielditemlist from ff7tk for all offsets and bits

https://github.com/sithlord48/ff7tk/blob/master/data/FF7FieldItemList.h

you should also look at FF7Save struct
  https://github.com/sithlord48/ff7tk/blob/master/data/FF7Save_Types.h

there might also be some more hints located in FF7Save.cpp as well since some of the "unused" data (z_#) is accessed outside the struct.
Great, thank you! So looking at your notes, if I delete those two potions from the dead guards at the start (md1stin), I can use those values for my own purposes?

But how did you know Var[15][32] correlates to Z_38[44]:0? Whats the difference between Var and Z values, and how do you work it out? I looked at this specific slot in the Black Chocbo test data and saw: 0F 15 00001111 - that means the save already has the two potions and some more stuff in reactor (but not the poison materia you mentioned later).

So earlier you said "as for the offsets they are not as stright foward as you might think 1/2 are the same address one bank is used for 8bit access the other for 16bit access. (all the field used banks have this dualility) some blocks addressed by the field are not saved." so what does that mean exactly for the above? How does that affect me if I just want to delete those two potions and use that value elsewhere?

Thanks for the Black Chocobo link, that's a great program. I looked in the test data and understand how it works with the memory slots, but I'm not sure how to use those unknown vars in Makou Reactor yet as I don't know which variables it points to (or is it something we all have to work out)?

Sorry for the questions, I'm very new here and just trying to understand :)

sithlord48

  • *
  • Posts: 1632
  • Dark Lord of the Savegame
    • View Profile
    • Blackchocobo
Re: Unused/useless variables safe to use in savemap? (PSX)
« Reply #3 on: 2014-10-23 16:50:51 »
when i get a chance i will write you a correct responce to that above message.

Roden

  • *
  • Posts: 125
    • View Profile
Re: Unused/useless variables safe to use in savemap? (PSX)
« Reply #4 on: 2014-10-23 21:02:12 »
when i get a chance i will write you a correct responce to that above message.
Thanks, man. Really appreciate it!

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: Unused/useless variables safe to use in savemap? (PSX)
« Reply #5 on: 2014-10-23 21:35:30 »
http://wiki.qhimm.com/view/FF7/Savemap

I'll also send you a list of bytes that Aali sent me detailing what the world map uses.  Battles can only affect bank 1 (field 1/2). Field can be seen with Makou.
Remember that Field vars:

1/2 are Bank 1
3/4 are Bank 2
5/6 are temporary vars in game and not saved.  They reset to 0 every time you enter new field.
8/9 & A cannot be written to. 
B/C is Bank 3
D/E is Bank 4
7/F is Bank 5

Field vars 1,3,5,7,B,D are for one-byte writes
Field vars  2,4,6,C,E,F are for two-byte writes

Remember that 1/2, 3/4, 5/6, B/C, D/E and 7/F share the SAME 256 bytes.
So if you write to var [1][10] you are ALSO writing to [2][10].
And if you write two bytes to [2][10] you are ALSO writing to [1][10] and [1][11]

From my own tests, Field B/C (Bank 3) is the safest bet.  I am using [B/C][243] through to [B/C][255]
For my Soldier mod.  So if you want your mod to remain compatible with mine, avoid those and
start at [B/C][242]  I am pretty sure a lot of those bytes down are unused. 

edit.

Oh... PSX again.  I keep assuming PC.  Well, you are free to use B/C[255] down really.  Can't see my Soldier mod being used in PSX game, though you never know.
« Last Edit: 2014-10-23 21:45:18 by DLPB »

Roden

  • *
  • Posts: 125
    • View Profile
Re: Unused/useless variables safe to use in savemap? (PSX)
« Reply #6 on: 2014-10-23 22:04:21 »
http://wiki.qhimm.com/view/FF7/Savemap

I'll also send you a list of bytes that Aali sent me detailing what the world map uses.  Battles can only affect bank 1 (field 1/2). Field can be seen with Makou.
Remember that Field vars:

1/2 are Bank 1
3/4 are Bank 2
5/6 are temporary vars in game and not saved.  They reset to 0 every time you enter new field.
8/9 & A cannot be written to. 
B/C is Bank 3
D/E is Bank 4
7/F is Bank 5

Field vars 1,3,5,7,B,D are for one-byte writes
Field vars  2,4,6,C,E,F are for two-byte writes

Remember that 1/2, 3/4, 5/6, B/C, D/E and 7/F share the SAME 256 bytes.
So if you write to var [1][10] you are ALSO writing to [2][10].
And if you write two bytes to [2][10] you are ALSO writing to [1][10] and [1][11]

From my own tests, Field B/C (Bank 3) is the safest bet.  I am using [B/C][243] through to [B/C][255]
For my Soldier mod.  So if you want your mod to remain compatible with mine, avoid those and
start at [B/C][242]  I am pretty sure a lot of those bytes down are unused. 

edit.

Oh... PSX again.  I keep assuming PC.  Well, you are free to use B/C[255] down really.  Can't see my Soldier mod being used in PSX game, though you never know.
Thanks for the great reply, DLPB. That makes a lot of sense - I was looking for that "safebet" list! Does B/C refer to VAR{11}{255}/VAR{12}{255} in Makou?

Only thing I don't quite get (because I don't usually work at this level) is the whole writing one-byte/two-bytes thing? Why would I need one or the other?  For example in the first very field map in the initialization is:
Var[6][9] = 12 (16-bit)

Why not Var[5][9] = 12 (8-bit)?
Or Var[6][9] = 12 (8-bit)

Though actually I have no idea what that is trying to set. Most of the things I would be adding is simple "switches" (such as the BITON/OFFs I find in the code?)

Also I removed those potions from the start of the game, is OK to use those bits for my own purposes now?

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: Unused/useless variables safe to use in savemap? (PSX)
« Reply #7 on: 2014-10-23 22:12:22 »
Yes, B is 11 decimal, and C is 12 decimal.

The writing issue is weird one, and Aali / NFITC1 explained it to me a while back but I forgot.
All you need to concern yourself with is that when writing a 16 bit (2 byte) value, you MUST use C (12) and if using one byte, you can use B or C (I think).  Though I'd just use B for one byte, and C for two. 

B/C is same bank, so keep track of it.  I requested to Mystere that he start marking bytes used across fields... so that when you use [11][1], [12][1] is also marked as used.  As it should be.  Or some sort of byte used tracker.
« Last Edit: 2014-10-23 22:16:30 by DLPB »

vayneruel

  • *
  • Posts: 161
    • View Profile
Re: Unused/useless variables safe to use in savemap? (PSX)
« Reply #8 on: 2014-10-23 22:21:48 »
one bytes and two bytes is 8 bytes and 16 bytes. This use for the size of the code, for example if you write If Var[3][133] bitON 6 (else go to label 1) in 8-bit
and you write a lot of code before the label, Makou says a error like this (Label 1 is unreacheable), if you change to 16-bit you can go to label 1.
If you want a free var to use, you can use 14-22, 14-23, 14-24, 14-25 with bit on to 8 ( bit on 0, bit on 1....)
I hope i´ve been hepful, sorry for my horrible english.

Roden

  • *
  • Posts: 125
    • View Profile
Re: Unused/useless variables safe to use in savemap? (PSX)
« Reply #9 on: 2014-10-23 22:26:26 »
Thanks guys, I understand it a hell of a lot better now :)

DLPB: What's this SOLDIER mod your working on?

Vayneruel, your example for the labels (8-bit/16-bits jumps) is just to do with the field map scripting and nothing to do with variables, right? I already changed a few to long jumps. Hope that didnt screw anything up! :)

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: Unused/useless variables safe to use in savemap? (PSX)
« Reply #10 on: 2014-10-23 22:36:51 »
Yeah, what he said had nothing to do with this.

Also, see Reunion thread for Soldier mod explanation.

Sega Chief

  • *
  • Posts: 4086
  • These guys is sick
    • View Profile
Re: Unused/useless variables safe to use in savemap? (PSX)
« Reply #11 on: 2014-10-23 22:46:05 »
Well, this is all very worrying info about banks sharing bytes; I've been using whatever banks are marked as empty on Makou but:

B/C is same bank, so keep track of it.  I requested to Mystere that he start marking bytes used across fields... so that when you use [11][1], [12][1] is also marked as used.  As it should be.  Or some sort of byte used tracker.

That's got me sweating so I'm going to check all the variables I've used but could someone confirm if this is correct:

For Bank 2 (3/4) I've used [3][107] for something in the mod but [4][106] is also marked as used (unaltered), which is for writing 2-bytes and would write to [3][107] when triggered?

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: Unused/useless variables safe to use in savemap? (PSX)
« Reply #12 on: 2014-10-23 22:54:14 »
Quote
For Bank 2 (3/4) I've used [3][107] for something in the mod but [4][106] is also marked as used (unaltered), which is for writing 2-bytes and would write to [3][107] when triggered?

You cannot write a 2 byte value to var [3].  Only [4] would allow a 2 byte write.  [3][107] Conflicts with [4][107].

And [4][106] conflicts with [3][106] and [3][107].
And [4][107] conflicts with [3][107] and [3][108].

Remember also, BANKS do not share bytes.  The VARS that the FIELD script uses shares the bank bytes.  There are only FIVE savable banks (and six usable, one is a temp).

Makou will not alert you to this conflict as it scans only for the vars used, and not the actual bytes used.
« Last Edit: 2014-10-23 22:59:14 by DLPB »

Roden

  • *
  • Posts: 125
    • View Profile
Re: Unused/useless variables safe to use in savemap? (PSX)
« Reply #13 on: 2014-10-23 22:56:34 »
Ah, I see 1/35 Soldier? Haha, in the days of old it was said you could rebuild Sephiroth with 99 of those and a masamune!

vayneruel

  • *
  • Posts: 161
    • View Profile
Re: Unused/useless variables safe to use in savemap? (PSX)
« Reply #14 on: 2014-10-23 22:59:08 »
Yes the 8 and 16-bit its for field map, but you must pay attetion what you change to not create conflicts in code

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: Unused/useless variables safe to use in savemap? (PSX)
« Reply #15 on: 2014-10-23 23:01:34 »
Sega Chief , also Makou can only show you what vars are being used in field. 

Bank 1 (Field 1/2) is used for savable things in battle (i.e., battle script sometimes writes to Bank 1).
Avoid Bank 1 like the plague.

And world map writes to some other banks also.  For all I know, more things write to the banks.  So using Makou to decide a bit is free can be catastrophic.
« Last Edit: 2014-10-23 23:05:32 by DLPB »

Sega Chief

  • *
  • Posts: 4086
  • These guys is sick
    • View Profile
Re: Unused/useless variables safe to use in savemap? (PSX)
« Reply #16 on: 2014-10-23 23:36:26 »
Cheers for the info, Dan; that would have been a nasty time bomb to sort out later on as more variables got used ('re-used', I should say). I'd better consult that savemap link you posted when picking variables from now on.

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: Unused/useless variables safe to use in savemap? (PSX)
« Reply #17 on: 2014-10-23 23:45:42 »
And remember it isn't complete...  These are the ones world map writes to (for a start):

Code: [Select]

BANK 1
0x0000: word
0x0054: byte
0x0055: byte
0x0056: byte
0x0057: byte
0x0058: byte
0x007a: bit 0
0x007a: bit 1
0x007a: bit 2
0x007a: bit 3
0x007b: bit 0
0x007b: bit 2
0x007b: bit 3
0x007c: byte
0x007d: bit 0
0x007e: bit 0
0x007e: bit 1
0x007e: bit 2
0x007e: bit 3
0x007e: bit 4
0x007e: bit 5
0x007e: bit 6
0x007f: bit 0
0x007f: bit 1
0x007f: bit 2
0x007f: bit 3
0x007f: bit 4
0x007f: bit 5

BANK 2
0x01cf: bit 0
0x01cf: bit 1
0x01cf: bit 2
0x01cf: bit 3
0x01cf: bit 4
0x01cf: bit 5
0x01cf: bit 6
0x01cf: bit 7

BANK 4
0x0350: bit 3
0x0351: byte
0x0352: bit 2
0x0352: bit 3
0x0380: byte
0x0381: byte
0x0382: byte
0x0383: byte
0x0384: bit 0
0x0384: bit 1
0x0384: bit 2
0x0384: bit 3
0x0384: bit 4
0x0384: bit 5
0x0384: bit 6
0x0384: bit 7
0x0385: bit 0
0x0385: bit 1
0x0385: bit 3
0x0385: bit 4
0x0385: bit 5
0x0385: bit 6
0x0385: bit 7
0x0386: bit 0
0x0386: bit 1
0x0386: bit 2
0x0386: bit 3
0x0386: bit 4
0x0386: bit 5
0x0386: bit 6
0x0386: bit 7
0x0387: bit 0
0x0387: bit 1
0x0387: bit 2
0x0387: bit 3
0x0387: bit 4
0x0387: bit 5
0x0388: word
0x038a: word
0x038c: byte
0x038d: byte
0x038e: byte
0x038f: byte
0x0390: word
0x0392: word
0x0394: byte
0x0396: byte

BANK 5
0x0491: bit 2


Note 0000 is Bank 1 (Field 1/2) Byte 0. 

And as it is a Word value, it is 2 bytes.  Note this is the game progress value (Var [2][0])

The bytes are offset from 0.
0 being Var [1][0] or Var [2][0] or Bank 1, byte 0.

Banks run consecutively in memory 1 through 5.

So byte 256 (100h) is in fact, Var [3][0] or Var [4][0] or Bank 2, Byte 0

Thus, it's easy to note

Code: [Select]
Bank 1 [1/2]: Starts 0x0000
Bank 2 [3/4]: Starts 0x0100
Bank 3 [11/12]: Starts 0x0200
Bank 4 [13/14]: Starts 0x0300
Bank 5 [7/15]: Starts 0x0400



« Last Edit: 2014-10-23 23:52:07 by DLPB »

Sega Chief

  • *
  • Posts: 4086
  • These guys is sick
    • View Profile
Re: Unused/useless variables safe to use in savemap? (PSX)
« Reply #18 on: 2014-10-24 00:01:20 »
Got it, I've added this to my notes. What might be handy is if we label the variables in Makou and produce a more complete vars.cfg file that can be distributed with the tool itself (sort of like how Game Moment/PPV is labeled but with more of them identified, particularly the ones not marked as used). I'm going to make one for my own use, but would that be worth distributing (assuming it was all correct)?

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: Unused/useless variables safe to use in savemap? (PSX)
« Reply #19 on: 2014-10-24 00:07:21 »
I think we need a comprehensive byte checker somewhere on Qhimms to let everyone know how the game works, and which bytes are used.  Aali has produced the above comprehensive World Map list.  NFITC1 could no doubt easily produce the Bank 1 writes that battle makes.  Field changes are easy to spot using Makou.

I am not sure if anything else writes to the banks.  Minigames do, but they should be easy to spot with Makou also.

The byte check list should probably also note which modders are using what.  I will be using 99 bits starting [11/12][255] (Bank 3, byte 255) (as said above) for Soldier mod.  So at least we could know what conflicts we will be having with others also.

In fact, maybe this thread needs stickying somewhere under "Read this before attempting to edit field script vars"  or something.
« Last Edit: 2014-10-24 00:12:52 by DLPB »

Sega Chief

  • *
  • Posts: 4086
  • These guys is sick
    • View Profile
Re: Unused/useless variables safe to use in savemap? (PSX)
« Reply #20 on: 2014-10-24 00:19:58 »
That'd be useful, would be able to coordinate with other mods better and see what's 'safe' too. Would it be like a spreadsheet or something?

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: Unused/useless variables safe to use in savemap? (PSX)
« Reply #21 on: 2014-10-24 00:26:21 »
I'll sort something.  A lot of people have started mods without fully realizing the implications of the shared bytes.  The Nightmare mod I think escaped an issue through pure luck.

Roden

  • *
  • Posts: 125
    • View Profile
Re: Unused/useless variables safe to use in savemap? (PSX)
« Reply #22 on: 2014-10-24 02:30:53 »
In fact, maybe this thread needs stickying somewhere under "Read this before attempting to edit field script vars"  or something.
Good idea, but may I suggest a more simpler title? Rename the thread to something like "variables safe to use in your savemap, read before editing" or something. I tried searching google but couldn't find anything so I made this thread. :)

sithlord48

  • *
  • Posts: 1632
  • Dark Lord of the Savegame
    • View Profile
    • Blackchocobo
Re: Unused/useless variables safe to use in savemap? (PSX)
« Reply #23 on: 2014-10-24 15:55:58 »
@ Roden what DLPB said!

@DLBP thanks for answering that when i was unable to get it done :D

Roden

  • *
  • Posts: 125
    • View Profile
Re: Unused/useless variables safe to use in savemap? (PSX)
« Reply #24 on: 2014-10-25 19:29:04 »
5/6 are temporary vars in game and not saved.  They reset to 0 every time you enter new field.
Actually this one seems very handy for certain rooms - do you know which ones are unused (or if someone has documented it?)? It seems a better alternative than trying to set a variable from other banks to 0 whenever you exit a room :P