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


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

Forum Jump:


Users browsing this thread: 2 Guest(s)