Coding Questions and other Quandaries
Monster Mayhem: Build and Battle Wii (U)

First item picked up gives you a quantity of 999 for all items

C20C187C 00000004
39800019 7D8903A6
3D8080B5 618C882C
380003E7 940C0004
4200FFF8 00000000

Source

Original code at insert:

0x800C187C stwx, r0, r4, r5

Changed to:

li r12, 0x19 #ASM there are 25 item addresses to write to
mtctr r12
lis r12, 0x80B5 #ASM Upper half word of item address block
ori r12, r12, 0x882C Lower half of item address block -0x4
the_loop:
li r0, 0x3E7 #ASM Loads 999 into register to be stored from
stwu r0, 0x4 (r12) #ASM store it 25 times
bdnz+ the_loop
Reply
Nice job on your first loop code!
Reply
Codes don't always have to make a game easier.

Normally, the game decreases your Elements quantity by 0x1 (0x3F800000 floating point).

So...

Monster Mayhem: Build and Battle Wii (U)

Element Decrement By Modifier

C21CB76C 00000003
3D608000 3D80ZZZZ
918B03C0 C04B03C0
EC211028 00000000

Source:


Original code line
0x801CB76C fsubs f1, f1, f2

Changed to:

lis r11, 0x8000 #ASM Load upper half word of EVA address to store modifier value to
lis r12, 0xZZZZ #ASM Load modifier value to store in EVA
stw r12, 0x3c0 (r11) #ASM Store modifier value at EVA address 0x800003C0
lfs f2, 0x3c0 (r11) #ASM Load f2 with value to be subtracted
fsubs f1, f1, f2 #ASM Subtract it

ZZZZ

0x4000 = 0x2
0x4040 = 0x3
0x4080 = 0x4
0x40A0 = 0x5

Anything above 0x5 is just silly!!!
Reply
On any of the Wii games you have been making codes for in the past, you should revisit them and try to make speed/xyz-coordinate type codes since you have learned the basics of Floats.

Nice work
Reply
Monster Mayhem: Build and Battle Wii (U)

Speed Boost x4/Walk Through Walls (Press C) [Use K Pad Read Hook Type]

C2037858 00000007
3D808062 A16C54BA
2C0B4000 40820020
3D608066 616B994C
7C045800 40820010
3D8040F8 618C1480
91840000 C0040000
60000000 00000000

0x806254BA Button activator half-word Address
0x8066994C Max Speed value loaded from this address on the stack (r4)
0x80C2CD24 Speed modifier address (r3)

Insert address 0x80037858 (also showing store code directly following):

0x80037858  lfs f0, 0x0 (r4)
0x8003785C stfs f0, 0x0 (r3)

***I was basing all my codes that worked in Dolphin, but not on the Wii, on the store portion of this routine.
Once I focused on the load portion (and changed the hook type to K Pad Read), the code worked flawlessly on the Wii.

Source:


lis r12, 0x8062            #ASM Load upper half word of button activator address
lhz r11, 0x54BA(r12)    #ASM Load r11 with value at button activator address
cmpwi r11, 0x4000      #ASM Check to see if the C button is pressed. If not, default_load
bne- default_load

lis r11, 0x8066            #ASM Load upper half word of address max speed value is to be loaded from
ori r11, r11, 0x994C    #ASM Load lower half word of address max speed value is to be loaded from
cmpw r4, r11              #ASM Check to see if that address is being held in r4. If not, default_load
bne- default_load

lis r12, 0x40F8              #ASM Load upper half word of max speed modifier value into r12
ori r12, r12, 0x1480      #ASM Load lower half word of max speed modifier value into r12
stw r12, 0(r4)              #ASM Store speed modifier value at address in r4, which is to be loaded into f0

default_load:
lfs f0, 0(r4)                  #ASM Load speed modifier value into f0

This is then directly followed by:

0x8003785C stfs f0, 0x0 (r3)
Reply
The way you are structuring you C2 ASM Codes to include button activator instructions within th esource should not be needed in most cases and probably has something to do with why your codes fail on certain Hooktypes for the different Wii games you are working on.

If you ever run into a situation where you want the C2 Hook Address's Instruction to be executed  whenever the button activator is not pressed, structure the C2 code like so..

04xxxxxx oooooooo #xxxxxx = C2 Hook Address, #oooooooo = Default/Original Instruction
283XXXXX YYYYZZZZ #16-bit If-Equal statement (button activator line))
C2xxxxxx 000000XX
.. ..    .. ..    #Somewhere in source is default/original instruction ofc
E0000000 80008000 #End If Statement via Final Terminator


You can rewrite the source of your ASM code like this...

