Nice code. It appears you should be able to actually combine the 2nd, 3rd, and 4th sources into one C0. Also don't forget about that sign-extension trick I mentioned before about working with offsets greater than 0x7FFF for stores and loads.
EDIT:
Here's a rough draft of those 3 sources combined into one.
99% chance I typo'd or forgot something. Step/debug first before live attempt.
Here's whole code in compiled form.
007542D7 0000000A
C0000000 00000011
3D808033 A16CFF1A
71602010 3D408000
39200000 41820040
71600010 41820010
38000000 980A03FF
48000030 880A03FF
2C000001 41820024
38000001 980A03FF
892A03FE 39290001
28090022 41A00008
39200001 992A03FE
71600040 4DA20020
3D808033 3D608035
3D40917E 3CA092BE
992C7F30 992C7EF0
992BD8E1 992AEBD3
9925EBD3 4E800020
EDIT:
Here's a rough draft of those 3 sources combined into one.
Code:
#Load Controller Halfword Input Value
lis r12, 0x8033
lhz r11, 0xFFFFFF1A (r12)
#Check if Z and + are at least pressed, if so, reset Weapon Value to 0
andi. r0, r11, 0x2010
#Setup EVA before branch
lis r10, 0x8000
#Preset weapon value to 0 if branch gets taken
li r9, 0
#Skip over Minus check if Z+ was pressed
beq- update_weapon_value
#Check if Minus button was at least pressed.
#We need to custom status check for this button as we don't want to weapon value to increase while we hold the button down, only when we press it.
andi. r0, r11, 0x0010
beq- button_has_been_pressed
#Minus button not Pressed, Reset Button Status
li r0, 0
stb r0, 0x3FF (r10)
b check_c_button
#Minus button Pressed, Adjust Button Status
#If Status is already 1, then button is being held down. If held down, skip the weapon incrementation
button_has_been_pressed:
lbz r0, 0x3FF (r10)
cmpwi r0, 1
beq- check_c_button
#Minus button newly pressed. Update button status
li r0, 1
stb r0, 0x3FF (r10)
#Increment weapon value
lbz r9, 0x03FE (r10)
addi r9, r9, 1
#Check if it exceeded max weapon value allowed. Allowed range of 1 thru 33 only.
cmplwi r9, 34
blt+ update_weapon_value
#Exceeded 33. Reset weapon value to 1
li r9, 1
#Update weapon
update_weapon_value:
stb r9, 0x03FE (r10)
#Weapon is fully updated, lets now check if C button was pressed to use said new weapon
check_c_button:
andi. r0, r11, 0x0040
beqlr+ #Not pressed, end C0
#Activate weapon! Weapon is in r9
#Setup addresses
lis r12, 0x8033
lis r11, 0x8035
lis r10, 0x917E
lis r5, 0x92BE
#Do all the memory writes
stb r9, 0x7F30 (r12)
stb r9, 0x7EF0 (r12)
stb r9, 0xFFFFD8E1 (r11)
stb r9, 0xFFFFEBD3 (r10)
stb r9, 0xFFFFEBD3 (r5)
#End C0
blr #Comment this if compiling with pyiiasmh. Pyiiasmh auto adds the blr.
99% chance I typo'd or forgot something. Step/debug first before live attempt.
Here's whole code in compiled form.
007542D7 0000000A
C0000000 00000011
3D808033 A16CFF1A
71602010 3D408000
39200000 41820040
71600010 41820010
38000000 980A03FF
48000030 880A03FF
2C000001 41820024
38000001 980A03FF
892A03FE 39290001
28090022 41A00008
39200001 992A03FE
71600040 4DA20020
3D808033 3D608035
3D40917E 3CA092BE
992C7F30 992C7EF0
992BD8E1 992AEBD3
9925EBD3 4E800020