diff --git a/sdcard/3ds/ctruLua/editor/main.lua b/sdcard/3ds/ctruLua/editor/main.lua index 6f2ed5f..64c9145 100644 --- a/sdcard/3ds/ctruLua/editor/main.lua +++ b/sdcard/3ds/ctruLua/editor/main.lua @@ -86,7 +86,7 @@ while ctr.run() do if not file then local t = os.time() repeat - gfx.start(gfx.GFX_TOP) + gfx.start(gfx.TOP) gfx.text(3, 3, "Can't open file in write mode") gfx.stop() gfx.render() @@ -94,7 +94,7 @@ while ctr.run() do else for i = 1, #lines, 1 do file:write(lines[i]..lineEnding) - gfx.start(gfx.GFX_TOP) + gfx.start(gfx.TOP) gfx.rectangle(0, 0, math.ceil(i/#lines*gfx.TOP_WIDTH), gfx.TOP_HEIGHT, 0, 0xFFFFFFFF) gfx.color.setDefault(color.background) gfx.text(gfx.TOP_WIDTH/2, gfx.TOP_HEIGHT/2, math.ceil(i/#lines*100).."%") @@ -138,7 +138,7 @@ while ctr.run() do end -- Draw - gfx.start(gfx.GFX_TOP) + gfx.start(gfx.TOP) -- Lines local sI = math.floor(scrollY / lineHeight) @@ -169,7 +169,7 @@ while ctr.run() do gfx.stop() - gfx.start(gfx.GFX_BOTTOM) + gfx.start(gfx.BOTTOM) gfx.text(3, 3, "FPS: "..math.ceil(gfx.getFPS())) diff --git a/sdcard/3ds/ctruLua/tests/audio/main.lua b/sdcard/3ds/ctruLua/examples/audio/audio.lua similarity index 51% rename from sdcard/3ds/ctruLua/tests/audio/main.lua rename to sdcard/3ds/ctruLua/examples/audio/audio.lua index af7c43f..d794708 100644 --- a/sdcard/3ds/ctruLua/tests/audio/main.lua +++ b/sdcard/3ds/ctruLua/examples/audio/audio.lua @@ -3,7 +3,7 @@ local hid = require("ctr.hid") local gfx = require("ctr.gfx") local audio = require("ctr.audio") -local test = assert(audio.load("test.wav")) +local test = assert(audio.load("test.wav")) -- Load audio file local channel = -1 local speed = 1 @@ -15,32 +15,33 @@ while true do if keys.down.start then break end if keys.down.a then - channel = test:play() + channel = test:play() -- Play audio (an audio can be played multiple times at the same time) end if keys.down.up then speed = speed + 0.01 - test:speed(speed) - audio.speed(nil, speed) + test:speed(speed) -- Set the audio object default speed, will affect the next time it is played + audio.speed(nil, speed) -- Set the speed of all the currently playing channels end if keys.down.down then speed = speed - 0.01 - test:speed(speed) + test:speed(speed) -- See above audio.speed(nil, speed) end if keys.down.left then leftBalance = leftBalance + 0.1 - test:mix(1-leftBalance, leftBalance) - audio.mix(nil, leftBalance, 1-leftBalance) + test:mix(1-leftBalance, leftBalance) -- Set the audio mix: left speaker will be at leftBalance% and right speaker 1-leftBalance%. + -- Like with test:speed(), it won't affect the currently playing audios but the nexts test:play() will have theses mix paramters. + audio.mix(nil, leftBalance, 1-leftBalance) -- Set the mix of all currently playing channels end if keys.down.right then leftBalance = leftBalance - 0.1 - test:mix(1-leftBalance, leftBalance) + test:mix(1-leftBalance, leftBalance) -- See above audio.mix(nil, leftBalance, 1-leftBalance) end - gfx.start(gfx.GFX_TOP) + gfx.start(gfx.TOP) gfx.text(5, 5, "Audio test! "..tostring(test:time()).."/"..tostring(test:duration()).."s") gfx.text(5, 25, "Last audio played on channel "..tostring(channel)) gfx.text(5, 65, "Speed: "..(speed*100).."% - Left balance: "..(leftBalance*100).."%") @@ -49,4 +50,4 @@ while true do gfx.render() end -test:unload() \ No newline at end of file +test:unload() -- Unload audio file \ No newline at end of file diff --git a/sdcard/3ds/ctruLua/tests/audio/test.wav b/sdcard/3ds/ctruLua/examples/audio/test.wav similarity index 100% rename from sdcard/3ds/ctruLua/tests/audio/test.wav rename to sdcard/3ds/ctruLua/examples/audio/test.wav diff --git a/sdcard/3ds/ctruLua/examples/example.lua b/sdcard/3ds/ctruLua/examples/example.lua index b9f0089..b85c187 100644 --- a/sdcard/3ds/ctruLua/examples/example.lua +++ b/sdcard/3ds/ctruLua/examples/example.lua @@ -47,19 +47,19 @@ while ctr.run() do dMul = hid.pos3d() - gfx.start(gfx.GFX_TOP, gfx.GFX_LEFT) + gfx.start(gfx.TOP, gfx.LEFT) drawStuffIn3D(-1) gfx.stop() - gfx.start(gfx.GFX_TOP, gfx.GFX_RIGHT) + gfx.start(gfx.TOP, gfx.RIGHT) drawStuffIn3D(1) gfx.stop() - gfx.start(gfx.GFX_BOTTOM) + gfx.start(gfx.BOTTOM) gfx.color.setDefault(gfx.color.RGBA8(0, 0, 0)) gfx.text(5, 5, "FPS: "..math.ceil(gfx.getFPS())) diff --git a/sdcard/3ds/ctruLua/libs/openfile.lua b/sdcard/3ds/ctruLua/libs/openfile.lua index 8954558..503af39 100644 --- a/sdcard/3ds/ctruLua/libs/openfile.lua +++ b/sdcard/3ds/ctruLua/libs/openfile.lua @@ -98,7 +98,7 @@ return function(title, curdir, exts, type) end -- Draw - gfx.start(gfx.GFX_TOP) + gfx.start(gfx.TOP) gfx.rectangle(0, 10+(sel-scroll)*15, gfx.TOP_WIDTH, 15, 0, gfx.color.RGBA8(0, 0, 200)) @@ -114,7 +114,7 @@ return function(title, curdir, exts, type) gfx.stop() - gfx.start(gfx.GFX_BOTTOM) + gfx.start(gfx.BOTTOM) gfx.text(5, 5, title) gfx.text(5, 20, "Accepted file extensions: "..(exts or "all")) diff --git a/sdcard/3ds/ctruLua/tests/httpc.lua b/sdcard/3ds/ctruLua/tests/httpc.lua index 791bed8..bb1b0a7 100644 --- a/sdcard/3ds/ctruLua/tests/httpc.lua +++ b/sdcard/3ds/ctruLua/tests/httpc.lua @@ -25,7 +25,7 @@ while ctr.run() do data = (data.."!") end - gfx.start(gfx.GFX_TOP) + gfx.start(gfx.TOP) gfx.text(0, 0, data) gfx.stop() diff --git a/source/gfx.c b/source/gfx.c index c60686e..9bae7ca 100644 --- a/source/gfx.c +++ b/source/gfx.c @@ -53,8 +53,8 @@ void load_map_lib(lua_State *L); Start drawing to a screen. Must be called before any draw operation. @function start -@tparam number screen the screen to draw to (`GFX_TOP` or `GFX_BOTTOM`) -@tparam[opt=GFX_LEFT] number eye the eye to draw to (`GFX_LEFT` or `GFX_RIGHT`) +@tparam number screen the screen to draw to (`gfx.TOP` or `gfx.BOTTOM`) +@tparam[opt=gfx.LEFT] number eye the eye to draw to (`gfx.LEFT` or `gfx.RIGHT`) */ static int gfx_start(lua_State *L) { u8 screen = luaL_checkinteger(L, 1); @@ -382,27 +382,27 @@ struct { char *name; int value; } gfx_constants[] = { /*** Constant used to select the top screen. It is equal to `0`. - @field GFX_TOP + @field TOP */ - { "GFX_TOP", GFX_TOP }, + { "TOP", GFX_TOP }, /*** Constant used to select the bottom screen. It is equal to `1`. - @field GFX_BOTTOM + @field BOTTOM */ - { "GFX_BOTTOM", GFX_BOTTOM }, + { "BOTTOM", GFX_BOTTOM }, /*** Constant used to select the left eye. It is equal to `0`. - @field GFX_LEFT + @field LEFT */ - { "GFX_LEFT", GFX_LEFT }, + { "LEFT", GFX_LEFT }, /*** Constant used to select the right eye. It is equal to `1`. - @field GFX_RIGHT + @field RIGHT */ - { "GFX_RIGHT", GFX_RIGHT }, + { "RIGHT", GFX_RIGHT }, /*** The top screen height, in pixels. It is equal to `240`.