knepe / cdogs-sdl-android

Android port of C-Dogs SDL
http://cxong.github.io/cdogs-sdl/
GNU Lesser General Public License v2.1
5 stars 3 forks source link

Custom build flag #1

Open cxong opened 11 years ago

cxong commented 11 years ago

I'd like to customise the android build by removing useless menu items. To detect the android build, the build script should define a compiler flag - maybe __ANDROID__.

In project/jni/application/c-dogs/AndroidAppSettings.cfg line 182, change this:

AppCflags='-O2 -finline-functions -D__MACTYPES__'

to this:

AppCflags='-O2 -finline-functions -D__MACTYPES__ -D__ANDROID__'

I haven't built the android port myself so I'm not sure if this works.

knepe commented 11 years ago

It should work! Will test and advise, I'm just a bit busy now and some weeks ahead..

cxong commented 11 years ago

Just to explain: this only adds a compiler flag available to C-Dogs; it does nothing on its own. C-Dogs will have to check if the flag is set, and modify the build.

For example, I was thinking of removing the "redefine keys..." menu, disabling "2 player" and "Dogfight" when there are no joysticks connected etc. A more ambitious goal would be to make a touch interface menu.

knepe commented 10 years ago

I have added the flag, but I'm unsure how I can test it?

cxong commented 10 years ago

@knepe thanks for adding the flag; I haven't used it in C-Dogs yet so you won't see any effect. That task is in the referenced issue cxong/cdogs-sdl#132

I can quickly implement a few so you can test by updating the sources and rebuilding. I'll let you know when I've done that.

cxong commented 10 years ago

Please try building with the latest revision (cxong/cdogs-sdl@305809b); you shouldn't see the fullscreen or redefine keys menu items.

knepe commented 10 years ago

Hey :)

I had a major breakdown of my build machine, so I lost my setup :( anyhow, I still got the src etc and was planning to build and release a new build to Play Store, I see you have added tons of things. But, I have an issue now with compiling the src, something with the lib hqx, the error is something with "IL/il.h no such file or folder". I guess that lib has some dependencies which I'm missing? Do you know how to fix this? Thank you

//Tobias

2013/7/31 Cong notifications@github.com

Just to explain: this only adds a compiler flag available to C-Dogs; it does nothing on its own. C-Dogs will have to check if the flag is set, and modify the build.

For example, I was thinking of removing the "redefine keys..." menu, disabling "2 player" and "Dogfight" when there are no joysticks connected etc. A more ambitious goal would be to make a touch interface menu.

— Reply to this email directly or view it on GitHubhttps://github.com/knepe/cdogs-sdl-android/issues/1#issuecomment-21832097 .

cxong commented 10 years ago

No I've never seen IL/il.h; libhqx should have no dependencies. Could you please show the full error output? Maybe it's something else.

knepe commented 10 years ago

Hm, okay here's the full error output (I think, not sure if cbehave is unrelated to the error): jni/../jni/application/c-dogs/src/src/tests/cbehave/cbehave.c -o ./obj/local/armeabi/objs/application/c-dogs/src/src/tests/cbehave/cbehave.o jni/../jni/application/c-dogs/src/src/cdogs/hqx/src/hqx.c:23:19: fatal error: IL/il.h: No such file or directory compilation terminated. make: *** [obj/local/armeabi/objs/application/c-dogs/src/src/cdogs/hqx/src/hqx.o] Error 1

2013/12/31 Cong notifications@github.com

No I've never seen IL/il.h; libhqx should have no dependencies. Could you please show the full error output? Maybe it's something else.

— Reply to this email directly or view it on GitHubhttps://github.com/knepe/cdogs-sdl-android/issues/1#issuecomment-31377128 .

cxong commented 10 years ago

ok I see it's trying to compile hqx.c; I think that's a sample program and is not needed to build libhqx. You can exclude that file from the build, or if it's possible - I'm not sure how - build the sources using CMake.

knepe commented 10 years ago

Ah okay. I can exclude files from the build np, will try that, thanks :-) On Dec 31, 2013 1:32 AM, "Cong" notifications@github.com wrote:

ok I see it's trying to compile hqx.c; I think that's a sample program and is not needed to build libhqx. You can exclude that file from the build, or if it's possible - I'm not sure how - build the sources using CMake.

— Reply to this email directly or view it on GitHubhttps://github.com/knepe/cdogs-sdl-android/issues/1#issuecomment-31377924 .

knepe commented 10 years ago

Hi

Got it working again now :) the ANDROID flag seem to work, I can't see those menu items you mentioned :)

One thing though, which could be my phone, but the game seems to be running in slowmotion (?). Anything you know that could cause that or should I check another phone?

//Tobias

2013/12/31 Tobias Johansson kneppedyr@gmail.com

Ah okay. I can exclude files from the build np, will try that, thanks :-) On Dec 31, 2013 1:32 AM, "Cong" notifications@github.com wrote:

ok I see it's trying to compile hqx.c; I think that's a sample program and is not needed to build libhqx. You can exclude that file from the build, or if it's possible - I'm not sure how - build the sources using CMake.

— Reply to this email directly or view it on GitHubhttps://github.com/knepe/cdogs-sdl-android/issues/1#issuecomment-31377924 .

cxong commented 10 years ago
knepe commented 10 years ago

Running at lowest resoultion (I think) and nearest neighbour (it was set to this as default) From the log: SDL_SetVideoMode(): application requested mode 320x240 OpenGL 0 HW 0 BPP 16

I think that is correct, but abit puzzled about the HW tag, I think I need the SW tag or else it won't work that good on Android (I've read). I checked grafx.c and that seem to init with SW flag? https://github.com/cxong/cdogs-sdl/blob/master/src/cdogs/grafx.c#L299

Maybe it gets the SW flag anyway..?

2014/1/3 Cong notifications@github.com

  • Check the resolution that it's running under; it should run faster with lower resolutions
  • Change the scaling mode to nearest neighbour; it may be defaulting to hqx which unfortunately is very slow. Which version of the source are you using? I can change the defaults or you can change them in the android build; they are set at the end of src/cdogs/config.c: https://github.com/cxong/cdogs-sdl/blob/master/src/cdogs/config.c#L331

— Reply to this email directly or view it on GitHubhttps://github.com/knepe/cdogs-sdl-android/issues/1#issuecomment-31500747 .

cxong commented 10 years ago

SDL_SetVideoMode(): application requested mode 320x240 OpenGL 0 HW 0 BPP 16

Doesn't HW 0 mean it's SW mode? Anyway if you still find performance to be poor, unfortunately there's not much else that can be done. I've done some profiling recently and most of the slowdown is due to pixel conversions that were added a while ago, these need to be optimised but it will be a lot of work.

knepe commented 10 years ago

Yeah you're probably right about the SetVideoMode thingie, sounds logical :)

Okay, it ran smooth on the last build I made (6 months ago maybe), but I'm gonna test on another phone now to be sure it's not my phone.

2014/1/3 Cong notifications@github.com

SDL_SetVideoMode(): application requested mode 320x240 OpenGL 0 HW 0 BPP 16

Doesn't HW 0 mean it's SW mode? Anyway if you still find performance to be poor, unfortunately there's not much else that can be done. I've done some profiling recently and most of the slowdown is due to pixel conversions that were added a while ago, these need to be optimised but it will be a lot of work.

— Reply to this email directly or view it on GitHubhttps://github.com/knepe/cdogs-sdl-android/issues/1#issuecomment-31501279 .

knepe commented 10 years ago

Tested now, and it seems to work as it should, have you changed anything regarding movement speed of player/enemies? Or do that change depending on difficulty setting?

2014/1/4 Tobias Johansson kneppedyr@gmail.com

Yeah you're probably right about the SetVideoMode thingie, sounds logical :)

Okay, it ran smooth on the last build I made (6 months ago maybe), but I'm gonna test on another phone now to be sure it's not my phone.

2014/1/3 Cong notifications@github.com

SDL_SetVideoMode(): application requested mode 320x240 OpenGL 0 HW 0 BPP 16

Doesn't HW 0 mean it's SW mode? Anyway if you still find performance to be poor, unfortunately there's not much else that can be done. I've done some profiling recently and most of the slowdown is due to pixel conversions that were added a while ago, these need to be optimised but it will be a lot of work.

— Reply to this email directly or view it on GitHubhttps://github.com/knepe/cdogs-sdl-android/issues/1#issuecomment-31501279 .

knepe commented 10 years ago

The thing is, that it does not lag, it's just the movement of player/enemies that are slower than before.

