Globe Control [Vega]
#1
Globe Control [Vega]

This is for GCN controller, port 1 only.

This code will allow you to use your C stick to manipulate the WiFi Globe's static position (only at the WiFi Main Menu) depending on which direction the C stick is set to. Meaning, you can rotate the Globe however you want!

NOTE: This code makes use of memory addresses, 0x80000FF8 thru 0x80001007. Make sure no other codes in your GCT/Cheat-Manager are using those addresses.

NTSC-U
04748A8C C03C1000
04748AAC C03C1004
C0000000 00000017
7C0802A6 3D808000
3D608035 894BC204
812C0FF8 C06C1000
48000029 912C0FF8
D06C1000 894BC205
812C0FFC C06C1004
48000011 912C0FFC
D06C1004 48000070
280A00C2 41810010
280A0050 41800010
4E800020 39290001
48000008 3929FFFF
2C0900B3 41810010
2C09FF4D 41800010
48000010 3920FF4D
48000008 392000B3
7D234B78 3CA04330
90A1FFF8 3CA08000
90A1FFFC C841FFF8
6C638000 9061FFFC
C861FFF8 FC631028
4E800020 7C0803A6
4E800020 00000000

PAL
0474DFCC C03C1000
0474DFEC C03C1004
C0000000 00000017
7C0802A6 3D808000
3D608035 894B0584
812C0FF8 C06C1000
48000029 912C0FF8
D06C1000 894B0585
812C0FFC C06C1004
48000011 912C0FFC
D06C1004 48000070
280A00C2 41810010
280A0050 41800010
4E800020 39290001
48000008 3929FFFF
2C0900B3 41810010
2C09FF4D 41800010
48000010 3920FF4D
48000008 392000B3
7D234B78 3CA04330
90A1FFF8 3CA08000
90A1FFFC C841FFF8
6C638000 9061FFFC
C861FFF8 FC631028
4E800020 7C0803A6
4E800020 00000000

NTSC-J
0474D638 C03C1000
0474D658 C03C1004
C0000000 00000017
7C0802A6 3D808000
3D608035 894BFF04
812C0FF8 C06C1000
48000029 912C0FF8
D06C1000 894BFF05
812C0FFC C06C1004
48000011 912C0FFC
D06C1004 48000070
280A00C2 41810010
280A0050 41800010
4E800020 39290001
48000008 3929FFFF
2C0900B3 41810010
2C09FF4D 41800010
48000010 3920FF4D
48000008 392000B3
7D234B78 3CA04330
90A1FFF8 3CA08000
90A1FFFC C841FFF8
6C638000 9061FFFC
C861FFF8 FC631028
4E800020 7C0803A6
4E800020 00000000

NTSC-K
0473C38C C03C1000
0473C3AC C03C1004
C0000000 00000017
7C0802A6 3D808000
3D608034 894BE584
812C0FF8 C06C1000
48000029 912C0FF8
D06C1000 894BE585
812C0FFC C06C1004
48000011 912C0FFC
D06C1004 48000070
280A00C2 41810010
280A0050 41800010
4E800020 39290001
48000008 3929FFFF
2C0900B3 41810010
2C09FF4D 41800010
48000010 3920FF4D
48000008 392000B3
7D234B78 3CA04330
90A1FFF8 3CA08000
90A1FFFC C841FFF8
6C638000 9061FFFC
C861FFF8 FC631028
4E800020 7C0803A6
4E800020 00000000



Source (RAM Writes):

lfs f1, 0x00D0 (r3) changed to lfs f1, 0x1000 (r28) #r28 is always 0x80000000; Load and apply the globe latitude
lfs f1, 0x00CC (r30) changed to lfs f1, 0x1004 (r28) #r28 is always 0x80000000; Load and apply the globe longitude

Source (Execute ASM):
#~~~~~~~~~~~~~~#
#START ASSEMBLY#
#~~~~~~~~~~~~~~#

#

.set region, '' #Fill in E, P, J, or K within the quotes for your region when Compiling! Lowercase letters can also be used.

#~~~~~~~~~~~~~~#
#Register Notes#
#~~~~~~~~~~~~~~#

#r0 = LR Backup
#r3 = Int to Float Routine
#r5 = Int to Float Routine
#r9 = Byte to Load/Store C Stick Increment/Decrement Tracker
#r10 = C Stick Status
#r11 = C Stick Memory Reference
#r12 = 0x80000000; For Exp. Vector Read/Write

#~~~~~~~~~~~~#
#Memory Notes#
#~~~~~~~~~~~~#

#0x80000FF8 = Globe Degree Latitude Integer
#0x80000FFC = Globe Degree Longitude Integer
#0x80001000 = Globe Degree Lateral Floating Point
#0x80001004 = Globe Degree Longitude Floating Point

#~~~~~~~~~#
#Backup LR#
#~~~~~~~~~#

mflr r0

