Address increment + value increment Roller

Started by Patedj, May 29, 2011, 07:41:26 AM

Previous topic - Next topic

Patedj

I'm trying to figure out how to do this...

if address a = hero's address
and in a there are 3 levels. level 1 is the first 16 bytes. level 2 the next 8 bytes. level 3 the last 8 bytes.
if address b = 38+ hero's address
and in b there are the same 3 levels.


how do I write +1 to the gn and + 38 to the gn in Gecko registers?


84000000 80C6C8CA ---> load address a into the register
289ACA9C xxxxxxxx ---> condition A
86000000 00000001 ----> add 1
289ACA9C xxxxxxxx ----> condition B
86000000 FFFFFFFF ----> add -1
289ACA9C XXXXXXXX ---> condition C
???????? 00000038 ----> add 38 to gn
[spoiler]289ACA9D XXXXXXXX ---> condition D
???????? 00000001 ----> add 1 to gn[/spoiler]
E0000000 80008000 --->release
84000000 80C6C8CA --->store to address ( is this grN??)
[spoiler]falling off the right is hard to avoid with 4 conditions I think[/spoiler]
2c/A4000000 00FFA400 ---> if address value is 0000a4xx (ignore the xx values because of the FF mask)
???????? 00000001 ---> then write/store to address (shouldn't this be grN)
2e/A6000001 00FF0100 ---->if address value is 000001xx
???????? 000000A4 ---->then write/store to address (shouldn't this be grN)
E0000000 80008000

Is it possible to put a fourth condition? How do I if a grN instead of it's value ([80C6C8CA] instead of xxxxyyyy) where the if greater value would be 80C6DD5)?
How would I write the write or store to?



MOD EDIT: turned off smileys on this post
You can pm me, I've got time for your troubles.

Patedj

#1
At this point, I'm thinking simply to add a grN changer to the code. something like
289ACA9C 00002000 -->button condition
86010000 00000038 --> add [grn] 38
E0000000 80008000

But I'm sure I'm not using this right...
You can pm me, I've got time for your troubles.

dcx2

You should give a better description of what you want to do.  I'm not sure I follow.

I think you mean to say you want a roller that can roll two different values.  Either [80C6C8CA] or [80C6C8CA + 38].  Yeah?

---

1) Regarding your conditions, remember to add 1 to the address of the if code to apply an end-if to the previous if.  This can help shorten your code too, Sharkbyte.

2) Your first line, 8400, actually *stores* grN, not load.  You actually want 8200 or 8000.

3) 8600 will add a value to a gr.  So if you used 8000 to load an address into grN, and then use 8600 to add 1, you actually added 1 to the address.  i.e. 8600 -> grN = grN + X

4) To add 1 to the value at the address in grN, use 8601.  [grN] = [grN] + X.  It's very important to understand the brackets mean "go to the address and get the value there".


Patedj

I noticed the brackets, I think the closed brackets  means the actual address and not the value. I might have flipped this around though...

So basically this will be applying an all around class change for an rpg. so I need both in the coding.. 1 condition that will allow me to change the class, and another condition that will allow me to change the next character, so I can change its class.

