Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
The Maze of Galious
 Brain Games Forums : The Maze of Galious
Subject Topic: MoG port to Playstation Portable (PSP) Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
Azrael
Newbie
Newbie
Avatar

Joined: 07 July 2010
Location: Germany
Posts: 11
Posted: 08 July 2010 at 12:02 | IP Logged Quote Azrael

Hi!

I'm working on a port of MoG for homebrew-enabled PSPs.
As of now it's running quite fine (Yeah!), though some things are not working:

1. Sound
There's no port of SDL_sound for the PSP, atleast I couldn't find one by now.

2. Customization
I bothered only to map the in-game controls for now. So no graphics-/sound-set changing, etc.

3. Password
I have yet to find a way around the PSP not having a keyboard... But there's plenty on-screen keyboards, so that should be solvable.

4. ...other stuff I did not think about yet.


But you can go around and slay monsters!



Since it's running now, I'd like to clean the warnings* the compiler throws. Just to make sure I only get errors/warnings of my own messing.

I fixed everything so far, except at 3 points the compiler complains about
warning: suggest parentheses around && within ||
One in gameinteractions.cpp at line 2600 - So: What is the correct order here?

((ENEMY or ITEM) and STATE)
or
(ENEMY or (ITEM and STATE))

c/c++ uses the second reading (See here!). Is this the intended check?


Same happens in gameobjects.cpp lines 2170 and 2221.

Could someone with more knowledge of the source tell me, whether it's save to add the parentheses?



Thanks in advance!
Sven



*I'll keep ignoring the
warning: deprecated conversion from string constant to ‘char*’
as you did, though... All hail -Wno-write-strings!





Edited by Azrael on 08 July 2010 at 12:04
Back to Top View Azrael's Profile Search for other posts by Azrael Send Private Message Add to Buddy List
 
Jorito
Admin Group
Admin Group
Avatar

Joined: 30 December 2002
Location: Netherlands
Posts: 1930
Posted: 08 July 2010 at 20:39 | IP Logged Quote Jorito

Hmm, I'm not that knowledgable about the source, I knew enough to create a Mac binary. Better ask Popolon on the forums, or send him a private message if it takes too long
Back to Top View Jorito's Profile Search for other posts by Jorito Visit Jorito's Homepage Send Private Message Add to Buddy List
 
Azrael
Newbie
Newbie
Avatar

Joined: 07 July 2010
Location: Germany
Posts: 11
Posted: 09 July 2010 at 09:34 | IP Logged Quote Azrael

Hey! Thanks for the answer!

Since I didn't get what this part of the code really does, I figured it might be good to ask, before spending time on finding out whether it's the intended check or not. I thought the warning might have been added for a reason. Though I don't think they changed the compilers default order or something confusing like that. Atleast brackets help legibility, and the reason for the warning might just be ambiguous code.


Jorito wrote:
Better ask Popolon on the forums


I hope by "on the forums" you meant "here"!? Or is there another place to ask?



Edited by Azrael on 09 July 2010 at 09:35
Back to Top View Azrael's Profile Search for other posts by Azrael Send Private Message Add to Buddy List
 
amoreira
Newbie
Newbie


Joined: 04 January 2010
Location: Brazil
Posts: 25
Posted: 10 July 2010 at 02:38 | IP Logged Quote amoreira

Hi Azrael.

I am also currently doing a port of MoG, but to the Wii homebrew devkit.

It is at an early status, but I managed to remove the dependency from SDL_sound, modifying sound.cpp/sound.h in order to use only functions from SDL_mixer.

It still has problems in the Wii, but this is mainly due to restrictions in Wii's SDL port. For the PC, it works nice, keeping the same behavior (conditions for music looping, and simultaneous playback of music and sound fx).

If you're interested in this patch, my e-mail address is in my profile. We could also exchange some ideas about making this game more "gamepad-friendly". :)
Back to Top View amoreira's Profile Search for other posts by amoreira Send Private Message Add to Buddy List
 
Azrael
Newbie
Newbie
Avatar

Joined: 07 July 2010
Location: Germany
Posts: 11
Posted: 10 July 2010 at 22:42 | IP Logged Quote Azrael

amoreira wrote:
It is at an early status, but I managed to remove the dependency from SDL_sound, modifying sound.cpp/sound.h in order to use only functions from SDL_mixer.


That sounds great ... literally ( bad joke but unavoidable!)

That was on my to-do list. I'd really like to have a look at it ...!

Your eMail address is set to private... I'll PM you mine

Edited by Azrael on 10 July 2010 at 23:02
Back to Top View Azrael's Profile Search for other posts by Azrael Send Private Message Add to Buddy List
 
Jorito
Admin Group
Admin Group
Avatar

Joined: 30 December 2002
Location: Netherlands
Posts: 1930
Posted: 10 July 2010 at 23:39 | IP Logged Quote Jorito

In fact, I'd be interested into incorporating that patch into the codebase as well. It saves an unnecessary dependecy of an unmaintained library (sdl_sound). Care to place the patch here?
Back to Top View Jorito's Profile Search for other posts by Jorito Visit Jorito's Homepage Send Private Message Add to Buddy List
 
Azrael
Newbie
Newbie
Avatar

Joined: 07 July 2010
Location: Germany
Posts: 11
Posted: 11 July 2010 at 10:57 | IP Logged Quote Azrael

Jorito wrote:
In fact, I'd be interested into incorporating that patch into the codebase as well. It saves an unnecessary dependecy of an unmaintained library (sdl_sound). Care to place the patch here?


Yeah - I read somewhere around the forum you'd like to get rid of SDL_sound and hoped there would be someone who'd already done it... Seems we're lucky.

Btw: What did you mean by asking Popolon "on the forum" above?

Back to Top View Azrael's Profile Search for other posts by Azrael Send Private Message Add to Buddy List
 
amoreira
Newbie
Newbie


Joined: 04 January 2010
Location: Brazil
Posts: 25
Posted: 11 July 2010 at 16:31 | IP Logged Quote amoreira

I don't know how to attach a file to a post (is this possible?). So, I will just paste here, inline, the contents of the diff file. Since I don't have an SVN working copy (is there an SVN for MoG, by the way?), the base was version 0.63.1548, downloaded from the website.

I ran Kompare over two different working copies of this source code, one of them unchanged. So, I don't know how easily this patch can be applied to a single working copy. Please notify me if you have any trouble

Well, here it goes:

diff -U 3 -H -d -r -N -- mog-unchanged-0.63.1548/sources/sound.cpp mog-PC-640x480-0.63.1548/sources/sound.cpp
--- mog-unchanged-0.63.1548/sources/sound.cpp     2008-09-13 16:31:49.000000000 -0300
+++ mog-PC-640x480-0.63.1548/sources/sound.cpp     2010-07-11 10:21:38.000000000 -0300
@@ -1,6 +1,5 @@
#include "SDL.h"

#include "SDL_mixer.h"

-#include "SDL_sound.h"

#include "sound.h"

#include "stdio.h"

#include "string.h"

@@ -27,7 +26,7 @@
int music_position=0;

bool playing_music=false;

bool music_loaded[8]={false,false,false,false,false,false,false,false};               

-Sound_Sample *music_sound[8]={0,0,0,0,0,0,0,0};

+Mix_Music *music_sound[8]={0,0,0,0,0,0,0,0};

char music_files[8][128];          /* File names */

char music_realfiles[8][128];     /* File names including music directory */



@@ -65,16 +64,23 @@
                Mix_Linked_Version()->minor,

                Mix_Linked_Version()->patch);



-     Sound_Init();

-     Mix_HookMusic(myMusicPlayer, 0);

-

+    Mix_HookMusicFinished(onMusicFinished);    

     return true;

-} /* Sound_init */

+} /* Sound_init */

+

+

+void onMusicFinished() {

+    if (music_loaded[music_position+1]) {

+        music_position++;       

+    }

+    Mix_SetMusicPosition(0.0);

+    Mix_PlayMusic(music_sound[music_position], 0);    

+//    Mix_PlayMusic(music_sound[music_position], music_loaded[music_position+1] ? 0 : -1);    

+}



void Sound_release(void)

{

     if (sound_enabled) {

-          Sound_Quit();

          Mix_CloseAudio();

     } /* if */

     sound_enabled=false;

@@ -173,33 +179,25 @@
} /* Sound_obtain_file_name */





-Sound_Sample *Sound_create_stream(char *file)

+Mix_Music *Sound_create_stream(char *file)

{

     int n_ext=6;

     char *ext[6]={".WAV",".OGG",".MP3",".wav",".ogg",".mp3"};

     char name[256],name2[256];

     int i;



-     Sound_AudioInfo inf;

-

-     inf.format=AUDIO_S16;

-     inf.channels=2;

-     inf.rate=44100;

-

     if (sound_enabled) {

          for(i=0;i<n_ext;i++) {

               strcpy(name,file);

               strcat(name,ext);

               sprintf(name2,"%s%s",s_path,name);

-               if (file_check(name2)) return Sound_NewSampleFromFile(name2,&inf,AUDIO_BUFFER);

-//               if (file_check(name2)) return Sound_NewSampleFromFile(name2,0,AUDIO_BUFFER);

+               if (file_check(name2)) return Mix_LoadMUS(name2);

          } /* for */

          for(i=0;i<n_ext;i++) {

               strcpy(name,file);

               strcat(name,ext);

               sprintf(name2,"%s%s",default_s_path,name);

-               if (file_check(name2)) return Sound_NewSampleFromFile(name2,&inf,AUDIO_BUFFER);

-//               if (file_check(name2)) return Sound_NewSampleFromFile(name2,0,AUDIO_BUFFER);

+               if (file_check(name2)) return Mix_LoadMUS(name2);

          } /* for */

          

          fprintf(stderr,"ERROR in Sound_create_stream(): Could not load sound file: %s%s.(wav|ogg|mp3)\n",s_path, file);

@@ -252,6 +250,7 @@


          music_position=0;

          playing_music=true;

+        Mix_PlayMusic(music_sound[music_position], 0);

     } /* if */

} /* Sound_create_music */



@@ -279,7 +278,7 @@
     if (sound_enabled) {

          playing_music=false;

          for(i=0;i<3;i++) {

-               if (music_loaded) Sound_FreeSample(music_sound);

+               if (music_loaded) Mix_FreeMusic(music_sound);

               music_loaded=false;

          } /* if */

     } /* if */

@@ -293,7 +292,7 @@
     if (sound_enabled) {

          playing_music=false;

          for(i=0;i<3;i++) {

-               if (music_loaded) Sound_FreeSample(music_sound);

+               if (music_loaded) Mix_FreeMusic(music_sound);

          } /* if */

     } /* if */

} /* Sound_release_music */

@@ -302,12 +301,14 @@
void Sound_pause_music(void)

{

     playing_music=false;

+    Mix_PauseMusic();    

} /* Sound_pause_music */





void Sound_unpause_music(void)

{

     playing_music=true;

+    Mix_ResumeMusic();

} /* Sound_unpause_music */





@@ -345,64 +346,7 @@
          } /* if */



          playing_music=true;

+        Mix_PlayMusic(music_sound[music_position], 0);

     } /* if */



} /* music_recovery */

-

-

-void myMusicPlayer(void *udata, Uint8 *stream, int len)

-{

-     int i,act=0;

-     Sint16 *ptr2;

-

-     if (stream!=0) {

-          ptr2=(Sint16 *)stream;

-          if (playing_music) {

-               while(act<len) {

-                    if (music_loaded[music_position]) {

-                         /* Play a music file: */

-

-                         if ((music_sound[music_position]->flags&SOUND_SAMPLEFLAG_EOF)) {

-                              /* End of file: */

-                              if (music_loaded[music_position+1]) {

-                                   music_position++;

-                              } /* if */

-                              Sound_Rewind(music_sound[music_position]);

-                         } else {

-                              /* In the middle of the file: */

-                              int decoded=0;

-                              Sint16 *ptr;

-

-                              Sound_SetBufferSize(music_sound[music_position], len-act);

-                              

-                              decoded=Sound_Decode(music_sound[music_position]);

-                              ptr=(Sint16 *)music_sound[music_position]->buffer;

-                              for(i=0;i<decoded;i+=2,ptr++,ptr2++) {

-                                   *ptr2=((Sint32(*ptr)*Sint32(music_volume))/127);

-                              } /* for */

-                              act+=decoded;

-                         } /* if */

-                    } else {

-                         /* No music file loaded: */

-                         for(i=act;i<len;i++) stream=0;

-                         act=len;

-                    } /* if */

-               } /* while */

-          } else {

-               /* No music to play: */

-               for(i=0;i<len;i++) stream=0;

-          } /* if */

-     } else {

-          fprintf(stderr,"ERROR in myMusicPlayer(): null music stream!!\n");

-     } /* if */

-} /* myMusicPlayer */

-

-

-

-

-

-

-

-

-

-

diff -U 3 -H -d -r -N -- mog-unchanged-0.63.1548/sources/sound.h mog-PC-640x480-0.63.1548/sources/sound.h
--- mog-unchanged-0.63.1548/sources/sound.h     2008-09-13 16:31:49.000000000 -0300
+++ mog-PC-640x480-0.63.1548/sources/sound.h     2010-07-09 18:10:10.000000000 -0300
@@ -19,8 +19,8 @@
void Sound_unpause_music(void);

void music_recovery(void);
+void onMusicFinished();

-void myMusicPlayer(void *udata, Uint8 *stream, int len);
void PlayAudioQueue(void);

#endif


Edited by amoreira on 11 July 2010 at 16:33
Back to Top View amoreira's Profile Search for other posts by amoreira Send Private Message Add to Buddy List
 
amoreira
Newbie
Newbie


Joined: 04 January 2010
Location: Brazil
Posts: 25
Posted: 11 July 2010 at 16:46 | IP Logged Quote amoreira

With this patch, you should be able to remove the -lSDL_sound piece from the Makefile, while retaining all the functionalities.

A few known issues with this patch:

- There seems to be a very small delay when the music loops. But I'm not sure if this also happens in the original. *

- When changing the sound set using F11, the music in progress will play from the beginning of the file, instead of playing from the current playback position. **

* This could be improved by changing the loops parameter in the calls to Mix_PlayMusic(), using -1 if the music is the last one in the sequence. But I'm not sure about how Mix_HookMusicFinished() is triggered when the music is in endless loop.

