Page 1 of 4

[WIP+RELEASE] lpp.prx - Create PSP/PSVITA plugins in LUA

Posted: Fri May 23, 2014 8:44 pm
by Rinnegatamante
lpp.prx is the first LUA interpreter in order to create PSP/PSVITA plugins in LUA!
Current public release: R204 BETA

Video
Sourcecode:
https://code.google.com/p/lua-player-plus/

Download:
http://rinnegatamante.netsons.org/lpp_204.rar

This is the list of current functions implemented:
[spoiler]----------------
Kernel Class
----------------
Kernel.memcpy(u32 addr,u32 source,int size) - Copy block of memory
Kernel.memset(u32 addr,int value,int size) - Fill block of memory
Kernel.memcmp(u32 addr,u32 addr2,int size) - Compare block of memory
Kernel.storeWord(u32 addr,u32 val) - Store Word (Equivalent of _sw C function)
Kernel.loadWord(u32 addr) - Load Word (Equivalent of _lw C function)
----------------
Screen Class
----------------
Screen.debugPrint(int x,int y,string text,u32 color) - Write a text with Debug font
Screen.debugPrintGradient(int x,int y,string text,u32 color1, u32 color2) - Write a gradient text with Debug font
Screen.waitVblankStart(int millisecond) - Wait Display Screen
Screen.clear() - Clear Debug Screen
----------------
Color Class
----------------
Color.new(int R,int G,int B) - Create a new BGR color
Color.getR(int color) - Get R value of a color
Color.getG(int color) - Get G value of a color
Color.getB(int color) - Get B value of a color
----------------
System Class
----------------
System.restart() - Restart interpreter
System.getFileSize(string filename) - Get size in bytes of a file
System.closeFile(int id) - Close a file
System.writeFile(int id, string string,int size) - Write a text in a file
System.readFile(int id,int size) - Read a text from file
System.seekFile(int id,int offset,int position) - Change pointer position in a file (position must be INIT_FILE, END_FILE, CUR_FILE)
System.openFile(string filename,int mode) - Open a file (mode must be PSP_READ, PSP_WRITE, PSP_APPEND, PSP_CREATE)
System.protodofile(string filename) - Temporary dofile/loadmodule replacing - Load a new LUA script restarting interpreter
System.loadModule(string file) - Load and start a PRX module
System.assign(string dev1,string dev2,string dev3) - Assign Device
System.unassign(string dev) - Unassign Device
System.md5sum(string string) - Get crypted MD5 string
System.sha1sum(string string) - Get crypted SHA1 string
System.isPSP() - Check if user is on PSP (1 = PSP, 0 = PSVITA)
System.getModel() - Get PSP Model
System.getTime(int mode) - Get time (mode: 1= hours,2= minutes,3= seconds)
System.getDate(int mode) - Get date (mode: 1= days,2= months,3= years)
System.getFreeSize(string device) - Get free size of selected device
System.getTotalSize(string device) - Get total size of selected device
System.startPBP(string filename) - Start a PBP
System.startPSX(string filename) - Start a PBP with POPS
System.getVersion() - Get firmware version
System.listDirectory() - List a Directory
System.doesFileExist(string file) - Check if file exist
System.renameFile(string file1,string file2) - Rename a File
System.renameDir(string file1,string file2) - Rename a Directory
System.removeFile(string file1,string file2) - Remove a File
System.removeDir(string file1,string file2) - Remove a Directory
System.copyFile(string file1,string file2) - Copy a File
System.copyDir(string file1,string file2) - Copy a Directory
System.createDirectory(string path) - Create a Directory
System.resumeThread() - Resume paused main thread
System.powerIsPowerOnline() - Get Battery status
System.powerIsBatteryExist() - Check if battery exist
System.powerIsBatteryCharging() - Check if battery is in charging
System.powerGetBatteryChargingStatus() - Get charging status
System.powerIsLowBattery() - Check if battery charging status is low
System.powerGetBatteryLifePercent() - Get battery life percent
System.powerGetBatteryLifeTime() - Get battery life time
System.powerGetBatteryTemp() - Get battery temperature
System.powerGetBatteryVolt() - Get battery voltage
----------------
Controls Class
----------------
Controls.read() - Read Controls Buffer
Controls.readPeek() - Peek Controls Buffer
----------------
Controls Methods - Interfacing with PSP buttons
----------------
controls:select
controls:start
controls:up
controls:right
controls:down
controls:left
controls:l
controls:r
controls:triangle
controls:circle
controls:square
controls:home
controls:hold
controls:note
controls:analogX
controls:analogY
controls:buttons[/spoiler]

