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 

PSP port of Meritous RELEASED!

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Marach



Joined: 24 May 2009
Posts: 31

PostPosted: Thu May 28, 2009 5:24 am    Post subject: PSP port of Meritous RELEASED! Reply with quote

Hello
I'm making a PSP port of an SDL game Meritous, it's written in C. I compiled it as C++ code, but PSP always crashes with black screen. Meritous uses SDL, SDL_image and SDL_mixer. I have an Ubuntu version of minpspw - a pre-compiled, native PSP Toolchain, but I wrote programs that have proven all libraries are working fine.
I managed to find the crashing line of code by putting fopen("breakpoint.txt", "w"); into different places of code until I found the place where it does not occur.
Here's the source:
Code:
extern "C"
int main(int, char*[])
{
   int on_title = 1;
   int executable_running = 1;
   SDL_Surface *title, *title_pr, *asceai;
   Uint8 *src_p, *col_p;
   int i;
   int light = 0;
   int x, y;
   int pulse[SCREEN_W * SCREEN_H];
   int precalc_sine[400];
   int tick = 10000000;
   int option = 0;
   int can_continue = 0;
   int maxoptions;
   
   int last_key = 0;
   
   int ticker_tick = 0;

   srand(time(NULL));
   SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO); // THIS LINE CRASHES MY APP!!!!!
   // BREAKPOINT
   fopen("breakpoint.txt", "w");

   screen = SDL_SetVideoMode(SCREEN_W, SCREEN_H, BPP, SDL_SWSURFACE);
   
   asceai = IMG_Load("dat/i/asceai.png");

Please, help me, I don't have any clues how to fix that, I tried everything. HEEEEEEEELP...
_________________
Why my REAL email adress has been BANNED???
marach5 (at) gmail (dot) com ???


Last edited by Marach on Mon Jun 01, 2009 6:41 am; edited 4 times in total
Back to top
View user's profile Send private message
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Thu May 28, 2009 7:49 am    Post subject: Reply with quote

Putting this:
int pulse[SCREEN_W * SCREEN_H];
on the stack is crazy.

Use malloc() instead, and make sure your heap is set big enough.

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



Joined: 24 May 2009
Posts: 31

PostPosted: Thu May 28, 2009 3:57 pm    Post subject: Reply with quote

Oww, if I only know what is that "pulse" used for, I'm sure I could eliminate it. What do I use to change heap size?
_________________
Why my REAL email adress has been BANNED???
marach5 (at) gmail (dot) com ???
Back to top
View user's profile Send private message
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Fri May 29, 2009 4:44 pm    Post subject: Reply with quote

Try the search on this forum, it's really useful.
PSP_HEAP_SIZE_KB( size of heap in kb).

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



Joined: 24 May 2009
Posts: 31

PostPosted: Fri May 29, 2009 6:33 pm    Post subject: Reply with quote

Ok, I will post if that works. What's the max heap value? Just want to be sure :) .
_________________
Why my REAL email adress has been BANNED???
marach5 (at) gmail (dot) com ???
Back to top
View user's profile Send private message
Wally



Joined: 26 Sep 2005
Posts: 672

PostPosted: Fri May 29, 2009 7:10 pm    Post subject: Reply with quote

I had a crack at this game, but got nowhere as well..

Make sure you resize the images so they fit the PSP Screen.
Back to top
View user's profile Send private message AIM Address
Marach



Joined: 24 May 2009
Posts: 31

PostPosted: Fri May 29, 2009 8:45 pm    Post subject: Reply with quote

Can I use
Code:
typedef int[SCREEN_W*SCREEN_H] pulse_t;
pulse_t& pulse = new pulse_t;


Will it be compatible with existing code?

EDIT: For now I only want that code to run, I will care about the rest later.
_________________
Why my REAL email adress has been BANNED???
marach5 (at) gmail (dot) com ???
Back to top
View user's profile Send private message
Marach



Joined: 24 May 2009
Posts: 31

PostPosted: Fri May 29, 2009 9:07 pm    Post subject: Reply with quote

