Auto Attempt to Use Dodge Item When Shocked -Online- [Vega]
#1
Auto Attempt to Use Dodge Item When Shocked -Online- [Vega]

Outdated by Unnamed's version which works 100% reliably.

Online only.

If you are holding a Mega, Star, or Bullet Bill when the shock occurs, you will automatically attempt to use your item and dodge the shock. Whether or not you dodge the shock depends a lot on the natneg between the clients.

Non-stable natneg between the clients will most likely cause a missed dodge, therefore I wouldn't call this code reliable enough to depend on as a way to always dodge shocks. Also for any moments where you normally can't use an item (i.e. during exit of cannon, spinning from getting hit by an item, etc), the code also won't work.

If desired, you can actually edit this code to effect other items instead of the 3 default ones. The compiled lines of "2C0C0009, 000B, and 000F" are the checks for Mega, Star, and Bill.

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

NTSC-U
C265EE14 00000002
88030001 3D808000
980C0299 00000000
C21D1880 00000004
81670008 7D4902A6
2C0A007B 40A20010
556A463E 3D208000
99490298 00000000
C251CE8C 0000000C
3D808000 896C0298
2C0B0026 41820010
39600000 996C029A
4800003C 896C029A
2C0B0000 40820030
39600001 996C029A
898C0299 2C0C0009
41820018 2C0C000B
41820010 2C0C000F
41820008 48000008
60000004 B01E002C
60000000 00000000

PAL
C265E18C 00000002
88030001 3D808000
980C0299 00000000
C21D1920 00000004
81670008 7D4902A6
2C0A007B 40A20010
556A463E 3D208000
99490298 00000000
C2521300 0000000C
3D808000 896C0298
2C0B0026 41820010
39600000 996C029A
4800003C 896C029A
2C0B0000 40820030
39600001 996C029A
898C0299 2C0C0009
41820018 2C0C000B
41820010 2C0C000F
41820008 48000008
60000004 B01E002C
60000000 00000000

NTSC-J
C265D7F8 00000002
88030001 3D808000
980C0299 00000000
C21D1840 00000004
81670008 7D4902A6
2C0A007B 40A20010
556A463E 3D208000
99490298 00000000
C2520C80 0000000C
3D808000 896C0298
2C0B0026 41820010
39600000 996C029A
4800003C 896C029A
2C0B0000 40820030
39600001 996C029A
898C0299 2C0C0009
41820018 2C0C000B
41820010 2C0C000F
41820008 48000008
60000004 B01E002C
60000000 00000000

NTSC-K
C264C4A4 00000002
88030001 3D808000
980C0299 00000000
C21D1C7C 00000004
81670008 7D4902A6
2C0A007B 40A20010
556A463E 3D208000
99490298 00000000
C250F324 0000000C
3D808000 896C0298
2C0B0026 41820010
39600000 996C029A
4800003C 896C029A
2C0B0000 40820030
39600001 996C029A
898C0299 2C0C0009
41820018 2C0C000B
41820010 2C0C000F
41820008 48000008
60000004 B01E002C
60000000 00000000



Code creator: Vega

Code credits: Seeky (Timed Item Usage Hook), Bully (Local Item Spy Hook)





List of Sources:

1st ASM: (Store Held Item to Memory)
Address Ports
NTSC-U = 0x8065EE14
PAL = 0x8065E18C
NTSC-J = 0x8065D7F8
NTSC-K = 0x8064C4A4

lbz r0, 0x1 (r3) #Default Instruction
lis r12, 0x8000
stb r0, 0x0299 (r12)

=====

2nd ASM: (Store Item Event to Memory)
Address Ports
NTSC-U = 0x801D1880
PAL = 0x801D1920
NTSC-J = 0x801D1840
NTSC-K = 0x801D1C7C

lwz r11, 0x0008 (r7) #Default Instruction
mfctr r10 #r10 safe for use
cmpwi r10, 0x7B #When CTR is decremented to 0x7B, r11's first byte will hold proper Item Event byte slot
bne+ the_end

srwi r10, r11, 24 #Item Event (that holds Shock) now only byte left in register
lis r9, 0x8000 #r12 NOT safe for use!
stb r10, 0x0298 (r9)

the_end:

=====

3rd ASM: (Auto Use Dodge Item When Shocked)

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

#

#~~~~~~~~~~~~~~~#
# Address Ports #
#~~~~~~~~~~~~~~~#