Any bug report, critic or advise is welcome and sorry for my really bad english :roll:

Re: [WIP] lpp.prx - Create PSP/PSVITA plugins in LUA

Posted: Sat May 24, 2014 8:07 am
by Applelo
Good Job :D It's a great idea for create new plugin :D
GO FOR MORE FUNCTION :D

(my english is very bad, sorry :cry: )

Re: [WIP] lpp.prx - Create PSP/PSVITA plugins in LUA

Posted: Sat May 24, 2014 8:26 am
by qwikrazor87
Wow, great job, Rinnegatamante. :)

Re: [WIP] lpp.prx - Create PSP/PSVITA plugins in LUA

Posted: Sat May 24, 2014 10:17 am
by toBsucht
Wow.. waiting for some new apps & games for xmb.
your video:

Re: [WIP] lpp.prx - Create PSP/PSVITA plugins in LUA

Posted: Sat May 24, 2014 12:23 pm
by Rinnegatamante
Thanks for the support, guys ;)

Today i added a lot of new functions to the interpreter (Battery functions, System.startPBP, Screen.clear and other System functions).

Newest sourcecodes are available on the repository.

The new list of functions is this:
[spoiler]----------------
Screen Class
----------------
Screen.debugPrint(int x,int y,string text,u32 color) - Write a text with Debug font
Screen.waitVblankStart(int millisecond) - Wait Display Screen
Screen.clear() - Clear Debug Screen
----------------
System Class
----------------
System.getTime(int mode) - Get time (mode: 1= hours,2= minutes,3= seconds)
System.getDate(int mode) - Get date (mode: 1= days,2= months,3= years)
System.getFreeSize(string device) - Get free size of selected device
System.getTotalSize(string device) - Get total size of selected device
System.startPBP(string filename) - Start a PBP
System.getVersion() - Get firmware version
System.renameFile(string file1,string file2) - Rename a File
System.renameDir(string file1,string file2) - Rename a Directory
System.removeFile(string file1,string file2) - Remove a File
System.removeDir(string file1,string file2) - Remove a Directory
System.copyFile(string file1,string file2) - Copy a File
System.copyDir(string file1,string file2) - Copy a Directory
System.createDirectory(string path) - Create a Directory
System.resumeThread() - Resume paused main thread
System.powerIsPowerOnline() - Get Battery status
System.powerIsBatteryCharging() - Check if battery is in charging
System.powerGetBatteryChargingStatus() - Get charging status
System.powerIsLowBattery() - Check if battery charging status is low
System.powerGetBatteryLifePercent() - Get battery life percent
System.powerGetBatteryLifeTime() - Get battery life time
System.powerGetBatteryTemp() - Get battery temperature
System.powerGetBatteryVolt() - Get battery voltage
----------------
Controls Class
----------------
Controls.read() - Read Controls Buffer
Controls.readPeek() - Peek Controls Buffer
----------------
Controls Methods - Interfacing with PSP buttons
----------------
controls:select
controls:start
controls:up
controls:right
controls:down
controls:left
controls:l
controls:r
controls:triangle
controls:circle
controls:square
controls:home
controls:hold
controls:note
controls:analogX
controls:analogY
controls:buttons[/spoiler]

Re: [WIP] lpp.prx - Create PSP/PSVITA plugins in LUA

Posted: Sat May 24, 2014 1:47 pm
by Joel16
Hey, this is a pretty cool project :) you should also add USB functions.

Re: [WIP] lpp.prx - Create PSP/PSVITA plugins in LUA

Posted: Sat May 24, 2014 3:42 pm
by Omega2058
This is a pretty interesting project. Keep it up mate :)

Re: [WIP] lpp.prx - Create PSP/PSVITA plugins in LUA

Posted: Wed May 28, 2014 6:28 pm
by Rinnegatamante
We made quite progress:

dofile/loadfile functions are buggy (on PSVITA, i've not a PSP to test) so i'm working to build a prototype of a new function (System.protodofile) which works like loadbuffer/loadstring which are fully working (The difference between them and System.protodofile is only that my function will accept filename of LUA script).
Actually System.protodofile is instable (few times it crash PSPemu) and it has a limitation: every time it's called, LUA interpreter is restarted (so actually, it's impossible to load module with this function).

Added few functions in order to manage memory of PSP/PSVITA (Kernel.memcmp, Kernel.memset, Kernel.memcpy, Kernel.storeWord) and also new functions on System class (System.doesFileExist, System.isPSP, System.loadModule, System.unassign, System.assign, System.getModel, System.md5sum, System.sha1sum).