OMG IT'S WORKING!!!!!!!

Code:
int* pulse = new int[SCREEN_W*SCREEN_H];


This replacement magically made the game working! Big THX for you guys!
Where's the "Helped" button? xDD

EDIT: One thing, what the hell is that?
Code:
warning: unused variable 'sce_newlib_heap_kb_size'

_________________
Why my REAL email adress has been BANNED???
marach5 (at) gmail (dot) com ???
Back to top
View user's profile Send private message
Marach



Joined: 24 May 2009
Posts: 31

PostPosted: Fri May 29, 2009 9:44 pm    Post subject: Reply with quote

At the moment I'm playing a full Meritous PSP port with working graphics, souns and game saving xDDD I never thought I will make it to that point... Just some fiddling with graphics mode and I will release it :) .
Changing thread name...

EDIT: Expect a release today or tomorrow.
_________________
Why my REAL email adress has been BANNED???
marach5 (at) gmail (dot) com ???
Back to top
View user's profile Send private message
Marach



Joined: 24 May 2009
Posts: 31

PostPosted: Sat May 30, 2009 12:11 am    Post subject: Reply with quote

I need help.
When I run this port in 640x480 resolution everything looks fine, but when I run it in 480x272 everything looks fine too (images are downsized), but text is all shattered. Text position isn't outside the screen, I'm sure it's not because of hardcoded text or image positions. Here's the code:
Code:
void draw_char(int cur_x, int cur_y, int c, Uint8 tcol)
{
   int px, py;
   Uint8 *pix;
   
   for (py = 0; py < 8; py++) {
      pix = (Uint8 *)screen->pixels;
      pix += (py+cur_y)*480;
      pix += cur_x;
      
      if ((cur_x >= 0)&&(py+cur_y >= 0)&&(cur_x < 480-8)&&(py+cur_y < 272)) {
         for (px = 0; px < 8; px++) {
            if (font_data[c][px][py] == 255) {
               *pix = tcol;
            }
            if ((font_data[c][px][py] < 255)&&(font_data[c][px][py] > 0)) {
               *pix = ((int)tcol * font_data[c][px][py] / 256) + ((int)*pix * (256-font_data[c][px][py]) / 256);
            }
            pix++;
         }
      }
   }
}

As you can see, this code ingerates into a SDL_Surface pixels structure.
"screen" surface is 8-bit.
Does anybody know what's wrong? Anything but text looks fine...
_________________
Why my REAL email adress has been BANNED???
marach5 (at) gmail (dot) com ???
Back to top
View user's profile Send private message
Marach



Joined: 24 May 2009
Posts: 31

PostPosted: Sat May 30, 2009 2:17 am    Post subject: Reply with quote

FIXED!
What was happening:

What guy did:
pix = (Uint8 *)screen->pixels;
^^ That sets pointer at the beggining of pixel structure
pix += (py+cur_y)*screen->w;
^^ Pointer is moved a certain number of rows down
pix += cur_x;
^^ Pointer is moved to right

What's wrong in it:
This guy thought that a bytes in a row = screen->w * bpp (bytes per pixel).
That's wrong! To fix this, I needed to replace screen->w by screen->pitch, what is a REAL length of a row.

Now, a question:
Do you already want a 640x480 version streched to 16:9 PSP display, or wait for a fully customized 480x272 version? The first one is ready!
_________________
Why my REAL email adress has been BANNED???
marach5 (at) gmail (dot) com ???
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Sat May 30, 2009 5:01 am    Post subject: Reply with quote

If you want to get fancy, add TV support for the Slim - that's 720x480. If you check the threads here, you'll find a version of SDL I made that automatically handles TV as well as scaling the surface to either the LCD or TV at 16:9 or 4:3.
Back to top
View user's profile Send private message AIM Address
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Sat May 30, 2009 4:02 pm    Post subject: Reply with quote

Why not just render natively at all supported resolutions? Its hardly a graphically taxing game.
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Sat May 30, 2009 4:54 pm    Post subject: Reply with quote

Torch wrote:
Why not just render natively at all supported resolutions? Its hardly a graphically taxing game.


