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, JNB_WIDTH*JNB_HEIGHT, pal);
62 memset(mask_pic, 0, JNB_WIDTH*JNB_HEIGHT);
63 register_mask(mask_pic);
65 recalculate_gob(&rabbit_gobs, pal);
66 recalculate_gob(&object_gobs, pal);
68 memset(ban_map, 0, sizeof(ban_map));
74 for (c2 = JNB_HEIGHT - 63; c2 < JNB_HEIGHT; c2++) {
75 clear_lines(0, c2, 1, get_color((c2 - 192) >> 2, pal));
76 clear_lines(1, c2, 1, get_color((c2 - 192) >> 2, pal));
81 setpalette(0, 256, pal);
83 for (c1 = 0; c1 < 20; c1++)
87 rabbits[0].colour = rnd(4);
88 rabbits[0].x = (int) (150 + rnd(100)) << 16;
89 rabbits[0].y = 256 << 16;
90 rabbits[0].x_add = ((int) rnd(65535) << 1) - 65536;
91 if (rabbits[0].x_add > 0)
92 rabbits[0].direction = 0;
94 rabbits[0].direction = 1;
95 rabbits[0].y_add = -262144 + (rnd(16384) * 5);
96 rabbits[0].timer = 30 + rnd(150);
99 rabbits[0].frame_tick = 0;
100 rabbits[0].image = player_anims[rabbits[0].anim].frame[rabbits[0].frame].image + rabbits[0].colour * 18 + rabbits[0].direction * 9;
103 for (c1 = 0; c1 < 300; c1++) {
105 s2 = rnd(JNB_HEIGHT);
107 stars[c1].x = stars[c1].old_x = (s1 << 16);
108 stars[c1].y = stars[c1].old_y = (s2 << 16);
110 stars[c1].back[0] = stars[c1].back[1] = get_pixel(0, s1, s2);
116 main_info.page_info[0].num_pobs = 0;
117 main_info.page_info[1].num_pobs = 0;
118 main_info.view_page = 0;
119 main_info.draw_page = 1;
121 while (key_pressed(1) == 0) {
126 for (c1 = 0; c1 < 300; c1++) {
127 stars[c1].old_x = stars[c1].x;
128 stars[c1].old_y = stars[c1].y;
129 stars[c1].y -= (int) (31 - stars[c1].col) * 16384;
130 if ((stars[c1].y >> 16) < 0)
131 stars[c1].y += JNB_HEIGHT << 16;
132 if ((stars[c1].y >> 16) >= JNB_HEIGHT)
133 stars[c1].y -= JNB_HEIGHT << 16;
136 for (c1 = 0, c2 = 0; c1 < 20; c1++) {
137 if (rabbits[c1].used == 1)
140 if ((c2 == 0 && rnd(10000) < 200) || (c2 == 1 && rnd(10000) < 150) || (c2 == 2 && rnd(10000) < 100) || (c2 == 3 && rnd(10000) < 50)) {
141 for (c1 = 0; c1 < 20; c1++) {
142 if (rabbits[c1].used == 0) {
143 rabbits[c1].used = 1;
144 rabbits[c1].colour = rnd(4);
145 rabbits[c1].x = (int) (150 + rnd(100)) << 16;
146 rabbits[c1].y = 256 << 16;
147 rabbits[c1].x_add = ((int) rnd(65535) << 1) - 65536;
148 if (rabbits[c1].x_add > 0)
149 rabbits[c1].direction = 0;
151 rabbits[c1].direction = 1;
152 rabbits[c1].y_add = -262144 + (rnd(16384) * 5);
153 rabbits[c1].timer = 30 + rnd(150);
154 rabbits[c1].anim = 2;
155 rabbits[c1].frame = 0;
156 rabbits[c1].frame_tick = 0;
157 rabbits[c1].image = player_anims[rabbits[c1].anim].frame[rabbits[c1].frame].image + rabbits[c1].colour * 18 + rabbits[c1].direction * 9;
165 main_info.page_info[main_info.draw_page].num_pobs = 0;
167 for (c1 = 0; c1 < 20; c1++) {
168 if (rabbits[c1].used == 1) {
169 rabbits[c1].y_add += 2048;
170 if (rabbits[c1].y_add > 36864 && rabbits[c1].anim != 3) {
171 rabbits[c1].anim = 3;
172 rabbits[c1].frame = 0;
173 rabbits[c1].frame_tick = 0;
174 rabbits[c1].image = player_anims[rabbits[c1].anim].frame[rabbits[c1].frame].image + rabbits[c1].colour * 18 + rabbits[c1].direction * 9;
176 rabbits[c1].x += rabbits[c1].x_add;
177 rabbits[c1].y += rabbits[c1].y_add;
178 if ((rabbits[c1].x >> 16) < 16 || (rabbits[c1].x >> 16) > JNB_WIDTH || (rabbits[c1].y >> 16) > JNB_HEIGHT) {
179 rabbits[c1].used = 0;
183 if (rabbits[c1].timer <= 0) {
184 rabbits[c1].used = 0;
185 for (c2 = 0; c2 < 6; c2++)
186 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);
187 for (c2 = 0; c2 < 6; c2++)
188 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);
189 for (c2 = 0; c2 < 6; c2++)
190 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);
191 for (c2 = 0; c2 < 8; c2++)
192 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);
193 for (c2 = 0; c2 < 10; c2++)
194 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);
195 dj_play_sfx(SFX_DEATH, SFX_DEATH_FREQ, 64, 0, 0, -1);
198 rabbits[c1].frame_tick++;
199 if (rabbits[c1].frame_tick >= player_anims[rabbits[c1].anim].frame[rabbits[c1].frame].ticks) {
201 if (rabbits[c1].frame >= player_anims[rabbits[c1].anim].num_frames)
202 rabbits[c1].frame = player_anims[rabbits[c1].anim].restart_frame;
203 rabbits[c1].frame_tick = 0;
205 rabbits[c1].image = player_anims[rabbits[c1].anim].frame[rabbits[c1].frame].image + rabbits[c1].colour * 18 + rabbits[c1].direction * 9;
206 if (rabbits[c1].used == 1)
207 add_pob(main_info.draw_page, rabbits[c1].x >> 16, rabbits[c1].y >> 16, rabbits[c1].image, &rabbit_gobs);
217 for (c1 = 0; c1 < 300; c1++) {
218 stars[c1].back[main_info.draw_page] = get_pixel(main_info.draw_page, stars[c1].x >> 16, stars[c1].y >> 16);
219 set_pixel(main_info.draw_page, stars[c1].x >> 16, stars[c1].y >> 16, get_color(stars[c1].col, pal));
224 draw_pobs(main_info.draw_page);
228 main_info.draw_page ^= 1;
229 main_info.view_page ^= 1;
231 flippage(main_info.view_page);
237 redraw_pob_backgrounds(main_info.draw_page);
242 for (c1 = 299; c1 >= 0; c1--) {
243 set_pixel(main_info.draw_page, stars[c1].old_x >> 16, stars[c1].old_y >> 16, stars[c1].back[main_info.draw_page]);