How to make a roller in ASM?

Started by Bully@Wiiplaza, June 19, 2011, 06:45:24 PM

Previous topic - Next topic

dcx2

After reviewing your edit, I have two questions for you.

1) Why is the lwz r4 at the end unnecessary?

2) What is the meaning of 0: and 0f?

Once you confirm the code works, I'll help you optimize it.  This code could be two lines shorter than it is now.

EDIT:

btw can you change your first post title to "how to make a roller in ASM?" instead?

Bully@Wiiplaza

#16
Quote from: dcx2 on June 22, 2011, 04:53:04 PM
1) Why is the lwz r4 at the end unnecessary?
2) What is the meaning of 0: and 0f?
btw can you change your first post title to "how to make a roller in ASM?" instead?
1) Because we already have the value from r3 + 5344 in r4 due to the lwz at the beginning
2) ble- 0f = if less or equal branch to 0: (0f = false condition)
0: = true condition
3.) I edited the title to "How to make a roller in ASM?"
4.) I tried the code and it worked fine!
My Wii hacking site...
http://bullywiihacks.com/

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

~Bully

dcx2

#17
1) Yes, r4 has the value in it from the beginning.  If the activator is false, it still has that value in it.  If the activator is true, it gets rolled, and the rolled value is still in the right register, so there's still no need to lwz again.

2) No, 0f means "branch to the label 0 that is forward".  0b would mean "branch to the label 0 that is backward"

A label represented by a single digit, 0-9, can be re-used multiple times.  It is nice if you don't want to keep coming up with label names for simple branches.  Review the ASM roller source that I posted earlier and you'll see 0: is used twice.

EDIT: optimized.

lwz r4,5344(r3)        # original instruction
lis r12, 0x803A         # load r12 with half of button activator address
lhz r12, 0x1ACE(r12) # load r12 with the delta buttons
andi. r12, r12, 0x1000  # was - pressed?
beq- _NOTPRESSED  # if not, skip roll
subic. r4, r4, 1         # dec and compare against 0
bgt- 0f                   # if greater than 0, skip wrap
li r4,6                     # wrap around to 6
0:
stw   r4,5344(r3)      # store rolled value
_NOTPRESSED:

Bully@Wiiplaza

#18
perfectly done, man. I guess I understood how to do it now.
Also created a level roller. :)
http://www.geckocodes.org/?c=SMNE01
My Wii hacking site...
http://bullywiihacks.com/

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

~Bully