True, if he uses my SDL lib, he just needs to set the resolution to the regular 640x480 and let SDL take care of scaling it to LCD or TV at 4:3 or 16:9. That's how most of my SDL-based game compiles are done... like the current Duke3D and ROTT.
Back to top
View user's profile Send private message AIM Address
Marach



Joined: 24 May 2009
Posts: 31

PostPosted: Sat May 30, 2009 6:05 pm    Post subject: Reply with quote

Sorry, I won't change SDL lib for 2 reasons:
1. I don't know how hard it's to install on my Ubuntu 9.04 with MinPSPW (precompiled toolchain)
2. The 480x272 port is almost finished! Say a big NO to streching xD

What's working:
- sound
- almost all graphics
- saving / loading (see below)
- minimap (see below)
What's not working:
- help browser
- bosses
Known bugs:
- game won't save after ca. 30 minutes of playing
- minimap doesn't scroll near the edges
- some artifacts are drawn outside the screen

Today I will try to fix all bugs, wish me luck :)
If I manage to fix even one bug, see you on PSPUpdates xDDD
_________________
Why my REAL email adress has been BANNED???
marach5 (at) gmail (dot) com ???
Back to top
View user's profile Send private message
Marach



Joined: 24 May 2009
Posts: 31

PostPosted: Sun May 31, 2009 5:15 pm    Post subject: Reply with quote

I've got some problems, so release will be delayed.
After some seconds after entering a boss battle (Meridian) game freezes and PSP resets. I have no idea what is happening.
_________________
Why my REAL email adress has been BANNED???
marach5 (at) gmail (dot) com ???
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Sun May 31, 2009 7:00 pm    Post subject: Reply with quote

Try increasing the stack size. The fact that the original code had several hundred KB on the stack right smack in main() tells me it treats the stack like candy. Try something like

PSP_MAIN_THREAD_STACK_SIZE_KB(1024);

That'll give you a MB of stack.
Back to top
View user's profile Send private message AIM Address
Marach



Joined: 24 May 2009
Posts: 31

PostPosted: Sun May 31, 2009 7:04 pm    Post subject: Reply with quote

What do you want? It's C code xD .

I'll edit to say if that works.
If it does, expect a release today.

EDIT: S**t happens. Any ideas? :-/
_________________
Why my REAL email adress has been BANNED???
marach5 (at) gmail (dot) com ???
Back to top
View user's profile Send private message
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Sun May 31, 2009 10:16 pm    Post subject: Reply with quote

The usual suspects:
memory leak.
memory corruption.
memory exhaustion.
stack overrun.

No silver bullets here, they're all quite tricky to track down.
You should try to get Tyranid's debugger working, or else you're stuck with debugprintf.


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



Joined: 24 May 2009
Posts: 31

PostPosted: Sun May 31, 2009 11:14 pm    Post subject: Reply with quote

Nevermind.
I fixed that bug with cooperation with Asceai himself!
Get ready for the release, coming in hours...
_________________
Why my REAL email adress has been BANNED???
marach5 (at) gmail (dot) com ???
Back to top
View user's profile Send private message
Marach



Joined: 24 May 2009
Posts: 31

PostPosted: Mon Jun 01, 2009 2:14 am    Post subject: Reply with quote

http://forums.qj.net/psp-development-forum/151981-release-meritous-psp.html
_________________
Why my REAL email adress has been BANNED???
marach5 (at) gmail (dot) com ???
Back to top
View user's profile Send private message
psPea



Joined: 01 Sep 2007
Posts: 64

PostPosted: Mon Jun 01, 2009 5:43 am    Post subject: Reply with quote

hurray another game
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Marach



Joined: 24 May 2009
Posts: 31

PostPosted: Sun Jun 07, 2009 10:51 pm    Post subject: Reply with quote

Please, look at my last post in this thread: http://forums.qj.net/psp-development-forum/151981-release-meritous-psp.html
Thank you.
_________________
Why my REAL email adress has been BANNED???
marach5 (at) gmail (dot) com ???
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
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