Fixed timing.
authorFlorian Schulze <crow@icculus.org>
Sun, 24 Feb 2002 19:06:51 +0000 (19:06 +0000)
committerFlorian Schulze <crow@icculus.org>
Sun, 24 Feb 2002 19:06:51 +0000 (19:06 +0000)
Makefile
main.c
menu.c
sdl/interrpt.c

index b258075..cf6a41e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,14 +2,13 @@ OBJS = sdl/gfx.o sdl/interrpt.o sdl/sound.o sdl/input.o fireworks.o main.o menu.
 TARGET = jumpnbump
 
 
-CC = gcc -g3
-CFLAGS = -Wall -O2 -ffast-math -funroll-loops -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -DUSE_SDL -I. `sdl-config --cflags`
-LIBS =  -lm `sdl-config --libs`
+CC = gcc
+CFLAGS = -Wall -O2 -ffast-math -funroll-loops -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -DUSE_SDL -DNDEBUG -I. $(shell sdl-config --cflags)
+LIBS = -lm $(shell sdl-config --libs) -lSDL_mixer
 
 $(TARGET): $(OBJS)
-       $(CC) $(LFLAGS) $(LIBS) -o $(TARGET) $(OBJS)
-
+       $(CC) $(LFLAGS) -o $(TARGET) $(OBJS) $(LIBS)
 
 clean:
