Graphical WiFi Status & Host Detector [Vega]
#1
Graphical WiFi Status & Host Detector [Vega]

NOTE: It's recommended to also include this code to eliminate frame flickers -> https://mkwii.com/showthread.php?tid=1530

This code will tell you (via a graphical image/message on the bottom left of your screen)) what your Wifi Status is. Thus, you can use this code to see whether or not you are the host of a WW Race/Battle.

List of Graphical Image Outputs:
Idling, or went offline after being Online - ONLINE
Guest (non-host) of race/battle - GUEST
Searching for WW/regional - SEARCH
Joining Open Room - JOIN..
Host of race/battle - HOST
Haven't connected online for first time - N/A

NTSC-U
C200A3F0 00000007
9421FF80 BC610008
806DA358 80630044
80630000 3D808002
618C23E0 7D8803A6
4E800021 B8610008
38210080 80010014
60000000 00000000
C2009640 0000001A
9421FF80 BC610008
3D808000 816C1508
38800000 2C0B0001
41820030 2C0B0002
41820038 2C0B0003
41820040 2C0B0004
41820048 2C0B0005
41820050 3C604E2F
60634100 4800004C
3C604F4E 60634C49
3C804E45 4800003C
3C604755 60634553
3C805400 4800002C
3C605345 60634152
3C804348 4800001C
3C604A4F 6063494E
3C802E2E 4800000C
3C60484F 60635354
6186150C 7C6645AA
38600009 388000DA
38A00001 3FE08002
63EC1DF0 7D8803A6
4E800021 63EC1DD0
7D8803A6 4E800021
B8610008 38210080
81830000 00000000
C20FC4A4 00000002
3D808000 93EC1508
93FC023C 00000000

PAL
C200A430 00000007
9421FF80 BC610008
806DA360 80630044
80630000 3D808002
618C2480 7D8803A6
4E800021 B8610008
38210080 80010014
60000000 00000000
C2009680 0000001A
9421FF80 BC610008
3D808000 816C1508
38800000 2C0B0001
41820030 2C0B0002
41820038 2C0B0003
41820040 2C0B0004
41820048 2C0B0005
41820050 3C604E2F
60634100 4800004C
3C604F4E 60634C49
3C804E45 4800003C
3C604755 60634553
3C805400 4800002C
3C605345 60634152
3C804348 4800001C
3C604A4F 6063494E
3C802E2E 4800000C
3C60484F 60635354
6186150C 7C6645AA
38600009 388000DA
38A00001 3FE08002
63EC1E90 7D8803A6
4E800021 63EC1E70
7D8803A6 4E800021
B8610008 38210080
81830000 00000000
C20FC544 00000002
3D808000 93EC1508
93FC023C 00000000

NTSC-J
C200A38C 00000007
9421FF80 BC610008
806DA360 80630044
80630000 3D808002
618C23A0 7D8803A6
4E800021 B8610008
38210080 80010014
60000000 00000000
C20095DC 0000001A
9421FF80 BC610008
3D808000 816C1508
38800000 2C0B0001
41820030 2C0B0002
41820038 2C0B0003
41820040 2C0B0004
41820048 2C0B0005
41820050 3C604E2F
60634100 4800004C
3C604F4E 60634C49
3C804E45 4800003C
3C604755 60634553
3C805400 4800002C
3C605345 60634152
3C804348 4800001C
3C604A4F 6063494E
3C802E2E 4800000C
3C60484F 60635354
6186150C 7C6645AA
38600009 388000DA
38A00001 3FE08002
63EC1DB0 7D8803A6
4E800021 63EC1D90
7D8803A6 4E800021
B8610008 38210080
81830000 00000000
C20FC464 00000002
3D808000 93EC1508
93FC023C 00000000

NTSC-K
C200A538 00000007
9421FF80 BC610008
806DA380 80630044
80630000 3D808002
618C24E0 7D8803A6
4E800021 B8610008
38210080 80010014
60000000 00000000
C2009788 0000001A
9421FF80 BC610008
3D808000 816C1508
38800000 2C0B0001
41820030 2C0B0002
41820038 2C0B0003
41820040 2C0B0004
41820048 2C0B0005
41820050 3C604E2F
60634100 4800004C
3C604F4E 60634C49
3C804E45 4800003C
3C604755 60634553
3C805400 4800002C
3C605345 60634152
3C804348 4800001C
3C604A4F 6063494E
3C802E2E 4800000C
3C60484F 60635354
6186150C 7C6645AA
38600009 388000DA
38A00001 3FE08002
63EC1EF0 7D8803A6
4E800021 63EC1ED0
7D8803A6 4E800021
B8610008 38210080
81830000 00000000
C20FC5BC 00000002
3D808000 93EC1508
93FC023C 00000000



List of Sources:
1st ASM (When Game loads StaticR.rel, Get Render Mode & Call Direct Print Setup Frame Buffer)

#~~~~~~~~~~~~~~~~#
# START ASSEMBLY #
#~~~~~~~~~~~~~~~~#

#

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# Register Notes: #
# No need to backup r0 or LR #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

#~~~~~~~~~~~~~~~~~~~~~#
# Macros & Statements #
#~~~~~~~~~~~~~~~~~~~~~#

.macro push_stack
stwu r1, -0x80 (r1)
stmw r3, 0x8 (r1)
.endm

.macro pop_stack
lmw r3, 0x8 (r1)
addi r1, r1, 0x80
.endm

.macro call_link address
lis r12, \address@h
ori r12, r12, \address@l
mtlr r12
blrl
.endm

.macro default_instruction
lwz r0, 0x0014 (r1)
.endm

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

.if (region == 'E' || region == 'e') # RMCE
.set nw4r_db_DirectPrint_SetupFB, 0x800223E0
.elseif (region == 'P' || region == 'p') # RMCP
.set nw4r_db_DirectPrint_SetupFB, 0x80022480
.elseif (region == 'J' || region == 'j') # RMCJ
.set nw4r_db_DirectPrint_SetupFB, 0x800223A0
.elseif (region == 'K' || region == 'k') # RMCK
.set nw4r_db_DirectPrint_SetupFB, 0x800224E0
.else # Invalid Region
.abort
.endif

#~~~~~~~~~~~~~~~~~~~~~~~#
# Start Register Safety #
#~~~~~~~~~~~~~~~~~~~~~~~#

push_stack

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# Get Render Mode (RKSystem->mpVideo()->pRenderMode) #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

.if (region == 'E' || region == 'e') # RMCE
lwz r3, -0x5CA8(r13)
.elseif (region == 'P' || region == 'p') # RMCP
lwz r3, -0x5CA0(r13)
.elseif (region == 'J' || region == 'j') # RMCJ
lwz r3, -0x5CA0(r13)
.elseif (region == 'K' || region == 'k') # RMCK
lwz r3, -0x5C80(r13)
.endif

lwz r3, 0x0044(r3)
lwz r3, 0x0 (r3)

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# Call nw4r::db: DirectPrint_SetupFB #
# r3 = Render Mode #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

call_link nw4r_db_DirectPrint_SetupFB

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# End Register Safety; Default Instruction #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

pop_stack
default_instruction

#

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

==========

2nd ASM (Draw Text to Screen)

#~~~~~~~~~~~~~~~~#
# START ASSEMBLY #
#~~~~~~~~~~~~~~~~#

#

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#      Register Notes:      #
# No need to backup r0, or LR #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

#~~~~~~~~~~~~~~~~~~~~~#
# Macros & Statements #
#~~~~~~~~~~~~~~~~~~~~~#

.macro push_stack
    stwu r1, -0x80 (r1)
    stmw r3, 0x8 (r1)
.endm

.macro pop_stack
    lmw r3, 0x8 (r1)
    addi r1, r1, 0x80
.endm

.macro call_nw4r address
    ori r12, r31, \address@l
    mtlr r12
    blrl
