mirror of
https://github.com/simtactics/niotso.git
synced 2025-03-15 08:11:22 +00:00
Added hitasm
This commit is contained in:
parent
5488883991
commit
0ec39fd968
15 changed files with 12469 additions and 368 deletions
|
@ -38,7 +38,7 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
|
|||
set(RCFLAGS "")
|
||||
|
||||
set(CFLAGS_LANG_C "-ansi")
|
||||
set(CFLAGS_LANG_CPP "-fvisibility-inlines-hidden -fno-exceptions -fno-rtti -fno-threadsafe-statics")
|
||||
set(CFLAGS_LANG_CPP "-fvisibility-inlines-hidden -fno-exceptions -fno-rtti -fno-threadsafe-statics -D__STDC_LIMIT_MACROS")
|
||||
|
||||
if(64BIT)
|
||||
set(CFLAGS "-m64 ${CFLAGS}")
|
||||
|
@ -70,7 +70,7 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
|
|||
set(LDFLAGS_SPEED "${LDFLAGS} -s -fwhole-program -flto -fno-stack-protector")
|
||||
else()
|
||||
# Debug
|
||||
set(CFLAGS_DEBUG "${CFLAGS} -O0 -g3 -fstack-protector-all")
|
||||
set(CFLAGS_DEBUG "${CFLAGS} -O0 -g3 -fstack-protector-all -D_FORTIFY_SOURCE=2 -DDEBUG")
|
||||
set(LDFLAGS_DEBUG "${LDFLAGS} -fstack-protector-all")
|
||||
set(CFLAGS_SIZE "${CFLAGS_DEBUG}")
|
||||
set(LDFLAGS_SIZE "${LDFLAGS_DEBUG}")
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
*/
|
||||
|
||||
#include "FileHandler.hpp"
|
||||
#include <setjmp.h> //Used for libpng
|
||||
#include <jpeglib.h>
|
||||
#include <jerror.h>
|
||||
#include <png.h>
|
||||
#include <setjmp.h> //Used for libpng
|
||||
#include "bmp/read_bmp.h"
|
||||
|
||||
namespace File {
|
||||
|
|
BIN
Libraries/FileHandler/tga/elf.dat
Normal file
BIN
Libraries/FileHandler/tga/elf.dat
Normal file
Binary file not shown.
93
Libraries/FileHandler/tga/elf.txt
Normal file
93
Libraries/FileHandler/tga/elf.txt
Normal file
|
@ -0,0 +1,93 @@
|
|||
* Elf32_Word sh_name:
|
||||
* Elf32_Word sh_type:
|
||||
* Elf32_Word sh_flags:
|
||||
* Elf32_Addr sh_addr:
|
||||
* Elf32_Off sh_offset: (?? ?? ?? ??)
|
||||
* Elf32_Word sh_size: (?? ?? ?? ??)
|
||||
* Elf32_Word sh_link:
|
||||
* Elf32_Word sh_info:
|
||||
* Elf32_Word sh_addralign: 1 (01 00 00 00)
|
||||
* Elf32_Word sh_entsize:
|
||||
|
||||
ELF Header:
|
||||
* e_ident:
|
||||
* Elf32_Word EI_MAG0: (7F 45 4C 46)
|
||||
* unsigned char EI_CLASS: ELFCLASS32 (01)
|
||||
* unsigned char EI_DATA: ELFDATA2LSB (01)
|
||||
* unsigned char EI_VERSION: EV_CURRENT (01)
|
||||
* unsigned char EI_PAD[9]: (00 00 00 00 00 00 00 00 00)
|
||||
* Elf32_Half e_type: ET_REL (01 00)
|
||||
* Elf32_Half e_machine: EM_NONE (00 00)
|
||||
* Elf32_Word e_version: EV_CURRENT (01 00 00 00)
|
||||
* Elf32_Addr e_entry: 0 (00 00 00 00)
|
||||
* Elf32_Off e_phoff: 0 (00 00 00 00)
|
||||
* Elf32_Off e_shoff: 64 (40 00 00 00)
|
||||
* Elf32_Word e_flags: 0x00000001 (01 00 00 00)
|
||||
* Elf32_Half e_ehsize: 52 (34 00)
|
||||
* Elf32_Half e_phentsize: 0 (00 00)
|
||||
* Elf32_Half e_phnum: 0 (00 00)
|
||||
* Elf32_Half e_shentsize: 40 (28 00)
|
||||
* Elf32_Half e_shnum: 6 (06 00)
|
||||
* Elf32_Half e_shstrndx: 2 (02 00)
|
||||
* unsigned char padding[12] = (00 00 00 00 00 00 00 00 00 00 00 00)
|
||||
|
||||
Section headers
|
||||
0 (""): All 0s
|
||||
1 (".text"):
|
||||
* Elf32_Word sh_name: 1 (01 00 00 00)
|
||||
* Elf32_Word sh_type: SHT_PROGBITS (01 00 00 00)
|
||||
* Elf32_Word sh_flags: SHF_ALLOC | SHF_EXECINSTR (06 00 00 00)
|
||||
* Elf32_Addr sh_addr: 0x00000010 (10 00 00 00)
|
||||
* Elf32_Off sh_offset: (?? ?? ?? ??)
|
||||
* Elf32_Word sh_size: (?? ?? ?? ??)
|
||||
* Elf32_Word sh_link: 0 (00 00 00 00)
|
||||
* Elf32_Word sh_info: 0 (00 00 00 00)
|
||||
* Elf32_Word sh_addralign: 1 (01 00 00 00)
|
||||
* Elf32_Word sh_entsize: 0 (00 00 00 00)
|
||||
2 (".shstrtab"):
|
||||
* Elf32_Word sh_name: 7 (07 00 00 00)
|
||||
* Elf32_Word sh_type: SHT_STRTAB (03 00 00 00)
|
||||
* Elf32_Word sh_flags: 0 (00 00 00 00)
|
||||
* Elf32_Addr sh_addr: 0 (00 00 00 00)
|
||||
* Elf32_Off sh_offset: (?? ?? ?? ??)
|
||||
* Elf32_Word sh_size: (?? ?? ?? ??)
|
||||
* Elf32_Word sh_link: 0 (00 00 00 00)
|
||||
* Elf32_Word sh_info: 0 (00 00 00 00)
|
||||
* Elf32_Word sh_addralign: 1 (01 00 00 00)
|
||||
* Elf32_Word sh_entsize: 0 (00 00 00 00)
|
||||
3 (".symtab"):
|
||||
* Elf32_Word sh_name: 17 (11 00 00 00)
|
||||
* Elf32_Word sh_type: SHT_SYMTAB (02 00 00 00)
|
||||
* Elf32_Word sh_flags: 0 (00 00 00 00)
|
||||
* Elf32_Addr sh_addr: 0 (00 00 00 00)
|
||||
* Elf32_Off sh_offset: (?? ?? ?? ??)
|
||||
* Elf32_Word sh_size: (?? ?? ?? ??)
|
||||
* Elf32_Word sh_link: 4 (04 00 00 00)
|
||||
* Elf32_Word sh_info: 5 (05 00 00 00)
|
||||
* Elf32_Word sh_addralign: 1 (01 00 00 00)
|
||||
* Elf32_Word sh_entsize: 16 (10 00 00 00)
|
||||
4 (".strtab"):
|
||||
* Elf32_Word sh_name: 25 (19 00 00 00)
|
||||
* Elf32_Word sh_type: SHT_STRTAB (03 00 00 00)
|
||||
* Elf32_Word sh_flags: 0 (00 00 00 00)
|
||||
* Elf32_Addr sh_addr: 0 (00 00 00 00)
|
||||
* Elf32_Off sh_offset: (?? ?? ?? ??)
|
||||
* Elf32_Word sh_size: (?? ?? ?? ??)
|
||||
* Elf32_Word sh_link: 0 (00 00 00 00)
|
||||
* Elf32_Word sh_info: 0 (00 00 00 00)
|
||||
* Elf32_Word sh_addralign: 1 (01 00 00 00)
|
||||
* Elf32_Word sh_entsize: 0 (00 00 00 00)
|
||||
5 (".rel.text"):
|
||||
* Elf32_Word sh_name: 33 (21 00 00 00)
|
||||
* Elf32_Word sh_type: SHT_REL (09 00 00 00)
|
||||
* Elf32_Word sh_flags: 0 (00 00 00 00)
|
||||
* Elf32_Addr sh_addr: 0 (00 00 00 00)
|
||||
* Elf32_Off sh_offset: (?? ?? ?? ??)
|
||||
* Elf32_Word sh_size: (?? ?? ?? ??)
|
||||
* Elf32_Word sh_link: 3 (03 00 00 00)
|
||||
* Elf32_Word sh_info: 1 (01 00 00 00)
|
||||
* Elf32_Word sh_addralign: 1 (01 00 00 00)
|
||||
* Elf32_Word sh_entsize: 8 (08 00 00 00)
|
||||
|
||||
Symbols:
|
||||
0: All 0s
|
461
Libraries/FileHandler/tga/hitutils.h
Normal file
461
Libraries/FileHandler/tga/hitutils.h
Normal file
|
@ -0,0 +1,461 @@
|
|||
/*
|
||||
hitutils - The Sims HIT (dis)assembler and linker
|
||||
hitutils.h - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef min
|
||||
#define min(x,y) ((x) < (y) ? (x) : (y))
|
||||
#endif
|
||||
#ifndef max
|
||||
#define max(x,y) ((x) > (y) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
#ifndef read_int32
|
||||
#define read_uint32(x) (unsigned)(((x)[0]<<(8*0)) | ((x)[1]<<(8*1)) | ((x)[2]<<(8*2)) | ((x)[3]<<(8*3)))
|
||||
#define read_uint16(x) (unsigned)(((x)[0]<<(8*0)) | ((x)[1]<<(8*1)))
|
||||
#endif
|
||||
|
||||
#ifndef write_int32
|
||||
#define write_uint32(dest, src) do {\
|
||||
(dest)[0] = ((src)&0x000000FF)>>(8*0); \
|
||||
(dest)[1] = ((src)&0x0000FF00)>>(8*1); \
|
||||
(dest)[2] = ((src)&0x00FF0000)>>(8*2); \
|
||||
(dest)[3] = ((src)&0xFF000000)>>(8*3); \
|
||||
} while(0)
|
||||
#define write_uint16(dest, src) do {\
|
||||
(dest)[0] = ((src)&0x00FF)>>(8*0); \
|
||||
(dest)[1] = ((src)&0xFF00)>>(8*1); \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
extern char *strdup (const char *__s)
|
||||
__THROW __attribute_malloc__ __nonnull ((1));
|
||||
|
||||
static void Shutdown();
|
||||
|
||||
static void Shutdown_M(const char * Message, ...){
|
||||
va_list args;
|
||||
va_start(args, Message);
|
||||
vfprintf(stderr, Message, args);
|
||||
va_end(args);
|
||||
|
||||
Shutdown();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
enum {
|
||||
VERSION_TS1 = 1, VERSION_TSO
|
||||
};
|
||||
|
||||
#define OPERAND_BYTES(x) (x)
|
||||
#define OPERAND(x, y) ((y)<<((x)*4+4))
|
||||
#define UNIMPLEMENTED ((uint32_t)~0)
|
||||
|
||||
enum operand_t {
|
||||
o_byte = 1,
|
||||
o_dword,
|
||||
o_address,
|
||||
o_variable,
|
||||
o_jump
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
const char * Name;
|
||||
uint32_t Operands;
|
||||
} instruction_t;
|
||||
|
||||
typedef struct {
|
||||
const char * Name;
|
||||
uint32_t Value;
|
||||
} variable_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t * Data;
|
||||
size_t Size;
|
||||
} ByteReaderContext;
|
||||
|
||||
static const uint8_t HITHeader[] = {'H','I','T','!',0x01,0x00,0x00,0x00,0x08,0x00,0x00,0x00,'T','R','A','X'};
|
||||
|
||||
#define InstructionCount 96
|
||||
static const instruction_t Instructions[] = {
|
||||
{"note", UNIMPLEMENTED},
|
||||
{"note_on", OPERAND_BYTES(1) | OPERAND(0, o_variable)},
|
||||
{"note_off", OPERAND_BYTES(1) | OPERAND(0, o_variable)},
|
||||
{"loadb", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_byte)},
|
||||
{"loadl", OPERAND_BYTES(5) | OPERAND(0, o_variable) | OPERAND(1, o_dword)},
|
||||
{"set", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"call", OPERAND_BYTES(4) | OPERAND(0, o_address)},
|
||||
{"return", OPERAND_BYTES(0)},
|
||||
{"wait", OPERAND_BYTES(1) | OPERAND(0, o_variable)},
|
||||
{"callentrypoint", UNIMPLEMENTED},
|
||||
{"wait_samp", OPERAND_BYTES(0)},
|
||||
{"end", OPERAND_BYTES(0)},
|
||||
{"jump", OPERAND_BYTES(1) | OPERAND(0, o_jump)},
|
||||
{"test", OPERAND_BYTES(1) | OPERAND(0, o_variable)},
|
||||
{"nop", OPERAND_BYTES(0)},
|
||||
{"add", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"sub", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"div", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"mul", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"cmp", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"less", UNIMPLEMENTED},
|
||||
{"greater", UNIMPLEMENTED},
|
||||
{"not", UNIMPLEMENTED},
|
||||
{"rand", OPERAND_BYTES(3) | OPERAND(0, o_variable) | OPERAND(1, o_variable) | OPERAND(2, o_variable)},
|
||||
{"abs", UNIMPLEMENTED},
|
||||
{"limit", UNIMPLEMENTED},
|
||||
{"error", UNIMPLEMENTED},
|
||||
{"assert", UNIMPLEMENTED},
|
||||
{"add_to_group", UNIMPLEMENTED},
|
||||
{"remove_from_group", UNIMPLEMENTED},
|
||||
{"get_var", UNIMPLEMENTED},
|
||||
{"loop", OPERAND_BYTES(0)},
|
||||
{"set_loop", OPERAND_BYTES(0)},
|
||||
{"callback", UNIMPLEMENTED},
|
||||
{"smart_add", UNIMPLEMENTED},
|
||||
{"smart_remove", UNIMPLEMENTED},
|
||||
{"smart_removeall", UNIMPLEMENTED},
|
||||
{"smart_setcrit", UNIMPLEMENTED},
|
||||
{"smart_choose", OPERAND_BYTES(1) | OPERAND(0, o_variable)},
|
||||
{"and", UNIMPLEMENTED},
|
||||
{"nand", UNIMPLEMENTED},
|
||||
{"or", UNIMPLEMENTED},
|
||||
{"nor", UNIMPLEMENTED},
|
||||
{"xor", UNIMPLEMENTED},
|
||||
{"max", OPERAND_BYTES(5) | OPERAND(0, o_variable) | OPERAND(1, o_dword)},
|
||||
{"min", OPERAND_BYTES(5) | OPERAND(0, o_variable) | OPERAND(1, o_dword)},
|
||||
{"inc", OPERAND_BYTES(1) | OPERAND(0, o_variable)},
|
||||
{"dec", OPERAND_BYTES(1) | OPERAND(0, o_variable)},
|
||||
{"printreg", UNIMPLEMENTED},
|
||||
{"play_trk", OPERAND_BYTES(1) | OPERAND(0, o_variable)},
|
||||
{"kill_trk", OPERAND_BYTES(1) | OPERAND(0, o_variable)},
|
||||
{"push", UNIMPLEMENTED},
|
||||
{"push_mask", UNIMPLEMENTED},
|
||||
{"push_vars", UNIMPLEMENTED},
|
||||
{"call_mask", UNIMPLEMENTED},
|
||||
{"call_push", UNIMPLEMENTED},
|
||||
{"pop", UNIMPLEMENTED},
|
||||
{"test1", OPERAND_BYTES(0)},
|
||||
{"test2", OPERAND_BYTES(0)},
|
||||
{"test3", OPERAND_BYTES(0)},
|
||||
{"test4", OPERAND_BYTES(0)},
|
||||
{"ifeq", OPERAND_BYTES(4) | OPERAND(0, o_address)},
|
||||
{"ifne", OPERAND_BYTES(4) | OPERAND(0, o_address)},
|
||||
{"ifgt", OPERAND_BYTES(4) | OPERAND(0, o_address)},
|
||||
{"iflt", OPERAND_BYTES(4) | OPERAND(0, o_address)},
|
||||
{"ifge", OPERAND_BYTES(4) | OPERAND(0, o_address)},
|
||||
{"ifle", OPERAND_BYTES(4) | OPERAND(0, o_address)},
|
||||
{"smart_setlist", OPERAND_BYTES(1) | OPERAND(0, o_variable)},
|
||||
{"seqgroup_kill", OPERAND_BYTES(1) | OPERAND(0, o_byte)},
|
||||
{"seqgroup_wait", UNIMPLEMENTED},
|
||||
{"seqgroup_return", OPERAND_BYTES(1) | OPERAND(0, o_byte)},
|
||||
{"getsrcdatafield", OPERAND_BYTES(3) | OPERAND(0, o_variable) | OPERAND(1, o_variable) | OPERAND(2, o_variable)},
|
||||
{"seqgroup_trkid", OPERAND_BYTES(2) | OPERAND(0, o_byte) | OPERAND(1, o_byte)},
|
||||
{"setll", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"setlt", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"settl", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"waiteq", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"waitne", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"waitgt", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"waitlt", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"waitge", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"waitle", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"duck", OPERAND_BYTES(0)},
|
||||
{"unduck", OPERAND_BYTES(0)},
|
||||
{"testx", UNIMPLEMENTED},
|
||||
{"setlg", OPERAND_BYTES(5) | OPERAND(0, o_variable) | OPERAND(1, o_dword)},
|
||||
{"setgl", OPERAND_BYTES(5) | OPERAND(0, o_variable) | OPERAND(1, o_dword)},
|
||||
{"throw", UNIMPLEMENTED},
|
||||
{"setsrcdatafield", OPERAND_BYTES(3) | OPERAND(0, o_variable) | OPERAND(1, o_variable) | OPERAND(2, o_variable)},
|
||||
{"stop_trk", OPERAND_BYTES(1) | OPERAND(0, o_variable)},
|
||||
{"setchanreg", UNIMPLEMENTED},
|
||||
{"play_note", UNIMPLEMENTED},
|
||||
{"stop_note", UNIMPLEMENTED},
|
||||
{"kill_note", UNIMPLEMENTED},
|
||||
{"smart_index", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"note_on_loop", OPERAND_BYTES(1) | OPERAND(0, o_variable)}
|
||||
};
|
||||
|
||||
#define TSOVariableCount 82
|
||||
static const variable_t TSOVariables[] = {
|
||||
{"arg0", 0x00},
|
||||
{"arg1", 0x01},
|
||||
{"arg2", 0x02},
|
||||
{"arg3", 0x03},
|
||||
{"arg4", 0x04},
|
||||
{"v1", 0x05},
|
||||
{"v2", 0x06},
|
||||
{"v3", 0x07},
|
||||
{"v4", 0x08},
|
||||
{"v5", 0x09},
|
||||
{"v6", 0x0A},
|
||||
{"v7", 0x0B},
|
||||
{"v8", 0x0C},
|
||||
{"h1", 0x0D},
|
||||
{"h2", 0x0E},
|
||||
{"h3", 0x0F},
|
||||
{"argstype", 0x10},
|
||||
{"trackdatasource", 0x11},
|
||||
{"patch", 0x12},
|
||||
{"priority", 0x13},
|
||||
{"vol", 0x14},
|
||||
{"extvol", 0x15},
|
||||
{"pan", 0x16},
|
||||
{"pitch", 0x17},
|
||||
{"paused", 0x18},
|
||||
{"fxtype", 0x19},
|
||||
{"fxlevel", 0x1a},
|
||||
{"duckpri", 0x1b},
|
||||
{"Is3d", 0x1c},
|
||||
{"IsHeadRelative", 0x1d},
|
||||
{"MinDistance", 0x1e},
|
||||
{"MaxDistance", 0x1f},
|
||||
{"X", 0x20},
|
||||
{"Y", 0x21},
|
||||
{"Z", 0x22},
|
||||
{"attack", 0x23},
|
||||
{"decay", 0x24},
|
||||
{"IsStreamed", 0x25},
|
||||
{"bufsizemult", 0x26},
|
||||
{"fade_dest", 0x27},
|
||||
{"fade_var", 0x28},
|
||||
{"fade_speed", 0x29},
|
||||
{"fade_on", 0x2a},
|
||||
{"Preload", 0x2b},
|
||||
{"isplaying", 0x2c},
|
||||
{"whattodowithupdate", 0x2d},
|
||||
{"tempo", 0x2e},
|
||||
{"target", 0x2f},
|
||||
{"ctrlgroup", 0x30},
|
||||
{"interrupt", 0x31},
|
||||
{"ispositioned", 0x32},
|
||||
{"AppObjectId", 0x34},
|
||||
{"callbackarg", 0x35},
|
||||
{"pitchrandmin", 0x36},
|
||||
{"pitchrandmax", 0x37},
|
||||
{"spl", 0x38},
|
||||
{"sem", 0x39},
|
||||
{"starttrackid", 0x3a},
|
||||
{"endtrackid", 0x3b},
|
||||
{"startdelay", 0x3c},
|
||||
{"fadeinspeed", 0x3d},
|
||||
{"fadeoutspeed", 0x3e},
|
||||
{"hitlist", 0x3f},
|
||||
{"SimSpeed", 0x64},
|
||||
{"test_g1", 0x65},
|
||||
{"test_g2", 0x66},
|
||||
{"test_g3", 0x67},
|
||||
{"test_g4", 0x68},
|
||||
{"test_g5", 0x69},
|
||||
{"test_g6", 0x6a},
|
||||
{"test_g7", 0x6b},
|
||||
{"test_g8", 0x6c},
|
||||
{"test_g9", 0x6d},
|
||||
{"main_songnum", 0x6e},
|
||||
{"main_musichitlistid", 0x6f},
|
||||
{"campfire_nexttrack", 0x70},
|
||||
{"campfire_busy", 0x71},
|
||||
{"main_duckpri", 0x7b},
|
||||
{"main_vol", 0x7c},
|
||||
{"main_fxtype", 0x7d},
|
||||
{"main_fxlevel", 0x7e},
|
||||
{"main_pause", 0x7f},
|
||||
};
|
||||
|
||||
#define TS1VariableCount 87
|
||||
static const variable_t TS1Variables[] = {
|
||||
{"arg0", 0x00},
|
||||
{"arg1", 0x01},
|
||||
{"arg2", 0x02},
|
||||
{"arg3", 0x03},
|
||||
{"arg4", 0x04},
|
||||
{"v1", 0x05},
|
||||
{"v2", 0x06},
|
||||
{"v3", 0x07},
|
||||
{"v4", 0x08},
|
||||
{"v5", 0x09},
|
||||
{"v6", 0x0a},
|
||||
{"v7", 0x0b},
|
||||
{"v8", 0x0c},
|
||||
{"h1", 0x0d},
|
||||
{"h2", 0x0e},
|
||||
{"h3", 0x0f},
|
||||
{"priority", 0x11},
|
||||
{"vol", 0x12},
|
||||
{"extvol", 0x13},
|
||||
{"pan", 0x14},
|
||||
{"pitch", 0x15},
|
||||
{"paused", 0x16},
|
||||
{"fxtype", 0x17},
|
||||
{"fxlevel", 0x18},
|
||||
{"duckpri", 0x19},
|
||||
{"Is3d", 0x1a},
|
||||
{"IsHeadRelative", 0x1b},
|
||||
{"MinDistance", 0x1c},
|
||||
{"MaxDistance", 0x1d},
|
||||
{"X", 0x1e},
|
||||
{"Y", 0x1f},
|
||||
{"Z", 0x20},
|
||||
{"filter_type", 0x21},
|
||||
{"filter_cutoff", 0x22},
|
||||
{"filter_level", 0x23},
|
||||
{"attack", 0x24},
|
||||
{"decay", 0x25},
|
||||
{"IsStreamed", 0x26},
|
||||
{"BufSizeMult", 0x27},
|
||||
{"fade_dest", 0x28},
|
||||
{"fade_var", 0x29},
|
||||
{"fade_speed", 0x2a},
|
||||
{"Preload", 0x2b},
|
||||
{"IsLooped", 0x2c},
|
||||
{"fade_on", 0x2d},
|
||||
{"isplaying", 0x2e},
|
||||
{"source", 0x2f},
|
||||
{"patch", 0x32},
|
||||
{"WhatToDoWithUpdate", 0x33},
|
||||
{"tempo", 0x34},
|
||||
{"target", 0x35},
|
||||
{"mutegroup", 0x36},
|
||||
{"interrupt", 0x37},
|
||||
{"IsPositioned", 0x38},
|
||||
{"Spl", 0x39},
|
||||
{"MultipleInstances", 0x3a},
|
||||
{"AssociatedTrack1", 0x3b},
|
||||
{"AssociatedTrack2", 0x3c},
|
||||
{"AssociatedTrack3", 0x3d},
|
||||
{"AssociatedTrack4", 0x3e},
|
||||
{"AssociatedTrack5", 0x3f},
|
||||
{"AssociatedTrack6", 0x40},
|
||||
{"AssociatedTrack7", 0x41},
|
||||
{"AssociatedTrack8", 0x42},
|
||||
{"SimSpeed", 0x64},
|
||||
{"test_g1", 0x65},
|
||||
{"test_g2", 0x66},
|
||||
{"test_g3", 0x67},
|
||||
{"test_g4", 0x68},
|
||||
{"test_g5", 0x69},
|
||||
{"test_g6", 0x6a},
|
||||
{"test_g7", 0x6b},
|
||||
{"test_g8", 0x6c},
|
||||
{"test_g9", 0x6d},
|
||||
{"main_songnum", 0x6e},
|
||||
{"main_musichitlistid", 0x6f},
|
||||
{"campfire_nexttrack", 0x70},
|
||||
{"campfire_busy", 0x71},
|
||||
{"main_duckpri", 0x7b},
|
||||
{"main_vol", 0x7c},
|
||||
{"main_fxtype", 0x7d},
|
||||
{"main_fxlevel", 0x7e},
|
||||
{"main_pause", 0x7f},
|
||||
};
|
||||
|
||||
#define ConstantCount 72
|
||||
static const variable_t Constants[] = {
|
||||
{"duckpri_always", 0x0},
|
||||
{"duckpri_low", 0xa},
|
||||
{"duckpri_normal", 0x14},
|
||||
{"duckpri_high", 0x1e},
|
||||
{"duckpri_higher", 0x28},
|
||||
{"duckpri_evenhigher", 0x32},
|
||||
{"duckpri_never", 0x64},
|
||||
{"spl_infinite", 0x0},
|
||||
{"spl_loud", 0xa},
|
||||
{"spl_normal", 0x14},
|
||||
{"spl_quiet", 0x64},
|
||||
{"Instance", 0x0},
|
||||
{"Gender", 0x1},
|
||||
{"GroupMusic", 0x1},
|
||||
{"GroupDialogMain", 0x2},
|
||||
{"GroupDialogOverlay", 0x3},
|
||||
{"PchDishwasherClose", 0x32},
|
||||
{"PchDishwasherLoad", 0x33},
|
||||
{"PchDishwasherLoad2", 0x34},
|
||||
{"PchDishwasherOpen", 0x35},
|
||||
{"PchDishwasherTurnDial", 0x39},
|
||||
{"PchDishwasherTurnDial2", 0x3a},
|
||||
{"TrkRadioStationCountry", 0x104},
|
||||
{"TrkRadioStationBossaNova", 0x10e},
|
||||
{"TrkRadioStationClassical", 0x10d},
|
||||
{"TrkRadioStationRock", 0x118},
|
||||
{"kSndobPlay", 1},
|
||||
{"kSndobStop", 2},
|
||||
{"kSndobKill", 3},
|
||||
{"kSndobUpdate", 4},
|
||||
{"kSndobSetVolume", 5},
|
||||
{"kSndobSetPitch", 6},
|
||||
{"kSndobSetPan", 7},
|
||||
{"kSndobSetPosition", 8},
|
||||
{"kSndobSetFxType", 9},
|
||||
{"kSndobSetFxLevel", 10},
|
||||
{"kSndobPause", 11},
|
||||
{"kSndobUnpause", 12},
|
||||
{"kSndobLoad", 13},
|
||||
{"kSndobUnload", 14},
|
||||
{"kSndobCache", 15},
|
||||
{"kSndobUncache", 16},
|
||||
{"kSndobCancelNote", 19},
|
||||
{"kPlayPiano", 43},
|
||||
{"kSetMusicMode", 36},
|
||||
{"kLive", 0},
|
||||
{"kBuy", 1},
|
||||
{"kBuild", 2},
|
||||
{"kHood", 3},
|
||||
{"kFrontEnd", 4},
|
||||
{"kGroupSfx", 1},
|
||||
{"kGroupMusic", 2},
|
||||
{"kGroupVox", 3},
|
||||
{"kAction", 1000},
|
||||
{"kComedy", 1001},
|
||||
{"kRomance", 1002},
|
||||
{"kNews", 1003},
|
||||
{"kCountry", 1004},
|
||||
{"kRock", 1005},
|
||||
{"kJazz", 1006},
|
||||
{"kClassical", 1007},
|
||||
{"kArgsNormal", 0},
|
||||
{"kArgsVolPan", 1},
|
||||
{"kArgsIdVolPan", 2},
|
||||
{"kArgsXYZ", 3},
|
||||
{"kKillAll", 20},
|
||||
{"kPause", 21},
|
||||
{"kUnpause", 22},
|
||||
{"kKillInstance", 23},
|
||||
{"kTurnOnTv", 30},
|
||||
{"kTurnOffTv", 31},
|
||||
{"kUpdateSourceVolPan", 32},
|
||||
};
|
||||
|
||||
static const uint8_t ObjectHeader[] = {
|
||||
0x7F, 0x45, 0x4C, 0x46, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00,
|
||||
0x06, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
|
||||
0x19, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00
|
||||
};
|
|
@ -15,3 +15,36 @@
|
|||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "read_tga.h"
|
||||
|
||||
#ifndef read_uint32
|
||||
#define read_uint32(x) (unsigned)(((x)[0]<<(8*0)) | ((x)[1]<<(8*1)) | ((x)[2]<<(8*2)) | ((x)[3]<<(8*3)))
|
||||
#define read_uint16(x) (unsigned)(((x)[0]<<(8*0)) | ((x)[1]<<(8*1)))
|
||||
#endif
|
||||
|
||||
int tga_read_header(tgaheader_t * TGAHeader, const uint8_t * Buffer, size_t FileSize){
|
||||
unsigned padding;
|
||||
if(FileSize < ?) return 0;
|
||||
TGAHeader->IDLength = read_uint8(Buffer);
|
||||
TGAHeader->ColorMapType = read_uint8(Buffer+1);
|
||||
TGAHeader->ImageType = read_uint8(Buffer+2);
|
||||
|
||||
/* Color map */
|
||||
TGAHeader->FirstEntry = read_uint16(Buffer+3);
|
||||
TGAHeader->ColorMapLength = read_uint16(Buffer+5);
|
||||
TGAHeader->EntrySize = read_uint8(Buffer+7);
|
||||
|
||||
/* Image */
|
||||
TGAHeader->XOrigin = read_uint16(Buffer+8);
|
||||
TGAHeader->YOrigin = read_uint16(Buffer+10);
|
||||
TGAHeader->Width = read_uint16(Buffer+12);
|
||||
TGAHeader->Height = read_uint16(Buffer+14);
|
||||
TGAHeader->ImageDepth = read_uint8(Buffer+16);
|
||||
TGAHeader->Descriptor = read_uint8(Buffer+17);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
17
Libraries/FileHandler/tga/read_tga.h
Normal file
17
Libraries/FileHandler/tga/read_tga.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
FileHandler - General-purpose file handling library for Niotso
|
||||
read_tga.h - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
10644
Libraries/FileHandler/tga/tsov2.txt
Normal file
10644
Libraries/FileHandler/tga/tsov2.txt
Normal file
File diff suppressed because it is too large
Load diff
BIN
Tools/hitutils/elf.dat
Normal file
BIN
Tools/hitutils/elf.dat
Normal file
Binary file not shown.
131
Tools/hitutils/elf.txt
Normal file
131
Tools/hitutils/elf.txt
Normal file
|
@ -0,0 +1,131 @@
|
|||
* Elf32_Word sh_name:
|
||||
* Elf32_Word sh_type:
|
||||
* Elf32_Word sh_flags:
|
||||
* Elf32_Addr sh_addr:
|
||||
* Elf32_Off sh_offset: (?? ?? ?? ??)
|
||||
* Elf32_Word sh_size: (?? ?? ?? ??)
|
||||
* Elf32_Word sh_link:
|
||||
* Elf32_Word sh_info:
|
||||
* Elf32_Word sh_addralign: 1 (01 00 00 00)
|
||||
* Elf32_Word sh_entsize:
|
||||
|
||||
ELF Header:
|
||||
* e_ident:
|
||||
* Elf32_Word EI_MAG0: (7F 45 4C 46)
|
||||
* unsigned char EI_CLASS: ELFCLASS32 (01)
|
||||
* unsigned char EI_DATA: ELFDATA2LSB (01)
|
||||
* unsigned char EI_VERSION: EV_CURRENT (01)
|
||||
* unsigned char EI_PAD[9]: (00 00 00 00 00 00 00 00 00)
|
||||
* Elf32_Half e_type: ET_REL (01 00)
|
||||
* Elf32_Half e_machine: EM_NONE (00 00)
|
||||
* Elf32_Word e_version: EV_CURRENT (01 00 00 00)
|
||||
* Elf32_Addr e_entry: 0 (00 00 00 00)
|
||||
* Elf32_Off e_phoff: 0 (00 00 00 00)
|
||||
* Elf32_Off e_shoff: 64 (40 00 00 00)
|
||||
* Elf32_Word e_flags: 0x00000001 (01 00 00 00)
|
||||
* Elf32_Half e_ehsize: 52 (34 00)
|
||||
* Elf32_Half e_phentsize: 0 (00 00)
|
||||
* Elf32_Half e_phnum: 0 (00 00)
|
||||
* Elf32_Half e_shentsize: 40 (28 00)
|
||||
* Elf32_Half e_shnum: 6 (06 00)
|
||||
* Elf32_Half e_shstrndx: 2 (02 00)
|
||||
* unsigned char padding[12] = (00 00 00 00 00 00 00 00 00 00 00 00)
|
||||
|
||||
Section headers
|
||||
0 (""): All 0s
|
||||
1 (".text"):
|
||||
* Elf32_Word sh_name: 1 (01 00 00 00)
|
||||
* Elf32_Word sh_type: SHT_PROGBITS (01 00 00 00)
|
||||
* Elf32_Word sh_flags: SHF_ALLOC | SHF_EXECINSTR (06 00 00 00)
|
||||
* Elf32_Addr sh_addr: 0 (00 00 00 00)
|
||||
* Elf32_Off sh_offset: (?? ?? ?? ??)
|
||||
* Elf32_Word sh_size: (?? ?? ?? ??)
|
||||
* Elf32_Word sh_link: 0 (00 00 00 00)
|
||||
* Elf32_Word sh_info: 0 (00 00 00 00)
|
||||
* Elf32_Word sh_addralign: 1 (01 00 00 00)
|
||||
* Elf32_Word sh_entsize: 0 (00 00 00 00)
|
||||
2 (".shstrtab"):
|
||||
* Elf32_Word sh_name: 7 (07 00 00 00)
|
||||
* Elf32_Word sh_type: SHT_STRTAB (03 00 00 00)
|
||||
* Elf32_Word sh_flags: 0 (00 00 00 00)
|
||||
* Elf32_Addr sh_addr: 0 (00 00 00 00)
|
||||
* Elf32_Off sh_offset: (?? ?? ?? ??)
|
||||
* Elf32_Word sh_size: (?? ?? ?? ??)
|
||||
* Elf32_Word sh_link: 0 (00 00 00 00)
|
||||
* Elf32_Word sh_info: 0 (00 00 00 00)
|
||||
* Elf32_Word sh_addralign: 1 (01 00 00 00)
|
||||
* Elf32_Word sh_entsize: 0 (00 00 00 00)
|
||||
3 (".symtab"):
|
||||
* Elf32_Word sh_name: 17 (11 00 00 00)
|
||||
* Elf32_Word sh_type: SHT_SYMTAB (02 00 00 00)
|
||||
* Elf32_Word sh_flags: 0 (00 00 00 00)
|
||||
* Elf32_Addr sh_addr: 0 (00 00 00 00)
|
||||
* Elf32_Off sh_offset: (?? ?? ?? ??)
|
||||
* Elf32_Word sh_size: (?? ?? ?? ??)
|
||||
* Elf32_Word sh_link: 4 (04 00 00 00)
|
||||
* Elf32_Word sh_info: 5 (05 00 00 00)
|
||||
* Elf32_Word sh_addralign: 1 (01 00 00 00)
|
||||
* Elf32_Word sh_entsize: 16 (10 00 00 00)
|
||||
4 (".strtab"):
|
||||
* Elf32_Word sh_name: 25 (19 00 00 00)
|
||||
* Elf32_Word sh_type: SHT_STRTAB (03 00 00 00)
|
||||
* Elf32_Word sh_flags: 0 (00 00 00 00)
|
||||
* Elf32_Addr sh_addr: 0 (00 00 00 00)
|
||||
* Elf32_Off sh_offset: (?? ?? ?? ??)
|
||||
* Elf32_Word sh_size: (?? ?? ?? ??)
|
||||
* Elf32_Word sh_link: 0 (00 00 00 00)
|
||||
* Elf32_Word sh_info: 0 (00 00 00 00)
|
||||
* Elf32_Word sh_addralign: 1 (01 00 00 00)
|
||||
* Elf32_Word sh_entsize: 0 (00 00 00 00)
|
||||
5 (".rel.text"):
|
||||
* Elf32_Word sh_name: 33 (21 00 00 00)
|
||||
* Elf32_Word sh_type: SHT_REL (09 00 00 00)
|
||||
* Elf32_Word sh_flags: 0 (00 00 00 00)
|
||||
* Elf32_Addr sh_addr: 0 (00 00 00 00)
|
||||
* Elf32_Off sh_offset: (?? ?? ?? ??)
|
||||
* Elf32_Word sh_size: (?? ?? ?? ??)
|
||||
* Elf32_Word sh_link: 3 (03 00 00 00)
|
||||
* Elf32_Word sh_info: 1 (01 00 00 00)
|
||||
* Elf32_Word sh_addralign: 1 (01 00 00 00)
|
||||
* Elf32_Word sh_entsize: 8 (08 00 00 00)
|
||||
|
||||
Symbol format: (4+4+4+1+1+2= 16 bytes)
|
||||
Undefined symbol:
|
||||
* Elf32_Word st_name: 0 (00 00 00 00)
|
||||
* Elf32_Addr st_value: 0 (00 00 00 00)
|
||||
* Elf32_Word st_size: 0 (00 00 00 00)
|
||||
* unsigned char st_info: 0 (00)
|
||||
* unsigned char st_other: 0 (00)
|
||||
* Elf32_Half st_shndx: 0 (00 00)
|
||||
Source file symbol:
|
||||
* Elf32_Word st_name: 1 (01 00 00 00)
|
||||
* Elf32_Addr st_value: 0 (00 00 00 00)
|
||||
* Elf32_Word st_size: 0 (00 00 00 00)
|
||||
* unsigned char st_info: ELF32_ST_INFO(STB_LOCAL, STT_FILE) (04)
|
||||
* unsigned char st_other: 0 (00)
|
||||
* Elf32_Half st_shndx: SHN_ABS (f1 ff)
|
||||
Text section symbol:
|
||||
* Elf32_Word st_name: 0 (00 00 00 00)
|
||||
* Elf32_Addr st_value: 0 (00 00 00 00)
|
||||
* Elf32_Word st_size: 0 (00 00 00 00)
|
||||
* unsigned char st_info: ELF32_ST_INFO(STB_LOCAL, STT_SECTION) (03)
|
||||
* unsigned char st_other: 0 (00)
|
||||
* Elf32_Half st_shndx: 1 (01 00)
|
||||
Undefined symbol:
|
||||
* Elf32_Word st_name: (?? ?? ?? ??)
|
||||
* Elf32_Addr st_value: 0 (00 00 00 00)
|
||||
* Elf32_Word st_size: 0 (00 00 00 00)
|
||||
* unsigned char st_info: ELF32_ST_INFO(STB_GLOBAL, STT_FUNC) (12)
|
||||
* unsigned char st_other: 0 (00)
|
||||
* Elf32_Half st_shndx: 0 (00 00)
|
||||
Defined symbol:
|
||||
* Elf32_Word st_name: (?? ?? ?? ??)
|
||||
* Elf32_Addr st_value: (?? ?? ?? ??)
|
||||
* Elf32_Word st_size: 0 (00 00 00 00)
|
||||
* unsigned char st_info: ELF32_ST_INFO(STB_GLOBAL, STT_FUNC) (12)
|
||||
* unsigned char st_other: 0 (00)
|
||||
* Elf32_Half st_shndx: 1 (01 00)
|
||||
|
||||
Relocation format: (4+4=8)
|
||||
* Elf32_Addr r_offset: (?? ?? ?? ??)
|
||||
* Elf32_Word r_info: ELF32_R_INFO(?, R_386_PC32) (?? ?? ?? ??)
|
|
@ -16,17 +16,605 @@
|
|||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include "hitutils.h"
|
||||
|
||||
static uint8_t ObjectHeader[] = {
|
||||
0x7F, 0x45, 0x4C, 0x46, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00,
|
||||
0x06, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
|
||||
0x19, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
enum {
|
||||
txt, out, filecount
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
uint8_t * Data;
|
||||
size_t Position;
|
||||
size_t Size;
|
||||
char * Name;
|
||||
} ByteWriterContext;
|
||||
|
||||
static void bw_expand(ByteWriterContext *bwc){
|
||||
bwc->Data = realloc(bwc->Data, (bwc->Size <<= 1));
|
||||
if(!bwc->Data)
|
||||
Shutdown_M("%sCould not allocate memory for %s section.\n", "hitasm: Error: ", bwc->Name);
|
||||
}
|
||||
|
||||
static void bw_write32(ByteWriterContext *bwc, uint32_t value){
|
||||
if(bwc->Size-bwc->Position < 4)
|
||||
bw_expand(bwc);
|
||||
write_uint32(bwc->Data+bwc->Position, value);
|
||||
bwc->Position += 4;
|
||||
}
|
||||
|
||||
static void bw_write8(ByteWriterContext *bwc, uint8_t value){
|
||||
if(bwc->Size-bwc->Position < 1)
|
||||
bw_expand(bwc);
|
||||
bwc->Data[bwc->Position] = value;
|
||||
bwc->Position += 1;
|
||||
}
|
||||
|
||||
static void bw_write_memory(ByteWriterContext *bwc, const uint8_t *ptr, size_t size){
|
||||
while(bwc->Size-bwc->Position < size)
|
||||
bw_expand(bwc);
|
||||
do bwc->Data[bwc->Position++] = *ptr++;
|
||||
while(--size);
|
||||
}
|
||||
|
||||
static void bw_write_string(ByteWriterContext *bwc, const char *string){
|
||||
do bw_write8(bwc, *string);
|
||||
while(*string++);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
char * Token;
|
||||
size_t Line, NextLine;
|
||||
size_t Col, NextCol;
|
||||
int GaveLastToken;
|
||||
ByteReaderContext brc;
|
||||
} ParserContext;
|
||||
|
||||
enum {
|
||||
TK_CROSSLINES = 1,
|
||||
CN_LABELONLY = 1
|
||||
};
|
||||
|
||||
static FILE *hFile = NULL;
|
||||
static char *path[filecount] = {NULL};
|
||||
static uint8_t *data[filecount] = {NULL};
|
||||
static ByteWriterContext TextSection = {0,0,1024,"text"};
|
||||
static ByteWriterContext SymbolTable = {0,0,1024,"symtab"};
|
||||
static ByteWriterContext StringTable = {0,0,1024,"strtab"};
|
||||
static ByteWriterContext RelocationTable = {0,0,1024,".rel.text"};
|
||||
|
||||
static uint8_t * add_symbol(const char * Name){
|
||||
bw_write32(&SymbolTable, StringTable.Position);
|
||||
bw_write32(&SymbolTable, 0);
|
||||
bw_write32(&SymbolTable, 0);
|
||||
bw_write32(&SymbolTable, 18);
|
||||
bw_write_string(&StringTable, Name);
|
||||
return SymbolTable.Data + SymbolTable.Position - 16;
|
||||
}
|
||||
|
||||
static uint8_t * find_symbol_by_name(const char * Name, uint32_t * SymbolIndex){
|
||||
uint32_t p;
|
||||
for(p=48; p<SymbolTable.Position; p+=16){
|
||||
if(!strcmp((char*) StringTable.Data + read_uint32(SymbolTable.Data + p), Name)){
|
||||
if(SymbolIndex) *SymbolIndex = p>>4;
|
||||
return SymbolTable.Data + p;
|
||||
}
|
||||
}
|
||||
|
||||
if(SymbolIndex) *SymbolIndex = p>>4;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static __inline int whitespace(const uint8_t *Data){
|
||||
return (Data[0] == ' ' || Data[0] == '\t' || Data[0] == '\r' || Data[0] == '\n' || Data[0] == '\0');
|
||||
}
|
||||
|
||||
static __inline int comment(const uint8_t *Data){
|
||||
return (Data[0] == ';' || (Data[0] == '#' && whitespace(Data+1)));
|
||||
}
|
||||
|
||||
static int parser_next_token(ParserContext *pc, int CrossLines){
|
||||
if(!pc->brc.Size) return 0;
|
||||
|
||||
if(pc->GaveLastToken){
|
||||
pc->GaveLastToken = 0;
|
||||
/* find the start of the next token */
|
||||
while(1){
|
||||
if(whitespace(pc->brc.Data)){
|
||||
if(pc->brc.Data[0] == '\n'){
|
||||
pc->NextLine++; pc->NextCol = 1;
|
||||
}else if(pc->brc.Data[0] == '\t'){
|
||||
pc->NextCol += 4 - ((pc->NextCol-1)%4);
|
||||
}else{
|
||||
pc->NextCol++;
|
||||
}
|
||||
}else if(comment(pc->brc.Data)){
|
||||
/* skip to the end of the line */
|
||||
pc->NextLine++; pc->NextCol = 1;
|
||||
do {
|
||||
if(!--pc->brc.Size) return 0;
|
||||
pc->brc.Data++;
|
||||
} while(pc->brc.Data[0] != '\n');
|
||||
}else break;
|
||||
|
||||
if(!--pc->brc.Size) return 0;
|
||||
pc->brc.Data++;
|
||||
}
|
||||
}
|
||||
if(!CrossLines && pc->Line != pc->NextLine) return 0;
|
||||
pc->Token = (char*)pc->brc.Data;
|
||||
pc->Line = pc->NextLine;
|
||||
pc->Col = pc->NextCol++;
|
||||
pc->GaveLastToken = 1;
|
||||
|
||||
/* mark the end of this token with a null character */
|
||||
while(1){
|
||||
if(!--pc->brc.Size) return 1;
|
||||
pc->brc.Data++;
|
||||
|
||||
if(whitespace(pc->brc.Data)){
|
||||
if(pc->brc.Data[0] == '\n'){
|
||||
pc->NextLine++; pc->NextCol = 1;
|
||||
}else if(pc->brc.Data[0] == '\t'){
|
||||
pc->NextCol += 4 - ((pc->NextCol-1)%4);
|
||||
}else{
|
||||
pc->NextCol++;
|
||||
}
|
||||
break;
|
||||
}else if(comment(pc->brc.Data)){
|
||||
/* skip to the end of the line */
|
||||
pc->NextLine++; pc->NextCol = 1;
|
||||
do {
|
||||
if(!--pc->brc.Size) return 1;
|
||||
pc->brc.Data++;
|
||||
} while(pc->brc.Data[0] != '\n');
|
||||
break;
|
||||
}else pc->NextCol++;
|
||||
}
|
||||
pc->brc.Size--;
|
||||
pc->brc.Data[0] = '\0';
|
||||
pc->brc.Data++;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static __inline void verify_eol(ParserContext *pc){
|
||||
if(parser_next_token(pc, 0))
|
||||
Shutdown_M("%s:%u:%u: error: expected newline before '%s'\n",
|
||||
path[txt], pc->Line, pc->Col, pc->Token);
|
||||
}
|
||||
|
||||
static void verify_name(const ParserContext *pc, const char *thistoken, const char *nexttoken){
|
||||
const char *Name;
|
||||
for(Name = pc->Token; *Name; Name++)
|
||||
if((Name == pc->Token || *Name < '0' || *Name > '9')
|
||||
&& (*Name < 'A' || *Name > 'Z') && (*Name < '_' || *Name > '_') && (*Name < 'a' || *Name > 'z'))
|
||||
Shutdown_M("%s:%u:%u: error: expected %s before '%c'\n",
|
||||
path[txt], pc->Line, pc->Col, (Name == pc->Token) ? thistoken : nexttoken, *Name);
|
||||
}
|
||||
|
||||
static __inline void parser_add_symbol(const ParserContext *pc){
|
||||
uint8_t * Symbol;
|
||||
verify_name(pc, "label or integer constant", "newline");
|
||||
|
||||
/* we're using the ELF st_size field (offset 8) to hold the line number temporarily */
|
||||
Symbol = find_symbol_by_name(pc->Token, NULL);
|
||||
if(Symbol){
|
||||
if(read_uint32(Symbol+4))
|
||||
Shutdown_M("%s:%u:%u: error: label '%s' redefined (previous definition at %s:%u:1)\n",
|
||||
path[txt], pc->Line, pc->Col, pc->Token, path[txt], read_uint32(Symbol+8));
|
||||
}else Symbol = add_symbol(pc->Token);
|
||||
|
||||
write_uint32(Symbol+4, TextSection.Position);
|
||||
write_uint32(Symbol+8, pc->Line);
|
||||
}
|
||||
|
||||
static __inline void parser_add_reference(const ParserContext *pc){
|
||||
uint32_t SymbolIndex;
|
||||
verify_name(pc, "label", "operand or newline");
|
||||
|
||||
if(!find_symbol_by_name(pc->Token, &SymbolIndex))
|
||||
add_symbol(pc->Token);
|
||||
|
||||
bw_write32(&RelocationTable, TextSection.Position);
|
||||
bw_write32(&RelocationTable, (SymbolIndex<<8)|0x02);
|
||||
}
|
||||
|
||||
static uint32_t read_integer(const ParserContext *pc, uint32_t maxval){
|
||||
unsigned long value;
|
||||
char * endptr;
|
||||
|
||||
if(pc->Token[0] == '-')
|
||||
Shutdown_M("%s:%u:%u: error: integer constant '%s' may not be negative\n",
|
||||
path[txt], pc->Line, pc->Col, pc->Token);
|
||||
if(pc->Token[0] < '0' || pc->Token[0] > '9')
|
||||
Shutdown_M("%s:%u:%u: error: expected integer constant before '%s'\n",
|
||||
path[txt], pc->Line, pc->Col, pc->Token);
|
||||
if(pc->Token[0] == '0' && (pc->Token[1] == 'x' || pc->Token[1] == '0' || pc->Token[1] == 'o'))
|
||||
Shutdown_M("%s:%u:%u: error: illegal %s prefix '%s%c' on integer constant '%s'\n",
|
||||
path[txt], pc->Line, pc->Col, pc->Token[1] == 'x' ? "hexadecimal" : "octal",
|
||||
pc->Token[1] != '0' ? "0" : "", pc->Token[1], pc->Token);
|
||||
|
||||
value = strtoul(pc->Token, &endptr, 10);
|
||||
if(*endptr == '.')
|
||||
Shutdown_M("%s:%u:%u: error: illegal floating point constant '%s'\n",
|
||||
path[txt], pc->Line, pc->Col, endptr, pc->Token);
|
||||
if(*endptr != '\0')
|
||||
Shutdown_M("%s:%u:%u: error: illegal suffix '%s' on integer constant '%s'\n",
|
||||
path[txt], pc->Line, pc->Col, endptr, pc->Token);
|
||||
if(value > (unsigned long) maxval || errno == ERANGE)
|
||||
Shutdown_M("%s:%u:%u: error: integer constant '%s' is out of range\n",
|
||||
path[txt], pc->Line, pc->Col, pc->Token);
|
||||
|
||||
return (uint32_t)value;
|
||||
}
|
||||
|
||||
static uint32_t read_constant(ParserContext *pc, int Type, uint32_t maxval){
|
||||
unsigned i;
|
||||
if(pc->Token[0] == '#') /* note that the tokens "#" and "" will never be returned by the parser */
|
||||
pc->Token++;
|
||||
|
||||
if((pc->Token[0] >= '0' && pc->Token[0] <= '9') || pc->Token[0] == '-' || pc->Token[0] == '.'){
|
||||
if(Type == CN_LABELONLY)
|
||||
Shutdown_M("%s:%u:%u: error: explicit address '%s' is forbidden\n",
|
||||
path[txt], pc->Line, pc->Col, pc->Token);
|
||||
return read_integer(pc, maxval);
|
||||
}
|
||||
|
||||
verify_name(pc, "constant or label", "operand or newline");
|
||||
for(i=0; i<ConstantCount; i++){
|
||||
if(!strcmp(Constants[i].Name, pc->Token)){
|
||||
if(Constants[i].Value > maxval)
|
||||
Shutdown_M("%s:%u:%u: error: integer constant '%s' (%u) is out of range\n",
|
||||
path[txt], pc->Line, pc->Col, pc->Token, Constants[i].Value);
|
||||
return Constants[i].Value;
|
||||
}
|
||||
}
|
||||
|
||||
if(maxval != 0xFFFFFFFF)
|
||||
Shutdown_M("%s:%u:%u: error: address referenced by label '%s' is out of range\n",
|
||||
path[txt], pc->Line, pc->Col, pc->Token);
|
||||
parser_add_reference(pc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static __inline uint8_t read_instruction(const ParserContext *pc, uint32_t *operands){
|
||||
uint8_t i;
|
||||
verify_name(pc, "instruction", "operand or newline");
|
||||
|
||||
for(i=0; i<InstructionCount; i++){
|
||||
if(!strcmp(pc->Token, Instructions[i].Name)){
|
||||
*operands = Instructions[i].Operands;
|
||||
return i+1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static __inline uint8_t read_variable(const ParserContext *pc, const variable_t *Variables, size_t VariableCount){
|
||||
unsigned i;
|
||||
verify_name(pc, "variable", "operand or newline");
|
||||
|
||||
for(i=0; i<VariableCount; i++)
|
||||
if(!strcmp(Variables[i].Name, pc->Token))
|
||||
return Variables[i].Value;
|
||||
|
||||
Shutdown_M("%s:%u:%u: error: unrecognized variable '%s'\n",
|
||||
path[txt], pc->Line, pc->Col, pc->Token);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void Shutdown(){
|
||||
unsigned i;
|
||||
for(i=0; i<filecount; i++){
|
||||
free(path[i]);
|
||||
free(data[i]);
|
||||
}
|
||||
free(TextSection.Data);
|
||||
free(SymbolTable.Data);
|
||||
free(StringTable.Data);
|
||||
free(RelocationTable.Data);
|
||||
if(hFile)
|
||||
fclose(hFile);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
unsigned i;
|
||||
int SimsVersion = 0;
|
||||
int overwrite = 0;
|
||||
size_t filesize[filecount-1] = {0};
|
||||
unsigned slash;
|
||||
const variable_t * Variables;
|
||||
size_t VariableCount;
|
||||
ParserContext pc;
|
||||
int InBinary = 0;
|
||||
|
||||
if(argc == 1 || !strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")){
|
||||
printf("Usage: hitasm [-ts1|-tso] [-f] [-o outfile.o] infile.txt\n"
|
||||
"Assemble a HIT source file to an intermediary object file\n"
|
||||
"which can be linked using hitld.\n"
|
||||
"\n"
|
||||
"Use -f to force overwriting without confirmation.\n"
|
||||
"\n"
|
||||
"Report bugs to <X-Fi6@phppoll.org>.\n"
|
||||
"hitutils is maintained by the Niotso project.\n"
|
||||
"Home page: <http://www.niotso.org/>\n");
|
||||
return 0;
|
||||
}
|
||||
for(i=1; i<(unsigned)argc-1; i++){
|
||||
if(!strcmp(argv[i], "-ts1")) SimsVersion = VERSION_TS1;
|
||||
else if(!strcmp(argv[i], "-tso")) SimsVersion = VERSION_TSO;
|
||||
else if(!strcmp(argv[i], "-f")) overwrite = 1;
|
||||
else if(i != (unsigned)argc-2){
|
||||
if(!strcmp(argv[i], "-o")) path[out] = argv[++i];
|
||||
else break;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
path[txt] = argv[i];
|
||||
for(i=0; i<filecount; i++)
|
||||
if(path[i])
|
||||
path[i] = strdup(path[i]); /* necessary for free(path[i]) in Shutdown_M */
|
||||
|
||||
if(!SimsVersion)
|
||||
Shutdown_M("%sSims version not specified. (Use -ts1 or -tso.)\n", "hitasm: Error: ");
|
||||
|
||||
if(SimsVersion == VERSION_TS1){
|
||||
Variables = TS1Variables;
|
||||
VariableCount = TS1VariableCount;
|
||||
}else{
|
||||
Variables = TSOVariables;
|
||||
VariableCount = TSOVariableCount;
|
||||
}
|
||||
|
||||
if(path[out] == NULL){
|
||||
int length = strlen(path[txt]);
|
||||
path[out] = malloc(max(length+1, 5));
|
||||
strcpy(path[out], path[txt]);
|
||||
strcpy(path[out] + max(length-4, 0), ".o");
|
||||
}
|
||||
|
||||
/****
|
||||
** Read all of the requested files
|
||||
*/
|
||||
|
||||
for(i=0; i<filecount-1; i++){
|
||||
size_t bytestransferred;
|
||||
if(!path[i]) continue;
|
||||
|
||||
hFile = fopen(path[i], "rb");
|
||||
if(hFile == NULL){
|
||||
if(i != txt){
|
||||
fprintf(stderr, "%sCould not open file: %s.\n", "hitasm: Warning: ", path[i]);
|
||||
continue;
|
||||
}else
|
||||
Shutdown_M("%sCould not open file: %s.\n", "hitasm: Error: ", path[i]);
|
||||
}
|
||||
|
||||
fseek(hFile, 0, SEEK_END);
|
||||
filesize[i] = ftell(hFile);
|
||||
if(filesize[i] == 0 || filesize[i] == SIZE_MAX){
|
||||
fclose(hFile); hFile = NULL;
|
||||
if(i != txt){
|
||||
fprintf(stderr, "%sFile is invalid: %s.\n", "hitasm: Warning: ", path[i]);
|
||||
continue;
|
||||
}else
|
||||
Shutdown_M("%sFile is invalid: %s.\n", "hitasm: Error: ", path[i]);
|
||||
}
|
||||
|
||||
data[i] = malloc(filesize[i]+1);
|
||||
if(data[i] == NULL){
|
||||
fclose(hFile); hFile = NULL;
|
||||
if(i != txt){
|
||||
fprintf(stderr, "%sCould not allocate memory for file: %s.\n", "hitasm: Warning: ", path[i]);
|
||||
continue;
|
||||
}else
|
||||
Shutdown_M("%sCould not allocate memory for file: %s.\n", "hitasm: Error: ", path[i]);
|
||||
}
|
||||
|
||||
fseek(hFile, 0, SEEK_SET);
|
||||
bytestransferred = fread(data[i], 1, filesize[i], hFile);
|
||||
fclose(hFile); hFile = NULL;
|
||||
if(bytestransferred != filesize[i]){
|
||||
free(data[i]); data[i] = NULL;
|
||||
if(i != txt){
|
||||
fprintf(stderr, "%sCould not read file: %s.\n", "hitasm: Warning: ", path[i]);
|
||||
continue;
|
||||
}else
|
||||
Shutdown_M("%sCould not read file: %s.\n", "hitasm: Error: ", path[i]);
|
||||
}
|
||||
data[i][filesize[i]++] = '\0'; /* add a null character to the end of the file */
|
||||
}
|
||||
|
||||
|
||||
/****
|
||||
** Open the output file for writing
|
||||
*/
|
||||
|
||||
if(!overwrite){
|
||||
hFile = fopen(path[out], "rb");
|
||||
if(hFile != NULL){
|
||||
/* File exists */
|
||||
char c;
|
||||
fclose(hFile); hFile = NULL;
|
||||
fprintf(stderr, "%sFile \"%s\" exists.\nContinue anyway? (y/n) ", "hitasm: ", path[out]);
|
||||
c = getchar();
|
||||
if(c != 'y' && c != 'Y')
|
||||
Shutdown_M("\nAborted.\n");
|
||||
}
|
||||
}
|
||||
hFile = fopen(path[out], "wb");
|
||||
if(hFile == NULL)
|
||||
Shutdown_M("%sCould not open file: %s.\n", "hitasm: Error: ", path[out]);
|
||||
|
||||
/****
|
||||
** Perform the assembly
|
||||
*/
|
||||
|
||||
TextSection.Data = malloc(TextSection.Size);
|
||||
SymbolTable.Data = malloc(SymbolTable.Size);
|
||||
StringTable.Data = malloc(StringTable.Size);
|
||||
RelocationTable.Data = malloc(RelocationTable.Size);
|
||||
pc.NextLine = 1;
|
||||
pc.NextCol = 1;
|
||||
pc.GaveLastToken = 1;
|
||||
pc.brc.Data = data[txt];
|
||||
pc.brc.Size = filesize[txt];
|
||||
|
||||
bw_write_memory(&SymbolTable, SymbolTableHeader, sizeof(SymbolTableHeader));
|
||||
|
||||
for(i=slash=0; path[txt][i]; i++)
|
||||
if(path[txt][i] == '/' || path[txt][i] == '\\') slash = i+1;
|
||||
bw_write8(&StringTable, '\0');
|
||||
bw_write_string(&StringTable, path[txt] + slash);
|
||||
|
||||
while(parser_next_token(&pc, TK_CROSSLINES)){
|
||||
printf("Token: %s\n", pc.Token);
|
||||
|
||||
/* Unimplemented commands */
|
||||
if(!strcmp(pc.Token, "BASEID_TRACKDATA") || !strcmp(pc.Token, "INCLUDE")
|
||||
|| !strcmp(pc.Token, "include") || !strcmp(pc.Token, "INIFILE")
|
||||
|| !strcmp(pc.Token, "LIST") || !strcmp(pc.Token, "SYMBOLFILE")){
|
||||
if(InBinary)
|
||||
Shutdown_M("%s:%u:%u: error: invalid use of '%s' inside BINARY section\n",
|
||||
path[txt], pc.Line, pc.Col, pc.Token);
|
||||
while(parser_next_token(&pc, 0)); /* skip to the end of the line */
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!strcmp(pc.Token, "BINARY") && !InBinary){
|
||||
InBinary++;
|
||||
if(!parser_next_token(&pc, TK_CROSSLINES) || strcmp(pc.Token, "["))
|
||||
Shutdown_M("%s:%u:%u: error: expected '[' for beginning of BINARY section before %s%s%s\n",
|
||||
path[txt], pc.Line, pc.Col,
|
||||
pc.Token ? "'" : "", pc.Token ? pc.Token : "end of file", pc.Token ? "'" : "");
|
||||
}
|
||||
|
||||
else if(!strcmp(pc.Token, "]") && InBinary)
|
||||
InBinary--;
|
||||
|
||||
else if(!InBinary)
|
||||
Shutdown_M("%s:%u:%u: error: '%s' is not a valid command\n",
|
||||
path[txt], pc.Line, pc.Col, pc.Token);
|
||||
|
||||
/****
|
||||
** Inside a BINARY section
|
||||
*/
|
||||
|
||||
else if(pc.Col == 1) /* no indent */
|
||||
parser_add_symbol(&pc);
|
||||
|
||||
else{ /* indent */
|
||||
uint8_t opcode;
|
||||
uint32_t operands;
|
||||
|
||||
if((pc.Token[0] >= '0' && pc.Token[0] <= '9') || pc.Token[0] == '-' || pc.Token[0] == '.'
|
||||
|| pc.Token[0] == '#' || !(opcode = read_instruction(&pc, &operands))){
|
||||
/* declare bytes (db and dd pseudo-instructions) */
|
||||
do {
|
||||
if(pc.Token[0] != '#')
|
||||
bw_write8(&TextSection, read_integer(&pc, 0x000000FF));
|
||||
else
|
||||
bw_write32(&TextSection, read_constant(&pc, 0, 0xFFFFFFFF));
|
||||
} while(parser_next_token(&pc, 0));
|
||||
continue;
|
||||
}else{
|
||||
const char * InstructionName = pc.Token;
|
||||
|
||||
printf("Instruction: %s\n", pc.Token);
|
||||
bw_write8(&TextSection, opcode);
|
||||
|
||||
for(i=0; (operands >>= 4) != 0; i++){
|
||||
int type = operands & 15;
|
||||
const char *position[] = {"one","two","three","four"};
|
||||
|
||||
if(!parser_next_token(&pc, 0)){
|
||||
int j;
|
||||
for(j=i+1; (operands >>= 4) != 0; j++);
|
||||
Shutdown_M("%s:%u:%u: error: instruction '%s' wants %s operands but only %s supplied\n",
|
||||
path[txt], pc.Line, pc.Col, pc.Token, InstructionName, position[j], position[i]);
|
||||
}
|
||||
|
||||
printf("Operand: %s\n", pc.Token);
|
||||
|
||||
if(type == o_byte)
|
||||
bw_write8(&TextSection, read_constant(&pc, 0, 0x000000FF));
|
||||
else if(type == o_dword)
|
||||
bw_write32(&TextSection, read_constant(&pc, 0, 0xFFFFFFFF));
|
||||
else if(type == o_address)
|
||||
bw_write32(&TextSection, read_constant(&pc, CN_LABELONLY, 0xFFFFFFFF));
|
||||
else if(type == o_variable)
|
||||
bw_write8(&TextSection, read_variable(&pc, Variables, VariableCount));
|
||||
else if(type == o_jump){
|
||||
/* TODO: Change this */
|
||||
bw_write32(&TextSection, read_constant(&pc, CN_LABELONLY, 0xFFFFFFFF));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
verify_eol(&pc);
|
||||
}
|
||||
|
||||
if(InBinary)
|
||||
Shutdown_M("%s:%u:%u: error: expected ']' for end of BINARY section before end of file\n",
|
||||
path[txt], pc.Line, pc.Col);
|
||||
|
||||
for(i=48+8; i<SymbolTable.Position; i+=16)
|
||||
write_uint32(SymbolTable.Data + i, 0);
|
||||
|
||||
i = 304;
|
||||
write_uint32(ObjectHeader + 120, i);
|
||||
write_uint32(ObjectHeader + 124, TextSection.Position);
|
||||
i += TextSection.Position;
|
||||
write_uint32(ObjectHeader + 160, i);
|
||||
write_uint32(ObjectHeader + 164, sizeof(SHStringTable));
|
||||
i += sizeof(SHStringTable);
|
||||
write_uint32(ObjectHeader + 200, i);
|
||||
write_uint32(ObjectHeader + 204, SymbolTable.Position);
|
||||
i += SymbolTable.Position;
|
||||
write_uint32(ObjectHeader + 240, i);
|
||||
write_uint32(ObjectHeader + 244, StringTable.Position);
|
||||
i += StringTable.Position;
|
||||
write_uint32(ObjectHeader + 280, i);
|
||||
write_uint32(ObjectHeader + 284, RelocationTable.Position);
|
||||
|
||||
fwrite(ObjectHeader, 1, sizeof(ObjectHeader), hFile);
|
||||
fwrite(TextSection.Data, 1, TextSection.Position, hFile);
|
||||
fwrite(SHStringTable, 1, sizeof(SHStringTable), hFile);
|
||||
fwrite(SymbolTable.Data, 1, SymbolTable.Position, hFile);
|
||||
fwrite(StringTable.Data, 1, StringTable.Position, hFile);
|
||||
fwrite(RelocationTable.Data, 1, RelocationTable.Position, hFile);
|
||||
|
||||
Shutdown();
|
||||
|
||||
int main(){
|
||||
printf("Usage: hitasm [-f] [-o outfile.o] infile.txt\n"
|
||||
"Compile a HIT source file to an intermediary object file\n"
|
||||
"which can be linked using hitld.\n"
|
||||
"\n"
|
||||
"Use -f to force overwriting without confirmation.\n"
|
||||
"\n"
|
||||
"Report bugs to <X-Fi6@phppoll.org>.\n"
|
||||
"hitutils is maintained by the Niotso project.\n"
|
||||
"Home page: <http://www.niotso.org/>\n");
|
||||
return 0;
|
||||
}
|
|
@ -21,326 +21,20 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef min
|
||||
#define min(x,y) ((x) < (y) ? (x) : (y))
|
||||
#endif
|
||||
#ifndef max
|
||||
#define max(x,y) ((x) > (y) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
#ifndef read_int32
|
||||
#define read_uint32(x) (unsigned)(((x)[0]<<(8*0)) | ((x)[1]<<(8*1)) | ((x)[2]<<(8*2)) | ((x)[3]<<(8*3)))
|
||||
#define read_uint16(x) (unsigned)(((x)[0]<<(8*0)) | ((x)[1]<<(8*1)))
|
||||
#endif
|
||||
|
||||
static void Shutdown_M(const char * Message, ...);
|
||||
#include "hitutils.h"
|
||||
|
||||
enum {
|
||||
hsm, hot, evt, hit, out, filecount
|
||||
};
|
||||
|
||||
enum {
|
||||
VERSION_TS1 = 1, VERSION_TSO
|
||||
};
|
||||
|
||||
#define OPERAND_BYTES(x) (x)
|
||||
#define OPERAND(x, y) ((y)<<((x)*4+4))
|
||||
#define UNIMPLEMENTED ((uint32_t)~0)
|
||||
|
||||
enum operand_t {
|
||||
o_byte = 1,
|
||||
o_dword,
|
||||
o_address,
|
||||
o_variable,
|
||||
o_jump
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
const char * Name;
|
||||
uint32_t Operands;
|
||||
} instruction_t;
|
||||
|
||||
typedef struct {
|
||||
const char * Name;
|
||||
uint32_t Value;
|
||||
} global_t;
|
||||
|
||||
static const uint8_t HITHeader[] = {'H','I','T','!',0x01,0x00,0x00,0x00,0x08,0x00,0x00,0x00,'T','R','A','X'};
|
||||
|
||||
static const instruction_t Instructions[] = {
|
||||
{"note", UNIMPLEMENTED},
|
||||
{"note_on", OPERAND_BYTES(1) | OPERAND(0, o_variable)},
|
||||
{"note_off", OPERAND_BYTES(1) | OPERAND(0, o_variable)},
|
||||
{"loadb", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_byte)},
|
||||
{"loadl", OPERAND_BYTES(5) | OPERAND(0, o_variable) | OPERAND(1, o_dword)},
|
||||
{"set", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"call", OPERAND_BYTES(4) | OPERAND(0, o_address)},
|
||||
{"return", OPERAND_BYTES(0)},
|
||||
{"wait", OPERAND_BYTES(1) | OPERAND(0, o_variable)},
|
||||
{"callentrypoint", UNIMPLEMENTED},
|
||||
{"wait_samp", OPERAND_BYTES(0)},
|
||||
{"end", OPERAND_BYTES(0)},
|
||||
{"jump", OPERAND_BYTES(1) | OPERAND(0, o_jump)},
|
||||
{"test", OPERAND_BYTES(1) | OPERAND(0, o_variable)},
|
||||
{"nop", OPERAND_BYTES(0)},
|
||||
{"add", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"sub", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"div", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"mul", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"cmp", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"less", UNIMPLEMENTED},
|
||||
{"greater", UNIMPLEMENTED},
|
||||
{"not", UNIMPLEMENTED},
|
||||
{"rand", OPERAND_BYTES(3) | OPERAND(0, o_variable) | OPERAND(1, o_variable) | OPERAND(2, o_variable)},
|
||||
{"abs", UNIMPLEMENTED},
|
||||
{"limit", UNIMPLEMENTED},
|
||||
{"error", UNIMPLEMENTED},
|
||||
{"assert", UNIMPLEMENTED},
|
||||
{"add_to_group", UNIMPLEMENTED},
|
||||
{"remove_from_group", UNIMPLEMENTED},
|
||||
{"get_var", UNIMPLEMENTED},
|
||||
{"loop", OPERAND_BYTES(0)},
|
||||
{"set_loop", OPERAND_BYTES(0)},
|
||||
{"callback", UNIMPLEMENTED},
|
||||
{"smart_add", UNIMPLEMENTED},
|
||||
{"smart_remove", UNIMPLEMENTED},
|
||||
{"smart_removeall", UNIMPLEMENTED},
|
||||
{"smart_setcrit", UNIMPLEMENTED},
|
||||
{"smart_choose", OPERAND_BYTES(1) | OPERAND(0, o_variable)},
|
||||
{"and", UNIMPLEMENTED},
|
||||
{"nand", UNIMPLEMENTED},
|
||||
{"or", UNIMPLEMENTED},
|
||||
{"nor", UNIMPLEMENTED},
|
||||
{"xor", UNIMPLEMENTED},
|
||||
{"max", OPERAND_BYTES(5) | OPERAND(0, o_variable) | OPERAND(1, o_dword)},
|
||||
{"min", OPERAND_BYTES(5) | OPERAND(0, o_variable) | OPERAND(1, o_dword)},
|
||||
{"inc", OPERAND_BYTES(1) | OPERAND(0, o_variable)},
|
||||
{"dec", OPERAND_BYTES(1) | OPERAND(0, o_variable)},
|
||||
{"printreg", UNIMPLEMENTED},
|
||||
{"play_trk", OPERAND_BYTES(1) | OPERAND(0, o_variable)},
|
||||
{"kill_trk", OPERAND_BYTES(1) | OPERAND(0, o_variable)},
|
||||
{"push", UNIMPLEMENTED},
|
||||
{"push_mask", UNIMPLEMENTED},
|
||||
{"push_vars", UNIMPLEMENTED},
|
||||
{"call_mask", UNIMPLEMENTED},
|
||||
{"call_push", UNIMPLEMENTED},
|
||||
{"pop", UNIMPLEMENTED},
|
||||
{"test1", OPERAND_BYTES(0)},
|
||||
{"test2", OPERAND_BYTES(0)},
|
||||
{"test3", OPERAND_BYTES(0)},
|
||||
{"test4", OPERAND_BYTES(0)},
|
||||
{"ifeq", OPERAND_BYTES(4) | OPERAND(0, o_address)},
|
||||
{"ifne", OPERAND_BYTES(4) | OPERAND(0, o_address)},
|
||||
{"ifgt", OPERAND_BYTES(4) | OPERAND(0, o_address)},
|
||||
{"iflt", OPERAND_BYTES(4) | OPERAND(0, o_address)},
|
||||
{"ifge", OPERAND_BYTES(4) | OPERAND(0, o_address)},
|
||||
{"ifle", OPERAND_BYTES(4) | OPERAND(0, o_address)},
|
||||
{"smart_setlist", OPERAND_BYTES(1) | OPERAND(0, o_variable)},
|
||||
{"seqgroup_kill", OPERAND_BYTES(1) | OPERAND(0, o_byte)},
|
||||
{"seqgroup_wait", UNIMPLEMENTED},
|
||||
{"seqgroup_return", OPERAND_BYTES(1) | OPERAND(0, o_byte)},
|
||||
{"getsrcdatafield", OPERAND_BYTES(3) | OPERAND(0, o_variable) | OPERAND(1, o_variable) | OPERAND(2, o_variable)},
|
||||
{"seqgroup_trkid", OPERAND_BYTES(2) | OPERAND(0, o_byte) | OPERAND(1, o_byte)},
|
||||
{"setll", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"setlt", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"settl", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"waiteq", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"waitne", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"waitgt", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"waitlt", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"waitge", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"waitle", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"duck", OPERAND_BYTES(0)},
|
||||
{"unduck", OPERAND_BYTES(0)},
|
||||
{"testx", UNIMPLEMENTED},
|
||||
{"setlg", OPERAND_BYTES(5) | OPERAND(0, o_variable) | OPERAND(1, o_dword)},
|
||||
{"setgl", OPERAND_BYTES(5) | OPERAND(0, o_variable) | OPERAND(1, o_dword)},
|
||||
{"throw", UNIMPLEMENTED},
|
||||
{"setsrcdatafield", OPERAND_BYTES(3) | OPERAND(0, o_variable) | OPERAND(1, o_variable) | OPERAND(2, o_variable)},
|
||||
{"stop_trk", OPERAND_BYTES(1) | OPERAND(0, o_variable)},
|
||||
{"setchanreg", UNIMPLEMENTED},
|
||||
{"play_note", UNIMPLEMENTED},
|
||||
{"stop_note", UNIMPLEMENTED},
|
||||
{"kill_note", UNIMPLEMENTED},
|
||||
{"smart_index", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"note_on_loop", OPERAND_BYTES(1) | OPERAND(0, o_variable)}
|
||||
};
|
||||
|
||||
static const char *Registers[] = {
|
||||
"arg0",
|
||||
"arg1",
|
||||
"arg2",
|
||||
"arg3",
|
||||
"arg4",
|
||||
"v1",
|
||||
"v2",
|
||||
"v3",
|
||||
"v4",
|
||||
"v5",
|
||||
"v6",
|
||||
"v7",
|
||||
"v8",
|
||||
"h1",
|
||||
"h2",
|
||||
"h3",
|
||||
"h4"
|
||||
};
|
||||
|
||||
#define TSOGlobalCount 66
|
||||
static const global_t TSOGlobals[] = {
|
||||
{"argstype", 0x10},
|
||||
{"trackdatasource", 0x11},
|
||||
{"patch", 0x12},
|
||||
{"priority", 0x13},
|
||||
{"vol", 0x14},
|
||||
{"extvol", 0x15},
|
||||
{"pan", 0x16},
|
||||
{"pitch", 0x17},
|
||||
{"paused", 0x18},
|
||||
{"fxtype", 0x19},
|
||||
{"fxlevel", 0x1a},
|
||||
{"duckpri", 0x1b},
|
||||
{"Is3d", 0x1c},
|
||||
{"IsHeadRelative", 0x1d},
|
||||
{"MinDistance", 0x1e},
|
||||
{"MaxDistance", 0x1f},
|
||||
{"X", 0x20},
|
||||
{"Y", 0x21},
|
||||
{"Z", 0x22},
|
||||
{"attack", 0x23},
|
||||
{"decay", 0x24},
|
||||
{"IsStreamed", 0x25},
|
||||
{"bufsizemult", 0x26},
|
||||
{"fade_dest", 0x27},
|
||||
{"fade_var", 0x28},
|
||||
{"fade_speed", 0x29},
|
||||
{"fade_on", 0x2a},
|
||||
{"Preload", 0x2b},
|
||||
{"isplaying", 0x2c},
|
||||
{"whattodowithupdate", 0x2d},
|
||||
{"tempo", 0x2e},
|
||||
{"target", 0x2f},
|
||||
{"ctrlgroup", 0x30},
|
||||
{"interrupt", 0x31},
|
||||
{"ispositioned", 0x32},
|
||||
{"AppObjectId", 0x34},
|
||||
{"callbackarg", 0x35},
|
||||
{"pitchrandmin", 0x36},
|
||||
{"pitchrandmax", 0x37},
|
||||
{"spl", 0x38},
|
||||
{"sem", 0x39},
|
||||
{"starttrackid", 0x3a},
|
||||
{"endtrackid", 0x3b},
|
||||
{"startdelay", 0x3c},
|
||||
{"fadeinspeed", 0x3d},
|
||||
{"fadeoutspeed", 0x3e},
|
||||
{"hitlist", 0x3f},
|
||||
{"SimSpeed", 0x64},
|
||||
{"test_g1", 0x65},
|
||||
{"test_g2", 0x66},
|
||||
{"test_g3", 0x67},
|
||||
{"test_g4", 0x68},
|
||||
{"test_g5", 0x69},
|
||||
{"test_g6", 0x6a},
|
||||
{"test_g7", 0x6b},
|
||||
{"test_g8", 0x6c},
|
||||
{"test_g9", 0x6d},
|
||||
{"main_songnum", 0x6e},
|
||||
{"main_musichitlistid", 0x6f},
|
||||
{"campfire_nexttrack", 0x70},
|
||||
{"campfire_busy", 0x71},
|
||||
{"main_duckpri", 0x7b},
|
||||
{"main_vol", 0x7c},
|
||||
{"main_fxtype", 0x7d},
|
||||
{"main_fxlevel", 0x7e},
|
||||
{"main_pause", 0x7f}
|
||||
};
|
||||
|
||||
#define TS1GlobalCount 71
|
||||
static const global_t TS1Globals[] = {
|
||||
{"priority", 0x11},
|
||||
{"vol", 0x12},
|
||||
{"extvol", 0x13},
|
||||
{"pan", 0x14},
|
||||
{"pitch", 0x15},
|
||||
{"paused", 0x16},
|
||||
{"fxtype", 0x17},
|
||||
{"fxlevel", 0x18},
|
||||
{"duckpri", 0x19},
|
||||
{"Is3d", 0x1a},
|
||||
{"IsHeadRelative", 0x1b},
|
||||
{"MinDistance", 0x1c},
|
||||
{"MaxDistance", 0x1d},
|
||||
{"X", 0x1e},
|
||||
{"Y", 0x1f},
|
||||
{"Z", 0x20},
|
||||
{"filter_type", 0x21},
|
||||
{"filter_cutoff", 0x22},
|
||||
{"filter_level", 0x23},
|
||||
{"attack", 0x24},
|
||||
{"decay", 0x25},
|
||||
{"IsStreamed", 0x26},
|
||||
{"BufSizeMult", 0x27},
|
||||
{"fade_dest", 0x28},
|
||||
{"fade_var", 0x29},
|
||||
{"fade_speed", 0x2a},
|
||||
{"Preload", 0x2b},
|
||||
{"IsLooped", 0x2c},
|
||||
{"fade_on", 0x2d},
|
||||
{"isplaying", 0x2e},
|
||||
{"source", 0x2f},
|
||||
{"patch", 0x32},
|
||||
{"WhatToDoWithUpdate", 0x33},
|
||||
{"tempo", 0x34},
|
||||
{"target", 0x35},
|
||||
{"mutegroup", 0x36},
|
||||
{"interrupt", 0x37},
|
||||
{"IsPositioned", 0x38},
|
||||
{"Spl", 0x39},
|
||||
{"MultipleInstances", 0x3a},
|
||||
{"AssociatedTrack1", 0x3b},
|
||||
{"AssociatedTrack2", 0x3c},
|
||||
{"AssociatedTrack3", 0x3d},
|
||||
{"AssociatedTrack4", 0x3e},
|
||||
{"AssociatedTrack5", 0x3f},
|
||||
{"AssociatedTrack6", 0x40},
|
||||
{"AssociatedTrack7", 0x41},
|
||||
{"AssociatedTrack8", 0x42},
|
||||
{"SimSpeed", 0x64},
|
||||
{"test_g1", 0x65},
|
||||
{"test_g2", 0x66},
|
||||
{"test_g3", 0x67},
|
||||
{"test_g4", 0x68},
|
||||
{"test_g5", 0x69},
|
||||
{"test_g6", 0x6a},
|
||||
{"test_g7", 0x6b},
|
||||
{"test_g8", 0x6c},
|
||||
{"test_g9", 0x6d},
|
||||
{"main_songnum", 0x6e},
|
||||
{"main_musichitlistid", 0x6f},
|
||||
{"campfire_nexttrack", 0x70},
|
||||
{"campfire_busy", 0x71},
|
||||
{"main_duckpri", 0x7b},
|
||||
{"main_vol", 0x7c},
|
||||
{"main_fxtype", 0x7d},
|
||||
{"main_fxlevel", 0x7e},
|
||||
{"main_pause", 0x7f},
|
||||
};
|
||||
|
||||
static __inline const char * find_global(uint32_t x, const global_t * Globals, size_t GlobalCount){
|
||||
static __inline const char * find_variable(uint32_t x, const variable_t * Variables, size_t VariableCount){
|
||||
size_t i;
|
||||
for(i=0; i<GlobalCount; i++)
|
||||
if(Globals[i].Value == x)
|
||||
return Globals[i].Name;
|
||||
for(i=0; i<VariableCount; i++)
|
||||
if(Variables[i].Value == x)
|
||||
return Variables[i].Name;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
uint8_t * Data;
|
||||
size_t Size;
|
||||
} ByteReaderContext;
|
||||
|
||||
enum TokenizeType {
|
||||
TK_STRING,
|
||||
TK_ID
|
||||
|
@ -531,7 +225,7 @@ static __inline void read_hot_trackdata(uint8_t * Data, size_t Size, addresslist
|
|||
while(1){
|
||||
address_t * Address;
|
||||
uint32_t SoundID, LogicalAddress;
|
||||
if(!brc.Size || *brc.Data == '\n' || *brc.Data == '[') return;
|
||||
if(!brc.Size || *brc.Data == '\r' || *brc.Data == '\n' || *brc.Data == '[') return;
|
||||
if(!parser_find(&brc,
|
||||
"=", &SoundID, TK_ID,
|
||||
"\n", &LogicalAddress, TK_ID,
|
||||
|
@ -559,7 +253,7 @@ static __inline void read_hot_track(uint8_t * Data, size_t Size, addresslist_t *
|
|||
address_t * Address;
|
||||
char * Name;
|
||||
uint32_t TrackID;
|
||||
if(!brc.Size || *brc.Data == '\n' || *brc.Data == '[') return;
|
||||
if(!brc.Size || *brc.Data == '\r' || *brc.Data == '\n' || *brc.Data == '[') return;
|
||||
if(!parser_find(&brc,
|
||||
"=", &TrackID, TK_ID,
|
||||
",", NULL,
|
||||
|
@ -604,25 +298,15 @@ static void Shutdown(){
|
|||
fclose(hFile);
|
||||
}
|
||||
|
||||
static void Shutdown_M(const char * Message, ...){
|
||||
va_list args;
|
||||
va_start(args, Message);
|
||||
vfprintf(stderr, Message, args);
|
||||
va_end(args);
|
||||
|
||||
Shutdown();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
unsigned i, j, addr;
|
||||
unsigned i, addr;
|
||||
int SimsVersion = 0;
|
||||
int overwrite = 0;
|
||||
int ShowAddresses = 0;
|
||||
int length;
|
||||
size_t filesize[filecount-1];
|
||||
const global_t * Globals;
|
||||
size_t GlobalCount;
|
||||
const variable_t * Variables;
|
||||
size_t VariableCount;
|
||||
uint32_t SymbolTable = 0;
|
||||
uint32_t BaseSoundID = 0, BaseSoundIDSet = 0;
|
||||
|
||||
|
@ -661,19 +345,19 @@ int main(int argc, char *argv[]){
|
|||
else break;
|
||||
}
|
||||
path[hit] = argv[i];
|
||||
for(j=0; j<filecount; j++)
|
||||
if(path[j])
|
||||
path[j] = strdup(path[j]); /* necessary for free(path[i]) in Shutdown_M */
|
||||
for(i=0; i<filecount; i++)
|
||||
if(path[i])
|
||||
path[i] = strdup(path[i]); /* necessary for free(path[i]) in Shutdown_M */
|
||||
|
||||
if(!SimsVersion)
|
||||
Shutdown_M("%sSims version not specified. (Use -ts1 or -tso.)\n", "hitdump: Error: ");
|
||||
|
||||
if(SimsVersion == VERSION_TS1){
|
||||
Globals = TS1Globals;
|
||||
GlobalCount = TS1GlobalCount;
|
||||
Variables = TS1Variables;
|
||||
VariableCount = TS1VariableCount;
|
||||
}else{
|
||||
Globals = TSOGlobals;
|
||||
GlobalCount = TSOGlobalCount;
|
||||
Variables = TSOVariables;
|
||||
VariableCount = TSOVariableCount;
|
||||
}
|
||||
|
||||
length = strlen(path[hit]);
|
||||
|
@ -813,7 +497,7 @@ int main(int argc, char *argv[]){
|
|||
"; tkd_GenericHitList 3\r\n"
|
||||
"\r\n"
|
||||
"INCLUDE defaultsyms.txt\r\n"
|
||||
"INCLUDE SimsGlobals.txt\r\n"
|
||||
"INCLUDE SimsVariables.txt\r\n"
|
||||
"\r\n"
|
||||
"LIST [Options] Version=1\r\n"
|
||||
"LIST [Options] LoadPriority=2\r\n"
|
||||
|
@ -878,7 +562,7 @@ int main(int argc, char *argv[]){
|
|||
}
|
||||
|
||||
opcode = data[hit][addr];
|
||||
if(opcode == 0 || opcode > 96)
|
||||
if(opcode == 0 || opcode > InstructionCount)
|
||||
Shutdown_M("%sIllegal opcode 0x%02X at address 0x%08X.\n", "hitdump: Error: ", opcode, addr);
|
||||
|
||||
instruction = Instructions + opcode - 1;
|
||||
|
@ -910,14 +594,12 @@ int main(int argc, char *argv[]){
|
|||
else fprintf(hFile, " #%u", LogicalAddress);
|
||||
addr += 4;
|
||||
}else if(type == o_variable){
|
||||
int x = data[hit][addr];
|
||||
if(x > 16){
|
||||
const char * Global = find_global(x, Globals, GlobalCount);
|
||||
if(Global == NULL)
|
||||
Shutdown_M("%sInvalid %s operand 0x%02X for '%s' instruction at address 0x%08X (expected %s).\n",
|
||||
"hitdump: Error: ", position[i], x, instruction->Name, addr, "argument, register, or global");
|
||||
fprintf(hFile, " %s", Global);
|
||||
} else fprintf(hFile, " %s", Registers[x]);
|
||||
unsigned x = data[hit][addr];
|
||||
const char * Variable = find_variable(x, Variables, VariableCount);
|
||||
if(Variable == NULL)
|
||||
Shutdown_M("%sInvalid %s operand 0x%02X for '%s' instruction at address 0x%08X (expected variable).\n",
|
||||
"hitdump: Error: ", position[i], x, instruction->Name, addr);
|
||||
fprintf(hFile, " %s", Variable);
|
||||
addr += 1;
|
||||
}else if(type == o_jump){
|
||||
unsigned x = 0;
|
||||
|
@ -934,14 +616,13 @@ int main(int argc, char *argv[]){
|
|||
else fprintf(hFile, " #%u", x);
|
||||
addr += 4;
|
||||
}else{
|
||||
const char * Variable;
|
||||
x = data[hit][addr];
|
||||
if(x > 16){
|
||||
const char * Global = find_global(x, Globals, GlobalCount);
|
||||
if(Global == NULL)
|
||||
Shutdown_M("%sInvalid %s operand 0x%02X for '%s' instruction at address 0x%08X (expected %s).\n",
|
||||
"hitdump: Error: ", position[i], x, instruction->Name, addr, "argument, register, or global");
|
||||
fprintf(hFile, " %s", Global);
|
||||
} else fprintf(hFile, " %s", Registers[x]);
|
||||
Variable = find_variable(x, Variables, VariableCount);
|
||||
if(Variable == NULL)
|
||||
Shutdown_M("%sInvalid %s operand 0x%02X for '%s' instruction at address 0x%08X (expected variable).\n",
|
||||
"hitdump: Error: ", position[i], x, instruction->Name, addr);
|
||||
fprintf(hFile, " %s", Variable);
|
||||
addr += (data[hit][addr] != 0x05 && data[hit][addr] != 0x06) ? 4 : 1;
|
||||
}
|
||||
}
|
||||
|
|
452
Tools/hitutils/hitutils.h
Normal file
452
Tools/hitutils/hitutils.h
Normal file
|
@ -0,0 +1,452 @@
|
|||
/*
|
||||
hitutils - The Sims HIT (dis)assembler and linker
|
||||
hitutils.h - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef min
|
||||
#define min(x,y) ((x) < (y) ? (x) : (y))
|
||||
#endif
|
||||
#ifndef max
|
||||
#define max(x,y) ((x) > (y) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
#ifndef read_int32
|
||||
#define read_uint32(x) (unsigned)(((x)[0]<<(8*0)) | ((x)[1]<<(8*1)) | ((x)[2]<<(8*2)) | ((x)[3]<<(8*3)))
|
||||
#define read_uint16(x) (unsigned)(((x)[0]<<(8*0)) | ((x)[1]<<(8*1)))
|
||||
#endif
|
||||
|
||||
#ifndef write_int32
|
||||
#define write_uint32(dest, src) do {\
|
||||
(dest)[0] = ((src)&0x000000FF)>>(8*0); \
|
||||
(dest)[1] = ((src)&0x0000FF00)>>(8*1); \
|
||||
(dest)[2] = ((src)&0x00FF0000)>>(8*2); \
|
||||
(dest)[3] = ((src)&0xFF000000)>>(8*3); \
|
||||
} while(0)
|
||||
#define write_uint16(dest, src) do {\
|
||||
(dest)[0] = ((src)&0x00FF)>>(8*0); \
|
||||
(dest)[1] = ((src)&0xFF00)>>(8*1); \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
extern char *strdup (const char *__s);
|
||||
|
||||
static void Shutdown();
|
||||
|
||||
static void Shutdown_M(const char * Message, ...){
|
||||
va_list args;
|
||||
va_start(args, Message);
|
||||
vfprintf(stderr, Message, args);
|
||||
va_end(args);
|
||||
|
||||
Shutdown();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
enum {
|
||||
VERSION_TS1 = 1, VERSION_TSO
|
||||
};
|
||||
|
||||
#define OPERAND_BYTES(x) (x)
|
||||
#define OPERAND(x, y) ((y)<<((x)*4+4))
|
||||
#define UNIMPLEMENTED ((uint32_t)~0)
|
||||
|
||||
enum operand_t {
|
||||
o_byte = 1,
|
||||
o_dword,
|
||||
o_address,
|
||||
o_variable,
|
||||
o_jump
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
const char * Name;
|
||||
uint32_t Operands;
|
||||
} instruction_t;
|
||||
|
||||
typedef struct {
|
||||
const char * Name;
|
||||
uint32_t Value;
|
||||
} variable_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t * Data;
|
||||
size_t Size;
|
||||
} ByteReaderContext;
|
||||
|
||||
static const uint8_t HITHeader[] = {'H','I','T','!',0x01,0x00,0x00,0x00,0x08,0x00,0x00,0x00,'T','R','A','X'};
|
||||
|
||||
#define InstructionCount 96
|
||||
static const instruction_t Instructions[] = {
|
||||
{"note", UNIMPLEMENTED},
|
||||
{"note_on", OPERAND_BYTES(1) | OPERAND(0, o_variable)},
|
||||
{"note_off", OPERAND_BYTES(1) | OPERAND(0, o_variable)},
|
||||
{"loadb", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_byte)},
|
||||
{"loadl", OPERAND_BYTES(5) | OPERAND(0, o_variable) | OPERAND(1, o_dword)},
|
||||
{"set", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"call", OPERAND_BYTES(4) | OPERAND(0, o_address)},
|
||||
{"return", OPERAND_BYTES(0)},
|
||||
{"wait", OPERAND_BYTES(1) | OPERAND(0, o_variable)},
|
||||
{"callentrypoint", UNIMPLEMENTED},
|
||||
{"wait_samp", OPERAND_BYTES(0)},
|
||||
{"end", OPERAND_BYTES(0)},
|
||||
{"jump", OPERAND_BYTES(1) | OPERAND(0, o_jump)},
|
||||
{"test", OPERAND_BYTES(1) | OPERAND(0, o_variable)},
|
||||
{"nop", OPERAND_BYTES(0)},
|
||||
{"add", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"sub", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"div", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"mul", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"cmp", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"less", UNIMPLEMENTED},
|
||||
{"greater", UNIMPLEMENTED},
|
||||
{"not", UNIMPLEMENTED},
|
||||
{"rand", OPERAND_BYTES(3) | OPERAND(0, o_variable) | OPERAND(1, o_variable) | OPERAND(2, o_variable)},
|
||||
{"abs", UNIMPLEMENTED},
|
||||
{"limit", UNIMPLEMENTED},
|
||||
{"error", UNIMPLEMENTED},
|
||||
{"assert", UNIMPLEMENTED},
|
||||
{"add_to_group", UNIMPLEMENTED},
|
||||
{"remove_from_group", UNIMPLEMENTED},
|
||||
{"get_var", UNIMPLEMENTED},
|
||||
{"loop", OPERAND_BYTES(0)},
|
||||
{"set_loop", OPERAND_BYTES(0)},
|
||||
{"callback", UNIMPLEMENTED},
|
||||
{"smart_add", UNIMPLEMENTED},
|
||||
{"smart_remove", UNIMPLEMENTED},
|
||||
{"smart_removeall", UNIMPLEMENTED},
|
||||
{"smart_setcrit", UNIMPLEMENTED},
|
||||
{"smart_choose", OPERAND_BYTES(1) | OPERAND(0, o_variable)},
|
||||
{"and", UNIMPLEMENTED},
|
||||
{"nand", UNIMPLEMENTED},
|
||||
{"or", UNIMPLEMENTED},
|
||||
{"nor", UNIMPLEMENTED},
|
||||
{"xor", UNIMPLEMENTED},
|
||||
{"max", OPERAND_BYTES(5) | OPERAND(0, o_variable) | OPERAND(1, o_dword)},
|
||||
{"min", OPERAND_BYTES(5) | OPERAND(0, o_variable) | OPERAND(1, o_dword)},
|
||||
{"inc", OPERAND_BYTES(1) | OPERAND(0, o_variable)},
|
||||
{"dec", OPERAND_BYTES(1) | OPERAND(0, o_variable)},
|
||||
{"printreg", UNIMPLEMENTED},
|
||||
{"play_trk", OPERAND_BYTES(1) | OPERAND(0, o_variable)},
|
||||
{"kill_trk", OPERAND_BYTES(1) | OPERAND(0, o_variable)},
|
||||
{"push", UNIMPLEMENTED},
|
||||
{"push_mask", UNIMPLEMENTED},
|
||||
{"push_vars", UNIMPLEMENTED},
|
||||
{"call_mask", UNIMPLEMENTED},
|
||||
{"call_push", UNIMPLEMENTED},
|
||||
{"pop", UNIMPLEMENTED},
|
||||
{"test1", OPERAND_BYTES(0)},
|
||||
{"test2", OPERAND_BYTES(0)},
|
||||
{"test3", OPERAND_BYTES(0)},
|
||||
{"test4", OPERAND_BYTES(0)},
|
||||
{"ifeq", OPERAND_BYTES(4) | OPERAND(0, o_address)},
|
||||
{"ifne", OPERAND_BYTES(4) | OPERAND(0, o_address)},
|
||||
{"ifgt", OPERAND_BYTES(4) | OPERAND(0, o_address)},
|
||||
{"iflt", OPERAND_BYTES(4) | OPERAND(0, o_address)},
|
||||
{"ifge", OPERAND_BYTES(4) | OPERAND(0, o_address)},
|
||||
{"ifle", OPERAND_BYTES(4) | OPERAND(0, o_address)},
|
||||
{"smart_setlist", OPERAND_BYTES(1) | OPERAND(0, o_variable)},
|
||||
{"seqgroup_kill", OPERAND_BYTES(1) | OPERAND(0, o_byte)},
|
||||
{"seqgroup_wait", UNIMPLEMENTED},
|
||||
{"seqgroup_return", OPERAND_BYTES(1) | OPERAND(0, o_byte)},
|
||||
{"getsrcdatafield", OPERAND_BYTES(3) | OPERAND(0, o_variable) | OPERAND(1, o_variable) | OPERAND(2, o_variable)},
|
||||
{"seqgroup_trkid", OPERAND_BYTES(2) | OPERAND(0, o_byte) | OPERAND(1, o_byte)},
|
||||
{"setll", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"setlt", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"settl", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"waiteq", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"waitne", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"waitgt", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"waitlt", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"waitge", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"waitle", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"duck", OPERAND_BYTES(0)},
|
||||
{"unduck", OPERAND_BYTES(0)},
|
||||
{"testx", UNIMPLEMENTED},
|
||||
{"setlg", OPERAND_BYTES(5) | OPERAND(0, o_variable) | OPERAND(1, o_dword)},
|
||||
{"setgl", OPERAND_BYTES(5) | OPERAND(0, o_variable) | OPERAND(1, o_dword)},
|
||||
{"throw", UNIMPLEMENTED},
|
||||
{"setsrcdatafield", OPERAND_BYTES(3) | OPERAND(0, o_variable) | OPERAND(1, o_variable) | OPERAND(2, o_variable)},
|
||||
{"stop_trk", OPERAND_BYTES(1) | OPERAND(0, o_variable)},
|
||||
{"setchanreg", UNIMPLEMENTED},
|
||||
{"play_note", UNIMPLEMENTED},
|
||||
{"stop_note", UNIMPLEMENTED},
|
||||
{"kill_note", UNIMPLEMENTED},
|
||||
{"smart_index", OPERAND_BYTES(2) | OPERAND(0, o_variable) | OPERAND(1, o_variable)},
|
||||
{"note_on_loop", OPERAND_BYTES(1) | OPERAND(0, o_variable)}
|
||||
};
|
||||
|
||||
#define TSOVariableCount 82
|
||||
static const variable_t TSOVariables[] = {
|
||||
{"arg0", 0x00},
|
||||
{"arg1", 0x01},
|
||||
{"arg2", 0x02},
|
||||
{"arg3", 0x03},
|
||||
{"arg4", 0x04},
|
||||
{"v1", 0x05},
|
||||
{"v2", 0x06},
|
||||
{"v3", 0x07},
|
||||
{"v4", 0x08},
|
||||
{"v5", 0x09},
|
||||
{"v6", 0x0A},
|
||||
{"v7", 0x0B},
|
||||
{"v8", 0x0C},
|
||||
{"h1", 0x0D},
|
||||
{"h2", 0x0E},
|
||||
{"h3", 0x0F},
|
||||
{"argstype", 0x10},
|
||||
{"trackdatasource", 0x11},
|
||||
{"patch", 0x12},
|
||||
{"priority", 0x13},
|
||||
{"vol", 0x14},
|
||||
{"extvol", 0x15},
|
||||
{"pan", 0x16},
|
||||
{"pitch", 0x17},
|
||||
{"paused", 0x18},
|
||||
{"fxtype", 0x19},
|
||||
{"fxlevel", 0x1a},
|
||||
{"duckpri", 0x1b},
|
||||
{"Is3d", 0x1c},
|
||||
{"IsHeadRelative", 0x1d},
|
||||
{"MinDistance", 0x1e},
|
||||
{"MaxDistance", 0x1f},
|
||||
{"X", 0x20},
|
||||
{"Y", 0x21},
|
||||
{"Z", 0x22},
|
||||
{"attack", 0x23},
|
||||
{"decay", 0x24},
|
||||
{"IsStreamed", 0x25},
|
||||
{"bufsizemult", 0x26},
|
||||
{"fade_dest", 0x27},
|
||||
{"fade_var", 0x28},
|
||||
{"fade_speed", 0x29},
|
||||
{"fade_on", 0x2a},
|
||||
{"Preload", 0x2b},
|
||||
{"isplaying", 0x2c},
|
||||
{"whattodowithupdate", 0x2d},
|
||||
{"tempo", 0x2e},
|
||||
{"target", 0x2f},
|
||||
{"ctrlgroup", 0x30},
|
||||
{"interrupt", 0x31},
|
||||
{"ispositioned", 0x32},
|
||||
{"AppObjectId", 0x34},
|
||||
{"callbackarg", 0x35},
|
||||
{"pitchrandmin", 0x36},
|
||||
{"pitchrandmax", 0x37},
|
||||
{"spl", 0x38},
|
||||
{"sem", 0x39},
|
||||
{"starttrackid", 0x3a},
|
||||
{"endtrackid", 0x3b},
|
||||
{"startdelay", 0x3c},
|
||||
{"fadeinspeed", 0x3d},
|
||||
{"fadeoutspeed", 0x3e},
|
||||
{"hitlist", 0x3f},
|
||||
{"SimSpeed", 0x64},
|
||||
{"test_g1", 0x65},
|
||||
{"test_g2", 0x66},
|
||||
{"test_g3", 0x67},
|
||||
{"test_g4", 0x68},
|
||||
{"test_g5", 0x69},
|
||||
{"test_g6", 0x6a},
|
||||
{"test_g7", 0x6b},
|
||||
{"test_g8", 0x6c},
|
||||
{"test_g9", 0x6d},
|
||||
{"main_songnum", 0x6e},
|
||||
{"main_musichitlistid", 0x6f},
|
||||
{"campfire_nexttrack", 0x70},
|
||||
{"campfire_busy", 0x71},
|
||||
{"main_duckpri", 0x7b},
|
||||
{"main_vol", 0x7c},
|
||||
{"main_fxtype", 0x7d},
|
||||
{"main_fxlevel", 0x7e},
|
||||
{"main_pause", 0x7f},
|
||||
};
|
||||
|
||||
#define TS1VariableCount 87
|
||||
static const variable_t TS1Variables[] = {
|
||||
{"arg0", 0x00},
|
||||
{"arg1", 0x01},
|
||||
{"arg2", 0x02},
|
||||
{"arg3", 0x03},
|
||||
{"arg4", 0x04},
|
||||
{"v1", 0x05},
|
||||
{"v2", 0x06},
|
||||
{"v3", 0x07},
|
||||
{"v4", 0x08},
|
||||
{"v5", 0x09},
|
||||
{"v6", 0x0a},
|
||||
{"v7", 0x0b},
|
||||
{"v8", 0x0c},
|
||||
{"h1", 0x0d},
|
||||
{"h2", 0x0e},
|
||||
{"h3", 0x0f},
|
||||
{"priority", 0x11},
|
||||
{"vol", 0x12},
|
||||
{"extvol", 0x13},
|
||||
{"pan", 0x14},
|
||||
{"pitch", 0x15},
|
||||
{"paused", 0x16},
|
||||
{"fxtype", 0x17},
|
||||
{"fxlevel", 0x18},
|
||||
{"duckpri", 0x19},
|
||||
{"Is3d", 0x1a},
|
||||
{"IsHeadRelative", 0x1b},
|
||||
{"MinDistance", 0x1c},
|
||||
{"MaxDistance", 0x1d},
|
||||
{"X", 0x1e},
|
||||
{"Y", 0x1f},
|
||||
{"Z", 0x20},
|
||||
{"filter_type", 0x21},
|
||||
{"filter_cutoff", 0x22},
|
||||
{"filter_level", 0x23},
|
||||
{"attack", 0x24},
|
||||
{"decay", 0x25},
|
||||
{"IsStreamed", 0x26},
|
||||
{"BufSizeMult", 0x27},
|
||||
{"fade_dest", 0x28},
|
||||
{"fade_var", 0x29},
|
||||
{"fade_speed", 0x2a},
|
||||
{"Preload", 0x2b},
|
||||
{"IsLooped", 0x2c},
|
||||
{"fade_on", 0x2d},
|
||||
{"isplaying", 0x2e},
|
||||
{"source", 0x2f},
|
||||
{"patch", 0x32},
|
||||
{"WhatToDoWithUpdate", 0x33},
|
||||
{"tempo", 0x34},
|
||||
{"target", 0x35},
|
||||
{"mutegroup", 0x36},
|
||||
{"interrupt", 0x37},
|
||||
{"IsPositioned", 0x38},
|
||||
{"Spl", 0x39},
|
||||
{"MultipleInstances", 0x3a},
|
||||
{"AssociatedTrack1", 0x3b},
|
||||
{"AssociatedTrack2", 0x3c},
|
||||
{"AssociatedTrack3", 0x3d},
|
||||
{"AssociatedTrack4", 0x3e},
|
||||
{"AssociatedTrack5", 0x3f},
|
||||
{"AssociatedTrack6", 0x40},
|
||||
{"AssociatedTrack7", 0x41},
|
||||
{"AssociatedTrack8", 0x42},
|
||||
{"SimSpeed", 0x64},
|
||||
{"test_g1", 0x65},
|
||||
{"test_g2", 0x66},
|
||||
{"test_g3", 0x67},
|
||||
{"test_g4", 0x68},
|
||||
{"test_g5", 0x69},
|
||||
{"test_g6", 0x6a},
|
||||
{"test_g7", 0x6b},
|
||||
{"test_g8", 0x6c},
|
||||
{"test_g9", 0x6d},
|
||||
{"main_songnum", 0x6e},
|
||||
{"main_musichitlistid", 0x6f},
|
||||
{"campfire_nexttrack", 0x70},
|
||||
{"campfire_busy", 0x71},
|
||||
{"main_duckpri", 0x7b},
|
||||
{"main_vol", 0x7c},
|
||||
{"main_fxtype", 0x7d},
|
||||
{"main_fxlevel", 0x7e},
|
||||
{"main_pause", 0x7f},
|
||||
};
|
||||
|
||||
#define ConstantCount 72
|
||||
static const variable_t Constants[] = {
|
||||
{"duckpri_always", 0x0},
|
||||
{"duckpri_low", 0xa},
|
||||
{"duckpri_normal", 0x14},
|
||||
{"duckpri_high", 0x1e},
|
||||
{"duckpri_higher", 0x28},
|
||||
{"duckpri_evenhigher", 0x32},
|
||||
{"duckpri_never", 0x64},
|
||||
{"spl_infinite", 0x0},
|
||||
{"spl_loud", 0xa},
|
||||
{"spl_normal", 0x14},
|
||||
{"spl_quiet", 0x64},
|
||||
{"Instance", 0x0},
|
||||
{"Gender", 0x1},
|
||||
{"GroupMusic", 0x1},
|
||||
{"GroupDialogMain", 0x2},
|
||||
{"GroupDialogOverlay", 0x3},
|
||||
{"PchDishwasherClose", 0x32},
|
||||
{"PchDishwasherLoad", 0x33},
|
||||
{"PchDishwasherLoad2", 0x34},
|
||||
{"PchDishwasherOpen", 0x35},
|
||||
{"PchDishwasherTurnDial", 0x39},
|
||||
{"PchDishwasherTurnDial2", 0x3a},
|
||||
{"TrkRadioStationCountry", 0x104},
|
||||
{"TrkRadioStationBossaNova", 0x10e},
|
||||
{"TrkRadioStationClassical", 0x10d},
|
||||
{"TrkRadioStationRock", 0x118},
|
||||
{"kSndobPlay", 1},
|
||||
{"kSndobStop", 2},
|
||||
{"kSndobKill", 3},
|
||||
{"kSndobUpdate", 4},
|
||||
{"kSndobSetVolume", 5},
|
||||
{"kSndobSetPitch", 6},
|
||||
{"kSndobSetPan", 7},
|
||||
{"kSndobSetPosition", 8},
|
||||
{"kSndobSetFxType", 9},
|
||||
{"kSndobSetFxLevel", 10},
|
||||
{"kSndobPause", 11},
|
||||
{"kSndobUnpause", 12},
|
||||
{"kSndobLoad", 13},
|
||||
{"kSndobUnload", 14},
|
||||
{"kSndobCache", 15},
|
||||
{"kSndobUncache", 16},
|
||||
{"kSndobCancelNote", 19},
|
||||
{"kPlayPiano", 43},
|
||||
{"kSetMusicMode", 36},
|
||||
{"kLive", 0},
|
||||
{"kBuy", 1},
|
||||
{"kBuild", 2},
|
||||
{"kHood", 3},
|
||||
{"kFrontEnd", 4},
|
||||
{"kGroupSfx", 1},
|
||||
{"kGroupMusic", 2},
|
||||
{"kGroupVox", 3},
|
||||
{"kAction", 1000},
|
||||
{"kComedy", 1001},
|
||||
{"kRomance", 1002},
|
||||
{"kNews", 1003},
|
||||
{"kCountry", 1004},
|
||||
{"kRock", 1005},
|
||||
{"kJazz", 1006},
|
||||
{"kClassical", 1007},
|
||||
{"kArgsNormal", 0},
|
||||
{"kArgsVolPan", 1},
|
||||
{"kArgsIdVolPan", 2},
|
||||
{"kArgsXYZ", 3},
|
||||
{"kKillAll", 20},
|
||||
{"kPause", 21},
|
||||
{"kUnpause", 22},
|
||||
{"kKillInstance", 23},
|
||||
{"kTurnOnTv", 30},
|
||||
{"kTurnOffTv", 31},
|
||||
{"kUpdateSourceVolPan", 32},
|
||||
};
|
||||
|
||||
static const char SHStringTable[] =
|
||||
"\0.text"
|
||||
"\0.shstrtab"
|
||||
"\0.symtab"
|
||||
"\0.strtab"
|
||||
"\0.rel.text"
|
||||
;
|
||||
|
||||
static const uint8_t SymbolTableHeader[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0xF1, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00
|
||||
};
|
|
@ -19,8 +19,8 @@
|
|||
#include <stdio.h>
|
||||
#include <iff/iff.h>
|
||||
#include <bmp/read_bmp.h>
|
||||
#include <setjmp.h>
|
||||
#include <png.h>
|
||||
#include <setjmp.h> /* Used for libpng */
|
||||
#include "opngreduc.h"
|
||||
|
||||
int WritePNG(const char * OutName, const IFFChunk * ChunkData, int ZBuffer,
|
||||
|
|
|
@ -26,8 +26,9 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <limits.h>
|
||||
|
||||
#ifndef read_int32
|
||||
#define read_uint32(x) (unsigned)(((x)[0]<<(8*0)) | ((x)[1]<<(8*1)) | ((x)[2]<<(8*2)) | ((x)[3]<<(8*3)))
|
||||
|
@ -408,7 +409,7 @@ int main(int argc, char *argv[]){
|
|||
Shutdown_M("Unexpectedly reached end of binary");
|
||||
|
||||
DLL.lookat(DLL.rdata);
|
||||
COL.VTableAddress = (DLL.find32(COLAddress)) ? DLL.brc.position + ImageBase + 4: (uint32_t)-1;
|
||||
COL.VTableAddress = (DLL.find32(COLAddress)) ? DLL.brc.position + ImageBase + 4 : (uint32_t)-1;
|
||||
|
||||
if(newclass){
|
||||
if(!DLL.seek(COL.Fields.ClassDescriptorAddress - ImageBase))
|
||||
|
@ -517,7 +518,7 @@ int main(int argc, char *argv[]){
|
|||
printf(";");
|
||||
}
|
||||
|
||||
printf("\n\nCompleted RTTI report.\nDependencies provided for %u of %u classes.\n", RCL.Count, TotalClassCount);
|
||||
printf("\n\nCompleted RTTI report.\nDependencies provided for %u of %u classes.\n", (unsigned)RCL.Count, TotalClassCount);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Reference in a new issue