lua - add nes.getclipleftandright(), nes.setclipleftandright(), also fix the previous nes library functions to work even if not in NESHawk

This commit is contained in:
adelikat 2012-09-23 04:26:07 +00:00
parent 8f3316e501
commit 2e19d31d33
1 changed files with 42 additions and 39 deletions

View File

@ -209,7 +209,7 @@ namespace BizHawk.MultiClient
for (int i = 0; i < NESFunctions.Length; i++) for (int i = 0; i < NESFunctions.Length; i++)
{ {
lua.RegisterFunction("nes." + NESFunctions[i], this, this.GetType().GetMethod("nes_" + NESFunctions[i])); lua.RegisterFunction("nes." + NESFunctions[i], this, this.GetType().GetMethod("nes_" + NESFunctions[i]));
docs.Add("bit", NESFunctions[i], this.GetType().GetMethod("nes_" + NESFunctions[i])); docs.Add("nes", NESFunctions[i], this.GetType().GetMethod("nes_" + NESFunctions[i]));
} }
docs.Sort(); docs.Sort();
@ -539,8 +539,10 @@ namespace BizHawk.MultiClient
public static string[] NESFunctions = new string[] public static string[] NESFunctions = new string[]
{ {
"setscanlines", "setscanlines",
"nes_gettopscanline", "gettopscanline",
"nes_getbottomscanline", "getbottomscanline",
"getclipleftandright",
"setclipleftandright",
}; };
/****************************************************/ /****************************************************/
/*************function definitions********************/ /*************function definitions********************/
@ -2450,8 +2452,7 @@ namespace BizHawk.MultiClient
public void nes_setscanlines(object top, object bottom) public void nes_setscanlines(object top, object bottom)
{ {
if (Global.Emulator is NES)
{
int first = LuaInt(top); int first = LuaInt(top);
int last = LuaInt(bottom); int last = LuaInt(bottom);
if (first > 127) if (first > 127)
@ -2473,34 +2474,36 @@ namespace BizHawk.MultiClient
} }
Global.Config.NESTopLine = first; Global.Config.NESTopLine = first;
(Global.Emulator as NES).FirstDrawLine = first;
Global.Config.NESBottomLine = last; Global.Config.NESBottomLine = last;
if (Global.Emulator is NES)
{
(Global.Emulator as NES).FirstDrawLine = first;
(Global.Emulator as NES).LastDrawLine = last; (Global.Emulator as NES).LastDrawLine = last;
} }
} }
public int nes_gettopscanline() public int nes_gettopscanline()
{
if (Global.Emulator is NES)
{ {
return Global.Config.NESTopLine; return Global.Config.NESTopLine;
} }
else
{
return 0;
}
}
public int nes_getbottomscanline() public int nes_getbottomscanline()
{
if (Global.Emulator is NES)
{ {
return Global.Config.NESBottomLine; return Global.Config.NESBottomLine;
} }
else
public bool nes_getclipleftandright()
{ {
return 0; return Global.Config.NESClipLeftAndRight;
}
public void nes_setclipleftandright(bool leftandright)
{
Global.Config.NESClipLeftAndRight = leftandright;
if (Global.Emulator is NES)
{
(Global.Emulator as NES).SetClipLeftAndRight(leftandright);
} }
} }
} }