[Project]Joyau: Programming in Ruby for PSP

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Mon Ouïe
Posts: 36
Joined: Sun Jul 05, 2009 10:22 pm

[Project]Joyau: Programming in Ruby for PSP

Post by Mon Ouïe »

Hi,

Perhaps have you seen Vincent Xu's patch to Ruby here ?
I just used it and the devslib in order to do like some did for Lua: a program which can run game entirely written in Ruby.

It aims to provide high-level interface, and to be easy to use.

If you speak French, you should know "Joyau" Means "Jewel" ;)

Actually, there are some features like :
  • - A working sprite system ;
    - A particles generator ( just a frontend to the devslib one in fact) ;
    - A scolling class ;
    - Some audio function ( really basic though, I've to work on that... I'll try with OpenAL to provide ogg support at least )
    - Also, text manipulation ( drawing text, ... )
    - Possibility to draw basic forms ( Circle, rect, ... )
    - Some things provided by Ruby itself :)
However, the documentation is still really uncomplete, since I can't use tools like doxygen, even if there are some samples which can "explain" you how it works.

You can get source on github : http://github.com/Kode/Joyau/tree/master
And, for people who can't compile, I provide an EBOOT too : http://github.com/Kode/Joyau/downloads
( Ahem... Now I notice a typo on the download description... well... I'll corect that the next time ;) )
MistPhoenix
Posts: 22
Joined: Sun Jul 12, 2009 5:09 am

Post by MistPhoenix »

This is great! I used to use Ruby back in the RPG Maker development for RMXP and RMVX, glad to see that Ruby can be used on the PSP! I am supporting you all the way to getting this program updated, as well as new features.

Doxygen documentation would be nice, but a simple text file going in depth about the functions and source files included in the project would work most definitely.
Dariusc123456
Posts: 388
Joined: Tue Aug 12, 2008 12:46 am

Post by Dariusc123456 »

Im not much of a ruby person, but I do use it in RPG XP and VX, so if you need help PM me.
PSHN - Playstation Hacking Network
PSX/PS1 - HACK - Game Shark
PS2 - HACK - Swap
PSP - HACK - Pandora
PS3 - ?
MistPhoenix
Posts: 22
Joined: Sun Jul 12, 2009 5:09 am

Post by MistPhoenix »

I was trying to compile the source files you provided and I didnt have libruby(-lruby) and the ruby.h and oslib.h. I went and clicked on the eboot link you provided and when I downloaded it, the package gave me the same folder, the source folder and files, not compiled.

Please post a link with the compiled eboot and other files necessary to make this work.

Edit: I clicked the "Download" button instead of clicking the eboot.pbp directly I got it now
MistPhoenix
Posts: 22
Joined: Sun Jul 12, 2009 5:09 am

Post by MistPhoenix »

Also, can you recompile the eboot for 3.xx firmware or higher? CFW 5.50 GEN-A can't do 1.50 kernel mode. Sorry
Mon Ouïe
Posts: 36
Joined: Sun Jul 05, 2009 10:22 pm

Post by Mon Ouïe »

Well, some people seem to have trouble with the EBOOT. I think I don't because I've LEDA installed -- Thus, it works on PSP 1000 and 2000 ;)

I'll try to compile it for 3.xx, but I can't guarantee it'll work.
Ok, now you can download the eboot compiled with PSP_FW_VERSION = 371. It works for me, I don't know if it'll with your firmware.

For the oslib ( In fact, it's the devslib - really important, I use some features the oslib doesn't provide ), you can get it there : http://projetpsp.free.fr/Beta.rar
( It's open source, at least that's what the author had said, but I can't find any source code, I've only found binaries )

