feat(profile): update 3.3.5a profile

This commit is contained in:
phaneron 2024-11-27 01:59:15 -05:00
parent 9053d61b6b
commit e1bab2b375
186 changed files with 1204 additions and 43942 deletions

View file

@ -0,0 +1,31 @@
#ifndef ASYNC_OBJECT_H
#define ASYNC_OBJECT_H
#include "storm/list.h"
DECLARE_STRUCT(CAsyncObject);
STORM_TS_LIST(CAsyncObject);
#include "system/types.h"
#include "async/queue.h"
struct CAsyncObject {
void* file;
void* buffer;
uint32_t size;
void* userArg;
void* userPostloadCallback;
void* userPostUnloadCallback;
CAsyncQueue* queue;
void* ptr1c;
int8_t priority;
int8_t isProcessed;
int8_t isRead;
int8_t isCurrent;
int8_t char24;
int8_t char25;
uint16_t padding;
TSLink_CAsyncObject link;
};
#endif

View file

@ -0,0 +1,19 @@
#ifndef ASYNC_QUEUE_H
#define ASYNC_QUEUE_H
DECLARE_STRUCT(CAsyncQueue);
STORM_TS_LIST(CAsyncQueue);
#include "system/types.h"
#include "storm/list.h"
#include "async/object.h"
struct CAsyncQueue {
TSLink_CAsyncQueue link;
TSExplicitList_CAsyncObject readList;
TSExplicitList_CAsyncObject unkList;
int32_t int20;
};
#endif

View file

@ -0,0 +1,31 @@
#ifndef CAMERA_CAMERA_H
#define CAMERA_CAMERA_H
DECLARE_STRUCT(CAngle);
DECLARE_STRUCT(CCamera);
#include "common/datamanager.h"
typedef HDATAMGR HCAMERA;
// class CAngle : public TManaged<float>
struct CAngle {
TManaged_float b_base;
float m_cos;
float m_sin;
};
// class CCamera : public CDataMgr
struct CCamera {
TManaged_C3Vector m_position;
TManaged_C3Vector m_target;
TManaged_float m_distance;
TManaged_float m_zFar;
TManaged_float m_zNear;
CAngle m_aoa;
CAngle m_fov;
CAngle m_roll;
CAngle m_rotation;
};
#endif

View file

@ -0,0 +1,26 @@
#ifndef CMD_OPTION_H
#define CMD_OPTION_H
DECLARE_ENUM(CMDOPT);
enum CMDOPT {
CMD_D3D = 0,
CMD_D3D9EX = 1,
CMD_DATA_DIR = 2,
CMD_NO_LAG_FIX = 3,
CMD_LOADFILE = 4,
CMD_GAMETYPE = 5,
CMD_OPENGL = 6,
CMD_SW_TNL = 7,
CMD_TIMEDEMO = 8,
CMD_DEMOREZ = 9,
CMD_DEMODEPTH = 10,
CMD_DEMODETAIL = 11,
CMD_DEMOSOUND = 12,
CMD_FULL_SCREEN = 13,
CMD_22050HZ = 14,
CMD_NO_WARNINGS = 15,
CMDOPTS = 16
};
#endif

View file

@ -0,0 +1,24 @@
#ifndef COMMON_ARRAY_H
#define COMMON_ARRAY_H
#include "storm/array.h"
#define COMMON_SIMPLE_SORTED_ARRAY(T) STORM_TS_GROWABLE_ARRAY(T); \
typedef struct CSimpleSortedArray_##T CSimpleSortedArray_##T; \
struct CSimpleSortedArray_##T { \
TSGrowableArray_##T m_array; \
uint32_t m_count; \
uint32_t m_maxcount; \
uint32_t m_iterator; \
};
#define COMMON_SIMPLE_SORTED_ARRAY_POINTER_TO(T) STORM_TS_GROWABLE_ARRAY_POINTER_TO(T); \
typedef struct CSimpleSortedArray_pointer_to_##T CSimpleSortedArray_pointer_to_##T; \
struct CSimpleSortedArray_pointer_to_##T { \
TSGrowableArray_pointer_to_##T m_array; \
uint32_t m_count; \
uint32_t m_maxcount; \
uint32_t m_iterator; \
};
#endif

View file

@ -0,0 +1,63 @@
#ifndef COMMON_DATA_MANAGER_H
#define COMMON_DATA_MANAGER_H
DECLARE_STRUCT(CBaseManaged);
DECLARE_STRUCT(CDataMgr);
DECLARE_ENUM(CBaseManaged__ManagedTypeIds);
DECLARE_ENUM(CBaseManaged__ManagedFlags);
#include "system/types.h"
#include "common/handle.h"
#include "storm/array.h"
#include "storm/list.h"
#include "tempest/vector.h"
typedef HOBJECT HDATAMGR;
STORM_TS_FIXED_ARRAY_POINTER_TO(CBaseManaged);
STORM_TS_LIST(CBaseManaged);
enum CBaseManaged__ManagedTypeIds {
// TODO
COORD = 3,
FLOAT = 6,
DATATYPEIDS = 7
};
enum CBaseManaged__ManagedFlags {
ALWAYSUPDATE = 0x1,
READONLY = 0x2,
REQUIRESUPDATE = 0x4,
UPDATED = 0x8,
};
struct CBaseManaged {
void* v_vtable;
TSLink_CBaseManaged m_link;
uint8_t m_dataTypeId;
uint8_t m_flags;
void (*m_updateFcn)(float, void*, void*);
void* m_updateData;
float m_updatePriority;
};
// class CDataMgr : public CHandleObject
struct CDataMgr {
CHandleObject b_base;
TSFixedArray_pointer_to_CBaseManaged m_managedArray;
TSExplicitList_CBaseManaged m_updateList;
};
// class TManaged<T> : public CBaseManaged
#define COMMON_T_MANAGED(T) \
typedef struct TManaged_##T TManaged_##T; \
struct TManaged_##T { \
CBaseManaged b_base; \
T m_data; \
};
// declare types
COMMON_T_MANAGED(float);
COMMON_T_MANAGED(C3Vector);
#endif

View file

@ -0,0 +1,39 @@
#ifndef COMMON_DATA_RECYCLER_H
#define COMMON_DATA_RECYCLER_H
#include "system/types.h"
DECLARE_STRUCT(CDataRecycler);
DECLARE_STRUCT(CDataRecycler__vtable);
DECLARE_STRUCT(CDataRecycler__NodeBlock);
DECLARE_STRUCT(CDataRecycler__Node);
struct CDataRecycler__vtable {
void* v_fn_00;
void* v_fn_01;
void* v_fn_02;
void* v_fn_03;
void* v_fn_04;
};
struct CDataRecycler__Node {
CDataRecycler__Node* m_next;
void* m_data;
uint32_t m_bytes;
};
struct CDataRecycler__NodeBlock {
CDataRecycler__NodeBlock* m_next;
CDataRecycler__Node m_nodes[1];
};
struct CDataRecycler {
CDataRecycler__vtable* v_vtable;
int32_t m_nodesRecyclable;
uint32_t m_nodesPerBlock;
CDataRecycler__NodeBlock* m_nodeBlockList;
CDataRecycler__Node* m_nodeFullList;
CDataRecycler__Node* m_nodeEmptyList;
};
#endif

View file

@ -0,0 +1,21 @@
#ifndef COMMON_HANDLE_H
#define COMMON_HANDLE_H
#include "system/types.h"
#if !defined(DECLARE_HANDLE)
#define DECLARE_HANDLE(name) \
typedef struct name##__ { \
int32_t unused; \
}* name
#endif
DECLARE_STRUCT(CHandleObject);
struct CHandleObject {
int32_t m_refcount;
};
DECLARE_HANDLE(HOBJECT);
#endif

View file

@ -0,0 +1,43 @@
#ifndef COMMON_INSTANCE_H
#define COMMON_INSTANCE_H
#include "system/types.h"
#include "storm/list.h"
#include "storm/thread.h"
// TSList<T>
// TSLinkedNode<T>
// TInstanceId<T>
// TSingletonInstanceId<T>
#define COMMON_INSTANCE_ID(T) \
STORM_TS_LIST(T); \
typedef struct TInstanceId_##T TInstanceId_##T; \
typedef struct TSingletonInstanceId_##T TSingletonInstanceId_##T; \
struct TInstanceId_##T { \
TSLinkedNode_##T b_base; \
uint32_t m_id; \
}; \
struct TSingletonInstanceId_##T { \
TInstanceId_##T b_base; \
};
#define COMMON_INSTANCE_ID_TABLE(T) \
STORM_TS_LIST(T); \
typedef struct TInstanceIdTable_##T TInstanceIdTable_##T; \
struct TInstanceIdTable_##T { \
SCritSect m_idCritSect; \
uint32_t m_id; \
int32_t m_idWrapped; \
CSRWLock m_idLock[8]; \
TSList_##T m_idList[8]; \
};
// template <class T>
// class TExtraInstanceRecyclable
typedef struct TExtraInstanceRecyclable TExtraInstanceRecyclable;
struct TExtraInstanceRecyclable {
uint32_t m_recycleBytes;
};
#endif

View file

@ -0,0 +1,14 @@
#ifndef COMMON_RC_STRING_H
#define COMMON_RC_STRING_H
#include "common/refcount.h"
DECLARE_STRUCT(RCString);
// struct RCString : TRefCnt
struct RCString {
TRefCnt b_base;
uint8_t* m_str;
};
#endif

View file

@ -0,0 +1,11 @@
#ifndef COMMON_REF_COUNT_H
#define COMMON_REF_COUNT_H
DECLARE_STRUCT(TRefCnt);
struct TRefCnt {
void* vfptr;
uint32_t m_refcnt;
};
#endif

View file

@ -0,0 +1,36 @@
#ifndef COMMON_STATUS_H
#define COMMON_STATUS_H
#include "storm/list.h"
DECLARE_ENUM(STATUS_TYPE);
DECLARE_STRUCT(CStatus);
DECLARE_STRUCT(CStatus__STATUSENTRY);
enum STATUS_TYPE {
STATUS_INFO = 0x0,
STATUS_WARNING = 0x1,
STATUS_ERROR = 0x2,
STATUS_FATAL = 0x3,
STATUS_NUMTYPES = 0x4
};
STORM_TS_LIST(CStatus__STATUSENTRY);
struct CStatus__STATUSENTRY {
char* text;
STATUS_TYPE severity;
TSLink_CStatus__STATUSENTRY link;
};
struct CStatus {
TSExplicitList_CStatus__STATUSENTRY statusList;
};
// class CWOWClientStatus : public CStatus {
// public:
// HSLOG m_logFile = nullptr;
// };
#endif

View file

@ -0,0 +1,72 @@
#ifndef CURSOR_TYPES_H
#define CURSOR_TYPES_H
DECLARE_ENUM(CURSORITEMTYPE);
DECLARE_ENUM(CURSORMODE);
enum CURSORITEMTYPE {
CURSOR_EMPTY = 0,
CURSOR_ITEM = 1,
CURSOR_MONEY = 2,
CURSOR_SPELL = 3,
NUM_CURSOR_ITEM_TYPES = 4
};
enum CURSORMODE {
NO_CURSOR = 0,
POINT_CURSOR = 1,
CAST_CURSOR = 2,
BUY_CURSOR = 3,
ATTACK_CURSOR = 4,
INTERACT_CURSOR = 5,
SPEAK_CURSOR = 6,
INSPECT_CURSOR = 7,
PICKUP_CURSOR = 8,
TAXI_CURSOR = 9,
TRAINER_CURSOR = 10,
MINE_CURSOR = 11,
SKIN_CURSOR = 12,
GATHER_CURSOR = 13,
LOCK_CURSOR = 14,
MAIL_CURSOR = 15,
LOOT_ALL_CURSOR = 16,
REPAIR_CURSOR = 17,
REPAIRNPC_CURSOR = 18,
ITEM_CURSOR = 19,
SKIN_HORDE_CURSOR = 20,
SKIN_ALLIANCE_CURSOR = 21,
INNKEEPER_CURSOR = 22,
QUEST_CURSOR = 23,
QUEST_REPEATABLE_CURSOR = 24,
QUEST_TURNIN_CURSOR = 25,
VEHICLE_CURSOR = 26,
POINT_ERROR_CURSOR = 27,
CAST_ERROR_CURSOR = 28,
BUY_ERROR_CURSOR = 29,
ATTACK_ERROR_CURSOR = 30,
INTERACT_ERROR_CURSOR = 31,
SPEAK_ERROR_CURSOR = 32,
INSPECT_ERROR_CURSOR = 33,
PICKUP_ERROR_CURSOR = 34,
TAXI_ERROR_CURSOR = 35,
TRAINER_ERROR_CURSOR = 36,
MINE_ERROR_CURSOR = 37,
SKIN_ERROR_CURSOR = 38,
GATHER_ERROR_CURSOR = 39,
LOCK_ERROR_CURSOR = 40,
MAIL_ERROR_CURSOR = 41,
LOOT_ALL_ERROR_CURSOR = 42,
REPAIR_ERROR_CURSOR = 43,
REPAIRNPC_ERROR_CURSOR = 44,
ITEM_ERROR_CURSOR = 45,
SKIN_HORDE_ERROR_CURSOR = 46,
SKIN_ALLIANCE_ERROR_CURSOR = 47,
INNKEEPER_ERROR_CURSOR = 48,
QUEST_ERROR_CURSOR = 49,
QUEST_REPEATABLE_ERROR_CURSOR = 50,
QUEST_TURNIN_ERROR_CURSOR = 51,
VEHICLE_ERROR_CURSOR = 52,
NUM_CURSOR_MODES = 53
};
#endif

View file

@ -0,0 +1,66 @@
#ifndef EVENT_CONTEXT_H
#define EVENT_CONTEXT_H
#include "storm/thread.h"
#include "common/instance.h"
#include "storm/queue/timer_priority_uint32_t.h"
#include "event/message.h"
#include "event/handler.h"
#include "event/keydown.h"
#include "event/types.h"
#include "event/timer.h"
#include "event/id_table.h"
DECLARE_ENUM(SCHEDSTATE);
DECLARE_STRUCT(EvtContext);
DECLARE_STRUCT(EvtTimer);
DECLARE_HANDLE(HPROPCONTEXT);
// EvtContext::SCHEDSTATE
enum SCHEDSTATE {
SCHEDSTATE_ACTIVE = 0x0,
SCHEDSTATE_CLOSED = 0x1,
SCHEDSTATE_DESTROYED = 0x2,
_UNIQUE_SYMBOL_SCHEDSTATE_96 = 0xFFFFFFFF
};
COMMON_INSTANCE_ID(EvtContext);
// class EvtContext : public TSingletonInstanceId<EvtContext, offsetof(TInstanceId<EvtContext>, m_id)>
struct EvtContext {
TSingletonInstanceId_EvtContext b_base;
uint32_t unkA;
// Member variables
SCritSect m_critsect;
uint32_t m_currTime;
SCHEDSTATE m_schedState;
TSTimerPriority_uint32_t m_schedNextWakeTime;
uint32_t m_schedLastIdle;
uint32_t m_schedFlags;
uint32_t m_schedIdleTime;
uint32_t m_schedInitialIdleTime;
uint32_t m_schedWeight;
uint32_t m_schedSmoothWeight;
int32_t m_schedRebalance;
int32_t unkXX;
int32_t unkXY;
int32_t unkXZ;
int32_t unkYY;
int32_t unkYZ;
// TSExplicitList<EvtHandler, offsetof(EvtHandler, link)> m_queueHandlerList[EVENTIDS];
TSExplicitList_EvtHandler m_queueHandlerList[36];
// TSExplicitList<EvtMessage, offsetof(EvtMessage, link)> m_queueMessageList;
TSExplicitList_EvtMessage m_queueMessageList;
uint32_t m_queueSyncButtonState;
// TSExplicitList<EvtKeyDown, offsetof(EvtKeyDown, link)> m_queueSyncKeyDownList;
TSExplicitList_EvtKeyDown m_queueSyncKeyDownList;
EvtIdTable_pointer_to_EvtTimer m_timerIdTable;
EvtTimerQueue m_timerQueue;
HPROPCONTEXT m_propContext;
void* m_callContext;
uint32_t m_startWatchdog;
};
#endif

View file

@ -0,0 +1,20 @@
#ifndef EVENT_HANDLER_H
#define EVENT_HANDLER_H
#include "system/types.h"
#include "storm/list.h"
DECLARE_STRUCT(EvtHandler);
STORM_TS_LIST(EvtHandler);
struct EvtHandler {
TSLink_EvtHandler link;
int32_t (*func)(const void*, void*);
void* param;
float priority;
int32_t marker;
};
#endif

View file

@ -0,0 +1,15 @@
#ifndef EVENT_ID_TABLE_H
#define EVENT_ID_TABLE_H
#include "storm/array.h"
#include "storm/array/uint32_t.h"
#include "event/timer.h"
DECLARE_STRUCT(EvtIdTable_pointer_to_EvtTimer);
struct EvtIdTable_pointer_to_EvtTimer {
TSGrowableArray_pointer_to_EvtTimer m_allocArray;
TSGrowableArray_uint32_t m_freeArray;
};
#endif

View file

@ -0,0 +1,16 @@
#ifndef EVENT_KEY_DOWN_H
#define EVENT_KEY_DOWN_H
#include "storm/list.h"
#include "event/types.h"
typedef struct EvtKeyDown EvtKeyDown;
STORM_TS_LIST(EvtKeyDown);
struct EvtKeyDown {
TSLink_EvtKeyDown link;
KEY key;
};
#endif

View file

@ -0,0 +1,23 @@
#ifndef EVENT_MESSAGE_H
#define EVENT_MESSAGE_H
#include "system/types.h"
#include "common/instance.h"
#include "storm/list.h"
#include "event/types.h"
typedef struct EvtMessage EvtMessage;
STORM_TS_LIST(EvtMessage);
// class EvtMessage : public TExtraInstanceRecyclable<EvtMessage>
struct EvtMessage {
TExtraInstanceRecyclable b_base;
TSLink_EvtMessage link;
EVENTID id;
char data[4];
};
#endif

View file

@ -0,0 +1,32 @@
#ifndef EVENT_TIMER_H
#define EVENT_TIMER_H
#include "system/types.h"
#include "storm/queue/timer_priority_uint32_t.h"
DECLARE_STRUCT(EvtTimer);
DECLARE_STRUCT(EvtTimerQueue);
// class EvtTimer
struct EvtTimer {
// Member variables
uint32_t id;
TSTimerPriority_uint32_t targetTime;
float timeout;
int32_t (*handler)(const void*, void*);
void* param;
int32_t (*guidHandler)(const void*, uint64_t, void*);
uint64_t guidParam;
void* guidParam2;
};
STORM_TS_PRIORITY_QUEUE(EvtTimer);
STORM_TS_GROWABLE_ARRAY_POINTER_TO(EvtTimer);
// class EvtTimerQueue : public TSPriorityQueue<EvtTimer>
struct EvtTimerQueue {
TSPriorityQueue_EvtTimer b_base;
};
#endif

View file

@ -0,0 +1,277 @@
#ifndef EVENT_TYPES_H
#define EVENT_TYPES_H
#include "system/types.h"
DECLARE_ENUM(EVENTID);
DECLARE_ENUM(KEY);
DECLARE_ENUM(MOUSEBUTTON);
DECLARE_ENUM(MOUSEMODE);
DECLARE_ENUM(OSINPUT);
DECLARE_ENUM(OS_MOUSE_MODE);
DECLARE_STRUCT(OSEVENT);
DECLARE_STRUCT(EVENT_DATA_CHAR);
DECLARE_STRUCT(EVENT_DATA_FOCUS);
DECLARE_STRUCT(EVENT_DATA_IDLE);
DECLARE_STRUCT(EVENT_DATA_KEY);
DECLARE_STRUCT(EVENT_DATA_MOUSE);
DECLARE_STRUCT(EVENT_DATA_SIZE);
typedef void* HEVENTCONTEXT;
typedef int32_t (*EVENTHANDLERFUNC)(const void*, void*);
enum EVENTID {
EVENT_ID_0 = 0,
EVENT_ID_CHAR = 1,
EVENT_ID_FOCUS = 2,
EVENT_ID_3 = 3,
EVENT_ID_DESTROY = 4,
EVENT_ID_5 = 5,
EVENT_ID_IDLE = 6,
EVENT_ID_POLL = 7,
EVENT_ID_INITIALIZE = 8,
EVENT_ID_KEYDOWN = 9,
EVENT_ID_KEYUP = 10,
EVENT_ID_KEYDOWN_REPEATING = 11,
EVENT_ID_MOUSEDOWN = 12,
EVENT_ID_MOUSEMOVE = 13,
EVENT_ID_MOUSEMOVE_RELATIVE = 14,
EVENT_ID_MOUSEUP = 15,
EVENT_ID_MOUSEMODE_CHANGED = 16,
EVENT_ID_MOUSEWHEEL = 17,
EVENT_ID_18 = 18,
EVENT_ID_19 = 19,
EVENT_ID_20 = 20,
EVENT_ID_21 = 21,
EVENT_ID_22 = 22,
EVENT_ID_PAINT = 23,
EVENT_ID_NET_DATA = 24,
EVENT_ID_NET_CONNECT = 25,
EVENT_ID_NET_DISCONNECT = 26,
EVENT_ID_NET_CANTCONNECT = 27,
EVENT_ID_NET_DESTROY = 28,
EVENT_ID_NET_AUTH_CHALLENGE = 29,
EVENT_ID_30 = 30,
EVENT_ID_31 = 31,
EVENT_ID_32 = 32,
EVENT_ID_33 = 33,
EVENT_ID_IME = 34,
EVENT_ID_SIZE = 35,
EVENTIDS = 36
};
enum KEY {
KEY_NONE = 0xFFFFFFFF,
KEY_LSHIFT = 0x0,
KEY_RSHIFT = 0x1,
KEY_LCONTROL = 0x2,
KEY_RCONTROL = 0x3,
KEY_LALT = 0x4,
KEY_RALT = 0x5,
KEY_LASTMETAKEY = 0x5,
KEY_SPACE = 0x20,
KEY_0 = 0x30,
KEY_1 = 0x31,
KEY_2 = 0x32,
KEY_3 = 0x33,
KEY_4 = 0x34,
KEY_5 = 0x35,
KEY_6 = 0x36,
KEY_7 = 0x37,
KEY_8 = 0x38,
KEY_9 = 0x39,
KEY_A = 0x41,
KEY_B = 0x42,
KEY_C = 0x43,
KEY_D = 0x44,
KEY_E = 0x45,
KEY_F = 0x46,
KEY_G = 0x47,
KEY_H = 0x48,
KEY_I = 0x49,
KEY_J = 0x4A,
KEY_K = 0x4B,
KEY_L = 0x4C,
KEY_M = 0x4D,
KEY_N = 0x4E,
KEY_O = 0x4F,
KEY_P = 0x50,
KEY_Q = 0x51,
KEY_R = 0x52,
KEY_S = 0x53,
KEY_T = 0x54,
KEY_U = 0x55,
KEY_V = 0x56,
KEY_W = 0x57,
KEY_X = 0x58,
KEY_Y = 0x59,
KEY_Z = 0x5A,
KEY_TILDE = 0x60,
KEY_NUMPAD0 = 0x100,
KEY_NUMPAD1 = 0x101,
KEY_NUMPAD2 = 0x102,
KEY_NUMPAD3 = 0x103,
KEY_NUMPAD4 = 0x104,
KEY_NUMPAD5 = 0x105,
KEY_NUMPAD6 = 0x106,
KEY_NUMPAD7 = 0x107,
KEY_NUMPAD8 = 0x108,
KEY_NUMPAD9 = 0x109,
KEY_NUMPAD_PLUS = 0x10A,
KEY_NUMPAD_MINUS = 0x10B,
KEY_NUMPAD_MULTIPLY = 0x10C,
KEY_NUMPAD_DIVIDE = 0x10D,
KEY_NUMPAD_DECIMAL = 0x10E,
KEY_NUMPAD_EQUALS = 0x30C,
KEY_PLUS = 0x3D,
KEY_MINUS = 0x2D,
KEY_BRACKET_OPEN = 0x5B,
KEY_BRACKET_CLOSE = 0x5D,
KEY_SLASH = 0x2F,
KEY_BACKSLASH = 0x5C,
KEY_SEMICOLON = 0x3B,
KEY_APOSTROPHE = 0x27,
KEY_COMMA = 0x2C,
KEY_PERIOD = 0x2E,
KEY_ESCAPE = 0x200,
KEY_ENTER = 0x201,
KEY_BACKSPACE = 0x202,
KEY_TAB = 0x203,
KEY_LEFT = 0x204,
KEY_UP = 0x205,
KEY_RIGHT = 0x206,
KEY_DOWN = 0x207,
KEY_INSERT = 0x208,
KEY_DELETE = 0x209,
KEY_HOME = 0x20A,
KEY_END = 0x20B,
KEY_PAGEUP = 0x20C,
KEY_PAGEDOWN = 0x20D,
KEY_CAPSLOCK = 0x20E,
KEY_NUMLOCK = 0x20F,
KEY_SCROLLLOCK = 0x210,
KEY_PAUSE = 0x211,
KEY_PRINTSCREEN = 0x212,
KEY_F1 = 0x300,
KEY_F2 = 0x301,
KEY_F3 = 0x302,
KEY_F4 = 0x303,
KEY_F5 = 0x304,
KEY_F6 = 0x305,
KEY_F7 = 0x306,
KEY_F8 = 0x307,
KEY_F9 = 0x308,
KEY_F10 = 0x309,
KEY_F11 = 0x30A,
KEY_F12 = 0x30B,
KEY_F13 = 0x212,
KEY_F14 = 0x30D,
KEY_F15 = 0x30E,
KEY_F16 = 0x30F,
KEY_F17 = 0x310,
KEY_F18 = 0x311,
KEY_F19 = 0x312,
KEY_LAST = 0x313
};
enum MOUSEBUTTON {
MOUSE_BUTTON_NONE = 0x0,
MOUSE_BUTTON_LEFT = 0x1,
MOUSE_BUTTON_MIDDLE = 0x2,
MOUSE_BUTTON_RIGHT = 0x4,
MOUSE_BUTTON_XBUTTON1 = 0x8,
MOUSE_BUTTON_XBUTTON2 = 0x10,
MOUSE_BUTTON_XBUTTON3 = 0x20,
MOUSE_BUTTON_XBUTTON4 = 0x40,
MOUSE_BUTTON_XBUTTON5 = 0x80,
MOUSE_BUTTON_XBUTTON6 = 0x100,
MOUSE_BUTTON_XBUTTON7 = 0x200,
MOUSE_BUTTON_XBUTTON8 = 0x400,
MOUSE_BUTTON_XBUTTON9 = 0x800,
MOUSE_BUTTON_XBUTTON10 = 0x1000,
MOUSE_BUTTON_XBUTTON11 = 0x2000,
MOUSE_BUTTON_XBUTTON12 = 0x4000,
MOUSE_BUTTON_ALL = 0xFFFFFFFF
};
enum MOUSEMODE {
MOUSE_MODE_NORMAL = 0x0,
MOUSE_MODE_RELATIVE = 0x1,
MOUSE_MODES = 0x2
};
enum OSINPUT {
OS_INPUT_CAPTURE_CHANGED = 0,
OS_INPUT_CHAR = 1,
OS_INPUT_STRING = 2,
OS_INPUT_IME = 3,
OS_INPUT_SIZE = 4,
OS_INPUT_CLOSE = 5,
OS_INPUT_FOCUS = 6,
OS_INPUT_KEY_DOWN = 7,
OS_INPUT_KEY_UP = 8,
OS_INPUT_MOUSE_DOWN = 9,
OS_INPUT_MOUSE_MOVE = 10,
OS_INPUT_MOUSE_WHEEL = 11,
OS_INPUT_MOUSE_MOVE_RELATIVE = 12,
OS_INPUT_MOUSE_UP = 13,
OS_INPUT_14 = 14,
OS_INPUT_15 = 15,
OS_INPUT_16 = 16,
OS_INPUT_17 = 17,
OS_INPUT_18 = 18,
OS_INPUT_SHUTDOWN = 19
};
enum OS_MOUSE_MODE {
OS_MOUSE_MODE_NORMAL = 0,
OS_MOUSE_MODE_RELATIVE = 1,
OS_MOUSE_MODES = 2,
};
struct OSEVENT {
OSINPUT id;
int32_t param[4];
};
struct EVENT_DATA_CHAR {
int32_t ch;
uint32_t metaKeyState;
uint32_t repeat;
};
struct EVENT_DATA_FOCUS {
int32_t focus;
};
struct EVENT_DATA_IDLE {
float elapsedSec;
uint32_t time;
};
struct EVENT_DATA_KEY {
KEY key;
uint32_t metaKeyState;
uint32_t repeat;
uint32_t time;
};
struct EVENT_DATA_MOUSE {
MOUSEMODE mode;
MOUSEBUTTON button;
uint32_t buttonState;
uint32_t metaKeyState;
uint32_t flags;
float x;
float y;
int32_t wheelDistance;
uint32_t time;
};
struct EVENT_DATA_SIZE {
int32_t w;
int32_t h;
};
#endif