lis r12, 0x8066
ori r12, r12, 0x994C
cmpw r4, r12
bne- default_instruction

lis r12, 0x40F8
ori r12, r12, 0x1480
stw r12, 0 (r4)

default_instruction:
lfs f0, 0 (r4)


And thus the finished code is this..

04037858 C0040000
286254BA YYYYZZZZ
C2037858 00000005
3D808066 618C994C
7C046000 40820010
3D8040F8 618C1480
91840000 C0040000
60000000 00000000
E0000000 80008000


This compiled code is longer by 1 line than your version, but it allows the end user to choose whether or not the button activator is the condition of "only can be pressed" or the condition of "at least pressed". Not only that, formatting your C2 Button Activated codes in this way should reduce the Hooktype issues.

If you are running into scenarios where you are doing 'address checks' in your sources, based on my experience, the code is 'hacky', and needs a better Hook Address or try finding some pattern/correlation in the GVRs.

Off-topic tips:

if you ever need to set an FPR to 0, do this

fsubs fZ, fX, fX #use fsub if double precision

To set an FPR to 1, do this...

fdivs fZ, fX, fX #use fdiv if double precision. fX cannot be 0.

Another note is be on the lookout for some FPRs (during time of Hook address execution) that may always be 0 or 1. Therefore you don't even need the above instructions.
Reply
MySims Sky Heroes - Wii (U)

Free For All Dogfight - Infinite Missiles (No Reload Time)

C28BC474 00000004
3D6080C2 396B5314
819F0000 7C0B6000
40A20008 C01F000C
D01F0010 00000000

[Insert & Original Source]

0x808BC474 stfs f0, 0x10 (r31)

The address which the missile refill timer is held at, is dynamic. but I found it is consistently in one of six, 48 byte blocks,
with a couple of unique values in the block it happens to be in.

[Replaced With]

loc_0x0:
lis r11, 0x80C2 #ASM Load upper half of unique block value for conditional
addi r11, r11, 0x5314 #ASM Load lower half of unique block value for conditional
lwz r12, 0x0 (r31) #ASM If writing to refill timer, r31 will hold the address of our unique block value for conditional
cmpw r11, r12 #ASM Compare 'em
bne+ not_rocket #ASM If not equal, carry on as usual, if equal then;
lbz r12, 0x2f(r31) #[ADDED] ASM Load unique value to P1 missile memory block
cmpwi r12, 0x1 #[ADDED] ASM Compare it
bne+ not_rocket #[ADDED] #ASM If not equal, carry on as usual, if equal then;

lfs f0, 0xC (r31) #ASM Load f0 with a floating point value conveniently located within the unique block

not_rocket:
stfs f0, 0x10 (r31) #ASM Store it


Free For All Dogfight - Machine Gun Doesn't Overheat

C29DA914 00000003
A183FFD8 718C2AA4
41A20008 EC000028
D0030000 00000000

[Insert & Original Source]

0x809DA914 stfs f0, 0x0 (r3)

The address which the machine gun heat value is held at, is dynamic. but I found it is consistently in one of six, 32 byte blocks,
with a couple of unique values in the block it happens to be in.

[Replaced With]

loc_0x0:
lhz r12, -0x28 (r3) #ASM If machine gun heat value is being increased, -0x28 (r3) will hold the unique block value 0x2AA4
andi. r12, r12, 0x2AA4 #ASM Check to see if increasing machine gun heat value
beq+ loc_0x10 #ASM If not, carry on as usual; if equal then
fsubs f0, f0, f0 #ASM Set f0 to 0x0 (cold machine gun barrel)

loc_0x10:
stfs f0, 0x0 (r3) #ASM Store it
Reply
My Sims Sky Heroes (U) Wii

Press (-) for x3 Turbo Boost (All Modes)

C2978C68 00000006
3D608059 616BC720
A18B0000 2C0C1000
40A20014 3D608000
3D804381 918B03B0
C38B03B0 D383001C
60000000 00000000


[Original Source]

0x80978C68 stfs f28, 0x1C (r3)     #ASM This line is used for P1 and AI's speed value write

[Insert]
  
  lis r11, 0x8059          #ASM Load upper half-word button activator address
  ori r11, r11, 0xC720   #ASM Load lower half-word button activator address
  lhz r12, 0(r11)           #ASM Load current button activator address value
  cmpwi r12, 0x1000    #ASM See if (-) button has been pressed
  bne+ default_inst      #ASM If not, carry out the default instruction
  lis r11, 0x8000          #ASM If equal, load r11 with upper half of EVA address
  lis r12, 0x4381          #ASM Load x3 speed boost value into upper half of r12; customizable
  stw r12, 0x3B0 (r11)  #ASM Store x3 speed boost value to EVA 0x800003B0
  lfs f28, 0x3B0 (r11)    #ASM Load floating speed boost value into f28; and then...

