├── .gitattributes ├── Changelog.md ├── Implemented.md ├── LICENSE ├── LOVE-WrapLua ├── OneLua │ ├── audio.lua │ ├── callbacks.lua │ ├── event.lua │ ├── graphics.lua │ ├── graphics_psp.lua │ ├── keyboard.lua │ ├── mouse.lua │ ├── shader.lua │ ├── timer.lua │ ├── touch.lua │ └── whileloop.lua ├── PS3 │ ├── audio.lua │ ├── event.lua │ ├── graphics.lua │ ├── keyboard.lua │ ├── timer.lua │ └── whileloop.lua ├── Vera.ttf ├── filesystem.lua ├── lpp-vita │ ├── audio.lua │ ├── event.lua │ ├── graphics.lua │ ├── keyboard.lua │ ├── timer.lua │ └── whileloop.lua ├── math.lua └── system.lua ├── README.md ├── app.lua ├── game ├── conf.lua ├── image.png └── main.lua ├── index.lua ├── script.lua └── tools ├── convertAudio.sh ├── convertSendAudio.sh ├── deleteAudio.sh └── fastCurl.sh /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /Changelog.md: -------------------------------------------------------------------------------- 1 | ## Changelog 2 | - By Hipreme/MrcSnm: 3 | ### OneLua/PS_Vita Only 4 | - Support most of love.graphics functions 5 | - touch.lua and mouse.lua added 6 | - Added command for resetting (Hold LEFT, UP, SQUARE, TRIANGLE, L and press R) 7 | - Support for quads, global scale and offset 8 | - Added printf function for right, left and center alignment 9 | - Backwards WrapLua compatibility 10 | - Now it supports love2d objects (Now you can call imageInstance:getWidth() etc) 11 | - Added some do-nothing functions for not breaking code compatibility with desktop version 12 | - Correctly replaced 'require' function 13 | - Added callbacks onResume and onLiveArea 14 | 15 | ### Needing 16 | - Rotated text 17 | - Blend modes 18 | - Shader support 19 | - Tint blit for everything 20 | - Better image.blit for quads 21 | 22 | 23 | #### Known Issues 24 | - Calling screen.textwidth(font, text, size) will make the font passed on the argument to blur, the current workaround is creating a clone e.g loading the same font 2 times and then using the guinea pig to get the text width 25 | - Calling image.blit() for a resized image quad will mantain the texture size, the current workaround is loading a image copy with image.copyscale() for the size needed, it will cache this resized image until it's scale is changed, the problem is that it will lag a bit when caching, don't know to what extent this is possible, and doing scale animations with images from quad is really inusable 26 | - The only supported audio that didn't crash the engine was mp3 at a 44100 sample rate, wav file didn't crash, but sounded strange, need more tests 27 | 28 | 29 | 30 | #### OneLua Wrong Documentations 31 | - screen.textheight -> Actually receiving (string) instead receiving (userdata, number), actually returning 20 no matter what, the Y offset = 18.5 32 | - image.setfilter -> Actually receives a image and the 2 types (image, number, number), image, mag, min 33 | 34 | ##### EXTRA 35 | - Tool for sending every type of file for Linux, called fastCurl, just call 36 | ```sh 37 | ./fastCurl.sh "filetype" 38 | ``` 39 | - Type only the filetype, without the ".", it will send recursively every "filetype" from the folder inside ./homebrew, it will send defaultly to ftp://192.168.15.19:1337/ux0:/ONELUAHP0/, change it to your needings, if you cancel while sending the files, enter in the directory of fastCurl and delete the cache .txt files 40 | - Added a tool to convert your audio files recursively instantly, it just requires 'sox' command from shelll, you can find it here: http://sox.sourceforge.net/ 41 | - The usage is the same as fastCurl, it won't delete your original audio files, it will create a copy to the supported filetype to vita, the usage is the same and the filetype can be overridden to the "filetype" you specify, the default type is mp3 42 | - A tool for deleting your audios, it is defaulted to only remove mp3 files, there is no confirm button, so take care 43 | -------------------------------------------------------------------------------- /Implemented.md: -------------------------------------------------------------------------------- 1 | # Implemented 2 | 3 | ## Callbacks 4 | - love.load 5 | - love.draw 6 | - love.update 7 | - love.keypressed 8 | - love.keyreleased 9 | - love.textinput 10 | - love.quit 11 | 12 | ## love 13 | - love.getVersion 14 | 15 | ## love.graphics 16 | - love.graphics.setBackgroundColor 17 | - love.graphics.setColor 18 | - love.graphics.newImage 19 | - love.graphics.newFont 20 | - love.graphics.draw 21 | - love.graphics.setFont 22 | - love.graphics.setNewFon 23 | - love.graphics.print 24 | - love.graphics.rectangle 25 | - love.graphics.circle 26 | - love.graphics.line 27 | 28 | ## love.timer 29 | - love.timer.getTime 30 | - love.timer.getDelta 31 | 32 | ## love.keyboard 33 | - love.keyboard.isDown 34 | - love.keyboard.setTextInput 35 | 36 | ## love.event 37 | - love.event.quit 38 | 39 | ## love.system 40 | - love.system.getOS 41 | - love.system.getLanguage 42 | - love.system.getUsername 43 | 44 | ## love.filesystem 45 | - love.filesystem.read 46 | - love.filesystem.write 47 | - love.filesystem.remove 48 | - love.filesystem.load 49 | - love.filesystem.isFile 50 | - love.filesystem.getInfo (currently same as isFile) 51 | - love.filesystem.getIdentity 52 | 53 | ## love.math 54 | - love.math.random (same as math.random) 55 | - love.math.setRandomSeed (same as math.randomseed) 56 | 57 | ## love.audio 58 | - love.audio.newSource 59 | - love.audio.play 60 | - love.audio.stop 61 | 62 | ## Source 63 | - Source:play 64 | - Source:stop 65 | - Source:getVolume 66 | - Source:isPlaying 67 | - Source:isLooping 68 | - Source:setLooping 69 | - Source:setVolume 70 | 71 | 72 | # VITA OneLua callbacks 73 | - onLiveArea 74 | - onResume 75 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 LukeeGD 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /LOVE-WrapLua/OneLua/audio.lua: -------------------------------------------------------------------------------- 1 | local _channel1 = nil 2 | local _channel2 = nil 3 | 4 | 5 | --Mode parameter should be private 6 | -- -1 means invert state 7 | -- 0 means resume 8 | -- 1 means pause 9 | function love.audio.pause(source, mode) 10 | if(mode == nil) then 11 | mode = 1 12 | end 13 | if(source == nil) then 14 | if(_channel1 ~= nil) then 15 | sound.pause(_channel1.loadsound, mode) 16 | end 17 | if(_channel2 ~= nil) then 18 | sound.pause(_channel2.loadsound, mode) 19 | end 20 | else 21 | sound.pause(source.loadsound, mode) 22 | end 23 | end 24 | 25 | function love.audio.resume(source) 26 | love.audio.pause(source, 0) 27 | end 28 | 29 | function __convertToSupported(source) 30 | local first, last = string.find(source, "%.%a+") 31 | local str = string.lower(string.sub(source, first+1, last)) 32 | 33 | local default = "mp3" 34 | if(str == "wav" or str == "wma" or str == "m4a" or str == "3gp" or str == "ogg") then 35 | return string.sub(source, 1, first) ..default 36 | else 37 | return source 38 | end 39 | end 40 | 41 | 42 | function love.audio.newSource(source,sourcetype) 43 | local table = { 44 | loadsound = sound.load(__convertToSupported(lv1lua.dataloc.."game/"..source)); 45 | type = sourcetype; 46 | play = function(self) 47 | if self.loadsound then love.audio.play(self) end; 48 | end; 49 | stop = function(self) 50 | if self.loadsound then love.audio.stop(self) end; 51 | end; 52 | getVolume = function(self) 53 | if self.loadsound then return sound.vol(self.loadsound) end; 54 | end; 55 | setVolume = function(self,vol) 56 | if self.loadsound then sound.vol(self.loadsound,vol*100) end; 57 | end; 58 | setLooping = function(self,setloop) 59 | if self.loadsound then 60 | if sound.looping(self.loadsound) ~= setloop then 61 | sound.loop(self.loadsound); 62 | end; 63 | end 64 | end; 65 | isPlaying = function(self) 66 | if self.loadsound then return sound.playing(self.loadsound) end; 67 | end; 68 | isLooping = function(self) 69 | if self.loadsound then return sound.looping(self.loadsound) end; 70 | end; 71 | } 72 | return table 73 | end 74 | 75 | --OneLua limitation -> Just have 2 sound channels 76 | function love.audio.play(source) 77 | if source.type == "static" then 78 | _channel1 = source 79 | sound.play(source.loadsound,1) 80 | else 81 | _channel2 = source 82 | sound.play(source.loadsound,2) 83 | end 84 | end 85 | 86 | function love.audio.stop(source) 87 | if(source == _channel1) then 88 | _channel1 = nil 89 | else 90 | _channel2 = nil 91 | end 92 | sound.stop(source.loadsound) 93 | end 94 | -------------------------------------------------------------------------------- /LOVE-WrapLua/OneLua/callbacks.lua: -------------------------------------------------------------------------------- 1 | --Currently WIP 2 | function onLiveArea() 3 | -- love.audio.pause() 4 | end 5 | 6 | function onResume() 7 | -- love.audio.resume() 8 | end -------------------------------------------------------------------------------- /LOVE-WrapLua/OneLua/event.lua: -------------------------------------------------------------------------------- 1 | function love.event.quit(re) 2 | if love.quit then 3 | love.quit() 4 | end 5 | 6 | if re == "restart" then 7 | os.restart() 8 | else 9 | lv1lua.running = false 10 | os.exit() 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /LOVE-WrapLua/OneLua/graphics.lua: -------------------------------------------------------------------------------- 1 | local defaultfont = lv1lua.dataloc.."LOVE-WrapLua/Vera.ttf" 2 | local scale = 0.75 3 | local defaultMinificationFilter = 3 4 | local defaultMagnificationFilter = 3 5 | local anisotropy = 0 6 | 7 | local _loadedFonts = {fontInstances = {}} 8 | function _loadedFonts:hasLoaded(fontName, size) 9 | return (self.fontInstances[fontName..size] ~= nil) 10 | end 11 | function _loadedFonts:setLoaded(fontName, fontInstance) 12 | self.fontInstances[fontName..fontInstance.size] = fontInstance 13 | end 14 | --There is a default font offset for OneLua, another issue instead of setting correctly a pivot point 15 | --It's pivot is (0, 1) + offsetY, this offsetY = default font size, it is easier to notice the pivot when scaling it down 16 | 17 | local _VITA_DEFAULT_PRINT_Y_OFFSET = 18.5 --Current Ugly Workaround 18 | --Another problem, screen.textheight is broken 19 | local __oldScreenTxtHeight = screen.textheight 20 | function screen.textheight(font, size) 21 | return size 22 | end 23 | 24 | local Transform = 25 | { 26 | new = function(self) 27 | local obj = {} 28 | setmetatable(obj, self) 29 | obj._scaleX = 1 30 | obj._scaleY = 1 31 | obj._offsetX = 0 32 | obj._offsetY = 0 33 | obj._usingScissor = false 34 | obj._scissorX = 0 35 | obj._scissorY = 0 36 | obj._scissorWidth = 0 37 | obj._scissorHeight = 0 38 | return obj 39 | end 40 | } 41 | 42 | local _transformStack = 43 | { 44 | transform = Transform:new(), 45 | stack = {}, 46 | _dirty = true, 47 | updateTransform = 48 | function (self) 49 | if(not self._dirty) then 50 | return 51 | end 52 | local x = 0 53 | local y = 0 54 | local scaleX = 1 55 | local scaleY = 1 56 | local usingScissor = false 57 | local scissorX = 0 58 | local scissorY = 0 59 | local scissorWidth = 0 60 | local scissorHeight = 0 61 | 62 | local transforms = self.stack 63 | for i = 1, #transforms do 64 | x = x * transforms[i]._scaleX + transforms[i]._offsetX 65 | y = y * transforms[i]._scaleY + transforms[i]._offsetY 66 | scaleX = scaleX * transforms[i]._scaleX 67 | scaleY = scaleY * transforms[i]._scaleY 68 | if transforms[i].usingScissor then usingScissor = true end 69 | if(usingScissor) then 70 | scissorX = transforms[i]._scissorX 71 | scissorY = transforms[i]._scissorY 72 | scissorWidth = transforms[i]._scissorWidth 73 | scissorHeight = transforms[i]._scissorHeight 74 | end 75 | end 76 | self.transform._offsetX= x 77 | self.transform._offsetY= y 78 | self.transform._scaleX= scaleX 79 | self.transform._scaleY= scaleY 80 | self.transform._usingScissor= usingScissor 81 | self.transform._scissorX= scissorX 82 | self.transform._scissorY= scissorY 83 | self.transform._scissorWidth= scissorWidth 84 | self.transform._scissorHeight= scissorHeight 85 | self._dirty = false 86 | end 87 | } 88 | 89 | local cachedPrintf = 90 | { 91 | text = {}, --Will be some map 92 | purgeAt = 100, 93 | } 94 | function cachedPrintf:cache(text, line, x, y, align) 95 | if(self.text[text..align] == nil) then 96 | self.text[text..align] = {lines = {}, x = {}, y = {}, sizes = {}, len = 0, purgeCount = 0} 97 | end 98 | local c = self.text[text..align] 99 | c.len = c.len + 1 100 | c.x[c.len] = x 101 | c.y[c.len] = y 102 | c.font = lv1lua.current.font.font 103 | c.size = lv1lua.current.font.size 104 | c.lines[c.len] = line 105 | end 106 | function cachedPrintf:purge() 107 | local v 108 | local at = self.purgeAt 109 | for i in pairs(self.text) do 110 | v = self.text[i] 111 | v.purgeCount = v.purgeCount + 1 112 | if v.purgeCount == at then 113 | self.text[i] = nil 114 | end 115 | end 116 | end 117 | function cachedPrintf:print(text, align) 118 | if(self.text[text..align] == nil) then 119 | return false 120 | else 121 | local v = self.text[text..align] 122 | if(v.size ~= lv1lua.current.font.size or v.font ~= lv1lua.current.font.font) then 123 | self.text[text..align] = nil 124 | return false 125 | end 126 | 127 | v.purgeCount = 0 128 | for i = 1, v.len do 129 | love.graphics.print(v.lines[i], v.x[i], v.y[i]) 130 | end 131 | return true 132 | end 133 | end 134 | 135 | function __mathRound(value) 136 | local remain = value % 1 137 | if(remain % 1 >= 0.49) then 138 | return value + 1 - remain 139 | else 140 | return value - remain 141 | end 142 | end 143 | 144 | --set up stuff 145 | font.setdefault(font.load(defaultfont)) 146 | lv1lua.current = 147 | { 148 | font=defaultfont, 149 | color=color.new(255,255,255,255) 150 | } 151 | 152 | --Set up compatibility from old to new api 153 | local _oldImageGetW = image.getw 154 | local _oldImageGetH = image.geth 155 | function image.getw(img) 156 | if(img.imgData ~= nil) then 157 | return image.getrealw(img.imgData) 158 | else 159 | return _oldImageGetW(img) 160 | end 161 | end 162 | function image.geth(img) 163 | if(img.imgData ~= nil) then 164 | return image.getrealh(img.imgData) 165 | else 166 | return _oldImageGetH(img) 167 | end 168 | end 169 | 170 | 171 | function love.graphics.newImage(filename) 172 | img = image.load(lv1lua.dataloc.."game/"..filename) 173 | 174 | if lv1luaconf.imgscale == true then 175 | image.scale(img,scale*100) 176 | end 177 | local imgWrapper = 178 | { 179 | imgData = img, 180 | flipX = false, 181 | flipY = false, 182 | getWidth = function(self)return image.getw(self)end, 183 | getHeight = function(self)return image.geth(self)end, 184 | getDimensions = function(self) return image.getw(self), image.geth(self)end 185 | } 186 | --Necessary to execute the same behavior from love2d desktop 187 | function imgWrapper:__handleNegativeScale(x, y, sx, sy) 188 | if(sx > 0 and self.flipX) then 189 | image.fliph(self.imgData) 190 | self.flipX = not self.flipX 191 | elseif(sx < 0 and self.flipX == false) then 192 | image.fliph(self.imgData) 193 | self.flipX = not self.flipX 194 | end 195 | if(sy > 0 and self.flipY) then 196 | image.flipv(self.imgData) 197 | self.flipY = not self.flipY 198 | elseif(sy < 0 and self.flipY == false) then 199 | image.flipv(self.imgData) 200 | self.flipY = not self.flipY 201 | end 202 | if(sx < 0) then 203 | x = x + (self:getWidth() * sx) 204 | end 205 | if(sy < 0) then 206 | y = y + self:getHeight() * sy 207 | end 208 | return x,y 209 | end 210 | 211 | return imgWrapper 212 | end 213 | 214 | function love.graphics.newQuad(x, y, width, height, sw, sh) 215 | local quad = 216 | { 217 | x=x,y=y,width=width,height=height,sw=sw,sh=sh, 218 | 219 | _savedScaleX = 1, 220 | _savedScaleY = 1, 221 | _bufferImage = nil, 222 | getTextureDimensions = function(self)return sw,sh end, 223 | getViewport = function(self)return self.x, self.y, self.width, self.height end, 224 | setViewport = function(self, x, y, width, height)self.x = x; self.y = y; self.width = width; self.height = height; end 225 | } 226 | function quad:getViewportScaled(sx, sy) 227 | return self.x * sx, self.y * sy, self.width * sx, self.height * sy 228 | end 229 | function quad:getTextureDimensionsScaled(sx, sy) 230 | return sw * sx,sh * sy 231 | end 232 | function quad:updateBufferScaled(drawable, sx, sy) 233 | --This function can lag a bit, but it is required, as I could not find in OneLua any other way to scale a image frame 234 | if(sx ~= self._savedScaleX or sy ~= self._savedScaleY or self._bufferImage == nil) then 235 | if(self._bufferImage ~= nil) then 236 | image.lost(drawable) --Clear the buffer 237 | end 238 | self._bufferImage = image.copyscale(drawable, self:getTextureDimensionsScaled(sx, sy)) 239 | self._savedScaleX = sx 240 | self._savedScaleY = sy 241 | end 242 | end 243 | function quad:draw(drawable, x, y, r, sx, sy) 244 | self:updateBufferScaled(drawable, sx,sy) 245 | love.graphics._defaultDraw(self._bufferImage, x, y, r, sx, sy, self:getViewportScaled(sx, sy)) 246 | end 247 | return quad 248 | end 249 | 250 | function love.graphics.translate(offsetX, offsetY) 251 | _transformStack.stack[#_transformStack.stack]._offsetX = offsetX 252 | _transformStack.stack[#_transformStack.stack]._offsetY = offsetY 253 | _transformStack._dirty = true 254 | end 255 | 256 | function love.graphics.scale(scaleX, scaleY) 257 | if not scaleY then scaleY = scaleX end 258 | _transformStack.stack[#_transformStack.stack]._scaleX = scaleX 259 | _transformStack.stack[#_transformStack.stack]._scaleY = scaleY 260 | _transformStack._dirty = true 261 | end 262 | 263 | function love.graphics.setScissor(scissorX, scissorY, scissorWidth, scissorHeight) 264 | _transformStack.stack[#_transformStack.stack].usingScissor = (scissorX ~= nil) 265 | _transformStack.stack[#_transformStack.stack]._scissorX = scissorX 266 | _transformStack.stack[#_transformStack.stack]._scissorY = scissorY 267 | _transformStack.stack[#_transformStack.stack]._scissorWidth = scissorWidth 268 | _transformStack.stack[#_transformStack.stack]._scissorHeight = scissorHeight 269 | _transformStack._dirty = true 270 | end 271 | 272 | function love.graphics.push() 273 | _transformStack.stack[#_transformStack.stack + 1] = Transform:new() 274 | end 275 | love.graphics.push() 276 | 277 | function love.graphics.pop() 278 | _transformStack.stack[#_transformStack.stack] = nil 279 | _transformStack._dirty = true 280 | end 281 | 282 | 283 | function love.graphics.setDefaultFilter(min, mag, anisotropy) 284 | --Point/Nearest 285 | --Apoint (Not supported from love) 286 | --Linear 287 | --Alinear (Not supported from love) 288 | if(min == "linear") then 289 | min = __IMG_FILTER_LINEAR 290 | elseif(min == "nearest" or min == "point") then 291 | min = __IMG_FILTER_POINT 292 | end 293 | if(mag == "linear") then 294 | mag = __IMG_FILTER_LINEAR 295 | elseif(mag == "nearest" or mag == "point") then 296 | mag = __IMG_FILTER_POINT 297 | end 298 | defaultMinificationFilter = min 299 | defaultMagnificationFilter = mag 300 | anisotropy = (anisotropy == nil) and 0 or 1 301 | end 302 | 303 | function love.graphics.getDefaultFilter() 304 | return defaultMinificationFilter, defaultMagnificationFilter, anisotropy 305 | end 306 | 307 | function love.graphics._defaultDraw(drawable,x,y,r,sx,sy, xf, yf, w, h) 308 | if drawable == nil then print("No drawable passed"); return end 309 | if not x then x = 0 end 310 | if not y then y = 0 end 311 | if sx and not sy then sy = sx end 312 | 313 | --scale 1280x720 to 960x540(vita) 314 | if lv1luaconf.imgscale == true or lv1luaconf.resscale == true then 315 | x = x * scale; y = y * scale 316 | end 317 | 318 | if r then 319 | image.rotate(drawable,(r/math.pi)*180) --radians to degrees 320 | end 321 | 322 | if sx then 323 | image.setfilter(drawable, defaultMagnificationFilter, defaultMinificationFilter) 324 | image.resize(drawable,image.getrealw(drawable)*sx,image.getrealh(drawable)*sy) 325 | end 326 | if(xf ~= nil) then 327 | image.blit(drawable,x,y, xf, yf, w, h, color.a(lv1lua.current.color)) 328 | else 329 | image.blit(drawable,x,y,color.a(lv1lua.current.color)) 330 | end 331 | end 332 | 333 | function love.graphics.draw(drawable,xOrQuad,y,r,sx,sy, x) 334 | local isDrawableNew = (type(drawable) == "table") 335 | 336 | local _x, _y, _r, _sx, _sy 337 | _transformStack:updateTransform() 338 | local transform = _transformStack.transform 339 | if (type(xOrQuad) == "table") then 340 | _x = (y == nil) and transform._offsetX or y + transform._offsetX 341 | _y = (r == nil) and transform._offsetY or r + transform._offsetY 342 | _r = sx 343 | _sx = (sy == nil) and transform._scaleX or sy * transform._scaleX 344 | _sy = (x == nil) and transform._scaleY or x * transform._scaleY 345 | local absSx, absSy = math.abs(_sx), math.abs(_sy) 346 | _x = __mathRound(_x * absSx) 347 | _y = __mathRound(_y * absSy) 348 | 349 | if(isDrawableNew) then 350 | _x, _y = drawable:__handleNegativeScale(_x, _y, _sx, _sy) 351 | xOrQuad:draw(drawable.imgData, _x, _y, _r, absSx, absSy) 352 | else 353 | xOrQuad:draw(drawable, _x, _y, _r, absSx, absSy) 354 | end 355 | else 356 | _x = xOrQuad or 0 357 | _y = y or 0 358 | _sx = (sx == nil) and transform._scaleX or sx * transform._scaleX 359 | _sy = (sy == nil) and transform._scaleY or sy * transform._scaleY 360 | _x = __mathRound(_x * math.abs(_sx)) 361 | _y = __mathRound(_y * math.abs(_sy)) 362 | local absSx, absSy = math.abs(_sx), math.abs(_sy) 363 | 364 | if isDrawableNew then 365 | _x, _y = drawable:__handleNegativeScale(_x, _y, _sx, _sy) 366 | love.graphics._defaultDraw(drawable.imgData, _x, _y, r, absSx, absSy) 367 | else 368 | love.graphics._defaultDraw(drawable, _x, _y, r, absSx, absSy) 369 | end 370 | end 371 | 372 | 373 | --Test for fps 374 | end 375 | 376 | --Too much text in just graphics.lua, considering in split graphics.lua in many modules 377 | 378 | function love.graphics.newFont(setfont, setsize) 379 | if not setfont or tonumber(setfont) then 380 | setfont = defaultfont 381 | end 382 | setsize = setsize or 12 383 | local fontName = setfont 384 | --For the currently OneLua ver, there must be one guinea pig for screen.textwidth, as using it on the current font may 385 | --Cause it to blur 386 | local guineaPig 387 | 388 | if(not _loadedFonts:hasLoaded(fontName, setsize)) then 389 | if fontName == defaultfont then 390 | setfont = font.load(defaultfont) 391 | guineaPig = font.load(defaultfont) 392 | else 393 | setfont = font.load(lv1lua.dataloc.."game/"..fontName) 394 | guineaPig = font.load(lv1lua.dataloc.."game/"..fontName) 395 | end 396 | local nFont = { 397 | name = fontName; 398 | font = setfont; 399 | guineaPig = guineaPig; 400 | size = setsize; 401 | } 402 | _loadedFonts:setLoaded(fontName, nFont) 403 | function nFont:getWidth(text) 404 | return screen.textwidth(self.guineaPig, text, self.size / 18.5) 405 | end 406 | function nFont:getHeight() 407 | return screen.textheight(self.guineaPig, self.size) 408 | end 409 | return nFont 410 | else 411 | return _loadedFonts.fontInstances[fontName..setsize] 412 | end 413 | end 414 | 415 | function love.graphics.setFont(setfont,setsize) 416 | lv1lua.current.font = setfont 417 | if setsize then 418 | lv1lua.current.font.size = setsize 419 | end 420 | end 421 | 422 | function love.graphics.setNewFont(setfont,setsize) 423 | newfont = love.graphics.newFont(setfont, setsize) 424 | love.graphics.setFont(newfont, setsize) 425 | return newfont 426 | end 427 | 428 | function love.graphics._defaultPrint(text, x, y, fontsize) 429 | if not x then x = 0 end 430 | if not y then y = 0 end 431 | fontsize = ((fontsize == nil) and lv1lua.current.font.size/18.5 or fontsize) 432 | 433 | --scale 1280x720 to 960x540(vita) 434 | if lv1luaconf.imgscale == true or lv1luaconf.resscale == true then 435 | x = x * scale; y = y * scale 436 | fontsize = fontsize * scale 437 | end 438 | 439 | screen.print(lv1lua.current.font.font,x,y,text,fontsize,lv1lua.current.color) 440 | end 441 | 442 | function love.graphics.print(text,x,y) 443 | if text == nil or text == "" then 444 | return 445 | end 446 | _transformStack:updateTransform() 447 | 448 | local _fontScale = (_transformStack.transform._scaleX + _transformStack.transform._scaleY) / 2 449 | local fontsize = lv1lua.current.font.size/18.5 * _fontScale 450 | 451 | local heightOffset = lv1lua.current.font:getHeight() * _fontScale 452 | x = x * _transformStack.transform._scaleX 453 | y = y * _transformStack.transform._scaleY 454 | --For actually pivoting it on (0,0) 455 | y = y - (_VITA_DEFAULT_PRINT_Y_OFFSET - heightOffset) 456 | 457 | love.graphics._defaultPrint(text, x, y, fontsize) 458 | end 459 | 460 | function ___getAlignX(x, align, size, wrapSize) 461 | if(align == "center") then 462 | return x + (wrapSize - size) / 2 463 | elseif(align == "right") then 464 | return x + wrapSize - size 465 | else 466 | return x 467 | end 468 | end 469 | 470 | function __formatTextPrint(text, x, y, wrapWidth, align) 471 | local word = "" 472 | local currentPhrase = "" 473 | local __phraseWidth = 0 474 | local __wordWidth = 0 475 | local currentIndex = 1 476 | local spaceWidth = lv1lua.current.font:getWidth(" ") 477 | 478 | for c in string.gmatch(text, ".") do 479 | if(c == "\n" or __wordWidth > wrapWidth or __wordWidth + __phraseWidth > wrapWidth) then 480 | if(__wordWidth > wrapWidth) then 481 | 482 | --Print word 483 | cachedPrintf:cache(text, word, ___getAlignX(x, align, __wordWidth , wrapWidth), y, align) 484 | love.graphics.print(word, ___getAlignX(x, align, __wordWidth , wrapWidth), y) 485 | 486 | word = "" 487 | __wordWidth = 0 488 | 489 | elseif(__wordWidth + __phraseWidth > wrapWidth) then 490 | --Print phrase and store word for the next print phase 491 | local found = false 492 | for i = currentIndex, string.len(text) do 493 | if string.sub(text, i, i) == " " then --Print what I have 494 | cachedPrintf:cache(text, currentPhrase, ___getAlignX(x, align, __phraseWidth + spaceWidth*2, wrapWidth), y, align) 495 | love.graphics.print(currentPhrase, ___getAlignX(x, align, __phraseWidth + spaceWidth*2, wrapWidth), y) 496 | found = true 497 | -- print("FOUND, printing '"..currentPhrase.."'") 498 | word = word..c 499 | __wordWidth = __wordWidth + spaceWidth 500 | break 501 | end 502 | end 503 | if(not found) then 504 | cachedPrintf:cache(text, currentPhrase..word, ___getAlignX(x, align, __phraseWidth + __wordWidth + spaceWidth , wrapWidth), y, align) 505 | love.graphics.print(currentPhrase..word, ___getAlignX(x, align, __phraseWidth + __wordWidth + spaceWidth , wrapWidth), y) 506 | word = "" 507 | __wordWidth = 0 508 | end 509 | else --\n case 510 | cachedPrintf:cache(text, currentPhrase..word, ___getAlignX(x, align, __wordWidth + __phraseWidth , wrapWidth), y, align) 511 | love.graphics.print(currentPhrase..word, ___getAlignX(x, align, __wordWidth + __phraseWidth , wrapWidth), y) 512 | word = "" 513 | __wordWidth = 0 514 | end 515 | y = y + lv1lua.current.font:getHeight() --Jump line 516 | currentPhrase = "" 517 | __phraseWidth = 0 518 | --If it has a space, append current word to the phrase for future print 519 | elseif(c == " ") then 520 | if(currentPhrase ~= "") then 521 | currentPhrase = currentPhrase.." "..word 522 | __phraseWidth = __wordWidth + __phraseWidth + spaceWidth 523 | else 524 | currentPhrase = word 525 | __phraseWidth = __wordWidth 526 | end 527 | 528 | -- print("Phrase = "..currentPhrase.." "..__phraseWidth) 529 | word = "" 530 | __wordWidth = 0 531 | else 532 | word = word..c 533 | __wordWidth = __wordWidth + lv1lua.current.font:getWidth(c) 534 | end 535 | currentIndex = currentIndex + 1 536 | end 537 | 538 | --If there is any remaining text unprinted 539 | if(__phraseWidth ~= 0 or __wordWidth ~= 0) then 540 | cachedPrintf:cache(text, currentPhrase.." "..word, ___getAlignX(x, align, __wordWidth + __phraseWidth + spaceWidth*2 , wrapWidth), y, align) 541 | love.graphics.print(currentPhrase.." "..word, ___getAlignX(x, align, __wordWidth + __phraseWidth + spaceWidth*2 , wrapWidth), y) 542 | end 543 | end 544 | 545 | function love.graphics.printf(text, x, y, wrapWidth, align) 546 | --Accepteds alignments 547 | --Left, Right and Center 548 | if text == nil or text == "" then 549 | return 550 | end 551 | --Adds a purge count to every cached printf call 552 | cachedPrintf:purge() 553 | --If it was printed, it will reset its counter to purge 554 | 555 | if(cachedPrintf:print(text, align)) then 556 | return 557 | end 558 | --If not, generate a formatted print cache and print on screen 559 | __formatTextPrint(text, x, y, wrapWidth, align) 560 | end 561 | 562 | function love.graphics.setColor(r,g,b,a) 563 | if not a then a = 255 end 564 | lv1lua.current.color = color.new(r,g,b,a) 565 | end 566 | 567 | function love.graphics.setBackgroundColor(r,g,b) 568 | screen.clear(color.new(r,g,b)) 569 | end 570 | 571 | function love.graphics.rectangle(mode, x, y, w, h) 572 | --scale 1280x720 to 960x540(vita) 573 | if lv1luaconf.imgscale == true or lv1luaconf.resscale == true then 574 | x = x * scale; y = y * scale; w = w * scale; h = h * scale 575 | end 576 | 577 | if mode == "fill" then 578 | draw.fillrect(x, y, w * _transformStack.transform._scaleX, h * _transformStack.transform._scaleY, lv1lua.current.color) 579 | elseif mode == "line" then 580 | draw.rect(x, y, w * _transformStack.transform._scaleX, h * _transformStack.transform._scaleY, lv1lua.current.color) 581 | end 582 | end 583 | 584 | function love.graphics.line(x1,y1,x2,y2) 585 | draw.line(x1,y1,x2,y2,lv1lua.current.color) 586 | end 587 | 588 | function love.graphics.circle(x,y,radius) 589 | draw.circle(x,y,radius * _transformStack.transform._scaleX,lv1lua.current.color,30) 590 | end 591 | 592 | function ___displaySystemInfo() 593 | local currRam = math.floor((os.ram() / 1000000) * 100) / 100 594 | local totalRam = math.floor((os.totalram() / 1000000) * 100) / 100 595 | currRam = totalRam - currRam 596 | screen.print(10, 10, "FPS: " .. screen.frame() .. "/" .. screen.fps(), 12 / 18.5, color.new(0, 255, 0, 255)) 597 | screen.print(10, 30, "RAM: " .. currRam .. "/" .. totalRam .. "MB", 12 / 18.5, color.new(0, 255, 0, 255)) 598 | screen.print(10, 50, "CPU: " .. os.cpu() .. "/444Mhz", 12 / 18.5, color.new(0, 255, 0, 255)) 599 | screen.print(10, 70, "GPU: " .. os.gpuclock() .. "/166Mhz", 12 / 18.5, color.new(0, 255, 0, 255)) 600 | screen.print(10, 90, "GPU CROSS: " .. os.crossbarclock() .. "/222Mhz", 12 / 18.5, color.new(0, 255, 0, 255)) 601 | end 602 | -------------------------------------------------------------------------------- /LOVE-WrapLua/OneLua/graphics_psp.lua: -------------------------------------------------------------------------------- 1 | -- old graphics.lua for psp compat 2 | local defaultfont 3 | local scale = 0.375 4 | local fontscale = 0.6 5 | 6 | --default print font 7 | defaultfont = {font=font.load("oneFont.pgf"),size=15} 8 | font.setdefault(defaultfont.font) 9 | 10 | --set up stuff 11 | lv1lua.current = {font=defaultfont,color=color.new(255,255,255,255)} 12 | 13 | function love.graphics.newImage(filename) 14 | img = image.load(lv1lua.dataloc.."game/"..filename) 15 | 16 | if lv1luaconf.imgscale == true then 17 | image.scale(img,scale*100) 18 | end 19 | 20 | return img 21 | end 22 | 23 | function love.graphics.draw(drawable,x,y,r,sx,sy) 24 | if not x then x = 0 end 25 | if not y then y = 0 end 26 | if sx and not sy then sy = sx end 27 | 28 | --scale 1280x720 to 480x270(psp) 29 | if lv1luaconf.imgscale == true or lv1luaconf.resscale == true then 30 | x = x * scale; y = y * scale 31 | end 32 | 33 | if r then 34 | image.rotate(drawable,(r/math.pi)*180) --radians to degrees 35 | end 36 | 37 | if sx then 38 | image.resize(drawable,image.getrealw(drawable)*sx,image.getrealh(drawable)*sy) 39 | end 40 | 41 | if drawable then 42 | image.blit(drawable,x,y,color.a(lv1lua.current.color)) 43 | end 44 | end 45 | 46 | function love.graphics.newFont(setfont, setsize) 47 | if tonumber(setfont) then 48 | setsize = setfont 49 | elseif not setsize then 50 | setsize = 12 51 | end 52 | 53 | if tonumber(setfont) or lv1lua.isPSP then 54 | setfont = defaultfont.font 55 | elseif setfont then 56 | setfont = font.load(lv1lua.dataloc.."game/"..setfont) 57 | end 58 | 59 | local table = { 60 | font = setfont; 61 | size = setsize; 62 | } 63 | return table 64 | end 65 | 66 | function love.graphics.setFont(setfont,setsize) 67 | if not lv1lua.isPSP and setfont then 68 | lv1lua.current.font = setfont 69 | else 70 | lv1lua.current.font = defaultfont 71 | end 72 | 73 | if setsize then 74 | lv1lua.current.font.size = setsize 75 | end 76 | end 77 | 78 | function love.graphics.print(text,x,y) 79 | local fontsize = lv1lua.current.font.size/18.5 80 | if not x then x = 0 end 81 | if not y then y = 0 end 82 | 83 | --scale 1280x720 to 480x270(psp) 84 | if lv1luaconf.imgscale == true or lv1luaconf.resscale == true then 85 | x = x * scale; y = y * scale 86 | fontsize = fontsize*fontscale 87 | end 88 | 89 | if text then 90 | screen.print(lv1lua.current.font.font,x,y,text,fontsize,lv1lua.current.color) 91 | end 92 | end 93 | 94 | function love.graphics.setColor(r,g,b,a) 95 | if not a then a = 255 end 96 | lv1lua.current.color = color.new(r,g,b,a) 97 | end 98 | 99 | function love.graphics.setBackgroundColor(r,g,b) 100 | screen.clear(color.new(r,g,b)) 101 | end 102 | 103 | function love.graphics.rectangle(mode, x, y, w, h) 104 | --scale 1280x720 to 480x270(psp) 105 | if lv1luaconf.imgscale == true or lv1luaconf.resscale == true then 106 | x = x * scale; y = y * scale; w = w * scale; h = h * scale 107 | end 108 | 109 | if mode == "fill" then 110 | draw.fillrect(x, y, w, h, lv1lua.current.color) 111 | elseif mode == "line" then 112 | draw.rect(x, y, w, h, lv1lua.current.color) 113 | end 114 | end 115 | 116 | function love.graphics.line(x1,y1,x2,y2) 117 | draw.line(x1,y1,x2,y2,lv1lua.current.color) 118 | end 119 | 120 | function love.graphics.circle(x,y,radius) 121 | draw.circle(x,y,radius,lv1lua.current.color,30) 122 | end 123 | -------------------------------------------------------------------------------- /LOVE-WrapLua/OneLua/keyboard.lua: -------------------------------------------------------------------------------- 1 | function love.keyboard.isDown(key) 2 | if key == lv1lua.keyset[1] then 3 | key = "circle" 4 | elseif key == lv1lua.keyset[2] then 5 | key = "cross" 6 | elseif key == lv1lua.keyset[3] then 7 | key = "triangle" 8 | elseif key == lv1lua.keyset[4] then 9 | key = "square" 10 | elseif key == lv1lua.keyset[5] then 11 | key = "l" 12 | elseif key == lv1lua.keyset[6] then 13 | key = "r" 14 | end 15 | return buttons.held[key] 16 | end 17 | 18 | function love.keyboard.showTextInput(table) 19 | if table then 20 | local header = {"",""} 21 | if table["header"] then header[1] = table["header"] end 22 | if table["subheader"] then header[2] = table["subheader"] end 23 | local text = osk.init(header[1],header[2]) 24 | if text and text ~= "" then love.textinput(text) end 25 | end 26 | end 27 | 28 | function love.keyboard.setTextInput(table) 29 | love.keyboard.showTextInput(table) 30 | end 31 | -------------------------------------------------------------------------------- /LOVE-WrapLua/OneLua/mouse.lua: -------------------------------------------------------------------------------- 1 | --Mouse is a wrapper for simpler integration with touch 2 | love.mouse = { 3 | _lastX = 0, 4 | _lastY = 0 5 | } 6 | 7 | love.mousepressed = function(x,y,button)end 8 | 9 | love.mouse.getX = function() 10 | return love.mouse._lastX 11 | end 12 | 13 | love.mouse.getY = function() 14 | return love.mouse._lastY 15 | end 16 | 17 | love.mouse.getPosition = function() 18 | return love.mouse.getX(), love.mouse.getY() 19 | end 20 | 21 | 22 | love.mouse.isDown = function() 23 | return love.touch.getPressure(love.touch._count) == 1 24 | end 25 | 26 | love.mouse.__updateMouse = function() 27 | love.mouse._lastX, love.mouse._lastY = love.touch.getPosition(1) 28 | end -------------------------------------------------------------------------------- /LOVE-WrapLua/OneLua/shader.lua: -------------------------------------------------------------------------------- 1 | __ALPHA = 0 2 | __ADD = 1 3 | __currentBlendMode = __ALPHA --This mode equals do nothing on shader 4 | 5 | --No use of string comparison here 6 | --Optimizations on this section is based on https://www.lua.org/gems/sample.pdf 7 | 8 | local _pixels = {} --Copy of the screen 9 | local _imageCache = {} --Cached image data 10 | local _screenWidth = 0 11 | local _screenHeight = 0 12 | love.shader = {} 13 | 14 | local c_ = color.new --Internal local 15 | local p_ = image.pixel --Internal local 16 | 17 | function love.shader.initialize(screenWidth, screenHeight) 18 | for y = 1, screenHeight do 19 | for x = 1, screenWidth do 20 | _pixels[y * screenWidth + x] = c_(0,0,0,0) 21 | end 22 | end 23 | _screenWidth = screenWidth 24 | _screenHeight = screenHeight 25 | end 26 | 27 | function love.shader.setPixel(x, y, color) 28 | _pixels[y * _screenWidth + x] = color 29 | end 30 | 31 | function love.shader.getPixel(x, y) 32 | return _pixels[y * _screenWidth + x] 33 | end 34 | 35 | function love.shader.getPixeCachel(img, x, y) 36 | return _imageCache[img].pixels[y * _screenWidth + x] 37 | end 38 | 39 | 40 | --This function will cache the image data 41 | function love.shader.cacheData(img) 42 | if _imageCache[img] == nil then 43 | _imageCache[img] = {} 44 | _imageCache[img].pixels = {} 45 | local w = image.getrealw(img) 46 | local h = image.getrealh(img) 47 | 48 | _imageCache[img].width = w 49 | _imageCache[img].height = h 50 | for y = 1, h do 51 | for x = 1, w do 52 | _imageCache[img].pixels[y *w + x] = p_(img, x, y) 53 | end 54 | end 55 | end 56 | end 57 | 58 | --This function will load the data into the _pixels 59 | function love.shader.loadData(img, x, y) 60 | local data = _imageCache[img] 61 | local w, h = data.width, data.height 62 | 63 | for yCount = 1, h do 64 | for xCount = 1, w do 65 | love.shader.setPixel(xCount + x, yCount + y, data.pixels[yCount * w + xCount]) 66 | end 67 | end 68 | end 69 | 70 | 71 | function love.shader.blend(img, x, y) 72 | love.shader.cacheData(img) 73 | if(__currentBlendMode == __ALPHA)then 74 | love.shader.loadData(img, x, y) 75 | return 76 | end 77 | if(__currentBlendMode == __ADD)then 78 | 79 | end 80 | end 81 | 82 | function love.shader.render() 83 | for y = 1, _screenHeight do 84 | for x = 1, _screenWidth do 85 | draw.rect(x, y, 1, 1, _pixels[y * _screenWidth + x]) 86 | end 87 | end 88 | end -------------------------------------------------------------------------------- /LOVE-WrapLua/OneLua/timer.lua: -------------------------------------------------------------------------------- 1 | --timer stuff for update dt 2 | lv1lua.timer = timer.new() 3 | local gtimer = timer.new() 4 | lv1lua.timer:start() 5 | gtimer:start() 6 | dt = 0 7 | 8 | function love.timer.getTime() 9 | return gtimer:time() / 1000 10 | end 11 | 12 | function love.timer.getDelta() 13 | return dt 14 | end 15 | -------------------------------------------------------------------------------- /LOVE-WrapLua/OneLua/touch.lua: -------------------------------------------------------------------------------- 1 | love.touch = { 2 | _touches = {}, 3 | _count = 0 4 | } 5 | 6 | love.touch.__getFrontTouches = function(touchUserData) 7 | love.touch._count = touchUserData.front.count 8 | for i = 1, touchUserData.front.count do 9 | love.touch._touches[i] = touchUserData.front[i] 10 | end 11 | 12 | end 13 | 14 | love.touch.getPosition = function(id) 15 | if(id >= love.touch._count) then 16 | return 0, 0 17 | end 18 | return love.touch._touches[id].x, love.touch._touches[id].y 19 | end 20 | 21 | love.touch.getPressure = function(id) 22 | if(love.touch._count >= id and love.touch._touches[id] and love.touch._touches[id].pressed) then 23 | return 1 24 | else 25 | return 0 26 | end 27 | end 28 | 29 | love.touch.getTouches = function() 30 | return love.touch._touches 31 | end -------------------------------------------------------------------------------- /LOVE-WrapLua/OneLua/whileloop.lua: -------------------------------------------------------------------------------- 1 | local mask = {"up", "down", "left", "right", "cross", "circle", "square", "triangle", "r", "l", "start", "select", "home", "volup", "voldown"} 2 | local homeHeldtime = 0 3 | local homeCallbackThreshold = 0.04 --Next to 3 frames 4 | local homeCallbackCancel = 1 5 | local homeTime = 545 6 | 7 | dofile(lv1lua.dataloc.."LOVE-WrapLua/"..lv1lua.mode.."/callbacks.lua") 8 | 9 | --Live area will be handled manually 10 | 11 | 12 | function lv1lua.draw() 13 | if love.draw then love.draw() end 14 | screen.flip() 15 | end 16 | 17 | function lv1lua.update() 18 | if lv1lua.timer:time() >= 16 then 19 | dt = lv1lua.timer:time() / 1000 20 | if love.update then 21 | love.update(dt) 22 | end 23 | lv1lua.timer:reset() 24 | lv1lua.timer:start() 25 | end 26 | end 27 | 28 | function lv1lua.updatecontrols() 29 | -- buttons.homepopup(0) 30 | buttons.read() 31 | for i=1,#mask do 32 | if buttons[mask[i]] and mask[i] == "circle" then 33 | love.keypressed(lv1lua.keyset[1]) 34 | elseif buttons[mask[i]] and mask[i] == "cross" then 35 | love.keypressed(lv1lua.keyset[2]) 36 | elseif buttons[mask[i]] and mask[i] == "triangle" then 37 | love.keypressed(lv1lua.keyset[3]) 38 | elseif buttons[mask[i]] and mask[i] == "square" then 39 | love.keypressed(lv1lua.keyset[4]) 40 | elseif buttons[mask[i]] and mask[i] == "l" then 41 | love.keypressed(lv1lua.keyset[5]) 42 | elseif buttons[mask[i]] and mask[i] == "r" then 43 | love.keypressed(lv1lua.keyset[6]) 44 | elseif buttons[mask[i]] and mask[i] == "select" then 45 | love.keypressed("back") 46 | elseif buttons[mask[i]] then 47 | love.keypressed(mask[i]) 48 | end 49 | if buttons.released[mask[i]] and mask[i] == "circle" then 50 | love.keyreleased(lv1lua.keyset[1]) 51 | elseif buttons.released[mask[i]] and mask[i] == "cross" then 52 | love.keyreleased(lv1lua.keyset[2]) 53 | elseif buttons.released[mask[i]] and mask[i] == "triangle" then 54 | love.keyreleased(lv1lua.keyset[3]) 55 | elseif buttons.released[mask[i]] and mask[i] == "square" then 56 | love.keyreleased(lv1lua.keyset[4]) 57 | elseif buttons.released[mask[i]] and mask[i] == "l" then 58 | love.keyreleased(lv1lua.keyset[5]) 59 | elseif buttons.released[mask[i]] and mask[i] == "r" then 60 | love.keyreleased(lv1lua.keyset[6]) 61 | elseif buttons.released[mask[i]] and mask[i] == "select" then 62 | love.keyreleased("back") 63 | elseif buttons.released[mask[i]] then 64 | love.keyreleased(mask[i]) 65 | end 66 | end 67 | __checkGameRestart() 68 | if not lv1lua.isPSP then 69 | ___updateFrontTouch() 70 | -- __checkHomePress() 71 | end 72 | end 73 | 74 | function __checkGameRestart() 75 | if buttons.start and buttons.held.l and buttons.held.r and buttons.held.down 76 | then 77 | print("RESTART") 78 | os.restart() 79 | end 80 | end 81 | 82 | --WIP 83 | function __checkHomePress() 84 | --When all analogs are 0 and not flicking, it means that home is pressed 85 | if(buttons.analoglx == 0 and buttons.analogly == 0 and buttons.analogrx == 0 and buttons.analogry == 0) then 86 | homeHeldtime = homeHeldtime + dt 87 | else 88 | if(homeHeldtime>= homeCallbackThreshold and homeHeldtime < homeCallbackCancel) then 89 | __goLiveArea() 90 | end 91 | __resume() 92 | end 93 | end 94 | 95 | function __goLiveArea() 96 | print("Live Area") 97 | onLiveArea() 98 | os.golivearea() 99 | os.delay(homeTime) 100 | end 101 | 102 | function __resume() 103 | if(homeHeldtime>= homeCallbackThreshold and homeHeldtime < homeCallbackCancel) then 104 | while(buttons.waitforkey(__HOME)) do 105 | os.delay(1) 106 | end 107 | print("Resume") 108 | homeHeldtime = 0 109 | onResume() 110 | end 111 | end 112 | 113 | function ___updateFrontTouch() 114 | local lastMouseDown = love.mouse.isDown() 115 | touch.read() 116 | love.touch.__getFrontTouches(touch) 117 | love.mouse.__updateMouse() 118 | 119 | local newMouseDown = love.mouse.isDown() 120 | if(not lastMouseDown and newMouseDown) then 121 | love.mousepressed(love.mouse.getX(), love.mouse.getY(), 1) 122 | end 123 | end 124 | -------------------------------------------------------------------------------- /LOVE-WrapLua/PS3/audio.lua: -------------------------------------------------------------------------------- 1 | snd.Init() 2 | snd.SetVolumeBGMusic(127) 3 | local audioplaying = {} 4 | 5 | function lv1lua.playsound() 6 | for i = 1, #audioplaying do 7 | if audioplaying[i] == 1 then 8 | snd.PlayVoice(i,0,0,200,200,0) 9 | sys.TimerUsleep(0) 10 | end 11 | end 12 | end 13 | 14 | function love.audio.newSource(source,sourcetype) 15 | local ch 16 | 17 | if sourcetype == "stream" then 18 | ch = 1 19 | audioplaying[ch] = 0 20 | ret = snd.SetVoice(ch,lv1lua.dataloc.."game/"..source) 21 | end 22 | 23 | local table = { 24 | channel = ch; 25 | type = sourcetype; 26 | play = function(self) 27 | love.audio.play(self) 28 | end; 29 | stop = function(self) 30 | love.audio.stop(self) 31 | end; 32 | getVolume = function(self) 33 | --if self.loadsound then return (Sound.getVolume(self.loadsound))/100 end 34 | end; 35 | setVolume = function(self,vol) 36 | --if self.loadsound then Sound.setVolume(self.loadsound,vol*100) end 37 | end; 38 | setLooping = function(self,setloop) 39 | --all voices are looping in PS3 Lua Player unless stopped 40 | end; 41 | isPlaying = function(self) 42 | --if self.loadsound then return Sound.isPlaying(self.loadsound) end; 43 | end; 44 | isLooping = function(self) 45 | --if self.loadsound then return self.loop end; 46 | end; 47 | } 48 | return table 49 | end 50 | 51 | function love.audio.play(source) 52 | if source.channel then 53 | audioplaying[source.channel] = 1 54 | end 55 | end 56 | 57 | function love.audio.stop(source) 58 | if source.channel then 59 | audioplaying[source.channel] = 0 60 | snd.StopVoice(source.channel) 61 | snd.FreeVoice(source.channel) 62 | table.remove(audioplaying,source.channel) 63 | end 64 | end 65 | -------------------------------------------------------------------------------- /LOVE-WrapLua/PS3/event.lua: -------------------------------------------------------------------------------- 1 | function love.event.quit(re) 2 | if love.quit then 3 | love.quit() 4 | end 5 | EndGFX() 6 | snd.Finalize() 7 | lv1lua.running = false 8 | end 9 | -------------------------------------------------------------------------------- /LOVE-WrapLua/PS3/graphics.lua: -------------------------------------------------------------------------------- 1 | InitGFX(720,480) 2 | InitFont("/dev_flash/data/font/SCE-PS3-RD-R-LATIN.TTF", 12) 3 | defaultfont = nil 4 | 5 | --set up stuff 6 | lv1lua.current = {font=defaultfont,color=nil} 7 | 8 | function love.graphics.newImage(filename) 9 | local img = surface() 10 | img:LoadIMG(lv1lua.dataloc.."game/"..filename) 11 | return img 12 | end 13 | 14 | function love.graphics.draw(drawable,x,y,r,sx,sy) 15 | if not x then x = 0 end 16 | if not y then y = 0 end 17 | if not r then r = 0 end 18 | if not sx then sx = 1 end 19 | if not sy then sy = 1 end 20 | if sx and not sy then sy = sx end 21 | 22 | --scale 1280x720 to 720x480 23 | x = x * 0.5625; y = y * 0.5625 24 | y = y + 37 25 | 26 | if not lv1lua.isPSP and lv1luaconf.imgscale == true then 27 | sx = sx * 0.5625 28 | sy = sy * 0.5625 29 | end 30 | 31 | if drawable then 32 | drawable:setRectPos(x,y) 33 | BlitToScreen(drawable) 34 | end 35 | end 36 | 37 | function love.graphics.newFont(setfont, setsize) 38 | if tonumber(setfont) then 39 | setsize = setfont 40 | elseif not setsize then 41 | setsize = 12 42 | end 43 | 44 | if tonumber(setfont) or lv1lua.isPSP then 45 | setfont = defaultfont 46 | elseif setfont then 47 | --setfont = Font.load(lv1lua.dataloc.."game/"..setfont) 48 | setfont = nil 49 | end 50 | 51 | --scale 1280x720 to 960x540(vita) or 480x270(psp) 52 | if not lv1lua.isPSP and (lv1luaconf.imgscale == true or lv1luaconf.resscale == true) then 53 | setsize = setsize*0.75 54 | elseif lv1lua.isPSP and lv1luaconf.resscale == true then 55 | setsize = setsize*0.6 56 | end 57 | --Font.setPixelSizes(setfont,setsize) 58 | 59 | return setfont 60 | end 61 | 62 | function love.graphics.setFont(setfont,setsize) 63 | if setsize then 64 | --Font.setPixelSizes(setfont,setsize) 65 | end 66 | --lv1lua.current.font = setfont 67 | end 68 | 69 | function love.graphics.setNewFont(setfont,setsize) 70 | newfont = love.graphics.newFont(setfont, setsize) 71 | love.graphics.setFont(newfont, setsize) 72 | return newfont 73 | end 74 | 75 | function love.graphics.print(text,x,y) 76 | if not x then x = 0 end 77 | if not y then y = 0 end 78 | 79 | --scale 1280x720 to 720x480 80 | x = x * 0.5625; y = y * 0.5625 81 | y = y + 37 82 | 83 | if text then 84 | DrawText(x,y,text) 85 | end 86 | end 87 | 88 | function love.graphics.setColor(r,g,b,a) 89 | if not a then a = 255 end 90 | --lv1lua.current.color = Color.new(r,g,b,a) 91 | end 92 | 93 | function love.graphics.setBackgroundColor(r,g,b) 94 | --Screen.clear(Color.new(r,g,b)) 95 | end 96 | 97 | function love.graphics.rectangle(mode, x, y, w, h) 98 | --scale 1280x720 to 720x480 99 | x = x * 0.5625; y = y * 0.5625; w = w * 0.5625; h = h * 0.5625 100 | 101 | if mode == "fill" then 102 | --Graphics.fillRect(x, x+w, y, y+h, lv1lua.current.color) 103 | elseif mode == "line" then 104 | --Graphics.fillEmptyRect(x, x+w, y, y+h, lv1lua.current.color) 105 | end 106 | end 107 | 108 | function love.graphics.line(x1,y1,x2,y2) 109 | --Graphics.drawLine(x1,y1,x2,y2,lv1lua.current.color) 110 | end 111 | 112 | function love.graphics.circle(x,y,radius) 113 | --Graphics.fillCircle(x,y,radius,lv1lua.current.color) 114 | end 115 | -------------------------------------------------------------------------------- /LOVE-WrapLua/PS3/keyboard.lua: -------------------------------------------------------------------------------- 1 | pad.InitPads(1) 2 | lv1lua.key = { 3 | up=0,down=0,left=0,right=0, 4 | cross=0,circle=0,square=0,triangle=0, 5 | l=0,r=0,select=0,start=0 6 | } 7 | 8 | function love.keyboard.isDown(key) 9 | if (pad.up(0)>0 and key=="up") or (pad.down(0)>0 and key=="down") or 10 | (pad.left(0)>0 and key=="left") or (pad.right(0)>0 and key=="right") or 11 | (pad.circle(0)>0 and key==lv1lua.keyset[1]) or (pad.cross(0)>0 and key==lv1lua.keyset[2]) or 12 | (pad.triangle(0)>0 and key==lv1lua.keyset[3]) or (pad.square(0)>0 and key==lv1lua.keyset[4]) or 13 | (pad.L1(0)>0 and key==lv1lua.keyset[5]) or (pad.R1(0)>0 and key==lv1lua.keyset[6]) or 14 | (pad.select(0)>0 and key=="select") or (pad.start(0)>0 and key=="start") then 15 | return true 16 | end 17 | end 18 | 19 | function love.keyboard.showTextInput(table) 20 | --textinput 21 | end 22 | 23 | function love.keyboard.setTextInput(table) 24 | love.keyboard.showTextInput(table) 25 | end 26 | -------------------------------------------------------------------------------- /LOVE-WrapLua/PS3/timer.lua: -------------------------------------------------------------------------------- 1 | function love.timer.getTime() 2 | return os.time() 3 | end 4 | 5 | function love.timer.getDelta() 6 | return dt 7 | end 8 | -------------------------------------------------------------------------------- /LOVE-WrapLua/PS3/whileloop.lua: -------------------------------------------------------------------------------- 1 | loadstring = load 2 | dt = 0.0167 3 | sys.UtilRegisterCallback() 4 | 5 | function lv1lua.draw() 6 | StartGFX() 7 | if love.draw then love.draw() end 8 | FlipGFX() 9 | end 10 | 11 | function lv1lua.update() --this isn't really dt stuff, but ok heh 12 | if love.update then love.update(dt) end 13 | 14 | --Check ingame XMB 15 | local ret = sys.UtilCheckCallback(g_status) 16 | if ret == sys.SYSUTIL_EXIT_GAME then 17 | love.event.quit() --quit game over ingame XMB 18 | end 19 | 20 | --Play audio 21 | lv1lua.playsound() 22 | end 23 | 24 | function lv1lua.updatecontrols() 25 | --pressed 26 | if pad.circle(0) > 0 and lv1lua.key.circle == 0 then 27 | love.keypressed(lv1lua.keyset[1]) 28 | lv1lua.key.circle = 1 29 | elseif pad.cross(0) > 0 and lv1lua.key.cross == 0 then 30 | love.keypressed(lv1lua.keyset[2]) 31 | lv1lua.key.cross = 1 32 | elseif pad.triangle(0) > 0 and lv1lua.key.triangle == 0 then 33 | love.keypressed(lv1lua.keyset[3]) 34 | lv1lua.key.triangle = 1 35 | elseif pad.square(0) > 0 and lv1lua.key.square == 0 then 36 | love.keypressed(lv1lua.keyset[4]) 37 | lv1lua.key.square = 1 38 | elseif pad.L1(0) > 0 and lv1lua.key.l == 0 then 39 | love.keypressed(lv1lua.keyset[5]) 40 | lv1lua.key.l = 1 41 | elseif pad.R1(0) > 0 and lv1lua.key.r == 0 then 42 | love.keypressed(lv1lua.keyset[6]) 43 | lv1lua.key.r = 1 44 | elseif pad.up(0) > 0 and lv1lua.key.up == 0 then 45 | love.keypressed("up") 46 | lv1lua.key.up = 1 47 | elseif pad.down(0) > 0 and lv1lua.key.down == 0 then 48 | love.keypressed("down") 49 | lv1lua.key.down = 1 50 | elseif pad.left(0) > 0 and lv1lua.key.left == 0 then 51 | love.keypressed("left") 52 | lv1lua.key.left = 1 53 | elseif pad.right(0) > 0 and lv1lua.key.right == 0 then 54 | love.keypressed("right") 55 | lv1lua.key.right = 1 56 | elseif pad.select(0) > 0 and lv1lua.key.select == 0 then 57 | love.keypressed("back") 58 | lv1lua.key.select = 1 59 | elseif pad.start(0) > 0 and lv1lua.key.start == 0 then 60 | love.keypressed("start") 61 | lv1lua.key.start = 1 62 | end 63 | 64 | --released 65 | if pad.circle(0) == 0 and lv1lua.key.circle == 1 then 66 | love.keyreleased(lv1lua.keyset[1]) 67 | lv1lua.key.circle = 0 68 | elseif pad.cross(0) == 0 and lv1lua.key.cross == 1 then 69 | love.keyreleased(lv1lua.keyset[2]) 70 | lv1lua.key.cross = 0 71 | elseif pad.triangle(0) == 0 and lv1lua.key.triangle == 1 then 72 | love.keyreleased(lv1lua.keyset[3]) 73 | lv1lua.key.triangle = 0 74 | elseif pad.square(0) == 0 and lv1lua.key.square == 1 then 75 | love.keyreleased(lv1lua.keyset[4]) 76 | lv1lua.key.square = 0 77 | elseif pad.L1(0) == 0 and lv1lua.key.l == 1 then 78 | love.keyreleased(lv1lua.keyset[5]) 79 | lv1lua.key.l = 0 80 | elseif pad.R1(0) == 0 and lv1lua.key.r == 1 then 81 | love.keyreleased(lv1lua.keyset[6]) 82 | lv1lua.key.r = 0 83 | elseif pad.up(0) == 0 and lv1lua.key.up == 1 then 84 | love.keyreleased("up") 85 | lv1lua.key.up = 0 86 | elseif pad.down(0) == 0 and lv1lua.key.down == 1 then 87 | love.keyreleased("down") 88 | lv1lua.key.down = 0 89 | elseif pad.left(0) == 0 and lv1lua.key.left == 1 then 90 | love.keyreleased("left") 91 | lv1lua.key.left = 0 92 | elseif pad.right(0) == 0 and lv1lua.key.right == 1 then 93 | love.keyreleased("right") 94 | lv1lua.key.right = 0 95 | elseif pad.select(0) == 0 and lv1lua.key.select == 1 then 96 | love.keyreleased("back") 97 | lv1lua.key.select = 0 98 | elseif pad.start(0) == 0 and lv1lua.key.start == 1 then 99 | love.keyreleased("start") 100 | lv1lua.key.start = 0 101 | end 102 | 103 | --force quit 104 | if pad.L3(0) > 0 and pad.R3(0) > 0 then 105 | love.event.quit() 106 | end 107 | end 108 | -------------------------------------------------------------------------------- /LOVE-WrapLua/Vera.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LukeZGD/LOVE-WrapLua/5ffbfd13c3319efaa1c476ffb5289fa7e954a9dd/LOVE-WrapLua/Vera.ttf -------------------------------------------------------------------------------- /LOVE-WrapLua/filesystem.lua: -------------------------------------------------------------------------------- 1 | if lv1lua.isPSP then 2 | lv1lua.saveloc = "ms0:/PSP/GAME/"..lv1lua.loveconf.identity.."/savedata/" 3 | elseif lv1lua.mode == "PS3" then 4 | lv1lua.saveloc = lv1lua.dataloc.."savedata/" 5 | else 6 | lv1lua.saveloc = "ux0:/data/"..lv1lua.loveconf.identity.."/savedata/" 7 | end 8 | 9 | if lv1lua.mode == "OneLua" then 10 | if not files.exists(lv1lua.saveloc) then 11 | files.mkdir(lv1lua.saveloc) 12 | end 13 | elseif lv1lua.mode == "lpp-vita" then 14 | if not System.doesDirExist(lv1lua.saveloc) then 15 | System.createDirectory("ux0:/data/"..lv1lua.loveconf.identity) 16 | System.createDirectory(lv1lua.saveloc) 17 | end 18 | end 19 | 20 | function love.filesystem.read(file) 21 | if lv1lua.exists(lv1lua.saveloc..file) then 22 | file = lv1lua.saveloc..file 23 | elseif lv1lua.exists(lv1lua.dataloc.."game/"..file) then 24 | file = lv1lua.dataloc.."game/"..file 25 | end 26 | 27 | local openfile = io.open(file, "r") 28 | local contents 29 | if openfile then 30 | contents = openfile:read() 31 | openfile:close() 32 | end 33 | return contents 34 | end 35 | 36 | function love.filesystem.write(file,datawrite) 37 | local writetype 38 | if lv1lua.mode == "PS3" then 39 | writetype = "w+" 40 | else 41 | writetype = "w" 42 | end 43 | local openfile = io.open(lv1lua.saveloc..file, writetype) 44 | local success = openfile:write(datawrite) 45 | openfile:close() 46 | return success 47 | end 48 | 49 | function love.filesystem.append(file,datawrite) 50 | local openfile = io.open(lv1lua.saveloc..file, "a") 51 | local success = openfile:write(datawrite.."\n") 52 | openfile:close() 53 | return success 54 | end 55 | 56 | function love.filesystem.isFile(file) 57 | if lv1lua.exists(lv1lua.saveloc..file) or lv1lua.exists(lv1lua.dataloc.."game/"..file) then 58 | return true 59 | end 60 | end 61 | 62 | function love.filesystem.getInfo(file) 63 | return love.filesystem.isFile(file) 64 | end 65 | 66 | function love.filesystem.load(file) 67 | return loadfile(lv1lua.saveloc..file) 68 | end 69 | 70 | function love.filesystem.remove(file) 71 | local success 72 | if lv1lua.mode == "OneLua" then 73 | success = files.delete(lv1lua.saveloc..file) 74 | elseif lv1lua.mode == "lpp-vita" then 75 | success = System.deleteFile(lv1lua.saveloc..file) 76 | end 77 | return success 78 | end 79 | 80 | function love.filesystem.getIdentity() 81 | return lv1lua.loveconf.identity 82 | end 83 | 84 | function love.filesystem.getUserDirectory() 85 | return "" 86 | end 87 | function love.filesystem.getSaveDirectory() 88 | return "" 89 | end 90 | -------------------------------------------------------------------------------- /LOVE-WrapLua/lpp-vita/audio.lua: -------------------------------------------------------------------------------- 1 | Sound.init() 2 | 3 | function love.audio.newSource(source,sourcetype) 4 | local table = { 5 | loadsound = Sound.open(lv1lua.dataloc.."game/"..source); 6 | type = sourcetype; 7 | play = function(self) 8 | if self.loadsound then love.audio.play(self) end; 9 | end; 10 | stop = function(self) 11 | if self.loadsound then love.audio.stop(self) end; 12 | end; 13 | getVolume = function(self) 14 | if self.loadsound then return (Sound.getVolume(self.loadsound))/32767 end; 15 | end; 16 | setVolume = function(self,vol) 17 | if self.loadsound then Sound.setVolume(self.loadsound,vol*32767) end; 18 | end; 19 | setLooping = function(self,setloop) 20 | self.loop = setloop 21 | end; 22 | isPlaying = function(self) 23 | if self.loadsound then return Sound.isPlaying(self.loadsound) end; 24 | end; 25 | isLooping = function(self) 26 | if self.loadsound then return self.loop end; 27 | end; 28 | } 29 | return table 30 | end 31 | 32 | function love.audio.play(source) 33 | if not source.loop then 34 | source.loop = false 35 | end 36 | Sound.play(source.loadsound,source.loop) 37 | end 38 | 39 | function love.audio.stop(source) 40 | Sound.pause(source.loadsound) 41 | Sound.close(source.loadsound) 42 | end 43 | -------------------------------------------------------------------------------- /LOVE-WrapLua/lpp-vita/event.lua: -------------------------------------------------------------------------------- 1 | function love.event.quit(re) 2 | if love.quit then 3 | love.quit() 4 | end 5 | 6 | if re == "restart" then 7 | System.launchEboot("app0:/eboot.bin") 8 | else 9 | lv1lua.running = false 10 | System.exit() 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /LOVE-WrapLua/lpp-vita/graphics.lua: -------------------------------------------------------------------------------- 1 | --default print font 2 | local defaultfont = Font.load(lv1lua.dataloc.."LOVE-WrapLua/Vera.ttf") 3 | Font.setPixelSizes(defaultfont,12) 4 | 5 | --set up stuff 6 | lv1lua.current = { 7 | font = defaultfont, 8 | color = Color.new(255,255,255,255), 9 | bgcolor=Color.new(0,0,0,255) 10 | } 11 | 12 | function love.graphics.newImage(filename) 13 | local img = Graphics.loadImage(lv1lua.dataloc.."game/"..filename) 14 | return img 15 | end 16 | 17 | function love.graphics.draw(drawable,x,y,r,sx,sy) 18 | if not x then x = 0 end 19 | if not y then y = 0 end 20 | if not r then r = 0 end 21 | if not sx then sx = 1 end 22 | if not sy then sy = 1 end 23 | if sx and not sy then sy = sx end 24 | 25 | --scale 1280x720 to 960x540(vita) 26 | if lv1luaconf.imgscale == true or lv1luaconf.resscale == true then 27 | x = x * 0.75; y = y * 0.75 28 | end 29 | 30 | if lv1luaconf.imgscale == true then 31 | sx = sx * 0.75 32 | sy = sy * 0.75 33 | end 34 | 35 | if drawable then 36 | Graphics.drawScaleImage(x,y,drawable,sx,sy,lv1lua.current.color) 37 | --[[ 38 | Graphics.drawImageExtended( 39 | x,y,drawable, --x,y,image 40 | x,y,Graphics.getImageWidth(drawable),Graphics.getImageHeight(drawable), --partial draw (not needed) 41 | r, --rotation 42 | sx,sy, --scale 43 | lv1lua.current.color 44 | ) 45 | ]] 46 | end 47 | end 48 | 49 | function love.graphics.newFont(setfont, setsize) 50 | if tonumber(setfont) then 51 | setsize = setfont 52 | elseif not setsize then 53 | setsize = 12 54 | end 55 | 56 | if tonumber(setfont) then 57 | setfont = defaultfont 58 | elseif setfont then 59 | setfont = Font.load(lv1lua.dataloc.."game/"..setfont) 60 | end 61 | 62 | --scale 1280x720 to 960x540 63 | if lv1luaconf.imgscale == true or lv1luaconf.resscale == true then 64 | setsize = setsize*0.825 65 | end 66 | Font.setPixelSizes(setfont,setsize) 67 | 68 | return setfont 69 | end 70 | 71 | function love.graphics.setFont(setfont,setsize) 72 | if setsize then 73 | Font.setPixelSizes(setfont,setsize) 74 | end 75 | lv1lua.current.font = setfont 76 | end 77 | 78 | function love.graphics.setNewFont(setfont,setsize) 79 | newfont = love.graphics.newFont(setfont, setsize) 80 | love.graphics.setFont(newfont, setsize) 81 | return newfont 82 | end 83 | 84 | function love.graphics.print(text,x,y) 85 | if not x then x = 0 end 86 | if not y then y = 0 end 87 | 88 | --scale 1280x720 to 960x540 89 | if lv1luaconf.imgscale == true or lv1luaconf.resscale == true then 90 | x = x * 0.75; y = y * 0.75 91 | end 92 | 93 | if text then 94 | Font.print(lv1lua.current.font,x,y,text,lv1lua.current.color) 95 | end 96 | end 97 | 98 | function love.graphics.setColor(r,g,b,a) 99 | if not a then a = 255 end 100 | lv1lua.current.color = Color.new(r,g,b,a) 101 | end 102 | 103 | function love.graphics.setBackgroundColor(r,g,b) 104 | lv1lua.current.bgcolor = Color.new(r,g,b,255) 105 | end 106 | 107 | function love.graphics.rectangle(mode, x, y, w, h) 108 | --scale 1280x720 to 960x540 109 | if lv1luaconf.imgscale == true or lv1luaconf.resscale == true then 110 | x = x * 0.75; y = y * 0.75; w = w * 0.75; h = h * 0.75 111 | end 112 | 113 | if mode == "fill" then 114 | Graphics.fillRect(x, x+w, y, y+h, lv1lua.current.color) 115 | elseif mode == "line" then 116 | Graphics.fillEmptyRect(x, x+w, y, y+h, lv1lua.current.color) 117 | end 118 | end 119 | 120 | function love.graphics.line(x1,y1,x2,y2) 121 | Graphics.drawLine(x1,y1,x2,y2,lv1lua.current.color) 122 | end 123 | 124 | function love.graphics.circle(x,y,radius) 125 | Graphics.fillCircle(x,y,radius,lv1lua.current.color) 126 | end 127 | -------------------------------------------------------------------------------- /LOVE-WrapLua/lpp-vita/keyboard.lua: -------------------------------------------------------------------------------- 1 | lv1lua.keyenum = {16,64,128,32,8,1,8192,16384,4096,32768,256,512} 2 | lv1lua.keyname = {"up","down","left","right","start","back"} 3 | lv1lua.keymask = {} 4 | 5 | for i = 1, #lv1lua.keyset do 6 | lv1lua.keyname[(#lv1lua.keyname)+1] = lv1lua.keyset[i] 7 | end 8 | 9 | function love.keyboard.isDown(key) 10 | for i = 1, #lv1lua.keyname do 11 | if key == lv1lua.keyname[i] then 12 | return lv1lua.keymask[i] 13 | end 14 | end 15 | end 16 | 17 | function love.keyboard.showTextInput(table) 18 | if table then 19 | local header = {"",""} 20 | if table["header"] then header[1] = table["header"] end 21 | if table["subheader"] then header[2] = table["subheader"] end 22 | Keyboard.start(header[1],header[2]) 23 | if Keyboard.getState() == FINISHED then 24 | local text = Keyboard.getInput() 25 | if text and text ~= "" then love.textinput(text) end 26 | end 27 | end 28 | end 29 | 30 | function love.keyboard.setTextInput(table) 31 | love.keyboard.showTextInput(table) 32 | end 33 | -------------------------------------------------------------------------------- /LOVE-WrapLua/lpp-vita/timer.lua: -------------------------------------------------------------------------------- 1 | --timer stuff for update dt 2 | lv1lua.timer = Timer.new() 3 | local gtimer = Timer.new() 4 | dt = 0 5 | 6 | function love.timer.getTime() 7 | return Timer.getTime(gtimer) / 1000 8 | end 9 | 10 | function love.timer.getDelta() 11 | return dt 12 | end 13 | -------------------------------------------------------------------------------- /LOVE-WrapLua/lpp-vita/whileloop.lua: -------------------------------------------------------------------------------- 1 | function lv1lua.draw() 2 | Graphics.initBlend() 3 | Screen.clear() 4 | Screen.waitVblankStart() 5 | Graphics.fillRect(0, 960, 0, 544, lv1lua.current.bgcolor) 6 | if love.draw then 7 | love.draw() 8 | end 9 | Graphics.fillRect(0, 960, 540, 544, Color.new(0,0,0,255)) 10 | Graphics.termBlend() 11 | Screen.flip() 12 | end 13 | 14 | function lv1lua.update() 15 | if Timer.getTime(lv1lua.timer) >= 16 then 16 | dt = Timer.getTime(lv1lua.timer) / 1000 17 | if love.update then 18 | love.update(dt) 19 | end 20 | Timer.reset(lv1lua.timer) 21 | end 22 | end 23 | 24 | function lv1lua.updatecontrols() 25 | lv1lua.pad = Controls.read() 26 | for i = 1, #lv1lua.keyenum do 27 | if Controls.check(lv1lua.pad, lv1lua.keyenum[i]) then 28 | if not lv1lua.keymask[i] then 29 | love.keypressed(lv1lua.keyname[i]) 30 | lv1lua.keymask[i] = true 31 | end 32 | else 33 | if lv1lua.keymask[i] then 34 | love.keyreleased(lv1lua.keyname[i]) 35 | lv1lua.keymask[i] = false 36 | end 37 | end 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /LOVE-WrapLua/math.lua: -------------------------------------------------------------------------------- 1 | function love.math.setRandomSeed(seed) 2 | return math.randomseed(seed) 3 | end 4 | 5 | function love.math.random(a,b) 6 | return math.random(a,b) 7 | end 8 | -------------------------------------------------------------------------------- /LOVE-WrapLua/system.lua: -------------------------------------------------------------------------------- 1 | if lv1lua.isPSP then 2 | love._console_name = "PSP" 3 | elseif lv1lua.mode == "PS3" then 4 | love._console_name = "PS3" 5 | else 6 | love._console_name = "Vita" 7 | end 8 | 9 | function love.system.getOS() 10 | return "LOVE-WrapLua" 11 | end 12 | 13 | function love.system.getLanguage() 14 | if lv1lua.mode == "lpp-vita" then 15 | return System.getLanguage() 16 | elseif lv1lua.mode == "OneLua" then 17 | return os.language() 18 | end 19 | end 20 | 21 | function love.system.getUsername() 22 | if lv1lua.mode == "lpp-vita" then 23 | return System.getUsername() 24 | elseif lv1lua.mode == "OneLua" then 25 | return os.nick() 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LOVE-WrapLua 2 | 3 | A small and simple LOVE2D wrapper for OneLua, lpp-vita, and Lua Player PS3 4 | 5 | You can use this to make LOVE2D stuff for a PSP, PS Vita, and/or PS3! As an example, this is used on [DDLC-LOVE](https://github.com/LukeZGD/DDLC-LOVE/) 6 | 7 | This is made just for fun and will only have the basic stuff. 8 | 9 | - See `Implemented.md` for the list of implemented stuff 10 | - `script.lua` is the main file for LOVE-WrapLua (required) 11 | - `index.lua` is for lpp-vita to run `script.lua` (required for lpp-vita only) 12 | - `app.lua` is for Lua Player PS3 to run `script.lua` (required for Lua Player PS3 only) 13 | - `lv1luaconf` in `conf.lua` is to set up some settings for key configuration `keyconf`, resolution scale `resscale`, and image scale `imgscale`. This is optional; See `script.lua` for the default values 14 | -------------------------------------------------------------------------------- /app.lua: -------------------------------------------------------------------------------- 1 | lv1lua = {} 2 | lv1lua.mode = "PS3" 3 | lv1lua.dataloc = "/dev_usb/DDLC-LOVE/" --replace DDLC-LOVE with other folder name 4 | dofile(lv1lua.dataloc.."script.lua") 5 | -------------------------------------------------------------------------------- /game/conf.lua: -------------------------------------------------------------------------------- 1 | function love.conf(t) 2 | t.window.width = 960 3 | t.window.height = 544 4 | end 5 | -------------------------------------------------------------------------------- /game/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LukeZGD/LOVE-WrapLua/5ffbfd13c3319efaa1c476ffb5289fa7e954a9dd/game/image.png -------------------------------------------------------------------------------- /game/main.lua: -------------------------------------------------------------------------------- 1 | local sectimer = 0 2 | local pos = 0 3 | local lg = love.graphics 4 | 5 | local lgsetColor = lg.setColor 6 | function lg.setColor(...) 7 | local args = {...} 8 | local ver = love.getVersion() 9 | if ver >= 11 then 10 | for i = 1, #args do 11 | if args[i] > 0 then 12 | args[i] = args[i] / 255 13 | end 14 | end 15 | end 16 | lgsetColor(args[1],args[2],args[3],args[4]) 17 | end 18 | 19 | function love.load() 20 | image = lg.newImage("image.png") 21 | local def = lg.setNewFont(24) 22 | end 23 | 24 | function love.draw() 25 | lg.draw(image, pos, pos) 26 | lg.setColor(128,128,128,128) 27 | lg.rectangle("fill",40,40,130,35) 28 | lg.setColor(255,255,255,255) 29 | if sectimer <= 1 then 30 | lg.print("No game!",44,42) 31 | end 32 | end 33 | 34 | function love.update(dt) 35 | sectimer = sectimer + dt 36 | if sectimer >= 2 then sectimer = 0 end 37 | 38 | pos = pos - 0.625 39 | if pos <= -200 then 40 | pos = -50 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /index.lua: -------------------------------------------------------------------------------- 1 | lv1lua = {} 2 | lv1lua.mode = "lpp-vita" 3 | lv1lua.dataloc = "app0:/" 4 | dofile(lv1lua.dataloc.."script.lua") 5 | -------------------------------------------------------------------------------- /script.lua: -------------------------------------------------------------------------------- 1 | --setup 2 | if not lv1lua then 3 | lv1lua = {} 4 | end 5 | lv1lua.isPSP = os.cfw 6 | lv1lua.running = true 7 | 8 | if not lv1lua.mode then 9 | lv1lua.dataloc = "" 10 | lv1lua.mode = "OneLua" 11 | end 12 | 13 | --set up love 14 | love = {} 15 | love.graphics = {} 16 | love.timer = {} 17 | love.audio = {} 18 | love.event = {} 19 | love.math = {} 20 | love.system = {} 21 | love.filesystem = {} 22 | love.keyboard = {} 23 | 24 | --for checking conf files 25 | function lv1lua.exists(file) 26 | if lv1lua.mode == "OneLua" then 27 | return files.exists(file) 28 | elseif lv1lua.mode == "lpp-vita" then 29 | return System.doesFileExist(file) or System.doesDirExist(file) 30 | else 31 | local openfile = io.open(file, "r") 32 | if openfile then 33 | openfile:close() 34 | return true 35 | end 36 | end 37 | end 38 | 39 | --love conf, custom configs go to game/conf.lua 40 | t = { 41 | window = {}, 42 | modules = {} 43 | } 44 | lv1lua.loveconf = t 45 | 46 | if lv1lua.exists(lv1lua.dataloc.."game/conf.lua") then 47 | dofile(lv1lua.dataloc.."game/conf.lua") 48 | love.conf(t) 49 | lv1lua.loveconf = t 50 | if not lv1lua.loveconf.identity then 51 | lv1lua.loveconf.identity = "LOVE-WrapLua" 52 | end 53 | end 54 | t = nil 55 | 56 | if not lv1luaconf then 57 | --lv1luaconf, custom configs should go to lv1lua.lua 58 | lv1luaconf = { 59 | keyconf = "XB", 60 | img_scale = false, 61 | res_scale = false 62 | } 63 | end 64 | 65 | --set key config 66 | if lv1luaconf.keyconf == "SE" then 67 | lv1lua.confirm = false 68 | 69 | if lv1lua.mode == "lpp-vita" then 70 | if Controls.getEnterButton() == SCE_CTRL_CIRCLE then lv1lua.confirm = true end 71 | elseif lv1lua.mode == "OneLua" then 72 | if buttons.assign() == 0 then lv1lua.confirm = true end 73 | if not lv1lua.isPSP then 74 | dofile(lv1lua.dataloc.."LOVE-WrapLua/"..lv1lua.mode.."/touch.lua") 75 | dofile(lv1lua.dataloc.."LOVE-WrapLua/"..lv1lua.mode.."/mouse.lua") 76 | end 77 | end 78 | if not lv1lua.confirm then 79 | lv1luaconf.keyconf = "XB" 80 | else 81 | lv1luaconf.keyconf = "XBA" 82 | end 83 | end 84 | 85 | if lv1luaconf.keyconf == "XB" then 86 | lv1lua.keyset = {"b","a","y","x","leftshoulder","rightshoulder"} 87 | elseif lv1luaconf.keyconf == "XBA" then 88 | lv1lua.keyset = {"a","b","x","y","leftshoulder","rightshoulder"} 89 | elseif lv1luaconf.keyconf == "PS" then 90 | lv1lua.keyset = {"circle","cross","triangle","square","l","r"} 91 | end 92 | 93 | --modules and stuff 94 | if lv1lua.isPSP then 95 | dofile(lv1lua.dataloc.."LOVE-WrapLua/OneLua/graphics_psp.lua") 96 | else 97 | dofile(lv1lua.dataloc.."LOVE-WrapLua/"..lv1lua.mode.."/graphics.lua") 98 | end 99 | dofile(lv1lua.dataloc.."LOVE-WrapLua/"..lv1lua.mode.."/whileloop.lua") 100 | dofile(lv1lua.dataloc.."LOVE-WrapLua/"..lv1lua.mode.."/timer.lua") 101 | dofile(lv1lua.dataloc.."LOVE-WrapLua/"..lv1lua.mode.."/audio.lua") 102 | dofile(lv1lua.dataloc.."LOVE-WrapLua/"..lv1lua.mode.."/event.lua") 103 | dofile(lv1lua.dataloc.."LOVE-WrapLua/"..lv1lua.mode.."/keyboard.lua") 104 | dofile(lv1lua.dataloc.."LOVE-WrapLua/filesystem.lua") 105 | dofile(lv1lua.dataloc.."LOVE-WrapLua/math.lua") 106 | dofile(lv1lua.dataloc.."LOVE-WrapLua/system.lua") 107 | 108 | --return LOVE 0.10.2 109 | function love.getVersion() 110 | return 0, 10, 2 111 | end 112 | 113 | if lv1lua.mode == "OneLua" then 114 | __oldRequire = require 115 | function require(param) 116 | return __oldRequire("game/"..param) 117 | end 118 | else 119 | function require(param) 120 | if string.sub(param, -4) == ".lua" then 121 | param = lv1lua.dataloc.."game/"..param 122 | else 123 | param = lv1lua.dataloc.."game/"..param..".lua" 124 | end 125 | return dofile(param) 126 | end 127 | end 128 | 129 | --START! 130 | love.math.setRandomSeed(os.time()) 131 | dofile(lv1lua.dataloc.."game/main.lua") 132 | if love.load then 133 | love.load() 134 | end 135 | 136 | --gamepadpressed or keypressed stuff 137 | if not love.keypressed and love.gamepadpressed then 138 | function love.keypressed(key) 139 | love.gamepadpressed(joy,button) 140 | end 141 | elseif not love.keypressed then 142 | love.keypressed = function() end 143 | end 144 | 145 | if not love.keyreleased and love.gamepadreleased then 146 | function love.keyreleased(key) 147 | love.gamepadreleased(joy,button) 148 | end 149 | elseif not love.keyreleased then 150 | love.keyreleased = function() end 151 | end 152 | 153 | --Main loop 154 | while lv1lua.running do 155 | --Draw 156 | lv1lua.draw() 157 | 158 | --Update 159 | lv1lua.update() 160 | 161 | --Controls 162 | lv1lua.updatecontrols() 163 | end 164 | -------------------------------------------------------------------------------- /tools/convertAudio.sh: -------------------------------------------------------------------------------- 1 | _rate="44100" 2 | _type=".ogg" 3 | _force=true 4 | _channels=1 5 | 6 | if [[ "$1" != "" ]]; then 7 | _type=".$1" 8 | fi 9 | 10 | _sox=$( command -v sox) 11 | if [[ "$_sox" == "" ]]; then 12 | currCommand=$( command -v zenity) 13 | if [[ "$currCommand" != "" ]]; then 14 | zenity --error --text="Please download SoX ( http://sox.sourceforge.net/ ) before using the convertAudio.sh" 15 | else 16 | currCommand=$( command -v notify-send) 17 | if [[ "$currCommand" != "" ]]; then 18 | notify-send -u critical "SoX Not Found" "Please download SoX ( http://sox.sourceforge.net/ ) before using the convertAudio.sh" 19 | else 20 | currCommand=$( command -v zenity) 21 | if [[ "$currCommand" != "" ]]; then 22 | kdialog --title "SoX Not Found " --passivepopup "Please download SoX ( http://sox.sourceforge.net/ ) before using the convertAudio.sh" 5 23 | fi 24 | fi 25 | fi 26 | echo "Please download SoX ( http://sox.sourceforge.net/ ) before using the convertAudio.sh" 27 | exit -1 28 | fi 29 | 30 | find ./homebrew/ -type f \( -iname \*.wav -o -iname \*.wma -o -iname \*.m4a -o -iname \*.3gp \) >> _audioToConvert.txt 31 | while read -r currAudio; do 32 | IFS="." 33 | read -ra SPLITTED <<< "$currAudio" 34 | FILE="." 35 | len="${#SPLITTED[@]}" 36 | for (( i = 0; i < $len - 1; i++ )); do 37 | FILE+="${SPLITTED[$i]}" 38 | done 39 | FILE+=$_type 40 | if [[ ! -f "$FILE" || "$_force" = true ]]; then 41 | sox "$currAudio" "$FILE" rate $_rate 42 | echo "Created $FILE" 43 | fi 44 | done < _audioToConvert.txt 45 | rm _audioToConvert.txt -------------------------------------------------------------------------------- /tools/convertSendAudio.sh: -------------------------------------------------------------------------------- 1 | _type="mp3" 2 | 3 | if [[ "$1" != "" ]]; then 4 | _type="$1" 5 | fi 6 | ./convertAudio.sh "$_type" 7 | ./fastCurl.sh "$_type" 8 | -------------------------------------------------------------------------------- /tools/deleteAudio.sh: -------------------------------------------------------------------------------- 1 | _type=".ogg" 2 | 3 | if [[ "$1" != "" ]]; then 4 | _type=".$1" 5 | fi 6 | 7 | find ./homebrew/ -type f \( -iname \*.wav -o -iname \*.wma -o -iname \*.m4a -o -iname \*.3gp \) >> _audioToConvert.txt 8 | while read -r currAudio; do 9 | IFS="." 10 | read -ra SPLITTED <<< "$currAudio" 11 | FILE="." 12 | len="${#SPLITTED[@]}" 13 | for (( i = 0; i < $len - 1; i++ )); do 14 | FILE+="${SPLITTED[$i]}" 15 | done 16 | FILE+=$_type 17 | rm "$FILE" 18 | done < _audioToConvert.txt 19 | rm _audioToConvert.txt -------------------------------------------------------------------------------- /tools/fastCurl.sh: -------------------------------------------------------------------------------- 1 | #Cache requests 2 | 3 | filetype="lua" 4 | if [[ "$1" != "" ]]; then 5 | filetype="$1" 6 | echo "Send .$1 files" 7 | fi 8 | 9 | find ./homebrew/ -name "*.$filetype" >> _tempFileRequests.txt 10 | _files="" 11 | _fileArr=() 12 | while read -r _cache; 13 | do _files+=${_cache}","; 14 | _fileArr+=( $_cache ) 15 | done < _tempFileRequests.txt 16 | _files=${_files%,} 17 | 18 | find ./homebrew/ -type d >> _tempDirRequests.txt 19 | _dirs=() 20 | 21 | while read -r _cache; 22 | do _dirs+=( ${_cache#./homebrew} ); 23 | done < _tempDirRequests.txt 24 | 25 | for dir in ${_dirs[@]}; do 26 | # echo $dir 27 | _buf="" 28 | #Populate _buf with useful filees 29 | for _file in ${_fileArr[@]}; do 30 | if [[ $_file =~ "$dir" ]]; then 31 | if [[ $dir == "/" ]]; then 32 | if [[ `grep -o '/' <<< $_file | wc -l` == $(( `grep -o '/' <<< $dir | wc -l` + 1 )) ]]; then #Must be 2, because it already has /homebrew/ 33 | _buf+=${_file}"," 34 | fi 35 | else 36 | if [[ `grep -o '/' <<< $_file | wc -l` == $(( `grep -o '/' <<< $dir | wc -l` + 2 )) ]]; then 37 | _buf+=${_file}"," 38 | fi 39 | fi 40 | fi 41 | done 42 | #Clean for curl 43 | _buf=${_buf%,} 44 | 45 | if [[ $_buf != "" ]]; then 46 | if [[ $dir != "/" ]]; then 47 | dir+="/" 48 | fi 49 | echo $dir 50 | curl --ftp-create-dirs -T "{$_buf}" ftp://192.168.15.19:1337/ux0:app/ONELUAHP0$dir 51 | fi 52 | done 53 | 54 | rm _tempFileRequests.txt 55 | rm _tempDirRequests.txt 56 | 57 | # echo $_files 58 | 59 | #_dirsList="" 60 | 61 | #To create multiple files request, they must be embraced with {}, have a ',' between each file 62 | #and don't have any space between them 63 | 64 | # curl --ftp-create-dirs -T "{$_files}" -X MKCOL ftp://192.168.15.19:1337/ux0:app/ONELUAHP0/ 65 | --------------------------------------------------------------------------------