Lua - new registration system added to NES and SNES libraries

This commit is contained in:
adelikat 2014-01-26 03:26:52 +00:00
parent ac9e4c1d3d
commit 583be2516c
3 changed files with 151 additions and 35 deletions

View File

@ -5,6 +5,10 @@ namespace BizHawk.Client.Common
{ {
public class NESLuaLibrary : LuaLibraryBase public class NESLuaLibrary : LuaLibraryBase
{ {
// TODO:
// perhaps with the new core config system, one could
// automatically bring out all of the settings to a lua table, with names. that
// would be completely arbitrary and would remove the whole requirement for this mess
public override string Name { get { return "nes"; } } public override string Name { get { return "nes"; } }
public override string[] Functions public override string[] Functions
{ {
@ -29,7 +33,11 @@ namespace BizHawk.Client.Common
} }
} }
public void nes_addgamegenie(string code) [LuaMethodAttributes(
"addgamegenie",
"TODO"
)]
public void AddGameGenie(string code)
{ {
if (Global.Emulator.SystemId == "NES") if (Global.Emulator.SystemId == "NES")
{ {
@ -50,15 +58,20 @@ namespace BizHawk.Client.Common
} }
} }
// these methods are awkward. perhaps with the new core config system, one could [LuaMethodAttributes(
// automatically bring out all of the settings to a lua table, with names. that "getallowmorethaneightsprites",
// would be completely arbitrary and would remove the whole requirement for this mess "TODO"
public static bool nes_getallowmorethaneightsprites() )]
public static bool GetAllowMoreThanEightSprites()
{ {
return ((NES.NESSettings)Global.Emulator.GetSettings()).AllowMoreThanEightSprites; return ((NES.NESSettings)Global.Emulator.GetSettings()).AllowMoreThanEightSprites;
} }
public static int nes_getbottomscanline(bool pal = false) [LuaMethodAttributes(
"getbottomscanline",
"TODO"
)]
public static int GetBottomScanline(bool pal = false)
{ {
if (pal) if (pal)
{ {
@ -70,22 +83,38 @@ namespace BizHawk.Client.Common
} }
} }
public static bool nes_getclipleftandright() [LuaMethodAttributes(
"getclipleftandright",
"TODO"
)]
public static bool GetClipLeftAndRight()
{ {
return ((NES.NESSettings)Global.Emulator.GetSettings()).ClipLeftAndRight; return ((NES.NESSettings)Global.Emulator.GetSettings()).ClipLeftAndRight;
} }
public static bool nes_getdispbackground() [LuaMethodAttributes(
"getdispbackground",
"TODO"
)]
public static bool GetDisplayBackground()
{ {
return ((NES.NESSettings)Global.Emulator.GetSettings()).DispBackground; return ((NES.NESSettings)Global.Emulator.GetSettings()).DispBackground;
} }
public static bool nes_getdispsprites() [LuaMethodAttributes(
"getdispsprites",
"TODO"
)]
public static bool GetDisplaySprites()
{ {
return ((NES.NESSettings)Global.Emulator.GetSettings()).DispSprites; return ((NES.NESSettings)Global.Emulator.GetSettings()).DispSprites;
} }
public static int nes_gettopscanline(bool pal = false) [LuaMethodAttributes(
"gettopscanline",
"TODO"
)]
public static int GetTopScanline(bool pal = false)
{ {
if (pal) if (pal)
{ {
@ -97,7 +126,11 @@ namespace BizHawk.Client.Common
} }
} }
public void nes_removegamegenie(string code) [LuaMethodAttributes(
"removegamegenie",
"TODO"
)]
public void RemoveGameGenie(string code)
{ {
if (Global.Emulator.SystemId == "NES") if (Global.Emulator.SystemId == "NES")
{ {
@ -108,7 +141,11 @@ namespace BizHawk.Client.Common
} }
} }
public static void nes_setallowmorethaneightsprites(bool allow) [LuaMethodAttributes(
"setallowmorethaneightsprites",
"TODO"
)]
public static void SetAllowMoreThanEightSprites(bool allow)
{ {
if (Global.Emulator is NES) if (Global.Emulator is NES)
{ {
@ -118,7 +155,11 @@ namespace BizHawk.Client.Common
} }
} }
public static void nes_setclipleftandright(bool leftandright) [LuaMethodAttributes(
"setclipleftandright",
"TODO"
)]
public static void SetClipLeftAndRight(bool leftandright)
{ {
if (Global.Emulator is NES) if (Global.Emulator is NES)
{ {
@ -128,8 +169,11 @@ namespace BizHawk.Client.Common
} }
} }
// these seem to duplicate emu.setrenderplanes??? [LuaMethodAttributes(
public static void nes_setdispbackground(bool show) "setdispbackground",
"TODO"
)]
public static void SetDisplayBackground(bool show)
{ {
if (Global.Emulator is NES) if (Global.Emulator is NES)
{ {
@ -139,7 +183,11 @@ namespace BizHawk.Client.Common
} }
} }
public static void nes_setdispsprites(bool show) [LuaMethodAttributes(
"setdispsprites",
"TODO"
)]
public static void SetDisplaySprites(bool show)
{ {
if (Global.Emulator is NES) if (Global.Emulator is NES)
{ {
@ -149,7 +197,11 @@ namespace BizHawk.Client.Common
} }
} }
public static void nes_setscanlines(object top, object bottom, bool pal = false) [LuaMethodAttributes(
"setscanlines",
"TODO"
)]
public static void SetScanlines(object top, object bottom, bool pal = false)
{ {
if (Global.Emulator is NES) if (Global.Emulator is NES)
{ {

View File

@ -31,47 +31,83 @@ namespace BizHawk.Client.Common
} }
} }
public static bool snes_getlayer_bg_1() [LuaMethodAttributes(
"getlayer_bg_1",
"TODO"
)]
public static bool GetLayerBg1()
{ {
return ((LibsnesCore.SnesSettings)Global.Emulator.GetSettings()).ShowBG1_1; return ((LibsnesCore.SnesSettings)Global.Emulator.GetSettings()).ShowBG1_1;
} }
public static bool snes_getlayer_bg_2() [LuaMethodAttributes(
"getlayer_bg_2",
"TODO"
)]
public static bool GetLayerBg2()
{ {
return ((LibsnesCore.SnesSettings)Global.Emulator.GetSettings()).ShowBG2_1; return ((LibsnesCore.SnesSettings)Global.Emulator.GetSettings()).ShowBG2_1;
} }
public static bool snes_getlayer_bg_3() [LuaMethodAttributes(
"getlayer_bg_3",
"TODO"
)]
public static bool GetLayerBg3()
{ {
return ((LibsnesCore.SnesSettings)Global.Emulator.GetSettings()).ShowBG3_1; return ((LibsnesCore.SnesSettings)Global.Emulator.GetSettings()).ShowBG3_1;
} }
public static bool snes_getlayer_bg_4() [LuaMethodAttributes(
"getlayer_bg_4",
"TODO"
)]
public static bool GetLayerBg4()
{ {
return ((LibsnesCore.SnesSettings)Global.Emulator.GetSettings()).ShowBG4_1; return ((LibsnesCore.SnesSettings)Global.Emulator.GetSettings()).ShowBG4_1;
} }
public static bool snes_getlayer_obj_1() [LuaMethodAttributes(
"getlayer_obj_1",
"TODO"
)]
public static bool GetLayerObj1()
{ {
return ((LibsnesCore.SnesSettings)Global.Emulator.GetSettings()).ShowOBJ_0; return ((LibsnesCore.SnesSettings)Global.Emulator.GetSettings()).ShowOBJ_0;
} }
public static bool snes_getlayer_obj_2() [LuaMethodAttributes(
"getlayer_obj_2",
"TODO"
)]
public static bool GetLayerObj2()
{ {
return ((LibsnesCore.SnesSettings)Global.Emulator.GetSettings()).ShowOBJ_1; return ((LibsnesCore.SnesSettings)Global.Emulator.GetSettings()).ShowOBJ_1;
} }
public static bool snes_getlayer_obj_3() [LuaMethodAttributes(
"getlayer_obj_3",
"TODO"
)]
public static bool GetLayerObj3()
{ {
return ((LibsnesCore.SnesSettings)Global.Emulator.GetSettings()).ShowOBJ_2; return ((LibsnesCore.SnesSettings)Global.Emulator.GetSettings()).ShowOBJ_2;
} }
public static bool snes_getlayer_obj_4() [LuaMethodAttributes(
"getlayer_obj_4",
"TODO"
)]
public static bool GetLayerObj4()
{ {
return ((LibsnesCore.SnesSettings)Global.Emulator.GetSettings()).ShowOBJ_3; return ((LibsnesCore.SnesSettings)Global.Emulator.GetSettings()).ShowOBJ_3;
} }
public static void snes_setlayer_bg_1(bool value) [LuaMethodAttributes(
"setlayer_bg_1",
"TODO"
)]
public static void SetLayerBg1(bool value)
{ {
if (Global.Emulator is LibsnesCore) if (Global.Emulator is LibsnesCore)
{ {
@ -81,7 +117,11 @@ namespace BizHawk.Client.Common
} }
} }
public static void snes_setlayer_bg_2(bool value) [LuaMethodAttributes(
"setlayer_bg_2",
"TODO"
)]
public static void SetLayerBg2(bool value)
{ {
if (Global.Emulator is LibsnesCore) if (Global.Emulator is LibsnesCore)
{ {
@ -91,7 +131,11 @@ namespace BizHawk.Client.Common
} }
} }
public static void snes_setlayer_bg_3(bool value) [LuaMethodAttributes(
"setlayer_bg_3",
"TODO"
)]
public static void SetLayerBg3(bool value)
{ {
if (Global.Emulator is LibsnesCore) if (Global.Emulator is LibsnesCore)
{ {
@ -101,7 +145,11 @@ namespace BizHawk.Client.Common
} }
} }
public static void snes_setlayer_bg_4(bool value) [LuaMethodAttributes(
"setlayer_bg_4",
"TODO"
)]
public static void SetLayerBg4(bool value)
{ {
if (Global.Emulator is LibsnesCore) if (Global.Emulator is LibsnesCore)
{ {
@ -111,7 +159,11 @@ namespace BizHawk.Client.Common
} }
} }
public static void snes_setlayer_obj_1(bool value) [LuaMethodAttributes(
"setlayer_obj_1",
"TODO"
)]
public static void SetLayerObj1(bool value)
{ {
if (Global.Emulator is LibsnesCore) if (Global.Emulator is LibsnesCore)
{ {
@ -121,7 +173,11 @@ namespace BizHawk.Client.Common
} }
} }
public static void snes_setlayer_obj_2(bool value) [LuaMethodAttributes(
"setlayer_obj_2",
"TODO"
)]
public static void SetLayerObj2(bool value)
{ {
if (Global.Emulator is LibsnesCore) if (Global.Emulator is LibsnesCore)
{ {
@ -131,7 +187,11 @@ namespace BizHawk.Client.Common
} }
} }
public static void snes_setlayer_obj_3(bool value) [LuaMethodAttributes(
"setlayer_obj_3",
"TODO"
)]
public static void SetLayerObj3(bool value)
{ {
if (Global.Emulator is LibsnesCore) if (Global.Emulator is LibsnesCore)
{ {
@ -141,7 +201,11 @@ namespace BizHawk.Client.Common
} }
} }
public static void snes_setlayer_obj_4(bool value) [LuaMethodAttributes(
"setlayer_obj_4",
"TODO"
)]
public static void SetLayerObj4(bool value)
{ {
if (Global.Emulator is LibsnesCore) if (Global.Emulator is LibsnesCore)
{ {

View File

@ -98,9 +98,9 @@ namespace BizHawk.Client.EmuHawk
new MemoryLuaLibrary().LuaRegisterNew(lua, Docs); new MemoryLuaLibrary().LuaRegisterNew(lua, Docs);
new MainMemoryLuaLibrary(_lua).LuaRegisterNew(lua, Docs); new MainMemoryLuaLibrary(_lua).LuaRegisterNew(lua, Docs);
new MovieLuaLibrary(_lua).LuaRegisterNew(lua, Docs); new MovieLuaLibrary(_lua).LuaRegisterNew(lua, Docs);
new NESLuaLibrary().LuaRegister(lua, Docs); new NESLuaLibrary().LuaRegisterNew(lua, Docs);
new SavestateLuaLibrary().LuaRegister(lua, Docs); new SavestateLuaLibrary().LuaRegister(lua, Docs);
new SNESLuaLibrary().LuaRegister(lua, Docs); new SNESLuaLibrary().LuaRegisterNew(lua, Docs);
new StringLuaLibrary().LuaRegister(lua, Docs); new StringLuaLibrary().LuaRegister(lua, Docs);
Docs.Sort(); Docs.Sort();