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)
|
||||
_p(data .. "")
|
||||
end
|
||||
|
@ -271,12 +271,51 @@ return function(server)
|
|||
server.response(server.responseType.BANKS_AVAILABLE, server.errorType.OK, command.requestId, table.concat(r));
|
||||
end
|
||||
|
||||
local function processExit(command)
|
||||
server.running = true
|
||||
local function processDisplayGet(command)
|
||||
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)
|
||||
|
||||
me.monitorClosed()
|
||||
|
||||
server.running = true
|
||||
end
|
||||
|
||||
local function processReset(command)
|
||||
|
@ -783,6 +822,8 @@ return function(server)
|
|||
processRegistersAvailable(command)
|
||||
elseif ct == server.commandType.BANKS_AVAILABLE then
|
||||
processBanksAvailable(command)
|
||||
elseif ct == server.commandType.DISPLAY_GET then
|
||||
processDisplayGet(command)
|
||||
|
||||
elseif ct == server.commandType.EXIT then
|
||||
processExit(command)
|
||||
|
@ -803,11 +844,10 @@ return function(server)
|
|||
return
|
||||
end
|
||||
|
||||
responseCheckpointInfo(server.EVENT_ID, trap, true)
|
||||
if trap.stop then
|
||||
me.monitorOpened()
|
||||
end
|
||||
responseCheckpointInfo(requestId, trap, true)
|
||||
if not trap.stop then
|
||||
else
|
||||
return
|
||||
end
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
local _p = emu.log
|
||||
local _p = print
|
||||
local function print(data)
|
||||
_p(data .. "")
|
||||
end
|
||||
|
@ -9,5 +9,6 @@ local server = dofile(baseDir.."/server.lua")
|
|||
|
||||
local host = os.getenv("MESEN_REMOTE_HOST") or "localhost"
|
||||
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)
|
||||
_p(data .. "")
|
||||
end
|
||||
|
@ -295,7 +295,7 @@ local function breakHandle()
|
|||
emu.resume()
|
||||
end
|
||||
|
||||
function me.start(host, port)
|
||||
function me.start(host, port, waitForConnection)
|
||||
me.stepping = false
|
||||
me.running = true
|
||||
|
||||
|
@ -304,7 +304,11 @@ function me.start(host, port)
|
|||
me.server = assert(socket.tcp())
|
||||
assert(me.server:bind(host, port))
|
||||
assert(me.server:listen(32))
|
||||
if waitForConnection then
|
||||
me.server:settimeout(-1)
|
||||
else
|
||||
me.server:settimeout(0)
|
||||
end
|
||||
|
||||
local i, p = me.server:getsockname()
|
||||
assert(i, p)
|
||||
|
@ -314,6 +318,8 @@ function me.start(host, port)
|
|||
me.registerFrameCallback()
|
||||
|
||||
emu.addEventCallback(breakHandle, emu.eventType.codeBreak)
|
||||
|
||||
emu.breakExecution()
|
||||
end
|
||||
|
||||
return me
|
Loading…
Add table
Reference in a new issue