mirror of
https://github.com/ctruLua/uCompat.git
synced 2025-10-27 16:49:31 +00:00
Some new things.
This commit is contained in:
parent
0a1f9930a0
commit
c70cfab18f
6 changed files with 130 additions and 5 deletions
11
uCompat/Canvas.lua
Normal file
11
uCompat/Canvas.lua
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
--[[
|
||||||
|
Canvas related µLua compatibility layer/lib for ctrµLua
|
||||||
|
]]
|
||||||
|
|
||||||
|
-- Local
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- Module
|
||||||
|
|
||||||
|
Canvas = {}
|
||||||
|
|
@ -25,7 +25,7 @@ Debug.print = function(text,aff)
|
||||||
if(text == nil) then text = "<nil>"
|
if(text == nil) then text = "<nil>"
|
||||||
elseif(text == true) then text = "TRUE"
|
elseif(text == true) then text = "TRUE"
|
||||||
elseif(text == false) then text = "FALSE"
|
elseif(text == false) then text = "FALSE"
|
||||||
elseif(type(text) == "table") then text = "<"..tostring(text).."["..table.maxn(text).."]>"
|
elseif(type(text) == "table") then text = "<"..tostring(text).."["..#text.."]>"
|
||||||
elseif(type(text) == "userdata") then text = "<"..tostring(text)..">"
|
elseif(type(text) == "userdata") then text = "<"..tostring(text)..">"
|
||||||
elseif(type(text) == "function") then text = "<"..tostring(text)..">"
|
elseif(type(text) == "function") then text = "<"..tostring(text)..">"
|
||||||
elseif(type(text) == "thread") then text = "<"..tostring(text)..">"
|
elseif(type(text) == "thread") then text = "<"..tostring(text)..">"
|
||||||
|
|
|
||||||
46
uCompat/Nifi.lua
Normal file
46
uCompat/Nifi.lua
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
--[[
|
||||||
|
Nifi related µLua compatibility layer/lib for ctrµLua
|
||||||
|
|
||||||
|
Actually use the IR port.
|
||||||
|
]]
|
||||||
|
|
||||||
|
-- Local
|
||||||
|
|
||||||
|
local ir = require("ctr.ir")
|
||||||
|
|
||||||
|
-- Module
|
||||||
|
|
||||||
|
Nifi = {}
|
||||||
|
|
||||||
|
function Nifi.init(channel)
|
||||||
|
ir.init(channel+3)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
function Nifi.changeChannel(channel)
|
||||||
|
ir.setBitRate(channel+3)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Nifi.stop()
|
||||||
|
ir.shutdown()
|
||||||
|
end
|
||||||
|
|
||||||
|
function Nifi.checkMessage()
|
||||||
|
if ir.receive(0) == "" then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
function Nifi.getTrame()
|
||||||
|
return ir.receive()
|
||||||
|
end
|
||||||
|
|
||||||
|
function Nifi.sendMessage(message)
|
||||||
|
ir.send(message, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Nifi.readMessage()
|
||||||
|
return ir.receive()
|
||||||
|
end
|
||||||
|
|
||||||
62
uCompat/Wifi.lua
Normal file
62
uCompat/Wifi.lua
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
--[[
|
||||||
|
Wifi related µLua compatibility layer/lib for ctrµLua
|
||||||
|
|
||||||
|
Only work for TCP sockets.
|
||||||
|
]]
|
||||||
|
|
||||||
|
-- Local
|
||||||
|
|
||||||
|
local socket = require("ctr.socket")
|
||||||
|
|
||||||
|
local meta = {
|
||||||
|
__index = function(t, k)
|
||||||
|
return function(...) end
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Module
|
||||||
|
|
||||||
|
Wifi = {}
|
||||||
|
setmetatable(Wifi, meta)
|
||||||
|
|
||||||
|
function Wifi.newAP()
|
||||||
|
return {
|
||||||
|
ssid = "",
|
||||||
|
bssid = "",
|
||||||
|
macaddr = "",
|
||||||
|
channel = 0,
|
||||||
|
rssi = 0,
|
||||||
|
maxrate = 0,
|
||||||
|
protection = "NONE",
|
||||||
|
adhoc = false,
|
||||||
|
active = false
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
function Wifi.getAP(n)
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function Wifi.connectAP(n, nk, k)
|
||||||
|
return -1 -- Connection ALWAYS refused
|
||||||
|
end
|
||||||
|
|
||||||
|
function Wifi.getLocalConf(c)
|
||||||
|
if c == 1 then -- IP
|
||||||
|
return "0.0.0.0"
|
||||||
|
elseif c == 2 then -- Gateway
|
||||||
|
return "0.0.0.0"
|
||||||
|
elseif c == 3 then -- Subnet mask
|
||||||
|
return "0.0.0.0"
|
||||||
|
elseif c == 4 then -- First DNS
|
||||||
|
return "0.0.0.0"
|
||||||
|
elseif c == 5 then -- Second DNS
|
||||||
|
return "0.0.0.0"
|
||||||
|
elseif c == 6 then -- MAC
|
||||||
|
return "0000000000"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Wifi.createTCPSocket()
|
||||||
|
return socket.tcp()
|
||||||
|
end
|
||||||
|
|
@ -28,3 +28,4 @@ require("uCompat.Rumble")
|
||||||
require("uCompat.dsUser")
|
require("uCompat.dsUser")
|
||||||
require("uCompat.System")
|
require("uCompat.System")
|
||||||
require("uCompat.ini")
|
require("uCompat.ini")
|
||||||
|
require("uCompat.Wifi")
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ function stopDrawing()
|
||||||
fpscount = fpscount + 1
|
fpscount = fpscount + 1
|
||||||
end
|
end
|
||||||
if (ctr.time() - fpstime) > 1000 then
|
if (ctr.time() - fpstime) > 1000 then
|
||||||
NB_FPS = math.floor(fpscount/2) -- remove the "/2" to enjoy having "60 FPS" displayed :)
|
NB_FPS = fpscount
|
||||||
fpstime = ctr.time()
|
fpstime = ctr.time()
|
||||||
fpscount = 0
|
fpscount = 0
|
||||||
end
|
end
|
||||||
|
|
@ -128,7 +128,7 @@ function screen.printFont(scr, x, y, text, color, font)
|
||||||
end
|
end
|
||||||
|
|
||||||
function screen.blit(scr, x, y, img, sx, sy, w, h)
|
function screen.blit(scr, x, y, img, sx, sy, w, h)
|
||||||
local sizex, sizey = img:getSize()
|
local sizex, sizey = img.texture:getSize()
|
||||||
checkBuffer(scr)[#videoStack[scr]+1] = {"img", img.texture, {offsetX+x, offsetY+y, (sx or 0), (sy or 0), (w or sizex), (h or sizey), img.rotation}}
|
checkBuffer(scr)[#videoStack[scr]+1] = {"img", img.texture, {offsetX+x, offsetY+y, (sx or 0), (sy or 0), (w or sizex), (h or sizey), img.rotation}}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -208,11 +208,16 @@ function screen.endDrawing()
|
||||||
gfx.endFrame()
|
gfx.endFrame()
|
||||||
|
|
||||||
-- set the screen
|
-- set the screen
|
||||||
drawScreen = ((drawScreen == 0 and 1) or gfx.render() or 0)
|
drawScreen = ((drawScreen == 0 and 1) or 0)
|
||||||
|
if drawScreen == 0 then
|
||||||
|
gfx.render()
|
||||||
|
else
|
||||||
|
gfx.waitForVBlank()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function screen.waitForVBL() -- unused
|
function screen.waitForVBL() -- unused
|
||||||
|
gfx.waitForVBLank()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Interface
|
-- Interface
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue