System Extension (v0.5,cpu,elf loading,mp3,zip)

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

Moderators: Shine, Insert_witty_name

be2003
Posts: 144
Joined: Thu Apr 20, 2006 2:46 pm

System Extension (v0.5,cpu,elf loading,mp3,zip)

Post by be2003 »

ok this is my first ever experience with the pspsdk, spent 2 days getting it to work and the first thing i did was create a LuaPlayer lrx, i was thinking about what LuaPlayer needed and i decided to port over the fuunctions that were in LuaPlayer 0.17dk2 but are not in the current release(0.20).

So with this lrx you can call all of the added functions in 0.17dk2 :)

Just read the samples on loading modules in Luaplayer and you can call these...

Added Sysext.Quit() which will exit Lua Player back to the PSP browser
Added Sysext.isUmdInserted() and will return true if a UMD is inserted
Added Sysext.initUMD() which will mount the UMD to disk0: (it will not launch it)
Added Sysext.setCpuSpeedHigh(), Sysext.setCpuSpeedMed(), and Sysext.setCpuSpeedReg() which changes the CPU speed to 333 MHz, 266 MHz, and 222 MHz respectively.

This was all based on the 0.17dk2 release and the effect.lrx source so thanks to them. I'm gonna need feedback though because even though it compiled fine, well um i cant find my psp usb cord and cant test it out lol.

I will add all the functions people want and hopefully make a collection of these nice little lrx's.

I would make them System.Quit(), etc. but i am not sure if i can have the library call functions of the same category that is build into the luaplayer...
and the reason i made it a lrx library instead of another release it to avoid it being replaced by a neew version and not keeping the functions implemented. ya so enough chit chat here it is:

right click on the link and click save as or what ever
dont regular click on it or angelfire.com will give you it's little page about direct linking and hating my guts, so right-click "save as" or "Save target as"
http://www.angelfire.com/blog/dev-be2003/sysext.zip

but one again, i need feedback on whether it works... and tell me if you get any errors... must be loaded in a luaplayer with module loading support and kernel mode access...

edit: Just tested it, via neighbor's wifi hehe, works like a charm, now those 3d lua apps run as fast a B-otch.
Last edited by be2003 on Wed Jul 26, 2006 5:08 pm, edited 6 times in total.
- be2003
blog
be2003
Posts: 144
Joined: Thu Apr 20, 2006 2:46 pm

Post by be2003 »

sorry about double post but if ur really newbie then do this:

open the zip and get the sysext.lrx file and put it in your LuaPlayer
folder, the one with luaplayer.prx in it and all the other lrx's.

and add this to the beginning of your code

Code: Select all

sysext = loadlib( "sysext", "init" ) 
if sysext then sysext() end 
edit: i will see if i can change the name over to system, so you can call System.Quit(), etc.

I will add a function to return the current cpu speed...

edit: v0.2 is out at same link:

added Sysext.getCpuSpeed() returns 333, 266, or 222
added Sysext.loadModule(path) - loads a module at path hopefully

yup thats all, i need some ideas folks, anything you wish luaplayer had.
- be2003
blog
be2003
Posts: 144
Joined: Thu Apr 20, 2006 2:46 pm

Post by be2003 »

v0.3 is out, and i feel like i'm talking to myself right now, you know this library can solve many of people problems, especially with mp3 support!

yes mp3, here is the readme

Code: Select all

-----------------------------------
version 0.3
-----------------------------------
Added Mp3 support :) kinda, all from psp media center --- thanks, all functions but one, MP3.GetTimeString(), i didn't know what it was for...
Includes MP3.Init() initializes the mp3 player
Includes MP3.Play() plays the loaded mp3
Includes MP3.Pause() pauses the playing mp3
Includes MP3.Stop() stops the loaded mp3
Includes MP3.End() ends the loaded mp3 (stops it and unloads it from ram)
Includes MP3.FreeTune() clears the ram of the loaded mp3
Includes MP3.Load(file) loads an mp3 as file
Includes MP3.EndOfStream() return true if the mp3 has ended and false if it didn't, duh
enjoy, if anyone's using this, i still want feedback and ideas for what to put in this ... and i would recommend changing the cpu speed to high for mp3 playback.

edit: ok, so getCpuSpeed is broken ... im gonna try a get a fix up soon...
- be2003
blog
User avatar
daurnimator
Posts: 38
Joined: Sun Dec 11, 2005 8:36 pm
Location: melbourne, australia

Post by daurnimator »

how bout a elf launcher? - with callbacks of course...
be2003
Posts: 144
Joined: Thu Apr 20, 2006 2:46 pm

Post by be2003 »

something like:

Sysext.loadExec(path) to load an elf file, only elf, not 1.0 eboots

-----------------------------------
version 0.4
-----------------------------------
Changed the mp3 api... hre it is:
Includes MP3.Play(file) initializes psp audio loads the file and plays it
Includes MP3.Pause() pauses the playing mp3
Includes MP3.Stop() stops the mp3 unloads it from memory and terminates psp audio
Includes MP3.EndOfStream() return true if the mp3 has ended and false if it didn't, duh

and ...

Added Sysext.loadExec(path) to load an elf executable at path.
*Fixed Sysext.getCpuSpeed() which was broken for some reason...

-----------------------------------
version 0.4b
-----------------------------------
Changed all Sysext.whatever() to System.whatever() and MP3.whatever() to Mp3.whatever()
so call System.Quit() etc.
Attempted to fix the mp3 call again to make it work, remember folks this is my first ever compiled by me thing... lol have fuun

and ...

-----------------------------------
version 0.4c
-----------------------------------
Took out System.loadModule(path) because it sucked at life, eg. Luaplayer didn't want anything to do with it so i decided loadExec was enough.

edit: fixed mp3player, it was that i forgot to put define mp3player.o in the makefile lol...

edit: nevermind its still gay...

now the api looks like this:

Mp3.init() initializes mp3 player
Mp3.play() plays the loaded mp3
Mp3.pause() pauses loaded mp3
Mp3.stop() stops loaded mp3
Mp3.end() ends loaded mp3
Mp3.load(file) loads file as mp3
Mp3.freeTune() removes loaded mp3 from ram
Mp3.endOfStream() return true if the mp3 is over, false if it isnt

make sure to call Mp3.init() before loading and playing mp3's and call Mp3.End() when you are finished.
- be2003
blog
be2003
Posts: 144
Joined: Thu Apr 20, 2006 2:46 pm

well v0.5 is out, like anyone cares or knows, lol...........

Post by be2003 »

ok here it is:

I added zip. sweet huh! this is alpha so i need feedback, wait, sorry, my bad, i forgot no one cares, or no one uses lua anymore.

well if anyone cares here it is: (at the same link up at the first post.)

-----------------------------------
version 0.5
-----------------------------------
ZIP ZIP ZIP !!!ALPHA!!!
NOT SURE IF MULTIPLE FILE ZIPS WORK...

Added Zip.compress(file, zipout) compress file into zipout, they are both files so they expect a relevant path
Added Zip.extract(zipin, filesout) uncompress zipin into filesout, they are both files so they expect a relevant path
- be2003
blog
Oobles
Site Admin
Posts: 347
Joined: Sat Jan 17, 2004 9:49 am
Location: Melbourne, Australia
Contact:

Post by Oobles »

be2003,

Looks like you've been having fun with those libraries. If you're interested in adding them directly to Subversion let me know. I will have to ask Shine, but I'm sure he would be happy to have your modules in Subversion.

Regards,
David. aka Oobles.

PS. Sorry, I haven't had time to try them out either. No time to Lua at the moment. :(
be2003
Posts: 144
Joined: Thu Apr 20, 2006 2:46 pm

Post by be2003 »

[quote="Oobles"]be2003,

Looks like you've been having fun with those libraries. If you're interested in adding them directly to Subversion let me know. I will have to ask Shine, but I'm sure he would be happy to have your modules in Subversion.

Regards,
David. aka Oobles.

PS. Sorry, I haven't had time to try them out either. No time to Lua at the moment. :([/quote]

ya, sure that would be great, i would have added most of the features directly into luaplayer, but we all remember luaplayer 0.17dk2, and i was kinda pissed to hear i can't change my cpu speed or quit to the psp menu, or whatever they call that freakin thing these days...

now, i am looking mostly looking into bug fixes and getting it to run efficiently with no memory leaks... :O

dont' worry i don't think there are any.

maybe i will add adhoc support... holy ker-app (that stands for kernel application...ya...ya....)

i know alot of people were asking for it though.
- be2003
blog
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

I'll add the modules to the official Lua Player distribution, if you like. If someone thinks changing the CPU speed is unsafe, he only needs to delete the sysext module.

AdHoc support sounds great, too.

But I don't like MP3. What do you think about implementing Ogg/Vorbis for Lua Player? There are free MP3 to Ogg converters, like http://audacity.sourceforge.net/ and the file size and quality is the same, but we don't get in trouble for MP3 licensing.

BTW: Maybe you should ask for SVN access, because then it is easier to maintain your modules within the Lua Player repository.
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

Shine wrote:But I don't like MP3. What do you think about implementing Ogg/Vorbis for Lua Player? There are free MP3 to Ogg converters, like http://audacity.sourceforge.net/ and the file size and quality is the same, but we don't get in trouble for MP3 licensing
I'm part way through implementing Ogg support (noticed it was on your todo list), if you wait a few days I'll send you what I have.

I already have the (software) decoding done in C, I just to finalise things in the Lua implementation. The C decoding is based on the PSP Media Center source code.
be2003
Posts: 144
Joined: Thu Apr 20, 2006 2:46 pm

Post by be2003 »

ya, i got the mp3 suppprt from pspmediacenter, on my psp it seems like the mp3 doesn't work, but that is probably a couple releases ago, anyway svn access to the svn.ps2dev.org/pspware/trunk/LuaPlayer/modules/sysext folder would be nice because i hate angelfire's guts, only sometimes though. Atleast it is better than geocities.

I will get rid of mp3 and add ogg for sure, then see if i can port a mp3 to ogg converter(doubtful) if it is open-source.

But yes please, add it just wait til i release 0.6, fix some bugs. and does anyone know if System.loadExec(file) works... i haven't tested it out all the way. I provided a sample elf to load(and it actually works). i also added a prx, but that is old and needs to be gone. I will clean up my code, my zip file then release 0.6. thank you all for the replies.
- be2003
blog
Oobles
Site Admin
Posts: 347
Joined: Sat Jan 17, 2004 9:49 am
Location: Melbourne, Australia
Contact:

Post by Oobles »

be2003, as you've been doing a lot of this lua wrapper code. I wonder if you should read up on SWIG. www.swig.org and see if it helps your efforts. I just re-found it this week and will hopefully get to use it to wrap some lua code.

Oobles.
be2003
Posts: 144
Joined: Thu Apr 20, 2006 2:46 pm

Post by be2003 »

ah, nice, thanks, im almost done with my next build of sysext, so i will definately use this tool to my advantage, thanks.

edit: haha cygwin had it installed for me and i didn't even know
- be2003
blog
be2003
Posts: 144
Joined: Thu Apr 20, 2006 2:46 pm

haha '06

Post by be2003 »

done! yay, ok no more mp3 :( but we gained ogg :| whatever i dont care, so ya... still need feedback on all functions...

same link as above...

-----------------------------------
version 0.6
-----------------------------------
MP3 ABOLISHED! lol, just switched to ogg, yup, i'm serious.

umm... here we go:

Added:

Ogg.init() initializes ogg player
Ogg.play() plays the loaded ogg
Ogg.pause() pauses loaded ogg
Ogg.stop() stops loaded ogg
Ogg.end() ends loaded ogg
Ogg.load(file) loads file as ogg (relative to current path)
Ogg.freeTune() removes loaded ogg from ram
Ogg.getTimeString() call like this 'oggtime = Ogg.getTimeString()' it returns time of ogg in HH:MM:SS form as a string or do:

screen.print(5,5,Ogg.getTimeString(),green) --sample

Ogg.endOfStream() return true if the ogg is over, false if it isnt
- be2003
blog
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Re: haha '06

Post by Insert_witty_name »

be2003 wrote:done! yay, ok no more mp3 :( but we gained ogg :| whatever i dont care, so ya... still need feedback on all functions...

same link as above...

-----------------------------------
version 0.6
-----------------------------------
MP3 ABOLISHED! lol, just switched to ogg, yup, i'm serious.

umm... here we go:

Added:

Ogg.init() initializes ogg player
Ogg.play() plays the loaded ogg
Ogg.pause() pauses loaded ogg
Ogg.stop() stops loaded ogg
Ogg.end() ends loaded ogg
Ogg.load(file) loads file as ogg (relative to current path)
Ogg.freeTune() removes loaded ogg from ram
Ogg.getTimeString() call like this 'oggtime = Ogg.getTimeString()' it returns time of ogg in HH:MM:SS form as a string or do:

screen.print(5,5,Ogg.getTimeString(),green) --sample

Ogg.endOfStream() return true if the ogg is over, false if it isnt
I think you should test more before you release something mate - just an observation.

The Ogg stuff working?
be2003
Posts: 144
Joined: Thu Apr 20, 2006 2:46 pm

Post by be2003 »

well the problem was(fixed it today) that i had to buy a new usb cable, so icouldn't test it. so i bought one today.
- be2003
blog
User avatar
daurnimator
Posts: 38
Joined: Sun Dec 11, 2005 8:36 pm
Location: melbourne, australia

Post by daurnimator »

why get rid of mp3?

its easily available, and many people already have their music in that format...

maybe you got make a 2nd lrx with just mp3?
User avatar
daurnimator
Posts: 38
Joined: Sun Dec 11, 2005 8:36 pm
Location: melbourne, australia

Post by daurnimator »

hmmm...

zip is corrupt for me :S

edit: no, it just downloaded the no linking html page :S
- i got it to download, but only in IE.

please host somewhere else.....


also, to add onto your zip support, could you make a function that lists the contents of the zip file? - and also maybe being able to extract only certain files at a time?
cools
Posts: 46
Joined: Sat Mar 04, 2006 12:57 pm

Post by cools »

well if you want to add in the ability to set the cpu to whatever you want just use this:

Code: Select all

static int lua_setCpuSpeed(lua_State *L)
{
	if (lua_gettop(L) != 1) return luaL_error(L, "Argument error: System.setCpuSpeed(cpu) takes one arguments.");
	int cpu = luaL_checkint(L, 1);
	if &#40;cpu < 1 || cpu > 333&#41; return luaL_error&#40;L, "invalid speed"&#41;;
	int bus = floor&#40;cpu/2&#41;;
    if &#40;bus == 0&#41; bus = 1;
    scePowerSetClockFrequency&#40;cpu, cpu, bus&#41;;
    return 0;
&#125;
^Its Safe, dont worry!(or so i hope)^

(Not sure if C/C++ is used in libraries)

I hope it helps!

--parts of the code written by youresam (made it safer...)
be2003
Posts: 144
Joined: Thu Apr 20, 2006 2:46 pm

Post by be2003 »

that's great code, i would add it except for the fact that lua is for newbs...

i don't want them to have too much power, changing the speed is cool if u need it but not in this case which could fizzle up your psp by some newb:

Code: Select all


function weeeeeeeee&#40;&#41;
     while true do
          for i=1,333 do
               System.setCpuSpeed&#40;tostring&#40;i&#41;&#41;
               screen&#58;clear&#40;black&#41;
               screen&#58;print&#40;0,0,"weeeeeee&#58;" .. i, white&#41;
               screen.flip&#40;&#41;
          end
          for i=333,1 do
               System.setCpuSpeed&#40;tostring&#40;i&#41;&#41;
               screen&#58;clear&#40;black&#41;
               screen&#58;print&#40;0,0,"weeeeeee&#58;" .. i, white&#41;
               screen.flip&#40;&#41;
          end
     end
end
see, no need for newbies gone wild, giving set speeds is pretty nice.

i could add more speeds if that is the issue...


Low -- being 133 mhz
Reg -- being 233 mhz
Med -- being 266 mhz
High -- being 333 mhz
- be2003
blog
cools
Posts: 46
Joined: Sat Mar 04, 2006 12:57 pm

Post by cools »

ok i understand, but you may still want to add in more speeds
dtodabreezy
Posts: 10
Joined: Wed Jun 21, 2006 5:05 am

Post by dtodabreezy »

is mp3 still in there that would be good for my game
User avatar
daurnimator
Posts: 38
Joined: Sun Dec 11, 2005 8:36 pm
Location: melbourne, australia

Post by daurnimator »

if you are still coding this thing, maybe you could make some oslib functions

- have the good image features like rotating etc ;)
romero126
Posts: 200
Joined: Sat Dec 24, 2005 2:42 pm

Post by romero126 »

maybe just have a faster blitting system.
be2003
Posts: 144
Joined: Thu Apr 20, 2006 2:46 pm

Post by be2003 »

i just dont have time rite now, maybe i will a dd a couple of functions, im gonna change them from static int to int, might be slower, but it will solve tons of issues
- be2003
blog
the underminer
Posts: 123
Joined: Mon Oct 03, 2005 4:25 am
Location: Netherlands

file corrupted

Post by the underminer »

I tried to follow the link in your first post be2003, with the right click thing. Once downloaded the zipfile seemed corrupt. Can you re-share the latest mp3-supporting build for me (would be 0.5 I guess) for I might need it in the future.
thnx
Behold! The Underminer got hold of a PSP
Hoshizora
Posts: 2
Joined: Mon Aug 28, 2006 12:16 am

Post by Hoshizora »

Yes, can you repost v0.5 or reimplement the mp3 functions in your next release please? Thanks! :)
matriculated
Posts: 31
Joined: Sat Mar 04, 2006 1:35 am

Post by matriculated »

Please re-host! Or can some else upload this file?
sou1
Posts: 3
Joined: Fri Sep 02, 2005 4:16 am

multiple play support

Post by sou1 »

sorry about my english.

hi be2003, thanks for this cool extension.
can you change the function of ogg player?
i wish multiple play support(look like sound function).
razorrifh
Posts: 23
Joined: Sat Jun 04, 2005 2:15 am
Location: Penn State
Contact:

Post by razorrifh »

matriculated wrote:Please re-host! Or can some else upload this file?
it worked for me but heres a mirror of version 0.6 http://hackersgonewild.com/sysext.zip

for reference:
Sysext by be2003 for Luaplayer

To use this put the sysext.lrx file in your luaplayer folder and call this from your script:

sysext = loadlib("sysext","init")
if sysext then sysext() end

thanks to John_K's for source from PSPMediaCenter,

-----------------------------------
version 0.1
-----------------------------------
Added Sysext.Quit() which will exit Lua Player back to the PSP browser
Added Sysext.isUmdInserted() and will return true if a UMD is inserted
Added Sysext.initUMD() which will mount the UMD to disk0: (it will not launch it)
Added Sysext.setCpuSpeedHigh()
Added Sysext.setCpuSpeedMed()
Added Sysext.setCpuSpeedReg()
which changes the CPU speed to 333 MHz, 266 MHz, and 222 MHz respectively.

-----------------------------------
version 0.2
-----------------------------------
Added Sysext.getCpuSpeed() which returns the current Cpu speed (333,266,222)
Added Sysext.loadModule(path) set the path of a prx module to load it (alpha, may not work)

-----------------------------------
version 0.3
-----------------------------------
Added Mp3 support :) kinda, all from psp media center --- thanks, all functions but one, MP3.GetTimeString(), i didn't know what it was for...
Includes MP3.Init() initializes the mp3 player
Includes MP3.Play() plays the loaded mp3
Includes MP3.Pause() pauses the playing mp3
Includes MP3.Stop() stops the loaded mp3
Includes MP3.End() ends the loaded mp3 (stops it and unloads it from ram)
Includes MP3.FreeTune() clears the ram of the loaded mp3
Includes MP3.Load(file) loads an mp3 as file
Includes MP3.EndOfStream() return true if the mp3 has ended and false if it didn't, duh

-----------------------------------
version 0.4
-----------------------------------
Changed the mp3 api... hre it is:
Includes MP3.Play(file) initializes psp audio loads the file and plays it
Includes MP3.Pause() pauses the playing mp3
Includes MP3.Stop() stops the mp3 unloads it from memory and terminates psp audio
Includes MP3.EndOfStream() return true if the mp3 has ended and false if it didn't, duh

and ...

Added Sysext.loadExec(path) to load an elf executable at path. must be the whole path, eg. "ms0:/psp/game/lua/testprxandelf/testelf.elf"
*Fixed Sysext.getCpuSpeed() which was broken for some reason...

-----------------------------------
version 0.4b
-----------------------------------
Changed all Sysext.whatever() to System.whatever() and MP3.whatever() to Mp3.whatever()
so call System.Quit() etc.
Attempted to fix the mp3 call again to make it work, remember folks this is my first ever compiled by me thing... lol have fuun

-----------------------------------
version 0.4c
-----------------------------------
Took out System.loadModule(path) because it sucked at life, eg. Luaplayer didn't want anything to do with it so i decided loadExec was enough.

edit: fixed mp3player, it was that i forgot to put define mp3player.o in the makefile lol...

now the api looks like this:

Mp3.init() initializes mp3 player
Mp3.play() plays the loaded mp3
Mp3.pause() pauses loaded mp3
Mp3.stop() stops loaded mp3
Mp3.end() ends loaded mp3
Mp3.load(file) loads file as mp3
Mp3.freeTune() removes loaded mp3 from ram
Mp3.endOfStream() return true if the mp3 is over, false if it isnt

make sure to call Mp3.init() before loading and playing mp3's and call Mp3.End() when you are finished.

-----------------------------------
version 0.5
-----------------------------------
ZIP ZIP ZIP !!!ALPHA!!!
NOT SURE IF MULTIPLE FILE ZIPS WORK...

Added Zip.compress(file, zipout) compress file into zipout, they are both files so they expect a relevant path
Added Zip.extract(zipin, filesout) uncompress zipin into filesout, they are both files so they expect a relevant path

-----------------------------------
version 0.6
-----------------------------------
MP3 ABOLISHED! lol, just switched to ogg, yup, i'm serious.

umm... here we go:

Added:

Ogg.init() initializes ogg player
Ogg.play() plays the loaded ogg
Ogg.pause() pauses loaded ogg
Ogg.stop() stops loaded ogg
Ogg.end() ends loaded ogg
Ogg.load(file) loads file as ogg (relative to current path)
Ogg.freeTune() removes loaded ogg from ram
Ogg.getTimeString() call like this 'oggtime = Ogg.getTimeString()' it returns time of ogg in HH:MM:SS form as a string or do:

screen.print(5,5,Ogg.getTimeString(),green) --sample

Ogg.endOfStream() return true if the ogg is over, false if it isnt
Post Reply