Coding Questions and other Quandaries
#91
Ah. Well if you ever make one, let me know. We have a Group Server on Discord for MarioKartWii.com members.
Reply
#92
I now have an account.

under

Hackwiz#9289
Reply
#93
Epic. Sent request.
Reply
#94
Here is the code(s) I came up with.

I ape'd your Wii Bowling button activator. I can see quite a few uses for that in the future.

Cocoto Kart Racer (USA) Wii

Infinite Items/Cycle Through Items

- Press (-) & B for next item
--------------------------------------------------------------------------------------------
Button Activator Portion

C0000000 0000000C
3C60801A 6063D000
88030A8C 2C000014
3C608000 41820010
38000000 980303FF
4E800020 880303FF
2C000001 4D820020
38000001 980303FF
88A303FE 38A50001
2805000A 41A00008
38A00001 98A303FE
818303F0 98AC0153
4E800020 00000000

C0 Insert:
lis r3, 0x801A
ori r3, r3, 0xD000
lbz r0, 0xA8C (r3) #ASM Load r0 with current control line value
cmpwi r0, 0x14 #ASM Check to see if (-) and B are being pressed
lis r3, 0x8000 #ASM Load r3 with upper half-word to EVA
beq- button_pressed
li r0, 0x0
stb r0, 0x3FF (r3)
blr

button_pressed:
lbz r0, 0x3FF (r3)
cmpwi r0, 0x1
beqlr-
li r0, 0x1
stb r0, 0x3FF (r3)
lbz r5, 0x3FE (r3)
addi r5, r5, 0x1
cmplwi r5, 10
blt+ next_item
li r5, 0x1

next_item:
stb r5, 0x3FE (r3)
lwz r12, 0x3F0 (r3) #ASM Loads r12 with item pointer address at 0x800003F0
stb r5, 0X153 (r12) #ASM Stores new item value at item address
blr


All Items Have Quantity 3

C2058FAC 00000002
38000003 901E0154
60000000 00000000

loc_0x0:
li r0, 0x3 #ASM this is normally 0x1 for items that come with a quantity of 1
stw r0, 0x154 (r30)
--------------------------------------------------------------------------------------------------------------
Pointer To Item Address In EVA

C2058F80 00000005
3D808015 618C5DEE
7C0CE800 40820010
7FCCF378 3D608000
918B03F0 901E0150
60000000 00000000

loc_0x0:
lis r12, 0x8015
ori r12, r12, 0x5DEE #ASM Loads r12 with unique value in r29 when I pick up an item
cmpw r12, r29
bne- not_my_item
mr r12, r30 #ASM r30 holds the item address minus 0x150
lis r11, 0x8000
stw r12, 0x3F0 (r11)

not_my_item:
stw r0, 0x150 (r30)
--------------------------------------------------------------------------------------------------------------
Infinite Items

C2054778 00000004
7D8802A6 3D608005
616B45AC 7C0C5800
40820008 38000003
90160154 00000000

loc_0x0:
mflr r12 #ASM The LR holds unique value when I use an item 0x800545AC
lis r11, 0x8005
ori r11, r11, 0x45AC #ASM Load r11 with value to compare
cmpw r12, r11
bne- not_me
li r0, 0x3 #ASM if they match, load r0, with 0x3 to be stored next

not_me:
stw r0, 0x154 (r22)

-------------------------------------------------------------------------------------------------------------

I noticed a little weirdness with the item address write to EVA 0x800003F0
At the beginning of the second race, There was an unexpected address (mem1) written there.
Will probably have to add a double check to that portion of the code.

But all in all, it does what I was hoping to do.
All ASM, no filler!!! Smile
Reply
#95
(01-12-2022, 12:41 PM)Hackwiz Wrote:
Code:
  mr r12, r30 #ASM r30 holds the item address minus 0x150
  lis r11, 0x8000
  stw r12, 0x3F0 (r11)

You can get rid of the mr instruction and change the stw instruction stw r30, 0x03F0 (r11). The Destination Register's value always remains intact during a store instruction.

(01-12-2022, 12:41 PM)Hackwiz Wrote: At the beginning of the second race, There was an unexpected address (mem1) written there.
Will probably have to add a double check to that portion of the code.

But all in all, it does what I was hoping to do.
All ASM, no filler!!! Smile

Code:
andis. rD, rA, 0x1000
beq- mem1
Reply
#96
Cocoto Kart Racer - Weapon/Item Auto-fire

C0000000 00000005
3D60801A 616BD000
A18B0A8C 2C0C0800
41A2000C 2C0C0C00
4C820020 38A00000
B0AB0A94 4E800020

On yet another Wii game, I found a button activator address that when held to 0x0, gives all buttons auto-fire
capabilities.

Searching for the button activator addresses returned 22 results.
In the watch window, one by one, I wrote 0x0 to the addresses and checked to see if pressing the A button gave me auto-fire.
The third address in the list gave me just that.
Rather than using the button write cycle, I wrote a simple C0 code to do the trick.

I used one of the nonauto-fire button activator addresses for the conditionals.

