Coding Questions and other Quandaries
#77
(12-29-2021, 02:00 PM)Hackwiz Wrote: I'm probably going to have ??? in regards to the code handler and that game. It gets mighty pissed off when you tinker with it.
Had to quickly activate/deactivate the above code so it wouldn't bring the game to it's knees. Yes, I know it is constantly writing that string,
But like I said, the game doesn't like playing with the code handler and button activators.

Now to study the button activator explanation you gave above.

Thanks!!!!!!!

Just an fyi: Always make sure your final assumptions & analysis are done on Real Hardware in regards to any Code testing. Dolphin may botch a code that works perfectly fine on Real Hardware.

Addressing your large 06 write, it may be best to write it as a C0 with standard button activation. Like this...

Code:
lis r3, 0xXXXX #Upper 16 bits of Controller Halfword Address
lhz r0, 0xXXXX (r3) #Load the Button Halfword
andi. r0, r0, 0xZZZZ #Check if activator was at least hit
beqlr+ #If activator not hit, end C0. Branch is most likely to occur, hence the plus symbol

#Setup a Loop to write out every Item and its Quantity
lis r3, 0x8046
ori r3, r3, 0xE588 #8046E58C minus 4

#Set the Loop amount
li r0, 0x102
mtctr r0

#Set the Item Quantity (it's the same for every type of Item)
li r5, 0x63 #99; do NOT use r0 as we will be doing addis instruction execution in the upcoming loop

#Loop
#Add Immediate Shift to set the current Item Value, then store ItemValue+Quantity word to its appropriate spot in Memory
loop:
addis r5, r5, 0x0001 #0x00010063 then 0x00020063 then 0x00030063, etc etc
stwu r5, 0x4 (r3)
bdnz+ loop

#All Done; end C0
#blr #Uncomment if NOT compiling with PyiiASMH, adjust compiled code accordingly to make it a working C0 code

Compiled code:
C0000000 00000007
3C60XXXX A003XXXX #XXXXXXXX = Controller button halfword address
7000ZZZZ 4DA20020 #ZZZZ = activator
3C608046 6063E588
38000102 7C0903A6
38A00063 3CA50001
94A30004 4200FFF8
4E800020 00000000

Due to how the source is written and I see that this is a GCN game (thus uses GCN controller), if the activator isn't working (you don't see the updates in Dolphin-memory-engine of items and quantity) be sure the ZZZZ values are the Wavebird ZZZZ values. https://mariokartwii.com/showthread.php?tid=44

XXXXXXXX = The controller button halfword address for Pokemon Colosseum (GCN). No idea what this is personally. So if the lower 16 bits of this address exceed 0x7FFF, be sure to do the sign extend trick

Example of sign extend trick for example address 0x80808CCC #8CCC is > than 7FFF

Code:
lis r3, 0x8081 #Add 1 to upper 16 bits
lhz r0, 0xFFFF8CCC (r3) #Sign extend the lower 16 bits

Btw the C0 code is setup to where if you press the activator, the items+quantities are applied but they are NOT re-applied when you let go of the activator. So if you need to re-update them again (let's say the Game wipes them later), press the activator again.
Reply


Messages In This Thread
RE: Coding Questions and other Quandaries - by Vega - 12-29-2021, 07:46 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)