9 #define M_PI 3.14159265358979323846
18 unsigned int ban_map[17][22] = {
19 {1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
20 {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0},
21 {1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0},
22 {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1},
23 {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1},
24 {1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
25 {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1},
26 {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1},
27 {1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1},
28 {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 0, 0, 0, 1},
29 {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1},
30 {1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1},
31 {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
32 {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1},
33 {2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 0, 0, 0, 0, 0, 1, 3, 3, 3, 1, 1, 1},
34 {2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
35 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
164 char back[2], back_defined[2];
174 } pobs[NUM_LEFTOVERS];
178 char pogostick, bunnies_in_space, jetpack, lord_of_the_flies, blood_is_thicker_than_water;
181 int main(int argc, char *argv[])
184 int c1, c2 = 0, c3, c4;
187 int closest_player = 0, dist, cur_dist;
188 char end_loop_flag, fade_flag;
189 char mod_vol, sfx_vol, mod_fade_direction;
190 char *ptr1 = (char *) NULL;
193 if (init_program(argc, argv) != 0)
196 if (main_info.fireworks == 1) {
206 if (key_pressed(1) == 1) {
209 if (init_level(0) != 0) {
214 setpalette(0, 256, cur_pal);
217 put_block(1, 0, 0, 400, 256, background_pic);
218 put_block(0, 0, 0, 400, 256, background_pic);
223 for (c1 = 0; c1 < NUM_FLIES; c1++) {
225 flies[c1].x = s1 + rnd(101) - 50;
226 flies[c1].y = s2 + rnd(101) - 50;
227 if (ban_map[flies[c1].y >> 4][flies[c1].x >> 4] == 0)
230 flies[c1].back_defined[0] = 0;
231 flies[c1].back_defined[1] = 0;
234 mod_vol = sfx_vol = 10;
235 mod_fade_direction = 1;
236 dj_ready_mod(MOD_GAME);
237 dj_set_mod_volume(mod_vol);
238 dj_set_sfx_volume(mod_vol);
240 dj_play_sfx(SFX_FLY, SFX_FLY_FREQ, 0, 0, 0, 4);
243 lord_of_the_flies = bunnies_in_space = jetpack = pogostick = blood_is_thicker_than_water = 0;
245 main_info.page_info[0].num_pobs = 0;
246 main_info.page_info[1].num_pobs = 0;
247 main_info.view_page = 0;
248 main_info.draw_page = 1;
252 if (key_pressed(1) == 1) {
255 mod_fade_direction = 0;
258 if (strncmp(last_keys, "kcitsogop", strlen("kcitsogop")) == 0) {
262 if (strncmp(last_keys, "ecapsniseinnub", strlen("ecapsniseinnub")) == 0) {
263 bunnies_in_space ^= 1;
266 if (strncmp(last_keys, "kcaptej", strlen("kcaptej")) == 0) {
270 if (strncmp(last_keys, "seilfehtfodrol", strlen("seilfehtfodrol")) == 0) {
271 lord_of_the_flies ^= 1;
274 if (strncmp(last_keys, "retawnahtrekcihtsidoolb", strlen("retawnahtrekcihtsidoolb")) == 0) {
275 blood_is_thicker_than_water ^= 1;
276 if (blood_is_thicker_than_water == 1) {
334 for (c3 = 0; c3 < 6; c3++) {
338 } else if (c3 == 1) {
341 } else if (c3 == 2) {
344 } else if (c3 == 3) {
347 } else if (c3 == 4) {
350 } else if (c3 == 5) {
354 if (player[c1].enabled == 1 && player[c2].enabled == 1) {
355 if (labs(player[c1].x - player[c2].x) < (12L << 16) && labs(player[c1].y - player[c2].y) < (12L << 16)) {
356 if ((labs(player[c1].y - player[c2].y) >> 16) > 5) {
357 if (player[c1].y < player[c2].y) {
358 if (player[c1].y_add >= 0) {
359 player[c1].y_add = -player[c1].y_add;
360 if (player[c1].y_add > -262144L)
361 player[c1].y_add = -262144L;
362 player[c1].jump_abort = 1;
363 player[c2].dead_flag = 1;
364 if (player[c2].anim != 6) {
366 player[c2].frame = 0;
367 player[c2].frame_tick = 0;
368 player[c2].image = player_anims[player[c2].anim].frame[player[c2].frame].image + player[c2].direction * 9;
369 if (main_info.no_gore == 0) {
370 for (c4 = 0; c4 < 6; c4++)
371 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);
372 for (c4 = 0; c4 < 6; c4++)
373 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);
374 for (c4 = 0; c4 < 6; c4++)
375 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);
376 for (c4 = 0; c4 < 8; c4++)
377 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);
378 for (c4 = 0; c4 < 10; c4++)
379 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);
381 dj_play_sfx(SFX_DEATH, SFX_DEATH_FREQ + rnd(2000) - 1000, 64, 0, 0, -1);
383 player[c1].bumped[c2]++;
384 s1 = player[c1].bumps % 100;
385 add_leftovers(0, 360, 34 + c1 * 64, s1 / 10, number_gobs);
386 add_leftovers(1, 360, 34 + c1 * 64, s1 / 10, number_gobs);
387 add_leftovers(0, 376, 34 + c1 * 64, s1 - (s1 / 10) * 10, number_gobs);
388 add_leftovers(1, 376, 34 + c1 * 64, s1 - (s1 / 10) * 10, number_gobs);
391 if (player[c2].y_add < 0)
392 player[c2].y_add = 0;
395 if (player[c2].y_add >= 0) {
396 player[c2].y_add = -player[c2].y_add;
397 if (player[c2].y_add > -262144L)
398 player[c2].y_add = -262144L;
399 player[c2].jump_abort = 1;
400 player[c1].dead_flag = 1;
401 if (player[c1].anim != 6) {
403 player[c1].frame = 0;
404 player[c1].frame_tick = 0;
405 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
406 if (main_info.no_gore == 0) {
407 for (c4 = 0; c4 < 6; c4++)
408 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);
409 for (c4 = 0; c4 < 6; c4++)
410 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);
411 for (c4 = 0; c4 < 7; c4++)
412 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);
413 for (c4 = 0; c4 < 8; c4++)
414 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);
415 for (c4 = 0; c4 < 10; c4++)
416 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);
418 dj_play_sfx(SFX_DEATH, SFX_DEATH_FREQ + rnd(2000) - 1000, 64, 0, 0, -1);
420 player[c2].bumped[c1]++;
421 s1 = player[c2].bumps % 100;
422 add_leftovers(0, 360, 34 + c2 * 64, s1 / 10, number_gobs);
423 add_leftovers(1, 360, 34 + c2 * 64, s1 / 10, number_gobs);
424 add_leftovers(0, 376, 34 + c2 * 64, s1 - (s1 / 10) * 10, number_gobs);
425 add_leftovers(1, 376, 34 + c2 * 64, s1 - (s1 / 10) * 10, number_gobs);
428 if (player[c1].y_add < 0)
429 player[c1].y_add = 0;
433 if (player[c1].x < player[c2].x) {
434 if (player[c1].x_add > 0)
435 player[c1].x = player[c2].x - (12L << 16);
436 else if (player[c2].x_add < 0)
437 player[c2].x = player[c1].x + (12L << 16);
439 player[c1].x -= player[c1].x_add;
440 player[c2].x -= player[c2].x_add;
442 l1 = player[c2].x_add;
443 player[c2].x_add = player[c1].x_add;
444 player[c1].x_add = l1;
445 if (player[c1].x_add > 0)
446 player[c1].x_add = -player[c1].x_add;
447 if (player[c2].x_add < 0)
448 player[c2].x_add = -player[c2].x_add;
450 if (player[c1].x_add > 0)
451 player[c2].x = player[c1].x - (12L << 16);
452 else if (player[c2].x_add < 0)
453 player[c1].x = player[c2].x + (12L << 16);
455 player[c1].x -= player[c1].x_add;
456 player[c2].x -= player[c2].x_add;
458 l1 = player[c2].x_add;
459 player[c2].x_add = player[c1].x_add;
460 player[c1].x_add = l1;
461 if (player[c1].x_add < 0)
462 player[c1].x_add = -player[c1].x_add;
463 if (player[c2].x_add > 0)
464 player[c2].x_add = -player[c2].x_add;
473 main_info.page_info[main_info.draw_page].num_pobs = 0;
474 for (c1 = 0; c1 < 4; c1++) {
475 if (player[c1].enabled == 1)
476 main_info.page_info[main_info.draw_page].num_pobs++;
484 for (c1 = 0; c1 < NUM_FLIES; c1++) {
492 for (c1 = 0; c1 < 4; c1++) {
493 if (player[c1].enabled == 1) {
494 cur_dist = 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)));
495 if (cur_dist < dist) {
504 dj_set_sfx_channel_volume(4, s3);
506 for (c1 = 0; c1 < NUM_FLIES; c1++) {
508 for (c2 = 0; c2 < 4; c2++) {
509 if (player[c2].enabled == 1) {
510 cur_dist = 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)));
511 if (cur_dist < dist) {
517 flies[c1].old_x = flies[c1].x;
518 flies[c1].old_y = flies[c1].y;
520 if ((s1 - flies[c1].x) > 30)
522 else if ((s1 - flies[c1].x) < -30)
525 if (((player[closest_player].x >> 16) + 8) > flies[c1].x) {
526 if (lord_of_the_flies == 0)
531 if (lord_of_the_flies == 0)
537 s4 = rnd(3) - 1 + s3;
538 if ((flies[c1].x + s4) < 16)
540 if ((flies[c1].x + s4) > 351)
542 if (ban_map[flies[c1].y >> 4][(flies[c1].x + s4) >> 4] != 0)
546 if ((s2 - flies[c1].y) > 30)
548 else if ((s2 - flies[c1].y) < -30)
551 if (((player[closest_player].y >> 16) + 8) > flies[c1].y) {
552 if (lord_of_the_flies == 0)
557 if (lord_of_the_flies == 0)
563 s4 = rnd(3) - 1 + s3;
564 if ((flies[c1].y + s4) < 0)
566 if ((flies[c1].y + s4) > 239)
568 if (ban_map[(flies[c1].y + s4) >> 4][flies[c1].x >> 4] != 0)
576 for (c1 = 0; c1 < 4; c1++) {
577 if (player[c1].enabled == 1) {
578 main_info.page_info[main_info.draw_page].pobs[s1].x = player[c1].x >> 16;
579 main_info.page_info[main_info.draw_page].pobs[s1].y = player[c1].y >> 16;
580 main_info.page_info[main_info.draw_page].pobs[s1].image = player[c1].image + c1 * 18;
581 main_info.page_info[main_info.draw_page].pobs[s1].pob_data = rabbit_gobs;
586 draw_pobs(main_info.draw_page);
591 ptr1 = (char *) (0xa0000 + ((long) main_info.draw_page << 15) - __djgpp_base_address);
592 for (c1 = 0; c1 < 4; c1++) {
593 outportw(0x3ce, (c1 << 8) + 0x04);
594 outportw(0x3c4, ((1 << c1) << 8) + 0x02);
595 for (c2 = 0; c2 < NUM_FLIES; c2++) {
596 if ((flies[c2].x & 3) == c1) {
597 flies[c2].back[main_info.draw_page] = *(char *) (ptr1 + flies[c2].y * 100 + (flies[c2].x >> 2));
598 flies[c2].back_defined[main_info.draw_page] = 1;
599 if (mask_pic[flies[c2].y * 400 + flies[c2].x] == 0)
600 *(char *) (ptr1 + flies[c2].y * 100 + (flies[c2].x >> 2)) = 0;
605 ptr1 = (char *) get_vgaptr(main_info.draw_page, 0, 0);
606 for (c2 = 0; c2 < NUM_FLIES; c2++) {
607 flies[c2].back[main_info.draw_page] = *(char *) (ptr1 + flies[c2].y * JNB_WIDTH + (flies[c2].x));
608 flies[c2].back_defined[main_info.draw_page] = 1;
609 if (mask_pic[(flies[c2].y * 400) + flies[c2].x] == 0)
610 *(char *) (ptr1 + flies[c2].y * JNB_WIDTH + (flies[c2].x)) = 0;
614 if (mod_fade_direction == 1) {
617 dj_set_mod_volume(mod_vol);
622 dj_set_mod_volume(mod_vol);
626 if (mod_fade_direction == 1) {
629 dj_set_sfx_volume(sfx_vol);
634 dj_set_sfx_volume(sfx_vol);
639 for (c1 = 0; c1 < 768; c1++) {
640 if (cur_pal[c1] < pal[c1]) {
643 } else if (cur_pal[c1] > pal[c1]) {
648 if (fade_flag == 0 && end_loop_flag == 1)
651 main_info.draw_page ^= 1;
652 main_info.view_page ^= 1;
654 flippage(main_info.view_page);
657 while ((inportb(0x3da) & 8) == 0)
659 while ((inportb(0x3da) & 8) == 8)
664 setpalette(0, 256, cur_pal);
667 ptr1 = (char *) (0xa0000 + ((long) main_info.draw_page << 15) - __djgpp_base_address);
668 for (c1 = 0; c1 < 4; c1++) {
669 outportw(0x3c4, ((1 << c1) << 8) + 0x02);
670 for (c2 = NUM_FLIES - 1; c2 >= 0; c2--) {
671 if ((flies[c2].old_x & 3) == c1 && flies[c2].back_defined[main_info.draw_page] == 1)
672 *(char *) (ptr1 + flies[c2].old_y * 100 + (flies[c2].old_x >> 2)) = flies[c2].back[main_info.draw_page];
676 ptr1 = (char *) get_vgaptr(main_info.draw_page, 0, 0);
677 for (c2 = NUM_FLIES - 1; c2 >= 0; c2--) {
678 if (flies[c2].back_defined[main_info.draw_page] == 1)
679 *(char *) (ptr1 + flies[c2].old_y * JNB_WIDTH + (flies[c2].old_x)) = flies[c2].back[main_info.draw_page];
683 redraw_pob_backgrounds(main_info.draw_page);
685 draw_leftovers(main_info.draw_page);
692 main_info.view_page = 0;
693 main_info.draw_page = 1;
696 dj_stop_sfx_channel(4);
700 memset(mask_pic, 0, 102400L);
703 outportw(0x3c4, 0x0f02);
704 memset((char *) (0xa0000 + (long) (main_info.view_page << 15) + __djgpp_conventional_base), 0, 32768);
706 memset((void *) get_vgaptr(main_info.view_page, 0, 0), 0, JNB_WIDTH * JNB_HEIGHT);
708 put_text(main_info.view_page, 100, 50, "DOTT", 2);
709 put_text(main_info.view_page, 160, 50, "JIFFY", 2);
710 put_text(main_info.view_page, 220, 50, "FIZZ", 2);
711 put_text(main_info.view_page, 280, 50, "MIJJI", 2);
712 put_text(main_info.view_page, 40, 80, "DOTT", 2);
713 put_text(main_info.view_page, 40, 110, "JIFFY", 2);
714 put_text(main_info.view_page, 40, 140, "FIZZ", 2);
715 put_text(main_info.view_page, 40, 170, "MIJJI", 2);
717 for (c1 = 0; c1 < 4; c1++) {
718 for (c2 = 0; c2 < 4; c2++) {
720 sprintf(str1, "%d", player[c1].bumped[c2]);
721 put_text(main_info.view_page, 100 + c2 * 60, 80 + c1 * 30, str1, 2);
723 put_text(main_info.view_page, 100 + c2 * 60, 80 + c1 * 30, "-", 2);
725 sprintf(str1, "%d", player[c1].bumps);
726 put_text(main_info.view_page, 350, 80 + c1 * 30, str1, 2);
729 put_text(main_info.view_page, 200, 230, "Press ESC to continue", 2);
732 flippage(main_info.view_page);
735 if ((handle = dat_open("menu.pcx", datfile_name, "rb")) == 0) {
736 strcpy(main_info.error_str, "Error loading 'menu.pcx', aborting...\n");
739 if (read_pcx(handle, background_pic, 102400L, pal) != 0) {
740 strcpy(main_info.error_str, "Error loading 'menu.pcx', aborting...\n");
745 memset(cur_pal, 0, 768);
747 setpalette(0, 256, cur_pal);
750 dj_ready_mod(MOD_SCORES);
751 dj_set_mod_volume(mod_vol);
755 while (key_pressed(1) == 0) {
758 dj_set_mod_volume(mod_vol);
759 for (c1 = 0; c1 < 768; c1++) {
760 if (cur_pal[c1] < pal[c1])
766 setpalette(0, 256, cur_pal);
768 while (key_pressed(1) == 1) {
775 while (mod_vol > 0) {
777 dj_set_mod_volume(mod_vol);
778 for (c1 = 0; c1 < 768; c1++) {
779 if (cur_pal[c1] > pal[c1])
784 setpalette(0, 256, cur_pal);
787 fillpalette(0, 0, 0);
800 void steer_players(void)
805 if (main_info.mouse_enabled == 1)
807 if (main_info.joy_enabled == 1)
810 for (c1 = 0; c1 < 4; c1++) {
812 if (player[c1].enabled == 1) {
814 if (player[c1].dead_flag == 0) {
816 if ((c1 == 0 && ((key_pressed(KEY_PL1_LEFT) == 1 && key_pressed(KEY_PL1_RIGHT) == 1))) || (c1 == 1 && ((key_pressed(KEY_PL2_LEFT) == 1 && key_pressed(KEY_PL2_RIGHT) == 1))) || (c1 == 2 && ((key_pressed(KEY_PL3_LEFT) == 1 && key_pressed(KEY_PL3_RIGHT) == 1))) || (c1 == 3 && ((key_pressed(KEY_PL4_LEFT) == 1 && key_pressed(KEY_PL4_RIGHT) == 1)))) {
817 if (player[c1].direction == 0) {
818 if ((c1 == 0 && key_pressed(KEY_PL1_RIGHT) == 1) || (c1 == 1 && key_pressed(KEY_PL2_RIGHT) == 1) || (c1 == 2 && key_pressed(KEY_PL3_RIGHT) == 1) || (c1 == 3 && key_pressed(KEY_PL4_RIGHT) == 1)) {
819 s1 = (player[c1].x >> 16);
820 s2 = (player[c1].y >> 16);
821 if (ban_map[(s2 + 16) >> 4][(s1 + 8) >> 4] == 3) {
822 if (player[c1].x_add < 0)
823 player[c1].x_add += 1024;
825 player[c1].x_add += 768;
826 } else if ((ban_map[(s2 + 16) >> 4][s1 >> 4] != 1 && ban_map[(s2 + 16) >> 4][(s1 + 15) >> 4] == 3) || (ban_map[(s2 + 16) >> 4][s1 >> 4] == 3 && ban_map[(s2 + 16) >> 4][(s1 + 15) >> 4] != 1)) {
827 if (player[c1].x_add > 0)
828 player[c1].x_add += 1024;
830 player[c1].x_add += 768;
832 if (player[c1].x_add < 0) {
833 player[c1].x_add += 16384;
834 if (player[c1].x_add < 98304L && player[c1].in_water == 0 && ban_map[(s2 + 16) >> 4][(s1 + 8) >> 4] == 1)
835 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);
837 player[c1].x_add += 12288;
839 if (player[c1].x_add > 98304L)
840 player[c1].x_add = 98304L;
841 player[c1].direction = 0;
842 if (player[c1].anim == 0) {
844 player[c1].frame = 0;
845 player[c1].frame_tick = 0;
846 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
850 if ((c1 == 0 && key_pressed(KEY_PL1_LEFT) == 1) || (c1 == 1 && key_pressed(KEY_PL2_LEFT) == 1) || (c1 == 2 && key_pressed(KEY_PL3_LEFT) == 1) || (c1 == 3 && key_pressed(KEY_PL4_LEFT) == 1)) {
851 s1 = (player[c1].x >> 16);
852 s2 = (player[c1].y >> 16);
853 if (ban_map[(s2 + 16) >> 4][(s1 + 8) >> 4] == 3) {
854 if (player[c1].x_add > 0)
855 player[c1].x_add -= 1024;
857 player[c1].x_add -= 768;
858 } else if ((ban_map[(s2 + 16) >> 4][s1 >> 4] != 1 && ban_map[(s2 + 16) >> 4][(s1 + 15) >> 4] == 3) || (ban_map[(s2 + 16) >> 4][s1 >> 4] == 3 && ban_map[(s2 + 16) >> 4][(s1 + 15) >> 4] != 1)) {
859 if (player[c1].x_add > 0)
860 player[c1].x_add -= 1024;
862 player[c1].x_add -= 768;
864 if (player[c1].x_add > 0) {
865 player[c1].x_add -= 16384;
866 if (player[c1].x_add > -98304L && player[c1].in_water == 0 && ban_map[(s2 + 16) >> 4][(s1 + 8) >> 4] == 1)
867 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);
869 player[c1].x_add -= 12288;
871 if (player[c1].x_add < -98304L)
872 player[c1].x_add = -98304L;
873 player[c1].direction = 1;
874 if (player[c1].anim == 0) {
876 player[c1].frame = 0;
877 player[c1].frame_tick = 0;
878 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
882 } else if ((c1 == 0 && key_pressed(KEY_PL1_LEFT) == 1) || (c1 == 1 && key_pressed(KEY_PL2_LEFT) == 1) || (c1 == 2 && key_pressed(KEY_PL3_LEFT) == 1) || (c1 == 3 && key_pressed(KEY_PL4_LEFT) == 1)) {
883 s1 = (player[c1].x >> 16);
884 s2 = (player[c1].y >> 16);
885 if (ban_map[(s2 + 16) >> 4][(s1 + 8) >> 4] == 3) {
886 if (player[c1].x_add > 0)
887 player[c1].x_add -= 1024;
889 player[c1].x_add -= 768;
890 } else if ((ban_map[(s2 + 16) >> 4][s1 >> 4] != 1 && ban_map[(s2 + 16) >> 4][(s1 + 15) >> 4] == 3) || (ban_map[(s2 + 16) >> 4][s1 >> 4] == 3 && ban_map[(s2 + 16) >> 4][(s1 + 15) >> 4] != 1)) {
891 if (player[c1].x_add > 0)
892 player[c1].x_add -= 1024;
894 player[c1].x_add -= 768;
896 if (player[c1].x_add > 0) {
897 player[c1].x_add -= 16384;
898 if (player[c1].x_add > -98304L && player[c1].in_water == 0 && ban_map[(s2 + 16) >> 4][(s1 + 8) >> 4] == 1)
899 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);
901 player[c1].x_add -= 12288;
903 if (player[c1].x_add < -98304L)
904 player[c1].x_add = -98304L;
905 player[c1].direction = 1;
906 if (player[c1].anim == 0) {
908 player[c1].frame = 0;
909 player[c1].frame_tick = 0;
910 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
912 } else if ((c1 == 0 && key_pressed(KEY_PL1_RIGHT) == 1) || (c1 == 1 && key_pressed(KEY_PL2_RIGHT) == 1) || (c1 == 2 && key_pressed(KEY_PL3_RIGHT)) || (c1 == 3 && key_pressed(KEY_PL4_RIGHT))) {
913 s1 = (player[c1].x >> 16);
914 s2 = (player[c1].y >> 16);
915 if (ban_map[(s2 + 16) >> 4][(s1 + 8) >> 4] == 3) {
916 if (player[c1].x_add < 0)
917 player[c1].x_add += 1024;
919 player[c1].x_add += 768;
920 } else if ((ban_map[(s2 + 16) >> 4][s1 >> 4] != 1 && ban_map[(s2 + 16) >> 4][(s1 + 15) >> 4] == 3) || (ban_map[(s2 + 16) >> 4][s1 >> 4] == 3 && ban_map[(s2 + 16) >> 4][(s1 + 15) >> 4] != 1)) {
921 if (player[c1].x_add > 0)
922 player[c1].x_add += 1024;
924 player[c1].x_add += 768;
926 if (player[c1].x_add < 0) {
927 player[c1].x_add += 16384;
928 if (player[c1].x_add < 98304L && player[c1].in_water == 0 && ban_map[(s2 + 16) >> 4][(s1 + 8) >> 4] == 1)
929 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);
931 player[c1].x_add += 12288;
933 if (player[c1].x_add > 98304L)
934 player[c1].x_add = 98304L;
935 player[c1].direction = 0;
936 if (player[c1].anim == 0) {
938 player[c1].frame = 0;
939 player[c1].frame_tick = 0;
940 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
942 } else if ((c1 == 0 && ((key_pressed(KEY_PL1_LEFT) == 0 && key_pressed(KEY_PL1_RIGHT) == 0))) || (c1 == 1 && ((key_pressed(KEY_PL2_LEFT) == 0 && key_pressed(KEY_PL2_RIGHT) == 0))) || (c1 == 2 && ((key_pressed(KEY_PL3_LEFT) == 0 && key_pressed(KEY_PL3_RIGHT) == 0))) || (c1 == 3 && ((key_pressed(KEY_PL4_LEFT) == 0 && key_pressed(KEY_PL4_RIGHT) == 0)))) {
943 s1 = (player[c1].x >> 16);
944 s2 = (player[c1].y >> 16);
945 if (ban_map[(s2 + 16) >> 4][(s1 + 8) >> 4] == 1 || ban_map[(s2 + 16) >> 4][(s1 + 8) >> 4] == 4 || (((ban_map[(s2 + 16) >> 4][s1 >> 4] == 1 || ban_map[(s2 + 16) >> 4][s1 >> 4] == 4) && ban_map[(s2 + 16) >> 4][(s1 + 15) >> 4] != 3) || (ban_map[(s2 + 16) >> 4][s1 >> 4] != 3 && (ban_map[(s2 + 16) >> 4][(s1 + 15) >> 4] == 1 || ban_map[(s2 + 16) >> 4][(s1 + 15) >> 4] == 4)))) {
946 if (player[c1].x_add < 0) {
947 player[c1].x_add += 16384;
948 if (player[c1].x_add > 0)
949 player[c1].x_add = 0;
951 player[c1].x_add -= 16384;
952 if (player[c1].x_add < 0)
953 player[c1].x_add = 0;
955 if (player[c1].x_add != 0 && ban_map[(s2 + 16) >> 4][(s1 + 8) >> 4] == 1)
956 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);
958 if (player[c1].anim == 1) {
960 player[c1].frame = 0;
961 player[c1].frame_tick = 0;
962 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
966 if (pogostick == 1 || (player[c1].jump_ready == 1 && ((c1 == 0 && key_pressed(KEY_PL1_JUMP) == 1) || (c1 == 1 && key_pressed(KEY_PL2_JUMP) == 1) || (c1 == 2 && key_pressed(KEY_PL3_JUMP) == 1) || (c1 == 3 && key_pressed(KEY_PL4_JUMP) == 1)))) {
967 s1 = (player[c1].x >> 16);
968 s2 = (player[c1].y >> 16);
971 if (ban_map[(s2 + 16) >> 4][s1 >> 4] == 1 || ban_map[(s2 + 16) >> 4][s1 >> 4] == 3 || ban_map[(s2 + 16) >> 4][(s1 + 15) >> 4] == 1 || ban_map[(s2 + 16) >> 4][(s1 + 15) >> 4] == 3) {
972 player[c1].y_add = -280000L;
974 player[c1].frame = 0;
975 player[c1].frame_tick = 0;
976 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
977 player[c1].jump_ready = 0;
978 player[c1].jump_abort = 1;
980 dj_play_sfx(SFX_JUMP, SFX_JUMP_FREQ + rnd(2000) - 1000, 64, 0, 0, -1);
982 dj_play_sfx(SFX_SPRING, SFX_SPRING_FREQ + rnd(2000) - 1000, 64, 0, 0, -1);
984 if ((ban_map[(s2 + 7) >> 4][s1 >> 4] == 0 || ban_map[(s2 + 7) >> 4][(s1 + 15) >> 4] == 0) && (ban_map[(s2 + 8) >> 4][s1 >> 4] == 2 || ban_map[(s2 + 8) >> 4][(s1 + 15) >> 4] == 2)) {
985 player[c1].y_add = -196608L;
986 player[c1].in_water = 0;
988 player[c1].frame = 0;
989 player[c1].frame_tick = 0;
990 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
991 player[c1].jump_ready = 0;
992 player[c1].jump_abort = 1;
994 dj_play_sfx(SFX_JUMP, SFX_JUMP_FREQ + rnd(2000) - 1000, 64, 0, 0, -1);
996 dj_play_sfx(SFX_SPRING, SFX_SPRING_FREQ + rnd(2000) - 1000, 64, 0, 0, -1);
999 if (pogostick == 0 && ((c1 == 0 && key_pressed(KEY_PL1_JUMP) == 0) || (c1 == 1 && key_pressed(KEY_PL2_JUMP) == 0) || (c1 == 2 && key_pressed(KEY_PL3_JUMP) == 0) || (c1 == 3 && key_pressed(KEY_PL4_JUMP) == 0))) {
1000 player[c1].jump_ready = 1;
1001 if (player[c1].in_water == 0 && player[c1].y_add < 0 && player[c1].jump_abort == 1) {
1002 if (bunnies_in_space == 0)
1003 player[c1].y_add += 32768;
1005 player[c1].y_add += 16384;
1006 if (player[c1].y_add > 0)
1007 player[c1].y_add = 0;
1010 if (c1 == 3 && main_info.num_mouse_buttons == 2 && (mouse.but1 == 0 || mouse.but2 == 0))
1011 player[c1].jump_ready = 1;
1015 if (((c1 == 0 && key_pressed(KEY_PL1_JUMP) == 1) || (c1 == 1 && key_pressed(KEY_PL2_JUMP) == 1) || (c1 == 2 && key_pressed(KEY_PL3_JUMP) == 1) || (c1 == 3 && key_pressed(KEY_PL4_JUMP) == 1))) {
1016 player[c1].y_add -= 16384;
1017 if (player[c1].y_add < -400000L)
1018 player[c1].y_add = -400000L;
1019 if ((ban_map[(s2 + 7) >> 4][s1 >> 4] == 0 || ban_map[(s2 + 7) >> 4][(s1 + 15) >> 4] == 0) && (ban_map[(s2 + 8) >> 4][s1 >> 4] == 2 || ban_map[(s2 + 8) >> 4][(s1 + 15) >> 4] == 2))
1020 player[c1].in_water = 0;
1022 add_object(OBJ_SMOKE, (player[c1].x >> 16) + 6 + rnd(5), (player[c1].y >> 16) + 10 + rnd(5), 0, 16384 + rnd(8192), OBJ_ANIM_SMOKE, 0);
1027 player[c1].x += player[c1].x_add;
1028 if ((player[c1].x >> 16) < 0) {
1030 player[c1].x_add = 0;
1032 if ((player[c1].x >> 16) + 15 > 351) {
1033 player[c1].x = 336L << 16;
1034 player[c1].x_add = 0;
1036 if (player[c1].y > 0) {
1037 s1 = (player[c1].x >> 16);
1038 s2 = (player[c1].y >> 16);
1039 if (ban_map[s2 >> 4][s1 >> 4] == 1 || ban_map[s2 >> 4][s1 >> 4] == 3 || ban_map[s2 >> 4][s1 >> 4] == 4 || ban_map[(s2 + 15) >> 4][s1 >> 4] == 1 || ban_map[(s2 + 15) >> 4][s1 >> 4] == 3 || ban_map[(s2 + 15) >> 4][s1 >> 4] == 4) {
1040 player[c1].x = (((s1 + 16) & 0xfff0)) << 16;
1041 player[c1].x_add = 0;
1043 s1 = (player[c1].x >> 16);
1044 s2 = (player[c1].y >> 16);
1045 if (ban_map[s2 >> 4][(s1 + 15) >> 4] == 1 || ban_map[s2 >> 4][(s1 + 15) >> 4] == 3 || ban_map[s2 >> 4][(s1 + 15) >> 4] == 4 || ban_map[(s2 + 15) >> 4][(s1 + 15) >> 4] == 1 || ban_map[(s2 + 15) >> 4][(s1 + 15) >> 4] == 3 || ban_map[(s2 + 15) >> 4][(s1 + 15) >> 4] == 4) {
1046 player[c1].x = (((s1 + 16) & 0xfff0) - 16) << 16;
1047 player[c1].x_add = 0;
1050 s1 = (player[c1].x >> 16);
1052 if (ban_map[s2 >> 4][s1 >> 4] == 1 || ban_map[s2 >> 4][s1 >> 4] == 3 || ban_map[s2 >> 4][s1 >> 4] == 4 || ban_map[(s2 + 15) >> 4][s1 >> 4] == 1 || ban_map[(s2 + 15) >> 4][s1 >> 4] == 3 || ban_map[(s2 + 15) >> 4][s1 >> 4] == 4) {
1053 player[c1].x = (((s1 + 16) & 0xfff0)) << 16;
1054 player[c1].x_add = 0;
1056 s1 = (player[c1].x >> 16);
1058 if (ban_map[s2 >> 4][(s1 + 15) >> 4] == 1 || ban_map[s2 >> 4][(s1 + 15) >> 4] == 3 || ban_map[s2 >> 4][(s1 + 15) >> 4] == 4 || ban_map[(s2 + 15) >> 4][(s1 + 15) >> 4] == 1 || ban_map[(s2 + 15) >> 4][(s1 + 15) >> 4] == 3 || ban_map[(s2 + 15) >> 4][(s1 + 15) >> 4] == 4) {
1059 player[c1].x = (((s1 + 16) & 0xfff0) - 16) << 16;
1060 player[c1].x_add = 0;
1064 player[c1].y += player[c1].y_add;
1066 s1 = (player[c1].x >> 16);
1067 s2 = (player[c1].y >> 16);
1068 if (ban_map[(s2 + 15) >> 4][(s1 + 8) >> 4] == 4 || ((ban_map[(s2 + 15) >> 4][s1 >> 4] == 4 && ban_map[(s2 + 15) >> 4][(s1 + 15) >> 4] != 1) || (ban_map[(s2 + 15) >> 4][s1 >> 4] != 1 && ban_map[(s2 + 15) >> 4][(s1 + 15) >> 4] == 4))) {
1069 player[c1].y = ((player[c1].y >> 16) & 0xfff0) << 16;
1070 player[c1].y_add = -400000L;
1071 player[c1].anim = 2;
1072 player[c1].frame = 0;
1073 player[c1].frame_tick = 0;
1074 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
1075 player[c1].jump_ready = 0;
1076 player[c1].jump_abort = 0;
1077 for (c2 = 0; c2 < 300; c2++) {
1078 if (objects[c2].used == 1 && objects[c2].type == OBJ_SPRING) {
1079 if (ban_map[(s2 + 15) >> 4][(s1 + 8) >> 4] == 4) {
1080 if ((objects[c2].x >> 20) == ((s1 + 8) >> 4) && (objects[c2].y >> 20) == ((s2 + 15) >> 4)) {
1081 objects[c2].frame = 0;
1082 objects[c2].ticks = object_anims[objects[c2].anim].frame[objects[c2].frame].ticks;
1083 objects[c2].image = object_anims[objects[c2].anim].frame[objects[c2].frame].image;
1087 if (ban_map[(s2 + 15) >> 4][s1 >> 4] == 4) {
1088 if ((objects[c2].x >> 20) == (s1 >> 4) && (objects[c2].y >> 20) == ((s2 + 15) >> 4)) {
1089 objects[c2].frame = 0;
1090 objects[c2].ticks = object_anims[objects[c2].anim].frame[objects[c2].frame].ticks;
1091 objects[c2].image = object_anims[objects[c2].anim].frame[objects[c2].frame].image;
1094 } else if (ban_map[(s2 + 15) >> 4][(s1 + 15) >> 4] == 4) {
1095 if ((objects[c2].x >> 20) == ((s1 + 15) >> 4) && (objects[c2].y >> 20) == ((s2 + 15) >> 4)) {
1096 objects[c2].frame = 0;
1097 objects[c2].ticks = object_anims[objects[c2].anim].frame[objects[c2].frame].ticks;
1098 objects[c2].image = object_anims[objects[c2].anim].frame[objects[c2].frame].image;
1105 dj_play_sfx(SFX_SPRING, SFX_SPRING_FREQ + rnd(2000) - 1000, 64, 0, 0, -1);
1107 s1 = (player[c1].x >> 16);
1108 s2 = (player[c1].y >> 16);
1111 if (ban_map[s2 >> 4][s1 >> 4] == 1 || ban_map[s2 >> 4][s1 >> 4] == 3 || ban_map[s2 >> 4][s1 >> 4] == 4 || ban_map[s2 >> 4][(s1 + 15) >> 4] == 1 || ban_map[s2 >> 4][(s1 + 15) >> 4] == 3 || ban_map[s2 >> 4][(s1 + 15) >> 4] == 4) {
1112 player[c1].y = (((s2 + 16) & 0xfff0)) << 16;
1113 player[c1].y_add = 0;
1114 player[c1].anim = 0;
1115 player[c1].frame = 0;
1116 player[c1].frame_tick = 0;
1117 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
1119 s1 = (player[c1].x >> 16);
1120 s2 = (player[c1].y >> 16);
1123 if (ban_map[(s2 + 8) >> 4][(s1 + 8) >> 4] == 2) {
1124 if (player[c1].in_water == 0) {
1125 player[c1].in_water = 1;
1126 player[c1].anim = 4;
1127 player[c1].frame = 0;
1128 player[c1].frame_tick = 0;
1129 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
1130 if (player[c1].y_add >= 32768) {
1131 add_object(OBJ_SPLASH, (player[c1].x >> 16) + 8, ((player[c1].y >> 16) & 0xfff0) + 15, 0, 0, OBJ_ANIM_SPLASH, 0);
1132 if (blood_is_thicker_than_water == 0)
1133 dj_play_sfx(SFX_SPLASH, SFX_SPLASH_FREQ + rnd(2000) - 1000, 64, 0, 0, -1);
1135 dj_play_sfx(SFX_SPLASH, SFX_SPLASH_FREQ + rnd(2000) - 5000, 64, 0, 0, -1);
1138 player[c1].y_add -= 1536;
1139 if (player[c1].y_add < 0 && player[c1].anim != 5) {
1140 player[c1].anim = 5;
1141 player[c1].frame = 0;
1142 player[c1].frame_tick = 0;
1143 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
1145 if (player[c1].y_add < -65536L)
1146 player[c1].y_add = -65536L;
1147 if (player[c1].y_add > 65535L)
1148 player[c1].y_add = 65535L;
1149 if (ban_map[(s2 + 15) >> 4][s1 >> 4] == 1 || ban_map[(s2 + 15) >> 4][s1 >> 4] == 3 || ban_map[(s2 + 15) >> 4][(s1 + 15) >> 4] == 1 || ban_map[(s2 + 15) >> 4][(s1 + 15) >> 4] == 3) {
1150 player[c1].y = (((s2 + 16) & 0xfff0) - 16) << 16;
1151 player[c1].y_add = 0;
1153 } else if (ban_map[(s2 + 15) >> 4][s1 >> 4] == 1 || ban_map[(s2 + 15) >> 4][s1 >> 4] == 3 || ban_map[(s2 + 15) >> 4][s1 >> 4] == 4 || ban_map[(s2 + 15) >> 4][(s1 + 15) >> 4] == 1 || ban_map[(s2 + 15) >> 4][(s1 + 15) >> 4] == 3 || ban_map[(s2 + 15) >> 4][(s1 + 15) >> 4] == 4) {
1154 player[c1].in_water = 0;
1155 player[c1].y = (((s2 + 16) & 0xfff0) - 16) << 16;
1156 player[c1].y_add = 0;
1157 if (player[c1].anim != 0 && player[c1].anim != 1) {
1158 player[c1].anim = 0;
1159 player[c1].frame = 0;
1160 player[c1].frame_tick = 0;
1161 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
1164 if (player[c1].in_water == 0) {
1165 if (bunnies_in_space == 0)
1166 player[c1].y_add += 12288;
1168 player[c1].y_add += 6144;
1169 if (player[c1].y_add > 327680L)
1170 player[c1].y_add = 327680L;
1172 player[c1].y = (player[c1].y & 0xffff0000) + 0x10000;
1173 player[c1].y_add = 0;
1175 player[c1].in_water = 0;
1177 if (player[c1].y_add > 36864 && player[c1].anim != 3 && player[c1].in_water == 0) {
1178 player[c1].anim = 3;
1179 player[c1].frame = 0;
1180 player[c1].frame_tick = 0;
1181 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
1186 player[c1].frame_tick++;
1187 if (player[c1].frame_tick >= player_anims[player[c1].anim].frame[player[c1].frame].ticks) {
1189 if (player[c1].frame >= player_anims[player[c1].anim].num_frames) {
1190 if (player[c1].anim != 6)
1191 player[c1].frame = player_anims[player[c1].anim].restart_frame;
1193 position_player(c1);
1195 player[c1].frame_tick = 0;
1197 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
1206 void position_player(short player_num)
1215 if (ban_map[s2][s1] == 0 && (ban_map[s2 + 1][s1] == 1 || ban_map[s2 + 1][s1] == 3))
1218 for (c1 = 0; c1 < 4; c1++) {
1219 if (c1 != player_num && player[c1].enabled == 1) {
1220 if (abs((s1 << 4) - (player[c1].x >> 16)) < 32 && abs((s2 << 4) - (player[c1].y >> 16)) < 32)
1225 player[player_num].dead_flag = 0;
1226 player[player_num].x = (long) s1 << 20;
1227 player[player_num].y = (long) s2 << 20;
1228 player[player_num].x_add = player[player_num].y_add = 0;
1229 player[player_num].direction = 0;
1230 player[player_num].jump_ready = 1;
1231 player[player_num].in_water = 0;
1232 player[player_num].anim = 0;
1233 player[player_num].frame = 0;
1234 player[player_num].frame_tick = 0;
1235 player[player_num].image = player_anims[player[player_num].anim].frame[player[player_num].frame].image;
1243 void fireworks(void)
1249 char used, direction, colour;
1253 int anim, frame, frame_tick, image;
1262 outportw(0x3c4, 0x0f02);
1263 memset((char *) (0xa0000 - __djgpp_base_address), 0, 65535);
1265 memset((char *) get_vgaptr(0, 0, 0), 0, JNB_WIDTH * JNB_HEIGHT);
1268 if ((handle = dat_open("level.pcx", datfile_name, "rb")) == 0) {
1269 strcpy(main_info.error_str, "Error loading 'level.pcx', aborting...\n");
1272 read_pcx(handle, mask_pic, 102400, pal);
1275 memset(mask_pic, 0, 102400);
1277 memset(ban_map, 0, sizeof(ban_map));
1279 fillpalette(0, 0, 0);
1282 for (c1 = 0; c1 < 4; c1++) {
1283 outportw(0x3c4, ((1 << c1) << 8) + 0x02);
1284 for (c2 = 193; c2 < 256; c2++) {
1285 memset((void *) (0xa0000 + c2 * 100 - __djgpp_base_address), (c2 - 192) >> 2, 100);
1286 memset((void *) (0xa0000 + 32768 + c2 * 100 - __djgpp_base_address), (c2 - 192) >> 2, 100);
1290 for (c2 = 193; c2 < 256; c2++) {
1291 memset((void *) get_vgaptr(0, 0, c2), (c2 - 192) >> 2, 400);
1295 setpalette(0, 256, pal);
1297 for (c1 = 0; c1 < 20; c1++)
1298 rabbits[c1].used = 0;
1300 rabbits[0].used = 1;
1301 rabbits[0].colour = rnd(4);
1302 rabbits[0].x = (int) (150 + rnd(100)) << 16;
1303 rabbits[0].y = 256 << 16;
1304 rabbits[0].x_add = ((int) rnd(65535) << 1) - 65536;
1305 if (rabbits[0].x_add > 0)
1306 rabbits[0].direction = 0;
1308 rabbits[0].direction = 1;
1309 rabbits[0].y_add = -262144 + (rnd(16384) * 5);
1310 rabbits[0].timer = 30 + rnd(150);
1311 rabbits[0].anim = 2;
1312 rabbits[0].frame = 0;
1313 rabbits[0].frame_tick = 0;
1314 rabbits[0].image = player_anims[rabbits[0].anim].frame[rabbits[0].frame].image + rabbits[0].colour * 18 + rabbits[0].direction * 9;
1316 for (c1 = 0; c1 < 300; c1++) {
1320 stars[c1].x = stars[c1].old_x = (s1 << 16);
1321 stars[c1].y = stars[c1].old_y = (s2 << 16);
1324 outportw(0x3ce, ((s1 & 3) << 8) + 0x04);
1325 stars[c1].back[0] = stars[c1].back[1] = *(char *) (0xa0000 + s2 * 100 + (s1 >> 2) - __djgpp_base_address);
1327 stars[c1].back[0] = stars[c1].back[1] = *(char *) get_vgaptr(0, s1, s2);
1333 main_info.page_info[0].num_pobs = 0;
1334 main_info.page_info[1].num_pobs = 0;
1335 main_info.view_page = 0;
1336 main_info.draw_page = 1;
1338 while (key_pressed(1) == 0) {
1343 for (c1 = 0; c1 < 300; c1++) {
1344 stars[c1].old_x = stars[c1].x;
1345 stars[c1].old_y = stars[c1].y;
1346 stars[c1].y -= (int) (31 - stars[c1].col) * 16384;
1347 if ((stars[c1].y >> 16) < 0)
1348 stars[c1].y += 256 << 16;
1349 if ((stars[c1].y >> 16) >= 256)
1350 stars[c1].y -= 256 << 16;
1353 for (c1 = 0, c2 = 0; c1 < 20; c1++) {
1354 if (rabbits[c1].used == 1)
1357 if ((c2 == 0 && rnd(10000) < 200) || (c2 == 1 && rnd(10000) < 150) || (c2 == 2 && rnd(10000) < 100) || (c2 == 3 && rnd(10000) < 50)) {
1358 for (c1 = 0; c1 < 20; c1++) {
1359 if (rabbits[c1].used == 0) {
1360 rabbits[c1].used = 1;
1361 rabbits[c1].colour = rnd(4);
1362 rabbits[c1].x = (int) (150 + rnd(100)) << 16;
1363 rabbits[c1].y = 256 << 16;
1364 rabbits[c1].x_add = ((int) rnd(65535) << 1) - 65536;
1365 if (rabbits[c1].x_add > 0)
1366 rabbits[c1].direction = 0;
1368 rabbits[c1].direction = 1;
1369 rabbits[c1].y_add = -262144 + (rnd(16384) * 5);
1370 rabbits[c1].timer = 30 + rnd(150);
1371 rabbits[c1].anim = 2;
1372 rabbits[c1].frame = 0;
1373 rabbits[c1].frame_tick = 0;
1374 rabbits[c1].image = player_anims[rabbits[c1].anim].frame[rabbits[c1].frame].image + rabbits[c1].colour * 18 + rabbits[c1].direction * 9;
1382 main_info.page_info[main_info.draw_page].num_pobs = 0;
1384 for (c1 = 0; c1 < 20; c1++) {
1385 if (rabbits[c1].used == 1) {
1386 rabbits[c1].y_add += 2048;
1387 if (rabbits[c1].y_add > 36864 && rabbits[c1].anim != 3) {
1388 rabbits[c1].anim = 3;
1389 rabbits[c1].frame = 0;
1390 rabbits[c1].frame_tick = 0;
1391 rabbits[c1].image = player_anims[rabbits[c1].anim].frame[rabbits[c1].frame].image + rabbits[c1].colour * 18 + rabbits[c1].direction * 9;
1393 rabbits[c1].x += rabbits[c1].x_add;
1394 rabbits[c1].y += rabbits[c1].y_add;
1395 if ((rabbits[c1].x >> 16) < 16 || (rabbits[c1].x >> 16) > 400 || (rabbits[c1].y >> 16) > 256) {
1396 rabbits[c1].used = 0;
1399 rabbits[c1].timer--;
1400 if (rabbits[c1].timer <= 0) {
1401 rabbits[c1].used = 0;
1402 for (c2 = 0; c2 < 6; c2++)
1403 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);
1404 for (c2 = 0; c2 < 6; c2++)
1405 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);
1406 for (c2 = 0; c2 < 6; c2++)
1407 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);
1408 for (c2 = 0; c2 < 8; c2++)
1409 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);
1410 for (c2 = 0; c2 < 10; c2++)
1411 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);
1412 dj_play_sfx(SFX_DEATH, SFX_DEATH_FREQ, 64, 0, 0, -1);
1415 rabbits[c1].frame_tick++;
1416 if (rabbits[c1].frame_tick >= player_anims[rabbits[c1].anim].frame[rabbits[c1].frame].ticks) {
1417 rabbits[c1].frame++;
1418 if (rabbits[c1].frame >= player_anims[rabbits[c1].anim].num_frames)
1419 rabbits[c1].frame = player_anims[rabbits[c1].anim].restart_frame;
1420 rabbits[c1].frame_tick = 0;
1422 rabbits[c1].image = player_anims[rabbits[c1].anim].frame[rabbits[c1].frame].image + rabbits[c1].colour * 18 + rabbits[c1].direction * 9;
1423 if (rabbits[c1].used == 1)
1424 add_pob(main_info.draw_page, rabbits[c1].x >> 16, rabbits[c1].y >> 16, rabbits[c1].image, rabbit_gobs);
1432 for (c1 = 0; c1 < 300; c1++) {
1434 outportw(0x3ce, (((stars[c1].x >> 16) & 3) << 8) + 0x04);
1435 outportw(0x3c4, ((1 << ((stars[c1].x >> 16) & 3)) << 8) + 0x02);
1436 stars[c1].back[main_info.draw_page] = *(char *) (0xa0000 + ((int) main_info.draw_page << 15) + (stars[c1].y >> 16) * 100 + (stars[c1].x >> 18) - __djgpp_base_address);
1437 *(char *) (0xa0000 + ((int) main_info.draw_page << 15) + (stars[c1].y >> 16) * 100 + (stars[c1].x >> 18) - __djgpp_base_address) = stars[c1].col;
1439 stars[c1].back[main_info.draw_page] = *(char *) get_vgaptr(main_info.draw_page, stars[c1].x >> 16, stars[c1].y >> 16);
1440 *(char *) get_vgaptr(main_info.draw_page, stars[c1].x >> 16, stars[c1].y >> 16) = stars[c1].col;
1446 draw_pobs(main_info.draw_page);
1448 main_info.draw_page ^= 1;
1449 main_info.view_page ^= 1;
1451 outportw(0x3d4, (main_info.view_page << 23) + 0x0d);
1452 outportw(0x3d4, ((main_info.view_page << 15) & 0xff00) + 0x0c);
1454 flippage(main_info.view_page);
1458 while ((inportb(0x3da) & 8) == 0)
1460 while ((inportb(0x3da) & 8) == 8)
1464 redraw_pob_backgrounds(main_info.draw_page);
1469 for (c1 = 299; c1 >= 0; c1--) {
1471 outportw(0x3c4, ((1 << ((stars[c1].old_x >> 16) & 3)) << 8) + 0x02);
1472 *(char *) (0xa0000 + ((int) main_info.draw_page << 15) + (stars[c1].old_y >> 16) * 100 + (stars[c1].old_x >> 18) - __djgpp_base_address) = stars[c1].back[main_info.draw_page];
1474 *(char *) get_vgaptr(main_info.draw_page, stars[c1].old_x >> 16, stars[c1].old_y >> 16) = stars[c1].back[main_info.draw_page];
1485 void add_object(char type, short x, short y, long x_add, long y_add, short anim, short frame)
1489 for (c1 = 0; c1 < NUM_OBJECTS; c1++) {
1490 if (objects[c1].used == 0) {
1491 objects[c1].used = 1;
1492 objects[c1].type = type;
1493 objects[c1].x = (long) x << 16;
1494 objects[c1].y = (long) y << 16;
1495 objects[c1].x_add = x_add;
1496 objects[c1].y_add = y_add;
1497 objects[c1].x_acc = 0;
1498 objects[c1].y_acc = 0;
1499 objects[c1].anim = anim;
1500 objects[c1].frame = frame;
1501 objects[c1].ticks = object_anims[anim].frame[frame].ticks;
1502 objects[c1].image = object_anims[anim].frame[frame].image;
1510 void update_objects(void)
1515 for (c1 = 0; c1 < NUM_OBJECTS; c1++) {
1516 if (objects[c1].used == 1) {
1517 switch (objects[c1].type) {
1519 objects[c1].ticks--;
1520 if (objects[c1].ticks <= 0) {
1521 objects[c1].frame++;
1522 if (objects[c1].frame >= object_anims[objects[c1].anim].num_frames) {
1523 objects[c1].frame--;
1524 objects[c1].ticks = object_anims[objects[c1].anim].frame[objects[c1].frame].ticks;
1526 objects[c1].ticks = object_anims[objects[c1].anim].frame[objects[c1].frame].ticks;
1527 objects[c1].image = object_anims[objects[c1].anim].frame[objects[c1].frame].image;
1530 if (objects[c1].used == 1)
1531 add_pob(main_info.draw_page, objects[c1].x >> 16, objects[c1].y >> 16, objects[c1].image, object_gobs);
1534 objects[c1].ticks--;
1535 if (objects[c1].ticks <= 0) {
1536 objects[c1].frame++;
1537 if (objects[c1].frame >= object_anims[objects[c1].anim].num_frames)
1538 objects[c1].used = 0;
1540 objects[c1].ticks = object_anims[objects[c1].anim].frame[objects[c1].frame].ticks;
1541 objects[c1].image = object_anims[objects[c1].anim].frame[objects[c1].frame].image;
1544 if (objects[c1].used == 1)
1545 add_pob(main_info.draw_page, objects[c1].x >> 16, objects[c1].y >> 16, objects[c1].image, object_gobs);
1548 objects[c1].x += objects[c1].x_add;
1549 objects[c1].y += objects[c1].y_add;
1550 objects[c1].ticks--;
1551 if (objects[c1].ticks <= 0) {
1552 objects[c1].frame++;
1553 if (objects[c1].frame >= object_anims[objects[c1].anim].num_frames)
1554 objects[c1].used = 0;
1556 objects[c1].ticks = object_anims[objects[c1].anim].frame[objects[c1].frame].ticks;
1557 objects[c1].image = object_anims[objects[c1].anim].frame[objects[c1].frame].image;
1560 if (objects[c1].used == 1)
1561 add_pob(main_info.draw_page, objects[c1].x >> 16, objects[c1].y >> 16, objects[c1].image, object_gobs);
1563 case OBJ_YEL_BUTFLY:
1564 case OBJ_PINK_BUTFLY:
1565 objects[c1].x_acc += rnd(128) - 64;
1566 if (objects[c1].x_acc < -1024)
1567 objects[c1].x_acc = -1024;
1568 if (objects[c1].x_acc > 1024)
1569 objects[c1].x_acc = 1024;
1570 objects[c1].x_add += objects[c1].x_acc;
1571 if (objects[c1].x_add < -32768)
1572 objects[c1].x_add = -32768;
1573 if (objects[c1].x_add > 32768)
1574 objects[c1].x_add = 32768;
1575 objects[c1].x += objects[c1].x_add;
1576 if ((objects[c1].x >> 16) < 16) {
1577 objects[c1].x = 16 << 16;
1578 objects[c1].x_add = -objects[c1].x_add >> 2;
1579 objects[c1].x_acc = 0;
1580 } else if ((objects[c1].x >> 16) > 350) {
1581 objects[c1].x = 350 << 16;
1582 objects[c1].x_add = -objects[c1].x_add >> 2;
1583 objects[c1].x_acc = 0;
1585 if (ban_map[objects[c1].y >> 20][objects[c1].x >> 20] != 0) {
1586 if (objects[c1].x_add < 0) {
1587 objects[c1].x = (((objects[c1].x >> 16) + 16) & 0xfff0) << 16;
1589 objects[c1].x = ((((objects[c1].x >> 16) - 16) & 0xfff0) + 15) << 16;
1591 objects[c1].x_add = -objects[c1].x_add >> 2;
1592 objects[c1].x_acc = 0;
1594 objects[c1].y_acc += rnd(64) - 32;
1595 if (objects[c1].y_acc < -1024)
1596 objects[c1].y_acc = -1024;
1597 if (objects[c1].y_acc > 1024)
1598 objects[c1].y_acc = 1024;
1599 objects[c1].y_add += objects[c1].y_acc;
1600 if (objects[c1].y_add < -32768)
1601 objects[c1].y_add = -32768;
1602 if (objects[c1].y_add > 32768)
1603 objects[c1].y_add = 32768;
1604 objects[c1].y += objects[c1].y_add;
1605 if ((objects[c1].y >> 16) < 0) {
1607 objects[c1].y_add = -objects[c1].y_add >> 2;
1608 objects[c1].y_acc = 0;
1609 } else if ((objects[c1].y >> 16) > 255) {
1610 objects[c1].y = 255 << 16;
1611 objects[c1].y_add = -objects[c1].y_add >> 2;
1612 objects[c1].y_acc = 0;
1614 if (ban_map[objects[c1].y >> 20][objects[c1].x >> 20] != 0) {
1615 if (objects[c1].y_add < 0) {
1616 objects[c1].y = (((objects[c1].y >> 16) + 16) & 0xfff0) << 16;
1618 objects[c1].y = ((((objects[c1].y >> 16) - 16) & 0xfff0) + 15) << 16;
1620 objects[c1].y_add = -objects[c1].y_add >> 2;
1621 objects[c1].y_acc = 0;
1623 if (objects[c1].type == OBJ_YEL_BUTFLY) {
1624 if (objects[c1].x_add < 0 && objects[c1].anim != OBJ_ANIM_YEL_BUTFLY_LEFT) {
1625 objects[c1].anim = OBJ_ANIM_YEL_BUTFLY_LEFT;
1626 objects[c1].frame = 0;
1627 objects[c1].ticks = object_anims[objects[c1].anim].frame[objects[c1].frame].ticks;
1628 objects[c1].image = object_anims[objects[c1].anim].frame[objects[c1].frame].image;
1629 } else if (objects[c1].x_add > 0 && objects[c1].anim != OBJ_ANIM_YEL_BUTFLY_RIGHT) {
1630 objects[c1].anim = OBJ_ANIM_YEL_BUTFLY_RIGHT;
1631 objects[c1].frame = 0;
1632 objects[c1].ticks = object_anims[objects[c1].anim].frame[objects[c1].frame].ticks;
1633 objects[c1].image = object_anims[objects[c1].anim].frame[objects[c1].frame].image;
1636 if (objects[c1].x_add < 0 && objects[c1].anim != OBJ_ANIM_PINK_BUTFLY_LEFT) {
1637 objects[c1].anim = OBJ_ANIM_PINK_BUTFLY_LEFT;
1638 objects[c1].frame = 0;
1639 objects[c1].ticks = object_anims[objects[c1].anim].frame[objects[c1].frame].ticks;
1640 objects[c1].image = object_anims[objects[c1].anim].frame[objects[c1].frame].image;
1641 } else if (objects[c1].x_add > 0 && objects[c1].anim != OBJ_ANIM_PINK_BUTFLY_RIGHT) {
1642 objects[c1].anim = OBJ_ANIM_PINK_BUTFLY_RIGHT;
1643 objects[c1].frame = 0;
1644 objects[c1].ticks = object_anims[objects[c1].anim].frame[objects[c1].frame].ticks;
1645 objects[c1].image = object_anims[objects[c1].anim].frame[objects[c1].frame].image;
1648 objects[c1].ticks--;
1649 if (objects[c1].ticks <= 0) {
1650 objects[c1].frame++;
1651 if (objects[c1].frame >= object_anims[objects[c1].anim].num_frames)
1652 objects[c1].frame = object_anims[objects[c1].anim].restart_frame;
1654 objects[c1].ticks = object_anims[objects[c1].anim].frame[objects[c1].frame].ticks;
1655 objects[c1].image = object_anims[objects[c1].anim].frame[objects[c1].frame].image;
1658 if (objects[c1].used == 1)
1659 add_pob(main_info.draw_page, objects[c1].x >> 16, objects[c1].y >> 16, objects[c1].image, object_gobs);
1663 add_object(OBJ_FLESH_TRACE, objects[c1].x >> 16, objects[c1].y >> 16, 0, 0, OBJ_ANIM_FLESH_TRACE, 0);
1664 if (ban_map[objects[c1].y >> 20][objects[c1].x >> 20] == 0) {
1665 objects[c1].y_add += 3072;
1666 if (objects[c1].y_add > 196608L)
1667 objects[c1].y_add = 196608L;
1668 } else if (ban_map[objects[c1].y >> 20][objects[c1].x >> 20] == 2) {
1669 if (objects[c1].x_add < 0) {
1670 if (objects[c1].x_add < -65536L)
1671 objects[c1].x_add = -65536L;
1672 objects[c1].x_add += 1024;
1673 if (objects[c1].x_add > 0)
1674 objects[c1].x_add = 0;
1676 if (objects[c1].x_add > 65536L)
1677 objects[c1].x_add = 65536L;
1678 objects[c1].x_add -= 1024;
1679 if (objects[c1].x_add < 0)
1680 objects[c1].x_add = 0;
1682 objects[c1].y_add += 1024;
1683 if (objects[c1].y_add < -65536L)
1684 objects[c1].y_add = -65536L;
1685 if (objects[c1].y_add > 65536L)
1686 objects[c1].y_add = 65536L;
1688 objects[c1].x += objects[c1].x_add;
1689 if ((objects[c1].y >> 16) > 0 && (ban_map[objects[c1].y >> 20][objects[c1].x >> 20] == 1 || ban_map[objects[c1].y >> 20][objects[c1].x >> 20] == 3)) {
1690 if (objects[c1].x_add < 0) {
1691 objects[c1].x = (((objects[c1].x >> 16) + 16) & 0xfff0) << 16;
1692 objects[c1].x_add = -objects[c1].x_add >> 2;
1694 objects[c1].x = ((((objects[c1].x >> 16) - 16) & 0xfff0) + 15) << 16;
1695 objects[c1].x_add = -objects[c1].x_add >> 2;
1698 objects[c1].y += objects[c1].y_add;
1699 if ((objects[c1].x >> 16) < -5 || (objects[c1].x >> 16) > 405 || (objects[c1].y >> 16) > 260)
1700 objects[c1].used = 0;
1701 if ((objects[c1].y >> 16) > 0 && (ban_map[objects[c1].y >> 20][objects[c1].x >> 20] != 0)) {
1702 if (objects[c1].y_add < 0) {
1703 if (ban_map[objects[c1].y >> 20][objects[c1].x >> 20] != 2) {
1704 objects[c1].y = (((objects[c1].y >> 16) + 16) & 0xfff0) << 16;
1705 objects[c1].x_add >>= 2;
1706 objects[c1].y_add = -objects[c1].y_add >> 2;
1709 if (ban_map[objects[c1].y >> 20][objects[c1].x >> 20] == 1) {
1710 if (objects[c1].y_add > 131072L) {
1711 objects[c1].y = ((((objects[c1].y >> 16) - 16) & 0xfff0) + 15) << 16;
1712 objects[c1].x_add >>= 2;
1713 objects[c1].y_add = -objects[c1].y_add >> 2;
1715 objects[c1].used = 0;
1716 } else if (ban_map[objects[c1].y >> 20][objects[c1].x >> 20] == 3) {
1717 objects[c1].y = ((((objects[c1].y >> 16) - 16) & 0xfff0) + 15) << 16;
1718 if (objects[c1].y_add > 131072L)
1719 objects[c1].y_add = -objects[c1].y_add >> 2;
1721 objects[c1].y_add = 0;
1725 if (objects[c1].x_add < 0 && objects[c1].x_add > -16384)
1726 objects[c1].x_add = -16384;
1727 if (objects[c1].x_add > 0 && objects[c1].x_add < 16384)
1728 objects[c1].x_add = 16384;
1729 if (objects[c1].used == 1) {
1730 s1 = atan2(objects[c1].y_add, objects[c1].x_add) * 4 / M_PI;
1737 add_pob(main_info.draw_page, objects[c1].x >> 16, objects[c1].y >> 16, objects[c1].frame + s1, object_gobs);
1741 if (rnd(100) < 30) {
1742 if (objects[c1].frame == 76)
1743 add_object(OBJ_FLESH_TRACE, objects[c1].x >> 16, objects[c1].y >> 16, 0, 0, OBJ_ANIM_FLESH_TRACE, 1);
1744 else if (objects[c1].frame == 77)
1745 add_object(OBJ_FLESH_TRACE, objects[c1].x >> 16, objects[c1].y >> 16, 0, 0, OBJ_ANIM_FLESH_TRACE, 2);
1746 else if (objects[c1].frame == 78)
1747 add_object(OBJ_FLESH_TRACE, objects[c1].x >> 16, objects[c1].y >> 16, 0, 0, OBJ_ANIM_FLESH_TRACE, 3);
1749 if (ban_map[objects[c1].y >> 20][objects[c1].x >> 20] == 0) {
1750 objects[c1].y_add += 3072;
1751 if (objects[c1].y_add > 196608L)
1752 objects[c1].y_add = 196608L;
1753 } else if (ban_map[objects[c1].y >> 20][objects[c1].x >> 20] == 2) {
1754 if (objects[c1].x_add < 0) {
1755 if (objects[c1].x_add < -65536L)
1756 objects[c1].x_add = -65536L;
1757 objects[c1].x_add += 1024;
1758 if (objects[c1].x_add > 0)
1759 objects[c1].x_add = 0;
1761 if (objects[c1].x_add > 65536L)
1762 objects[c1].x_add = 65536L;
1763 objects[c1].x_add -= 1024;
1764 if (objects[c1].x_add < 0)
1765 objects[c1].x_add = 0;
1767 objects[c1].y_add += 1024;
1768 if (objects[c1].y_add < -65536L)
1769 objects[c1].y_add = -65536L;
1770 if (objects[c1].y_add > 65536L)
1771 objects[c1].y_add = 65536L;
1773 objects[c1].x += objects[c1].x_add;
1774 if ((objects[c1].y >> 16) > 0 && (ban_map[objects[c1].y >> 20][objects[c1].x >> 20] == 1 || ban_map[objects[c1].y >> 20][objects[c1].x >> 20] == 3)) {
1775 if (objects[c1].x_add < 0) {
1776 objects[c1].x = (((objects[c1].x >> 16) + 16) & 0xfff0) << 16;
1777 objects[c1].x_add = -objects[c1].x_add >> 2;
1779 objects[c1].x = ((((objects[c1].x >> 16) - 16) & 0xfff0) + 15) << 16;
1780 objects[c1].x_add = -objects[c1].x_add >> 2;
1783 objects[c1].y += objects[c1].y_add;
1784 if ((objects[c1].x >> 16) < -5 || (objects[c1].x >> 16) > 405 || (objects[c1].y >> 16) > 260)
1785 objects[c1].used = 0;
1786 if ((objects[c1].y >> 16) > 0 && (ban_map[objects[c1].y >> 20][objects[c1].x >> 20] != 0)) {
1787 if (objects[c1].y_add < 0) {
1788 if (ban_map[objects[c1].y >> 20][objects[c1].x >> 20] != 2) {
1789 objects[c1].y = (((objects[c1].y >> 16) + 16) & 0xfff0) << 16;
1790 objects[c1].x_add >>= 2;
1791 objects[c1].y_add = -objects[c1].y_add >> 2;
1794 if (ban_map[objects[c1].y >> 20][objects[c1].x >> 20] == 1) {
1795 if (objects[c1].y_add > 131072L) {
1796 objects[c1].y = ((((objects[c1].y >> 16) - 16) & 0xfff0) + 15) << 16;
1797 objects[c1].x_add >>= 2;
1798 objects[c1].y_add = -objects[c1].y_add >> 2;
1800 if (rnd(100) < 10) {
1802 add_leftovers(0, objects[c1].x >> 16, (objects[c1].y >> 16) + s1, objects[c1].frame, object_gobs);
1803 add_leftovers(1, objects[c1].x >> 16, (objects[c1].y >> 16) + s1, objects[c1].frame, object_gobs);
1805 objects[c1].used = 0;
1807 } else if (ban_map[objects[c1].y >> 20][objects[c1].x >> 20] == 3) {
1808 objects[c1].y = ((((objects[c1].y >> 16) - 16) & 0xfff0) + 15) << 16;
1809 if (objects[c1].y_add > 131072L)
1810 objects[c1].y_add = -objects[c1].y_add >> 2;
1812 objects[c1].y_add = 0;
1816 if (objects[c1].x_add < 0 && objects[c1].x_add > -16384)
1817 objects[c1].x_add = -16384;
1818 if (objects[c1].x_add > 0 && objects[c1].x_add < 16384)
1819 objects[c1].x_add = 16384;
1820 if (objects[c1].used == 1)
1821 add_pob(main_info.draw_page, objects[c1].x >> 16, objects[c1].y >> 16, objects[c1].frame, object_gobs);
1823 case OBJ_FLESH_TRACE:
1824 objects[c1].ticks--;
1825 if (objects[c1].ticks <= 0) {
1826 objects[c1].frame++;
1827 if (objects[c1].frame >= object_anims[objects[c1].anim].num_frames)
1828 objects[c1].used = 0;
1830 objects[c1].ticks = object_anims[objects[c1].anim].frame[objects[c1].frame].ticks;
1831 objects[c1].image = object_anims[objects[c1].anim].frame[objects[c1].frame].image;
1834 if (objects[c1].used == 1)
1835 add_pob(main_info.draw_page, objects[c1].x >> 16, objects[c1].y >> 16, objects[c1].image, object_gobs);
1844 char add_pob(int page, short x, short y, short image, char *pob_data)
1847 if (main_info.page_info[page].num_pobs >= NUM_POBS)
1850 main_info.page_info[page].pobs[main_info.page_info[page].num_pobs].x = x;
1851 main_info.page_info[page].pobs[main_info.page_info[page].num_pobs].y = y;
1852 main_info.page_info[page].pobs[main_info.page_info[page].num_pobs].image = image;
1853 main_info.page_info[page].pobs[main_info.page_info[page].num_pobs].pob_data = pob_data;
1854 main_info.page_info[page].num_pobs++;
1861 void draw_pobs(int page)
1868 for (c1 = main_info.page_info[page].num_pobs - 1; c1 >= 0; c1--) {
1869 main_info.page_info[page].pobs[c1].back_buf_ofs = back_buf_ofs;
1870 get_block(page, main_info.page_info[page].pobs[c1].x - pob_hs_x(main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data), main_info.page_info[page].pobs[c1].y - pob_hs_y(main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data), pob_width(main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data), pob_height(main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data), (char *) (main_info.pob_backbuf[page] + back_buf_ofs));
1871 back_buf_ofs += pob_width(main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data) * pob_height(main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data);
1872 put_pob(page, main_info.page_info[page].pobs[c1].x, main_info.page_info[page].pobs[c1].y, main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data, 1, mask_pic);
1878 void redraw_pob_backgrounds(int page)
1882 for (c1 = 0; c1 < main_info.page_info[page].num_pobs; c1++)
1883 put_block(page, main_info.page_info[page].pobs[c1].x - pob_hs_x(main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data), main_info.page_info[page].pobs[c1].y - pob_hs_y(main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data), pob_width(main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data), pob_height(main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data), (char *) (main_info.pob_backbuf[page] + main_info.page_info[page].pobs[c1].back_buf_ofs));
1888 char add_leftovers(int page, short x, short y, short image, char *pob_data)
1891 if (leftovers.page[page].num_pobs >= NUM_LEFTOVERS)
1894 leftovers.page[page].pobs[leftovers.page[page].num_pobs].x = x;
1895 leftovers.page[page].pobs[leftovers.page[page].num_pobs].y = y;
1896 leftovers.page[page].pobs[leftovers.page[page].num_pobs].image = image;
1897 leftovers.page[page].pobs[leftovers.page[page].num_pobs].pob_data = pob_data;
1898 leftovers.page[page].num_pobs++;
1905 void draw_leftovers(int page)
1909 for (c1 = leftovers.page[page].num_pobs - 1; c1 >= 0; c1--)
1910 put_pob(page, leftovers.page[page].pobs[c1].x, leftovers.page[page].pobs[c1].y, leftovers.page[page].pobs[c1].image, leftovers.page[page].pobs[c1].pob_data, 1, mask_pic);
1912 leftovers.page[page].num_pobs = 0;
1917 char init_level(short level)
1923 if ((handle = dat_open("level.pcx", datfile_name, "rb")) == 0) {
1924 strcpy(main_info.error_str, "Error loading 'level.pcx', aborting...\n");
1927 if (read_pcx(handle, background_pic, 102400L, pal) != 0) {
1928 strcpy(main_info.error_str, "Error loading 'level.pcx', aborting...\n");
1932 if ((handle = dat_open("mask.pcx", datfile_name, "rb")) == 0) {
1933 strcpy(main_info.error_str, "Error loading 'mask.pcx', aborting...\n");
1936 if (read_pcx(handle, mask_pic, 102400L, 0) != 0) {
1937 strcpy(main_info.error_str, "Error loading 'mask.pcx', aborting...\n");
1941 memset(cur_pal, 0, 768);
1943 for (c1 = 0; c1 < 4; c1++) {
1944 if (player[c1].enabled == 1) {
1945 player[c1].bumps = 0;
1946 player[c1].bumped[0] = 0;
1947 player[c1].bumped[1] = 0;
1948 player[c1].bumped[2] = 0;
1949 player[c1].bumped[3] = 0;
1950 position_player(c1);
1954 for (c1 = 0; c1 < 300; c1++)
1955 objects[c1].used = 0;
1957 for (c1 = 0; c1 < 16; c1++) {
1958 for (c2 = 0; c2 < 22; c2++) {
1959 if (ban_map[c1][c2] == 4)
1960 add_object(OBJ_SPRING, c2 << 4, c1 << 4, 0, 0, OBJ_ANIM_SPRING, 5);
1967 if (ban_map[s2][s1] == 0) {
1968 add_object(OBJ_YEL_BUTFLY, (s1 << 4) + 8, (s2 << 4) + 8, (rnd(65535) - 32768) * 2, (rnd(65535) - 32768) * 2, 0, 0);
1975 if (ban_map[s2][s1] == 0) {
1976 add_object(OBJ_YEL_BUTFLY, (s1 << 4) + 8, (s2 << 4) + 8, (rnd(65535) - 32768) * 2, (rnd(65535) - 32768) * 2, 0, 0);
1983 if (ban_map[s2][s1] == 0) {
1984 add_object(OBJ_PINK_BUTFLY, (s1 << 4) + 8, (s2 << 4) + 8, (rnd(65535) - 32768) * 2, (rnd(65535) - 32768) * 2, 0, 0);
1991 if (ban_map[s2][s1] == 0) {
1992 add_object(OBJ_PINK_BUTFLY, (s1 << 4) + 8, (s2 << 4) + 8, (rnd(65535) - 32768) * 2, (rnd(65535) - 32768) * 2, 0, 0);
2002 void deinit_level(void)
2009 char init_program(int argc, char *argv[])
2011 FILE *handle = (FILE *) NULL;
2014 char force2, force3;
2016 int player_anim_data[] = {
2017 1, 0, 0, 0x7fff, 0, 0, 0, 0, 0, 0,
2018 4, 0, 0, 4, 1, 4, 2, 4, 3, 4,
2019 1, 0, 4, 0x7fff, 0, 0, 0, 0, 0, 0,
2020 4, 2, 5, 8, 6, 10, 7, 3, 6, 3,
2021 1, 0, 6, 0x7fff, 0, 0, 0, 0, 0, 0,
2022 2, 1, 5, 8, 4, 0x7fff, 0, 0, 0, 0,
2023 1, 0, 8, 5, 0, 0, 0, 0, 0, 0
2027 if (__djgpp_nearptr_enable() == 0)
2033 if (hook_keyb_handler() != 0)
2036 memset(&main_info, 0, sizeof(main_info));
2037 main_info.joy_enabled = 0; /* CHANGE THIS FOR JOY */
2039 strcpy(datfile_name, "data/jumpbump.dat");
2041 force2 = force3 = 0;
2044 for (c1 = 1; c1 < argc; c1++) {
2045 if (stricmp(argv[c1], "-nosound") == 0)
2046 main_info.no_sound = 1;
2047 else if (stricmp(argv[c1], "-nogore") == 0)
2048 main_info.no_gore = 1;
2049 else if (stricmp(argv[c1], "-nojoy") == 0)
2050 main_info.joy_enabled = 0;
2051 else if (stricmp(argv[c1], "-fireworks") == 0)
2052 main_info.fireworks = 1;
2054 else if (stricmp(argv[c1], "-fullscreen") == 0)
2057 else if (stricmp(argv[c1], "-dat") == 0) {
2058 if (c1 < (argc - 1)) {
2059 if ((handle = fopen(argv[c1 + 1], "rb")) != NULL) {
2061 strcpy(datfile_name, argv[c1 + 1]);
2064 } else if (stricmp(argv[c1], "-mouse") == 0) {
2065 if (c1 < (argc - 1)) {
2066 if (stricmp(argv[c1 + 1], "2") == 0)
2068 if (stricmp(argv[c1 + 1], "3") == 0)
2075 for (c1 = 0; c1 < 7; c1++) {
2076 player_anims[c1].num_frames = player_anim_data[c1 * 10];
2077 player_anims[c1].restart_frame = player_anim_data[c1 * 10 + 1];
2078 for (c2 = 0; c2 < 4; c2++) {
2079 player_anims[c1].frame[c2].image = player_anim_data[c1 * 10 + c2 * 2 + 2];
2080 player_anims[c1].frame[c2].ticks = player_anim_data[c1 * 10 + c2 * 2 + 3];
2084 if ((background_pic = malloc(102400)) == NULL)
2086 if ((mask_pic = malloc(102400)) == NULL)
2088 memset(mask_pic, 0, 102400);
2090 main_info.pob_backbuf[0] = malloc(65535);
2091 main_info.pob_backbuf[1] = malloc(65535);
2092 if (main_info.pob_backbuf[0] == 0 || main_info.pob_backbuf[1] == 0)
2095 if ((handle = dat_open("rabbit.gob", datfile_name, "rb")) == 0) {
2096 strcpy(main_info.error_str, "Error loading 'rabbit.gob', aborting...\n");
2099 if ((rabbit_gobs = malloc(dat_filelen("rabbit.gob", datfile_name))) == 0) {
2100 strcpy(main_info.error_str, "Not enough memory, aborting...\n");
2104 fread(rabbit_gobs, 1, dat_filelen("rabbit.gob", datfile_name), handle);
2107 if ((handle = dat_open("objects.gob", datfile_name, "rb")) == 0) {
2108 strcpy(main_info.error_str, "Error loading 'objects.gob', aborting...\n");
2111 if ((object_gobs = malloc(dat_filelen("objects.gob", datfile_name))) == 0) {
2112 strcpy(main_info.error_str, "Not enough memory, aborting...\n");
2116 fread(object_gobs, 1, dat_filelen("objects.gob", datfile_name), handle);
2119 if ((handle = dat_open("font.gob", datfile_name, "rb")) == 0) {
2120 strcpy(main_info.error_str, "Error loading 'font.gob', aborting...\n");
2123 if ((font_gobs = malloc(dat_filelen("font.gob", datfile_name))) == 0) {
2124 strcpy(main_info.error_str, "Not enough memory, aborting...\n");
2128 fread(font_gobs, 1, dat_filelen("font.gob", datfile_name), handle);
2131 if ((handle = dat_open("numbers.gob", datfile_name, "rb")) == 0) {
2132 strcpy(main_info.error_str, "Error loading 'numbers.gob', aborting...\n");
2135 if ((number_gobs = malloc(dat_filelen("numbers.gob", datfile_name))) == 0) {
2136 strcpy(main_info.error_str, "Not enough memory, aborting...\n");
2140 fread(number_gobs, 1, dat_filelen("numbers.gob", datfile_name), handle);
2143 if (read_level() != 0) {
2144 strcpy(main_info.error_str, "Error loading 'levelmap.txt', aborting...\n");
2150 if (main_info.no_sound == 0) {
2152 dj_set_mixing_freq(20000);
2156 dj_set_num_sfx_channels(5);
2157 dj_set_sfx_volume(64);
2161 if ((handle = dat_open("jump.mod", datfile_name, "rb")) == 0) {
2162 strcpy(main_info.error_str, "Error loading 'jump.mod', aborting...\n");
2165 if (dj_load_mod(handle, 0, MOD_MENU) != 0) {
2166 strcpy(main_info.error_str, "Error loading 'jump.mod', aborting...\n");
2171 if ((handle = dat_open("bump.mod", datfile_name, "rb")) == 0) {
2172 strcpy(main_info.error_str, "Error loading 'bump.mod', aborting...\n");
2175 if (dj_load_mod(handle, 0, MOD_GAME) != 0) {
2176 strcpy(main_info.error_str, "Error loading 'bump.mod', aborting...\n");
2181 if ((handle = dat_open("scores.mod", datfile_name, "rb")) == 0) {
2182 strcpy(main_info.error_str, "Error loading 'scores.mod', aborting...\n");
2185 if (dj_load_mod(handle, 0, MOD_SCORES) != 0) {
2186 strcpy(main_info.error_str, "Error loading 'scores.mod', aborting...\n");
2191 if ((handle = dat_open("jump.smp", datfile_name, "rb")) == 0) {
2192 strcpy(main_info.error_str, "Error loading 'jump.smp', aborting...\n");
2195 if (dj_load_sfx(handle, 0, dat_filelen("jump.smp", datfile_name), DJ_SFX_TYPE_SMP, SFX_JUMP) != 0) {
2196 strcpy(main_info.error_str, "Error loading 'jump.smp', aborting...\n");
2201 if ((handle = dat_open("death.smp", datfile_name, "rb")) == 0) {
2202 strcpy(main_info.error_str, "Error loading 'death.smp', aborting...\n");
2205 if (dj_load_sfx(handle, 0, dat_filelen("death.smp", datfile_name), DJ_SFX_TYPE_SMP, SFX_DEATH) != 0) {
2206 strcpy(main_info.error_str, "Error loading 'death.smp', aborting...\n");
2211 if ((handle = dat_open("spring.smp", datfile_name, "rb")) == 0) {
2212 strcpy(main_info.error_str, "Error loading 'spring.smp', aborting...\n");
2215 if (dj_load_sfx(handle, 0, dat_filelen("spring.smp", datfile_name), DJ_SFX_TYPE_SMP, SFX_SPRING) != 0) {
2216 strcpy(main_info.error_str, "Error loading 'spring.smp', aborting...\n");
2221 if ((handle = dat_open("splash.smp", datfile_name, "rb")) == 0) {
2222 strcpy(main_info.error_str, "Error loading 'splash.smp', aborting...\n");
2225 if (dj_load_sfx(handle, 0, dat_filelen("splash.smp", datfile_name), DJ_SFX_TYPE_SMP, SFX_SPLASH) != 0) {
2226 strcpy(main_info.error_str, "Error loading 'splash.smp', aborting...\n");
2231 if ((handle = dat_open("fly.smp", datfile_name, "rb")) == 0) {
2232 strcpy(main_info.error_str, "Error loading 'fly.smp', aborting...\n");
2235 if (dj_load_sfx(handle, 0, dat_filelen("fly.smp", datfile_name), DJ_SFX_TYPE_SMP, SFX_FLY) != 0) {
2236 strcpy(main_info.error_str, "Error loading 'fly.smp', aborting...\n");
2241 dj_get_sfx_settings(SFX_FLY, &fly);
2243 fly.default_freq = SFX_FLY_FREQ;
2246 fly.loop_length = fly.length;
2247 dj_set_sfx_settings(SFX_FLY, &fly);
2252 if ((handle = dat_open("menu.pcx", datfile_name, "rb")) == 0) {
2253 strcpy(main_info.error_str, "Error loading 'menu.pcx', aborting...\n");
2256 if (read_pcx(handle, background_pic, 102400L, pal) != 0) {
2257 strcpy(main_info.error_str, "Error loading 'menu.pcx', aborting...\n");
2262 setpalette(0, 256, pal);
2264 if (main_info.joy_enabled == 1 && main_info.fireworks == 0) {
2268 while (c1 < 0x7fff) {
2269 if ((inportb(0x201) & 1) == 0)
2275 main_info.joy_enabled = 1;
2277 put_text(0, 200, 40, "JOYSTICK CALIBRATION", 2);
2278 put_text(0, 200, 100, "Move the joystick to the", 2);
2279 put_text(0, 200, 115, "UPPER LEFT", 2);
2280 put_text(0, 200, 130, "and press button A", 2);
2281 put_text(0, 200, 200, "Or press ESC to use", 2);
2282 put_text(0, 200, 215, "previous settings", 2);
2283 if (calib_joy(0) != 0)
2287 outportw(0x3c4, 0x0f02);
2288 memset((char *) (0xa0000 + 32768 + __djgpp_conventional_base), 0, 32768);
2290 memset((char *) get_vgaptr(1, 0, 0), 0, JNB_WIDTH * JNB_HEIGHT);
2293 main_info.view_page = 1;
2295 outportw(0x3d4, (1 << 23) + 0x0d);
2296 outportw(0x3d4, ((1 << 15) & 0xff00) + 0x0c);
2298 flippage(main_info.view_page);
2302 put_text(1, 200, 40, "JOYSTICK CALIBRATION", 2);
2303 put_text(1, 200, 100, "Move the joystick to the", 2);
2304 put_text(1, 200, 115, "LOWER RIGHT", 2);
2305 put_text(1, 200, 130, "and press button A", 2);
2306 put_text(1, 200, 200, "Or press ESC to use", 2);
2307 put_text(1, 200, 215, "previous settings", 2);
2308 if (calib_joy(1) != 0)
2312 outportw(0x3c4, 0x0f02);
2313 memset((char *) (0xa0000 + __djgpp_conventional_base), 0, 32768);
2314 outportw(0x3d4, (0 << 23) + 0x0d);
2315 outportw(0x3d4, ((0 << 15) & 0xff00) + 0x0c);
2319 put_text(0, 200, 40, "JOYSTICK CALIBRATION", 2);
2320 put_text(0, 200, 100, "Move the joystick to the", 2);
2321 put_text(0, 200, 115, "CENTER", 2);
2322 put_text(0, 200, 130, "and press button A", 2);
2323 put_text(0, 200, 200, "Or press ESC to use", 2);
2324 put_text(0, 200, 215, "previous settings", 2);
2325 if (calib_joy(2) != 0)
2328 if (joy.calib_data.x1 == joy.calib_data.x2)
2329 joy.calib_data.x1 -= 10;
2330 if (joy.calib_data.x3 == joy.calib_data.x2)
2331 joy.calib_data.x3 += 10;
2332 if (joy.calib_data.y1 == joy.calib_data.y2)
2333 joy.calib_data.y1 -= 10;
2334 if (joy.calib_data.y3 == joy.calib_data.y2)
2335 joy.calib_data.y3 += 10;
2340 if (load_flag == 1) {
2341 if ((handle = dat_open("calib.dat", datfile_name, "rb")) == 0) {
2342 strcpy(main_info.error_str, "Error loading 'calib.dat', aborting...\n");
2345 joy.calib_data.x1 = fgetc(handle) + (fgetc(handle) << 8) + (fgetc(handle) << 16) + (fgetc(handle) << 24);
2346 joy.calib_data.x2 = fgetc(handle) + (fgetc(handle) << 8) + (fgetc(handle) << 16) + (fgetc(handle) << 24);
2347 joy.calib_data.x3 = fgetc(handle) + (fgetc(handle) << 8) + (fgetc(handle) << 16) + (fgetc(handle) << 24);
2348 joy.calib_data.y1 = fgetc(handle) + (fgetc(handle) << 8) + (fgetc(handle) << 16) + (fgetc(handle) << 24);
2349 joy.calib_data.y2 = fgetc(handle) + (fgetc(handle) << 8) + (fgetc(handle) << 16) + (fgetc(handle) << 24);
2350 joy.calib_data.y3 = fgetc(handle) + (fgetc(handle) << 8) + (fgetc(handle) << 16) + (fgetc(handle) << 24);
2354 main_info.joy_enabled = 0;
2359 __dpmi_int(0x33, ®s);
2360 if (regs.x.ax == 0xffff) {
2361 main_info.mouse_enabled = 1;
2362 main_info.num_mouse_buttons = regs.x.bx;
2364 main_info.num_mouse_buttons = 2;
2366 main_info.num_mouse_buttons = 3;
2369 main_info.mouse_enabled = 0;
2376 void deinit_program(void)
2383 dj_free_mod(MOD_MENU);
2384 dj_free_mod(MOD_GAME);
2385 dj_free_sfx(SFX_DEATH);
2386 dj_free_sfx(SFX_SPRING);
2387 dj_free_sfx(SFX_SPLASH);
2390 if (rabbit_gobs != 0)
2392 if (object_gobs != 0)
2394 if (number_gobs != 0)
2397 if (main_info.pob_backbuf[0] != 0)
2398 free(main_info.pob_backbuf[0]);
2399 if (main_info.pob_backbuf[1] != 0)
2400 free(main_info.pob_backbuf[1]);
2402 if (background_pic != 0)
2403 free(background_pic);
2407 remove_keyb_handler();
2411 __dpmi_int(0x10, ®s);
2414 if (main_info.error_str[0] != 0) {
2415 printf(main_info.error_str);
2430 c1 = x = y = flag = 0;
2438 s1 = inportb(0x201);
2449 if (x != 0 && y != 0)
2464 if (joy.raw_x < joy.calib_data.x2)
2465 joy.x = ((long) (joy.raw_x - joy.calib_data.x2) << 10) / (joy.calib_data.x2 - joy.calib_data.x1);
2467 joy.x = ((long) (joy.raw_x - joy.calib_data.x2) << 10) / (joy.calib_data.x3 - joy.calib_data.x2);
2468 if (joy.raw_y < joy.calib_data.y2)
2469 joy.y = ((long) (joy.raw_y - joy.calib_data.y2) << 10) / (joy.calib_data.y2 - joy.calib_data.y1);
2471 joy.y = ((long) (joy.raw_y - joy.calib_data.y2) << 10) / (joy.calib_data.y3 - joy.calib_data.y2);
2483 s1 = inportb(0x201);
2485 joy.but1 = (((s1 >> 4) & 1) ^ 1);
2486 joy.but2 = (((s1 >> 5) & 1) ^ 1);
2488 joy.raw_x = joy.calib_data.x2;
2489 joy.raw_y = joy.calib_data.y2;
2493 joy.but1 = joy.but2 = 0;
2499 char calib_joy(char type)
2507 while (joy.but1 == 1) {
2509 s1 = inportb(0x201);
2511 joy.but1 = (((s1 >> 4) & 1) ^ 1);
2512 if (key_pressed(1) == 1) {
2513 while (key_pressed(1) == 1);
2520 while (joy.but1 == 0) {
2522 c1 = x = y = flag = 0;
2530 s1 = inportb(0x201);
2541 if (x != 0 && y != 0)
2556 s1 = inportb(0x201);
2558 joy.but1 = (((s1 >> 4) & 1) ^ 1);
2560 if (num_times < 0x7fffffff)
2566 if (key_pressed(1) == 1) {
2567 while (key_pressed(1) == 1);
2580 joy.calib_data.x1 = joy.raw_x;
2581 joy.calib_data.y1 = joy.raw_y;
2584 joy.calib_data.x3 = joy.raw_x;
2585 joy.calib_data.y3 = joy.raw_y;
2588 joy.calib_data.x2 = joy.raw_x;
2589 joy.calib_data.y2 = joy.raw_y;
2593 while (joy.but1 == 1) {
2595 s1 = inportb(0x201);
2597 joy.but1 = (((s1 >> 4) & 1) ^ 1);
2607 void read_mouse(void)
2612 __dpmi_int(0x33, ®s);
2613 mouse.but1 = regs.x.bx & 1;
2614 mouse.but2 = (regs.x.bx & 2) >> 1;
2615 mouse.but3 = (regs.x.bx & 4) >> 2;
2621 unsigned short rnd(unsigned short max)
2623 return (rand() % max);
2627 char read_level(void)
2633 if ((handle = dat_open("levelmap.txt", datfile_name, "rb")) == 0) {
2634 strcpy(main_info.error_str, "Error loading 'levelmap.txt', aborting...\n");
2638 for (c1 = 0; c1 < 16; c1++) {
2639 for (c2 = 0; c2 < 22; c2++) {
2641 chr = fgetc(handle);
2646 if (chr >= '0' && chr <= '4')
2649 ban_map[c1][c2] = chr - '0';
2653 for (c2 = 0; c2 < 22; c2++)
2654 ban_map[16][c2] = 1;
2662 FILE *dat_open(char *file_name, char *dat_name, char *mode)
2670 if ((handle = fopen(dat_name, mode)) == NULL)
2673 num = fgetc(handle) + (fgetc(handle) << 8) + (fgetc(handle) << 16) + (fgetc(handle) << 24);
2674 for (c1 = 0; c1 < num; c1++) {
2675 fread(name, 1, 12, handle);
2676 if (strnicmp(name, file_name, strlen(file_name)) == 0) {
2677 ofs = fgetc(handle) + (fgetc(handle) << 8) + (fgetc(handle) << 16) + (fgetc(handle) << 24);
2678 fseek(handle, ofs, SEEK_SET);
2681 fseek(handle, 8, SEEK_CUR);
2688 int dat_filelen(char *file_name, char *dat_name)
2696 if ((handle = fopen(dat_name, "rb")) == NULL)
2699 num = fgetc(handle) + (fgetc(handle) << 8) + (fgetc(handle) << 16) + (fgetc(handle) << 24);
2701 for (c1 = 0; c1 < num; c1++) {
2702 fread(name, 1, 12, handle);
2703 if (strnicmp(name, file_name, strlen(file_name)) == 0) {
2704 fseek(handle, 4, SEEK_CUR);
2705 len = fgetc(handle) + (fgetc(handle) << 8) + (fgetc(handle) << 16) + (fgetc(handle) << 24);
2710 fseek(handle, 8, SEEK_CUR);
2717 void write_calib_data(void)
2725 if ((handle = fopen(datfile_name, "rb")) == NULL)
2727 len = filelength(fileno(handle));
2728 if ((mem = malloc(len)) == NULL)
2730 fread(mem, 1, len, handle);
2734 num = *(int *) (&mem[0]);
2735 for (c1 = 0; c1 < num; c1++) {
2736 if (strnicmp(&mem[ofs], "calib.dat", strlen("calib.dat")) == 0) {
2737 ofs = *(int *) (&mem[ofs + 12]);
2743 mem[ofs] = joy.calib_data.x1 & 0xff;
2744 mem[ofs + 1] = (joy.calib_data.x1 >> 8) & 0xff;
2745 mem[ofs + 2] = (joy.calib_data.x1 >> 16) & 0xff;
2746 mem[ofs + 3] = (joy.calib_data.x1 >> 24) & 0xff;
2747 mem[ofs + 4] = joy.calib_data.x2 & 0xff;
2748 mem[ofs + 5] = (joy.calib_data.x2 >> 8) & 0xff;
2749 mem[ofs + 6] = (joy.calib_data.x2 >> 16) & 0xff;
2750 mem[ofs + 7] = (joy.calib_data.x2 >> 24) & 0xff;
2751 mem[ofs + 8] = joy.calib_data.x3 & 0xff;
2752 mem[ofs + 9] = (joy.calib_data.x3 >> 8) & 0xff;
2753 mem[ofs + 10] = (joy.calib_data.x3 >> 16) & 0xff;
2754 mem[ofs + 11] = (joy.calib_data.x3 >> 24) & 0xff;
2755 mem[ofs + 12] = joy.calib_data.y1 & 0xff;
2756 mem[ofs + 13] = (joy.calib_data.y1 >> 8) & 0xff;
2757 mem[ofs + 14] = (joy.calib_data.y1 >> 16) & 0xff;
2758 mem[ofs + 15] = (joy.calib_data.y1 >> 24) & 0xff;
2759 mem[ofs + 16] = joy.calib_data.y2 & 0xff;
2760 mem[ofs + 17] = (joy.calib_data.y2 >> 8) & 0xff;
2761 mem[ofs + 18] = (joy.calib_data.y2 >> 16) & 0xff;
2762 mem[ofs + 19] = (joy.calib_data.y2 >> 24) & 0xff;
2763 mem[ofs + 20] = joy.calib_data.y3 & 0xff;
2764 mem[ofs + 21] = (joy.calib_data.y3 >> 8) & 0xff;
2765 mem[ofs + 22] = (joy.calib_data.y3 >> 16) & 0xff;
2766 mem[ofs + 23] = (joy.calib_data.y3 >> 24) & 0xff;
2768 if ((handle = fopen(datfile_name, "wb")) == NULL)
2770 fwrite(mem, 1, len, handle);