From 5ea4493bacda731c88cf045513394d0ddf002738 Mon Sep 17 00:00:00 2001 From: Firew0lf Date: Sun, 27 Mar 2016 01:47:21 +0100 Subject: [PATCH] I tested and fixed everything, and now it works. Yes I test sometimes. --- uCompat/Canvas.lua | 4 ++-- uCompat/Sound.lua | 57 ++++++++++++++++++++++++++++++++++++++++++++++ uCompat/dsUser.lua | 2 +- uCompat/init.lua | 7 +++++- uCompat/screen.lua | 27 ++++++++++++++++------ 5 files changed, 86 insertions(+), 11 deletions(-) diff --git a/uCompat/Canvas.lua b/uCompat/Canvas.lua index 4b25298..dade243 100644 --- a/uCompat/Canvas.lua +++ b/uCompat/Canvas.lua @@ -133,7 +133,7 @@ function Canvas.newGradientRect(x1, y1, x2, y2, color1, color2, color3, color4) return o end -function Canvas.newText(x1, y1 text, color) +function Canvas.newText(x1, y1, text, color) local o = attrTable() o.type = TYPE_TEXT o[ATTR_X1] = x1 @@ -212,7 +212,7 @@ function Canvas.setAttr(object, attrName, attrValue) end function Canvas.getAttr(object, attrName) - return obect[attrName] + return object[attrName] end function Canvas.setObjOnTop(canvas, object) diff --git a/uCompat/Sound.lua b/uCompat/Sound.lua index 70df84e..74a15eb 100644 --- a/uCompat/Sound.lua +++ b/uCompat/Sound.lua @@ -9,6 +9,17 @@ PLAY_LOOP = 1 -- Module +-- Sound banks + +function Sound.loadBank(filename) + +end + +function Sound.unloadBank() + +end + +-- Mods function Sound.loadMod(id) end @@ -25,6 +36,10 @@ function Sound.pause() end +function Sound.resume() + +end + function Sound.stop() end @@ -56,3 +71,45 @@ end function Sound.setModPitch(pitch) end + +-- SFX + +function Sound.loadSFX(id) + +end + +function Sound.unloadSFX(id) + +end + +function Sound.startSFX(id) + return {"I am a SFX handle"} +end + +function Sound.stopSFX(handle) + +end + +function Sound.releaseSFX(handle) + +end + +function Sound.stopAllSFX() + +end + +function Sound.setSFXVolume(handle, volume) + +end + +function Sound.setSFXPanning(handle, panning) + +end + +function Sound.setSFXPitch(handle, pitch) + +end + +function Sound.setSFXScalePitch(handle, scale) + +end diff --git a/uCompat/dsUser.lua b/uCompat/dsUser.lua index d6a823f..fed265e 100644 --- a/uCompat/dsUser.lua +++ b/uCompat/dsUser.lua @@ -67,7 +67,7 @@ function dsUser.getAlarmMinute() end function dsUser.getLanguage() - return language5[cgfu.getLanguage()] + return language5[cfgu.getLanguage()] end function dsUser.getGBAScreen() diff --git a/uCompat/init.lua b/uCompat/init.lua index abc0306..4e439b7 100644 --- a/uCompat/init.lua +++ b/uCompat/init.lua @@ -16,6 +16,11 @@ ULUA_LIBS = (ULUA_DIR.."libs/") ULUA_BOOT_FILE = "main.lua" ULUA_BOOT_FULLPATH = (ULUA_DIR..ULUA_BOOT_FILE) +-- Some old Lua functions +function table.getn(t) + return #t +end + -- Other libs require("uCompat.screen") require("uCompat.Color") @@ -35,4 +40,4 @@ require("uCompat.dsUser") require("uCompat.System") require("uCompat.ini") require("uCompat.Wifi") -reqiore("uCompat.Nifi") +require("uCompat.Nifi") diff --git a/uCompat/screen.lua b/uCompat/screen.lua index 926d845..acae02d 100644 --- a/uCompat/screen.lua +++ b/uCompat/screen.lua @@ -124,12 +124,14 @@ function screen.print(scr, x, y, text, color) end function screen.printFont(scr, x, y, text, color, font) - checkBuffer(scr)[#videoStack[scr]+1] = {"text", {offsetX+x, offsetY+y, text, 8, RGB2RGBA(color), font}} + checkBuffer(scr)[#videoStack[scr]+1] = {"text", {offsetX+x, offsetY+y, text, 8, RGB2RGBA(color), nil}} end function screen.blit(scr, x, y, img, sx, sy, w, h) + local x = math.floor(x) -- \ Compatibility patch for some homebrews not using integers + local y = math.floor(y) -- / 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+math.floor(sizex/2), offsetY+y+math.floor(sizey/2), (sx or 0), (sy or 0), (w or sizex), (h or sizey), img.rotation}} end function screen.drawPoint(scr, x, y, color) @@ -191,15 +193,13 @@ function screen.startDrawing2D() -- unused -- As you can change the screen size, we have to re-calculate this every time. offsetX = math.floor((gfx.BOTTOM_WIDTH-SCREEN_WIDTH)/2) offsetY = math.floor((gfx.BOTTOM_HEIGHT-SCREEN_HEIGHT)/2) - if drawScreen == gfx.GFX_TOP then + if drawScreen == gfx.TOP then offsetX = offsetX + 40 end end function screen.endDrawing() - gfx.startFrame(drawScreen) - --gfx.text(2, 2, "x: "..offsetX.." ;y: "..offsetY.." ;stackUP: "..#videoStack[0].." ;stackDOWN: "..#videoStack[1]) -- debug only - --gfx.text(2, 12, "screen: "..drawScreen.." ; stack: "..#videoStack[drawScreen]) -- debug only + gfx.start(drawScreen) for i=1, #videoStack[drawScreen] do local e = videoStack[drawScreen][i] if e[1] == "img" then @@ -210,7 +210,20 @@ function screen.endDrawing() gfx[e[1]](table.unpack(e[2])) end end - gfx.endFrame() + + if offsetY ~= 0 then + gfx.rectangle(0, 0, 400, offsetY, 0, color.getBackground()) + gfx.rectangle(0, SCREEN_HEIGHT+offsetY, 400, offsetY, 0, color.getBackground()) + end + if offsetX ~= 0 then + gfx.rectangle(0, 0, offsetX, 240, 0, color.getBackground()) + gfx.rectangle(offsetX+SCREEN_WIDTH, 0, offsetX, 240, 0, color.getBackground()) + end + if drawScreen == gfx.TOP then + gfx.text(380, 225, tostring(gfx.getFPS())) + end + + gfx.stop() -- set the screen drawScreen = ((drawScreen == 0 and 1) or 0)