Coding Questions and other Quandaries
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


Messages In This Thread
RE: Coding Questions and other Quandaries - by Hackwiz - 03-01-2022, 01:01 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)