Users browsing this thread: 1 Guest(s)
Battlescript variables...

#51
Posts: 1,633
Threads: 56
Thanks Received: 13
Thanks Given: 84
Joined: Apr 2014
Reputation: 12
Status
Atma
Quote:You probably mean "in the SNES memory", not "in the ROM file" right?
I can't say to know how exactly SNES handles stuff, clearly the ram is not inside the rom, but now i understood that ram variables are in 7E0000 area of the rom, anyway...


Quote:You could probably get away with using VAR004 - Brave New World used it for a few fights up until 1.7, and we never had any problems. That said, Four global variables plus one local variable should be plenty for anything you want to do. If you find you need more, try simplifying your logic.
What i'm actually using the other variables for is something completely different, using them for enemy AI is the most trivial use...

Too bad anyway, var 36 is bounded to slots, so i lost the chance to use them for something way more useful Sad


THE GREATEST CHALLENGE OF ALL TIMES AWAITS:
http://www.ff6hacking.com/forums/showthr...p?tid=2593
DO YOU HAVE WHAT IT TAKES TO SLAY A GOD?
------------------------------------------------------------------------
Tenkarider's project #2 is started: FF6 Curse of the Madsiur Joke (CotMJ)
http://www.ff6hacking.com/forums/showthr...p?tid=2755
What happens when Madsiur tweaks your account? This full game hack will show that!
  Find
Quote  

#52
Posts: 3,969
Threads: 279
Thanks Received: 236
Thanks Given: 57
Joined: Oct 2011
Reputation: 65
Status
Tissue-aware
(12-26-2015, 12:22 PM)Tenkarider Wrote: I can't say to know how exactly SNES handles stuff, clearly the ram is not inside the rom, but now i understood that ram variables are in 7E0000 area of the rom, anyway...

You're using the wrong terminology. The SNES has a 128kb WRAM (banks $7E and $7F). It's not because the WRAM has a bank mapping that it is "in the ROM". If fact, the ROM image is limited to banks $C0-$FF and 40$-6F (and their shadows).

SNES memory has offsets too!

See: http://www.emulatronia.com/doctec/consol...NESMem.txt

and last post here: http://stackoverflow.com/questions/18970...-addresses

Edit: I knew some of this already but I had to google this to be able to understand it fully also... There's no shame!

Edit2: One thing I'm not sure is when to specify or not the bank when writing to memory. Writing to $1132 (ex: STA $1132) will be equal to writing to $7E1132 (STA $7E1132) but in the game both formulations are used so the register (DB register?) holding the bank number must be set somewhere prior to one/multiple RAM writing.
  Find
Quote  

#53
Posts: 200
Threads: 1
Thanks Received: 10
Thanks Given: 0
Joined: Oct 2015
Reputation: 18
Status
None
Quote  
[-] The following 2 users say Thank You to assassin for this post:
  • Gi Nattak (12-26-2015), ReturnerScum (01-25-2016)

#54
Posts: 1,633
Threads: 56
Thanks Received: 13
Thanks Given: 84
Joined: Apr 2014
Reputation: 12
Status
Atma
@Everything: I'd PM this post if it was another thing, but since it involves battle variables it might be a good idea to leave here a better explaination on this argument...
So, i was scrolling battle RAM map until i reached this area:

Code:
---------------------------------
    $3EB0-$3ED3 Global Battle Variables
