Debugger: LUA - Inverted meaning of alpha byte in colors
This commit is contained in:
parent
dc5ddaf87e
commit
602643b0f2
8 changed files with 32 additions and 34 deletions
|
@ -19,7 +19,11 @@ protected:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((color & 0xFF000000) != 0xFF000000) {
|
uint32_t alpha = (color & 0xFF000000);
|
||||||
|
|
||||||
|
if(alpha == 0) {
|
||||||
|
//do nothing
|
||||||
|
} else if(alpha != 0xFF000000) {
|
||||||
BlendColors((uint8_t*)&_argbBuffer[(y - _overscan.Top)*_overscan.GetScreenWidth() + (x - _overscan.Left)], (uint8_t*)&color);
|
BlendColors((uint8_t*)&_argbBuffer[(y - _overscan.Top)*_overscan.GetScreenWidth() + (x - _overscan.Left)], (uint8_t*)&color);
|
||||||
} else {
|
} else {
|
||||||
_argbBuffer[(y - _overscan.Top)*_overscan.GetScreenWidth() + (x - _overscan.Left)] = color;
|
_argbBuffer[(y - _overscan.Top)*_overscan.GetScreenWidth() + (x - _overscan.Left)] = color;
|
||||||
|
|
|
@ -35,8 +35,7 @@ public:
|
||||||
DrawLineCommand(int x, int y, int x2, int y2, int color, int frameCount) :
|
DrawLineCommand(int x, int y, int x2, int y2, int color, int frameCount) :
|
||||||
DrawCommand(frameCount), _x(x), _y(y), _x2(x2), _y2(y2), _color(color)
|
DrawCommand(frameCount), _x(x), _y(y), _x2(x2), _y2(y2), _color(color)
|
||||||
{
|
{
|
||||||
if(!(_color & 0xFF000000)) {
|
//Invert alpha byte - 0 = opaque, 255 = transparent (this way, no need to specifiy alpha channel all the time)
|
||||||
_color |= 0xFF000000;
|
_color = (~color & 0xFF000000) | (color & 0xFFFFFF);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,8 +17,7 @@ public:
|
||||||
DrawPixelCommand(int x, int y, int color, int frameCount) :
|
DrawPixelCommand(int x, int y, int color, int frameCount) :
|
||||||
DrawCommand(frameCount), _x(x), _y(y), _color(color)
|
DrawCommand(frameCount), _x(x), _y(y), _color(color)
|
||||||
{
|
{
|
||||||
if(!(_color & 0xFF000000)) {
|
//Invert alpha byte - 0 = opaque, 255 = transparent (this way, no need to specifiy alpha channel all the time)
|
||||||
_color |= 0xFF000000;
|
_color = (~color & 0xFF000000) | (color & 0xFFFFFF);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,7 +22,7 @@ protected:
|
||||||
DrawPixel(_x + i, _y, _color);
|
DrawPixel(_x + i, _y, _color);
|
||||||
DrawPixel(_x + i, _y + _height - 1, _color);
|
DrawPixel(_x + i, _y + _height - 1, _color);
|
||||||
}
|
}
|
||||||
for(int i = 0; i < _height; i++) {
|
for(int i = 1; i < _height - 1; i++) {
|
||||||
DrawPixel(_x, _y + i, _color);
|
DrawPixel(_x, _y + i, _color);
|
||||||
DrawPixel(_x + _width - 1, _y + i, _color);
|
DrawPixel(_x + _width - 1, _y + i, _color);
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,7 @@ public:
|
||||||
DrawRectangleCommand(int x, int y, int width, int height, int color, bool fill, int frameCount) :
|
DrawRectangleCommand(int x, int y, int width, int height, int color, bool fill, int frameCount) :
|
||||||
DrawCommand(frameCount), _x(x), _y(y), _width(width), _height(height), _color(color), _fill(fill)
|
DrawCommand(frameCount), _x(x), _y(y), _width(width), _height(height), _color(color), _fill(fill)
|
||||||
{
|
{
|
||||||
if(!(_color & 0xFF000000)) {
|
//Invert alpha byte - 0 = opaque, 255 = transparent (this way, no need to specifiy alpha channel all the time)
|
||||||
_color |= 0xFF000000;
|
_color = (~color & 0xFF000000) | (color & 0xFFFFFF);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
|
@ -153,11 +153,8 @@ public:
|
||||||
DrawStringCommand(int x, int y, string text, int color, int backColor, int frameCount) :
|
DrawStringCommand(int x, int y, string text, int color, int backColor, int frameCount) :
|
||||||
DrawCommand(frameCount), _x(x), _y(y), _color(color), _backColor(backColor), _text(text)
|
DrawCommand(frameCount), _x(x), _y(y), _color(color), _backColor(backColor), _text(text)
|
||||||
{
|
{
|
||||||
if(!(_color & 0xFF000000)) {
|
//Invert alpha byte - 0 = opaque, 255 = transparent (this way, no need to specifiy alpha channel all the time)
|
||||||
_color |= 0xFF000000;
|
_color = (~color & 0xFF000000) | (color & 0xFFFFFF);
|
||||||
}
|
_backColor = (~backColor & 0xFF000000) | (backColor & 0xFFFFFF);
|
||||||
if(!(_backColor & 0xFF000000)) {
|
|
||||||
_backColor |= 0xFF000000;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
--This is an example script to give an idea of how scripting work
|
--This is an example script to give an idea of how scripting work
|
||||||
--Press F5 or click the Run button to execute it
|
--Press F5 or click the Run button to execute it
|
||||||
--Scripts must be written in LUA (https://www.lua.org)
|
--Scripts must be written in Lua (https://www.lua.org)
|
||||||
--This text editor contains an auto-complete feature for all Mesen-specific functions
|
--This text editor contains an auto-complete feature for all Mesen-specific functions
|
||||||
--Typing "emu." will display a list containing every available API function to interact with Mesen
|
--Typing "emu." will display a list containing every available API function to interact with Mesen
|
||||||
|
|
||||||
|
@ -20,30 +20,30 @@ function printInfo()
|
||||||
emu.drawPixel(x, y, color & 0xFFFF, 1)
|
emu.drawPixel(x, y, color & 0xFFFF, 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
bgColor = 0xFF6020
|
bgColor = 0x30FF6020
|
||||||
fgColor = 0x4040FF
|
fgColor = 0x304040FF
|
||||||
else
|
else
|
||||||
bgColor = 0x2060FF
|
bgColor = 0x302060FF
|
||||||
fgColor = 0xFF4040
|
fgColor = 0x30FF4040
|
||||||
end
|
end
|
||||||
|
|
||||||
--Draw some rectangles and print some text
|
--Draw some rectangles and print some text
|
||||||
emu.drawRectangle(8, 8, 128, 24, bgColor, true, 1)
|
emu.drawRectangle(8, 8, 128, 24, bgColor, true, 1)
|
||||||
emu.drawRectangle(8, 8, 128, 24, fgColor, false, 1)
|
emu.drawRectangle(8, 8, 128, 24, fgColor, false, 1)
|
||||||
emu.drawString(12, 12, "Frame: " .. state.ppu.frameCount, 0xFFFFFF, bgColor, 1)
|
emu.drawString(12, 12, "Frame: " .. state.ppu.frameCount, 0xFFFFFF, 0xFF000000, 1)
|
||||||
emu.drawString(12, 21, "CPU Cycle: " .. state.cpu.cycleCount, 0xFFFFFF, bgColor, 1)
|
emu.drawString(12, 21, "CPU Cycle: " .. state.cpu.cycleCount, 0xFFFFFF, 0xFF000000, 1)
|
||||||
|
|
||||||
emu.drawRectangle(8, 218, 193, 11, bgColor, true, 1)
|
emu.drawRectangle(8, 218, 193, 11, bgColor, true, 1)
|
||||||
emu.drawRectangle(8, 218, 193, 11, fgColor, false, 1)
|
emu.drawRectangle(8, 218, 193, 11, fgColor, false, 1)
|
||||||
emu.drawString(11, 220, "Hold left mouse button to switch colors", 0xFFFFFF, bgColor, 1)
|
emu.drawString(11, 220, "Hold left mouse button to switch colors", 0xFFFFFF, 0xFF000000, 1)
|
||||||
|
|
||||||
--Draw a block behind the mouse cursor - leaves a trail when moving the mouse
|
--Draw a block behind the mouse cursor - leaves a trail when moving the mouse
|
||||||
emu.drawRectangle(mouseState.x - 2, mouseState.y - 2, 5, 5, 0x3F00FF90, true, 20)
|
emu.drawRectangle(mouseState.x - 2, mouseState.y - 2, 5, 5, 0xAF00FF90, true, 20)
|
||||||
emu.drawRectangle(mouseState.x - 2, mouseState.y - 2, 5, 5, 0x3F000000, false, 20)
|
emu.drawRectangle(mouseState.x - 2, mouseState.y - 2, 5, 5, 0xAF000000, false, 20)
|
||||||
end
|
end
|
||||||
|
|
||||||
--Register some code (printInfo function) that will be run at the end of each frame
|
--Register some code (printInfo function) that will be run at the end of each frame
|
||||||
emu.addEventCallback(printInfo, emu.eventType.endFrame);
|
emu.addEventCallback(printInfo, emu.eventType.endFrame);
|
||||||
|
|
||||||
--Display a startup message
|
--Display a startup message
|
||||||
emu.displayMessage("Script", "Example LUA script loaded.")
|
emu.displayMessage("Script", "Example Lua script loaded.")
|
|
@ -65,9 +65,9 @@ namespace Mesen.GUI.Debugger
|
||||||
_containedRtiRts = ContainsRtiOrRts(_initialCode);
|
_containedRtiRts = ContainsRtiOrRts(_initialCode);
|
||||||
txtCode.Text = _initialCode;
|
txtCode.Text = _initialCode;
|
||||||
} else {
|
} else {
|
||||||
_initialCode = ";Input 6502 assembly here.\n;The resulting bytecode is\n;displayed on the right.\n; -Labels can be used.\n; -Use .byte to define data\n";
|
_initialCode = ";Tips:\n; -Labels can be used.\n; -Use .byte to define data\n";
|
||||||
txtCode.Text = _initialCode;
|
txtCode.Text = _initialCode;
|
||||||
txtCode.Selection = txtCode.GetLine(5);
|
txtCode.Selection = txtCode.GetLine(3);
|
||||||
txtCode.SelectionLength = 0;
|
txtCode.SelectionLength = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -154,7 +154,7 @@ namespace Mesen.GUI.Debugger
|
||||||
private void LoadScript()
|
private void LoadScript()
|
||||||
{
|
{
|
||||||
using(OpenFileDialog ofd = new OpenFileDialog()) {
|
using(OpenFileDialog ofd = new OpenFileDialog()) {
|
||||||
ofd.SetFilter("LUA scripts (*.lua)|*.lua");
|
ofd.SetFilter("Lua scripts (*.lua)|*.lua");
|
||||||
if(ofd.ShowDialog() == DialogResult.OK) {
|
if(ofd.ShowDialog() == DialogResult.OK) {
|
||||||
LoadScriptFile(ofd.FileName);
|
LoadScriptFile(ofd.FileName);
|
||||||
}
|
}
|
||||||
|
@ -249,7 +249,7 @@ namespace Mesen.GUI.Debugger
|
||||||
{
|
{
|
||||||
using(SaveFileDialog sfd = new SaveFileDialog()) {
|
using(SaveFileDialog sfd = new SaveFileDialog()) {
|
||||||
sfd.FileName = newName;
|
sfd.FileName = newName;
|
||||||
sfd.SetFilter("LUA scripts (*.lua)|*.lua");
|
sfd.SetFilter("Lua scripts (*.lua)|*.lua");
|
||||||
if(sfd.ShowDialog() == DialogResult.OK) {
|
if(sfd.ShowDialog() == DialogResult.OK) {
|
||||||
SetFilePath(sfd.FileName);
|
SetFilePath(sfd.FileName);
|
||||||
txtScriptContent.SaveToFile(_filePath, Encoding.UTF8);
|
txtScriptContent.SaveToFile(_filePath, Encoding.UTF8);
|
||||||
|
@ -412,9 +412,9 @@ namespace Mesen.GUI.Debugger
|
||||||
|
|
||||||
static readonly List<List<string>> _availableFunctions = new List<List<string>>() {
|
static readonly List<List<string>> _availableFunctions = new List<List<string>>() {
|
||||||
new List<string> {"enum", "emu", "", "", "", "", "" },
|
new List<string> {"enum", "emu", "", "", "", "", "" },
|
||||||
new List<string> {"func","emu.addEventCallback","emu.addEventCallback(function, type)","function - A LUA function.\ntype - *Enum* See eventCallbackType.","Returns an integer value that can be used to remove the callback by calling removeEventCallback.","Registers a callback function to be called whenever the specified event occurs.",},
|
new List<string> {"func","emu.addEventCallback","emu.addEventCallback(function, type)","function - A Lua function.\ntype - *Enum* See eventCallbackType.","Returns an integer value that can be used to remove the callback by calling removeEventCallback.","Registers a callback function to be called whenever the specified event occurs.",},
|
||||||
new List<string> {"func","emu.removeEventCallback","emu.removeEventCallback(reference, type)","reference - The value returned by the call to[addEventCallback] (#addEventCallback).\ntype - *Enum* See eventCallbackType.","","Removes a previously registered callback function.",},
|
new List<string> {"func","emu.removeEventCallback","emu.removeEventCallback(reference, type)","reference - The value returned by the call to[addEventCallback] (#addEventCallback).\ntype - *Enum* See eventCallbackType.","","Removes a previously registered callback function.",},
|
||||||
new List<string> {"func","emu.addMemoryCallback","emu.addMemoryCallback(function, type, startAddress, endAddress)","function - A LUA function.\ntype - *Enum* See memCallbackType\nstartAddress - *Integer* Start of the CPU memory address range to register the callback on.\nendAddress - *Integer* End of the CPU memory address range to register the callback on.","Returns an integer value that can be used to remove the callback by callingremoveMemoryCallback.","Registers a callback function to be called whenever the specified event occurs."},
|
new List<string> {"func","emu.addMemoryCallback","emu.addMemoryCallback(function, type, startAddress, endAddress)","function - A Lua function.\ntype - *Enum* See memCallbackType\nstartAddress - *Integer* Start of the CPU memory address range to register the callback on.\nendAddress - *Integer* End of the CPU memory address range to register the callback on.","Returns an integer value that can be used to remove the callback by callingremoveMemoryCallback.","Registers a callback function to be called whenever the specified event occurs."},
|
||||||
new List<string> {"func","emu.removeMemoryCallback","emu.removeMemoryCallback(reference, type, startAddress, endAddress)","reference - The value returned by the call to[addMemoryCallback] (#addMemoryCallback).\ntype - *Enum* See memCallbackType.\nstartAddress - *Integer* Start of the CPU memory address range to unregister the callback from.\nendAddress - *Integer* End of the CPU memory address range to unregister the callback from.","","Removes a previously registered callback function."},
|
new List<string> {"func","emu.removeMemoryCallback","emu.removeMemoryCallback(reference, type, startAddress, endAddress)","reference - The value returned by the call to[addMemoryCallback] (#addMemoryCallback).\ntype - *Enum* See memCallbackType.\nstartAddress - *Integer* Start of the CPU memory address range to unregister the callback from.\nendAddress - *Integer* End of the CPU memory address range to unregister the callback from.","","Removes a previously registered callback function."},
|
||||||
new List<string> {"func","emu.read","emu.read(address, type)","address - *Integer* The address/offset to read from.\ntype - *Enum* The type of memory to read from. See memType.","An 8-bit (read) or 16-bit (readWord) value.","Reads a value from the specified memory type.\nThe read / readWord variants may cause side-effects that can alter the emulation's behavior.\nThe debugRead/debugReadWord variants have no side-effects."},
|
new List<string> {"func","emu.read","emu.read(address, type)","address - *Integer* The address/offset to read from.\ntype - *Enum* The type of memory to read from. See memType.","An 8-bit (read) or 16-bit (readWord) value.","Reads a value from the specified memory type.\nThe read / readWord variants may cause side-effects that can alter the emulation's behavior.\nThe debugRead/debugReadWord variants have no side-effects."},
|
||||||
new List<string> {"func","emu.readWord","emu.readWord(address, type)","address - *Integer* The address/offset to read from.\ntype - *Enum* The type of memory to read from. See memType.","An 8-bit (read) or 16-bit (readWord) value.","Reads a value from the specified memory type.\nThe read / readWord variants may cause side-effects that can alter the emulation's behavior.\nThe debugRead/debugReadWord variants have no side-effects."},
|
new List<string> {"func","emu.readWord","emu.readWord(address, type)","address - *Integer* The address/offset to read from.\ntype - *Enum* The type of memory to read from. See memType.","An 8-bit (read) or 16-bit (readWord) value.","Reads a value from the specified memory type.\nThe read / readWord variants may cause side-effects that can alter the emulation's behavior.\nThe debugRead/debugReadWord variants have no side-effects."},
|
||||||
|
|
Loading…
Add table
Reference in a new issue