View file

@ -0,0 +1,125 @@
#ifndef D3D9_CAPS_H
#define D3D9_CAPS_H
#include "system/types.h"
typedef enum D3DDEVTYPE D3DDEVTYPE;
typedef struct D3DVSHADERCAPS2_0 D3DVSHADERCAPS2_0;
typedef struct D3DPSHADERCAPS2_0 D3DPSHADERCAPS2_0;
typedef struct D3DCAPS9 D3DCAPS9;
enum D3DDEVTYPE {
D3DDEVTYPE_HAL = 1,
D3DDEVTYPE_REF = 2,
D3DDEVTYPE_SW = 3,
D3DDEVTYPE_NULLREF = 4,
D3DDEVTYPE_FORCE_uint32_t = 0xffffffff
};
struct D3DVSHADERCAPS2_0 {
uint32_t Caps;
int32_t DynamicFlowControlDepth;
int32_t NumTemps;
int32_t StaticFlowControlDepth;
};
struct D3DPSHADERCAPS2_0 {
uint32_t Caps;
int32_t DynamicFlowControlDepth;
int32_t NumTemps;
int32_t StaticFlowControlDepth;
int32_t NumInstructionSlots;
};
struct D3DCAPS9 {
D3DDEVTYPE DeviceType;
uint32_t AdapterOrdinal;
uint32_t Caps;
uint32_t Caps2;
uint32_t Caps3;
uint32_t PresentationIntervals;
uint32_t CursorCaps;
uint32_t DevCaps;
uint32_t PrimitiveMiscCaps;
uint32_t RasterCaps;
uint32_t ZCmpCaps;
uint32_t SrcBlendCaps;
uint32_t DestBlendCaps;
uint32_t AlphaCmpCaps;
uint32_t ShadeCaps;
uint32_t TextureCaps;
uint32_t TextureFilterCaps;
uint32_t CubeTextureFilterCaps;
uint32_t VolumeTextureFilterCaps;
uint32_t TextureAddressCaps;
uint32_t VolumeTextureAddressCaps;
uint32_t LineCaps;
uint32_t MaxTextureWidth, MaxTextureHeight;
uint32_t MaxVolumeExtent;
uint32_t MaxTextureRepeat;
uint32_t MaxTextureAspectRatio;
uint32_t MaxAnisotropy;
float MaxVertexW;
float GuardBandLeft;
float GuardBandTop;
float GuardBandRight;
float GuardBandBottom;
float ExtentsAdjust;
uint32_t StencilCaps;
uint32_t FVFCaps;
uint32_t TextureOpCaps;
uint32_t MaxTextureBlendStages;
uint32_t MaxSimultaneousTextures;
uint32_t VertexProcessingCaps;
uint32_t MaxActiveLights;
uint32_t MaxUserClipPlanes;
uint32_t MaxVertexBlendMatrices;
uint32_t MaxVertexBlendMatrixIndex;
float MaxPointSize;
uint32_t MaxPrimitiveCount;
uint32_t MaxVertexIndex;
uint32_t MaxStreams;
uint32_t MaxStreamStride;
uint32_t VertexShaderVersion;
uint32_t MaxVertexShaderConst;
uint32_t PixelShaderVersion;
float PixelShader1xMaxValue;
/* DX 9 */
uint32_t DevCaps2;
float MaxNpatchTessellationLevel;
uint32_t Reserved5;
uint32_t MasterAdapterOrdinal;
uint32_t AdapterOrdinalInGroup;
uint32_t NumberOfAdaptersInGroup;
uint32_t DeclTypes;
uint32_t NumSimultaneousRTs;
uint32_t StretchRectFilterCaps;
D3DVSHADERCAPS2_0 VS20Caps;
D3DPSHADERCAPS2_0 PS20Caps;
uint32_t VertexTextureFilterCaps;
uint32_t MaxVShaderInstructionsExecuted;
uint32_t MaxPShaderInstructionsExecuted;
uint32_t MaxVertexShader30InstructionSlots;
uint32_t MaxPixelShader30InstructionSlots;
};
#endif

View file

@ -0,0 +1,237 @@
#ifndef D3D9_DEVICE_H
#define D3D9_DEVICE_H
#include "system/types.h"
#include "external/d3d9/caps.h"
typedef int32_t D3DFORMAT;
DECLARE_STRUCT(D3DDISPLAYMODE);
DECLARE_STRUCT(IDirect3D9);
DECLARE_STRUCT(IDirect3DDevice9);
DECLARE_STRUCT(IDirect3DDevice9_vtable);
DECLARE_STRUCT(IDirect3DVertexDeclaration9);
DECLARE_STRUCT(IDirect3DSurface9__vtable);
DECLARE_STRUCT(IDirect3DSurface9);
DECLARE_STRUCT(IDirect3DIndexBuffer9);
DECLARE_STRUCT(IDirect3DVertexBuffer9);
DECLARE_STRUCT(IDirect3DTexture9);
DECLARE_STRUCT(IDirect3DVertexShader9__vtable);
DECLARE_STRUCT(IDirect3DVertexShader9);
DECLARE_STRUCT(IDirect3DPixelShader9__vtable);
DECLARE_STRUCT(IDirect3DPixelShader9);
DECLARE_STRUCT(D3DLOCKED_RECT);
struct D3DDISPLAYMODE {
uint32_t Width;
uint32_t Height;
uint32_t RefreshRate;
D3DFORMAT Format;
};
struct IDirect3D9 {
void** v_vtable;
};
struct IDirect3DDevice9_vtable {
void* v_fn_0_QueryInterface;
void* v_fn_1_AddRef;
void* v_fn_2_Release;
void* v_fn_3_TestCooperativeLevel;
void* v_fn_4_GetAvailableTextureMem;
void* v_fn_5_EvictManagedResources;
void* v_fn_6_GetDirect3D;
void* v_fn_7_GetDeviceCaps;
void* v_fn_8_GetDisplayMode;
void* v_fn_9_GetCreationParameters;
void* v_fn_10_SetCursorProperties;
void* v_fn_11_SetCursorPosition;
void* v_fn_12_ShowCursor;
void* v_fn_13_CreateAdditionalSwapChain;
void* v_fn_14_GetSwapChain;
void* v_fn_15_GetNumberOfSwapChains;
void* v_fn_16_Reset;
void* v_fn_17_Present;
void* v_fn_18_GetBackBuffer;
void* v_fn_19_GetRasterStatus;
void* v_fn_20_SetDialogBoxMode;
void* v_fn_21_SetGammaRamp;
void* v_fn_22_GetGammaRamp;
void* v_fn_23_CreateTexture;
void* v_fn_24_CreateVolumeTexture;
void* v_fn_25_CreateCubeTexture;
void* v_fn_26_CreateVertexBuffer;
void* v_fn_27_CreateIndexBuffer;
void* v_fn_28_CreateRenderTarget;
void* v_fn_29_CreateDepthStencilSurface;
void* v_fn_30_UpdateSurface;
void* v_fn_31_UpdateTexture;
void* v_fn_32_GetRenderTargetData;
void* v_fn_33_GetFrontBufferData;
void* v_fn_34_StretchRect;
void* v_fn_35_ColorFill;
void* v_fn_36_CreateOffscreenPlainSurface;
void* v_fn_37_SetRenderTarget;
void* v_fn_38_GetRenderTarget;
void* v_fn_39_SetDepthStencilSurface;
void* v_fn_40_GetDepthStencilSurface;
void* v_fn_41_BeginScene;
void* v_fn_42_EndScene;
void* v_fn_43_Clear;
void* v_fn_44_SetTransform;
void* v_fn_45_GetTransform;
void* v_fn_46_MultiplyTransform;
void* v_fn_47_SetViewport;
void* v_fn_48_GetViewport;
void* v_fn_49_SetMaterial;
void* v_fn_50_GetMaterial;
void* v_fn_51_SetLight;
void* v_fn_52_GetLight;
void* v_fn_53_LightEnable;
void* v_fn_54_GetLightEnable;
void* v_fn_55_SetClipPlane;
void* v_fn_56_GetClipPlane;
void* v_fn_57_SetRenderState;
void* v_fn_58_GetRenderState;
void* v_fn_59_CreateStateBlock;
void* v_fn_60_BeginStateBlock;
void* v_fn_61_EndStateBlock;
void* v_fn_62_SetClipStatus;
void* v_fn_63_GetClipStatus;
void* v_fn_64_GetTexture;
void* v_fn_65_SetTexture;
void* v_fn_66_GetTextureStageState;
void* v_fn_67_SetTextureStageState;
void* v_fn_68_GetSamplerState;
void* v_fn_69_SetSamplerState;
void* v_fn_70_ValidateDevice;
void* v_fn_71_SetPaletteEntries;
void* v_fn_72_GetPaletteEntries;
void* v_fn_73_SetCurrentTexturePalette;
void* v_fn_74_GetCurrentTexturePalette;
void* v_fn_75_SetScissorRect;
void* v_fn_76_GetScissorRect;
void* v_fn_77_SetSoftwareVertexProcessing;
void* v_fn_78_GetSoftwareVertexProcessing;
void* v_fn_79_SetNPatchMode;
void* v_fn_80_GetNPatchMode;
void* v_fn_81_DrawPrimitive;
void* v_fn_82_DrawIndexedPrimitive;
void* v_fn_83_DrawPrimitiveUP;
void* v_fn_84_DrawIndexedPrimitiveUP;
void* v_fn_85_ProcessVertices;
void* v_fn_86_CreateVertexDeclaration;
void* v_fn_87_SetVertexDeclaration;
void* v_fn_88_GetVertexDeclaration;
void* v_fn_89_SetFVF;
void* v_fn_90_GetFVF;
void* v_fn_91_CreateVertexShader;
void* v_fn_92_SetVertexShader;
void* v_fn_93_GetVertexShader;
void* v_fn_94_SetVertexShaderConstantF;
void* v_fn_95_GetVertexShaderConstantF;
void* v_fn_96_SetVertexShaderConstantI;
void* v_fn_97_GetVertexShaderConstantI;
void* v_fn_98_SetVertexShaderConstantB;
void* v_fn_99_GetVertexShaderConstantB;
void* v_fn_100_SetStreamSource;
void* v_fn_101_GetStreamSource;
void* v_fn_102_SetStreamSourceFreq;
void* v_fn_103_GetStreamSourceFreq;
void* v_fn_104_SetIndices;
void* v_fn_105_GetIndices;
void* v_fn_106_CreatePixelShader;
void* v_fn_107_SetPixelShader;
void* v_fn_108_GetPixelShader;
void* v_fn_109_SetPixelShaderConstantF;
void* v_fn_110_GetPixelShaderConstantF;
void* v_fn_111_SetPixelShaderConstantI;
void* v_fn_112_GetPixelShaderConstantI;
void* v_fn_113_SetPixelShaderConstantB;
void* v_fn_114_GetPixelShaderConstantB;
void* v_fn_115_DrawRectPatch;
void* v_fn_116_DrawTriPatch;
void* v_fn_117_DeletePatch;
void* v_fn_118_CreateQuery;
};
struct IDirect3DDevice9 {
IDirect3DDevice9_vtable* v_vtable;
};
struct IDirect3DVertexDeclaration9 {
void** v_vtable;
};
struct IDirect3DSurface9__vtable {
/*** IUnknown methods ***/
void* v_fn_0_QueryInterface;
void* v_fn_1_AddRef;
void* v_fn_2_Release;
/*** IDirect3DResource9 methods ***/
void* v_fn_3_GetDevice;
void* v_fn_4_SetPrivateData;
void* v_fn_5_GetPrivateData;
void* v_fn_6_FreePrivateData;
void* v_fn_7_SetPriority;
void* v_fn_8_GetPriority;
void* v_fn_9_PreLoad;
void* v_fn_10_GetType;
/*** IDirect3DSurface9 methods ***/
void* v_fn_11_GetContainer;
void* v_fn_12_GetDesc;
void* v_fn_13_LockRect;
void* v_fn_14_UnlockRect;
void* v_fn_15_GetDC;
void* v_fn_16_ReleaseDC;
};
struct IDirect3DSurface9 {
IDirect3DSurface9__vtable* v_vtable;
};
struct IDirect3DIndexBuffer9 {
void** v_vtable;
};
struct IDirect3DVertexBuffer9 {
void** v_vtable;
};
struct IDirect3DTexture9 {
void** v_vtable;
};
struct D3DLOCKED_RECT {
int32_t Pitch;
void* pBits;
};
struct IDirect3DVertexShader9__vtable {
void* v_fn_0_QueryInterface;
void* v_fn_1_AddRef;
void* v_fn_2_Release;
void* v_fn_3_GetDevice;
void* v_fn_4_GetFunction;
};
struct IDirect3DVertexShader9 {
IDirect3DVertexShader9__vtable* v_vtable;
};
struct IDirect3DPixelShader9__vtable {
void* v_fn_0_QueryInterface;
void* v_fn_1_AddRef;
void* v_fn_2_Release;
void* v_fn_3_GetDevice;
void* v_fn_4_GetFunction;
};
struct IDirect3DPixelShader9 {
IDirect3DPixelShader9__vtable* v_vtable;
};
#endif

View file

@ -0,0 +1,16 @@
/*
** $Id: lapi.h,v 2.2.1.1 2007/12/27 13:02:25 roberto Exp $
** Auxiliary functions from Lua API
** See Copyright Notice in lua.h
*/
#ifndef lapi_h
#define lapi_h
#include "external/lua/lobject.h"
LUAI_FUNC void luaA_pushobject (lua_State *L, const TValue *o);
#endif

View file

@ -0,0 +1,174 @@
/*
** $Id: lauxlib.h,v 1.88.1.1 2007/12/27 13:02:25 roberto Exp $
** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h
*/
#ifndef lauxlib_h
#define lauxlib_h
#include <stddef.h>
#include <stdio.h>
#include "external/lua/lua.h"
#if defined(LUA_COMPAT_GETN)
LUALIB_API int (luaL_getn) (lua_State *L, int t);
LUALIB_API void (luaL_setn) (lua_State *L, int t, int n);
#else
#define luaL_getn(L,i) ((int)lua_objlen(L, i))
#define luaL_setn(L,i,j) ((void)0) /* no op! */
#endif
#if defined(LUA_COMPAT_OPENLIB)
#define luaI_openlib luaL_openlib
#endif
/* extra error code for `luaL_load' */
#define LUA_ERRFILE (LUA_ERRERR+1)
typedef struct luaL_Reg {
const char *name;
lua_CFunction func;
} luaL_Reg;
LUALIB_API void (luaI_openlib) (lua_State *L, const char *libname,
const luaL_Reg *l, int nup);
LUALIB_API void (luaL_register) (lua_State *L, const char *libname,
const luaL_Reg *l);
LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e);
LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e);
LUALIB_API int (luaL_typerror) (lua_State *L, int narg, const char *tname);
LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg);
LUALIB_API const char *(luaL_checklstring) (lua_State *L, int numArg,
size_t *l);
LUALIB_API const char *(luaL_optlstring) (lua_State *L, int numArg,
const char *def, size_t *l);
LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int numArg);
LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int nArg, lua_Number def);
LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg);
LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg,
lua_Integer def);
LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg);
LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t);
LUALIB_API void (luaL_checkany) (lua_State *L, int narg);
LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname);
LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname);
LUALIB_API void (luaL_where) (lua_State *L, int lvl);
LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...);
LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def,
const char *const lst[]);
LUALIB_API int (luaL_ref) (lua_State *L, int t);
LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref);
LUALIB_API int (luaL_loadfile) (lua_State *L, const char *filename);
LUALIB_API int (luaL_loadbuffer) (lua_State *L, const char *buff, size_t sz,
const char *name);
LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s);
LUALIB_API lua_State *(luaL_newstate) (void);
LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p,
const char *r);
LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx,
const char *fname, int szhint);
/*
** ===============================================================
** some useful macros
** ===============================================================
*/
#define luaL_argcheck(L, cond,numarg,extramsg) \
((void)((cond) || luaL_argerror(L, (numarg), (extramsg))))
#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL))
#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL))
#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n)))
#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d)))
#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n)))
#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d)))
#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i)))
#define luaL_dofile(L, fn) \
(luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0))
#define luaL_dostring(L, s) \
(luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0))
#define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n)))
#define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n)))
/*
** {======================================================
** Generic Buffer manipulation
** =======================================================
*/
typedef struct luaL_Buffer {
char *p; /* current position in buffer */
int lvl; /* number of strings in the stack (level) */
lua_State *L;
char buffer[LUAL_BUFFERSIZE];
} luaL_Buffer;
#define luaL_addchar(B,c) \
((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \
(*(B)->p++ = (char)(c)))
/* compatibility only */
#define luaL_putchar(B,c) luaL_addchar(B,c)
#define luaL_addsize(B,n) ((B)->p += (n))
LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B);
LUALIB_API char *(luaL_prepbuffer) (luaL_Buffer *B);
LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l);
LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s);
LUALIB_API void (luaL_addvalue) (luaL_Buffer *B);
LUALIB_API void (luaL_pushresult) (luaL_Buffer *B);
/* }====================================================== */
/* compatibility with ref system */
/* pre-defined references */
#define LUA_NOREF (-2)
#define LUA_REFNIL (-1)
#define lua_ref(L,lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \
(lua_pushstring(L, "unlocked references are obsolete"), lua_error(L), 0))
#define lua_unref(L,ref) luaL_unref(L, LUA_REGISTRYINDEX, (ref))
#define lua_getref(L,ref) lua_rawgeti(L, LUA_REGISTRYINDEX, (ref))
#define luaL_reg luaL_Reg
#endif

View file

@ -0,0 +1,76 @@
/*
** $Id: lcode.h,v 1.48.1.1 2007/12/27 13:02:25 roberto Exp $
** Code generator for Lua
** See Copyright Notice in lua.h
*/
#ifndef lcode_h
#define lcode_h
#include "external/lua/llex.h"
#include "external/lua/lobject.h"
#include "external/lua/lopcodes.h"
#include "external/lua/lparser.h"
/*
** Marks the end of a patch list. It is an invalid value both as an absolute
** address, and as a list link (would link an element to itself).
*/
#define NO_JUMP (-1)
/*
** grep "ORDER OPR" if you change these enums
*/
typedef enum BinOpr {
OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW,
OPR_CONCAT,
OPR_NE, OPR_EQ,
OPR_LT, OPR_LE, OPR_GT, OPR_GE,
OPR_AND, OPR_OR,
OPR_NOBINOPR
} BinOpr;
typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr;
#define getcode(fs,e) ((fs)->f->code[(e)->u.s.info])
#define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx)
#define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET)
LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx);
LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C);
LUAI_FUNC void luaK_fixline (FuncState *fs, int line);
LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n);
LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n);
LUAI_FUNC void luaK_checkstack (FuncState *fs, int n);
LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s);
LUAI_FUNC int luaK_numberK (FuncState *fs, lua_Number r);
LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e);
LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e);
LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e);
LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e);
LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e);
LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key);
LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k);
LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e);
LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e);
LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults);
LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e);
LUAI_FUNC int luaK_jump (FuncState *fs);
LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret);
LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target);
LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list);
LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2);
LUAI_FUNC int luaK_getlabel (FuncState *fs);
LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v);
LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v);
LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, expdesc *v2);
LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore);
#endif

View file

@ -0,0 +1,33 @@
/*
** $Id: ldebug.h,v 2.3.1.1 2007/12/27 13:02:25 roberto Exp $
** Auxiliary functions from Debug Interface module
** See Copyright Notice in lua.h
*/
#ifndef ldebug_h
#define ldebug_h
#include "external/lua/lstate.h"
#define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1)
#define getline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0)
#define resethookcount(L) (L->hookcount = L->basehookcount)
LUAI_FUNC void luaG_typeerror (lua_State *L, const TValue *o,
const char *opname);
LUAI_FUNC void luaG_concaterror (lua_State *L, StkId p1, StkId p2);
LUAI_FUNC void luaG_aritherror (lua_State *L, const TValue *p1,
const TValue *p2);
LUAI_FUNC int luaG_ordererror (lua_State *L, const TValue *p1,
const TValue *p2);
LUAI_FUNC void luaG_runerror (lua_State *L, const char *fmt, ...);
LUAI_FUNC void luaG_errormsg (lua_State *L);
LUAI_FUNC int luaG_checkcode (const Proto *pt);
LUAI_FUNC int luaG_checkopenop (Instruction i);
#endif

View file

@ -0,0 +1,57 @@
/*
** $Id: ldo.h,v 2.7.1.1 2007/12/27 13:02:25 roberto Exp $
** Stack and Call structure of Lua
** See Copyright Notice in lua.h
*/
#ifndef ldo_h
#define ldo_h
#include "external/lua/lobject.h"
#include "external/lua/lstate.h"
#include "external/lua/lzio.h"
#define luaD_checkstack(L,n) \
if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TValue)) \
luaD_growstack(L, n); \
else condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1));
#define incr_top(L) {luaD_checkstack(L,1); L->top++;}
#define savestack(L,p) ((char *)(p) - (char *)L->stack)
#define restorestack(L,n) ((TValue *)((char *)L->stack + (n)))
#define saveci(L,p) ((char *)(p) - (char *)L->base_ci)
#define restoreci(L,n) ((CallInfo *)((char *)L->base_ci + (n)))
/* results from luaD_precall */
#define PCRLUA 0 /* initiated a call to a Lua function */
#define PCRC 1 /* did a call to a C function */
#define PCRYIELD 2 /* C funtion yielded */
/* type of protected functions, to be ran by `runprotected' */
typedef void (*Pfunc) (lua_State *L, void *ud);
LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name);
LUAI_FUNC void luaD_callhook (lua_State *L, int event, int line);
LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults);
LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults);
LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u,
ptrdiff_t oldtop, ptrdiff_t ef);
LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult);
LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize);
LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize);
LUAI_FUNC void luaD_growstack (lua_State *L, int n);
LUAI_FUNC void luaD_throw (lua_State *L, int errcode);
LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop);
#endif

View file

@ -0,0 +1,34 @@
/*
** $Id: lfunc.h,v 2.4.1.1 2007/12/27 13:02:25 roberto Exp $
** Auxiliary functions to manipulate prototypes and closures
** See Copyright Notice in lua.h
*/
#ifndef lfunc_h
#define lfunc_h
#include "external/lua/lobject.h"
#define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \
cast(int, sizeof(TValue)*((n)-1)))
#define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \
cast(int, sizeof(TValue *)*((n)-1)))
LUAI_FUNC Proto *luaF_newproto (lua_State *L);
LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e);
LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e);
LUAI_FUNC UpVal *luaF_newupval (lua_State *L);
LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level);
LUAI_FUNC void luaF_close (lua_State *L, StkId level);
LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f);
LUAI_FUNC void luaF_freeclosure (lua_State *L, Closure *c);
LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv);
LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number,
int pc);
#endif

View file

@ -0,0 +1,110 @@
/*
** $Id: lgc.h,v 2.15.1.1 2007/12/27 13:02:25 roberto Exp $
** Garbage Collector
** See Copyright Notice in lua.h
*/
#ifndef lgc_h
#define lgc_h
#include "external/lua/lobject.h"
/*
** Possible states of the Garbage Collector
*/
#define GCSpause 0
#define GCSpropagate 1
#define GCSsweepstring 2
#define GCSsweep 3
#define GCSfinalize 4
/*
** some userful bit tricks
*/
#define resetbits(x,m) ((x) &= cast(lu_byte, ~(m)))
#define setbits(x,m) ((x) |= (m))
#define testbits(x,m) ((x) & (m))
#define bitmask(b) (1<<(b))
#define bit2mask(b1,b2) (bitmask(b1) | bitmask(b2))
#define l_setbit(x,b) setbits(x, bitmask(b))
#define resetbit(x,b) resetbits(x, bitmask(b))
#define testbit(x,b) testbits(x, bitmask(b))
#define set2bits(x,b1,b2) setbits(x, (bit2mask(b1, b2)))
#define reset2bits(x,b1,b2) resetbits(x, (bit2mask(b1, b2)))
#define test2bits(x,b1,b2) testbits(x, (bit2mask(b1, b2)))
/*
** Layout for bit use in `marked' field:
** bit 0 - object is white (type 0)
** bit 1 - object is white (type 1)
** bit 2 - object is black
** bit 3 - for userdata: has been finalized
** bit 3 - for tables: has weak keys
** bit 4 - for tables: has weak values
** bit 5 - object is fixed (should not be collected)
** bit 6 - object is "super" fixed (only the main thread)
*/
#define WHITE0BIT 0
#define WHITE1BIT 1
#define BLACKBIT 2
#define FINALIZEDBIT 3
#define KEYWEAKBIT 3
#define VALUEWEAKBIT 4
#define FIXEDBIT 5
#define SFIXEDBIT 6
#define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT)
#define iswhite(x) test2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT)
#define isblack(x) testbit((x)->gch.marked, BLACKBIT)
#define isgray(x) (!isblack(x) && !iswhite(x))
#define otherwhite(g) (g->currentwhite ^ WHITEBITS)
#define isdead(g,v) ((v)->gch.marked & otherwhite(g) & WHITEBITS)
#define changewhite(x) ((x)->gch.marked ^= WHITEBITS)
#define gray2black(x) l_setbit((x)->gch.marked, BLACKBIT)
#define valiswhite(x) (iscollectable(x) && iswhite(gcvalue(x)))
#define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS)
#define luaC_checkGC(L) { \
condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); \
if (G(L)->totalbytes >= G(L)->GCthreshold) \
luaC_step(L); }
#define luaC_barrier(L,p,v) { if (valiswhite(v) && isblack(obj2gco(p))) \
luaC_barrierf(L,obj2gco(p),gcvalue(v)); }
#define luaC_barriert(L,t,v) { if (valiswhite(v) && isblack(obj2gco(t))) \
luaC_barrierback(L,t); }
#define luaC_objbarrier(L,p,o) \
{ if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) \
luaC_barrierf(L,obj2gco(p),obj2gco(o)); }
#define luaC_objbarriert(L,t,o) \
{ if (iswhite(obj2gco(o)) && isblack(obj2gco(t))) luaC_barrierback(L,t); }
LUAI_FUNC size_t luaC_separateudata (lua_State *L, int all);
LUAI_FUNC void luaC_callGCTM (lua_State *L);
LUAI_FUNC void luaC_freeall (lua_State *L);
LUAI_FUNC void luaC_step (lua_State *L);
LUAI_FUNC void luaC_fullgc (lua_State *L);
LUAI_FUNC void luaC_link (lua_State *L, GCObject *o, lu_byte tt);
LUAI_FUNC void luaC_linkupval (lua_State *L, UpVal *uv);
LUAI_FUNC void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v);
LUAI_FUNC void luaC_barrierback (lua_State *L, Table *t);
#endif

View file

@ -0,0 +1,81 @@
/*
** $Id: llex.h,v 1.58.1.1 2007/12/27 13:02:25 roberto Exp $
** Lexical Analyzer
** See Copyright Notice in lua.h
*/
#ifndef llex_h
#define llex_h
#include "external/lua/lobject.h"
#include "external/lua/lzio.h"
#define FIRST_RESERVED 257
/* maximum length of a reserved word */
#define TOKEN_LEN (sizeof("function")/sizeof(char))
/*
* WARNING: if you change the order of this enumeration,
* grep "ORDER RESERVED"
*/
enum RESERVED {
/* terminal symbols denoted by reserved words */
TK_AND = FIRST_RESERVED, TK_BREAK,
TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION,
TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT,
TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE,
/* other terminal symbols */
TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_NUMBER,
TK_NAME, TK_STRING, TK_EOS
};
/* number of reserved words */
#define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1))
/* array with token `names' */
LUAI_DATA const char *const luaX_tokens [];
typedef union {
lua_Number r;
TString *ts;
} SemInfo; /* semantics information */
typedef struct Token {
int token;
SemInfo seminfo;
} Token;
typedef struct LexState {
int current; /* current character (charint) */
int linenumber; /* input line counter */
int lastline; /* line of last token `consumed' */
Token t; /* current token */
Token lookahead; /* look ahead token */
struct FuncState *fs; /* `FuncState' is private to the parser */
struct lua_State *L;
ZIO *z; /* input stream */
Mbuffer *buff; /* buffer for tokens */
TString *source; /* current source name */
char decpoint; /* locale decimal point */
} LexState;
LUAI_FUNC void luaX_init (lua_State *L);
LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z,
TString *source);
LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l);
LUAI_FUNC void luaX_next (LexState *ls);
LUAI_FUNC void luaX_lookahead (LexState *ls);
LUAI_FUNC void luaX_lexerror (LexState *ls, const char *msg, int token);
LUAI_FUNC void luaX_syntaxerror (LexState *ls, const char *s);
LUAI_FUNC const char *luaX_token2str (LexState *ls, int token);
#endif

View file

@ -0,0 +1,128 @@
/*
** $Id: llimits.h,v 1.69.1.1 2007/12/27 13:02:25 roberto Exp $
** Limits, basic types, and some other `installation-dependent' definitions
** See Copyright Notice in lua.h
*/
#ifndef llimits_h
#define llimits_h
#include <limits.h>
#include <stddef.h>
#include "external/lua/lua.h"
typedef LUAI_UINT32 lu_int32;
typedef LUAI_UMEM lu_mem;
typedef LUAI_MEM l_mem;
/* chars used as small naturals (so that `char' is reserved for characters) */
typedef unsigned char lu_byte;
#define MAX_SIZET ((size_t)(~(size_t)0)-2)
#define MAX_LUMEM ((lu_mem)(~(lu_mem)0)-2)
#define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */
/*
** conversion of pointer to integer
** this is for hashing only; there is no problem if the integer
** cannot hold the whole pointer value
*/
#define IntPoint(p) ((unsigned int)(lu_mem)(p))
/* type to ensure maximum alignment */
typedef LUAI_USER_ALIGNMENT_T L_Umaxalign;
/* result of a `usual argument conversion' over lua_Number */
typedef LUAI_UACNUMBER l_uacNumber;
/* internal assertions for in-house debugging */
#ifdef lua_assert
#define check_exp(c,e) (lua_assert(c), (e))
#define api_check(l,e) lua_assert(e)
#else
#define lua_assert(c) ((void)0)
#define check_exp(c,e) (e)
#define api_check luai_apicheck
#endif
#ifndef UNUSED
#define UNUSED(x) ((void)(x)) /* to avoid warnings */
#endif
#ifndef cast
#define cast(t, exp) ((t)(exp))
#endif
#define cast_byte(i) cast(lu_byte, (i))
#define cast_num(i) cast(lua_Number, (i))
#define cast_int(i) cast(int, (i))
/*
** type for virtual-machine instructions
** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h)
*/
typedef lu_int32 Instruction;
/* maximum stack for a Lua function */
#define MAXSTACK 250
/* minimum size for the string table (must be power of 2) */
#ifndef MINSTRTABSIZE
#define MINSTRTABSIZE 32
#endif
/* minimum size for string buffer */
#ifndef LUA_MINBUFFER
#define LUA_MINBUFFER 32
#endif
#ifndef lua_lock
#define lua_lock(L) ((void) 0)
#define lua_unlock(L) ((void) 0)
#endif
#ifndef luai_threadyield
#define luai_threadyield(L) {lua_unlock(L); lua_lock(L);}
#endif
/*
** macro to control inclusion of some hard tests on stack reallocation
*/
#ifndef HARDSTACKTESTS
#define condhardstacktests(x) ((void)0)
#else
#define condhardstacktests(x) x
#endif
#endif

View file

@ -0,0 +1,49 @@
/*
** $Id: lmem.h,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $
** Interface to Memory Manager
** See Copyright Notice in lua.h
*/
#ifndef lmem_h
#define lmem_h
#include <stddef.h>
#include "external/lua/llimits.h"
#include "external/lua/lua.h"
#define MEMERRMSG "not enough memory"
#define luaM_reallocv(L,b,on,n,e) \
((cast(size_t, (n)+1) <= MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \
luaM_realloc_(L, (b), (on)*(e), (n)*(e)) : \
luaM_toobig(L))
#define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0)
#define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0)
#define luaM_freearray(L, b, n, t) luaM_reallocv(L, (b), n, 0, sizeof(t))
#define luaM_malloc(L,t) luaM_realloc_(L, NULL, 0, (t))
#define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t)))
#define luaM_newvector(L,n,t) \
cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t)))
#define luaM_growvector(L,v,nelems,size,t,limit,e) \
if ((nelems)+1 > (size)) \
((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e)))
#define luaM_reallocvector(L, v,oldn,n,t) \
((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t))))
LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize,
size_t size);
LUAI_FUNC void *luaM_toobig (lua_State *L);
LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size,
size_t size_elem, int limit,
const char *errormsg);
#endif

View file

@ -0,0 +1,387 @@
/*
** $Id: lobject.h,v 2.20.1.1 2007/12/27 13:02:25 roberto Exp $
** Type definitions for Lua objects
** See Copyright Notice in lua.h
*/
#ifndef lobject_h
#define lobject_h
#if defined(IDA) || defined(BINANA_GENERATOR)
#include "external/lua/shim.h"
#else
#include <stdarg.h>
#endif
#include "external/lua/llimits.h"
#include "external/lua/lua.h"
/* tags for values visible from Lua */
#define LAST_TAG LUA_TTHREAD
#define NUM_TAGS (LAST_TAG+1)
/*
** Extra tags for non-values
*/
#define LUA_TPROTO (LAST_TAG+1)
#define LUA_TUPVAL (LAST_TAG+2)
#define LUA_TDEADKEY (LAST_TAG+3)
/*
** Union of all collectable objects
*/
typedef union GCObject GCObject;
/*
** Common Header for all collectable objects (in macro form, to be
** included in other objects)
*/
#define CommonHeader GCObject *next; lu_byte tt; lu_byte marked
/*
** Common header in struct form
*/
typedef struct GCheader {
CommonHeader;
} GCheader;
/*
** Union of all Lua values
*/
typedef union {
GCObject *gc;
void *p;
lua_Number n;
int b;
} Value;
/*
** Tagged Values
*/
#define TValuefields Value value; int tt
typedef struct lua_TValue {
TValuefields;
} TValue;
/* Macros to test type */
#define ttisnil(o) (ttype(o) == LUA_TNIL)
#define ttisnumber(o) (ttype(o) == LUA_TNUMBER)
#define ttisstring(o) (ttype(o) == LUA_TSTRING)
#define ttistable(o) (ttype(o) == LUA_TTABLE)
#define ttisfunction(o) (ttype(o) == LUA_TFUNCTION)
#define ttisboolean(o) (ttype(o) == LUA_TBOOLEAN)
#define ttisuserdata(o) (ttype(o) == LUA_TUSERDATA)
#define ttisthread(o) (ttype(o) == LUA_TTHREAD)
#define ttislightuserdata(o) (ttype(o) == LUA_TLIGHTUSERDATA)
/* Macros to access values */
#define ttype(o) ((o)->tt)
#define gcvalue(o) check_exp(iscollectable(o), (o)->value.gc)
#define pvalue(o) check_exp(ttislightuserdata(o), (o)->value.p)
#define nvalue(o) check_exp(ttisnumber(o), (o)->value.n)
#define rawtsvalue(o) check_exp(ttisstring(o), &(o)->value.gc->ts)
#define tsvalue(o) (&rawtsvalue(o)->tsv)
#define rawuvalue(o) check_exp(ttisuserdata(o), &(o)->value.gc->u)
#define uvalue(o) (&rawuvalue(o)->uv)
#define clvalue(o) check_exp(ttisfunction(o), &(o)->value.gc->cl)
#define hvalue(o) check_exp(ttistable(o), &(o)->value.gc->h)
#define bvalue(o) check_exp(ttisboolean(o), (o)->value.b)
#define thvalue(o) check_exp(ttisthread(o), &(o)->value.gc->th)
#define l_isfalse(o) (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0))
/*
** for internal debug only
*/
#define checkconsistency(obj) \
lua_assert(!iscollectable(obj) || (ttype(obj) == (obj)->value.gc->gch.tt))
#define checkliveness(g,obj) \
lua_assert(!iscollectable(obj) || \
((ttype(obj) == (obj)->value.gc->gch.tt) && !isdead(g, (obj)->value.gc)))
/* Macros to set values */
#define setnilvalue(obj) ((obj)->tt=LUA_TNIL)
#define setnvalue(obj,x) \
{ TValue *i_o=(obj); i_o->value.n=(x); i_o->tt=LUA_TNUMBER; }
#define setpvalue(obj,x) \
{ TValue *i_o=(obj); i_o->value.p=(x); i_o->tt=LUA_TLIGHTUSERDATA; }
#define setbvalue(obj,x) \
{ TValue *i_o=(obj); i_o->value.b=(x); i_o->tt=LUA_TBOOLEAN; }
#define setsvalue(L,obj,x) \
{ TValue *i_o=(obj); \
i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TSTRING; \
checkliveness(G(L),i_o); }
#define setuvalue(L,obj,x) \
{ TValue *i_o=(obj); \
i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TUSERDATA; \
checkliveness(G(L),i_o); }
#define setthvalue(L,obj,x) \
{ TValue *i_o=(obj); \
i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTHREAD; \
checkliveness(G(L),i_o); }
#define setclvalue(L,obj,x) \
{ TValue *i_o=(obj); \
i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TFUNCTION; \
checkliveness(G(L),i_o); }
#define sethvalue(L,obj,x) \
{ TValue *i_o=(obj); \
i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTABLE; \
checkliveness(G(L),i_o); }
#define setptvalue(L,obj,x) \
{ TValue *i_o=(obj); \
i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TPROTO; \
checkliveness(G(L),i_o); }
#define setobj(L,obj1,obj2) \
{ const TValue *o2=(obj2); TValue *o1=(obj1); \
o1->value = o2->value; o1->tt=o2->tt; \
checkliveness(G(L),o1); }
/*
** different types of sets, according to destination
*/
/* from stack to (same) stack */
#define setobjs2s setobj
/* to stack (not from same stack) */
#define setobj2s setobj
#define setsvalue2s setsvalue
#define sethvalue2s sethvalue
#define setptvalue2s setptvalue
/* from table to same table */
#define setobjt2t setobj
/* to table */
#define setobj2t setobj
/* to new object */
#define setobj2n setobj
#define setsvalue2n setsvalue
#define setttype(obj, tt) (ttype(obj) = (tt))
#define iscollectable(o) (ttype(o) >= LUA_TSTRING)
typedef TValue *StkId; /* index to stack elements */
/*
** String headers for string table
*/
typedef union TString {
L_Umaxalign dummy; /* ensures maximum alignment for strings */
struct {
CommonHeader;
lu_byte reserved;
unsigned int hash;
size_t len;
} tsv;
} TString;
#define getstr(ts) cast(const char *, (ts) + 1)
#define svalue(o) getstr(tsvalue(o))
typedef union Udata {
L_Umaxalign dummy; /* ensures maximum alignment for `local' udata */
struct {
CommonHeader;
struct Table *metatable;
struct Table *env;
size_t len;
} uv;
} Udata;
/*
** Function Prototypes
*/
typedef struct Proto {
CommonHeader;
TValue *k; /* constants used by the function */
Instruction *code;
struct Proto **p; /* functions defined inside the function */
int *lineinfo; /* map from opcodes to source lines */
struct LocVar *locvars; /* information about local variables */
TString **upvalues; /* upvalue names */
TString *source;
int sizeupvalues;
int sizek; /* size of `k' */
int sizecode;
int sizelineinfo;
int sizep; /* size of `p' */
int sizelocvars;
int linedefined;
int lastlinedefined;
GCObject *gclist;
lu_byte nups; /* number of upvalues */
lu_byte numparams;
lu_byte is_vararg;
lu_byte maxstacksize;
} Proto;
/* masks for new-style vararg */
#define VARARG_HASARG 1
#define VARARG_ISVARARG 2
#define VARARG_NEEDSARG 4
typedef struct LocVar {
TString *varname;
int startpc; /* first point where variable is active */
int endpc; /* first point where variable is dead */
} LocVar;
/*
** Upvalues
*/
typedef struct UpVal {
CommonHeader;
TValue *v; /* points to stack or to its own value */
union {
TValue value; /* the value (when closed) */
struct { /* double linked list (when open) */
struct UpVal *prev;
struct UpVal *next;
} l;
} u;
} UpVal;
/*
** Closures
*/
#define ClosureHeader \
CommonHeader; lu_byte isC; lu_byte nupvalues; GCObject *gclist; \
struct Table *env
typedef struct CClosure {
ClosureHeader;
lua_CFunction f;
TValue upvalue[1];
} CClosure;
typedef struct LClosure {
ClosureHeader;
struct Proto *p;
UpVal *upvals[1];
} LClosure;
typedef union Closure {
CClosure c;
LClosure l;
} Closure;
#define iscfunction(o) (ttype(o) == LUA_TFUNCTION && clvalue(o)->c.isC)
#define isLfunction(o) (ttype(o) == LUA_TFUNCTION && !clvalue(o)->c.isC)
/*
** Tables
*/
typedef union TKey {
struct {
TValuefields;
struct Node *next; /* for chaining */
} nk;
TValue tvk;
} TKey;
typedef struct Node {
TValue i_val;
TKey i_key;
} Node;
typedef struct Table {
CommonHeader;
lu_byte flags; /* 1<<p means tagmethod(p) is not present */
lu_byte lsizenode; /* log2 of size of `node' array */
struct Table *metatable;
TValue *array; /* array part */
Node *node;
Node *lastfree; /* any free position is before this position */
GCObject *gclist;
int sizearray; /* size of `array' array */
} Table;
/*
** `module' operation for hashing (size is always a power of 2)
*/
#define lmod(s,size) \
(check_exp((size&(size-1))==0, (cast(int, (s) & ((size)-1)))))
#define twoto(x) (1<<(x))
#define sizenode(t) (twoto((t)->lsizenode))
#define luaO_nilobject (&luaO_nilobject_)
LUAI_DATA const TValue luaO_nilobject_;
#define ceillog2(x) (luaO_log2((x)-1) + 1)
LUAI_FUNC int luaO_log2 (unsigned int x);
LUAI_FUNC int luaO_int2fb (unsigned int x);
LUAI_FUNC int luaO_fb2int (int x);
LUAI_FUNC int luaO_rawequalObj (const TValue *t1, const TValue *t2);
LUAI_FUNC int luaO_str2d (const char *s, lua_Number *result);
LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt,
va_list argp);
LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...);
LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t len);
#endif

View file

@ -0,0 +1,268 @@
/*
** $Id: lopcodes.h,v 1.125.1.1 2007/12/27 13:02:25 roberto Exp $
** Opcodes for Lua virtual machine
** See Copyright Notice in lua.h
*/
#ifndef lopcodes_h
#define lopcodes_h
#include "external/lua/llimits.h"
/*===========================================================================
We assume that instructions are unsigned numbers.
All instructions have an opcode in the first 6 bits.
Instructions can have the following fields:
`A' : 8 bits
`B' : 9 bits
`C' : 9 bits
`Bx' : 18 bits (`B' and `C' together)
`sBx' : signed Bx
A signed argument is represented in excess K; that is, the number
value is the unsigned value minus K. K is exactly the maximum value
for that argument (so that -max is represented by 0, and +max is
represented by 2*max), which is half the maximum for the corresponding
unsigned argument.
===========================================================================*/
enum OpMode {iABC, iABx, iAsBx}; /* basic instruction format */
/*
** size and position of opcode arguments.
*/
#define SIZE_C 9
#define SIZE_B 9
#define SIZE_Bx (SIZE_C + SIZE_B)
#define SIZE_A 8
#define SIZE_OP 6
#define POS_OP 0
#define POS_A (POS_OP + SIZE_OP)
#define POS_C (POS_A + SIZE_A)
#define POS_B (POS_C + SIZE_C)
#define POS_Bx POS_C
/*
** limits for opcode arguments.
** we use (signed) int to manipulate most arguments,
** so they must fit in LUAI_BITSINT-1 bits (-1 for sign)
*/
#if SIZE_Bx < LUAI_BITSINT-1
#define MAXARG_Bx ((1<<SIZE_Bx)-1)
#define MAXARG_sBx (MAXARG_Bx>>1) /* `sBx' is signed */
#else
#define MAXARG_Bx MAX_INT
#define MAXARG_sBx MAX_INT
#endif
#define MAXARG_A ((1<<SIZE_A)-1)
#define MAXARG_B ((1<<SIZE_B)-1)
#define MAXARG_C ((1<<SIZE_C)-1)
/* creates a mask with `n' 1 bits at position `p' */
#define MASK1(n,p) ((~((~(Instruction)0)<<n))<<p)
/* creates a mask with `n' 0 bits at position `p' */
#define MASK0(n,p) (~MASK1(n,p))
/*
** the following macros help to manipulate instructions
*/
#define GET_OPCODE(i) (cast(OpCode, ((i)>>POS_OP) & MASK1(SIZE_OP,0)))
#define SET_OPCODE(i,o) ((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \
((cast(Instruction, o)<<POS_OP)&MASK1(SIZE_OP,POS_OP))))
#define GETARG_A(i) (cast(int, ((i)>>POS_A) & MASK1(SIZE_A,0)))
#define SETARG_A(i,u) ((i) = (((i)&MASK0(SIZE_A,POS_A)) | \
((cast(Instruction, u)<<POS_A)&MASK1(SIZE_A,POS_A))))
#define GETARG_B(i) (cast(int, ((i)>>POS_B) & MASK1(SIZE_B,0)))
#define SETARG_B(i,b) ((i) = (((i)&MASK0(SIZE_B,POS_B)) | \
((cast(Instruction, b)<<POS_B)&MASK1(SIZE_B,POS_B))))
#define GETARG_C(i) (cast(int, ((i)>>POS_C) & MASK1(SIZE_C,0)))
#define SETARG_C(i,b) ((i) = (((i)&MASK0(SIZE_C,POS_C)) | \
((cast(Instruction, b)<<POS_C)&MASK1(SIZE_C,POS_C))))
#define GETARG_Bx(i) (cast(int, ((i)>>POS_Bx) & MASK1(SIZE_Bx,0)))
#define SETARG_Bx(i,b) ((i) = (((i)&MASK0(SIZE_Bx,POS_Bx)) | \
((cast(Instruction, b)<<POS_Bx)&MASK1(SIZE_Bx,POS_Bx))))
#define GETARG_sBx(i) (GETARG_Bx(i)-MAXARG_sBx)
#define SETARG_sBx(i,b) SETARG_Bx((i),cast(unsigned int, (b)+MAXARG_sBx))
#define CREATE_ABC(o,a,b,c) ((cast(Instruction, o)<<POS_OP) \
| (cast(Instruction, a)<<POS_A) \
| (cast(Instruction, b)<<POS_B) \
| (cast(Instruction, c)<<POS_C))
#define CREATE_ABx(o,a,bc) ((cast(Instruction, o)<<POS_OP) \
| (cast(Instruction, a)<<POS_A) \
| (cast(Instruction, bc)<<POS_Bx))
/*
** Macros to operate RK indices
*/
/* this bit 1 means constant (0 means register) */
#define BITRK (1 << (SIZE_B - 1))
/* test whether value is a constant */
#define ISK(x) ((x) & BITRK)
/* gets the index of the constant */
#define INDEXK(r) ((int)(r) & ~BITRK)
#define MAXINDEXRK (BITRK - 1)
/* code a constant index as a RK value */
#define RKASK(x) ((x) | BITRK)
/*
** invalid register that fits in 8 bits
*/
#define NO_REG MAXARG_A
/*
** R(x) - register
** Kst(x) - constant (in constant table)
** RK(x) == if ISK(x) then Kst(INDEXK(x)) else R(x)
*/
/*
** grep "ORDER OP" if you change these enums
*/
typedef enum {
/*----------------------------------------------------------------------
name args description
------------------------------------------------------------------------*/
OP_MOVE,/* A B R(A) := R(B) */
OP_LOADK,/* A Bx R(A) := Kst(Bx) */
OP_LOADBOOL,/* A B C R(A) := (Bool)B; if (C) pc++ */
OP_LOADNIL,/* A B R(A) := ... := R(B) := nil */
OP_GETUPVAL,/* A B R(A) := UpValue[B] */
OP_GETGLOBAL,/* A Bx R(A) := Gbl[Kst(Bx)] */
OP_GETTABLE,/* A B C R(A) := R(B)[RK(C)] */
OP_SETGLOBAL,/* A Bx Gbl[Kst(Bx)] := R(A) */
OP_SETUPVAL,/* A B UpValue[B] := R(A) */
OP_SETTABLE,/* A B C R(A)[RK(B)] := RK(C) */
OP_NEWTABLE,/* A B C R(A) := {} (size = B,C) */
OP_SELF,/* A B C R(A+1) := R(B); R(A) := R(B)[RK(C)] */
OP_ADD,/* A B C R(A) := RK(B) + RK(C) */
OP_SUB,/* A B C R(A) := RK(B) - RK(C) */
OP_MUL,/* A B C R(A) := RK(B) * RK(C) */
OP_DIV,/* A B C R(A) := RK(B) / RK(C) */
OP_MOD,/* A B C R(A) := RK(B) % RK(C) */
OP_POW,/* A B C R(A) := RK(B) ^ RK(C) */
OP_UNM,/* A B R(A) := -R(B) */
OP_NOT,/* A B R(A) := not R(B) */
OP_LEN,/* A B R(A) := length of R(B) */
OP_CONCAT,/* A B C R(A) := R(B).. ... ..R(C) */
OP_JMP,/* sBx pc+=sBx */
OP_EQ,/* A B C if ((RK(B) == RK(C)) ~= A) then pc++ */
OP_LT,/* A B C if ((RK(B) < RK(C)) ~= A) then pc++ */
OP_LE,/* A B C if ((RK(B) <= RK(C)) ~= A) then pc++ */
OP_TEST,/* A C if not (R(A) <=> C) then pc++ */
OP_TESTSET,/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */
OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */
OP_TAILCALL,/* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */
OP_RETURN,/* A B return R(A), ... ,R(A+B-2) (see note) */
OP_FORLOOP,/* A sBx R(A)+=R(A+2);
if R(A) <?= R(A+1) then { pc+=sBx; R(A+3)=R(A) }*/
OP_FORPREP,/* A sBx R(A)-=R(A+2); pc+=sBx */
OP_TFORLOOP,/* A C R(A+3), ... ,R(A+2+C) := R(A)(R(A+1), R(A+2));
if R(A+3) ~= nil then R(A+2)=R(A+3) else pc++ */
OP_SETLIST,/* A B C R(A)[(C-1)*FPF+i] := R(A+i), 1 <= i <= B */
OP_CLOSE,/* A close all variables in the stack up to (>=) R(A)*/
OP_CLOSURE,/* A Bx R(A) := closure(KPROTO[Bx], R(A), ... ,R(A+n)) */
OP_VARARG/* A B R(A), R(A+1), ..., R(A+B-1) = vararg */
} OpCode;
#define NUM_OPCODES (cast(int, OP_VARARG) + 1)
/*===========================================================================
Notes:
(*) In OP_CALL, if (B == 0) then B = top. C is the number of returns - 1,
and can be 0: OP_CALL then sets `top' to last_result+1, so
next open instruction (OP_CALL, OP_RETURN, OP_SETLIST) may use `top'.
(*) In OP_VARARG, if (B == 0) then use actual number of varargs and
set top (like in OP_CALL with C == 0).
(*) In OP_RETURN, if (B == 0) then return up to `top'
(*) In OP_SETLIST, if (B == 0) then B = `top';
if (C == 0) then next `instruction' is real C
(*) For comparisons, A specifies what condition the test should accept
(true or false).
(*) All `skips' (pc++) assume that next instruction is a jump
===========================================================================*/
/*
** masks for instruction properties. The format is:
** bits 0-1: op mode
** bits 2-3: C arg mode
** bits 4-5: B arg mode
** bit 6: instruction set register A
** bit 7: operator is a test
*/
enum OpArgMask {
OpArgN, /* argument is not used */
OpArgU, /* argument is used */
OpArgR, /* argument is a register or a jump offset */
OpArgK /* argument is a constant or register/constant */
};
LUAI_DATA const lu_byte luaP_opmodes[NUM_OPCODES];
#define getOpMode(m) (cast(enum OpMode, luaP_opmodes[m] & 3))
#define getBMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 4) & 3))
#define getCMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 2) & 3))
#define testAMode(m) (luaP_opmodes[m] & (1 << 6))
#define testTMode(m) (luaP_opmodes[m] & (1 << 7))
LUAI_DATA const char *const luaP_opnames[NUM_OPCODES+1]; /* opcode names */
/* number of list items to accumulate before a SETLIST instruction */
#define LFIELDS_PER_FLUSH 50
#endif

View file

@ -0,0 +1,82 @@
/*
** $Id: lparser.h,v 1.57.1.1 2007/12/27 13:02:25 roberto Exp $
** Lua Parser
** See Copyright Notice in lua.h
*/
#ifndef lparser_h
#define lparser_h
#include "external/lua/llimits.h"
#include "external/lua/lobject.h"
#include "external/lua/lzio.h"
/*
** Expression descriptor
*/
typedef enum {
VVOID, /* no value */
VNIL,
VTRUE,
VFALSE,
VK, /* info = index of constant in `k' */
VKNUM, /* nval = numerical value */
VLOCAL, /* info = local register */
VUPVAL, /* info = index of upvalue in `upvalues' */
VGLOBAL, /* info = index of table; aux = index of global name in `k' */
VINDEXED, /* info = table register; aux = index register (or `k') */
VJMP, /* info = instruction pc */
VRELOCABLE, /* info = instruction pc */
VNONRELOC, /* info = result register */
VCALL, /* info = instruction pc */
VVARARG /* info = instruction pc */
} expkind;
typedef struct expdesc {
expkind k;
union {
struct { int info, aux; } s;
lua_Number nval;
} u;
int t; /* patch list of `exit when true' */
int f; /* patch list of `exit when false' */
} expdesc;
typedef struct upvaldesc {
lu_byte k;
lu_byte info;
} upvaldesc;
struct BlockCnt; /* defined in lparser.c */
/* state needed to generate code for a given function */
typedef struct FuncState {
Proto *f; /* current function header */
Table *h; /* table to find (and reuse) elements in `k' */
struct FuncState *prev; /* enclosing function */
struct LexState *ls; /* lexical state */
struct lua_State *L; /* copy of the Lua state */
struct BlockCnt *bl; /* chain of current blocks */
int pc; /* next position to code (equivalent to `ncode') */
int lasttarget; /* `pc' of last `jump target' */
int jpc; /* list of pending jumps to `pc' */
int freereg; /* first free register */
int nk; /* number of elements in `k' */
int np; /* number of elements in `p' */
short nlocvars; /* number of elements in `locvars' */
lu_byte nactvar; /* number of active local variables */
upvaldesc upvalues[LUAI_MAXUPVALUES]; /* upvalues */
unsigned short actvar[LUAI_MAXVARS]; /* declared-variable stack */
} FuncState;
LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff,
const char *name);
#endif

View file

@ -0,0 +1,169 @@
/*
** $Id: lstate.h,v 2.24.1.2 2008/01/03 15:20:39 roberto Exp $
** Global State
** See Copyright Notice in lua.h
*/
#ifndef lstate_h
#define lstate_h
#include "external/lua/lua.h"
#include "external/lua/lobject.h"
#include "external/lua/ltm.h"
#include "external/lua/lzio.h"
struct lua_longjmp; /* defined in ldo.c */
/* table of globals */
#define gt(L) (&L->l_gt)
/* registry */
#define registry(L) (&G(L)->l_registry)
/* extra stack space to handle TM calls and some other extras */
#define EXTRA_STACK 5
#define BASIC_CI_SIZE 8
#define BASIC_STACK_SIZE (2*LUA_MINSTACK)
typedef struct stringtable {
GCObject **hash;
lu_int32 nuse; /* number of elements */
int size;
} stringtable;
/*
** informations about a call
*/
typedef struct CallInfo {
StkId base; /* base for this function */
StkId func; /* function index in the stack */
StkId top; /* top for this function */
const Instruction *savedpc;
int nresults; /* expected number of results from this function */
int tailcalls; /* number of tail calls lost under this entry */
} CallInfo;
#define curr_func(L) (clvalue(L->ci->func))
#define ci_func(ci) (clvalue((ci)->func))
#define f_isLua(ci) (!ci_func(ci)->c.isC)
#define isLua(ci) (ttisfunction((ci)->func) && f_isLua(ci))
/*
** `global state', shared by all threads of this state
*/
typedef struct global_State {
stringtable strt; /* hash table for strings */
lua_Alloc frealloc; /* function to reallocate memory */
void *ud; /* auxiliary data to `frealloc' */
lu_byte currentwhite;
lu_byte gcstate; /* state of garbage collector */
int sweepstrgc; /* position of sweep in `strt' */
GCObject *rootgc; /* list of all collectable objects */
GCObject **sweepgc; /* position of sweep in `rootgc' */
GCObject *gray; /* list of gray objects */
GCObject *grayagain; /* list of objects to be traversed atomically */
GCObject *weak; /* list of weak tables (to be cleared) */
GCObject *tmudata; /* last element of list of userdata to be GC */
Mbuffer buff; /* temporary buffer for string concatentation */
lu_mem GCthreshold;
lu_mem totalbytes; /* number of bytes currently allocated */
lu_mem estimate; /* an estimate of number of bytes actually in use */
lu_mem gcdept; /* how much GC is `behind schedule' */
int gcpause; /* size of pause between successive GCs */
int gcstepmul; /* GC `granularity' */
lua_CFunction panic; /* to be called in unprotected errors */
TValue l_registry;
struct lua_State *mainthread;
UpVal uvhead; /* head of double-linked list of all open upvalues */
struct Table *mt[NUM_TAGS]; /* metatables for basic types */
TString *tmname[TM_N]; /* array with tag-method names */
} global_State;
/*
** `per thread' state
*/
struct lua_State {
CommonHeader;
lu_byte status;
StkId top; /* first free slot in the stack */
StkId base; /* base of current function */
global_State *l_G;
CallInfo *ci; /* call info for current function */
const Instruction *savedpc; /* `savedpc' of current function */
StkId stack_last; /* last free slot in the stack */
StkId stack; /* stack base */
CallInfo *end_ci; /* points after end of ci array*/
CallInfo *base_ci; /* array of CallInfo's */
int stacksize;
int size_ci; /* size of array `base_ci' */
unsigned short nCcalls; /* number of nested C calls */
unsigned short baseCcalls; /* nested C calls when resuming coroutine */
lu_byte hookmask;
lu_byte allowhook;
int basehookcount;
int hookcount;
lua_Hook hook;
TValue l_gt; /* table of globals */
TValue env; /* temporary place for environments */
GCObject *openupval; /* list of open upvalues in this stack */
GCObject *gclist;
struct lua_longjmp *errorJmp; /* current error recover point */
ptrdiff_t errfunc; /* current error handling function (stack index) */
};
#define G(L) (L->l_G)
/*
** Union of all collectable objects
*/
union GCObject {
GCheader gch;
union TString ts;
union Udata u;
union Closure cl;
struct Table h;
struct Proto p;
struct UpVal uv;
struct lua_State th; /* thread */
};
/* macros to convert a GCObject into a specific value */
#define rawgco2ts(o) check_exp((o)->gch.tt == LUA_TSTRING, &((o)->ts))
#define gco2ts(o) (&rawgco2ts(o)->tsv)
#define rawgco2u(o) check_exp((o)->gch.tt == LUA_TUSERDATA, &((o)->u))
#define gco2u(o) (&rawgco2u(o)->uv)
#define gco2cl(o) check_exp((o)->gch.tt == LUA_TFUNCTION, &((o)->cl))
#define gco2h(o) check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h))
#define gco2p(o) check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p))
#define gco2uv(o) check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv))
#define ngcotouv(o) \
check_exp((o) == NULL || (o)->gch.tt == LUA_TUPVAL, &((o)->uv))
#define gco2th(o) check_exp((o)->gch.tt == LUA_TTHREAD, &((o)->th))
/* macro to convert any Lua object into a GCObject */
#define obj2gco(v) (cast(GCObject *, (v)))
LUAI_FUNC lua_State *luaE_newthread (lua_State *L);
LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1);
#endif

View file

@ -0,0 +1,31 @@
/*
** $Id: lstring.h,v 1.43.1.1 2007/12/27 13:02:25 roberto Exp $
** String table (keep all strings handled by Lua)
** See Copyright Notice in lua.h
*/
#ifndef lstring_h
#define lstring_h
#include "external/lua/lgc.h"
#include "external/lua/lobject.h"
#include "external/lua/lstate.h"
#define sizestring(s) (sizeof(union TString)+((s)->len+1)*sizeof(char))
#define sizeudata(u) (sizeof(union Udata)+(u)->len)
#define luaS_new(L, s) (luaS_newlstr(L, s, strlen(s)))
#define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \
(sizeof(s)/sizeof(char))-1))
#define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT)
LUAI_FUNC void luaS_resize (lua_State *L, int newsize);
LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e);
LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
#endif

View file

@ -0,0 +1,40 @@
/*
** $Id: ltable.h,v 2.10.1.1 2007/12/27 13:02:25 roberto Exp $
** Lua tables (hash)
** See Copyright Notice in lua.h
*/
#ifndef ltable_h
#define ltable_h
#include "lobject.h"
#define gnode(t,i) (&(t)->node[i])
#define gkey(n) (&(n)->i_key.nk)
#define gval(n) (&(n)->i_val)
#define gnext(n) ((n)->i_key.nk.next)
#define key2tval(n) (&(n)->i_key.tvk)
LUAI_FUNC const TValue *luaH_getnum (Table *t, int key);
LUAI_FUNC TValue *luaH_setnum (lua_State *L, Table *t, int key);
LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key);
LUAI_FUNC TValue *luaH_setstr (lua_State *L, Table *t, TString *key);
LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key);
LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key);
LUAI_FUNC Table *luaH_new (lua_State *L, int narray, int lnhash);
LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, int nasize);
LUAI_FUNC void luaH_free (lua_State *L, Table *t);
LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key);
LUAI_FUNC int luaH_getn (Table *t);
#if defined(LUA_DEBUG)
LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key);
LUAI_FUNC int luaH_isdummy (Node *n);
#endif
#endif

View file

@ -0,0 +1,54 @@
/*
** $Id: ltm.h,v 2.6.1.1 2007/12/27 13:02:25 roberto Exp $
** Tag methods
** See Copyright Notice in lua.h
*/
#ifndef ltm_h
#define ltm_h
#include "external/lua/lobject.h"
/*
* WARNING: if you change the order of this enumeration,
* grep "ORDER TM"
*/
typedef enum {
TM_INDEX,
TM_NEWINDEX,
TM_GC,
TM_MODE,
TM_EQ, /* last tag method with `fast' access */
TM_ADD,
TM_SUB,
TM_MUL,
TM_DIV,
TM_MOD,
TM_POW,
TM_UNM,
TM_LEN,
TM_LT,
TM_LE,
TM_CONCAT,
TM_CALL,
TM_N /* number of elements in the enum */
} TMS;
#define gfasttm(g,et,e) ((et) == NULL ? NULL : \
((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e]))
#define fasttm(l,et,e) gfasttm(G(l), et, e)
LUAI_DATA const char *const luaT_typenames[];
LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename);
LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o,
TMS event);
LUAI_FUNC void luaT_init (lua_State *L);
#endif

View file

@ -0,0 +1,385 @@
/*
** $Id: lua.h,v 1.218.1.4 2008/01/03 15:41:15 roberto Exp $
** Lua - An Extensible Extension Language
** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
** See Copyright Notice at the end of this file
*/
#ifndef lua_h
#define lua_h
#include "system/types.h"
#include "external/lua/luaconf.h"
#define LUA_VERSION "Lua 5.1"
#define LUA_RELEASE "Lua 5.1.3"
#define LUA_VERSION_NUM 501
#define LUA_COPYRIGHT "Copyright (C) 1994-2008 Lua.org, PUC-Rio"
#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes"
/* mark for precompiled code (`<esc>Lua') */
#define LUA_SIGNATURE "\033Lua"
/* option for multiple returns in `lua_pcall' and `lua_call' */
#define LUA_MULTRET (-1)
/*
** pseudo-indices
*/
#define LUA_REGISTRYINDEX (-10000)
#define LUA_ENVIRONINDEX (-10001)
#define LUA_GLOBALSINDEX (-10002)
#define lua_upvalueindex(i) (LUA_GLOBALSINDEX-(i))
/* thread status; 0 is OK */
#define LUA_YIELD 1
#define LUA_ERRRUN 2
#define LUA_ERRSYNTAX 3
#define LUA_ERRMEM 4
#define LUA_ERRERR 5
typedef struct lua_State lua_State;
typedef int (*lua_CFunction) (lua_State *L);
/*
** functions that read/write blocks when loading/dumping Lua chunks
*/
typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz);
typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud);
/*
** prototype for memory-allocation functions
*/
typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize);
/*
** basic types
*/
#define LUA_TNONE (-1)
#define LUA_TNIL 0
#define LUA_TBOOLEAN 1
#define LUA_TLIGHTUSERDATA 2
#define LUA_TNUMBER 3
#define LUA_TSTRING 4
#define LUA_TTABLE 5
#define LUA_TFUNCTION 6
#define LUA_TUSERDATA 7
#define LUA_TTHREAD 8
/* minimum Lua stack available to a C function */
#define LUA_MINSTACK 20
/*
** generic extra include file
*/
#if defined(LUA_USER_H)
#include LUA_USER_H
#endif
/* type of numbers in Lua */
typedef LUA_NUMBER lua_Number;
/* type for integer functions */
typedef LUA_INTEGER lua_Integer;
/*
** state manipulation
*/
LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud);
LUA_API void (lua_close) (lua_State *L);
LUA_API lua_State *(lua_newthread) (lua_State *L);
LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf);
/*
** basic stack manipulation
*/
LUA_API int (lua_gettop) (lua_State *L);
LUA_API void (lua_settop) (lua_State *L, int idx);
LUA_API void (lua_pushvalue) (lua_State *L, int idx);
LUA_API void (lua_remove) (lua_State *L, int idx);
LUA_API void (lua_insert) (lua_State *L, int idx);
LUA_API void (lua_replace) (lua_State *L, int idx);
LUA_API int (lua_checkstack) (lua_State *L, int sz);
LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n);
/*
** access functions (stack -> C)
*/
LUA_API int (lua_isnumber) (lua_State *L, int idx);
LUA_API int (lua_isstring) (lua_State *L, int idx);
LUA_API int (lua_iscfunction) (lua_State *L, int idx);
LUA_API int (lua_isuserdata) (lua_State *L, int idx);
LUA_API int (lua_type) (lua_State *L, int idx);
LUA_API const char *(lua_typename) (lua_State *L, int tp);
LUA_API int (lua_equal) (lua_State *L, int idx1, int idx2);
LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2);
LUA_API int (lua_lessthan) (lua_State *L, int idx1, int idx2);
LUA_API lua_Number (lua_tonumber) (lua_State *L, int idx);
LUA_API lua_Integer (lua_tointeger) (lua_State *L, int idx);
LUA_API int (lua_toboolean) (lua_State *L, int idx);
LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len);
LUA_API size_t (lua_objlen) (lua_State *L, int idx);
LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx);
LUA_API void *(lua_touserdata) (lua_State *L, int idx);
LUA_API lua_State *(lua_tothread) (lua_State *L, int idx);
LUA_API const void *(lua_topointer) (lua_State *L, int idx);
/*
** push functions (C -> stack)
*/
LUA_API void (lua_pushnil) (lua_State *L);
LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n);
LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n);
LUA_API void (lua_pushlstring) (lua_State *L, const char *s, size_t l);
LUA_API void (lua_pushstring) (lua_State *L, const char *s);
LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt,
va_list argp);
LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...);
LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n);
LUA_API void (lua_pushboolean) (lua_State *L, int b);
LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p);
LUA_API int (lua_pushthread) (lua_State *L);
/*
** get functions (Lua -> stack)
*/
LUA_API void (lua_gettable) (lua_State *L, int idx);
LUA_API void (lua_getfield) (lua_State *L, int idx, const char *k);
LUA_API void (lua_rawget) (lua_State *L, int idx);
LUA_API void (lua_rawgeti) (lua_State *L, int idx, int n);
LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec);
LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz);
LUA_API int (lua_getmetatable) (lua_State *L, int objindex);
LUA_API void (lua_getfenv) (lua_State *L, int idx);
/*
** set functions (stack -> Lua)
*/
LUA_API void (lua_settable) (lua_State *L, int idx);
LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k);
LUA_API void (lua_rawset) (lua_State *L, int idx);
LUA_API void (lua_rawseti) (lua_State *L, int idx, int n);
LUA_API int (lua_setmetatable) (lua_State *L, int objindex);
LUA_API int (lua_setfenv) (lua_State *L, int idx);
/*
** `load' and `call' functions (load and run Lua code)
*/
LUA_API void (lua_call) (lua_State *L, int nargs, int nresults);
LUA_API int (lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc);
LUA_API int (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud);
LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt,
const char *chunkname);
LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data);
/*
** coroutine functions
*/
LUA_API int (lua_yield) (lua_State *L, int nresults);
LUA_API int (lua_resume) (lua_State *L, int narg);
LUA_API int (lua_status) (lua_State *L);
/*
** garbage-collection function and options
*/
#define LUA_GCSTOP 0
#define LUA_GCRESTART 1
#define LUA_GCCOLLECT 2
#define LUA_GCCOUNT 3
#define LUA_GCCOUNTB 4
#define LUA_GCSTEP 5
#define LUA_GCSETPAUSE 6
#define LUA_GCSETSTEPMUL 7
LUA_API int (lua_gc) (lua_State *L, int what, int data);
/*
** miscellaneous functions
*/
LUA_API int (lua_error) (lua_State *L);
LUA_API int (lua_next) (lua_State *L, int idx);
LUA_API void (lua_concat) (lua_State *L, int n);
LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud);
LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);
/*
** ===============================================================
** some useful macros
** ===============================================================
*/
#define lua_pop(L,n) lua_settop(L, -(n)-1)
#define lua_newtable(L) lua_createtable(L, 0, 0)
#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n)))
#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0)
#define lua_strlen(L,i) lua_objlen(L, (i))
#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION)
#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE)
#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA)
#define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL)
#define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN)
#define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD)
#define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE)
#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0)
#define lua_pushliteral(L, s) \
lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1)
#define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, (s))
#define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, (s))
#define lua_tostring(L,i) lua_tolstring(L, (i), NULL)
/*
** compatibility macros and functions
*/
#define lua_open() luaL_newstate()
#define lua_getregistry(L) lua_pushvalue(L, LUA_REGISTRYINDEX)
#define lua_getgccount(L) lua_gc(L, LUA_GCCOUNT, 0)
#define lua_Chunkreader lua_Reader
#define lua_Chunkwriter lua_Writer
/* hack */
LUA_API void lua_setlevel (lua_State *from, lua_State *to);
/*
** {======================================================================
** Debug API
** =======================================================================
*/
/*
** Event codes
*/
#define LUA_HOOKCALL 0
#define LUA_HOOKRET 1
#define LUA_HOOKLINE 2
#define LUA_HOOKCOUNT 3
#define LUA_HOOKTAILRET 4
/*
** Event masks
*/
#define LUA_MASKCALL (1 << LUA_HOOKCALL)
#define LUA_MASKRET (1 << LUA_HOOKRET)
#define LUA_MASKLINE (1 << LUA_HOOKLINE)
#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT)
typedef struct lua_Debug lua_Debug; /* activation record */
/* Functions to be called by the debuger in specific events */
typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);
LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar);
LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar);
LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n);
LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n);
LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n);
LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n);
LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count);
LUA_API lua_Hook lua_gethook (lua_State *L);
LUA_API int lua_gethookmask (lua_State *L);
LUA_API int lua_gethookcount (lua_State *L);
struct lua_Debug {
int event;
const char *name; /* (n) */
const char *namewhat; /* (n) `global', `local', `field', `method' */
const char *what; /* (S) `Lua', `C', `main', `tail' */
const char *source; /* (S) */
int currentline; /* (l) */
int nups; /* (u) number of upvalues */
int linedefined; /* (S) */
int lastlinedefined; /* (S) */
char short_src[LUA_IDSIZE]; /* (S) */
/* private part */
int i_ci; /* active function */
};
/* }====================================================================== */
/******************************************************************************
* Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
******************************************************************************/
#endif

View file

@ -0,0 +1,762 @@
/*
** $Id: luaconf.h,v 1.82.1.6 2008/01/18 17:07:48 roberto Exp $
** Configuration file for Lua
** See Copyright Notice in lua.h
*/
#ifndef lconfig_h
#define lconfig_h
#include "system/limits.h"
#include "system/types.h"
/*
** ==================================================================
** Search for "@@" to find all configurable definitions.
** ===================================================================
*/
/*
@@ LUA_ANSI controls the use of non-ansi features.
** CHANGE it (define it) if you want Lua to avoid the use of any
** non-ansi feature or library.
*/
#if defined(__STRICT_ANSI__)
#define LUA_ANSI
#endif
#if !defined(LUA_ANSI) && defined(_WIN32)
#define LUA_WIN
#endif
#if defined(LUA_USE_LINUX)
#define LUA_USE_POSIX
#define LUA_USE_DLOPEN /* needs an extra library: -ldl */
#define LUA_USE_READLINE /* needs some extra libraries */
#endif
#if defined(LUA_USE_MACOSX)
#define LUA_USE_POSIX
#define LUA_DL_DYLD /* does not need extra library */
#endif
/*
@@ LUA_USE_POSIX includes all functionallity listed as X/Open System
@* Interfaces Extension (XSI).
** CHANGE it (define it) if your system is XSI compatible.
*/
#if defined(LUA_USE_POSIX)
#define LUA_USE_MKSTEMP
#define LUA_USE_ISATTY
#define LUA_USE_POPEN
#define LUA_USE_ULONGJMP
#endif
/*
@@ LUA_PATH and LUA_CPATH are the names of the environment variables that
@* Lua check to set its paths.
@@ LUA_INIT is the name of the environment variable that Lua
@* checks for initialization code.
** CHANGE them if you want different names.
*/
#define LUA_PATH "LUA_PATH"
#define LUA_CPATH "LUA_CPATH"
#define LUA_INIT "LUA_INIT"
/*
@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for
@* Lua libraries.
@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for
@* C libraries.
** CHANGE them if your machine has a non-conventional directory
** hierarchy or if you want to install your libraries in
** non-conventional directories.
*/
#if defined(_WIN32)
/*
** In Windows, any exclamation mark ('!') in the path is replaced by the
** path of the directory of the executable file of the current process.
*/
#define LUA_LDIR "!\\lua\\"
#define LUA_CDIR "!\\"
#define LUA_PATH_DEFAULT \
".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \
LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua"
#define LUA_CPATH_DEFAULT \
".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll"
#else
#define LUA_ROOT "/usr/local/"
#define LUA_LDIR LUA_ROOT "share/lua/5.1/"
#define LUA_CDIR LUA_ROOT "lib/lua/5.1/"
#define LUA_PATH_DEFAULT \
"./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua"
#define LUA_CPATH_DEFAULT \
"./?.so;" LUA_CDIR"?.so;" LUA_CDIR"loadall.so"
#endif
/*
@@ LUA_DIRSEP is the directory separator (for submodules).
** CHANGE it if your machine does not use "/" as the directory separator
** and is not Windows. (On Windows Lua automatically uses "\".)
*/
#if defined(_WIN32)
#define LUA_DIRSEP "\\"
#else
#define LUA_DIRSEP "/"
#endif
/*
@@ LUA_PATHSEP is the character that separates templates in a path.
@@ LUA_PATH_MARK is the string that marks the substitution points in a
@* template.
@@ LUA_EXECDIR in a Windows path is replaced by the executable's
@* directory.
@@ LUA_IGMARK is a mark to ignore all before it when bulding the
@* luaopen_ function name.
** CHANGE them if for some reason your system cannot use those
** characters. (E.g., if one of those characters is a common character
** in file/directory names.) Probably you do not need to change them.
*/
#define LUA_PATHSEP ";"
#define LUA_PATH_MARK "?"
#define LUA_EXECDIR "!"
#define LUA_IGMARK "-"
/*
@@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger.
** CHANGE that if ptrdiff_t is not adequate on your machine. (On most
** machines, ptrdiff_t gives a good choice between int or long.)
*/
#define LUA_INTEGER ptrdiff_t
/*
@@ LUA_API is a mark for all core API functions.
@@ LUALIB_API is a mark for all standard library functions.
** CHANGE them if you need to define those functions in some special way.
** For instance, if you want to create one Windows DLL with the core and
** the libraries, you may want to use the following definition (define
** LUA_BUILD_AS_DLL to get it).
*/
#if defined(LUA_BUILD_AS_DLL)
#if defined(LUA_CORE) || defined(LUA_LIB)
#define LUA_API __declspec(dllexport)
#else
#define LUA_API __declspec(dllimport)
#endif
#else
#define LUA_API extern
#endif
/* more often than not the libs go together with the core */
#define LUALIB_API LUA_API
/*
@@ LUAI_FUNC is a mark for all extern functions that are not to be
@* exported to outside modules.
@@ LUAI_DATA is a mark for all extern (const) variables that are not to
@* be exported to outside modules.
** CHANGE them if you need to mark them in some special way. Elf/gcc
** (versions 3.2 and later) mark them as "hidden" to optimize access
** when Lua is compiled as a shared library.
*/
#if defined(luaall_c)
#define LUAI_FUNC static
#define LUAI_DATA /* empty */
#elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
defined(__ELF__)
#define LUAI_FUNC __attribute__((visibility("hidden"))) extern
#define LUAI_DATA LUAI_FUNC
#else
#define LUAI_FUNC extern
#define LUAI_DATA extern
#endif
/*
@@ LUA_QL describes how error messages quote program elements.
** CHANGE it if you want a different appearance.
*/
#define LUA_QL(x) "'" x "'"
#define LUA_QS LUA_QL("%s")
/*
@@ LUA_IDSIZE gives the maximum size for the description of the source
@* of a function in debug information.
** CHANGE it if you want a different size.
*/
#define LUA_IDSIZE 60
/*
** {==================================================================
** Stand-alone configuration
** ===================================================================
*/
#if defined(lua_c) || defined(luaall_c)
/*
@@ lua_stdin_is_tty detects whether the standard input is a 'tty' (that
@* is, whether we're running lua interactively).
** CHANGE it if you have a better definition for non-POSIX/non-Windows
** systems.
*/
#if defined(LUA_USE_ISATTY)
#include <unistd.h>
#define lua_stdin_is_tty() isatty(0)
#elif defined(LUA_WIN)
#include <io.h>
#include <stdio.h>
#define lua_stdin_is_tty() _isatty(_fileno(stdin))
#else
#define lua_stdin_is_tty() 1 /* assume stdin is a tty */
#endif
/*
@@ LUA_PROMPT is the default prompt used by stand-alone Lua.
@@ LUA_PROMPT2 is the default continuation prompt used by stand-alone Lua.
** CHANGE them if you want different prompts. (You can also change the
** prompts dynamically, assigning to globals _PROMPT/_PROMPT2.)
*/
#define LUA_PROMPT "> "
#define LUA_PROMPT2 ">> "
/*
@@ LUA_PROGNAME is the default name for the stand-alone Lua program.
** CHANGE it if your stand-alone interpreter has a different name and
** your system is not able to detect that name automatically.
*/
#define LUA_PROGNAME "lua"
/*
@@ LUA_MAXINPUT is the maximum length for an input line in the
@* stand-alone interpreter.
** CHANGE it if you need longer lines.
*/
#define LUA_MAXINPUT 512
/*
@@ lua_readline defines how to show a prompt and then read a line from
@* the standard input.
@@ lua_saveline defines how to "save" a read line in a "history".
@@ lua_freeline defines how to free a line read by lua_readline.
** CHANGE them if you want to improve this functionality (e.g., by using
** GNU readline and history facilities).
*/
#if defined(LUA_USE_READLINE)
#include <stdio.h>
#include <readline/readline.h>
#include <readline/history.h>
#define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL)
#define lua_saveline(L,idx) \
if (lua_strlen(L,idx) > 0) /* non-empty line? */ \
add_history(lua_tostring(L, idx)); /* add it to history */
#define lua_freeline(L,b) ((void)L, free(b))
#else
#define lua_readline(L,b,p) \
((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \
fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */
#define lua_saveline(L,idx) { (void)L; (void)idx; }
#define lua_freeline(L,b) { (void)L; (void)b; }
#endif
#endif
/* }================================================================== */
/*
@@ LUAI_GCPAUSE defines the default pause between garbage-collector cycles
@* as a percentage.
** CHANGE it if you want the GC to run faster or slower (higher values
** mean larger pauses which mean slower collection.) You can also change
** this value dynamically.
*/
#define LUAI_GCPAUSE 200 /* 200% (wait memory to double before next GC) */
/*
@@ LUAI_GCMUL defines the default speed of garbage collection relative to
@* memory allocation as a percentage.
** CHANGE it if you want to change the granularity of the garbage
** collection. (Higher values mean coarser collections. 0 represents
** infinity, where each step performs a full collection.) You can also
** change this value dynamically.
*/
#define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */
/*
@@ LUA_COMPAT_GETN controls compatibility with old getn behavior.
** CHANGE it (define it) if you want exact compatibility with the
** behavior of setn/getn in Lua 5.0.
*/
#undef LUA_COMPAT_GETN
/*
@@ LUA_COMPAT_LOADLIB controls compatibility about global loadlib.
** CHANGE it to undefined as soon as you do not need a global 'loadlib'
** function (the function is still available as 'package.loadlib').
*/
#undef LUA_COMPAT_LOADLIB
/*
@@ LUA_COMPAT_VARARG controls compatibility with old vararg feature.
** CHANGE it to undefined as soon as your programs use only '...' to
** access vararg parameters (instead of the old 'arg' table).
*/
#define LUA_COMPAT_VARARG
/*
@@ LUA_COMPAT_MOD controls compatibility with old math.mod function.
** CHANGE it to undefined as soon as your programs use 'math.fmod' or
** the new '%' operator instead of 'math.mod'.
*/
#define LUA_COMPAT_MOD
/*
@@ LUA_COMPAT_LSTR controls compatibility with old long string nesting
@* facility.
** CHANGE it to 2 if you want the old behaviour, or undefine it to turn
** off the advisory error when nesting [[...]].
*/
#define LUA_COMPAT_LSTR 1
/*
@@ LUA_COMPAT_GFIND controls compatibility with old 'string.gfind' name.
** CHANGE it to undefined as soon as you rename 'string.gfind' to
** 'string.gmatch'.
*/
#define LUA_COMPAT_GFIND
/*
@@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib'
@* behavior.
** CHANGE it to undefined as soon as you replace to 'luaL_register'
** your uses of 'luaL_openlib'
*/
#define LUA_COMPAT_OPENLIB
/*
@@ luai_apicheck is the assert macro used by the Lua-C API.
** CHANGE luai_apicheck if you want Lua to perform some checks in the
** parameters it gets from API calls. This may slow down the interpreter
** a bit, but may be quite useful when debugging C code that interfaces
** with Lua. A useful redefinition is to use assert.h.
*/
#if defined(LUA_USE_APICHECK)
#include <assert.h>
#define luai_apicheck(L,o) { (void)L; assert(o); }
#else
#define luai_apicheck(L,o) { (void)L; }
#endif
/*
@@ LUAI_BITSINT defines the number of bits in an int.
** CHANGE here if Lua cannot automatically detect the number of bits of
** your machine. Probably you do not need to change this.
*/
/* avoid overflows in comparison */
#if INT_MAX-20 < 32760
#define LUAI_BITSINT 16
#elif INT_MAX > 2147483640L
/* int has at least 32 bits */
#define LUAI_BITSINT 32
#else
#error "you must define LUA_BITSINT with number of bits in an integer"
#endif
/*
@@ LUAI_UINT32 is an unsigned integer with at least 32 bits.
@@ LUAI_INT32 is an signed integer with at least 32 bits.
@@ LUAI_UMEM is an unsigned integer big enough to count the total
@* memory used by Lua.
@@ LUAI_MEM is a signed integer big enough to count the total memory
@* used by Lua.
** CHANGE here if for some weird reason the default definitions are not
** good enough for your machine. (The definitions in the 'else'
** part always works, but may waste space on machines with 64-bit
** longs.) Probably you do not need to change this.
*/
#if LUAI_BITSINT >= 32
#define LUAI_UINT32 unsigned int
#define LUAI_INT32 int
#define LUAI_MAXINT32 INT_MAX
#define LUAI_UMEM size_t
#define LUAI_MEM ptrdiff_t
#else
/* 16-bit ints */
#define LUAI_UINT32 unsigned long
#define LUAI_INT32 long
#define LUAI_MAXINT32 LONG_MAX
#define LUAI_UMEM unsigned long
#define LUAI_MEM long
#endif
/*
@@ LUAI_MAXCALLS limits the number of nested calls.
** CHANGE it if you need really deep recursive calls. This limit is
** arbitrary; its only purpose is to stop infinite recursion before
** exhausting memory.
*/
#define LUAI_MAXCALLS 20000
/*
@@ LUAI_MAXCSTACK limits the number of Lua stack slots that a C function
@* can use.
** CHANGE it if you need lots of (Lua) stack space for your C
** functions. This limit is arbitrary; its only purpose is to stop C
** functions to consume unlimited stack space.
*/
#define LUAI_MCS_AUX ((int)(INT_MAX / (4*sizeof(LUA_NUMBER))))
#define LUAI_MAXCSTACK (LUAI_MCS_AUX > SHRT_MAX ? SHRT_MAX : LUAI_MCS_AUX)
/*
** {==================================================================
** CHANGE (to smaller values) the following definitions if your system
** has a small C stack. (Or you may want to change them to larger
** values if your system has a large C stack and these limits are
** too rigid for you.) Some of these constants control the size of
** stack-allocated arrays used by the compiler or the interpreter, while
** others limit the maximum number of recursive calls that the compiler
** or the interpreter can perform. Values too large may cause a C stack
** overflow for some forms of deep constructs.
** ===================================================================
*/
/*
@@ LUAI_MAXCCALLS is the maximum depth for nested C calls (short) and
@* syntactical nested non-terminals in a program.
*/
#define LUAI_MAXCCALLS 200
/*
@@ LUAI_MAXVARS is the maximum number of local variables per function
@* (must be smaller than 250).
*/
#define LUAI_MAXVARS 200
/*
@@ LUAI_MAXUPVALUES is the maximum number of upvalues per function
@* (must be smaller than 250).
*/
#define LUAI_MAXUPVALUES 60
/*
@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
*/
#define LUAL_BUFFERSIZE BUFSIZ
/* }================================================================== */
/*
** {==================================================================
@@ LUA_NUMBER is the type of numbers in Lua.
** CHANGE the following definitions only if you want to build Lua
** with a number type different from double. You may also need to
** change lua_number2int & lua_number2integer.
** ===================================================================
*/
#define LUA_NUMBER_DOUBLE
#define LUA_NUMBER double
/*
@@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
@* over a number.
*/
#define LUAI_UACNUMBER double
/*
@@ LUA_NUMBER_SCAN is the format for reading numbers.
@@ LUA_NUMBER_FMT is the format for writing numbers.
@@ lua_number2str converts a number to a string.
@@ LUAI_MAXNUMBER2STR is maximum size of previous conversion.
@@ lua_str2number converts a string to a number.
*/
#define LUA_NUMBER_SCAN "%lf"
#define LUA_NUMBER_FMT "%.14g"
#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
#define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */
#define lua_str2number(s,p) strtod((s), (p))
/*
@@ The luai_num* macros define the primitive operations over numbers.
*/
#if defined(LUA_CORE)
#include <math.h>
#define luai_numadd(a,b) ((a)+(b))
#define luai_numsub(a,b) ((a)-(b))
#define luai_nummul(a,b) ((a)*(b))
#define luai_numdiv(a,b) ((a)/(b))
#define luai_nummod(a,b) ((a) - floor((a)/(b))*(b))
#define luai_numpow(a,b) (pow(a,b))
#define luai_numunm(a) (-(a))
#define luai_numeq(a,b) ((a)==(b))
#define luai_numlt(a,b) ((a)<(b))
#define luai_numle(a,b) ((a)<=(b))
#define luai_numisnan(a) (!luai_numeq((a), (a)))
#endif
/*
@@ lua_number2int is a macro to convert lua_Number to int.
@@ lua_number2integer is a macro to convert lua_Number to lua_Integer.
** CHANGE them if you know a faster way to convert a lua_Number to
** int (with any rounding method and without throwing errors) in your
** system. In Pentium machines, a naive typecast from double to int
** in C is extremely slow, so any alternative is worth trying.
*/
/* On a Pentium, resort to a trick */
#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \
(defined(__i386) || defined (_M_IX86) || defined(__i386__))
/* On a Microsoft compiler, use assembler */
#if defined(_MSC_VER)
#define lua_number2int(i,d) __asm fld d __asm fistp i
#define lua_number2integer(i,n) lua_number2int(i, n)
/* the next trick should work on any Pentium, but sometimes clashes
with a DirectX idiosyncrasy */
#else
union luai_Cast { double l_d; long l_l; };
#define lua_number2int(i,d) \
{ volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; }
#define lua_number2integer(i,n) lua_number2int(i, n)
#endif
/* this option always works, but may be slow */
#else
#define lua_number2int(i,d) ((i)=(int)(d))
#define lua_number2integer(i,d) ((i)=(lua_Integer)(d))
#endif
/* }================================================================== */
/*
@@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment.
** CHANGE it if your system requires alignments larger than double. (For
** instance, if your system supports long doubles and they must be
** aligned in 16-byte boundaries, then you should add long double in the
** union.) Probably you do not need to change this.
*/
#define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; }
/*
@@ LUAI_THROW/LUAI_TRY define how Lua does exception handling.
** CHANGE them if you prefer to use longjmp/setjmp even with C++
** or if want/don't to use _longjmp/_setjmp instead of regular
** longjmp/setjmp. By default, Lua handles errors with exceptions when
** compiling as C++ code, with _longjmp/_setjmp when asked to use them,
** and with longjmp/setjmp otherwise.
*/
#if defined(__cplusplus)
/* C++ exceptions */
#define LUAI_THROW(L,c) throw(c)
#define LUAI_TRY(L,c,a) try { a } catch(...) \
{ if ((c)->status == 0) (c)->status = -1; }
#define luai_jmpbuf int /* dummy variable */
#elif defined(LUA_USE_ULONGJMP)
/* in Unix, try _longjmp/_setjmp (more efficient) */
#define LUAI_THROW(L,c) _longjmp((c)->b, 1)
#define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a }
#define luai_jmpbuf jmp_buf
#else
/* default handling with long jumps */
#define LUAI_THROW(L,c) longjmp((c)->b, 1)
#define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a }
#define luai_jmpbuf jmp_buf
#endif
/*
@@ LUA_MAXCAPTURES is the maximum number of captures that a pattern
@* can do during pattern-matching.
** CHANGE it if you need more captures. This limit is arbitrary.
*/
#define LUA_MAXCAPTURES 32
/*
@@ lua_tmpnam is the function that the OS library uses to create a
@* temporary name.
@@ LUA_TMPNAMBUFSIZE is the maximum size of a name created by lua_tmpnam.
** CHANGE them if you have an alternative to tmpnam (which is considered
** insecure) or if you want the original tmpnam anyway. By default, Lua
** uses tmpnam except when POSIX is available, where it uses mkstemp.
*/
#if defined(loslib_c) || defined(luaall_c)
#if defined(LUA_USE_MKSTEMP)
#include <unistd.h>
#define LUA_TMPNAMBUFSIZE 32
#define lua_tmpnam(b,e) { \
strcpy(b, "/tmp/lua_XXXXXX"); \
e = mkstemp(b); \
if (e != -1) close(e); \
e = (e == -1); }
#else
#define LUA_TMPNAMBUFSIZE L_tmpnam
#define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); }
#endif
#endif
/*
@@ lua_popen spawns a new process connected to the current one through
@* the file streams.
** CHANGE it if you have a way to implement it in your system.
*/
#if defined(LUA_USE_POPEN)
#define lua_popen(L,c,m) ((void)L, fflush(NULL), popen(c,m))
#define lua_pclose(L,file) ((void)L, (pclose(file) != -1))
#elif defined(LUA_WIN)
#define lua_popen(L,c,m) ((void)L, _popen(c,m))
#define lua_pclose(L,file) ((void)L, (_pclose(file) != -1))
#else
#define lua_popen(L,c,m) ((void)((void)c, m), \
luaL_error(L, LUA_QL("popen") " not supported"), (FILE*)0)
#define lua_pclose(L,file) ((void)((void)L, file), 0)
#endif
/*
@@ LUA_DL_* define which dynamic-library system Lua should use.
** CHANGE here if Lua has problems choosing the appropriate
** dynamic-library system for your platform (either Windows' DLL, Mac's
** dyld, or Unix's dlopen). If your system is some kind of Unix, there
** is a good chance that it has dlopen, so LUA_DL_DLOPEN will work for
** it. To use dlopen you also need to adapt the src/Makefile (probably
** adding -ldl to the linker options), so Lua does not select it
** automatically. (When you change the makefile to add -ldl, you must
** also add -DLUA_USE_DLOPEN.)
** If you do not want any kind of dynamic library, undefine all these
** options.
** By default, _WIN32 gets LUA_DL_DLL and MAC OS X gets LUA_DL_DYLD.
*/
#if defined(LUA_USE_DLOPEN)
#define LUA_DL_DLOPEN
#endif
#if defined(LUA_WIN)
#define LUA_DL_DLL
#endif
/*
@@ LUAI_EXTRASPACE allows you to add user-specific data in a lua_State
@* (the data goes just *before* the lua_State pointer).
** CHANGE (define) this if you really need that. This value must be
** a multiple of the maximum alignment required for your machine.
*/
#define LUAI_EXTRASPACE 0
/*
@@ luai_userstate* allow user-specific actions on threads.
** CHANGE them if you defined LUAI_EXTRASPACE and need to do something
** extra when a thread is created/deleted/resumed/yielded.
*/
#define luai_userstateopen(L) ((void)L)
#define luai_userstateclose(L) ((void)L)
#define luai_userstatethread(L,L1) ((void)L)
#define luai_userstatefree(L) ((void)L)
#define luai_userstateresume(L,n) ((void)L)
#define luai_userstateyield(L,n) ((void)L)
/*
@@ LUA_INTFRMLEN is the length modifier for integer conversions
@* in 'string.format'.
@@ LUA_INTFRM_T is the integer type correspoding to the previous length
@* modifier.
** CHANGE them if your system supports long long or does not support long.
*/
#if defined(LUA_USELONGLONG)
#define LUA_INTFRMLEN "ll"
#define LUA_INTFRM_T long long
#else
#define LUA_INTFRMLEN "l"
#define LUA_INTFRM_T long
#endif
/* =================================================================== */
/*
** Local configuration. You can use this space to add your redefinitions
** without modifying the main part of the file.
*/
#endif

View file

@ -0,0 +1,56 @@
/*
** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $
** Lua standard libraries
** See Copyright Notice in lua.h
*/
#ifndef lualib_h
#define lualib_h
#include "external/lua/lua.h"
/* Key to file-handle type */
#define LUA_FILEHANDLE "FILE*"
#define LUA_COLIBNAME "coroutine"
LUALIB_API int (luaopen_base) (lua_State *L);
#define LUA_TABLIBNAME "table"
LUALIB_API int (luaopen_table) (lua_State *L);
#define LUA_IOLIBNAME "io"
LUALIB_API int (luaopen_io) (lua_State *L);
#define LUA_OSLIBNAME "os"
LUALIB_API int (luaopen_os) (lua_State *L);
#define LUA_STRLIBNAME "string"
LUALIB_API int (luaopen_string) (lua_State *L);
#define LUA_MATHLIBNAME "math"
LUALIB_API int (luaopen_math) (lua_State *L);
#define LUA_DBLIBNAME "debug"
LUALIB_API int (luaopen_debug) (lua_State *L);
#define LUA_LOADLIBNAME "package"
LUALIB_API int (luaopen_package) (lua_State *L);
#define LUA_BITLIBNAME "bit"
LUALIB_API int luaopen_bit(lua_State *L);
/* open all previous libraries */
LUALIB_API void (luaL_openlibs) (lua_State *L);
#ifndef lua_assert
#define lua_assert(x) ((void)0)
#endif
#endif

View file

@ -0,0 +1,36 @@
/*
** $Id: lundump.h,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $
** load precompiled Lua chunks
** See Copyright Notice in lua.h
*/
#ifndef lundump_h
#define lundump_h
#include "external/lua/lobject.h"
#include "external/lua/lzio.h"
/* load one chunk; from lundump.c */
LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name);
/* make header; from lundump.c */
LUAI_FUNC void luaU_header (char* h);
/* dump one chunk; from ldump.c */
LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip);
#ifdef luac_c
/* print one chunk; from print.c */
LUAI_FUNC void luaU_print (const Proto* f, int full);
#endif
/* for header of binary files -- this is Lua 5.1 */
#define LUAC_VERSION 0x51
/* for header of binary files -- this is the official format */
#define LUAC_FORMAT 0
/* size of header of binary files */
#define LUAC_HEADERSIZE 12
#endif

View file

@ -0,0 +1,36 @@
/*
** $Id: lvm.h,v 2.5.1.1 2007/12/27 13:02:25 roberto Exp $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
#ifndef lvm_h
#define lvm_h
#include "external/lua/ldo.h"
#include "external/lua/lobject.h"
#include "external/lua/ltm.h"
#define tostring(L,o) ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o)))
#define tonumber(o,n) (ttype(o) == LUA_TNUMBER || \
(((o) = luaV_tonumber(o,n)) != NULL))
#define equalobj(L,o1,o2) \
(ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2))
LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r);
LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2);
LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n);
LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj);
LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key,
StkId val);
LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key,
StkId val);
LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls);
LUAI_FUNC void luaV_concat (lua_State *L, int total, int last);
#endif

View file

@ -0,0 +1,67 @@
/*
** $Id: lzio.h,v 1.21.1.1 2007/12/27 13:02:25 roberto Exp $
** Buffered streams
** See Copyright Notice in lua.h
*/
#ifndef lzio_h
#define lzio_h
#include "external/lua/lua.h"
#include "external/lua/lmem.h"
#define EOZ (-1) /* end of stream */
typedef struct Zio ZIO;
#define char2int(c) cast(int, cast(unsigned char, (c)))
#define zgetc(z) (((z)->n--)>0 ? char2int(*(z)->p++) : luaZ_fill(z))
typedef struct Mbuffer {
char *buffer;
size_t n;
size_t buffsize;
} Mbuffer;
#define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0)
#define luaZ_buffer(buff) ((buff)->buffer)
#define luaZ_sizebuffer(buff) ((buff)->buffsize)
#define luaZ_bufflen(buff) ((buff)->n)
#define luaZ_resetbuffer(buff) ((buff)->n = 0)
#define luaZ_resizebuffer(L, buff, size) \
(luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \
(buff)->buffsize = size)
#define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0)
LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n);
LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader,
void *data);
LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */
LUAI_FUNC int luaZ_lookahead (ZIO *z);
/* --------- Private Part ------------------ */
struct Zio {
size_t n; /* bytes still unread */
const char *p; /* current position in buffer */
lua_Reader reader;
void* data; /* additional data */
lua_State *L; /* Lua state (for reader) */
};
LUAI_FUNC int luaZ_fill (ZIO *z);
#endif

View file

@ -0,0 +1,27 @@
#ifndef FRAMESCRIPT_EVENT_OBJECT_H
#define FRAMESCRIPT_EVENT_OBJECT_H
#include "storm/hash.h"
#include "framescript/object.h"
#include "ui/simpleframe.h"
DECLARE_STRUCT(FrameScript_EventObject);
DECLARE_STRUCT(EVENTLISTENERNODE);
STORM_TS_LIST(EVENTLISTENERNODE);
// struct EVENTLISTENERNODE : TSLinkedNode<EVENTLISTENERNODE> {
struct EVENTLISTENERNODE {
TSLinkedNode_EVENTLISTENERNODE b_base;
FrameScript_Object* listener;
};
STORM_TS_HASH(FrameScript_EventObject, HASHKEY_STRI);
struct FrameScript_EventObject {
TSHashObject_FrameScript_EventObject_HASHKEY_STRI b_base;
};
#endif

View file

@ -0,0 +1,32 @@
#ifndef FRAMESCRIPT_OBJECT_H
#define FRAMESCRIPT_OBJECT_H
#include "system/types.h"
DECLARE_STRUCT(FrameScript_Object);
DECLARE_STRUCT(FrameScript_Object__ScriptIx);
struct FrameScript_Object {
void** v_vtable;
int32_t lua_registered;
int32_t lua_objectRef;
int32_t m_onEvent;
};
// struct FrameScript_Object::ScriptIx
struct FrameScript_Object__ScriptIx {
int32_t luaRef;
int8_t* unk;
};
// struct FrameScript_Object::ScriptData
struct FrameScript_Object__ScriptData {
char* wrapper;
};
// struct FrameScript_Object::ScriptFunction {
struct FrameScript_Object__ScriptFunction {
int32_t luaRef;
};
#endif

View file

@ -0,0 +1,17 @@
#ifndef GX_BATCH_H
#define GX_BATCH_H
#include "gx/types.h"
DECLARE_STRUCT(CGxBatch);
struct CGxBatch {
// Member variables
EGxPrim m_primType;
uint32_t m_start;
uint32_t m_count;
uint16_t m_minIndex;
uint16_t m_maxIndex;
};
#endif

View file

@ -0,0 +1,130 @@
#ifndef GX_BUFFER_H
#define GX_BUFFER_H
#include "system/types.h"
#include "storm/list.h"
#include "tempest/vector.h"
DECLARE_ENUM(EGxPoolHintBits);
DECLARE_ENUM(EGxPoolTarget);
DECLARE_ENUM(EGxPoolUsage);
DECLARE_ENUM(EGxVertexAttrib);
DECLARE_ENUM(EGxVertexBufferFormat);
DECLARE_STRUCT(ubyte4);
DECLARE_STRUCT(CGxVertexAttrib);
DECLARE_STRUCT(CGxVertexPBNT2);
DECLARE_STRUCT(CGxVertexPCT);
DECLARE_STRUCT(CGxPool);
DECLARE_STRUCT(CGxBuf);
enum EGxPoolHintBits {
GxPoolHintBit_Unk0 = 0,
GxPoolHintBit_Unk1 = 1,
GxPoolHintBit_Unk2 = 2,
GxPoolHintBit_Unk3 = 3
};
enum EGxPoolTarget {
GxPoolTarget_Vertex = 0,
GxPoolTarget_Index = 1,
GxPoolTargets_Last = 2
};
enum EGxPoolUsage {
GxPoolUsage_Static = 0,
GxPoolUsage_Dynamic = 1,
GxPoolUsage_Stream = 2,
GxPoolUsages_Last = 3
};
enum EGxVertexAttrib {
GxVA_Position = 0,
GxVA_BlendWeight = 1,
GxVA_BlendIndices = 2,
GxVA_Normal = 3,
GxVA_Color0 = 4,
GxVA_Color1 = 5,
GxVA_TexCoord0 = 6,
GxVA_TexCoord1 = 7,
GxVA_TexCoord2 = 8,
GxVA_TexCoord3 = 9,
GxVA_TexCoord4 = 10,
GxVA_TexCoord5 = 11,
GxVA_TexCoord6 = 12,
GxVA_TexCoord7 = 13,
GxVAs_Last = 14
};
enum EGxVertexBufferFormat {
GxVBF_P = 0,
GxVBF_PN = 1,
GxVBF_PNC = 2,
GxVBF_PNT = 3,
GxVBF_PNCT = 4,
GxVBF_PNT2 = 5,
GxVBF_PNCT2 = 6,
GxVBF_PC = 7,
GxVBF_PCT = 8,
GxVBF_PCT2 = 9,
GxVBF_PT = 10,
GxVBF_PT2 = 11,
GxVBF_PBNT2 = 12,
GxVBF_PNC2T2 = 13,
GxVertexBufferFormats_Last = 14
};
struct CGxVertexAttrib {
EGxVertexAttrib attrib;
uint32_t type;
uint32_t offset;
uint32_t bufSize;
};
struct CGxVertexPBNT2 {
C3Vector p;
ubyte4 bw;
ubyte4 bi;
C3Vector n;
C2Vector tc[2];
};
struct CGxVertexPCT {
C3Vector p;
CImVector c;
C2Vector tc[1];
};
STORM_TS_LIST(CGxBuf);
STORM_TS_LIST(CGxPool);
// class CGxPool : public TSLinkedNode<CGxPool>
struct CGxPool {
TSLinkedNode_CGxPool b_base;
EGxPoolTarget m_target;
EGxPoolUsage m_usage;
int32_t m_size;
void* m_apiSpecific;
void* m_mem;
int32_t unk1C; // TODO
TSList_CGxBuf m_bufList;
EGxPoolHintBits m_hint;
const char* m_name;
};
// class CGxBuf : public TSLinkedNode<CGxBuf>
struct CGxBuf {
TSLinkedNode_CGxBuf b_base;
CGxPool* m_pool;
uint32_t m_itemSize;
uint32_t m_itemCount;
uint32_t m_size;
uint32_t m_index;
uint8_t unk1C; // TODO
uint8_t unk1D; // TODO
uint8_t unk1E; // TODO
uint8_t unk1F; // TODO
};
#endif

View file

@ -0,0 +1,61 @@
#ifndef GX_CAPS_H
#define GX_CAPS_H
#include "system/types.h"
#include "gx/types.h"
typedef struct CGxCaps CGxCaps;
struct CGxCaps {
int32_t m_numTmus;
int32_t m_pixelCenterOnEdge;
int32_t m_texelCenterOnEdge;
int32_t m_numStreams;
int32_t int10;
EGxColorFormat m_colorFormat;
uint32_t unk18;
uint32_t m_maxIndex;
int32_t m_generateMipMaps;
// int32_t m_texFmt[GxTexFormats_Last];
int32_t m_texFmt[13];
// int32_t m_texTarget[GxTexTargets_Last];
int32_t m_texTarget[4];
uint32_t unk68;
// uint32_t m_texMaxSize[GxTexTargets_Last];
uint32_t m_texMaxSize[4];
uint32_t unk7C;
uint32_t unk80;
uint32_t unk84;
uint32_t unk88;
uint32_t unk8C;
uint32_t unk90;
uint32_t unk94;
uint32_t unk98;
uint32_t unk9C;
uint32_t unkA0;
uint32_t unkA4;
uint32_t unkA8;
int32_t hwPcf;
uint32_t unkB0;
// int32_t m_shaderTargets[GxShTargets_Last];
int32_t m_shaderTargets[6];
// Evidence for this: go to 0x00684CD8
uint32_t m_shaderConstants[6];
int32_t m_texFilterTrilinear;
int32_t m_texFilterAnisotropic;
uint32_t m_maxTexAnisotropy;
int32_t m_depthBias;
uint32_t unkF4;
int32_t m_maxClipPlanes;
// CGxDeviceD3d::ISetCaps
int32_t m_hardwareCursor;
uint32_t unk100[5];
uint32_t unk114[6];
int32_t m_stereoAvailable;
int32_t int130;
int32_t int134;
int32_t int138;
};
#endif

View file

@ -0,0 +1,59 @@
#ifndef GX_D3D9_H
#define GX_D3D9_H
#include "gx/device.h"
#include "external/d3d9/device.h"
#include "storm/array.h"
DECLARE_STRUCT(CGxDeviceD3d);
DECLARE_STRUCT(CGxDeviceD3d__GxVertexDecl);
struct CGxDeviceD3d__GxVertexDecl {
uint32_t m_unk00;
};
STORM_TS_GROWABLE_ARRAY(CGxDeviceD3d__GxVertexDecl);
struct CGxDeviceD3d {
CGxDevice b_base;
void* m_hwnd;
uint16_t m_hwndClass;
uint16_t unk396E;
int32_t m_ownhwnd;
void* m_d3dLib;
IDirect3D9* m_d3d;
IDirect3DDevice9* m_d3dDevice;
D3DCAPS9 m_d3dCaps;
int32_t m_d3dIsHwDevice;
int32_t m_d3dNVAPI;
uint32_t unk3AB8;
uint32_t unk3ABC;
uint32_t m_d3dStereoHandle;
uint32_t unk3AC4[3]; //TSList?
TSGrowableArray_CGxDeviceD3d__GxVertexDecl m_vertexDecl;
IDirect3DVertexDeclaration9* m_d3dVertexDecl[14];
D3DDISPLAYMODE m_desktopDisplayMode;
int32_t m_inScene;
uint32_t unk3B2C;
D3DFORMAT m_devDepthFormat;
D3DFORMAT m_devAdapterFormat;
uint32_t unk3B38;
IDirect3DSurface9* m_defColorSurface;
IDirect3DSurface9* m_defDepthSurface;
uint32_t unk3B44;
uint32_t unk3B48;
int32_t m_hwCursorNeedsUpdate;
IDirect3DTexture9* m_hwCursorTexture;
IDirect3DSurface9* m_hwCursorBitmap;
uint32_t unk3B58;
IDirect3DVertexDeclaration9* m_d3dCurrentVertexDecl;
IDirect3DIndexBuffer9* m_d3dCurrentIndexBuf;
IDirect3DVertexBuffer9* m_d3dVertexStreamBuf[8];
uint32_t m_d3dVertexStreamOfs[8];
uint32_t m_d3dVertexStreamStride[8];
uint32_t m_deviceStates[182];
bool m_texEnabled[8];
};
#endif

View file

