Item Timer [JoshuaMK]
#1
Item Timer [JoshuaMK]

This code will keep track (via Milliseconds in timer) of how long you have left before your timed item (Mega Mushroom, Golden Mushroom, or Star) runs out. Whenever you are not using any of these items, the timer will function normally.

Works in all modes, offline and online



(NTSC-U)
C27ED9F8 0000000A
A3840008 3D80809C
816CEE20 816B0014
834B00A8 2C1A0000
41810030 816CD110
816B0020 816B0000
816B0010 816B0010
A34B0194 2C1A0000
41810010 AB4B018A
2C1A0000 40A10008
7F5CD378 00000000

(PAL)
C27F84F8 0000000A
A3840008 3D80809C
816C3618 816B0014
834B00A8 2C1A0000
41810030 816C18F8
816B0020 816B0000
816B0010 816B0010
A34B0194 2C1A0000
41810010 AB4B018A
2C1A0000 40A10008
7F5CD378 00000000

(NTSC-J)
C27F7B64 0000000A
A3840008 3D80809C
816C2678 816B0014
834B00A8 2C1A0000
41810030 816C0958
816B0020 816B0000
816B0010 816B0010
A34B0194 2C1A0000
41810010 AB4B018A
2C1A0000 40A10008
7F5CD378 00000000

(NTSC-K)
C27E68B8 0000000A
A3840008 3D80809B
816C1C58 816B0014
834B00A8 2C1A0000
41810030 816CFF38
816B0020 816B0000
816B0010 816B0010
A34B0194 2C1A0000
41810010 AB4B018A
2C1A0000 40A10008
7F5CD378 00000000



.set region, ''

.if    (region == 'E' || region == 'e') # RMCE
        .set UPPER, 0x809C
        .set OFFSET, -0x2EF0
        .set GOLDEN_OFFSET, -0x11E0
.elseif (region == 'P' || region == 'p') # RMCP
        .set UPPER, 0x809C
        .set OFFSET, 0x18F8
        .set GOLDEN_OFFSET, 0x3618
.elseif (region == 'J' || region == 'j') # RMCJ
        .set UPPER, 0x809C
        .set OFFSET, 0x0958
        .set GOLDEN_OFFSET, 0x2678
.elseif (region == 'K' || region == 'k') # RMCK
        .set UPPER, 0x809B
        .set OFFSET, -0x00C8
        .set GOLDEN_OFFSET, 0x1C58
.else # Invalid Region
        .abort
.endif

#Golden mushroom
lhz r28, 0x8 (r4) #Default instruction
lis r12, UPPER
lwz r11, GOLDEN_OFFSET (r12)
lwz r11, 0x14 (r11)
lwz r26, 0xA8 (r11)
cmpwi r26, 0
bgt active

#Mega Mushroom
lwz r11, OFFSET (r12)
lwz r11, 0x20 (r11)
lwz r11, 0 (r11)
lwz r11, 0x10 (r11)
lwz r11, 0x10 (r11)
lhz r26, 0x194 (r11)
cmpwi r26, 0
bgt active

#Star
lha r26, 0x18A (r11)
cmpwi r26, 0
ble+ the_end

active:
mr r28, r26

the_end:



Code Creator: JoshuaMK
Code Contributors: Vega (Hook addresses to find pointers)
(10-14-2019, 11:55 PM)Vega Wrote: Was lucky enough to be one of few to learn proper ASM. Now I just post random garbage on Make it to a 1000 thread.
Was lucky enough to be one of few to learn proper ASM. Now I'm writing codes that I hope amaze!  Tongue
Reply
#2
Does the timer still work if you lose your Timed Item under any condition? (Can't test code atm)
Reply
#3
Yes it does. I made sure to die and get hit a few times and it was working. The problem with your old code is that you hook addresses and stuff for letting the timer act as normal wouldn't be called when a player directly lost their item.

This code however, directly calls the pointer chain for each item accordingly so that the timer value for each timed item is always accessible at any point in time. In this case, being the player's timer hook itself.
(10-14-2019, 11:55 PM)Vega Wrote: Was lucky enough to be one of few to learn proper ASM. Now I just post random garbage on Make it to a 1000 thread.
Was lucky enough to be one of few to learn proper ASM. Now I'm writing codes that I hope amaze!  Tongue
Reply
#4
Very nice. Moved all my timer codes to Incomplete/Outdated.
Reply
#5
Great code, Joshua!
Reply
#6
Btw I noticed you still have the 'untested' next to online Tongue
Reply
#7
Has it been tested?
(10-14-2019, 11:55 PM)Vega Wrote: Was lucky enough to be one of few to learn proper ASM. Now I just post random garbage on Make it to a 1000 thread.
Was lucky enough to be one of few to learn proper ASM. Now I'm writing codes that I hope amaze!  Tongue
Reply
#8
Yes it has. My bad, I forgot to tell you some days ago.
Reply
#9
Well I fixed it Tongue
(10-14-2019, 11:55 PM)Vega Wrote: Was lucky enough to be one of few to learn proper ASM. Now I just post random garbage on Make it to a 1000 thread.
Was lucky enough to be one of few to learn proper ASM. Now I'm writing codes that I hope amaze!  Tongue
Reply
#10
After few testing, I can say that it don't work on Wiimmfi with patched main.dol.
Sad, then I try an Alternative.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)