Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 366
» Latest member: jawa
» Forum threads: 1,320
» Forum posts: 6,650

Full Statistics

Online Users
There are currently 94 online users.
» 2 Member(s) | 90 Guest(s)
Bing, Google, BlueStreak

Latest Threads
Position Graphic Modifier...
Forum: Visual & Sound Effects
Last Post: 1superchip
Yesterday, 01:39 AM
» Replies: 0
» Views: 65
How to bypass ANY ban on ...
Forum: Other
Last Post: Dorian
04-13-2021, 02:00 AM
» Replies: 7
» Views: 3,464
Make it to 10,000
Forum: General Discussion
Last Post: Mewmaster99
04-12-2021, 08:16 PM
» Replies: 1,761
» Views: 447,760
How would download a file...
Forum: Hacking General Discussion
Last Post: Vega
04-11-2021, 11:26 PM
» Replies: 1
» Views: 81
How would I copy a file t...
Forum: Hacking General Discussion
Last Post: jawa
04-11-2021, 05:03 PM
» Replies: 2
» Views: 199
Replace/Edit Bootstrap Sc...
Forum: Other
Last Post: HackerCop
04-10-2021, 03:34 PM
» Replies: 1
» Views: 2,484
VS Points Based on Finish...
Forum: Online Non-Item
Last Post: WhatisLoaf
04-10-2021, 02:11 PM
» Replies: 1
» Views: 148
CC Tracker [JoshuaMK]
Forum: Misc/Other
Last Post: Vega
04-08-2021, 08:58 PM
» Replies: 8
» Views: 3,673
Check if Time Trials [Jos...
Forum: Misc/Other
Last Post: 1superchip
04-07-2021, 04:20 PM
» Replies: 7
» Views: 3,027
Golden Length Modifier [1...
Forum: Offline; Item
Last Post: 1superchip
04-07-2021, 12:49 AM
» Replies: 0
» Views: 184

 
  Customizable Scorestreaks [TheNinjaKingOW and Vega]
Posted by: TheNinjaKingOW - 02-10-2021, 08:42 PM - Forum: Offline; Item - Replies (11)

The code will give players items based on how many players you hit. Your streak will reset if you are hit by an item.

NTSC-U:
c258B0D8 00000003
9004000c 3d808000
39600000 996c01b0
60000000 00000000
c258B0B4 00000003
90040008 3d808000
896c01b0 396b0001
996c01b0 00000000
C27E4B88 00000014
2C1F0000 40820094
3D808000 898C01B0
2C0C0003 39600001
38000002 41820074
2C0C0005 39600001
38000003 41820064
2C0C0008 39600003
38000010 41820054
2C0C000C 39600003
38000011 41820044
2C0C000F 39600001
38000009 41820034
2C0C0012 39600001
3800000B 41820024
2C0C0015 39600001
38000007 41820014
2C0C0019 39600001
38000008 40A2000C
91640090 9004008C
8004008C 00000000
c252E968 00000003
38000001 3d808000
618c01b0 39600000
996c0000 00000000

PAL:
c25918FC 00000003
9004000c 3d808000
39600000 996c01b0
60000000 00000000
c258B0B4 00000003
90040008 3d808000
896c01b0 396b0001
996c01b0 00000000
C27EEE98 00000014
2C1F0000 40820094
3D808000 898C01B0
2C0C0003 39600001
38000002 41820074
2C0C0005 39600001
38000003 41820064
2C0C0008 39600003
38000010 41820054
2C0C000C 39600003
38000011 41820044
2C0C000F 39600001
38000009 41820034
2C0C0012 39600001
3800000B 41820024
2C0C0015 39600001
38000007 41820014
2C0C0019 39600001
38000008 40A2000C
91640090 9004008C
8004008C 00000000
c25334B0 00000003
38000001 3d808000
618c01b0 39600000
996c0000 00000000

NTSC-J:
c259127C 00000003
9004000c 3d808000
39600000 996c01b0
60000000 00000000
c2591258 00000003
90040008 3d808000
896c01b0 396b0001
996c01b0 00000000
C27EE504 00000014
2C1F0000 40820094
3D808000 898C01B0
2C0C0003 39600001
38000002 41820074
2C0C0005 39600001
38000003 41820064
2C0C0008 39600003
38000010 41820054
2C0C000C 39600003
38000011 41820044
2C0C000F 39600001
38000009 41820034
2C0C0012 39600001
3800000B 41820024
2C0C0015 39600001
38000007 41820014
2C0C0019 39600001
38000008 40A2000C
91640090 9004008C
8004008C 00000000
c2532E30 00000003
38000001 3d808000
618c01b0 39600000
996c0000 00000000

NTSC-K:
c257F954 00000003
9004000c 3d808000
39600000 996c01b0
60000000 00000000
c257F930 00000003
90040008 3d808000
896c01b0 396b0001
996c01b0 00000000
C27DD258 00000014
2C1F0000 40820094
3D808000 898C01B0
2C0C0003 39600001
38000002 41820074
2C0C0005 39600001
38000003 41820064
2C0C0008 39600003
38000010 41820054
2C0C000C 39600003
38000011 41820044
2C0C000F 39600001
38000009 41820034
2C0C0012 39600001
3800000B 41820024
2C0C0015 39600001
38000007 41820014
2C0C0019 39600001
38000008 40A2000C
91640090 9004008C
8004008C 00000000
c2521508 00000003
38000001 3d808000
618c01b0 39600000
996c0000 00000000

Reset Score if hit

Code:
loc_0x0:
  stw r0, 12(r4)
  lis r12, 0x8000
  li r11, 0x0
  stb r11, 432(r12)




Add point to score if you hit a player
Code:
loc_0x0:
  stw r0, 8(r4)
  lis r12, 0x8000
  lbz r11, 432(r12)
  addi r11, r11, 0x1
  stb r11, 432(r12)




Scorestreak Table
Code:
start:
  lis r12, 0x8000
  lbz r12, 432(r12)

  cmpwi r12, 0x3 #Item 1
  li r11, 0x1
  li r0, 0x2
  beq- store_to_mem

  cmpwi r12, 0x5 #Item 2
  li r11, 0x1
  li r0, 0x3
  beq- store_to_mem

  cmpwi r12, 0x8 #Item 3
  li r11, 0x3
  li r0, 0x10
  beq- store_to_mem
 
  cmpwi r12, 0xC #Item 4
  li r11, 0x3
  li r0, 0x11
  beq- store_to_mem

  cmpwi r12, 0xF #Item 5
  li r11, 0x1
  li r0, 0x9
  beq- store_to_mem

  cmpwi r12, 0x12 #Item 6
  li r11, 0x1
  li r0, 0xB
  beq- store_to_mem

  cmpwi r12, 0x15 #Item 7
  li r11, 0x1
  li r0, 0x7
  beq- store_to_mem

  cmpwi r12, 0x19 #Item 8
  li r11, 0x1
  li r0, 0x8
  bne+ end

store_to_mem:
  stw r11, 144(r4)
  stw r0, 140(r4)

end:




Reset value to 0 if race countdown occurs (if the value you had of the previous race is kept as the same score as a scorestreak, you will start with an item)
Code:
loc_0x0:
  li r0, 0x1
  lis r12, 0x8000
  ori r12, r12, 0x1B0
  li r11, 0x0
  stb r11, 0(r12)

Print this item

  Process Invalid Arena ID Vote [CLF78]
Posted by: CLF78 - 02-10-2021, 03:31 PM - Forum: Online Non-Item - No Replies

Same as the track version, but for battle mode.

NTSC-U
04612F38 60000000

PAL
04644358 60000000

NTSC-J
046439C4 60000000

NTSC-K
04632670 60000000

Notes:
- If you or someone else picks an invalid arena id, your game will not hang.
- The selected arena's name will be blank.

Code created by: CLF78

Print this item

  Just signed up!
Posted by: WiiHx4d - 02-07-2021, 10:47 PM - Forum: Introductions - Replies (6)

Hi All,
   Softmodded an old Red Wii. Now I'm here learning more.
Shy

Print this item

  New Speedometer that works for Dolphin and doesn't go on a pink screen?
Posted by: snjy - 02-05-2021, 10:27 PM - Forum: Code Support / Help / Requests - Replies (1)

Kind of said everything in the title, but if someone made this or linked one, they would be a lifesaver! I tried Vega's but it went on a pink screen the whole race, probs because it was on the outdated section. Big Grin Big Grin Big Grin

Print this item

  Mega Mushroom Increased FOV [TheLordScruffy]
Posted by: TheLordScruffy - 02-02-2021, 11:23 PM - Forum: Visual & Sound Effects - No Replies

Mega Mushroom Increased FOV [TheLordScruffy]

This code increases the field of view when a Mega Mushroom is used, making it possible to see where you're driving.


NTSC-U
C2572B48 00000006
809C0000 83A40024
2C1D0000 4182001C
80640004 8063000C
54630421 4182000C
3C0041F0 901D0120
60000000 00000000

NTSC-J
C2578D2C 00000006
809C0000 83A40024
2C1D0000 4182001C
80640004 8063000C
54630421 4182000C
3C0041F0 901D0120
60000000 00000000

PAL
C25793AC 00000006
809C0000 83A40024
2C1D0000 4182001C
80640004 8063000C
54630421 4182000C
3C0041F0 901D0120
60000000 00000000

NTSC-K
C2567404 00000006
809C0000 83A40024
2C1D0000 4182001C
80640004 8063000C
54630421 4182000C
3C0041F0 901D0120
60000000 00000000

Print this item

  Code Request
Posted by: ZOOM - 02-02-2021, 06:06 AM - Forum: Code Support / Help / Requests - Replies (6)

I've been working on tasing for about a month now, and I could never find a working Infinite Mushrooms gecko code for TT's. If anyone could help give me a code that could help me with this, or even direct me towards an already existing one, that would be much appreciated. Thanks!

Print this item

  (Request) Line Tracer for Time Trials
Posted by: saturn - 02-01-2021, 11:04 PM - Forum: Code Support / Help / Requests - No Replies

I'd like to request a code that would be very helpful for Time Trials. I call this concept "Line Tracer".



A colored line would trace the player's/ghost's XYZ position. Something like this already exists in the game, but the tracer line (colored light blue) only appears during fliptricks.


[Image: iniAQOd.png]


Theoretically, if this line was active for the whole race, we could see the exact driving lines the player took during the race. This would bring a lot of value to Time Trialers, giving a great visualization of their driving.

For visual clarity, this line should be more opaque (like 80-90%). Ideally, the line's color would change every lap (Red on Lap 1, Green on Lap 2, Blue on Lap 3) but I'm not sure if that's possible.


Thanks in advance.

Print this item

  Load Any Data Save [Vega]
Posted by: Vega - 02-01-2021, 01:11 AM - Forum: Misc/Other - Replies (2)

Load Any Data Save [Vega]

This code will allow you to load any data save to play on without having to change disc/iso. Everything works: your unlocks, TT records, wifi info, etc. I added in my 'Disable Data Save Region ID Check' Code or else you will get a prompt about changed Country/Region Settings blocking you from playing.

XXXX values (ASCII):
American Data Save = 3435
PAL Data Save = 3530
Japanese Data Save = 3461
Korean Data Save = 3462

NTSC-U
0228A756 0000XXXX
0453F3EC 7C601B78

PAL
0228EA96 0000XXXX
04544928 7C601B78

NTSC-J
0228E436 0000XXXX
045442A8 7C601B78

NTSC-K
0227CA96 0000XXXX
04532980 7C601B78

Source:
16 bit write: XXXX overwrites the two ASCII bytes that is the file path used by NANDOpen
32 bit write: 'rlwinm r0,r0,20,28,31' instruction changed to 'mr r0, r3' #Tell game Region ID's are a match

Code creator: Vega

Print this item

  Working with Floats
Posted by: Vega - 01-30-2021, 10:17 PM - Forum: Power PC Assembly - No Replies

Working with Floats

Beginner or Intermediate ASM coders may have not done any work on Floating Points yet or very little. This thread will cover some basics of working with floats.



Chapter 1: Fundamentals

There are 32 floating point registers aka fpr's (f0 thru f31). Floating point values in the fpr's are displayed in their 64-bit (double-word) hexadecimal form. The float values can either used as single precision or double precision. Single precision floats will have less accuracy, but they only take up a word of space when residing in memory (in their 32 bit hexadecimal form). Double precision floats are for precise work, but at a cost with taking two words of space in memory.

When a fpr value is stored to memory as single precision, its hexadecimal 32 bit (word) converted value is what gets stored. When a fpr value is stored to memory as double precision, what you see in the fpr register is what gets exactly stored to memory (double word)

Example of a Single Precision float in an fpr

Code:
40B3880000000000 #Converted to decimal = 5000

If this fpr value was stored to memory (converted to its 32 bit form), it will show a word value of 0x459C4000.

Question:
How do I tell if a fpr value is in single precision?

Answer:
If the last 7 digits of the fpr is null while the first digit of the second 32 bit segment is an even hex number (0,2,4,6,8,a,c,e), then the value is in single precision. See the guide below...

Code:
Guide:
XXXXXXXXY0000000

XXXXXXXXY = The value in fpr while Y is an even hex digit

Lets look at an example of a Double Precision float in an fpr...

Code:
40B3880B8723A502 #Converted to decimal = 5000.045030811105

If you took this fpr value and stored it to memory as double precision, it store as a doubleword hexadecimal value of 0x40B3880B8723A502 (what you exactly see in the fpr).

Remember when I said double precision is used to maintain high accuracy? Well, if you were to take this double precision float value from its fpr and store it to memory as single precision, it would store as 0x459C405C.

Convert 0x459C405C to decimal and you get 5000.0449. Accuracy is now off by more than 0.0001!

You will notice that there is a entirely separate second 64 bit segment in each fpr. For now we will not cover this second 64 bit segment as that deals with what's called 'Paired Singles'. Float instructions (that are NOT paired single instructions) only use the first 64 bit segment. Paired Singles are any instructions that have the first two letters of 'ps' it its instruction operand.

You will need a good 32 bit and 64 bit float converter. Here's a 64 bit converter (only allows one way converting. ie: 64bit float -> 32bit float & decimal)...

https://babbage.cs.qc.cuny.edu/IEEE-754.old/64bit.html

The converter is handy if you need to take the 64 bit value of a floating point register and find out what word value it would be if it was stored to memory as single precision.

Also here's a 32 bit float converter, obviously this can only be used for single precision. (Allows both ways of conversion for single precision 32-bit float to/from decimal)

https://www.h-schmidt.net/FloatConverter/IEEE754.html

Question:
How do I know which precision to use?

Answer:
Use the precision that corresponds to the default instruction of your code address. Both single precision and double precision instructions will be covered in the next chapters, showing you how to tell the difference between the two.

FYI:
Aldelaro's Dolphin-memory-engine comes with options to search for floats. You can only search using a decimal represent to look for single precision 32-bit float values in memory (word values).



Chapter 2: Storing/Loading

Here are the two basic instructions for loading and storing floating points.

stfs fD, VALUE (rA) #NOTE use stfd for double precision

This will store the float word value was single precision to the memory address calculated by VALUE+rA. VALUE (the offset) is signed.

lfs fD, VALUE (rA) #NOTE: use lfd for double precision

This will load the float word value as single precision from the memory address calculated by VALUE+rA and store it in fD. VALUE (the offset) is signed.

Let's look at example where you have a single precision loading float instruction 'lfs f2, 0x20 (r5)', and you want to manually modify the value that gets loaded into f2.

#rX = Whatever is a safe register for use in your code

Code:
lis rX, 0x4201 #Single precision float value for decimal value of 32.3
ori rX, rX, 0x3333
stfs rX, 0x20 (r5) #Write over what's going to be loaded from memory
lfs f2, 0x20 (r5) #Now load it; default instruction

If you are working with a double precision loading float instruction, it's gonna require a bit more work. Let's say our default instruction is lfd f3, 0x64 (r30).

WWWWXXXXYYYYZZZZ = Desired manually written 64 bit double precision float value

Code:
lis rX, 0xWWWW #Set upper 32 bits
ori rX, rX, 0xXXXX
stw rX, 0x64 (r30) #Store upper bits
lis rX, 0xYYYY #Set lower 32 bits
ori rX, rX, 0xZZZZ
stw rX, 0x68 (r30) #Store lower bits, Remember we have to increment the address by 0x4, due to double word value in memory
lfd f3, 0x64 (r30) #Default instruction



Chapter 3: Basic Math plus other instructions

There's a lot more math-based instructions for floats than compared to integers in Broadway PPC.

Important NOTE for all instructions listed in this chapter EXCEPT for 'fmr', 'fneg', and 'frsp': to have the instruction as double precision remove the final 's' from the instruction operand. Example: fadds -> fadd

fadds fD, fA, fB #Adds single precision values of fA and fB, result is written to fD.

fmuls fD, fA, fB #Multiplies the single precision values of fA and fB, result written to fD.

fsubs fD, fA, fB #fA minus fb = fD. 

fdivs fD, fA, fB #fA / fB = fD.

---

Need to copy a value from floating point register to another? Simple.

fmr fD, fA #fA's value is copied to fD

Need to flip a positive value to be negative, or vice versa? Easy to do.

fneg fD, fA #fA's value is flipped and result is written to fD.

Need to make any possible negative results positive (their absolute value); easy peasy

fabs fD, fA #The absolute value of fA is placed in fD

Need to do the opposite of that (ngeative absolute), say no more

fnabs fD, fA #The negative absolute value of fA is placed in fD

Gotta round the float to its single precision value? Here ya go

frsp fD, fA #The rounded single precision value of fA is placed in fD



Chapter 4: Float Comparisons

What if we need to do some comparison work with floats? Its similar to integer or GPR comparisons, but requires some extra work.

Floating Compare Ordered

fcmpo crf, fD, fA

This will do a comparison of fD vs fA. crf = the Condition Field within the Condition Register that will be used. For more details of the Condition Register and CR fields view this thread HERE.

You need to specify the condition field. For basic Wii code usage, cr1 is what you want to use.

Examples:

Code:
#Compare f1 vs f2, if equal then branch. The branch is less likely to occur
fcmpo cr1, f1, f2
beq- cr1, some_label

Code:
#Compare f0 vs f30, if f0 is greater than f30, branch. The branch is most likely to occur
fcmpo cr1, f0, f30
bgt+ cr1, some_label

It's important to note that there's no such thing as logical vs signed when it comes to floating comparisons. Bit 0 of the floating point value will let you know if a value is positive or not. Here's a snippet of source that checks if a float is negative~

Code:
#Example that assumes f13 is safe, and you want to check if f7 is negative, adjust which registers to use for your code
fsub f13, f13, f13 #Subtract f13 by itself to make it zero
fcmpo cr1, f7, f13 #Now check f7's value against zero; place desired branch below

Another note: There's another different type of floating compare instruction, its is fcmpu. fcmpu = floating compared unordered. To my limited knowledge, this does a 'faster' comparison which can make it less accurate. For Wii codes, it is futile to be concerned with saving speed. Use the ordered comparison to always ensure accuracy.



Chapter 5: Conversions

Do you need a convert a value in an fpr to an integer value? There's an entire separate thread covering that - https://mkwii.com/showthread.php?tid=967

Do you need to convert an integer value to it's fpr value? Here's a snippet of code to do that (thank you salmon01)~

Code:
#r3 holds your integer value to convert, result will be placed into f1.
#This code assumes r3, r4, f1, and f2 are all safe. Adjust choosing which registers to use accordingly for your code's safety requirements
lis r4, 0x4330
stw r4, -0x8 (r1)
lis r4, 0x8000
stw r4, -0x4 (r1)
lfd f2, -0x8 (r1) # load magic double into f2
xoris r3, r3, 0x8000 # flip sign bit
stw r3, -0x4 (r1) # store lower half (upper half already stored)
lfd f1, -0x8 (r1)
fsub f1, f1, f2 # complete conversion

^Due to not being able to set fractional integer values in the GPRs, the result will always safe to use as single precision in memory if needed.



Chapter 6: Paired Singles

For advanced coders only, provided here for the rare case somebody needs it.

Remember that second 64 bit segment that was mentioned at the beginning of the thread? That deals with paired singles. Paired singles are just two single precision floats that can be manipulated simultaneously.

The first 64 bit segment of the fpr is the first paired single. And the second 64 bit segment is the second paired single. Paired singles are ALWAYS single precision!

If a paired single is stored to memory, both single precision floats are converted to their hexadecimal word value and stored to memory as a double word.

Example~

Code:
C06C800000000000 4170000000000000 is the value in the fpr


When written to memory, it will have a double word value of 0xC36400004B800000.

WiiBrew has a great article covering Paired Singles along with a list of instructions - http://wiibrew.org/wiki/Paired_single

Regarding the W and I values from the article: Use what your default instruction uses.
Regarding ps0 and ps1: ps0 = first 64 bit segment of fpr. ps1 = second 64 bit segment

Happy coding!

Print this item

  More Info about Comparisons and Branches
Posted by: Vega - 01-30-2021, 09:53 PM - Forum: Power PC Assembly - No Replies

More Info about Comparisons and Branches

I was getting some messages recently from new ASM learners who were still confused about logical and signed values when it comes to comparison + branches. This thread will also dive into great detail about the condition register, CR fields, and what comparison instructions actually do.

First understand that cmpw and cmpwi are used for signed value comparisons. While cmplw and cmplwi are for logical/unsigned value comparisons. Refer back to the Assembly Tutorial HERE if needed.

Signed 16 bit range for cmpwi: 0xFFFF8000 thru 0x7FFF (-32768 thru 32767)
Logical 16 bit range for cmpwi: 0x0000 thru 0xFFFF (0 thru 65535)

Examples~

Code:
cmpwi r3, 0x1388 #This is valid
cmpwi r3, 0x24C00 #This is NOT valid

Code:
cmplwi r3, 40000 #This is valid
cmplwi r3, -1 #This is NOT valid

If you need to work with numbers outside of these ranges (or work with values exceeding 16 bits), you must set the value in a register then do a register vs register (cmpw/cmplw) comparison.

Examples~

Code:
#Do a signed comparison or r3 against the value of 0x80000000 (placed in r5)
lis r5, 0x8000
cmpw r3, r5

Code:
#Do a logical comparison of r3 against the value of 0x8055EF68 (placed in r5)
lis r5, 0x8055
ori r5, r5, 0xEF68
cmplw r3, r5



Now that you understand the range of signed and logical values in using comparison instructions, its a good thing to know that if your branch instruction that's after your comparison is a beq (branch if equal) or bne (branch if not equal), then your comparison can be logical or signed, it doesn't matter as long as you still follow the rules for the number ranges. This is because you are only checking if values are a match, whether or not said values are logical or signed doesn't effect this match.

Example~

Code:
lis r5, 0x8000
cmpw r3, r5
bne- some_label

will execute the exact same as...

Code:
lis r5, 0x8000
cmplw r3, r5
bne- some_label

and...

Code:
lis r5, 0x8055
ori r5, r5, 0xEF68
cmplw r3, r5
beq- some_label

will execute the exact same as...

Code:
lis r5, 0x8055
ori r5, r5, 0xEF68
cmpw r3, r5
beq- some_label



When it comes to any branch instructions that involve a 'greater/lesser' (bgt, bge, blt, and ble), you need to be sure your comparison is the correct type (signed vs logical) or else your branch might execute differently than what you are expecting.

Let's say your code loads a word value from memory into r3, and you want to check said value against what you have in r4. If r3 is less than r4, we want a branch to be taken. Look at the following sources below. Also, let's pretend r3 ended up with a value of -10 while r4 has a value of 10.

Code:
lwz r3, 0 (r5) #r5 is some pointer to memory where our r3 value is located
cmpw r3, r4 #Compare r3 (-10) to r4 (10)
blt- some_label

^The above source is correct. Since r3 vs r4 was a signed comparison, r3 was treated as a negative value (-10) and is thus less than r4 (10), so the branch will be taken. Let's observe an incorrect source..

Code:
lwz r3, 0 (r5)
cmplw r3, r4
blt- some_label

^This would be incorrect, The comparison was done logically which will treat r3 as a positive value. Remember your decimal to hex conversion. r3 is -10 which in hex the register value will be 0xFFFFFFF6. The hex value in r4 (10) is 0x0000000A. 0xFFFFFFF6 is greater than 0x00000000A (when numbers are treated logically), so this will cause the branch to NOT be taken, which is not what we wanted.



What Comparison Instructions actually do:

NOTE: This section may be a bit overwhelming for the beginner ASM coder, you don't really need to understand this unless you are making some complex codes.

When a comparison is executed, the processor will edit the Condition Register (CR) accordingly based on the result said comparison. The following branch instruction reads the Condition Register and if certain values are present/not-present, the branch will be taken.

Before diving deeper into the Condition Register, lets breakdown a typical signed comparison instruction against the value of 1.

Code:
cmpwi r3, 1 = cmpi cr0, 0, r3, 1

The comparison instructions you see in Wii cheat codes are actually simplified mnemonics.

cmpi = do a signed integer comparison (fyi: cmpli = logical integer comparison, cmp = signed register comparison, cmplw = logical register comparison)

cr0 = This is the CR field. There are 8 CR fields (cr0 thru cr7). Each field takes on one digit (or half of a byte) in the Condition Register.

Condition Register layout
STUVWXYZ

S = cr0
T = cr1
U = cr2
etc etc..

0 = L bit. For Broadway, this must always be 0 or else it is an invalid instruction and will cause an exception/freeze. For anyone who cares, a '1' for the L bit is for a 64 bit comparison while '0' is for a 32 bit comparison. In lamest terms, you could say this was 'left' in by the Broadway devs from previous work of other PPC assembly languages.

r3 and 1 is obviously comparing the value in r3 vs the signed 16 bit value value of 0x0001.

cr0 is the CR field used for basic integer comparisons, which account for (if i had to guess) around 95% of comparisons done in Wii cheat codes. cr1 is used for floating point comparisons. Sometimes a coder may need to use another CR field while not wanting to modify cr0 or cr1. This is easy to do, just specify the CR field like so..

Code:
cmpwi cr7, r3, 1

This will put the comparison result in cr7 instead of cr0. Now when you want to branch based on the result that's placed in cr7, do this...

Code:
bne+ cr7, some_label #bne+ just used as an example ofc, can be any branch instruction

Just add the CR field then a comma to specify its to prevent the assembler from defaulting to cr0.

NOTE: Never use cr2 thru cr4. If you need extra cr fields, start with cr7, then cr6, and then cr5. There's no way you will need more than 3 extra cr fields in a Wii code, lol.



More in-depth details of the Condition Register

NOTE: Once again, if you are a beginner and are overwhelmed, don't worry about reading the following contents.

There are certain bit values within each CR field, here is a list of them.

Code:
bit 0 = <0 flag
bit 1 = >0 flag
bit 2 = =0 flag
bit 3 = SO (Summary overflow)

Comparison instructions will flip the corresponding bit(s) high/low based on the result of the comparison. Any unrelated bits are left alone. And the branch instructions will check certain bits, and execute based on whether certain hits are flipped high and/or low.

List of branch instruction bit checks~

Code:
beq (branch if equal) = checks bit 2, if bit is high, branch is taken
bge (branch if greater than or equal) = checks bits 1 and 2, if either bit is high, branch is taken
bgt (branch if greater than) = checks bit 1, if bit is high, branch is taken
ble (branch if less than or equal) = checks bits 0 and 2, if either bit is high, branch is taken
blt (branch if less than) = checks bit 0, if it is high, branch is taken
bne (branch if not equal) = checks bit 2, if bit is low, branch is taken
bng (branch if not greater than) = equivalent to ble
bnl (branch if not less than) = equivalent to bge
bns (branch if not summary overflow) = checks bit 3, if bit is low, branch is taken
bso (branch if summary overflow) = checks bit 3, if bit is high, branch is taken

NOTE: The branch instructions are all simplified mnemonics. In fact every branch instruction you see in a source of a Wii cheat code will be a simplified mnemonic. There's really no point breaking down the complexity of all these mnemonics as it doesn't help the Coder at all to try to use the actual 'real form' branch-conditional (bc) instructions.



Final section: Instructions allowing modification of the CR w/o using comparisons

Want CR's value in a register or vice versa?? There are instructions for that...

mfcr rD #Copy the value of CR to rD
mtcr rD #Copy the value of rD to the CR

Here's a handy instruction to copy the value of one CR field and paste it in another CR field...

mcrf crD, crA #Copy value of crA, paste it in crD

Example~

Code:
mcrf cr7, cr0 #This will copy the value of CR field 0 and paste it in CR field 7.


Here are a couple of handy instructions if you need to manully flip bit(s) high/low in a CR field

crset B #B = the bit of the CR register, see bit map below for assistance. This will flip the desired bit high.
crclr B #This will flip the desired bit low

Code:
bit map:
bits 0 thru 3 = cr0's bits
bits 4 thru 7 = cr1
bits 8 thru 11 = cr2
bits 12 thru 15 = cr3
bits 16 thru 19 = cr4
bits 20 thru 23 = cr5
bits 24 thru 27 = cr6
bits 28 thru 31 = cr7

crset B is a simplified mnemonic of creqv B, B, B
crclr B is a simplifed mnemonic of crxor B, B, B

For even more condition register instructions, refer back to your favorite PPC manual.

Print this item