@ -0,0 +1,351 @@
#ifndef GX_DEVICE_H
#define GX_DEVICE_H
#include "system/types.h"
#include "storm/array.h"
#include "storm/array/uint16_t.h"
#include "storm/array/uint32_t.h"
#include "storm/array/c2vector.h"
#include "storm/array/c3vector.h"
#include "storm/array/cimvector.h"
#include "tempest/box.h"
#include "tempest/matrix.h"
#include "tempest/rect.h"
#include "tempest/vector.h"
#include "gx/types.h"
#include "gx/caps.h"
#include "gx/format.h"
#include "gx/state_bom.h"
#include "gx/shader.h"
#include "gx/matrix_stack.h"
#include "gx/buffer.h"
#include "gx/texture.h"
DECLARE_STRUCT(CGxAppRenderState);
DECLARE_STRUCT(CGxPushedRenderState);
DECLARE_STRUCT(ShaderConstants);
DECLARE_STRUCT(CGxDevice);
DECLARE_STRUCT(CGxDevice__vtable);
typedef void (*DEVICERESTOREDCALLBACK)();
STORM_TS_GROWABLE_ARRAY(DEVICERESTOREDCALLBACK);
typedef void (*TEXTURERECREATIONCALLBACK)();
STORM_TS_GROWABLE_ARRAY(TEXTURERECREATIONCALLBACK);
typedef void (*STEREOCHANGEDCALLBACK)();
STORM_TS_GROWABLE_ARRAY(STEREOCHANGEDCALLBACK);
struct CGxAppRenderState {
CGxStateBom m_value;
uint32_t m_stackDepth;
int32_t m_dirty;
};
STORM_TS_FIXED_ARRAY(CGxAppRenderState);
struct CGxPushedRenderState {
EGxRenderState m_which;
CGxStateBom m_value;
uint32_t m_stackDepth;
};
STORM_TS_GROWABLE_ARRAY(CGxPushedRenderState);
struct ShaderConstants {
C4Vector constants[256];
uint32_t unk1;
uint32_t unk2;
};
// 84 functions
struct CGxDevice__vtable {
// void ITexMarkAsUpdated(CGxTex* texId);
void* v_fn_0_ITexMarkAsUpdated;
// void IRsSendToHw(EGxRenderState rs);
// no base implementation
void* v_fn_1_IRsSendToHw;
// void ICursorCreate(const CGxFormat& format);
void* v_fn_2_ICursorCreate;
// void ICursorDestroy();
void* v_fn_3_ICursorDestroy;
// void ICursorDraw();
void* v_fn_4_ICursorDraw;
// This gets called when window is resized. It runs a list of callbacks in an array.
// two functions that are in this array (ONLY once in-game, not in login screen):
// * 007E7FE0
// * 00512920
// void NotifyOnDeviceRestored();
void* v_fn_5_NotifyOnDeviceRestored;
// void NotifyOnTextureRecreation();
void* v_fn_6_NotifyOnTextureRecreation;
// void NotifyOnDisplayChange();
void* v_fn_7_NotifyOnDisplayChange;
// void `scalar deleting destructor'(uint32_t __flags)
void* v_fn_8_scalar_deleting_destructor;
// int32_t DeviceCreate(const CGxFormat& format);
void* v_fn_9_DeviceCreate;
// int32_t DeviceCreate(long (*windowProc)(void*, uint32_t, uint32_t, int32_t), CGxFormat const& format);
void* v_fn_10_DeviceCreate;
// void DeviceDestroy();
void* v_fn_11_DeviceDestroy;
// void DeviceEvictResources();
void* v_fn_12_DeviceEvictResources;
// int32_t DeviceSetFormat(const CGxFormat& format);
void* v_fn_13_DeviceSetFormat;
// void DeviceSetBaseMipLevel(uint32_t mipLevel);
void* v_fn_14_DeviceSetBaseMipLevel;
// void DeviceSetGamma(CGxGammaRamp const& ramp);
void* v_fn_15_DeviceSetGamma;
// void DeviceSetGamma(float gamma);
void* v_fn_16_DeviceSetGamma;
// no base implementation
// void* DeviceWindow();
void* v_fn_17_DeviceWindow;
// void DeviceTakeScreenShot();
void* v_fn_18_DeviceTakeScreenShot;
// void DeviceReadScreenShot(uint32_t& w, uint32_t& h, const CImVector*& pixels) */
void* v_fn_19_DeviceReadScreenShot;
// void DeviceReadPixels(CiRect& rect, TSGrowableArray<CImVector>& pixels);
void* v_fn_20_DeviceReadPixels;
// void DeviceReadDepths(CiRect& rect, TSGrowableArray<float>& depths);
void* v_fn_21_DeviceReadDepths;
// void DeviceWM(EGxWM wm, int32_t param1, int32_t param2);
void* v_fn_22_DeviceWM;
// void DeviceSetRenderTarget(EGxBuffer buffer, CGxTex* texture, uint32_t plane);
void* v_fn_23_DeviceSetRenderTarget;
// void v_fn_24(); DeviceReleaseDepthBuffer?
// d3d:
// this->m_d3dDevice->GetDepthStencilSurface(&PTR_00C6033C);
// PTR_00C6033C->Release();
void* v_fn_24;
// void v_fn_25(); DeviceResetDepthBuffer?
// d3d:
// this->m_d3dDevice->SetDepthStencilSurface(PTR_00C6033C);
void* v_fn_25;
// void v_fn_26(CGxTex* texId); DeviceResolveDepthBuffer(CGxTex*) seems to be the most logical candidate for this
// d3d:
// if (this->m_context) {
// if (texId &&
// (texId->m_needsCreation ||
// (texId->m_apiSpecificData == nullptr &&
// texId->m_apiSpecificData2 == nullptr)) {
// this->ITexCreate(texId);
// }
// this->m_d3dDevice->SetDepthStencilSurface(texId->m_apiSpecificData);
// }
// void DeviceResolveDepthBuffer(CGxTex* texId);
void* v_fn_26_DeviceResolveDepthBuffer;
// void DeviceCopyTex(CGxTex* a1, int32_t a2, CGxTex* a3, int32_t a4);
void* v_fn_27_DeviceCopyTex;
// void DeviceOverride(EGxOverride override, uint32_t value);
void* v_fn_28_DeviceOverride;
// void AddDeviceRestoredCallback(DEVICERESTOREDCALLBACK callback);
void* v_fn_29_AddDeviceRestoredCallback;
// int32_t RemoveDeviceRestoredCallback(DEVICERESTOREDCALLBACK callback);
void* v_fn_30_RemoveDeviceRestoredCallback;
// void AddTextureRecreationCallback(TEXTURERECREATIONCALLBACK callback);
void* v_fn_31_AddTextureRecreationCallback;
// int32_t RemoveTextureRecreationCallback(TEXTURERECREATIONCALLBACK callback);
void* v_fn_32_RemoveTextureRecreationCallback;
// void AddStereoChangedCallback(STEREOCHANGEDCALLBACK callback);
void* v_fn_33_AddStereoChangedCallback;
// int32_t RemoveStereoChangeCallback(STEREOCHANGEDCALLBACK callback);
void* v_fn_34_RemoveStereoChangedCallback;
// void CapsWindowSize(CRect& dst);
void* v_fn_35_CapsWindowSize;
// void CapsWindowSize(CRect& dst);
void* v_fn_36_CapsWindowSizeInScreenCoords;
// void LogCrashInfo(char* buffer, uint32_t size);
void* v_fn_37_LogCrashInfo;
// void ScenePresent(uint32_t mask);
void* v_fn_38_ScenePresent;
// void SceneClear(uint32_t mask, CImVector color);
void* v_fn_39_SceneClear;
// void XformSetProjection(const C44Matrix& matrix);
void* v_fn_40_XformSetProjection;
// void XformSetView(const C44Matrix& matrix);
void* v_fn_41_XformSetView;
// void Draw(CGxBatch*, int32_t);
void* v_fn_42_Draw;
// void PrimBegin(EGxPrim primType);
void* v_fn_43_PrimBegin;
// void PrimDrawElements();
void* v_fn_44_PrimDrawElements;
// void PrimVertex(const C3Vector& v);
void* v_fn_45_PrimVertex;
// void PrimTexCoord(uint32_t tmu, const C2Vector& t);
void* v_fn_46_PrimTexCoord;
// void PrimNormal(const C3Vector& n);
void* v_fn_47_PrimNormal;
// void PrimColor(const CImVector& c);
void* v_fn_48_PrimColor;
// void PrimPointSize(float s);
void* v_fn_49_PrimPointSize;
// void PrimeLineWidth(float w);
void* v_fn_50_PrimLineWidth;
// void MasterEnableSet(EGxMasterEnables state, int32_t enable);
void* v_fn_51_MasterEnableSet;
// void PoolSizeSet(CGxPool* pool, uint32_t size);
void* v_fn_52_PoolSizeSet;
// void PoolDestroy(CGxPool* pool);
void* v_fn_53_PoolDestroy;
// char* BufLock(CGxBuf* buf);
void* v_fn_54_BufLock;
// int32_t BufUnlock(CGxBuf* buf, uint32_t size);
void* v_fn_55_BufUnlock;
// void BufData(CGxBuf* buf, const void* data, uint32_t size, uint32_t offset);
void* v_fn_56_BufData;
// int32_t TexCreate(EGxTexTarget target, uint32_t width, uint32_t height, uint32_t depth, EGxTexFormat format, EGxTexFormat dataFormat, CGxTexFlags flags, void* userArg, void (*userFunc)(EGxTexCommand, uint32_t, uint32_t, uint32_t, uint32_t, void*, uint32_t&, void const*&), const char* name, CGxTex*& texId);
void* v_fn_57_TexCreate;
// void TexDestroy(CGxTex* texId);
void* v_fn_58_TexDestroy;
// int32_t TexCopy(CGxTex* a1, CGxTex* a2, const C2iVector& a3, const C2iVector& a4, const C2iVector& a5, uint32_t a6);
void* v_fn_59_TexCopy;
// bool TexStretch(CGxTex* a1, CGxTex* a2, const CiRect* a3, const CiRect* a4, uint32_t a5, uint32_t a6);
void* v_fn_60_TexStretch;
// void TexSetCacheSize(int32_t cacheSize);
void* v_fn_61_TexSetCacheSize;
// void QueryCreate(CGxQuery*& query, EGxQueryType queryType);
void* v_fn_62_QueryCreate;
// bool QueryDestroy(CGxQuery* query);
void* v_fn_63_QueryDestroy;
// bool QueryBegin(CGxQuery* query);
void* v_fn_64_QueryBegin;
// bool QueryEnd(CGxQuery* query);
void* v_fn_65_QueryEnd;
// bool QueryGetParam(CGxQuery* query, EGxQueryParam param, uint32_t* data);
void* v_fn_66_QueryGetParam;
// bool QueryGetData(CGxQuery* query, uint32_t* data);
void* v_fn_67_QueryGetData;
// void ShaderCreate(CGxShader*[] shaders, EGxShTarget target, const char* a3, const char* a4, int32_t permutations);
void* v_fn_68_ShaderCreate;
// void ShaderRelease(CGxShader*& shader);
void* v_fn_69_ShaderRelease;
// void ShaderConstantsSet(EGxShTarget target, uint32_t index, const float* constraints, uint32_t count);
void* v_fn_70_ShaderConstantsSet;
// void IShaderReload(CGxShader* shader, const char* a2, const char* a3);
void* v_fn_71_IShaderReload;
// void IShaderCreate(CGxShader* shader);
void* v_fn_72_IShaderCreate;
// void CursorSetVisible(int32_t visible);
void* v_fn_73_CursorSetVisible;
// uint32_t* CursorLock();
void* v_fn_74_CursorLock;
// void CursorUnlock(uint32_t x, uint32_t y);
void* v_fn_75_CursorUnlock;
// void StereoSetConvergence(float c);
void* v_fn_76_StereoSetConvergence;
// double StereoGetConvergence();
void* v_fn_77_StereoGetConvergence;
// void StereoSetSeparation(float s);
void* v_fn_78_StereoSetSeparation;
// double StereoGetSeparation();
void* v_fn_79_StereoGetSeparation;
// bool StereoEnabled();
void* v_fn_80_StereoEnabled;
// void DebugGroupBegin(const char* a1, char* a2);
void* v_fn_81_DebugGroupBegin;
// void DebugGroupEnd();
void* v_fn_82_DebugGroupEnd;
// void DebugEvent(const char* a1, char* a2);
void* v_fn_83_DebugEvent;
};
// this class is 14692 bytes in size
struct CGxDevice {
// pointer to struct CGxDevice__vtable
CGxDevice__vtable* v_vtable; // 0x0 (size: 0x4)
TSGrowableArray_CGxPushedRenderState m_pushedStates; // 0x4 (size: 0x14)
TSGrowableArray_uint32_t m_stackOffsets; // 0x18 (size: 0x14)
TSGrowableArray_EGxRenderState m_dirtyStates; // 0x2C (size: 0x14)
EGxPrim m_primType;
uint32_t m_unk38[2]; // m_indexLocked-m_vertexLocked?
int32_t m_inBeginEnd;
C3Vector m_primVertex;
C2Vector m_primTexCoord[8];
C3Vector m_primNormal;
CImVector m_primColor;
TSGrowableArray_C3Vector m_primVertexArray;
TSGrowableArray_C2Vector m_primTexCoordArray[8];
TSGrowableArray_C3Vector m_primNormalArray;
TSGrowableArray_CImVector m_primColorArray;
TSGrowableArray_uint16_t m_primIndexArray;
uint32_t m_primMask;
CRect m_defWindowRect; // 0x164 (size: 0x10)
CRect m_curWindowRect; // 0x174 (size: 0x10)
TSGrowableArray_DEVICERESTOREDCALLBACK m_deviceRestoredCallbacks; // 0x184
TSGrowableArray_TEXTURERECREATIONCALLBACK m_textureRecreationCallbacks;
TSGrowableArray_STEREOCHANGEDCALLBACK m_stereoChangedCallbacks; // check darwin @ 00a2b779
EGxApi m_api; // 0x1b4
uint32_t m_cpuFeatures;
CGxFormat m_format;
CGxCaps m_caps;
uint32_t m_baseMipLevel;
CGxGammaRamp m_gammaRamp;
CGxGammaRamp m_systemGammaRamp;
// TSHashTable_CGxShader_HASHKEY_STRI m_shaderList[GxShTargets_Last];
// TSHashTable_CGxShader_HASHKEY_STRI m_shaderList[6];
int32_t (*m_windowProc)(void* window, uint32_t message, uintptr_t wparam, intptr_t lparam);
int32_t m_context;
int32_t intF5C;
int32_t m_windowVisible;
int32_t intF64;
int32_t intF68;
// Invented name, though seems to have the same place as CGxDeviceD3d::m_d3dNeedsReset (Alpha)
int32_t m_needsReset;
CBoundingBox m_viewport;
C44Matrix m_projection;
C44Matrix m_projNative;
// CGxMatrixStack m_xforms[GxXforms_Last];
CGxMatrixStack m_xforms[11];
CGxMatrixStack m_texGen[8];
uint32_t unk24D0[102];
// uint32_t unk2536[60];
TSHashTable_CGxShader_HASHKEY_STRI m_shaderList[6];
uint32_t m_appMasterEnables;
uint32_t m_hwMasterEnables;
TSList_CGxPool m_poolList;
uint32_t unk276C[3];
// CGxBuf* m_bufLocked[GxPoolTargets_Last];
CGxBuf* m_bufLocked[2];
CGxPool* m_vertexPool;
CGxPool* m_indexPool;
// CGxBuf* m_streamBufs[GxPoolTargets_Last];
CGxBuf* m_streamBufs[2];
// CGxVertexAttrib m_primVertexFormatAttrib[GxVertexBufferFormats_Last];
CGxVertexAttrib m_primVertexFormatAttrib[14];
// CGxBuf* m_primVertexFormatBuf[GxVertexBufferFormats_Last];
CGxBuf* m_primVertexFormatBuf[14];
uint32_t m_primVertexMask;
uint32_t m_primVertexDirty;
EGxVertexBufferFormat m_primVertexFormat;
CGxBuf* m_primVertexBuf;
uint32_t m_primVertexSize;
CGxBuf* m_primIndexBuf;
int32_t m_primIndexDirty;
uint32_t unk28C4;
uint32_t unk28C8;
uint32_t unk28CC;
uint32_t unk28D0;
uint32_t unk28D4;
uint32_t unk28D8;
uint32_t unk28DC;
uint32_t unk28E0;
uint32_t unk28E4;
uint32_t unk28E8;
TSFixedArray_CGxAppRenderState m_appRenderStates;
TSFixedArray_CGxStateBom m_hwRenderStates;
uint32_t unk2904[19]; // 0x2904 (size 0x4C)
int32_t m_cursorVisible;
int32_t m_hardwareCursor; // 0x2954 (size 0x4)
uint32_t m_cursorHotspotX;
uint32_t m_cursorHotspotY;
uint32_t m_cursor[1024]; // 0x2960 (size 0x4)
CGxTex* m_cursorTexture; // 0x3960 (size 0x4)
float m_cursorDepth; // 0x3964 (size 0x4)
// 0x3968 == 14692 (the complete size of CGxDevice)
};
#endif

View file

@ -0,0 +1,99 @@
#ifndef GX_FONT_H
#define GX_FONT_H
#include "system/types.h"
#include "tempest/rect.h"
#include "storm/list.h"
#include "storm/hash.h"
#include "gx/string.h"
DECLARE_HANDLE(HFACE);
DECLARE_STRUCT(CGxFont);
DECLARE_STRUCT(GLYPHBITMAPDATA);
DECLARE_STRUCT(CHARCODEDESC);
DECLARE_STRUCT(KERNNODE);
DECLARE_STRUCT(KERNINGHASHKEY);
DECLARE_STRUCT(TEXTURECACHE);
DECLARE_STRUCT(TEXTURECACHEROW);
STORM_TS_LIST(CGxFont);
STORM_TS_LIST(CHARCODEDESC);
STORM_TS_HASH(CHARCODEDESC, HASHKEY_NONE);
struct GLYPHBITMAPDATA {
void* m_data;
uint32_t m_dataSize;
uint32_t m_glyphWidth;
uint32_t m_glyphHeight;
uint32_t m_glyphCellWidth;
float m_glyphAdvance;
float m_glyphBearing;
uint32_t m_glyphPitch;
int32_t m_yOffset;
int32_t m_yStart;
CRect m_textureCoords;
};
// struct CHARCODEDESC : TSHashObject<CHARCODEDESC,HASHKEY_NONE>
struct CHARCODEDESC {
TSHashObject_CHARCODEDESC_HASHKEY_NONE b_base;
TSLink_CHARCODEDESC textureRowLink;
TSLink_CHARCODEDESC fontGlyphLink;
uint32_t textureNumber;
uint32_t rowNumber;
uint32_t glyphStartPixel;
uint32_t glyphEndPixel;
GLYPHBITMAPDATA bitmapData;
};
//
// struct KERNNODE : TSHashObject<KERNNODE,KERNINGHASHKEY>
struct KERNNODE {
uint32_t flags;
float proporportionalSpacing;
float fixedWidthSpacing;
};
struct KERNINGHASHKEY {
uint32_t code;
};
struct TEXTURECACHEROW {
uint32_t widestFreeSlot;
TSExplicitList_CHARCODEDESC glyphList;
};
STORM_TS_FIXED_ARRAY(TEXTURECACHEROW);
struct TEXTURECACHE {
void* m_texture;
CGxFont* m_theFace;
uint8_t m_anyDirtyGlyphs;
uint8_t pad[3];
TSFixedArray_TEXTURECACHEROW m_textureRows;
};
STORM_TS_HASH(KERNNODE, KERNINGHASHKEY);
// struct CGxFont : TSLinkedNode<CGxFont>
struct CGxFont {
TSLinkedNode_CGxFont b_base;
TSExplicitList_CGxString m_strings;
TSHashTable_CHARCODEDESC_HASHKEY_NONE m_activeCharacters;
TSHashTable_KERNNODE_KERNINGHASHKEY m_kernInfo;
TSExplicitList_CHARCODEDESC m_activeCharacterCache;
HFACE m_faceHandle;
char m_fontName[260];
uint32_t m_cellHeight;
uint32_t m_baseline;
uint32_t m_flags;
float float184;
float m_pixelsPerUnit;
TEXTURECACHE m_textureCache[8];
uint32_t m_pixelSize;
};
#endif

View file

@ -0,0 +1,50 @@
#ifndef GX_FORMAT_H
#define GX_FORMAT_H
#include "system/types.h"
#include "tempest/vector.h"
DECLARE_ENUM(CGxFormat__Format);
typedef struct CGxFormat CGxFormat;
enum CGxFormat__Format {
Fmt_Rgb565 = 0,
Fmt_ArgbX888 = 1,
Fmt_Argb8888 = 2,
Fmt_Argb2101010 = 3,
Fmt_Ds160 = 4,
Fmt_Ds24X = 5,
Fmt_Ds248 = 6,
Fmt_Ds320 = 7,
Formats_Last = 8
};
struct CGxFormat {
uint32_t unk0;
bool hwTnL;
// TODO: verify this name
bool hwCursor; // 0x5
int8_t fixLag;
int8_t window;
uint32_t unk8;
int32_t maximize;
CGxFormat__Format depthFormat;
C2iVector size;
uint32_t unk1C;
uint32_t sampleCount;
float float24;
CGxFormat__Format colorFormat;
uint32_t refreshRate;
uint32_t vsync;
uint32_t unk34;
uint32_t unk38;
uint32_t unk3C;
uint32_t unk40;
uint32_t unk44;
uint32_t unk48;
uint32_t unk4C;
C2iVector pos;
};
#endif

View file

@ -0,0 +1,21 @@
#ifndef GX_LIGHT_H
#define GX_LIGHT_H
#include "tempest/vector.h"
DECLARE_STRUCT(CGxLight);
struct CGxLight {
// int32_t m_enabled : 1;
// int32_t m_isOmni : 1;
int32_t m_flags;
C3Vector m_dir;
C3Vector m_ambColor;
C3Vector m_dirColor;
C3Vector m_specColor;
float m_constantAttenuation;
float m_linearAttenuation;
float m_quadraticAttenuation;
};
#endif

View file

@ -0,0 +1,22 @@
#ifndef GX_MATRIX_STACK_H
#define GX_MATRIX_STACK_H
#include "system/types.h"
#include "tempest/matrix.h"
DECLARE_ENUM(CGxMatrixStack__EMatrixFlags);
DECLARE_STRUCT(CGxMatrixStack);
enum CGxMatrixStack__EMatrixFlags {
F_Identity = 0x1
};
struct CGxMatrixStack {
uint32_t m_level;
int8_t m_dirty;
C44Matrix m_mtx[4];
uint32_t m_flags[4];
};
#endif

View file

@ -0,0 +1,14 @@
#ifndef GX_OPENGL_H
#define GX_OPENGL_H
DECLARE_STRUCT(CGxDeviceOpenGl);
#include "gx/device.h"
// 15264 bytes - 14696 cgxdevice = 568
struct CGxDeviceOpenGl {
CGxDevice b_base;
uint32_t unk3968[142];
};
#endif

View file

@ -0,0 +1,32 @@
#ifndef GX_SHADER_H
#define GX_SHADER_H
#include "storm/hash.h"
#include "storm/array/uint8_t.h"
DECLARE_STRUCT(CGxShader);
STORM_TS_HASH(CGxShader, HASHKEY_STRI);
// class CGxShader : public TSHashObject<CGxShader, HASHKEY_STRI>
struct CGxShader {
TSHashObject_CGxShader_HASHKEY_STRI b_base;
void* v_table;
uint32_t refCount;
void* apiSpecific;
int32_t target;
int32_t int28;
int32_t valid;
int32_t loaded;
int32_t int34;
int32_t patched;
int32_t int3C;
int32_t int40;
int16_t int44;
int16_t int46;
TSGrowableArray_uint8_t code;
// bool IsEnabled();
};
#endif

View file

@ -0,0 +1,21 @@
#ifndef GX_STATE_BOM_H
#define GX_STATE_BOM_H
#include "system/types.h"
#include "storm/array.h"
DECLARE_STRUCT(CGxStateBom);
struct CGxStateBom {
union {
int32_t i[3];
uint32_t u[3];
float f[3];
void* p;
} m_data;
int32_t filler;
};
STORM_TS_FIXED_ARRAY(CGxStateBom);
#endif

View file

@ -0,0 +1,50 @@
#ifndef GX_STRING_H
#define GX_STRING_H
#include "tempest/vector.h"
DECLARE_STRUCT(CGxString);
STORM_TS_LIST(CGxString);
// struct CGxString : TSLinkedNode<CGxString>
struct CGxString {
TSLinkedNode_CGxString b_base;
TSLink_CGxString m_fontStringLink;
TSLink_CGxString m_batchedStringLink;
float m_requestedFontHeight;
float m_currentFontHeight;
C3Vector m_position;
CImVector m_fontColor;
CImVector m_shadowColor;
C2Vector m_shadowOffset;
float m_blockWidth;
float m_blockHeight;
void* m_currentFace;
char* m_text;
int32_t m_textLen;
int32_t m_vertJust;
int32_t m_horzJust;
float m_spacing;
uint32_t m_flags;
uint32_t m_texturePagesUsed;
int32_t m_textureEvicted;
uint32_t m_lastGradientStart;
uint32_t m_lastGradientLength;
C3Vector m_viewTranslation;
float m_scale;
uint32_t m_hyperlinkInfo[4];
uint32_t dword90;
uint32_t dword94;
uint32_t dword98;
uint32_t dword9C;
uint32_t dwordA0;
uint32_t dwordA4;
uint32_t dwordA8;
uint32_t dwordAC;
int32_t m_intB0;
void* m_textLines[8];
int32_t m_intD4;
};
#endif

View file

@ -0,0 +1,30 @@
#ifndef GX_STRING_BATCH_H
#define GX_STRING_BATCH_H
#include "storm/list.h"
#include "storm/hash.h"
#include "gx/font.h"
DECLARE_STRUCT(CGxStringBatch);
DECLARE_STRUCT(BATCHEDRENDERFONTDESC);
STORM_TS_HASH(BATCHEDRENDERFONTDESC, HASHKEY_PTR);
STORM_TS_LIST(CGxStringBatch);
// struct BATCHEDRENDERFONTDESC : TSHashObject<BATCHEDRENDERFONTDESC, HASHKEY_PTR>
struct BATCHEDRENDERFONTDESC {
TSHashObject_BATCHEDRENDERFONTDESC_HASHKEY_PTR b_base;
CGxFont* m_face;
// STORM_EXPLICIT_LIST(CGxString, m_batchedStringLink) m_strings;
TSExplicitList_CGxString m_strings;
};
// CGxStringBatch : TSLinkedNode<CGxStringBatch>
struct CGxStringBatch {
TSLinkedNode_CGxStringBatch b_base;
TSHashTable_BATCHEDRENDERFONTDESC_HASHKEY_PTR m_fontBatch;
uint32_t m_flags;
};
#endif

View file

@ -0,0 +1,56 @@
#ifndef GX_TEXTURE_H
#define GX_TEXTURE_H
#include "tempest/rect.h"
#include "common/handle.h"
#include "storm/array.h"
typedef HOBJECT HTEXTURE;
STORM_TS_GROWABLE_ARRAY(HTEXTURE);
typedef struct CGxTexFlags CGxTexFlags;
typedef struct CGxTex CGxTex;
struct CGxTexFlags {
// unsigned __int32 m_filter : 3;
// unsigned __int32 m_wrapU : 1;
// unsigned __int32 m_wrapV : 1;
// unsigned __int32 m_forceMipTracking : 1;
// unsigned __int32 m_generateMipMaps : 1;
// unsigned __int32 m_renderTarget : 1;
// unsigned __int32 m_maxAnisotropy : 5;
uint32_t f_flags;
};
struct CGxTex {
CiRect m_updateRect;
int16_t m_updatePlaneMin;
int16_t m_updatePlaneMax;
uint32_t m_width;
uint32_t m_height;
uint32_t m_depth;
uint32_t m_target;
uint32_t m_format;
uint32_t m_dataFormat;
CGxTexFlags m_flags;
void* m_userArg;
void* m_userFunc;
void* m_apiSpecificData;
void* m_apiSpecificData2;
uint32_t unk40;
uint32_t unk44;
uint32_t unk48;
uint32_t unk4C;
uint32_t unk50;
uint32_t unk54;
int8_t char58;
int8_t char59;
int8_t m_needsUpdate;
int8_t m_needsCreation;
int8_t m_needsFlagUpdate;
int8_t char5D;
uint16_t m_pad;
};
#endif

View file

