Root/supertux/patches/001-gp2x.patch

1Only in supertux-0.1.3: aclocal.m4
2diff -ur supertux-0.1.3/AUTHORS supertux-0.1.3-gp2x/AUTHORS
3--- supertux-0.1.3/AUTHORS 2005-07-02 14:37:30.000000000 +0300
4+++ supertux-0.1.3-gp2x/AUTHORS 2006-04-13 06:11:02.000000000 +0300
5@@ -91,6 +91,12 @@
6 
7     Royalty free CDROMs and FTP sites sounds
8 
9+Port to GP2X
10+-----------
11+ Ingo Arndt
12+ scachi@gmx.de
13+ http://www.bitmage.de
14+
15 More information and contacts
16 =============================
17 
18Only in supertux-0.1.3: autom4te.cache
19Only in supertux-0.1.3-gp2x: autoscan.log
20Only in supertux-0.1.3-gp2x: COMPILE4GP2X
21Only in supertux-0.1.3: config.guess
22Only in supertux-0.1.3: config.log
23Only in supertux-0.1.3: config.status
24Only in supertux-0.1.3: config.sub
25Only in supertux-0.1.3: configure
26diff -ur supertux-0.1.3/configure.ac supertux-0.1.3-gp2x/configure.ac
27--- supertux-0.1.3/configure.ac 2005-07-06 12:26:15.000000000 +0300
28+++ supertux-0.1.3-gp2x/configure.ac 2006-04-19 22:29:05.000000000 +0300
29@@ -76,13 +76,33 @@
30 CFLAGS="$CFLAGS $SDL_CFLAGS"
31 LIBS="$LIBS $SDL_LIBS"
32 
33+AM_PATH_LIBMIKMOD(,
34+ :,
35+ AC_MSG_ERROR([*** mikmod not found!]))
36+CXXFLAGS="$CXXFLAGS $LIBMIKMOD_CFLAGS"
37+CFLAGS="$CFLAGS $LIBMIKMOD_CFLAGS"
38+LIBS="$LIBS $LIBMIKMOD_LIBS"
39+
40 dnl Checks for additional libraries.
41+AC_CHECK_LIB(smpeg, SMPEG_status)
42+
43+AC_CHECK_LIB(mikmod, MikMod_Init)
44+
45 AC_CHECK_LIB(SDL_mixer, Mix_OpenAudio,,
46     AC_MSG_ERROR([SDL_mixer library required]))
47 
48+AC_CHECK_LIB(jpeg,jpeg_abort)
49+
50+AC_CHECK_LIB(z,compress)
51+
52+AC_CHECK_LIB(png,png_free)
53+
54 AC_CHECK_LIB(SDL_image, IMG_Load,,
55     AC_MSG_ERROR([SDL_image library required]))
56 
57+AC_CHECK_LIB(SDL_gfx, rotozoomSurface,,
58+ AC_MSG_ERROR([SDL_gfx library required]))
59+
60 if test "x${enable_opengl}" != "xno"; then
61   AX_CHECK_GL
62 fi
63@@ -95,7 +115,30 @@
64   LIBS="$LIBS $GL_LIBS"
65 fi
66 
67-AC_CHECK_LIB(z, gzopen,, AC_MSG_ERROR([*** zlib is missing]))
68+# compile for the testing the 320x240 resolution
69+# compile for the gp2x
70+AC_ARG_ENABLE(gp2x,
71+[ --enable-gp2x Build the gp2x version [default=no]],
72+ , enable_gp2x=no)
73+if test x$enable_gp2x = xyes; then
74+ CXXFLAGS="$CXXFLAGS -DGP2X"
75+fi
76+
77+AC_ARG_ENABLE(320x240,
78+[ --enable-320x240 Test the 320x240 resolution [default=no]],
79+ , enable_320x240=no)
80+if test x$enable_320x240 = xyes; then
81+ CXXFLAGS="$CXXFLAGS -DRES320X240"
82+fi
83+
84+# compile static
85+AC_ARG_ENABLE(static,
86+[ --enable-static Build the static version [default=no]],
87+ , enable_static=no)
88+if test x$enable_static = xyes; then
89+ CXXFLAGS="$CXXFLAGS -static"
90+fi
91+
92 
93 CXXFLAGS="$CXXFLAGS -DDATA_PREFIX='\"$datadir/supertux\"'"
94 
95@@ -110,6 +153,9 @@
96 echo " Profile Mode: $enable_gprof"
97 echo " Debug Mode: $enable_debug"
98 echo " OpenGL Support: $enable_opengl"
99+echo " 320x240 Resolution: $enable_320x240"
100+echo " GP2X Build (+320x240): $enable_gp2x"
101+echo " Static Build: $enable_static"
102 echo ""
103 
104 # EOF #
105Only in supertux-0.1.3/data: CREDITS
106Only in supertux-0.1.3/data: extro-bonus2.txt
107Only in supertux-0.1.3/data: extro-bonus.txt
108Only in supertux-0.1.3/data: extro.txt
109Only in supertux-0.1.3/data: images
110Only in supertux-0.1.3/data: intro.txt
111Only in supertux-0.1.3/data: levels
112Only in supertux-0.1.3/data: Makefile
113Only in supertux-0.1.3/data: Makefile.in
114Only in supertux-0.1.3/data: music
115Only in supertux-0.1.3/data: sounds
116Only in supertux-0.1.3/data: supertux.strf
117Only in supertux-0.1.3: depcomp
118Only in supertux-0.1.3: install-sh
119Only in supertux-0.1.3: m4
120Only in supertux-0.1.3: Makefile
121Only in supertux-0.1.3: Makefile.in
122Only in supertux-0.1.3: missing
123Only in supertux-0.1.3: mkinstalldirs
124Only in supertux-0.1.3: patches
125diff -ur supertux-0.1.3/src/badguy.cpp supertux-0.1.3-gp2x/src/badguy.cpp
126--- supertux-0.1.3/src/badguy.cpp 2005-06-22 00:16:07.000000000 +0300
127+++ supertux-0.1.3-gp2x/src/badguy.cpp 2006-04-20 21:32:23.000000000 +0300
128@@ -250,7 +250,11 @@
129           tux.kick_timer.start(KICKING_TIME);
130           set_sprite(img_mriceblock_flat_left, img_mriceblock_flat_right);
131           physic.set_velocity_x((dir == LEFT) ? -3.5 : 3.5);
132+#ifndef GP2X
133           play_sound(sounds[SND_KICK],SOUND_CENTER_SPEAKER);
134+#else
135+ play_chunk(SND_KICK);
136+#endif
137         }
138     }
139 
140@@ -260,6 +264,7 @@
141       check_horizontal_bump();
142       if(mode == KICK && changed != dir)
143         {
144+#ifndef GP2X
145           /* handle stereo sound (number 10 should be tweaked...)*/
146           if (base.x < scroll_x + screen->w/2 - 10)
147             play_sound(sounds[SND_RICOCHET], SOUND_LEFT_SPEAKER);
148@@ -267,6 +272,9 @@
149             play_sound(sounds[SND_RICOCHET], SOUND_RIGHT_SPEAKER);
150           else
151             play_sound(sounds[SND_RICOCHET], SOUND_CENTER_SPEAKER);
152+#else
153+ play_chunk(SND_RICOCHET);
154+#endif
155         }
156     }
157 
158@@ -455,11 +463,15 @@
159 
160       /* play explosion sound */ // FIXME: is the stereo all right? maybe we should use player cordinates...
161       if (base.x < scroll_x + screen->w/2 - 10)
162+#ifndef GP2X
163         play_sound(sounds[SND_EXPLODE], SOUND_LEFT_SPEAKER);
164       else if (base.x > scroll_x + screen->w/2 + 10)
165         play_sound(sounds[SND_EXPLODE], SOUND_RIGHT_SPEAKER);
166       else
167         play_sound(sounds[SND_EXPLODE], SOUND_CENTER_SPEAKER);
168+#else
169+ play_chunk(SND_EXPLODE);
170+#endif
171 
172     } else if(mode == BOMB_EXPLODE) {
173       remove_me();
174@@ -677,13 +689,21 @@
175     }
176 
177   // BadGuy fall below the ground
178+#ifndef RES320X240
179   if (base.y > screen->h) {
180+#else
181+ if (base.y > 640) {
182+#endif
183     remove_me();
184     return;
185   }
186 
187   // Once it's on screen, it's activated!
188+#ifndef RES320X240
189   if (base.x <= scroll_x + screen->w + OFFSCREEN_DISTANCE)
190+#else
191+ if (base.x <= scroll_x + 640 + OFFSCREEN_DISTANCE)
192+#endif
193     seen = true;
194 
195   if(!seen)
196@@ -743,7 +763,11 @@
197 BadGuy::draw()
198 {
199   // Don't try to draw stuff that is outside of the screen
200+#ifndef RES320X240
201   if(base.x <= scroll_x - base.width || base.x >= scroll_x + screen->w)
202+#else
203+ if(base.x <= scroll_x - base.width || base.x >= scroll_x + 640)
204+#endif
205     return;
206   
207   if(sprite_left == 0 || sprite_right == 0)
208@@ -811,7 +835,11 @@
209     
210   World::current()->add_score(base.x - scroll_x,
211                               base.y, 50 * player_status.score_multiplier);
212+#ifndef GP2X
213   play_sound(sounds[SND_SQUISH], SOUND_CENTER_SPEAKER);
214+#else
215+ play_chunk(SND_SQUISH);
216+#endif
217   player_status.score_multiplier++;
218 
219   dying = DYING_SQUISHED;
220@@ -830,7 +858,11 @@
221    
222     player->jump_of_badguy(this);
223     World::current()->add_score(base.x - scroll_x, base.y, 50 * player_status.score_multiplier);
224+#ifndef GP2X
225     play_sound(sounds[SND_SQUISH], SOUND_CENTER_SPEAKER);
226+#else
227+ play_chunk(SND_SQUISH);
228+#endif
229     player_status.score_multiplier++;
230     remove_me();
231     return;
232@@ -839,7 +871,11 @@
233     if (mode == NORMAL || mode == KICK)
234       {
235         /* Flatten! */
236+#ifndef GP2X
237         play_sound(sounds[SND_STOMP], SOUND_CENTER_SPEAKER);
238+#else
239+ play_chunk(SND_STOMP);
240+#endif
241         mode = FLAT;
242         set_sprite(img_mriceblock_flat_left, img_mriceblock_flat_right);
243         physic.set_velocity_x(0);
244@@ -847,7 +883,11 @@
245         timer.start(4000);
246       } else if (mode == FLAT) {
247         /* Kick! */
248+#ifndef GP2X
249         play_sound(sounds[SND_KICK], SOUND_CENTER_SPEAKER);
250+#else
251+ play_chunk(SND_KICK);
252+#endif
253 
254         if (player->base.x < base.x + (base.width/2)) {
255           physic.set_velocity_x(5);
256@@ -925,7 +965,11 @@
257                     score * player_status.score_multiplier);
258 
259   /* Play death sound: */
260+#ifndef GP2X
261   play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER);
262+#else
263+ play_chunk(SND_FALL);
264+#endif
265 }
266 
267 void BadGuy::explode(BadGuy *badguy)
268@@ -1053,7 +1097,11 @@
269       /* Get kicked if were flat */
270       if (mode == FLAT && !dying)
271       {
272+#ifndef GP2X
273         play_sound(sounds[SND_KICK], SOUND_CENTER_SPEAKER);
274+#else
275+ play_chunk(SND_KICK);
276+#endif
277 
278         // Hit from left side
279         if (player->base.x < base.x) {
280diff -ur supertux-0.1.3/src/configfile.cpp supertux-0.1.3-gp2x/src/configfile.cpp
281--- supertux-0.1.3/src/configfile.cpp 2005-06-22 00:16:07.000000000 +0300
282+++ supertux-0.1.3-gp2x/src/configfile.cpp 2006-04-10 13:32:19.000000000 +0300
283@@ -92,12 +92,22 @@
284   else
285     use_joystick = true;
286 
287+#ifndef GP2X
288   reader.read_int ("joystick-x", &joystick_keymap.x_axis);
289   reader.read_int ("joystick-y", &joystick_keymap.y_axis);
290   reader.read_int ("joystick-a", &joystick_keymap.a_button);
291   reader.read_int ("joystick-b", &joystick_keymap.b_button);
292   reader.read_int ("joystick-start", &joystick_keymap.start_button);
293   reader.read_int ("joystick-deadzone", &joystick_keymap.dead_zone);
294+#else
295+ reader.read_int ("joystick-up", &joystick_keymap.up_button);
296+ reader.read_int ("joystick-down", &joystick_keymap.down_button);
297+ reader.read_int ("joystick-right", &joystick_keymap.right_button);
298+ reader.read_int ("joystick-left", &joystick_keymap.left_button);
299+ reader.read_int ("joystick-a", &joystick_keymap.a_button);
300+ reader.read_int ("joystick-b", &joystick_keymap.b_button);
301+ reader.read_int ("joystick-start", &joystick_keymap.start_button);
302+#endif
303 
304   reader.read_int ("keyboard-jump", &keymap.jump);
305   reader.read_int ("keyboard-duck", &keymap.duck);
306@@ -130,12 +140,22 @@
307       fprintf(config, "\n\t;; joystick number (-1 means no joystick):\n");
308       fprintf(config, "\t(joystick %d)\n", use_joystick ? joystick_num : -1);
309 
310+#ifndef GP2X
311       fprintf(config, "\t(joystick-x %d)\n", joystick_keymap.x_axis);
312       fprintf(config, "\t(joystick-y %d)\n", joystick_keymap.y_axis);
313       fprintf(config, "\t(joystick-a %d)\n", joystick_keymap.a_button);
314       fprintf(config, "\t(joystick-b %d)\n", joystick_keymap.b_button);
315       fprintf(config, "\t(joystick-start %d)\n", joystick_keymap.start_button);
316       fprintf(config, "\t(joystick-deadzone %d)\n", joystick_keymap.dead_zone);
317+#else
318+ fprintf(config, "\t(joystick-up %d)\n", joystick_keymap.up_button);
319+ fprintf(config, "\t(joystick-down %d)\n", joystick_keymap.down_button);
320+ fprintf(config, "\t(joystick-right %d)\n", joystick_keymap.right_button);
321+ fprintf(config, "\t(joystick-left %d)\n", joystick_keymap.left_button);
322+ fprintf(config, "\t(joystick-a %d)\n", joystick_keymap.a_button);
323+ fprintf(config, "\t(joystick-b %d)\n", joystick_keymap.b_button);
324+ fprintf(config, "\t(joystick-start %d)\n", joystick_keymap.start_button);
325+#endif
326 
327       fprintf(config, "\t(keyboard-jump %d)\n", keymap.jump);
328       fprintf(config, "\t(keyboard-duck %d)\n", keymap.duck);
329diff -ur supertux-0.1.3/src/defines.h supertux-0.1.3-gp2x/src/defines.h
330--- supertux-0.1.3/src/defines.h 2005-07-07 02:05:03.000000000 +0300
331+++ supertux-0.1.3-gp2x/src/defines.h 2006-04-11 22:02:05.000000000 +0300
332@@ -91,7 +91,11 @@
333 
334 /* Scrolling text speed */
335 
336+#ifndef RES320X240
337 #define SCROLL_SPEED_CREDITS 1.2
338+#else
339+#define SCROLL_SPEED_CREDITS 2.4
340+#endif
341 #define SCROLL_SPEED_MESSAGE 1.0
342 
343 /* Debugging */
344Only in supertux-0.1.3/src: .deps
345diff -ur supertux-0.1.3/src/gameloop.cpp supertux-0.1.3-gp2x/src/gameloop.cpp
346--- supertux-0.1.3/src/gameloop.cpp 2005-07-02 15:16:08.000000000 +0300
347+++ supertux-0.1.3-gp2x/src/gameloop.cpp 2006-05-05 23:22:58.000000000 +0300
348@@ -288,6 +288,7 @@
349   
350               switch(event.type)
351                 {
352+#ifndef GP2X
353                 case SDL_QUIT: /* Quit event - quit: */
354                   st_abort("Received window close", "");
355                   break;
356@@ -434,22 +435,60 @@
357                         tux.input.down = UP;
358                     }
359                   break;
360-
361+#endif
362                 case SDL_JOYBUTTONDOWN:
363+#ifndef GP2X
364+ if (event.jbutton.button == joystick_keymap.a_button)
365+ tux.input.up = DOWN;
366+ else if (event.jbutton.button == joystick_keymap.b_button)
367+ tux.input.fire = DOWN;
368+ else if (event.jbutton.button == joystick_keymap.start_button)
369+ on_escape_press();
370+ break;
371+#else
372                   if (event.jbutton.button == joystick_keymap.a_button)
373                     tux.input.up = DOWN;
374                   else if (event.jbutton.button == joystick_keymap.b_button)
375                     tux.input.fire = DOWN;
376                   else if (event.jbutton.button == joystick_keymap.start_button)
377                     on_escape_press();
378+ else if (event.jbutton.button == joystick_keymap.up_button)
379+ tux.input.up = DOWN;
380+ else if (event.jbutton.button == joystick_keymap.down_button)
381+ tux.input.down = DOWN;
382+ else if (event.jbutton.button == joystick_keymap.right_button)
383+ tux.input.right = DOWN;
384+ else if (event.jbutton.button == joystick_keymap.left_button)
385+ tux.input.left = DOWN;
386+ else if (event.jbutton.button == joystick_keymap.voldown_button)
387+ decreaseSoundVolume();
388+ else if (event.jbutton.button == joystick_keymap.volup_button)
389+ increaseSoundVolume();
390                   break;
391+#endif
392+
393                 case SDL_JOYBUTTONUP:
394+#ifndef GP2X
395                   if (event.jbutton.button == joystick_keymap.a_button)
396                     tux.input.up = UP;
397                   else if (event.jbutton.button == joystick_keymap.b_button)
398                     tux.input.fire = UP;
399                   break;
400-
401+#else
402+ if (event.jbutton.button == joystick_keymap.a_button)
403+ tux.input.up = UP;
404+ else if (event.jbutton.button == joystick_keymap.b_button)
405+ tux.input.fire = UP;
406+ else if (event.jbutton.button == joystick_keymap.up_button)
407+ tux.input.up = UP;
408+ else if (event.jbutton.button == joystick_keymap.down_button)
409+ tux.input.down = UP;
410+ else if (event.jbutton.button == joystick_keymap.right_button)
411+ tux.input.right = UP;
412+ else if (event.jbutton.button == joystick_keymap.left_button)
413+ tux.input.left = UP;
414+ break;
415+#endif
416                 default:
417                   break;
418                 } /* switch */
419@@ -464,7 +503,7 @@
420   Player* tux = world->get_tux();
421 
422   /* End of level? */
423- int endpos = (World::current()->get_level()->width-5) * 32;
424+ int endpos = (World::current()->get_level()->width-5) * (32);
425   Tile* endtile = collision_goal(tux->base);
426 
427   // fallback in case the other endpositions don't trigger
428@@ -545,7 +584,7 @@
429       Menu::current()->draw();
430       mouse_cursor->draw();
431     }
432-
433+ //updateSound();
434   updatescreen();
435 }
436 
437@@ -599,6 +638,7 @@
438 
439   while (exit_status == ES_NONE)
440     {
441+ SDL_Delay(10);
442       /* Calculate the movement-factor */
443       double frame_ratio = ((double)(update_time-last_update_time))/((double)FRAME_RATE);
444 
445@@ -686,6 +726,7 @@
446               fps_cnt = 0;
447             }
448         }
449+ //updateSound();
450     }
451   
452   return exit_status;
453@@ -694,21 +735,32 @@
454 /* Bounce a brick: */
455 void bumpbrick(float x, float y)
456 {
457- World::current()->add_bouncy_brick(((int)(x + 1) / 32) * 32,
458- (int)(y / 32) * 32);
459+ World::current()->add_bouncy_brick(((int)(x + 1) / (32)) * (32),
460+ (int)(y / (32)) * (32));
461 
462+#ifndef GP2X
463   play_sound(sounds[SND_BRICK], SOUND_CENTER_SPEAKER);
464+#else
465+ play_chunk(SND_BRICK);
466+#endif
467 }
468 
469 /* (Status): */
470 void
471 GameSession::drawstatus()
472 {
473+ int xdiv;
474+#ifdef RES320X240
475+ xdiv=2;
476+#else
477+ xdiv=1;
478+#endif
479+
480   char str[60];
481 
482   sprintf(str, "%d", player_status.score);
483   white_text->draw("SCORE", 0, 0, 1);
484- gold_text->draw(str, 96, 0, 1);
485+ gold_text->draw(str, 96/xdiv, 0, 1);
486 
487   if(st_gl_mode == ST_GL_TEST)
488     {
489@@ -716,28 +768,33 @@
490     }
491 
492   if(!time_left.check()) {
493- white_text->draw("TIME'S UP", 224, 0, 1);
494+ white_text->draw("TIME'S UP", 224/xdiv, 0, 1);
495   } else if (time_left.get_left() > TIME_WARNING || (global_frame_counter % 10) < 5) {
496     sprintf(str, "%d", time_left.get_left() / 1000 );
497- white_text->draw("TIME", 224, 0, 1);
498- gold_text->draw(str, 304, 0, 1);
499+ white_text->draw("TIME", 224/xdiv, 0, 1);
500+ gold_text->draw(str, 304/xdiv, 0, 1);
501   }
502 
503   sprintf(str, "%d", player_status.distros);
504   white_text->draw("COINS", screen->h, 0, 1);
505- gold_text->draw(str, 608, 0, 1);
506+ gold_text->draw(str, 608/xdiv, 0, 1);
507 
508- white_text->draw("LIVES", 480, 20);
509+ white_text->draw("LIVES", 480/xdiv, 20);
510   if (player_status.lives >= 5)
511     {
512       sprintf(str, "%dx", player_status.lives);
513+#ifdef RES320X240
514+ gold_text->draw_align(str, 617/xdiv-5, 20, A_RIGHT, A_TOP);
515+ tux_life->draw(565+(18*3)/xdiv+10, 20);
516+#else
517       gold_text->draw_align(str, 617, 20, A_RIGHT, A_TOP);
518       tux_life->draw(565+(18*3), 20);
519+#endif
520     }
521   else
522     {
523       for(int i= 0; i < player_status.lives; ++i)
524- tux_life->draw(565+(18*i),20);
525+ tux_life->draw(565+(18*i)/xdiv,20);
526     }
527 
528   if(show_fps)
529@@ -746,6 +803,7 @@
530       white_text->draw("FPS", screen->h, 40, 1);
531       gold_text->draw(str, screen->h + 60, 40, 1);
532     }
533+// updateSound();
534 }
535 
536 void
537@@ -824,4 +882,3 @@
538   return tmp;
539 }
540 
541-
542diff -ur supertux-0.1.3/src/gameobjs.cpp supertux-0.1.3-gp2x/src/gameobjs.cpp
543--- supertux-0.1.3/src/gameobjs.cpp 2005-06-22 00:16:07.000000000 +0300
544+++ supertux-0.1.3-gp2x/src/gameobjs.cpp 2006-04-11 21:52:52.000000000 +0300
545@@ -98,6 +98,9 @@
546   src.h = 16;
547 
548   dest.x = (int)(base.x - scroll_x);
549+#ifdef RES320X240
550+ dest.x=dest.x/2;
551+#endif
552   dest.y = (int)base.y;
553   dest.w = 16;
554   dest.h = 16;
555@@ -143,8 +146,13 @@
556 {
557   SDL_Rect dest;
558   
559+#ifndef RES320X240
560   if (base.x >= scroll_x - 32 &&
561       base.x <= scroll_x + screen->w)
562+#else
563+ if (base.x >= scroll_x - 32 &&
564+ base.x <= scroll_x + 640)
565+#endif
566     {
567       dest.x = (int)(base.x - scroll_x);
568       dest.y = (int)base.y;
569@@ -165,8 +173,14 @@
570       else
571         {
572           int s = ((int)scroll_x / 2)%640;
573+
574+#ifdef RES320X240
575+ plevel->img_bkgd->draw_part(dest.x/2 + s/2, dest.y/2,
576+ dest.x/2, dest.y,dest.w/2,dest.h/2);
577+#else
578           plevel->img_bkgd->draw_part(dest.x + s, dest.y,
579                                       dest.x, dest.y,dest.w,dest.h);
580+#endif
581         }
582 
583       Tile::draw(base.x - scroll_x,
584diff -ur supertux-0.1.3/src/globals.cpp supertux-0.1.3-gp2x/src/globals.cpp
585--- supertux-0.1.3/src/globals.cpp 2005-06-22 00:16:07.000000000 +0300
586+++ supertux-0.1.3-gp2x/src/globals.cpp 2006-04-11 22:39:03.000000000 +0300
587@@ -25,6 +25,7 @@
588 
589 JoystickKeymap::JoystickKeymap()
590 {
591+#ifndef GP2X
592   a_button = 0;
593   b_button = 1;
594   start_button = 2;
595@@ -33,6 +34,17 @@
596   y_axis = 1;
597     
598   dead_zone = 4096;
599+#else
600+ a_button = GP2X_BUTTON_A;
601+ b_button = GP2X_BUTTON_X;
602+ start_button = GP2X_BUTTON_START;
603+ up_button = GP2X_BUTTON_UP;
604+ down_button = GP2X_BUTTON_DOWN;
605+ left_button = GP2X_BUTTON_LEFT;
606+ right_button = GP2X_BUTTON_RIGHT;
607+ volup_button = GP2X_BUTTON_VOLUP;
608+ voldown_button = GP2X_BUTTON_VOLDOWN;
609+#endif
610 }
611 
612 JoystickKeymap joystick_keymap;
613diff -ur supertux-0.1.3/src/globals.h supertux-0.1.3-gp2x/src/globals.h
614--- supertux-0.1.3/src/globals.h 2005-06-22 00:16:07.000000000 +0300
615+++ supertux-0.1.3-gp2x/src/globals.h 2006-04-11 23:45:27.000000000 +0300
616@@ -28,10 +28,33 @@
617 #include "menu.h"
618 #include "mousecursor.h"
619 
620+#ifdef GP2X
621+#define GP2X_BUTTON_UP (0)
622+#define GP2X_BUTTON_DOWN (4)
623+#define GP2X_BUTTON_LEFT (2)
624+#define GP2X_BUTTON_RIGHT (6)
625+#define GP2X_BUTTON_UPLEFT (1)
626+#define GP2X_BUTTON_UPRIGHT (7)
627+#define GP2X_BUTTON_DOWNLEFT (3)
628+#define GP2X_BUTTON_DOWNRIGHT (5)
629+#define GP2X_BUTTON_CLICK (18)
630+#define GP2X_BUTTON_A (12)
631+#define GP2X_BUTTON_B (13)
632+#define GP2X_BUTTON_X (15)
633+#define GP2X_BUTTON_Y (14)
634+#define GP2X_BUTTON_L (10)
635+#define GP2X_BUTTON_R (11)
636+#define GP2X_BUTTON_START (8)
637+#define GP2X_BUTTON_SELECT (9)
638+#define GP2X_BUTTON_VOLUP (16)
639+#define GP2X_BUTTON_VOLDOWN (17)
640+#endif
641+
642 extern std::string datadir;
643 
644 struct JoystickKeymap
645 {
646+#ifndef GP2X
647   int a_button;
648   int b_button;
649   int start_button;
650@@ -42,6 +65,19 @@
651   int dead_zone;
652 
653   JoystickKeymap();
654+#else
655+ int a_button;
656+ int b_button;
657+ int start_button;
658+ int up_button;
659+ int down_button;
660+ int left_button;
661+ int right_button;
662+ int volup_button;
663+ int voldown_button;
664+
665+ JoystickKeymap();
666+#endif
667 };
668 
669 extern JoystickKeymap joystick_keymap;
670diff -ur supertux-0.1.3/src/lispreader.h supertux-0.1.3-gp2x/src/lispreader.h
671Only in supertux-0.1.3/src: Makefile
672diff -ur supertux-0.1.3/src/Makefile.am supertux-0.1.3-gp2x/src/Makefile.am
673--- supertux-0.1.3/src/Makefile.am 2005-06-22 00:16:07.000000000 +0300
674+++ supertux-0.1.3-gp2x/src/Makefile.am 2006-04-19 21:55:54.000000000 +0300
675@@ -77,3 +77,5 @@
676 musicref.h
677 
678 # EOF #
679+
680+#supertux_LDADD = libmikmod
681Only in supertux-0.1.3/src: Makefile.in
682diff -ur supertux-0.1.3/src/menu.cpp supertux-0.1.3-gp2x/src/menu.cpp
683--- supertux-0.1.3/src/menu.cpp 2005-06-29 15:44:13.000000000 +0300
684+++ supertux-0.1.3-gp2x/src/menu.cpp 2006-05-04 23:59:29.000000000 +0300
685@@ -53,6 +53,8 @@
686 Menu* options_menu = 0;
687 Menu* options_keys_menu = 0;
688 Menu* options_joystick_menu = 0;
689+Menu* options_joystick_axis_menu = 0;
690+Menu* options_joystick_button_menu = 0;
691 Menu* highscore_menu = 0;
692 Menu* load_game_menu = 0;
693 Menu* save_game_menu = 0;
694@@ -240,8 +242,10 @@
695 }
696 
697 /* Set ControlField a key */
698+//TODO: get joystick in here somehow
699 void Menu::get_controlfield_key_into_input(MenuItem *item)
700 {
701+#ifndef GP2X
702   switch(*item->int_p)
703   {
704   case SDLK_UP:
705@@ -288,6 +292,11 @@
706     }
707     break;
708   }
709+#else
710+ char tmp[64];
711+ snprintf(tmp, 64, "%d", *item->int_p);
712+ item->change_input(tmp);
713+#endif
714 }
715 
716 /* Free a menu and all its items */
717@@ -497,8 +506,13 @@
718                 int menu_height)
719 {
720   MenuItem& pitem = item[index];
721-
722+
723+#ifndef RES320X240
724   int font_width = 16;
725+#else
726+ int font_width = 16/2;
727+#endif
728+
729   int effect_offset = 0;
730   {
731     int effect_time = 0;
732@@ -510,7 +524,7 @@
733   }
734 
735   int x_pos = pos_x;
736- int y_pos = pos_y + 24*index - menu_height/2 + 12 + effect_offset;
737+ int y_pos = pos_y + (int)(24)*index - menu_height/2 + 12 + effect_offset;
738   int shadow_size = 2;
739   int text_width = strlen(pitem.text) * font_width;
740   int input_width = (strlen(pitem.input)+ 1) * font_width;
741@@ -518,7 +532,7 @@
742   Text* text_font = white_text;
743 
744   if (arrange_left)
745- x_pos += 24 - menu_width/2 + (text_width + input_width + list_width)/2;
746+ x_pos += (int)(24) - menu_width/2 + (text_width + input_width + list_width)/2;
747 
748   if(index == active_item)
749   {
750@@ -538,7 +552,11 @@
751 
752   case MN_HL:
753     {
754+#ifndef RES320X240
755       int x = pos_x - menu_width/2;
756+#else
757+ int x = pos_x - menu_width/4;
758+#endif
759       int y = y_pos - 12 - effect_offset;
760       /* Draw a horizontal line with a little 3d effect */
761       fillrect(x, y + 6,
762@@ -551,9 +569,15 @@
763     }
764   case MN_LABEL:
765     {
766+#ifndef RES320X240
767       white_big_text->draw_align(pitem.text,
768                                  x_pos, y_pos,
769                                  A_HMIDDLE, A_VMIDDLE, 2);
770+#else
771+ white_text->draw_align(pitem.text,
772+ x_pos, y_pos,
773+ A_HMIDDLE, A_VMIDDLE, 2);
774+#endif
775       break;
776     }
777   case MN_TEXTFIELD:
778@@ -570,8 +594,9 @@
779                input_width + font_width, 18,
780                0,0,0,128);
781 
782- if(pitem.kind == MN_CONTROLFIELD)
783+ if(pitem.kind == MN_CONTROLFIELD) {
784         get_controlfield_key_into_input(&pitem);
785+ }
786 
787       if(pitem.kind == MN_TEXTFIELD || pitem.kind == MN_NUMFIELD)
788       {
789@@ -663,7 +688,7 @@
790         menu_width += 2;
791     }
792   }
793-
794+
795   return (menu_width * 16 + 24);
796 }
797 
798@@ -680,10 +705,17 @@
799   int menu_width = get_width();
800 
801   /* Draw a transparent background */
802+#ifndef RES320X240
803   fillrect(pos_x - menu_width/2,
804            pos_y - 24*item.size()/2 - 10,
805            menu_width,menu_height + 20,
806            150,180,200,125);
807+#else
808+ fillrect(pos_x - menu_width/4,
809+ pos_y - 24*item.size()/2 - 10,
810+ menu_width,menu_height + 20,
811+ 150,180,200,125);
812+#endif
813 
814   for(unsigned int i = 0; i < item.size(); ++i)
815   {
816@@ -723,6 +755,8 @@
817   SDLKey key;
818   switch(event.type)
819   {
820+
821+#ifndef GP2X
822   case SDL_KEYDOWN:
823     key = event.key.keysym.sym;
824     SDLMod keymod;
825@@ -754,7 +788,6 @@
826       return;
827     }
828 
829-
830     switch(key)
831     {
832     case SDLK_UP: /* Menu Up */
833@@ -800,12 +833,14 @@
834       break;
835     }
836     break;
837+
838   case SDL_JOYHATMOTION:
839       if(event.jhat.value == SDL_HAT_UP)
840            menuaction = MENU_ACTION_UP;
841       if(event.jhat.value == SDL_HAT_DOWN)
842            menuaction = MENU_ACTION_DOWN;
843        break;
844+
845   case SDL_JOYAXISMOTION:
846     if(event.jaxis.axis == joystick_keymap.y_axis)
847     {
848@@ -815,9 +850,88 @@
849         menuaction = MENU_ACTION_UP;
850     }
851     break;
852+#endif
853+
854   case SDL_JOYBUTTONDOWN:
855+#ifndef GP2X
856     menuaction = MENU_ACTION_HIT;
857     break;
858+#else
859+
860+ if(item[active_item].kind == MN_CONTROLFIELD)
861+ {
862+ if( event.jbutton.button == joystick_keymap.start_button )
863+ {
864+ Menu::pop_current();
865+ return;
866+ }
867+
868+ static int save[8]={-1,-1,-1,-1,-1,-1,-1,-1};
869+ int itemid=get_active_item_id();
870+ int inputkey;
871+ switch ( itemid ) {
872+ case 11 : inputkey=joystick_keymap.up_button;
873+ break;
874+ case 12 : inputkey=joystick_keymap.down_button;
875+ break;
876+ case 13 : inputkey=joystick_keymap.left_button;
877+ break;
878+ case 14 : inputkey=joystick_keymap.right_button;
879+ break;
880+ case 15 : inputkey=joystick_keymap.a_button;
881+ break;
882+ case 16 : inputkey=joystick_keymap.b_button;
883+ break;
884+ default : break;
885+ }
886+
887+ *item[active_item].int_p = event.jbutton.button;
888+
889+ bool okay=true;
890+
891+ save[itemid-11]=event.jbutton.button;
892+
893+ int i;
894+ for ( i=0;i<itemid-11;i++ ) {
895+ if ( save[i] == event.jbutton.button ) okay=false;
896+ }
897+ if ( okay == true ) menuaction = MENU_ACTION_DOWN;
898+ else menuaction = MENU_ACTION_NONE;
899+
900+ return;
901+ }
902+
903+ if (event.jbutton.button == joystick_keymap.a_button)
904+ menuaction = MENU_ACTION_HIT;
905+ else if (event.jbutton.button == joystick_keymap.b_button)
906+ menuaction = MENU_ACTION_HIT;
907+ else if (event.jbutton.button == joystick_keymap.start_button)
908+ menuaction = MENU_ACTION_HIT;
909+ else if (event.jbutton.button == joystick_keymap.up_button)
910+ menuaction = MENU_ACTION_UP;
911+ else if (event.jbutton.button == joystick_keymap.down_button)
912+ menuaction = MENU_ACTION_DOWN;
913+ else if (event.jbutton.button == joystick_keymap.right_button)
914+ menuaction = MENU_ACTION_RIGHT;
915+ else if (event.jbutton.button == joystick_keymap.left_button)
916+ menuaction = MENU_ACTION_LEFT;
917+ else if (event.jbutton.button == joystick_keymap.volup_button)
918+#ifdef GP2X
919+ increaseSoundVolume();
920+#else
921+ sound_volume(2);
922+#endif
923+ else if (event.jbutton.button == joystick_keymap.voldown_button)
924+#ifdef GP2X
925+ decreaseSoundVolume();
926+#else
927+ sound_volume(1);
928+#endif
929+ break;
930+
931+#endif
932+
933+#ifndef GP2X
934   case SDL_MOUSEBUTTONDOWN:
935     x = event.motion.x;
936     y = event.motion.y;
937@@ -847,6 +961,7 @@
938     break;
939   default:
940     break;
941+#endif
942   }
943 }
944 
945diff -ur supertux-0.1.3/src/menu.h supertux-0.1.3-gp2x/src/menu.h
946--- supertux-0.1.3/src/menu.h 2005-06-22 00:16:07.000000000 +0300
947+++ supertux-0.1.3-gp2x/src/menu.h 2006-05-04 23:48:30.000000000 +0300
948@@ -236,6 +236,8 @@
949 extern Menu* options_menu;
950 extern Menu* options_keys_menu;
951 extern Menu* options_joystick_menu;
952+extern Menu* options_joystick_axis_menu;
953+extern Menu* options_joystick_button_menu;
954 extern Menu* highscore_menu;
955 extern Menu* load_game_menu;
956 extern Menu* save_game_menu;
957diff -ur supertux-0.1.3/src/music_manager.cpp supertux-0.1.3-gp2x/src/music_manager.cpp
958--- supertux-0.1.3/src/music_manager.cpp 2005-06-22 00:16:07.000000000 +0300
959+++ supertux-0.1.3-gp2x/src/music_manager.cpp 2006-04-22 13:16:32.000000000 +0300
960@@ -59,7 +59,14 @@
961     return true;
962   }
963   
964+#ifndef GP2X
965   Mix_Music* song = Mix_LoadMUS(file.c_str());
966+#else
967+ char mfile[100];
968+ snprintf(mfile,sizeof(mfile),"%s",file.c_str());
969+ MODULE *song=Player_Load(mfile, 64, 0);
970+#endif
971+
972   if(song == 0)
973     return false;
974 
975@@ -84,6 +91,8 @@
976 void
977 MusicManager::play_music(const MusicRef& musicref, int loops)
978 {
979+// printf("loop: %d, musicref: %d\n",loops,musicref.music);
980+
981   if(!audio_device)
982     return;
983 
984@@ -97,7 +106,16 @@
985   current_music->refcount++;
986   
987   if(music_enabled)
988+#ifndef GP2X
989     Mix_PlayMusic(current_music->music, loops);
990+#else
991+ {
992+ if ( loops == -1 ) current_music->music->wrap=1;
993+ Player_Stop();
994+ Player_Start(current_music->music);
995+ Player_SetPosition(0);
996+ }
997+#endif
998 }
999 
1000 void
1001@@ -106,13 +124,17 @@
1002   if(!audio_device)
1003     return;
1004   
1005+#ifndef GP2X
1006   Mix_HaltMusic();
1007+#else
1008+ Player_Stop();
1009+#endif
1010   
1011   if(current_music) {
1012     current_music->refcount--;
1013     if(current_music->refcount == 0)
1014       free_music(current_music);
1015- current_music = 0;
1016+ current_music = 0;
1017   }
1018 }
1019 
1020@@ -127,9 +149,17 @@
1021   
1022   music_enabled = enable;
1023   if(music_enabled == false) {
1024+#ifndef GP2X
1025     Mix_HaltMusic();
1026+#else
1027+ Player_Stop();
1028+#endif
1029   } else {
1030+#ifndef GP2X
1031     Mix_PlayMusic(current_music->music, -1);
1032+#else
1033+ Player_Start(current_music->music);
1034+#endif
1035   }
1036 }
1037 
1038diff -ur supertux-0.1.3/src/music_manager.h supertux-0.1.3-gp2x/src/music_manager.h
1039--- supertux-0.1.3/src/music_manager.h 2005-06-22 00:16:07.000000000 +0300
1040+++ supertux-0.1.3-gp2x/src/music_manager.h 2006-04-22 04:51:32.000000000 +0300
1041@@ -20,6 +20,10 @@
1042 #ifndef HEADER_MUSIC_MANAGER_H
1043 #define HEADER_MUSIC_MANAGER_H
1044 
1045+#ifdef GP2X
1046+#include "mikmod.h"
1047+#endif
1048+
1049 #include <SDL_mixer.h>
1050 #include <string>
1051 #include <map>
1052@@ -51,7 +55,12 @@
1053     ~MusicResource();
1054 
1055     MusicManager* manager;
1056+#ifndef GP2X
1057     Mix_Music* music;
1058+#else
1059+ MODULE *music;
1060+#endif
1061+
1062     int refcount;
1063   };
1064 
1065diff -ur supertux-0.1.3/src/particlesystem.cpp supertux-0.1.3-gp2x/src/particlesystem.cpp
1066--- supertux-0.1.3/src/particlesystem.cpp 2005-06-22 00:16:07.000000000 +0300
1067+++ supertux-0.1.3-gp2x/src/particlesystem.cpp 2006-04-12 22:20:41.000000000 +0300
1068@@ -28,8 +28,13 @@
1069 
1070 ParticleSystem::ParticleSystem()
1071 {
1072+#ifndef RES320X240
1073     virtual_width = screen->w;
1074     virtual_height = screen->h;
1075+#else
1076+ virtual_width = 640;
1077+ virtual_height = 480;
1078+#endif
1079 }
1080 
1081 ParticleSystem::~ParticleSystem()
1082@@ -57,13 +62,24 @@
1083         float ymax = fmodf(y + particle->texture->h, virtual_height);
1084 
1085         // particle on screen
1086+#ifndef RES320X240
1087         if(x >= screen->w && xmax >= screen->w)
1088             continue;
1089         if(y >= screen->h && ymax >= screen->h)
1090             continue;
1091-
1092+
1093         if(x > screen->w) x -= virtual_width;
1094         if(y > screen->h) y -= virtual_height;
1095+#else
1096+ if(x >= 640 && xmax >= 640)
1097+ continue;
1098+ if(y >= 480 && ymax >= 480)
1099+ continue;
1100+
1101+ if(x > 640) x -= virtual_width;
1102+ if(y > 480) y -= virtual_height;
1103+#endif
1104+
1105         particle->texture->draw(x, y);
1106     }
1107 }
1108@@ -74,14 +90,21 @@
1109     snowimages[1] = new Surface(datadir+"/images/shared/snow1.png", USE_ALPHA);
1110     snowimages[2] = new Surface(datadir+"/images/shared/snow2.png", USE_ALPHA);
1111 
1112+#ifndef RES320X240
1113     virtual_width = screen->w * 2;
1114-
1115+#else
1116+ virtual_width = 640 * 2;
1117+#endif
1118     // create some random snowflakes
1119     size_t snowflakecount = size_t(virtual_width/10.0);
1120     for(size_t i=0; i<snowflakecount; ++i) {
1121         SnowParticle* particle = new SnowParticle;
1122         particle->x = rand() % int(virtual_width);
1123+#ifndef RES320X240
1124         particle->y = rand() % screen->h;
1125+#else
1126+ particle->y = rand() % 480;
1127+#endif
1128         particle->layer = i % 2;
1129         int snowsize = rand() % 3;
1130         particle->texture = snowimages[snowsize];
1131@@ -106,7 +129,11 @@
1132     for(i = particles.begin(); i != particles.end(); ++i) {
1133         SnowParticle* particle = (SnowParticle*) *i;
1134         particle->y += particle->speed * elapsed_time;
1135+#ifndef RES320X240
1136         if(particle->y > screen->h) {
1137+#else
1138+ if(particle->y > 480) {
1139+#endif
1140             particle->y = fmodf(particle->y , virtual_height);
1141             particle->x = rand() % int(virtual_width);
1142         }
1143diff -ur supertux-0.1.3/src/player.cpp supertux-0.1.3-gp2x/src/player.cpp
1144--- supertux-0.1.3/src/player.cpp 2005-06-22 00:16:07.000000000 +0300
1145+++ supertux-0.1.3-gp2x/src/player.cpp 2006-05-05 22:59:52.000000000 +0300
1146@@ -261,6 +261,7 @@
1147             }
1148         }
1149     }
1150+// updateSound();
1151 
1152   /* ---- DONE HANDLING TUX! --- */
1153 
1154@@ -337,7 +338,11 @@
1155   if(on_ground() && ((vx < 0 && dirsign >0) || (vx>0 && dirsign<0))) {
1156       if(fabs(vx)>SKID_XM && !skidding_timer.check()) {
1157           skidding_timer.start(SKID_TIME);
1158+#ifndef GP2X
1159           play_sound(sounds[SND_SKID], SOUND_CENTER_SPEAKER);
1160+#else
1161+ play_chunk(SND_SKID);
1162+#endif
1163           ax *= 2.5;
1164       } else {
1165           ax *= 2;
1166@@ -391,9 +396,17 @@
1167           jumping = true;
1168           can_jump = false;
1169           if (size == SMALL)
1170+#ifndef GP2X
1171             play_sound(sounds[SND_JUMP], SOUND_CENTER_SPEAKER);
1172+#else
1173+ play_chunk(SND_JUMP);
1174+#endif
1175           else
1176+#ifndef GP2X
1177             play_sound(sounds[SND_BIGJUMP], SOUND_CENTER_SPEAKER);
1178+#else
1179+ play_chunk(SND_BIGJUMP);
1180+#endif
1181         }
1182     }
1183   // Let go of jump key
1184@@ -533,7 +546,11 @@
1185       if(player_status.lives < MAX_LIVES)
1186         ++player_status.lives;
1187       /*We want to hear the sound even, if MAX_LIVES is reached*/
1188+#ifndef GP2X
1189       play_sound(sounds[SND_LIFEUP], SOUND_CENTER_SPEAKER);
1190+#else
1191+ play_chunk(SND_LIFEUP);
1192+#endif
1193     }
1194 }
1195 
1196@@ -665,7 +682,11 @@
1197               else
1198                 {
1199                    pbad_c->dying = DYING_FALLING;
1200+#ifndef GP2X
1201                    play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER);
1202+#else
1203+ play_chunk(SND_FALL);
1204+#endif
1205                    World::current()->add_score(pbad_c->base.x - scroll_x,
1206                                                pbad_c->base.y,
1207                                                25 * player_status.score_multiplier);
1208@@ -696,7 +717,12 @@
1209 void
1210 Player::kill(HurtMode mode)
1211 {
1212+#ifndef GP2X
1213   play_sound(sounds[SND_HURT], SOUND_CENTER_SPEAKER);
1214+#else
1215+ play_chunk(SND_HURT);
1216+ updateSound();
1217+#endif
1218 
1219   physic.set_velocity_x(0);
1220 
1221@@ -734,7 +760,11 @@
1222 
1223 bool Player::is_dead()
1224 {
1225+#ifndef RES320X240
1226   if(base.y > screen->h || base.x < scroll_x - AUTOSCROLL_DEAD_INTERVAL) // last condition can happen in auto-scrolling
1227+#else
1228+ if(base.y > 640 || base.x < scroll_x - AUTOSCROLL_DEAD_INTERVAL) // last condition can happen in auto-scrolling
1229+#endif
1230     return true;
1231   else
1232     return false;
1233@@ -760,9 +790,20 @@
1234     }
1235 
1236   /* Keep in-bounds, vertically: */
1237+#ifndef RES320X240
1238   if (base.y > screen->h)
1239+#else
1240+ if (base.y > 640)
1241+#endif
1242     {
1243       kill(KILL);
1244+#ifdef GP2X
1245+ float wait=SDL_GetTicks()+800;
1246+ while ( wait > SDL_GetTicks()) {
1247+ updateSound();
1248+ }
1249+#endif
1250+
1251     }
1252 
1253   if(base.x < scroll_x && (!back_scrolling || hor_autoscroll)) // can happen if back scrolling is disabled
1254@@ -777,7 +818,6 @@
1255     if(base.x + base.width > scroll_x + screen->w)
1256       base.x = scroll_x + screen->w - base.width;
1257     }
1258-
1259 }
1260 
1261 // EOF //
1262diff -ur supertux-0.1.3/src/resources.cpp supertux-0.1.3-gp2x/src/resources.cpp
1263--- supertux-0.1.3/src/resources.cpp 2005-07-02 15:20:14.000000000 +0300
1264+++ supertux-0.1.3-gp2x/src/resources.cpp 2006-04-22 13:14:01.000000000 +0300
1265@@ -18,6 +18,7 @@
1266 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1267 
1268 #include "globals.h"
1269+#include "sound.h"
1270 #include "scene.h"
1271 #include "player.h"
1272 #include "badguy.h"
1273@@ -187,11 +188,13 @@
1274                     // This is also true with if (use_music)
1275                     Send a mail to me: neoneurone@users.sf.net, if you have another opinion. :)
1276   */
1277+#ifndef GP2X
1278   for (i = 0; i < NUM_SOUNDS; i++)
1279     sounds[i] = load_sound(datadir + soundfilenames[i]);
1280+#endif
1281 
1282   /* Herring song */
1283- herring_song = music_manager->load_music(datadir + "/music/SALCON.MOD");
1284+ herring_song = music_manager->load_music(datadir + "/music/SALCON.MOD");
1285   level_end_song = music_manager->load_music(datadir + "/music/leveldone.mod");
1286 }
1287 
1288@@ -223,8 +226,10 @@
1289 
1290   delete tux_life;
1291 
1292+#ifndef GP2X
1293   for (i = 0; i < NUM_SOUNDS; i++)
1294     free_chunk(sounds[i]);
1295+#endif
1296 
1297   delete sprite_manager;
1298   sprite_manager = 0;
1299diff -ur supertux-0.1.3/src/screen.cpp supertux-0.1.3-gp2x/src/screen.cpp
1300--- supertux-0.1.3/src/screen.cpp 2005-06-22 00:16:07.000000000 +0300
1301+++ supertux-0.1.3-gp2x/src/screen.cpp 2006-04-14 18:18:47.000000000 +0300
1302@@ -81,7 +81,6 @@
1303   else
1304   {
1305 #endif
1306-
1307     for(float y = 0; y < 480; y += 2)
1308       fillrect(0, (int)y, 640, 2,
1309                      (int)(((float)(top_clr.red-bot_clr.red)/(0-480)) * y + top_clr.red),
1310@@ -199,11 +198,23 @@
1311       SDL_UnlockSurface(screen);
1312     }
1313   /* Update just the part of the display that we've changed */
1314+#ifndef RES320X240
1315   SDL_UpdateRect(screen, x, y, 1, 1);
1316+#else
1317+ SDL_UpdateRect(screen, x/2, y/2, 1, 1);
1318+#endif
1319 }
1320 
1321 void drawline(int x1, int y1, int x2, int y2, int r, int g, int b, int a)
1322 {
1323+
1324+#ifdef RES320X240
1325+ x1=x1/2;
1326+ x2=x2/2;
1327+ y1=y1/2;
1328+ y2=y2/2;
1329+#endif
1330+
1331 #ifndef NOOPENGL
1332   if(use_gl)
1333     {
1334@@ -280,6 +291,13 @@
1335     y += h;
1336     h = -h;
1337     }
1338+
1339+#ifdef RES320X240
1340+ x=x;
1341+ y=y/2;
1342+ w=w/2;
1343+ h=h/2;
1344+#endif
1345 
1346 #ifndef NOOPENGL
1347   if(use_gl)
1348@@ -367,6 +385,9 @@
1349 void update_rect(SDL_Surface *scr, Sint32 x, Sint32 y, Sint32 w, Sint32 h)
1350 {
1351   if(!use_gl)
1352+#ifndef RES320X240
1353+ SDL_UpdateRect(scr, x, y, w, h);
1354+#else
1355     SDL_UpdateRect(scr, x, y, w, h);
1356+#endif
1357 }
1358-
1359diff -ur supertux-0.1.3/src/setup.cpp supertux-0.1.3-gp2x/src/setup.cpp
1360--- supertux-0.1.3/src/setup.cpp 2005-07-08 15:19:17.000000000 +0300
1361+++ supertux-0.1.3-gp2x/src/setup.cpp 2006-05-03 23:32:49.000000000 +0300
1362@@ -62,10 +62,19 @@
1363 #define DATA_PREFIX "./data/"
1364 #endif
1365 
1366-/* Screen proprities: */
1367+/* Screen properties: */
1368 /* Don't use this to test for the actual screen sizes. Use screen->w/h instead! */
1369+#ifndef RES320X240
1370 #define SCREEN_W 640
1371 #define SCREEN_H 480
1372+#else
1373+#define SCREEN_W 320
1374+#define SCREEN_H 240
1375+#endif
1376+
1377+#ifdef GP2X
1378+#define DATA_PREFIX "data/"
1379+#endif
1380 
1381 /* Local function prototypes: */
1382 
1383@@ -308,10 +317,14 @@
1384   char str[1024];
1385   /* Get home directory (from $HOME variable)... if we can't determine it,
1386      use the current directory ("."): */
1387+#ifndef GP2X
1388   if (getenv("HOME") != NULL)
1389     home = getenv("HOME");
1390   else
1391     home = ".";
1392+#else
1393+ home = ".";
1394+#endif
1395 
1396   st_dir = (char *) malloc(sizeof(char) * (strlen(home) +
1397                                            strlen("/.supertux") + 1));
1398@@ -340,9 +353,10 @@
1399   // User has not that a datadir, so we try some magic
1400   if (datadir.empty())
1401     {
1402-#ifndef WIN32
1403       // Detect datadir
1404       char exe_file[PATH_MAX];
1405+
1406+#ifndef WIN32
1407       if (readlink("/proc/self/exe", exe_file, PATH_MAX) < 0)
1408         {
1409           puts("Couldn't read /proc/self/exe, using default path: " DATA_PREFIX);
1410@@ -358,7 +372,12 @@
1411               datadir = exedir + "../share/supertux"; // SuperTux run from PATH
1412               if (access(datadir.c_str(), F_OK) != 0)
1413                 { // If all fails, fall back to compiled path
1414- datadir = DATA_PREFIX;
1415+ datadir = exedir + "./data"; // SuperTux run with data in same path as executable
1416+ if (access(datadir.c_str(), F_OK) != 0)
1417+ {
1418+ // If all fails, fall back to compiled path
1419+ datadir = DATA_PREFIX;
1420+ }
1421                 }
1422             }
1423         }
1424@@ -375,7 +394,8 @@
1425   main_menu = new Menu();
1426   options_menu = new Menu();
1427   options_keys_menu = new Menu();
1428- options_joystick_menu = new Menu();
1429+ options_joystick_axis_menu = new Menu();
1430+ options_joystick_button_menu = new Menu();
1431   load_game_menu = new Menu();
1432   save_game_menu = new Menu();
1433   game_menu = new Menu();
1434@@ -384,22 +404,27 @@
1435   contrib_subset_menu = new Menu();
1436   worldmap_menu = new Menu();
1437 
1438- main_menu->set_pos(screen->w/2, 335);
1439+ main_menu->set_pos(screen->w/2, (int)(335)+20);
1440   main_menu->additem(MN_GOTO, "Start Game",0,load_game_menu, MNID_STARTGAME);
1441   main_menu->additem(MN_GOTO, "Bonus Levels",0,contrib_menu, MNID_CONTRIB);
1442   main_menu->additem(MN_GOTO, "Options",0,options_menu, MNID_OPTIONMENU);
1443+
1444+#ifndef GP2X
1445   main_menu->additem(MN_ACTION,"Level Editor",0,0, MNID_LEVELEDITOR);
1446+#endif
1447   main_menu->additem(MN_ACTION,"Credits",0,0, MNID_CREDITS);
1448   main_menu->additem(MN_ACTION,"Quit",0,0, MNID_QUITMAINMENU);
1449 
1450   options_menu->additem(MN_LABEL,"Options",0,0);
1451   options_menu->additem(MN_HL,"",0,0);
1452+#ifndef GP2X
1453 #ifndef NOOPENGL
1454   options_menu->additem(MN_TOGGLE,"OpenGL",use_gl,0, MNID_OPENGL);
1455 #else
1456   options_menu->additem(MN_DEACTIVE,"OpenGL (not supported)",use_gl, 0, MNID_OPENGL);
1457 #endif
1458   options_menu->additem(MN_TOGGLE,"Fullscreen",use_fullscreen,0, MNID_FULLSCREEN);
1459+#endif
1460   if(audio_device)
1461     {
1462       options_menu->additem(MN_TOGGLE,"Sound ", use_sound,0, MNID_SOUND);
1463@@ -411,10 +436,15 @@
1464       options_menu->additem(MN_DEACTIVE,"Music ", false,0, MNID_MUSIC);
1465     }
1466   options_menu->additem(MN_TOGGLE,"Show FPS ",show_fps,0, MNID_SHOWFPS);
1467+#ifndef GP2X
1468   options_menu->additem(MN_GOTO,"Keyboard Setup",0,options_keys_menu);
1469+#endif
1470 
1471   //if(use_joystick)
1472- // options_menu->additem(MN_GOTO,"Joystick Setup",0,options_joystick_menu);
1473+#ifdef GP2X
1474+ options_menu->additem(MN_GOTO,"Joystick Move Setup",0,options_joystick_axis_menu);
1475+ options_menu->additem(MN_GOTO,"Joystick Action Setup",0,options_joystick_button_menu);
1476+#endif
1477 
1478   options_menu->additem(MN_HL,"",0,0);
1479   options_menu->additem(MN_BACK,"Back",0,0);
1480@@ -429,6 +459,7 @@
1481   options_keys_menu->additem(MN_HL,"",0,0);
1482   options_keys_menu->additem(MN_BACK,"Back",0,0);
1483 
1484+#ifndef GP2X
1485   if(use_joystick)
1486     {
1487     options_joystick_menu->additem(MN_LABEL,"Joystick Setup",0,0);
1488@@ -442,6 +473,20 @@
1489     options_joystick_menu->additem(MN_HL,"",0,0);
1490     options_joystick_menu->additem(MN_BACK,"Back",0,0);
1491     }
1492+#else
1493+ options_joystick_axis_menu->additem(MN_LABEL,"Joystick Move Setup",0,0);
1494+ options_joystick_axis_menu->additem(MN_CONTROLFIELD,"Up", 0,0, 11,&joystick_keymap.up_button);
1495+ options_joystick_axis_menu->additem(MN_CONTROLFIELD,"Down", 0,0, 12,&joystick_keymap.down_button);
1496+ options_joystick_axis_menu->additem(MN_CONTROLFIELD,"Left", 0,0, 13,&joystick_keymap.left_button);
1497+ options_joystick_axis_menu->additem(MN_CONTROLFIELD,"Right", 0,0, 14,&joystick_keymap.right_button);
1498+ options_joystick_axis_menu->additem(MN_BACK,"Back",0,0);
1499+
1500+ options_joystick_button_menu->additem(MN_LABEL,"Joystick Action Setup",0,0);
1501+ options_joystick_button_menu->additem(MN_CONTROLFIELD,"Jump", 0,0, 15,&joystick_keymap.a_button);
1502+ options_joystick_button_menu->additem(MN_CONTROLFIELD,"Shoot/Run", 0,0, 16,&joystick_keymap.b_button);
1503+ options_joystick_button_menu->additem(MN_BACK,"Back",0,0);
1504+#endif
1505+
1506   
1507   load_game_menu->additem(MN_LABEL,"Start Game",0,0);
1508   load_game_menu->additem(MN_HL,"",0,0);
1509@@ -576,9 +621,10 @@
1510 
1511   srand(SDL_GetTicks());
1512 
1513+#ifndef GP2X
1514   /* Set icon image: */
1515-
1516   seticon();
1517+#endif
1518 
1519   /* Unicode needed for input handling: */
1520 
1521@@ -586,13 +632,32 @@
1522 
1523   /* Load global images: */
1524 
1525+#ifndef RES320X240
1526+ white_text = new Text(datadir + "/images/status/letters-white.png", TEXT_TEXT, 16,18);
1527+#else
1528+ white_text = new Text(datadir + "/images/status/letters-white-small.png", TEXT_TEXT, 8,9);
1529+ fadeout();
1530+#endif
1531+
1532+
1533+#ifndef RES320X240
1534   black_text = new Text(datadir + "/images/status/letters-black.png", TEXT_TEXT, 16,18);
1535+#else
1536+ black_text = new Text(datadir + "/images/status/letters-black.png", TEXT_TEXT, 8,9);
1537+#endif
1538+#ifndef RES320X240
1539   gold_text = new Text(datadir + "/images/status/letters-gold.png", TEXT_TEXT, 16,18);
1540+#else
1541+ gold_text = new Text(datadir + "/images/status/letters-gold.png", TEXT_TEXT, 8,9);
1542+#endif
1543   silver_text = new Text(datadir + "/images/status/letters-silver.png", TEXT_TEXT, 16,18);
1544+#ifndef RES320X240
1545   blue_text = new Text(datadir + "/images/status/letters-blue.png", TEXT_TEXT, 16,18);
1546+#else
1547+ blue_text = new Text(datadir + "/images/status/letters-blue.png", TEXT_TEXT, 8,9);
1548+#endif
1549   red_text = new Text(datadir + "/images/status/letters-red.png", TEXT_TEXT, 16,18);
1550   green_text = new Text(datadir + "/images/status/letters-green.png", TEXT_TEXT, 16,18);
1551- white_text = new Text(datadir + "/images/status/letters-white.png", TEXT_TEXT, 16,18);
1552   white_small_text = new Text(datadir + "/images/status/letters-white-small.png", TEXT_TEXT, 8,9);
1553   white_big_text = new Text(datadir + "/images/status/letters-white-big.png", TEXT_TEXT, 20,22);
1554   yellow_nums = new Text(datadir + "/images/status/numbers.png", TEXT_NUM, 32,32);
1555@@ -665,14 +736,22 @@
1556   Surface::reload_all();
1557 
1558   /* Set window manager stuff: */
1559+#ifndef GP2X_VERSION
1560   SDL_WM_SetCaption("SuperTux " VERSION, "SuperTux");
1561+#endif
1562 }
1563 
1564 void st_video_setup_sdl(void)
1565 {
1566   if (use_fullscreen)
1567     {
1568+#ifndef GP2X
1569       screen = SDL_SetVideoMode(SCREEN_W, SCREEN_H, 0, SDL_FULLSCREEN ) ; /* | SDL_HWSURFACE); */
1570+#else
1571+// screen = SDL_SetVideoMode(SCREEN_W, SCREEN_H, 16, SDL_HWSURFACE | SDL_DOUBLEBUF ) ; /* GP2X */
1572+ printf("screen width: %d, height: %d\n",SCREEN_W, SCREEN_H);
1573+ screen = SDL_SetVideoMode(SCREEN_W, SCREEN_H, 16, SDL_SWSURFACE ) ; /* GP2X */
1574+#endif
1575       if (screen == NULL)
1576         {
1577           fprintf(stderr,
1578@@ -685,14 +764,22 @@
1579     }
1580   else
1581     {
1582+#ifndef GP2X
1583       screen = SDL_SetVideoMode(SCREEN_W, SCREEN_H, 0, SDL_HWSURFACE | SDL_DOUBLEBUF );
1584-
1585+#else
1586+// screen = SDL_SetVideoMode(SCREEN_W, SCREEN_H, 16, SDL_HWSURFACE | SDL_DOUBLEBUF ) ; /* GP2X */
1587+ screen = SDL_SetVideoMode(SCREEN_W, SCREEN_H, 16, SDL_SWSURFACE ) ; /* GP2X */
1588+#endif
1589       if (screen == NULL)
1590         {
1591           fprintf(stderr,
1592                   "\nError: I could not set up video for 640x480 mode.\n"
1593                   "The Simple DirectMedia error that occured was:\n"
1594                   "%s\n\n", SDL_GetError());
1595+#ifdef GP2X_VERSION
1596+ chdir("/usr/gp2x");
1597+ execl("/usr/gp2x/gp2xmenu", "/usr/gp2x/gp2xmenu", NULL);
1598+#endif
1599           exit(1);
1600         }
1601     }
1602@@ -790,6 +877,7 @@
1603 
1604               use_joystick = false;
1605             }
1606+#ifndef GP2X
1607           else
1608             {
1609               if (SDL_JoystickNumAxes(js) < 2)
1610@@ -811,6 +899,7 @@
1611                     }
1612                 }
1613             }
1614+#endif
1615         }
1616     }
1617 }
1618@@ -844,12 +933,17 @@
1619         }
1620     }
1621 
1622-
1623+ audio_device = true;
1624+
1625   /* Open sound silently regarless the value of "use_sound": */
1626 
1627   if (audio_device)
1628     {
1629+#ifndef GP2X
1630       if (open_audio(44100, AUDIO_S16, 2, 2048) < 0)
1631+#else
1632+ if (open_audio(44100, AUDIO_S16, 1, 1024) < 0)
1633+#endif
1634         {
1635           /* only print out message if sound or music
1636              was not disabled at command-line
1637@@ -878,6 +972,12 @@
1638   close_audio();
1639   SDL_Quit();
1640   saveconfig();
1641+
1642+#ifdef GP2X
1643+ chdir("/usr/gp2x");
1644+ execl("/usr/gp2x/gp2xmenu", "/usr/gp2x/gp2xmenu", NULL);
1645+#endif
1646+
1647 }
1648 
1649 /* --- ABORT! --- */
1650@@ -893,6 +993,7 @@
1651 
1652 void seticon(void)
1653 {
1654+#ifndef GP2X
1655 // int masklen;
1656 // Uint8 * mask;
1657   SDL_Surface * icon;
1658@@ -927,6 +1028,7 @@
1659 
1660 // free(mask);
1661   SDL_FreeSurface(icon);
1662+#endif
1663 }
1664 
1665 
1666@@ -956,6 +1058,7 @@
1667         }
1668       else if (strcmp(argv[i], "--joymap") == 0)
1669         {
1670+#ifndef GP2X
1671           assert(i+1 < argc);
1672           if (sscanf(argv[++i],
1673                      "%d:%d:%d:%d:%d",
1674@@ -976,6 +1079,7 @@
1675                         << " B-Button: " << joystick_keymap.b_button << "\n"
1676                         << " Start-Button: " << joystick_keymap.start_button << std::endl;
1677             }
1678+#endif
1679         }
1680       else if (strcmp(argv[i], "--leveleditor") == 0)
1681         {
1682diff -ur supertux-0.1.3/src/sound.cpp supertux-0.1.3-gp2x/src/sound.cpp
1683--- supertux-0.1.3/src/sound.cpp 2005-06-22 00:16:07.000000000 +0300
1684+++ supertux-0.1.3-gp2x/src/sound.cpp 2006-04-22 02:07:57.000000000 +0300
1685@@ -22,6 +22,9 @@
1686 #include "globals.h"
1687 #include "sound.h"
1688 #include "setup.h"
1689+#ifdef GP2X
1690+#include <string.h>
1691+#endif
1692 
1693 /*global variable*/
1694 bool use_sound = true; /* handle sound on/off menu and command-line option */
1695@@ -54,12 +57,21 @@
1696 
1697 #include <SDL_mixer.h>
1698 
1699+#ifndef GP2X
1700 Mix_Chunk * sounds[NUM_SOUNDS];
1701+#else
1702 
1703-/* --- OPEN THE AUDIO DEVICE --- */
1704+#include <mikmod.h>
1705+static MODULE *music=NULL;
1706+static SAMPLE *chunk[NUM_SOUNDS];
1707+static int chunkFlag[NUM_SOUNDS];
1708+#endif
1709 
1710+/* --- OPEN THE AUDIO DEVICE --- */
1711 int open_audio (int frequency, Uint16 format, int channels, int chunksize)
1712 {
1713+// close_audio();
1714+#ifndef GP2X
1715   if (Mix_OpenAudio( frequency, format, channels, chunksize ) < 0)
1716     return -1;
1717 
1718@@ -74,20 +86,93 @@
1719   /* prepare the spanning effects */
1720   Mix_SetPanning( SOUND_LEFT_SPEAKER, 230, 24 );
1721   Mix_SetPanning( SOUND_RIGHT_SPEAKER, 24, 230 );
1722+#else
1723+ if (drv_oss.Name) // Valid OSS driver
1724+ {
1725+ if (drv_oss.CommandLine) // Valid Commandline
1726+ {
1727+ drv_oss.CommandLine("buffer=14,count=2");
1728+ }
1729+ MikMod_RegisterDriver(&drv_oss);
1730+ }
1731+ if (drv_alsa.Name) // Valid ALSA driver
1732+ {
1733+ if (drv_alsa.CommandLine) // Valid Commandline
1734+ {
1735+ drv_alsa.CommandLine("buffer=14");
1736+ }
1737+ MikMod_RegisterDriver(&drv_alsa);
1738+ }
1739+ MikMod_RegisterDriver(&drv_nos);
1740+
1741+ // register standard tracker
1742+ MikMod_RegisterAllLoaders();
1743+
1744+ // Note, the md_mode flags are already set by default
1745+ md_mode |= DMODE_SOFT_SNDFX | DMODE_SOFT_MUSIC;
1746+
1747+ if (MikMod_Init("")) // Command paramenters are ignored as all drivers are registered
1748+ {
1749+ printf("mikmod init war fürn arsch\n");
1750+ return 1;
1751+ }
1752+
1753+ load_sounds();
1754+
1755+ // get ready to play
1756+ MikMod_EnableOutput();
1757+ md_volume =64;
1758+ md_sndfxvolume = 64;
1759+ //md_musicvolume = md_sndfxvolume = 64;
1760+
1761+ use_sound = true;
1762+ audio_device=true;
1763+
1764+#endif
1765   return 0;
1766-}
1767 
1768+}
1769 
1770 /* --- CLOSE THE AUDIO DEVICE --- */
1771 
1772 void close_audio( void )
1773 {
1774+#ifndef GP2X
1775   if (audio_device) {
1776     Mix_UnregisterAllEffects( SOUND_LEFT_SPEAKER );
1777     Mix_UnregisterAllEffects( SOUND_RIGHT_SPEAKER );
1778     Mix_CloseAudio();
1779   }
1780+#else
1781+ int i;
1782+ if (! audio_device) return;
1783+
1784+ MikMod_DisableOutput();
1785+ Player_Stop();
1786+ MikMod_Update();
1787+
1788+ if (music) {
1789+ Player_Free(music);
1790+ music = NULL;
1791+ }
1792+
1793+ for ( i=0 ; i<NUM_SOUNDS ; i++ ) {
1794+ if ( chunk[i] ) {
1795+ Sample_Free(chunk[i]);
1796+ }
1797+ }
1798+
1799+ MikMod_Update();
1800+ MikMod_Exit();
1801+#endif
1802+}
1803+
1804+#ifdef GP2X
1805+void updateSound ( void ) {
1806+ if (! audio_device) return;
1807+ MikMod_Update();
1808 }
1809+#endif
1810 
1811 
1812 /* --- LOAD A SOUND --- */
1813@@ -105,6 +190,30 @@
1814   return(snd);
1815 }
1816 
1817+#ifdef GP2X
1818+static void load_sounds() {
1819+ int i;
1820+ std::string name;
1821+ char file[100];
1822+
1823+ for ( i=0 ; i<NUM_SOUNDS ; i++ ) {
1824+ name = datadir + soundfilenames[i];
1825+ printf("loading: %s\n",name.c_str());
1826+ snprintf(file,sizeof(file),"%s",name.c_str());
1827+ if ( NULL == (chunk[i] = Sample_Load(file)) ) {
1828+ fprintf(stderr, "Couldn't load: %s\n", file);
1829+ use_sound = 0;
1830+ return;
1831+ }
1832+ chunkFlag[i] = 0;
1833+ }
1834+
1835+ // reserve voices for sound effects
1836+ MikMod_SetNumVoices(-1, 4);
1837+}
1838+#endif
1839+
1840+
1841 /* --- PLAY A SOUND ON LEFT OR RIGHT OR CENTER SPEAKER --- */
1842 
1843 void play_sound(Mix_Chunk * snd, enum Sound_Speaker whichSpeaker)
1844@@ -130,8 +239,45 @@
1845   }
1846 }
1847 
1848+
1849+#ifdef GP2X
1850+void play_chunk(int idx)
1851+{
1852+ int cid;
1853+// if (use_sound) return;
1854+ cid = Sample_Play (chunk[idx], 0, 0);
1855+ Voice_SetPanning(cid, PAN_CENTER);
1856+ Voice_SetVolume(cid, 1000);
1857+}
1858+#endif
1859+
1860+
1861 void free_chunk(Mix_Chunk *chunk)
1862 {
1863   Mix_FreeChunk( chunk );
1864 }
1865 
1866+void sound_volume ( int vol )
1867+{
1868+#ifndef GP2X
1869+ static int volume = 10;
1870+
1871+ if ( vol == 1 ) volume-=5;
1872+ else if ( vol == 2 ) volume+=5;
1873+ Mix_Volume(-1,volume);
1874+#endif
1875+}
1876+
1877+#ifdef GP2X
1878+void increaseSoundVolume(void)
1879+{
1880+ if (md_volume > (256 - 13)) md_volume = 256;
1881+ else md_volume += 13;
1882+}
1883+
1884+void decreaseSoundVolume(void)
1885+{
1886+ if (md_volume < 13) md_volume = 0;
1887+ else md_volume -= 13;
1888+}
1889+#endif
1890diff -ur supertux-0.1.3/src/sound.h supertux-0.1.3-gp2x/src/sound.h
1891--- supertux-0.1.3/src/sound.h 2005-06-22 00:16:07.000000000 +0300
1892+++ supertux-0.1.3-gp2x/src/sound.h 2006-04-21 00:17:09.000000000 +0300
1893@@ -75,14 +75,27 @@
1894 #include <SDL_mixer.h>
1895 
1896 /* variables for stocking the sound and music */
1897+#ifndef GP2X
1898 extern Mix_Chunk* sounds[NUM_SOUNDS];
1899+#endif
1900 
1901 /* functions handling the sound and music */
1902 int open_audio(int frequency, Uint16 format, int channels, int chunksize);
1903 void close_audio( void );
1904 
1905+#ifndef GP2X
1906 Mix_Chunk * load_sound(const std::string& file);
1907+#endif
1908 void free_chunk(Mix_Chunk*chunk);
1909 void play_sound(Mix_Chunk * snd, enum Sound_Speaker whichSpeaker);
1910+void sound_volume ( int vol );
1911 
1912 #endif /*SUPERTUX_SOUND_H*/
1913+
1914+#ifdef GP2X
1915+void play_chunk(int idx);
1916+static void load_sounds();
1917+void updateSound ( void );
1918+void increaseSoundVolume(void);
1919+void decreaseSoundVolume(void);
1920+#endif
1921diff -ur supertux-0.1.3/src/special.cpp supertux-0.1.3-gp2x/src/special.cpp
1922--- supertux-0.1.3/src/special.cpp 2005-06-22 00:16:07.000000000 +0300
1923+++ supertux-0.1.3-gp2x/src/special.cpp 2006-04-20 21:39:41.000000000 +0300
1924@@ -105,12 +105,21 @@
1925 
1926   base.ym = base.ym + 0.5 * frame_ratio;
1927 
1928+#ifndef RES320X240
1929   if (base.x < scroll_x ||
1930       base.x > scroll_x + screen->w ||
1931       base.y > screen->h ||
1932       issolid(base.x + 4, base.y + 2) ||
1933       issolid(base.x, base.y + 2) ||
1934       life_count <= 0)
1935+#else
1936+ if (base.x < scroll_x ||
1937+ base.x > scroll_x + 640 ||
1938+ base.y > 480 ||
1939+ issolid(base.x + 4, base.y + 2) ||
1940+ issolid(base.x, base.y + 2) ||
1941+ life_count <= 0)
1942+#endif
1943     {
1944       remove_me();
1945     }
1946@@ -120,8 +129,13 @@
1947 void
1948 Bullet::draw()
1949 {
1950+#ifndef RES320X240
1951   if (base.x >= scroll_x - base.width &&
1952       base.x <= scroll_x + screen->w)
1953+#else
1954+ if (base.x >= scroll_x - base.width &&
1955+ base.x <= scroll_x + 640)
1956+#endif
1957     {
1958       img_bullet->draw(base.x - scroll_x, base.y);
1959     }
1960@@ -140,7 +154,7 @@
1961 {
1962   kind = kind_;
1963   dir = dir_;
1964-
1965+
1966   base.width = 32;
1967   base.height = 0;
1968   base.x = x_;
1969@@ -197,7 +211,11 @@
1970       remove_me();
1971       return;
1972   }
1973+#ifndef RES320X240
1974   if(base.y > screen->h) {
1975+#else
1976+ if(base.y > 640) {
1977+#endif
1978     remove_me();
1979     return;
1980   }
1981@@ -252,7 +270,12 @@
1982     {
1983       /* Rising up... */
1984 
1985+
1986+#ifndef RES320X240
1987       dest.x = (int)(base.x - scroll_x);
1988+#else
1989+ dest.x = (int)(base.x - scroll_x)/2;
1990+#endif
1991       dest.y = (int)(base.y + 32 - base.height);
1992       dest.w = 32;
1993       dest.h = (int)base.height;
1994@@ -297,7 +320,11 @@
1995   if(kind != UPGRADE_GROWUP)
1996     return;
1997 
1998+#ifndef GP2X
1999   play_sound(sounds[SND_BUMP_UPGRADE], SOUND_CENTER_SPEAKER);
2000+#else
2001+ play_chunk(SND_BUMP_UPGRADE);
2002+#endif
2003   
2004   // do a little jump and change direction
2005   physic.set_velocity(-physic.get_velocity_x(), 3);
2006@@ -329,18 +356,30 @@
2007 
2008       if (kind == UPGRADE_GROWUP)
2009         {
2010+#ifndef GP2X
2011           play_sound(sounds[SND_EXCELLENT], SOUND_CENTER_SPEAKER);
2012+#else
2013+ play_chunk(SND_EXCELLENT);
2014+#endif
2015           pplayer->grow();
2016         }
2017       else if (kind == UPGRADE_ICEFLOWER)
2018         {
2019+#ifndef GP2X
2020           play_sound(sounds[SND_COFFEE], SOUND_CENTER_SPEAKER);
2021+#else
2022+ play_chunk(SND_COFFEE);
2023+#endif
2024           pplayer->grow();
2025           pplayer->got_coffee = true;
2026         }
2027       else if (kind == UPGRADE_HERRING)
2028         {
2029+#ifndef GP2X
2030           play_sound(sounds[SND_HERRING], SOUND_CENTER_SPEAKER);
2031+#else
2032+ play_chunk(SND_HERRING);
2033+#endif
2034           pplayer->invincible_timer.start(TUX_INVINCIBLE_TIME);
2035           World::current()->play_music(HERRING_MUSIC);
2036         }
2037@@ -348,7 +387,11 @@
2038         {
2039           if(player_status.lives < MAX_LIVES) {
2040             player_status.lives++;
2041+#ifndef GP2X
2042             play_sound(sounds[SND_LIFEUP], SOUND_CENTER_SPEAKER);
2043+#else
2044+ play_chunk(SND_LIFEUP);
2045+#endif
2046           }
2047         }
2048 
2049diff -ur supertux-0.1.3/src/text.cpp supertux-0.1.3-gp2x/src/text.cpp
2050--- supertux-0.1.3/src/text.cpp 2005-06-22 00:16:07.000000000 +0300
2051+++ supertux-0.1.3-gp2x/src/text.cpp 2006-04-22 01:59:36.000000000 +0300
2052@@ -24,6 +24,7 @@
2053 #include "defines.h"
2054 #include "screen.h"
2055 #include "text.h"
2056+#include "sound.h"
2057 
2058 Text::Text(const std::string& file, int kind_, int w_, int h_)
2059 {
2060@@ -79,6 +80,7 @@
2061 void
2062 Text::draw(const char* text, int x, int y, int shadowsize, int update)
2063 {
2064+
2065   if(text != NULL)
2066     {
2067       if(shadowsize != 0)
2068@@ -116,6 +118,9 @@
2069           else if ( text[i] == '\n')
2070             {
2071               y += h + 2;
2072+#ifdef RES320X240
2073+ y+=6;
2074+#endif
2075               j = 0;
2076             }
2077         }
2078@@ -129,6 +134,9 @@
2079           else if ( text[i] == '\n')
2080             {
2081               y += h + 2;
2082+#ifdef RES320X240
2083+ y+=6;
2084+#endif
2085               j = 0;
2086             }
2087         }
2088@@ -306,6 +314,24 @@
2089                 break;
2090               }
2091             break;
2092+
2093+#ifdef GP2X
2094+ case SDL_JOYBUTTONDOWN:
2095+ if ( event.jbutton.button == joystick_keymap.down_button ) {
2096+ speed += SPEED_INC;
2097+ }
2098+ if ( event.jbutton.button == joystick_keymap.up_button ) {
2099+ speed -= SPEED_INC;
2100+ }
2101+ if ( event.jbutton.button == joystick_keymap.b_button ) {
2102+ done = 1;
2103+ }
2104+ if ( event.jbutton.button == joystick_keymap.a_button ) {
2105+ scroll += SCROLL;
2106+ }
2107+ break;
2108+#endif
2109+
2110           case SDL_QUIT:
2111             done = 1;
2112             break;
2113@@ -330,21 +356,36 @@
2114             white_small_text->drawf(names.item[i]+1, 0, screen->h+y-int(scroll),
2115                 A_HMIDDLE, A_TOP, 1);
2116             y += white_small_text->h+ITEMS_SPACE;
2117+#ifdef RES320X240
2118+ y += 6;
2119+#endif
2120             break;
2121           case ' ':
2122             white_text->drawf(names.item[i]+1, 0, screen->h+y-int(scroll),
2123                 A_HMIDDLE, A_TOP, 1);
2124             y += white_text->h+ITEMS_SPACE;
2125+#ifdef RES320X240
2126+ y += 6;
2127+#endif
2128             break;
2129           case '-':
2130- white_big_text->drawf(names.item[i]+1, 0, screen->h+y-int(scroll),
2131- A_HMIDDLE, A_TOP, 3);
2132+#ifdef RES320X240
2133+ white_text->drawf(names.item[i]+1, 0, screen->h+y-int(scroll), A_HMIDDLE, A_TOP, 3);
2134+#else
2135+ white_big_text->drawf(names.item[i]+1, 0, screen->h+y-int(scroll), A_HMIDDLE, A_TOP, 3);
2136+#endif
2137             y += white_big_text->h+ITEMS_SPACE;
2138+#ifdef RES320X240
2139+ y += 6;
2140+#endif
2141             break;
2142           default:
2143             blue_text->drawf(names.item[i], 0, screen->h+y-int(scroll),
2144                 A_HMIDDLE, A_TOP, 1);
2145             y += blue_text->h+ITEMS_SPACE;
2146+#ifdef RES320X240
2147+ y += 6;
2148+#endif
2149             break;
2150           }
2151         }
2152@@ -360,7 +401,13 @@
2153       if(scroll < 0)
2154         scroll = 0;
2155 
2156- SDL_Delay(10);
2157+#ifndef GP2X
2158+ SDL_Delay(10);
2159+#else
2160+ SDL_Delay(2);
2161+ updateSound();
2162+#endif
2163+
2164     }
2165   string_list_free(&names);
2166 
2167diff -ur supertux-0.1.3/src/texture.cpp supertux-0.1.3-gp2x/src/texture.cpp
2168--- supertux-0.1.3/src/texture.cpp 2005-06-22 00:16:07.000000000 +0300
2169+++ supertux-0.1.3-gp2x/src/texture.cpp 2006-04-10 14:29:03.000000000 +0300
2170@@ -211,7 +211,8 @@
2171 {
2172   if (impl)
2173   {
2174- if (impl->draw(x, y, alpha, update) == -2)
2175+// if (impl->draw(x, y, alpha, update) == -2)
2176+ if (impl->draw(x/2, y/2, alpha, update) == -2)
2177       reload();
2178   }
2179 }
2180@@ -231,7 +232,8 @@
2181 {
2182   if (impl)
2183   {
2184- if (impl->draw_part(sx, sy, x, y, w, h, alpha, update) == -2)
2185+// if (impl->draw_part(sx, sy, x, y, w, h, alpha, update) == -2)
2186+ if (impl->draw_part(sx, sy, x, y/2, w, h, alpha, update) == -2)
2187       reload();
2188   }
2189 }
2190@@ -241,7 +243,8 @@
2191 {
2192   if (impl)
2193   {
2194- if (impl->draw_stretched(x, y, w, h, alpha, update) == -2)
2195+// if (impl->draw_stretched(x, y, w, h, alpha, update) == -2)
2196+ if (impl->draw_stretched(x/2, y/2, w, h, alpha, update) == -2)
2197       reload();
2198   }
2199 }
2200diff -ur supertux-0.1.3/src/title.cpp supertux-0.1.3-gp2x/src/title.cpp
2201--- supertux-0.1.3/src/title.cpp 2005-07-08 15:19:17.000000000 +0300
2202+++ supertux-0.1.3-gp2x/src/title.cpp 2006-04-22 01:29:08.000000000 +0300
2203@@ -51,6 +51,7 @@
2204 #include "tile.h"
2205 #include "resources.h"
2206 #include "worldmap.h"
2207+#include "sound.h"
2208 
2209 static Surface* bkg_title;
2210 static Surface* logo;
2211@@ -80,6 +81,10 @@
2212 
2213 void generate_contrib_menu()
2214 {
2215+#ifdef RES320X240
2216+ fadeout();
2217+#endif
2218+
2219   string_list_type level_subsets = dsubdirs("/levels", "info");
2220 
2221   free_contrib_menu();
2222@@ -208,7 +213,7 @@
2223     }
2224 
2225   // Wrap around at the end of the level back to the beginnig
2226- if(plevel->width * 32 - 320 < tux->base.x)
2227+ if((plevel->width * 32) - 320 < tux->base.x)
2228     {
2229       tux->level_begin();
2230       scroll_x = 0;
2231@@ -226,7 +231,6 @@
2232     {
2233       walking = false;
2234     }
2235-
2236   world->draw();
2237 }
2238 
2239@@ -301,13 +305,26 @@
2240       
2241       if (Menu::current() == main_menu)
2242         logo->draw( 160, 30);
2243-
2244+
2245+#ifndef RES320X240
2246       white_small_text->draw(" SuperTux " VERSION "\n"
2247                              "Copyright (c) 2003 SuperTux Devel Team\n"
2248                              "This game comes with ABSOLUTELY NO WARRANTY. This is free software, and you\n"
2249                              "are welcome to redistribute it under certain conditions; see the file COPYING\n"
2250                              "for details.\n",
2251                              0, 420, 0);
2252+#else
2253+ white_small_text->draw(" SuperTux " VERSION "\n"
2254+ "Copyright (c) 2003 SuperTux Devel Team\n"
2255+ "This game comes with ABSOLUTELY NO \n"
2256+ "WARRANTY. This is free software, and\n"
2257+ "you are welcome to redistribute it\n"
2258+ "under certain conditions; see the file\n"
2259+ "COPYING for details.\n",
2260+ 0, 360, 0);
2261+#endif
2262+
2263+ //updateSound();
2264 
2265       /* Don't draw menu, if quit is true */
2266       Menu* menu = Menu::current();
2267@@ -337,10 +354,10 @@
2268                   break;
2269                 case MNID_CREDITS:
2270                   music_manager = new MusicManager();
2271- menu_song = music_manager->load_music(datadir + "/music/credits.ogg");
2272+ menu_song = music_manager->load_music(datadir + "/music/credits.mod");
2273                   music_manager->halt_music();
2274                   music_manager->play_music(menu_song,0);
2275- display_text_file("CREDITS", bkg_title, SCROLL_SPEED_CREDITS);
2276+ display_text_file("CREDITS", bkg_title, SCROLL_SPEED_CREDITS);
2277                   music_manager->halt_music();
2278                   menu_song = music_manager->load_music(datadir + "/music/theme.mod");
2279                   music_manager->play_music(menu_song);
2280diff -ur supertux-0.1.3/src/world.cpp supertux-0.1.3-gp2x/src/world.cpp
2281--- supertux-0.1.3/src/world.cpp 2005-06-22 00:16:07.000000000 +0300
2282+++ supertux-0.1.3-gp2x/src/world.cpp 2006-05-05 23:16:47.000000000 +0300
2283@@ -206,6 +206,7 @@
2284         }
2285     }
2286 
2287+
2288   /* Draw interactive tiles: */
2289   for (y = 0; y < 15; ++y)
2290     {
2291@@ -255,6 +256,8 @@
2292     {
2293       (*p)->draw(scroll_x, 0, 1);
2294     }
2295+
2296+ //updateSound();
2297 }
2298 
2299 void
2300@@ -312,7 +315,12 @@
2301 
2302 // the space that it takes for the screen to start scrolling, regarding
2303 // screen bounds (in pixels)
2304+#ifndef RES320X240
2305 #define X_SPACE (400-16)
2306+#else
2307+#define X_SPACE (80-16)
2308+#endif
2309+
2310 // the time it takes to move the camera (in ms)
2311 #define CHANGE_DIR_SCROLL_SPEED 2000
2312 
2313@@ -388,8 +396,13 @@
2314   // this code prevent the screen to scroll before the start or after the level's end
2315   if(scroll_x < 0)
2316     scroll_x = 0;
2317+#ifndef RES320X240
2318   if(scroll_x > level->width * 32 - screen->w)
2319     scroll_x = level->width * 32 - screen->w;
2320+#else
2321+ if(scroll_x > level->width * 32 - 640)
2322+ scroll_x = level->width * 32 - 640;
2323+#endif
2324 }
2325 
2326 void
2327@@ -481,6 +494,10 @@
2328 void
2329 World::add_score(float x, float y, int s)
2330 {
2331+#ifdef RES320X240
2332+ x=x/2;
2333+#endif
2334+
2335   player_status.score += s;
2336 
2337   FloatingScore* new_floating_score = new FloatingScore();
2338@@ -547,8 +564,11 @@
2339   Bullet new_bullet;
2340   new_bullet.init(x,y,xm,dir);
2341   bullets.push_back(new_bullet);
2342-
2343+#ifndef GP2X
2344   play_sound(sounds[SND_SHOOT], SOUND_CENTER_SPEAKER);
2345+#else
2346+ play_chunk(SND_SHOOT);
2347+#endif
2348 }
2349 
2350 void
2351@@ -608,8 +628,11 @@
2352               counting_distros = false;
2353               plevel->change(x, y, TM_IA, tile->next_tile);
2354             }
2355-
2356+#ifndef GP2X
2357           play_sound(sounds[SND_DISTRO], SOUND_CENTER_SPEAKER);
2358+#else
2359+ play_chunk(SND_DISTRO);
2360+#endif
2361           player_status.score = player_status.score + SCORE_DISTRO;
2362           player_status.distros++;
2363         }
2364@@ -622,9 +645,13 @@
2365           add_broken_brick(tile,
2366                                  ((int)(x + 1) / 32) * 32,
2367                                  (int)(y / 32) * 32);
2368-
2369+
2370           /* Get some score: */
2371+#ifndef GP2X
2372           play_sound(sounds[SND_BRICK], SOUND_CENTER_SPEAKER);
2373+#else
2374+ play_chunk(SND_BRICK);
2375+#endif
2376           player_status.score = player_status.score + SCORE_BRICK;
2377         }
2378     }
2379@@ -652,7 +679,11 @@
2380     {
2381     case 1: // Box with a distro!
2382       add_bouncy_distro(posx, posy);
2383+#ifndef GP2X
2384       play_sound(sounds[SND_DISTRO], SOUND_CENTER_SPEAKER);
2385+#else
2386+ play_chunk(SND_DISTRO);
2387+#endif
2388       player_status.score = player_status.score + SCORE_DISTRO;
2389       player_status.distros++;
2390       break;
2391@@ -662,7 +693,11 @@
2392         add_upgrade(posx, posy, col_side, UPGRADE_GROWUP);
2393       else /* Tux is big, add an iceflower: */
2394         add_upgrade(posx, posy, col_side, UPGRADE_ICEFLOWER);
2395+#ifndef GP2X
2396       play_sound(sounds[SND_UPGRADE], SOUND_CENTER_SPEAKER);
2397+#else
2398+ play_chunk(SND_UPGRADE);
2399+#endif
2400       break;
2401 
2402     case 3: // Add a golden herring
2403@@ -688,7 +723,11 @@
2404   if (tile && tile->distro)
2405     {
2406       level->change(x, y, TM_IA, tile->next_tile);
2407+#ifndef GP2X
2408       play_sound(sounds[SND_DISTRO], SOUND_CENTER_SPEAKER);
2409+#else
2410+ play_chunk(SND_DISTRO);
2411+#endif
2412 
2413       if (bounciness == BOUNCE)
2414         {
2415diff -ur supertux-0.1.3/src/worldmap.cpp supertux-0.1.3-gp2x/src/worldmap.cpp
2416--- supertux-0.1.3/src/worldmap.cpp 2005-07-08 15:19:17.000000000 +0300
2417+++ supertux-0.1.3-gp2x/src/worldmap.cpp 2006-05-05 22:54:04.000000000 +0300
2418@@ -376,11 +376,11 @@
2419 {
2420   tile_manager = new TileManager();
2421 
2422- width = 20;
2423- height = 15;
2424+ width = (int)(20);
2425+ height = (int)(15);
2426   
2427- start_x = 4;
2428- start_y = 5;
2429+ start_x = int(4);
2430+ start_y = int(5);
2431 
2432   passive_message_timer.init(true);
2433 
2434@@ -395,7 +395,7 @@
2435   enter_level = false;
2436 
2437   name = "<no file>";
2438- music = "SALCON.MOD";
2439+ music = "salcon.mod";
2440 }
2441 
2442 WorldMap::~WorldMap()
2443@@ -589,7 +589,8 @@
2444                   break;
2445                 }
2446               break;
2447-
2448+
2449+#ifndef GP2X
2450             case SDL_JOYAXISMOTION:
2451               if (event.jaxis.axis == joystick_keymap.x_axis)
2452                 {
2453@@ -617,13 +618,29 @@
2454           if (event.jhat.value == SDL_HAT_RIGHT)
2455                     input_direction = D_EAST;
2456           break;
2457-
2458+#endif
2459             case SDL_JOYBUTTONDOWN:
2460+#ifndef GP2X
2461               if (event.jbutton.button == joystick_keymap.b_button)
2462                 enter_level = true;
2463               else if (event.jbutton.button == joystick_keymap.start_button)
2464                 on_escape_press();
2465               break;
2466+#else
2467+ if (event.jbutton.button == joystick_keymap.a_button)
2468+ enter_level = true;
2469+ else if (event.jbutton.button == joystick_keymap.start_button)
2470+ on_escape_press();
2471+ else if (event.jbutton.button == joystick_keymap.up_button)
2472+ input_direction = D_NORTH;
2473+ else if (event.jbutton.button == joystick_keymap.down_button)
2474+ input_direction = D_SOUTH;
2475+ else if (event.jbutton.button == joystick_keymap.right_button)
2476+ input_direction = D_EAST;
2477+ else if (event.jbutton.button == joystick_keymap.left_button)
2478+ input_direction = D_WEST;
2479+ break;
2480+#endif
2481 
2482             default:
2483               break;
2484@@ -769,13 +786,13 @@
2485                       {
2486                         MusicRef theme =
2487                           music_manager->load_music(datadir + "/music/theme.mod");
2488- MusicRef credits = music_manager->load_music(datadir + "/music/credits.ogg");
2489+ MusicRef credits = music_manager->load_music(datadir + "/music/credits.xm");
2490                         music_manager->play_music(theme);
2491                         // Display final credits and go back to the main menu
2492                         display_text_file(level->extro_filename,
2493                                           "/images/background/extro.jpg", SCROLL_SPEED_MESSAGE);
2494             music_manager->play_music(credits,0);
2495- display_text_file("CREDITS",
2496+ display_text_file("CREDITS",
2497                                           "/images/background/oiltux.jpg", SCROLL_SPEED_CREDITS);
2498                         music_manager->play_music(theme);
2499                         quit = true;
2500@@ -812,7 +829,12 @@
2501             if (level->x == tux->get_tile_pos().x &&
2502               level->y == tux->get_tile_pos().y)
2503                 {
2504+#ifndef GP2X
2505                     play_sound(sounds[SND_TELEPORT], SOUND_CENTER_SPEAKER);
2506+#else
2507+ play_chunk(SND_TELEPORT);
2508+ updateSound();
2509+#endif
2510                     tux->back_direction = D_NONE;
2511                     tux->set_tile_pos(Point(level->teleport_dest_x, level->teleport_dest_y));
2512                     SDL_Delay(1000);
2513@@ -914,26 +936,39 @@
2514 void
2515 WorldMap::draw_status()
2516 {
2517+ int xdiv;
2518+
2519+#ifdef RES320X240
2520+ xdiv=2;
2521+#else
2522+ xdiv=1;
2523+#endif
2524+
2525   char str[80];
2526   sprintf(str, "%d", player_status.score);
2527   white_text->draw("SCORE", 0, 0);
2528- gold_text->draw(str, 96, 0);
2529+ gold_text->draw(str, (int)(96)/xdiv, 0);
2530 
2531   sprintf(str, "%d", player_status.distros);
2532- white_text->draw_align("COINS", 320-64, 0, A_LEFT, A_TOP);
2533- gold_text->draw_align(str, 320+64, 0, A_RIGHT, A_TOP);
2534+ white_text->draw_align("COINS", (int)(320-64)/xdiv, 0, A_LEFT, A_TOP);
2535+ gold_text->draw_align(str, (int)(320+64)/xdiv, 0, A_RIGHT, A_TOP);
2536 
2537- white_text->draw("LIVES", 480, 0);
2538+ white_text->draw("LIVES", (int)(480)/xdiv, 0);
2539   if (player_status.lives >= 5)
2540     {
2541       sprintf(str, "%dx", player_status.lives);
2542- gold_text->draw_align(str, 617, 0, A_RIGHT, A_TOP);
2543- tux_life->draw(565+(18*3), 0);
2544+#ifdef RES320X240
2545+ gold_text->draw_align(str, (int)(617)/xdiv-5, 0, A_RIGHT, A_TOP);
2546+ tux_life->draw((int)((565-12+(18*3))), 0);
2547+#else
2548+ gold_text->draw_align(str, (int)(617), 0, A_RIGHT, A_TOP);
2549+ tux_life->draw((int)((565+(18*3))), 0);
2550+#endif
2551     }
2552   else
2553     {
2554       for(int i= 0; i < player_status.lives; ++i)
2555- tux_life->draw(565+(18*i),0);
2556+ tux_life->draw((565+(18/xdiv*i)),0);
2557     }
2558 
2559   if (!tux->is_moving())
2560@@ -945,7 +980,11 @@
2561             {
2562               if(!i->name.empty())
2563                 {
2564+#ifndef RES320X240
2565               white_text->draw_align(i->title.c_str(), screen->w/2, screen->h, A_HMIDDLE, A_BOTTOM);
2566+#else
2567+ white_text->draw_align(i->title.c_str(), screen->w/2, 470, A_HMIDDLE, A_BOTTOM);
2568+#endif
2569                 }
2570                   else if (i->teleport_dest_x != -1) {
2571                       if(!i->teleport_message.empty())
2572@@ -955,7 +994,7 @@
2573               /* Display a message in the map, if any as been selected */
2574               if(!i->display_map_message.empty() && !i->passive_message)
2575                 gold_text->draw_align(i->display_map_message.c_str(),
2576- screen->w/2, screen->h - 30,A_HMIDDLE, A_BOTTOM);
2577+ screen->w/2, screen->h - (int)(30),A_HMIDDLE, A_BOTTOM);
2578               break;
2579             }
2580         }
2581@@ -964,7 +1003,7 @@
2582   /* Display a passive message in the map, if needed */
2583   if(passive_message_timer.check())
2584     gold_text->draw_align(passive_message.c_str(),
2585- screen->w/2, screen->h - 30,A_HMIDDLE, A_BOTTOM);
2586+ screen->w/2, screen->h - (int)(30),A_HMIDDLE, A_BOTTOM);
2587 }
2588 
2589 void
2590@@ -997,6 +1036,7 @@
2591       Point tux_pos = tux->get_pos();
2592       if (1)
2593         {
2594+#ifndef GP2X
2595           offset.x = -tux_pos.x + screen->w/2;
2596           offset.y = -tux_pos.y + screen->h/2;
2597 
2598@@ -1005,6 +1045,16 @@
2599 
2600           if (offset.x < screen->w - width*32) offset.x = screen->w - width*32;
2601           if (offset.y < screen->h - height*32) offset.y = screen->h - height*32;
2602+#else
2603+ offset.x = -tux_pos.x + 640/2;
2604+ offset.y = -tux_pos.y + 480/2;
2605+
2606+ if (offset.x > 0) offset.x = 0;
2607+ if (offset.y > 0) offset.y = 0;
2608+
2609+ if (offset.x < 640 - width*32) offset.x = 640 - width*32;
2610+ if (offset.y < 480 - height*32) offset.y = 480 - height*32;
2611+#endif
2612         }
2613 
2614       draw(offset);
2615

Archive Download this file



interactive