Zelda: Majora's Mask (Debug)

From en64 wiki
Jump to: navigation, search

load_file

 0x80081094
 void load_file(ftl_d * f);

Loads a file from the filesystem
f is a pointer to an instance of this structure:

 typedef struct {
    u32 rom_v_start;
    char *dest;
    int siz;
 } ftl_d;

Note that the memory must already be allocated for dest!

Native Functions

void TextXY(void * text_buffer, u16 x, u16 y) = 0x800872EC;
void TextRGBA(void * text_buffer, u8 r, u8 g, u8 b, u8 a) = 0x8008727C;
void TextString(void * text_buffer, char * format, ...) = 0x800879AC;
void TextDo(void * text_buffer) = 0x80087974;
void dma_rom_to_ram(u32 rom_addr, u32 ram_addr, int siz) = 0x80080CE0;
ActorSpawn = 0x800CF0B8
set_actor_size = 0x800C8FE0

OS Functions

rm is a tool that ran alongside the debugger (some kind of thread management tool)

0x8008ab60,__osSetCause
0x8008b070,osSetIntMask
0x8008b110,osGetIntMask
0x80090030,__osGetConfig
0x80090040,__osSetConfig
0x80090a60,__osProbeTLB
0x80091e20,osGetCount
0x80092260,sqrtf
0x80093940,osUnmapTLBAll
0x800966c0,__osSetCompare
0x800966d0,__osGetCompare
0x8009b580,__osSetFpcCsr
0x8009b590,__osGetFpcCsr
0x8009df40,osWritebackDCacheAll
0x800a37b0,__osRcpImTable
0x800a3eb0,__libm_qnan_f
0x8008ab70,osSendMesg
0x8008ae70,osStopThread
0x8008af30,osRecvMesg
0x8008b430,__sinf/fsin/sinf
0x8008b5f0,sins
0x8008b970,__ull_rshift
0x8008b99c,__ull_rem
0x8008b9d8,__ull_div
0x8008ba14,__ll_lshift
0x8008ba40,__ll_rem
0x8008ba7c,__ll_div
0x8008bad8,__ll_mul
0x8008bb08,__ull_divremi
0x8008bb68,__ll_mod
0x8008bc04,__ll_rshift
0x8008ca00,__osDequeueThread
0x8008cc00,bzero/_bzero/blkclr/_blkclr
0x80090970,osStopTimer
0x80093e60,osCreateMesgQueue
0x80093e90,osInvalICache
0x80093f10,osInvalDCache
0x80094ef0,osJamMesg
0x80095040,osSetThreadPri
0x80095120,osGetThreadPri
0x80095740,bcmp/_bcmp
0x80095860,osGetTime
0x80095ac0,__osSetGlobalIntMask
0x800966e0,osDpGetStatus
0x800966f0,osDpSetStatus
0x80096700,bcopy/_bcopy
0x80096a10,__osResetGlobalIntMask
0x80097380,__cosf/fcos/cosf
0x800976a0,coss
0x800976d0,osSetTime
0x8009d860,_Litob
0x8009dbf0,__osSpGetStatus
0x8009dc00,__osSpSetStatus
0x8009e1b0,osStartThread
0x8009e460,__d_to_ll
0x8009e47c,__f_to_ll
0x8009e498,__d_to_ull
0x8009e538,__f_to_ull
0x8009e5d4,__ll_to_d
0x8009e5ec,__ll_to_f
0x8009e604,__ull_to_d
0x8009e638,__ull_to_f
0x800a0070,osViModeNtscHpf1
0x800a00c0,osViModeMpalHpf1
0x800a0a80,osViModeNtscHpn1
0x800a0ba0,osViModeNtscLan1
0x800a0bf0,osViModeMpalLan1
0x8008fe10,osReadHost
0x80093fc0,__rmonSendFault
0x80094034,__rmonIOflush
0x80094084,__rmonIOputw
0x800940f0,__rmonIOhandler
0x80097880,__osRdbSend
0x80098180,__rmonExecute
0x80098220,__rmonWriteWordTo
0x80098268,__rmonReadWordAt
0x800982bc,__rmonMemcpy
0x800982f0,__rmonCopyWords
0x80098360,__rmonReadMem
0x8009855c,__rmonWriteMem
0x800987a8,__rmonListProcesses
0x80098828,__rmonLoadProgram
0x80098834,__rmonGetExeName
0x800988dc,__rmonGetRegionCount
0x8009894c,__rmonGetRegions
0x80098b40,__rmonSendHeader
0x80098bd8,__rmonSendReply
0x80098c80,__rmonSendData
0x80098da0,rmonMain
0x80098f40,__rmonMaskIdleThreadInts
0x80098fbc,__rmonGetTCB
0x8009903c,__rmonStopUserThreads
0x80099144,__rmonListThreads
0x80099278,__rmonGetThreadStatus
0x8009956c,__rmonThreadStatus
0x800995d4,__rmonStopThread
0x8009971c,__rmonRunThread
0x800999c0,__rmonSetFault
0x80099a0c,__rmonInit
0x80099ae8,__rmonPanic
0x80099b08,__rmonSetComm
0x80099b50,__rmonRCPrunning
0x80099b74,__rmonIdleRCP
0x80099bb8,__rmonStepRCP
0x80099bcc,__rmonRunRCP
0x80099d84,__rmonSetBreak
0x80099f44,__rmonListBreak
0x80099f50,__rmonClearBreak
0x8009a0ac,__rmonGetBranchTarget
0x8009a368,__rmonSetSingleStep
0x8009a42c,__rmonGetExceptionStatus
0x8009a528,__rmonHitBreak
0x8009a558,__rmonHitSpBreak
0x8009a5c0,__rmonHitCpuFault
0x8009a988,__rmonGetGRegisters
0x8009aae4,__rmonSetGRegisters
0x8009ac34,__rmonGetFRegisters
0x8009acec,__rmonSetFRegisters
0x8009ae04,__rmonGetSRegs
0x8009af64,__rmonSetSRegs
0x8009b074,__rmonGetVRegs
0x8009b18c,__rmonSetVRegs
0x8009b250,__rmonGetRegisterContents