.endm

.macro default_instruction
    lwz r12, 0x0 (r3)
.endm

.set region, ''

.if    (region == 'E' || region == 'e') # RMCE
    .set nw4r_db_DirectPrint_Printf, 0x1DF0
    .set nw4r_db_DirectPrint_StoreCache, 0x1DD0
.elseif (region == 'P' || region == 'p') # RMCP
    .set nw4r_db_DirectPrint_Printf, 0x1E90
    .set nw4r_db_DirectPrint_StoreCache, 0x1E70
.elseif (region == 'J' || region == 'j') # RMCJ
    .set nw4r_db_DirectPrint_Printf, 0x1DB0
    .set nw4r_db_DirectPrint_StoreCache, 0x1D90
.elseif (region == 'K' || region == 'k') # RMCK
    .set nw4r_db_DirectPrint_Printf, 0x1EF0
    .set nw4r_db_DirectPrint_StoreCache, 0x1ED0
.else # Invalid Region
    .err
.endif

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#          Mem Address Notes:            #
# 0x80001504 = Online/Offline Status Word #
#      0x80001508 = Wifi Word Number      #
#  0x8000150C thru 1514 = ASCii String  #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

#~~~~~~~~~~~~~~~~~~~~~~~#
# Start Register Safety #
#~~~~~~~~~~~~~~~~~~~~~~~#

push_stack

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# Load WiFi Status Number, Do Checks, Apply ASCii in Registers #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

lis r12, 0x8000
lwz r11, 0x1508 (r12)
li r4, 0x0

cmpwi r11, 0x1
beq- online_1
cmpwi r11, 0x2
beq- guest_2
cmpwi r11, 0x3
beq- search_3
cmpwi r11, 0x4
beq- connectfriend_4
cmpwi r11, 0x5
beq- host_5

lis r3, 0x4E2F
ori r3, r3, 0x4100
b status_done

online_1:
lis r3, 0x4F4E
ori r3, r3, 0x4C49
lis r4, 0x4E45
b status_done

guest_2:
lis r3, 0x4755
ori r3, r3, 0x4553
lis r4, 0x5400
b status_done

search_3:
lis r3, 0x5345
ori r3, r3, 0x4152
lis r4, 0x4348
b status_done

connectfriend_4:
lis r3, 0x4A4F
ori r3, r3, 0x494E
lis r4, 0x2E2E
b status_done

host_5:
lis r3, 0x484F
ori r3, r3, 0x5354

status_done:
ori r6, r12, 0x150C #r6 Arg set for DirectPrint
stswi r3, r6, 8

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#              DirectPrint Printf & Store Cache              #
#                  Purpose: Draw on Screen                    #
#            r3 = X coordinate (starts far left)              #
#            r4 = Y coordinate (starts at very top)          #
#  r5 = 0 No Wrap; 1 Wrap #Put Black Border Fill around text  #
# r6 = Address Pointer to String that will be Drawn on Screen #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

li r3, 0x9  # X coordinate of text start
li r4, 0xDA # Y coordinate of text start
li r5, 0x1  # Wrap text

lis r31, 0x8002 #For nw4r macro

call_nw4r nw4r_db_DirectPrint_Printf
call_nw4r nw4r_db_DirectPrint_StoreCache

#~~~~~~~~~~~~~~~~~~~~~#
# End Register Safety #
#~~~~~~~~~~~~~~~~~~~~~#

pop_stack

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# dont_execute label; Default Instruction #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

default_instruction

#

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

==========

3rd ASM (Store WiFi Status Number):
lis r12, 0x8000
stw r31, 0x1508 (r12)
stw r31, 0x023C (r28) #Default Instruction



Code creator: Vega
Code credits: Star & Riidefi (Draw Text to Screen Code)
Reply


Messages In This Thread
Graphical WiFi Status & Host Detector [Vega] - by Vega - 09-01-2018, 09:24 PM

Forum Jump:


Users browsing this thread: 3 Guest(s)