-       rm -f $(TARGET) *.o *~ log
+       rm -f $(TARGET) *.o sdl/*.o *~ log
 
diff --git a/main.c b/main.c
index 32c61f7..849aa8a 100644 (file)
--- a/main.c
+++ b/main.c
@@ -184,6 +184,7 @@ struct {
 struct {
        int x, y;
        int old_x, old_y;
+       int old_draw_x, old_draw_y;
        int back[2];
        int back_defined[2];
 } flies[NUM_FLIES];
@@ -213,6 +214,7 @@ int main(int argc, char *argv[])
        char str1[100];
        char pal[768];
        char cur_pal[768];
+       int update_count;
 
        if (init_program(argc, argv, pal) != 0)
                deinit_program();
@@ -276,417 +278,435 @@ int main(int argc, char *argv[])
                main_info.view_page = 0;
                main_info.draw_page = 1;
 
+               update_count = 1;
                while (1) {
 
-                       if (key_pressed(1) == 1) {
-                               end_loop_flag = 1;
-                               memset(pal, 0, 768);
-                               mod_fade_direction = 0;
-                       }
-
-                       if (strncmp(last_keys, "kcitsogop", strlen("kcitsogop")) == 0) {
-                               pogostick ^= 1;
-                               last_keys[0] = 0;
-                       }
-                       if (strncmp(last_keys, "ecapsniseinnub", strlen("ecapsniseinnub")) == 0) {
-                               bunnies_in_space ^= 1;
-                               last_keys[0] = 0;
-                       }
-                       if (strncmp(last_keys, "kcaptej", strlen("kcaptej")) == 0) {
-                               jetpack ^= 1;
-                               last_keys[0] = 0;
-                       }
-                       if (strncmp(last_keys, "seilfehtfodrol", strlen("seilfehtfodrol")) == 0) {
-                               lord_of_the_flies ^= 1;
-                               last_keys[0] = 0;
-                       }
-                       if (strncmp(last_keys, "retawnahtrekcihtsidoolb", strlen("retawnahtrekcihtsidoolb")) == 0) {
-                               blood_is_thicker_than_water ^= 1;
-                               if (blood_is_thicker_than_water == 1) {
-                                       pal[432] = 63;
-                                       pal[433] = 32;
-                                       pal[434] = 32;
-                                       pal[435] = 53;
-                                       pal[436] = 17;
-                                       pal[437] = 17;
-                                       pal[438] = 42;
-                                       pal[439] = 7;
-                                       pal[440] = 7;
-                                       pal[441] = 28;
-                                       pal[442] = 0;
-                                       pal[443] = 0;
-                                       pal[444] = 24;
-                                       pal[445] = 0;
-                                       pal[446] = 0;
-                                       pal[447] = 19;
-                                       pal[448] = 0;
-                                       pal[449] = 0;
-                                       pal[450] = 12;
-                                       pal[451] = 0;
-                                       pal[452] = 0;
-                                       pal[453] = 7;
-                                       pal[454] = 0;
-                                       pal[455] = 0;
-                               } else {
-                                       pal[432] = 63;
-                                       pal[433] = 63;
-                                       pal[434] = 63;
-                                       pal[435] = 40;
-                                       pal[436] = 53;
-                                       pal[437] = 62;
-                                       pal[438] = 19;
-                                       pal[439] = 42;
-                                       pal[440] = 60;
-                                       pal[441] = 0;
-                                       pal[442] = 33;
-                                       pal[443] = 60;
-                                       pal[444] = 3;
-                                       pal[445] = 32;
-                                       pal[446] = 46;
-                                       pal[447] = 3;
-                                       pal[448] = 26;
-                                       pal[449] = 33;
-                                       pal[450] = 3;
-                                       pal[451] = 19;
-                                       pal[452] = 21;
-                                       pal[453] = 1;
-                                       pal[454] = 8;
-                                       pal[455] = 8;
-                               }
-                               register_background(background_pic, pal);
-                               recalculate_gob(&object_gobs, pal);
-                               last_keys[0] = 0;
-                       }
+                       printf("update_countg: %i\n",update_count);
 
-                       steer_players();
+                       while (update_count) {
 
-                       dj_mix();
+                               if (key_pressed(1) == 1) {
+                                       end_loop_flag = 1;
+                                       memset(pal, 0, 768);
+                                       mod_fade_direction = 0;
+                               }
 
-                       for (c3 = 0; c3 < 6; c3++) {
-                               if (c3 == 0) {
-                                       c1 = 0;
-                                       c2 = 1;
-                               } else if (c3 == 1) {
-                                       c1 = 0;
-                                       c2 = 2;
-                               } else if (c3 == 2) {
-                                       c1 = 0;
-                                       c2 = 3;
-                               } else if (c3 == 3) {
-                                       c1 = 1;
-                                       c2 = 2;
-                               } else if (c3 == 4) {
-                                       c1 = 1;
-                                       c2 = 3;
-                               } else if (c3 == 5) {
-                                       c1 = 2;
-                                       c2 = 3;
+                               if (strncmp(last_keys, "kcitsogop", strlen("kcitsogop")) == 0) {
+                                       pogostick ^= 1;
+                                       last_keys[0] = 0;
+                               }
+                               if (strncmp(last_keys, "ecapsniseinnub", strlen("ecapsniseinnub")) == 0) {
+                                       bunnies_in_space ^= 1;
+                                       last_keys[0] = 0;
                                }
-                               if (player[c1].enabled == 1 && player[c2].enabled == 1) {
-                                       if (labs(player[c1].x - player[c2].x) < (12L << 16) && labs(player[c1].y - player[c2].y) < (12L << 16)) {
-                                               if ((labs(player[c1].y - player[c2].y) >> 16) > 5) {
-                                                       if (player[c1].y < player[c2].y) {
-                                                               if (player[c1].y_add >= 0) {
-                                                                       player[c1].y_add = -player[c1].y_add;
-                                                                       if (player[c1].y_add > -262144L)
-                                                                               player[c1].y_add = -262144L;
-                                                                       player[c1].jump_abort = 1;
-                                                                       player[c2].dead_flag = 1;
-                                                                       if (player[c2].anim != 6) {
-                                                                               player[c2].anim = 6;
-                                                                               player[c2].frame = 0;
-                                                                               player[c2].frame_tick = 0;
-                                                                               player[c2].image = player_anims[player[c2].anim].frame[player[c2].frame].image + player[c2].direction * 9;
-                                                                               if (main_info.no_gore == 0) {
-                                                                                       for (c4 = 0; c4 < 6; c4++)
-                                                                                               add_object(OBJ_FUR, (player[c2].x >> 16) + 6 + rnd(5), (player[c2].y >> 16) + 6 + rnd(5), (rnd(65535) - 32768) * 3, (rnd(65535) - 32768) * 3, 0, 44 + c2 * 8);
-                                                                                       for (c4 = 0; c4 < 6; c4++)
-                                                                                               add_object(OBJ_FLESH, (player[c2].x >> 16) + 6 + rnd(5), (player[c2].y >> 16) + 6 + rnd(5), (rnd(65535) - 32768) * 3, (rnd(65535) - 32768) * 3, 0, 76);
-                                                                                       for (c4 = 0; c4 < 6; c4++)
-                                                                                               add_object(OBJ_FLESH, (player[c2].x >> 16) + 6 + rnd(5), (player[c2].y >> 16) + 6 + rnd(5), (rnd(65535) - 32768) * 3, (rnd(65535) - 32768) * 3, 0, 77);
-                                                                                       for (c4 = 0; c4 < 8; c4++)
-                                                                                               add_object(OBJ_FLESH, (player[c2].x >> 16) + 6 + rnd(5), (player[c2].y >> 16) + 6 + rnd(5), (rnd(65535) - 32768) * 3, (rnd(65535) - 32768) * 3, 0, 78);
-                                                                                       for (c4 = 0; c4 < 10; c4++)
-                                                                                               add_object(OBJ_FLESH, (player[c2].x >> 16) + 6 + rnd(5), (player[c2].y >> 16) + 6 + rnd(5), (rnd(65535) - 32768) * 3, (rnd(65535) - 32768) * 3, 0, 79);
+                               if (strncmp(last_keys, "kcaptej", strlen("kcaptej")) == 0) {
+                                       jetpack ^= 1;
+                                       last_keys[0] = 0;
+                               }
+                               if (strncmp(last_keys, "seilfehtfodrol", strlen("seilfehtfodrol")) == 0) {
+                                       lord_of_the_flies ^= 1;
+                                       last_keys[0] = 0;
+                               }
+                               if (strncmp(last_keys, "retawnahtrekcihtsidoolb", strlen("retawnahtrekcihtsidoolb")) == 0) {
+                                       blood_is_thicker_than_water ^= 1;
+                                       if (blood_is_thicker_than_water == 1) {
+                                               pal[432] = 63;
+                                               pal[433] = 32;
+                                               pal[434] = 32;
+                                               pal[435] = 53;
+                                               pal[436] = 17;
+                                               pal[437] = 17;
+                                               pal[438] = 42;
+                                               pal[439] = 7;
+                                               pal[440] = 7;
+                                               pal[441] = 28;
+                                               pal[442] = 0;
+                                               pal[443] = 0;
+                                               pal[444] = 24;
+                                               pal[445] = 0;
+                                               pal[446] = 0;
+                                               pal[447] = 19;
+                                               pal[448] = 0;
+                                               pal[449] = 0;
+                                               pal[450] = 12;
+                                               pal[451] = 0;
+                                               pal[452] = 0;
+                                               pal[453] = 7;
+                                               pal[454] = 0;
+                                               pal[455] = 0;
+                                       } else {
+                                               pal[432] = 63;
+                                               pal[433] = 63;
+                                               pal[434] = 63;
+                                               pal[435] = 40;
+                                               pal[436] = 53;
+                                               pal[437] = 62;
+                                               pal[438] = 19;
+                                               pal[439] = 42;
+                                               pal[440] = 60;
+                                               pal[441] = 0;
+                                               pal[442] = 33;
+                                               pal[443] = 60;
+                                               pal[444] = 3;
+                                               pal[445] = 32;
+                                               pal[446] = 46;
+                                               pal[447] = 3;
+                                               pal[448] = 26;
+                                               pal[449] = 33;
+                                               pal[450] = 3;
+                                               pal[451] = 19;
+                                               pal[452] = 21;
+                                               pal[453] = 1;
+                                               pal[454] = 8;
+                                               pal[455] = 8;
+                                       }
+                                       register_background(background_pic, pal);
+                                       recalculate_gob(&object_gobs, pal);
+                                       last_keys[0] = 0;
+                               }
+
+                               steer_players();
+
+                               dj_mix();
+
+                               for (c3 = 0; c3 < 6; c3++) {
+                                       if (c3 == 0) {
+                                               c1 = 0;
+                                               c2 = 1;
+                                       } else if (c3 == 1) {
+                                               c1 = 0;
+                                               c2 = 2;
+                                       } else if (c3 == 2) {
+                                               c1 = 0;
+                                               c2 = 3;
+                                       } else if (c3 == 3) {
+                                               c1 = 1;
+                                               c2 = 2;
+                                       } else if (c3 == 4) {
+                                               c1 = 1;
+                                               c2 = 3;
+                                       } else if (c3 == 5) {
+                                               c1 = 2;
+                                               c2 = 3;
+                                       }
+                                       if (player[c1].enabled == 1 && player[c2].enabled == 1) {
+                                               if (labs(player[c1].x - player[c2].x) < (12L << 16) && labs(player[c1].y - player[c2].y) < (12L << 16)) {
+                                                       if ((labs(player[c1].y - player[c2].y) >> 16) > 5) {
+                                                               if (player[c1].y < player[c2].y) {
+                                                                       if (player[c1].y_add >= 0) {
+                                                                               player[c1].y_add = -player[c1].y_add;
+                                                                               if (player[c1].y_add > -262144L)
+                                                                                       player[c1].y_add = -262144L;
+                                                                               player[c1].jump_abort = 1;
+                                                                               player[c2].dead_flag = 1;
+                                                                               if (player[c2].anim != 6) {
+                                                                                       player[c2].anim = 6;
+                                                                                       player[c2].frame = 0;
+                                                                                       player[c2].frame_tick = 0;
+                                                                                       player[c2].image = player_anims[player[c2].anim].frame[player[c2].frame].image + player[c2].direction * 9;
+                                                                                       if (main_info.no_gore == 0) {
+                                                                                               for (c4 = 0; c4 < 6; c4++)
+                                                                                                       add_object(OBJ_FUR, (player[c2].x >> 16) + 6 + rnd(5), (player[c2].y >> 16) + 6 + rnd(5), (rnd(65535) - 32768) * 3, (rnd(65535) - 32768) * 3, 0, 44 + c2 * 8);
+                                                                                               for (c4 = 0; c4 < 6; c4++)
+                                                                                                       add_object(OBJ_FLESH, (player[c2].x >> 16) + 6 + rnd(5), (player[c2].y >> 16) + 6 + rnd(5), (rnd(65535) - 32768) * 3, (rnd(65535) - 32768) * 3, 0, 76);
+                                                                                               for (c4 = 0; c4 < 6; c4++)
+                                                                                                       add_object(OBJ_FLESH, (player[c2].x >> 16) + 6 + rnd(5), (player[c2].y >> 16) + 6 + rnd(5), (rnd(65535) - 32768) * 3, (rnd(65535) - 32768) * 3, 0, 77);
+                                                                                               for (c4 = 0; c4 < 8; c4++)
+                                                                                                       add_object(OBJ_FLESH, (player[c2].x >> 16) + 6 + rnd(5), (player[c2].y >> 16) + 6 + rnd(5), (rnd(65535) - 32768) * 3, (rnd(65535) - 32768) * 3, 0, 78);
+                                                                                               for (c4 = 0; c4 < 10; c4++)
+                                                                                                       add_object(OBJ_FLESH, (player[c2].x >> 16) + 6 + rnd(5), (player[c2].y >> 16) + 6 + rnd(5), (rnd(65535) - 32768) * 3, (rnd(65535) - 32768) * 3, 0, 79);
+                                                                                       }
+                                                                                       dj_play_sfx(SFX_DEATH, (unsigned short)(SFX_DEATH_FREQ + rnd(2000) - 1000), 64, 0, 0, -1);
+                                                                                       player[c1].bumps++;
+                                                                                       player[c1].bumped[c2]++;
+                                                                                       s1 = player[c1].bumps % 100;
+                                                                                       add_leftovers(0, 360, 34 + c1 * 64, s1 / 10, &number_gobs);
+                                                                                       add_leftovers(1, 360, 34 + c1 * 64, s1 / 10, &number_gobs);
+                                                                                       add_leftovers(0, 376, 34 + c1 * 64, s1 - (s1 / 10) * 10, &number_gobs);
+                                                                                       add_leftovers(1, 376, 34 + c1 * 64, s1 - (s1 / 10) * 10, &number_gobs);
                                                                                }
-                                                                               dj_play_sfx(SFX_DEATH, (unsigned short)(SFX_DEATH_FREQ + rnd(2000) - 1000), 64, 0, 0, -1);
-                                                                               player[c1].bumps++;
-                                                                               player[c1].bumped[c2]++;
-                                                                               s1 = player[c1].bumps % 100;
-                                                                               add_leftovers(0, 360, 34 + c1 * 64, s1 / 10, &number_gobs);
-                                                                               add_leftovers(1, 360, 34 + c1 * 64, s1 / 10, &number_gobs);
-                                                                               add_leftovers(0, 376, 34 + c1 * 64, s1 - (s1 / 10) * 10, &number_gobs);
-                                                                               add_leftovers(1, 376, 34 + c1 * 64, s1 - (s1 / 10) * 10, &number_gobs);
+                                                                       } else {
+                                                                               if (player[c2].y_add < 0)
+                                                                                       player[c2].y_add = 0;
                                                                        }
                                                                } else {
-                                                                       if (player[c2].y_add < 0)
-                                                                               player[c2].y_add = 0;
-                                                               }
-                                                       } else {
-                                                               if (player[c2].y_add >= 0) {
-                                                                       player[c2].y_add = -player[c2].y_add;
-                                                                       if (player[c2].y_add > -262144L)
-                                                                               player[c2].y_add = -262144L;
-                                                                       player[c2].jump_abort = 1;
-                                                                       player[c1].dead_flag = 1;
-                                                                       if (player[c1].anim != 6) {
-                                                                               player[c1].anim = 6;
-                                                                               player[c1].frame = 0;
-                                                                               player[c1].frame_tick = 0;
-                                                                               player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
-                                                                               if (main_info.no_gore == 0) {
-                                                                                       for (c4 = 0; c4 < 6; c4++)
-                                                                                               add_object(OBJ_FUR, (player[c1].x >> 16) + 6 + rnd(5), (player[c1].y >> 16) + 6 + rnd(5), (rnd(65535) - 32768) * 3, (rnd(65535) - 32768) * 3, 0, 44 + c1 * 8);
-                                                                                       for (c4 = 0; c4 < 6; c4++)
-                                                                                               add_object(OBJ_FLESH, (player[c1].x >> 16) + 6 + rnd(5), (player[c1].y >> 16) + 6 + rnd(5), (rnd(65535) - 32768) * 3, (rnd(65535) - 32768) * 3, 0, 76);
-                                                                                       for (c4 = 0; c4 < 7; c4++)
-                                                                                               add_object(OBJ_FLESH, (player[c1].x >> 16) + 6 + rnd(5), (player[c1].y >> 16) + 6 + rnd(5), (rnd(65535) - 32768) * 3, (rnd(65535) - 32768) * 3, 0, 77);
-                                                                                       for (c4 = 0; c4 < 8; c4++)
-                                                                                               add_object(OBJ_FLESH, (player[c1].x >> 16) + 6 + rnd(5), (player[c1].y >> 16) + 6 + rnd(5), (rnd(65535) - 32768) * 3, (rnd(65535) - 32768) * 3, 0, 78);
-                                                                                       for (c4 = 0; c4 < 10; c4++)
-                                                                                               add_object(OBJ_FLESH, (player[c1].x >> 16) + 6 + rnd(5), (player[c1].y >> 16) + 6 + rnd(5), (rnd(65535) - 32768) * 3, (rnd(65535) - 32768) * 3, 0, 79);
+                                                                       if (player[c2].y_add >= 0) {
+                                                                               player[c2].y_add = -player[c2].y_add;
+                                                                               if (player[c2].y_add > -262144L)
+                                                                                       player[c2].y_add = -262144L;
+                                                                               player[c2].jump_abort = 1;
+                                                                               player[c1].dead_flag = 1;
+                                                                               if (player[c1].anim != 6) {
+                                                                                       player[c1].anim = 6;
+                                                                                       player[c1].frame = 0;
+                                                                                       player[c1].frame_tick = 0;
+                                                                                       player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
+                                                                                       if (main_info.no_gore == 0) {
+                                                                                               for (c4 = 0; c4 < 6; c4++)
+                                                                                                       add_object(OBJ_FUR, (player[c1].x >> 16) + 6 + rnd(5), (player[c1].y >> 16) + 6 + rnd(5), (rnd(65535) - 32768) * 3, (rnd(65535) - 32768) * 3, 0, 44 + c1 * 8);
+                                                                                               for (c4 = 0; c4 < 6; c4++)
+                                                                                                       add_object(OBJ_FLESH, (player[c1].x >> 16) + 6 + rnd(5), (player[c1].y >> 16) + 6 + rnd(5), (rnd(65535) - 32768) * 3, (rnd(65535) - 32768) * 3, 0, 76);
+                                                                                               for (c4 = 0; c4 < 7; c4++)
+                                                                                                       add_object(OBJ_FLESH, (player[c1].x >> 16) + 6 + rnd(5), (player[c1].y >> 16) + 6 + rnd(5), (rnd(65535) - 32768) * 3, (rnd(65535) - 32768) * 3, 0, 77);
+                                                                                               for (c4 = 0; c4 < 8; c4++)
+                                                                                                       add_object(OBJ_FLESH, (player[c1].x >> 16) + 6 + rnd(5), (player[c1].y >> 16) + 6 + rnd(5), (rnd(65535) - 32768) * 3, (rnd(65535) - 32768) * 3, 0, 78);
+                                                                                               for (c4 = 0; c4 < 10; c4++)
+                                                                                                       add_object(OBJ_FLESH, (player[c1].x >> 16) + 6 + rnd(5), (player[c1].y >> 16) + 6 + rnd(5), (rnd(65535) - 32768) * 3, (rnd(65535) - 32768) * 3, 0, 79);
+                                                                                       }
+                                                                                       dj_play_sfx(SFX_DEATH, (unsigned short)(SFX_DEATH_FREQ + rnd(2000) - 1000), 64, 0, 0, -1);
+                                                                                       player[c2].bumps++;
+                                                                                       player[c2].bumped[c1]++;
+                                                                                       s1 = player[c2].bumps % 100;
+                                                                                       add_leftovers(0, 360, 34 + c2 * 64, s1 / 10, &number_gobs);
+                                                                                       add_leftovers(1, 360, 34 + c2 * 64, s1 / 10, &number_gobs);
+                                                                                       add_leftovers(0, 376, 34 + c2 * 64, s1 - (s1 / 10) * 10, &number_gobs);
+                                                                                       add_leftovers(1, 376, 34 + c2 * 64, s1 - (s1 / 10) * 10, &number_gobs);
                                                                                }
-                                                                               dj_play_sfx(SFX_DEATH, (unsigned short)(SFX_DEATH_FREQ + rnd(2000) - 1000), 64, 0, 0, -1);
-                                                                               player[c2].bumps++;
-                                                                               player[c2].bumped[c1]++;
-                                                                               s1 = player[c2].bumps % 100;
-                                                                               add_leftovers(0, 360, 34 + c2 * 64, s1 / 10, &number_gobs);
-                                                                               add_leftovers(1, 360, 34 + c2 * 64, s1 / 10, &number_gobs);
-                                                                               add_leftovers(0, 376, 34 + c2 * 64, s1 - (s1 / 10) * 10, &number_gobs);
-                                                                               add_leftovers(1, 376, 34 + c2 * 64, s1 - (s1 / 10) * 10, &number_gobs);
+                                                                       } else {
+                                                                               if (player[c1].y_add < 0)
+                                                                                       player[c1].y_add = 0;
                                                                        }
-                                                               } else {
-                                                                       if (player[c1].y_add < 0)
-                                                                               player[c1].y_add = 0;
-                                                               }
-                                                       }
-                                               } else {
-                                                       if (player[c1].x < player[c2].x) {
-                                                               if (player[c1].x_add > 0)
-                                                                       player[c1].x = player[c2].x - (12L << 16);
-                                                               else if (player[c2].x_add < 0)
-                                                                       player[c2].x = player[c1].x + (12L << 16);
-                                                               else {
-                                                                       player[c1].x -= player[c1].x_add;
-                                                                       player[c2].x -= player[c2].x_add;
                                                                }
-                                                               l1 = player[c2].x_add;
-                                                               player[c2].x_add = player[c1].x_add;
-                                                               player[c1].x_add = l1;
-                                                               if (player[c1].x_add > 0)
-                                                                       player[c1].x_add = -player[c1].x_add;
-                                                               if (player[c2].x_add < 0)
-                                                                       player[c2].x_add = -player[c2].x_add;
                                                        } else {
-                                                               if (player[c1].x_add > 0)
-                                                                       player[c2].x = player[c1].x - (12L << 16);
-                                                               else if (player[c2].x_add < 0)
-                                                                       player[c1].x = player[c2].x + (12L << 16);
-                                                               else {
-                                                                       player[c1].x -= player[c1].x_add;
-                                                                       player[c2].x -= player[c2].x_add;
+                                                               if (player[c1].x < player[c2].x) {
+                                                                       if (player[c1].x_add > 0)
+                                                                               player[c1].x = player[c2].x - (12L << 16);
+                                                                       else if (player[c2].x_add < 0)
+                                                                               player[c2].x = player[c1].x + (12L << 16);
+                                                                       else {
+                                                                               player[c1].x -= player[c1].x_add;
+                                                                               player[c2].x -= player[c2].x_add;
+                                                                       }
+                                                                       l1 = player[c2].x_add;
+                                                                       player[c2].x_add = player[c1].x_add;
+                                                                       player[c1].x_add = l1;
+                                                                       if (player[c1].x_add > 0)
+                                                                               player[c1].x_add = -player[c1].x_add;
+                                                                       if (player[c2].x_add < 0)
+                                                                               player[c2].x_add = -player[c2].x_add;
+                                                               } else {
+                                                                       if (player[c1].x_add > 0)
+                                                                               player[c2].x = player[c1].x - (12L << 16);
+                                                                       else if (player[c2].x_add < 0)
+                                                                               player[c1].x = player[c2].x + (12L << 16);
+                                                                       else {
+                                                                               player[c1].x -= player[c1].x_add;
+                                                                               player[c2].x -= player[c2].x_add;
+                                                                       }
+                                                                       l1 = player[c2].x_add;
+                                                                       player[c2].x_add = player[c1].x_add;
+                                                                       player[c1].x_add = l1;
+                                                                       if (player[c1].x_add < 0)
+                                                                               player[c1].x_add = -player[c1].x_add;
+                                                                       if (player[c2].x_add > 0)
+                                                                               player[c2].x_add = -player[c2].x_add;
                                                                }
-                                                               l1 = player[c2].x_add;
-                                                               player[c2].x_add = player[c1].x_add;
-                                                               player[c1].x_add = l1;
-                                                               if (player[c1].x_add < 0)
-                                                                       player[c1].x_add = -player[c1].x_add;
-                                                               if (player[c2].x_add > 0)
-                                                                       player[c2].x_add = -player[c2].x_add;
                                                        }
                                                }
                                        }
                                }
-                       }
 
-                       dj_mix();
+                               dj_mix();
 
-                       main_info.page_info[main_info.draw_page].num_pobs = 0;
-                       for (c1 = 0; c1 < 4; c1++) {
-                               if (player[c1].enabled == 1)
-                                       main_info.page_info[main_info.draw_page].num_pobs++;
-                       }
+                               main_info.page_info[main_info.draw_page].num_pobs = 0;
+                               for (c1 = 0; c1 < 4; c1++) {
+                                       if (player[c1].enabled == 1)
+                                               main_info.page_info[main_info.draw_page].num_pobs++;
+                               }
 
-                       update_objects();
+                               update_objects();
 
-                       dj_mix();
+                               dj_mix();
 
-                       /* get center of fly swarm */
-                       s1 = s2 = 0;
-                       for (c1 = 0; c1 < NUM_FLIES; c1++) {
-                               s1 += flies[c1].x;
-                               s2 += flies[c1].y;
-                       }
-                       s1 /= NUM_FLIES;
-                       s2 /= NUM_FLIES;
-
-                       /* get closest player to fly swarm */
-                       dist = 0x7fff;
-                       for (c1 = 0; c1 < 4; c1++) {
-                               if (player[c1].enabled == 1) {
-                                       cur_dist = (int)sqrt((s1 - ((player[c1].x >> 16) + 8)) * (s1 - ((player[c1].x >> 16) + 8)) + (s2 - ((player[c1].y >> 16) + 8)) * (s2 - ((player[c1].y >> 16) + 8)));
-                                       if (cur_dist < dist) {
-                                               closest_player = c1;
-                                               dist = cur_dist;
-                                       }
+                               /* get center of fly swarm */
+                               s1 = s2 = 0;
+                               for (c1 = 0; c1 < NUM_FLIES; c1++) {
+                                       s1 += flies[c1].x;
+                                       s2 += flies[c1].y;
                                }
-                       }
-                       /* update fly swarm sound */
-                       s3 = 32 - dist / 3;
-                       if (s3 < 0)
-                               s3 = 0;
-                       dj_set_sfx_channel_volume(4, (char)(s3));
-
-                       for (c1 = 0; c1 < NUM_FLIES; c1++) {
-                               /* get closest player to fly */
-                               dist = 0x7fff;
-                               for (c2 = 0; c2 < 4; c2++) {
-                                       if (player[c2].enabled == 1) {
-                                               cur_dist = (int)sqrt((flies[c1].x - ((player[c2].x >> 16) + 8)) * (flies[c1].x - ((player[c2].x >> 16) + 8)) + (flies[c1].y - ((player[c2].y >> 16) + 8)) * (flies[c1].y - ((player[c2].y >> 16) + 8)));
-                                               if (cur_dist < dist) {
-                                                       closest_player = c2;
-                                                       dist = cur_dist;
+                               s1 /= NUM_FLIES;
+                               s2 /= NUM_FLIES;
+
+                               if (update_count == 1) {
+                                       /* get closest player to fly swarm */
+                                       dist = 0x7fff;
+                                       for (c1 = 0; c1 < 4; c1++) {
+                                               if (player[c1].enabled == 1) {
+                                                       cur_dist = (int)sqrt((s1 - ((player[c1].x >> 16) + 8)) * (s1 - ((player[c1].x >> 16) + 8)) + (s2 - ((player[c1].y >> 16) + 8)) * (s2 - ((player[c1].y >> 16) + 8)));
+                                                       if (cur_dist < dist) {
+                                                               closest_player = c1;
+                                                               dist = cur_dist;
+                                                       }
                                                }
                                        }
+                                       /* update fly swarm sound */
+                                       s3 = 32 - dist / 3;
+                                       if (s3 < 0)
+                                               s3 = 0;
+                                       dj_set_sfx_channel_volume(4, (char)(s3));
                                }
-                               flies[c1].old_x = flies[c1].x;
-                               flies[c1].old_y = flies[c1].y;
-                               s3 = 0;
-                               if ((s1 - flies[c1].x) > 30)
-                                       s3 += 1;
-                               else if ((s1 - flies[c1].x) < -30)
-                                       s3 -= 1;
-                               if (dist < 30) {
-                                       if (((player[closest_player].x >> 16) + 8) > flies[c1].x) {
-                                               if (lord_of_the_flies == 0)
-                                                       s3 -= 1;
-                                               else
-                                                       s3 += 1;
-                                       } else {
-                                               if (lord_of_the_flies == 0)
-                                                       s3 += 1;
-                                               else
-                                                       s3 -= 1;
+
+                               for (c1 = 0; c1 < NUM_FLIES; c1++) {
+                                       /* get closest player to fly */
+                                       dist = 0x7fff;
+                                       for (c2 = 0; c2 < 4; c2++) {
+                                               if (player[c2].enabled == 1) {
+                                                       cur_dist = (int)sqrt((flies[c1].x - ((player[c2].x >> 16) + 8)) * (flies[c1].x - ((player[c2].x >> 16) + 8)) + (flies[c1].y - ((player[c2].y >> 16) + 8)) * (flies[c1].y - ((player[c2].y >> 16) + 8)));
+                                                       if (cur_dist < dist) {
+                                                               closest_player = c2;
+                                                               dist = cur_dist;
+                                                       }
+                                               }
                                        }
-                               }
-                               s4 = rnd(3) - 1 + s3;
-                               if ((flies[c1].x + s4) < 16)
-                                       s4 = 0;
-                               if ((flies[c1].x + s4) > 351)
-                                       s4 = 0;
-                               if (ban_map[flies[c1].y >> 4][(flies[c1].x + s4) >> 4] != BAN_VOID)
-                                       s4 = 0;
-                               flies[c1].x += s4;
-                               s3 = 0;
-                               if ((s2 - flies[c1].y) > 30)
-                                       s3 += 1;
-                               else if ((s2 - flies[c1].y) < -30)
-                                       s3 -= 1;
-                               if (dist < 30) {
-                                       if (((player[closest_player].y >> 16) + 8) > flies[c1].y) {
-                                               if (lord_of_the_flies == 0)
-                                                       s3 -= 1;
-                                               else
-                                                       s3 += 1;
-                                       } else {
-                                               if (lord_of_the_flies == 0)
-                                                       s3 += 1;
-                                               else
-                                                       s3 -= 1;
+                                       flies[c1].old_x = flies[c1].x;
+                                       flies[c1].old_y = flies[c1].y;
+                                       s3 = 0;
+                                       if ((s1 - flies[c1].x) > 30)
+                                               s3 += 1;
+                                       else if ((s1 - flies[c1].x) < -30)
+                                               s3 -= 1;
+                                       if (dist < 30) {
+                                               if (((player[closest_player].x >> 16) + 8) > flies[c1].x) {
+                                                       if (lord_of_the_flies == 0)
+                                                               s3 -= 1;
+                                                       else
+                                                               s3 += 1;
+                                               } else {
+                                                       if (lord_of_the_flies == 0)
+                                                               s3 += 1;
+                                                       else
+                                                               s3 -= 1;
+                                               }
                                        }
+                                       s4 = rnd(3) - 1 + s3;
+                                       if ((flies[c1].x + s4) < 16)
+                                               s4 = 0;
+                                       if ((flies[c1].x + s4) > 351)
+                                               s4 = 0;
+                                       if (ban_map[flies[c1].y >> 4][(flies[c1].x + s4) >> 4] != BAN_VOID)
+                                               s4 = 0;
+                                       flies[c1].x += s4;
+                                       s3 = 0;
+                                       if ((s2 - flies[c1].y) > 30)
+                                               s3 += 1;
+                                       else if ((s2 - flies[c1].y) < -30)
+                                               s3 -= 1;
+                                       if (dist < 30) {
+                                               if (((player[closest_player].y >> 16) + 8) > flies[c1].y) {
+                                                       if (lord_of_the_flies == 0)
+                                                               s3 -= 1;
+                                                       else
+                                                               s3 += 1;
+                                               } else {
+                                                       if (lord_of_the_flies == 0)
+                                                               s3 += 1;
+                                                       else
+                                                               s3 -= 1;
+                                               }
+                                       }
+                                       s4 = rnd(3) - 1 + s3;
+                                       if ((flies[c1].y + s4) < 0)
+                                               s4 = 0;
+                                       if ((flies[c1].y + s4) > 239)
+                                               s4 = 0;
+                                       if (ban_map[(flies[c1].y + s4) >> 4][flies[c1].x >> 4] != BAN_VOID)
+                                               s4 = 0;
+                                       flies[c1].y += s4;
                                }
-                               s4 = rnd(3) - 1 + s3;
-                               if ((flies[c1].y + s4) < 0)
-                                       s4 = 0;
-                               if ((flies[c1].y + s4) > 239)
-                                       s4 = 0;
-                               if (ban_map[(flies[c1].y + s4) >> 4][flies[c1].x >> 4] != BAN_VOID)
-                                       s4 = 0;
-                               flies[c1].y += s4;
-                       }
 
-                       dj_mix();
+                               dj_mix();
 
-                       s1 = 0;
-                       for (c1 = 0; c1 < 4; c1++) {
-                               if (player[c1].enabled == 1) {
-                                       main_info.page_info[main_info.draw_page].pobs[s1].x = player[c1].x >> 16;
-                                       main_info.page_info[main_info.draw_page].pobs[s1].y = player[c1].y >> 16;
-                                       main_info.page_info[main_info.draw_page].pobs[s1].image = player[c1].image + c1 * 18;
-                                       main_info.page_info[main_info.draw_page].pobs[s1].pob_data = &rabbit_gobs;
-                                       s1++;
+                               s1 = 0;
+                               for (c1 = 0; c1 < 4; c1++) {
+                                       if (player[c1].enabled == 1) {
+                                               main_info.page_info[main_info.draw_page].pobs[s1].x = player[c1].x >> 16;
+                                               main_info.page_info[main_info.draw_page].pobs[s1].y = player[c1].y >> 16;
+                                               main_info.page_info[main_info.draw_page].pobs[s1].image = player[c1].image + c1 * 18;
+                                               main_info.page_info[main_info.draw_page].pobs[s1].pob_data = &rabbit_gobs;
+                                               s1++;
+                                       }
                                }
-                       }
 
-                       draw_begin();
+                               if (update_count == 1) {
+                                       draw_begin();
 
-                       draw_pobs(main_info.draw_page);
+                                       draw_pobs(main_info.draw_page);
 
-                       dj_mix();
-
-                       draw_flies(main_info.draw_page);
+                                       dj_mix();
 
-                       draw_end();
+                                       draw_flies(main_info.draw_page);
 
-                       if (mod_fade_direction == 1) {
-                               if (mod_vol < 30) {
-                                       mod_vol++;
-                                       dj_set_mod_volume((char)mod_vol);
-                               }
-                       } else {
-                               if (mod_vol > 0) {
-                                       mod_vol--;
-                                       dj_set_mod_volume((char)mod_vol);
+                                       draw_end();
                                }
-                       }
 
-                       if (mod_fade_direction == 1) {
-                               if (sfx_vol < 64) {
-                                       sfx_vol++;
-                                       dj_set_sfx_volume((char)sfx_vol);
+                               if (mod_fade_direction == 1) {
+                                       if (mod_vol < 30) {
+                                               mod_vol++;
+                                               dj_set_mod_volume((char)mod_vol);
+                                       }
+                               } else {
+                                       if (mod_vol > 0) {
+                                               mod_vol--;
+                                               dj_set_mod_volume((char)mod_vol);
+                                       }
                                }
-                       } else {
-                               if (sfx_vol > 0) {
-                                       sfx_vol--;
-                                       dj_set_sfx_volume((char)sfx_vol);
+
+                               if (mod_fade_direction == 1) {
+                                       if (sfx_vol < 64) {
+                                               sfx_vol++;
+                                               dj_set_sfx_volume((char)sfx_vol);
+                                       }
+                               } else {
+                                       if (sfx_vol > 0) {
+                                               sfx_vol--;
+                                               dj_set_sfx_volume((char)sfx_vol);
+                                       }
                                }
-                       }
 
-                       fade_flag = 0;
-                       for (c1 = 0; c1 < 768; c1++) {
-                               if (cur_pal[c1] < pal[c1]) {
-                                       cur_pal[c1]++;
-                                       fade_flag = 1;
-                               } else if (cur_pal[c1] > pal[c1]) {
-                                       cur_pal[c1]--;
-                                       fade_flag = 1;
+                               fade_flag = 0;
+                               for (c1 = 0; c1 < 768; c1++) {
+                                       if (cur_pal[c1] < pal[c1]) {
+                                               cur_pal[c1]++;
+                                               fade_flag = 1;
+                                       } else if (cur_pal[c1] > pal[c1]) {
+                                               cur_pal[c1]--;
+                                               fade_flag = 1;
+                                       }
                                }
-                       }
-                       if (fade_flag == 0 && end_loop_flag == 1)
-                               break;
+                               if (fade_flag == 0 && end_loop_flag == 1)
+                                       break;
 
-                       main_info.draw_page ^= 1;
-                       main_info.view_page ^= 1;
+                               if (update_count == 1) {
+                                       main_info.draw_page ^= 1;
+                                       main_info.view_page ^= 1;
 
-                       flippage(main_info.view_page);
+                                       flippage(main_info.view_page);
+       
+                                       wait_vrt(1);
+                               }
 
-                       wait_vrt(1);
+                               if (fade_flag == 1)
+                                       setpalette(0, 256, cur_pal);
 
-                       if (fade_flag == 1)
-                               setpalette(0, 256, cur_pal);
+                               if (update_count == 1) {
+                                       draw_begin();
 
-                       draw_begin();
+                                       redraw_flies_background(main_info.draw_page);
 
-                       redraw_flies_background(main_info.draw_page);
+                                       redraw_pob_backgrounds(main_info.draw_page);
 
-                       redraw_pob_backgrounds(main_info.draw_page);
+                                       draw_leftovers(main_info.draw_page);
 
-                       draw_leftovers(main_info.draw_page);
+                                       draw_end();
+                               }
 
-                       draw_end();
+                               update_count--;
+                       }
 
-                       intr_sysupdate();
+                       update_count = intr_sysupdate();
 
+                       if (fade_flag == 0 && end_loop_flag == 1)
+                               break;
                }
 
                main_info.view_page = 0;
@@ -1649,7 +1669,9 @@ void redraw_flies_background(int page)
 
        for (c2 = NUM_FLIES - 1; c2 >= 0; c2--) {
                if (flies[c2].back_defined[page] == 1)
-                       set_pixel(page, flies[c2].old_x, flies[c2].old_y, flies[c2].back[page]);
+                       set_pixel(page, flies[c2].old_draw_x, flies[c2].old_draw_y, flies[c2].back[page]);
+               flies[c2].old_draw_x = flies[c2].x;
+               flies[c2].old_draw_y = flies[c2].y;
        }
 }
 
diff --git a/menu.c b/menu.c
index d35f346..10731c3 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -75,6 +75,7 @@ int menu(void)
        int cur_message;
        int fade_dir, fade_count, fade_tick;
        char fade_pal[48];
+       int update_count;
 
        if (menu_init() != 0)
                return 1;
@@ -103,92 +104,149 @@ int menu(void)
        esc_pressed = key_pressed(1);
        end_loop_flag = new_game_flag = 0;
 
+       update_count = 1;
        while (1) {
 
                dj_mix();
-               intr_sysupdate();
-
-               if (key_pressed(1) == 1 && esc_pressed == 0) {
-                       end_loop_flag = 1;
-                       new_game_flag = 0;
-                       memset(menu_pal, 0, 768);
-                       mod_fade_direction = 0;
-               } else if (key_pressed(1) == 0)
-                       esc_pressed = 0;
-
-               update_player_actions();
-               for (c1 = 0; c1 < 4; c1++) {
-                       if (end_loop_flag == 1 && new_game_flag == 1) {
-                               if ((player[c1].x >> 16) > (165 + c1 * 2)) {
-                                       if (player[c1].x_add < 0)
-                                               player[c1].x_add += 16384;
-                                       else
-                                               player[c1].x_add += 12288;
-                                       if (player[c1].x_add > 98304L)
-                                               player[c1].x_add = 98304L;
-                                       player[c1].direction = 0;
-                                       if (player[c1].anim == 0) {
-                                               player[c1].anim = 1;
+
+               printf("update_count: %i\n",update_count);
+
+               while (update_count) {
+
+                       if (key_pressed(1) == 1 && esc_pressed == 0) {
+                               end_loop_flag = 1;
+                               new_game_flag = 0;
+                               memset(menu_pal, 0, 768);
+                               mod_fade_direction = 0;
+                       } else if (key_pressed(1) == 0)
+                               esc_pressed = 0;
+
+                       update_player_actions();
+                       for (c1 = 0; c1 < 4; c1++) {
+                               if (end_loop_flag == 1 && new_game_flag == 1) {
+                                       if ((player[c1].x >> 16) > (165 + c1 * 2)) {
+                                               if (player[c1].x_add < 0)
+                                                       player[c1].x_add += 16384;
+                                               else
+                                                       player[c1].x_add += 12288;
+                                               if (player[c1].x_add > 98304L)
+                                                       player[c1].x_add = 98304L;
+                                               player[c1].direction = 0;
+                                               if (player[c1].anim == 0) {
+                                                       player[c1].anim = 1;
+                                                       player[c1].frame = 0;
+                                                       player[c1].frame_tick = 0;
+                                                       player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
+                                               }
+                                               player[c1].enabled = 1;
+                                       }
+                                       if (!player[c1].action_up) {
+                                               if (player[c1].y_add < 0) {
+                                                       player[c1].y_add += 32768;
+                                                       if (player[c1].y_add > 0)
+                                                               player[c1].y_add = 0;
+                                               }
+                                       }
+                                       player[c1].y_add += 12288;
+                                       if (player[c1].y_add > 36864 && player[c1].anim != 3) {
+                                               player[c1].anim = 3;
                                                player[c1].frame = 0;
                                                player[c1].frame_tick = 0;
                                                player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
                                        }
-                                       player[c1].enabled = 1;
-                               }
-                               if (!player[c1].action_up) {
-                                       if (player[c1].y_add < 0) {
-                                               player[c1].y_add += 32768;
-                                               if (player[c1].y_add > 0)
+                                       player[c1].y += player[c1].y_add;
+                                       if ((player[c1].x >> 16) <= (165 + c1 * 2) || (player[c1].x >> 16) >= (208 + c1 * 2)) {
+                                               if ((player[c1].y >> 16) > (160 + c1 * 2)) {
+                                                       player[c1].y = (160L + c1 * 2) << 16;
                                                        player[c1].y_add = 0;
-                                       }
-                               }
-                               player[c1].y_add += 12288;
-                               if (player[c1].y_add > 36864 && player[c1].anim != 3) {
-                                       player[c1].anim = 3;
-                                       player[c1].frame = 0;
-                                       player[c1].frame_tick = 0;
-                                       player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
-                               }
-                               player[c1].y += player[c1].y_add;
-                               if ((player[c1].x >> 16) <= (165 + c1 * 2) || (player[c1].x >> 16) >= (208 + c1 * 2)) {
-                                       if ((player[c1].y >> 16) > (160 + c1 * 2)) {
-                                               player[c1].y = (160L + c1 * 2) << 16;
-                                               player[c1].y_add = 0;
-                                               if (player[c1].anim != 0 && player[c1].anim != 1) {
-                                                       player[c1].anim = 0;
-                                                       player[c1].frame = 0;
-                                                       player[c1].frame_tick = 0;
-                                                       player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
+                                                       if (player[c1].anim != 0 && player[c1].anim != 1) {
+                                                               player[c1].anim = 0;
+                                                               player[c1].frame = 0;
+                                                               player[c1].frame_tick = 0;
+                                                               player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
+                                                       }
+                                               }
+                                       } else {
+                                               if ((player[c1].y >> 16) > (138 + c1 * 2)) {
+                                                       player[c1].y = (138L + c1 * 2) << 16;
+                                                       player[c1].y_add = 0;
+                                                       if (player[c1].anim != 0 && player[c1].anim != 1) {
+                                                               player[c1].anim = 0;
+                                                               player[c1].frame = 0;
+                                                               player[c1].frame_tick = 0;
+                                                               player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
+                                                       }
+                                                       if (!player[c1].action_up)
+                                                               player[c1].jump_ready = 1;
                                                }
                                        }
-                               } else {
+                                       player[c1].x += player[c1].x_add;
                                        if ((player[c1].y >> 16) > (138 + c1 * 2)) {
-                                               player[c1].y = (138L + c1 * 2) << 16;
-                                               player[c1].y_add = 0;
-                                               if (player[c1].anim != 0 && player[c1].anim != 1) {
-                                                       player[c1].anim = 0;
-                                                       player[c1].frame = 0;
-                                                       player[c1].frame_tick = 0;
-                                                       player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
+                                               if ((player[c1].x >> 16) > (165 + c1 * 2) && (player[c1].x >> 16) < (190 + c1 * 2)) {
+                                                       player[c1].x = (165L + c1 * 2) << 16;
+                                                       player[c1].x_add = 0;
+                                               }
+                                               if ((player[c1].x >> 16) > (190 + c1 * 2) && (player[c1].x >> 16) < (208 + c1 * 2)) {
+                                                       player[c1].x = (208L + c1 * 2) << 16;
+                                                       player[c1].x_add = 0;
                                                }
-                                               if (!player[c1].action_up)
-                                                       player[c1].jump_ready = 1;
-                                       }
-                               }
-                               player[c1].x += player[c1].x_add;
-                               if ((player[c1].y >> 16) > (138 + c1 * 2)) {
-                                       if ((player[c1].x >> 16) > (165 + c1 * 2) && (player[c1].x >> 16) < (190 + c1 * 2)) {
-                                               player[c1].x = (165L + c1 * 2) << 16;
-                                               player[c1].x_add = 0;
-                                       }
-                                       if ((player[c1].x >> 16) > (190 + c1 * 2) && (player[c1].x >> 16) < (208 + c1 * 2)) {
-                                               player[c1].x = (208L + c1 * 2) << 16;
-                                               player[c1].x_add = 0;
                                        }
-                               }
-                       } else {
-                               if (player[c1].action_left && player[c1].action_right) {
-                                       if (player[c1].direction == 1) {
+                               } else {
+                                       if (player[c1].action_left && player[c1].action_right) {
+                                               if (player[c1].direction == 1) {
+                                                       if ((player[c1].x >> 16) <= (165 + c1 * 2) || (player[c1].x >> 16) >= (208 + c1 * 2)) {
+                                                               if (player[c1].x_add > 0) {
+                                                                       player[c1].x_add -= 16384;
+                                                                       if ((player[c1].y >> 16) >= (160 + c1 * 2))
+                                                                               add_object(OBJ_SMOKE, (player[c1].x >> 16) + 2 + rnd(9), (player[c1].y >> 16) + 13 + rnd(5), 0, -16384 - rnd(8192), OBJ_ANIM_SMOKE, 0);
+                                                               } else
+                                                                       player[c1].x_add -= 12288;
+                                                       }
+                                                       if ((player[c1].x >> 16) > (165 + c1 * 2) && (player[c1].x >> 16) < (208 + c1 * 2)) {
+                                                               if (player[c1].x_add > 0) {
+                                                                       player[c1].x_add -= 16384;
+                                                                       if ((player[c1].y >> 16) >= (138 + c1 * 2))
+                                                                               add_object(OBJ_SMOKE, (player[c1].x >> 16) + 2 + rnd(9), (player[c1].y >> 16) + 13 + rnd(5), 0, -16384 - rnd(8192), OBJ_ANIM_SMOKE, 0);
+                                                               } else
+                                                                       player[c1].x_add -= 12288;
+                                                       }
+                                                       if (player[c1].x_add < -98304L)
+                                                               player[c1].x_add = -98304L;
+                                                       player[c1].direction = 1;
+                                                       if (player[c1].anim == 0) {
+                                                               player[c1].anim = 1;
+                                                               player[c1].frame = 0;
+                                                               player[c1].frame_tick = 0;
+                                                               player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
+                                                       }
+                                               } else {
+                                                       if ((player[c1].x >> 16) <= (165 + c1 * 2) || (player[c1].x >> 16) >= (208 + c1 * 2)) {
+                                                               if (player[c1].x_add < 0) {
+                                                                       player[c1].x_add += 16384;
+                                                                       if ((player[c1].y >> 16) >= (160 + c1 * 2))
+                                                                               add_object(OBJ_SMOKE, (player[c1].x >> 16) + 2 + rnd(9), (player[c1].y >> 16) + 13 + rnd(5), 0, -16384 - rnd(8192), OBJ_ANIM_SMOKE, 0);
+                                                               } else
+                                                                       player[c1].x_add += 12288;
+                                                       }
+                                                       if ((player[c1].x >> 16) > (165 + c1 * 2) && (player[c1].x >> 16) < (208 + c1 * 2)) {
+                                                               if (player[c1].x_add < 0) {
+                                                                       player[c1].x_add += 16384;
+                                                                       if ((player[c1].y >> 16) >= (138 + c1 * 2))
+                                                                               add_object(OBJ_SMOKE, (player[c1].x >> 16) + 2 + rnd(9), (player[c1].y >> 16) + 13 + rnd(5), 0, -16384 - rnd(8192), OBJ_ANIM_SMOKE, 0);
+                                                               } else
+                                                                       player[c1].x_add += 12288;
+                                                       }
+                                                       if (player[c1].x_add > 98304L)
+                                                               player[c1].x_add = 98304L;
+                                                       player[c1].direction = 0;
+                                                       if (player[c1].anim == 0) {
+                                                               player[c1].anim = 1;
+                                                               player[c1].frame = 0;
+                                                               player[c1].frame_tick = 0;
+                                                               player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
+                                                       }
+                                               }
+                                       } else if (player[c1].action_left) {
                                                if ((player[c1].x >> 16) <= (165 + c1 * 2) || (player[c1].x >> 16) >= (208 + c1 * 2)) {
                                                        if (player[c1].x_add > 0) {
                                                                player[c1].x_add -= 16384;
@@ -214,7 +272,7 @@ int menu(void)
                                                        player[c1].frame_tick = 0;
                                                        player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
                                                }
-                                       } else {
+                                       } else if (player[c1].action_right) {
                                                if ((player[c1].x >> 16) <= (165 + c1 * 2) || (player[c1].x >> 16) >= (208 + c1 * 2)) {
                                                        if (player[c1].x_add < 0) {
                                                                player[c1].x_add += 16384;
@@ -240,294 +298,252 @@ int menu(void)
                                                        player[c1].frame_tick = 0;
                                                        player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
                                                }
-                                       }
-                               } else if (player[c1].action_left) {
-                                       if ((player[c1].x >> 16) <= (165 + c1 * 2) || (player[c1].x >> 16) >= (208 + c1 * 2)) {
-                                               if (player[c1].x_add > 0) {
-                                                       player[c1].x_add -= 16384;
-                                                       if ((player[c1].y >> 16) >= (160 + c1 * 2))
+                                       } else {
+                                               if (((player[c1].x >> 16) <= (165 + c1 * 2) || (player[c1].x >> 16) >= (208 + c1 * 2)) && (player[c1].y >> 16) >= (160 + c1 * 2)) {
+                                                       if (player[c1].x_add < 0) {
+                                                               player[c1].x_add += 16384;
+                                                               if (player[c1].x_add > 0)
+                                                                       player[c1].x_add = 0;
                                                                add_object(OBJ_SMOKE, (player[c1].x >> 16) + 2 + rnd(9), (player[c1].y >> 16) + 13 + rnd(5), 0, -16384 - rnd(8192), OBJ_ANIM_SMOKE, 0);
-                                               } else
-                                                       player[c1].x_add -= 12288;
-                                       }
-                                       if ((player[c1].x >> 16) > (165 + c1 * 2) && (player[c1].x >> 16) < (208 + c1 * 2)) {
-                                               if (player[c1].x_add > 0) {
-                                                       player[c1].x_add -= 16384;
-                                                       if ((player[c1].y >> 16) >= (138 + c1 * 2))
+                                                       } else if (player[c1].x_add > 0) {
+                                                               player[c1].x_add -= 16384;
+                                                               if (player[c1].x_add < 0)
+                                                                       player[c1].x_add = 0;
                                                                add_object(OBJ_SMOKE, (player[c1].x >> 16) + 2 + rnd(9), (player[c1].y >> 16) + 13 + rnd(5), 0, -16384 - rnd(8192), OBJ_ANIM_SMOKE, 0);
-                                               } else
-                                                       player[c1].x_add -= 12288;
-                                       }
-                                       if (player[c1].x_add < -98304L)
-                                               player[c1].x_add = -98304L;
-                                       player[c1].direction = 1;
-                                       if (player[c1].anim == 0) {
-                                               player[c1].anim = 1;
-                                               player[c1].frame = 0;
-                                               player[c1].frame_tick = 0;
-                                               player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
-                                       }
-                               } else if (player[c1].action_right) {
-                                       if ((player[c1].x >> 16) <= (165 + c1 * 2) || (player[c1].x >> 16) >= (208 + c1 * 2)) {
-                                               if (player[c1].x_add < 0) {
-                                                       player[c1].x_add += 16384;
-                                                       if ((player[c1].y >> 16) >= (160 + c1 * 2))
+                                                       }
+                                               }
+                                               if ((((player[c1].x >> 16) > (165 + c1 * 2) && (player[c1].x >> 16) < (208 + c1 * 2)) && (player[c1].y >> 16) >= (138 + c1 * 2))) {
+                                                       if (player[c1].x_add < 0) {
+                                                               player[c1].x_add += 16384;
+                                                               if (player[c1].x_add > 0)
+                                                                       player[c1].x_add = 0;
                                                                add_object(OBJ_SMOKE, (player[c1].x >> 16) + 2 + rnd(9), (player[c1].y >> 16) + 13 + rnd(5), 0, -16384 - rnd(8192), OBJ_ANIM_SMOKE, 0);
-                                               } else
-                                                       player[c1].x_add += 12288;
-                                       }
-                                       if ((player[c1].x >> 16) > (165 + c1 * 2) && (player[c1].x >> 16) < (208 + c1 * 2)) {
-                                               if (player[c1].x_add < 0) {
-                                                       player[c1].x_add += 16384;
-                                                       if ((player[c1].y >> 16) >= (138 + c1 * 2))
+                                                       } else if (player[c1].x_add > 0) {
+                                                               player[c1].x_add -= 16384;
+                                                               if (player[c1].x_add < 0)
+                                                                       player[c1].x_add = 0;
                                                                add_object(OBJ_SMOKE, (player[c1].x >> 16) + 2 + rnd(9), (player[c1].y >> 16) + 13 + rnd(5), 0, -16384 - rnd(8192), OBJ_ANIM_SMOKE, 0);
-                                               } else
-                                                       player[c1].x_add += 12288;
-                                       }
-                                       if (player[c1].x_add > 98304L)
-                                               player[c1].x_add = 98304L;
-                                       player[c1].direction = 0;
-                                       if (player[c1].anim == 0) {
-                                               player[c1].anim = 1;
-                                               player[c1].frame = 0;
-                                               player[c1].frame_tick = 0;
-                                               player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
+                                                       }
+                                               }
+                                               if (player[c1].anim == 1) {
+                                                       player[c1].anim = 0;
+                                                       player[c1].frame = 0;
+                                                       player[c1].frame_tick = 0;
+                                                       player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
+                                               }
                                        }
-                               } else {
-                                       if (((player[c1].x >> 16) <= (165 + c1 * 2) || (player[c1].x >> 16) >= (208 + c1 * 2)) && (player[c1].y >> 16) >= (160 + c1 * 2)) {
-                                               if (player[c1].x_add < 0) {
-                                                       player[c1].x_add += 16384;
-                                                       if (player[c1].x_add > 0)
-                                                               player[c1].x_add = 0;
-                                                       add_object(OBJ_SMOKE, (player[c1].x >> 16) + 2 + rnd(9), (player[c1].y >> 16) + 13 + rnd(5), 0, -16384 - rnd(8192), OBJ_ANIM_SMOKE, 0);
-                                               } else if (player[c1].x_add > 0) {
-                                                       player[c1].x_add -= 16384;
-                                                       if (player[c1].x_add < 0)
-                                                               player[c1].x_add = 0;
-                                                       add_object(OBJ_SMOKE, (player[c1].x >> 16) + 2 + rnd(9), (player[c1].y >> 16) + 13 + rnd(5), 0, -16384 - rnd(8192), OBJ_ANIM_SMOKE, 0);
+                                       if ((player[c1].jump_ready == 1) && player[c1].action_up) {
+                                               if ((player[c1].x >> 16) <= (165 + c1 * 2) || (player[c1].x >> 16) >= (208 + c1 * 2)) {
+                                                       if ((player[c1].y >> 16) >= (160 + c1 * 2)) {
+                                                               player[c1].y_add = -280000L;
+                                                               player[c1].anim = 2;
+                                                               player[c1].frame = 0;
+                                                               player[c1].frame_tick = 0;
+                                                               player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
+                                                               player[c1].jump_ready = 0;
+                                                               dj_play_sfx(SFX_JUMP, (unsigned short)(SFX_JUMP_FREQ + rnd(2000) - 1000), 64, 0, 0, -1);
+                                                       }
+                                               } else {
+                                                       if ((player[c1].y >> 16) >= (138 + c1 * 2)) {
+                                                               player[c1].y_add = -280000L;
+                                                               player[c1].anim = 2;
+                                                               player[c1].frame = 0;
+                                                               player[c1].frame_tick = 0;
+                                                               player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
+                                                               player[c1].jump_ready = 0;
+                                                               dj_play_sfx(SFX_JUMP, (unsigned short)(SFX_JUMP_FREQ + rnd(2000) - 1000), 64, 0, 0, -1);
+                                                       }
                                                }
                                        }
-                                       if ((((player[c1].x >> 16) > (165 + c1 * 2) && (player[c1].x >> 16) < (208 + c1 * 2)) && (player[c1].y >> 16) >= (138 + c1 * 2))) {
-                                               if (player[c1].x_add < 0) {
-                                                       player[c1].x_add += 16384;
-                                                       if (player[c1].x_add > 0)
-                                                               player[c1].x_add = 0;
-                                                       add_object(OBJ_SMOKE, (player[c1].x >> 16) + 2 + rnd(9), (player[c1].y >> 16) + 13 + rnd(5), 0, -16384 - rnd(8192), OBJ_ANIM_SMOKE, 0);
-                                               } else if (player[c1].x_add > 0) {
-                                                       player[c1].x_add -= 16384;
-                                                       if (player[c1].x_add < 0)
-                                                               player[c1].x_add = 0;
-                                                       add_object(OBJ_SMOKE, (player[c1].x >> 16) + 2 + rnd(9), (player[c1].y >> 16) + 13 + rnd(5), 0, -16384 - rnd(8192), OBJ_ANIM_SMOKE, 0);
+                                       if (!player[c1].action_up) {
+                                               if (player[c1].y_add < 0) {
+                                                       player[c1].y_add += 32768;
+                                                       if (player[c1].y_add > 0)
+                                                               player[c1].y_add = 0;
                                                }
                                        }
-                                       if (player[c1].anim == 1) {
-                                               player[c1].anim = 0;
+                                       if (!player[c1].action_up)
+                                               player[c1].jump_ready = 1;
+                                       player[c1].y_add += 12288;
+                                       if (player[c1].y_add > 36864 && player[c1].anim != 3) {
+                                               player[c1].anim = 3;
                                                player[c1].frame = 0;
                                                player[c1].frame_tick = 0;
                                                player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
                                        }
-                               }
-                               if ((player[c1].jump_ready == 1) && player[c1].action_up) {
+                                       player[c1].y += player[c1].y_add;
                                        if ((player[c1].x >> 16) <= (165 + c1 * 2) || (player[c1].x >> 16) >= (208 + c1 * 2)) {
-                                               if ((player[c1].y >> 16) >= (160 + c1 * 2)) {
-                                                       player[c1].y_add = -280000L;
-                                                       player[c1].anim = 2;
-                                                       player[c1].frame = 0;
-                                                       player[c1].frame_tick = 0;
-                                                       player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
-                                                       player[c1].jump_ready = 0;
-                                                       dj_play_sfx(SFX_JUMP, (unsigned short)(SFX_JUMP_FREQ + rnd(2000) - 1000), 64, 0, 0, -1);
+                                               if ((player[c1].y >> 16) > (160 + c1 * 2)) {
+                                                       player[c1].y = (160L + c1 * 2) << 16;
+                                                       player[c1].y_add = 0;
+                                                       if (player[c1].anim != 0 && player[c1].anim != 1) {
+                                                               player[c1].anim = 0;
+                                                               player[c1].frame = 0;
+                                                               player[c1].frame_tick = 0;
+                                                               player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
+                                                       }
                                                }
                                        } else {
-                                               if ((player[c1].y >> 16) >= (138 + c1 * 2)) {
-                                                       player[c1].y_add = -280000L;
-                                                       player[c1].anim = 2;
-                                                       player[c1].frame = 0;
-                                                       player[c1].frame_tick = 0;
-                                                       player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
-                                                       player[c1].jump_ready = 0;
-                                                       dj_play_sfx(SFX_JUMP, (unsigned short)(SFX_JUMP_FREQ + rnd(2000) - 1000), 64, 0, 0, -1);
+                                               if ((player[c1].y >> 16) > (138 + c1 * 2)) {
+                                                       player[c1].y = (138L + c1 * 2) << 16;
+                                                       player[c1].y_add = 0;
+                                                       if (player[c1].anim != 0 && player[c1].anim != 1) {
+                                                               player[c1].anim = 0;
+                                                               player[c1].frame = 0;
+                                                               player[c1].frame_tick = 0;
+                                                               player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
+                                                       }
                                                }
                                        }
-                               }
-                               if (!player[c1].action_up) {
-                                       if (player[c1].y_add < 0) {
-                                               player[c1].y_add += 32768;
-                                               if (player[c1].y_add > 0)
-                                                       player[c1].y_add = 0;
+                                       player[c1].x += player[c1].x_add;
+                                       if ((player[c1].x >> 16) < 0) {
+                                               player[c1].x = 0;
+                                               player[c1].x_add = 0;
                                        }
-                               }
-                               if (!player[c1].action_up)
-                                       player[c1].jump_ready = 1;
-                               player[c1].y_add += 12288;
-                               if (player[c1].y_add > 36864 && player[c1].anim != 3) {
-                                       player[c1].anim = 3;
-                                       player[c1].frame = 0;
-                                       player[c1].frame_tick = 0;
-                                       player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
-                               }
-                               player[c1].y += player[c1].y_add;
-                               if ((player[c1].x >> 16) <= (165 + c1 * 2) || (player[c1].x >> 16) >= (208 + c1 * 2)) {
-                                       if ((player[c1].y >> 16) > (160 + c1 * 2)) {
-                                               player[c1].y = (160L + c1 * 2) << 16;
-                                               player[c1].y_add = 0;
-                                               if (player[c1].anim != 0 && player[c1].anim != 1) {
-                                                       player[c1].anim = 0;
-                                                       player[c1].frame = 0;
-                                                       player[c1].frame_tick = 0;
-                                                       player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
-                                               }
+                                       if ((player[c1].x >> 16) > 400) {
+                                               end_loop_flag = 1;
+                                               new_game_flag = 1;
+                                               memset(menu_pal, 0, 768);
+                                               mod_fade_direction = 0;
                                        }
-                               } else {
                                        if ((player[c1].y >> 16) > (138 + c1 * 2)) {
-                                               player[c1].y = (138L + c1 * 2) << 16;
-                                               player[c1].y_add = 0;
-                                               if (player[c1].anim != 0 && player[c1].anim != 1) {
-                                                       player[c1].anim = 0;
-                                                       player[c1].frame = 0;
-                                                       player[c1].frame_tick = 0;
-                                                       player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
+                                               if ((player[c1].x >> 16) > (165 + c1 * 2) && (player[c1].x >> 16) < (190 + c1 * 2)) {
+                                                       player[c1].x = (165L + c1 * 2) << 16;
+                                                       player[c1].x_add = 0;
+                                               }
+                                               if ((player[c1].x >> 16) > (190 + c1 * 2) && (player[c1].x >> 16) < (208 + c1 * 2)) {
+                                                       player[c1].x = (208L + c1 * 2) << 16;
+                                                       player[c1].x_add = 0;
                                                }
                                        }
                                }
-                               player[c1].x += player[c1].x_add;
-                               if ((player[c1].x >> 16) < 0) {
-                                       player[c1].x = 0;
-                                       player[c1].x_add = 0;
-                               }
-                               if ((player[c1].x >> 16) > 400) {
-                                       end_loop_flag = 1;
-                                       new_game_flag = 1;
-                                       memset(menu_pal, 0, 768);
-                                       mod_fade_direction = 0;
-                               }
-                               if ((player[c1].y >> 16) > (138 + c1 * 2)) {
-                                       if ((player[c1].x >> 16) > (165 + c1 * 2) && (player[c1].x >> 16) < (190 + c1 * 2)) {
-                                               player[c1].x = (165L + c1 * 2) << 16;
-                                               player[c1].x_add = 0;
-                                       }
-                                       if ((player[c1].x >> 16) > (190 + c1 * 2) && (player[c1].x >> 16) < (208 + c1 * 2)) {
-                                               player[c1].x = (208L + c1 * 2) << 16;
-                                               player[c1].x_add = 0;
-                                       }
+                               player[c1].frame_tick++;
+                               if (player[c1].frame_tick >= player_anims[player[c1].anim].frame[player[c1].frame].ticks) {
+                                       player[c1].frame++;
+                                       if (player[c1].frame >= player_anims[player[c1].anim].num_frames)
+                                               player[c1].frame = player_anims[player[c1].anim].restart_frame;
+                                       player[c1].frame_tick = 0;
                                }
+                               player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
                        }
-                       player[c1].frame_tick++;
-                       if (player[c1].frame_tick >= player_anims[player[c1].anim].frame[player[c1].frame].ticks) {
-                               player[c1].frame++;
-                               if (player[c1].frame >= player_anims[player[c1].anim].num_frames)
-                                       player[c1].frame = player_anims[player[c1].anim].restart_frame;
-                               player[c1].frame_tick = 0;
-                       }
-                       player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
-               }
 
-               dj_mix();
+                       dj_mix();
 
-               main_info.page_info[main_info.draw_page].num_pobs = 0;
+                       main_info.page_info[main_info.draw_page].num_pobs = 0;
 
-               for (c1 = 3; c1 >= 0; c1--)
-                       add_pob(main_info.draw_page, player[c1].x >> 16, player[c1].y >> 16, player[c1].image + c1 * 18, &rabbit_gobs);
+                       for (c1 = 3; c1 >= 0; c1--)
+                               add_pob(main_info.draw_page, player[c1].x >> 16, player[c1].y >> 16, player[c1].image + c1 * 18, &rabbit_gobs);
 
-               update_objects();
+                       update_objects();
 
-               draw_begin();
-               draw_pobs(main_info.draw_page);
-               draw_end();
+                       if (update_count == 1) {
+                               draw_begin();
+                               draw_pobs(main_info.draw_page);
+                               draw_end();
 
-               dj_mix();
+                               dj_mix();
 
-               if (mod_fade_direction == 1) {
-                       if (mod_vol < 35) {
-                               mod_vol++;
-                               dj_set_mod_volume((char)mod_vol);
-                       }
-               } else {
-                       if (mod_vol > 0) {
-                               mod_vol--;
-                               dj_set_mod_volume((char)mod_vol);
+                               if (mod_fade_direction == 1) {
+                                       if (mod_vol < 35) {
+                                               mod_vol++;
+                                               dj_set_mod_volume((char)mod_vol);
+                                       }
+                               } else {
+                                       if (mod_vol > 0) {
+                                               mod_vol--;
+                                               dj_set_mod_volume((char)mod_vol);
+                                       }
+                               }
                        }
-               }
 
-               fade_flag = 0;
-               for (c1 = 0; c1 < 720; c1++) {
-                       if (menu_cur_pal[c1] < menu_pal[c1]) {
-                               menu_cur_pal[c1]++;
-                               fade_flag = 1;
-                       } else if (menu_cur_pal[c1] > menu_pal[c1]) {
-                               menu_cur_pal[c1]--;
-                               fade_flag = 2;
-                       }
-               }
-               if (fade_flag == 0 && end_loop_flag == 1) {
-                       menu_deinit();
-                       if (new_game_flag == 1)
-                               return 0;
-                       else
-                               return 1;
-               }
-               switch (fade_dir) {
-               case 0:
-                       if (fade_count < 30) {
-                               for (c1 = 0; c1 < 48; c1++) {
-                                       if (fade_pal[c1] > 0)
-                                               fade_pal[c1]--;
+                       fade_flag = 0;
+                       for (c1 = 0; c1 < 720; c1++) {
+                               if (menu_cur_pal[c1] < menu_pal[c1]) {
+                                       menu_cur_pal[c1]++;
+                                       fade_flag = 1;
+                               } else if (menu_cur_pal[c1] > menu_pal[c1]) {
+                                       menu_cur_pal[c1]--;
+                                       fade_flag = 2;
                                }
-                               fade_count++;
-                       } else {
-                               draw_begin();
-                               clear_lines(0, 220, 20, 0);
-                               clear_lines(1, 220, 20, 0);
-
-                               cur_message++;
-                               if (cur_message >= NUM_MESSAGES)
-                                       cur_message -= NUM_MESSAGES;
-                               put_text(0, 200, 220, message[cur_message], 2);
-                               put_text(1, 200, 220, message[cur_message], 2);
-                               fade_dir = 1;
-                               fade_count = 0;
-                               fade_tick = 0;
-                               draw_end();
                        }
-                       break;
-               case 1:
-                       if (fade_count < 100) {
-                               for (c1 = 0; c1 < 48; c1++) {
-                                       if (fade_pal[c1] < menu_pal[c1 + 720])
-                                               fade_pal[c1]++;
+                       if (fade_flag == 0 && end_loop_flag == 1) {
+                               menu_deinit();
+                               if (new_game_flag == 1)
+                                       return 0;
+                               else
+                                       return 1;
+                       }
+                       switch (fade_dir) {
+                       case 0:
+                               if (fade_count < 30) {
+                                       for (c1 = 0; c1 < 48; c1++) {
+                                               if (fade_pal[c1] > 0)
+                                                       fade_pal[c1]--;
+                                       }
+                                       fade_count++;
+                               } else {
+                                       draw_begin();
+                                       clear_lines(0, 220, 20, 0);
+                                       clear_lines(1, 220, 20, 0);
+
+                                       cur_message++;
+                                       if (cur_message >= NUM_MESSAGES)
+                                               cur_message -= NUM_MESSAGES;
+                                       put_text(0, 200, 220, message[cur_message], 2);
+                                       put_text(1, 200, 220, message[cur_message], 2);
+                                       fade_dir = 1;
+                                       fade_count = 0;
+                                       fade_tick = 0;
+                                       draw_end();
                                }
-                               fade_count++;
-                       } else {
-                               fade_dir = 0;
-                               fade_count = 0;
-                               fade_tick = 0;
+                               break;
+                       case 1:
+                               if (fade_count < 100) {
+                                       for (c1 = 0; c1 < 48; c1++) {
+                                               if (fade_pal[c1] < menu_pal[c1 + 720])
+                                                       fade_pal[c1]++;
+                                       }
+                                       fade_count++;
+                               } else {
+                                       fade_dir = 0;
+                                       fade_count = 0;
+                                       fade_tick = 0;
+                               }
+                               break;
                        }
-                       break;
-               }
 
-               for (c1 = 0; c1 < 48; c1++) {
-                       if (fade_pal[c1] > menu_pal[c1 + 720])
-                               fade_pal[c1]--;
-               }
+                       for (c1 = 0; c1 < 48; c1++) {
+                               if (fade_pal[c1] > menu_pal[c1 + 720])
+                                       fade_pal[c1]--;
+                       }
 
-               main_info.draw_page ^= 1;
-               main_info.view_page ^= 1;
+                       if (update_count == 1) {
+                               main_info.draw_page ^= 1;
+                               main_info.view_page ^= 1;
+       
+                               flippage(main_info.view_page);
+       
+                               wait_vrt(1);
+                       }
 
-               flippage(main_info.view_page);
+                       if (fade_flag != 0) {
+                               setpalette(0, 240, menu_cur_pal);
+                       }
 
-               wait_vrt(1);
+                       if (update_count == 1) {
+                               setpalette(240, 16, fade_pal);
 
-               if (fade_flag != 0) {
-                       setpalette(0, 240, menu_cur_pal);
-               }
+                               dj_mix();
 
-               setpalette(240, 16, fade_pal);
+                               draw_begin();
+                               redraw_pob_backgrounds(main_info.draw_page);
+                               draw_end();
+                       }
 
-               dj_mix();
+                       update_count--;
+               }
 
-               draw_begin();
-               redraw_pob_backgrounds(main_info.draw_page);
-               draw_end();
+               update_count = intr_sysupdate();
 
        }
 
index bb0d7e2..0c6d2ed 100644 (file)
@@ -104,7 +104,8 @@ int intr_sysupdate()
 {
        SDL_Event e;
        int i = 0;
-       static Uint32 now, then = 0;
+       static int last_time = 0;
+       int now, time_diff;
 
        while (SDL_PollEvent(&e)) {
                switch (e.type) {
@@ -144,8 +145,22 @@ int intr_sysupdate()
                }
                i++;
        }
-       //SDL_Delay(4);
+       SDL_Delay(0);
        now = SDL_GetTicks();
+       time_diff = now - last_time;
+       if (time_diff>0) {
+               i = time_diff / (1000 / 60);
+               if (i) {
+                       last_time = now;
+               } else {
+                       int tmp;
+
+                       tmp = (1000/60) - i - 10;
+                       if (tmp>0)
+                               SDL_Delay(tmp);
+               }
+       }
+/*
        if (!then)
                SDL_Delay(1);
        else {
@@ -154,6 +169,7 @@ int intr_sysupdate()
                        SDL_Delay(then);
        }
        then = now;
+*/
 
        return i;
 }