And for ruby, there's a patch to apply : https://rubyforge.org/tracker/index.php ... &atid=1700
( I use the 1.8-5, and it seems to work for 1.8-6. I tried to modify it for the 1.9 branch, but there are too much new things to change for me -- I'm not familiar with ruby source code ;)
Doxygen documentation would be nice, but a simple text file going in depth about the functions and source files included in the project would work most definitely.
That's almost it : a wki page ( in textile thus ) with all the functions, classes, and some notes. It's now up to date.

PS : Now, cursor can be used easier than before. See the cursor sample ;)
MistPhoenix
Posts: 22
Joined: Sun Jul 12, 2009 5:09 am

Post by MistPhoenix »

I do have LEDA on my psp, but CFW 5.50 Gen-A freezes anytime I try to start a game after executing LEDA. It sucks. The only thing good about it is the fact that it bypasses PSN check(I am a fan of Resistance). Can't use any plugins and no 1.50 kernel support either. There isn't even "Shutdown Device" in VSH menu!

The Wiki has alot of functions since the last time I visited it.

Questions about fonts: What type of font does Joyau support? ttf, .bmp?

Even with the eboot being 3.71, I still can't execute it. Oh well
Mon Ouïe
Posts: 36
Joined: Sun Jul 05, 2009 10:22 pm

Post by Mon Ouïe »

For the font, it's oft. It's a specific format to the oslib, you can get a tool in order to convert ttf to oft with the oslib. ( Well, in the devslib features list, they say TTF are supported, but nothing in the documentation say that )
Even with the eboot being 3.71, I still can't execute it. Oh well
Do you have the time machine installed ? And does it work with it ?
It works both in 5.00 M33 and with the time machine and the kernel 1.5 on my PSP, but I can't be sure he kernel mode matters.
( The only changement I see is that when I use a function which doesn't work usually, like "kinitAudio", it give me a blue screen with written "bus error" )

And I don't understand what you mean when you say "executing LEDA". Is there anything to do before loading a homebrew which need kernel mode ? Because I don't do anything but pressing cross when Joyau is selected.
I'd want to know why it works :P
MistPhoenix
Posts: 22
Joined: Sun Jul 12, 2009 5:09 am

Post by MistPhoenix »

I believe you have to start the LEDA eboot in order to ready your psp for legacy(1.50) support. But when I do start LEDA and it copies the prx's into flash, and returns back to the XMB, I select the Joyau eboot and the psp simply hangs, then turns off(out of mem?)

I will have to try Time Machine, since DevHook doesn't work being it needs 1.50 kernel mode access as well.
Mon Ouïe
Posts: 36
Joined: Sun Jul 05, 2009 10:22 pm

Post by Mon Ouïe »

If we have to copy the prx each time ( I don't think so, but I don't really know... ), then Joyau don't need them.

And by the way, you have a script.rb file in the same folder as the eboot ? Because anyway, it won't work without the script.rb ^^
MistPhoenix
Posts: 22
Joined: Sun Jul 12, 2009 5:09 am

Post by MistPhoenix »

I figured it operated like Lua does with script.lua so yes, the eboot is in the folder. As I was mentioning, the game freezes up right at the point where the psp gameboot video ends, and never actually starts the Joyau but ends up crashing and powering off.
Mon Ouïe
Posts: 36
Joined: Sun Jul 05, 2009 10:22 pm

Post by Mon Ouïe »

Well, I've never had that error. The module is defined so :

Code: Select all

PSP_MODULE_INFO("Joyau", 0x1000, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_VFPU);
I know it is supposed to be the kernel mode, but it doesn't seems so, since some functions which need the kenel mode don't work. ( Perhaps is it still in user mode because I set "THREAD_ATTR_VFPU" ? It was after having done that that I tried for the first time in a "normal" firmware ).

PS : you can find a really experimental support of ogg in the experimental branch ;)
( I'm not sure about why the sound is so ugly, but I'll look about that. )
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

User mode would be

Code: Select all

PSP_MODULE_INFO("Joyau", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER|THREAD_ATTR_VFPU);
I think more effort should be put into making this user mode before going further. Nothing should be kernel mode anymore, beyond prx's like the one to use the MediaEngine or to install an exception handler.
Mon Ouïe
Posts: 36
Joined: Sun Jul 05, 2009 10:22 pm

Post by Mon Ouïe »

Well, when I compile the eboot so I get the 8002013C error.

I've tried to remove the callbacks and to use the oslib ones ( and thus, I remove the stdoutInit function too ), but it doesn't work.

I don't know how I could use a prx in that case, since I need functions pointers for the ruby library.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

8002013C is library not found. Something is trying to use a library that's not present, or can't be loaded for some reason. This whole project is in so many pieces, I can't figure out what's what. It sounds like you're trying to make something like LuaPlayer, but with Ruby and using oslib for the PSP specific support. Rather than make people try to gather all the pieces, you should gather everything up in one place, especially since none of this is part of the "standard" PSP SDK or libraries. I'd have a Ruby and a oslib directory in your app directory that had the code just the way it's needed for the project. If you do that, maybe people would be able to help you out.
Mon Ouïe
Posts: 36
Joined: Sun Jul 05, 2009 10:22 pm

Post by Mon Ouïe »

Well, I don't really understand what's called a library for the PSP, since we don't use static links.

Anyway, I've done a tarball which contains :
- Joyau ( the last experimental version )
- freealut ( The one with yur patches ^^ )
- openAL
- the devslib
- ruby
- ogg and vorbis

( I don't think the pspsdk is needed in that archive... )

I've only set the includes and the libraries files, I don't think their sources are needed.

Here is the tar ball : http://cloud.github.com/downloads/Kode/ ... dep.tar.gz

I've indicated the lines I'd have commented for the user mode. It's in main.cpp, and in Graphics.cpp ( only the line « oslInit(0); », in order to have callbacks... )
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Ogg and vorbis are "standard", so you probably don't need to include them. OpenAL and freealut are not, so you either include them or point people to the thread where I released it (probably better to include it), and what the heck is devslib?
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

Your code is littered with calls to kernel level functions.

All the USB code you have is kernel level.
Think I spotted a few in Kernel.cpp too.

As a general rule, any functions in a *_kernel.h or *_driver.h file are kernel level.

I'll take a small look at it later after work if I get 10 minutes.

[EDIT] I quickly went through and commented out all the kernel level function calls as well as removing the kernel libs from the Makefile.

It probably won't compile (and I can't test it) because of internal dependencies etc. but at least you can identify the kernel level calls.

http://www.didev-studios.com/temp/Joyau_User.zip
Mon Ouïe
Posts: 36
Joined: Sun Jul 05, 2009 10:22 pm

Post by Mon Ouïe »

All the USB code you have is kernel level.
Think I spotted a few in Kernel.cpp too.
Anyway, the USB functions aren't working. They may be removed.

Well, I tried your version, and it compile well ;)
I've tried right now, and it runs too.

The only thing which I'd like to use is the function about eboot loading. Can't they be used in user mode ? ( Even though I can do without them )

Thus, I'll apply these changements on the experimental branch, and it'll soon be commited on master.

Thanks for your help :)

EDIT : Code commited on master !
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

Everything that is kernel level can be handled in an external kernel level PRX.

You can then load this kernel PRX from your regular user-mode PRX and have access to the function 'wrappers'.

I think this method still works, there were a few bits of sample code about too...
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

You can find the MediaEnginePRX and demo code in the arc linked in this post:
http://forums.ps2dev.org/viewtopic.php?p=82591#82591

That shows how to make and use a kernel level prx.
MistPhoenix
Posts: 22
Joined: Sun Jul 12, 2009 5:09 am

Post by MistPhoenix »

I went to psp-hacks.com and downloaded your latest Joyau(v0.8) with 3.xx kernel. Program runs smoothly.

Question: could you maybe add a networking interface to this, or do you simply need to use ruby sockets class implemented in Ruby to do this?

EDIT: is there something wrong with the audio sample? It did not playback anything
Mon Ouïe
Posts: 36
Joined: Sun Jul 05, 2009 10:22 pm

Post by Mon Ouïe »

The Ruby socket class need to be built as a separate extension, so you can't use it ( even if, since berkley socket should work, recompiling it with Joyau is perhaps possible, it's just the psp-specific part... )
I'd look at some samples (simple_prx seems to do that), but I'm not sure I'll implement that.

About the audio sample... Well, I tried it right now ( with the 0.9 version, which can be downloaded on github ;) ), and it plays music. The only thing is that, since I don't check return value, the music stop after some time.
Also, the first seconds, the music just play nothing ;)
You don't even hear a sound when you press cross ?

I'm sure it works on 5.50 GEN-B and 5.00 M33-4, and I don't see why it wouldn't work on any other custom firmware.
MistPhoenix
Posts: 22
Joined: Sun Jul 12, 2009 5:09 am

Post by MistPhoenix »

Well I am currently running 0.8 on CFW 5.50 Gen-A which it runs fine on now that it is a user mode app. I will have to get Joyau 0.9 and test it from there
Teixe
Posts: 2
Joined: Sun Aug 02, 2009 3:37 pm
Location: Spain
Contact:

Post by Teixe »

@Mon Ouïe

First of all congratulate you for this application, I see it very useful, more easy and powerful than Lua!

I'm using Joyau 0.8 eboot, because the eboot 0.10 has given me some problems with some functions, but eboot 0.8 works very well
I hope you continue to develop this Ruby interpreter, and speaking of development, I would make some suggestions of what you could implement.

Important:
  • *OSK support (I think it is a basic functionality and needed. Would it be possible to link the OSK, with the function 'gets' from Ruby?)
    *USB support (It is not an essential function, but comfortable at the time of editing the scripts on your PSP without having to use homebrews as PSPLink to avoid having to enter and exit the eboot to make changes.)
Other:
  • *Run eboots support
    *Compression/Decompression data support
    *Adhoc/Wlan support
They are only suggestions, I am a novice programmer and I can not imagine the great work that would implement this, but I hope they at least serve as something.


A greeting!
Mon Ouïe
Posts: 36
Joined: Sun Jul 05, 2009 10:22 pm

Post by Mon Ouïe »

Well, I've uploaded two new version after 0.10, you could try the last one ^^
And yeah, the developement continues :P