default_inst:
  stfs f28, 28(r3)          #ASM Default instruction; store boost value
Reply
My Sims Sky Heroes (U) Wii

Infinite Health (All Modes)

C34221F8 00000005
3D609196 616B5C50
7C0B9000 40A20010
3D808000 3979FFD1
916C03E4 B3320000
60000000 00000000
C2BDC8D0 00000007
D01F0010 3D608000
818B03E8 2C0C0000
398C0001 918B03E8
40A20008 93EB03E0
812B03E4 7C0C4800
41A00008 39800000
918B03E8 00000000
040003EC 42C80000
C2BDCE3C 00000004
3D608000 818B03E0
7C0CF800 40A20008
C00B03EC D01F0010
60000000 00000000


Serious use of EVA for pointer and conditionals for a code that works in all gameplay modes without giving the AI infinite health also.

[Insert/Original Code]

0x814221F8 sth r25, 0(r18)  #ASM This is storing the # of AI selected in the match option screen

[Insert]

loc_0x0:
  lis r11, 0x9196                  #ASM Load upper half-word of address # of AI stored at          
  ori r11, r11, 0x5C50          #ASM Load lower half-word of address # of AI stored at 
  cmpw r11, r18                  #ASM Check that it is only writing # of AI address
  bne+ default_code            #ASM If not equal, AI # not being written to
  lis r12, 0x8000                  #ASM If equal, load upper half-word of EVA address
  subi r11, r25, 0x2F            #ASM Subtract 0x2F from r25 for 4 bit value that equals P1 + number of AI selected
                                           The values in r25 is in this format: 0x0033 = 3 AI, 0x0035 = 5 AI etc...
                                           Subtracting 0x2F from r25 leaves me with 4 bit representation of P1 + AI Qty.
                                           The reason I did this is for use in another insert to follow.
                                            

stw r11, 0x3E4(r12)             #ASM Store value of P1 + number of AI at EVA 0x800003E4; this is used in a conditional, 
                                              in the following insert below.

default_code:                  
  sth r25, 0(r18)                  #ASM Default AI quantity select store



[Insert/Original Code]

0x80BDC8D0 stfs f0, 0x10 (r31) #ASM Stores beginning health value to P1 and AI; Code is executed (# of AI + 1 for P1) times.
                                                P1 health value is always the first to be stored Yay!!!.

[Insert]

loc_0x0:
  stfs f0, 0x10(r31)        #ASM Default code; Stores beginning health value to P1 and AI
  lis r11, 0x8000            #ASM Load upper half-word of EVA address
  lwz r12, 0x3E8(r11)     #ASM Load write cycle counter from EVA
  cmpwi r12, 0x0            #ASM See if it is the first write
  addi r12, r12, 0x1        #ASM Increment write cycle counter
  stw r12, 0x3E8(r11)     #ASM Store updated value back to EVA
  bne+ not_me              #ASM If not the first cycle don't write health value address to EVA
  stw r31, 0x3E0(r11)     #ASM If 1st write cycle, store P1 Health address in EVA

not_me:
  lwz r9, 0x3E4(r11)       #ASM Load r9 with (# of AI + 1 for P1) in EVA
  cmpw r12, r9              #ASM Compare with write cycle counter in r12
  blt+ store_it               #ASM If less than, store updated write cycle count 
  li r12, 0x0                   #ASM if (# of AI + 1 for P1) equals write cycle counter 
                                   #Reset write cycle counter for next dogfight, race or story mode level 
store_it:
  stw r12, 0x3E8(r11)    #ASM Store updated write cycle count in EVA


The portion that gives P1 infinite health:

[Insert/Original Code]

0x80BDCE3C stfs f0, 16(r31) #ASM Stores decreased health value after damage

[Before Insert]

040003EC 42C80000   #ASM Write full health floating point value in EVA

[Insert]

loc_0x0:
  lis r11, 0x8000         #ASM Load upper half-word of EVA address
  lwz r12, 0x3E0(r11)  #ASM Load health address pointer in EVA
  cmpw r12, r31          #ASM Compare with address in r31 
  bne+ store_it           #ASM If not equal, it's not P1. 
  lfs f0, 1004(r11)       #ASM If equal it is P1. Grab full Health value from EVA

store_it:
  stfs f0, 16(r31)         #ASM Default code. Store it.
Reply
Great work! This is by far your most complex code yet. Keep it up!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)