Display get.
This commit is contained in:
parent
4008fb3454
commit
168d9373b3
3 changed files with 58 additions and 11 deletions
52
commands.lua
52
commands.lua
|
@ -1,4 +1,4 @@
|
||||||
local _p = emu.log
|
local _p = print
|
||||||
local function print(data)
|
local function print(data)
|
||||||
_p(data .. "")
|
_p(data .. "")
|
||||||
end
|
end
|
||||||
|
@ -271,12 +271,51 @@ return function(server)
|
||||||
server.response(server.responseType.BANKS_AVAILABLE, server.errorType.OK, command.requestId, table.concat(r));
|
server.response(server.responseType.BANKS_AVAILABLE, server.errorType.OK, command.requestId, table.concat(r));
|
||||||
end
|
end
|
||||||
|
|
||||||
local function processExit(command)
|
local function processDisplayGet(command)
|
||||||
server.running = true
|
if command.apiVersion < 0x02 then
|
||||||
|
server.errorResponse(server.errorType.INVALID_API_VERSION, command.requestId)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local infoLength = 13;
|
||||||
|
|
||||||
|
local shot = emu.takeScreenshot()
|
||||||
|
|
||||||
|
local r = {}
|
||||||
|
|
||||||
|
-- Length of fields before display buffer
|
||||||
|
r[#r+1] = server.uint32ToLittleEndian(infoLength)
|
||||||
|
|
||||||
|
-- Full width of buffer
|
||||||
|
r[#r+1] = server.uint16ToLittleEndian(256)
|
||||||
|
-- Full height of buffer
|
||||||
|
r[#r+1] = server.uint16ToLittleEndian(240)
|
||||||
|
-- X offset of the inner part of the screen
|
||||||
|
r[#r+1] = server.uint16ToLittleEndian(0)
|
||||||
|
-- Y offset of the inner part of the screen
|
||||||
|
r[#r+1] = server.uint16ToLittleEndian(0)
|
||||||
|
-- Width of the inner part of the screen
|
||||||
|
r[#r+1] = server.uint16ToLittleEndian(256)
|
||||||
|
-- Height of the inner part of the screen
|
||||||
|
r[#r+1] = server.uint16ToLittleEndian(240)
|
||||||
|
-- Bits per pixel of image
|
||||||
|
r[#r+1] = server.uint8ToLittleEndian(24)
|
||||||
|
|
||||||
|
-- Length of display buffer
|
||||||
|
r[#r+1] = server.uint32ToLittleEndian(shot:len())
|
||||||
|
|
||||||
|
-- Buffer Data in requested format
|
||||||
|
r[#r+1] = shot
|
||||||
|
|
||||||
|
server.response(server.responseType.DISPLAY_GET, server.errorType.OK, command.requestId, table.concat(r));
|
||||||
|
end
|
||||||
|
|
||||||
|
local function processExit(command)
|
||||||
server.response(server.responseType.EXIT, server.errorType.OK, command.requestId, nil)
|
server.response(server.responseType.EXIT, server.errorType.OK, command.requestId, nil)
|
||||||
|
|
||||||
me.monitorClosed()
|
me.monitorClosed()
|
||||||
|
|
||||||
|
server.running = true
|
||||||
end
|
end
|
||||||
|
|
||||||
local function processReset(command)
|
local function processReset(command)
|
||||||
|
@ -783,6 +822,8 @@ return function(server)
|
||||||
processRegistersAvailable(command)
|
processRegistersAvailable(command)
|
||||||
elseif ct == server.commandType.BANKS_AVAILABLE then
|
elseif ct == server.commandType.BANKS_AVAILABLE then
|
||||||
processBanksAvailable(command)
|
processBanksAvailable(command)
|
||||||
|
elseif ct == server.commandType.DISPLAY_GET then
|
||||||
|
processDisplayGet(command)
|
||||||
|
|
||||||
elseif ct == server.commandType.EXIT then
|
elseif ct == server.commandType.EXIT then
|
||||||
processExit(command)
|
processExit(command)
|
||||||
|
@ -803,11 +844,10 @@ return function(server)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
responseCheckpointInfo(server.EVENT_ID, trap, true)
|
||||||
if trap.stop then
|
if trap.stop then
|
||||||
me.monitorOpened()
|
me.monitorOpened()
|
||||||
end
|
else
|
||||||
responseCheckpointInfo(requestId, trap, true)
|
|
||||||
if not trap.stop then
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
local _p = emu.log
|
local _p = print
|
||||||
local function print(data)
|
local function print(data)
|
||||||
_p(data .. "")
|
_p(data .. "")
|
||||||
end
|
end
|
||||||
|
@ -9,5 +9,6 @@ local server = dofile(baseDir.."/server.lua")
|
||||||
|
|
||||||
local host = os.getenv("MESEN_REMOTE_HOST") or "localhost"
|
local host = os.getenv("MESEN_REMOTE_HOST") or "localhost"
|
||||||
local port = os.getenv("MESEN_REMOTE_PORT") or 9355
|
local port = os.getenv("MESEN_REMOTE_PORT") or 9355
|
||||||
|
local wait = os.getenv("MESEN_REMOTE_WAIT") == "1"
|
||||||
|
|
||||||
server.start(host, port)
|
server.start(host, port, wait)
|
10
server.lua
10
server.lua
|
@ -1,4 +1,4 @@
|
||||||
local _p = emu.log
|
local _p = print
|
||||||
local function print(data)
|
local function print(data)
|
||||||
_p(data .. "")
|
_p(data .. "")
|
||||||
end
|
end
|
||||||
|
@ -295,7 +295,7 @@ local function breakHandle()
|
||||||
emu.resume()
|
emu.resume()
|
||||||
end
|
end
|
||||||
|
|
||||||
function me.start(host, port)
|
function me.start(host, port, waitForConnection)
|
||||||
me.stepping = false
|
me.stepping = false
|
||||||
me.running = true
|
me.running = true
|
||||||
|
|
||||||
|
@ -304,7 +304,11 @@ function me.start(host, port)
|
||||||
me.server = assert(socket.tcp())
|
me.server = assert(socket.tcp())
|
||||||
assert(me.server:bind(host, port))
|
assert(me.server:bind(host, port))
|
||||||
assert(me.server:listen(32))
|
assert(me.server:listen(32))
|
||||||
|
if waitForConnection then
|
||||||
|
me.server:settimeout(-1)
|
||||||
|
else
|
||||||
me.server:settimeout(0)
|
me.server:settimeout(0)
|
||||||
|
end
|
||||||
|
|
||||||
local i, p = me.server:getsockname()
|
local i, p = me.server:getsockname()
|
||||||
assert(i, p)
|
assert(i, p)
|
||||||
|
@ -314,6 +318,8 @@ function me.start(host, port)
|
||||||
me.registerFrameCallback()
|
me.registerFrameCallback()
|
||||||
|
|
||||||
emu.addEventCallback(breakHandle, emu.eventType.codeBreak)
|
emu.addEventCallback(breakHandle, emu.eventType.codeBreak)
|
||||||
|
|
||||||
|
emu.breakExecution()
|
||||||
end
|
end
|
||||||
|
|
||||||
return me
|
return me
|
Loading…
Add table
Reference in a new issue