Debug ROM: RAM Map

From z64 wiki
Revision as of 00:37, 8 March 2014 by Mzxrules (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Let's put info on the Debug ROM's RAM here. If something needs more info on it add %% to the end of the line. Example:

8015E6EF (ui8?) Arrows

To-Do:
-Where?
-Data type of variables:
--Integer? Float? Strucure? etc. Signedness is important.
--Size in bytes? Or, dynamic?

Should-Do:
-Specify functions and structures in C style
-Array and string length

Contents

Functions

The N64 functions and math functions were found with LFE unless otherwise noted.

Misc

AssertMessage

0x80001ff0
void AssertMessage(char* cond, char* fn, int line);

Called when an assert() fails
cond is the condition that was asserted
fn is the file (__FILE__)
line is the line (__LINE__)

DebugMessage

0x80002130
void DebugMessage(char* format, ...);

Print an informational debug message
format is a printf()-style format string

NullPointerCheck

0x80002d60
void NullPointerCheck(char* exp, void* ptr, char* fn, int line);

Prints a debug message if the pointer is NULL
exp is the name of the value to check
ptr is the pointer value
fn is the file (__FILE__)
line is the line (__LINE__)

DebugMessageWithThreadId

0x80002e10
void NullPointerCheck(char* str, int val);

Prints a debug message "<%d %s %d>" where the first integer is the current thread ID
str Unknown. File name?
val Unknown. Line number?

game_alloc

0x800C5484
char * game_alloc(u32 z_gp, int siz, char * fn, int line);

Allocates memory
z_gp is 0x80212020
siz is the size of the block to be allocated
fn is the file (__FILE__)
line is the line (__LINE__)

graph_alloc

0x800C69cc
void * graph_alloc(u32 z_gp, int siz);

Allocates graphics memory
z_gp is 0x80212020
siz is the size of the block to be allocated

DMARomToRam

0x80000BFC
void DMARomToRam(u32 rom_addr, u32 ram_addr, int siz);

Transfers data from ROM to RAM
Variables are self explanatory

GetFile

0x800013FC
void GetFile(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!

set_actor_size

0x8002D62C
void set_actor_size(z64_actor_t * a, f32 size);

Sets an actor's scale
a is the actor's structure, and
size is the scale (float) that it is to be scaled to.

set_bgm

0x800FA00C
void set_bgm(u8 seq_num);

Sets background music to be played
seq_num is the sequence number to use

OoT spawn functions

SpawnObject

0x80097C00
void ObjectSpawn(u32 const_1, u16 object_number);

Spawns an object
const_1 is 0x802237C4

ActorSpawn

0x80031F50
actor * ActorSpawn(u32 const_1, GlobalContext* ctxt, int actor_no, f32 fx, f32 fy, f32 fz, u16 rx, u16 ry, u16 rz, int actor_var);

Spawns an actor
const_1 is 0x80213C44
ctxt is probably the global context (0x80212020).
Return value is a pointer to a loaded actor.

Other:

0x80032458
actor_loaded_t* ( void* (z_ctxt + 0x1C24), actor_loaded_t* link, void *z_ctxt, uint16_t actor_number, float x, float y, float z, uint16_t xrot, uint16_t yrot, uint16_t zrot, uint16_t variable);

SpawnArea

0x800C0008
void SpawnArea(GlobalContext* ctxt, int scene_no, int entrance_no);

Spawns a specified scene
ctxt is probably the global context (0x80212020).
scene_no is the scene number to use
entrance_no is the start position to use.

EffectAdd

0x80026cd4
? EffectAdd(...);

Spawns an effect? Name gleaned from debug message.

OoT Text functions

buffer is a text object, 0x2C bytes as I recall. It's structure is still yet to be determined.

SetTextRGBA

0x800FB3AC
void SetTextRGBA(void * buffer, u8 r, u8 g, u8 b, u8 a);

Sets color of text to be drawn

SetTextXY

0x800FB41C
void SetTextXY(void * buffer, u16 x, u16 y);

Sets the position of text to be drawn

SetTextString

0x800FBCB4
void SetTextString(void * buffer, char * format, ...);

Sets the text string to be drawn

Math functions

absf

0x801067E0
float absf(float value);

Returns absolute value of a float
Not found with LFE, manually found

__sinf/fsin/sinf

0x80100290
float sinf(float angle);

Computes the sine of an angle in floating point

sins

0x80100450
float sins(unsigned short angle)

Computes the sine of an angle in fixed point

__cosf/fcos/cosf

0x80104610
float cosf(float angle);

Computes the cosine of an angle in floating point

coss

0x80104780
float coss(unsigned short angle);

Computes the cosine of an angle in fixed point

sqrtf

0x801031E0
float sqrtf (float value);

Computes the square root

N64 OS functions

osSendMesg

0x80003060
void osSendMesg(OSMesgQueue *mq, OSMesg msg, s32 flag);

Provides messaging and synchronization facilities

osStopThread

0x800031B0
void osStopThread(OSThread *t);

Suspends a given thread

osRecvMesg

0x80003280
s32 osRecvMesg(OSMesgQueue *mq, OSMesg *msg, s32 flag);

Provides messaging and synchronization facilities

osCreateThread

0x80004550
void osCreateThread(OSThread *t, OSId id, void (*entry)(void *),
               void *arg, void *sp, OSPri pri);

Registers a schedulable object

osWritebackDCache

0x800046C0
void osWritebackDCache(void *vaddr, s32 nbytes);

Writes back CPU data cache lines to physical memory

osVirtualToPhysical

0x80004DE0
u32 osVirtualToPhysical(void *vaddr)

Translates between CPU virtual address/physical memory address

osGetThreadId

0x80004F20
void osGetThreadId(OSThread *t);

Obtains the debugger identifier of a thread

osSetIntMask

0x80004F40
OSIntMask osSetIntMask(OSIntMask im);

Sets the enabled interrupt mask

osInvalICache

0x80006150
void osInvalICache(void *vaddr, s32 nbytes);

Invalidates CPU instruction cache

osCreateMesgQueue

0x800061D0
void osCreateMesgQueue(OSMesgQueue *mq, OSMesg *msg, s32 count);

Provides messaging and synchronization facilities

osInvalDCache

0x80006200
void osInvalDCache(void *vaddr, s32 nbytes);

Invalidates CPU data cache lines

osJamMesg

0x800062E0
void osJamMesg(OSMesgQueue *mq, OSMesg msg, s32 flag);

Provides messaging and synchronization facilities

osSetThreadPri

0x80006430
void osSetThreadPri(OSThread *t, OSPri pri);

Sets the priority of specified thread

osGetThreadPri

0x80006510
void osGetThreadPri(OSThread *t);

Gets the priority of specified thread

osGetTime

0x800069E0
OSTime osGetTime(void);

Gets the real time counter value

osGetCount

0x80006EA0
u32 osGetCount(void);

Returns CPU count register

__osSetCompare

0x80006F00 : 
void __osSetCompare(u32 value);

Internal routine to access to multiple MIPS R4300 registers

__osSetFpcCsr

0x80007A70
u32 __osSetFpcCsr(u32 value);

Sets the current value of the R4300 floating-point control/status register

__osGetFpcCsr

0x80007A80
u32 __osGetFpcCsr(void);

Returns the current value of the R4300 floating-point control/status register

osYieldThread

0x80007B40
void osYieldThread(void);

Yields the CPU and invokes the thread dispatcher

__osGetCause

0x80007B90
u32 __osGetCause(void);

Returns the current value of the MIPS R4300 Cause register that describes the cause of the most recent exception

osStartThread

0x80008FC0
void osStartThread(OSThread *t);

Starts or resumes a thread

osSpTaskYield

0x801014A0
void osSpTaskLoad(OSTask *task);

Requests that the SP"yield"

osStopTimer

0x80102330
void osStopTimer(OSTimer *timer);

Stops an interval or countdown timer

osDpGetStatus

0x801041C0
u32 osDpGetStatus(void);

Returns the hardware status of the display processor command status register

osDpSetStatus

0x801041D0
void osDpSetStatus(u32 status);

Updates the display processor command status register with status

osAiGetLength

0x80105C00
u32 osAiGetLength(void);

Returns the number of bytes remaining in the current DMA buffer

osWritebackDCacheAll

0x80106490
void osWritebackDCache(void *vaddr, s32 nbytes);

Writes back all cached locations to physical memory

Undocumented OS functions

0x8000AE50 : osViModeMpalLan1
0x80012160 : __osRcpImTable
0x80106470 : __osSpGetStatus
0x80106480 : __osSpSetStatus
0x80004300 : __osDequeueThread
0x800046A0 : __osSetSR
0x800046B0 : __osGetSR
0x80005040 : __osProbeTLB
0x80006EB0 : __osSetGlobalIntMask
0x80007220 : __osResetGlobalIntMask
0x80007AE0 : osMapTLBRdb

Other N64 functions

bzero/_bzero/blkclr/_blkclr

0x80004450
void bzero(void *dst, int length);

Zero-clears a byte string

bcmp/_bcmp

0x800068C0
int bcmp(const void *s1, const void *s2, int length);

Compares byte strings

bcopy/_bcopy

0x80006F10
void bcopy(const void *src,void *dst,int length);

Copies a byte string

guPerspectiveF

0x801010D0
void guPerspectiveF(
       float mf[4][4],
       u16 *perspNorm,
       float fovy,
       float aspect,
       float near,
       float far,
       float scale);

Creates a perspective projection matrix (floating point)

guPerspective

0x80101300
void guPerspective(
       Mtx *m,
       u16 *perspNorm,
       float fovy,
       float aspect,
       float near,
       float far,
       float scale);

Creates a perspective projection matrix (fixed point)

Other Zelda Functions

T_BGCheck_getBGDataInfo

0x8003c4c4
int T_BGCheck_getBGDataInfo(void* ctx, int index);

Unknown use (name gleaned from debug message). Contains a DebugMessage call that says (in Japanese) "That bg_actor_index is unused. index=%d"
ctxt is probably the global context (0x80212020).
index is a "background actor index"
Return value (if any) unknown.

DynaPolyInfo_setActor

0x8003ea74
int DynaPolyInfo_setActor(GlobalContext* ctx, int unk, Actor* actor);

Unknown use (name gleaned from debug message). Contains a DebugMessage call that says (in Japanese) something like "Dynamic polygon ??? index missing".
ctxt is the global context (0x80212020).
unk is unknown
actor is an actor in RAM
Return value (if any) unknown.

DynaPolyInfo_delReserve

0x8003ed58
int DynaPolyInfo_delReserve(GlobalContext* ctx, int unk, int index);

Unknown use (name gleaned from debug message).
ctxt is the global context (0x80212020).
unk is unknown
index is unknown (name gleaned from debug message)
Return value (if any) unknown.

setCameraData

0x8005afd4
? setCameraData(...);

Unknown use (name gleaned from debug message). Unknown signature. Contains a debug message that says "mcamera: setCameraData: last argument not alive!".

CollisionBtlTbl_get

0x8005b200
int CollisionBtlTbl_get(int index);

Unknown use (name gleaned from debug message).

ClObjJntSph_set3

0x8005be50
? ClObjJntSph_set3(...);

Unknown use (name gleaned from debug message). Unknown signature.

CollisionCheck_setAT

// z_collision_check.c
0x8005d79c
? CollisionCheck_setAT(...);

Unknown use (name gleaned from debug message). Unknown signature.

CollisionCheck_setAC

// z_collision_check.c
0x8005d9f4
? CollisionCheck_setAC(...);

Unknown use (name gleaned from debug message). Unknown signature.

CollisionCheck_setOT

// z_collision_check.c
0x8005dc4c
? CollisionCheck_setOT(...);

Unknown use (name gleaned from debug message). Unknown signature.

Vec3f_Copy

0x80077e40
void Vec3f_Copy(Vec3f* dst, Vec3f* src);

Copy a three-component floating-point vector.

Vec3f_CopyVec3s

0x80077e5c
void Vec3f_CopyVec3s(Vec3f* dst, Vec3s* src);

Copy a three-component 16-bit short vector to a three-component float vector.

Vec3f_Add

0x80077e9c
void Vec3f_Add(Vec3f* left, Vec3f* right, Vec3f* dst);

Add two three-component vectors.

Vec3f_Sub

0x80077ed0
void Vec3f_Sub(Vec3f* left, Vec3f* right, Vec3f* dst);

Subtract two three-component vectors.

DisplayList_AllocSetEnvColor

0x800951d0
void* DisplayList_AllocSetEnvColor(GlobalContext* ctxt, int r, int g, int b, int a);

Allocates and returns a display list that sets the environment color.
ctxt is the global context (0x80212020).
r is red component (0-255).
g is green component (0-255).
b is blue component (0-255).
a is alpha component (0-255).

MapLoad_SetStartPositions_0x00

0x80098508
void MapLoad_SetStartPositions_0x00(GlobalContext* ctxt, void* cmd);

Map-loading callback for command 0x00 (start positions).
ctxt is the global context (0x80212020).
cmd is a pointer to the map/scene command.

MapLoad_SetActorList_0x01

0x800985dc
void MapLoad_SetActorList_0x01(GlobalContext* ctxt, void* cmd);

Map-loading callback for command 0x01 (actors).
ctxt is the global context (0x80212020).
cmd is a pointer to the map/scene command.

MapLoad_0x02

0x80098630
void MapLoad_0x02(GlobalContext* ctxt, void* cmd);

Map-loading callback for command 0x02 (unknown).
ctxt is the global context (0x80212020).
cmd is a pointer to the map/scene command.

MapLoad_SetCollision_0x03

0x80098674
void MapLoad_SetCollision_0x03(GlobalContext* ctxt, void* cmd);

Map-loading callback for command 0x03 (collision).
ctxt is the global context (0x80212020).
cmd is a pointer to the map/scene command.

MapLoad_SetMaps_0x04

0x800987a4
void MapLoad_SetMaps_0x04(GlobalContext* ctxt, void* cmd);

Map-loading callback for command 0x04 (maps).
ctxt is the global context (0x80212020).
cmd is a pointer to the map/scene command.

MapLoad_SetEntrances_0x06

0x800987f8
void MapLoad_SetEntrances_0x06(GlobalContext* ctxt, void* cmd);

Map-loading callback for command 0x06 (entrances).
ctxt is the global context (0x80212020).
cmd is a pointer to the map/scene command.

MapLoad_0x07

0x8009883c
void MapLoad_0x07(GlobalContext* ctxt, void* cmd);

Map-loading callback for command 0x07 (unknown).
ctxt is the global context (0x80212020).
cmd is a pointer to the map/scene command.

MapLoad_0x08

0x80098904
void MapLoad_0x08(GlobalContext* ctxt, void* cmd);

Map-loading callback for command 0x08 (unknown).
ctxt is the global context (0x80212020).
cmd is a pointer to the map/scene command.

MapLoad_SetMesh_0x0a

0x80098958
void MapLoad_SetMesh_0x0a(GlobalContext* ctxt, void* cmd);

Map-loading callback for command 0x0a (mesh).
ctxt is the global context (0x80212020).
cmd is a pointer to the map/scene command.

MapLoad_SetObjects_0x0b

0x8009899c
void MapLoad_SetObjects_0x0b(GlobalContext* ctxt, void* cmd);

Map-loading callback for command 0x0b (objects).
ctxt is the global context (0x80212020).
cmd is a pointer to the map/scene command.

MapLoad_0x0c

0x80098b74
void MapLoad_0x0c(GlobalContext* ctxt, void* cmd);

Map-loading callback for command 0x0c (unknown).
ctxt is the global context (0x80212020).
cmd is a pointer to the map/scene command.

MapLoad_0x0d

0x80098c24
void MapLoad_0x0d(GlobalContext* ctxt, void* cmd);

Map-loading callback for command 0x0d (unknown).
ctxt is the global context (0x80212020).
cmd is a pointer to the map/scene command.

MapLoad_SetTransitionActors_0x0e

0x80098c68
void MapLoad_SetTransitionActors_0x0e(GlobalContext* ctxt, void* cmd);

Map-loading callback for command 0x0e (transition actors).
ctxt is the global context (0x80212020).
cmd is a pointer to the map/scene command.

MapLoad_SetEnvironment_0x0f

0x80098cc8
void MapLoad_SetEnvironment_0x0f(GlobalContext* ctxt, void* cmd);

Map-loading callback for command 0x0f (environment settings).
ctxt is the global context (0x80212020).
cmd is a pointer to the map/scene command.

MapLoad_SetSkybox_0x11

0x80098d1c
void MapLoad_SetSkybox_0x11(GlobalContext* ctxt, void* cmd);

Map-loading callback for command 0x11 (skybox).
ctxt is the global context (0x80212020).
cmd is a pointer to the map/scene command.

MapLoad_SetSkyboxControl_0x12

0x80098d5c
void MapLoad_SetSkyboxControl_0x12(GlobalContext* ctxt, void* cmd);

Map-loading callback for command 0x12 (skybox modifier).
ctxt is the global context (0x80212020).
cmd is a pointer to the map/scene command.

MapLoad_SetTime_0x10

0x80098d80
void MapLoad_SetTime_0x10(GlobalContext* ctxt, void* cmd);

Map-loading callback for command 0x10 (time).
ctxt is the global context (0x80212020).
cmd is a pointer to the map/scene command.

MapLoad_0x05

0x80099090
void MapLoad_0x05(GlobalContext* ctxt, void* cmd);

Map-loading callback for command 0x05 (unknown).
ctxt is the global context (0x80212020).
cmd is a pointer to the map/scene command.

MapLoad_SetExits_0x13

0x800990f0
void MapLoad_SetExits_0x13(GlobalContext* ctxt, void* cmd);

Map-loading callback for command 0x13 (exits).
ctxt is the global context (0x80212020).
cmd is a pointer to the map/scene command.

MapLoad_0x09

0x80099134
void MapLoad_0x09(GlobalContext* ctxt, void* cmd);

Map-loading callback for command 0x09 (unknown).
ctxt is the global context (0x80212020).
cmd is a pointer to the map/scene command.

MapLoad_SetMusic_0x15

0x80099140
void MapLoad_SetMusic_0x15(GlobalContext* ctxt, void* cmd);

Map-loading callback for command 0x15 (music).
ctxt is the global context (0x80212020).
cmd is a pointer to the map/scene command.

MapLoad_SetEcho_0x16

0x8009918c
void MapLoad_SetEcho_0x16(GlobalContext* ctxt, void* cmd);

Map-loading callback for command 0x16 (echo).
ctxt is the global context (0x80212020).
cmd is a pointer to the map/scene command.

MapLoad_SetAltHeaders_0x18

0x800991a0
void MapLoad_SetAltHeaders_0x18(GlobalContext* ctxt, void* cmd);

Map-loading callback for command 0x18 (alt. headers).
ctxt is the global context (0x80212020).
cmd is a pointer to the map/scene command.

MapLoad_0x17

0x8009934c
void MapLoad_0x17(GlobalContext* ctxt, void* cmd);

Map-loading callback for command 0x17 (unknown).
ctxt is the global context (0x80212020).
cmd is a pointer to the map/scene command.

MapLoad_0x19

0x800993c0
void MapLoad_0x19(GlobalContext* ctxt, void* cmd);

Map-loading callback for command 0x19 (unknown).
ctxt is the global context (0x80212020).
cmd is a pointer to the map/scene command.

Animation_GetFrameCount

0x800a2000
int Animation_GetFrameCount(int animation);

Get the number of frames in an animation.
animation is the animation in bank/offset format.

Skeleton_Info_Rom_SV_ct

0x800a46f8
int Skeleton_Info_Rom_SV_ct(int a0, int a1, int a2, int a3, int a4, int a5, int a6);

Unknown (name gleaned from debug message). Seems to be related to skeletal hierarchies and animation.

Skeleton_Info2_skin2_ct

0x800a487c
int Skeleton_Info2_skin2_ct(int a0, int a1, int a2, int a3);

Unknown (name gleaned from debug message). Seems to be related to skeletal hierarchies and animation.

Undocumented

0x80003710 : __ull_rshift
0x8000373C : __ull_rem
0x80003778 : __ull_div
0x800037B4 : __ll_lshift
0x800037E0 : __ll_rem
0x8000381C : __ll_div
0x80003878 : __ll_mul
0x800038A8 : __ull_divremi
0x80003908 : __ll_mod
0x800039A4 : __ll_rshift
0x80007D00 : _Litob
0x80106550 : __d_to_ll
0x8010656C : __f_to_ll
0x80106588 : __d_to_ull
0x80106628 : __f_to_ull
0x801066C4 : __ll_to_d
0x801066DC : __ll_to_f
0x801066F4 : __ull_to_d
0x80106728 : __ull_to_f
0x8014B2D0 : __libm_qnan_f

Within code

Main Article: Code notes

0x8001CE60 - 0x80157D90 is code

801274A0(u32)[0x1A]	Jump table for map reading functions
80127520(u16)		Adult link object number
80127522(u16)		Child link object number
80127524(u32)		Number of objects
80127528(u32)[# objs]	Object table
801162A0		Actor Table

TODO: scene table, exit table, more functions

Global Context

80212020 is a very important address, it seems to be argument 0 for many functions, is the 'base' for many variables. Also known as 'ctxt'

Distance/typ		Actual Addr	Description
---------------------------------------------------
000000(void*)          80212020        (*(void*)(ctxt+0) + 0x2C0) = Current end position of top level display list.
0000A4(u16)            802120C4        Current scene number
0000C0(u32)            802120E0        screen top
0000C4(u32)            802120E4        screen bottom
0000C8(u32)            802120E8        screen left
0000CC(u32)            802120EC        screen right
0000D0(f32)            802120F0        camera distance
0000D4(f32)            802124F4        fog distance
0000D8(f32)            802124F8        z distance
0000DC(f32)            802124FC        unknown camera variable - leave at 1.0
000270(actor*)         80212290        Actor that camera follows
001C30(actor*)[12][2]  80213C50	List of actors, organized by type. first word is number of actors of that type,
                                       second word is address of the first of those actors. See also: Actors
001CC8(actor*)         80213CE8        What actor the z-target arrow is over
001CCC(actor*)         80213CEC        What actor is being z-targeted
011CC8(void*)          80223CE8        Map pointer (points to current object set iirc? someone doublecheck)
011DEA(u8)             80223E0A        Current entrance number being used.
011DEB(u8)             80223E0B        Number of map actors (nulled after actors are spawned iirc)
011DF8(actor_list*)[]  80223E18        Pointer to map actor list with position/rotation of stuff.
0117A4(?)              802237C4        Argument 0 for SpawnObject() (this address,
                                       not value at this address)

fixme

802120C4 (u16)		Current Scene number

RAM segments

80166FA8(u32)[(number of segments)]	Segment table, value|0x80000000 = ram addr
char * segments[8] = 0x80166FA8;

Example: Segment 0x6 would be pointed to at 0x80166FC0 ( 0x6 << 2 = 0x18 + 0x80166FA8 = 0x80166FC0 )
Note: the table is for the engine's reference only, so it is not reliable at all times, it is only updated when the game needs to update it, but not necessarily as the banks are updated. Also, it does not have banks 8 - 15. Segments values are:
0 - unknown
1 - unknown
2 - scene
3 - map
4 - gameplay_keep
5 - gameplay_field_keep (outside of dungeons), or gameplay_dangeon_keep (dungeons)
6 - current object
7 - unknown/link_animetion
8+ determined by current game circumstances.

Controller

typedef struct /* ZZT32 did this struct */
{
    /* Buttons */
    u16 pad;
    
    /* Joystick */
    signed x : 8;
    signed y : 8;
} Controller; 
80166AF0	Player 1
80166B08	Player 2
80166B20	Player 3
80166B38	Player 4

Misc

8015E693 (s16?)	Magic amount
8015FA54               Magic bar length
8015E6EE (s8?)		Bombs amount
8015E6EF               Arrow amount
8015E695               Rupee amount
80062078               Link's damage amount
8023D9A3               Explosions damage
8015E6F2               Deku seed amount
8015E690               Heart amount
80224C24               Link's action
8015FA7A               Time of day
80211174(u16)		Make any Non-Zero value to "freeze" all actors
802245B0 z64_actor_t	Link

See also

zelda64.h