Graphical Speedometer [SwareJonge]
#1
Graphical Speedometer [SwareJonge]

Shows a Speedometer at the bottom left of the screen.

(NTSC-U)
047E1CC8 4B81F7E8
060014B0 00000080
9421FF80 BC410008
C0230024 3D80802A
398C2D38 806C0344
A0830004 A0A30008
800C0340 481B95B1
480208B9 2C000000
41820040 480206ED
2C030000 41820034
3860000C 388000D8
38A00001 FC200A10
4CC63242 48000011
25332E30 66206B6D
2F680000 7CC802A6
480208D9 480208B5
B8410008 38210080
C0030080 487E07A0


(PAL)
047EB574 4B815F3C
060014B0 00000080
9421FF80 BC410008
C0230024 3D80802A
398C70B8 806C0344
A0830004 A0A30008
800C0340 481B9651
48020959 2C000000
41820040 4802078D
2C030000 41820034
38600009 388000DC
38A00001 FC200A10
4CC63242 48000011
25332E30 66206B6D
2F680000 7CC802A6
48020979 48020955
B8410008 38210080
C0030080 487EA04C

(NTSC-J)
047EABE0 4B8168D0
060014B0 00000080
9421FF80 BC410008
C0230024 3D80802A
398C6A38 806C0344
A0830004 A0A30008
800C0340 481B9571
48020879 2C000000
41820040 480206AD
2C030000 41820034
3860000C 388000D8
38A00001 FC200A10
4CC63242 48000011
25332E30 66206B6D
2F680000 7CC802A6
48020899 48020875
B8410008 38210080
C0030080 487E96B8

(NTSC-K)
047D9934 4B827B7C
060014b0 00000080
9421FF80 BC410008
C0230024 3D808029
398C50B8 806C0344
A0830004 A0A30008
800C0340 481B99AD
480209B9 2C000000
41820040 480207ED
2C030000 41820034
3860000C 388000D8
38A00001 FC200A10
4CC63242 48000011
25332E30 66206B6D
2F680000 7CC802A6
480209D9 480209B5
B8410008 38210080
C0030080 487D840C



Code Creator: SwareJonge



Source:

Code:
.set region, ''
.set codePosition, 0x800014B0

.if     (region == 'E' || region == 'e') # RMCE
        .set instructionAddress, 0x807E1CC8
        .set nw4r_db_DirectPrint_ChangeXfb, 0x80021D90
        .set nw4r_db_DirectPrint_IsActive, 0x80021BD0
        .set nw4r_db_DirectPrint_Printf, 0x80021DF0
        .set nw4r_db_DirectPrint_StoreCache, 0x80021DD0
        .set VIGetNextFrameBuffer, 0x801BAA84
        .set r28thing, 0x802A2d38
.elseif (region == 'P' || region == 'p') # RMCP
        .set instructionAddress, 0x807eb574
        .set nw4r_db_DirectPrint_ChangeXfb, 0x80021e30
        .set nw4r_db_DirectPrint_IsActive, 0x80021c70
        .set nw4r_db_DirectPrint_Printf, 0x80021E90
        .set nw4r_db_DirectPrint_StoreCache, 0x80021E70
        .set VIGetNextFrameBuffer, 0x801BAB24
        .set r28thing, 0x802a70b8
.elseif (region == 'J' || region == 'j') # RMCJ
        .set instructionAddress, 0x807EABE0
        .set nw4r_db_DirectPrint_ChangeXfb, 0x80021D50
        .set nw4r_db_DirectPrint_IsActive, 0x80021B90
        .set nw4r_db_DirectPrint_Printf, 0x80021DB0
        .set nw4r_db_DirectPrint_StoreCache, 0x80021D90
        .set VIGetNextFrameBuffer, 0x801BAA44
        .set r28thing, 0x802A6A38
.elseif (region == 'K' || region == 'k') # RMCK
        .set instructionAddress, 0x807D9934
        .set nw4r_db_DirectPrint_ChangeXfb, 0x80021E90
        .set nw4r_db_DirectPrint_IsActive, 0x80021CD0
        .set nw4r_db_DirectPrint_Printf, 0x80021EF0
        .set nw4r_db_DirectPrint_StoreCache, 0x80021ED0
        .set VIGetNextFrameBuffer, 0x801BAE80
        .set r28thing, 0x802950B8
.else # Invalid Region
        .abort
.endif

.macro push_stack size, registers
      stwu r1, \size(r1)
      stmw \registers, 8(r1)
.endm

.macro pop_stack registers, size
      lmw \registers, 8(r1)
      addi r1, r1, \size
.endm

# 04 Write
#b (0x800014B0 - instructionAddress) # branch to the 06 code

# 06 Write
# Function Prologue...
push_stack -128, r2

lfs f1, 0x0024 (r3) #Load the Speed Float from Pointer into Float Register 1

lis r12,r28thing@h
addi r12, r12, r28thing@l
lwz r3, 0x344(r12)
lhz r4, 0x4(r3) # width
lhz r5, 0x8(r3) # height
lwz r0, 0x340(r12)
bl -((codePosition + 0x24) - VIGetNextFrameBuffer)
bl -((codePosition + 0x28) - nw4r_db_DirectPrint_ChangeXfb)
cmpwi r0, 0x0
beq the_end
bl -((codePosition + 0x34) - nw4r_db_DirectPrint_IsActive)
cmpwi r3, 0x0 # If r3 and r0 equal 0, branch to the end, don't draw
beq the_end

li r3, 0xC
li r4, 0xD8
li r5, 0x1

fabs f1, f1 #Handle negative values
crset 4*cr1+eq #Set the Condition Register before the Float Arg is used in DirectPrint Printf

bl branch_link_write_printf_statement

.string "%3.0f km/h\0"

branch_link_write_printf_statement:
mflr r6 # Store the pointer to the String into r6

bl -((codePosition + 0x68) - nw4r_db_DirectPrint_Printf)
bl -((codePosition + 0x6C) - nw4r_db_DirectPrint_StoreCache)

the_end:

# Function Epilogue...
pop_stack r2, 128

lfs f0, 0x80(r3) # (original instruction)
b -((codePosition + 0x7C) - (instructionAddress+4)) # branch back
#
Reply
#2
All ports working. Nice work on all your recent codes!
Reply
#3
I just noticed this code is broken in local multiplayer mode, i'll try and find a better hook instruction
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)