80000000 80C6C8CA  ---> load initial address
289ACA9C xxxxxxxx ---> condition A
86000000 00000001 ----> add 1 to [gn]
289ACA9C xxxxxxxx ----> condition B
86010000 FFFFFFFF ----> add -1 to [gn]
289ACA9D XXXXXXXX ---> condition C
86000000 00000038 ----> add 38 to gn
E0000000 80008000 --->release
84000000 80C6C8CA --->store gn to address
2c000000 00FFA400 ---> if address value is 0000a4xx (ignore the xx values because of the FF mask)
00C6C8CA 00000001 ---> then write/store to address (shouldn't this be grN)
2E000001 00FF0100 ---->if/end address value is 000001xx
00C6C8CA 000000A4 ---->then write/store to address (shouldn't this be grN)
E0000000 80008000

Is this right?
You can pm me, I've got time for your troubles.

dcx2

Oh, I think I see.

So you have multiple characters.  The first character's class lives at 80C6C8CA.  The next character's class is 0x38 beyond that, or 80C6C902.  And then 80C6C93A.  And so on.

You're approaching the level of complexity where it's impractical to use WiiRD code types instead of ASM.  I think I can make this work with regular code types but I'll need a bit to figure it out.  I've got some other stuff I'm working on.   But I will come back to this later today.

Patedj

My thoughts exactly, but since this is for a wiiware, ( even though it could be nice to have a template for normal wii games) I thought that asm isn't really plausible.
You can pm me, I've got time for your troubles.

dcx2

#6
Okay, you basically need two rollers.  You need to test for an uninitialized gr.  This will also require permanent control of that gr as well.

Since this will start to become very long, and this list of values is short, we will only increment the pointer.  This means we only have one condition to test after each roll.

We'll use gr3 for the pointer.  gr4 can be the temp register used to increment stuff.

# if gr3 < 80C6C8CA (i.e. initialize gr3)
# gr3 = 80C6C8CA
# end-if; if pointer-increment activator buttons
# gr3 += 0x38
# end if; if gr3 > UPPER_BOUND? (prevent over-roll)
# gr3 = 80C6C8CA
# terminator

# po = gr3
# gr4 = 16bits at [po]
# if class-increment activator buttons
# gr4 += 1;
# end if; if gr4 > UPPER_CLASS
# gr4 = LOWER_CLASS
# end-if (NOT TERMINATOR, which would reset po)
# 16 bits at [po] = gr4
# terminator

EDIT:

That's your basic template, let's see if you can make a code out of it.  Also, you'll need to provide values for UPPER_BOUND, UPPER_CLASS, and LOWER_CLASS as necessary.

Patedj

#7
Thank you oh wise one! I appreciate the challenge! This will be fun.
lower:80C6C8CA Upper: 80C6DD5A ([94(dec)*38(hex)]+80C6C8CA)

A6000000 0300C8CA
80000003 80C6C8CA
289ACA9C xxxxxxxx
86110003 00000038
A4000001 0300DD5A
80000003 80C6DD5A
E0000000 80008000

Lower class:1 Upperclass:A4
90010003 00000000
92110004 00000000
289ACA9C xxxxxxxx
90110004 00000001
A4000000 040000A4
90010004 00000001
E2000001 80C6C8CA
10000000 00000001
E0000000 80008000

Here's the first draft. No success
You can pm me, I've got time for your troubles.

dcx2

#8
You can't if a gr by its n.  You have to use its address directly.  Each gr is just a 4-byte word that was reserved by the code handler.  For the versions of the code handler that people use, gr0 = [80001808], or the value at address 80001808.  grn = [80001808 + n*4].  That means gr3 = [80001814] and gr4 = [80001818].

You must also *always* remember that if you start dropping terminates, that you must make METICULOUSLY count all the if codes and make sure they have matching end-if's.  I think for now you should keep using terminators until the code works and then try optimizing them out.

Finally, there are several places that you didn't use po quite right.  I think this is more like the code that you want.  I could still have made a mistake though

26001814 80C6C8CA # if gr3 < 80C6C8CA
80000003 80C6C8CA # gr3 = 80C6C8CA
289ACA9D xxxxxxxx # add 1 to address for end-if; if button activator
86000003 00000038 # gr3 += 0x38
24001815 80C6DD5A # end-if; if gr3 > 80C6DD5A
80000003 80C6C8CA # gr3 = 80C6C8CA
E0000000 80008000

4A001003 00000000 # po = gr3
92010004 00000000 # gr4 = 8 bits at [po] (this is 8-bit right?  oops)
289ACA9C xxxxxxxx # activator; does not require end-if!
86000004 00000001 # gr4 += 1
24001819 000000A4 # end-if; if gr4 > A4
80000004 00000001 # gr4 = 1
E2000001 00000000 # end-if; do not reset po
94010004 00000000 # 8-bits at [po] = gr4
E0000000 80008000 # terminator resets po

EDIT:

8600 instead of 8601 oops lol

Patedj

#9
dcx2, you're the best.

Here's the code!
Address Roller with value increment  v1. Explained (v2. will have - conditions without re-cycle)


26001814 Initial address (IA) # if gr3 < IA
80000003 IA # gr3 = IA
28REMOTE+1 xxxxxxxx # add 1 to address for end-if; if button activator
86000003 0000incr # gr3 += 0xhex increment needed for the other addresses
24001815 LAST Address (LA) # end-if; if gr3 > LA
80000003 IA # gr3 = IA so that you can re-cycle
E0000000 80008000

4A001003 00000000 # po = gr3
92010004 00000000 # gr4 = 8 bits at [po] (you can always make this 16/32 bytes)
28REMOTE xxxxxxxx # activator; does not require end-if!
86000004 0000INCR # gr4 += Increment added to value
24001819 0000XMAX # end-if; if gr4 > MAX
80000004 0000beginning # gr4 = beginning of value
E2000001 00000000 # end-if; do not reset po
94010004 00000000 # 8-bits at [po] = gr4
E0000000 80008000 # terminator resets po


V2.
26001814 Initial address (IA) # if gr3 < IA
80000003 IA # gr3 = IA
28REMOTE+1 xxxxxxxx # add 1 to address for end-if; if button activator
86000003 0000incr # gr3 += 0xhex increment needed for the other addresses
28REMOTE+1 xxxxxxxx # add 1 to address for end-if; if button activator
86000003 0000incr # gr3 += 0xhex increment needed for the other addresses in - value (FFFFFFFF - value)
24001815 LAST Address (LA) # if; if gr3 > LA
80000003 LA # gr3 = LA
26001815 IA # end-if; if gr4 > MIN
80000003 IA # gr3 = IA
E0000000 80008000

4A001003 00000000 # po = gr3
92010004 00000000 # gr4 = 8 bits at [po] (you can always make this 16/32 bytes)
28REMOTE xxxxxxxx # activator; does not require end-if!
86000004 0000INCR # gr4 += Increment added to value
28REMOTE xxxxxxxx # activator; does not require end-if!
86000004 0000INCR # gr4 += Increment added in - value (FFFFFFFF- value)
24001819 00000MAX # end if; if gr4 > MAX
80000004 00000MAX # gr4 = MAX value
26001819 00000MIN # end-if; if gr4 > MIN
80000004 00000MIN # gr4 = MIN value
E2000001 00000000 # end-if; do not reset po
94010004 00000000 # 8-bits at [po] = gr4
E0000000 80008000
You can pm me, I've got time for your troubles.

Patedj

#10
This needs an identifier.
Something like

gr4=po
if remote = value wanted
then put gr4 into address (unimportant or graphic address needed)(UA)
Terminate

00Address Value # Keeps address at initial value once the condition is over
28remote xxxxxxxx # if
84000003 Address #puts po into a desired address 8byte
E0000000 80008000

If only I could figure out how to replace the address increment as a dec.. hex if necessary so that address+increment = the number of times it incremented.

I can do this if there's a # that accompanies the character which is being modified. ie: gr3+another increment into gr5. put gr5 into UA when condition is true.

Something like this
04Address Value # Keeps address at initial value once the condition is over
28remote xxxxxxxx # if
4A001003 increment #set po gr3+increment
94110005 00000000 #store 32 bytes from the po into gr5
84000005  address # store gr5 into address
E0000000 80008000
You can pm me, I've got time for your troubles.

Nutmeg

Well, I'm not too sure what you are asking (sorry, I only had time to skim), but would the 66 codetype help.

You could set a loop and everytime the loop executes add 0x38 to the ba.  With this method however, you would need to write the same value to every address (on the 0x38 interval).  You could write different values, but it would be much more complex.

Sorry if that was a crappy post.  I only had time to skim. D:
I'm inbetween your legs... that's not awkward.

Patedj

Stop degrading your offers. You are worthy of thanks! I'm grateful. Goto (66) sounds like it should work. It does sound like guaranteed. Like you said, at every occurring shift looks like it should have 66 written with it.

I tried the alternative (see below) for Ogre Battle and it worked nicely. I imagine that this setting should work for every rpg. I believe that this could work for fighting games too.

If anyone uses this code please post the game you used it for. I'm curious to know if the code inspired anyone.

You can pm me, I've got time for your troubles.