Lua: Basic groundwork. Needs a lot more.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4364 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
XTra.KrazzY 2009-10-05 22:59:11 +00:00
parent 89a1677365
commit 58df543e6a
3 changed files with 5115 additions and 1 deletions

File diff suppressed because it is too large Load Diff

View File

@ -20,6 +20,92 @@
namespace Lua {
void OpenLuaContext(int uid, void(*print)(int uid, const char* str) = 0, void(*onstart)(int uid) = 0, void(*onstop)(int uid, bool statusOK) = 0);
void RunLuaScriptFile(int uid, const char* filename);
void StopLuaScript(int uid);
void RequestAbortLuaScript(int uid, const char* message = 0);
void CloseLuaContext(int uid);
enum LuaCallID
{
LUACALL_BEFOREEMULATION,
LUACALL_AFTEREMULATION,
LUACALL_AFTEREMULATIONGUI,
LUACALL_BEFOREEXIT,
LUACALL_BEFORESAVE,
LUACALL_AFTERLOAD,
LUACALL_ONSTART,
LUACALL_SCRIPT_HOTKEY_1,
LUACALL_SCRIPT_HOTKEY_2,
LUACALL_SCRIPT_HOTKEY_3,
LUACALL_SCRIPT_HOTKEY_4,
LUACALL_SCRIPT_HOTKEY_5,
LUACALL_SCRIPT_HOTKEY_6,
LUACALL_SCRIPT_HOTKEY_7,
LUACALL_SCRIPT_HOTKEY_8,
LUACALL_SCRIPT_HOTKEY_9,
LUACALL_SCRIPT_HOTKEY_10,
LUACALL_SCRIPT_HOTKEY_11,
LUACALL_SCRIPT_HOTKEY_12,
LUACALL_SCRIPT_HOTKEY_13,
LUACALL_SCRIPT_HOTKEY_14,
LUACALL_SCRIPT_HOTKEY_15,
LUACALL_SCRIPT_HOTKEY_16,
LUACALL_COUNT
};
void CallRegisteredLuaFunctions(LuaCallID calltype);
enum LuaMemHookType
{
LUAMEMHOOK_WRITE,
LUAMEMHOOK_READ,
LUAMEMHOOK_EXEC,
LUAMEMHOOK_WRITE_SUB,
LUAMEMHOOK_READ_SUB,
LUAMEMHOOK_EXEC_SUB,
LUAMEMHOOK_COUNT
};
void CallRegisteredLuaMemHook(unsigned int address, int size, unsigned int value, LuaMemHookType hookType);
struct LuaSaveData
{
LuaSaveData() { recordList = 0; }
~LuaSaveData() { ClearRecords(); }
struct Record
{
unsigned int key; // crc32
unsigned int size; // size of data
unsigned char* data;
Record* next;
};
Record* recordList;
void SaveRecord(int uid, unsigned int key); // saves Lua stack into a record and pops it
void LoadRecord(int uid, unsigned int key, unsigned int itemsToLoad) const; // pushes a record's data onto the Lua stack
void SaveRecordPartial(int uid, unsigned int key, int idx); // saves part of the Lua stack (at the given index) into a record and does NOT pop anything
void ExportRecords(void* file) const; // writes all records to an already-open file
void ImportRecords(void* file); // reads records from an already-open file
void ClearRecords(); // deletes all record data
private:
// disallowed, it's dangerous to call this
// (because the memory the destructor deletes isn't refcounted and shouldn't need to be copied)
// so pass LuaSaveDatas by reference and this should never get called
LuaSaveData(const LuaSaveData& copy) {}
};
void CallRegisteredLuaSaveFunctions(int savestateNumber, LuaSaveData& saveData);
void CallRegisteredLuaLoadFunctions(int savestateNumber, const LuaSaveData& saveData);
void StopAllLuaScripts();
void RestartAllLuaScripts();
void EnableStopAllLuaScripts(bool enable);
void DontWorryLua();

View File

@ -25,7 +25,7 @@
namespace Frame {
// Enumerations and structs
enum PlayMode {
MODE_NONE = 0,
MODE_RECORDING,
@ -43,6 +43,18 @@ typedef struct {
bool reserved[6]; // Reserved bits, 6 bits
} ControllerState; // Total: 58 + 6 = 64 bits per frame
// Global declarations
extern bool g_bFrameStep, g_bAutoFire, g_bFirstKey, g_bPolled;
extern u32 g_autoFirstKey, g_autoSecondKey;
extern PlayMode g_playMode;
extern int g_framesToSkip, g_frameSkipCounter, g_numPads;
extern ControllerState *g_padStates;
extern FILE *g_recordfd;
extern u64 g_frameCounter, g_lagCounter;
typedef struct {
u8 filetype[4]; // Unique Identifier (always "DTM"0x1A)