-==-
!
ASM - Dpad up/down toggles rumble on CSS
[Dan Salvato]
Revision ---- DOL Offset ---- Hex to Replace ---------- ASM Code -
NTSC 1.02 --- 0x802608D8 ---- 889F0004 -> Branch
# code written by Dan Salvato
# comments by Punkline
# registers:
.set rPadID, 23 # HSD PAD ID identifies the controller port
.set rPad, 28 # HSD PAD structure contains input information
.set rCursor, 31 # structure contains cursor coordinates
# offsets:
.set xPadID, 0x4
.set xShakeFlag, 0x7
.set xCursorX, 0xC
.set xShakeTrans, 0x14
# masks:
.set mDPadUp, 0x08
.set mDPadDown, 0x04
# states:
.set Shaking, 1
.set NotShaking, 0
_check_shaking:
lbz r3, xShakeFlag(rCursor)
cmpwi r3, NotShaking
bne- _shaking
# if flag != 0, then cursor is shaking
# else, check for dpad inputs
_check_dpad_up:
mr rPadID, r4
rlwinm. r0, rPad, 0, mDPadUp
bne- _enable
# if dpad up, then enable rumble
_check_dpad_down:
rlwinm. r0, rPad, 0, mDPadDown
bne- _disable
b _return
# if dpad down, then disable rumble; else, do nothing
_enable:
mr r3, rPadID
li r4, 0
li r5, 14
li r6, 0
subi r7, r13, 0x66B0 # NTSC 1.00, 1.01, 1.02
##subi r7, r13, 0x6500 # PAL
# r13 reference needs to be ported
bl 0x80378430 # 1.02
##bl 0x80378334 # PAL
##bl 0x80377750 # 1.01
##bl 0x8037657C # 1.00
# HSD_PadRumbleActiveId
li r4, 1
b _set_rumble_flag
# enabled
_disable:
li r4, 0
# if disabling, r4 = 0 instead of 1
_set_rumble_flag:
mr r3, rPadID
bl 0x8015ED4C # 1.02
##bl 0x8015F4F0 # PAL
##bl 0x8015E8B0 # 1.01
##bl 0x8015E2D0 # 1.00
# Rumble_StoreRumbleFlag
_initialize_shaking_state:
li r4, Shaking
stb r4, xShakeFlag(rCursor)
lis r4, 0xC040 # -3
stw r4, xShakeTrans(rCursor)
# shaking state has been initialized
_shaking:
lfs f1, xShakeTrans(rCursor)
lis r0, 0x3F4C # ~0.8
stw r0, -0x10(sp)
lfs f2, -0x10(sp)
lfs f0, xCursorX(rCursor)
# f0 = Cursor X position
# f1 = Decaying shake translation
# f2 = ~0.8
fadds f0, f1, f0
stfs f0, xCursorX(rCursor)
# apply shake translation to current X position
fneg f3, f1
# f3 = old shake translation * -1.0
fcmpo cr0, f3, f1
bgt- _store_cursor_X
fmuls f3, f3, f2
# if new translation value is positive,
# then we decay the value with *= 0.8
_store_cursor_X:
stfs f3, xShakeTrans(rCursor)
blt- _return
# shake translation has been updated for next frame
_check_for_shake_end:
lis r0, 0x3C80
stw r0, -0x10(sp)
lfs f4, -0x10(sp)
# f4 = 0.015625
fcmpo cr0, f3, f4
bgt- _return
# if decay has almost reached 0, then exit Shaking state
_end_of_shake_effect:
li r4, NotShaking # null used as both bool and float
stw r4, xShakeTrans(rCursor) # 0.0
stb r4, xShakeFlag(rCursor) # 00
# no longer in Shaking state
_return:
lbz r4, xPadID(rCursor)
.long 0
PAL 1.00 --- 0x80261078 ---- 889F0004 -> Branch
.set rPadID, 23
.set rPad, 28
.set rCursor, 31
.set xPadID, 0x4
.set xShakeFlag, 0x7
.set xCursorX, 0xC
.set xShakeTrans, 0x14
.set mDPadUp, 0x08
.set mDPadDown, 0x04
.set Shaking, 1
.set NotShaking, 0
_check_shaking:
lbz r3, xShakeFlag(rCursor)
cmpwi r3, NotShaking
bne- _shaking
_check_dpad_up:
mr rPadID, r4
rlwinm. r0, rPad, 0, mDPadUp
bne- _enable
_check_dpad_down:
rlwinm. r0, rPad, 0, mDPadDown
bne- _disable
b _return
_enable:
mr r3, rPadID
li r4, 0
li r5, 14
li r6, 0
##subi r7, r13, 0x66B0 # NTSC 1.00, 1.01, 1.02
subi r7, r13, 0x6500 # PAL
# r13 reference needs to be ported
##bl 0x80378430 # 1.02
bl 0x80378334 # PAL
##bl 0x80377750 # 1.01
##bl 0x8037657C # 1.00
# HSD_PadRumbleActiveId
li r4, 1
b _set_rumble_flag
_disable:
li r4, 0
_set_rumble_flag:
mr r3, rPadID
##bl 0x8015ED4C # 1.02
bl 0x8015F4F0 # PAL
##bl 0x8015E8B0 # 1.01
##bl 0x8015E2D0 # 1.00
# Rumble_StoreRumbleFlag
_initialize_shaking_state:
li r4, Shaking
stb r4, xShakeFlag(rCursor)
lis r4, 0xC040 # -3
stw r4, xShakeTrans(rCursor)
_shaking:
lfs f1, xShakeTrans(rCursor)
lis r0, 0x3F4C # ~0.8
stw r0, -0x10(sp)
lfs f2, -0x10(sp)
lfs f0, xCursorX(rCursor)
fadds f0, f1, f0
stfs f0, xCursorX(rCursor)
fneg f3, f1
fcmpo cr0, f3, f1
bgt- _store_cursor_X
fmuls f3, f3, f2
_store_cursor_X:
stfs f3, xShakeTrans(rCursor)
blt- _return
_check_for_shake_end:
lis r0, 0x3C80
stw r0, -0x10(sp)
lfs f4, -0x10(sp)
fcmpo cr0, f3, f4
bgt- _return
_end_of_shake_effect:
li r4, NotShaking
stw r4, xShakeTrans(rCursor)
stb r4, xShakeFlag(rCursor)
_return:
lbz r4, xPadID(rCursor)
.long 0
NTSC 1.01 --- 0x8026013C ---- 889F0004 -> Branch
.set rPadID, 23
.set rPad, 28
.set rCursor, 31
.set xPadID, 0x4
.set xShakeFlag, 0x7
.set xCursorX, 0xC
.set xShakeTrans, 0x14
.set mDPadUp, 0x08
.set mDPadDown, 0x04
.set Shaking, 1
.set NotShaking, 0
_check_shaking:
lbz r3, xShakeFlag(rCursor)
cmpwi r3, NotShaking
bne- _shaking
_check_dpad_up:
mr rPadID, r4
rlwinm. r0, rPad, 0, mDPadUp
bne- _enable
_check_dpad_down:
rlwinm. r0, rPad, 0, mDPadDown
bne- _disable
b _return
_enable:
mr r3, rPadID
li r4, 0
li r5, 14
li r6, 0
subi r7, r13, 0x66B0 # NTSC 1.00, 1.01, 1.02
##subi r7, r13, 0x6500 # PAL
# r13 reference needs to be ported
##bl 0x80378430 # 1.02
##bl 0x80378334 # PAL
bl 0x80377750 # 1.01
##bl 0x8037657C # 1.00
# HSD_PadRumbleActiveId
li r4, 1
b _set_rumble_flag
_disable:
li r4, 0
_set_rumble_flag:
mr r3, rPadID
##bl 0x8015ED4C # 1.02
##bl 0x8015F4F0 # PAL
bl 0x8015E8B0 # 1.01
##bl 0x8015E2D0 # 1.00
# Rumble_StoreRumbleFlag
_initialize_shaking_state:
li r4, Shaking
stb r4, xShakeFlag(rCursor)
lis r4, 0xC040 # -3
stw r4, xShakeTrans(rCursor)
_shaking:
lfs f1, xShakeTrans(rCursor)
lis r0, 0x3F4C # ~0.8
stw r0, -0x10(sp)
lfs f2, -0x10(sp)
lfs f0, xCursorX(rCursor)
fadds f0, f1, f0
stfs f0, xCursorX(rCursor)
fneg f3, f1
fcmpo cr0, f3, f1
bgt- _store_cursor_X
fmuls f3, f3, f2
_store_cursor_X:
stfs f3, xShakeTrans(rCursor)
blt- _return
_check_for_shake_end:
lis r0, 0x3C80
stw r0, -0x10(sp)
lfs f4, -0x10(sp)
fcmpo cr0, f3, f4
bgt- _return
_end_of_shake_effect:
li r4, NotShaking
stw r4, xShakeTrans(rCursor)
stb r4, xShakeFlag(rCursor)
_return:
lbz r4, xPadID(rCursor)
.long 0
NTSC 1.00 --- 0x8025F5CC ---- 889F0004 -> Branch
.set rPadID, 23
.set rPad, 28
.set rCursor, 31
.set xPadID, 0x4
.set xShakeFlag, 0x7
.set xCursorX, 0xC
.set xShakeTrans, 0x14
.set mDPadUp, 0x08
.set mDPadDown, 0x04
.set Shaking, 1
.set NotShaking, 0
_check_shaking:
lbz r3, xShakeFlag(rCursor)
cmpwi r3, NotShaking
bne- _shaking
_check_dpad_up:
mr rPadID, r4
rlwinm. r0, rPad, 0, mDPadUp
bne- _enable
_check_dpad_down:
rlwinm. r0, rPad, 0, mDPadDown
bne- _disable
b _return
_enable:
mr r3, rPadID
li r4, 0
li r5, 14
li r6, 0
subi r7, r13, 0x66B0 # NTSC 1.00, 1.01, 1.02
##subi r7, r13, 0x6500 # PAL
# r13 reference needs to be ported
##bl 0x80378430 # 1.02
##bl 0x80378334 # PAL
##bl 0x80377750 # 1.01
bl 0x8037657C # 1.00
# HSD_PadRumbleActiveId
li r4, 1
b _set_rumble_flag
_disable:
li r4, 0
_set_rumble_flag:
mr r3, rPadID
##bl 0x8015ED4C # 1.02
##bl 0x8015F4F0 # PAL
##bl 0x8015E8B0 # 1.01
bl 0x8015E2D0 # 1.00
# Rumble_StoreRumbleFlag
_initialize_shaking_state:
li r4, Shaking
stb r4, xShakeFlag(rCursor)
lis r4, 0xC040 # -3
stw r4, xShakeTrans(rCursor)
_shaking:
lfs f1, xShakeTrans(rCursor)
lis r0, 0x3F4C # ~0.8
stw r0, -0x10(sp)
lfs f2, -0x10(sp)
lfs f0, xCursorX(rCursor)
fadds f0, f1, f0
stfs f0, xCursorX(rCursor)
fneg f3, f1
fcmpo cr0, f3, f1
bgt- _store_cursor_X
fmuls f3, f3, f2
_store_cursor_X:
stfs f3, xShakeTrans(rCursor)
blt- _return
_check_for_shake_end:
lis r0, 0x3C80
stw r0, -0x10(sp)
lfs f4, -0x10(sp)
fcmpo cr0, f3, f4
bgt- _return
_end_of_shake_effect:
li r4, NotShaking
stw r4, xShakeTrans(rCursor)
stb r4, xShakeFlag(rCursor)
_return:
lbz r4, xPadID(rCursor)
.long 0