2 /* third part of synchro.
4 * handle global elements.
6 * this should be spread over the frames for reduced cpu load.
15 register unsigned int x;
16 register unsigned int y;
17 register unsigned int count;
18 register unsigned long random;
20 /* update variables */
21 if(lev.score > 9999) lev.score = 9999;
23 if(lev.time) lev.time--;
24 if(lev.android_move_cnt-- == 0) lev.android_move_cnt = lev.android_move_time;
25 if(lev.android_clone_cnt-- == 0) lev.android_clone_cnt = lev.android_clone_time;
26 if(lev.ball_state) if(lev.ball_cnt-- == 0) lev.ball_cnt = lev.ball_time;
27 if(lev.lenses_cnt) lev.lenses_cnt--;
28 if(lev.magnify_cnt) lev.magnify_cnt--;
29 if(lev.wheel_cnt) lev.wheel_cnt--;
30 if(lev.wind_cnt) lev.wind_cnt--;
31 if(lev.wonderwall_time && lev.wonderwall_state) lev.wonderwall_time--;
33 if(lev.time > 0 && lev.time <= 50 && lev.time % 5 == 0) play[SAMPLE_time] = 1;
34 if(lev.wheel_cnt) play[SAMPLE_wheel] = 1;
38 for(count = lev.ameuba_time; count--;) {
39 x = (random >> 10) % (WIDTH - 2);
40 y = (random >> 20) % (HEIGHT - 2);
50 if(tab_ameuba[Cave[y-1][x]] || tab_ameuba[Cave[y][x+1]] || tab_ameuba[Cave[y+1][x]] || tab_ameuba[Cave[y][x-1]]) Cave[y][x] = Xdrip_eat;
52 random = random * 129 + 1;
56 /* handle explosions */
57 for(y = 1; y < HEIGHT - 1; y++) for(x = 1; x < WIDTH - 1; x++) {
61 Cave[y-1][x] = tab_explode_normal[Cave[y-1][x]];
62 Cave[y][x-1] = tab_explode_normal[Cave[y][x-1]];
63 Cave[y][x+1] = tab_explode_normal[Cave[y][x+1]];
64 Cave[y+1][x] = tab_explode_normal[Cave[y+1][x]];
65 Cave[y-1][x-1] = tab_explode_normal[Cave[y-1][x-1]];
66 Cave[y-1][x+1] = tab_explode_normal[Cave[y-1][x+1]];
67 Cave[y+1][x-1] = tab_explode_normal[Cave[y+1][x-1]];
68 Cave[y+1][x+1] = tab_explode_normal[Cave[y+1][x+1]];
72 Cave[y-1][x] = tab_explode_dynamite[Cave[y-1][x]];
73 Cave[y][x-1] = tab_explode_dynamite[Cave[y][x-1]];
74 Cave[y][x+1] = tab_explode_dynamite[Cave[y][x+1]];
75 Cave[y+1][x] = tab_explode_dynamite[Cave[y+1][x]];
76 Cave[y-1][x-1] = tab_explode_dynamite[Cave[y-1][x-1]];
77 Cave[y-1][x+1] = tab_explode_dynamite[Cave[y-1][x+1]];
78 Cave[y+1][x-1] = tab_explode_dynamite[Cave[y+1][x-1]];
79 Cave[y+1][x+1] = tab_explode_dynamite[Cave[y+1][x+1]];
84 /* triple buffering */
85 for(y = 0; y < HEIGHT; y++) for(x = 0; x < WIDTH; x++) {
86 Next[y][x] = Cave[y][x];