diff --git a/uCompat/Canvas.lua b/uCompat/Canvas.lua new file mode 100644 index 0000000..1f455fd --- /dev/null +++ b/uCompat/Canvas.lua @@ -0,0 +1,11 @@ +--[[ + Canvas related µLua compatibility layer/lib for ctrµLua +]] + +-- Local + + + +-- Module + +Canvas = {} diff --git a/uCompat/Debug.lua b/uCompat/Debug.lua index 800aa5c..883e2b6 100644 --- a/uCompat/Debug.lua +++ b/uCompat/Debug.lua @@ -25,7 +25,7 @@ Debug.print = function(text,aff) if(text == nil) then text = "" elseif(text == true) then text = "TRUE" 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) == "function") then text = "<"..tostring(text)..">" elseif(type(text) == "thread") then text = "<"..tostring(text)..">" diff --git a/uCompat/Nifi.lua b/uCompat/Nifi.lua new file mode 100644 index 0000000..6d5f9e6 --- /dev/null +++ b/uCompat/Nifi.lua @@ -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 + diff --git a/uCompat/Wifi.lua b/uCompat/Wifi.lua new file mode 100644 index 0000000..fb0f2c6 --- /dev/null +++ b/uCompat/Wifi.lua @@ -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 diff --git a/uCompat/init.lua b/uCompat/init.lua index aec04c7..8c4b0c1 100644 --- a/uCompat/init.lua +++ b/uCompat/init.lua @@ -28,3 +28,4 @@ require("uCompat.Rumble") require("uCompat.dsUser") require("uCompat.System") require("uCompat.ini") +require("uCompat.Wifi") diff --git a/uCompat/screen.lua b/uCompat/screen.lua index 833dfc9..2cb0757 100644 --- a/uCompat/screen.lua +++ b/uCompat/screen.lua @@ -73,7 +73,7 @@ function stopDrawing() fpscount = fpscount + 1 end 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() fpscount = 0 end @@ -128,7 +128,7 @@ function screen.printFont(scr, x, y, text, color, font) end 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}} end @@ -208,11 +208,16 @@ function screen.endDrawing() gfx.endFrame() -- 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 function screen.waitForVBL() -- unused - + gfx.waitForVBLank() end -- Interface