Users browsing this thread: 1 Guest(s)
ASM coding - Checking battle command in use

#1
Posts: 676
Threads: 44
Thanks Received: 26
Thanks Given: 21
Joined: Jan 2015
Reputation: 11
Status
Zombie
I'm working on a command rewrite. Since I'm trying to use one set of code to work two different commands, I need to check which command the code was executed from. I've only chamged pointers to the code, I didn't change the graphic pointers for the new command and that part works seperate. In other words, the game still knows the difference at that point in C1/.

Looking at several other lines, I should have been able to:

Code:
B2 76      LDA $76     (Used other places to load command number)
C9 19      CMP 19       (Should be checking for the "Summon" command)
D0 06      BNE           (branch if not Summon)

Problem being, using the debugger at that point, from the Magitek command I get a value of ... not Magitek's number... using the Summon command, I get a value of FF( definatly not Summon's number). Even then if I change it to check for FF, it still branches.

I do have a plan B, not to fond of it though. Would rather figure out why this isn't doing what I ask it to, or the proper way to check what command is being used.

All of this is during battle and executing in C1 btw. Least this part of it, not sure how much that matters.

Any advice would be great.

*Edit*
For the records: at C1/7CC8 starts a block of code for loading the command in battle and uses it for the following table. It looks to load this value at line C1/7CD4, however doing a LDA $202E will not load the value while in the middle of drawing a command's window. The next line however: STA $2BAF does help.

So in my case,

AD AF 2B LDA $2BAF

Loaded the proper command number, consistantly. Still not sure why $B5 only held a value sometimes and not every time, but problem solved.


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

#2
Posts: 149
Threads: 21
Thanks Received: 40
Thanks Given: 3
Joined: Dec 2013
Reputation: 9
Status
Auto-life
I don't know about the C1 bank, but i know about the commands in the C2 bank.

In the C2 bank, $B5 is used as the command Id and $B6 is used as the command index. As example, consider the swordtech command. The command itself ($B5) is #$07 (swordtech). The command index ($B6) is used to select one of the available actions from the command. It is #$00 for dispatch, #$01 for retort, #$03 for Slash, etc.

You can use the table at C2/19C7 for the command adjustments. The fight command is a good example of the replacement of the command behavior. The default setting is the normal attack command. However, it can be changed for a desperation attack for characters. For Umaro's, it can be changed for his tackle attack and his special actions. Also, when equipped with the offering, the fight command behavior is changed to a four times attack.

Code:
C2/19C7: C8 15     (Fight)
C2/19C9: 97 18     (Item)
C2/19CB: 41 17     (Magic)
C2/19CD: 36 19     (Morph)
C2/19CF: 27 19     (Revert)
C2/19D1: 91 15     (Steal)   (05)
C2/19D3: 10 16     (Capture)
C2/19D5: 47 18     (Swdtech)
C2/19D7: 8D 18     (Throw)
C2/19D9: 85 18     (Tools)
C2/19DB: 9D 15     (Blitz)   (0A)
C2/19DD: 5B 19     (Runic)
C2/19DF: 5F 17     (Lore)
C2/19E1: 1F 15     (Sketch)
C2/19E3: 76 19     (Control)
C2/19E5: 26 17     (Slot)
C2/19E7: 60 15     (Rage)    (10)
C2/19E9: 9D 19     (Leap)
C2/19EB: 1E 15     (Mimic)
C2/19ED: 7D 17     (Dance)
C2/19EF: 4C 19     (Row)
C2/19F1: 6A 19     (Def.)    (15)
C2/19F3: F6 17     (Jump)
C2/19F5: 41 17     (X-Magic)
C2/19F7: 07 19     (GP Rain)
C2/19F9: 63 17     (Summon)
C2/19FB: 1E 17     (Health)  (1A)
C2/19FD: 1A 17     (Shock)
C2/19FF: E5 17     (Possess)
C2/1A01: 5F 17     (Magitek)

You can also check the code of the Custom Tools hack. It reloads the attack data of the Tools command based on the configuration of the Tools items.
  Find
Quote  

#3
Posts: 676
Threads: 44
Thanks Received: 26
Thanks Given: 21
Joined: Jan 2015
Reputation: 11
Status
Zombie
Tried checking against $B5 with no luck, at least it didn't show any signs of pulling the proper values. Think I'm missing an extra line of math somehow, or the mode I'm running in is wrong for how I'm trying. I know the game checks for it at C1/7CDE to access a table of pointers.

I actually merged the two commands at the table you posted, (the Summon command pointed at the MagiTek code), which works as expected. Change a pointer in C1 and it mimics MagiTek exactly, except for the casting animation, which is still pointed to the normal Summon/Casting animation. So at that point the game can still tell the two commands appart despite using the same code in C2. The reason I have to check the command is to seperate them before the commands are loaded into the window during battle, and the only thing I can think of to tell them apart is the command number. If I can get it to check it.

Will check the patch, and recheck the use of $B5, don't see why it would read in C2 and not in C1 less I'm reading it wrong. Thanks for the advice.

Wow, seriously wtf.

Yes, $B5 holds the command number... sometimes...

The reason it didn't seem to work the first time I tried it, it seems to be empty every now and then. When I'm in battle, if the character with the custom command turn comes up first, loading $B5 gets a zero value. If I switch characters, even just hitting the X to skip turn and it goes right back to the same character, loading $B5 then will produce a proper result.

This doesn't happen just during the first turn either. Seems every time that character's turn comes up directly due to a full timer, it loads a zero and skips the check. Opening the command window, then closing and reopening it still returns a zero value as well.

Frankly.... wtf.


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

#4
Posts: 149
Threads: 21
Thanks Received: 40
Thanks Given: 3
Joined: Dec 2013
Reputation: 9
Status
Auto-life
Perhaps, can it be the direct page value? In the C2 bank, it is always zero and TDC is almost used to clear the two bytes of the A register. When the direct page is changed, it always is set back to zero afterwards.

The direct page can be different in the code in the C1 bank. You can try a TDC and check if the value returned to A is zero (two bytes). If it is not, it is the wrong value for the direct page and all opcodes related to the direct page will load the wrong value.
  Find
Quote  

#5
Posts: 676
Threads: 44
Thanks Received: 26
Thanks Given: 21
Joined: Jan 2015
Reputation: 11
Status
Zombie
That's the thing though, with $B5 I was either getting 0 or the correct value. All based on how that character's turn was started, as far as I could tell.

Well, actually yeah it does make sence with that. When I would switch characters with the X button, it would return the correct value (depending on what command I selected to start that code from), but when I let the battle meter fill up and start that character's turn directly, it would clear it... somehow.

Even then, it should still have had a value after I selected the command in battle. I don't see how it was cleared in one instance, yet correct in another instance, nothing should have effected it (let alone cleared it) from the time I selected the command until the window opened.

Right now, its working by checking a bit stored earlier in the command execution code. I did have one instance, after changing it, that it returned a 0 value when I tried to check it. I couldn't get it to do it again though. Still going to add this to my list of things to investigate next time I'm fealing really stuborn.

Actually probably going to try that tomorrow morning, left an extra byte or two free here and there in the code for modification room. Should be able to drop that command inline and see what it is without chamging anything. Now I have to wonder what it'll show.


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



Forum Jump:

Users browsing this thread: 1 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite