 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
emumaniac
Joined: 08 May 2005 Posts: 79
|
Posted: Fri Aug 05, 2005 2:37 am Post subject: |
|
|
| bloody hell some great work guys, im gonna have quite a time posting all these new releases, is there a Lua base site with the releases on i can link to instead of the forum thread ? |
|
| Back to top |
|
 |
nevyn
Joined: 31 Jul 2005 Posts: 136 Location: Sweden
|
Posted: Fri Aug 05, 2005 2:44 am Post subject: |
|
|
edit: Oops. I pasted into the wrong window.
edit again: Aw crap, I pasted over the message I had already written here.
Egh. I had written that me and Shine concluded that keeping backwards-compatibility with the API isn't that important this early in the project, so we'll simply change the API. I'll get back to this subject later today... |
|
| Back to top |
|
 |
Kinsman
Joined: 18 Jul 2005 Posts: 15 Location: Canada
|
Posted: Fri Aug 05, 2005 6:42 am Post subject: |
|
|
Sorry about getting that 'setGlobalVolume' wrong, I mistyped.
The problem was actually with 'setMusicVolume', but it's probably because you forgot to release an updated EBOOT.PBP with the code or something. |
|
| Back to top |
|
 |
nevyn
Joined: 31 Jul 2005 Posts: 136 Location: Sweden
|
Posted: Fri Aug 05, 2005 7:44 am Post subject: |
|
|
| Kinsman wrote: | | The problem was actually with 'setMusicVolume', but it's probably because you forgot to release an updated EBOOT.PBP with the code or something. |
I did? Aw crap. Oh well. There'll be a new api by next version anyway...
Example with the new sound API, should be self-explainatory:
| Code: | Music.volume(96)
SoundSystem.SFXVolume(128) -- max
SoundSystem.reverb(4) -- out of 15
SoundSystem.panoramicSeparation(128) -- 0 is mono
Music.playFile("music.xm")
while Music.playing() do
print("A music file is playing.")
end
Music.playFile("music.xm", true) -- loops forever
local sndExplosion = Sound.load("explosion.wav")
voice = sndExplosion:play()
voice:volume(255) -- max volume
voice:frequency(11000) -- play at half speed
voice:pan(0) -- pan all the way to the left
while voice:playing() do
i = i + 1
voice:pan(i)
waitVblankStart(5)
end
-- note that the voice has stopped playing now, and is invalid.
voice = sndExplosion:play()
voice:stop()
Music.stop()
|
Edit: Changed some calls to oo-style
Last edited by nevyn on Sun Aug 07, 2005 12:03 am; edited 1 time in total |
|
| Back to top |
|
 |
VgSlag
Joined: 30 Jun 2005 Posts: 43
|
Posted: Sat Aug 06, 2005 10:28 pm Post subject: |
|
|
| Is there a version with all the new functions in yet? |
|
| Back to top |
|
 |
nevyn
Joined: 31 Jul 2005 Posts: 136 Location: Sweden
|
Posted: Sun Aug 07, 2005 12:00 am Post subject: |
|
|
| VgSlag wrote: | | Is there a version with all the new functions in yet? |
It's available at svn so you can compile it yourself, but I don't think there'll be a binary release until the graphics API has been fixed too... |
|
| Back to top |
|
 |
VgSlag
Joined: 30 Jun 2005 Posts: 43
|
Posted: Mon Aug 08, 2005 2:27 am Post subject: |
|
|
Is anyone seeing an odd image bug when moving an image off the left hand side of the screen?
I haven't tested any other scenarios but what I have is my BG being blitted to screen then blitting and alpha image (16 * 16) on top.
When the character moves off the left hand side of the screen the image appears to stop moving but the right hand side starts cutting off like it is moving off screen jsut not updating the image.
The only file I have to show this is my "Pyramid Panic" game, but it's in the middle of being worked on, so if you do look at it in this file you may get crashes or unexpected results.
To see it move right, and slowly onto the next screen. If you were slow enough then you'll see the character is half missing.
Move right then slowly move left onto the first screen again, you'll see it there.
Any ideas? Can this be fixed?
My game is here:
http://www.flash-git.net/pyramidPanic.rar |
|
| Back to top |
|
 |
Soban
Joined: 06 Aug 2005 Posts: 14
|
Posted: Mon Aug 08, 2005 3:56 am Post subject: |
|
|
OK. I have the latest svn of everything - luaplayer, zlib, libpng, mikmodlib, and lua. But when I try to make luaplayer it gives me all sorts of errors in liblualib.a:
| Code: | <somefile.c>:(.text+<some offset>): relocation truncated to fit: R_MIPS_GPREL16 against '_i
mpure_ptr' |
|
|
| Back to top |
|
 |
Shine
Joined: 03 Dec 2004 Posts: 728 Location: Germany
|
Posted: Mon Aug 08, 2005 4:29 am Post subject: |
|
|
| Soban wrote: | OK. I have the latest svn of everything - luaplayer, zlib, libpng, mikmodlib, and lua. But when I try to make luaplayer it gives me all sorts of errors in liblualib.a:
|
You need the latest psp toolchain from SVN. Checkout psptoolchain and update your environment with the toochain.sh shell script. The current Lua Player from SVN works for me, but it is not ready for release, so be patient. |
|
| Back to top |
|
 |
Soban
Joined: 06 Aug 2005 Posts: 14
|
Posted: Mon Aug 08, 2005 4:33 am Post subject: |
|
|
| OK. I'll try updating my toolchain. |
|
| Back to top |
|
 |
Kinsman
Joined: 18 Jul 2005 Posts: 15 Location: Canada
|
Posted: Mon Aug 08, 2005 8:14 am Post subject: |
|
|
| VgSlag wrote: | Is anyone seeing an odd image bug when moving an image off the left hand side of the screen?
I haven't tested any other scenarios but what I have is my BG being blitted to screen then blitting and alpha image (16 * 16) on top.
When the character moves off the left hand side of the screen the image appears to stop moving but the right hand side starts cutting off like it is moving off screen jsut not updating the image.
The only file I have to show this is my "Pyramid Panic" game, but it's in the middle of being worked on, so if you do look at it in this file you may get crashes or unexpected results.
To see it move right, and slowly onto the next screen. If you were slow enough then you'll see the character is half missing.
Move right then slowly move left onto the first screen again, you'll see it there.
Any ideas? Can this be fixed?
|
Haven't checked the game, but I ran into a similar-sounding issue on my own project. You can't just say you want to draw an image at, for example, (-10,30), and expect it to work, since the Lua Player goes through a bitmap adjusting step where it does bound checking on what it's going to draw. Try using blitAlphaImageRect() for the chases that your images are going to go off-screen, and clip it yourself. |
|
| Back to top |
|
 |
Kinsman
Joined: 18 Jul 2005 Posts: 15 Location: Canada
|
Posted: Mon Aug 08, 2005 8:16 am Post subject: |
|
|
Looks like posts picked up again after a rest of a day or so :)
Here's a screenshot of what I'm working on: a 'digital novel' engine, and an engine that could be used for any console-style text game - or a text game mixed with inline graphics.
Ignore the mediocre script and art :) I just made up something off the cuff..
 |
|
| Back to top |
|
 |
Shine
Joined: 03 Dec 2004 Posts: 728 Location: Germany
|
Posted: Mon Aug 08, 2005 9:42 am Post subject: |
|
|
| Kinsman wrote: | | Haven't checked the game, but I ran into a similar-sounding issue on my own project. You can't just say you want to draw an image at, for example, (-10,30), and expect it to work, since the Lua Player goes through a bitmap adjusting step where it does bound checking on what it's going to draw. Try using blitAlphaImageRect() for the chases that your images are going to go off-screen, and clip it yourself. |
I've fixed the bug, I hope now everything is ok, perhaps someone can verify, if it is correct for every boundary case:
| Code: |
// returns 0, if nothing to blit
static int adjustBlitRectangle(
int sourceWidth, int sourceHeight,
int destinationWidth, int destinationHeight,
int* sx, int* sy,
int* width, int* height,
int* dx, int* dy)
{
if (*width <= 0 || *height <= 0) return 0; // zero area, nothing to blit
if (*sx < 0 || *sy < 0) return 0; // illegal, source is not clipped
if (*dx < 0) {
*width += *dx;
if (*width <= 0) return 0;
*sx -= *dx;
*dx = 0;
if (*sx >= destinationWidth) return 0;
}
if (*dy < 0) {
*height += *dy;
if (*height <= 0) return 0;
*sy -= *dy;
*dy = 0;
if (*sy >= destinationHeight) return 0;
}
if (*dx + *width > destinationWidth) {
*width = destinationWidth - *dx;
if (*width <= 0) return 0;
}
if (*dy + *height > destinationHeight) {
*height = destinationHeight - *dy;
if (*height <= 0) return 0;
}
return 1;
}
|
@nevyn: please change it in the upcoming luagraphics.c.
I've tested it with a small program, where you can move a mandelbrot fractal, which is calculated by the program:
| Code: |
-- create mandelbrot fractal
w = 50
h = 50
image = createImage(w, h)
for x=0,w-1 do
for y=0,h-1 do
r = 0; n = 0; b = x / w * 3 - 2; e = y / h * 2 - 1; i = 31
while i > 0 and r * r < 4 do
d = r; r = r * r - n * n + b; n = 2 * d * n + e; i = i - 1
end
color = math.mod(i * 43, 32)
putPixel(color * 1024 + color * 32, x, y, image)
end
end
-- move
x = 200
y = 100
while true do
pad = ctrlRead()
if isCtrlUp(pad) then
y = y - 3
elseif isCtrlDown(pad) then
y = y + 3
elseif isCtrlLeft(pad) then
x = x - 3
elseif isCtrlRight(pad) then
x = x + 3
end
clear(0)
blitImage(x, y, image)
waitVblankStart()
flipScreen()
end
|
|
|
| Back to top |
|
 |
Soban
Joined: 06 Aug 2005 Posts: 14
|
Posted: Mon Aug 08, 2005 11:33 am Post subject: |
|
|
I just ran the toolchain and recompiled lua itself, and now luaplayer compiles fine. I have no idea what changed... svn didn't do anything to lua when I ran it and I just ran the toolchain friday, but whatever... For some reason it decided to work now...
Anyway, I'm starting a text editor in lua and c specifically for editing lua scripts. I suppose you could call it a lua IDE. Right now the only special features I'm planning to add are a second virtual keyboard for lua commands and auto-indenting and coloring of functions, vars, reserved words, etc. but if anyone has any suggestions, I'm open.
I probably won't get much done on it this week with family over from cali and work and all, but I'll be working hard on it next week. |
|
| Back to top |
|
 |
nevyn
Joined: 31 Jul 2005 Posts: 136 Location: Sweden
|
Posted: Mon Aug 08, 2005 6:41 pm Post subject: |
|
|
| Soban wrote: | I just ran the toolchain and recompiled lua itself, and now luaplayer compiles fine. I have no idea what changed... svn didn't do anything to lua when I ran it and I just ran the toolchain friday, but whatever... For some reason it decided to work now...
Anyway, I'm starting a text editor in lua and c specifically for editing lua scripts. I suppose you could call it a lua IDE. Right now the only special features I'm planning to add are a second virtual keyboard for lua commands and auto-indenting and coloring of functions, vars, reserved words, etc. but if anyone has any suggestions, I'm open.
I probably won't get much done on it this week with family over from cali and work and all, but I'll be working hard on it next week. |
"lua and c"? Why not just lua?
I'm planning on writing an event-driven application framework for Lua after LuaPlayer 0.7 is done. That should probably make application writing very much easier. (it will probably take some time though...) (I'll be designing it to resemble the Cocoa framework) |
|
| Back to top |
|
 |
