multiply gecko register's value at address

Started by Sharkbyte, July 27, 2011, 10:24:50 PM

Previous topic - Next topic

Sharkbyte

How would i multiply the value at the loaded gecko registers times 2 so that every value is times 2 and then store it back? I have tried this.

82200000 809F38B8
86A00000 40000000
84200000 809F38B8

I want all the values at 809F38B8 to always be double.

dcx2

That will double the float value at 809F38B8 every frame.

A better approach would be to find the write breakpoint which writes the float to 809F38B8.  Then I would hook that instruction and double it there.

dcx2

If I could, I would ban the code tag from existence...lol.

[spoiler=ahh, that's better...]
  289F38B8 00000100
  82200000 811A532C
  84200010 811AA3C8
  E0000000 80008000
  289F38B8 00000100
  82200000 811A5330
  84200010 811AA3CC
  E0000000 80008000
  289F38B8 00000100
  82200000 811A5334
  84200010 811AA3D0
  E0000000 80008000[/spoiler]

The first thing I would do is remove redundant if codes.

[spoiler]
  289F38B8 00000100
  82200000 811A532C
  84200010 811AA3C8
  82200000 811A5330
  84200010 811AA3CC
  82200000 811A5334
  84200010 811AA3D0
  E0000000 80008000[/spoiler]

Why are you using Y=1?  This will write to two consecutive 32-bit addresses, one of which is the next address you want to write to.  Assuming you meant Y=0, you could use memory copy code type 8A.

[spoiler]
  289F38B8 00000100
  80000000 811A532C
  8A000C0F 011AA3C8
  E0000000 80008000[/spoiler]

However, that's just a straight copy of 0xC bytes from 811A532C to ba+011AA3C8.  It doesn't do anything fancy like slider codes can.

For greater flexibility, you can roll-your-own-slider with the repeat code type 60.  This will copy po+011A532C to po+011AA3C8, then add 4 to po, and repeat that sequence two more times.  It's longer than the code above, but you can be much more creative with address and value increments using repeats.

[spoiler]
  289F38B8 00000100
  60000002 00000001
  92210000 011A532C
  94210010 011AA3C8
  4A100000 00000004
  62000000 00000001
  E0000000 80008000[/spoiler]

dcx2

#3
If you're using Gecko.NET 0.66 or newer with GCT Autosave checked, you can't lose codes.  Every code ever made will be stored in /codes/codeBackup.zip.

I'm not sure I understand what you're trying to do.  But the Set Repeat/Execute Repeat is basically a for loop.  The following two codes are functionally identical.

  289F38B8 00000100
  60000002 00000001

  92210000 011A532C
  94210010 011AA3C8
  4A100000 00000004

  62000000 00000001
  E0000000 80008000

---

  289F38B8 00000100

  92210000 011A532C
  94210010 011AA3C8
  4A100000 00000004

  92210000 011A532C
  94210010 011AA3C8
  4A100000 00000004

  92210000 011A532C
  94210010 011AA3C8
  4A100000 00000004

  E0000000 80008000

dcx2

There is very little that Gecko code types can't do, it's just a matter of knowing how to use them together.  ^_^

There are two ways to approach this.  First I'll use repeat, because it's the best way to do it.  Then I'll use a self-modifying code just for kicks.

---

Gecko Register Slider with Repeat codes

82200000 811A532C # gr0 = [811A532C]
60000008 00000001 # set repeat b1 the following 8 additional times
94210000 011AA3C8 # [po+011AA3C8] = gr0
4A100000 00000260 # po += 0x260
62000000 00000001 # execute repeat b1
E0000000 80008000 # terminator

---

Gecko Register Slider with Self-Modifying codes

82200000 811A532C # gr0 = [811A532C]
4E00000C 00000000 # po = address of slider code's X
94210000 00000000 # [po] = gr0
091AA3C8 00000000 # slider, addr = 811AA3C8, X = modified by 9421 above
20080260 00000000 # 32-bit, repeat 8 additional times, Z = 0x260
E0000000 80008000 # terminator

dcx2

#5
60/62 are the best way to do sliders, because you can create exotic address and value increments.  You can even do a 16-bit if code on the NNNN value in the associated block if you wanted to do something different for a particular iteration.

The 4E code puts the address of the 09 code's 00000000 into the po.  This allows the 9421 code to over-write the 00000000 with whatever you put into gr0.  This requires the po because you need to use all 32-bits of the po, whereas the ba really only lets you use the top 7 bits.

The 09 code is using the ba, so that's why it writes to 811AA3C8.

There are 8 or 16 blocks, I can't remember.  Each block is 64-bits (two words).  The first word is usually a pointer, the second word is the repeat counter.  I think blocks start with b0 at 80001848.  They're located right after the Gecko Registers (grF would then be 80001844).

grK just means a second Gecko Register.  You can't use grN again because it would be ambiguous.  For instance, grN = ( grN ? grK), for n = 2 and k = 3 and ? = *, means that gr2 = gr2 * gr3.

EDIT:

I should note that these addresses for the blocks and Gecko Registers assume 1.9.3.x code handlers.  Gecko OS Mod uses a very old code handler and I think they're all one byte backward (e.g. b0 = 80001844)

dcx2

I took this one step farther and made it a C0 ASM code.  I haven't tested it, but it should work.  I think you're allowed to use the CTR register in a C0 code.

C0000000 00000004
39600009 7D6903A6
3D80811A 618CA168
816CB1C4 956C0260
4200FFFC 4E800020



li r11,9      # get CTR set up for a loop
mtctr r11

lis r12,0x811A
ori r12,r12,0xA168   # r12 = pointer to destination - 0x260
lwz r11,-20028(r12)   # r11 = [811A532C]

_TOP_OF_LOOP:
stwu r11,0x260(r12)   # r12 += 0x260; [r12] = r11
bdnz+ _TOP_OF_LOOP   # ctr -= 1; if ctr > 0, branch to _TOP_OF_LOOP