Attempting to create a new event command - Printable Version +- FF6 Hacking (https://www.ff6hacking.com/forums) +-- Forum: Discussion Forums (https://www.ff6hacking.com/forums/forum-5.html) +--- Forum: Magitek Research Facility (https://www.ff6hacking.com/forums/forum-9.html) +--- Thread: Attempting to create a new event command (/thread-2848.html) Pages:
1
2
|
RE: Attempting to create a new event command - m06 - 04-06-2015 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 SEP and REP are assembly commands used to set or reset flags in the p register. Code: MACHINE ASSEMBLY EFFECT FLAGS So you can use these commands to clear or set negative flag or zero flag aswell: Code: MACHINE ASSEMBLY EFFECT FLAGS http://wiki.superfamicom.org/snes/show/65816+Reference RE: Attempting to create a new event command - Tenkarider - 04-06-2015 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 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 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?!? 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... RE: Attempting to create a new event command - madsiur - 04-06-2015 Does the debugger show the right command at that line? RE: Attempting to create a new event command - Tenkarider - 04-06-2015 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 RE: Attempting to create a new event command - Catone - 04-06-2015 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. RE: Attempting to create a new event command - m06 - 04-06-2015 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. RE: Attempting to create a new event command - Tenkarider - 04-06-2015 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) 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? RE: Attempting to create a new event command - Drakkhen - 04-06-2015 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. RE: Attempting to create a new event command - Tenkarider - 04-07-2015 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 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 Here i don't really know anymore which number is the highest that you can store on that var... i'm counting on you. RE: Attempting to create a new event command - Tenkarider - 07-29-2015 The event i was making is now a patch: http://www.mediafire.com/download/bhyn4isl0j4robx/Command+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! |