---------------------------------
          $3EB0 Local Battle Variable 1
          $3EB1 Local Battle Variable 2
          $3EB2 Local Battle Variable 3
          $3EB3 Local Battle Variable 4
          $3EB4 - (same as $1DC9)
          $3EB5 - (same as $1DCA)
          $3EB6 - (same as $1DCB)
          $3EB7 - (same as $1DCC)
          $3EB8 - (same as $1DCD)
         +$3EB9 abcdefgh Conditional Battle Flags (same as +$1DCE)
                a: if set, program compares current battle index with
                   battle index at CF3780,X. if equal, battle index
                   is changed to battle index at CF3782,X. (used with GtBehemoth/SrBehemoth, M-TekArmor)
                b-h: same as a
          $3EBB -----mtf (same as $1DD0)
                m: permanent morph (for Phunbaba battle)
                t: morph lasts twice as long (set after Phunbaba battle)
                f: magic only (fanatic's tower)
          $3EBC ztrbemsg (same as $1DD1)
                z: zone eater just ate you
                t: timers are shown in menu and battle
                r: ran out of time (before emperor's banquet)
                b: ran away from battle (before emperor's banquet)
                e: espers have been acquired
                m: morph is available
                s: enables scene with LOCKE and EDGAR if TERRA uses magic (battle event 6)
                g: game over after battle ends
          $3EBD --ums-gd (same as $1DD2)
                u: LOCKE is wearing soldier uniform
                m: LOCKE is wearing merchant clothes
                s: SHADOW won't leave after battle
                g: GAU has been obtained
                d: Doom Gaze has been defeated
         +$3EBE Doom Gaze's HP (same as +$1DD3)
          $3EC0 Battles fought with the Cursed Shield (same as $1DD5)
          $3EC1 - (same as $1DD6)
          $3EC2 - (same as $1DD7)
          $3EC3 - (same as $1DD8)
          $3EC4 - (same as $1DD9)
          $3EC5 - (same as $1DDA)
          $3EC6 - (same as $1DDB)
          $3EC7 - (same as $1DDC)
          $3EC8 Elements Nullified by Forcefield
          $3EC9 number of targets
          $3ECA Number of different types of monsters in combat (alive)
    $3ECB-$3ED3 unused local battle variables
---------------------------------
         +$3ED4 Battle index
 

I'm pretty sure you did an excellent job with RAM map new details posted in our wiki, so i'll assume that it's all correct and even updated info
there's some extra or even different info, compared to previous information available in the site, so i'd like you answer some question to 
explain better the differences and new info:

1)
Code:
 +$3EB9 abcdefgh Conditional Battle Flags (same as +$1DCE)
                a: if set, program compares current battle index with
                   battle index at CF3780,X. if equal, battle index
                   is changed to battle index at CF3782,X. (used with GtBehemoth/SrBehemoth, M-TekArmor)
                b-h: same as a
until now what we knew about it was that it was an unused var, except for bit 0 and 1... MMMagic event and M-tek armor dealt with it;
Those new info say that var 09 and 0A are both used for the same thing and M-tek armor stuff is the same done with Sr.Behemoth?
What is exactly battle index? i saw that you refered to var 36 in the same way... just a coincidence or it's really var 36 the battle index?
anyway it's a very nice feature, i also verified values in CF3780,X and CF3782,X and they match with the 2 formations used in Sr.Behemoth fight
Still i didn't find anything about M-tek armor... the point is also that i don't even know what's the X value, i mean from which value the game gets the X?
how the bits of those variables are used for that feature... could you explain better this stuff, please?

2)
Code:
$3EBC ztrbemsg (same as $1DD1)
r: ran out of time (before emperor's banquet)
b: ran away from battle (before emperor's banquet)
  
I'm pretty sure the thing about emperor's banquet was never mentioned until now... so those 2 bits are used ONLY here?

3)
Code:
+$3ED4 Battle index
 
well, aside what i mentioned before about this one... (var 36)
some previous quote:

Quote:Hmm, var 36 is stored at 7E/3DAC.
so i searched that value on your RAM map and i found this:
Code:
+$3DAC Character/Monster Variable (bit 7 set after using seize)
ok, what does that mean? so var 36 sets its bit 7 if that monster uses seize or what?


THE GREATEST CHALLENGE OF ALL TIMES AWAITS:
http://www.ff6hacking.com/forums/showthr...p?tid=2593
DO YOU HAVE WHAT IT TAKES TO SLAY A GOD?
------------------------------------------------------------------------
Tenkarider's project #2 is started: FF6 Curse of the Madsiur Joke (CotMJ)
http://www.ff6hacking.com/forums/showthr...p?tid=2755
What happens when Madsiur tweaks your account? This full game hack will show that!
  Find
Quote  

#55
Posts: 179
Threads: 3
Thanks Received: 24
Thanks Given: 4
Joined: Apr 2015
Reputation: 18
Status
None
Great questions. I'm glad to see the RAM map is coming in handy.

1) From my notes, the MMMMMagic cutscene is controlled by bit 1 (0x02) of $3EBC / $1DD1. I don't think it has anything to do with $3EB9.
$3EB9 is different. The "X" is the bit index. Check out the code at C2/30E8-C2/310D for more details.
"Battle index" is just the battle number. I think FF3usME calls it the "Formation" Index.

2) The emperor's banquet thing is a little weird, and I think I remember that it doesn't really work correctly. I think it's supposed to work like this: After a battle with one of the soldiers, the screen is supposed to flash a different color depending on the outcome of the battle. Red if you died, blue if you ran out of time, green if you ran away. I didn't test this, but you can take a look at the event script at CC/886C for an example.

