Game Development Reference
In-Depth Information
Bringing Doom to a Mobile Device
After working on Wolfenstein 3D for Android, I was so excited that I decided my next challenge would be
to bring the great game Doom to the platform. But I had my doubts that this could even be achieved
once I looked at the complexity and the amount of original C code. Listing 7-1 shows a portion of the
total number of lines of C code of the popular Doom engine PrBoom (available from
http://prboom.sourceforge.net/ ).
I knew I had two choices for this project:
Port the C code line by line to Java. I even started porting a few files to Java. Believe
me when I say that this is not a good idea. The amount of time that it would take to
do this makes the project unfeasible, especially considering that the hard work
must be done pro bono .
Find a way to pack the game as a dynamic shared object (DSO) and call it from Java
using JNI. This option seems to be simpler and quicker, but requires expert knowledge
of C and JNI, as well as changes to the original game to glue both languages together.
Given these two options, the latter is the best approach to the problem, so I decided to build a DSO
and glue it to Java with JNI.
Listing 7-1. Portion of Code for the PrBoom Doom Engine (Approximately 90,000 Lines in Total)
$ wc -l *.c
1585 am_map.c
554 d_client.c
3093 d_deh.c
140 d_items.c
1744 d_main.c
759 d_server.c
48 doomdef.c
108 doomstat.c
85 dstrings.c
668 f_finale.c
202 f_wipe.c
2979 g_game.c
2717 gl_main.c
957 gl_texture.c
767 hu_lib.c
1593 hu_stuff.c
866 mmus2mid.c
467 p_ceilng.c
// …
450 r_fps.c
649 r_main.c
788 r_patch.c
468 r_plane.c
854 r_segs.c
56 r_sky.c
1077 r_things.c
714 s_sound.c
Search WWH ::




Custom Search