New functions list:
[spoiler]----------------
Kernel Class
----------------
Kernel.memcpy(u32 addr,u32 source,int size) - Copy block of memory
Kernel.memset(u32 addr,int value,int size) - Fill block of memory
Kernel.memcmp(u32 addr,u32 addr2,int size) - Compare block of memory
Kernel.storeWord(u32 addr,u32 val) - Store Word (Equivalent of _sw C function)
----------------
Screen Class
----------------
Screen.debugPrint(int x,int y,string text,u32 color) - Write a text with Debug font
Screen.waitVblankStart(int millisecond) - Wait Display Screen
Screen.clear() - Clear Debug Screen
----------------
System Class
----------------
System.protodofile(string filename) - Temporary dofile/loadmodule replacing - Load a new LUA script restarting interpreter
System.loadModule(string file) - Load and start a PRX module
System.assign(string dev1,string dev2,string dev3) - Assign Device
System.unassign(string dev) - Unassign Device
System.md5sum(string string) - Get crypted MD5 string
System.sha1sum(string string) - Get crypted SHA1 string
System.isPSP() - Check if user is on PSP (1 = PSP, 0 = PSVITA)
System.getModel() - Get PSP Model
System.getTime(int mode) - Get time (mode: 1= hours,2= minutes,3= seconds)
System.getDate(int mode) - Get date (mode: 1= days,2= months,3= years)
System.getFreeSize(string device) - Get free size of selected device
System.getTotalSize(string device) - Get total size of selected device
System.startPBP(string filename) - Start a PBP
System.getVersion() - Get firmware version
System.doesFileExist(string file) - Check if file exist
System.renameFile(string file1,string file2) - Rename a File
System.renameDir(string file1,string file2) - Rename a Directory
System.removeFile(string file1,string file2) - Remove a File
System.removeDir(string file1,string file2) - Remove a Directory
System.copyFile(string file1,string file2) - Copy a File
System.copyDir(string file1,string file2) - Copy a Directory
System.createDirectory(string path) - Create a Directory
System.resumeThread() - Resume paused main thread
System.powerIsPowerOnline() - Get Battery status
System.powerIsBatteryExist() - Check if battery exist
System.powerIsBatteryCharging() - Check if battery is in charging
System.powerGetBatteryChargingStatus() - Get charging status
System.powerIsLowBattery() - Check if battery charging status is low
System.powerGetBatteryLifePercent() - Get battery life percent
System.powerGetBatteryLifeTime() - Get battery life time
System.powerGetBatteryTemp() - Get battery temperature
System.powerGetBatteryVolt() - Get battery voltage
----------------
Controls Class
----------------
Controls.read() - Read Controls Buffer
Controls.readPeek() - Peek Controls Buffer
----------------
Controls Methods - Interfacing with PSP buttons
----------------
controls:select
controls:start
controls:up
controls:right
controls:down
controls:left
controls:l
controls:r
controls:triangle
controls:circle
controls:square
controls:home
controls:hold
controls:note
controls:analogX
controls:analogY
controls:buttons[/spoiler]

Also, i added a check on number of scripts in lpp.prx folder. In order to improve compatibility between future plugins, if there are more then one script on lpp.prx folder, lpp.prx wil load a simple menu where user can select which one to load.

I planned to release a first official alpha when System.protodofile will be fully working.

Re: [WIP+RELEASE] lpp.prx - Create PSP/PSVITA plugins in LUA

Posted: Fri May 30, 2014 6:45 pm
by Rinnegatamante
Finally, i fixxed System.protodofile which now works very good!

I also added Color class in order to simplify print functions (Color.new, Color.getR, Color.getB, Color.getG) and i added System.debugPrintGradient.

As i promised, i release the first public beta of the project (R196 Beta).
Download: http://rinnegatamante.netsons.org/lpp.rar

New video:

Re: [WIP+RELEASE] lpp.prx - Create PSP/PSVITA plugins in LUA

Posted: Fri May 30, 2014 11:09 pm
by Joel16
Hey Rinnegatamante, when I press R to launch the plugin, it gives me an error.

Code: Select all

Error: [string "?"]:3: bad argument number #1 to 'getn' (table expected, got nil)
I'm using a PSP Go, so I load the plugins from the internal storage. (ef0) Also I'm on fw 6.20, don't know if that'll make a difference.

Anyways I had a look, at your sample scripts. I improved your 'pspident' sample, with a few extra functions and making the code more user friendly(That is adding indentation and such). If you wanna use it, I uploaded it on here: https://www.mediafire.com/?qua6b2xk60bagir

Thanks for your work ;)