Graphical Item Warning Offline [Vega]
#1
Graphical Item Warning Offline [Vega]

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

Works Offline only.

This code will place a graphical image on the bottom on your screen saying "ALERT!" whenever someone is holding an item (in inventory) that you have chosen in the code to monitor.

XX Value = Item to Monitor

XX Values:
00 = Green Shell
01 = Red Shell
02 = Banana
03 = Fib
04 = Shroom
05 = Triple Shrooms
06 = Bomb
07 = Blue Shell
08 = Shock
09 = Star
0A = Golden
0B = Mega
0C = Blooper
0D = POW
0E = TC
0F = Bullet Bill
10 = Triple Greens
11 = Triple Reds
12 = Triple Nanas
14 = Nothing / No Item Available

NOTE: This code makes use of the following memory addresses...
0x81500000 thru 0x8150002F
0x81510000 thru 0x81510003

Make sure no other codes in your GCT/Cheat-Manager are using those addresses.

NTSC-U
C200A3F0 00000007
9421FF80 BC610008
806DA358 80630044
80630000 3D808002
618C23E0 7D8803A6
4E800021 B8610008
38210080 80010014
60000000 00000000
C2009640 00000011
3D808151 818C0000
2C0C0000 41820074
9421FF80 BC610008
3DC0814F 61CEFFFC
39E000XX 3A00000C
862E0004 7C117800
41820010 3610FFFF
4082FFF0 4800003C
4800000D 414C4552
54210000 7CC802A6
38600080 388000D8
38A00001 3FE08002
63EC1DF0 7D8803A6
4E800021 63EC1DD0
7D8803A6 4E800021
B8610008 38210080
81830000 00000000
C278EEF8 00000004
801D008C 1D9B0004
3D8C8150 900C0000
3D608151 93AB0000
60000000 00000000

PAL
C200A430 00000007
9421FF80 BC610008
806DA360 80630044
80630000 3D808002
618C2480 7D8803A6
4E800021 B8610008
38210080 80010014
60000000 00000000
C2009680 00000011
3D808151 818C0000
2C0C0000 41820074
9421FF80 BC610008
3DC0814F 61CEFFFC
39E000XX 3A00000C
862E0004 7C117800
41820010 3610FFFF
4082FFF0 4800003C
4800000D 414C4552
54210000 7CC802A6
38600080 388000D8
38A00001 3FE08002
63EC1E90 7D8803A6
4E800021 63EC1E70
7D8803A6 4E800021
B8610008 38210080
81830000 00000000
C2797F04 00000004
801D008C 1D9B0004
3D8C8150 900C0000
3D608151 93AB0000
60000000 00000000


NTSC-J
C200A38C 00000007
9421FF80 BC610008
806DA360 80630044
80630000 3D808002
618C23A0 7D8803A6
4E800021 B8610008
38210080 80010014
60000000 00000000
C20095DC 00000011
3D808151 818C0000
2C0C0000 41820074
9421FF80 BC610008
3DC0814F 61CEFFFC
39E000XX 3A00000C
862E0004 7C117800
41820010 3610FFFF
4082FFF0 4800003C
4800000D 414C4552
54210000 7CC802A6
38600080 388000D8
38A00001 3FE08002
63EC1DB0 7D8803A6
4E800021 63EC1D90
7D8803A6 4E800021
B8610008 38210080
81830000 00000000
C2797570 00000004
801D008C 1D9B0004
3D8C8150 900C0000
3D608151 93AB0000
60000000 00000000


NTSC-K
C200A538 00000007
9421FF80 BC610008
806DA380 80630044
80630000 3D808002
618C24E0 7D8803A6
4E800021 B8610008
38210080 80010014
60000000 00000000
C2009788 00000011
3D808151 818C0000
2C0C0000 41820074
9421FF80 BC610008
3DC0814F 61CEFFFC
39E000XX 3A00000C
862E0004 7C117800
41820010 3610FFFF
4082FFF0 4800003C
4800000D 414C4552
54210000 7CC802A6
38600080 388000D8
38A00001 3FE08002
63EC1EF0 7D8803A6
4E800021 63EC1ED0
7D8803A6 4E800021
B8610008 38210080
81830000 00000000
C27862C4 00000004
801D008C 1D9B0004
3D8C8150 900C0000
3D608151 93AB0000
60000000 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 Source:

#~~~~~~~~~~~~~~~~#
# 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, '' #Must set region value, or else source will not compile

.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

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#      Check to See if a Race is Active:      #
#        Load Status Word from Mem 81          #
# If not zero, we know to execute the Draw Code #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

lis r12, 0x8151
lwz r12, 0x0 (r12)
cmpwi r12, 0x0
beq- dont_execute

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

push_stack

#~~~~~~~~~~~~~~~~~#
# Pre-Loop Config #
#~~~~~~~~~~~~~~~~~#

lis r14, 0x814F #Set address 0x4 before player slot 0 item word address location of 0x81660000
ori r14, r14, 0xFFFC
li r15, 0xXX #User's set item value to Monitor; set a value here when compiling
li r16, 0xC #Run loop max of 12 times for 12 possible players

#~~~~~~#
# Loop #
#~~~~~~#

the_loop:
lwzu r17, 0x0004 (r14)
cmpw r17, r15 #Compare item value of current read player to monitored item value
beq- item_found #If item monitored is held by opponent, jump to item_found label
subic. r16, r16, 1
bne+ the_loop

b not_found #Item not found, skip rest of code, go to pop_stack

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# Item Found, Create ASCII String #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

item_found:
bl ascii_string

.llong 0x414C455254210000 #String for "ALERT!"

ascii_string:
mflr r6 #4th Argument set for DirectPrint Printf

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#              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                    #
# r6 = Address Pointer to String that will be Drawn on Screen #
#              r7 thru r10 printf format args                #
#          f1 thru f13 printf float format args              #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

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

lis r31, 0x8002

call_nw4r nw4r_db_DirectPrint_Printf
call_nw4r nw4r_db_DirectPrint_StoreCache

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

not_found:
pop_stack

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

dont_execute:
default_instruction

#

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

==========

3rd ASM Source:

lwz r0, 0x8C (r29) #Default Instruction, r0 holds current Player/CPU's Held Item
mulli r12, r27, 0x4 #Multiple Player Slot value in r27 by 0x4, put result in r12
addis r12, r12, 0x8150 #Add 0x8150 to upper 16 bits of r12. The player slot will increment/separate the address by 0x4 depending on slot value
stw r0, 0x0 (r12) #Store current Player/CPU's Held Item value to address of r12
lis r11, 0x8151 #Set 1st Half Address for Race-Status Word Check
stw r29, 0x0 (r11) #We need anything not zero at 0x81510000, store r29 to that spot



Code creator: Vega
Code credits: Star & RiiDefi (Draw Text to Screen Code); Bully (Item Spy ASM)
Reply


Messages In This Thread
Graphical Item Warning Offline [Vega] - by Vega - 02-11-2019, 08:26 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)