VgSlag
Joined: 30 Jun 2005 Posts: 43
|
Posted: Mon Aug 08, 2005 6:47 pm Post subject: |
|
|
| Shine wrote: |
I've fixed the bug, I hope now everything is ok, perhaps someone can verify, if it is correct for every boundary case:
|
Thanks Shine, I'll check the latest compiled version with my game and see if it's fixed. |
|
| Back to top |
|
 |
nevyn
Joined: 31 Jul 2005 Posts: 136 Location: Sweden
|
Posted: Mon Aug 08, 2005 6:49 pm Post subject: |
|
|
| VgSlag wrote: | | Shine wrote: |
I've fixed the bug, I hope now everything is ok, perhaps someone can verify, if it is correct for every boundary case:
|
Thanks Shine, I'll check the latest compiled version with my game and see if it's fixed. |
It's not in svn yet, I'm still working hard on the new API... I'm getting there, give me one more day... |
|
| Back to top |
|
 |
Soban
Joined: 06 Aug 2005 Posts: 14
|
Posted: Tue Aug 09, 2005 3:34 am Post subject: |
|
|
| nevyn wrote: | | "lua and c"? Why not just lua? |
Because I've barely done any programming on the PSP and I want to mess with it :D . |
|
| Back to top |
|
 |
nevyn
Joined: 31 Jul 2005 Posts: 136 Location: Sweden
|
Posted: Tue Aug 09, 2005 3:40 am Post subject: |
|
|
| Soban wrote: | | nevyn wrote: | | "lua and c"? Why not just lua? |
Because I've barely done any programming on the PSP and I want to mess with it :D . |
Point ;)
The problem is, you can't bundle c with lua, so it would need a custom build of luaplayer...
otoh, if you write useful reusable code, it could of course be merged with the real luaplayer sources :) |
|
| Back to top |
|
 |
Soban
Joined: 06 Aug 2005 Posts: 14
|
Posted: Tue Aug 09, 2005 3:47 am Post subject: |
|
|
The body of the program would be in lua, all that would be added in the C source is a few functions in C, some globals, and a few lua_register()s.
So yeah, I'll try to write something useful :) . |
|
| Back to top |
|
 |
MikeHaggar
Joined: 18 Jul 2005 Posts: 116
|
Posted: Tue Aug 09, 2005 6:50 am Post subject: |
|
|
Well... Here's my page with Dr. Mario coded in Lua:
http://haggar.pocketheaven.com/
Prolly some of the worst code you'll ever see though ;) |
|
| Back to top |
|
 |
nevyn
Joined: 31 Jul 2005 Posts: 136 Location: Sweden
|
Posted: Tue Aug 09, 2005 7:09 am Post subject: |
|
|
| MikeHaggar wrote: | Well... Here's my page with Dr. Mario coded in Lua:
http://haggar.pocketheaven.com/
Prolly some of the worst code you'll ever see though ;) |
Ohyeah! Excellent job! How long did it take to write?
Oh, as long as it works it doesn't matter what the code lo-- holy /crap/! One thousand lines of Lua? That's... That's... You were right, that code ain't too pretty :P I'm impressed that you got it working! (that's actually a compliment :P) |
|
| Back to top |
|
 |
MikeHaggar
Joined: 18 Jul 2005 Posts: 116
|
Posted: Tue Aug 09, 2005 7:49 am Post subject: |
|
|
| Took me 3 days to write... started this saturday and finished today (monday) |
|
| Back to top |
|
 |
