Camera Toggle [JoshuaMK]
#1
Camera Toggle [JoshuaMK]

Press a mapped button of choice to switch the camera between 3 modes.

(NTSC-U)
C27E4C9C 00000011
3D608034 807FEE20
616BXXXX A16B0000
3D808170 717DYYYY
2C1DYYYY 40A20014
896C0F00 396B0001
280B000F 41A00008
39600000 996C0F00
2C0B0002 40820048
3D808088 618CDBD0
A16C0000 2C0B3F50
41820018 2C0B3FB0
4182001C 39603F50
3BA03ECD 48000018
39603FB8 3BA03F20
4800000C 39603F80
3BA03F00 B16C0000
B3AC0014 00000000
045979c4 60000000

(PAL)
C27EEFAC 00000011
3D608034 807F3618
616BXXXX A16B0000
3D808170 717DYYYY
2C1DYYYY 40A20014
896C0F00 396B0001
280B000F 41A00008
39600000 996C0F00
2C0B0002 40820048
3D808089 618C2310
A16C0000 2C0B3F50
41820018 2C0B3FB0
4182001C 39603F50
3BA03ECD 48000018
39603FB8 3BA03F20
4800000C 39603F80
3BA03F00 B16C0000
B3AC0014 00000000
045A29FC 60000000

(NTSC-J)
C27EE618 00000011
3D608034 807F2678
616BXXXX A16B0000
3D808170 717DYYYY
2C1DYYYY 40A20014
896C0F00 396B0001
280B000F 41A00008
39600000 996C0F00
2C0B0002 40820048
3D808089 618C1960
A16C0000 2C0B3F50
41820018 2C0B3FB0
4182001C 39603F50
3BA03ECD 48000018
39603FB8 3BA03F20
4800000C 39603F80
3BA03F00 B16C0000
B3AC0014 00000000
045A237C 60000000

(NTSC-K)
C27DD36C 00000011
3D608033 807F1C58
616BXXXX A16B0000
3D808170 717DYYYY
2C1DYYYY 40A20014
896C0F00 396B0001
280B000F 41A00008
39600000 996C0F00
2C0B0002 40820048
3D808088 618C0718
A16C0000 2C0B3F50
41820018 2C0B3FB0
4182001C 39603F50
3BA03ECD 48000018
39603FB8 3BA03F20
4800000C 39603F80
3BA03F00 B16C0000
B3AC0014 00000000
04590A54 60000000



Guide

Note: This code makes use of user input. See this guide for reference on filling in values: https://mkwii.com/showthread.php?tid=44

XXXX = Controller Address
YYYY = Button that changes camera view



Suggested Values:

(GCN) 
YYYY = 0880 - Y 
[b](Wavebird GCN) [/b]
YYYY = 0800 - Y 
(Classic Controller) 
YYYY = 8000 - Y 
[b](Wii Remote + Nunchuck) [/b]
YYYY = 1000 - ( - )
[b](Wii Wheel) [/b]
YYYY = 1000 - ( - )



#########
#Source ASM#
#########

###############
#Register Safety Notes#
###############

#r29 is safe to use as it gets overwritten by a mulli instruction the line after this code.

.set region, ' ' #Fill in E, P, J, or K within the quotes for your region when Compiling! Lowercase letters can also be used.

.if (region == 'E' || region == 'e') # RMCE
lis r11, 0x8034
lwz r3, -0x11E0 (r31)
.elseif (region == 'P' || region == 'p') # RMCP
lis r11, 0x8034
lwz r3, 0x3618 (r31)
.elseif (region == 'J' || region == 'j') # RMCJ
lis r11, 0x8034
lwz r3, 0x2678 (r31)
.elseif (region == 'K' || region == 'k') # RMCK
lis r11, 0x8033
lwz r3, 0x1C58 (r31)
.else # Invalid Region
.abort
.endif

ori r11, r11, 0x3e80 #NTSC-U GCN used just for compilation
lhz r11, 0 (r11)

lis r12, 0x8170 #Set Mem81 address, 1st Half, used offset for 2nd half

andi. r29, r11, 0x0880 #Y button used just for compilation
cmpwi r29, 0x0880 #Check if button is at least pressed
bne+ reset_timer #Reset Timer Back to 0 if no Y Button Press

lbz r11, 0x0F00 (r12) #Load Timer Value
addi r11, r11, 1 #Increment Timer

cmplwi r11, 15
blt+ dont_reset_timer #If not greater than 15, do NOT reset timer

reset_timer:
li r11, 0 #Once timer hits 15, reset it

dont_reset_timer:
stb r11, 0x0F00 (r12) #Store updated Timer Value
cmpwi r11, 2 #Check if value is 2 (time to update camera)
bne- no_change #If not 2, skip already down to vannila instruction

#Set Camera Height Address

.if (region == 'E' || region == 'e') # RMCE
lis r12, 0x8088
ori r12, r12, 0xDBD0
.elseif (region == 'P' || region == 'p') # RMCP
lis r12, 0x8089
ori r12, r12, 0x2310
.elseif (region == 'J' || region == 'j') # RMCJ
lis r12, 0x8089
ori r12, r12, 0x1960
.elseif (region == 'K' || region == 'k') # RMCK
lis r12, 0x8088
ori r12, r12, 0x0718
.else # Invalid Region
.abort
.endif

lhz r11, 0 (r12)

cmpwi r11, 0x3f50 #Compare Camera Height to "Close Up" Setting
beq- far_out #If Equal, Set Camera to "Far Out"

cmpwi r11, 0x3fb0 #Compare Camera Height to "Far Out" Setting
beq- normal_value #If Equal, Set Camera to "Normal"

li r11, 0x3f50
li r29, 0x3ecd
b store_value

far_out:
li r11, 0x3fb8
li r29, 0x3f20
b store_value

normal_value:
li r11, 0x3f80
li r29, 0x3f00

store_value:
sth r11, 0 (r12) #Store New Camera Height to Proper RAM Address
sth r29, 0x0014 (r12) #Offset 0x0014 From Camera Height is Camera Distance. Store Camera Distance There.

no_change:



Code Creator: JoshuaMK
Code Contributors: Jae (Camera Height Address), davidevgen (Camera Distance Address), Vega (Optimized Source)
Super Mario Eclipse, what Super Mario Sunshine could've been.
Reply


Messages In This Thread
Camera Toggle [JoshuaMK] - by JoshuaMK - 07-08-2019, 02:43 AM
RE: Camera Toggle - by Vega - 07-09-2019, 01:26 AM
RE: Camera Toggle - by JoshuaMK - 07-09-2019, 03:22 AM
RE: Camera Toggle - by Vega - 07-09-2019, 07:54 PM
RE: Camera Toggle - by JoshuaMK - 07-09-2019, 08:23 PM
RE: Camera Toggle - by Vega - 07-09-2019, 08:34 PM
RE: Camera Toggle - by JoshuaMK - 07-09-2019, 08:58 PM
RE: Camera Toggle - by JoshuaMK - 07-09-2019, 11:35 PM
RE: Camera Toggle - by Vega - 07-09-2019, 11:42 PM
RE: Camera Toggle - by JoshuaMK - 07-10-2019, 01:03 AM
RE: Camera Toggle - by Vega - 07-10-2019, 08:23 PM

Forum Jump:


Users browsing this thread: 3 Guest(s)