3 * Copyright (C) 1998 Brainchild Design - http://brainchilddesign.com/
5 * Copyright (C) 2001 Chuck Mason <cemason@users.sourceforge.net>
7 * Copyright (C) 2002 Florian Schulze <crow@icculus.org>
9 * Portions of this code are from the MPEG software simulation group
10 * idct implementation. This code will be replaced with a new
11 * implementation soon.
13 * This file is part of Jump'n'Bump.
15 * Jump'n'Bump is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
20 * Jump'n'Bump is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 extern unsigned int ban_map[17][22];
41 int used, direction, colour;
45 int anim, frame, frame_tick, image;
54 register_background(NULL, NULL);
56 if ((handle = dat_open("level.pcx", datfile_name, "rb")) == 0) {
57 strcpy(main_info.error_str, "Error loading 'level.pcx', aborting...\n");
60 read_pcx(handle, mask_pic, 102400, pal);
63 memset(mask_pic, 0, 102400);
64 register_mask(mask_pic);
66 recalculate_gob(&rabbit_gobs, pal);
67 recalculate_gob(&object_gobs, pal);
69 memset(ban_map, 0, sizeof(ban_map));
75 for (c2 = 193; c2 < 256; c2++) {
76 clear_lines(0, c2, 1, get_color((c2 - 192) >> 2, pal));
77 clear_lines(1, c2, 1, get_color((c2 - 192) >> 2, pal));
82 setpalette(0, 256, pal);
84 for (c1 = 0; c1 < 20; c1++)
88 rabbits[0].colour = rnd(4);
89 rabbits[0].x = (int) (150 + rnd(100)) << 16;
90 rabbits[0].y = 256 << 16;
91 rabbits[0].x_add = ((int) rnd(65535) << 1) - 65536;
92 if (rabbits[0].x_add > 0)
93 rabbits[0].direction = 0;
95 rabbits[0].direction = 1;
96 rabbits[0].y_add = -262144 + (rnd(16384) * 5);
97 rabbits[0].timer = 30 + rnd(150);
100 rabbits[0].frame_tick = 0;
101 rabbits[0].image = player_anims[rabbits[0].anim].frame[rabbits[0].frame].image + rabbits[0].colour * 18 + rabbits[0].direction * 9;
104 for (c1 = 0; c1 < 300; c1++) {
108 stars[c1].x = stars[c1].old_x = (s1 << 16);
109 stars[c1].y = stars[c1].old_y = (s2 << 16);
111 stars[c1].back[0] = stars[c1].back[1] = get_pixel(0, s1, s2);
117 main_info.page_info[0].num_pobs = 0;
118 main_info.page_info[1].num_pobs = 0;
119 main_info.view_page = 0;
120 main_info.draw_page = 1;
122 while (key_pressed(1) == 0) {
127 for (c1 = 0; c1 < 300; c1++) {
128 stars[c1].old_x = stars[c1].x;
129 stars[c1].old_y = stars[c1].y;
130 stars[c1].y -= (int) (31 - stars[c1].col) * 16384;
131 if ((stars[c1].y >> 16) < 0)
132 stars[c1].y += JNB_HEIGHT << 16;
133 if ((stars[c1].y >> 16) >= JNB_HEIGHT)
134 stars[c1].y -= JNB_HEIGHT << 16;
137 for (c1 = 0, c2 = 0; c1 < 20; c1++) {
138 if (rabbits[c1].used == 1)
141 if ((c2 == 0 && rnd(10000) < 200) || (c2 == 1 && rnd(10000) < 150) || (c2 == 2 && rnd(10000) < 100) || (c2 == 3 && rnd(10000) < 50)) {
142 for (c1 = 0; c1 < 20; c1++) {
143 if (rabbits[c1].used == 0) {
144 rabbits[c1].used = 1;
145 rabbits[c1].colour = rnd(4);
146 rabbits[c1].x = (int) (150 + rnd(100)) << 16;
147 rabbits[c1].y = 256 << 16;
148 rabbits[c1].x_add = ((int) rnd(65535) << 1) - 65536;
149 if (rabbits[c1].x_add > 0)
150 rabbits[c1].direction = 0;
152 rabbits[c1].direction = 1;
153 rabbits[c1].y_add = -262144 + (rnd(16384) * 5);
154 rabbits[c1].timer = 30 + rnd(150);
155 rabbits[c1].anim = 2;
156 rabbits[c1].frame = 0;
157 rabbits[c1].frame_tick = 0;
158 rabbits[c1].image = player_anims[rabbits[c1].anim].frame[rabbits[c1].frame].image + rabbits[c1].colour * 18 + rabbits[c1].direction * 9;
166 main_info.page_info[main_info.draw_page].num_pobs = 0;
168 for (c1 = 0; c1 < 20; c1++) {
169 if (rabbits[c1].used == 1) {
170 rabbits[c1].y_add += 2048;
171 if (rabbits[c1].y_add > 36864 && rabbits[c1].anim != 3) {
172 rabbits[c1].anim = 3;
173 rabbits[c1].frame = 0;
174 rabbits[c1].frame_tick = 0;
175 rabbits[c1].image = player_anims[rabbits[c1].anim].frame[rabbits[c1].frame].image + rabbits[c1].colour * 18 + rabbits[c1].direction * 9;
177 rabbits[c1].x += rabbits[c1].x_add;
178 rabbits[c1].y += rabbits[c1].y_add;
179 if ((rabbits[c1].x >> 16) < 16 || (rabbits[c1].x >> 16) > 400 || (rabbits[c1].y >> 16) > 256) {
180 rabbits[c1].used = 0;
184 if (rabbits[c1].timer <= 0) {
185 rabbits[c1].used = 0;
186 for (c2 = 0; c2 < 6; c2++)
187 add_object(OBJ_FUR, (rabbits[c1].x >> 16) + 6 + rnd(5), (rabbits[c1].y >> 16) + 6 + rnd(5), rabbits[c1].x_add + (rnd(65535) - 32768) * 3, rabbits[c1].y_add + (rnd(65535) - 32768) * 3, 0, 44 + rabbits[c1].colour * 8);
188 for (c2 = 0; c2 < 6; c2++)
189 add_object(OBJ_FLESH, (rabbits[c1].x >> 16) + 6 + rnd(5), (rabbits[c1].y >> 16) + 6 + rnd(5), rabbits[c1].x_add + (rnd(65535) - 32768) * 3, rabbits[c1].y_add + (rnd(65535) - 32768) * 3, 0, 76);
190 for (c2 = 0; c2 < 6; c2++)
191 add_object(OBJ_FLESH, (rabbits[c1].x >> 16) + 6 + rnd(5), (rabbits[c1].y >> 16) + 6 + rnd(5), rabbits[c1].x_add + (rnd(65535) - 32768) * 3, rabbits[c1].y_add + (rnd(65535) - 32768) * 3, 0, 77);
192 for (c2 = 0; c2 < 8; c2++)
193 add_object(OBJ_FLESH, (rabbits[c1].x >> 16) + 6 + rnd(5), (rabbits[c1].y >> 16) + 6 + rnd(5), rabbits[c1].x_add + (rnd(65535) - 32768) * 3, rabbits[c1].y_add + (rnd(65535) - 32768) * 3, 0, 78);
194 for (c2 = 0; c2 < 10; c2++)
195 add_object(OBJ_FLESH, (rabbits[c1].x >> 16) + 6 + rnd(5), (rabbits[c1].y >> 16) + 6 + rnd(5), rabbits[c1].x_add + (rnd(65535) - 32768) * 3, rabbits[c1].y_add + (rnd(65535) - 32768) * 3, 0, 79);
196 dj_play_sfx(SFX_DEATH, SFX_DEATH_FREQ, 64, 0, 0, -1);
199 rabbits[c1].frame_tick++;
200 if (rabbits[c1].frame_tick >= player_anims[rabbits[c1].anim].frame[rabbits[c1].frame].ticks) {
202 if (rabbits[c1].frame >= player_anims[rabbits[c1].anim].num_frames)
203 rabbits[c1].frame = player_anims[rabbits[c1].anim].restart_frame;
204 rabbits[c1].frame_tick = 0;
206 rabbits[c1].image = player_anims[rabbits[c1].anim].frame[rabbits[c1].frame].image + rabbits[c1].colour * 18 + rabbits[c1].direction * 9;
207 if (rabbits[c1].used == 1)
208 add_pob(main_info.draw_page, rabbits[c1].x >> 16, rabbits[c1].y >> 16, rabbits[c1].image, &rabbit_gobs);
218 for (c1 = 0; c1 < 300; c1++) {
219 stars[c1].back[main_info.draw_page] = get_pixel(main_info.draw_page, stars[c1].x >> 16, stars[c1].y >> 16);
220 set_pixel(main_info.draw_page, stars[c1].x >> 16, stars[c1].y >> 16, get_color(stars[c1].col, pal));
225 draw_pobs(main_info.draw_page);
229 main_info.draw_page ^= 1;
230 main_info.view_page ^= 1;
232 flippage(main_info.view_page);
238 redraw_pob_backgrounds(main_info.draw_page);
243 for (c1 = 299; c1 >= 0; c1--) {
244 set_pixel(main_info.draw_page, stars[c1].old_x >> 16, stars[c1].old_y >> 16, stars[c1].back[main_info.draw_page]);