Create ASM codes for "specific players"?

Started by Bully@Wiiplaza, September 18, 2010, 12:32:29 AM

Previous topic - Next topic

dcx2

@Sharkbyte - I'm going to use branch labels, so you may need to use PyiiASMH to convert this.  Others have had success with Link's ASMWiiRD converter.

cmpwi r19,3
beq- MOON_JUMP  # make player 4 moon jump
cmpwi r19,2
beq- MOON_JUMP  # make player 3 moon jump
cmpwi r19,1
beq- NO_MOON_JUMP  # player 2 gets normal jump
b NO_MOON_JUMP  # player 1 gets normal jump
MOON_JUMP:
lis r12,16752
stw r12,88(r26)
lfs f2,88(r26)
NO_MOON_JUMP:
stfs f2,88(r26)

Change the branch label next to the player you want to give or remove moon jump from.

dcx2

Nono, you should AVOID using hex values with branch displacements.  Read the post before the one addressed to you.  Calculating branch displacements by hand is tedious and error prone.

When a branch is taken, execution will "jump" over some instructions, and execution "lands" where the label is.  For instance, let's walk through the code and pretend that r19 has a 1 in it.  The bold instructions will be executed; the non-bold instructions will be skipped over.

cmpwi r19,3  # is r19 == 3?
beq- MOON_JUMP  # no; branch not taken; go to next instruction
cmpwi r19,2  # is r19 == 3?
beq- MOON_JUMP  # no; branch not taken; go to next instruction
cmpwi r19,1  # is r19 == 1?
beq- NO_MOON_JUMP  # yes!  branch taken; go to instruction after NO_MOON_JUMP!

| b NO_MOON_JUMP  # these instructions are skipped
| MOON_JUMP:  # these instructions are skipped
| lis r12,16752  # these instructions are skipped
| stw r12,88(r26)  # these instructions are skipped
v lfs f2,88(r26)  # these instructions are skipped

NO_MOON_JUMP:
stfs f2,88(r26)



Let's look at if r19 == 3

cmpwi r19,3  # is r19 == 3?
beq- MOON_JUMP  # yes!  branch taken; go to instruction after MOON_JUMP!

| cmpwi r19,2  # is r19 == 3?  # these instructions are skipped
| beq- MOON_JUMP  # these instructions are skipped
| cmpwi r19,1  # these instructions are skipped
| beq- NO_MOON_JUMP  # these instructions are skipped
v b NO_MOON_JUMP  # these instructions are skipped

MOON_JUMP:
lis r12,16752  # load your new float
stw r12,88(r26)  # store it to memory
lfs f2,88(r26)  # make sure the new float is also in f2!
NO_MOON_JUMP:
stfs f2,88(r26)  # this is unnecessary because the value is already there, but it won't hurt


---

The beauty of the branch labels...if you want to give only player 1 moon jump, make everyone else's branch label NO_MOON_JUMP.  If you want everyone but player 1 to have moon jump, give him NO_MOON_JUMP and everyone else MOON_JUMP.  Just change the branch labels and the assembler will do all the hard work for you.

Bully@Wiiplaza

Quote from: dcx2 on October 10, 2010, 12:05:35 AM

THE_END is a branch label.  When a branch is taken, execution will "jump" over some instructions, and execution "lands" where the label is.  This allows us to "skip" the li r0,0 if we are hurting an enemy OR if we are healing the player.  For instance, the assembled code is

C23CB648 00000004
2C050000 40820010
2C000000 40800008
38000000 7C030215
60000000 00000000

If you run that backwards through PyiiASMH, you get


cmpwi r5,0
bne- 0x0010
cmpwi r0,0
bge- 0x0010
li r0,0
add. r0,r3,r0


refering to that, it is working like charme.
Thx for letting me know the branch label stuff.
If you need help with anything, don´t hesitate to PM me (if I can help you there)
My Wii hacking site...
http://bullywiihacks.com/

My youtube account with a lot of hacking videos...
http://www.youtube.com/user/BullyWiiPlaza

~Bully

Bully@Wiiplaza

