-
Notifications
You must be signed in to change notification settings - Fork 606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document z_horse.c and related actors #2278
base: main
Are you sure you want to change the base?
Changes from 3 commits
c52955e
e4f78d8
bebf75e
580ba61
3c62a20
7dfe82b
dbcaf2c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef Z64HORSE_H | ||
#define Z64HORSE_H | ||
|
||
#include "ultra64.h" | ||
#include "z64math.h" | ||
|
||
struct PlayState; | ||
struct Actor; | ||
struct Player; | ||
|
||
void Horse_ResetHorseData(struct PlayState* play); | ||
void Horse_FixLakeHyliaPosition(struct PlayState* play); | ||
void Horse_Set(struct PlayState* play, struct Player* player); | ||
void Horse_RotateToPoint(struct Actor* actor, Vec3f* pos, s16 turnAmount); | ||
|
||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -890,66 +890,66 @@ typedef enum LinkAge { | |
* SaveContext.eventInf | ||
*/ | ||
|
||
// 0x00-0x0F | ||
// horses related | ||
// EVENTINF 0x00-0x0F | ||
// Ingo Race, Lon Lon Ranch minigames, and Horseback Archery minigame flags | ||
#define EVENTINF_HORSES_INDEX 0 | ||
#define EVENTINF_HORSES_STATE_SHIFT 0 | ||
#define EVENTINF_HORSES_HORSETYPE_SHIFT 4 | ||
#define EVENTINF_HORSES_05_SHIFT 5 | ||
#define EVENTINF_HORSES_06_SHIFT 6 | ||
#define EVENTINF_HORSES_08_SHIFT 8 | ||
#define EVENTINF_HORSES_0A_SHIFT 10 | ||
#define EVENTINF_HORSES_0F_SHIFT 15 // unused? | ||
#define EVENTINF_HORSES_STATE_MASK (0xF << EVENTINF_HORSES_STATE_SHIFT) | ||
#define EVENTINF_HORSES_HORSETYPE_MASK (1 << EVENTINF_HORSES_HORSETYPE_SHIFT) | ||
#define EVENTINF_HORSES_05_MASK (1 << EVENTINF_HORSES_05_SHIFT) | ||
#define EVENTINF_HORSES_06_MASK (1 << EVENTINF_HORSES_06_SHIFT) | ||
#define EVENTINF_HORSES_0F_MASK (1 << EVENTINF_HORSES_0F_SHIFT) | ||
#define EVENTINF_HORSES_05 ((EVENTINF_HORSES_INDEX << 4) | EVENTINF_HORSES_05_SHIFT) | ||
#define EVENTINF_HORSES_06 ((EVENTINF_HORSES_INDEX << 4) | EVENTINF_HORSES_06_SHIFT) | ||
// EVENTINF 0x00-0x03 reserved for IngoRaceState | ||
#define EVENTINF_INGORACE_STATE_MASK (0xF << 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: maybe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. INGORACE matches the pre-existing spellings There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The inconsistency between There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would change it now with the understanding that horse_game will also change later. INGORACE as one word is just worse. |
||
typedef enum IngoRaceState { | ||
/* 0 */ INGORACE_STATE_OFFER_RENTAL, | ||
/* 1 */ INGORACE_STATE_HORSE_RENTAL_PERIOD, | ||
/* 2 */ INGORACE_STATE_RACING, | ||
/* 3 */ INGORACE_STATE_PLAYER_LOSE, | ||
/* 4 */ INGORACE_STATE_FIRST_WIN, | ||
/* 5 */ INGORACE_STATE_TRAPPED_WIN_UNUSED, | ||
/* 6 */ INGORACE_STATE_TRAPPED_WIN_EPONA, // Ingo Traps you in Lon Lon | ||
/* 7 */ INGORACE_STATE_REMATCH | ||
} IngoRaceState; | ||
|
||
#define EVENTINF_INGORACE_HORSETYPE 4 | ||
#define EVENTINF_INGORACE_HORSETYPE_MASK (1 << EVENTINF_INGORACE_HORSETYPE) | ||
#define EVENTINF_INGORACE_LOST_ONCE 5 | ||
#define EVENTINF_INGORACE_LOST_ONCE_MASK (1 << EVENTINF_INGORACE_LOST_ONCE) | ||
#define EVENTINF_INGORACE_SECOND_RACE 6 | ||
#define EVENTINF_INGORACE_SECOND_RACE_MASK (1 << EVENTINF_INGORACE_SECOND_RACE) | ||
// Used in z_en_ta (Talon) to store Cucco game winning status | ||
// and in z_en_ge1 (Gerudo) to store archery in-progress status | ||
#define EVENTINF_HORSES_08 ((EVENTINF_HORSES_INDEX << 4) | EVENTINF_HORSES_08_SHIFT) | ||
#define EVENTINF_HORSES_08 8 | ||
#define EVENTINF_CUCCO_GAME_WON EVENTINF_HORSES_08 | ||
// Used in z_en_ta (Talon) and z_en_ma3 (Malon) to store minigame finishing status | ||
#define EVENTINF_HORSES_0A ((EVENTINF_HORSES_INDEX << 4) | EVENTINF_HORSES_0A_SHIFT) | ||
#define EVENTINF_HORSES_0A 10 | ||
#define EVENTINF_CUCCO_GAME_FINISHED EVENTINF_HORSES_0A | ||
|
||
typedef enum EventInfHorsesState { | ||
/* 0 */ EVENTINF_HORSES_STATE_0, | ||
/* 1 */ EVENTINF_HORSES_STATE_1, | ||
/* 2 */ EVENTINF_HORSES_STATE_2, | ||
/* 3 */ EVENTINF_HORSES_STATE_3, | ||
/* 4 */ EVENTINF_HORSES_STATE_4, | ||
/* 5 */ EVENTINF_HORSES_STATE_5, | ||
/* 6 */ EVENTINF_HORSES_STATE_6, | ||
/* 7 */ EVENTINF_HORSES_STATE_7 | ||
} EventInfHorsesState; | ||
#define EVENTINF_INGORACE_0F 15 // unused? | ||
#define EVENTINF_INGORACE_0F_MASK (1 << EVENTINF_INGORACE_0F) | ||
|
||
// "InRaceSeq" | ||
#define GET_EVENTINF_HORSES_STATE() \ | ||
((gSaveContext.eventInf[EVENTINF_HORSES_INDEX] & EVENTINF_HORSES_STATE_MASK) >> EVENTINF_HORSES_STATE_SHIFT) | ||
#define SET_EVENTINF_HORSES_STATE(v) \ | ||
gSaveContext.eventInf[EVENTINF_HORSES_INDEX] = \ | ||
(gSaveContext.eventInf[EVENTINF_HORSES_INDEX] & ~EVENTINF_HORSES_STATE_MASK) | \ | ||
((v) << EVENTINF_HORSES_STATE_SHIFT) | ||
|
||
#define GET_EVENTINF_HORSES_HORSETYPE() \ | ||
((gSaveContext.eventInf[EVENTINF_HORSES_INDEX] & EVENTINF_HORSES_HORSETYPE_MASK) >> EVENTINF_HORSES_HORSETYPE_SHIFT) | ||
#define SET_EVENTINF_HORSES_HORSETYPE(v) \ | ||
gSaveContext.eventInf[EVENTINF_HORSES_INDEX] = \ | ||
(gSaveContext.eventInf[EVENTINF_HORSES_INDEX] & ~EVENTINF_HORSES_HORSETYPE_MASK) | \ | ||
((v) << EVENTINF_HORSES_HORSETYPE_SHIFT) | ||
|
||
#define SET_EVENTINF_HORSES_0F(v) \ | ||
#define GET_EVENTINF_INGORACE_STATE() \ | ||
(gSaveContext.eventInf[EVENTINF_HORSES_INDEX] & EVENTINF_INGORACE_STATE_MASK) | ||
|
||
#define SET_EVENTINF_INGORACE_STATE(v) \ | ||
gSaveContext.eventInf[EVENTINF_HORSES_INDEX] = \ | ||
(gSaveContext.eventInf[EVENTINF_HORSES_INDEX] & ~EVENTINF_HORSES_0F_MASK) | ((v) << EVENTINF_HORSES_0F_SHIFT) | ||
(gSaveContext.eventInf[EVENTINF_HORSES_INDEX] & ~EVENTINF_INGORACE_STATE_MASK) | (v) | ||
|
||
#define GET_EVENTINF_INGORACE_FLAG(flag) \ | ||
((gSaveContext.eventInf[EVENTINF_HORSES_INDEX] & (1 << ((flag) & 0xF))) >> ((flag) & 0xF)) | ||
|
||
#define SET_EVENTINF_INGORACE_FLAG(flag) \ | ||
gSaveContext.eventInf[EVENTINF_HORSES_INDEX] = \ | ||
(gSaveContext.eventInf[EVENTINF_HORSES_INDEX] & 0xFFFF) | (1 << ((flag) & 0xF)) | ||
|
||
#define WRITE_EVENTINF_INGORACE_FLAG(flag, v) \ | ||
gSaveContext.eventInf[EVENTINF_HORSES_INDEX] = \ | ||
(gSaveContext.eventInf[EVENTINF_HORSES_INDEX] & ~(1 << ((flag) & 0xF))) | ((v) << ((flag) & 0xF)) | ||
|
||
#define GET_EVENTINF_INGORACE_HORSETYPE() GET_EVENTINF_INGORACE_FLAG(EVENTINF_INGORACE_HORSETYPE) | ||
#define WRITE_EVENTINF_INGORACE_HORSETYPE(v) WRITE_EVENTINF_INGORACE_FLAG(EVENTINF_INGORACE_HORSETYPE, v) | ||
|
||
#define WRITE_EVENTINF_INGORACE_0F(v) WRITE_EVENTINF_INGORACE_FLAG(EVENTINF_INGORACE_0F, v) | ||
|
||
// Is the running man race active | ||
#define EVENTINF_MARATHON_ACTIVE 0x10 | ||
|
||
// 0x20-0x24 | ||
// EVENTINF 0x20-0x24 | ||
#define EVENTINF_20_21_22_23_24_INDEX 2 | ||
#define EVENTINF_20_MASK (1 << 0) | ||
#define EVENTINF_21_MASK (1 << 1) | ||
|
@@ -959,7 +959,6 @@ typedef enum EventInfHorsesState { | |
|
||
#define EVENTINF_30 0x30 | ||
|
||
|
||
#define GET_EVENTINF(flag) (gSaveContext.eventInf[(flag) >> 4] & (1 << ((flag) & 0xF))) | ||
#define SET_EVENTINF(flag) (gSaveContext.eventInf[(flag) >> 4] |= (1 << ((flag) & 0xF))) | ||
#define CLEAR_EVENTINF(flag) (gSaveContext.eventInf[(flag) >> 4] &= ~(1 << ((flag) & 0xF))) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
#include "rand.h" | ||
#include "terminal.h" | ||
#include "versions.h" | ||
#include "z64horse.h" | ||
|
||
#include "overlays/actors/ovl_Arms_Hook/z_arms_hook.h" | ||
#include "overlays/actors/ovl_En_Part/z_en_part.h" | ||
|
@@ -1130,7 +1131,7 @@ void func_8002DE04(PlayState* play, Actor* actorA, Actor* actorB) { | |
actorA->flags &= ~ACTOR_FLAG_13; | ||
} | ||
|
||
void func_8002DE74(PlayState* play, Player* player) { | ||
void Actor_SetCameraHorseSetting(PlayState* play, Player* player) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I find the wording of this function name awkward ("set" appears twice, and what's a "camera horse"?). Some suggestions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting. Actor_RequestHorseCameraSetting might be best, but I'm not confident on word ordering. |
||
if ((play->roomCtx.curRoom.type != ROOM_TYPE_4) && Play_CamIsNotFixed(play)) { | ||
Camera_RequestSetting(Play_GetCamera(play, CAM_ID_MAIN), CAM_SET_HORSE); | ||
} | ||
|
@@ -1147,8 +1148,8 @@ int func_8002DEEC(Player* player) { | |
(player->csAction != PLAYER_CSACTION_NONE); | ||
} | ||
|
||
void func_8002DF18(PlayState* play, Player* player) { | ||
func_8006DC68(play, player); | ||
void Actor_InitPlayerHorse(PlayState* play, Player* player) { | ||
Horse_Set(play, player); | ||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: space between
//
andIf