@ -0,0 +1,401 @@
#ifndef GX_TYPES_H
#define GX_TYPES_H
#include "system/types.h"
#include "storm/array.h"
DECLARE_ENUM(BlitAlpha);
DECLARE_ENUM(BlitFormat);
DECLARE_ENUM(EGxApi);
DECLARE_ENUM(EGxBlend);
DECLARE_ENUM(EGxColorFormat);
DECLARE_ENUM(EGxFontHJusts);
DECLARE_ENUM(EGxFontVJusts);
DECLARE_ENUM(EGxMasterEnables);
DECLARE_ENUM(EGxPrim);
DECLARE_ENUM(EGxPrimMask);
DECLARE_ENUM(EGxRenderState);
DECLARE_ENUM(EGxShPS);
DECLARE_ENUM(EGxShTarget);
DECLARE_ENUM(EGxShVS);
DECLARE_ENUM(EGxTexCommand);
DECLARE_ENUM(EGxTexFilter);
DECLARE_ENUM(EGxTexFormat);
DECLARE_ENUM(EGxTexTarget);
DECLARE_ENUM(EGxTexWrapMode);
DECLARE_ENUM(EGxXform);
DECLARE_ENUM(EGxuDrawListCategory);
DECLARE_ENUM(EGxWM);
DECLARE_ENUM(COLOR_FILE_FORMAT);
DECLARE_ENUM(PIXEL_FORMAT);
DECLARE_STRUCT(C4Pixel);
DECLARE_STRUCT(C4LargePixel);
DECLARE_STRUCT(MipBits);
DECLARE_STRUCT(CGxGammaRamp);
enum BlitAlpha {
BlitAlpha_0 = 0,
BlitAlpha_1 = 1,
BlitAlpha_8 = 2,
BlitAlpha_Filler = 3,
BlitAlphas_Last = 4
};
enum BlitFormat {
BlitFormat_Unknown = 0,
BlitFormat_Abgr8888 = 1,
BlitFormat_Argb8888 = 2,
BlitFormat_Argb4444 = 3,
BlitFormat_Argb1555 = 4,
BlitFormat_Rgb565 = 5,
BlitFormat_Dxt1 = 6,
BlitFormat_Dxt3 = 7,
BlitFormat_Dxt5 = 8,
BlitFormat_Uv88 = 9,
BlitFormat_Gr1616F = 10,
BlitFormat_R32F = 11,
BlitFormat_D24X8 = 12,
BlitFormats_Last = 13
};
enum EGxApi {
GxApi_OpenGl = 0,
GxApi_D3d9 = 1,
GxApi_D3d9Ex = 2,
GxApi_D3d10 = 3,
GxApi_D3d11 = 4,
GxApi_GLL = 5,
GxApis_Last = 6
};
enum EGxBlend {
GxBlend_Opaque = 0,
GxBlend_AlphaKey = 1,
GxBlend_Alpha = 2,
GxBlend_Add = 3,
GxBlend_Mod = 4,
GxBlend_Mod2x = 5,
GxBlend_ModAdd = 6,
GxBlend_InvSrcAlphaAdd = 7,
GxBlend_InvSrcAlphaOpaque = 8,
GxBlend_SrcAlphaOpaque = 9,
GxBlend_NoAlphaAdd = 10,
GxBlend_ConstantAlpha = 11,
GxBlends_Last = 12
};
enum EGxColorFormat {
GxCF_argb = 0,
GxCF_rgba = 1,
GxColorFormats_Last = 2,
};
enum EGxFontHJusts {
GxHJ_Left = 0,
GxHJ_Center = 1,
GxHJ_Right = 2,
GxHJ_Last = 3
};
enum EGxFontVJusts {
GxVJ_Top = 0,
GxVJ_Middle = 1,
GxVJ_Bottom = 2,
GxVJ_Last = 3
};
enum EGxMasterEnables {
GxMasterEnable_Lighting = 0,
GxMasterEnable_Fog = 1,
GxMasterEnable_DepthTest = 2,
GxMasterEnable_DepthWrite = 3,
GxMasterEnable_ColorWrite = 4,
GxMasterEnable_Culling = 5,
GxMasterEnable_DoubleBuffering = 6,
GxMasterEnable_NormalProjection = 7,
GxMasterEnable_PolygonFill = 8,
GxMasterEnables_Last = 9
};
enum EGxPrim {
GxPrim_Points = 0,
GxPrim_Lines = 1,
GxPrim_LineStrip = 2,
GxPrim_Triangles = 3,
GxPrim_TriangleStrip = 4,
GxPrim_TriangleFan = 5,
GxPrims_Last = 6
};
enum EGxPrimMask {
GxPrim_Position = 0x1,
GxPrim_BlendWeight = 0x2,
GxPrim_BlendIndices = 0x4,
GxPrim_Normal = 0x8,
GxPrim_Color0 = 0x10,
GxPrim_Color1 = 0x20,
GxPrim_TexCoord0 = 0x40,
GxPrim_TexCoord1 = 0x80
};
enum EGxRenderState {
GxRs_PolygonOffset = 0,
GxRs_MatDiffuse = 1,
GxRs_MatEmissive = 2,
GxRs_MatSpecular = 3,
GxRs_MatSpecularExp = 4,
GxRs_NormalizeNormals = 5,
GxRs_BlendingMode = 6,
GxRs_AlphaRef = 7,
GxRs_FogStart = 8,
GxRs_FogEnd = 9,
GxRs_FogColor = 10,
GxRs_Lighting = 11,
GxRs_Fog = 12,
GxRs_DepthTest = 13,
GxRs_DepthFunc = 14,
GxRs_DepthWrite = 15,
GxRs_ColorWrite = 16,
GxRs_Culling = 17,
GxRs_ClipPlaneMask = 18,
GxRs_Multisample = 19,
GxRs_ScissorTest = 20,
GxRs_Texture0 = 21,
GxRs_Texture1 = 22,
GxRs_Texture2 = 23,
GxRs_Texture3 = 24,
GxRs_Texture4 = 25,
GxRs_Texture5 = 26,
GxRs_Texture6 = 27,
GxRs_Texture7 = 28,
GxRs_Texture8 = 29,
GxRs_Texture9 = 30,
GxRs_Texture10 = 31,
GxRs_Texture11 = 32,
GxRs_Texture12 = 33,
GxRs_Texture13 = 34,
GxRs_Texture14 = 35,
GxRs_Texture15 = 36,
GxRs_ColorOp0 = 37,
GxRs_ColorOp1 = 38,
GxRs_ColorOp2 = 39,
GxRs_ColorOp3 = 40,
GxRs_ColorOp4 = 41,
GxRs_ColorOp5 = 42,
GxRs_ColorOp6 = 43,
GxRs_ColorOp7 = 44,
GxRs_AlphaOp0 = 45,
GxRs_AlphaOp1 = 46,
GxRs_AlphaOp2 = 47,
GxRs_AlphaOp3 = 48,
GxRs_AlphaOp4 = 49,
GxRs_AlphaOp5 = 50,
GxRs_AlphaOp6 = 51,
GxRs_AlphaOp7 = 52,
GxRs_TexGen0 = 53,
GxRs_TexGen1 = 54,
GxRs_TexGen2 = 55,
GxRs_TexGen3 = 56,
GxRs_TexGen4 = 57,
GxRs_TexGen5 = 58,
GxRs_TexGen6 = 59,
GxRs_TexGen7 = 60,
GxRs_Unk61 = 61,
GxRs_Unk62 = 62,
GxRs_Unk63 = 63,
GxRs_Unk64 = 64,
GxRs_Unk65 = 65,
GxRs_Unk66 = 66,
GxRs_Unk67 = 67,
GxRs_Unk68 = 68,
GxRs_Unk69 = 69,
GxRs_Unk70 = 70,
GxRs_Unk71 = 71,
GxRs_Unk72 = 72,
GxRs_Unk73 = 73,
GxRs_Unk74 = 74,
GxRs_Unk75 = 75,
GxRs_Unk76 = 76,
GxRs_VertexShader = 77,
GxRs_PixelShader = 78,
GxRs_PointScale = 79,
GxRs_PointScaleAttenuation = 80,
GxRs_PointScaleMin = 81,
GxRs_PointScaleMax = 82,
GxRs_PointSprite = 83,
GxRs_Unk84 = 84,
GxRs_ColorMaterial = 85,
GxRenderStates_Last = 86
};
STORM_TS_GROWABLE_ARRAY(EGxRenderState);
enum EGxShPS {
GxShPS_none = 0,
GxShPS_ps_1_1 = 1,
GxShPS_ps_1_4 = 2,
GxShPS_ps_2_0 = 3,
GxShPS_ps_3_0 = 4,
GxShPS_ps_4_0 = 5,
GxShPS_ps_5_0 = 6,
GxShPS_nvrc = 7,
GxShPS_nvts = 8,
GxShPS_nvts2 = 9,
GxShPS_nvts3 = 10,
GxShPS_nvfp2 = 11,
GxShPS_arbfp1 = 12,
GxShPS_glsl = 13,
};
enum EGxShTarget {
GxSh_Vertex = 0,
GxSh_Hull = 1,
GxSh_Domain = 2,
GxSh_Geometry = 3,
GxSh_Pixel = 4,
GxSh_Compute = 5,
GxShTargets_Last = 6
};
enum EGxShVS {
GxShVS_none = 0,
GxShVS_vs_1_1 = 1,
GxShVS_vs_2_0 = 2,
GxShVS_vs_3_0 = 3,
GxShVS_vs_4_0 = 4,
GxShVS_vs_5_0 = 5,
GxShVS_arbvp1 = 6,
GxShVS_arbvp1_cg12 = 7,
GxShVS_nvvp = 8,
GxShVS_nvvp2 = 9,
GxShVS_nvvp3 = 10,
GxShVS_glsl = 11
};
enum EGxTexCommand {
GxTex_Lock = 0,
GxTex_Latch = 1,
GxTex_Unlock = 2,
GxTexCommands_Last = 3
};
enum EGxTexFilter {
GxTex_Nearest = 0x0,
GxTex_Linear = 0x1,
GxTex_NearestMipNearest = 0x2,
GxTex_LinearMipNearest = 0x3,
GxTex_LinearMipLinear = 0x4,
GxTex_Anisotropic = 0x5,
GxTexFilters_Last = 0x6,
};
enum EGxTexFormat {
GxTex_Unknown = 0x0,
GxTex_Abgr8888 = 0x1,
GxTex_Argb8888 = 0x2,
GxTex_Argb4444 = 0x3,
GxTex_Argb1555 = 0x4,
GxTex_Rgb565 = 0x5,
GxTex_Dxt1 = 0x6,
GxTex_Dxt3 = 0x7,
GxTex_Dxt5 = 0x8,
GxTex_Uv88 = 0x9,
GxTex_Gr1616F = 0xA,
GxTex_R32F = 0xB,
GxTex_D24X8 = 0xC,
GxTexFormats_Last = 0xD,
};
enum EGxTexTarget {
GxTex_2d = 0x0,
GxTex_CubeMap = 0x1,
GxTex_Rectangle = 0x2,
GxTex_NonPow2 = 0x3,
GxTexTargets_Last = 0x4
};
enum EGxTexWrapMode {
GxTex_Clamp = 0,
GxTex_Wrap = 1
};
enum EGxQueryType {
GxQueryType_Occlusion = 0,
};
enum EGxXform {
GxXform_Tex0 = 0,
GxXform_Tex1 = 1,
GxXform_Tex2 = 2,
GxXform_Tex3 = 3,
GxXform_Tex4 = 4,
GxXform_Tex5 = 5,
GxXform_Tex6 = 6,
GxXform_Tex7 = 7,
GxXform_World = 8,
GxXform_Projection = 9,
GxXform_View = 10,
GxXforms_Last = 11
};
enum EGxuDrawListCategory {
GxuCat_0 = 0,
GxuCat_1 = 1,
GxuCat_2 = 2
};
enum EGxWM {
GxWM_Size = 0,
GxWM_DisplayChange = 1,
GxWM_Destroy = 2,
GxWM_SetFocus = 3,
GxWM_KillFocus = 4,
};
enum COLOR_FILE_FORMAT {
COLOR_JPEG = 0,
COLOR_PAL = 1,
COLOR_DXT = 2,
COLOR_3 = 3
};
enum PIXEL_FORMAT {
PIXEL_DXT1 = 0x0,
PIXEL_DXT3 = 0x1,
PIXEL_ARGB8888 = 0x2,
PIXEL_ARGB1555 = 0x3,
PIXEL_ARGB4444 = 0x4,
PIXEL_RGB565 = 0x5,
PIXEL_A8 = 0x6,
PIXEL_DXT5 = 0x7,
PIXEL_UNSPECIFIED = 0x8,
PIXEL_ARGB2565 = 0x9,
NUM_PIXEL_FORMATS = 0xA
};
struct C4Pixel {
uint8_t b;
uint8_t g;
uint8_t r;
uint8_t a;
};
struct C4LargePixel {
uint64_t b;
uint64_t g;
uint64_t r;
uint64_t a;
};
struct MipBits {
C4Pixel* mip[1];
};
struct CGxGammaRamp {
uint16_t red[256];
uint16_t green[256];
uint16_t blue[256];
};
#endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,455 @@
#ifndef M2_DATA_H
#define M2_DATA_H
#include "system/types.h"
#include "gx/buffer.h"
#include "tempest/vector.h"
#include "tempest/box.h"
#include "tempest/quaternion.h"
DECLARE_STRUCT(M2SequenceTimes);
DECLARE_STRUCT(M2TrackBase);
DECLARE_STRUCT(M2Attachment);
DECLARE_STRUCT(M2Batch);
DECLARE_STRUCT(M2Bounds);
DECLARE_STRUCT(M2Camera);
DECLARE_STRUCT(M2Color);
DECLARE_STRUCT(M2CompQuat);
DECLARE_STRUCT(M2CompBone__CompressData);
DECLARE_STRUCT(M2CompBone);
DECLARE_STRUCT(M2Event);
DECLARE_STRUCT(M2Light);
DECLARE_STRUCT(M2Loop);
DECLARE_STRUCT(M2Material);
DECLARE_STRUCT(M2Particle);
DECLARE_STRUCT(M2Ribbon);
DECLARE_STRUCT(M2Sequence);
DECLARE_STRUCT(M2SkinSection);
DECLARE_STRUCT(M2Texture);
DECLARE_STRUCT(M2TextureTransform);
DECLARE_STRUCT(M2TextureWeight);
DECLARE_STRUCT(M2Vertex);
DECLARE_STRUCT(M2Data);
DECLARE_STRUCT(M2SkinProfile);
// from whoa: src/model/M2Data.hpp
/*
M2Array has been modified from the implementation present in 12340. The
implementation present in 12340 looks like this:
template<class T>
struct M2Array {
uint32_t count;
union {
T* data;
uint32_t offset;
}
};
On a 32-bit system, sizeof(M2Array) == 8 bytes in memory: 4 bytes for the
count, and 4 bytes for the union. This lines up with M2Array in the .m2
files: each M2Array is 8 bytes.
In 12340 (and until 64-bit support was introduced), the M2Init functions
simply adjust the M2Array when loading:
m2Data->someM2Array.offset =
(uint32_t)m2Data + m2Data->someM2Array.offset;
This ensures T* data points to the appropriate (absolute) location in
memory.
Unfortunately, this approach fails on 64-bit systems. On a 64-bit system,
M2Array would occupy 12 bytes in memory: 4 bytes for the count, and 8 bytes
for the union. This would make the approach outlined above fail.
As a result, on 64-bit systems, a different approach is used: M2Arrays are
assumed (reasonably so) to only exist within the same structure that their
on-disk offsets reference. Thus, M2Init adjusts the M2Array when loading:
uintptr_t absoluteOffset =
(uintptr_t)m2Data + m2Data->someM2Array.offset;
uintptr_t relativeOffset =
absoluteOffset - (uintptr_t)&m2Data->someM2Array;
m2Data->someM2Array.offset =
(uint32_t)relativeOffset;
By storing the relative offset, access to the data is possible by adding
the relative offset to the address of the M2Array:
uintptr_t absoluteOffset =
(uintptr_t)m2Data->someM2Array + m2Data->someM2Array.offset;
T* data = (T*)absoluteOffset;
*/
#define M2_ARRAY(T) typedef struct M2Array_##T M2Array_##T; \
struct M2Array_##T { \
uint32_t count; \
union { \
T* data; \
uint32_t offset; \
} data_or_offset; \
};
// declare basic types here
M2_ARRAY(ubyte4);
M2_ARRAY(uint32_t);
M2_ARRAY(C2Vector); // required by M2PartTrack
#define M2_SEQUENCE_KEYS(T) \
M2_ARRAY(T); \
typedef struct M2SequenceKeys_##T M2SequenceKeys_##T; \
struct M2SequenceKeys_##T { \
M2Array_##T keys; \
};
struct M2SequenceTimes {
M2Array_uint32_t times;
};
M2_ARRAY(M2SequenceTimes);
struct M2TrackBase {
uint16_t trackType;
uint16_t loopIndex;
M2Array_M2SequenceTimes sequenceTimes;
};
// template<class T>
// class M2Track : public M2TrackBase
#define M2_TRACK(T) \
M2_SEQUENCE_KEYS(T); \
M2_ARRAY(M2SequenceKeys_##T); \
typedef struct M2Track_##T M2Track_##T; \
struct M2Track_##T { \
M2TrackBase b_base; \
M2Array_M2SequenceKeys_##T sequenceKeys; \
};
// declare basic types here
M2_TRACK(uint8_t);
M2_TRACK(uint16_t);
M2_TRACK(fixed16);
M2_TRACK(float);
M2_TRACK(C3Vector);
M2_TRACK(C4Quaternion);
struct M2Attachment {
uint32_t attachmentId;
uint16_t boneIndex;
C3Vector position;
M2Track_uint8_t visibilityTrack;
};
M2_ARRAY(M2Attachment);
struct M2Batch {
uint8_t flags;
int8_t priorityPlane;
uint16_t shader;
uint16_t skinSectionIndex;
uint16_t geosetIndex;
uint16_t colorIndex;
uint16_t materialIndex;
uint16_t materialLayer;
uint16_t textureCount;
uint16_t textureComboIndex;
uint16_t textureCoordComboIndex;
uint16_t textureWeightComboIndex;
uint16_t textureTransformComboIndex;
};
M2_ARRAY(M2Batch);
struct M2Bounds {
CAaBox extent;
float radius;
};
#define M2_SPLINE_KEY(T) \
typedef struct M2SplineKey_##T M2SplineKey_##T; \
struct M2SplineKey_##T { \
T value; \
T inTan; \
T outTan; \
};
// declare types here
M2_SPLINE_KEY(float);
M2_SPLINE_KEY(C3Vector);
M2_TRACK(M2SplineKey_float);
M2_TRACK(M2SplineKey_C3Vector);
struct M2Camera {
uint32_t cameraId;
float fieldOfView;
float farClip;
float nearClip;
M2Track_M2SplineKey_C3Vector positionTrack;
C3Vector positionPivot;
M2Track_M2SplineKey_C3Vector targetTrack;
C3Vector targetPivot;
M2Track_M2SplineKey_float rollTrack;
};
M2_ARRAY(M2Camera);
struct M2Color {
M2Track_C3Vector colorTrack;
M2Track_fixed16 alphaTrack;
};
M2_ARRAY(M2Color);
struct M2CompQuat {
uint32_t auCompQ[2];
};
M2_TRACK(M2CompQuat);
struct M2CompBone__CompressData {
uint16_t uDistToFurthDesc;
uint16_t uZRatioOfChain;
};
struct M2CompBone {
uint32_t boneId;
uint32_t flags;
uint16_t parentIndex;
uint16_t uDistToParent;
union {
M2CompBone__CompressData CompressData;
uint32_t boneNameCRC;
};
M2Track_C3Vector translationTrack;
M2Track_M2CompQuat rotationTrack;
M2Track_C3Vector scaleTrack;
C3Vector pivot;
};
M2_ARRAY(M2CompBone);
struct M2Event {
uint32_t eventId;
uint32_t data;
uint16_t boneIndex;
C3Vector position;
M2TrackBase eventTrack;
};
M2_ARRAY(M2Event);
struct M2Light {
uint16_t lightType;
uint16_t boneIndex;
C3Vector position;
M2Track_C3Vector ambientColorTrack;
M2Track_float ambientIntensityTrack;
M2Track_C3Vector diffuseColorTrack;
M2Track_float diffuseIntensityTrack;
M2Track_float attenuationStartTrack;
M2Track_float attenuationEndTrack;
M2Track_uint8_t visibilityTrack;
};
M2_ARRAY(M2Light);
struct M2Loop {
uint32_t length;
};
M2_ARRAY(M2Loop);
struct M2Material {
uint16_t flags;
uint16_t blendMode;
};
M2_ARRAY(M2Material);
#define M2_PART_TRACK(T) \
typedef struct M2PartTrack_##T M2PartTrack_##T; \
struct M2PartTrack_##T { \
M2Array_fixed16 times; \
M2Array_##T values; \
};
// declare types here
M2_PART_TRACK(fixed16);
M2_PART_TRACK(uint16_t);
M2_PART_TRACK(C2Vector);
M2_PART_TRACK(C3Vector);
struct M2Particle {
uint32_t particleId;
uint32_t flags;
C3Vector position;
uint16_t boneIndex;
uint16_t textureIndex;
M2Array_uint8_t geometryMdl;
M2Array_uint8_t recursionMdl;
uint8_t blendMode;
uint8_t emitterType;
uint16_t colorIndex;
uint16_t pad;
int16_t priorityPlane;
uint16_t rows;
uint16_t cols;
M2Track_float speedTrack;
M2Track_float variationTrack;
M2Track_float latitudeTrack;
M2Track_float longitudeTrack;
M2Track_float gravityTrack;
M2Track_float lifeTrack;
float lifeVariation;
M2Track_float emissionRateTrack;
float emissionRateVariation;
M2Track_float widthTrack;
M2Track_float lengthTrack;
M2Track_float zsourceTrack;
M2PartTrack_C3Vector colorTrack;
M2PartTrack_fixed16 alphaTrack;
M2PartTrack_C2Vector scaleTrack;
C2Vector scaleVariation;
M2PartTrack_uint16_t headCellTrack;
M2PartTrack_uint16_t tailCellTrack;
float tailLength;
float twinkleFPS;
float twinkleOnOff;
CRange twinkleScale;
float ivelScale;
float drag;
float initialSpin;
float initialSpinVariation;
float spin;
float spinVariation;
CAaBox tumble;
C3Vector windVector;
float windTime;
float followSpeed1;
float followScale1;
float followSpeed2;
float followScale2;
M2Array_C3Vector spline;
M2Track_uint8_t visibilityTrack;
};
M2_ARRAY(M2Particle);
struct M2Ribbon {
uint32_t ribbonId;
uint16_t boneIndex;
C3Vector position;
M2Track_uint16_t textureIndices;
M2Track_uint16_t materialIndices;
M2Track_C3Vector colorTrack;
M2Track_fixed16 alphaTrack;
M2Track_float heightAboveTrack;
M2Track_float heightBelowTrack;
float edgesPerSecond;
float edgeLifetime;
float gravity;
uint16_t textureRows;
uint16_t textureCols;
M2Track_uint16_t textureSlotTrack;
M2Track_uint8_t visibilityTrack;
int16_t priorityPlane;
uint16_t pad;
};
M2_ARRAY(M2Ribbon);
struct M2Sequence {
uint16_t id;
uint16_t variationIndex;
uint32_t duration;
float movespeed;
uint32_t flags;
uint32_t frequency;
CiRange replay;
uint32_t blendtime;
M2Bounds bounds;
uint16_t variationNext;
uint16_t aliasNext;
};
M2_ARRAY(M2Sequence);
struct M2SkinSection {
uint32_t skinSectionId;
uint16_t vertexStart;
uint16_t vertexCount;
uint16_t indexStart;
uint16_t indexCount;
uint16_t boneCount;
uint16_t boneComboIndex;
uint16_t boneInfluences;
uint16_t centerBoneIndex;
C3Vector centerPosition;
C3Vector sortCenterPosition;
float sortRadius;
};
M2_ARRAY(M2SkinSection);
struct M2Texture {
uint32_t textureId;
uint16_t flags;
M2Array_uint8_t filename;
};
M2_ARRAY(M2Texture);
struct M2TextureTransform {
M2Track_C3Vector translationTrack;
M2Track_M2CompQuat rotationTrack;
M2Track_C3Vector scaleTrack;
};
M2_ARRAY(M2TextureTransform);
struct M2TextureWeight {
M2Track_fixed16 weightTrack;
};
M2_ARRAY(M2TextureWeight);
struct M2Vertex {
C3Vector position;
ubyte4 weights;
ubyte4 indices;
C3Vector normal;
C2Vector texcoord[2];
};
M2_ARRAY(M2Vertex);
// .m2 files
struct M2Data {
uint32_t MD20;
uint32_t version;
M2Array_uint8_t name;
uint32_t flags;
M2Array_M2Loop loops;
M2Array_M2Sequence sequences;
M2Array_uint16_t sequenceIdxHashById;
M2Array_M2CompBone bones;
M2Array_uint16_t boneIndicesById;
M2Array_M2Vertex vertices;
uint32_t numSkinProfiles;
M2Array_M2Color colors;
M2Array_M2Texture textures;
M2Array_M2TextureWeight textureWeights;
M2Array_M2TextureTransform textureTransforms;
M2Array_uint16_t textureIndicesById;
M2Array_M2Material materials;
M2Array_uint16_t boneCombos;
M2Array_uint16_t textureCombos;
M2Array_uint16_t textureCoordCombos;
M2Array_uint16_t textureWeightCombos;
M2Array_uint16_t textureTransformCombos;
M2Bounds bounds;
M2Bounds collisionBounds;
M2Array_uint16_t collisionIndices;
M2Array_C3Vector collisionPositions;
M2Array_C3Vector collisionFaceNormals;
M2Array_M2Attachment attachments;
M2Array_uint16_t attachmentIndicesById;
M2Array_M2Event events;
M2Array_M2Light lights;
M2Array_M2Camera cameras;
M2Array_uint16_t cameraIndicesById;
M2Array_M2Ribbon ribbons;
M2Array_M2Particle particles;
M2Array_uint16_t textureCombinerCombos;
};
// .skin files
struct M2SkinProfile {
uint32_t magic;
M2Array_uint16_t vertices;
M2Array_uint16_t indices;
M2Array_ubyte4 bones;
M2Array_M2SkinSection skinSections;
M2Array_M2Batch batches;
uint32_t boneCountMax;
};
#endif

View file

@ -0,0 +1,28 @@
#ifndef M2_LIGHT_H
#define M2_LIGHT_H
DECLARE_STRUCT(CM2Light);
#include "m2/scene.h"
struct CM2Light {
CM2Scene* m_scene;
uint32_t dword4;
uint32_t m_type;
C3Vector m_pos;
float float10;
float float14;
float float18;
C3Vector m_dir;
C3Vector m_ambColor;
C3Vector m_dirColor;
C3Vector m_specColor;
float m_constantAttenuation;
float m_linearAttenuation;
float m_quadraticAttenuation;
uint32_t m_visible;
CM2Light** m_lightPrev;
CM2Light* m_lightNext;
};
#endif

View file

@ -0,0 +1,34 @@
#ifndef M2_LIGHTING_H
#define M2_LIGHTING_H
DECLARE_STRUCT(CM2Lighting);
#include "m2/scene.h"
#include "tempest/vector.h"
#include "tempest/sphere.h"
#include "tempest/plane.h"
struct CM2Lighting {
CM2Scene* m_scene;
CAaSphere sphere4;
uint32_t m_flags;
C3Vector vector18;
C3Vector vector24;
C3Vector vector30;
C3Vector vector3C;
C3Vector vector48;
C3Vector m_sunAmbient;
C3Vector m_sunDiffuse;
C3Vector m_sunSpecular;
C3Vector m_sunDir;
CM2Light* m_lights[4];
uint32_t m_lightCount;
float m_fogStart;
float m_fogEnd;
float m_fogScale;
float m_fogDensity;
C3Vector m_fogColor;
C4Plane m_liquidPlane;
};
#endif

View file

@ -0,0 +1,270 @@
#ifndef M2_MODEL_H
#define M2_MODEL_H
DECLARE_STRUCT(M2ModelAttachment);
DECLARE_STRUCT(M2ModelBoneSeq);
DECLARE_STRUCT(M2ModelBone);
DECLARE_STRUCT(M2ModelCamera);
DECLARE_STRUCT(M2ModelColor);
DECLARE_STRUCT(M2ModelLight);
DECLARE_STRUCT(M2ModelRibbon);
DECLARE_STRUCT(M2ModelTextureTransform);
DECLARE_STRUCT(M2ModelTextureWeight);
DECLARE_STRUCT(M2ModelOptGeo);
DECLARE_STRUCT(CM2ModelCall);
DECLARE_STRUCT(CM2Model);
#include "camera/camera.h"
#include "m2/data.h"
#include "m2/scene.h"
#include "m2/shared.h"
#include "m2/lighting.h"
#include "m2/ribbon.h"
#include "tempest/vector.h"
#include "tempest/quaternion.h"
#include "gx/texture.h"
// template<class T>
#define M2_MODEL_TRACK(T) \
typedef struct M2ModelTrack_##T M2ModelTrack_##T; \
struct M2ModelTrack_##T { \
uint32_t currentKey; \
M2Track_##T* sourceTrack; \
T currentValue; \
};
M2_MODEL_TRACK(uint8_t);
M2_MODEL_TRACK(float);
M2_MODEL_TRACK(C3Vector);
M2_MODEL_TRACK(C4Quaternion);
struct M2ModelAttachment {
int32_t unk;
};
struct M2ModelBoneSeq {
uint32_t uint0;
uint16_t uint4;
uint16_t uint6;
uint16_t uint8;
uint8_t uintA;
uint8_t uintB;
uint32_t uintC;
uint32_t uint10;
float float14;
float float18;
uint32_t uint1C;
uint32_t uint20;
};
struct M2ModelBone {
M2ModelTrack_C3Vector translationTrack;
M2ModelTrack_C4Quaternion rotationTrack;
M2ModelTrack_C3Vector scaleTrack;
M2ModelBoneSeq sequence;
M2ModelBoneSeq secondarySequence;
uint32_t flags;
uint32_t uint90;
uint16_t uint94;
uint32_t uint9C;
float floatA0;
float floatA4;
float floatA8;
};
struct M2ModelCamera {
M2ModelTrack_C3Vector positionTrack;
M2ModelTrack_C3Vector targetTrack;
M2ModelTrack_float rollTrack;
HCAMERA m_camera;
};
struct M2ModelColor {
M2ModelTrack_C3Vector colorTrack;
M2ModelTrack_float alphaTrack;
};
struct M2ModelLight {
M2ModelTrack_C3Vector ambientColorTrack;
M2ModelTrack_float ambientIntensityTrack;
M2ModelTrack_C3Vector diffuseColorTrack;
M2ModelTrack_float diffuseIntensityTrack;
M2ModelTrack_uint8_t visibilityTrack;
uint32_t uint64;
CM2Light light;
};
struct M2ModelRibbon {
uint32_t dword0;
uint32_t dword4;
uint32_t dword8;
uint32_t dwordC;
uint32_t dword10;
uint32_t dword14;
uint32_t dword18;
uint32_t dword1C;
uint32_t dword20;
uint32_t dword24;
uint32_t dword28;
uint32_t dword2C;
uint32_t dword30;
uint32_t dword34;
uint32_t dword38;
uint32_t dword3C;
uint32_t dword40;
uint32_t dword44;
uint32_t dword48;
uint32_t dword4C;
};
struct M2ModelTextureTransform {
int32_t unk;
};
struct M2ModelTextureWeight {
M2ModelTrack_float weightTrack;
};
struct M2ModelOptGeo {
M2Batch* batches;
uint32_t dword4;
M2SkinSection* skinSections;
uint32_t dwordC;
uint32_t dword10;
uint32_t dword14;
uint32_t dword18;
CShaderEffect** effects;
uint32_t dword20;
uint32_t dword24;
uint32_t dword28;
uint32_t dword2C;
uint32_t dword30;
uint32_t dword34;
uint32_t dword38;
uint32_t dword3C;
uint32_t dword40;
uint32_t dword44;
uint32_t dword48;
uint32_t dword4C;
};
struct CM2ModelCall {
uint32_t type;
CM2ModelCall* modelCallNext;
uint32_t time;
uint32_t args[8];
};
struct CM2Model {
uint32_t m_refCount;
uint32_t m_flags;
CM2Model** m_scenePrev;
CM2Model* m_sceneNext;
// uint32_t m_loaded : 1;
// uint32_t m_flag2 : 1;
// uint32_t m_flag4 : 1;
// uint32_t m_flag8 : 1;
// uint32_t m_flag10 : 1;
// uint32_t m_flag20 : 1;
// uint32_t m_flag40 : 1;
// uint32_t m_flag80 : 1;
// uint32_t m_flag100 : 1;
// uint32_t m_flag200 : 1;
// uint32_t m_flag400 : 1;
// uint32_t m_flag800 : 1;
// uint32_t m_flag1000 : 1;
// uint32_t m_flag2000 : 1;
// uint32_t m_flag4000 : 1;
// uint32_t m_flag8000 : 1;
// uint32_t m_flag10000 : 1;
// uint32_t m_flag20000 : 1;
// uint32_t m_flag40000 : 1;
// uint32_t m_flag80000 : 1;
// uint32_t m_flag100000 : 1;
// uint32_t m_flag200000 : 1;
// uint32_t m_flag400000 : 1;
uint32_t f_flags;
uint32_t dword14;
CM2Model** m_callbackPrev;
CM2Model* m_callbackNext;
void* m_loadedCallback;
void* m_loadedArg;
CM2Scene* m_scene;
CM2Shared* m_shared;
CM2Model* model30;
CM2ModelCall* m_modelCallList;
CM2ModelCall** m_modelCallTail;
uint32_t dword3C;
CM2Model** m_animatePrev;
CM2Model* m_animateNext;
CM2Model* m_attachParent;
void* m_attachments;
uint32_t dword50;
uint32_t dword54;
CM2Model* model58;
uint32_t dword5C;
CM2Model* model60;
uint32_t m_time;
CM2Model** m_drawPrev;
CM2Model* m_drawNext;
uint32_t* m_loops;
uint32_t uint74;
uint32_t dword78;
uint32_t dword7C;
uint32_t dword80;
uint32_t dword84;
float float88;
uint32_t uint8C;
uint32_t uint90;
M2ModelBone* m_bones;
C44Matrix* m_boneMatrices;
void* m_skinSections;
M2ModelColor* m_colors;
HTEXTURE* m_textures;
M2ModelTextureWeight* m_textureWeights;
void* m_textureTransforms;
C44Matrix* m_textureMatrices;
C44Matrix matrixB4;
C44Matrix matrixF4;
C44Matrix matrix134;
uint32_t dword174;
float m_alpha;
uint32_t dword17C;
uint32_t dword180;
uint32_t dword184;
uint32_t dword188;
uint32_t dword18C;
uint32_t dword190;
uint32_t dword194;
float float198;
float alpha19C;
C3Vector m_currentDiffuse;
C3Vector m_currentEmissive;
uint32_t dword1B8;
void* m_drawCallback;
uint32_t dword1C0;
uint32_t dword1C4;
uint32_t dword1C8;
uint32_t dword1CC;
M2ModelLight* m_lights;
CM2Lighting m_lighting;
CM2Lighting* m_currentLighting;
void* m_lightingCallback;
void* m_lightingArg;
M2ModelCamera* m_cameras;
M2ModelRibbon* m_ribbons;
CRibbonEmitter* m_ribbonEmitters;
void* m_particles;
uint32_t dword2C4;
uint32_t dword2C8;
uint32_t dword2CC;
M2ModelOptGeo* m_optGeo;
uint32_t dword2D4;
uint32_t dword2D8;
uint32_t dword2DC;
uint32_t dword2E0;
uint32_t dword2E4;
uint32_t dword2E8;
uint32_t dword2EC;
};
#endif