** This might be fixed with a clever trick: using the difference between the value returned by gettimeofday() (or the corresponding function in non-POSIX OS's) when the song is started, and when the sound set is changed. This difference value could then be used as parameter of a call to Mix_SetMusicPosition().
Back to Top View amoreira's Profile Search for other posts by amoreira Send Private Message Add to Buddy List
 
Jorito
Admin Group
Admin Group
Avatar

Joined: 30 December 2002
Location: Netherlands
Posts: 1930
Posted: 11 July 2010 at 16:48 | IP Logged Quote Jorito

Azrael wrote:
Btw: What did you mean by asking Popolon "on the forum" above?


Popolon (Santi in real life) is the coder of all the Braingames remakes. If you have questions about the code, better ask him! Feel free to use the forum's private message option to point him to the forums.
Back to Top View Jorito's Profile Search for other posts by Jorito Visit Jorito's Homepage Send Private Message Add to Buddy List
 
Azrael
Newbie
Newbie
Avatar

Joined: 07 July 2010
Location: Germany
Posts: 11
Posted: 11 July 2010 at 17:06 | IP Logged Quote Azrael

amoreira wrote:
I don't know how to attach a file to a post (is this possible?). So, I will just paste here, inline, the contents of the diff file. Since I don't have an SVN working copy (is there an SVN for MoG, by the way?), the base was version 0.63.1548, downloaded from the website.


I don't think this forum allows attachment, but you could use some upload or nopaste service...

I didn't find a public SVN either. But there are nightly exports here. But a diff on this and the v0.63 source showed only additional Makefiles for Win and Mac (where the v0.63 only had Linux...).

amoreira wrote:
I ran Kompare over two different working copies of this source code, one of them unchanged. So, I don't know how easily this patch can be applied to a single working copy. Please notify me if you have any trouble


This should be usable as patch (See here), but it would be nice if you could send me the cpp-/h-files via eMail. You never know what a forum makes out of fileencoding, lineendings, tabs or quotes etc.

Thanks a lot!
Back to Top View Azrael's Profile Search for other posts by Azrael Send Private Message Add to Buddy List
 
Azrael
Newbie
Newbie
Avatar

Joined: 07 July 2010
Location: Germany
Posts: 11
Posted: 11 July 2010 at 17:12 | IP Logged Quote Azrael

Jorito wrote:
Azrael wrote:
Btw: What did you mean by asking Popolon "on the forum" above?


Popolon (Santi in real life) is the coder of all the Braingames remakes. If you have questions about the code, better ask him! Feel free to use the forum's private message option to point him to the forums.


Ah! Okay, you meant PM by "on the forum" ... That did somehow confuse me, since I actually posted on "the forum". Nevermind! And thanks for telling me!!

Edited by Azrael on 11 July 2010 at 17:13
Back to Top View Azrael's Profile Search for other posts by Azrael Send Private Message Add to Buddy List
 
Popolon
Admin Group
Admin Group
Avatar

Joined: 05 November 2002
Location: Spain
Posts: 3135
Posted: 12 July 2010 at 18:04 | IP Logged Quote Popolon

Hi all, sorry for not seeing this post earlier!

About the parenthesis, the right way should be: (ENEMY or (ITEM and STATE))

Which is the standard C++ way.

Btw, I'm really, really sorry you have to put up with the source code of MoG, hehehe, it's the most patchy piece of code I've ever seen (and I can say it, since I coded it ;)).
Back to Top View Popolon's Profile Search for other posts by Popolon Visit Popolon's Homepage Send Private Message Add to Buddy List
 
Azrael
Newbie
Newbie
Avatar

Joined: 07 July 2010
Location: Germany
Posts: 11
Posted: 13 July 2010 at 09:47 | IP Logged Quote Azrael

Ah, Great! Thanks!!

Popolon wrote:
Btw, I'm really, really sorry you have to put up with the source code of MoG, hehehe, it's the most patchy piece of code I've ever seen (and I can say it, since I coded it ;)).


...and it's getting way more patchy, since I'm adding ifdef's for the PSP build!!

Btw, I wondered: Is there an Editor/IDE/Jedi-Mindtrick that allows hiding certain paths of precompiler-ifdef-flags? e.g. parsing them and then allowing one to choose which to see and which not!?


EDIT: There obviously is, namely unifdef, rmifdef, scpp and rmsif. And emacs has a hide-ifdef-mode.

Anyone ever used one of these!?


Edited by Azrael on 22 July 2010 at 15:35
Back to Top View Azrael's Profile Search for other posts by Azrael Send Private Message Add to Buddy List
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum

Powered by Web Wiz Forums version 7.01
Copyright ©2001-2003 Web Wiz Guide

This page was generated in 0,3906 seconds.