Update for LOVE 11.0
Fixed color Fixed canvas being accessed while enabled Fixed screenshots Updated love.run Removed shader workaround Removed usage of depreciated apis Fixed cart argument Not thoroughly tested but does atleast run and look correct.
This commit is contained in:
parent
7850bae68b
commit
110189bb09
|
@ -23,7 +23,7 @@ local typecheck = {
|
||||||
Returns the correct alFormat enum value for the given SoundData.
|
Returns the correct alFormat enum value for the given SoundData.
|
||||||
]]
|
]]
|
||||||
local function getALFormat(data)
|
local function getALFormat(data)
|
||||||
local stereo = data:getChannels() == 2
|
local stereo = data:getChannelCount() == 2
|
||||||
local deep = data:getBitDepth() == 16
|
local deep = data:getBitDepth() == 16
|
||||||
|
|
||||||
if (stereo) then
|
if (stereo) then
|
||||||
|
|
65
api.lua
65
api.lua
|
@ -7,7 +7,7 @@ scrblitMesh:setAttributeEnabled("VertexColor", true)
|
||||||
local function color(c)
|
local function color(c)
|
||||||
c=flr(c or 0)%16
|
c=flr(c or 0)%16
|
||||||
pico8.color=c
|
pico8.color=c
|
||||||
love.graphics.setColor(c, 0, 0, 255)
|
setColor(c)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function warning(msg)
|
local function warning(msg)
|
||||||
|
@ -64,7 +64,7 @@ function api.cls(c)
|
||||||
|
|
||||||
pico8.clip=nil
|
pico8.clip=nil
|
||||||
love.graphics.setScissor()
|
love.graphics.setScissor()
|
||||||
love.graphics.clear(c, 0, 0, 255)
|
love.graphics.clear(c/15, 0, 0, 1)
|
||||||
pico8.cursor={0, 0}
|
pico8.cursor={0, 0}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -104,8 +104,10 @@ function api.pget(x, y)
|
||||||
x=x-pico8.camera_x
|
x=x-pico8.camera_x
|
||||||
y=y-pico8.camera_y
|
y=y-pico8.camera_y
|
||||||
if x>=0 and x<pico8.resolution[1] and y>=0 and y<pico8.resolution[2] then
|
if x>=0 and x<pico8.resolution[1] and y>=0 and y<pico8.resolution[2] then
|
||||||
local r, g, b, a=pico8.screen:newImageData():getPixel(flr(x), flr(y))
|
love.graphics.setCanvas()
|
||||||
return r
|
local c=pico8.screen:newImageData():getPixel(flr(x), flr(y))*15
|
||||||
|
love.graphics.setCanvas(pico8.screen)
|
||||||
|
return c
|
||||||
end
|
end
|
||||||
warning(string.format("pget out of screen %d, %d", x, y))
|
warning(string.format("pget out of screen %d, %d", x, y))
|
||||||
return 0
|
return 0
|
||||||
|
@ -133,14 +135,14 @@ function api.print(str, x, y, col)
|
||||||
if not x and not y then
|
if not x and not y then
|
||||||
if pico8.cursor[2]+size>122 then
|
if pico8.cursor[2]+size>122 then
|
||||||
love.graphics.setShader()
|
love.graphics.setShader()
|
||||||
love.graphics.setColor(255, 255, 255, 255)
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
love.graphics.setCanvas(pico8.tmpscr)
|
love.graphics.setCanvas(pico8.tmpscr)
|
||||||
love.graphics.draw(pico8.screen)
|
love.graphics.draw(pico8.screen)
|
||||||
love.graphics.setCanvas(pico8.screen)
|
love.graphics.setCanvas(pico8.screen)
|
||||||
love.graphics.draw(pico8.tmpscr, 0, -size)
|
love.graphics.draw(pico8.tmpscr, 0, -size)
|
||||||
love.graphics.setColor(0, 0, 0, 255)
|
love.graphics.setColor(0, 0, 0, 1)
|
||||||
love.graphics.rectangle("fill", 0, pico8.resolution[2]-size, pico8.resolution[1], size)
|
love.graphics.rectangle("fill", 0, pico8.resolution[2]-size, pico8.resolution[1], size)
|
||||||
love.graphics.setColor(pico8.color, 0, 0, 255)
|
setColor(pico8.color)
|
||||||
else
|
else
|
||||||
pico8.cursor[2]=pico8.cursor[2]+size
|
pico8.cursor[2]=pico8.cursor[2]+size
|
||||||
end
|
end
|
||||||
|
@ -488,8 +490,8 @@ function api.sget(x, y)
|
||||||
x=flr(x)
|
x=flr(x)
|
||||||
y=flr(y)
|
y=flr(y)
|
||||||
if x>=0 and x<128 and y>=0 and y<128 then
|
if x>=0 and x<128 and y>=0 and y<128 then
|
||||||
local r, g, b, a=pico8.spritesheet_data:getPixel(x, y)
|
local c=pico8.spritesheet_data:getPixel(x, y)*15
|
||||||
return r
|
return c
|
||||||
end
|
end
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
@ -499,7 +501,7 @@ function api.sset(x, y, c)
|
||||||
y=flr(y)
|
y=flr(y)
|
||||||
c=flr(c or 0)%16
|
c=flr(c or 0)%16
|
||||||
if x>=0 and x<128 and y>=0 and y<128 then
|
if x>=0 and x<128 and y>=0 and y<128 then
|
||||||
pico8.spritesheet_data:setPixel(x, y, c, 0, 0, 255)
|
pico8.spritesheet_data:setPixel(x, y, c/15, 0, 0, 1)
|
||||||
pico8.spritesheet:refresh()
|
pico8.spritesheet:refresh()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -601,8 +603,8 @@ function api.peek(addr)
|
||||||
if addr<0 then
|
if addr<0 then
|
||||||
return 0
|
return 0
|
||||||
elseif addr<0x2000 then
|
elseif addr<0x2000 then
|
||||||
local lo=pico8.spritesheet_data:getPixel(addr*2%128, flr(addr/64))
|
local lo=pico8.spritesheet_data:getPixel(addr*2%128, flr(addr/64))*15
|
||||||
local hi=pico8.spritesheet_data:getPixel(addr*2%128+1, flr(addr/64))
|
local hi=pico8.spritesheet_data:getPixel(addr*2%128+1, flr(addr/64))*15
|
||||||
return hi*16+lo
|
return hi*16+lo
|
||||||
elseif addr<0x3000 then
|
elseif addr<0x3000 then
|
||||||
addr=addr-0x2000
|
addr=addr-0x2000
|
||||||
|
@ -647,8 +649,17 @@ function api.peek(addr)
|
||||||
-- FIXME: Unused but memory
|
-- FIXME: Unused but memory
|
||||||
elseif addr<0x8000 then
|
elseif addr<0x8000 then
|
||||||
addr=addr-0x6000
|
addr=addr-0x6000
|
||||||
local lo=(__scrimg or pico8.screen:newImageData()):getPixel(addr*2%128, flr(addr/64))
|
local lo, hi
|
||||||
local hi=(__scrimg or pico8.screen:newImageData()):getPixel(addr*2%128+1, flr(addr/64))
|
if __scrimg then
|
||||||
|
lo=__scrimg:getPixel(addr*2%128, flr(addr/64))*15
|
||||||
|
hi=__scrimg:getPixel(addr*2%128+1, flr(addr/64))*15
|
||||||
|
else
|
||||||
|
love.graphics.setCanvas()
|
||||||
|
local tmpscr = pico8.screen:newImageData()
|
||||||
|
lo=tmpscr:getPixel(addr*2%128, flr(addr/64))*15
|
||||||
|
hi=tmpscr:getPixel(addr*2%128+1, flr(addr/64))*15
|
||||||
|
love.graphics.setCanvas(pico8.screen)
|
||||||
|
end
|
||||||
return hi*16+lo
|
return hi*16+lo
|
||||||
end
|
end
|
||||||
return 0
|
return 0
|
||||||
|
@ -661,13 +672,13 @@ function api.poke(addr, val)
|
||||||
elseif addr<0x1000 then
|
elseif addr<0x1000 then
|
||||||
local lo=val%16
|
local lo=val%16
|
||||||
local hi=flr(val/16)
|
local hi=flr(val/16)
|
||||||
pico8.spritesheet_data:setPixel(addr*2%128, flr(addr/64), lo, 0, 0, 255)
|
pico8.spritesheet_data:setPixel(addr*2%128, flr(addr/64), lo/15, 0, 0, 1)
|
||||||
pico8.spritesheet_data:setPixel(addr*2%128+1, flr(addr/64), hi, 0, 0, 255)
|
pico8.spritesheet_data:setPixel(addr*2%128+1, flr(addr/64), hi/15, 0, 0, 1)
|
||||||
elseif addr<0x2000 then
|
elseif addr<0x2000 then
|
||||||
local lo=val%16
|
local lo=val%16
|
||||||
local hi=flr(val/16)
|
local hi=flr(val/16)
|
||||||
pico8.spritesheet_data:setPixel(addr*2%128, flr(addr/64), lo, 0, 0, 255)
|
pico8.spritesheet_data:setPixel(addr*2%128, flr(addr/64), lo/15, 0, 0, 1)
|
||||||
pico8.spritesheet_data:setPixel(addr*2%128+1, flr(addr/64), hi, 0, 0, 255)
|
pico8.spritesheet_data:setPixel(addr*2%128+1, flr(addr/64), hi/15, 0, 0, 1)
|
||||||
pico8.map[flr(addr/128)][addr%128]=val
|
pico8.map[flr(addr/128)][addr%128]=val
|
||||||
elseif addr<0x3000 then
|
elseif addr<0x3000 then
|
||||||
addr=addr-0x2000
|
addr=addr-0x2000
|
||||||
|
@ -718,14 +729,14 @@ function api.poke(addr, val)
|
||||||
local lo=val%16
|
local lo=val%16
|
||||||
local hi=flr(val/16)
|
local hi=flr(val/16)
|
||||||
if __scrblit then
|
if __scrblit then
|
||||||
table.insert(__scrblit, {addr*2%128, flr(addr/64), 0, 0, lo, 0, 0, 255})
|
table.insert(__scrblit, {addr*2%128, flr(addr/64), 0, 0, lo/15, 0, 0, 1})
|
||||||
table.insert(__scrblit, {addr*2%128+1, flr(addr/64), 0, 0, hi, 0, 0, 255})
|
table.insert(__scrblit, {addr*2%128+1, flr(addr/64), 0, 0, hi/15, 0, 0, 1})
|
||||||
else
|
else
|
||||||
love.graphics.setColor(lo, 0, 0, 255)
|
setColor(lo)
|
||||||
love.graphics.point(addr*2%128, flr(addr/64))
|
love.graphics.point(addr*2%128, flr(addr/64))
|
||||||
love.graphics.setColor(hi, 0, 0, 255)
|
setColor(hi)
|
||||||
love.graphics.point(addr*2%128+1, flr(addr/64))
|
love.graphics.point(addr*2%128+1, flr(addr/64))
|
||||||
love.graphics.setColor(pico8.color, 0, 0, 255)
|
setColor(pico8.color)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -754,6 +765,7 @@ function api.memcpy(dest_addr, source_addr, len)
|
||||||
|
|
||||||
-- Screen Hack
|
-- Screen Hack
|
||||||
if source_addr+len-1>=0x6000 then
|
if source_addr+len-1>=0x6000 then
|
||||||
|
love.graphics.setCanvas()
|
||||||
__scrimg=pico8.screen:newImageData()
|
__scrimg=pico8.screen:newImageData()
|
||||||
end
|
end
|
||||||
if dest_addr+len-1>=0x6000 then
|
if dest_addr+len-1>=0x6000 then
|
||||||
|
@ -774,12 +786,15 @@ function api.memcpy(dest_addr, source_addr, len)
|
||||||
api.poke(i, api.peek(i-offset))
|
api.poke(i, api.peek(i-offset))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if __scrimg then
|
||||||
|
love.graphics.setCanvas(pico8.screen)
|
||||||
|
end
|
||||||
if __scrblit then
|
if __scrblit then
|
||||||
scrblitMesh:setVertices(__scrblit)
|
scrblitMesh:setVertices(__scrblit)
|
||||||
scrblitMesh:setDrawRange(1, #__scrblit)
|
scrblitMesh:setDrawRange(1, #__scrblit)
|
||||||
love.graphics.setColor(255, 255, 255, 255)
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
love.graphics.draw(scrblitMesh)
|
love.graphics.draw(scrblitMesh)
|
||||||
love.graphics.setColor(pico8.color, 0, 0, 255)
|
setColor(pico8.color)
|
||||||
end
|
end
|
||||||
__scrblit, __scrimg=nil
|
__scrblit, __scrimg=nil
|
||||||
end
|
end
|
||||||
|
|
16
cart.lua
16
cart.lua
|
@ -86,11 +86,10 @@ function cart.load_p8(filename)
|
||||||
|
|
||||||
local header=love.filesystem.read(filename, 8)
|
local header=love.filesystem.read(filename, 8)
|
||||||
if header=="\137PNG\r\n\26\n" then
|
if header=="\137PNG\r\n\26\n" then
|
||||||
local img=love.graphics.newImage(filename)
|
local data=love.image.newImageData(filename)
|
||||||
if img:getWidth()~=160 or img:getHeight()~=205 then
|
if data:getWidth()~=160 or data:getHeight()~=205 then
|
||||||
error("Image is the wrong size")
|
error("Image is the wrong size")
|
||||||
end
|
end
|
||||||
local data=img:getData()
|
|
||||||
|
|
||||||
local outX=0
|
local outX=0
|
||||||
local outY=0
|
local outY=0
|
||||||
|
@ -104,6 +103,7 @@ function cart.load_p8(filename)
|
||||||
for y=0, 204 do
|
for y=0, 204 do
|
||||||
for x=0, 159 do
|
for x=0, 159 do
|
||||||
local r, g, b, a=data:getPixel(x, y)
|
local r, g, b, a=data:getPixel(x, y)
|
||||||
|
r, g, b, a=r*255, g*255, b*255, a*255
|
||||||
-- extract lowest bits
|
-- extract lowest bits
|
||||||
r=bit.band(r, 0x0003)
|
r=bit.band(r, 0x0003)
|
||||||
g=bit.band(g, 0x0003)
|
g=bit.band(g, 0x0003)
|
||||||
|
@ -122,9 +122,9 @@ function cart.load_p8(filename)
|
||||||
mapY=mapY+1
|
mapY=mapY+1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
pico8.spritesheet_data:setPixel(outX, outY, lo, 0, 0, 255)
|
pico8.spritesheet_data:setPixel(outX, outY, lo/15, 0, 0, 1)
|
||||||
outX=outX+1
|
outX=outX+1
|
||||||
pico8.spritesheet_data:setPixel(outX, outY, hi, 0, 0, 255)
|
pico8.spritesheet_data:setPixel(outX, outY, hi/15, 0, 0, 1)
|
||||||
outX=outX+1
|
outX=outX+1
|
||||||
if outX==128 then
|
if outX==128 then
|
||||||
outY=outY+1
|
outY=outY+1
|
||||||
|
@ -240,7 +240,7 @@ function cart.load_p8(filename)
|
||||||
local col=0
|
local col=0
|
||||||
for v in line:gmatch(".") do
|
for v in line:gmatch(".") do
|
||||||
v=tonumber(v, 16)
|
v=tonumber(v, 16)
|
||||||
pico8.spritesheet_data:setPixel(col, row, v, 0, 0, 255)
|
pico8.spritesheet_data:setPixel(col, row, v/15, 0, 0, 1)
|
||||||
|
|
||||||
col=col+1
|
col=col+1
|
||||||
if col==128 then break end
|
if col==128 then break end
|
||||||
|
@ -256,8 +256,8 @@ function cart.load_p8(filename)
|
||||||
for sy=64, 127 do
|
for sy=64, 127 do
|
||||||
for sx=0, 127, 2 do
|
for sx=0, 127, 2 do
|
||||||
-- get the two pixel values and merge them
|
-- get the two pixel values and merge them
|
||||||
local lo=pico8.spritesheet_data:getPixel(sx, sy)
|
local lo=pico8.spritesheet_data:getPixel(sx, sy)*15
|
||||||
local hi=pico8.spritesheet_data:getPixel(sx+1, sy)
|
local hi=pico8.spritesheet_data:getPixel(sx+1, sy)*15
|
||||||
local v=bit.bor(bit.lshift(hi, 4), lo)
|
local v=bit.bor(bit.lshift(hi, 4), lo)
|
||||||
pico8.map[ty][tx]=v
|
pico8.map[ty][tx]=v
|
||||||
shared=shared+1
|
shared=shared+1
|
||||||
|
|
2
conf.lua
2
conf.lua
|
@ -1,6 +1,6 @@
|
||||||
function love.conf(t)
|
function love.conf(t)
|
||||||
t.identity="picolove"
|
t.identity="picolove"
|
||||||
t.version="0.10.1"
|
t.version="11.0"
|
||||||
|
|
||||||
t.window.title="picolove"
|
t.window.title="picolove"
|
||||||
t.window.width=580
|
t.window.width=580
|
||||||
|
|
1
gif.lua
1
gif.lua
|
@ -101,6 +101,7 @@ function gif:frame(data)
|
||||||
for y=y0, y1 do
|
for y=y0, y1 do
|
||||||
for x=x0, x1 do
|
for x=x0, x1 do
|
||||||
local r, g, b=data:getPixel(x, y)
|
local r, g, b=data:getPixel(x, y)
|
||||||
|
r, g, b=r*255, g*255, b*255
|
||||||
local index=string.char(palmap[bit.lshift(r, 16)+bit.lshift(g, 8)+b])
|
local index=string.char(palmap[bit.lshift(r, 16)+bit.lshift(g, 8)+b])
|
||||||
local temp=buffer..index
|
local temp=buffer..index
|
||||||
if codetbl[temp] then
|
if codetbl[temp] then
|
||||||
|
|
64
main.lua
64
main.lua
|
@ -93,7 +93,7 @@ log=print
|
||||||
--log=function() end
|
--log=function() end
|
||||||
|
|
||||||
function shdr_unpack(thing)
|
function shdr_unpack(thing)
|
||||||
return unpack(thing, 0, 16) -- change to 15 once love2d bug is fixed
|
return unpack(thing, 0, 15)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_bits(v, s, e)
|
local function get_bits(v, s, e)
|
||||||
|
@ -109,11 +109,15 @@ function restore_clip()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function setColor(c)
|
||||||
|
love.graphics.setColor(c/15, 0, 0, 1)
|
||||||
|
end
|
||||||
|
|
||||||
local exts={"", ".p8", ".p8.png", ".png"}
|
local exts={"", ".p8", ".p8.png", ".png"}
|
||||||
function _load(filename)
|
function _load(filename)
|
||||||
filename=filename or cartname
|
filename=filename or cartname
|
||||||
for i=1, #exts do
|
for i=1, #exts do
|
||||||
if love.filesystem.exists(filename..exts[i]) then
|
if love.filesystem.getInfo(filename..exts[i]) ~= nil then
|
||||||
filename=filename..exts[i]
|
filename=filename..exts[i]
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
@ -127,7 +131,7 @@ function _load(filename)
|
||||||
love.graphics.setScissor()
|
love.graphics.setScissor()
|
||||||
api.pal()
|
api.pal()
|
||||||
pico8.color=6
|
pico8.color=6
|
||||||
love.graphics.setColor(6, 0, 0, 255)
|
setColor(pico8.color)
|
||||||
love.graphics.setCanvas(pico8.screen)
|
love.graphics.setCanvas(pico8.screen)
|
||||||
love.graphics.setShader(pico8.draw_shader)
|
love.graphics.setShader(pico8.draw_shader)
|
||||||
|
|
||||||
|
@ -285,9 +289,9 @@ function love.load(argv)
|
||||||
extern float palette[16];
|
extern float palette[16];
|
||||||
|
|
||||||
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords) {
|
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords) {
|
||||||
int index=int(color.r*255.0+0.5);
|
int index=int(color.r*15.0+0.5);
|
||||||
ifblock(palette);
|
ifblock(palette);
|
||||||
return vec4(palette[index]/255.0, 0.0, 0.0, 1.0);
|
return vec4(palette[index]/15.0, 0.0, 0.0, 1.0);
|
||||||
}]]))
|
}]]))
|
||||||
pico8.draw_shader:send('palette', shdr_unpack(pico8.draw_palette))
|
pico8.draw_shader:send('palette', shdr_unpack(pico8.draw_palette))
|
||||||
|
|
||||||
|
@ -296,10 +300,10 @@ extern float palette[16];
|
||||||
extern float transparent[16];
|
extern float transparent[16];
|
||||||
|
|
||||||
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords) {
|
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords) {
|
||||||
int index=int(Texel(texture, texture_coords).r*255.0+0.5);
|
int index=int(Texel(texture, texture_coords).r*15.0+0.5);
|
||||||
ifblock(palette);
|
ifblock(palette);
|
||||||
ifblock(transparent);
|
ifblock(transparent);
|
||||||
return vec4(palette[index]/255.0, 0.0, 0.0, transparent[index]);
|
return vec4(palette[index]/15.0, 0.0, 0.0, transparent[index]);
|
||||||
}]]))
|
}]]))
|
||||||
pico8.sprite_shader:send('palette', shdr_unpack(pico8.draw_palette))
|
pico8.sprite_shader:send('palette', shdr_unpack(pico8.draw_palette))
|
||||||
pico8.sprite_shader:send('transparent', shdr_unpack(pico8.pal_transparent))
|
pico8.sprite_shader:send('transparent', shdr_unpack(pico8.pal_transparent))
|
||||||
|
@ -309,9 +313,9 @@ extern float palette[16];
|
||||||
|
|
||||||
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords) {
|
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords) {
|
||||||
vec4 texcolor=Texel(texture, texture_coords);
|
vec4 texcolor=Texel(texture, texture_coords);
|
||||||
int index=int(color.r*255.0+0.5);
|
int index=int(color.r*15.0+0.5);
|
||||||
ifblock(palette);
|
ifblock(palette);
|
||||||
return vec4(palette[index]/255.0, 0.0, 0.0, texcolor.a);
|
return vec4(palette[index]/15.0, 0.0, 0.0, texcolor.a);
|
||||||
}]]))
|
}]]))
|
||||||
pico8.text_shader:send('palette', shdr_unpack(pico8.draw_palette))
|
pico8.text_shader:send('palette', shdr_unpack(pico8.draw_palette))
|
||||||
|
|
||||||
|
@ -319,7 +323,7 @@ vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords)
|
||||||
extern vec4 palette[16];
|
extern vec4 palette[16];
|
||||||
|
|
||||||
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords) {
|
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords) {
|
||||||
int index=int(Texel(texture, texture_coords).r*255.0+0.5);
|
int index=int(Texel(texture, texture_coords).r*15.0+0.5);
|
||||||
ifblock(palette);
|
ifblock(palette);
|
||||||
// lookup the colour in the palette by index
|
// lookup the colour in the palette by index
|
||||||
return palette[index]/255.0;
|
return palette[index]/255.0;
|
||||||
|
@ -331,7 +335,7 @@ vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords)
|
||||||
gif=require("gif")
|
gif=require("gif")
|
||||||
|
|
||||||
-- load the cart
|
-- load the cart
|
||||||
_load(argv[2] or 'nocart.p8')
|
_load(argv[1] or 'nocart.p8')
|
||||||
end
|
end
|
||||||
|
|
||||||
local function inside(x, y, x0, y0, w, h)
|
local function inside(x, y, x0, y0, w, h)
|
||||||
|
@ -434,14 +438,14 @@ function flip_screen()
|
||||||
if gif_recording then
|
if gif_recording then
|
||||||
love.graphics.setCanvas(gif_canvas)
|
love.graphics.setCanvas(gif_canvas)
|
||||||
love.graphics.draw(pico8.screen, 0, 0, 0, 2, 2)
|
love.graphics.draw(pico8.screen, 0, 0, 0, 2, 2)
|
||||||
gif_recording:frame(gif_canvas:newImageData())
|
|
||||||
love.graphics.setCanvas()
|
love.graphics.setCanvas()
|
||||||
|
gif_recording:frame(gif_canvas:newImageData())
|
||||||
end
|
end
|
||||||
|
|
||||||
-- draw touchscreen overlay
|
-- draw touchscreen overlay
|
||||||
if mobile then
|
if mobile then
|
||||||
local col=(love.graphics.getColor())
|
local col=(love.graphics.getColor())
|
||||||
love.graphics.setColor(255, 255, 255, 255)
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
love.graphics.setShader()
|
love.graphics.setShader()
|
||||||
|
|
||||||
local keys=pico8.keypressed[0]
|
local keys=pico8.keypressed[0]
|
||||||
|
@ -451,7 +455,7 @@ function flip_screen()
|
||||||
love.graphics.rectangle(keys[1] and "fill" or "line", tobase*2+topad*3, screen_h-tobase*3-topad, tobase, tobase, topad, topad)
|
love.graphics.rectangle(keys[1] and "fill" or "line", tobase*2+topad*3, screen_h-tobase*3-topad, tobase, tobase, topad, topad)
|
||||||
love.graphics.circle(keys[4] and "fill" or "line", screen_w-tobase*8/3, screen_h-tobase*3/2, tobase/2)
|
love.graphics.circle(keys[4] and "fill" or "line", screen_w-tobase*8/3, screen_h-tobase*3/2, tobase/2)
|
||||||
love.graphics.circle(keys[5] and "fill" or "line", screen_w-tobase, screen_h-tobase*2, tobase/2)
|
love.graphics.circle(keys[5] and "fill" or "line", screen_w-tobase, screen_h-tobase*2, tobase/2)
|
||||||
love.graphics.setColor(col, 0, 0, 255)
|
love.graphics.setColor(col, 0, 0, 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
love.graphics.present()
|
love.graphics.present()
|
||||||
|
@ -620,9 +624,8 @@ function love.keypressed(key)
|
||||||
paused=not paused
|
paused=not paused
|
||||||
elseif key=='f1' or key=='f6' then
|
elseif key=='f1' or key=='f6' then
|
||||||
-- screenshot
|
-- screenshot
|
||||||
local screenshot=love.graphics.newScreenshot(false)
|
|
||||||
local filename=cartname..'-'..os.time()..'.png'
|
local filename=cartname..'-'..os.time()..'.png'
|
||||||
screenshot:encode(filename)
|
love.graphics.captureScreenshot(filename)
|
||||||
log('saved screenshot to', filename)
|
log('saved screenshot to', filename)
|
||||||
elseif key=='f3' or key=='f8' then
|
elseif key=='f3' or key=='f8' then
|
||||||
-- start recording
|
-- start recording
|
||||||
|
@ -681,11 +684,7 @@ function love.run()
|
||||||
math.randomseed(os.time())
|
math.randomseed(os.time())
|
||||||
for i=1, 3 do math.random() end
|
for i=1, 3 do math.random() end
|
||||||
|
|
||||||
if love.event then
|
if love.load then love.load(love.arg.parseGameArguments(arg), arg) end
|
||||||
love.event.pump()
|
|
||||||
end
|
|
||||||
|
|
||||||
if love.load then love.load(arg) end
|
|
||||||
|
|
||||||
-- We don't want the first frame's dt to include time taken by love.load.
|
-- We don't want the first frame's dt to include time taken by love.load.
|
||||||
if love.timer then love.timer.step() end
|
if love.timer then love.timer.step() end
|
||||||
|
@ -693,28 +692,24 @@ function love.run()
|
||||||
local dt=0
|
local dt=0
|
||||||
|
|
||||||
-- Main loop time.
|
-- Main loop time.
|
||||||
while true do
|
return function()
|
||||||
-- Process events.
|
-- Process events.
|
||||||
if love.event then
|
if love.event then
|
||||||
|
love.graphics.setCanvas() -- TODO: Rework this
|
||||||
love.event.pump()
|
love.event.pump()
|
||||||
for e, a, b, c, d in love.event.poll() do
|
love.graphics.setCanvas(pico8.screen) -- TODO: Rework this
|
||||||
if e=="quit" then
|
for name, a, b, c, d, e, f in love.event.poll() do
|
||||||
|
if name == "quit" then
|
||||||
if not love.quit or not love.quit() then
|
if not love.quit or not love.quit() then
|
||||||
if love.audio then
|
return a or 0
|
||||||
love.audio.stop()
|
|
||||||
end
|
|
||||||
return
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
love.handlers[e](a, b, c, d)
|
love.handlers[name](a, b, c, d, e, f)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Update dt, as we'll be passing it to update
|
-- Update dt, as we'll be passing it to update
|
||||||
if love.timer then
|
if love.timer then dt=dt+love.timer.step() end
|
||||||
love.timer.step()
|
|
||||||
dt=dt+love.timer.getDelta()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Call update and draw
|
-- Call update and draw
|
||||||
local render=false
|
local render=false
|
||||||
|
@ -726,9 +721,10 @@ function love.run()
|
||||||
end
|
end
|
||||||
dt=dt-frametime
|
dt=dt-frametime
|
||||||
render=true
|
render=true
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if render and love.window and love.graphics and love.window.isCreated() then
|
if render and love.graphics and love.graphics.isActive() then
|
||||||
love.graphics.origin()
|
love.graphics.origin()
|
||||||
if paused then
|
if paused then
|
||||||
api.rectfill(64-4*4, 60, 64+4*4-2, 64+4+4, 1)
|
api.rectfill(64-4*4, 60, 64+4*4-2, 64+4+4, 1)
|
||||||
|
|
Loading…
Reference in New Issue