diff --git a/uCompat/Image.lua b/uCompat/Image.lua index 8dbc05f..26a9a9c 100644 --- a/uCompat/Image.lua +++ b/uCompat/Image.lua @@ -1,8 +1,5 @@ --[[ Images related µLua compatibility layer/lib for ctrµLua - - Actually doesn't support GIFs, because sfillib doesn't. Use PNGs, these are -better. ]] -- Local @@ -23,7 +20,9 @@ function Image.load(path, dest) if not t then return nil end return { -- Image object texture = t, - rotation = 0 + rotation = 0, + scaleX = 1, + scaleY = 1 } end @@ -43,23 +42,28 @@ function Image.height(img) end function Image.scale(img, w, h) - + local iw,ih = img.texture:getSize() + img.scaleX = w/iw + img.scaleY = h/ih + img.texture:scale(img.scaleX, img.scaleY) end function Image.rotate(img, angle, cx, cy) - img.rotation = angle*((math.pi*2)/512) + img.rotation = angle*(math.pi/256) end function Image.rotateDegree(img, angle, cx, cy) - img.rotation = angle*((math.pi*2)/360) + img.rotation = angle*(math.pi/180) end function Image.mirrorH(img, activate) - + img.scaleY = (0-img.scaleY) + img.texture:scale(img.scaleX, img.scaleY) end function Image.mirrorV(img, activate) - + img.scaleX = (0-img.scaleY) + img.textire:scale(img.scaleX, img.scaleY) end function Image.setTint(img, color) diff --git a/uCompat/System.lua b/uCompat/System.lua index 048ded5..07af3da 100644 --- a/uCompat/System.lua +++ b/uCompat/System.lua @@ -9,6 +9,30 @@ local fs = require("ctr.fs") local gfx = require("ctr.gfx") +-- µ -> ctrµ +local function fixPath(DSpath) + local path + if DSpath:sub(1, 1) == "/" or DSpath:sub(1, 5) == "fat:/" then -- fix root + path = ("sdmc:/"..DSpath:sub(6, -1)) + elseif DSpath:sub(1, 5) == "efs:/" then + path = ("romfs:/"..DSpath:sub(6,-1)) + end + + return path +end + +-- ctrµ -> µ +local function unfixPath(path) + local DSpath + if path:sub(1, 6) == "sdmc:/" or path.sub(1, 1) == "/" then + DSpath = ("fat:/"..path:sub(7, -1)) + elseif path:sub(1, 7) == "romfs:/" then + DSpath = ("efs:/"..path:sub(8, -1)) + end + + return DSpath +end + -- Constants LED_ON = 0 @@ -19,12 +43,14 @@ LED_SLEEP = 2 System = {} +System.EFS = false + function System.currentDirectory() - return fs.getDirectory() + return unfixPath(fs.getDirectory()) end function System.changeDirectory(dir) - fs.setDirectory(dir) + fs.setDirectory(fixPath(dir)) end function System.remove(path) @@ -40,7 +66,8 @@ function System.makeDirectory(name) end function System.listDirectory(path) - local list = fs.list(path) + + local list = fs.list(fixPath(path)) local flist = {} for i=1, #list do flist[i] = { diff --git a/uCompat/Timer.lua b/uCompat/Timer.lua index 5ae94b7..7d7ca7b 100644 --- a/uCompat/Timer.lua +++ b/uCompat/Timer.lua @@ -13,7 +13,7 @@ local ctr = require("ctr") Timer = { new = function() - local t = ctr.time() + local t = ctr.time() -- small patch local isStarted = false local tick = 0 diff --git a/uCompat/dsUser.lua b/uCompat/dsUser.lua index 5e1fa43..d6a823f 100644 --- a/uCompat/dsUser.lua +++ b/uCompat/dsUser.lua @@ -4,6 +4,26 @@ Informations are fake ones, until ctrµLua/the ctruLib can deal with it. ]] +-- Local + +local cfgu = require("ctr.cfgu") + +local language5 = { + [cfgu.LANGUAGE_JP] = 0, + [cfgu.LANGUAGE_EN] = 1, + [cfgu.LANGUAGE_FR] = 2, + [cfgu.LANGUAGE_DE] = 3, + [cfgu.LANGUAGE_IT] = 4, + [cfgu.LANGUAGE_ES] = 5, + -- always english if not in the list above + [cfgu.LANGUAGE_ZH] = 1, + [cfgu.LANGUAGE_KO] = 1, + [cfgu.LANGUAGE_NL] = 1, + [cfgu.LANGUAGE_PT] = 1, + [cfgu.LANGUAGE_RU] = 1, + [cfgu.LANGUAGE_TW] = 1 +} + -- Module dsUser = {} @@ -13,19 +33,21 @@ function dsUser.getColor() end function dsUser.getBirthDay() - return 1 + local _, day = cfgu.getBirthday() + return day end function dsUser.getBirthMonth() - return 1 + local month, _ = cfgu.getBirthday() + return month end function dsUser.getName() - return "NDS" + return cfgu.getUsername() end function dsUser.getNameLength() - return 3 + return #(dsUser.getName()) end function dsUser.getMessage() @@ -33,7 +55,7 @@ function dsUser.getMessage() end function dsUser.getMessageLength() - return 0 + return #(dsUser.getMessage()) end function dsUser.getAlarmHour() @@ -45,7 +67,7 @@ function dsUser.getAlarmMinute() end function dsUser.getLanguage() - return 0 + return language5[cgfu.getLanguage()] end function dsUser.getGBAScreen() diff --git a/uCompat/init.lua b/uCompat/init.lua index 065927d..abc0306 100644 --- a/uCompat/init.lua +++ b/uCompat/init.lua @@ -4,10 +4,14 @@ The goal is not to provide a full compatibility, but something close. ]] +-- Just something needed + +local ctr = require("ctr") + -- Constants -ULUA_VERSION = "4.7.2" -ULUA_DIR = "sdmc:/3ds/ctruLua/" -ULUA_SCRIPTS = (ULUA_DIR.."scripts/") -- Warning: you need to create the folder +ULUA_VERSION = "Microlua 4.7.2" +ULUA_DIR = ctr.root -- you can change it to anything +ULUA_SCRIPTS = (ULUA_DIR.."scripts/") -- Warning: you may need to create the folder ULUA_LIBS = (ULUA_DIR.."libs/") ULUA_BOOT_FILE = "main.lua" ULUA_BOOT_FULLPATH = (ULUA_DIR..ULUA_BOOT_FILE) diff --git a/uCompat/screen.lua b/uCompat/screen.lua index 6a458b6..926d845 100644 --- a/uCompat/screen.lua +++ b/uCompat/screen.lua @@ -112,7 +112,7 @@ function screen.getLayer() end function screen.getAlphaLevel() - return ALPHA_RESET + return alpha end function screen.setAlpha(level, layer) @@ -137,14 +137,14 @@ function screen.drawPoint(scr, x, y, color) end function screen.drawLine(scr, x0, y0, x1, y1, color) - checkBuffer(scr)[#videoStack[scr]+1] = {"line", {offsetX+x0, offsetX+y0, offsetX+x1, offsetY+y1, RGB2RGBA(color)}} + checkBuffer(scr)[#videoStack[scr]+1] = {"line", {offsetX+x0, offsetX+y0, offsetX+x1, offsetY+y1, 1, RGB2RGBA(color)}} end function screen.drawRect(scr, x0, y0, x1, y1, color) - checkBuffer(scr)[#videoStack[scr]+1] = {"line", {offsetX+x0, offsetY+y0, offsetX+x0, offsetY+y1, RGB2RGBA(color)}} - checkBuffer(scr)[#videoStack[scr]+1] = {"line", {offsetX+x0, offsetY+y0, offsetX+x1, offsetY+y0, RGB2RGBA(color)}} - checkBuffer(scr)[#videoStack[scr]+1] = {"line", {offsetX+x0, offsetY+y1, offsetX+x1, offsetY+y1, RGB2RGBA(color)}} - checkBuffer(scr)[#videoStack[scr]+1] = {"line", {offsetX+x1, offsetY+y0, offsetX+x1, offsetY+y1, RGB2RGBA(color)}} + checkBuffer(scr)[#videoStack[scr]+1] = {"line", {offsetX+x0, offsetY+y0, offsetX+x0, offsetY+y1, 1, RGB2RGBA(color)}} + checkBuffer(scr)[#videoStack[scr]+1] = {"line", {offsetX+x0, offsetY+y0, offsetX+x1, offsetY+y0, 1, RGB2RGBA(color)}} + checkBuffer(scr)[#videoStack[scr]+1] = {"line", {offsetX+x0, offsetY+y1, offsetX+x1, offsetY+y1, 1, RGB2RGBA(color)}} + checkBuffer(scr)[#videoStack[scr]+1] = {"line", {offsetX+x1, offsetY+y0, offsetX+x1, offsetY+y1, 1, RGB2RGBA(color)}} end function screen.drawFillRect(scr, x0, y0, x1, y1, color)