The nonauto-fire button activator address is: 0x801ADA8C
The auto-fire button activator address is: 0x801ADA94

I needed two conditionals. One for when only the fire (A) button is pressed, and the other for when the accelerator (B) button is being pressed also.

#Source
#C0 insert:

  lis r11, 0x801A #ASM loads r11 with upper half-word of button activator address(es)
  ori r11, r11, 0xD000 #ASM loads r11 lower half-word of button activator address(es)
  lhz r12, 0xA8C (r11) #ASM loads r12 with current value at nonauto-fire button address
  cmpwi r12, 0x800 #ASM check to see if "A" being pressed
  beq+ fire_button_pressed
  
  cmpwi r12, 0xC00 #ASM check to see if "A and B" are being pressed
  bnelr- #if not, end C0

fire_button_pressed: 
  li r5, 0x0 #ASM load r5 with 0x0
  sth r5, 0xA94 (r11) #ASM stores 0x0 at auto-fire button activator address
  blr #end C0
 
Works great!!!
Reply
#97
Resident Evil - The Umbrella Chronicles Wii (USA)

Toggle Infinite Health On/Off (1 or 2 Player)

2843A832 00000200
C20F4FBC 00000002
3D808000 C00C03D0
D0036C00 00000000
E0000000 00000000
2843A832 00000100
040F4FBC D0036C00
E0000000 80008000

#Source
# If button 1 is pressed, infinite health:

lis r12, 0x8000 #ASM Loads r12 with upper half-word of EVA address. Load f0 with 0x0 from
lfs f0, 0x3D0 (r12) #ASM Load f0 with 0x0 from EVA address 0x800003D0; Full health = 0x0
stfs f0, 0x6C00 (r3) #ASM Store f0 at player 1 and player 2 health addresses.

# Source
# If button 2 is pressed, can take damage:
# Writes original code at insert 0x800F4FBC:

stfs f0, 0x6C00 (r3) #ASM Store f0 at player 1 and player 2 health addresses.
Reply
#98
Hey floating points! Nice work.

Here's a cool trick.

To set an FPR to 0, just substract it by itself. Since your default instruction is in single precision, use that for the subtraction.

fsubs f0, f0, f0
stfs f0, 0x6C00 (r3)

--

Also to set an FPR value to 1, just divide it by itself. Obviously it won't work if the FPR value is zero.
Reply
#99
(02-21-2022, 02:32 PM)Vega Wrote: Hey floating points! Nice work.

Here's a cool trick.

To set an FPR to 0, just substract it by itself. Since your default instruction is in single precision, use that for the subtraction.

fsubs f0, f0, f0
stfs f0, 0x6C00 (r3)

--

Also to set an FPR value to 1, just divide it by itself. Obviously it won't work if the FPR value is zero.

Another opcode to use. Very cool indeed!
I would have never thought of doing that.
Must...restrain...the...urge...to...overthink Lol!!
Reply
Resident Evil 4 Wii (USA) - Button Cycled Default Weapon Mod With Infinite Ammo (See note below)
The Code:

007542D7 0000000A

C0000000 0000000B
3C608032 6063F000
88030F1B 2C000010
3C608000 41820010
38000000 980303FF
4E800020 880303FF
2C000001 4D820020
38000001 980303FF
88A303FE 38A50001
28050022 41A00008
38A00001 98A303FE
4E800020 00000000

2832FF1A 00002010
000003FE 00000000
E0000000 80008000

C0000000 0000000A
3D608032 616BF000
898B0F1A 718C0040
4DA20020 3CA08000
886503FE 3CA08033
98657F30 98657EF0
3CA08034 60A5D8E1
98650000 3CA0917D
60A5EBD3 98650000
3CA092BD 60A5EBD3
98650000 4E800020

---------------------------------------------------------------------------------------------------------------------------------------

#ASM

007542D7 0000000A #ASM 8 bit constant write to default weapon ammo address 0x807542D7

---------------------------------------------------------------------------------------------------------------------------------------------

#Source [slight variation of Vega's Button increment code]
#C0 insert [increments weapon mod value to be loaded, at EVA address 0x800003FE]

#Get button(s) pressed, check against desired activator
lis r3, 0x8032
ori r3, r3, 0xF000
lbz r0, 0xF1B (r3)
cmpwi r0, 0x10 #Checks to see if (+) is being pressed
lis r3, 0x8000 #Before taking the branch, set r3 to its new value, upper 16 bits of EVA
beq- button_has_been_pressed

#Nothing Pressed, Reset Button Status
li r0, 0
stb r0, 0x3FF (r3)
blr #End C0

#Button Pressed, Adjust Button Status
#0 = Not Pressed
#1 = Pressed
button_has_been_pressed:
lbz r0, 0x3FF (r3)
cmpwi r0, 1
beqlr- #End C0
li r0, 1
stb r0, 0x3FF (r3)

#Update weapon mod value
lbz r5, 0x03FE (r3)
addi r5, r5, 1

#Check if it exceeded max weapon mod value allowed (33 weapons allowed in this source currently - 1, 2 .. .. 33)
cmplwi r5, 34 #Check if we went beyond 33
blt+ store_tracker
li r5, 1 #Reset tracker byte
store_tracker:
stb r5, 0x03FE (r3)

------------------------------------------------------------------------------------------------------------------------------------

#Source [Resets Weapon mod value in EVA to 0x0, to start at top of the weapon list]

2832FF1A 00002010 #ASM Button activator; if Z + (+) are pressed, next line
000003FE 00000000 #ASM Writes 0x0 to 0x800003FE
E0000000 80008000 #ASM Full terminator

----------------------------------------------------------------------------------------------------------------------------------------------

#Source [When C button held, constant 8 bit write to 5 Weapon mod addresses]

loc_0x0:
lis r11, 0x8032 #ASM load upper half-word of button activator address
ori r11, r11, 0xF000 #ASM load lower half-word of button activator address
lbz r12, 0xF1A (r11) #ASM load byte at 0x8032FF1A into r12
andi. r12, r12, 0x40 #ASM checks to see if C is pressed
beqlr+ #ASM If C button not pressed End C0

lis r5, 0x8000 #ASM load r5 with upper 16 bits of EVA
lbz r3, 0x3FE(r5) #ASM load r3 with weapon mod value in EVA
lis r5, 0x8033 #ASM load r5 with upper half-word of 1 of 5 addresses to be written to
stb r3, 0x7F30(r5) #ASM stores weapon mod to 1st address 0x80337F30
stb r3, 0x7EF0(r5) #ASM stores weapon mod to 2nd address 0x80337EF0
lis r5, 0x8034 #ASM load r5 with upper half-word of 3rd address to be written to
ori r5, r5, 0xD8E1 #ASM load r5 with lower half-word of 3rd address to be written to
stb r3, 0 (r5) #ASM stores weapon mod to 3rd address 0x8034D8E1
lis r5, 0x917D #ASM load r5 with upper half-word of 4th address to be written to
ori r5, r5, 0xEBD3 #ASM load r5 with lower half-word of 4th address to be written to
stb r3, 0 (r5) #ASM stores weapon mod to 4th address 0x917DEBD3
lis r5, 0x92BD #ASM load r5 with upper half-word of 5th address to be written to
ori r5, r5, 0xEBD3 #ASM load r5 with lower half-word of 5th address to be written to
stb r3, 0(r5) #ASM stores weapon mod to 5th address 0x92BDEBD3
blr #End C0

-------------------------------------------------------------------------------------------------------------------

(Note)
(Note) Press the (+) button the appropriate number of times listed, for your weapon of choice. To reset this to the top of the list, hold the Z button, while pressing and releasing the (+) button. Pressing the C button forces the weapon of choice to be loaded at certain times.
For a NEW game, at the main screen, choose your weapon by pressing the (+) the appropriate number of times. Press A to choose new game, then immediately press and hold the C button. If you want to watch the opening cut-scene, just keep holding C until Leon appears on the screen. If not, while still holding C, press B a couple times to skip the cut-scene. When Leon appears on the screen, you can release the C button.
For a SAVED game, scroll to the game save you want to open. Choose your weapon by pressing the (+) the appropriate number of times. Press and hold the C button. Select yes to load saved game and hit A. Release the C button when Leon appears on the screen.
Also, you can hold C when saving your game so the next time you load it, you will already have your desired weapon.
This works with the Mercenaries and Ada games also.
Caution!!! Going through some gates and cut-scenes (Hannigan), may cause you to lose your default weapon, as will going into the items screen and equipping a different weapon you have. You can use usable items freely without effecting your weapon. If you lose your weapon, you can either, restart from the last checkpoint, or go to one of the gates (not the ones you can simply walk through or kick open). This is a great time to change weapons if you want. In the case of gates in between different areas of the game, when press A is displayed, make sure you have the weapon you want selected, press and hold C then press A to enter the new area. Release C when Leon appears on the screen. It works the same way with loading from a checkpoint. Just make sure you press and hold C when selecting Yes and hold until Leon appears. Do the same at the beginning of cut-scenes (Hannigan etc.) , or going through area change gates/doors, to retain your chosen weapon
Here is the Weapons list with the number of (+) button presses:

0) – Start of list (no weapon)
1) - Punisher
2) - Handgun
3) - Red9
4) - Blacktail
5) - Broken Butterfly
6) - Killer7
7) - Shotgun
8) - Striker
9) - Rifle
10) - Auto Rifle
11) - TMP
12) - Chicago Typewriter
13) - Rocket Launcher
14) - Mine Thrower
15) - Hand Cannon
16) - Knife
17) - Matilda
18) - Beta? (Looks Like A Red9)
19) - Grenades (Unlimited!)
20) - Beta TMP (Kills Enemies At Your Sides)
21) - Beta Rifle (Beta Scope)
22) - Incendary Grenades
23) - Flash Grenades
24) - Beta Rifle
25) - White Eggs
26) - Grenades
27) - Grenades
28) - Grenades
29) - Grenades
30) - Beta Rocket Launcher (Beta Scope)
31) - Pink Eggs
32) - Gold Eggs
33) - Riot Shotgun
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)