ASM Activator/Deactivator For Dolphin [Vega]
#1
ASM Activator/Deactivator For Dolphin [Vega]

On Dolphin the standard 2833/2834XXXX YYYYZZZZ' controller activator/deactivator lines do not work on older dev versions unless some Graphic Hacks are done via Graphics Config. Therefore in order to activate/deactivate codes, extra ASM must be written to the codes source. I decided to make this code for veteran ASM coders. At memory address 0x800015F0, the byte with value of 1 would be code activated, and 0 would be deactivated. Simply use this code, and then edit in the correct ASM functions on your current ASM code to read the byte value at 0x800015F0, and have the code activate/deactivate to that byte value accordingly. Obviously, you don't have to use that address, feel free to use whatever address you want for the byte value. Also, the base address of my code is constantly read by the game in all modes. It will instantly breakpoint at any time the game is running. This is needed because let's say your own code will have a base address that will only breakpoint when you grab an item box. Well if you don't use my code, you would be required to hold your activator/deactivator while picking up a box for activator/deactivator to take effect within your code.

NTSC-U
C21AA91C 0000000A
3D808034 618CXXXX
A18C0000 3960ZZZZ
3880zzzz 7D805838
7C005800 41820014
7D802038 7C002000
41820014 4800001C
3D808000 39600001
4800000C 3D808000
39600000 996C15F0
7C0802A6 00000000

PAL
C21AA9BC 0000000A
3D808034 618CXXXX
A18C0000 3960ZZZZ
3880zzzz 7D805838
7C005800 41820014
7D802038 7C002000
41820014 4800001C
3D808000 39600001
4800000C 3D808000
39600000 996C15F0
7C0802A6 00000000

NTSC-J
C21AA8DC 0000000A
3D808034 618CXXXX
A18C0000 3960ZZZZ
3880zzzz 7D805838
7C005800 41820014
7D802038 7C002000
41820014 4800001C
3D808000 39600001
4800000C 3D808000
39600000 996C15F0
7C0802A6 00000000

NTSC-K
C21AAD18 0000000A
3D808033 618CXXXX
A18C0000 3960ZZZZ
3880zzzz 7D805838
7C005800 41820014
7D802038 7C002000
41820014 4800001C
3D808000 39600001
4800000C 3D808000
39600000 996C15F0
7C0802A6 00000000

XXXX = Controller Address
ZZZZ = Activator
zzzz = Deactivator



SOURCE (NTSC-K):

####################
###START ASSEMBLY###
####################

#

##########################
##Set Controller Address##
##########################

lis r12, 0x8033 #Set 1st half address for Korean Controller
ori r12, r12, 0xXXXX #Set 2nd half address (XXXX) for specific Korean Controller

##############################################
##Load Current Halfword of Button(s) Pressed##
##############################################

lhz r12, 0x0 (r12) #Load Halfword from specific Korean Controller Address

########################
##Set User Act & Deact##
########################

li r11, 0xZZZZ #Load Activator value into r11
li r4, 0xzzzz #Load De-Activator value into r4

###########################
##Check if Act is Pressed##
###########################

and r0, r12, r11 #Logically AND the contents of buttons being pressed versus your activator. If activator is at least pressed, r0 will equal 11.
cmpw r0, r11
beq- set_act #If equal (activator pressed), jump to set_act label

#############################
##Check if Deact is Pressed##
#############################

and r0, r12, r4 #Logically AND the contents of buttons being pressed versus your deactivator. If second activator is at least pressed, r0 will equal r4.
cmpw r0, r4
beq- set_deact #If equal (other activator preseed), jump to set_deact label

###########################################
##Jump to End (Act nor Deact were Pressed##
###########################################

b the_end #If ZZZZ nor zzzz wasn't pressed, jump to the_end label

#################
##Set_Act Label##
#################

set_act:
lis r12, 0x8000 #Set first half address for code activation status number
li r11, 1 #Load code activation status number in r11
b store_byte #Jump to store_byte label

###################
##Set_Deact Label##
###################

set_deact:
lis r12, 0x8000 #Set first half address for code deactivation status number
li r11, 0 #Load code deactivation status number in r11

####################
##Store_Byte Label##
####################

store_byte:
stb r11, 0x15F0 (r12) #Store code deactivation status number to mem location 0x800015F0

#################
##The_End Label##
#################

the_end:
mflr r0 #Default ASM

#############################################
##Notes about Using r0 & r4 w/o Restoration##
#############################################

##r0 gets written to later on by a mflr 0, and r4 gets written to after a BL during a rlwinm function##
##Thus, they are safe to use w/o restoring original values##

#

##################
###END ASSEMBLY###
##################



Code creator: Vega
Code contributor(s): Megazig (OSSleepThread subroutine)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)