#33
... I am stuck again. :(

[spoiler]Breakpoint Execute: 803B7648

If the player does something....

 CR:44000000  XER:00000000  CTR:00000004 DSIS:00000000
DAR:00000000 SRR0:803B7648 SRR1:00009032   LR:803B75F0
 r0:0000001E   r1:80F66328   r2:80648600   r3:00000000
 r4:92485320   r5:92485320   r6:00000000   r7:00000000
 r8:00000000   r9:00000000  r10:92488060  r11:80F66328
r12:803B6AA8  r13:806452C0  r14:00000008  r15:00000002
r16:00000000  r17:00000004  r18:00000000  r19:00000004
r20:00000000  r21:92482F00  r22:92485320  r23:00000001


If an enemy does something...

 CR:44000000  XER:00000000  CTR:00000002 DSIS:00000000
DAR:00000000 SRR0:803B7648 SRR1:00009032   LR:803B75F0
 r0:00000004   r1:80F66328   r2:80648600   r3:00000002
 r4:924853E2   r5:92485360   r6:00000001   r7:00000002
 r8:00000000   r9:00000000  r10:91C8E1D4  r11:80F66328
r12:803B6AA8  r13:806452C0  r14:00000008  r15:00000002
r16:00000000  r17:00000004  r18:00000000  r19:00000004
r20:00000000  r21:92482F00  r22:92485320  r23:00000001

803B7648:  7C170050   sub   r0,r0,r23
803B764C:  98042D6C   stb   r0,11628(r4)
803B7650:  4800000C   b   0x803b765c
803B7654:  38000000   li   r0,0
803B7658:  98042D6C   stb   r0,11628(r4)[/spoiler]

Let´s say that r6 is the right register for the compares.

My code should do the following:

If r6 is 0
nop the instruction (sub r0,r0,r23)
if it´s not 0, go to the next line
if r6 is 1
load immediate r0 with a value of 0 and do
sub r0,r0,r23
the end

-> this code should allow me infinite "attacks" , but when my enemy attacks, they go to 0 and ran out next time.

my attemps:
[spoiler]
cmpwi r6, 0
beq- NOP
cmpwi r6, 1
beq- NO_AP
NOP:
nop
NO_AP:
li r0, 0
sub r0, r0, r23
[/spoiler]
My Wii hacking site...
http://bullywiihacks.com/

My youtube account with a lot of hacking videos...
http://www.youtube.com/user/BullyWiiPlaza

~Bully

Y.S.

Quotecmpwi r6, 0
beq- NOP
cmpwi r6, 1
beq- NO_AP
NOP:
nop
NO_AP:
li r0, 0
sub r0, r0, r23

In the code you made, instructions after NO_AP: will be executed regardless of r6 :(
If you want to give infinite attacks to the player, and finite attacks to enemies,  the code would be like this:

cmpwi r6, 1
bne- _end
sub r0, r0, r23
_end:


Bully@Wiiplaza

#35
cmpwi r6, 1
bne- _end
sub r0, r0, r23
_end:

wait, the code should give the player infinite attacks and the opponnent 0 (li r0,0 in this case) !
How would it look like then?
My Wii hacking site...
http://bullywiihacks.com/

My youtube account with a lot of hacking videos...
http://www.youtube.com/user/BullyWiiPlaza

~Bully

Y.S.

Quote from: Bully@Wiiplaza on October 31, 2010, 11:40:09 AM
the code should give the player infinite attacks and the opponnent 0 (li r0,0 in this case) !

Okay, then the code becomes:
cmpwi r6, 1
bne- _end
li r0,0
_end:

dcx2

In the case where r6 is 0, it will branch over the instruction, effectively "doing nothing".  You don't need to manually insert a nop.

Note that this is a special case where the anti-code (sub r0,r0,r23) is not required to be in the code.  Normally we are very careful to include the anti-code.  However, the destination register rD of the anti-code is r0, so as long as r0 has a valid value in it by the end of the code, it won't crash.  If r6 is 0, the value in r0 is unchanged (i.e. no more sub -> infinite player attacks).  If r6 is 1, the value in r0 becomes 0 (i.e. li replaces sub -> zero enemy attacks)

Bully@Wiiplaza

yes nice work :)
does his job properly.
[spoiler]
C23B7648 00000002
2C060001 40820008
38000000 00000000
[/spoiler]
My Wii hacking site...
http://bullywiihacks.com/

My youtube account with a lot of hacking videos...
http://www.youtube.com/user/BullyWiiPlaza

~Bully

Bully@Wiiplaza

another game:

[spoiler]player attacks and hurts the enemy:

  CR:44004488  XER:00000000  CTR:80096060 DSIS:02400000
DAR:80D6039C SRR0:8009606C SRR1:0000B032   LR:80083214
  r0:00000001   r1:8049A4E8   r2:8048FA20   r3:80D603C4
  r4:00000002   r5:0001005F   r6:803778FC   r7:00000005
  r8:00000000   r9:803A21F0  r10:80499FE4  r11:FFFFFFFF
r12:80096060  r13:8048BDA0  r14:00000008  r15:8049A5F0
r16:00000001  r17:00000001  r18:80375038  r19:80373D00
r20:8036F2F0  r21:00000002  r22:00000002  r23:80320000
r24:80318CBC  r25:00000003  r26:00000000  r27:80318C80
r28:80D49914  r29:80C65064  r30:80C2A864  r31:0000000F

enemy attacks, hurts the player:

  CR:44004488  XER:00000000  CTR:80096060 DSIS:02400000
DAR:80D6039C SRR0:8009606C SRR1:0000B032   LR:80083214
  r0:00000001   r1:8049A4E8   r2:8048FA20   r3:80D603C4
  r4:800E08D8   r5:00000000   r6:00000001   r7:00001479
  r8:D9900051   r9:00001479  r10:D9900051  r11:8049A398
r12:80096060  r13:8048BDA0  r14:00000008  r15:8049A5F0
r16:00000000  r17:00000000  r18:80375038  r19:80373D00
r20:8036F2F0  r21:00000002  r22:00000002  r23:80320000
r24:80318CBC  r25:00000003  r26:00000000  r27:80318C80
r28:80D49914  r29:80C65064  r30:80C2A864  r31:0000000F[/spoiler]

8009606C: stfs f1,8(r3) -> Health instruction

r17 seems to be a good candidate... it always matched to the players pattern above.


cmpwi r17, 1
bne- _end
stfs f1,8(r3)
_end:

C209606C 00000002
2C110001 40820008
D0230008 00000000


this code should give the player infinite health and the enemy normal health, but somehow the code makes both players invincible even with the bne in it... but why? :eek:
My Wii hacking site...
http://bullywiihacks.com/

My youtube account with a lot of hacking videos...
http://www.youtube.com/user/BullyWiiPlaza

~Bully