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

#41
Posts: 1,633
Threads: 56
Thanks Received: 13
Thanks Given: 84
Joined: Apr 2014
Reputation: 12
Status
Atma
This is M-tek armor battle AI script:

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

Reading the code the bit involved of var 09(1DCE) is bit 1, not bit 0...
I read the event address you wrote, that sets var 12 bit 1 right before the battle... so the situation is that if you hit them with magic...
- the check on var 12, bit 1 is true;
- var 09, bit 1 is clear, so the check is true;
- since var 09, bit 1 is clear, now that bit is toggled, so it becomes set...

Well... looks like if you trigger the battle event, then (1DCE:1) will be set! Surprised this is weird under many aspects: documents say that (1DCE:0) disables MMMagic event, still it will never be set, now... if in the script it's used (1DCE:1) and not (1DCE:0), then when/where exactly (1DCE:0) is involved and how is involved, if it will never change from clear status?

Besides in the script var 12, bit 1 won't change its value, even if you trigger the event, (1DCE:1) will block the event instead, but that's not documented...?
so var 12, bit 1 will return clear, only by map events.

That's all what happens in M-tek battle, yet there's a period, in which you trigger MMMagic battle event if you cast some spell in a random battle: now... i'm 200% sure that there's no other monster in the whole list, except M-tek armor, that trigger that event, with his AI...
Then how the event is triggered during random battles? i really need to know the address of that piece of code, which must be hardcoded.
Do you know where i can find it?


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  

#42
Posts: 1,633
Threads: 56
Thanks Received: 13
Thanks Given: 84
Joined: Apr 2014
Reputation: 12
Status
Atma
Quote:That's all what happens in M-tek battle, yet there's a period, in which you trigger MMMagic battle event if you cast some spell in a random battle: now... i'm 200% sure that there's no other monster in the whole list, except M-tek armor, that trigger that event, with his AI...
Then how the event is triggered during random battles? i really need to know the address of that piece of code, which must be hardcoded.
Do you know where i can find it?

So no one really knows anything about this one? Those battlevars are not safe unless i discover where's that code... Sad


___________________


Meanwhile i noticed something interesting about battlevar 10(hex) the one which handles Cursed Shield battle counter:

Code:
C2/5FFA: C9 66 CMP #$66         ;Compare accumulator to 66h (Cursed Shld value).
C2/5FFC: D0 0E BNE $600C        ;Branch past the rest if it's not the shield.
C2/5FFE: EE C0 3E INC $3EC0     ;Increment battle count (loaded from 7E:1DD5).
C2/6001: D0 09 BNE $600C        ;Branch past the rest if the battle count has not returned to 0.

Pay attention to 4th line, please: "Branch past the rest if the battle count has not returned to 0." that means that when the counter is at 255, then with the last battle it's incremented by 1 and returns to 0... overflow, right? then what's happened to the carry bit? did they do CLC(clear carry) with it? in that case fine, but if not that would mean that the next battle var have been incremented by 1, there's no problem in doing that since battlevar 11(hex) is unused, but i wanna use it so it's a problem and i need to know if that var is actually safe.

Anyone knows if battle var 11 stays unchanged or not?


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  

#43
Posts: 179
Threads: 3
Thanks Received: 24
Thanks Given: 4
Joined: Apr 2015
Reputation: 18
Status
None
(09-24-2015, 04:03 PM)Tenkarider Wrote: Anyone knows if battle var 11 stays unchanged or not?

No, it won't overflow into the next byte because the accumulator is in 8-bit mode at that point. It will set the carry like you said, but that's all. You could check this by dispelling the cursed shield and then checking the value in $3EC1 (or $1DD6).
  Find
Quote  

#44
Posts: 1,633
Threads: 56
Thanks Received: 13
Thanks Given: 84
Joined: Apr 2014
Reputation: 12
Status
Atma
Now, i don't remember if variables that resets, are manually resetted or just won't be saved and so will automatically return to 0, anyway i had an idea about variable 036(0x24)
The first 4 variables are more than enough to handle any normal/uncommon/boss fight so i think it's a waste of potential to just use var 036 in that way... what if it could keep it's value?
A first note: i'm assuming that there's a local var 36 for each monster of the game, if for some reason that var is bounded to the 6 slots of the enemies instead, then my theory crumbles and it can't work anymore, since i'd have no more use of it.

On the other hand if i'm right then i'd be interested in know how to avoid to reset var 36... since it follows a different behavior than the other variables, then i assume they have their own memory space for each monster, so they already have a space to store their value after battle, then if i can also avoid to make them reset their value after battle, i reached a nice goal.


