Jump to content

GEMRB on Android


Guest Chas Grady

Recommended Posts

I applied a part of your diff. The buildsystem uglyness was left out, as was swab (under what license is it available? Does the android sdk provide an unistd.h (should contain swab)?) and the version definition (I'll move it to the build system). Is the size of an integer not 4 bytes? Or better yet, what error did you get without that modification.

Link to comment

Android has unistd.h, but without swab(). And cygwin not contains swab too. I get swab() implementation from the WEB. I could take out from Linux libc, but I not have installed linux.

Size of an integer is 4 bytes. But macro SIZEOF_INT is not defined in Android, you may add this lines, instead my changes.

 

#ifdef ANDROID

#define SIZEOF_INT 4

#define SIZEOF_LONG_INT 4

#endif

Link to comment
Do you have a link? The glibc implementation is a bit different and supposedly safer with regards to casting.

http://www.sfr-fresh.com/unix/misc/glibc-2..._8c_source.html

 

Oh, why /do/ you need the VERSION and a redefined PACKAGE?

 

I forgot link. You may replace my swab.c to implementation from glibc, it's also nice.

PACKAGE is not defined in Android. Android does not support packages.

 

Android has many differences from linux, despite the fact that it uses linux kernel.

Android using Java for applications. All interactions with the user interface are possible in Java only.

Android does not support elf executables, support libraries only. I link GemRB as shared library and use a Java wrapper (included in pelya's SDL port) to call the main() and interaction with the application. It's some slow, but no other way. I do not use cmake for build. In the Android uses a different tools.

 

VERSION is not needed. I thought to use it for auto-generated building config, but refused.

Link to comment
Do you have pointers on where to get the tools to build GemRB for android?

 

I am the sometimes maintainer of the sometimes buildbot, and would like to get it set up to do android builds.

You need Android NDK, I'm use patched NDK from Crystax: http://www.crystax.net/android/ndk-r4.php

Pelya's SDL port: http://www.anddev.org/code-snippets-for-an...-1-6-t9218.html

if you need Python, you can get it here: http://code.google.com/p/android-scripting/

Link to comment

lynx, I've added two new functions in Audio interface: Pause() and Resume(), but implement it in OpenALPlugin only, not in SDLAudio. I use these functions with switching application to background. If application goes to background, music pauses, if comes back to foreground - music plays from the same place.

This functionality needs for phones, but very usable for PC's too.

 

bool OpenALAudioDriver::Pause()
{
SDL_mutexP( musicMutex );
if (!alIsSource( MusicSource )) {
	SDL_mutexV( musicMutex );
	return false;
}
alSourcePause(MusicSource);
checkALError("Unable to pause music source", "WARNING");
MusicPlaying = false;
SDL_mutexV( musicMutex );
return true;
}

bool OpenALAudioDriver::Resume()
{
SDL_mutexP( musicMutex );
if (!alIsSource( MusicSource )) {
	SDL_mutexV( musicMutex );
	return false;
}
alSourcePlay(MusicSource);
checkALError("Unable to resume music source", "WARNING");
MusicPlaying = true;
SDL_mutexV( musicMutex );
return true;
}

Link to comment
Beholder - good job for making this port :-) I only want to ask about progress of the project and if u can say, when it will be released for public? :)

I think that very soon. In principle, is almost ready. The port will only work on devices with VGA or higher. Also, it requires at least 50-60 megabytes of free RAM.

I do not know where I publish it. It makes no sense to publish in the Market, because the engine will not work without the original game resources. Maybe should publish the package on GemRB page in sourceforge.net? Developers, what do you think about this?

Link to comment
Beholder - good job for making this port :-) I only want to ask about progress of the project and if u can say, when it will be released for public? :D

I think that very soon. In principle, is almost ready. The port will only work on devices with VGA or higher. Also, it requires at least 50-60 megabytes of free RAM.

I do not know where I publish it. It makes no sense to publish in the Market, because the engine will not work without the original game resources. Maybe should publish the package on GemRB page in sourceforge.net? Developers, what do you think about this?

It's not a problem. On the market we got many types of emulators and they need some ROMs and BIOSes to work too :) If somebody wants to play IE based games, he will easily copy the game to SDcard and run it with ported GemRB for Android.

Market would give you more popularity, testers, people who will want to help in coding, maybe even some donations. Decision belongs to you :thumbsup:

 

VGA and 50-60MB of free ram is not much :D I will test it with my Motorola Milestone after you release it for sure.

Link to comment

It's not needed. This file generated by SDL-port's configuration script.

 

diff -c -r original//Audio.h my//Audio.h
*** original//Audio.h	2010-12-05 00:11:43.337400000 +0300
--- my//Audio.h	2010-12-07 00:11:24.887633400 +0300
***************
*** 61,66 ****
--- 61,68 ----
  virtual void ResetMusics() = 0;
  virtual bool Play() = 0;
  virtual bool Stop() = 0;
+ 	virtual bool Pause() = 0;
+ 	virtual bool Resume() = 0;
  virtual int CreateStream(Holder<SoundMgr>) = 0;
  virtual void UpdateListenerPos(int XPos, int YPos ) = 0;
  virtual void GetListenerPos(int &XPos, int &YPos ) = 0;
diff -c -r original//Control.cpp my//Control.cpp
*** original//Control.cpp	2010-12-04 01:55:25.744735300 +0300
--- my//Control.cpp	2010-12-06 22:07:32.823633400 +0300
***************
*** 129,157 ****
  {
	  case 'o': // volume down
	  case 'p': // volume up
! 			ieDword Ambients, Movie, Music, SFX, Voices;
! 			core->GetDictionary()->Lookup( "Volume Ambients", Ambients );
! 			core->GetDictionary()->Lookup( "Volume Movie", Movie );
! 			core->GetDictionary()->Lookup( "Volume Music", Music );
! 			core->GetDictionary()->Lookup( "Volume SFX", SFX );
! 			core->GetDictionary()->Lookup( "Volume Voices", Voices );
		  if(Key=='o')
		  {
! 				if(Ambients>0) Ambients--;
! 				if(Movie>0) Movie--;
! 				if(Music>0) Music--;
! 				if(SFX>=0) SFX--;
! 				if(Voices>0) Voices--;
		  }
		  else
		  {
! 				if(Ambients<100) Ambients++;
! 				if(Movie<100) Movie++;
! 				if(Music<100) Music++;
! 				if(SFX<100) SFX++;
! 				if(Voices<100) Voices++;
		  }
! 			core->GetDictionary()->SetAt( "Volume Ambients", Ambients );
		  core->GetDictionary()->SetAt( "Volume Movie", Movie );
		  core->GetDictionary()->SetAt( "Volume Music", Music );
		  core->GetDictionary()->SetAt( "Volume SFX", SFX );
--- 129,157 ----
  {
	  case 'o': // volume down
	  case 'p': // volume up
! 			int Ambients, Movie, Music, SFX, Voices;
! 			core->GetDictionary()->Lookup( "Volume Ambients", (ieDword&)Ambients );
! 			core->GetDictionary()->Lookup( "Volume Movie", (ieDword&)Movie );
! 			core->GetDictionary()->Lookup( "Volume Music", (ieDword&)Music );
! 			core->GetDictionary()->Lookup( "Volume SFX", (ieDword&)SFX );
! 			core->GetDictionary()->Lookup( "Volume Voices", (ieDword&)Voices );
		  if(Key=='o')
		  {
! 				if(Ambients>0) Ambients-=10; if(Ambients<0) Ambients=0;
! 				if(Movie>0) Movie-=10; if(Movie<0) Movie=0;
! 				if(Music>0) Music-=10; if(Music<0) Music=0;
! 				if(SFX>0) SFX-=10; if(SFX<0) SFX=0;
! 				if(Voices>0) Voices-=10; if(Voices<0) Voices=0;
		  }
		  else
		  {
! 				if(Ambients<100) Ambients+=10; if(Ambients>100) Ambients=100;
! 				if(Movie<100) Movie+=10; if(Movie>100) Movie=100;
! 				if(Music<100) Music+=10; if(Music>100) Music=100;
! 				if(SFX<100) SFX+=10; if(SFX>100) SFX=100;
! 				if(Voices<100) Voices+=10; if(Voices>100) Voices=100;
		  }
! 			core->GetDictionary()->SetAt( "Volume Ambients", (ieDword)Ambients );
		  core->GetDictionary()->SetAt( "Volume Movie", Movie );
		  core->GetDictionary()->SetAt( "Volume Music", Music );
		  core->GetDictionary()->SetAt( "Volume SFX", SFX );
diff -c -r original//GemRB.cpp my//GemRB.cpp
*** original//GemRB.cpp	2010-12-05 00:11:43.313400000 +0300
--- my//GemRB.cpp	2010-12-07 00:12:44.595633400 +0300
***************
*** 34,44 ****
 #endif

 #ifdef ANDROID
! #include <SDL.h>
 #endif

 int main(int argc, char* argv[])
 {
  Interface::SanityCheck(VERSION_GEMRB);
  core = new Interface( argc, argv );
  if (core->Init() == GEM_ERROR) {
--- 34,60 ----
 #endif

 #ifdef ANDROID
! #include <SDL/SDL.h>
! #include "audio.h"
! 
! // pause audio playing if app goes in background
! static void appPutToBackground()
! {
!   core->GetAudioDrv()->Pause();
! }
! // resume audio playing if app return to foreground
! static void appPutToForeground()
! {
!   core->GetAudioDrv()->Resume();
! }
! 
 #endif

 int main(int argc, char* argv[])
 {
+ #ifdef ANDROID
+ 	SDL_ANDROID_SetApplicationPutToBackgroundCallback(&appPutToBackground, &appPutToForeground);
+ #endif	
  Interface::SanityCheck(VERSION_GEMRB);
  core = new Interface( argc, argv );
  if (core->Init() == GEM_ERROR) {
diff -c -r original//NullSound/NullSound.cpp my//NullSound/NullSound.cpp
*** original//NullSound/NullSound.cpp	2010-12-05 00:11:46.597400000 +0300
--- my//NullSound/NullSound.cpp	2010-12-07 00:12:44.621633400 +0300
***************
*** 63,68 ****
--- 63,78 ----
  return true;
 }

+ bool NullSound::Pause()
+ {
+ 	return true;
+ }
+ 
+ bool NullSound::Resume()
+ {
+ 	return true;
+ }
+ 
 void NullSound::ResetMusics()
 {
 }
diff -c -r original//NullSound/NullSound.h my//NullSound/NullSound.h
*** original//NullSound/NullSound.h	2010-12-05 00:11:46.599400000 +0300
--- my//NullSound/NullSound.h	2010-12-07 00:12:44.627633400 +0300
***************
*** 32,37 ****
--- 32,39 ----
  int CreateStream(Holder<SoundMgr>);
  bool Play();
  bool Stop();
+ 	bool Pause();
+ 	bool Resume();
  bool CanPlay();
  bool IsSpeaking();
  void ResetMusics();
diff -c -r original//OpenALAudio/OpenALAudio.cpp my//OpenALAudio/OpenALAudio.cpp
*** original//OpenALAudio/OpenALAudio.cpp	2010-12-05 00:11:46.613400000 +0300
--- my//OpenALAudio/OpenALAudio.cpp	2010-12-07 00:16:35.005633400 +0300
***************
*** 506,511 ****
--- 506,539 ----
  return true;
 }

+ bool OpenALAudioDriver::Pause()
+ {
+ 	SDL_mutexP( musicMutex );
+ 	if (!alIsSource( MusicSource )) {
+ 		SDL_mutexV( musicMutex );
+ 		return false;
+ 	}
+ 	alSourcePause(MusicSource);
+ 	checkALError("Unable to pause music source", "WARNING");
+ 	MusicPlaying = false;
+ 	SDL_mutexV( musicMutex );
+ 	return true;
+ }
+ 
+ bool OpenALAudioDriver::Resume()
+ {
+ 	SDL_mutexP( musicMutex );
+ 	if (!alIsSource( MusicSource )) {
+ 		SDL_mutexV( musicMutex );
+ 		return false;
+ 	}
+ 	alSourcePlay(MusicSource);
+ 	checkALError("Unable to resume music source", "WARNING");
+ 	MusicPlaying = true;
+ 	SDL_mutexV( musicMutex );
+ 	return true;
+ }
+ 
 int OpenALAudioDriver::CreateStream(Holder<SoundMgr> newMusic)
 {
  StackLock l(musicMutex, "musicMutex in CreateStream()");
diff -c -r original//OpenALAudio/OpenALAudio.h my//OpenALAudio/OpenALAudio.h
*** original//OpenALAudio/OpenALAudio.h	2010-12-05 00:11:46.615400000 +0300
--- my//OpenALAudio/OpenALAudio.h	2010-12-07 00:12:44.609633400 +0300
***************
*** 106,111 ****
--- 106,113 ----
  void ResetMusics();
  bool Play();
  bool Stop();
+ 	bool Pause();
+ 	bool Resume();
  int CreateStream(Holder<SoundMgr>);
  void UpdateListenerPos(int XPos, int YPos );
  void GetListenerPos( int &XPos, int &YPos );
diff -c -r original//SDLAudio/SDLAudio.h my//SDLAudio/SDLAudio.h
*** original//SDLAudio/SDLAudio.h	2010-12-05 00:11:46.677400000 +0300
--- my//SDLAudio/SDLAudio.h	2010-12-07 00:12:44.615633400 +0300
***************
*** 39,44 ****
--- 39,46 ----
  int CreateStream(Holder<SoundMgr>);
  bool Play();
  bool Stop();
+ 	bool Pause() {/*not implemented*/}
+ 	bool Resume() {/*not implemented*/}
  bool CanPlay();
  bool IsSpeaking();
  void ResetMusics();

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...