Lua player core development

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

nevyn
Posts: 136
Joined: Sun Jul 31, 2005 5:05 pm
Location: Sweden
Contact:

Post by nevyn »

LuMo wrote: src/luaplayer.c:9:17: error: lua.h: No such file or directory
src/luaplayer.c:10:20: error: lualib.h: No such file or directory
src/luaplayer.c:11:21: error: lauxlib.h: No such file or directory
Sounds to me like lualib isn't in your path. Confirm that the above three files really are in your /usr/local/pspdev/psp/include/
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

Post by LuMo »

seems that i updated just when you posted :)
yes, those files are located in the dir, NOW

following files are included:
  • alloca.h
    ar.h
    argz.h
    assert.h
    ctype.h
    dirent.h
    envz.h
    errno.h
    fastmath.h
    fcntl.h
    files
    getopt.h
    grp.h
    iconv.h
    ieeefp.h
    langinfo.h
    lauxlib.h
    limits.h
    locale.h
    lua.h
    lualib.h
    machine
    malloc.h
    math.h
    mikmod.h
    mmio.h
    newlib.h
    paths.h
    png.h
    pngconf.h
    process.h
    ptform.h
    pthread.h
    pwd.h
    reent.h
    regdef.h
    search.h
    setjmp.h
    signal.h
    stdio.h
    stdlib.h
    string.h
    sys
    tdefs.h
    termios.h
    time.h
    timer.h
    unctrl.h
    unistd.h
    utime.h
    utmp.h
    wchar.h
    wctype.h
    zconf.h
    zlib.h
    _ansi.h
    _syslist.h
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
nevyn
Posts: 136
Joined: Sun Jul 31, 2005 5:05 pm
Location: Sweden
Contact:

Post by nevyn »

Yes, you're not getting a preprocessor error now, that thing there is a linker error.

Confirm that you have the file
/usr/local/pspdev/psp/lib/liblua.a

(see that "/usr/local/pspdev/lib/gcc/psp/4.0.1/../../../../psp/lib/liblua.a: could not read" there? MIGHT give you a clue to what's wrong. . .)
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

LuMo wrote:[UPDATE] Lua did not compile ok
had to force it:
make -f Makefile.psp
make install -f Makefile.psp
now i am getting new errors :/
If you have compiled Lua before without Makefile.psp, there are old files compiled for your host system. Call a "make clean" and "make -f Makefile.psp clean" and then again a "make -f Makefile.psp" and "make -f Makefile.psp install".
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

Post by LuMo »

thats evil :)
it works now
thanks to the chiefs ;)

greets
Lumo
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Zenurb
Posts: 106
Joined: Fri Sep 30, 2005 8:33 am
Location: United Kingdom
Contact:

Post by Zenurb »

I'm not sure but is there a socket like interface for lua <-> psp's wifi connection?
Proud Dvorak User
US 1.5 PSP (Original)
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

Post by LuMo »

not yet
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Zenurb
Posts: 106
Joined: Fri Sep 30, 2005 8:33 am
Location: United Kingdom
Contact:

Post by Zenurb »

LuMo wrote:not yet
Ah, there should be, Like a Net class or something.

e.g. Net.startWifi() would start the wifi connection

You could have something to poll available connections like

Code: Select all

Net.connections Array

Net.connections&#91;0&#93;&#91;0&#93; == "Home"  // SSID  &#123;
Net.connections&#91;0&#93;&#91;1&#93; == "10.0.0.3" // IP    &#123;    Read-only as defined on PSP vmenu
Net.connections&#91;0&#93;&#91;1&#93; == "10.0.0.1" // Gateway    &#123;

Net.pickConnection&#40;0&#41;

time = 0
notconnect = 0
data = ""

while Net.connected = false do
  time = time + 1
  if time > 200 then
    notconnect = 1
    break
  end
end

if notconnect = 0 then
  while Net.connected = true do
    if Net.error = true do
      screen&#58;print&#40;1,1,Net.LastError&#40;&#41;,Color.new&#40;255,255,255&#41;&#41;
      break
    end
    sock = Net.Socket.New&#40;"10.0.0.1", 80&#41; // This halts the script while it connects, adds any error to sock.Errors array
    while sock.connected = true
      if sock.error = true do
        screen&#58;print&#40;1,1,sock.LastError&#40;&#41;,Color.new&#40;255,255,255&#41;&#41;
        break       
      end
      sock.get&#40;data&#41;
      // Decide what to do with the socket data
      sock.send&#40;"String"&#41;
    end
  end
end
Something like that.. would be idea...

I don't even know if you can define Classes in Lua lol
Proud Dvorak User
US 1.5 PSP (Original)
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

Post by LuMo »

the problem is not the lua end
its mainly cause the backend (c-side) is not stable yet (guessing!!)

greets
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
nevyn
Posts: 136
Joined: Sun Jul 31, 2005 5:05 pm
Location: Sweden
Contact:

Post by nevyn »

I promise, the reason that we don't have sockets in LuaPlayer isn't because we can't come up with an API...

When sockets in the toolchain is stable, luaplayer will get it.
Last edited by nevyn on Mon Oct 03, 2005 9:11 pm, edited 1 time in total.
Zenurb
Posts: 106
Joined: Fri Sep 30, 2005 8:33 am
Location: United Kingdom
Contact:

Post by Zenurb »

LuMo wrote:the problem is not the lua end
its mainly cause the backend (c-side) is not stable yet (guessing!!)

greets
Well PSPRadio and PSPWifiJukebox seems to work fine...
Proud Dvorak User
US 1.5 PSP (Original)
nevyn
Posts: 136
Joined: Sun Jul 31, 2005 5:05 pm
Location: Sweden
Contact:

Post by nevyn »

Zenurb wrote:
LuMo wrote:the problem is not the lua end
its mainly cause the backend (c-side) is not stable yet (guessing!!)

greets
Well PSPRadio and PSPWifiJukebox seems to work fine...
They aren't what you'd call "stable" when it comes to the networking end. Also, they aren't using BSD sockets, but rather interface directly with the sce* functions.
Zenurb
Posts: 106
Joined: Fri Sep 30, 2005 8:33 am
Location: United Kingdom
Contact:

Post by Zenurb »

nevyn wrote:
Zenurb wrote:
LuMo wrote:the problem is not the lua end
its mainly cause the backend (c-side) is not stable yet (guessing!!)

greets
Well PSPRadio and PSPWifiJukebox seems to work fine...
They aren't what you'd call "stable" when it comes to the networking end. Also, they aren't using BSD sockets, but rather interface directly with the sce* functions.
Why does LuaPlayer have to use BSD sockets?

LuaPlayer should map the sce socket functions, that way, people can get an understanding of them, and when they move onto C/C++ they will find it easier =)
Proud Dvorak User
US 1.5 PSP (Original)
nevyn
Posts: 136
Joined: Sun Jul 31, 2005 5:05 pm
Location: Sweden
Contact:

Post by nevyn »

Because BSD sockets is the de facto standard for networking. And because there's already a great network library written, and I hate to reinvent the wheel. And because "mapping the sce functions" makes the API damn ugly and non-user-friendly.

"..and when they move onto C/C++...": LuaPlayer isn't a first step of programming, so that newbies can start somewhere instead of C (although it can certainly be used that way). Rather, it's a rapid application development environment, perfectly suitable for "real programmers". Thus the language shouldn't be designed to help you progress onto C, but to make every part of the language/interface fast and simple to use.

Using BSD sockets allows it to be portable, as well, needing no extra code to port it to Win, Mac and Linux (or even, say, nintendo DS, when their bsd sockets stabilize)
Zenurb
Posts: 106
Joined: Fri Sep 30, 2005 8:33 am
Location: United Kingdom
Contact:

Post by Zenurb »

nevyn wrote:Because BSD sockets is the de facto standard for networking. And because there's already a great network library written, and I hate to reinvent the wheel. And because "mapping the sce functions" makes the API damn ugly and non-user-friendly.

"..and when they move onto C/C++...": LuaPlayer isn't a first step of programming, so that newbies can start somewhere instead of C (although it can certainly be used that way). Rather, it's a rapid application development environment, perfectly suitable for "real programmers". Thus the language shouldn't be designed to help you progress onto C, but to make every part of the language/interface fast and simple to use.

Using BSD sockets allows it to be portable, as well, needing no extra code to port it to Win, Mac and Linux (or even, say, nintendo DS, when their bsd sockets stabilize)
Good point. I just am impatient waiting for socket support in LuaPlayer.

Is there a way to bundle your Lua scripts directly into the LuaPlayer Eboot and have bundled applications? *Is a noob*
Proud Dvorak User
US 1.5 PSP (Original)
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

Post by LuMo »

you could add your code to the boot.lua, which will be included into the eboot (shine said something like that)
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Zenurb
Posts: 106
Joined: Fri Sep 30, 2005 8:33 am
Location: United Kingdom
Contact:

Post by Zenurb »

LuMo wrote:you could add your code to the boot.lua, which will be included into the eboot (shine said something like that)
I mean like, with python, you can embed the script directly into the interpeter and have one file which runs the interpreter which loads the code from a resource in itself, can you do that with LuaPlayer?
Proud Dvorak User
US 1.5 PSP (Original)
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

Post by LuMo »

lots of questions hehe, you can compile luaplayer and include the script to the binary, but a.f.a.i.k. you are not able to include the resources
zip support (loading scripts and res. from a zip file) is planned to be done

greets
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Zenurb
Posts: 106
Joined: Fri Sep 30, 2005 8:33 am
Location: United Kingdom
Contact:

Post by Zenurb »

LuMo wrote:lots of questions hehe, you can compile luaplayer and include the script to the binary, but a.f.a.i.k. you are not able to include the resources
zip support (loading scripts and res. from a zip file) is planned to be done

greets
Cool =] My last question for now. I'm in college, and I'll tinker more when I get home.
Proud Dvorak User
US 1.5 PSP (Original)
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

C-Side of LuaPlayer(windows)

Post by LuMo »

well i tried to add a >>little<< function just to test if it works.
i copied the blit-function (to seperate files)
and compiled it, which worked without any errors!
i tested created an lua file to test the original code (so i did not **** something up)

Code: Select all

--load images
picture=Image.load&#40;'landscape.png'&#41;
backbuffer = Image.createEmpty&#40;480, 272&#41;


while not Controls.read&#40;&#41;&#58;start&#40;&#41; do
	backbuffer&#58;blit&#40;0,0,picture,0,0,240,272,false&#41;
	backbuffer&#58;blit&#40;240,0,picture,240,0,240,272,false&#41;
	screen&#58;blit&#40;0,0,backbuffer,0,0,backbuffer&#58;width&#40;&#41;,backbuffer&#58;height&#40;&#41;,false&#41;
	screen.waitVblankStart&#40;&#41;
	screen.flip&#40;&#41;
end
test successful

after that i changed the line

Code: Select all

	backbuffer&#58;blit&#40;0,0,picture,0,0,240,272,false&#41;
	backbuffer&#58;myblit&#40;240,0,picture,240,0,240,272,false&#41;
this should give me exactly the same result as the one above (due just copying the function)
but luaplayer returns me the following error:

Code: Select all

loop in gettable
in the line where myblit is used!
i do not know what this means...
any ideas?

[EDIT] i just get the same error when i put the function in the same file (graphics.c and luagraphics.c)

thanks in advance
lumo
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Arwin
Posts: 426
Joined: Tue Jul 12, 2005 7:00 pm

Post by Arwin »

nevyn wrote:
Zenurb wrote:
LuMo wrote:the problem is not the lua end
its mainly cause the backend (c-side) is not stable yet (guessing!!)

greets
Well PSPRadio and PSPWifiJukebox seems to work fine...
They aren't what you'd call "stable" when it comes to the networking end. Also, they aren't using BSD sockets, but rather interface directly with the sce* functions.
What do you mean here exactly? I've been using PSP Radio last weekend for a fair bit, and I had no problems ... But I assume that you'll likely know something about the internals that I don't. ;)
haust
Posts: 25
Joined: Sat Oct 01, 2005 12:37 am
Location: France

Post by haust »

Would it be possible to obtain all the call stack when an error occurs ??
I have lots of functions called from many points and I have hard time to find exactly where the error occured :(
I don't known if it's possible or difficlut but it would be useful :)
haust
Posts: 25
Joined: Sat Oct 01, 2005 12:37 am
Location: France

Post by haust »

Another request : would it be possible to add LuaExpat for xml support. I think it would be useful for data storing, config file and things like that....

vh.
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

haust wrote:Another request : would it be possible to add LuaExpat for xml support. I think it would be useful for data storing, config file and things like that....
Why do you want XML for config files? You can do it in Lua, if you need hierarchicly configs:

Code: Select all

config = &#123; a=&#123;1,2,b=&#123;3&#125;&#125;, c="Hallo"&#125;
and the just a dofile to read the config. But if you really want to use XML, there is a very short pure Lua solution: http://lua-users.org/wiki/LuaXml
nevyn
Posts: 136
Joined: Sun Jul 31, 2005 5:05 pm
Location: Sweden
Contact:

Post by nevyn »

Arwin wrote:What do you mean here exactly? I've been using PSP Radio last weekend for a fair bit, and I had no problems ... But I assume that you'll likely know something about the internals that I don't. ;)
Tried connecting using DHCP? Seen what happens when a socket timeout? Those problems were fixed in the latest release, but that was like today, so I haven't had time to look at it.

And it's still not socket.h. There's a guy, David Beyer, who's working on that, though.
haust
Posts: 25
Joined: Sat Oct 01, 2005 12:37 am
Location: France

Post by haust »

Shine wrote:Why do you want XML for config files? You can do it in Lua, if you need hierarchicly configs:

Code: Select all

config = &#123; a=&#123;1,2,b=&#123;3&#125;&#125;, c="Hallo"&#125;
and the just a dofile to read the config. But if you really want to use XML, there is a very short pure Lua solution: http://lua-users.org/wiki/LuaXml
Well, I should had say (sorry if my english is not correct) that I know Lua tables can be used for all kind of needs including config data. However I like separation between code and data. When I need to modify the core logic I change the source code, when I need to modify the visuals, audio, config, etc. I change the data files, but it's just me....
Anyway it was just a request, I can live without it :)

vh.
Durante
Posts: 65
Joined: Sun Oct 02, 2005 6:07 am
Location: Austria

Post by Durante »

You sound like a Java or C++ programmer :P
But I guess that's to be expected from someone who prepends all his member variables with m_ *shudder*

But seriously, why would you need a seperate config file format in a Lua app? I mean, the lua table constructor syntax is actually far more suited to the task than XML, and it will be faster to parse as well ;)

And why shouldn't you be able to seperate code and data just because the data is in Lua tables?
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

haust wrote:However I like separation between code and data. When I need to modify the core logic I change the source code, when I need to modify the visuals, audio, config, etc. I change the data files
Separation of code and data is a good idea for bigger programs, but I don't see why you don't want to use tables for it. You have your main program, index.lua (or script.lua)

Code: Select all

dofile&#40;"level1.lua"&#41;
...
doSomethingWith&#40;level.name, level.timeLimit&#41;
and then in a separate file your config, e.g. for a level, as a file named "level1.lua" :

Code: Select all

level = &#123;
  name = "The big one",
  timeLimit = 12345
&#125;
(of course, instead of hardcoding dofile("level1.lua") a list of levels could be in some other config files). The nice thing is, that you can save numbers and strings without the need to convert it. With XML you have only strings.
haust
Posts: 25
Joined: Sat Oct 01, 2005 12:37 am
Location: France

Post by haust »

haust wrote:Anyway it was just a request, I can live without it :)
I already use tables for data handling (since, I guess, tables were designed for this)....
th0mas
Posts: 43
Joined: Sun Apr 24, 2005 1:59 am
Location: Canada
Contact:

Post by th0mas »

I apologize in advance if this would be better suited in a different thread.

I've ported the windows emulator to SDL. It should be possible to get it to run on a wide array of devices and other consoles. I did not port sound, nor (obviously) 3d.

I just took the src/emulator/windows/windows.c and ported the glut code to SDL, and took sound.c and made a set of stub functions.

[nevermind this part, bug fixed, see footnote]
AFAIK, there is only one bug that is not fixed at the moment. It seems that certain blitting functions do not work, and I am unsure why this is. For example:

- helloworld works
- clock, calculator, minesweeper works
- stars works

- fractal doesn't work
- snake - the background is there, but the snake itself does not show up.

I just did this in the past hour or two, so probably the fix will appear soon.. but if anyone knows what is going on offhand please let me know.

I'll pass the code onto whoever wants it once the bug is fixed.

Cheers,
Tom

Update: Bug fixed. i updated to the SVN source (I was using the 0.11 release) and it fixed it. Games appear to be completely playable (sans sound & 3d).
Post Reply