1 /*! \file 2 * \brief AF move handling. 3 * \details Functions and structs for reading, writing and modifying OMF:2097 Fighter specific move structures. 4 * \copyright MIT license. 5 * \date 2013-2014 6 * \author Andrew Thompson 7 * \author Tuomas Virtanen 8 */ 9 10 #ifndef _SD_MOVE_H 11 #define _SD_MOVE_H 12 13 #include <stdint.h> 14 #include "shadowdive/animation.h" 15 #ifdef SD_USE_INTERNAL 16 #include "shadowdive/internal/reader.h" 17 #include "shadowdive/internal/writer.h" 18 #endif 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 #define SD_MOVE_STRING_MAX 21 ///< Maximum allowed move string length 25 #define SD_MOVE_FOOTER_STRING_MAX 512 ///< Maximum allowed footer string length 26 27 /*! \brief HAR Move information 28 * 29 * Contains information about the HAR move. Wraps a generic animation. 30 * \todo Find out what the unknown fields are. 31 */ 32 typedef struct { 33 sd_animation *animation; ///< Animation field for Move. When saving AF file, this should be != NULL. 34 35 uint16_t unknown_0; ///< Unknown value 36 uint16_t unknown_2; ///< Unknown value 37 uint8_t unknown_4; ///< Unknown value 38 uint8_t unknown_5; ///< Unknown value 39 uint8_t unknown_6; ///< Unknown value 40 uint8_t unknown_7; ///< Unknown value 41 uint8_t unknown_8; ///< Unknown value 42 uint8_t unknown_9; ///< Unknown value 43 uint8_t unknown_10; ///< Unknown value 44 uint8_t unknown_11; ///< Unknown value 45 uint8_t next_anim_id; ///< Next animation ID 46 uint8_t category; ///< Move category ID 47 uint8_t unknown_14; ///< Unknown value 48 uint8_t scrap_amount; ///< Scrap amount when this move connects 49 uint8_t successor_id; ///< Successor animation ID 50 uint8_t damage_amount; ///< Damage amount when this move connects 51 uint8_t unknown_18; ///< Unknown value 52 uint8_t unknown_19; ///< Unknown value 53 uint8_t points; ///< Score gained for this hit 54 55 char move_string[SD_MOVE_STRING_MAX]; ///< Move string 56 char footer_string[SD_MOVE_FOOTER_STRING_MAX]; ///< Footer string 57 } sd_move; 58 59 /*! \brief Initialize Move structure 60 * 61 * Initializes the move structure with empty values. 62 * 63 * \retval SD_INVALID_INPUT BK struct pointer was NULL 64 * \retval SD_SUCCESS Success. 65 * 66 * \param move Allocated move struct pointer. 67 */ 68 int sd_move_create(sd_move *move); 69 70 /*! \brief Copy Move structure 71 * 72 * Copies the contents of an move structure. _ALL_ internals will be copied. 73 * The copied structure must be freed using sd_move_free(). 74 * 75 * Destination buffer does not need to be cleared. Source buffer must be a valid 76 * move structure, or problems are likely to appear. 77 * 78 * \retval SD_OUT_OF_MEMORY Memory ran out. Destination struct should now be considered invalid and freed. 79 * \retval SD_INVALID_INPUT Either input value was NULL. 80 * \retval SD_SUCCESS Success. 81 * 82 * \param dst Destination move struct pointer. 83 * \param src Source move struct pointer. 84 */ 85 int sd_move_copy(sd_move *dst, const sd_move *src); 86 87 /*! \brief Free move structure 88 * 89 * Frees up all memory reserved by the move structure. 90 * All contents will be freed, all pointers to contents will be invalid. 91 * 92 * \param move Move struct to modify. 93 */ 94 void sd_move_free(sd_move *move); 95 96 /*! \brief Set animation struct for move 97 * 98 * Sets an animation for the move. Animation will be copied, 99 * so remember to free your local copy yourself. Note that any valid 100 * move struct should ALWAYS contain an animation. Otherwise there will be problems 101 * eg. saving the AF file. 102 * 103 * A NULL value for animation field will result in move->animation field getting freed. 104 * 105 * \retval SD_OUT_OF_MEMORY Memory ran out. Animation field will be NULL. 106 * \retval SD_INVALID_INPUT Move struct pointer was NULL. 107 * \retval SD_SUCCESS on success. 108 * 109 * \param move Move struct to modify. 110 * \param animation Animation to set. This will be copied. 111 */ 112 int sd_move_set_animation(sd_move *move, const sd_animation *animation); 113 114 /*! \brief Get the current animation 115 * 116 * Returns a pointer to the current animation for the move. If animation 117 * is not set, NULL will be returned. 118 * 119 * \retval NULL Animation does not exist 120 * \retval sd_animation* Success 121 * 122 * \param move Move struct to modify. 123 */ 124 sd_animation* sd_move_get_animation(const sd_move *move); 125 126 /*! \brief Set move footer string for the Move struct. 127 * 128 * Sets the move footer string for the Move struct. Maximum length is 129 * 512 bytes. Longer strings will result in error. 130 * 131 * \retval SD_INVALID_INPUT Input string was too long. 132 * \retval SD_SUCCESS Success. 133 * 134 * \param move Move struct to modify. 135 * \param str String to set. 136 */ 137 int sd_move_set_footer_string(sd_move *move, const char *str); 138 139 /*! \brief Set move string for the Move struct. 140 * 141 * Sets the move string for the Move struct. Maximum length is 142 * 21 bytes. Longer strings will result in error. 143 * 144 * \retval SD_INVALID_INPUT Input string was too long. 145 * \retval SD_SUCCESS Success. 146 * 147 * \param move Move struct to modify. 148 * \param str String to set. 149 */ 150 int sd_move_set_move_string(sd_move *move, const char *str); 151 152 #ifdef SD_USE_INTERNAL 153 int sd_move_load(sd_reader *reader, sd_move *move); 154 int sd_move_save(sd_writer *writer, const sd_move *move); 155 #endif 156 157 #ifdef __cplusplus 158 } 159 #endif 160 161 #endif // _SD_MOVE_H 162