aindump/ainedit: initial ain v14 support

Support for Evenicle 2 and Haha Ranman.

There are a few changes in v14:
* a number of new instructions (semantics yet unknown)
* HLL function arguments and return values can now be complex types
  (e.g. arrays, enums)
* support for nested arrays (this isn't necessarily new, but it doesn't
  occur in Rance X at all)
This commit is contained in:
Nunuhara Cabbage
2020-05-17 13:21:37 -07:00
parent 43818e636a
commit b617449178
13 changed files with 302 additions and 106 deletions
+20 -7
View File
@@ -74,11 +74,13 @@ enum ain_data_type {
AIN_REF_ARRAY = 80,
AIN_ITERATOR = 82, // array iterator
AIN_ENUM1 = 86, // return value of EnumType::Parse; has type 91 in array type
AIN_UNKNOWN_TYPE_87 = 87,
AIN_IFACE = 89, // 2 values: [0] = struct page, [1] = vtable offset to inteface methods
AIN_ENUM2 = 91, // used as array type of type 86; has enum type in struct type
AIN_ENUM3 = 92, // used as argument type, and array type in EnumType::GetList; has enum type in struct type
AIN_REF_ENUM = 93,
AIN_UNKNOWN_TYPE_95 = 95, // function?
AIN_UNKNOWN_TYPE_100 = 100,
};
#define AIN_ARRAY_TYPE \
@@ -186,12 +188,12 @@ struct ain_struct {
struct ain_hll_argument {
char *name;
int32_t data_type;
struct ain_type type;
};
struct ain_hll_function {
char *name;
int32_t data_type;
struct ain_type return_type;
int32_t nr_arguments;
struct ain_hll_argument *arguments;
};
@@ -234,9 +236,6 @@ struct ain_enum {
char **symbols;
};
struct kh_func_ht_s;
struct kh_struct_ht_s;
struct ain_section {
uint32_t addr;
uint32_t size;
@@ -307,8 +306,8 @@ struct ain {
struct ain_section OBJG;
struct ain_section ENUM;
struct kh_func_ht_s *_func_ht;
struct kh_struct_ht_s *_struct_ht;
struct hash_table *_func_ht;
struct hash_table *_struct_ht;
};
const char *ain_strerror(int error);
@@ -338,4 +337,18 @@ void ain_free_delegates(struct ain *ain);
void ain_free_global_groups(struct ain *ain);
void ain_free_enums(struct ain *ain);
static inline bool ain_array_data_type(int32_t type)
{
switch (type) {
case AIN_ARRAY:
case AIN_REF_ARRAY:
case AIN_ITERATOR:
case AIN_ENUM1:
case AIN_UNKNOWN_TYPE_87:
return true;
default:
return false;
}
}
#endif /* SYSTEM4_AIN_H */
+36
View File
@@ -0,0 +1,36 @@
/* 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_HASHTABLE_H
#define SYSTEM4_HASHTABLE_H
#include <stddef.h>
struct ht_slot {
const char *key;
void *value;
};
struct hash_table;
struct hash_table *ht_create(size_t nr_buckets);
void ht_free(struct hash_table *ht);
void *ht_get(struct hash_table *ht, const char *key);
struct ht_slot *ht_put(struct hash_table *ht, const char *key);
void ht_foreach_value(struct hash_table *ht, void(*fun)(void*));
#endif /* SYSTEM4_HASHTABLE_H */
+11
View File
@@ -332,6 +332,17 @@ enum opcode
OP_0X103 = 0x103,
OP_0X104 = 0x104,
OP_0X105 = 0x105,
OP_0X106 = 0x106,
OP_0X107 = 0x107, // unused
OP_0X108 = 0x108, // unused
OP_0X109 = 0x109, // unused
OP_0X10A = 0x10A,
OP_0X10B = 0x10B,
OP_0X10C = 0x10C,
OP_0X10D = 0x10D,
OP_0X10E = 0x10E,
OP_0X10F = 0x10F,
OP_0X110 = 0x110,
NR_OPCODES
};