C0 codetype....

Started by Deathwolf, August 02, 2010, 03:05:10 PM

Previous topic - Next topic

Deathwolf

execute codetype?
how should this work without any hook address?
what does execute mean?
it only activate it, if you do someting?

C0000000 NNNNNNNN <--- how many instructions
ZZZZZZZZ ZZZZZZZZ<-- which instructions?
ZZZZZZZZ ZZZZZZZZ
4E800020 00000000 <-- blr 4E800020

thanks for any help
lolz

wiiztec

If there's any code at all that you want to be button activated, or even able to toggle on & off, and I have the game, just PM me and I'll make it happen

Deathwolf

can I use instruction from a C2 code on this?
lolz

dcx2

C2 codes hook the game (thus, the hook address).  C0 codes "hook" the code handler, so there's no hook address.

C2 codes have easy access to pointers because they hook while the game is running.  For instance, my Teleportation code has access to Mario's coordinates via the pointer in r3.  They are executed when the game would normally run the hook address.

C0 codes have no easy access to those pointers.  However, C0 codes have easy access to ba, po, and Gecko registers.  C0 codes are run like other codes (04, 28, etc); once per frame by the code handler.

PyiiASMH can assemble C0 codes for you, so you don't need to worry about including the blr, or how many instructions = NNNNNNNN.

Deathwolf

what happens if I do this?

C203CAE8 00000003
3D800000 618C0BB8
919F0030 807F0030
60000000 00000000

code:
lis r12,0
ori r12,r12,3000
stw r12,48(r31)
lwz r3,48(r31)

to C0

C0000000 00000003
3D800000 618C0BB8
919F0030 807F0030
4E800020 00000000

lis r12,0
ori r12,r12,3000
stw r12,48(r31)
lwz r3,48(r31)
blr


lolz

dcx2

Total Fail happens.  C2 codes have easy access to pointers because they hook while the game is running.

When the game is running and it executes instruction 8003CAE8, it just so happens that a useful pointer is in r31.

When the code handler is running and it executes your C0 code, r31 DOES NOT have this useful pointer!

Deathwolf

ohhh okay lol...

how should I write it now to get it worked in C0?
I've never done something like this.
Did you need more information?
lolz

dcx2

C2 codes and C0 codes are not generally interchangeable, even though they both use ASM.  C2 codes rely on the contents of the registers during the hook.  C0 codes never have access to those contents.

Most non-ASM WiiRD codes (04, 28, 4E, 86, etc) can be "ported" to C0 codes.  In some cases, this can make a complicated code shorter.

Deathwolf

#8
so okay I've tried around and got this.

0423EDD4 00000000


code:
.word 0xEDD4
.word 0xEDD4


to C0:
C0000000 00000001
EDD4EDD4 4E800020
lolz

dcx2

lol, no...you still use ASM codes, but they do the same things as WiiRD codes...

WiiRD ->

0423EDD4 00000000
0423ED64 00000000

---

C0 ->

lis r12,0x8023
ori r12,r12,0xED64
li r0,0
stw r0,0(r12)      # 0423ED64 00000000
stw r0,112(r12)      # 0423EDD4 00000000

---

C0 codes aren't really useful until you start getting epic WiiRD codes.  For example, my Mario Size Roller would probably be shorter if I ported it to C0.  http://wiird.l0nk.org/forum/index.php/topic,5791.msg54813.html#msg54813

Deathwolf

this is the code?

C0000000 00000003
3D808023 618CED64
38000000 900C0000
900C0070 4E800020
lolz

dcx2

That looks right but I can't test it because I don't have the game (I don't even know what game it's for)

Deathwolf

what do you mean with this?

lis r12,0x8023 <---- load into address 8023ED64
ori r12,r12,0xED64
li r0,0 <--- value
stw r0,0(r12)      # 0423ED64 00000000 <--- ???
stw r0,112(r12)      # 0423EDD4 00000000 <--- but what about this?

does it loads only in 8023ED64?
if yes, how to write more than one address into one C0 code?
thanks...
lolz

dcx2

Did you suddenly forget what stw does?

The code loads r12 with the first address to write to, 8023ED64.  Then it loads r0 with the value 0.  Then it writes r0 to 0(r12).  Then it writes r0 to 112(r12).  0x8023ED64 + 112 = 8023EDD4

Deathwolf

oh but I can't write every time the same value on different addresses...
is there maybe another way?
lolz