Added entity struct

This commit is contained in:
AnonymousRandomPerson 2023-08-27 22:06:17 -04:00
parent 68593e2d2f
commit 2b134f8fe4
7 changed files with 226 additions and 3 deletions

23
include/LICENSE.txt Normal file
View File

@ -0,0 +1,23 @@
NOTE: The following license applies only to the files within this directory.
MIT License
Copyright (c) 2022 UsernameFodder
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

71
include/dungeon_mode.h Normal file
View File

@ -0,0 +1,71 @@
#ifndef PMDSKY_DUNGEON_MODE_H
#define PMDSKY_DUNGEON_MODE_H
#include "graphics.h"
// Used in various contexts, like with entity positions in the dungeon
struct position {
s16 x;
s16 y;
};
// Used to indicate the pixel position of an entity. Values are shifted 8 bits to the left, so they
// are probably decimal numbers instead.
struct pixel_position {
u32 x;
u32 y;
};
// Entity type. This is used to tag generic entity pointers.
enum entity_type {
ENTITY_NOTHING = 0,
ENTITY_MONSTER = 1,
ENTITY_TRAP = 2,
ENTITY_ITEM = 3,
ENTITY_HIDDEN_STAIRS = 5,
// Used when a temporary instance of this struct is created to pass it to some
// function that requires it as a parameter
ENTITY_TEMPORARY = 6,
};
// Generic entity data
struct entity {
enum entity_type type; // 0x0
struct position pos; // 0x4
struct position prev_pos; // 0x8
struct pixel_position pixel_pos; // 0xC
struct pixel_position pixel_pos_mirror; // 0x14: Monsters only?
// 0x1C: Graphical parameter for evelation above the ground. Last byte behaves weirdly.
s32 elevation;
u8 is_visible; // 0x20: For traps/hidden stairs
u8 field_0x21;
// 0x22: If true, the sprite will be shown with a certain degree of transparency
u8 transparent;
// 0x23: Seems to be the animation frame counter for the 10-frame "shuffle" animation that
// plays at the end of a walk sequence
u8 end_walk_anim_frame;
u8 field_0x24;
u8 room_idx; // 0x25: Index of the room a monster is in. 0xFF for hall
// 0x26: Unique index for each monster that spawns. Starts at 0xA for the leader, and each
// subsequent monster to spawn is assigned the next number (0xB, 0xC, ...)
u16 spawn_genid;
u8 field_0x28;
u8 field_0x29;
u8 field_0x2a;
u8 field_0x2b;
struct animation_control anim_ctrl;
u16 sprite_index; // 0xA8
u8 field_0xaa;
u8 field_0xab;
u8 field_0xac;
u8 field_0xad;
u8 animation_group_id; // 0xAE
u8 animation_group_id_mirror; // 0xAF
u8 animation_id; // 0xB0
u8 animation_id_mirror0; // 0xB1
u8 field_0xb2;
u8 field_0xb3;
void* info; // 0xB4: Points to info struct for monster/item/trap
};
#endif //PMDSKY_DUNGEON_MODE_H

89
include/graphics.h Normal file
View File

