#pragma pack(push)
#pragma pack(1)
namespace koei
{
	struct index_t
	{
		int get_offset() const { return addr.get_offset(); }
		char name[8];
		snes::address_lorom_t addr;
		u16 length;
		u16 unk;
	};
}

struct header_t
{
	// 00/8000
	// 00000 jmp to 9fd0 exc_vm_op()
	u08 sub_8000[3];
	// 00003 jmp to 9fac pre_sysdep_op()
	u08 sub_8003[3];
	// 00006 jmp to a86a next_vm_op()
	u08 sub_8006[3];
	// 00009 jmp to a86a next_vm_op()
	u08 sub_8009[3];
	// 0000c jmp to 8d3a sysdep_op_dup()
	u08 sub_800c[3];

	// 0000f reset()
	u08 reset[141];
	// 0009c = 007e2000
	u32 long_addr;
	// 000a0 init_hw_registers()
	u08 sub_80a0[240];
	// 00190 init_mem()
	// first few functions are init related
	// and called in/directly from reset()
	// later functions appear to be sysdep
	// ops entered in the table at 18b9
	u08 code1[5021];

	// 0152d decompress()
	// dst_addr = #7f  / [54]
	// src_addr = [58] / [56]
	u08 sub_952d[24];

	// decompression tables
	// 01545 mask N low bits
	u16 dc_mask_table[17];
	// 0155f
	u08 dc_tb_a[56];
	// 0159f
	u08 dc_tb_b[63];
	// 015de
	u08 dc_tb_c[8];
	// 015e6 exponential table
	u08 dc_tb_d[192];
	// 016a6
	u08 dc_tb_e[22];

	// decompress1()
	// compressed data appears to be based upon
	// backreferences, further reversing needed
	u08 sub_96bc[246];
	// decompress2() called from decompress1()
	u08 sub_97b2[115];

	// these tables provide variable bitshifts
	// since asl, lsr, rol, ror shift one bit at a time
	// they are used to mask and position bitsets
	// from the input word (A) based upon command (X)
	// 01825 used in sub_97b2
	u16 dc_fptr_1[17];
	// 01847 code referenced in the above table
	u08 subs_9847[38];
	// 0186d used in sub_96bc
	u16 dc_fptr_2[17];
	// 0188f code referenced in the above table
	u08 subs_988f[42];

	// 018b9 used in sub_8d13 sysdep_op()
	// is a jump table
	sys_op_t sys_op[256];
	// 01ab9 = 00/9ab9
	// more sysdep ops
	u08 code2[2993];
	// 0266a used in sub_9fd0 vm_op()
	// is a jump table
	// the code pointed to is arranged contiguously
	// usually ending with jmp to loop start at a014 
	vm_op_t vm_op[256];
	// 0286a = 00/a86a
	u08 code3[3892];
	// 0379d rts from last known code

	// 0379e
	u08 unk2[16482];

	// 07800
	koei::index_t index[80];
	// 07d00
	u08 unk3[256];
	// 07e00
	u08 unk4[256];
	// 07f00
	u08 unk5[176];

	// 07fe0
	snes::rom_reg_t reg;
	// 07ff0
	snes::rom_spec_t spec;
};
#pragma pack(pop)