Shine
Joined: 03 Dec 2004 Posts: 728 Location: Germany
|
Posted: Tue Aug 09, 2005 8:10 am Post subject: |
|
|
| MikeHaggar wrote: | Well... Here's my page with Dr. Mario coded in Lua:
http://haggar.pocketheaven.com/
Prolly some of the worst code you'll ever see though ;) |
Nice game. The code is not so bad, but you can shorten it a bit, for example if you use a table for indexing the image for drawing with drawPillTile, so you don't need the long if-elseif-end statement any more. And you could use some more verbose names instead of just indexes (in Lua you can index the tables, like you've done with the red/yellow/blue tables). Nested tables and prototype based classes are possible, too.
And you should use the screenshot function instead of a digital camera, but you can use the picture below.
 |
|
| Back to top |
|
 |
MikeHaggar
Joined: 18 Jul 2005 Posts: 116
|
Posted: Tue Aug 09, 2005 8:14 am Post subject: |
|
|
| Shine wrote: | | The code is not so bad, but you can shorten it a bit, for example if you use a table for indexing the image for drawing with drawPillTile, so you don't need the long if-elseif-end statement any more. |
for the stuff in the drawFullPill() function you mean, or the stuff in drawMap()?
Whoops! Forgot all about the screenshot function. I'll use your pic instead of my crappy digicam ones ;)
I'll fix that other pic tomorrow... Time for sleep... 00:30 here now... |
|
| Back to top |
|
 |
LiquidIce
Joined: 04 Apr 2005 Posts: 55
|
Posted: Tue Aug 09, 2005 9:32 am Post subject: |
|
|
For those of you who are writing an IDE for Lua, check out some of the features this editor has: http://www.wowguru.com/ui/wow-scite-lua/
It was made for World of Warcraft Lua scripting, but it works great for editing my PSP Lua scripts. It's based off SciTe.
While debugging on the PC would speed up the development process, having an enviornment to do realtime debugging on the PSP itself would be much more beneficial. I downloaded nevyn's last build and the 'press any key to restart' is a great help, but what we really need to do is map a function in Lua to activate the USB port. Then the script.lua file can be modified while Lua Player is running, and a key sequence can be used to restart the game.
This should be all we need as far as the drivers go... But how can it be made into a function accessible in Lua?
| Code: |
//start necessary drivers
LoadStartModule("flash0:/kd/semawm.prx");
LoadStartModule("flash0:/kd/usbstor.prx");
LoadStartModule("flash0:/kd/usbstormgr.prx");
LoadStartModule("flash0:/kd/usbstorms.prx");
LoadStartModule("flash0:/kd/usbstorboot.prx");
//setup USB drivers
retVal = sceUsbStart(PSP_USBBUS_DRIVERNAME, 0, 0);
if (retVal != 0) {
printf("Error starting USB Bus driver (0x%08X)\n", retVal);
sceKernelSleepThread();
}
retVal = sceUsbStart(PSP_USBSTOR_DRIVERNAME, 0, 0);
if (retVal != 0) {
printf("Error starting USB Mass Storage driver (0x%08X)\n",
retVal);
sceKernelSleepThread();
}
retVal = sceUsbstorBootSetCapacity(0x800000);
if (retVal != 0) {
printf
("Error setting capacity with USB Mass Storage driver (0x%08X)\n",
retVal);
sceKernelSleepThread();
}
retVal = 0;
|
From the USB Sample |
|
| Back to top |
|
 |