3) Yes, the monster variable is stored separately from the other variables. $3ED4 is the battle index and is not accessible as a battle variable.
Also, the program sets bit 7 of the monster variable when a monster uses seize. This is hardcoded into the code for seize. If you look at the AI script for the tentacle battle, it checks bit 7 of the monster variable to determine if a character has been seized.
  Find
Quote  

#56
Posts: 1,633
Threads: 56
Thanks Received: 13
Thanks Given: 84
Joined: Apr 2014
Reputation: 12
Status
Atma
questions to your answers incoming:


Quote:1) From my notes, the MMMMMagic cutscene is controlled by bit 1 (0x02) of $3EBC / $1DD1. I don't think it has anything 
to do with $3EB9. $3EB9 is different. The "X" is the bit index. Check out the code at C2/30E8-C2/310D for more details.
"Battle index" is just the battle number. I think FF3usME calls it the "Formation" Index.



From M-tek armor battlescript:
Code:
[script #-1]   ; orig idx=66, "M-TekArmor", nb. bytes=24
F0 EF EF B5    ; Rand. spell: Special or Special or Tek Laser
FF             ; End first wave of attack
FC 14 0C 01    ; If VAR012 has all the following bit set: 1
FC 01 02 02    ; If monster has been attacked by cmd: Magic or Magic, will target attacker
FC 15 09 01    ; If VAR009 has all the following bit cleared: 1
F9 00 09 01    ; VAR009 toggle bit: 1
F7 06          ; Trigger event: Terra + Edgar + Locke (about Terra's magic power)
FF             ; End

M-tek armor deals with var 009, bit 1(3EB9) as well, i read somewhere that even bit 0 had something to do with it, 
but i can't remember exactly where, in the case.
in any case in your RAM you consider both 3EB9 and 3EBA as a single variable that is composed from 2 bytes...
about Sr.Behemoth:
Code:
[script #-1]   ; orig idx=281, "SrBehemoth", nb. bytes=194
FC 08 36 05    ; If target self is affected by status Imp
F1 44          ; Targeting: random ally
EE             ; Battle
EE             ; Battle
FD             ; Wait until the attack sequence is called upon again, then continue (reset targeting)
.
.
.
FC 12 01 00    ; If following monster is/are dead: #1
F9 01 0A 00    ; VAR010 set bit: 0
F5 0B 03 00    ; Monsters  are hidden and their HP restored, diagonal
F3 7C 00       ; Text: " Enemy's coming from behind!<D>"
FA 06 00 00    ; Allies switch from right to left side
F3 7D 00       ; Text: " Another monster appeared!<D>"
F2 00 A8 81    ; Call form. #424 (SrBehemoth), gets max HP
F9 01 00 00    ; VAR000 set bit: 0
FE             ; End If and reset targeting
.
.
i'm pretty sure that for changing formation "call form. #424"(already used this command elsewhere), is more than
enough, so i wonder how the code at C2/30E8-C2/310D is called during the battle...
besides those 2 var's values don't look like any formation number involved, probably they tell which element the 
program has to check in "Formations to Change From" list(yet i don't know where 3EB9 comes in play)

considering all what i said above, the only thing that M-tek armor and Sr.Behemoth have in common is that they both
call a battle event(not exactly, Sr.Behemoth calls an FA command instead) and since i don't get where C2/30E8 is 
called, i'm starting to think that it's called inside the event/FA command itself.
I remember that there are certain battle commands that can be called only in some specific battle formation like
final battle against kefka that makes scroll BG vertically; they also told me that FA command that makes move the party
on the left side of the screen can be used only in Sr.Behemoth formation, otherwise the game will glitch... could 
that depend on var 3EB9-3EBA and the matching formation? 
Understanding how this thing actually works is very difficult but it would be a great discovery! if we collaborate 
here, we might find the answer. 



Quote:2) The emperor's banquet thing is a little weird, and I think I remember that it doesn't really work correctly. 
I think it's supposed to work like this: After a battle with one of the soldiers, the screen is supposed to 
flash a different color depending on the outcome of the battle. Red if you died, blue if you ran out of time, 
green if you ran away. I didn't test this, but you can take a look at the event script at CC/886C for an example.


I saw the code, yeah it works in the way you said, but it's actually not a matter, as far those battle variable bits
values are changed according to the outcome of the battle: even if they are used before the banquet, they can still be
used anywhere. 




Quote:3) Yes, the monster variable is stored separately from the other variables. $3ED4 is the battle index and is not 
accessible as a battle variable. Also, the program sets bit 7 of the monster variable when a monster uses seize. 
This is hardcoded into the code for seize. If you look at the AI script for the tentacle battle, it checks bit 7 of 
the monster variable to determine if a character has been seized.


well, this is a nice discovery! i didn't knew there was a way to know if seize was used in battle! just saying...
if i set bit 7 manually even if i never use Seize, it's not like it might happen something weird, right?


THE GREATEST CHALLENGE OF ALL TIMES AWAITS:
http://www.ff6hacking.com/forums/showthr...p?tid=2593
DO YOU HAVE WHAT IT TAKES TO SLAY A GOD?
------------------------------------------------------------------------
Tenkarider's project #2 is started: FF6 Curse of the Madsiur Joke (CotMJ)
http://www.ff6hacking.com/forums/showthr...p?tid=2755
What happens when Madsiur tweaks your account? This full game hack will show that!
  Find
Quote  

#57
Posts: 179
Threads: 3
Thanks Received: 24
Thanks Given: 4
Joined: Apr 2015
Reputation: 18
Status
None
The subroutine at C2/30E8 gets called at the beginning of a battle, and then again if the battle changes (like SrBehemoth or final Kefka). Maybe if you kill the SrBehemoth and then die during the GtBehemoth, it will save your progress so that you will only face the GtBehemoth the second time around. That's my guess anyway. I've never tried it. Or maybe the whole $3EB9 thing is redundant.

You're right, the M-TekArmor battle does also set one of the bits in $3EB9. I don't know why. It seems like it wouldn't have any effect.

I don't think you will have any problems if you use bit 7 of the monster variable, as long as you are not using Seize.
  Find
Quote  

#58
Posts: 1,633
Threads: 56
Thanks Received: 13
Thanks Given: 84
Joined: Apr 2014
Reputation: 12
Status
Atma
100% sure that won't be that the case in case of lose against Sr.Behemoth(both the monsters are Sr.Behemoth) 
that would make sense if it was something like the final battle, despite it's totally hardcoded that thing(after you defeat face and the 2 arms there will be a BG shift and formation change as well, but there's no formation change command in any script of the battle)

One way to solve this damn mistery would be knowing where's the code which describes what happens when you use FA ai command that makes move the
whole party on the left side of the screen, in that location it might be possible to discover why the game crushes when it's used outside Sr.Behemoth fight


THE GREATEST CHALLENGE OF ALL TIMES AWAITS:
http://www.ff6hacking.com/forums/showthr...p?tid=2593
DO YOU HAVE WHAT IT TAKES TO SLAY A GOD?
------------------------------------------------------------------------
Tenkarider's project #2 is started: FF6 Curse of the Madsiur Joke (CotMJ)
http://www.ff6hacking.com/forums/showthr...p?tid=2755
What happens when Madsiur tweaks your account? This full game hack will show that!
  Find
Quote  



Forum Jump:

Users browsing this thread: 1 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite