Mario Kart Wii Gecko Codes, Cheats, & Hacks
True Velocity Meter [Vega] - Printable Version

+- Mario Kart Wii Gecko Codes, Cheats, & Hacks (https://mariokartwii.com)
+-- Forum: Cheat Codes (https://mariokartwii.com/forumdisplay.php?fid=51)
+--- Forum: Time Trials & Battle (https://mariokartwii.com/forumdisplay.php?fid=54)
+--- Thread: True Velocity Meter [Vega] (/showthread.php?tid=1864)



True Velocity Meter [Vega] - Vega - 07-23-2021

True Velocity Meter [Vega]

This will display your velocity (factoring in force, collisions, gravity, engine speed, etc) in the milliseconds section of your timer. Will only work in Solo TT's.

NTSC-U
C2690444 00000008
2C190000 41820034
C1BA0804 FDA0681C
D9A1FFF8 8181FFFC
3D603B80 7D6B6378
3D80807F 956CD9F8
7C00606C 7C0004AC
7C0067AC 4C00012C
3B390001 00000000

PAL
C26948CC 00000008
2C190000 41820034
C1BA0804 FDA0681C
D9A1FFF8 8181FFFC
3D603B80 7D6B6378
3D808080 956C84F8
7C00606C 7C0004AC
7C0067AC 4C00012C
3B390001 00000000

NTSC-J
C2693F38 00000008
2C190000 41820034
C1BA0804 FDA0681C
D9A1FFF8 8181FFFC
3D603B80 7D6B6378
3D80807F 956C7B64
7C00606C 7C0004AC
7C0067AC 4C00012C
3B390001 00000000

NTSC-K
C2682C74 00000008
2C190000 41820034
C1BA0804 FDA0681C
D9A1FFF8 8181FFFC
3D603B80 7D6B6378
3D80807E 956C68B8
7C00606C 7C0004AC
7C0067AC 4C00012C
3B390001 00000000



Code creator: Vega
Code Credits: JoshuaMK (Millisecond Display Mod)



Source:
Code:
#Address Ports
#NTSC-U = 80690444
#PAL = 806948CC
#NTSC-J = 80693F38
#NTSC-K = 80682C74

#Compilation Region Setting
.set region, ''

#Region Dependent Addresses
.if (region == 'E' || region == 'e') # RMCE
.set millmod, 0x807ED9F8
.elseif (region == 'P' || region == 'p') # RMCP
.set millmod, 0x807F84F8
.elseif (region == 'J' || region == 'j') # RMCJ
.set millmod, 0x807F7B64
.elseif (region == 'K' || region == 'k') # RMCK
.set millmod, 0x807E68B8
.else # Invalid Region
.err
.endif

#Velocity is most updated (r26 correct address) when r25 is 1 (can only be 0 or 1 before default instruction)
cmpwi r25, 0
beq- default_instruction

#Get Velocity
lfs f13, 0x0804 (r26)

#Convert float w/ standard rounding, place conversion into a GPR; no need for fabs, value is always positive
fctiw f13, f13
stfd f13, -0x8 (sp)
lwz r12, -0x4 (sp)

#Modify millisecond value of timer
lis r11, 0x3B80 #Upper bits of new instruction
or r11, r11, r12
lis r12, millmod@ha #Use ha in macro to adjust for possible signed offset values in the following store instruction
stwu r11, millmod@l (r12) #Use stwu for upcoming cache instructions

#Update cache
dcbst 0, r12 #Adjust cache for new instruction
sync
icbi 0, r12
isync

#Default Instruction
default_instruction:
addi r25, r25, 1



RE: Grabbing a specific player's velocity - 1superchip - 07-23-2021

https://github.com/SeekyCt/mkw-structures/blob/master/player.h#L533
Load the pointers to the PlayerSub10 pointer and then load the velocity for the specific player


RE: Grabbing a specific player's velocity - Vega - 07-23-2021

Thanks for the quick reply and the help via Discord. I have looked at the Sub10, I see the normal speed but the velocity I'm looking at doesn't correspond to the velocity in my code or for w/e reason I'm just not seeing it in memory. I guess I could always manually calculate it if I need it for the CPU.


RE: Grabbing a specific player's velocity - Vega - 07-23-2021

Update: Was able to find a velocity reading that i can use on any slot. It was nearby the XYZ position in memory for said player. This one is a bit different than the one in my original post. I guess you can call it Standard Velocity while the one in my original post is True Velocity.

Example: On the 1st TF green belt let yourself ride on the belt without any engine speed, both velocity readings are similar (small amount of velocity cause you are moving). But if you happen to hit the side of the stomper which stops you during the ride, the Standard Velocity reading still shows the same velocity reading (doesn't factor in the stomper hit), but the True Velocity shows a quick spike down in velocity as it's suppose to.

The Standard Velocity has to be one I'm seeing in a lot of TT vids recently as its easy to grab in memory since its right by the XYZ's.

UPDATE 2: Ported rest of code, moved thread. Thx again Chip for the help.