Debugger: Lua - Added setScreenBuffer/getScreenBuffer API
This commit is contained in:
parent
16828a0d12
commit
535b7d4361
7 changed files with 73 additions and 4 deletions
|
@ -518,6 +518,7 @@
|
||||||
<ClInclude Include="BatteryManager.h" />
|
<ClInclude Include="BatteryManager.h" />
|
||||||
<ClInclude Include="BattleBox.h" />
|
<ClInclude Include="BattleBox.h" />
|
||||||
<ClInclude Include="ControlDeviceState.h" />
|
<ClInclude Include="ControlDeviceState.h" />
|
||||||
|
<ClInclude Include="DrawScreenBufferCommand.h" />
|
||||||
<ClInclude Include="FdsSystemActionManager.h" />
|
<ClInclude Include="FdsSystemActionManager.h" />
|
||||||
<ClInclude Include="HdPackConditions.h" />
|
<ClInclude Include="HdPackConditions.h" />
|
||||||
<ClInclude Include="IBarcodeReader.h" />
|
<ClInclude Include="IBarcodeReader.h" />
|
||||||
|
|
|
@ -1363,6 +1363,9 @@
|
||||||
<ClInclude Include="BaseLoader.h">
|
<ClInclude Include="BaseLoader.h">
|
||||||
<Filter>Nes\RomLoader</Filter>
|
<Filter>Nes\RomLoader</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="DrawScreenBufferCommand.h">
|
||||||
|
<Filter>Debugger\Scripting\DebugHud</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="stdafx.cpp">
|
<ClCompile Include="stdafx.cpp">
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "DrawPixelCommand.h"
|
#include "DrawPixelCommand.h"
|
||||||
#include "DrawRectangleCommand.h"
|
#include "DrawRectangleCommand.h"
|
||||||
#include "DrawStringCommand.h"
|
#include "DrawStringCommand.h"
|
||||||
|
#include "DrawScreenBufferCommand.h"
|
||||||
|
|
||||||
DebugHud* DebugHud::_instance = nullptr;
|
DebugHud* DebugHud::_instance = nullptr;
|
||||||
|
|
||||||
|
@ -61,6 +62,12 @@ void DebugHud::DrawRectangle(int x, int y, int width, int height, int color, boo
|
||||||
_commands.push_back(shared_ptr<DrawRectangleCommand>(new DrawRectangleCommand(x, y, width, height, color, fill, frameCount)));
|
_commands.push_back(shared_ptr<DrawRectangleCommand>(new DrawRectangleCommand(x, y, width, height, color, fill, frameCount)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DebugHud::DrawScreenBuffer(uint32_t* screenBuffer)
|
||||||
|
{
|
||||||
|
auto lock = _commandLock.AcquireSafe();
|
||||||
|
_commands.push_back(shared_ptr<DrawScreenBufferCommand>(new DrawScreenBufferCommand(screenBuffer)));
|
||||||
|
}
|
||||||
|
|
||||||
void DebugHud::DrawString(int x, int y, string text, int color, int backColor, int frameCount)
|
void DebugHud::DrawString(int x, int y, string text, int color, int backColor, int frameCount)
|
||||||
{
|
{
|
||||||
auto lock = _commandLock.AcquireSafe();
|
auto lock = _commandLock.AcquireSafe();
|
||||||
|
|
|
@ -22,5 +22,6 @@ public:
|
||||||
void DrawPixel(int x, int y, int color, int frameCount);
|
void DrawPixel(int x, int y, int color, int frameCount);
|
||||||
void DrawLine(int x, int y, int x2, int y2, int color, int frameCount);
|
void DrawLine(int x, int y, int x2, int y2, int color, int frameCount);
|
||||||
void DrawRectangle(int x, int y, int width, int height, int color, bool fill, int frameCount);
|
void DrawRectangle(int x, int y, int width, int height, int color, bool fill, int frameCount);
|
||||||
|
void DrawScreenBuffer(uint32_t* screenBuffer);
|
||||||
void DrawString(int x, int y, string text, int color, int backColor, int frameCount);
|
void DrawString(int x, int y, string text, int color, int backColor, int frameCount);
|
||||||
};
|
};
|
||||||
|
|
25
Core/DrawScreenBufferCommand.h
Normal file
25
Core/DrawScreenBufferCommand.h
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#pragma once
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "DrawCommand.h"
|
||||||
|
|
||||||
|
class DrawScreenBufferCommand : public DrawCommand
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
uint32_t _screenBuffer[256*240];
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void InternalDraw()
|
||||||
|
{
|
||||||
|
for(int y = 0; y < 240; y++) {
|
||||||
|
for(int x = 0; x < 256; x++) {
|
||||||
|
DrawPixel(x, y, _screenBuffer[(y << 8) + x]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
DrawScreenBufferCommand(uint32_t* screenBuffer) : DrawCommand(1)
|
||||||
|
{
|
||||||
|
memcpy(_screenBuffer, screenBuffer, 256 * 240 * sizeof(uint32_t));
|
||||||
|
}
|
||||||
|
};
|
|
@ -73,6 +73,8 @@ int LuaApi::GetLibrary(lua_State *lua)
|
||||||
{ "drawLine", LuaApi::DrawLine },
|
{ "drawLine", LuaApi::DrawLine },
|
||||||
{ "drawRectangle", LuaApi::DrawRectangle },
|
{ "drawRectangle", LuaApi::DrawRectangle },
|
||||||
{ "clearScreen", LuaApi::ClearScreen },
|
{ "clearScreen", LuaApi::ClearScreen },
|
||||||
|
{ "getScreenBuffer", LuaApi::GetScreenBuffer },
|
||||||
|
{ "setScreenBuffer", LuaApi::SetScreenBuffer },
|
||||||
{ "getPixel", LuaApi::GetPixel },
|
{ "getPixel", LuaApi::GetPixel },
|
||||||
{ "getMouseState", LuaApi::GetMouseState },
|
{ "getMouseState", LuaApi::GetMouseState },
|
||||||
{ "log", LuaApi::Log },
|
{ "log", LuaApi::Log },
|
||||||
|
@ -357,6 +359,38 @@ int LuaApi::ClearScreen(lua_State *lua)
|
||||||
return l.ReturnCount();
|
return l.ReturnCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int LuaApi::GetScreenBuffer(lua_State *lua)
|
||||||
|
{
|
||||||
|
LuaCallHelper l(lua);
|
||||||
|
|
||||||
|
uint32_t *palette = EmulationSettings::GetRgbPalette();
|
||||||
|
lua_newtable(lua);
|
||||||
|
for(int y = 0; y < PPU::ScreenHeight; y++) {
|
||||||
|
for(int x = 0; x < PPU::ScreenWidth; x++) {
|
||||||
|
lua_pushnumber(lua, palette[PPU::GetPixel(x, y) & 0x3F] & 0xFFFFFF);
|
||||||
|
lua_rawseti(lua, -2, (y << 8) + x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int LuaApi::SetScreenBuffer(lua_State *lua)
|
||||||
|
{
|
||||||
|
LuaCallHelper l(lua);
|
||||||
|
|
||||||
|
uint32_t pixels[PPU::PixelCount] = {};
|
||||||
|
luaL_checktype(lua, 1, LUA_TTABLE);
|
||||||
|
for(int i = 0; i < PPU::PixelCount; i++) {
|
||||||
|
lua_rawgeti(lua, 1, i);
|
||||||
|
pixels[i] = l.ReadInteger() ^ 0xFF000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
DebugHud::GetInstance()->DrawScreenBuffer(pixels);
|
||||||
|
|
||||||
|
return l.ReturnCount();
|
||||||
|
}
|
||||||
|
|
||||||
int LuaApi::GetPixel(lua_State *lua)
|
int LuaApi::GetPixel(lua_State *lua)
|
||||||
{
|
{
|
||||||
LuaCallHelper l(lua);
|
LuaCallHelper l(lua);
|
||||||
|
|
|
@ -18,12 +18,8 @@ public:
|
||||||
|
|
||||||
static int ReadMemory(lua_State *lua);
|
static int ReadMemory(lua_State *lua);
|
||||||
static int WriteMemory(lua_State *lua);
|
static int WriteMemory(lua_State *lua);
|
||||||
static int DebugReadMemory(lua_State *lua);
|
|
||||||
static int DebugWriteMemory(lua_State *lua);
|
|
||||||
static int ReadMemoryWord(lua_State *lua);
|
static int ReadMemoryWord(lua_State *lua);
|
||||||
static int WriteMemoryWord(lua_State *lua);
|
static int WriteMemoryWord(lua_State *lua);
|
||||||
static int DebugReadMemoryWord(lua_State *lua);
|
|
||||||
static int DebugWriteMemoryWord(lua_State *lua);
|
|
||||||
static int RevertPrgChrChanges(lua_State *lua);
|
static int RevertPrgChrChanges(lua_State *lua);
|
||||||
|
|
||||||
static int RegisterMemoryCallback(lua_State *lua);
|
static int RegisterMemoryCallback(lua_State *lua);
|
||||||
|
@ -36,6 +32,8 @@ public:
|
||||||
static int DrawPixel(lua_State *lua);
|
static int DrawPixel(lua_State *lua);
|
||||||
static int DrawRectangle(lua_State *lua);
|
static int DrawRectangle(lua_State *lua);
|
||||||
static int ClearScreen(lua_State *lua);
|
static int ClearScreen(lua_State *lua);
|
||||||
|
static int GetScreenBuffer(lua_State *lua);
|
||||||
|
static int SetScreenBuffer(lua_State *lua);
|
||||||
static int GetPixel(lua_State *lua);
|
static int GetPixel(lua_State *lua);
|
||||||
static int GetMouseState(lua_State *lua);
|
static int GetMouseState(lua_State *lua);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue