Users browsing this thread: 1 Guest(s)
Attempting to create a new event command

#11
Posts: 127
Threads: 8
Thanks Received: 21
Thanks Given: 12
Joined: Jan 2012
Reputation: 13
Status
None
Yeah, I think you got it with $E5-$E7. Why they are not in the RAM list you'll have to ask Madsiur, but the RAM map states that it is incomplete.

Jumping to itself is more like jumping back in the code that results in the same place aka. looping. So it's like a high level while(true) loop that lasts forever unless we break (in high level languages). The event processor is a very complicated example of this so I find it just good to know that each command ends in JMP $9A6D and all is well.

____________________________________

Regarding your code it looks fine, very good, I'm not sure why it doesn't work. Debugger might help as Catone suggested.

One idea is that the battle variables might be reset after battle and return zero. But I've never used them so I don't know how they are handled at all.

Another idea is the P register (processor flags) might be incorrectly set. Although it shouldn't be, I'll try to explain SEP and REP a bit better here:

I noticed you set A to be 16-bit and then load and store with X and then change A back to 8-bit. (A is also known as Accumulator)

So the P register or Process Register is a byte that helps the other registers function. Each bit of the byte represents a flag:

Code:
HEX  FLAG  WHEN SET
0x80 n     negative
0x40 v     overflow
0x20 m     8-bit A (accumulator)
0x10 x     8-bit X and Y
0x08 d     decimal
0x04 i     IRQ disable
0x02 z     zero
0x01 c     carry

SEP and REP are assembly commands used to set or reset flags in the p register.

Code:
MACHINE        ASSEMBLY           EFFECT                         FLAGS
e2 nn          sep #$nn           set processor flags            nvmxdizc
c2 nn          rep #$nn           reset processor flags          nvmxdizc

So you can use these commands to clear or set negative flag or zero flag aswell:

Code:
MACHINE        ASSEMBLY           EFFECT                         FLAGS
e2 20          SEP #$20           set 8-bit A                    --m-----
c2 20          REP #$20           set 16-bit A                   --m-----
e2 10          SEP #$10           set 8-bit X and Y              ---x----
c2 10          REP #$10           set 16-bit X and Y             ---x----
c2 83          REP #$82           clear negative and zero        n-----z-

http://wiki.superfamicom.org/snes/show/65816+Reference
  Find
Quote  