#~~~~~~~~~~~~~~~~~~~~~~#
#Set Exp Vector Address#
#~~~~~~~~~~~~~~~~~~~~~~#

lis r12, 0x8000

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#Set C Stick X/Y Axis Stick Address Reference#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

#RMCE = 0x8034C204/5
#RMCP = 0x80350584/5
#RMCJ = 0x8034FF04/5
#RMCK = 0x8033E584/5

.if (region == 'E' || region == 'e') # RMCE
    lis r11, 0x8035
.elseif (region == 'P' || region == 'p') # RMCP
    lis r11, 0x8035
.elseif (region == 'J' || region == 'j') # RMCJ
    lis r11, 0x8035
.elseif (region == 'K' || region == 'k') # RMCK
    lis r11, 0x8034
.else # Invalid Region
    .abort
.endif

#~~~~~~~~~~~~~~~~~~~~~~~#
#Check X Axis Byte Value#
#~~~~~~~~~~~~~~~~~~~~~~~#

.if (region == 'E' || region == 'e') # RMCE
    lbz r10, 0xFFFFC204 (r11)
.elseif (region == 'P' || region == 'p') # RMCP
    lbz r10, 0x0584 (r11)
.elseif (region == 'J' || region == 'j') # RMCJ
    lbz r10, 0xFFFFFF04 (r11)
.elseif (region == 'K' || region == 'k') # RMCK
    lbz r10, 0xFFFFE584 (r11)
.else # Invalid Region
    .abort
.endif

lwz r9, 0x0FF8 (r12)
lfs f3, 0x1000 (r12)

bl main_routine

stw r9, 0x0FF8 (r12) #Update Globe Latitude Integer Tracker
stfs f3, 0x1000 (r12) #Update the Globe Latitude

#~~~~~~~~~~~~~~~~~~~~~~~#
#Check Y Axis Byte Value#
#~~~~~~~~~~~~~~~~~~~~~~~#

.if (region == 'E' || region == 'e') # RMCE
    lbz r10, 0xFFFFC205 (r11)
.elseif (region == 'P' || region == 'p') # RMCP
    lbz r10, 0x0585 (r11)
.elseif (region == 'J' || region == 'j') # RMCJ
    lbz r10, 0xFFFFFF05 (r11)
.elseif (region == 'K' || region == 'k') # RMCK
    lbz r10, 0xFFFFE585 (r11)
.else # Invalid Region
    .abort
.endif

lwz r9, 0x0FFC (r12)
lfs f3, 0x1004 (r12)

bl main_routine

stw r9, 0x0FFC (r12) #Update Globe Longitude Integer Tracker
stfs f3, 0x1004 (r12) #Update the Globe Longitude

b the_end

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#Main Routine, Calculate Byte Load After Subtraction Equation, Branch Accordingly#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

main_routine:
cmplwi r10, 0xC2
bgt- in_crease
cmplwi r10, 0x50
blt- de_crease

blr #If C Stick wasn't moved far enough, don't update anything

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#Increase/Decrease Globe Integer Lat/Long Degree (Hex Integer)#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

in_crease:
addi r9, r9, 1
b check_for_degree_limit
   
de_crease:
addi r9, r9, -1

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#Check If Globe Degree Limit Has Been Surpassed#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

check_for_degree_limit: #Negative numbers are possible, hence why compares are NOT done as logical
cmpwi r9, 0xB3
bgt- pos_to_neg
cmpwi r9, -0xB3
blt- neg_to_pos

b int_to_float

pos_to_neg:
li r9, -0xB3
b int_to_float

neg_to_pos:
li r9, 0xB3

#~~~~~~~~~~~~~~~~~~~~#
#Hex Integer to Float#
#~~~~~~~~~~~~~~~~~~~~#

int_to_float:
mr r3, r9
lis r5, 0x4330
stw r5, -0x8 (r1)
lis r5, 0x8000
stw r5, -0x4 (r1)
lfd f2, -0x8 (r1) #Load magic double into f2
xoris r3, r3, 0x8000 #Flip sign bit
stw r3, -0x4 (r1) #Store lower half (upper half already stored)
lfd f3, -0x8 (r1)
fsub f3, f3, f2 #Complete conversion
blr

#~~~~~~~#
#The End#
#~~~~~~~#

the_end:
mtlr r0

#blr #If compiling with WiiRGUI, set address to 0x80000000. Uncomment this instruction. Compile code. Change C2 line to C0.

#

#~~~~~~~~~~~~#
#END ASSEMBLY#
#~~~~~~~~~~~~#



Code creator: Vega

Code credits: salmon01 (Int to Float), Atlas (Change Earth Rotation Speed), JoshuaMK (Help with C Stick Values)
Reply
#2
Great work Vega. I’m so proud of you! I can’t wait to put it to use!
Reply
#3
Nice job on this!
Was lucky enough to be one of few to learn proper ASM. Now I'm writing codes that I hope amaze!  Tongue
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)