Files
nunuhara_xsystem4/include/system4/ex.h
T
Nunuhara Cabbage 05d998886f exdump/exbuild: fix issues with Evenicle2EX.ex
Evenicle2EX.ex uses the previously unknown field data in a different way
that what was assumed. Thanks to that, the unknown data is now more or
less understood:
  * uk0 indicates whether there is a value associated with the field
  * uk1 indicates whether the field is an index
  * uk2 is the value associated with the field, which can be an integer,
    float or string (so far, at least...)

Previously it was assumed that uk2 was a single 32-bit integer, but it
can actually store strings as well. Evenicle 2 is the first game to use
a field with a string value other than the empty string, which breaks
this assumption (the empty string is a 32-bit zero, which is why the old
approach worked).

There is now a new syntax for specifying this data. E.g., a field may
now look like this:
    indexed string s = ""
where it would previously have looked like this:
    string s[1,1,0]

The old syntax is still supported in ainbuild for backwards
compatibility, but is no longer emitted by aindump.

This commit also adds the tool "excmp" which compares two ex files to
see if they are equivalent.
2020-05-18 10:34:43 -07:00

110 lines
2.2 KiB
C

/* Copyright (C) 2019 Nunuhara Cabbage <nunuhara@haniwa.technology>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://gnu.org/licenses/>.
*/
#ifndef SYSTEM4_EX_H
#define SYSTEM4_EX_H
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
enum ex_value_type {
EX_INT = 1,
EX_FLOAT = 2,
EX_STRING = 3,
EX_TABLE = 4,
EX_LIST = 5,
EX_TREE = 6
};
struct ex_value {
enum ex_value_type type;
union {
int32_t i;
float f;
struct string *s;
struct ex_table *t;
struct ex_list *list;
struct ex_tree *tree;
};
};
struct ex_field {
enum ex_value_type type;
struct string *name;
int32_t has_value;
struct ex_value value;
int32_t is_index;
uint32_t nr_subfields;
struct ex_field *subfields;
};
struct ex_table {
uint32_t nr_fields;
struct ex_field *fields;
uint32_t nr_columns;
uint32_t nr_rows;
struct ex_value **rows;
};
struct ex_list_item {
uint32_t size;
struct ex_value value;
};
struct ex_list {
uint32_t nr_items;
struct ex_list_item *items;
};
struct ex_leaf {
uint32_t size;
struct string *name;
struct ex_value value;
};
struct ex_tree {
struct string *name;
bool is_leaf;
union {
struct {
uint32_t nr_children;
struct ex_tree *children;
};
struct ex_leaf leaf;
};
};
struct ex_block {
size_t size;
struct string *name;
struct ex_value val;
};
struct ex {
uint32_t nr_blocks;
struct ex_block *blocks;
};
uint8_t *ex_decrypt(const char *path, size_t *size, uint32_t *nr_blocks);
struct ex *ex_read(const char *path);
void ex_free(struct ex *ex);
void ex_encode(uint8_t *buf, size_t size);
const char *ex_strtype(enum ex_value_type type);
#endif /* SYSTE4_EX_H */