Soooo... do you know what exactly happens when battle finishes? does it manually reset var 36? do you know it it's feasible to skip that operation so that their value stay untouched?


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  

#45
Posts: 179
Threads: 3
Thanks Received: 24
Thanks Given: 4
Joined: Apr 2015
Reputation: 18
Status
None
Hmm, var 36 is stored at 7E/3DAC. When the map gets re-loaded after a battle, all of the RAM from 7E/2000-7E/5FFF gets reset so that it can be used by the map program. The code for this is at C0/566A. That's the reason why they copy the global battle variables from $3EB4 to $1DC9 at the end of every battle. The map program uses a ton of memory, so pretty much everything gets reset when the map loads.
  Find
Quote  

#46
Posts: 1,633
Threads: 56
Thanks Received: 13
Thanks Given: 84
Joined: Apr 2014
Reputation: 12
Status
Atma
Lol, finally i understood today where the RAM is located, in the rom, exactly Laugh


reading RAM map:
$3DAC : Unique monster variables (1 for each monster)
$3DC0 : Counter for how long monster has been alive (2 bytes)
uhm... where's the space to something like 383 variables, considering that after at least 0x14 bytes there's already another thing? i mean, that surely happens, so i wonder how they store them...



you said that 7E/2000-7E/5FFF gets reset, but if i read the code well it looks like it actually stops at 7E/5678?

Code:
C0/566A:    A20020      LDX #$2000        (from C0/560A)
C0/566D:    8E8121      STX $2181
C0/5670:    9C8321      STZ $2183
C0/5673:    A20040      LDX #$4000
C0/5676:    A9FF        LDA #$FF
C0/5678:    8D8021      STA $2180
C0/567B:    CA          DEX
C0/567C:    D0FA        BNE $5678
C0/567E:    60          RTS


------------------------


Anyway you say the RAM area used for battle is the same space used for maps? in other words it would be necessary to save them into another area and load them before a 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  

#47
Posts: 179
Threads: 3
Thanks Received: 24
Thanks Given: 4
Joined: Apr 2015
Reputation: 18
Status
None
(12-24-2015, 02:06 PM)Tenkarider Wrote: $3DAC : Unique monster variables (1 for each monster)
$3DC0 : Counter for how long monster has been alive (2 bytes)
uhm... where's the space to something like 383 variables, considering that after at least 0x14 bytes there's already another thing? i mean, that surely happens, so i wonder how they store them...

When it says 1 for each monster, it means 1 for each of the 6 monsters in the current battle. Not one for each type of monster in the entire game. There's actually a variable for each of the 4 character slots as well, so...

$3DAC is for character 1
$3DAE is for character 2
$3DB0 is for character 3
$3DB2 is for character 4
$3DB4 is for monster 1
$3DB6 is for monster 2
$3DB8 is for monster 3
$3DBA is for monster 4
$3DBC is for monster 5
$3DBE is for monster 6

2 bytes for each variable * (4 characters + 6 monsters) = 0x14 bytes total. If you look through the RAM map, you'll notice that many things are spaced 0x14 bytes apart. This is why.

(12-24-2015, 02:06 PM)Tenkarider Wrote: Anyway you say the RAM area used for battle is the same space used for maps? in other words it would be necessary to save them into another area and load them before a fight?

Yep
  Find
Quote  

#48
Posts: 676
Threads: 44
Thanks Received: 26
Thanks Given: 21
Joined: Jan 2015
Reputation: 11
Status
Zombie
Expand SRAM to include a chunk of data per save game that holds all your toys, then play with them as you wish.

Just don't forget to put them back in the toy box when your done.


The only true wisdom is knowing you know nothing.
  Find
Quote  

#49
Posts: 3,970
Threads: 279
Thanks Received: 236
Thanks Given: 58
Joined: Oct 2011
Reputation: 65
Status
Tissue-aware
(12-24-2015, 02:06 PM)Tenkarider Wrote: Lol, finally i understood today where the RAM is located, in the rom, exactly Laugh

You probably mean "in the SNES memory", not "in the ROM file" right?
  Find
Quote  

#50
Posts: 259
Threads: 3
Thanks Received: 5
Thanks Given: 1
Joined: Jun 2013
Reputation: 6
Status
None
VAR036 is a local variable (i.e. it is local to the monster using it), whereas VAR000-003 are global.

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.


"You don't have to be a vampire to die like one... b*t*h." -Simon Belmont
Quote  



Forum Jump:

Users browsing this thread: 1 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite