Lua Player for PSP
Moderators: Shine, Insert_witty_name
-
- Posts: 13
- Joined: Wed Aug 03, 2005 9:48 pm
I was able to reproduce the warning message with Lua Player 0.5 and with Lua Player 0.6 it works, even with the images which causes a warning, because version 0.6 ignores the warnings.SnowSurfer wrote:ok i got it to work, it was the button pictures from the button match program, i made my own buttons and low and behold it works fine..
i put the bad pictures in a handy zip for you to look at
http://www.members.cox.net/snowsurfns/Buttons.zip
-
- Posts: 23
- Joined: Thu Jul 07, 2005 3:56 pm
-
- Posts: 21
- Joined: Fri Jul 08, 2005 2:59 am
waitVblankStart has an optional parameter and since the VSync frequency on PSP is 60 Hz, you can use waitVblankStart(60) for 1 second delay.SnowSurfer wrote:how do i get a timer to work so it counts down 60seconds on an interval of 1 second at a time?
the code im using just counts down really really really fast..
any ideas? thanks again :)
I know, it should be better documented, but someone wrote me, that he is already working at a small tutorial and I'll setup a dedicated domain with forum etc. for Lua Player, when I have some time (I want to use it for my own games on PC, too).
Where does it say that? You can do it manually, however, by breaking out of your main loop like so:27Bstroke6 wrote:The Lowser doc specifies that pressing START should exit from the current running script. This doesn't seem to work for me (using Lowser 0.5). Any clues? Thanks.
Code: Select all
while true do
... (your app code)
if isCtrlStart(pad) then-- assumes that you have done pad = ctrlRead()
break
end
end
From the documentation:SnowSurfer wrote:how do i get a timer to work so it counts down 60seconds on an interval of 1 second at a time?
the code im using just counts down really really really fast..
any ideas? thanks again :)
Documentation wrote:void waitVblankStart([int count])
Wait for next Vblank start. If you specify a count parameter, it waits multiple times for Vblank start. This can be used for delays, for example 60 for a one seconds delay.
Great work Shine on the Lua player :)
I started to toy around with it, even if documentation on lua.org website is really bad.
Development is easy, but one looses too much time sending to psp / testing / reconnecting psp resending...
I ended up testing bits of my code on weblua (http://doris.sourceforge.net/lua/weblua.php) in order to have a quick small debuger.
I wondered, and i saw it has been asked already, if you would include a rotation feature for png ? Like the Flash one, object._rotation = angle. A handy feature ...
I'll port i guess one of my Flash games to Lua. I talked a bit with VgSlag, and it seems that Lua for the PSP is kinda the "Flash" of the psp, in many aspects. Lua is fast enough on the PSP to let us do virtually any 2D games.
Keep up the good work !
I started to toy around with it, even if documentation on lua.org website is really bad.
Development is easy, but one looses too much time sending to psp / testing / reconnecting psp resending...
I ended up testing bits of my code on weblua (http://doris.sourceforge.net/lua/weblua.php) in order to have a quick small debuger.
I wondered, and i saw it has been asked already, if you would include a rotation feature for png ? Like the Flash one, object._rotation = angle. A handy feature ...
I'll port i guess one of my Flash games to Lua. I talked a bit with VgSlag, and it seems that Lua for the PSP is kinda the "Flash" of the psp, in many aspects. Lua is fast enough on the PSP to let us do virtually any 2D games.
Keep up the good work !
Sound and music
I've ported Jim Shaw's port of mikmod for use with LuaPlayer. With this, any mod file (xm, s3m, mod, mad, ...) can be played as background music, and any wav file can be played as a sound effect (with stereo panning, changeable frequency and volume).
There's a major bug in it now though, that disables the playing of wav files. If you want to try out just the music part, or if you want to help with the bug, here's the modified luaplayer code (with compiled eboot):
http://ncoder.nevyn.nu/psp/LuaPlayer_mikmod_TEST.zip
Bug description in KNOWN-BUGS. If you want to compile, read "README.linking-with-mikmod". If you want to hear a good tune, install luaplayer and luaplayer% on your psp and launch Music Test from Lowser.
There's a major bug in it now though, that disables the playing of wav files. If you want to try out just the music part, or if you want to help with the bug, here's the modified luaplayer code (with compiled eboot):
http://ncoder.nevyn.nu/psp/LuaPlayer_mikmod_TEST.zip
Bug description in KNOWN-BUGS. If you want to compile, read "README.linking-with-mikmod". If you want to hear a good tune, install luaplayer and luaplayer% on your psp and launch Music Test from Lowser.
Re: Sound and music
Cool! I went and set the Pyramid Panic demo to some music :)nevyn wrote:I've ported Jim Shaw's port of mikmod for use with LuaPlayer. With this, any mod file (xm, s3m, mod, mad, ...) can be played as background music, and any wav file can be played as a sound effect (with stereo panning, changeable frequency and volume).
There's a major bug in it now though, that disables the playing of wav files.
I think I see the problem of the sound bug. When Shine set up his image handles, he didn't use the value of the pointer as his handle - instead he wrapped the image in an array of 'Image' structs and used the index of the array as his handle. Try setting up something similar for sounds and see what happens.
-
- Posts: 21
- Joined: Fri Jul 08, 2005 2:59 am
hmm im trying to put a counter on my game so it starts at 60 seconds and when it goes down to zero the game is over.
heres what i have so far (at least i think this is how it should work)
heres what i have so far (at least i think this is how it should work)
any ideas?timerout=0 (this is for the display on the screen to show how much time is left)
timer=60 (main timer)
while timerout != 0 (not sure how to write not equals)
void waitVblankStart(timer)
timerout=timer-1
printText(100, 50, "Timer: " .. timerout, red)
waitVblankStart()
flipScreen()
Snow:
Relational expressions
Relational operators are supplied which return the boolean values true or false.
== equal to
~= not equal to
< less than
> greater than
<= less than or equal to
>= greater than or equal to
This came from:
http://lua-users.org/wiki/ExpressionsTutorial
Kins:
Cool, I've already got some sound fx and eery music that a friend made for me for the Flash version of Pyramid Panic.
Shine:
Will nevyn's port of milkmod get put into the offical player?
Relational expressions
Relational operators are supplied which return the boolean values true or false.
== equal to
~= not equal to
< less than
> greater than
<= less than or equal to
>= greater than or equal to
This came from:
http://lua-users.org/wiki/ExpressionsTutorial
Kins:
Cool, I've already got some sound fx and eery music that a friend made for me for the Flash version of Pyramid Panic.
Shine:
Will nevyn's port of milkmod get put into the offical player?
Last edited by VgSlag on Thu Aug 04, 2005 8:09 am, edited 1 time in total.
Sorry, my mistake, will edit the original;
Snow:
Snow:
Code: Select all
timerout=0
timer=60
red = getColorNumber(255, 0, 0)
while timerout < 60 do
waitVblankStart(60)
timerout=timerout+1
clear(0);
printText(100, 50, "Timer: " .. timerout, red)
flipScreen()
end
Re: Sound and music
They're both numbers. I don't see what the difference is. Anyhow, I tried it at least, but it doesn't work. soundfile is /still/ being reported as a nil value. I just don't get it.Kinsman wrote:Cool! I went and set the Pyramid Panic demo to some music :)nevyn wrote:I've ported Jim Shaw's port of mikmod for use with LuaPlayer. With this, any mod file (xm, s3m, mod, mad, ...) can be played as background music, and any wav file can be played as a sound effect (with stereo panning, changeable frequency and volume).
There's a major bug in it now though, that disables the playing of wav files.
I think I see the problem of the sound bug. When Shine set up his image handles, he didn't use the value of the pointer as his handle - instead he wrapped the image in an array of 'Image' structs and used the index of the array as his handle. Try setting up something similar for sounds and see what happens.
The sound is definitely loaded, I can see the ms light flash for a second, and no errors are reported from anywhere. Lua keeps getting a nil value even though I'm explicitly pushing a number.
Now that I think about it though, I have never... Oh holy CRAP what a stupid mistake. Perhaps if I read the manual now and then...
You have to return the number of arguments that you have pushed as the function return value. D'OH! I thought that stuff was automatic. Now that's working. I have to fix some new bugs, then it's ready to go.
-
- Posts: 21
- Joined: Fri Jul 08, 2005 2:59 am
thanks vg, i got the timer to work i just need to be able to get everything else to show up on the screen at the same time...
what exactly is a vblank start? could someone explain it to me, like can it run in the background when other program functions are running?
the timer will run in its own function but when i start the function in my main program code or in my intialization code it wont go to the program until after the amount of time. i wanted the timer to be able to be used as a timer for the game. ill play with it some more. i also tried to write the main function as
while timerout > 0 do
(main program code)
waitVblankStart(60)
end
what exactly is a vblank start? could someone explain it to me, like can it run in the background when other program functions are running?
the timer will run in its own function but when i start the function in my main program code or in my intialization code it wont go to the program until after the amount of time. i wanted the timer to be able to be used as a timer for the game. ill play with it some more. i also tried to write the main function as
while timerout > 0 do
(main program code)
waitVblankStart(60)
end
LuaPlayer with Mikmod done!
Hooray! It works! Music, sounds, panning, frequencies, everything :)
Check out the package:
http://ncoder.nevyn.nu/psp/LuaPlayer_mikmod.zip
Binary "nice" package:
http://ncoder.nevyn.nu/Lowser/Lowser_bundle_0.12.zip
Interface:
Example in luaplayer/Applications/Music Test/index.lua
Check out the package:
http://ncoder.nevyn.nu/psp/LuaPlayer_mikmod.zip
Binary "nice" package:
http://ncoder.nevyn.nu/Lowser/Lowser_bundle_0.12.zip
Interface:
Code: Select all
loadAndPlayMusicFile(filename, bool loop)
stopAndUnloadMusic()
Sound loadSound(filename) - ONLY MONO, stereo will crash your PSP
unloadSound(sound)
Voice playSound(sound)
stopSound(voice)
setVoiceVolume(voice) - 0-255
setVoicePanning(voice) - 0-255, 128 is center
setVoiceFrequency(voice), 0-44000
bool musicIsPlaying()
bool voiceIsPlaying(voice)
Re: LuaPlayer with Mikmod done!
So far, so good. I added Mario jumping noises to the Pyramid Panic demo :)nevyn wrote:Hooray! It works! Music, sounds, panning, frequencies, everything :)
The sound is playing awfully quietly. I don't think it's a library problem, since you're using a sample-playing function, and the background music is drowning out the sound effects.
When you play the sound effect, I see you're setting the panning straight away - would setting the volume straight away have an effect?
Also, where can I find a copy of the mikmod library? I can't seem to find it in PSPSDK, or in the toolchain.
Re: LuaPlayer with Mikmod done!
Hmm. In my Music Test, I set the volume to 255 when I start the sample. You're right, that sample is playing pretty quietly... I could provide a function to lower the music volume. Yeah, I think I'll add that... Check back in an hour.Kinsman wrote:So far, so good. I added Mario jumping noises to the Pyramid Panic demo :)nevyn wrote:Hooray! It works! Music, sounds, panning, frequencies, everything :)
The sound is playing awfully quietly. I don't think it's a library problem, since you're using a sample-playing function, and the background music is drowning out the sound effects.
When you play the sound effect, I see you're setting the panning straight away - would setting the volume straight away have an effect?
Also, where can I find a copy of the mikmod library? I can't seem to find it in PSPSDK, or in the toolchain.
As for the mikmod library, see
http://forums.ps2dev.org/viewtopic.php?t=2540
and
http://ncoder.nevyn.nu/psp/mikmodlib.zip (ugly repack)
Re: LuaPlayer with Mikmod done!
I'm about to head for bed, but I hunted through the mikmod source code and found something in mdriver.c, lines 26-28:
Maybe you can fiddle with the global variables - turn up the master volume a bit, then turn down the music volume until it sounds about right compared to the sound effects.
I expected to see md_musicvolume turned up much higher than md_sndfxvolume based on the behaviour I was seeing, but oh well.
I don't think it'd be good to have the sound quiet all around - players would have to turn their PSP volume up to hear a Lua game, then turn it down again when moving to something else..
Code: Select all
UBYTE md_volume = 96; /* Global sound volume (0-128) */
UBYTE md_musicvolume = 128; /* volume of song */
UBYTE md_sndfxvolume = 128; /* volume of sound effects */
I expected to see md_musicvolume turned up much higher than md_sndfxvolume based on the behaviour I was seeing, but oh well.
I don't think it'd be good to have the sound quiet all around - players would have to turn their PSP volume up to hear a Lua game, then turn it down again when moving to something else..
Re: LuaPlayer with Mikmod done!
One step ahead of you ;)Kinsman wrote:I'm about to head for bed, but I hunted through the mikmod source code and found something in mdriver.c, lines 26-28:
Maybe you can fiddle with the global variables - turn up the master volume a bit, then turn down the music volume until it sounds about right compared to the sound effects.Code: Select all
UBYTE md_volume = 96; /* Global sound volume (0-128) */ UBYTE md_musicvolume = 128; /* volume of song */ UBYTE md_sndfxvolume = 128; /* volume of sound effects */
I expected to see md_musicvolume turned up much higher than md_sndfxvolume based on the behaviour I was seeing, but oh well.
I don't think it'd be good to have the sound quiet all around - players would have to turn their PSP volume up to hear a Lua game, then turn it down again when moving to something else..
http://ncoder.nevyn.nu/psp/LuaPlayer_mikmod.zip
http://ncoder.nevyn.nu/lowser/Lowser_bundle_0.12.zip
Both are updated with the following lua functions:
setMusicVolume(arg) -- 0-128
setSFXVolume(arg) -- 0-128
setReverb(arg) -- 0-15 ( 0 = no reverb)
setPanSep(arg) -- 0-128 ( 0 = mono, 128 = full separation)
I have also changed the initial volume values:
md_volume = 128;
md_musicvolume = 96;
md_sndfxvolume = 128;
Re: LuaPlayer with Mikmod done!
Tried it out - got an error; 'tried to reference setGlobalVolume (a nil value)'.
Not sure what it could be, and don't have time at the moment to check..
Not sure what it could be, and don't have time at the moment to check..
Re: LuaPlayer with Mikmod done!
There is no such function, "setGlobalVolume"... Only setMusicVolume and setSFXVolume. I don't see the reason for setting the mikmod global volume programatically; there's the psp global volume that the user can adjust him/herself.Kinsman wrote:Tried it out - got an error; 'tried to reference setGlobalVolume (a nil value)'.
Not sure what it could be, and don't have time at the moment to check..
-
- Posts: 21
- Joined: Fri Jul 08, 2005 2:59 am
is there anyway that i can have two different functions running at the same time such as my timer needs to be running (and counting down) while the game is being played..
if i put it in a new function and call it, the game wont show up.
if i put it in the main game code it will just hang on the timer until the time is up.
if i put it in a new function and call it, the game wont show up.
if i put it in the main game code it will just hang on the timer until the time is up.
nevyn, that's brilliant news!
I bought some sounds for the phone version of my game and my friend that does music made me some.
I'm going to source or make a jumping sound and add some rooms over the weekend. Will up a new version on Sunday.
Will all functionality remain the same when it gets added to the official version?
I bought some sounds for the phone version of my game and my friend that does music made me some.
I'm going to source or make a jumping sound and add some rooms over the weekend. Will up a new version on Sunday.
Will all functionality remain the same when it gets added to the official version?
SnowSurfer wrote:is there anyway that i can have two different functions running at the same time such as my timer needs to be running (and counting down) while the game is being played..
if i put it in a new function and call it, the game wont show up.
if i put it in the main game code it will just hang on the timer until the time is up.
There are two ways of doing stuff simultaneously. Either you do it little-by-little in the main loop, or you thread it. The first one is way simpler.
Code: Select all
timeout = 0
while timeout < (60 * 60) do -- 60 seconds times framerate
timeout = timeout + 1
clear(0)
printText(100,50,"Timer: ".. 60 - timeout/60, red)
[ anything else your app would want to do in this frame ]
waitVblankStart()
flipScreen()
end
Looking forward to the new version of your game!VgSlag wrote:nevyn, that's brilliant news!
I bought some sounds for the phone version of my game and my friend that does music made me some.
I'm going to source or make a jumping sound and add some rooms over the weekend. Will up a new version on Sunday.
Will all functionality remain the same when it gets added to the official version?
I think the interface is all okay, I don't know what Shine thinks of it though. If I were to add it now it'd be identical, except for one thing: the freeSound() doesn't belong in lua since it's a garbage collected environment and shouldn't be needed. I'll have to read up on garbage collection to fix that, though... For now, just never mind freeSound() and be content that theoretically, your sound will be automatically freed sometime.
-
- Posts: 21
- Joined: Fri Jul 08, 2005 2:59 am
nevyn im reading about coroutines in the wiki right now
it is...interesting to say the least
http://lua-users.org/wiki/CoroutinesTutorial
i am going to try what you said when i get home from breakfast, thanks for the help.
edit: yeahhhhhhhhhh! it works, thanks nevyn :)
it is...interesting to say the least
http://lua-users.org/wiki/CoroutinesTutorial
i am going to try what you said when i get home from breakfast, thanks for the help.
edit: yeahhhhhhhhhh! it works, thanks nevyn :)