Partially match m_watch_my_step.c

This commit is contained in:
Cuyler36
2023-06-15 17:19:42 -04:00
parent 2d9e699c7e
commit fd8fbd9c92
24 changed files with 1223 additions and 33 deletions
+18
View File
@@ -37,6 +37,24 @@ extern inline float sqrtf(float x)
}
#endif
// hack to get some functions matching where the static const locals are needed
extern inline float sqrtf2(float x)
{
static const double _half=.5;
static const double _three=3.0;
volatile float y;
if(x > 0.0f)
{
double guess = __frsqrte((double)x); // returns an approximation to
guess = _half*guess*(_three - guess*guess*x); // now have 12 sig bits
guess = _half*guess*(_three - guess*guess*x); // now have 24 sig bits
guess = _half*guess*(_three - guess*guess*x); // now have 32 sig bits
y=(float)(x*guess);
return y;
}
return x;
}
extern inline double fabs(double x)
{
return __fabs(x) ;
+6
View File
@@ -2,6 +2,7 @@
#define AUDIO_H
#include "types.h"
#include "audio_defs.h"
#ifdef __cplusplus
extern "C" {
@@ -16,6 +17,11 @@ typedef struct audio_tempo_beat_s {
extern void sAdo_GameFrame();
extern void sAdo_SoftReset();
extern void sAdo_SysLevStop(u8 id);
extern void sAdo_SysLevStart(u8 id);
extern void sAdo_SysTrgStart(u16 id);
/* Not sure about the last param name */
extern void sAdo_VoiceSe(u8 num, u8 num2, u8 num3, s16 character_idx, u8 scale, u8 mode);
+20
View File
@@ -0,0 +1,20 @@
#ifndef AUDIO_DEFS_H
#define AUDIO_DEFS_H
#include "types.h"
#ifdef __cplusplus
extern "C" {
#endif
/* audio is monophonic */
#define MONO(id) (id | 0x1000)
#define SE_COIN 0x4C
#define SE_REGISTER MONO(0x50)
#ifdef __cplusplus
}
#endif
#endif
+12
View File
@@ -7,6 +7,18 @@
extern "C" {
#endif
typedef struct xy_s {
f32 x, y;
} xy_t;
typedef struct xyz_s {
f32 x, y, z;
} xyz_t;
typedef struct s_xyz_s {
s16 x, y, z;
} s_xyz;
typedef struct {
u32 r:8;
u32 g:8;
+331
View File
@@ -0,0 +1,331 @@
#ifndef M_CAMERA2_H
#define M_CAMERA2_H
#include "types.h"
#include "m_lib.h"
#include "m_actor.h"
#ifdef __cplusplus
extern "C" {
#endif
enum {
CAMERA2_PROCESS_STOP,
CAMERA2_PROCESS_NORMAL,
CAMERA2_PROCESS_WADE,
CAMERA2_PROCESS_TALK,
CAMERA2_PROCESS_DEMO,
CAMERA2_PROCESS_ITEM,
CAMERA2_PROCESS_LOCK,
CAMERA2_PROCESS_DOOR,
CAMERA2_PROCESS_SIMPLE,
CAMERA2_PROCESS_CUST_TALK,
CAMERA2_PROCESS_INTER,
CAMERA2_PROCESS_STAFF_ROLL,
CAMERA2_PROCESS_INTER2,
CAMERA2_PROCESS_NUM
};
typedef struct camera_main_cust_talk_s {
ACTOR* speaker_actor;
ACTOR* listener_actor;
f32 center_ratio;
f32 cull_timer;
s16 angle_x;
s16 angle_y;
f32 distance;
} CameraCustTalk;
typedef struct camera_main_demo_s {
xyz_t starting_center_pos;
f32 starting_distance;
s_xyz starting_direction;
xyz_t goal_center_pos;
f32 goal_distance;
s_xyz goal_direction;
f32 goal_delta;
f32 acceleration_delta;
f32 braking_delta;
f32 now_delta;
} CameraDemo;
typedef struct camera_main_door_s {
u32 flags;
int morph_counter;
xyz_t center_position;
} CameraDoor;
typedef struct camera_main_inter_s {
xyz_t starting_center_pos;
xyz_t starting_eye_pos;
xyz_t goal_center_pos;
xyz_t goal_eye_pos;
f32 slope0;
f32 slope1;
u32 flags;
int now_delta;
int max_delta;
int pad[2];
} CameraInter;
typedef struct camera_main_item_s {
int type;
f32 cull_timer;
} CameraItem;
typedef struct camera_main_lock_s {
xyz_t center_pos;
xyz_t eye_pos;
f32 fov_y;
int morph_counter;
f32 near;
f32 far;
} CameraLock;
typedef struct camera_main_normal_s {
u32 flags;
int last_indoor_distance_addition_idx;
int last_indoor_direction_addition_idx;
int morph_counter;
} CameraNormal;
typedef struct camera_main_simple_s {
xyz_t center_pos;
xyz_t eye_pos;
f32 distance;
int morph_counter;
int mode;
f32 cull_timer;
} CameraSimple;
typedef struct camera_main_staff_roll_s {
xyz_t last_center_pos;
xyz_t last_eye_pos;
f32 last_distance;
ACTOR* speaker_actor;
ACTOR* listener_actor;
s16 rotation_y_delta;
s16 r_delta;
s16 rotation_x_delta;
u16 flags;
u16 morph_counter;
u16 pad;
u16 dist_counter;
s_xyz last_direction;
} CameraStaffRoll;
typedef struct camera_main_talk_s {
ACTOR* speaker_actor;
ACTOR* listener_actor;
xyz_t listener_pos;
f32 cull_timer;
u32 flags;
xyz_t goal_center_pos;
} CameraTalk;
typedef struct camera_main_wade_s {
f32 timer;
xyz_t start_pos;
xyz_t goal_pos;
f32 goal_time;
} CameraWade;
typedef union camera_main_data_u {
CameraCustTalk cust_talk;
CameraDemo demo;
CameraDoor door;
CameraInter inter;
CameraItem item;
CameraLock lock;
CameraNormal normal;
CameraSimple simple;
CameraStaffRoll staff_roll;
CameraTalk talk;
CameraWade wade;
u64 align;
} CameraMainData;
/* request index data */
typedef struct camera_request_cust_talk_s {
ACTOR* speaker_actor;
ACTOR* listener_actor;
f32 center_ratio;
f32 cull_timer;
s16 angle_x;
s16 angle_y;
f32 distance;
} CameraRequestCustTalk;
typedef struct camera_request_demo_s {
xyz_t starting_center_pos;
f32 starting_distance;
s_xyz starting_direction;
xyz_t goal_center_pos;
f32 goal_distance;
s_xyz goal_direction;
f32 goal_delta;
f32 acceleration_delta;
f32 braking_delta;
} CameraRequestDemo;
typedef struct camera_request_door_s {
ACTOR* door_actor;
u32 flags;
} CameraRequestDoor;
typedef struct camera_request_inter_s {
xyz_t starting_center_pos;
xyz_t starting_eye_pos;
xyz_t goal_center_pos;
xyz_t goal_eye_pos;
f32 slope0;
f32 slope1;
u32 flags;
int morph_counter;
int pad[2];
} CameraRequestInter;
typedef struct camera_request_item_s {
int type;
} CameraRequestItem;
typedef struct camera_request_lock_s {
xyz_t center_pos;
xyz_t eye_pos;
f32 fov_y;
int morph_counter;
f32 near;
f32 far;
} CameraRequestLock;
typedef struct camera_request_normal_s {
xyz_t position;
int flags;
} CameraRequestNormal;
typedef struct camera_request_simple_s {
xyz_t center_pos;
s_xyz angle;
f32 distance;
int morph_counter;
int mode;
} CameraRequestSimple;
typedef struct camera_request_staff_roll_s {
ACTOR* speaker_actor;
ACTOR* listener_actor;
} CameraRequestStaffRoll;
typedef struct camera_request_talk_s {
ACTOR* speaker_actor;
ACTOR* listener_actor;
xyz_t listener_pos;
u32 flags;
} CameraRequestTalk;
typedef struct camera_request_wade_s {
xyz_t goal_pos;
f32 goal_time;
} CameraRequestWade;
typedef union camera_request_data_u {
CameraRequestCustTalk cust_talk;
CameraRequestDemo demo;
CameraRequestDoor door;
CameraRequestInter inter;
CameraRequestItem item;
CameraRequestLock lock;
CameraRequestNormal normal;
CameraRequestSimple simple;
CameraRequestStaffRoll staff_roll;
CameraRequestTalk talk;
CameraRequestWade wade;
u64 align;
} CameraRequestData;
typedef struct camera_s {
struct {
xyz_t eye;
xyz_t center;
xyz_t up;
} lookat;
struct {
f32 fov_y;
f32 aspect_ratio;
f32 near;
f32 far;
f32 scale;
} perspective;
s_xyz direction; /* camera orientation */
s_xyz direction_velocity; /* camera orentation rate of change */
xyz_t movement_velocity; /* camera world position velocity */
f32 focus_distance; /* distance to the camera focal point/subject */
f32 focus_distance_velocity; /* rate of change of the camera focus */
int indoor_distance_addition_idx; /* index of indoor distance adjustment LUT value to apply */
int indoor_direction_addition_idx; /* index of indoor direction adjustment LUT value to apply */
int now_main_index; /* current main index type */
int last_main_index; /* previous main index type */
int requested_main_index; /* requested main index type */
int requested_main_index_priority; /* requested main index priority value */
int requested_main_index_flag; /* TRUE/FALSE requested main index has been set */
CameraMainData main_data; /* current main index data */
CameraRequestData request_data; /* requested index data */
xyz_t mic_pos; /* mic position */
u32 flags; /* camera flags */
xyz_t unused[2]; // potentially unused, idk if it's even xyz_t
} Camera2;
#ifdef __cplusplus
}
#endif
#endif
+1
View File
@@ -137,6 +137,7 @@ typedef struct ghost_common_s {
} mEv_gst_common_c;
extern int mEv_CheckFirstJob();
extern int mEv_CheckFirstIntro();
extern int mEv_CheckArbeit();
extern int mEv_CheckTitleDemo();
extern int mEv_check_status(int event, s16 status);
+9
View File
@@ -33,6 +33,15 @@ enum field_type {
mFI_FIELDTYPE_NUM
};
enum field_type2 {
mFI_FIELDTYPE2_FG,
mFI_FIELDTYPE2_PLAYER_ROOM,
mFI_FIELDTYPE2_NPC_ROOM,
mFI_FIELDTYPE2_ROOM,
mFI_FIELDTYPE2_NUM
};
#define mFI_TO_FIELD_ID(type, index) (((type) << 12) | (index))
#define mFI_GET_TYPE(field_id) ((field_id) & 0xF000)
#define mFI_TYPE(type) ((type) << 12)
+3 -13
View File
@@ -2,9 +2,11 @@
#define M_LIB_H
#include "types.h"
#include "m_play.h"
#include "m_play_h.h"
#include "m_actor_type.h"
#include "MSL_C/math.h"
#include "libu64/u64types.h"
#include "game.h"
#ifdef __cplusplus
extern "C" {
@@ -32,18 +34,6 @@ extern "C" {
/* short angle -> degrees */
#define SHORT2DEG_ANGLE(s) ((((f32)(s)) / (65536.0f / 360.0f)))
typedef struct xy_s {
f32 x, y;
} xy_t;
typedef struct xyz_s {
f32 x, y, z;
} xyz_t;
typedef struct s_xyz_s {
s16 x, y, z;
} s_xyz;
typedef struct rgba_t { //can be put in other place
u8 r, g, b, a;
} rgba_t;
+2
View File
@@ -21,6 +21,8 @@ extern void mMsg_debug_draw(gfxprint_t* gfxprint);
extern void mMsg_aram_init();
extern int mMsg_Check_MainHide(M_MSG_WINDOW* msg);
#ifdef __cplusplus
}
#endif
+8 -1
View File
@@ -343,7 +343,14 @@ extern int mNT_check_unknown(mActor_name_t item_no);
#define ITM_PAPER_STACK_TWO_START 0x2040
#define ITM_PAPER_STACK_THREE_START 0x2080
#define ITM_PAPER_STACK_FOUR_START 0x20C0
#define ITM_PAPER_END 0x2FFF
#define ITM_PAPER_END 0x20FF
#define ITM_MONEY_START 0x2100
#define ITM_MONEY_1000 ITM_MONEY_START // 0x2100
#define ITM_MONEY_10000 (ITM_MONEY_1000 + 1) // 0x2101
#define ITM_MONEY_30000 (ITM_MONEY_10000 + 1) // 0x2102
#define ITM_MONEY_100 (ITM_MONEY_30000 + 1) // 0x2103
#define ITM_MONEY_END ITM_MONEY_100 // 0x2103
#define ITM_TOOL_START 0x2200
#define ITM_NET ITM_TOOL_START
+10 -3
View File
@@ -3,9 +3,12 @@
#include "types.h"
#include "libu64/u64types.h"
#include "m_lib.h"
#include "libc/math.h"
#ifdef __cplusplus
extern "C" {
#endif
//gotta put these somewhere else
#define TRUNCF_BINANG(f) (s16)(s32)(f)
#define CAM_DEG_TO_BINANG(degrees) (s16)TRUNCF_BINANG((degrees) * 182.04167f + .5f)
@@ -16,7 +19,11 @@ typedef struct rect_s {
int l, r;
} rect;
void radianxy_by_2pos(xyz_t* dest, xyz_t* sub, xyz_t* min);
s_xyz sanglexy_by_2pos(xyz_t* sub, xyz_t* min);
extern void radianxy_by_2pos(xyz_t* dest, xyz_t* sub, xyz_t* min);
extern s_xyz sanglexy_by_2pos(xyz_t* sub, xyz_t* min);
#ifdef __cplusplus
}
#endif
#endif
+14 -5
View File
@@ -4,18 +4,27 @@
#include "types.h"
#include "game.h"
#include "libultra/ultratypes.h"
#include "m_view.h"
#include "m_camera2.h"
#include "m_submenu.h"
#include "m_play_h.h"
#ifdef __cplusplus
extern "C" {
#endif
/* sizeof(struct game_play_s) == 0x2600 */
typedef struct game_play_s {
struct game_play_s {
/* 0x0000 */ GAME game;
// TODO: finish
/* 0x00E0 */ u8 d[0x1CC0];
/* 0x1DA0 */ int isPause;
/* 0x1DA4 */ u8 _temp[0x268];
/* 0x00E0 */ u8 _00E0[0x1A68 - 0x00E0];
/* 0x1A68 */ View view;
/* 0x1B88 */ Camera2 camera;
/* 0x1CC0 */ u8 _1CC0[0x1DA0 - 0x1CC0];
/* 0x1DA0 */ int isPause;
/* 0x1DA4 */ u8 _1DA4[0x1DEC - 0x1DA4];
/* 0x1DEC */ Submenu submenu;
/* 0x1FA4 */ u8 _1FA4[0x200C - 0x1FA4];
/* 0x200C */ MtxF matrix;
/* 0x204C */ u8 _204C[0x20D0-0x204C];
/* 0x20D0 */ u8 fb_fade_type;
@@ -23,7 +32,7 @@ typedef struct game_play_s {
/* 0x20D2 */ u8 fb_mode;
/* 0x20D3 */ u8 fb_wipe_mode;
/* 0x20D4 */ u8 _20D4[0x2600 - 0x20D4];
} GAME_PLAY;
};
extern void play_init(GAME_PLAY* play);
extern void play_cleanup(GAME_PLAY* play);
+16
View File
@@ -0,0 +1,16 @@
#ifndef M_PLAY_H_H
#define M_PLAY_H_H
#include "types.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct game_play_s GAME_PLAY;
#ifdef __cplusplus
}
#endif
#endif
+2
View File
@@ -12,6 +12,8 @@ extern PLAYER_ACTOR* get_player_actor_withoutCheck(GAME_PLAY* play);
extern void mPlib_SetData1_controller_data_for_title_demo(f32 stick_x, f32 stick_y, int btn_a, int btn_b);
extern void mPlib_SetData2_controller_data_for_title_demo(mActor_name_t tool);
extern void mPlib_request_main_invade_type1(GAME_PLAY* play);
extern mActor_name_t mPlib_Get_itemNo_forWindow();
extern int mPlib_check_able_change_camera_normal_index();
#ifdef __cplusplus
}
+9
View File
@@ -28,6 +28,14 @@ enum {
mPr_PLAYER_NUM
};
enum {
mPr_ITEM_COND_NORMAL,
mPr_ITEM_COND_PRESENT,
mPr_ITEM_COND_QUEST,
mPr_ITEM_COND_NUM
};
#define mPr_ECARD_NUM 367
#define mPr_ECARD_LETTER_NUM ((mPr_ECARD_NUM + 7) / 8) // 46
@@ -182,6 +190,7 @@ extern void mPr_CopyPersonalID(PersonalID_c* dst, PersonalID_c* src);
extern void mPr_ClearPrivateInfo(Private_c* private_data);
extern int mPr_CheckCmpPlayerName(u8* str0, u8* str1);
extern void mPr_RandomSetPlayerData_title_demo();
extern int mPr_GetPossessionItemSumWithCond(Private_c* priv, mActor_name_t item_no, u32 cond);
#ifdef __cplusplus
}
+1
View File
@@ -107,5 +107,6 @@ extern int mRmTp_FtrItemNo2FtrIdx(mActor_name_t ftr_item_no);
extern mActor_name_t mRmTp_FtrIdx2FtrItemNo(int ftr_idx, int rotation);
extern int mRmTp_GetFurnitureData(mActor_name_t ftr, int ut_x, int ut_z, mRmTp_FtrPlaceInfo_t* place_info);
extern int mRmTp_FurnitureIdx2FurnitureKind(int ftr_idx);
extern int mRmTp_PleaseDrawLightSwitch();
#endif
+26 -3
View File
@@ -13,10 +13,33 @@ extern "C" {
*/
enum scene_table {
/* TODO: finish */
SCENE_FG = 0x07, /* outdoors/FG */
SCENE_TEST1,
SCENE_TEST2,
SCENE_TEST3,
SCENE_WATER_TEST,
SCENE_FOOTPRINT_TEST,
SCENE_NPC_TEST,
SCENE_NPC_HOUSE, /* npc house interior */
SCENE_FG, /* outdoors/FG */
SCENE_RANDOM_NPC_TEST,
SCENE_SHOP0 = 0x09, /* nook's cranny */
SCENE_BROKER_SHOP = 0x0C, /* crazy redd's tent */
SCENE_POST_OFFICE = 0x0E, /* post office */
SCENE_START_DEMO = 0x0F, /* after player select */
SCENE_START_DEMO2 = 0x10, /* */
SCENE_BUGGY = 0x12,
SCENE_PLAYERSELECT = 0x13,
SCENE_CONVENI = 0x17, /* nook 'n' go */
SCENE_SUPER = 0x18, /* nookway */
SCENE_DEPART = 0x19, /* nookington's 1st floor */
SCENE_DEPART_2 = 0x1D, /* nookington's 2nd floor */
SCENE_TITLE_DEMO = 0x21, /* title screen demo */
SCENE_ISLAND_COTTAGE = 0x2F,
SCENE_PLAYERSELECT_SAVE = 0x22,
SCENE_MUSEUM_ENTRANCE = 0x23,
SCENE_MUSEUM_ROOM = 0x24,
SCENE_NEEDLEWORK = 0x2E, /* able sister's */
SCENE_COTTAGE_MY = 0x2F,
SCENE_COTTAGE_NPC = 0x30,
/* TODO: finish */
};
+35
View File
@@ -0,0 +1,35 @@
#ifndef M_SUBMENU_H
#define M_SUBMENU_H
#include "types.h"
#ifdef __cplusplus
extern "C" {
#endif
enum {
mSM_PROCESS_WAIT,
mSM_PROCESS_PREWAIT,
mSM_PROCESS_LINKWAIT,
mSM_PROCESS_PLAY,
mSM_PROCESS_END,
mSM_PROCESS_NUM
};
/* sizeof (Submenu) == 0x1B8 */
typedef struct submenu_s {
/* 0x000 */ int mode;
/* 0x004 */ int menu_type;
/* 0x008 */ int current_menu_type;
/* 0x00C */ int process_status;
/* 0x010 */ u8 _10[0x1B8 - 0x010];
// TODO: finish
} Submenu;
#ifdef __cplusplus
}
#endif
#endif
+36
View File
@@ -0,0 +1,36 @@
#ifndef M_WATCH_MY_STEP_H
#define M_WATCH_MY_STEP_H
#include "types.h"
#include "m_play.h"
#include "main.h"
#ifdef __cplusplus
extern "C" {
#endif
extern Gfx fki_win_mode[];
extern Gfx fki_win_w3T_model[];
extern Gfx fki_win_w2T_model[];
extern Gfx fki_win_w4_model[];
extern Gfx fki_win_w1T_model[];
extern Gfx cam_win_winT_model[];
extern Gfx cam_win_cT_model[];
extern Gfx cam_win_mojiT_model[];
extern Gfx cam_win_yajirushi_model[];
extern Gfx elc_win_winT_model[];
extern Gfx elc_win_zT_model[];
extern Gfx elc_win_moji_model[];
extern Gfx elc_win_moji2T_model[];
extern Gfx mny_win_ueT_model[];
extern Gfx mny_win_beruT_model[];
extern Gfx mny_win_mojiT_model[];
#ifdef __cplusplus
}
#endif
#endif
+3
View File
@@ -22,7 +22,10 @@ extern void new_Matrix(GAME* game);
extern void Matrix_softcv3_mult(xyz_t* src, s_xyz* dest);
extern Mtx* _MtxF_to_Mtx(MtxF* src, Mtx* dest);
extern void Matrix_mult(MtxF* m, s8 flag);
extern void Matrix_scale(f32 x, f32 y, f32 z, s8 flag);
extern void Matrix_translate(f32 x, f32 y, f32 z, s8 flag);
extern void Matrix_Position(xyz_t* wpos, xyz_t* screen_pos);
extern Mtx* _Matrix_to_Mtx_new(GRAPH* graph);
#ifdef __cplusplus
}