Golden Mushroom Timer (Online only) [Vega]
#1
Golden Mushroom Timer (Online only) [Vega]

NOTE: Outdated by JoshuaMK's Item Timer Code

Works Online only!

This code will keep track (via Milliseconds in timer) of how long you have left before your Golden Mushroom runs out. Whenever you are not using a Golden, the timer will function normally.

NTSC-U
C2658828 00000003
3D808053 3D6080A1
616B0024 916C10A0
9903001F 00000000
C27ADD30 00000005
3403FFFF 3D808053
41820010 3D6038A0
7D6B0214 4800000C
3D6080A1 616B0024
916C10A0 00000000

PAL
C2660764 00000003
3D808053 3D6080A1
616B0024 916C5BE8
9903001F 00000000
C27BC790 00000005
3403FFFF 3D808053
41820010 3D6038A0
7D6B0214 4800000C
3D6080A1 616B0024
916C5BE8 00000000

NTSC-J
C265FDD0 00000003
3D808053 3D6080A1
616B0024 916C5568
9903001F 00000000
C27BBDFC 00000005
3403FFFF 3D808053
41820010 3D6038A0
7D6B0214 4800000C
3D6080A1 616B0024
916C5568 00000000

NTSC-K
C264EA7C 00000003
3D808052 3D6080A1
616B0024 916C3C40
9903001F 00000000
C27AAB50 00000005
3403FFFF 3D808052
41820010 3D6038A0
7D6B0214 4800000C
3D6080A1 616B0024
916C3C40 00000000

Source for Timer Reset In Between Races:
#Values per Region

.set region, '' #Must set region value, or else source will not compile

.if (region == 'E' || region == 'e') # RMCE
    .set _1sthalf, 0x8053
    .set _2ndhalf, 0x10A0
.elseif (region == 'P' || region == 'p') # RMCP
    .set _1sthalf, 0x8053
    .set _2ndhalf, 0x5BE8
.elseif (region == 'J' || region == 'j') # RMCJ
    .set _1sthalf, 0x8053
    .set _2ndhalf, 0x5568
.elseif (region == 'K' || region == 'k') # RMCK
    .set _1sthalf, 0x8052
    .set _2ndhalf, 0x3C40
.else # Invalid Region
    .abort
.endif

lis r12, _1sthalf
lis r11, 0x80A1 #Default Word Value (instruction) at Millisecond Display Code Address
ori r11, r11, 0x0024
stw r11, _2ndhalf (r12)

stb r8, 0x001F (r3) #Default Instruction


=====

Source for Golden Mushroom Timer (NTSC-K):
subic. r0, r3, 1 #Default ASM, Condition Register is now set

lis r12, 0x8052 #Set 1st half address for Millisecond Display Modifier address

beq- fix_timer #If value in r0 is equal to 0, we need to now set the timer back to normal, jump to fix_timer label

lis r11, 0x38A0 #Set 1st half of word value to write to Millisecond Display address
add r11, r11, r0 #Add r11 and r0 together to get finalized word value

b the_end #No need to fix timer ofc, jump to the_end label

fix_timer:
lis r11, 0x80A1 #Set 1st half of default word value to write to Millisecond Display address
ori r11, r11, 0x0024 #Set 2nd half of default word value

the_end:
stw r11, 0x3C40 (r12) #Store word of r11 to 0x80523C40, 2nd half of address completed by offset

Code creator: Vega
Code credits: Bully (Millisecond Display Modifier & Address founder for Golden Mushroom ASM)
Reply
#2
Good code Vega, but I have a question.

I noticed that the timer freezes if there's a shock or anything that makes you lose the golden mushroom.

Is there any way to improve that so that the timer still works normal if you lose the golden mushroom?
Reply
#3
Here ya go

Try this in battle too. Also try losing your item via respawn.

#Code creator: Vega
#Code credits: JoshuaMK (timer), Xer (lose item hook)

#Ports
#80658828 NTSC-U
#80660764 PAL
#8065FDD0 NTSC-J
#8064EA7C NTSC-K

#Hook to reset timer in between races

.set region, '' #Must set region value, or else source will not compile

.if (region == 'E' || region == 'e') # RMCE
.set _1sthalf, 0x807F
.set _2ndhalf, 0xFFFFD9F8
.elseif (region == 'P' || region == 'p') # RMCP
.set _1sthalf, 0x8080
.set _2ndhalf, 0xFFFF84F8
.elseif (region == 'J' || region == 'j') # RMCJ
.set _1sthalf, 0x807F
.set _2ndhalf, 0x7B64
.elseif (region == 'K' || region == 'k') # RMCK
.set _1sthalf, 0x807E
.set _2ndhalf, 0x68B8
.else # Invalid Region
.err
.endif

lis r12, _1sthalf
lis r11, 0xA384 #Default Word Value (instruction) at Millisecond Display Code Address
ori r11, r11, 0x0008
stw r11, _2ndhalf (r12)

stb r8, 0x001F (r3) #Default Instruction

##############################

#Ports
#807ADD30 NTSC-U
#807BC790 PAL
#807BBDFC NTSC-J
#807AAB50 NTSC-K

#Hook to modify timer

.set region, '' #Must set region value, or else source will not compile

.if (region == 'E' || region == 'e') # RMCE
.set _1sthalf, 0x807F
.set _2ndhalf, 0xFFFFD9F8
.elseif (region == 'P' || region == 'p') # RMCP
.set _1sthalf, 0x8080
.set _2ndhalf, 0xFFFF84F8
.elseif (region == 'J' || region == 'j') # RMCJ
.set _1sthalf, 0x807F
.set _2ndhalf, 0x7B64
.elseif (region == 'K' || region == 'k') # RMCK
.set _1sthalf, 0x807E
.set _2ndhalf, 0x68B8
.else # Invalid Region
.err
.endif

subic. r0, r3, 1 #Default Instruction, Condition Register is now set

lis r12, _1sthalf #Set 1st half address for Millisecond Display Modifier address

beq- fix_timer #If value in r0 is equal to 0, we need to now set the timer back to normal, jump to fix_timer label

oris r11, r0, 0x3B80 #Or 0x3B800000 and r0 together to get finalized word value

b the_end #No need to fix timer ofc, jump to the_end label

fix_timer:
lis r11, 0xA384 #Set 1st half of default word value to write to Millisecond Display address
ori r11, r11, 0x0008 #Set 2nd half of default word value

the_end:
stw r11, _2ndhalf (r12) #Store word of r11 to 0x80523C40, 2nd half of address completed by offset

################################

#Ports
#807AD73C NTSC-U
#807BC19C PAL
#807BB808 NTSC-J
#807AA55C NTSC-K

#Hook to reset timer if you lose your item

.set region, '' #Must set region value, or else source will not compile

.if (region == 'E' || region == 'e') # RMCE
.set _1sthalf, 0x807F
.set _2ndhalf, 0xFFFFD9F8
.elseif (region == 'P' || region == 'p') # RMCP
.set _1sthalf, 0x8080
.set _2ndhalf, 0xFFFF84F8
.elseif (region == 'J' || region == 'j') # RMCJ
.set _1sthalf, 0x807F
.set _2ndhalf, 0x7B64
.elseif (region == 'K' || region == 'k') # RMCK
.set _1sthalf, 0x807E
.set _2ndhalf, 0x68B8
.else # Invalid Region
.err
.endif

lis r12, _1sthalf
lis r11, 0xA384 #Default Word Value (instruction) at Millisecond Display Code Address
ori r11, r11, 0x0008
stw r11, _2ndhalf (r12)

stw r0, 0x0008 (r3) #Default Instruction
Reply
#4
Is this correct compiled for pal? If yes, it does not write to the timer.

C2660764 00000003
3D808080 3D60A384
616B0008 916C84F8
9903001F 00000000
C27BC790 00000004
3403FFFF 3D808080
4182000C 640B3B80
4800000C 3D60A384
616B0008 916C84F8
60000000 00000000
C27BC19C 00000003
3D808080 3D60A384
616B0008 916C84F8
90030008 00000000
Reply
#5
Ye I implemented Joshua's timer code which does work but maybe needs a cache flush.

You can try to use bullys old timer the way the code in the OP does

change all the macro-region stuff to this..

.set region, '' #Must set region value, or else source will not compile

.if (region == 'E' || region == 'e') # RMCE
.set _1sthalf, 0x8053
.set _2ndhalf, 0x10A0
.elseif (region == 'P' || region == 'p') # RMCP
.set _1sthalf, 0x8053
.set _2ndhalf, 0x5BE8
.elseif (region == 'J' || region == 'j') # RMCJ
.set _1sthalf, 0x8053
.set _2ndhalf, 0x5568
.elseif (region == 'K' || region == 'k') # RMCK
.set _1sthalf, 0x8052
.set _2ndhalf, 0x3C40
.else # Invalid Region
.err
.endif

And any source parts that contain this...
lis r12, _1sthalf
lis r11, 0xA384 #Default Word Value (instruction) at Millisecond Display Code Address
ori r11, r11, 0x0008
stw r11, _2ndhalf (r12)

---
lis r11, 0xA384 #Set 1st half of default word value to write to Millisecond Display address
ori r11, r11, 0x0008 #Set 2nd half of default word value

Change the A3840008 to 80A10024

And in the second ASM..
oris r11, r0, 0x3B80

change that to oris r11, r0, 0x38A0
Reply
#6
Done and it works! Thank you. Will you edit the code above?
Reply
#7
Your compiled code (on the 2nd ASM) is wrong. the Byte that tells the handler the length of lines below is 4 instead of 5.

and that's my fault cause I just realized I messed up with J and K macros which I bet you had to manually fix/delete them before compiling and somehow this messed up the compilation. I revised the source that's in Post #3. Heres the PAL compiled version with a Shared Item code of Golden attached

C2660764 00000003
3D808080 3D60A384
616B0008 916C84F8
9903001F 00000000
C27BC790 00000005
3403FFFF 3D808080
4182000C 640B3B80
4800000C 3D60A384
616B0008 916C84F8
60000000 00000000
C27BC19C 00000003
3D808080 3D60A384
616B0008 916C84F8
90030008 00000000
C27BA164 00000002
3860000A 90770020
60000000 00000000

Works fine for me on USB Loader GX r1272 with standard VBI hook.

The only issue I found is that when I was falling off the map in battle during a Golden, the timer wouldn't reset. So i need yet another hook for that... Lol
Reply
#8
Why is this online only? I was looking at the source and I see you using hooks to change instructions. I'm gonna overhaul this code lol
Super Mario Eclipse, what Super Mario Sunshine could've been.
Reply
#9
This isn't offline only? It's for online use. I use a hook that iirc only happens online to reset the timer in between races. So that should be an easy hook change to make this also work offline
Reply
#10
I edited online right after you saw this Tongue It was a typo that I put offline
Super Mario Eclipse, what Super Mario Sunshine could've been.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)