2014/1/4 Tobias Johansson kneppedyr@gmail.com

Tested now, and it seems to work as it should, have you changed anything regarding movement speed of player/enemies? Or do that change depending on difficulty setting?

2014/1/4 Tobias Johansson kneppedyr@gmail.com

Yeah you're probably right about the SetVideoMode thingie, sounds logical :)

Okay, it ran smooth on the last build I made (6 months ago maybe), but I'm gonna test on another phone now to be sure it's not my phone.

2014/1/3 Cong notifications@github.com

SDL_SetVideoMode(): application requested mode 320x240 OpenGL 0 HW 0 BPP 16

Doesn't HW 0 mean it's SW mode? Anyway if you still find performance to be poor, unfortunately there's not much else that can be done. I've done some profiling recently and most of the slowdown is due to pixel conversions that were added a while ago, these need to be optimised but it will be a lot of work.

— Reply to this email directly or view it on GitHubhttps://github.com/knepe/cdogs-sdl-android/issues/1#issuecomment-31501279 .

cxong commented 10 years ago

Now that you mention it, I remember I've raised the FPS from 30 to 60. 60 may be overkill for mobile games, so I can add a frame skip or FPS cap option.

knepe commented 10 years ago

Ah yes, that might be the issue maybe. Where in the code do you set that? I can try and change it to 30 again locally and build to see if that solves it, and maybe you can use the android flag to set that to 30 if that solves it?

2014/1/4 Cong notifications@github.com

Now that you mention it, I remember I've raised the FPS from 30 to 60. 60 may be overkill for mobile games, so I can add a frame skip or FPS cap option.

— Reply to this email directly or view it on GitHubhttps://github.com/knepe/cdogs-sdl-android/issues/1#issuecomment-31564037 .

cxong commented 10 years ago

The FPS code isn't the best right now; you can try making the following changes:

https://github.com/cxong/cdogs-sdl/blob/master/src/game.c#L190 change ticksIdeal to 33

https://github.com/cxong/cdogs-sdl/blob/master/src/game.c#L657 change ticks to 2

knepe commented 10 years ago

Thanks, that worked :)

Any possibility that you can set these below for the ANDROID flag?:

2014/1/4 Cong notifications@github.com

The FPS code isn't the best right now; you can try making the following changes:

https://github.com/cxong/cdogs-sdl/blob/master/src/game.c#L190 change ticksIdeal to 33

https://github.com/cxong/cdogs-sdl/blob/master/src/game.c#L657 change ticks to 2

— Reply to this email directly or view it on GitHubhttps://github.com/knepe/cdogs-sdl-android/issues/1#issuecomment-31565827 .

cxong commented 10 years ago

I've created an issue for this: cxong/cdogs-sdl#207

I'd still like to leave the number of players selection in; if no other players join then the AI takes over as co-op AI.

Unfortunately I'm busy doing some other work so I may get this done some time next week.

knepe commented 10 years ago

Yes you are right lets leave that as it is :-) On Jan 4, 2014 12:44 PM, "Cong" notifications@github.com wrote:

I've created an issue for this: cxong/cdogs-sdl#207https://github.com/cxong/cdogs-sdl/issues/207

I'd still like to leave the number of players selection in; if no other players join then the AI takes over as co-op AI.

— Reply to this email directly or view it on GitHubhttps://github.com/knepe/cdogs-sdl-android/issues/1#issuecomment-31576726 .

cxong commented 10 years ago

Hi, I've fixed the issues in the game; it can skip frames to a minimum of 5 frames per second, which means the game should still be playable and fast but only seem a bit choppy.

If you're not in a hurry to release, I suggest waiting a bit until the testing is done for the next release. I've done a lot of refactoring so there's a risk of bugs introduced.

knepe commented 10 years ago

Nice! I'm not in a hurry, I'm trying to work out which commit made the game running so slow on Android right now. I'm testing commits since the one that worked good, and looking for the commit that caused it. I don't really know what to look for in the code, so I'm just trying until I find the commit then maybe you can help me find why that commit made it run slower :)

2014/1/8 Cong notifications@github.com

Hi, I've fixed the issues in the game; it can skip frames to a minimum of 5 frames per second, which means the game should still be playable and fast but only seem a bit choppy.

If you're not in a hurry to release, I suggest waiting a bit until the testing is done for the next release. I've done a lot of refactoring so there's a risk of bugs introduced.

