Skip to content

Commit

Permalink
update some npc structures
Browse files Browse the repository at this point in the history
  • Loading branch information
SBird1337 committed Jul 30, 2018
1 parent 732e4c1 commit 1063239
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 24 deletions.
21 changes: 13 additions & 8 deletions build/include/pokeagb/core/m4a.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ struct WaveData
#define TONEDATA_P_S_PAN 0xc0
#define TONEDATA_P_S_PAM TONEDATA_P_S_PAN

#define CHN_TYPE_FIXED_FREQ 0x8
#define CHN_TYPE_REVERSE 0x10
#define CHN_TYPE_COMP 0x20
#define CHN_TYPE_SYNTH 0x40

struct ToneData
{
u8 type;
Expand Down Expand Up @@ -143,14 +148,14 @@ struct SoundChannel
u8 pr;
u8 rp;
u8 d3[3];
u32 ct;
u32 fw;
u32 ct; // current sample countdown
u32 fw; // fine sample inter position
u32 freq;
struct WaveData *wav;
u32 cp;
u32 cp; // current position of sample playback (pointer)
struct MusicPlayerTrack *track;
u32 pp;
u32 np;
struct SoundChannel *pp;
struct SoundChannel *np;
u32 d4;
u16 xpi;
u16 xpc;
Expand Down Expand Up @@ -181,9 +186,9 @@ struct SoundInfo
u8 pcmDmaPeriod; // number of V-blanks per PCM DMA
u8 maxLines;
u8 gap[3];
s32 pcmSamplesPerVBlank;
s32 pcmFreq;
s32 divFreq;
u32 pcmSamplesPerVBlank;
u32 pcmFreq;
u32 divFreq;
struct CgbChannel *cgbChans;
u32 func;
u32 intp;
Expand Down
57 changes: 49 additions & 8 deletions build/include/pokeagb/overworld/npc.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,22 @@ POKEAGB_BEGIN_DECL
*/
#define NPC_STATE_ID_MAX 0x10

/**
* Direction for the player to walk in, TODO: Check if right
*/
enum Direction {
NONE = 0,
SOUTH = 1,
NORTH = 2,
WEST = 3,
EAST = 4,
SOUTH_WEST = 5,
SOUTH_EAST = 6,
NORTH_WEST = 7,
NORTH_EAST = 8,
DIRECTION_MAX
};

/**
* An NPC in the overworld.
*/
Expand All @@ -41,7 +57,7 @@ struct NpcState {
struct Coords16 stay_around;
struct Coords16 to;
struct Coords16 from;
u8 direction;
enum Direction direction;
u8 movement_area;
u8 field1A;
u8 oamid2;
Expand Down Expand Up @@ -127,12 +143,12 @@ POKEAGB_EXTERN u8 npc_half_reset_no_checks(struct NpcState* npc);
/**
* @address{BPRE,0805FBDC}
*/
POKEAGB_EXTERN void npc_update_direction(struct NpcState* npc, u8 direction);
POKEAGB_EXTERN void npc_update_direction(struct NpcState* npc, enum Direction direction);

/**
* @address{BPRE, 08064678}
*/
POKEAGB_EXTERN void npc_apply_direction(struct NpcState *npc, struct Object *obj, u8 direction);
POKEAGB_EXTERN void npc_apply_direction(struct NpcState *npc, struct Object *obj, enum Direction direction);

/**
* @address{BPRE, 08081BEC}
Expand All @@ -152,7 +168,7 @@ POKEAGB_EXTERN bool npc_move_end(struct NpcState *npc, struct Object* obj);
/**
* @address{BPRE, 080646FC}
*/
POKEAGB_EXTERN void npc_run_any(struct NpcState* npc, struct Object* obj, u8 direction, u8);
POKEAGB_EXTERN void npc_run_any(struct NpcState* npc, struct Object* obj, enum Direction direction, u8);

/**
* @address{BPRE, 08080334}
Expand Down Expand Up @@ -181,7 +197,7 @@ POKEAGB_EXTERN void npc_fix_position(u16 x, u16 y, s16 *obj_x, s16 *obj_y);
* Returns the animation image number corresponding to the given direction
* @address{BPRE,08063430}
*/
POKEAGB_EXTERN u8 npc_direction_to_obj_anim_image_number(u8 direction);
POKEAGB_EXTERN u8 npc_direction_to_obj_anim_image_number(enum Direction direction);

/**
* @address{BPRE,0805F5A0}
Expand Down Expand Up @@ -231,7 +247,7 @@ POKEAGB_EXTERN void obj_npc_animation_step(struct NpcState *npc, struct Object *
* Create a struct Template that can be used to spawn an NPC
* @address{BPRE,0806359C}
*/
POKEAGB_EXTERN void npc_set_direction(struct NpcState *npc, u8 direction);
POKEAGB_EXTERN void npc_set_direction(struct NpcState *npc, enum Direction direction);

/**
* Create a struct Template that can be used to spawn an NPC
Expand Down Expand Up @@ -295,7 +311,7 @@ POKEAGB_EXTERN void npc_change_sprite(struct NpcState* npc, u8 sprite);
*
* @address{BPRE,0805F218}
*/
POKEAGB_EXTERN void npc_turn(struct NpcState* npc, u8 direction);
POKEAGB_EXTERN void npc_turn(struct NpcState* npc, enum Direction direction);

/**
* Exclamation mark animation over npc.
Expand Down Expand Up @@ -341,7 +357,32 @@ POKEAGB_EXTERN u8 npc_id_by_pos_and_height(u16 x, u16 y, u8 height);
* Move the coordinates one square in the given direction.
* @address{BPRE,08063A20}
*/
POKEAGB_EXTERN void coordinates_move_direction(u8 direction, u16* x, u16* y);
POKEAGB_EXTERN void coordinates_move_direction(enum Direction direction, u16* x, u16* y);

/**
* @address{BPRE,080636AC}
*/
POKEAGB_EXTERN u8 npc_block_way(struct NpcState *npc, u16 x, u16 y, enum Direction direction);

/**
* @address{BPRE,0805BC60}
*/
POKEAGB_EXTERN bool npc_is_passable_maybe(u16 x, u16 y, enum Direction direction);

/**
* @address{BPRE,0805BCC8}
*/
POKEAGB_EXTERN bool npc_handle_jump(u16 x, u16 y, enum Direction direction);

/**
* @address{BPRE,0805BCEC}
*/
POKEAGB_EXTERN bool npc_handle_strength(u16 x, u16 y, enum Direction direction);

/**
* @address{BPRE,0805C024}
*/
POKEAGB_EXTERN void npc_player_set_movement_and_x22(u8 movement, u8 x22);

POKEAGB_END_DECL

Expand Down
5 changes: 5 additions & 0 deletions build/linker/BPRE.ld
Original file line number Diff line number Diff line change
Expand Up @@ -536,20 +536,25 @@ PROVIDE(coordinates_move_direction = 0x08063a20|1);
PROVIDE(hacked_npc_pal_idx_for_given_tag = 0x0805f5a0|1);
PROVIDE(npc_805EFF4 = 0x0805eff4|1);
PROVIDE(npc_apply_direction = 0x08064678|1);
PROVIDE(npc_block_way = 0x080636ac|1);
PROVIDE(npc_change_sprite = 0x0805f060|1);
PROVIDE(npc_coords_shift_still = 0x0805f818|1);
PROVIDE(npc_direction_to_obj_anim_image_number = 0x08063430|1);
PROVIDE(npc_fix_position = 0x08063ad4|1);
PROVIDE(npc_half_reset = 0x08063d1c|1);
PROVIDE(npc_half_reset_no_checks = 0x08063d34|1);
PROVIDE(npc_half_reset_when_bit7_is_set = 0x08063d7c|1);
PROVIDE(npc_handle_jump = 0x0805bcc8|1);
PROVIDE(npc_handle_strength = 0x0805bcec|1);
PROVIDE(npc_id_by_local_id = 0x0805df60|1);
PROVIDE(npc_id_by_local_id_and_map_ret_success = 0x0805df84|1);
PROVIDE(npc_id_by_pos_and_height = 0x0805f894|1);
PROVIDE(npc_instanciation_something = 0x0805e72c|1);
PROVIDE(npc_is_passable_maybe = 0x0805bc60|1);
PROVIDE(npc_move_end = 0x08067934|1);
PROVIDE(npc_obj_offscreen_culling_and_flag_update = 0x080679f8|1);
PROVIDE(npc_pal_idx_for_given_tag = 0x0805f5a0|1);
PROVIDE(npc_player_set_movement_and_x22 = 0x0805c024|1);
PROVIDE(npc_run_any = 0x080646fc|1);
PROVIDE(npc_run_is_finished = 0x080652ec|1);
PROVIDE(npc_set_direction = 0x0806359c|1);
Expand Down
57 changes: 49 additions & 8 deletions include/pokeagb/overworld/npc.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,22 @@ POKEAGB_BEGIN_DECL
*/
#define NPC_STATE_ID_MAX 0x10

/**
* Direction for the player to walk in, TODO: Check if right
*/
enum Direction {
NONE = 0,
SOUTH = 1,
NORTH = 2,
WEST = 3,
EAST = 4,
SOUTH_WEST = 5,
SOUTH_EAST = 6,
NORTH_WEST = 7,
NORTH_EAST = 8,
DIRECTION_MAX
};

/**
* An NPC in the overworld.
*/
Expand All @@ -41,7 +57,7 @@ struct NpcState {
struct Coords16 stay_around;
struct Coords16 to;
struct Coords16 from;
u8 direction;
enum Direction direction;
u8 movement_area;
u8 field1A;
u8 oamid2;
Expand Down Expand Up @@ -127,12 +143,12 @@ POKEAGB_EXTERN u8 npc_half_reset_no_checks(struct NpcState* npc);
/**
* @address{BPRE,0805FBDC}
*/
POKEAGB_EXTERN void npc_update_direction(struct NpcState* npc, u8 direction);
POKEAGB_EXTERN void npc_update_direction(struct NpcState* npc, enum Direction direction);

/**
* @address{BPRE, 08064678}
*/
POKEAGB_EXTERN void npc_apply_direction(struct NpcState *npc, struct Object *obj, u8 direction);
POKEAGB_EXTERN void npc_apply_direction(struct NpcState *npc, struct Object *obj, enum Direction direction);

/**
* @address{BPRE, 08081BEC}
Expand All @@ -152,7 +168,7 @@ POKEAGB_EXTERN bool npc_move_end(struct NpcState *npc, struct Object* obj);
/**
* @address{BPRE, 080646FC}
*/
POKEAGB_EXTERN void npc_run_any(struct NpcState* npc, struct Object* obj, u8 direction, u8);
POKEAGB_EXTERN void npc_run_any(struct NpcState* npc, struct Object* obj, enum Direction direction, u8);

/**
* @address{BPRE, 08080334}
Expand Down Expand Up @@ -181,7 +197,7 @@ POKEAGB_EXTERN void npc_fix_position(u16 x, u16 y, s16 *obj_x, s16 *obj_y);
* Returns the animation image number corresponding to the given direction
* @address{BPRE,08063430}
*/
POKEAGB_EXTERN u8 npc_direction_to_obj_anim_image_number(u8 direction);
POKEAGB_EXTERN u8 npc_direction_to_obj_anim_image_number(enum Direction direction);

/**
* @address{BPRE,0805F5A0}
Expand Down Expand Up @@ -231,7 +247,7 @@ POKEAGB_EXTERN void obj_npc_animation_step(struct NpcState *npc, struct Object *
* Create a struct Template that can be used to spawn an NPC
* @address{BPRE,0806359C}
*/
POKEAGB_EXTERN void npc_set_direction(struct NpcState *npc, u8 direction);
POKEAGB_EXTERN void npc_set_direction(struct NpcState *npc, enum Direction direction);

/**
* Create a struct Template that can be used to spawn an NPC
Expand Down Expand Up @@ -295,7 +311,7 @@ POKEAGB_EXTERN void npc_change_sprite(struct NpcState* npc, u8 sprite);
*
* @address{BPRE,0805F218}
*/
POKEAGB_EXTERN void npc_turn(struct NpcState* npc, u8 direction);
POKEAGB_EXTERN void npc_turn(struct NpcState* npc, enum Direction direction);

/**
* Exclamation mark animation over npc.
Expand Down Expand Up @@ -341,7 +357,32 @@ POKEAGB_EXTERN u8 npc_id_by_pos_and_height(u16 x, u16 y, u8 height);
* Move the coordinates one square in the given direction.
* @address{BPRE,08063A20}
*/
POKEAGB_EXTERN void coordinates_move_direction(u8 direction, u16* x, u16* y);
POKEAGB_EXTERN void coordinates_move_direction(enum Direction direction, u16* x, u16* y);

/**
* @address{BPRE,080636AC}
*/
POKEAGB_EXTERN u8 npc_block_way(struct NpcState *npc, u16 x, u16 y, enum Direction direction);

/**
* @address{BPRE,0805BC60}
*/
POKEAGB_EXTERN bool npc_is_passable_maybe(u16 x, u16 y, enum Direction direction);

/**
* @address{BPRE,0805BCC8}
*/
POKEAGB_EXTERN bool npc_handle_jump(u16 x, u16 y, enum Direction direction);

/**
* @address{BPRE,0805BCEC}
*/
POKEAGB_EXTERN bool npc_handle_strength(u16 x, u16 y, enum Direction direction);

/**
* @address{BPRE,0805C024}
*/
POKEAGB_EXTERN void npc_player_set_movement_and_x22(u8 movement, u8 x22);

POKEAGB_END_DECL

Expand Down

0 comments on commit 1063239

Please sign in to comment.