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:
parent
5ea4493bac
commit
7fdae891d9
5 changed files with 42 additions and 7 deletions
|
|
@ -9,7 +9,7 @@ local texture = require("ctr.gfx.texture")
|
||||||
-- Constants
|
-- Constants
|
||||||
|
|
||||||
RAM = texture.PLACE_RAM
|
RAM = texture.PLACE_RAM
|
||||||
VRAM = texture.PLACE_VRAM
|
VRAM = texture.PLACE_VRAM -- has to be "PLACE_RAM" on hardware
|
||||||
|
|
||||||
-- Module
|
-- Module
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,40 @@
|
||||||
|
|
||||||
map = require("ctr.gfx.map")
|
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
|
-- Module
|
||||||
|
|
||||||
require("uCompat.screen")
|
require("uCompat.screen")
|
||||||
|
|
||||||
Map = {}
|
|
||||||
|
|
||||||
function Map.new(image, mapFile, width, height, tileWidth, tileHeight)
|
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 {
|
return {
|
||||||
map = m,
|
map = m,
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,13 @@ map = require("ctr.gfx.map")
|
||||||
-- Module
|
-- Module
|
||||||
|
|
||||||
require("uCompat.screen")
|
require("uCompat.screen")
|
||||||
|
require("uCompat.Map")
|
||||||
|
|
||||||
ScrollMap = {}
|
ScrollMap = {}
|
||||||
|
|
||||||
function ScrollMap.new(image, mapFile, width, height, tileWidth, tileHeight)
|
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 {
|
return {
|
||||||
map = m,
|
map = m,
|
||||||
scrollX = 0,
|
scrollX = 0,
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,14 @@ local gfx = require("ctr.gfx")
|
||||||
-- µ -> ctrµ
|
-- µ -> ctrµ
|
||||||
local function fixPath(DSpath)
|
local function fixPath(DSpath)
|
||||||
local path
|
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))
|
path = ("sdmc:/"..DSpath:sub(6, -1))
|
||||||
|
elseif DSpath:sub(1, 1) == "/" then
|
||||||
|
path = ("sdmc:"..DSpath)
|
||||||
elseif DSpath:sub(1, 5) == "efs:/" then
|
elseif DSpath:sub(1, 5) == "efs:/" then
|
||||||
path = ("romfs:/"..DSpath:sub(6,-1))
|
path = ("romfs:/"..DSpath:sub(6,-1))
|
||||||
|
else
|
||||||
|
path = DSpath
|
||||||
end
|
end
|
||||||
|
|
||||||
return path
|
return path
|
||||||
|
|
@ -24,8 +28,10 @@ end
|
||||||
-- ctrµ -> µ
|
-- ctrµ -> µ
|
||||||
local function unfixPath(path)
|
local function unfixPath(path)
|
||||||
local DSpath
|
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))
|
DSpath = ("fat:/"..path:sub(7, -1))
|
||||||
|
elseif path.sub(1, 1) == "/" then
|
||||||
|
DSpath = ("fat:"..path)
|
||||||
elseif path:sub(1, 7) == "romfs:/" then
|
elseif path:sub(1, 7) == "romfs:/" then
|
||||||
DSpath = ("efs:/"..path:sub(8, -1))
|
DSpath = ("efs:/"..path:sub(8, -1))
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -200,6 +200,7 @@ end
|
||||||
|
|
||||||
function screen.endDrawing()
|
function screen.endDrawing()
|
||||||
gfx.start(drawScreen)
|
gfx.start(drawScreen)
|
||||||
|
gfx.rectangle(offsetX, offsetY, SCREEN_WIDTH, SCREEN_HEIGHT, 0, color.RGBA8(0,0,0,255))
|
||||||
for i=1, #videoStack[drawScreen] do
|
for i=1, #videoStack[drawScreen] do
|
||||||
local e = videoStack[drawScreen][i]
|
local e = videoStack[drawScreen][i]
|
||||||
if e[1] == "img" then
|
if e[1] == "img" then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue