forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

FRONTIER 1337 - a port of FRONTIER: Elite II for PSP
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Ats



Joined: 05 Dec 2005
Posts: 46
Location: Biarritz - France

PostPosted: Sun May 14, 2006 11:28 am    Post subject: Reply with quote

I've made a little test program to find the best calculation for a fluid mouse movement using the analogic pad.
The mouse cursor is the SDL one and I'm moving it with: SDL_WarpMouse(abs_x, abs_y);
Everything is fine but when I'm using this code in Frontier, I get a blue screen telling me that there is a problem with SDL_WarpMouse,
and precisely in file sdl/src/video/SDL_cursor.c line 304:
Code:
/* If we have an offset video mode, offset the mouse coordinates */
x += (this->screen->offset % this->screen->pitch) /
      this->screen->format->BytesPerPixel;
y += (this->screen->offset / this->screen->pitch);


After some tests, it seems that I can't get the SDL_WarpMouse function to run if I'm using the flag SDL_OPENGL in SDL_SetVideoMode.
(I'm also using the SDL_DOUBLEBUF flag.)

What do you suggest me so that I can display the mouse cursor ?
Back to top
View user's profile Send private message Visit poster's website
Jim



Joined: 02 Jul 2005
Posts: 489
Location: Sydney

PostPosted: Mon May 15, 2006 8:47 am    Post subject: Reply with quote

Possible problems are either screen is a null pointer, or screen->pitch is 0 or screen->format is a null pointer or screen->format->BytesPerPixel is 0.

Jim
_________________
http://www.dbfinteractive.com
Back to top
View user's profile Send private message Visit poster's website
Ats



Joined: 05 Dec 2005
Posts: 46
Location: Biarritz - France

PostPosted: Mon May 15, 2006 10:51 am    Post subject: Reply with quote

Effectively, when the SDL_OPENGL flag is enabled in SDL_SetVideoMode function, the screen->pitch is equal to 0.
But I need both OPENGL and a mouse cursor, so I don't really know what to do...
Do you have some answers for me? I'm kind of stuck with this one.
Or maybe I don't have to use a SDL cursor but instead, draw a cursor with OPENGL?
Back to top
View user's profile Send private message Visit poster's website
Jim



Joined: 02 Jul 2005
Posts: 489
Location: Sydney

PostPosted: Mon May 15, 2006 9:50 pm    Post subject: Reply with quote

Draw your own. No reason to use SDL.

Jim
_________________
http://www.dbfinteractive.com
Back to top
View user's profile Send private message Visit poster's website
Ats



Joined: 05 Dec 2005
Posts: 46
Location: Biarritz - France

PostPosted: Wed May 17, 2006 1:58 am    Post subject: Reply with quote

Today is the first beta release!

The game is slow when there is a lot of stuff drawn in the 3Dview, but is almost playable when you are in space.
You can save/load your commander, but don't try to rename your save file in the game: there is no OSK implemented yet so it will freeze your PSP.

You can download FRONTIER 1337 on my dedicated website.

I didn't really know the C language when I began the project, I'm glad that it has reached this point. Big thanks for all those which helped me!

Now, I'm taking a little break for my exams and then I'll start to speed the game up... and I will surely have a lot more questions to ask you :D
Back to top
View user's profile Send private message Visit poster's website
dot_blank



Joined: 28 Sep 2005
Posts: 498
Location: Brasil

PostPosted: Wed May 17, 2006 7:02 am    Post subject: Reply with quote

nicely down for you not knowing C ;)
_________________
10011011 00101010 11010111 10001001 10111010
Back to top
View user's profile Send private message
johnsto



Joined: 18 Jan 2006
Posts: 30

PostPosted: Thu May 18, 2006 10:44 pm    Post subject: Reply with quote

Just a note to mention it does not load on 2.00 using the eLoader. The PSP just hangs and turns off (like most non-2.00 homebrew stuff)
Back to top
View user's profile Send private message
Ats



Joined: 05 Dec 2005
Posts: 46
Location: Biarritz - France

PostPosted: Wed May 24, 2006 7:06 am    Post subject: Reply with quote

Back from my exams.

I've made a quick update to the game so you can continue playing after the police arrest you when you land on a spaceport. Now you only have to press the select button to get rid of the police.
The 1.00 firmware version is also included in the package: FRONTIER_1337_v0.1b.rar


Now I'm trying to optimize the game speed. I would like to test the fe2.s.part1 optimisation up to -O1 or -O2.
Can someone with a HUGE amount of RAM (1978708224 bytes...) contacts me so that I send him the fe2.s.c file and the corresponding makefile needed to obtain the fe2.s.part1 optimized? Thanks.

Another thing, after a lot of optimization, the only OpenGL thing that remains in the source code screen section is a GLtexture of the size you want (fullscreen), and where the FRONTIER screen is drawn. Is there a quicker way to obtain the same thing using the GU?
If I can get rid of OpenGL, I don't think I need to initialise SDL too. So is the pspctrl.h faster than the SDL one?

Thanks for your advises.
Back to top
View user's profile Send private message Visit poster's website
ector



Joined: 12 May 2005
Posts: 195

PostPosted: Wed May 24, 2006 9:43 pm    Post subject: Reply with quote

My guess would be that it's the huge converted 68k asm->c file that's using most of the CPU power. Getting rid of OpenGL wouldn't be hard at all, gu can do textures too you know, but probably won't give you much in the way of additional speed, unless you're building new textures every frame unnecessarily or something.

Yeah, optimizing GCC is one SERIOUS memory hog..
_________________
http://www.dtek.chalmers.se/~tronic/PSPTexTool.zip Free texture converter for PSP with source. More to come.
Back to top
View user's profile Send private message
danzel



Joined: 04 Nov 2005
Posts: 182

PostPosted: Thu May 25, 2006 9:17 am    Post subject: Reply with quote

I have access to a 64bit linux machine with 8gig of ram, so I could run it for you :)
PM me or post a link to what you want built and I can run it.

You could probably get a better speed up by reading through the code and restructuring some of it since it is built from assembly. Or making an assembly converter like the original dev said (could be difficult due to mips reordering).

Edit: Compiled and sent :)

O1: 8minutes 3GB ram!! :)
O2: 15 minutes, only 1.5GB ram.
Back to top
View user's profile Send private message
Ats



Joined: 05 Dec 2005
Posts: 46
Location: Biarritz - France

PostPosted: Fri May 26, 2006 1:00 am    Post subject: Reply with quote

Thank you Danzel with your NASA machine :D

I made some benchmark with every optimized part1. The FPS are calculated by the game itself at the Ross154 spacestation when all the clouds appeared.
Here are the results:

O0 -> 25 - before :(
O1 -> 39
O2 -> 45 - now :)
O3 -> 25 - ...

With the part1 optimized up to O2 and all the details set to low in the setup screen, the game is now very playable when you are on a planet.

But while the game engine shows 45FPS, it is obvious that the real framerate is near 12FPS. I think this must come from the screen rendering or maybe the sounds... I'm going to make some more tests.
Back to top
View user's profile Send private message Visit poster's website
groepaz



Joined: 01 Sep 2005
Posts: 305

PostPosted: Fri May 26, 2006 1:03 am    Post subject: Reply with quote

you should try -Os aswell, in some cases that results in faster code than -O2.
_________________
http://www.hitmen-console.org
http://hitmen.c02.at/files/yapspd/
Back to top
View user's profile Send private message Visit poster's website
danzel



Joined: 04 Nov 2005
Posts: 182

PostPosted: Fri May 26, 2006 9:52 am    Post subject: Reply with quote

Nice to see there are some speed improvements :)

Os compiled version PM'd now.
Back to top
View user's profile Send private message
Ats



Joined: 05 Dec 2005
Posts: 46
Location: Biarritz - France

PostPosted: Sat May 27, 2006 12:00 am    Post subject: Reply with quote

Thanks again Danzel!
Up to 50FPS (engine, not real...) with part1 optimized to Os. I tried to optimize part2 with Os too but it gave me 25FPS, so I keep O2 for part2.

=> FRONTIER_1337_v0.1c.rar

The game is now playable when you are on a spaceport. You have to set the level of shape detail to 'low' in the setup screen (start button).
You can also disable the 'Space dust, clouds etc' and 'Background stars' if you want.
Back to top
View user's profile Send private message Visit poster's website
Ats



Joined: 05 Dec 2005
Posts: 46
Location: Biarritz - France

PostPosted: Mon Jul 24, 2006 11:32 pm    Post subject: Reply with quote

Hi everyone!
After a good break and some code cleaning, I released the Frontier sourcecode so anyone who have the time and the skills to speed it up can take a look at it.
If anyone is interested, please tell me!

Frontier 1337 v0.1c sourcecode
Back to top
View user's profile Send private message Visit poster's website
monkeymagic



Joined: 05 Oct 2005
Posts: 6

PostPosted: Tue Jul 25, 2006 5:16 am    Post subject: Ok folks, now we have the source, where too next? Reply with quote

Atien,

Thanks for providing the source code. Hopefully people can contribute to it. Having a brief look, the following spring to mind as places to start:

FE2 is still emulating 68k. As long as it's doing that it's always going to be slower than native C, let alone MIPS. So we can work on optimizing the emulation for the PSP, or reducing the amount of stuff that's emulated.

I've read somewhere that CaSTaway PSP has a very quick 68k emulation engine, maybe we can take fe2.s.c and compare it with that to see if there's anywhere we could speed things up.

It's damned ugly in there, but if we can find the slowest or even most called functions, then that might give us an idea of where to start. This might mean altering as68k to dump the code necessary to log the start of each function call.

There's also a lot of stuff that is emulated that maybe doesn't need to be. For example, the DrawTriangle function should be fairly straightforward to replace with something reasonable in C so we aren't jumping all over the place.

I've already told Ats via email that I don't really have much time to work on this, but If I get some time to look, then I'll give it a try.

Anyone else have any ideas on how we might improve the speed of this?
Back to top
View user's profile Send private message
Ats



Joined: 05 Dec 2005
Posts: 46
Location: Biarritz - France

PostPosted: Fri Oct 06, 2006 1:43 am    Post subject: Reply with quote

Hi! It's been a long time since I have worked on Frontier.
Now that I have the time to add an OSK, I've reinstalled Cygwin and everything as it was before on my computer. I use the same code that I sent online for v0.1c and...
I can't compile my own code anymore.

I've tried everything and all that I get is:

Code:
make: Warning: File 'src/input.o' has modification time 1.6 s in the future
...
make: warning: Clock skew detected. Your build may be incomplete.

Each time I compile the sourcecode, I get a different obj that has modification time. Sometimes (1 out of 10) the game compiles properly...
I tried the "touch" utility to fix them, or to remove the obj and elf files before compiling the game. I tried to reinstall the libs, even Cygwin... but nothing seems to work.

Do you have an idea where does this problem comes from?
Back to top
View user's profile Send private message Visit poster's website
Wally



Joined: 26 Sep 2005
Posts: 673

PostPosted: Fri Oct 06, 2006 11:30 am    Post subject: Reply with quote

Tried make clean and recompiling??

Wierd bug..
Back to top
View user's profile Send private message
Ats



Joined: 05 Dec 2005
Posts: 46
Location: Biarritz - France

PostPosted: Sat Oct 07, 2006 9:32 pm    Post subject: Reply with quote

After some more tries, I've discovered that I have two problems at the same time. The 'clock skew' thing don't seems to cause much trouble. The big problem comes from the initialization function in audio.c

The worst thing is that I already had the same problem when I started the project several month ago, and now I don't remember how did I fixed it...

Here is the function with the problem highlited inside:

Code:
void Audio_Init(void) {
   int i;
   char filename[32];
   SDL_AudioSpec desiredAudioSpec;

   if (SDL_WasInit(SDL_INIT_AUDIO) == 0) {
      if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) {
         fprintf(stderr, "Could not init audio: %s\n", SDL_GetError() );
         bSoundWorking = FALSE;
         return;
      }
   }

   desiredAudioSpec.freq = SND_FREQ;
   desiredAudioSpec.format = AUDIO_S16;
   desiredAudioSpec.channels = 2;
   desiredAudioSpec.samples = 1024;
   desiredAudioSpec.callback = Audio_CallBack;
   desiredAudioSpec.userdata = NULL;

   if (SDL_OpenAudio(&desiredAudioSpec, NULL)) {
      fprintf(stderr, "Can't use audio: %s\n", SDL_GetError());
      bSoundWorking = FALSE;
      return;
   }

   SoundBufferSize = desiredAudioSpec.size;

   for (i=0; i<MAX_SAMPLES; i++) {
      snprintf (filename, sizeof (filename), "sfx/sfx_%02d.wav", i);

      // -------------------------------------------
      // THE PROBLEM COMES FROM THE SDL_loadWAV LINE
      if (SDL_LoadWAV (filename, &desiredAudioSpec, &sfx_buf[i].buf, &sfx_buf[i].buf_len) == NULL) {

         printf ("Error loading %s: %s\n", filename, SDL_GetError ());
         sfx_buf[i].buf = NULL;
      }
      check_sample_format (&desiredAudioSpec, &sfx_buf[i].buf, &sfx_buf[i].buf_len, filename);
    
      if (i == 19) sfx_buf[i].loop = SND_FREQ; // loop to about 0.5 sec in
      else if (i == 23) sfx_buf[i].loop = 0;
      else sfx_buf[i].loop = -1;
      
   }

   bSoundWorking = TRUE;
   Audio_EnableAudio(TRUE);
}


And the blue screen returns this:

Code:
psp-addr2line -e frontier.elf -f -C 0x8d5ab14 0x408b000 0x8d5aab0
_free_r
../../../../../newlib/libc/stdlib/mallocr.c:2696
??
??:0
_free_r
../../../../../newlib/libc/stdlib/mallocr.c:2632


SOS!
Back to top
View user's profile Send private message Visit poster's website
Jim



Joined: 02 Jul 2005
Posts: 489
Location: Sydney

PostPosted: Sun Oct 08, 2006 8:43 am    Post subject: Reply with quote

Check your buffer size for sfx_buf. A common reason for free() to complain is someone wrote over the end of an allocation and corrupted the heap.

Jim
_________________
http://www.dbfinteractive.com
Back to top
View user's profile Send private message Visit poster's website
Ats



Joined: 05 Dec 2005
Posts: 46
Location: Biarritz - France

PostPosted: Sat Mar 24, 2007 3:49 am    Post subject: Reply with quote

I'm still working from time to time on this game.
I've found why the wav file loading wasn't working: at the beginning of audio.c, #define MAX_CHANNELS was equal to 4 instead of 2...
I gained some speed and finally enabled the ogg music, but this last one is quite crappy. The frequency is twice higher than normal and there is a lot of noise.
Can somehone take a look at the #ifdef OGG_MUSIC parts in my audio.c to give me clues why it is like this?
Thanks!

Source code for audio.c
Back to top
View user's profile Send private message Visit poster's website
RCON



Joined: 03 Aug 2005
Posts: 16

PostPosted: Sat Mar 24, 2007 8:02 am    Post subject: Reply with quote

It looks like the music you are playing is 22050 hz while the audio callback runs at 44100. That would cause the sounds to play at double speed. You will probably need to resample it to 44100 for it to sound right.

-Louie
Back to top
View user's profile Send private message Visit poster's website
Ats



Joined: 05 Dec 2005
Posts: 46
Location: Biarritz - France

PostPosted: Sun Mar 25, 2007 12:20 pm    Post subject: Reply with quote

So I resampled all the wav sounds and ogg music to 44100Hz and now all the sounds work perfectly, thank you!

I have two more things to do before the next release:
- Launch the game at 333Mhz without using IRshell.
- Try to implement Danzeff keyboard for changing savefile name.
Back to top
View user's profile Send private message Visit poster's website
Ats



Joined: 05 Dec 2005
Posts: 46
Location: Biarritz - France

PostPosted: Sun May 06, 2007 4:54 am    Post subject: Reply with quote

Hi! Here's the latest version of the game with some new things:
Quote:
version 0.2a :
- The game is now running at 333MHz.
- The music has been enabled.
- All wav sounds and ogg music have been resampled to 44100Hz and are now working perfectly.
- All sub-folders (but savs) have been moved to data folder.
- The Fkeys highliter has been turned from red to black for not interfering with the intro and outro of the game.

The package contains the kxploited game and the sources. Download the MUSIC and SFX packs if you want, and place them in the FRONTIER/data folder.
- FRONTIER1337 v0.2a
- SFX pack
- MUSIC pack

I'm advancing very slowly so any help is still welcome ;)

Edit: Sorry, I forget to add fe2.s.bin file in the package yesterday. Everything should work fine now!
By the way, at the end of the compilation, how can I move fe2.s.bin from a directory to another using the Makefile?
This would help me to avoid this kind of mistakes in the futur...
Back to top
View user's profile Send private message Visit poster's website
Ats



Joined: 05 Dec 2005
Posts: 46
Location: Biarritz - France

PostPosted: Sun Oct 24, 2010 4:43 am    Post subject: Reply with quote

Hi everyone! Good to see that this forum is back.
It's been literaly years since I worked on that game, and right now, I'm trying to port it to 5.xx kernel.

I'm following this tutorial : http://forums.ps2dev.org/viewtopic.php?p=59266#59266
At first, it seemed to be quite simple...

I had to reinstall everything, so this time I tried the Minimalist PSPSDK instead of Cygwin/PSPToolchain. The game is compiling good, but don't works on the PSP. It only shows a SDL cursor on a blackscreen for a few seconds and then shuts down.
After some code striping, I figured that the problem comes form the openGL init. The GL function are not working at all! So I was wondering if one of you guys had any clue about this?
Without the added lines for 5.xx kernel and the old 'make default kxploit', the game is working...

Thanks for your help !
Back to top
View user's profile Send private message Visit poster's website
Wally



Joined: 26 Sep 2005
Posts: 673

PostPosted: Wed Jan 05, 2011 5:18 am    Post subject: Reply with quote

You have to define a heapsize in your main.cpp file, that should fix it.

We generally use a negative value to use all available memory except the defined value.
Back to top
View user's profile Send private message
Ats



Joined: 05 Dec 2005
Posts: 46
Location: Biarritz - France

PostPosted: Mon Jan 10, 2011 10:22 pm    Post subject: Reply with quote

Hi Wally, I just saw your response today:
I tried PSP_HEAP_SIZE_KB(20480) and PSP_HEAP_SIZE_MAX() without success, but PSP_HEAP_SIZE_KB(-1) is working fine. THANK YOU!!!

I also had to set the callbacks to be able to quit the game. Now everything is ok but I didn't remembered the fps was that slow... Crazy memory :)
New release soon!
Back to top
View user's profile Send private message Visit poster's website
Salvy



Joined: 30 Jun 2009
Posts: 12

PostPosted: Tue Jan 11, 2011 3:44 pm    Post subject: Reply with quote

@Ats : I would recommend to set the heapsize -256 instead of -1.

Also you should let the compiler help you optimize your code, try adding -ffast-math to your CFLAGS and see if it helps.
Back to top
View user's profile Send private message
Ats



Joined: 05 Dec 2005
Posts: 46
Location: Biarritz - France

PostPosted: Sun Jan 16, 2011 4:41 am    Post subject: Reply with quote

@Salvy : Ok for the -256. I didn't notice a big difference by adding -ffast-math but at least it didn't break the game!

By the way (Heimdall if you read this), the game don't run on the psp when compiled with MINPSPW 0.11.1. It gives me the same problem as before adding PSP_HEAP_SIZE_KB(-256) linecode: a black screen with a SDL cursor and no OpenGL init. I had to revert to MINPSPW 0.10.0. Still MINPSPW is a great tool :)

I contacted the man who ported the same Frontier sourcecode to GP2X and he told me that besides optimising the C files, there's not much we can do on the asm part to optimise the game speed...

So the new version is out. Not much improvement. I got rid of some warnings and the game works on firmwares > 1.50
I didn't provided the sourcecode this time though because some parts of the game cannot be compiled with MINPSPW... I had to use the object generated from as68k to C from an old cygwin compilation. I'm working on that.

You can grab Frontier 0.2.1 on my website.
Back to top
View user's profile Send private message Visit poster's website
Ats



Joined: 05 Dec 2005
Posts: 46
Location: Biarritz - France

PostPosted: Mon Jan 31, 2011 4:10 am    Post subject: Reply with quote

Today I was cleaning the sourcecode in order to release it, and I found how to improve the fps greatly: the game emulation was called every 20ms! I dropped it to 1ms and now the fps is easily twice better. But is it safe? I read here that 10ms is a most commun number. What do you think of that?

In the main function :
Code:
SDL_AddTimer (1, &vbl_callback, NULL);

And the callback :
Code:
static Uint32 vbl_callback () {
   FlagException (0);
   return 1;
}



Now here comes my three new real problems :

First one: Years ago when I had problems with the music, I resampled every sounds from 22KHz to 44KHz. It worked but the sounds sizes are twice bigger so the loading time at the begining of the game is long. I tried many things, but when I play the sound and music at 22KHz, it sounds very crappy. I searched on the net but didn't find any clue. Here is the sound c file if you can find something I should change other than the line 13.
Code:
#define SND_FREQ   44100 //22050=crappy... why?


Second one: When I compile the game with MINPSPW, cc1.exe is crashing half way through the huge "c file part2" compilation. I don't know if it is because I'm lacking of memory or anything else. I made a mini package if someone wants to give it a try. Just launch build.bat, it will generate the huge c file from the 68k source and compile the part2 without optimisation in order to gain some time.

Last one: As said in my previous post, the game is not linking well under the last MINPSPW version. I have to stay to 0.10.0 otherwise there is a lot of SDL problems with music and GL. Is there anything I should know about SDL, maybe libs, and the latest version of MINPSPW that have change?

Sorry for the big text block, I'm quite excited to have such an improvement in the game speed :)
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
Jump to:  
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