For the USB... Well, I did it right after I read your message. It seems to work, but I don't know how it can be used. You can init the usb connection, and get the usb state; that's all. ( I followed the sample on zorba's site... )

I'll look for the OSK now :P and yes, gets can be redefined (as well as puts in fact).
( Of course, only the global functions would be redefined. File#puts and File#gets still work... )

For the adhoc or wlan support, I don't think I'd do it. It's hard to test, etc.

And, I don't understand what you mean by "compresison/decompression data". Could you explain that?

By the way, the new thing in the lastest version ( yeah, copay and paste... ) :

- I've fixed a bug ( thanks to Code1, the one who reported it :P ). Look at this code :

Code: Select all

readKeys
if $keys["pressed_cross"]
   t=t+100
end
cursor.updatePos
It seems correct, no ? Yes, but it isn't. When you call readKeys, the keys are read (indeed) and saved in array. But when you call updatePos, the keys are read too (we need the analogic stick position), but they're not updated in the array. Thus if the user has pressed or released a key right before updatePos... the event would never be raised, and t would never be increased.

Now, updatePos call readKeys and update the $keys array. Here's the fixed code :

Code: Select all

cursor.updatePos
if $keys["pressed_cross"]
   t=t+100
end
- I've added a Shape class. Some code have been removed from the source :P It allows to set gradient and color to a drawable.

- for the sprites, there's a new method, "unTile". It disable the tiled option.

- about the collision, management, look at how it works :

Code: Select all

sprite.move(2, 0)
if obstacle.collide sprite
   sprite.move(-2, 0)
end
you have to cancel the move if the position is not correct. thus, for eight directions, you'll have... eight times that code ! Look at the new way it's done :

Code: Select all

if $keys["left"]
   sprite.move(-2, 0)
end
if $keys["up"]
   sprite.move(0 -2)
end
# etc.

if obstacle.collide sprite
  sprite.cancelMove
end
Each time you move, movements are registred. They can be canceled with cancelMove. notice the rigstered movement are set to zero by setPos, clearMove, and draw.
MistPhoenix
Posts: 22
Joined: Sun Jul 12, 2009 5:09 am

Post by MistPhoenix »

Good work keeping up with this.

By compression/decompression data, he is referring to archiving files such as .zip or .rar and being able to decompress them to save on project space as well as load times.

Ad hoc/Wifi would be nice, but I don't recommend adding it until you add more features to your existing methods and classes.
Teixe
Posts: 2
Joined: Sun Aug 02, 2009 3:37 pm
Location: Spain
Contact:

Post by Teixe »

Hello again!

- Speaking of updates, there is the simple reason that I do not use an eboot > 0.8.
The problem is the function: drawText(0, 0, ''). Running the exact same script with a eboot 0.8 and with eboot > 0.8, I get different results.

I put a screenshoot:
Image
(Is the main menu of a game that I started to create, using Ruby for the first time xD)

The more rare thing is that this "issue" does not occur always, only sometimes.

Know something about this?

- Another problem, with the function: drawText(0, 0, '') and ("") and ('') and (\n).
For example, this drawText(0, 0, "Player says: \n Hello!") has resulted in:

Code: Select all

Player says:
Hello!
For example, this drawText(0, 0, 'Player says: \n Hello!') has resulted in:

Code: Select all

Player says: \n Hello!
In short, \n between '' not working.

- How would the code to start the usb connection? I have been looking http://wiki.github.com/Kode/Joyau and I could not find anything.


- Speaking of OSK, I do not know anything about advanced programming, and looking for something more simple I found one OSK in lua, has 159 lines of code, I take a look and I think does not use any specific function of lua. you think it would be possible to translate this script to Ruby?

Danzeff 1.0 for PSP Lua Player download link here!

- About compression/decompression data MistPhoenix has answered.

About the updates and fixes good work. I hope it continues well!


A greeting!
~Sorry for my bad English~
Mon Ouïe
Posts: 36
Joined: Sun Jul 05, 2009 10:22 pm

Post by Mon Ouïe »

Yes, that's normal. In older version, I've used a function which allows \n, etc. and which is always drawed so. However, now, the only way to do this is using DrawableText#toggleScripted. I did that because the "scripted" mode can't be used in other color.

If it is just for the background, you'd just have to call "setTextBackground color(0, 0, 0, 0)".

For the USB connection, it is just in the experimental version. Here's the sample : http://github.com/Kode/Joyau/blob/6ee2d ... /script.rb

For the OSK... It should be transscripted in C++, not in Ruby ^^
( Buy anyway, it's not that the OSK. I found what I was looking for anyway ^^ )
Mon Ouïe
Posts: 36
Joined: Sun Jul 05, 2009 10:22 pm

Post by Mon Ouïe »

Hey,

Now, OSK and USB connections are supported.
I've changed alot of construcors too. Now, you can write things like :

Code: Select all

sprite = Sprite.new("sprite.png")
cursor = Cursor.new("cur.png", 40)
map = GameMap.new("atileset.png", "another.png", "yetanother.png")
tile = Tile.new(0, 0, 0, 50, 50)
It allows things like :

Code: Select all

map << Tile.new&#40;0, 0, 32, 32, 0, 0&#41;
For the text, you can use drawScripted, instead of drawText. It works as the "old" drawText, so you don't have to instanciate any objects.
Post Reply