Lua Player for PSP
Moderators: Shine, Insert_witty_name
Lua Player for PSP
Lua Player, for 1.0 and 1.5 compiled. Copy the EBOOT.PBP on your PSP and edit the script.lua for your own great programs and games. The script will be compiled on-the-fly on the PSP, without any compiler on your PC, you just need a text editor! A PNG loader is integrated, so you can write your own games with it, by changing the script.lua and copying all your PNGs to the game directory. And important for newbies (and sometimes for me) : It doesn't crash (or at least it should not), but if you pass a null-pointer to a function, you'll get a nice error message, with the line in the script, which caused the error.
Last edited by Shine on Mon Dec 05, 2005 3:15 am, edited 7 times in total.
Hehe, I had the same idea, though I ported LuaPlus, which has incredibly sweet integration with C++. You can do this:
and then lua code can just call it:
The opposite (calling Lua from C++) looks like this:
I haven't actually written enough interfaces for it to be usable yet though.
Just making a little plug for LuaPlus here because few people seem to know about it, and it rocks ;)
Code: Select all
//C++:
int hello(float a, const char *instr)
{
//do whatever
}
lua->RegisterDirect("hello", hello);
Code: Select all
if hello(3.0,"yo") > 2 then
-- do some lua
end
Code: Select all
LuaFunction<int> myluafunc(lua, "myluafunc");
myluafunc(param1,param2);
Just making a little plug for LuaPlus here because few people seem to know about it, and it rocks ;)
This is a first beta version, but it is already useable and it is possible to write other games with it by just changing the Lua script, like Tetris, Pong, PacMan etc. (should take only a few hours for each game for an average programmer), so you can post the news, but perhaps the interface will change a bit, e.g. I think it is better to make the background image optional (now it is required) and I'll enhance the implementation, for example using the Gu-library for faster bit blitting. I'll release the final version next weekend, when some more feedback from users are available to improve and bugfix the current version (I don't know of any bugs in it, but I'm sure it is not bugfree).emumaniac wrote:Is this a proper release now or would you rather sites wait before posting the news :) ?
In the final version perhaps there will be a Java implementation to run your scripts without changes on Windows, Mac and Linux.
Have you considered something like LuaSDL?
http://sourceforge.net/projects/luasdl/
Built with tolua, which isn't so bad.
http://sourceforge.net/projects/luasdl/
Built with tolua, which isn't so bad.
-
- Posts: 64
- Joined: Fri Jul 15, 2005 11:44 pm
Re: Lua for PSP, or: writing games the easy way without comp
Very cool. I was thinking about porting Javascript to the PSP myself, but this is just as good. :)
You probably have a lot of ideas about what you want to put in your library (sound, graphics, etc.), so I'll just suggest some less obvious things..
* Analog stick reading. I've seen some code in the forums or elsewhere that manages this..
* You should have a 'freeImage' command. (As well as a 'free' command for whatever else you want to load.)
* A timer that handles milliseconds. I checked the OS library for Lua, and it looks like the smallest time it can handle is seconds.
And also, when you release the final version, make sure you give it a general name like 'LUA Player' so we don't have a bunch of homebrew games all named 'Snake' :)
EDIT: If you check Section 3.8 of the "LUA 5.0 reference manual", you should find a section on 'userdata' objects. I think you can use them to avoid having to keep track of image handles - and, LUA will garbage collect image data for you.
You probably have a lot of ideas about what you want to put in your library (sound, graphics, etc.), so I'll just suggest some less obvious things..
* Analog stick reading. I've seen some code in the forums or elsewhere that manages this..
* You should have a 'freeImage' command. (As well as a 'free' command for whatever else you want to load.)
* A timer that handles milliseconds. I checked the OS library for Lua, and it looks like the smallest time it can handle is seconds.
And also, when you release the final version, make sure you give it a general name like 'LUA Player' so we don't have a bunch of homebrew games all named 'Snake' :)
EDIT: If you check Section 3.8 of the "LUA 5.0 reference manual", you should find a section on 'userdata' objects. I think you can use them to avoid having to keep track of image handles - and, LUA will garbage collect image data for you.
Re: Lua for PSP, or: writing games the easy way without comp
Thanks, I'll add this and I'll change the image handling, if Lua helps with GC.Kinsman wrote:* Analog stick reading. I've seen some code in the forums or elsewhere that manages this..
* A timer that handles milliseconds. I checked the OS library for Lua, and it looks like the smallest time it can handle is seconds.
And also, when you release the final version, make sure you give it a general name like 'LUA Player' so we don't have a bunch of homebrew games all named 'Snake' :)
EDIT: If you check Section 3.8 of the "LUA 5.0 reference manual", you should find a section on 'userdata' objects. I think you can use them to avoid having to keep track of image handles - and, LUA will garbage collect image data for you.
The integration of functions looks nice, I assume this is some template metaprogramming magic. Perhaps I'll use it, if I want to use C++ for PSP.ector wrote:I had the same idea, though I ported LuaPlus, which has incredibly sweet integration with C++
Doesn't look like a production quality product. I've found another one: http://lua-users.org/wiki/LuaModuleLuaSdl, should be easy to use it.rinco wrote: Have you considered something like LuaSDL?
I've seperated the project for Lua now, see this topic, so it can be used independently from my Snake game or a Lua player.
Thanks for this, its great!
I've started with a tile engine:
http://www.flash-git.net/pspProg1.jpg
http://www.flash-git.net/pspProg2.jpg
I'll be stripping out the mario gfx and using my own eventually.
When I draw my character over the tiles it removes the tiles, is there a way round this? I've not done this before so please excuse my ignorance.
G
I've started with a tile engine:
http://www.flash-git.net/pspProg1.jpg
http://www.flash-git.net/pspProg2.jpg
I'll be stripping out the mario gfx and using my own eventually.
When I draw my character over the tiles it removes the tiles, is there a way round this? I've not done this before so please excuse my ignorance.
G
Yes, use images with alpha channel and when moving, call fillBackground, with the position and size of your character and then again draw your character at the next position.VgSlag wrote:When I draw my character over the tiles it removes the tiles, is there a way round this? I've not done this before so please excuse my ignorance.
It's a bit a hack, the next version will provide an interface for multiple offscreen images and will be faster, so it should be possible to blit all images in every VSync, including the whole background.
Cheers, thats fixed the BG looking messy when I move my character. I'm blitting my tiles to the"foreground" so redrawing the background isn't helping with my character making those dissapear.
Is there a better way of my doing that? Please excuse if my vernacular is all wrong and thanks for any help you can give.
Is there a better way of my doing that? Please excuse if my vernacular is all wrong and thanks for any help you can give.
So you have to blit anything from bottom to top: background (with fillBackground), tiles and the character.VgSlag wrote:Cheers, thats fixed the BG looking messy when I move my character. I'm blitting my tiles to the"foreground" so redrawing the background isn't helping with my character making those dissapear.
If there are many tiles, this can be slow, this is the reason why I plan to add multiple offscreen support: You have one offscreen image, in which you can blit the background and all tiles. This offscreen image is blitted to the display and the the character will be blitted on it. Or you can use multiple offscreens for parallax scrolling, like in good old jump-and-run games. I'll provide some samples with the new player, but I'll have more time at weekend to implement it.
I love it!
Hey shine, great work on this.
To the person about the icon always being snake, just use PBP Unpacker and repack it with a new .SFO and new ICON0. Please keep this project going. It is a lot of fun.
here is my first psp lua demo:
- PSP 1.0 ( tested )
http://www.geocities.com/huntingdanimal ... psp1.0.zip
- PSP 1.5 ( untested )
http://www.geocities.com/huntingdanimal ... psp1.5.zip
let me know what you think.
To the person about the icon always being snake, just use PBP Unpacker and repack it with a new .SFO and new ICON0. Please keep this project going. It is a lot of fun.
here is my first psp lua demo:
- PSP 1.0 ( tested )
http://www.geocities.com/huntingdanimal ... psp1.0.zip
- PSP 1.5 ( untested )
http://www.geocities.com/huntingdanimal ... psp1.5.zip
let me know what you think.
so do i just unpack the zip file and put in my PSP/GAME directory?tank wrote: here is my first psp lua demo:
- PSP 1.0 ( tested )
http://www.geocities.com/huntingdanimal ... psp1.0.zip
- PSP 1.5 ( untested )
http://www.geocities.com/huntingdanimal ... psp1.5.zip
let me know what you think.
edit:tried that... error 80020001 the game could not be started...so i guess thats now how its done, on version 1.5
-
- Posts: 17
- Joined: Thu Jul 21, 2005 4:42 am
I'm trying to run Snake and Steel Demo on Windows XP using PSPe09b.
Neither games will load, giving me an error like this:
Neither games will load, giving me an error like this:
Am I doing something wrong or is Lua player not supported by PSPe?load C:\Documents and Settings\Administrator\Desktop\PSPfiles\PSPEmulator\pspe09b\pspe\ms0\PSP\GAME\SOFT2\EBOOT.PBP
PBP format
illegal address
PC = 00000000
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000
Fatal signal: Segmentation Fault (SDL Parachute Deployed)
Just to let you know I'm still working on this project: Preview of the PC Lua Player. The Snake game script works, but only image loading and blitting is implemented so far, I'll do the rest the next days, like joystick implementation with cursor keys, sound etc.
-
- Posts: 17
- Joined: Thu Jul 21, 2005 4:42 am
-
- Posts: 64
- Joined: Fri Jul 15, 2005 11:44 pm
Please excuse me for speaking for Shine but I've already asked this and he replied:
This will be solved with the new GU lib support, again this weekend. Now I'm blitting the images by software, which is really slow. Using the GU lib fom PSPSDK is as fast as 33 million polygons per second, so I think some million full-screen blits per second are possible.
Hi Shine. I just wanted to post and say think you for providing this execelent development tool. It is going to be a lot easier for people to make quick games without having to know anything about compiling the toolchain.
It's something like this that sony should pick up sign with their key and put on a UMD with a nice graphics library. Then they give the ability to allow people to create their own games allowing homebrew to thrive without feeding into the piracy of their commercial games.
I'm looking forward to the PC player and the next release of Lua with GU lib. I have not ran into any major bugs, but it was difficult to understand some of the syntax. It helps to learn by example, and so far there are only 2 games out for this. I will be releasing the source code for my game when it's ready.
One thing that would speed up the development process is the ability for Lua to activate the USB on the PSP so you can modify the script while still in the game, then just hook the start button to restart the script when it's finished loading.
Thanks again!
Update: the SVN has a lua/doc directory with some good docs and examples. I also went to the bookstore and read a chapter in a book called "Programming Game AI by Example" by Mat Buckland. It was very helpful in understanding the way Lua works.
Armed with new knowledge, I still have questions.. is there any kind of hitTest in Lua? I want to do a hit test to see if one image intersects with another image on screen. In flash this is as simple as:
_root["bounce" + i].hitTest(_root.instanceName) //Checks to see if the bounce instance intersects the instanceName instance.
It's something like this that sony should pick up sign with their key and put on a UMD with a nice graphics library. Then they give the ability to allow people to create their own games allowing homebrew to thrive without feeding into the piracy of their commercial games.
I'm looking forward to the PC player and the next release of Lua with GU lib. I have not ran into any major bugs, but it was difficult to understand some of the syntax. It helps to learn by example, and so far there are only 2 games out for this. I will be releasing the source code for my game when it's ready.
One thing that would speed up the development process is the ability for Lua to activate the USB on the PSP so you can modify the script while still in the game, then just hook the start button to restart the script when it's finished loading.
Thanks again!
Update: the SVN has a lua/doc directory with some good docs and examples. I also went to the bookstore and read a chapter in a book called "Programming Game AI by Example" by Mat Buckland. It was very helpful in understanding the way Lua works.
Armed with new knowledge, I still have questions.. is there any kind of hitTest in Lua? I want to do a hit test to see if one image intersects with another image on screen. In flash this is as simple as:
_root["bounce" + i].hitTest(_root.instanceName) //Checks to see if the bounce instance intersects the instanceName instance.
-
- Posts: 64
- Joined: Fri Jul 15, 2005 11:44 pm
I tried putting nothing to the screen as of right now and it still slows down according to my score(it is an active counter, like when you get 300 points it raises your score 100 points every second for three seconds), it slows down when killin lots of enemies at once with special weapons and such.VgSlag wrote:Please excuse me for speaking for Shine but I've already asked this and he replied:
This will be solved with the new GU lib support, again this weekend. Now I'm blitting the images by software, which is really slow. Using the GU lib fom PSPSDK is as fast as 33 million polygons per second, so I think some million full-screen blits per second are possible.
And this is more like a Ikuruga or 1942 type clone... now...
-
- Posts: 5
- Joined: Fri Jul 22, 2005 11:40 am
Install problem
hi guys,
I already installed PSPToolchain20050713 successfully. Now I'm installing the Lua by running "make" and get this error:
This might be a dump question cuz I'm new to Unix-based programming. Anyway, thanks for your help!
I already installed PSPToolchain20050713 successfully. Now I'm installing the Lua by running "make" and get this error:
Code: Select all
make: psp-config: command not found
Makefile:18: /lib/build.mak: No such file or directory
make: *** No rule to make target '/lib/build.mak'. Stop.
You will need to install both the toolchain and the pspsdk to compile this app. There are several threads in the PSPSDK forum which describe this process in great detail. Good Luck!
BTW, if all you want to do is make a Lua game, all you need to do is edit the script.lua file included in Shine's distribution. You do not need to compile anything to do this.
I'm waiting for Shine to release the next version of the player so I can finish my game. The way it runs right now is unplayable due to the speed of blitting multiple graphics at once, and the alpha issues i'm having for not filling the background correctly. Once I finish my game, I may attempt to add some quick networking code which will save and load high scores from a server.
BTW, if all you want to do is make a Lua game, all you need to do is edit the script.lua file included in Shine's distribution. You do not need to compile anything to do this.
I'm waiting for Shine to release the next version of the player so I can finish my game. The way it runs right now is unplayable due to the speed of blitting multiple graphics at once, and the alpha issues i'm having for not filling the background correctly. Once I finish my game, I may attempt to add some quick networking code which will save and load high scores from a server.
Re: Install problem
you need to make sure you put the correct path settings and environment variables. What environment are you using? Unix? Dos? Cygwin?bugkiller78 wrote:hi guys,
I already installed PSPToolchain20050713 successfully. Now I'm installing the Lua by running "make" and get this error:
This might be a dump question cuz I'm new to Unix-based programming. Anyway, thanks for your help!Code: Select all
make: psp-config: command not found Makefile:18: /lib/build.mak: No such file or directory make: *** No rule to make target '/lib/build.mak'. Stop.
I put the following lines in my bashrc (cygwin), taken from some instructions in the ps2dev forums and just replacing all the ps2s with psps:
export PSPDEV=/user/local/pspdev
export PSPSDK=$PSPDEV/pspsdk
export PATH=$PATH:$PSPDEV/bin:$PSPDEV/ee/bin:$PSPDEV/iop/bin:$PSPDEV/dvp/bin:$PSPSDK/bin
-
- Posts: 5
- Joined: Fri Jul 22, 2005 11:40 am
hi Arwin,
Yes, it was all about the PATH. I added C:\cygwin\usr\local\pspdev\bin\ to my path and the installation worked. However, when I "make" the ./lua/sample/ I got some errors:
I'm using cygwin on WinXP. Any clue?
Thanks[/code]
Yes, it was all about the PATH. I added C:\cygwin\usr\local\pspdev\bin\ to my path and the installation worked. However, when I "make" the ./lua/sample/ I got some errors:
Code: Select all
$ make
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -L. -L/usr/local/pspdev/psp/sdk/lib main.o -llua -lm -lpspdebug -lpsplibc -lpspkernel
-o luatest.elf
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/liblua.a(lobject.o): In function `luaO_str2d':
lobject.c:(.text+0x1bc): undefined reference to `_ctype_'
lobject.c:(.text+0x1c8): undefined reference to `_ctype_'
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/liblua.a(lvm.o): In function `luaV_strcmp':
lvm.c:(.text+0xa08): undefined reference to `strcoll'
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/liblua.a(lauxlib.o): In function `errfile':
lauxlib.c:(.text+0x1500): undefined reference to `__errno'
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/liblua.a(lauxlib.o): In function `luaL_loadfile':
lauxlib.c:(.text+0x15dc): undefined reference to `_ctype_'
lauxlib.c:(.text+0x15e0): undefined reference to `_ctype_'
lauxlib.c:(.text+0x15fc): undefined reference to `_impure_ptr'
lauxlib.c:(.text+0x162c): undefined reference to `_impure_ptr'
lauxlib.c:(.text+0x1600): undefined reference to `_impure_ptr'
lauxlib.c:(.text+0x16c0): undefined reference to `_impure_ptr'
lauxlib.c:(.text+0x1710): undefined reference to `_impure_ptr'
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/liblua.a(lauxlib.o):lauxlib.c:(.text+0x1714): more undefined references to `_impure_ptr' follo
w
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/liblua.a(lauxlib.o): In function `luaL_loadfile':
lauxlib.c:(.text+0x1724): undefined reference to `__srget'
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/liblua.a(lauxlib.o): In function `aux_do':
lauxlib.c:(.text+0x17e0): undefined reference to `_impure_ptr'
lauxlib.c:(.text+0x17e4): undefined reference to `_impure_ptr'
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/liblua.a(lbaselib.o): In function `luaB_print':
lbaselib.c:(.text+0x60): undefined reference to `_impure_ptr'
lbaselib.c:(.text+0x84): undefined reference to `_impure_ptr'
lbaselib.c:(.text+0xd4): undefined reference to `_impure_ptr'
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/liblua.a(lbaselib.o):lbaselib.c:(.text+0xd8): more undefined references to `_impure_ptr' follo
w
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/liblua.a(lbaselib.o): In function `luaB_tonumber':
lbaselib.c:(.text+0x228): undefined reference to `_ctype_'
lbaselib.c:(.text+0x234): undefined reference to `_ctype_'
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/liblua.a(liolib.o): In function `pushresult':
liolib.c:(.text+0x2c): undefined reference to `__errno'
liolib.c:(.text+0x54): undefined reference to `__errno'
liolib.c:(.text+0x8c): undefined reference to `__errno'
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/liblua.a(liolib.o): In function `aux_close':
liolib.c:(.text+0x320): undefined reference to `_impure_ptr'
liolib.c:(.text+0x324): undefined reference to `_impure_ptr'
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/liblua.a(liolib.o): In function `g_iofile':
liolib.c:(.text+0x758): undefined reference to `__errno'
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/liblua.a(liolib.o): In function `io_lines':
liolib.c:(.text+0x968): undefined reference to `__errno'
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/liblua.a(liolib.o): In function `g_read':
liolib.c:(.text+0xd90): undefined reference to `fscanf'
liolib.c:(.text+0xde0): undefined reference to `__srget'
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/liblua.a(liolib.o): In function `io_execute':
liolib.c:(.text+0x12b0): undefined reference to `system'
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/liblua.a(liolib.o): In function `io_date':
liolib.c:(.text+0x166c): undefined reference to `localtime'
liolib.c:(.text+0x16a4): undefined reference to `strftime'
liolib.c:(.text+0x17e4): undefined reference to `gmtime'
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/liblua.a(liolib.o): In function `io_time':
liolib.c:(.text+0x196c): undefined reference to `mktime'
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/liblua.a(liolib.o): In function `io_difftime':
liolib.c:(.text+0x1a54): undefined reference to `difftime'
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/liblua.a(liolib.o): In function `io_setloc':
liolib.c:(.text+0x1b18): undefined reference to `setlocale'
liolib.c:(.text+0x1b64): undefined reference to `setlocale'
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/liblua.a(liolib.o): In function `luaopen_io':
liolib.c:(.text+0x1c98): undefined reference to `_impure_ptr'
liolib.c:(.text+0x1cb8): undefined reference to `_impure_ptr'
liolib.c:(.text+0x1c80): undefined reference to `_impure_ptr'
liolib.c:(.text+0x1cd8): undefined reference to `_impure_ptr'
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/liblua.a(lstrlib.o): In function `str_lower':
lstrlib.c:(.text+0x214): undefined reference to `_ctype_'
lstrlib.c:(.text+0x218): undefined reference to `_ctype_'
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/liblua.a(lstrlib.o): In function `str_upper':
lstrlib.c:(.text+0x2f4): undefined reference to `_ctype_'
lstrlib.c:(.text+0x2f8): undefined reference to `_ctype_'
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/liblua.a(lstrlib.o): In function `match_class':
lstrlib.c:(.text+0x80c): undefined reference to `_ctype_'
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/liblua.a(lstrlib.o):lstrlib.c:(.text+0x810): more undefined references to `_ctype_' follow
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/libm.a(s_ldexp.o): In function `ldexp':
../../../../../newlib/libm/math/s_ldexp.c:77: undefined reference to `__errno'
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/libm.a(w_acos.o): In function `acos':
../../../../../newlib/libm/math/w_acos.c:111: undefined reference to `__errno'
../../../../../newlib/libm/math/w_acos.c:108: undefined reference to `__errno'
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/libm.a(w_asin.o): In function `asin':
../../../../../newlib/libm/math/w_asin.c:114: undefined reference to `__errno'
../../../../../newlib/libm/math/w_asin.c:111: undefined reference to `__errno'
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/libm.a(w_atan2.o):../../../../../newlib/libm/math/w_atan2.c:110: more undefined references to
`__errno' follow
collect2: ld returned 1 exit status
make: *** [luatest.elf] Error 1
I'm using cygwin on WinXP. Any clue?
Thanks[/code]