1
0
Fork 0
mirror of https://github.com/ctruLua/uCompat.git synced 2025-10-27 16:49:31 +00:00

Fixed maps, scrollmaps, images rotation, paths correction and screen background

This commit is contained in:
Firew0lf 2016-03-27 20:43:03 +02:00
parent 5ea4493bac
commit 7fdae891d9
5 changed files with 42 additions and 7 deletions

View file

@ -9,7 +9,7 @@ local texture = require("ctr.gfx.texture")
-- Constants
RAM = texture.PLACE_RAM
VRAM = texture.PLACE_VRAM
VRAM = texture.PLACE_VRAM -- has to be "PLACE_RAM" on hardware
-- Module

View file

@ -6,14 +6,40 @@
map = require("ctr.gfx.map")
-- Interface
Map = {}
function Map.mapToTable(filename, w, h)
local f = io.open(filename, "r")
local data = f:read("a")
f:close()
local buff = {}
local word
for word in string.gmatch(data, "(%d)|\n*") do
buff[#buff+1] = tonumber(word)
if #buff == w*h then break end
end
local t = {}
local x,y
for y=1, h do
t[y] = {}
for x=1, w do
t[y][x] = buff[x+((y-1)*w)]
end
end
return t
end
-- Module
require("uCompat.screen")
Map = {}
function Map.new(image, mapFile, width, height, tileWidth, tileHeight)
local m = map.load(mapFile, image.texture, tileWidth, tileHeight)
local tiles = mapToTable(mapFile, width, height)
local m = map.load(tiles, image.texture, tileWidth, tileHeight)
return {
map = m,

View file

@ -9,11 +9,13 @@ map = require("ctr.gfx.map")
-- Module
require("uCompat.screen")
require("uCompat.Map")
ScrollMap = {}
function ScrollMap.new(image, mapFile, width, height, tileWidth, tileHeight)
local m = map.load(mapFile, image.texture, tileWidth, tileHeight)
local tiles = Map.mapToTable(mapFile, width, height)
local m = map.load(tiles, image.texture, tileWidth, tileHeight)
return {
map = m,
scrollX = 0,

View file

@ -12,10 +12,14 @@ 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
if DSpath:sub(1, 5) == "fat:/" then -- fix root
path = ("sdmc:/"..DSpath:sub(6, -1))
elseif DSpath:sub(1, 1) == "/" then
path = ("sdmc:"..DSpath)
elseif DSpath:sub(1, 5) == "efs:/" then
path = ("romfs:/"..DSpath:sub(6,-1))
else
path = DSpath
end
return path
@ -24,8 +28,10 @@ end
-- ctrµ -> µ
local function unfixPath(path)
local DSpath
if path:sub(1, 6) == "sdmc:/" or path.sub(1, 1) == "/" then
if path:sub(1, 6) == "sdmc:/" then
DSpath = ("fat:/"..path:sub(7, -1))
elseif path.sub(1, 1) == "/" then
DSpath = ("fat:"..path)
elseif path:sub(1, 7) == "romfs:/" then
DSpath = ("efs:/"..path:sub(8, -1))
end

View file

@ -200,6 +200,7 @@ end
function screen.endDrawing()
gfx.start(drawScreen)
gfx.rectangle(offsetX, offsetY, SCREEN_WIDTH, SCREEN_HEIGHT, 0, color.RGBA8(0,0,0,255))
for i=1, #videoStack[drawScreen] do
local e = videoStack[drawScreen][i]
if e[1] == "img" then