nevyn
Joined: 31 Jul 2005 Posts: 136 Location: Sweden
|
Posted: Tue Aug 09, 2005 9:46 am Post subject: -- BIG UPDATE -- |
|
|
The new version of LuaPlayer, 0.7b5, is ready for testing. It has an ENTIRE NEW API, so old apps will NOT be compatible without rewriting. It is entirely possible to write a wrapper library (defining functions with the old names calling functions with the new names), but I'm not going to do it myself...
New in 0.7 (from 0.6):
- Sound and music through Mikmodlib
- Analog stick is fully functional
- Objects garbage collect
- The API is completely redesigned.
I hope people are willing to test the API a little before it's released in binary form... And plus, I have to rewrite Lowser first, too... So, anyone who wants to try it out, update from svn and build. The luaplayer folder (into which a 'make kxploit' will create a binary) contains an example.
The new API:
| Code: | Graphics
========================================
Image Image.createEmpty(width, height)
Image Image.load( filename )
nil image:blit(x, y, Image source, [sourcex, sourcey, width, height], [alpha = true])
nil image:clear([color = white])
nil image:fillRect(x, y, width, height, [color = black])
nil image:drawLine(x0, y0, x1, y1, [color = black])
Color image:pixel(x, y) --get
nil image:pixel(x, y, Color) --set
nil image:print(x, y, text, [color = black])
Number image:width()
Number image:height()
nil Image:save( filename )
global Image screen
nil screen.flip() -- note the small s; this is a function of the screen
nil screen.waitVblankStart([count])
Color Color.new(r, g, b, [a])
table[r,g,b,a] color:colors()
Bool (Color a == Color b)
Controls
========================================
Controls Controls.read()
Bool controls:select()
Bool controls:start()
Bool controls:up()
Bool controls:right()
Bool controls:down()
Bool controls:left()
Bool controls:l()
Bool controls:r()
Bool controls:triangle()
Bool controls:circle()
Bool controls:cross()
Bool controls:square()
Bool controls:home()
Bool controls:hold()
Bool controls:note()
Number controls:analogX() -- ranges from -127 to 128.
Number controls:analogY() -- same
Bool (Controls a == Controls b) -- note! The analog stick is NOT considered when comparing because of analog fluctuations.
System
========================================
String System.currentDirectory() -- get
String System.currentDirectory( path ) -- set, returns old path.
table System.listDirectory()
table System.listDirectory( path )
Sound and music
========================================
nil Music.playFile( string file, bool loop )
nil Music.stop()
bool Music.playing()
nil Music.volume( number {0-128} )
nil SoundSystem.SFXVolume( number {0-128} )
nil SoundSystem.reverb( number {0-15} )
nil SoundSystem.panoramicSeparation( number {0-128} )
Sound Sound.load(filename)
Voice sound:play()
nil voice:stop()
nil voice:volume( number [0-25] )
nil voice:pan( number [0-255] )
nil voice:frequency( number [0-255] )
bool voice:playing() |
|
|
| Back to top |
|
 |
Soban
Joined: 06 Aug 2005 Posts: 14
|
Posted: Tue Aug 09, 2005 11:22 am Post subject: |
|
|
Looks good.
Fortunately, it looks like everything can be converted just with regular expressions... hell, even regular search and replace... |
|
| Back to top |
|
 |
Shine
Joined: 03 Dec 2004 Posts: 728 Location: Germany
|
Posted: Tue Aug 09, 2005 1:24 pm Post subject: Re: -- BIG UPDATE -- |
|
|
| nevyn wrote: | | I hope people are willing to test the API a little before it's released in binary form... |
This is difficult for many people without a psptoolchain, so I've built a binary release, but I'll announce it on my webpage later, when the new API is more stable and Nevyn has ported Lowser. The other scripts in the samples directory are ported, including Snake, now with some background music and effect sounds. And there are 2 new functions for activating and deactivating USB. Together with Lowser, the turnaround-time for uploading and testing a new script could be really fast now. |
|
| Back to top |
|
 |
Oobles Site Admin
Joined: 17 Jan 2004 Posts: 362 Location: Melbourne, Australia
|
Posted: Tue Aug 09, 2005 1:49 pm Post subject: |
|
|
I've added a link on the main ps2dev.org web site for LuaPlayer. I've only added a couple of lines of text for the comments. Please add some more details. Just select edit topic on the top right menu.
Feel free to add binary releases of the software there too by using "Add File".
David. aka Oobles. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|