@ -0,0 +1,89 @@
#ifndef PMDSKY_GRAPHICS_H
#define PMDSKY_GRAPHICS_H
#include "util.h"
#include "wan.h"
struct wan_offset {
struct uvec2_16 head;
struct uvec2_16 hand_left;
struct uvec2_16 hand_right;
struct uvec2_16 center;
};
struct wan_palettes {
struct rgba* palette_bytes;
u16 unk1;
u16 nb_color;
u16 unk2;
u16 unk3;
s32 unk4; // Normally always 0
};
// Contains data relating to animation.
// Mentioned under the name of "AnimeCtrl" in a debug message.
struct animation_control {
u16 some_bitfield;
u16 field1_0x2;
u16 field2_0x4;
u16 anim_frame_duration;
u16 field4_0x8;
u16 field5_0xa;
u16 field6_0xc; // (from struct entity) animation frame counter for the idle animation?
u8 field7_0xe;
u8 field8_0xf;
// appears to be a structure used for unknown purpose with 6 2-byte value
u16 field9_0x10[6];
u16 field10_0x1c;
u16 field11_0x1e;
struct vec2_16 anim_frame_offset;
struct vec2_16 anim_frame_shadow_offset;
s32 anim_frame_flag;
s32 anim_frame_flag_sum; // ORed from the current WAN animation frame flag
u16 animations_or_group_len; // number of animation group Chara sprites, other number of
// animation in the first animation group
u16 field19_0x32;
u8 field20_0x34;
u8 field21_0x35;
u16 field22_0x36; // seems to be an index into the wan fragments table
u16 field23_0x38;
u16 anim_frame_frame_id;
u16 field25_0x3c;
u8 field26_0x3e;
u8 field27_0x3f;
// Used to determine where to store the palette's colors. Multiplied by 0x100
u8 palette_pos_high;
u8 palette_pos_low; // Used to determine where to store the palette's colors
u8 field30_0x42;
u8 field31_0x43;
u8 field32_0x44;
u8 field33_0x45;
u8 field34_0x46;
u8 field35_0x47;
struct wan_animation_frame* first_animation_frame; // first frame in animation group
struct wan_animation_frame* next_animation_frame;
struct wan_offset* wan_offsets;
u8* wan_frames;
void** wan_fragments_byte_store;
struct wan_palettes* wan_palettes;
u16 wan_is_256_color;
u16 loop_start; // same meaning as in struct wan_animation_frame
u8 field44_0x64;
u8 field45_0x65;
u8 field46_0x66;
u8 field47_0x67;
// seems to point to a SIRO file containing another sprite, that is sometimes used instead of
// the one specified in loaded_sprite_id (maybe it is loaded_sprite_id but looked up?)
u8* sprite_override;
u32 field49_0x6c;
u16 loaded_sprite_id; // id in the WAN_TABLE static list
u16 field51_0x72;
u8 field52_0x74;
u8 field53_0x75;
u16 animation_group_id;
u16 animation_id;
u8 palette_bank;
u8 field57_0x7b;
};
#endif //PMDSKY_GRAPHICS_H

View File

@ -1,6 +1,8 @@
#ifndef PMDSKY_OVERLAY_29_022E0354_H
#define PMDSKY_OVERLAY_29_022E0354_H
u8 EntityIsValid__022E0354(s32 *entity);
#include "dungeon_mode.h"
u8 EntityIsValid__022E0354(struct entity *entity);
#endif //PMDSKY_OVERLAY_29_022E0354_H

24
include/util.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef PMDSKY_UTIL_H
#define PMDSKY_UTIL_H
// RGBA8 structure. Sometimes alpha is ignored and only used for padding
struct rgba {
u8 r;
u8 b;
u8 g;
u8 a; // Sometimes used only for padding
};
// a 2d short (16bit) vector
struct vec2_16 {
s16 x;
s16 y;
};
// a 2d ushort (16bit) vector
struct uvec2_16 {
u16 x;
u16 y;
};
#endif //PMDSKY_UTIL_H

14
include/wan.h Normal file
View File

@ -0,0 +1,14 @@
#ifndef PMDSKY_WAN_H
#define PMDSKY_WAN_H
#include "util.h"
struct wan_animation_frame {
u8 duration;
u8 flag;
u16 frame_id;
struct vec2_16 offset;
struct vec2_16 shadow_offset;
};
#endif //PMDSKY_WAN_H

View File

@ -1,10 +1,10 @@
#include "overlay_29_022E0354.h"
u8 EntityIsValid__022E0354(s32 *entity)
u8 EntityIsValid__022E0354(struct entity *entity)
{
if (entity == NULL)
{
return FALSE;
}
return *entity != 0;
return entity->type != ENTITY_NOTHING;
}