#0x8051CE8C NTSC-U
#0x80521300 PAL
#0x80520C80 NTSC-J
#0x8050F324 NTSC-K

#~~~~~~~~~~~~~~~~~~~~~~~~#
# Exception Vector Notes #
#~~~~~~~~~~~~~~~~~~~~~~~~#

#0x80000298 = Event Type
#0x80000299 = Your Held Item
#0x8000029A = Shock Status; Custom

#~~~~~~~~~~~~~~~~~~~~~~~~~~#
# Load & Verify Event Type #
#~~~~~~~~~~~~~~~~~~~~~~~~~~#

lis r12, 0x8000
lbz r11, 0x0298 (r12)
cmpwi r11, 0x26
beq- shock_event_occurring

#~~~~~~~~~~~~~~~~~~~#
# Reset Status Byte #
#~~~~~~~~~~~~~~~~~~~#

li r11, 0 #Always reset when shock event isn't occuring
stb r11, 0x029A (r12)
b default_instruction

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# Load & Verify Shock Status Byte #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

shock_event_occurring:
lbz r11, 0x029A (r12)
cmpwi r11, 0
bne- default_instruction

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# Update Status Byte, Load & Verify Item #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

#The 0x26 event byte can last for a tiny bit cause of natneg, therefore
#we set this status byte to 1, so the code won't autouse your
#next item if you chain right before a box and your next
#item is a bill, mega, or star.

#Once event byte is no longer 0x26, the status byte
#gets reset to 0, refer to "Reset Status Byte" portion of source

li r11, 1
stb r11, 0x029A (r12)

lbz r12, 0x0299 (r12)

cmpwi r12, 0x9 #Star
beq- go
cmpwi r12, 0xB #Mega
beq- go
cmpwi r12, 0xF #Bullet
beq- go
b default_instruction

#~~~~~~~~~~~~~~~~~~~~~~~~~~#
# Flip the Item Usage Bit! #
#~~~~~~~~~~~~~~~~~~~~~~~~~~#

go:
ori r0, r0, 0x0004

#~~~~~~~~~~~~~~~~~~~~~#
# Default Instruction #
#~~~~~~~~~~~~~~~~~~~~~#

default_instruction:
sth r0, 0x002C (r30)

#

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


Reply
#2
Awesome! Smile
Reply
#3
After more testing it appears misses can happen quite a bit. Natneg really effects the performance of this code.

Title/Description updated accordingly
Reply
#4
This code is very cool, but I think it can be improved. It happens quite seldom, but it can happen that e.g. the second to last person uses a star just before an itembox and gets another star.  The last player then gets a shock and fires immediately. If the second last player has already stopped the roulette, the code uses the star in the inventory, even though he is still in star state. However, according to the item rules, you could keep the star for another 30 seconds before the next shock could arrive.

Therefore you could add a state check to check if you are in mega state or star state. If so, the code can be skipped. Now you just need to know where the status bytes are located. I'm going to ask you that anyway.
Reply
#5
The code just needs the correct breakpoint address (in regards to the 2nd ASM), it's way too hard to try to find it in a conventional code-making sense. So I had to 'rig' a lot of instructions with a crappy address for this to even 'work'.

Someone who knows a lot about the event packets/rules (like Star) can definitely make the correct 'version' of this where it works 100% of the time.
Reply
#6
Just fyi, the adresses 0x80000298 to 0x8000029A are UNSAFE bytes of the EVA (at least for PAL). The first safe bytes after those adresses start at 0x800002B0 (for PAL).

I noticed that because I am trying to improve the code.
Reply
#7
Yes, iirc I made this code when I grabbed the EVA range off either the Wii only or Dolphin only (instead of looking at both at the time). Regardless ,the EVA is still "safe" because it's rewriting over the Machine Check Exception. If you get a Machine Check, you're not going to recover from it.

As an fyi to the EVA's, if you don't plan on ever using the PPC Instruction BP feature, you can write over the 0x1300 vector. The 0x1400 vector is completely unused (and never will be used by normal game function) even though instructions reside there. The 0x1700 vector is for thermal stuff which was simply carried over from Gekko but isn't applicable to Broadway. Thus, it's unused and you can write over it.

Same concept with the Trace and PM vectors, if you don't plan on using them and don't supplement other codes that use said vector(s), you can write over them.

And I'm looking forward to your rewrite!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)