View file

@ -0,0 +1,115 @@
#ifndef M2_RIBBON_H
#define M2_RIBBON_H
#include "system/types.h"
#include "gx/types.h"
#include "gx/texture.h"
#include "storm/array.h"
#include "storm/array/uint32_t.h"
#include "tempest/vector.h"
DECLARE_STRUCT(CRibbonMat);
DECLARE_STRUCT(CRibbonEmitter);
struct CRibbonMat {
// int32 enableLighting : 1;
// int32 enableFog : 1;
// int32 enableDepthTest : 1;
// int32 enableDepthWrite : 1;
// int32 enableCulling : 1;
uint32_t f_flags;
EGxBlend alpha;
};
STORM_TS_GROWABLE_ARRAY(CRibbonMat);
struct CRibbonEmitter {
uint32_t m_refCount;
uint32_t dword4;
uint32_t dword8;
uint32_t dwordC;
uint32_t dword10;
uint32_t dword14;
uint32_t dword18;
uint32_t dword1C;
uint32_t dword20;
uint32_t dword24;
uint32_t dword28;
uint32_t dword2C;
uint32_t dword30;
uint32_t dword34;
uint32_t dword38;
uint32_t dword3C;
uint32_t dword40;
uint32_t dword44;
uint32_t dword48;
uint32_t dword4C;
uint32_t dword50;
uint32_t dword54;
float m_ooLifeSpan;
float m_tmpDU;
float m_tmpDV;
float m_ooTmpDU;
float m_ooTmpDV;
uint32_t dword6C;
uint32_t dword70;
uint32_t dword74;
uint32_t dword78;
uint32_t dword7C;
uint32_t dword80;
uint32_t dword84;
uint32_t dword88;
uint32_t dword8C;
uint32_t dword90;
uint32_t dword94;
uint32_t dword98;
uint32_t dword9C;
uint32_t dwordA0;
uint32_t dwordA4;
uint32_t dwordA8;
uint32_t dwordAC;
uint32_t dwordB0;
uint32_t dwordB4;
uint32_t dwordB8;
uint32_t dwordBC;
uint32_t dwordC0;
uint32_t dwordC4;
uint32_t dwordC8;
uint32_t dwordCC;
uint32_t dwordD0;
uint32_t dwordD4;
uint32_t dwordD8;
uint32_t dwordDC;
uint32_t dwordE0;
uint32_t dwordE4;
uint32_t dwordE8;
uint32_t dwordEC;
uint32_t dwordF0;
uint32_t dwordF4;
uint32_t dwordF8;
uint32_t dwordFC;
uint32_t dword100;
uint32_t dword104;
uint32_t dword108;
uint32_t dword10C;
float m_edgeLifeSpan;
TSGrowableArray_CRibbonMat m_materials;
TSGrowableArray_HTEXTURE m_textures;
TSGrowableArray_uint32_t m_replaces;
CImVector m_diffuseClr;
uint32_t dword148;
uint32_t dword14C;
uint32_t dword150;
uint32_t dword154;
uint32_t dword158;
uint32_t dword15C;
uint32_t dword160;
uint32_t dword164;
uint32_t dword168;
uint32_t dword16C;
uint32_t m_texSlot;
float m_above;
float m_below;
float m_gravity;
};
#endif

View file

@ -0,0 +1,51 @@
#ifndef M2_SCENE_H
#define M2_SCENE_H
DECLARE_STRUCT(CM2Scene);
#include "m2/cache.h"
#include "m2/types.h"
#include "m2/model.h"
#include "m2/light.h"
#include "storm/array/uint32_t.h"
#include "tempest/matrix.h"
struct CM2Scene {
uint32_t dword0;
CM2Cache* m_cache;
CM2Model* m_modelList;
uint32_t m_time;
uint32_t uint10;
uint32_t uint14;
uint32_t dword18;
uint32_t m_flags;
CM2Light* m_lightList;
uint32_t dword24;
CM2Model* m_animateList;
CM2Model* m_drawList;
uint32_t dword30;
TSGrowableArray_M2Element m_elements;
TSGrowableArray_uint32_t array44;
TSGrowableArray_uint32_t array54[3];
C44Matrix m_view;
C44Matrix m_viewInv;
uint32_t uint104;
uint32_t dword108;
uint32_t dword10C;
uint32_t dword110;
uint32_t dword114;
uint32_t dword118;
uint32_t dword11C;
uint32_t dword120;
uint32_t dword124;
uint32_t m_hitList;
uint32_t dword12C;
uint32_t dword130;
uint32_t dword134;
uint32_t dword138;
uint32_t dword13C;
uint32_t dword140;
uint32_t dword144;
};
#endif

View file

@ -0,0 +1,28 @@
#ifndef M2_SHADER_EFFECT
#define M2_SHADER_EFFECT
DECLARE_STRUCT(CShaderEffect);
DECLARE_STRUCT(CShaderEffect_LocalLights);
#include "storm/hash.h"
#include "gx/shader.h"
STORM_TS_HASH(CShaderEffect, HASHKEY_STRI);
struct CShaderEffect_LocalLights {
float float0[44];
};
// class CShaderEffect : public TSHashObject<CShaderEffect, HASHKEY_STRI>
struct CShaderEffect {
TSHashObject_CShaderEffect_HASHKEY_STRI b_base;
uint32_t dword18;
uint32_t dword1C;
uint32_t dword20;
uint32_t dword24;
uint32_t dword28;
CGxShader* vertexShaders[90];
CGxShader* pixelShaders[16];
};
#endif

View file

@ -0,0 +1,52 @@
#ifndef M2_SHARED_H
#define M2_SHARED_H
DECLARE_STRUCT(CM2Shared);
#include "tempest/box.h"
#include "async/object.h"
#include "m2/cache.h"
#include "m2/model.h"
#include "m2/shadereffect.h"
struct CM2Shared {
uint32_t m_refCount;
CM2Cache* m_cache;
uint32_t m_flags;
CAsyncObject* asyncObject;
CM2Model* m_callbackList;
CM2Model** m_callbackTail;
uint32_t dword18;
uint32_t dword1C;
uint32_t dword20;
uint32_t numLowPrioritySequences;
void* lowPrioritySequences;
uint32_t dword2C;
CM2Shared** m_freePrev;
CM2Shared* m_freeNext;
uint32_t dword38;
uint8_t m_filePath[260];
uint8_t* ext;
uint32_t dword144;
uint32_t dword148;
uint32_t dword14C;
M2Data* data;
CAaBox aaBox154;
uint32_t size;
M2SkinProfile* skinProfile;
HTEXTURE* textures;
CGxPool* m_indexPool;
CGxBuf* m_indexBuf;
CGxPool* m_vertexPool;
CGxBuf* m_vertexBuf;
CShaderEffect** m_batchShaders;
M2SkinSection* m_skinSections;
uint32_t uint190;
uint32_t uint194;
uint32_t dword198;
uint32_t dword19C;
uint32_t dword1A0;
uint32_t dword1A4;
};
#endif

View file

@ -0,0 +1,73 @@
#ifndef M2_TYPES_HPP
#define M2_TYPES_HPP
#include "m2/data.h"
#include "storm/array.h"
DECLARE_STRUCT(CM2Model);
DECLARE_STRUCT(CShaderEffect);
DECLARE_ENUM(M2BLEND);
DECLARE_ENUM(M2COMBINER);
DECLARE_ENUM(M2LIGHTTYPE);
DECLARE_ENUM(M2PASS);
DECLARE_STRUCT(M2Element);
enum M2BLEND {
M2BLEND_OPAQUE = 0x0,
M2BLEND_ALPHA_KEY = 0x1,
M2BLEND_ALPHA = 0x2,
M2BLEND_NO_ALPHA_ADD = 0x3,
M2BLEND_ADD = 0x4,
M2BLEND_MOD = 0x5,
M2BLEND_MOD_2X = 0x6,
M2BLEND_COUNT = 0x7,
};
enum M2COMBINER {
M2COMBINER_OPAQUE = 0x0,
M2COMBINER_MOD = 0x1,
M2COMBINER_DECAL = 0x2,
M2COMBINER_ADD = 0x3,
M2COMBINER_MOD2X = 0x4,
M2COMBINER_FADE = 0x5,
M2COMBINER_MOD2X_NA = 0x6,
M2COMBINER_ADD_NA = 0x7,
M2COMBINER_OP_MASK = 0x7,
M2COMBINER_ENVMAP = 0x8,
M2COMBINER_STAGE_SHIFT = 0x4,
};
enum M2LIGHTTYPE {
M2LIGHT_0 = 0,
M2LIGHT_1 = 1
};
enum M2PASS {
M2PASS_0 = 0,
M2PASS_1 = 1,
M2PASS_2 = 2,
M2PASS_COUNT = 3
};
struct M2Element {
int32_t type;
CM2Model* model;
uint32_t flags;
float alpha;
float float10;
float float14;
int32_t index;
int32_t priorityPlane;
M2Batch* batch;
M2SkinSection* skinSection;
CShaderEffect* effect;
uint32_t vertexPermute;
uint32_t pixelPermute;
uint32_t dword3C;
uint32_t dword40;
};
STORM_TS_GROWABLE_ARRAY(M2Element);
#endif

View file

@ -0,0 +1,115 @@
// Defines
#include "system/detect.h"
// Types (include all files to expose them in the disassembler)
// external types (c-ified)
#include "external/d3d9/caps.h"
#include "external/d3d9/device.h"
#include "external/lua/lua.h"
#include "async/object.h"
#include "async/queue.h"
#include "camera/camera.h"
#include "cmd/option.h"
#include "common/array.h"
#include "common/handle.h"
#include "common/instance.h"
#include "common/datarecycler.h"
#include "common/status.h"
#include "common/refcount.h"
#include "common/rcstring.h"
#include "cursor/types.h"
#include "event/types.h"
#include "event/context.h"
#include "event/handler.h"
#include "event/id_table.h"
#include "event/keydown.h"
#include "event/message.h"
#include "event/timer.h"
#include "framescript/object.h"
#include "framescript/event_object.h"
#include "gx/batch.h"
#include "gx/buffer.h"
#include "gx/caps.h"
#include "gx/device.h"
#include "gx/format.h"
#include "gx/matrix_stack.h"
#include "gx/opengl.h"
#include "gx/shader.h"
#include "gx/state_bom.h"
#include "gx/string.h"
#include "gx/stringbatch.h"
#include "gx/texture.h"
#include "gx/types.h"
#include "gx/batch.h"
#include "gx/d3d9.h"
#include "m2/cache.h"
#include "m2/data.h"
#include "m2/light.h"
#include "m2/lighting.h"
#include "m2/model.h"
#include "m2/ribbon.h"
#include "m2/scene.h"
#include "m2/shadereffect.h"
#include "m2/shared.h"
#include "m2/types.h"
#include "screen/layer.h"
#include "storm/array.h"
#include "storm/big.h"
#include "storm/cmd.h"
#include "storm/list.h"
#include "storm/hash.h"
#include "storm/queue.h"
#include "storm/region.h"
#include "storm/thread.h"
#include "tempest/box.h"
#include "tempest/matrix.h"
#include "tempest/plane.h"
#include "tempest/quaternion.h"
#include "tempest/range.h"
#include "tempest/rect.h"
#include "tempest/sphere.h"
#include "tempest/vector.h"
#include "texture/blp.h"
#include "texture/texture.h"
#include "texture/tga.h"
#include "ui/backdropgenerator.h"
#include "ui/framestrata.h"
#include "ui/layoutframe.h"
#include "ui/renderbatch.h"
#include "ui/scriptobject.h"
#include "ui/scriptregion.h"
#include "ui/simplebatchedmesh.h"
#include "ui/simpleframe.h"
#include "ui/simpleregion.h"
#include "ui/simpletexture.h"
#include "ui/simpletop.h"
// include files that define the use of template classes for standard library types
// template classes for whoa types should be entered immediately after where the type is
#include "storm/array/pointer_to_void.h"
#include "storm/array/uint8_t.h"
#include "storm/array/uint32_t.h"
#include "storm/queue/timer_priority_uint32_t.h"
// template types that are defined in our headers, should be declared immediately after the base type
// and not used anywhere else

View file

@ -0,0 +1,24 @@
#ifndef SCREEN_LAYER_H
#define SCREEN_LAYER_H
#include "storm/list.h"
#include "common/handle.h"
#include "storm/region/rect.h"
DECLARE_HANDLE(HLAYER);
DECLARE_STRUCT(CILayer);
STORM_TS_LIST(CILayer);
struct CILayer {
CHandleObject b_base;
RECTF rect;
RECTF visible;
float zorder;
uint32_t flags;
void* param;
void (*paintfunc)(void*, RECTF*, RECTF*, float);
TSLink_CILayer zorderlink;
};
#endif

View file

@ -0,0 +1,52 @@
#ifndef STORM_ARRAY_H
#define STORM_ARRAY_H
#include "system/types.h"
#define STORM_TS_BASE_ARRAY(T) typedef struct TSBaseArray_##T TSBaseArray_##T; \
struct TSBaseArray_##T { \
uint32_t m_alloc; \
uint32_t m_count; \
T* m_data; \
};
#define STORM_TS_FIXED_ARRAY(T) typedef struct TSFixedArray_##T TSFixedArray_##T; \
struct TSFixedArray_##T { \
uint32_t m_alloc; \
uint32_t m_count; \
T* m_data; \
};
#define STORM_TS_GROWABLE_ARRAY(T) typedef struct TSGrowableArray_##T TSGrowableArray_##T; \
struct TSGrowableArray_##T { \
uint32_t m_alloc; \
uint32_t m_count; \
T* m_data; \
uint32_t m_chunk; \
};
// "pointer-to" types hack
#define STORM_TS_BASE_ARRAY_POINTER_TO(T) typedef struct TSBaseArray_pointer_to_##T TSBaseArray_pointer_to_##T; \
struct TSBaseArray_pointer_to_##T { \
uint32_t m_alloc; \
uint32_t m_count; \
T** m_data; \
};
#define STORM_TS_FIXED_ARRAY_POINTER_TO(T) typedef struct TSFixedArray_pointer_to_##T TSFixedArray_pointer_to_##T; \
struct TSFixedArray_pointer_to_##T { \
uint32_t m_alloc; \
uint32_t m_count; \
T** m_data; \
};
#define STORM_TS_GROWABLE_ARRAY_POINTER_TO(T) typedef struct TSGrowableArray_pointer_to_##T TSGrowableArray_pointer_to_##T; \
struct TSGrowableArray_pointer_to_##T { \
uint32_t m_alloc; \
uint32_t m_count; \
T** m_data; \
uint32_t m_chunk; \
};
#endif

View file

@ -0,0 +1,10 @@
#ifndef STORM_ARRAY_C_2_VECTOR_H
#define STORM_ARRAY_C_2_VECTOR_H
#include "tempest/vector.h"
#include "storm/array.h"
STORM_TS_GROWABLE_ARRAY(C2Vector);
#endif

View file

@ -0,0 +1,10 @@
#ifndef STORM_ARRAY_C_3_VECTOR_H
#define STORM_ARRAY_C_3_VECTOR_H
#include "tempest/vector.h"
#include "storm/array.h"
STORM_TS_GROWABLE_ARRAY(C3Vector);
#endif

View file

@ -0,0 +1,10 @@
#ifndef STORM_ARRAY_C_IM_VECTOR_H
#define STORM_ARRAY_C_IM_VECTOR_H
#include "tempest/vector.h"
#include "storm/array.h"
STORM_TS_GROWABLE_ARRAY(CImVector);
#endif

View file

@ -0,0 +1,10 @@
#ifndef STORM_ARRAY_POINTER_TO_VOID_H
#define STORM_ARRAY_POINTER_TO_VOID_H
#include "system/types.h"
#include "storm/array.h"
STORM_TS_GROWABLE_ARRAY_POINTER_TO(void);
#endif

View file

@ -0,0 +1,10 @@
#ifndef STORM_ARRAY_UINT16_T_H
#define STORM_ARRAY_UINT16_T_H
#include "system/types.h"
#include "storm/array.h"
STORM_TS_GROWABLE_ARRAY(uint16_t);
#endif

View file

@ -0,0 +1,10 @@
#ifndef STORM_ARRAY_UINT32_T_H
#define STORM_ARRAY_UINT32_T_H
#include "system/types.h"
#include "storm/array.h"
STORM_TS_GROWABLE_ARRAY(uint32_t);
#endif

View file

@ -0,0 +1,10 @@
#ifndef STORM_ARRAY_UINT8_T_H
#define STORM_ARRAY_UINT8_T_H
#include "system/types.h"
#include "storm/array.h"
STORM_TS_GROWABLE_ARRAY(uint8_t);
#endif

View file

@ -0,0 +1,27 @@
#ifndef STORM_BIG_H
#define STORM_BIG_H
DECLARE_STRUCT(BigData);
DECLARE_STRUCT(BigBuffer);
DECLARE_STRUCT(BigStack);
#include "storm/array/uint8_t.h"
#include "storm/array/uint32_t.h"
struct BigBuffer {
TSGrowableArray_uint32_t m_data;
uint32_t m_offset;
};
struct BigStack {
BigBuffer m_buffer[16];
uint32_t m_used;
};
struct BigData {
BigBuffer m_primary;
BigStack m_stack;
TSGrowableArray_uint8_t m_output;
};
#endif

View file

@ -0,0 +1,78 @@
#ifndef STORM_CMD_H
#define STORM_CMD_H
DECLARE_STRUCT(ARGLIST);
DECLARE_STRUCT(CMDPARAMS);
DECLARE_STRUCT(CMDDEF);
STORM_TS_LIST(CMDDEF);
DECLARE_STRUCT(CMDERROR);
DECLARE_STRUCT(PROCESSING);
#include "storm/list.h"
// Callback types
typedef int32_t (*CMDEXTRACALLBACK)(const char*);
typedef int32_t (*CMDERRORCALLBACK)(CMDERROR*);
typedef int32_t (*CMDPARAMSCALLBACK)(CMDPARAMS*, const char*);
// Details a command line argument
// class ARGLIST
struct ARGLIST {
uint32_t flags;
uint32_t id;
const char* name;
CMDPARAMSCALLBACK callback;
};
// Parameters passed to argument callback
// class CMDPARAMS
struct CMDPARAMS {
uint32_t flags;
uint32_t id;
const char* name;
void* variable;
uint32_t setvalue;
uint32_t setmask;
union {
int32_t boolvalue;
int32_t signedvalue;
uint32_t unsignedvalue;
const char* stringvalue;
};
};
// Command definitions
// class CMDDEF : public TSLinkedNode<CMDDEF>
struct CMDDEF {
TSLinkedNode_CMDDEF b_base;
uint32_t flags;
uint32_t id;
char name[16];
int32_t namelength;
uint32_t setvalue;
uint32_t setmask;
void* variableptr;
uint32_t variablebytes;
CMDPARAMSCALLBACK callback;
int32_t found;
union {
uint32_t currvalue;
char* currvaluestr;
};
};
// class CMDERROR
struct CMDERROR {
uint32_t errorcode;
const char* itemstr;
const char* errorstr;
};
// class PROCESSING
struct PROCESSING {
CMDDEF* ptr;
char name[16];
int32_t namelength;
};
#endif

View file

@ -0,0 +1,9 @@
#ifndef STORM_FILE_H
#define STORM_FILE_H
DECLARE_STRUCT(SFile);
struct SFile {
};
#endif

View file

@ -0,0 +1,49 @@
#ifndef STORM_HASH_H
#define STORM_HASH_H
#include "system/types.h"
#include "storm/array.h"
#include "storm/list.h"
#define STORM_TS_HASH(T, K) \
STORM_TS_LIST(T); \
STORM_TS_GROWABLE_ARRAY(TSList_##T); \
typedef struct TSHashTable_##T##_##K TSHashTable_##T##_##K; \
typedef struct TSHashObject_##T##_##K TSHashObject_##T##_##K; \
struct TSHashTable_##T##_##K { \
void** v_table; \
TSList_##T m_fulllist; \
uint32_t m_fullnessIndicator; \
TSGrowableArray_TSList_##T m_slotlistarray; \
uint32_t m_slotmask; \
}; \
struct TSHashObject_##T##_##K { \
uint32_t m_hashval; \
TSLink_##T m_linktoslot; \
TSLink_##T m_linktofull; \
K m_key; \
}
DECLARE_STRUCT(HASHKEY_PTR);
DECLARE_STRUCT(HASHKEY_STR);
DECLARE_STRUCT(HASHKEY_STRI);
DECLARE_STRUCT(HASHKEY_NONE);
struct HASHKEY_PTR {
void* m_key;
};
struct HASHKEY_STR {
char* m_str;
};
struct HASHKEY_STRI {
char* m_str;
};
struct HASHKEY_NONE {
int32_t m_unused;
};
#endif

View file

@ -0,0 +1,30 @@
#ifndef STORM_LIST_H
#define STORM_LIST_H
#include "system/types.h"
// TSLink<T>
#define STORM_TS_LINK(T) typedef struct TSLink_##T TSLink_##T; \
struct TSLink_##T { \
TSLink_##T* m_prevlink; \
T* m_next; \
}
// TSList<T>
// TSExplicitList<T>
// TSLinkedNode<T>
#define STORM_TS_LIST(T) \
STORM_TS_LINK(T); \
typedef struct TSList_##T TSList_##T; \
typedef struct TSList_##T TSExplicitList_##T; \
typedef struct TSLinkedNode_##T TSLinkedNode_##T; \
struct TSList_##T { \
ptrdiff_t m_linkoffset; \
TSLink_##T m_terminator; \
}; \
struct TSLinkedNode_##T { \
TSLink_##T m_link; \
}; \
typedef TSList_##T TSExplicitList_##T
#endif

View file

@ -0,0 +1,31 @@
#ifndef STORM_QUEUE_H
#define STORM_QUEUE_H
#include "system/types.h"
#include "storm/array/pointer_to_void.h"
DECLARE_STRUCT(CSBasePriorityQueue);
DECLARE_STRUCT(CSBasePriority);
struct CSBasePriorityQueue {
TSGrowableArray_pointer_to_void b_base;
uint32_t m_linkOffset;
};
struct CSBasePriority {
CSBasePriorityQueue* m_queue;
uint32_t m_index;
};
#define STORM_TS_TIMER_PRIORITY(T) \
typedef struct TSTimerPriority_##T TSTimerPriority_##T; \
struct TSTimerPriority_##T { \
CSBasePriority b_base; \
T m_val; \
}
#define STORM_TS_PRIORITY_QUEUE(T) \
typedef CSBasePriorityQueue TSPriorityQueue_##T
#endif

View file

@ -0,0 +1,10 @@
#ifndef STORM_QUEUE_TIMER_PRIORITY_UINT32_T_H
#define STORM_QUEUE_TIMER_PRIORITY_UINT32_T_H
#include "system/types.h"
#include "storm/queue.h"
STORM_TS_TIMER_PRIORITY(uint32_t);
#endif

View file

@ -0,0 +1,9 @@
#ifndef STORM_REGION_H
#define STORM_REGION_H
#include "storm/region/found_param.h"
#include "storm/region/rect.h"
#include "storm/region/source.h"
#include "storm/region/region.h"
#endif

View file

@ -0,0 +1,14 @@
#ifndef STORM_REGION_FOUND_PARAM_H
#define STORM_REGION_FOUND_PARAM_H
#include "storm/array.h"
DECLARE_STRUCT(FOUNDPARAM);
struct FOUNDPARAM {
void* param;
int32_t sequence;
};
STORM_TS_GROWABLE_ARRAY(FOUNDPARAM);
#endif

View file

@ -0,0 +1,16 @@
#ifndef STORM_REGION_RECT_H
#define STORM_REGION_RECT_H
#include "storm/array.h"
DECLARE_STRUCT(RECTF);
struct RECTF {
float left;
float bottom;
float right;
float top;
};
STORM_TS_GROWABLE_ARRAY(RECTF);
#endif

View file

@ -0,0 +1,31 @@
#ifndef STORM_REGION_REGION_H
#define STORM_REGION_REGION_H
#include "common/handle.h"
#include "storm/hash.h"
#include "storm/region/source.h"
#include "storm/region/rect.h"
#include "storm/region/found_param.h"
DECLARE_HANDLE(HSRGN);
DECLARE_HANDLE(HLOCKEDRGN);
DECLARE_STRUCT(RGN);
DECLARE_STRUCT(CSRgn);
STORM_TS_HASH(RGN, HASHKEY_NONE);
struct RGN {
TSHashObject_RGN_HASHKEY_NONE b_base;
TSGrowableArray_SOURCE source;
TSGrowableArray_RECTF combined;
TSGrowableArray_FOUNDPARAM foundparams;
RECTF foundparamsrect;
int32_t sequence;
int32_t dirty;
};
struct CSRgn {
HSRGN m_handle;
};
#endif

View file

@ -0,0 +1,17 @@
#ifndef STORM_REGION_SOURCE_H
#define STORM_REGION_SOURCE_H
#include "storm/array.h"
#include "storm/region/rect.h"
DECLARE_STRUCT(SOURCE);
struct SOURCE {
RECTF rect;
void* param;
int32_t sequence;
uint32_t flags;
};
STORM_TS_GROWABLE_ARRAY(SOURCE);
#endif

View file

@ -0,0 +1,17 @@
#ifndef STORM_THREAD_H
#define STORM_THREAD_H
#include "system/types.h"
DECLARE_STRUCT(SCritSect);
typedef struct CSRWLock CSRWLock;
struct SCritSect {
uint8_t m_critsect[24];
};
struct CSRWLock {
uint8_t m_opaqueData[12];
};
#endif

View file

@ -0,0 +1,21 @@
#ifndef SYSTEM_DETECT_H
#define SYSTEM_DETECT_H
#if !defined(IDA) && !defined(GHIDRA) && !defined(BINANA_GENERATOR)
#error "Preprocessor mode not detected! You must define either IDA or GHIDRA or BINANA_GENERATOR"
#endif
#if defined(IDA)
// why does this work?
#define DECLARE_ENUM(E) typedef enum E##__ E
#else
#define DECLARE_ENUM(E) typedef enum E E
#endif
#define DECLARE_STRUCT(T) typedef struct T T
#endif

View file

@ -0,0 +1,6 @@
#ifndef SYSTEM_LIMITS_H
#define SYSTEM_LIMITS_H
#define INT_MAX 2147483647
#endif

View file

@ -0,0 +1,77 @@
#ifndef SYSTEM_TYPES_H
#define SYSTEM_TYPES_H
// stdint
#if defined(IDA) || defined(BINANA_GENERATOR)
typedef signed char int8_t;
typedef short int16_t;
typedef int int32_t;
typedef long long int64_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;
typedef int32_t ptrdiff_t;
typedef uint32_t uintptr_t;
typedef int32_t intptr_t;
#else
#include <stdint.h>
#endif
// stdbool
#if defined(BINANA_GENERATOR)
typedef char bool;
#endif
#if defined(GHIDRA)
#include <stdbool.h>
#endif
// stddef
#if defined(GHIDRA)
#include <stddef.h>
#else
typedef uint32_t size_t;
#endif
// stdarg
#if defined(GHIDRA)
#include <stdarg.h>
#else
typedef char* va_list;
#endif
// other types
typedef struct fixed16 fixed16;
struct fixed16 {
int16_t n;
};
struct ubyte4 {
union {
uint8_t b[4];
uint32_t u;
};
};
#endif

View file

@ -0,0 +1,21 @@
#ifndef TEMPEST_BOX_H
#define TEMPEST_BOX_H
#include "tempest/vector.h"
#include "tempest/range.h"
DECLARE_STRUCT(CAaBox);
DECLARE_STRUCT(CBoundingBox);
struct CAaBox {
C3Vector b;
C3Vector t;
};
struct CBoundingBox {
CRange x;
CRange y;
CRange z;
};
#endif

Some files were not shown because too many files have changed in this diff Show more