The following warnings occurred:
Warning [2] Undefined property: MyLanguage::$archive_pages - Line: 2 - File: printthread.php(287) : eval()'d code PHP 8.2.18 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/printthread.php(287) : eval()'d code 2 errorHandler->error_callback
/printthread.php 287 eval
/printthread.php 117 printthread_multipage



Mario Kart Wii Gecko Codes, Cheats, & Hacks
Item Timer [JoshuaMK] - Printable Version

+- Mario Kart Wii Gecko Codes, Cheats, & Hacks (https://mariokartwii.com)
+-- Forum: Cheat Codes (https://mariokartwii.com/forumdisplay.php?fid=51)
+--- Forum: Online; Item (https://mariokartwii.com/forumdisplay.php?fid=57)
+--- Thread: Item Timer [JoshuaMK] (/showthread.php?tid=1481)

Pages: 1 2


Item Timer [JoshuaMK] - JoshuaMK - 03-18-2020

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)


RE: Item Timer [JoshuaMK] - Vega - 03-18-2020

Does the timer still work if you lose your Timed Item under any condition? (Can't test code atm)


RE: Item Timer [JoshuaMK] - JoshuaMK - 03-18-2020

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.


RE: Item Timer [JoshuaMK] - Vega - 03-18-2020

Very nice. Moved all my timer codes to Incomplete/Outdated.


RE: Item Timer [JoshuaMK] - Unnamed - 03-19-2020

Great code, Joshua!


RE: Item Timer [JoshuaMK] - Vega - 03-26-2020

Btw I noticed you still have the 'untested' next to online Tongue


RE: Item Timer [JoshuaMK] - JoshuaMK - 03-26-2020

Has it been tested?


RE: Item Timer [JoshuaMK] - Vega - 03-26-2020

Yes it has. My bad, I forgot to tell you some days ago.


RE: Item Timer [JoshuaMK] - JoshuaMK - 03-26-2020

Well I fixed it Tongue


RE: Item Timer [JoshuaMK] - Unnamed - 06-23-2020

After few testing, I can say that it don't work on Wiimmfi with patched main.dol.
Sad, then I try an Alternative.

EDIT: It looks like the code is not quite correct. It loads the pointer, but always only the one for the player in the first item slot (Player 0). I have seen with the "Mega lasts forever" code from mdmwii that it stores this value and adds between lwz r11, 0x20 (r11) and lwz r11, 0x0 (r11) to the address. Then the mega and star timer worked fine for me. Maybe you can test it yourself and judge what I have said. Here is the PAL code, I have marked the Changes in red:

Mega Timer PAL
C27EEFB0 00000003
3FA08000 1CA00004
B0BD0FC8 1FA00248
60000000 00000000
C27F84F8 00000006
3D60809C 816B18F8
816B0020 3D808000
A18C0FC8 7D6C5A14
816B0000 816B0010
816B0010 A34B0194
7F5CD378 00000000

The First ASM stores the local player item slot to the Memory Location 80000FC8 and in the Timer ASM, this Value is loaded and add to the Adress to compute the correct pointer.
I only don't know how to use it for the Golden Timer, that should then somehow work similarly.