#12
Posts: 1,633
Threads: 56
Thanks Received: 13
Thanks Given: 84
Joined: Apr 2014
Reputation: 12
Status
Atma
While i already knew most of the stuff you explained here(if i wasn't able to deal with 8-16 bit accumulators, CotG hack would never started...) there's still an info or two that might be useful to know, thanks for that Wink

Btw, before i read your message i managed to use Snes debugger and figured out some problem, which i fixed too. Everything works as it should, but there's still one last thing i have to fix:

The problem is inside this block i already wrote: (it might be slightly different now, but it's not a matter... the problematic line has been left untouched)

Code:
C0/D645: 48            PHA
C0/D646: E0 24        CPX #$24
C0/D648: B0 05        BCS $D64F  
C0/D64A: BD B0 3E   LDA $3EB0,X
C0/D64D: 80 03        BRA $D652
C0/D64F: B9 AC 3D   LDA $3DAC,Y
C0/D652: 85 EB        STA $EB
C0/D654: 68            PLA
C0/D655: 18            CLC
C0/D656: 60            RTS

Let's take this line:
C0/D64A: BD B0 3E LDA $3EB0,X

ok, in this point i'm using an 8 bit accumulator: right in this moment X is equal to 4, like the battle var i loaded here, and i'd expect to load on the accumulator the value stored in $3EB0,X (for example... 6) but i get instead 3E as value...
What's the problem? it took a bit to realize this weird thing: the command is
BD B0 3E, right? well that 3E value i always get is right the third byte of the command BD B0 3E... what?!? Surprised

Do you know why? here i'm stopped, but i need just one little help here and then i succesfully created the command.


PS. that piece of code is imported and adapted from monster AI command FC 0D (if var is greater or equal than...) that line of code loads $3EB0,X as expected as monster AI command; inside my event command looks like it has a different behavior...


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  

#13
Posts: 3,970
Threads: 279
Thanks Received: 236
Thanks Given: 58
Joined: Oct 2011
Reputation: 65
Status
Tissue-aware
Does the debugger show the right command at that line?
  Find
Quote  

#14
Posts: 1,633
Threads: 56
Thanks Received: 13
Thanks Given: 84
Joined: Apr 2014
Reputation: 12
Status
Atma
Yes... i also checked X and A values in the right columns, while and after that line is executed: A gets 3E value, which is weird 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  

#15
Posts: 676
Threads: 44
Thanks Received: 26
Thanks Given: 21
Joined: Jan 2015
Reputation: 11
Status
Zombie
Are you sure your in the correct mode for that line to execute properly? Would doing a SEP or REP or such at the start of that code make it read?

If A is getting 3E, its either loading 3E as a value instead of a source address or somehow adding up to = 3E. I would guess the first case, which leads me to guess... wrong mode.


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

#16
Posts: 127
Threads: 8
Thanks Received: 21
Thanks Given: 12
Joined: Jan 2012
Reputation: 13
Status
None
Are you sure LDX at the beginning isn't 16-bit?
Code:
C0/D613: A6 EB LDX $EB

Usually X will be 16-bit and load $EB and $EC to X as a word.
  Find
Quote  

#17
Posts: 1,633
Threads: 56
Thanks Received: 13
Thanks Given: 84
Joined: Apr 2014
Reputation: 12
Status
Atma
I hoped it wasn't necessary to show the updated code, since i already said it was fixed...:
Code:
C0/D613: E2 20        SEP #$20        (8 bit accum./memory)
C0/D615: A5 EB        LDA $EB     (First byte for FC)
C0/D617: AA            TAX
C0/D618: 20 48 D6    JSR $D647   ($EB = variable #X)
C0/D61B: A5 EB        LDA $EB  (after the JSR the n. of the var is changed into its value)
C0/D61D: C5 EC        CMP $EC
C0/D61F: 30 13          BMI             (Branch if AA value < BB)

C0/D621: C2 20            REP #$20          (16 bit accum./memory)
C0/D623: A6 ED            LDX $ED            (Load parameter 3 and 4)
C0/D625: 86 E5            STX $E5            (store the low and middle byte of the                offset in $E5)
C0/D627: E2 20            SEP #$20        (8 bit accum./memory)
C0/D629: A5 EF            LDA $EF            (Load parameter 5)
C0/D62B: 18                      CLC                (clear carry)
C0/D62C: 69 CA            ADC #$CA        (Add #$CA to the high byte of the offset)
C0/D62E: 85 E7            STA $E7            (Stre high byte of the offset in $E7)
C0/D630: 5C 6D 9A C0      JMP $C09A6D        (Make the event branching/jumping effective)
C0/D634: C2 21            REP #$21
C0/D636: A5 E5            LDA $E5            (Load low and middle byte of current offset)
C0/D638: 69 06 00          ADC #$0006        (Command + parameters length)
C0/D63B: 85 E5            STA $E5            (Save in $E5)
C0/D63D: 7B                      TDC             (Transfer D to C)
C0/D63E: E2 20            SEP #$20          (8 bit accum./memory)
C0/D640: 65 E7            ADC $E7            (Add to A $E7)
C0/D642: 85 E7            STA $E7            (Store A in $E7)
C0/D644: 5C 6D 9A C0     JMP $C09A6D        (Make a 6 bytes jump from the command number in the event)


C0/D648: 48            PHA
C0/D649: E0 24 00    CPX #$0024
C0/D64C: B0 05        BCS $D64F  
C0/D64E: BD B0 3E   LDA $3EB0,X
C0/D651: 80 03        BRA $D652
C0/D653: B9 AC 3D   LDA $3DAC,Y
C0/D656: 85 EB        STA $EB
C0/D658: 68            PLA
C0/D659: 18            CLC
C0/D65A: 60            RTS

With the new changes A is 8 bit, instead of doing LDX at the beginning i do LDA and then TAX (so it transfers just an 8 bit value... yeah i didn't changed bit n. of X and Y, i didn't knew how to do that before...)
C0/D649: E0 24 00 CPX #$0024
this line now compares to 0024 instead of 24, in this way the value size matches with the one of the value compared.

So it's not that the problem you pointed out in the latest posts... maybe the bit size of X and Y should be changed, when i do the following code?
C0/D64E: BD B0 3E LDA $3EB0,X

C0/D653: B9 AC 3D LDA $3DAC,Y

Please, check this one, while i'm away... ok? Wink


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  

#18
Posts: 52
Threads: 5
Thanks Received: 24
Thanks Given: 0
Joined: Jun 2010
Reputation: 6
Status
None
I believe the problem is that the address you're reading from, $3EB4, is getting overwritten at the end of battle.
Try loading from $1DC5,X, or subtract 4 from the index and load from $1DC9,X instead.(The variables start at $1DC9, but $1DC9 corresponds with $3EB4)
I don't believe the $3DAC-$3DBF variables are retained out of battle at all. You'd have to copy them somewhere else that isn't overwritten.
Quote  

#19
Posts: 1,633
Threads: 56
Thanks Received: 13
Thanks Given: 84
Joined: Apr 2014
Reputation: 12
Status
Atma
Drakken, you're right! loading from $1DC5,X instead... it loads the correct value of the var! but... why? If those are battle vars that keep their value after battle, then why this not actually happen even for $3EB0,X values? on a side note i was testing values, until something weird happened: the value of the var i was using(var 4) did overflow before reaching FF value: after some test i figured out that the highest value it can reach before it overflows is B1. (177 in decimal)
Does anyone know the reason?
___________________________________

Ok, shit's happening: while i'm sure the event command is working fine, that won't happen for the highest number stored inside var 04, since i saw that the limit was 177, then i changed the compare value of each check(BB) into a lower one... now it overflows if i go above 166(decimal)...

I'll post here the data that show snes debugger, so that you might notice something that i cannot see:

var 4 = 166
Code:
$00/FF00 78          SEI                     A:0000 X:0000 Y:0000 P:EnvMXdIzc
$C0/D613 E2 20       SEP #$20                A:0000 X:00DC Y:0000 P:enVMxdiZc
$C0/D615 A5 EB       LDA $EB    [$00:00EB]   A:0000 X:00DC Y:0000 P:enVMxdiZc
$C0/D617 AA          TAX                     A:0004 X:00DC Y:0000 P:enVMxdizc
$C0/D618 20 48 D6    JSR $D648  [$C0:D648]   A:0004 X:0004 Y:0000 P:enVMxdizc
$C0/D648 48          PHA                     A:0004 X:0004 Y:0000 P:enVMxdizc
$C0/D649 E0 24 00    CPX #$0024              A:0004 X:0004 Y:0000 P:enVMxdizc
$C0/D64C B0 05       BCS $05    [$D653]      A:0004 X:0004 Y:0000 P:eNVMxdizc
$C0/D64E BD C5 1D    LDA $1DC5,x[$00:1DC9]   A:0004 X:0004 Y:0000 P:eNVMxdizc
$C0/D651 80 03       BRA $03    [$D656]      A:0069 X:0004 Y:0000 P:enVMxdizc
$C0/D656 85 EB       STA $EB    [$00:00EB]   A:0069 X:0004 Y:0000 P:enVMxdizc
$C0/D658 68          PLA                     A:0069 X:0004 Y:0000 P:enVMxdizc
$C0/D659 18          CLC                     A:0004 X:0004 Y:0000 P:enVMxdizc
$C0/D65A 60          RTS                     A:0004 X:0004 Y:0000 P:enVMxdizc
$C0/D61B A5 EB       LDA $EB    [$00:00EB]   A:0004 X:0004 Y:0000 P:enVMxdizc
$C0/D61D C5 EC       CMP $EC    [$00:00EC]   A:0069 X:0004 Y:0000 P:enVMxdizc
$C0/D61F 30 13       BMI $13    [$D634]      A:0069 X:0004 Y:0000 P:enVMxdizC
$C0/D621 C2 20       REP #$20                A:0069 X:0004 Y:0000 P:enVMxdizC
$C0/D623 A6 ED       LDX $ED    [$00:00ED]   A:0069 X:0004 Y:0000 P:enVmxdizC
$C0/D625 86 E5       STX $E5    [$00:00E5]   A:0069 X:000B Y:0000 P:enVmxdizC
$C0/D627 E2 20       SEP #$20                A:0069 X:000B Y:0000 P:enVmxdizC
$C0/D629 A5 EF       LDA $EF    [$00:00EF]   A:0069 X:000B Y:0000 P:enVMxdizC
$C0/D62B 18          CLC                     A:0035 X:000B Y:0000 P:enVMxdizC
$C0/D62C 69 CA       ADC #$CA                A:0035 X:000B Y:0000 P:enVMxdizc
$C0/D62E 85 E7       STA $E7    [$00:00E7]   A:00FF X:000B Y:0000 P:eNvMxdizc
$C0/D630 5C 6D 9A C0 JMP $C09A6D[$C0:9A6D]   A:00FF X:000B Y:0000 P:eNvMxdizc

As you can see the var value doesn't match... here's the case in which i overflow with it:

var 4 = 167
Code:
$C0/D613 E2 20       SEP #$20                A:0000 X:00DC Y:0000 P:enVMxdiZc
$C0/D615 A5 EB       LDA $EB    [$00:00EB]   A:0000 X:00DC Y:0000 P:enVMxdiZc
$C0/D617 AA          TAX                     A:0004 X:00DC Y:0000 P:enVMxdizc
$C0/D618 20 48 D6    JSR $D648  [$C0:D648]   A:0004 X:0004 Y:0000 P:enVMxdizc
$C0/D648 48          PHA                     A:0004 X:0004 Y:0000 P:enVMxdizc
$C0/D649 E0 24 00    CPX #$0024              A:0004 X:0004 Y:0000 P:enVMxdizc
$C0/D64C B0 05       BCS $05    [$D653]      A:0004 X:0004 Y:0000 P:eNVMxdizc
$C0/D64E BD C5 1D    LDA $1DC5,x[$00:1DC9]   A:0004 X:0004 Y:0000 P:eNVMxdizc
$C0/D651 80 03       BRA $03    [$D656]      A:0069 X:0004 Y:0000 P:enVMxdizc
$C0/D656 85 EB       STA $EB    [$00:00EB]   A:0069 X:0004 Y:0000 P:enVMxdizc
$C0/D658 68          PLA                     A:0069 X:0004 Y:0000 P:enVMxdizc
$C0/D659 18          CLC                     A:0004 X:0004 Y:0000 P:enVMxdizc
$C0/D65A 60          RTS                     A:0004 X:0004 Y:0000 P:enVMxdizc
$C0/D61B A5 EB       LDA $EB    [$00:00EB]   A:0004 X:0004 Y:0000 P:enVMxdizc
$C0/D61D C5 EC       CMP $EC    [$00:00EC]   A:0069 X:0004 Y:0000 P:enVMxdizc
$C0/D61F 30 13       BMI $13    [$D634]      A:0069 X:0004 Y:0000 P:enVMxdizC
$C0/D621 C2 20       REP #$20                A:0069 X:0004 Y:0000 P:enVMxdizC
$C0/D623 A6 ED       LDX $ED    [$00:00ED]   A:0069 X:0004 Y:0000 P:enVmxdizC
$C0/D625 86 E5       STX $E5    [$00:00E5]   A:0069 X:000B Y:0000 P:enVmxdizC
$C0/D627 E2 20       SEP #$20                A:0069 X:000B Y:0000 P:enVmxdizC
$C0/D629 A5 EF       LDA $EF    [$00:00EF]   A:0069 X:000B Y:0000 P:enVMxdizC
$C0/D62B 18          CLC                     A:0035 X:000B Y:0000 P:enVMxdizC
$C0/D62C 69 CA       ADC #$CA                A:0035 X:000B Y:0000 P:enVMxdizc
$C0/D62E 85 E7       STA $E7    [$00:00E7]   A:00FF X:000B Y:0000 P:eNvMxdizc
$C0/D630 5C 6D 9A C0 JMP $C09A6D[$C0:9A6D]   A:00FF X:000B Y:0000 P:eNvMxdiz

Here i don't really know anymore which number is the highest that you can store on that var... i'm counting on you.


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  

#20
Posts: 1,633
Threads: 56
Thanks Received: 13
Thanks Given: 84
Joined: Apr 2014
Reputation: 12
Status
Atma
The event i was making is now a patch:
http://www.mediafire.com/download/bhyn4i...and+A3.rar

i didn't solve the last problem, anyway it shouldn't overflow at least until 128 (max 255) in the readme you can find the code...
Just in the case you forgot the effect it was: A3 <AA> <BB> <CC CC CC> (length = 6 bytes)
if battlevar AA(00 is battlevar 04) is greater than or equal to BB then jump to CC CC CC


I would really apreciate if anyone could check the code and try to fix the overflow issue, we'd have a perfect event command in that way!


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