Header commands

0x02

Seemingly the same as the header commands in OoT Debug
0x02 - Cameras used for the 0x1B command.


Format
02xx0000 yyyyyyyy
xx = number of entries
yy = offset xxxxyyyy zzzzzzzz
xx = camera type?
yy = unknown
zz = offset xxxxyyyy

zzzzpppp qqqqrrrr FFFFFFFF FFFF
xx = x position
yy = y position
zz = z position
pp = x rotation
qq = y rotation
rr = z rotation

0x17

Cutscenes
17xx0000 yyyyyyyy
xx = number of cutscenes
yy = offset

Entries
xxxxxxxx yyyyuutt
xx = Offset of cutscene data
yy = Exit
uu = Entrance cutscene activates at
tt = Event flag

Cutscene Header Format
xxxxxxxx yyyyyyyy
xx = Number of markers
yy = Length (Frames)

Small list of cutscene markers (More can be found below): 0000000A Text
0000005A Camera data
00000066 Zelda
00000070 Epona
00000078 Romani
00000082 Happy mask man
00000096 Sound effects?
00000097 ???
00000098 Screen Transition
00000099 Motion blur?
0000009B ???
0000009C ???
000000C8 Link
000000C9 Tatl
0000012C Play song
0000015E End Cutscene
The formats for these markers should be the same as they are in OoT, except for the camera data.

0x1A

Used to animate textures. Maps with mesh that use animated textures will use the DE000000 aa000000 display list command where aa = 08+.

Format
1A000000 xxxxxxxx
xx = offset


then it's


xx00yyyy zzzzzzzz
xx = animated mesh entry (take aa value in DE command and subtract 07 (last entry needs to be negative)
yy = type   00 = one layer   01 = two layers zz = pointer


then
aabbccdd
aa = x velocity factor
bb = y velocity factor
cc = unknown - use 0x20 if unsure
dd = unknown - use 0x20 if unsure

0x1B

Used by actors to decide what camera to use/cutscene to play.


Format
uuuutttt bbbbcccc nnnnssuu uuuuddee
tt = length (FFFF = constantly playing)
bb = camera to use FFF5 = Mask Transformation FFF6 = opening a large chest FFF7 = ??? FFF8 = ??? FFF9 = ??? FFFA = Song of Soaring FFFB = using event item FFFC = drinking bottle FFFD = playing ocarina FFFE = receiving item from small chest FFFF = null 0000+ = additional cameras (see 0x02 command)
cc = cutscene to play FFFF = null
nn = next entry?
ss = puzzle sound effect to play after
dd = camera position after 00 = keep current position 01 = place behind link 02 = rotate until behind link
ee = size of black bars 80 = max
uu = unknown

-change actor's y rotation to link with 0x1B entry

0x1C

Format
xxxxxxxx yyyyzzzz
xx = pointer to data
yy = zoom
zz = unknown

aaaaxxxx yyyyzzzz bbbb
aa = mini map
xx = x position
yy = y position
zz = z position bb = unknown

Values for the mini map are 0100-0164 iirc.

Cutscenes

Cutscene Data

(Taken from the 0x17 command above)


Cutscenes
17xx0000 yyyyyyyy
xx = number of cutscenes
yy = offset

Entries
xxxxxxxx yyyyuutt
xx = Offset of cutscene data
yy = Exit
uu = Entrance cutscene activates at
tt = Event flag

Scene Table Format

xxxxxxxx yyyyyyyy aaaabbbb 00000000
xx = Scene Start
yy = Scene End
aa = Message Number
bb = Scene Configuration (01 if you want to use the 0x1A command. Goes up to 0x0D IIRC)

Cutscene Header

Cutscene Header Format
xxxxxxxx yyyyyyyy
xx = Number of markers
yy = Length (Frames)

Cutscene Markers

(mostly actor markers)
0000000A Text
0000005A Camera data
00000064 En_Elfgrp
00000065 En_Dnp (Deku Princess)
00000066 Dm_Zl (Zelda)
00000067 Bg_Dy_Yoseizo
00000068 Bg_Ctower_Gear
00000069 En_Dnq (Deku King)
0000006B Dm_Stk (Skullkid)
0000006C En_Ge3
0000006D Dm_Char05
00000070 En_Horse (Epona)
00000073 Dm_Opstage
00000077 En_Gg
00000078 En_Ma_Yts, En_Ma4 (Romani)
00000079 En_Ge1
0000007C Bg_Open_Shutter
0000007D Bg_Open_Spot
0000007E En_Dnk
0000007F En_Mk (Professor)
00000082 En_Osn (Happy Mask Man)
00000083 Dm_Char02
00000084 Obj_Tokeidai
00000086 Obj_Tokei_Step
00000087 Dm_Char01
00000088 Dm_Char03
00000096 Sound effects?
00000098 Screen Transition
00000099 Motion blur?
000000C8 Player (Link)
000000C9 En_Elf (Tatl)
0000012C Play song
0000015E End Cutscene
000001C9 En_Zoraegg
000001CF Dm_Char06
000001D5 Bg_Haka_Curtain
000001D6 En_Jg
000001D7 En_Zog
000001D8 En_Dai
000001DA Dm_Char08
000001DB En_Dno
000001DC En_Ge2
000001DF En_Gk
000001E0 Eff_Kamejima_Wave
000001E2 En_Po_Composer
000001E3 Obj_Hgdoor
000001E4 En_Hg
000001E5 En_Pamera
000001E6 En_Hgo
000001F4 En_Zob
000001F5 En_Zos
000001F6 Eff_Kamejima_Wave
000001F7 Dm_Char09
000001F8 En_Zov
000001F9 En_Test6
000001FA En_Test3
000001FF Obj_Boat
00000200 Eff_Stk
00000201 Dm_Stk (Skullkid)
00000202 Dm_Tsg
00000203 En_Zod
0000020D En_Toto
0000020E En_Gm
0000020F Eff_Zoraband
00000214 En_Bsb
00000228 Obj_Usiyane
0000022C En_Ma_Yto (Cremia)
0000022D En_An, Dm_An, Dm_Gm
00000232 Dm_Al, Dm_Ah, Dm_Nb
00000235 En_And
00000238 Dm_Bal
00000239 Door_Warp1
000002C8 En_Dns (Deku Palace Scrub)


The actors are programmed to check for a specific value. So, to find them, search in their source file for "jal external_func_8010B11C". If there was a match, then usually before or after that instruction would be "li a1, x" where x is the decimal value for the marker. The method doesn't work all the time though, e.g. En_Giant has LHU instructions instead.

Camera Data

0000005A xxxxxxxx
xx = size of data

xxxxyyyy zzzzzzzz
xx = number of camera points
yy = size
zz = length (frames)


Camera Points
The first part of the data is for the camera focus, the second part is for the camera positions. The last part is for the angle of view.
aabbcccc xxxxyyyy zzzz0000
aa = camera behaviour (use 05 if you don't know what to use)
bb = FACTOR (?) <--- What the camera debug calls it. 0x64 seems to be the default
cc = unknown (something to do with the number of frames?)
xx = x position
yy = y position
zz = z position


xxxx0000 yyyy0000
xx = TIME (?) <--- what the camera debug calls it
yy = angle of view