— Reply to this email directly or view it on GitHubhttps://github.com/knepe/cdogs-sdl-android/issues/1#issuecomment-31824980 .

cxong commented 10 years ago

I think it's probably this: https://github.com/cxong/cdogs-sdl/commit/f05692d35fa3d7ce713efa5f223bdc6501bd7717 from 5-6 months ago or between version 0.4.4 and 0.4.5. The graphics were converted from using an 8-bit palette to RGB, but since the graphics files are still paletted, drawing them meant pixel conversions and that's most likely what slows things down.

I plan to convert everything to RGB eventually so at least those conversions won't be necessary, and what will be even better would be to use OpenGL textures and accelerate everything.

knepe commented 10 years ago

Ah, yes that is probably it. When do you plan on converting it to RGB? Is that alot of work?

2014/1/9 Cong notifications@github.com

I think it's probably this: cxong/cdogs-sdl@f05692dhttps://github.com/cxong/cdogs-sdl/commit/f05692d35fa3d7ce713efa5f223bdc6501bd7717 from 5-6 months ago or between version 0.4.4 and 0.4.5. The graphics were converted from using an 8-bit palette to RGB, but since the graphics files are still paletted, drawing them meant pixel conversions and that's most likely what slows things down.

I plan to convert everything to RGB eventually so at least those conversions won't be necessary, and what will be even better would be to use OpenGL textures and accelerate everything.

— Reply to this email directly or view it on GitHubhttps://github.com/knepe/cdogs-sdl-android/issues/1#issuecomment-31916171 .

cxong commented 10 years ago

Yes it will take quite some work; maybe I'll aim to do it in one or two releases.

cxong commented 10 years ago

Good news; I've discovered that the slowdown was almost entirely due to a very inefficient gamma correction routine. I've fixed that and now the game runs much faster than even version 0.4.4.

knepe commented 10 years ago

Cool! Will try the new version when I get back home :)

2014/1/13 Cong notifications@github.com

Good news; I've discovered that the slowdown was almost entirely due to a very inefficient gamma correction routine. I've fixed that and now the game runs much faster than even version 0.4.4.

— Reply to this email directly or view it on GitHubhttps://github.com/knepe/cdogs-sdl-android/issues/1#issuecomment-32173697 .

knepe commented 10 years ago

Hi

Tried with the newest commit now, seems like it runs better. Still not like before though, but OK :) Was FPS_FRAMELIMIT set to 30 before you changed it? I didn't find the #define for ANDROID, only #define FPS_FRAMELIMIT 70

2014-01-13 Tobias Johansson kneppedyr@gmail.com:

Cool! Will try the new version when I get back home :)

2014/1/13 Cong notifications@github.com

Good news; I've discovered that the slowdown was almost entirely due to a very inefficient gamma correction routine. I've fixed that and now the game runs much faster than even version 0.4.4.

Reply to this email directly or view it on GitHubhttps://github.com/knepe/cdogs-sdl-android/issues/1#issuecomment-32173697 .

cxong commented 10 years ago

I haven't lowered FPS_FRAMELIMIT for android, I was hoping the optimisations and frame skipping would have made things better than before but it seems not? I will try later with FPS_FRAMELIMIT at 35 - half the normal rate. Will let you know once that's done.

knepe commented 10 years ago

Okay thanks :)

FYI I tried with FPS_FRAMELIMIT 30 but only got ~22 FPS ingame. With Nearest neighbour and lowest resolution. With newer phones than mine (I have a Samsung Galaxy Nexus), the game is smooth, But if I try with my old version (the one that is on Play Store now, I get smooth gameplay even on my phone).

2014-02-05 Cong notifications@github.com:

I haven't lowered FPS_FRAMELIMIT for android, I was hoping the optimisations and frame skipping would have made things better than before but it seems not? I will try later with FPS_FRAMELIMIT at 35 - half the normal rate. Will let you know once that's done.

Reply to this email directly or view it on GitHubhttps://github.com/knepe/cdogs-sdl-android/issues/1#issuecomment-34124578 .

cxong commented 10 years ago

Maybe performance on Android is different than on PCs; the new version is definitely faster on mine. Did you test both using the same graphics resolution?

cxong commented 10 years ago

Please try the latest version; I've made another optimisation (to reverse a pessimisation actually) which in my testing improved frame rates by about 20%.