PS2 Lua Player

Discuss the development of software, tools, libraries and anything else that helps make ps2dev happen.

Moderators: cheriff, Herben

Post Reply
User avatar
evilo
Posts: 230
Joined: Thu Apr 22, 2004 8:40 pm
Contact:

PS2 Lua Player

Post by evilo »

Now that we have a recent (5.1) and functional lua interpreter running on the PS2 (still have few minor issues but they will be corrected in the next few days), it would be great to see coming a PS2 Lua player ! Aiming to enjoy on our beloved black box those nice lua games available today "only" on the PSP.

Having reviewed a bit the PSP player, I noticed that there is no abstraction layer with all the "system calls", meaning that a script will not be able to run both on PS2 or PSP.

So I would appreciate if interested people (if there is any) could give their feedback/idea(s) for the implementation of a PS2 player :)

Hoping to see you soon here...

evilo.

NB : for those interested lua is in the svn repository
http://svn.ps2dev.org/listing.php?repna ... rev=0&sc=0
Last edited by evilo on Sun Aug 13, 2006 11:04 am, edited 1 time in total.
tmator_
Posts: 9
Joined: Sat Jun 10, 2006 11:52 pm
Contact:

Post by tmator_ »

i'm ready to start ps2luaplayer
MikeHaggar
Posts: 116
Joined: Mon Jul 18, 2005 2:20 am

Post by MikeHaggar »

Well, one would need to have multiple ways to run the LUA script files, hopefully with USB Stick/HDD support, so one doesn't have to burn 100's of CD's everytime to debug ;)
tmator_
Posts: 9
Joined: Sat Jun 10, 2006 11:52 pm
Contact:

Post by tmator_ »

there is network to debug on ps2 ;)
SSpeare
Posts: 63
Joined: Tue May 23, 2006 11:45 pm
Contact:

Post by SSpeare »

I think it will be too hard (or impossible) as evilo has mentioned to support PSP LuaPlayer scripts on the PS2. Also, the capabilities of both machines are so different, a different interface is really needed.

So, what we need to do is start by defining what functionality we'd like to see in a Lua 4 PS2 and then figuring out how to get there. We can post suggestions here and then maybe use a Wiki to really fill out the API.

Simple beginning:

2d drawing operations (2d sprites, blitting, etc)
3d drawing operations (3d objects, rotations & translations, camera, etc)
pad input (multitap support)
sound (music, sfx)
??
User avatar
evilo
Posts: 230
Joined: Thu Apr 22, 2004 8:40 pm
Contact:

Post by evilo »

In my opinion (making a very quick analysis), and seeing the PSP lua player implementation, main parts are :

* luaplayer : This is the player itself, I would recommend just loading script by host in the first time, then once we'll have a first stable version, we'll add others possibilities (usb, hdd or whatever)

* luacontrols : This can be easily ported to PS2, functions name are independent of the target machine (without mentioning that buttons names are almost identical). Only one pad support could be coded in a first time.

* luasound : The PSP version is based on mikmodlib, we could also use it. It gives the advantage of some portability for this part and if I'm not wrong, someone was working on porting it to the ps2 (I'll check with him), so the work is already half done.

* luagraphics : Functions names can be maintained, however there is a huge work to be done here. Here we have two choices :
- SDL (that relies on gsKit), that already implements most of the needed features (sprite managing, blitting, font, etc....)
- gsKIt, surely better to use it directly, as using SDL would add an additional layer (lua script -> luagraphics-> SDL -> gsKit -> GS)

* luatimer : This can be recoded easily as well. Additionally ntba has coded a timer library (that contains missing time functions from the ps2sdk : http://www.ntba2.de/?p=libps2time) so we just need to plug it in.

* luawlan : no wlan support in the PS2, but we could add network play, would be even nice to be able to interconnect lua on the psp through wifi and lua on the ps2 through network.

* lua3d : I don't know yet... but gsKit is the key as for the luagraphics, this can be done in a second step.

* luasystem : this part has to be reviewed completely...


Speaking about priority for a first step, I would say :

1. luaplayer (loading from host)
2 .luacontrols (only 1 pad support)
3. luagraphics (as complete as possible)
4. luasound (mikmodlib)
5. luatimer (in case it's really needed by games in a first time).

Second step :
- enhance previous points :
- add lua3d, luawlan (-> lualan), luasystem,etc..


I would also suggest to everyone participating to agree on a first simple game, and to concentrate on the first features needed to get it running.

Evilo.
Last edited by evilo on Sat Jun 17, 2006 3:57 am, edited 2 times in total.
SSpeare
Posts: 63
Joined: Tue May 23, 2006 11:45 pm
Contact:

Post by SSpeare »

Wiki has begun:

http://wiki.ps2dev.org/ps2:lua_player

Please contribute.
User avatar
Drakonite
Site Admin
Posts: 990
Joined: Sat Jan 17, 2004 1:30 am
Contact:

Post by Drakonite »

evilo wrote: * luacontrols : This can be easily ported to PS2, functions name are independent of the target machine (without mentioning that buttons names are almost identical). Only one pad support could be coded in a first time.
I don't know much about how luacontrols is setup... but this part should be pretty easy to do... I think aiming to have support for up to four players should be the goal. I have some code for pad that looks really good, but I'll have to see if I can use it or not..
evilo wrote: * luagraphics : Functions names can be maintained, however there is a huge work to be done here. Here we have two choices :
- SDL (that relies on gsKit), that already implements most of the needed features (sprite managing, blitting, font, etc....)
- gsKIt, surely better to use it directly, as using SDL would add an additional layer (lua script -> luagraphics-> SDL -> gsKit -> GS)
I'd highly recommend going with gskit and staying away from SDL. Along with removing an extra layer it would also give a big speed boost, as unless someone has done some major work on it, SDL does all graphics in software (which is quite slow!)
Shoot Pixels Not People!
Makeshift Development
SSpeare
Posts: 63
Joined: Tue May 23, 2006 11:45 pm
Contact:

Post by SSpeare »

Here's what I have done (but it needs to be formed into a nice API):

input:

lp2ReadInput() - updates the state of all the pads
pads - this global variable has the number of pads plugged in
pad[x] - this contains the state of pad x at the last update.
pad[x].SELECT - true/false whether SELECT button was pressed
-- etc for START, LEFT,RIGHT,UP,DOWN, CROSS,CIRCLE,TRIANGLE,SQUARE, R1,R2,R3,L1,L2,L3
pad[x].RJOY_V - value of joystick access between 0-255 (127 is center)
-- etc for RJOY_H, LJOY_V, LJOY_H
normJoyAxis(value) - lua helper function that converts analog stick data into the range [-1,1] with a dead zone between 92 - 162 (based on some tests with different joysticks)

3d:
lp2BeginScene(r,g,b) - sets up the beginning of a frame
lp2MatrixMode(LP2.PROJECTION) - set Matrix Mode to LP2.PROJECTION or LP2.MODELVIEW (like OpenGL)
lp2LoadIdentity() - load identity into current matrix
lp2Perspective(fov, aspect, znear, zfar)- multiply current matrix by the perspective matrix defined
lp2Rotate(angle, x,y,z) - angle and x,y,z vector to rotate current matrix around
lp2Translate(x,y,z) - Translates current matrix by given amount.
lp2PushMatrix() - push current matrix
lp2PopMatrix() - pop current matrix

lp2WaitVSync() - Wait for a VSync
lp2EndScene(r,g,b) - End the scene and clear the screen (clears screen on PS2, renders vertex queues)
lp2RenderBuffers(verts, vertArray, colorArray, points, pointArray) - renders buffers of vertices and colors in the triangles specified by pointArray.

lp2Begin(LP2.TRIANGLES) - begin rendering vertices as triangles
lp2End() - finished rendering vertices
lp2Vertex(x,y,z) - x,y,z of vertex to render
lp2Color(r, g, b) - r,g,b of vertex to render

I also have a character animation/rendering class built in Lua and a model exporter for Blender that current only exports meshes. Working on skeleton and animation exporting.

Big TODOs are texturing and animation support.

But, all this will need reworked into reusable components for others.

Oh, and the whole thing runs in OpenGL and is mostly identical to the PS2.
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Re: PS2 Lua Player ?

Post by Shine »

evilo wrote:Now that we have a recent (5.1) and functional lua interpreter running on the PS2 (still have few minor issues but they will be corrected in the next few days), it would be great to see coming a PS2 Lua player !
This is a good idea.
evilo wrote: Having reviewed a bit the PSP player, I noticed that there is no abstraction layer with all the "system calls", meaning that a script will not be able to run both on PS2 or PSP.
There is some kind of abstraction layer: For the Windows player I've just emulated all the needed PSP functions. But you are right, maybe it would be better to create a more high level abstraction layer. One idea would be to seperate more cleanly the Lua part and the implementation part, like in luagraphics.cpp and graphics.cpp. The driver then is graphics.cpp, only.

I don't have a PS2 any more, is an OpenGL implementation available for it? I ask becaus I want to change the graphics part to OpenGL, emulating all current luagraphics functions with OpenGL. This should be even faster for some operations, like fillRect and image blitting, when caching multiple images in VRAM as a texture. And then it would be easier to port it to other platforms, e.g. PS3 and MacOSX.
User avatar
daurnimator
Posts: 38
Joined: Sun Dec 11, 2005 8:36 pm
Location: melbourne, australia

Post by daurnimator »

has anyone gotten further on this?

whos working on it?
SSpeare
Posts: 63
Joined: Tue May 23, 2006 11:45 pm
Contact:

Post by SSpeare »

I've got some code that implements parts of this. But, I've been involved in packing and moving and I don't have my PC set up again. Hopefully I'll get it up some time this weekend and start refactoring what I've got into a more library-esque distribution.

That, and I need to figure out how to get my updates into svn since I don't have an internet connection at home.
User avatar
evilo
Posts: 230
Joined: Thu Apr 22, 2004 8:40 pm
Contact:

Post by evilo »

Hi,

I'm working on it, together with tmator and sspeare !

I've been off these last days, but I started to make a skeleton of the ps2 player, and started working on the control part.

tmator has been working on the mikmodlib, that is used on the psp for all the sound stuff, so we plan to use it as well for the PS2 (dunno if he finally got it working). The plan beeing to be as close as possible of the PSP one, in order to give some kind of interoperability between the two players :)

if you want to join, you're welcome. As soon as I'll have a first clean skeleton with a few things inside maybe i'll put it into svn if other are working on it as well.

regards,
evilo.
User avatar
evilo
Posts: 230
Joined: Thu Apr 22, 2004 8:40 pm
Contact:

Post by evilo »

Just to give a quick update on the project : I now have LuaControls library implemented.

I know that it's not so much, and that there is nothing to make a big fuzz about, but this is a first step done for the player :)

now I'm able to run this kind of script :

Code: Select all

-- A very simple pad test script
print("Lua pad test program by evilo", "Press buttons for testing")

while true do
	-- screen.waitVblankStart()

	pad = Controls.read()

	if pad:circle() then 
	  print("circle pressed")
	end
	if pad:cross() then 
	  print("cross pressed")
	end
	if pad:triangle() then 
	  print("triangle pressed")
	end
	if pad:square() then 
	  print("square pressed")
	end
	if pad:select() then 
	  print("select pressed")
	end
	if pad:start() then 
	  print("start pressed")
	end
	if pad:up() then 
	  print("up pressed")
	end
	if pad:down() then 
	  print("down pressed")
	end
	if pad:left() then 
	  print("left pressed")
	end
	if pad:right() then 
	  print("right pressed")
	end
	if pad:l1() then 
	  print("l1 pressed")
	end
	if pad:r1() then 
	  print("r1 pressed")
	end
	if pad:l2() then
	  print("l2 pressed")
	end
	if pad:r2() then
	  print("r2 pressed")
	end
	if pad:l3() then
	  print("l3 pressed")
	end
	if pad:r3() then
	  print("r3 pressed")
	end
end
drakonite: right now, there is support for one pad only (port 0, slot 0), later i think to add a new function Controls.read(pad number) in order to use the others.

next step is the graphic part with LuaGraphics (using gsKit).

cheers !
User avatar
evilo
Posts: 230
Joined: Thu Apr 22, 2004 8:40 pm
Contact:

Post by evilo »

A little hello from LuaPlayer on the PS2 :)

Code: Select all

green = Color.new(0, 255, 0)

screen:print(200, 100, "Hello World!", green)

for i=0,20 do
	x0 = i/20*479
	y1 = 271-i/20*271
	screen:drawLine(x0, 271, 479, y1, green)
end

screen.flip()
while true do
	screen.waitVblankStart()
end
Image

Luagraphics need more testing, but this is a nice step !

a quick status :

LuaControls : one pad support implemented
LuaGraphics : see above :)
LuaSounds : on it's way :)

More to come !!
gawd
Posts: 28
Joined: Wed Feb 09, 2005 10:36 pm
Location: Israel
Contact:

Post by gawd »

OMFG!

Congratulations!
Give PS2DEV a kickstarts!

-.... and use audsrv!

:)
User avatar
evilo
Posts: 230
Joined: Thu Apr 22, 2004 8:40 pm
Contact:

Post by evilo »

thanks :)

it's used for mikmodlib :)

and gsKit for the graphic part :)
User avatar
evilo
Posts: 230
Joined: Thu Apr 22, 2004 8:40 pm
Contact:

Post by evilo »

A little video of the player in action, running the starfield sample from Shine :
http://psxdev.info/evilo/download/luapl ... rfield.avi


:-)
User avatar
evilo
Posts: 230
Joined: Thu Apr 22, 2004 8:40 pm
Contact:

Post by evilo »

Some fresh news from the PS2 Lua Player :

Image

I made some progress, and as you can see it can now run some more complex script like Luamines ! (version 0.03 by Dragula96)

For those interested you can also find here :
http://psxdev.info/evilo/download/luapl ... amines.avi a video (30Mo) of the game running. The game is a bit slow to show up and you'll see the "Lua Powered" splash for a few seconds because of the loading time (all images used by the lua script are loaded from host). Also, font display seems a bit screwed up on the video, but this is because of the divx compression (check the screen capture above).

a Quick status :
----------------
LuaControls : one pad support
LuaGraphics : need more work on the blitting functions to use gsKit properly
LuaTimer : done
LuaSounds : no sound output yet :(

Still in alpha stage and a work in progress anyway :)
User avatar
daurnimator
Posts: 38
Joined: Sun Dec 11, 2005 8:36 pm
Location: melbourne, australia

Post by daurnimator »

nice work

can't wait for this to be working well :D
JorDy
Posts: 121
Joined: Sun Dec 11, 2005 8:45 am

Post by JorDy »

wow great work i cant wait until the sounds is finsihed
User avatar
evilo
Posts: 230
Joined: Thu Apr 22, 2004 8:40 pm
Contact:

Post by evilo »

Hi guys,

some updates on the LuaPlayer for PS2. Most of the libs are now implemented (except lua3d and luawlan that anyway won't be implemented for the first release), so the player is now really advanced.

I posted a new video on my blog (http://psxdev.info/evilo/), showing the lowser app running and then executing DrMario (note that, yes, the loading time is slow, this is due to loading through the network for debbugging purpose). Note also that the drMario script is the unmodified current PSP version :)

cheers :)
sparrow
Posts: 24
Joined: Thu Apr 13, 2006 3:36 am
Contact:

Post by sparrow »

evilo, you're doing a GREAT job! :D

When is the first public release going out? I just can't wait to play that Lua games on my PS2!

Cheers,

Sparrow
User avatar
daurnimator
Posts: 38
Joined: Sun Dec 11, 2005 8:36 pm
Location: melbourne, australia

Post by daurnimator »

any progress on this?

evilo?
User avatar
evilo
Posts: 230
Joined: Thu Apr 22, 2004 8:40 pm
Contact:

Post by evilo »

A first beta is out since a few days now :)

check my blog : http://psxdev.info/evilo/

evilo.
jgrimm
Posts: 27
Joined: Sun Nov 29, 2009 2:00 am

Post by jgrimm »

i was wondering if ps2 lua player has network support at the moment? also i do likethe idea of connecting ps2 and psp. with network support, is it possible to code a web browser? i relly want a web browser for ps2 and i dont have ps2linux so i cant use one
dlanor
Posts: 258
Joined: Thu Oct 28, 2004 6:28 pm
Location: Stockholm, Sweden

Post by dlanor »

jgrimm wrote:i was wondering if ps2 lua player has network support at the moment? also i do likethe idea of connecting ps2 and psp. with network support, is it possible to code a web browser? i relly want a web browser for ps2 and i dont have ps2linux so i cant use one
Be aware that you are the first person to post in this thread for over three years, so don't expect the previous posters to be ready to continue discussions where they left off.

As for making a real web browser, I doubt very much that the PS2 lua player is a suitable tool for it. If working at all it would be bound to become extremely limited in all its capabilities.

Best regards: dlanor
Post Reply