12 unsigned int ban_map[17][22] = {
13 {1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
14 {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0},
15 {1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0},
16 {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1},
17 {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1},
18 {1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
19 {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1},
20 {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1},
21 {1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1},
22 {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 0, 0, 0, 1},
23 {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1},
24 {1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1},
25 {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
26 {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1},
27 {2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 0, 0, 0, 0, 0, 1, 3, 3, 3, 1, 1, 1},
28 {2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
29 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
158 char back[2], back_defined[2];
168 } pobs[NUM_LEFTOVERS];
172 char pogostick, bunnies_in_space, jetpack, lord_of_the_flies, blood_is_thicker_than_water;
175 char main(int argc, char *argv[])
181 int closest_player, dist, cur_dist;
182 char end_loop_flag, fade_flag;
183 char mod_vol, sfx_vol, mod_fade_direction;
187 if (init_program(argc, argv) != 0)
190 if (main_info.fireworks == 1) {
200 if (key_pressed(1) == 1)
203 if (init_level(0) != 0) {
209 for (c1 = 0; c1 < 768; c1++)
210 outportb(0x3c9, cur_pal[c1]);
212 for (c1 = 0; c1 < 4; c1++) {
213 outportw(0x3c4, ((1 << c1) << 8) + 0x02);
215 for (l2 = 0; l2 < 25600; l2++) {
216 *(char *) (0xa0000 + l2 + __djgpp_conventional_base) = *(char *) (background_pic + l1);
217 *(char *) (0xa0000 + 32768 + l2 + __djgpp_conventional_base) = *(char *) (background_pic + l1);
224 for (c1 = 0; c1 < NUM_FLIES; c1++) {
226 flies[c1].x = s1 + rnd(101) - 50;
227 flies[c1].y = s2 + rnd(101) - 50;
228 if (ban_map[flies[c1].y >> 4][flies[c1].x >> 4] == 0)
231 flies[c1].back_defined[0] = 0;
232 flies[c1].back_defined[1] = 0;
235 mod_vol = sfx_vol = 10;
236 mod_fade_direction = 1;
237 dj_ready_mod(MOD_GAME);
238 dj_set_mod_volume(mod_vol);
239 dj_set_sfx_volume(mod_vol);
241 dj_play_sfx(SFX_FLY, SFX_FLY_FREQ, 0, 0, 0, 4);
244 lord_of_the_flies = bunnies_in_space = jetpack = pogostick = blood_is_thicker_than_water = 0;
246 main_info.page_info[0].num_pobs = 0;
247 main_info.page_info[1].num_pobs = 0;
248 main_info.view_page = 0;
249 main_info.draw_page = 1;
253 if (key_pressed(1) == 1) {
256 mod_fade_direction = 0;
259 if (strncmp(last_keys, "kcitsogop", strlen("kcitsogop")) == 0) {
263 if (strncmp(last_keys, "ecapsniseinnub", strlen("ecapsniseinnub")) == 0) {
264 bunnies_in_space ^= 1;
267 if (strncmp(last_keys, "kcaptej", strlen("kcaptej")) == 0) {
271 if (strncmp(last_keys, "seilfehtfodrol", strlen("seilfehtfodrol")) == 0) {
272 lord_of_the_flies ^= 1;
275 if (strncmp(last_keys, "retawnahtrekcihtsidoolb", strlen("retawnahtrekcihtsidoolb")) == 0) {
276 blood_is_thicker_than_water ^= 1;
277 if (blood_is_thicker_than_water == 1) {
335 for (c3 = 0; c3 < 6; c3++) {
339 } else if (c3 == 1) {
342 } else if (c3 == 2) {
345 } else if (c3 == 3) {
348 } else if (c3 == 4) {
351 } else if (c3 == 5) {
355 if (player[c1].enabled == 1 && player[c2].enabled == 1) {
356 if (labs(player[c1].x - player[c2].x) < (12L << 16) && labs(player[c1].y - player[c2].y) < (12L << 16)) {
357 if ((labs(player[c1].y - player[c2].y) >> 16) > 5) {
358 if (player[c1].y < player[c2].y) {
359 if (player[c1].y_add >= 0) {
360 player[c1].y_add = -player[c1].y_add;
361 if (player[c1].y_add > -262144L)
362 player[c1].y_add = -262144L;
363 player[c1].jump_abort = 1;
364 player[c2].dead_flag = 1;
365 if (player[c2].anim != 6) {
367 player[c2].frame = 0;
368 player[c2].frame_tick = 0;
369 player[c2].image = player_anims[player[c2].anim].frame[player[c2].frame].image + player[c2].direction * 9;
370 if (main_info.no_gore == 0) {
371 for (c4 = 0; c4 < 6; c4++)
372 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);
373 for (c4 = 0; c4 < 6; c4++)
374 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);
375 for (c4 = 0; c4 < 6; c4++)
376 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);
377 for (c4 = 0; c4 < 8; c4++)
378 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);
379 for (c4 = 0; c4 < 10; c4++)
380 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);
382 dj_play_sfx(SFX_DEATH, SFX_DEATH_FREQ + rnd(2000) - 1000, 64, 0, 0, -1);
384 player[c1].bumped[c2]++;
385 s1 = player[c1].bumps % 100;
386 add_leftovers(0, 360, 34 + c1 * 64, s1 / 10, number_gobs);
387 add_leftovers(1, 360, 34 + c1 * 64, s1 / 10, number_gobs);
388 add_leftovers(0, 376, 34 + c1 * 64, s1 - (s1 / 10) * 10, number_gobs);
389 add_leftovers(1, 376, 34 + c1 * 64, s1 - (s1 / 10) * 10, number_gobs);
392 if (player[c2].y_add < 0)
393 player[c2].y_add = 0;
396 if (player[c2].y_add >= 0) {
397 player[c2].y_add = -player[c2].y_add;
398 if (player[c2].y_add > -262144L)
399 player[c2].y_add = -262144L;
400 player[c2].jump_abort = 1;
401 player[c1].dead_flag = 1;
402 if (player[c1].anim != 6) {
404 player[c1].frame = 0;
405 player[c1].frame_tick = 0;
406 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
407 if (main_info.no_gore == 0) {
408 for (c4 = 0; c4 < 6; c4++)
409 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);
410 for (c4 = 0; c4 < 6; c4++)
411 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);
412 for (c4 = 0; c4 < 7; c4++)
413 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);
414 for (c4 = 0; c4 < 8; c4++)
415 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);
416 for (c4 = 0; c4 < 10; c4++)
417 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);
419 dj_play_sfx(SFX_DEATH, SFX_DEATH_FREQ + rnd(2000) - 1000, 64, 0, 0, -1);
421 player[c2].bumped[c1]++;
422 s1 = player[c2].bumps % 100;
423 add_leftovers(0, 360, 34 + c2 * 64, s1 / 10, number_gobs);
424 add_leftovers(1, 360, 34 + c2 * 64, s1 / 10, number_gobs);
425 add_leftovers(0, 376, 34 + c2 * 64, s1 - (s1 / 10) * 10, number_gobs);
426 add_leftovers(1, 376, 34 + c2 * 64, s1 - (s1 / 10) * 10, number_gobs);
429 if (player[c1].y_add < 0)
430 player[c1].y_add = 0;
434 if (player[c1].x < player[c2].x) {
435 if (player[c1].x_add > 0)
436 player[c1].x = player[c2].x - (12L << 16);
437 else if (player[c2].x_add < 0)
438 player[c2].x = player[c1].x + (12L << 16);
440 player[c1].x -= player[c1].x_add;
441 player[c2].x -= player[c2].x_add;
443 l1 = player[c2].x_add;
444 player[c2].x_add = player[c1].x_add;
445 player[c1].x_add = l1;
446 if (player[c1].x_add > 0)
447 player[c1].x_add = -player[c1].x_add;
448 if (player[c2].x_add < 0)
449 player[c2].x_add = -player[c2].x_add;
451 if (player[c1].x_add > 0)
452 player[c2].x = player[c1].x - (12L << 16);
453 else if (player[c2].x_add < 0)
454 player[c1].x = player[c2].x + (12L << 16);
456 player[c1].x -= player[c1].x_add;
457 player[c2].x -= player[c2].x_add;
459 l1 = player[c2].x_add;
460 player[c2].x_add = player[c1].x_add;
461 player[c1].x_add = l1;
462 if (player[c1].x_add < 0)
463 player[c1].x_add = -player[c1].x_add;
464 if (player[c2].x_add > 0)
465 player[c2].x_add = -player[c2].x_add;
474 main_info.page_info[main_info.draw_page].num_pobs = 0;
475 for (c1 = 0; c1 < 4; c1++) {
476 if (player[c1].enabled == 1)
477 main_info.page_info[main_info.draw_page].num_pobs++;
485 for (c1 = 0; c1 < NUM_FLIES; c1++) {
493 for (c1 = 0; c1 < 4; c1++) {
494 if (player[c1].enabled == 1) {
495 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)));
496 if (cur_dist < dist) {
505 dj_set_sfx_channel_volume(4, s3);
507 for (c1 = 0; c1 < NUM_FLIES; c1++) {
509 for (c2 = 0; c2 < 4; c2++) {
510 if (player[c2].enabled == 1) {
511 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)));
512 if (cur_dist < dist) {
518 flies[c1].old_x = flies[c1].x;
519 flies[c1].old_y = flies[c1].y;
521 if ((s1 - flies[c1].x) > 30)
523 else if ((s1 - flies[c1].x) < -30)
526 if (((player[closest_player].x >> 16) + 8) > flies[c1].x) {
527 if (lord_of_the_flies == 0)
532 if (lord_of_the_flies == 0)
538 s4 = rnd(3) - 1 + s3;
539 if ((flies[c1].x + s4) < 16)
541 if ((flies[c1].x + s4) > 351)
543 if (ban_map[flies[c1].y >> 4][(flies[c1].x + s4) >> 4] != 0)
547 if ((s2 - flies[c1].y) > 30)
549 else if ((s2 - flies[c1].y) < -30)
552 if (((player[closest_player].y >> 16) + 8) > flies[c1].y) {
553 if (lord_of_the_flies == 0)
558 if (lord_of_the_flies == 0)
564 s4 = rnd(3) - 1 + s3;
565 if ((flies[c1].y + s4) < 0)
567 if ((flies[c1].y + s4) > 239)
569 if (ban_map[(flies[c1].y + s4) >> 4][flies[c1].x >> 4] != 0)
577 for (c1 = 0; c1 < 4; c1++) {
578 if (player[c1].enabled == 1) {
579 main_info.page_info[main_info.draw_page].pobs[s1].x = player[c1].x >> 16;
580 main_info.page_info[main_info.draw_page].pobs[s1].y = player[c1].y >> 16;
581 main_info.page_info[main_info.draw_page].pobs[s1].image = player[c1].image + c1 * 18;
582 main_info.page_info[main_info.draw_page].pobs[s1].pob_data = rabbit_gobs;
587 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 if (mod_fade_direction == 1) {
608 dj_set_mod_volume(mod_vol);
613 dj_set_mod_volume(mod_vol);
617 if (mod_fade_direction == 1) {
620 dj_set_sfx_volume(sfx_vol);
625 dj_set_sfx_volume(sfx_vol);
630 for (c1 = 0; c1 < 768; c1++) {
631 if (cur_pal[c1] < pal[c1]) {
634 } else if (cur_pal[c1] > pal[c1]) {
639 if (fade_flag == 0 && end_loop_flag == 1)
642 main_info.draw_page ^= 1;
643 main_info.view_page ^= 1;
645 outportw(0x3d4, (main_info.view_page << 23) + 0x0d);
646 outportw(0x3d4, ((main_info.view_page << 15) & 0xff00) + 0x0c);
648 while ((inportb(0x3da) & 8) == 0)
650 while ((inportb(0x3da) & 8) == 8)
653 if (fade_flag == 1) {
655 for (c1 = 0; c1 < 768; c1++)
656 outportb(0x3c9, cur_pal[c1]);
659 ptr1 = (char *) (0xa0000 + ((long) main_info.draw_page << 15) - __djgpp_base_address);
660 for (c1 = 0; c1 < 4; c1++) {
661 outportw(0x3c4, ((1 << c1) << 8) + 0x02);
662 for (c2 = NUM_FLIES - 1; c2 >= 0; c2--) {
663 if ((flies[c2].old_x & 3) == c1 && flies[c2].back_defined[main_info.draw_page] == 1)
664 *(char *) (ptr1 + flies[c2].old_y * 100 + (flies[c2].old_x >> 2)) = flies[c2].back[main_info.draw_page];
668 redraw_pob_backgrounds(main_info.draw_page);
670 draw_leftovers(main_info.draw_page);
674 dj_stop_sfx_channel(4);
678 memset(mask_pic, 0, 102400L);
680 outportw(0x3c4, 0x0f02);
681 memset((char *) (0xa0000 + (long) (main_info.view_page << 15) + __djgpp_conventional_base), 0, 32768);
682 put_text(main_info.view_page, 100, 50, "DOTT", 2);
683 put_text(main_info.view_page, 160, 50, "JIFFY", 2);
684 put_text(main_info.view_page, 220, 50, "FIZZ", 2);
685 put_text(main_info.view_page, 280, 50, "MIJJI", 2);
686 put_text(main_info.view_page, 40, 80, "DOTT", 2);
687 put_text(main_info.view_page, 40, 110, "JIFFY", 2);
688 put_text(main_info.view_page, 40, 140, "FIZZ", 2);
689 put_text(main_info.view_page, 40, 170, "MIJJI", 2);
690 for (c1 = 0; c1 < 4; c1++) {
691 for (c2 = 0; c2 < 4; c2++) {
693 itoa(player[c1].bumped[c2], str1, 10);
694 put_text(main_info.view_page, 100 + c2 * 60, 80 + c1 * 30, str1, 2);
696 put_text(main_info.view_page, 100 + c2 * 60, 80 + c1 * 30, "-", 2);
698 itoa(player[c1].bumps, str1, 10);
699 put_text(main_info.view_page, 350, 80 + c1 * 30, str1, 2);
701 put_text(main_info.view_page, 200, 230, "Press ESC to continue", 2);
703 if ((handle = dat_open("menu.pcx", datfile_name, "rb")) == 0) {
704 strcpy(main_info.error_str, "Error loading 'menu.pcx', aborting...\n");
707 if (read_pcx(handle, background_pic, 102400L, pal) != 0) {
708 strcpy(main_info.error_str, "Error loading 'menu.pcx', aborting...\n");
713 memset(cur_pal, 0, 768);
716 for (c1 = 0; c1 < 768; c1++)
717 outportb(0x3c9, cur_pal[c1]);
720 dj_ready_mod(MOD_SCORES);
721 dj_set_mod_volume(mod_vol);
725 while (key_pressed(1) == 0) {
728 dj_set_mod_volume(mod_vol);
729 for (c1 = 0; c1 < 768; c1++) {
730 if (cur_pal[c1] < pal[c1])
736 for (c1 = 0; c1 < 768; c1++)
737 outportb(0x3c9, cur_pal[c1]);
739 while (key_pressed(1) == 1)
744 while (mod_vol > 0) {
746 dj_set_mod_volume(mod_vol);
747 for (c1 = 0; c1 < 768; c1++) {
748 if (cur_pal[c1] > pal[c1])
754 for (c1 = 0; c1 < 768; c1++)
755 outportb(0x3c9, cur_pal[c1]);
759 for (c1 = 0; c1 < 768; c1++)
772 void steer_players(void)
777 if (main_info.mouse_enabled == 1)
779 if (main_info.joy_enabled == 1)
782 for (c1 = 0; c1 < 4; c1++) {
784 if (player[c1].enabled == 1) {
786 if (player[c1].dead_flag == 0) {
788 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 && ((joy.x < -512 && joy.x > 512))) || (c1 == 3 && ((mouse.but1 == 1 && mouse.but2 == 1)))) {
789 if (player[c1].direction == 0) {
790 if ((c1 == 0 && key_pressed(KEY_PL1_RIGHT) == 1) || (c1 == 1 && key_pressed(KEY_PL2_RIGHT) == 1) || (c1 == 2 && joy.x > 512) || (c1 == 3 && mouse.but2 == 1)) {
791 s1 = (player[c1].x >> 16);
792 s2 = (player[c1].y >> 16);
793 if (ban_map[(s2 + 16) >> 4][(s1 + 8) >> 4] == 3) {
794 if (player[c1].x_add < 0)
795 player[c1].x_add += 1024;
797 player[c1].x_add += 768;
798 } 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)) {
799 if (player[c1].x_add > 0)
800 player[c1].x_add += 1024;
802 player[c1].x_add += 768;
804 if (player[c1].x_add < 0) {
805 player[c1].x_add += 16384;
806 if (player[c1].x_add < 98304L && player[c1].in_water == 0 && ban_map[(s2 + 16) >> 4][(s1 + 8) >> 4] == 1)
807 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);
809 player[c1].x_add += 12288;
811 if (player[c1].x_add > 98304L)
812 player[c1].x_add = 98304L;
813 player[c1].direction = 0;
814 if (player[c1].anim == 0) {
816 player[c1].frame = 0;
817 player[c1].frame_tick = 0;
818 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
822 if ((c1 == 0 && key_pressed(KEY_PL1_LEFT) == 1) || (c1 == 1 && key_pressed(KEY_PL2_LEFT) == 1) || (c1 == 2 && joy.x < -512) || (c1 == 3 && mouse.but1 == 1)) {
823 s1 = (player[c1].x >> 16);
824 s2 = (player[c1].y >> 16);
825 if (ban_map[(s2 + 16) >> 4][(s1 + 8) >> 4] == 3) {
826 if (player[c1].x_add > 0)
827 player[c1].x_add -= 1024;
829 player[c1].x_add -= 768;
830 } 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)) {
831 if (player[c1].x_add > 0)
832 player[c1].x_add -= 1024;
834 player[c1].x_add -= 768;
836 if (player[c1].x_add > 0) {
837 player[c1].x_add -= 16384;
838 if (player[c1].x_add > -98304L && player[c1].in_water == 0 && ban_map[(s2 + 16) >> 4][(s1 + 8) >> 4] == 1)
839 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);
841 player[c1].x_add -= 12288;
843 if (player[c1].x_add < -98304L)
844 player[c1].x_add = -98304L;
845 player[c1].direction = 1;
846 if (player[c1].anim == 0) {
848 player[c1].frame = 0;
849 player[c1].frame_tick = 0;
850 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
854 } else if ((c1 == 0 && key_pressed(KEY_PL1_LEFT) == 1) || (c1 == 1 && key_pressed(KEY_PL2_LEFT) == 1) || (c1 == 2 && joy.x < -512) || (c1 == 3 && mouse.but1 == 1)) {
855 s1 = (player[c1].x >> 16);
856 s2 = (player[c1].y >> 16);
857 if (ban_map[(s2 + 16) >> 4][(s1 + 8) >> 4] == 3) {
858 if (player[c1].x_add > 0)
859 player[c1].x_add -= 1024;
861 player[c1].x_add -= 768;
862 } 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)) {
863 if (player[c1].x_add > 0)
864 player[c1].x_add -= 1024;
866 player[c1].x_add -= 768;
868 if (player[c1].x_add > 0) {
869 player[c1].x_add -= 16384;
870 if (player[c1].x_add > -98304L && player[c1].in_water == 0 && ban_map[(s2 + 16) >> 4][(s1 + 8) >> 4] == 1)
871 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);
873 player[c1].x_add -= 12288;
875 if (player[c1].x_add < -98304L)
876 player[c1].x_add = -98304L;
877 player[c1].direction = 1;
878 if (player[c1].anim == 0) {
880 player[c1].frame = 0;
881 player[c1].frame_tick = 0;
882 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
884 } else if ((c1 == 0 && key_pressed(KEY_PL1_RIGHT) == 1) || (c1 == 1 && key_pressed(KEY_PL2_RIGHT) == 1) || (c1 == 2 && joy.x > 512) || (c1 == 3 && mouse.but2 == 1)) {
885 s1 = (player[c1].x >> 16);
886 s2 = (player[c1].y >> 16);
887 if (ban_map[(s2 + 16) >> 4][(s1 + 8) >> 4] == 3) {
888 if (player[c1].x_add < 0)
889 player[c1].x_add += 1024;
891 player[c1].x_add += 768;
892 } 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)) {
893 if (player[c1].x_add > 0)
894 player[c1].x_add += 1024;
896 player[c1].x_add += 768;
898 if (player[c1].x_add < 0) {
899 player[c1].x_add += 16384;
900 if (player[c1].x_add < 98304L && player[c1].in_water == 0 && ban_map[(s2 + 16) >> 4][(s1 + 8) >> 4] == 1)
901 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);
903 player[c1].x_add += 12288;
905 if (player[c1].x_add > 98304L)
906 player[c1].x_add = 98304L;
907 player[c1].direction = 0;
908 if (player[c1].anim == 0) {
910 player[c1].frame = 0;
911 player[c1].frame_tick = 0;
912 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
914 } 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 && ((joy.x >= -512 && joy.x <= 512))) || (c1 == 3 && ((mouse.but1 == 0 && mouse.but2 == 0)))) {
915 s1 = (player[c1].x >> 16);
916 s2 = (player[c1].y >> 16);
917 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)))) {
918 if (player[c1].x_add < 0) {
919 player[c1].x_add += 16384;
920 if (player[c1].x_add > 0)
921 player[c1].x_add = 0;
923 player[c1].x_add -= 16384;
924 if (player[c1].x_add < 0)
925 player[c1].x_add = 0;
927 if (player[c1].x_add != 0 && ban_map[(s2 + 16) >> 4][(s1 + 8) >> 4] == 1)
928 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);
930 if (player[c1].anim == 1) {
932 player[c1].frame = 0;
933 player[c1].frame_tick = 0;
934 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
938 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 && joy.but1 == 1) || (c1 == 3 && ((main_info.num_mouse_buttons == 2 && mouse.but1 == 1 && mouse.but2 == 1) || (main_info.num_mouse_buttons == 3 && mouse.but3 == 1)))))) {
939 s1 = (player[c1].x >> 16);
940 s2 = (player[c1].y >> 16);
943 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) {
944 player[c1].y_add = -280000L;
946 player[c1].frame = 0;
947 player[c1].frame_tick = 0;
948 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
949 player[c1].jump_ready = 0;
950 player[c1].jump_abort = 1;
952 dj_play_sfx(SFX_JUMP, SFX_JUMP_FREQ + rnd(2000) - 1000, 64, 0, 0, -1);
954 dj_play_sfx(SFX_SPRING, SFX_SPRING_FREQ + rnd(2000) - 1000, 64, 0, 0, -1);
956 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)) {
957 player[c1].y_add = -196608L;
958 player[c1].in_water = 0;
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;
963 player[c1].jump_ready = 0;
964 player[c1].jump_abort = 1;
966 dj_play_sfx(SFX_JUMP, SFX_JUMP_FREQ + rnd(2000) - 1000, 64, 0, 0, -1);
968 dj_play_sfx(SFX_SPRING, SFX_SPRING_FREQ + rnd(2000) - 1000, 64, 0, 0, -1);
971 if (pogostick == 0 && ((c1 == 0 && key_pressed(KEY_PL1_JUMP) == 0) || (c1 == 1 && key_pressed(KEY_PL2_JUMP) == 0) || (c1 == 2 && joy.but1 == 0) || (c1 == 3 && ((main_info.num_mouse_buttons == 2 && (mouse.but1 == 0 && mouse.but2 == 0)) || (main_info.num_mouse_buttons == 3 && mouse.but3 == 0))))) {
972 player[c1].jump_ready = 1;
973 if (player[c1].in_water == 0 && player[c1].y_add < 0 && player[c1].jump_abort == 1) {
974 if (bunnies_in_space == 0)
975 player[c1].y_add += 32768;
977 player[c1].y_add += 16384;
978 if (player[c1].y_add > 0)
979 player[c1].y_add = 0;
982 if (c1 == 3 && main_info.num_mouse_buttons == 2 && (mouse.but1 == 0 || mouse.but2 == 0))
983 player[c1].jump_ready = 1;
987 if (((c1 == 0 && key_pressed(KEY_PL1_JUMP) == 1) || (c1 == 1 && key_pressed(KEY_PL2_JUMP) == 1) || (c1 == 2 && joy.but1 == 1) || (c1 == 3 && mouse.but3 == 1))) {
988 player[c1].y_add -= 16384;
989 if (player[c1].y_add < -400000L)
990 player[c1].y_add = -400000L;
991 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))
992 player[c1].in_water = 0;
994 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);
999 player[c1].x += player[c1].x_add;
1000 if ((player[c1].x >> 16) < 0) {
1002 player[c1].x_add = 0;
1004 if ((player[c1].x >> 16) + 15 > 351) {
1005 player[c1].x = 336L << 16;
1006 player[c1].x_add = 0;
1008 if (player[c1].y > 0) {
1009 s1 = (player[c1].x >> 16);
1010 s2 = (player[c1].y >> 16);
1011 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) {
1012 player[c1].x = (((s1 + 16) & 0xfff0)) << 16;
1013 player[c1].x_add = 0;
1015 s1 = (player[c1].x >> 16);
1016 s2 = (player[c1].y >> 16);
1017 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) {
1018 player[c1].x = (((s1 + 16) & 0xfff0) - 16) << 16;
1019 player[c1].x_add = 0;
1022 s1 = (player[c1].x >> 16);
1024 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) {
1025 player[c1].x = (((s1 + 16) & 0xfff0)) << 16;
1026 player[c1].x_add = 0;
1028 s1 = (player[c1].x >> 16);
1030 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) {
1031 player[c1].x = (((s1 + 16) & 0xfff0) - 16) << 16;
1032 player[c1].x_add = 0;
1036 player[c1].y += player[c1].y_add;
1038 s1 = (player[c1].x >> 16);
1039 s2 = (player[c1].y >> 16);
1040 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))) {
1041 player[c1].y = ((player[c1].y >> 16) & 0xfff0) << 16;
1042 player[c1].y_add = -400000L;
1043 player[c1].anim = 2;
1044 player[c1].frame = 0;
1045 player[c1].frame_tick = 0;
1046 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
1047 player[c1].jump_ready = 0;
1048 player[c1].jump_abort = 0;
1049 for (c2 = 0; c2 < 300; c2++) {
1050 if (objects[c2].used == 1 && objects[c2].type == OBJ_SPRING) {
1051 if (ban_map[(s2 + 15) >> 4][(s1 + 8) >> 4] == 4) {
1052 if ((objects[c2].x >> 20) == ((s1 + 8) >> 4) && (objects[c2].y >> 20) == ((s2 + 15) >> 4)) {
1053 objects[c2].frame = 0;
1054 objects[c2].ticks = object_anims[objects[c2].anim].frame[objects[c2].frame].ticks;
1055 objects[c2].image = object_anims[objects[c2].anim].frame[objects[c2].frame].image;
1059 if (ban_map[(s2 + 15) >> 4][s1 >> 4] == 4) {
1060 if ((objects[c2].x >> 20) == (s1 >> 4) && (objects[c2].y >> 20) == ((s2 + 15) >> 4)) {
1061 objects[c2].frame = 0;
1062 objects[c2].ticks = object_anims[objects[c2].anim].frame[objects[c2].frame].ticks;
1063 objects[c2].image = object_anims[objects[c2].anim].frame[objects[c2].frame].image;
1066 } else if (ban_map[(s2 + 15) >> 4][(s1 + 15) >> 4] == 4) {
1067 if ((objects[c2].x >> 20) == ((s1 + 15) >> 4) && (objects[c2].y >> 20) == ((s2 + 15) >> 4)) {
1068 objects[c2].frame = 0;
1069 objects[c2].ticks = object_anims[objects[c2].anim].frame[objects[c2].frame].ticks;
1070 objects[c2].image = object_anims[objects[c2].anim].frame[objects[c2].frame].image;
1077 dj_play_sfx(SFX_SPRING, SFX_SPRING_FREQ + rnd(2000) - 1000, 64, 0, 0, -1);
1079 s1 = (player[c1].x >> 16);
1080 s2 = (player[c1].y >> 16);
1083 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) {
1084 player[c1].y = (((s2 + 16) & 0xfff0)) << 16;
1085 player[c1].y_add = 0;
1086 player[c1].anim = 0;
1087 player[c1].frame = 0;
1088 player[c1].frame_tick = 0;
1089 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
1091 s1 = (player[c1].x >> 16);
1092 s2 = (player[c1].y >> 16);
1095 if (ban_map[(s2 + 8) >> 4][(s1 + 8) >> 4] == 2) {
1096 if (player[c1].in_water == 0) {
1097 player[c1].in_water = 1;
1098 player[c1].anim = 4;
1099 player[c1].frame = 0;
1100 player[c1].frame_tick = 0;
1101 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
1102 if (player[c1].y_add >= 32768) {
1103 add_object(OBJ_SPLASH, (player[c1].x >> 16) + 8, ((player[c1].y >> 16) & 0xfff0) + 15, 0, 0, OBJ_ANIM_SPLASH, 0);
1104 if (blood_is_thicker_than_water == 0)
1105 dj_play_sfx(SFX_SPLASH, SFX_SPLASH_FREQ + rnd(2000) - 1000, 64, 0, 0, -1);
1107 dj_play_sfx(SFX_SPLASH, SFX_SPLASH_FREQ + rnd(2000) - 5000, 64, 0, 0, -1);
1110 player[c1].y_add -= 1536;
1111 if (player[c1].y_add < 0 && player[c1].anim != 5) {
1112 player[c1].anim = 5;
1113 player[c1].frame = 0;
1114 player[c1].frame_tick = 0;
1115 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
1117 if (player[c1].y_add < -65536L)
1118 player[c1].y_add = -65536L;
1119 if (player[c1].y_add > 65535L)
1120 player[c1].y_add = 65535L;
1121 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) {
1122 player[c1].y = (((s2 + 16) & 0xfff0) - 16) << 16;
1123 player[c1].y_add = 0;
1125 } 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) {
1126 player[c1].in_water = 0;
1127 player[c1].y = (((s2 + 16) & 0xfff0) - 16) << 16;
1128 player[c1].y_add = 0;
1129 if (player[c1].anim != 0 && player[c1].anim != 1) {
1130 player[c1].anim = 0;
1131 player[c1].frame = 0;
1132 player[c1].frame_tick = 0;
1133 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
1136 if (player[c1].in_water == 0) {
1137 if (bunnies_in_space == 0)
1138 player[c1].y_add += 12288;
1140 player[c1].y_add += 6144;
1141 if (player[c1].y_add > 327680L)
1142 player[c1].y_add = 327680L;
1144 player[c1].y = (player[c1].y & 0xffff0000) + 0x10000;
1145 player[c1].y_add = 0;
1147 player[c1].in_water = 0;
1149 if (player[c1].y_add > 36864 && player[c1].anim != 3 && player[c1].in_water == 0) {
1150 player[c1].anim = 3;
1151 player[c1].frame = 0;
1152 player[c1].frame_tick = 0;
1153 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
1158 player[c1].frame_tick++;
1159 if (player[c1].frame_tick >= player_anims[player[c1].anim].frame[player[c1].frame].ticks) {
1161 if (player[c1].frame >= player_anims[player[c1].anim].num_frames) {
1162 if (player[c1].anim != 6)
1163 player[c1].frame = player_anims[player[c1].anim].restart_frame;
1165 position_player(c1);
1167 player[c1].frame_tick = 0;
1169 player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
1178 void position_player(short player_num)
1187 if (ban_map[s2][s1] == 0 && (ban_map[s2 + 1][s1] == 1 || ban_map[s2 + 1][s1] == 3))
1190 for (c1 = 0; c1 < 4; c1++) {
1191 if (c1 != player_num && player[c1].enabled == 1) {
1192 if (abs((s1 << 4) - (player[c1].x >> 16)) < 32 && abs((s2 << 4) - (player[c1].y >> 16)) < 32)
1197 player[player_num].dead_flag = 0;
1198 player[player_num].x = (long) s1 << 20;
1199 player[player_num].y = (long) s2 << 20;
1200 player[player_num].x_add = player[player_num].y_add = 0;
1201 player[player_num].direction = 0;
1202 player[player_num].jump_ready = 1;
1203 player[player_num].in_water = 0;
1204 player[player_num].anim = 0;
1205 player[player_num].frame = 0;
1206 player[player_num].frame_tick = 0;
1207 player[player_num].image = player_anims[player[player_num].anim].frame[player[player_num].frame].image;
1215 void fireworks(void)
1221 char used, direction, colour;
1225 int anim, frame, frame_tick, image;
1233 outportw(0x3c4, 0x0f02);
1234 memset((char *) (0xa0000 - __djgpp_base_address), 0, 65535);
1236 if ((handle = dat_open("level.pcx", datfile_name, "rb")) == 0) {
1237 strcpy(main_info.error_str, "Error loading 'level.pcx', aborting...\n");
1240 read_pcx(handle, mask_pic, 102400, pal);
1243 memset(mask_pic, 0, 102400);
1245 memset(ban_map, 0, sizeof(ban_map));
1248 for (c1 = 0; c1 < 768; c1++)
1251 for (c1 = 0; c1 < 4; c1++) {
1252 outportw(0x3c4, ((1 << c1) << 8) + 0x02);
1253 for (c2 = 193; c2 < 256; c2++) {
1254 memset((void *) (0xa0000 + c2 * 100 - __djgpp_base_address), (c2 - 192) >> 2, 100);
1255 memset((void *) (0xa0000 + 32768 + c2 * 100 - __djgpp_base_address), (c2 - 192) >> 2, 100);
1260 for (c1 = 0; c1 < 768; c1++)
1261 outportb(0x3c9, pal[c1]);
1263 for (c1 = 0; c1 < 20; c1++)
1264 rabbits[c1].used = 0;
1266 rabbits[0].used = 1;
1267 rabbits[0].colour = rnd(4);
1268 rabbits[0].x = (int) (150 + rnd(100)) << 16;
1269 rabbits[0].y = 256 << 16;
1270 rabbits[0].x_add = ((int) rnd(65535) << 1) - 65536;
1271 if (rabbits[0].x_add > 0)
1272 rabbits[0].direction = 0;
1274 rabbits[0].direction = 1;
1275 rabbits[0].y_add = -262144 + (rnd(16384) * 5);
1276 rabbits[0].timer = 30 + rnd(150);
1277 rabbits[0].anim = 2;
1278 rabbits[0].frame = 0;
1279 rabbits[0].frame_tick = 0;
1280 rabbits[0].image = player_anims[rabbits[0].anim].frame[rabbits[0].frame].image + rabbits[0].colour * 18 + rabbits[0].direction * 9;
1282 for (c1 = 0; c1 < 300; c1++) {
1286 stars[c1].x = stars[c1].old_x = (s1 << 16);
1287 stars[c1].y = stars[c1].old_y = (s2 << 16);
1289 outportw(0x3ce, ((s1 & 3) << 8) + 0x04);
1290 stars[c1].back[0] = stars[c1].back[1] = *(char *) (0xa0000 + s2 * 100 + (s1 >> 2) - __djgpp_base_address);
1295 main_info.page_info[0].num_pobs = 0;
1296 main_info.page_info[1].num_pobs = 0;
1297 main_info.view_page = 0;
1298 main_info.draw_page = 1;
1300 while (key_pressed(1) == 0) {
1304 for (c1 = 0; c1 < 300; c1++) {
1305 stars[c1].old_x = stars[c1].x;
1306 stars[c1].old_y = stars[c1].y;
1307 stars[c1].y -= (int) (31 - stars[c1].col) * 16384;
1308 if ((stars[c1].y >> 16) < 0)
1309 stars[c1].y += 256 << 16;;
1310 if ((stars[c1].y >> 16) >= 256)
1311 stars[c1].y -= 256 << 16;;
1314 for (c1 = 0, c2 = 0; c1 < 20; c1++) {
1315 if (rabbits[c1].used == 1)
1318 if ((c2 == 0 && rnd(10000) < 200) || (c2 == 1 && rnd(10000) < 150) || (c2 == 2 && rnd(10000) < 100) || (c2 == 3 && rnd(10000) < 50)) {
1319 for (c1 = 0; c1 < 20; c1++) {
1320 if (rabbits[c1].used == 0) {
1321 rabbits[c1].used = 1;
1322 rabbits[c1].colour = rnd(4);
1323 rabbits[c1].x = (int) (150 + rnd(100)) << 16;
1324 rabbits[c1].y = 256 << 16;
1325 rabbits[c1].x_add = ((int) rnd(65535) << 1) - 65536;
1326 if (rabbits[c1].x_add > 0)
1327 rabbits[c1].direction = 0;
1329 rabbits[c1].direction = 1;
1330 rabbits[c1].y_add = -262144 + (rnd(16384) * 5);
1331 rabbits[c1].timer = 30 + rnd(150);
1332 rabbits[c1].anim = 2;
1333 rabbits[c1].frame = 0;
1334 rabbits[c1].frame_tick = 0;
1335 rabbits[c1].image = player_anims[rabbits[c1].anim].frame[rabbits[c1].frame].image + rabbits[c1].colour * 18 + rabbits[c1].direction * 9;
1343 main_info.page_info[main_info.draw_page].num_pobs = 0;
1345 for (c1 = 0; c1 < 20; c1++) {
1346 if (rabbits[c1].used == 1) {
1347 rabbits[c1].y_add += 2048;
1348 if (rabbits[c1].y_add > 36864 && rabbits[c1].anim != 3) {
1349 rabbits[c1].anim = 3;
1350 rabbits[c1].frame = 0;
1351 rabbits[c1].frame_tick = 0;
1352 rabbits[c1].image = player_anims[rabbits[c1].anim].frame[rabbits[c1].frame].image + rabbits[c1].colour * 18 + rabbits[c1].direction * 9;
1354 rabbits[c1].x += rabbits[c1].x_add;
1355 rabbits[c1].y += rabbits[c1].y_add;
1356 if ((rabbits[c1].x >> 16) < 16 || (rabbits[c1].x >> 16) > 400 || (rabbits[c1].y >> 16) > 256) {
1357 rabbits[c1].used = 0;
1360 rabbits[c1].timer--;
1361 if (rabbits[c1].timer <= 0) {
1362 rabbits[c1].used = 0;
1363 for (c2 = 0; c2 < 6; c2++)
1364 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);
1365 for (c2 = 0; c2 < 6; c2++)
1366 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);
1367 for (c2 = 0; c2 < 6; c2++)
1368 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);
1369 for (c2 = 0; c2 < 8; c2++)
1370 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);
1371 for (c2 = 0; c2 < 10; c2++)
1372 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);
1373 dj_play_sfx(SFX_DEATH, SFX_DEATH_FREQ, 64, 0, 0, -1);
1376 rabbits[c1].frame_tick++;
1377 if (rabbits[c1].frame_tick >= player_anims[rabbits[c1].anim].frame[rabbits[c1].frame].ticks) {
1378 rabbits[c1].frame++;
1379 if (rabbits[c1].frame >= player_anims[rabbits[c1].anim].num_frames)
1380 rabbits[c1].frame = player_anims[rabbits[c1].anim].restart_frame;
1381 rabbits[c1].frame_tick = 0;
1383 rabbits[c1].image = player_anims[rabbits[c1].anim].frame[rabbits[c1].frame].image + rabbits[c1].colour * 18 + rabbits[c1].direction * 9;
1384 if (rabbits[c1].used == 1)
1385 add_pob(main_info.draw_page, rabbits[c1].x >> 16, rabbits[c1].y >> 16, rabbits[c1].image, rabbit_gobs);
1393 for (c1 = 0; c1 < 300; c1++) {
1394 outportw(0x3ce, (((stars[c1].x >> 16) & 3) << 8) + 0x04);
1395 outportw(0x3c4, ((1 << ((stars[c1].x >> 16) & 3)) << 8) + 0x02);
1396 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);
1397 *(char *) (0xa0000 + ((int) main_info.draw_page << 15) + (stars[c1].y >> 16) * 100 + (stars[c1].x >> 18) - __djgpp_base_address) = stars[c1].col;
1402 draw_pobs(main_info.draw_page);
1404 main_info.draw_page ^= 1;
1405 main_info.view_page ^= 1;
1406 outportw(0x3d4, (main_info.view_page << 23) + 0x0d);
1407 outportw(0x3d4, ((main_info.view_page << 15) & 0xff00) + 0x0c);
1409 while ((inportb(0x3da) & 8) == 0)
1411 while ((inportb(0x3da) & 8) == 8)
1414 redraw_pob_backgrounds(main_info.draw_page);
1418 for (c1 = 299; c1 >= 0; c1--) {
1419 outportw(0x3c4, ((1 << ((stars[c1].old_x >> 16) & 3)) << 8) + 0x02);
1420 *(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];
1429 void add_object(char type, short x, short y, long x_add, long y_add, short anim, short frame)
1433 for (c1 = 0; c1 < NUM_OBJECTS; c1++) {
1434 if (objects[c1].used == 0) {
1435 objects[c1].used = 1;
1436 objects[c1].type = type;
1437 objects[c1].x = (long) x << 16;
1438 objects[c1].y = (long) y << 16;
1439 objects[c1].x_add = x_add;
1440 objects[c1].y_add = y_add;
1441 objects[c1].x_acc = 0;
1442 objects[c1].y_acc = 0;
1443 objects[c1].anim = anim;
1444 objects[c1].frame = frame;
1445 objects[c1].ticks = object_anims[anim].frame[frame].ticks;
1446 objects[c1].image = object_anims[anim].frame[frame].image;
1454 void update_objects(void)
1459 for (c1 = 0; c1 < NUM_OBJECTS; c1++) {
1460 if (objects[c1].used == 1) {
1461 switch (objects[c1].type) {
1463 objects[c1].ticks--;
1464 if (objects[c1].ticks <= 0) {
1465 objects[c1].frame++;
1466 if (objects[c1].frame >= object_anims[objects[c1].anim].num_frames) {
1467 objects[c1].frame--;
1468 objects[c1].ticks = object_anims[objects[c1].anim].frame[objects[c1].frame].ticks;
1470 objects[c1].ticks = object_anims[objects[c1].anim].frame[objects[c1].frame].ticks;
1471 objects[c1].image = object_anims[objects[c1].anim].frame[objects[c1].frame].image;
1474 if (objects[c1].used == 1)
1475 add_pob(main_info.draw_page, objects[c1].x >> 16, objects[c1].y >> 16, objects[c1].image, object_gobs);
1478 objects[c1].ticks--;
1479 if (objects[c1].ticks <= 0) {
1480 objects[c1].frame++;
1481 if (objects[c1].frame >= object_anims[objects[c1].anim].num_frames)
1482 objects[c1].used = 0;
1484 objects[c1].ticks = object_anims[objects[c1].anim].frame[objects[c1].frame].ticks;
1485 objects[c1].image = object_anims[objects[c1].anim].frame[objects[c1].frame].image;
1488 if (objects[c1].used == 1)
1489 add_pob(main_info.draw_page, objects[c1].x >> 16, objects[c1].y >> 16, objects[c1].image, object_gobs);
1492 objects[c1].x += objects[c1].x_add;
1493 objects[c1].y += objects[c1].y_add;
1494 objects[c1].ticks--;
1495 if (objects[c1].ticks <= 0) {
1496 objects[c1].frame++;
1497 if (objects[c1].frame >= object_anims[objects[c1].anim].num_frames)
1498 objects[c1].used = 0;
1500 objects[c1].ticks = object_anims[objects[c1].anim].frame[objects[c1].frame].ticks;
1501 objects[c1].image = object_anims[objects[c1].anim].frame[objects[c1].frame].image;
1504 if (objects[c1].used == 1)
1505 add_pob(main_info.draw_page, objects[c1].x >> 16, objects[c1].y >> 16, objects[c1].image, object_gobs);
1507 case OBJ_YEL_BUTFLY:
1508 case OBJ_PINK_BUTFLY:
1509 objects[c1].x_acc += rnd(128) - 64;
1510 if (objects[c1].x_acc < -1024)
1511 objects[c1].x_acc = -1024;
1512 if (objects[c1].x_acc > 1024)
1513 objects[c1].x_acc = 1024;
1514 objects[c1].x_add += objects[c1].x_acc;
1515 if (objects[c1].x_add < -32768)
1516 objects[c1].x_add = -32768;
1517 if (objects[c1].x_add > 32768)
1518 objects[c1].x_add = 32768;
1519 objects[c1].x += objects[c1].x_add;
1520 if ((objects[c1].x >> 16) < 16) {
1521 objects[c1].x = 16 << 16;
1522 objects[c1].x_add = -objects[c1].x_add >> 2;
1523 objects[c1].x_acc = 0;
1524 } else if ((objects[c1].x >> 16) > 350) {
1525 objects[c1].x = 350 << 16;
1526 objects[c1].x_add = -objects[c1].x_add >> 2;
1527 objects[c1].x_acc = 0;
1529 if (ban_map[objects[c1].y >> 20][objects[c1].x >> 20] != 0) {
1530 if (objects[c1].x_add < 0) {
1531 objects[c1].x = (((objects[c1].x >> 16) + 16) & 0xfff0) << 16;
1533 objects[c1].x = ((((objects[c1].x >> 16) - 16) & 0xfff0) + 15) << 16;
1535 objects[c1].x_add = -objects[c1].x_add >> 2;
1536 objects[c1].x_acc = 0;
1538 objects[c1].y_acc += rnd(64) - 32;
1539 if (objects[c1].y_acc < -1024)
1540 objects[c1].y_acc = -1024;
1541 if (objects[c1].y_acc > 1024)
1542 objects[c1].y_acc = 1024;
1543 objects[c1].y_add += objects[c1].y_acc;
1544 if (objects[c1].y_add < -32768)
1545 objects[c1].y_add = -32768;
1546 if (objects[c1].y_add > 32768)
1547 objects[c1].y_add = 32768;
1548 objects[c1].y += objects[c1].y_add;
1549 if ((objects[c1].y >> 16) < 0) {
1551 objects[c1].y_add = -objects[c1].y_add >> 2;
1552 objects[c1].y_acc = 0;
1553 } else if ((objects[c1].y >> 16) > 255) {
1554 objects[c1].y = 255 << 16;
1555 objects[c1].y_add = -objects[c1].y_add >> 2;
1556 objects[c1].y_acc = 0;
1558 if (ban_map[objects[c1].y >> 20][objects[c1].x >> 20] != 0) {
1559 if (objects[c1].y_add < 0) {
1560 objects[c1].y = (((objects[c1].y >> 16) + 16) & 0xfff0) << 16;
1562 objects[c1].y = ((((objects[c1].y >> 16) - 16) & 0xfff0) + 15) << 16;
1564 objects[c1].y_add = -objects[c1].y_add >> 2;
1565 objects[c1].y_acc = 0;
1567 if (objects[c1].type == OBJ_YEL_BUTFLY) {
1568 if (objects[c1].x_add < 0 && objects[c1].anim != OBJ_ANIM_YEL_BUTFLY_LEFT) {
1569 objects[c1].anim = OBJ_ANIM_YEL_BUTFLY_LEFT;
1570 objects[c1].frame = 0;
1571 objects[c1].ticks = object_anims[objects[c1].anim].frame[objects[c1].frame].ticks;
1572 objects[c1].image = object_anims[objects[c1].anim].frame[objects[c1].frame].image;
1573 } else if (objects[c1].x_add > 0 && objects[c1].anim != OBJ_ANIM_YEL_BUTFLY_RIGHT) {
1574 objects[c1].anim = OBJ_ANIM_YEL_BUTFLY_RIGHT;
1575 objects[c1].frame = 0;
1576 objects[c1].ticks = object_anims[objects[c1].anim].frame[objects[c1].frame].ticks;
1577 objects[c1].image = object_anims[objects[c1].anim].frame[objects[c1].frame].image;
1580 if (objects[c1].x_add < 0 && objects[c1].anim != OBJ_ANIM_PINK_BUTFLY_LEFT) {
1581 objects[c1].anim = OBJ_ANIM_PINK_BUTFLY_LEFT;
1582 objects[c1].frame = 0;
1583 objects[c1].ticks = object_anims[objects[c1].anim].frame[objects[c1].frame].ticks;
1584 objects[c1].image = object_anims[objects[c1].anim].frame[objects[c1].frame].image;
1585 } else if (objects[c1].x_add > 0 && objects[c1].anim != OBJ_ANIM_PINK_BUTFLY_RIGHT) {
1586 objects[c1].anim = OBJ_ANIM_PINK_BUTFLY_RIGHT;
1587 objects[c1].frame = 0;
1588 objects[c1].ticks = object_anims[objects[c1].anim].frame[objects[c1].frame].ticks;
1589 objects[c1].image = object_anims[objects[c1].anim].frame[objects[c1].frame].image;
1592 objects[c1].ticks--;
1593 if (objects[c1].ticks <= 0) {
1594 objects[c1].frame++;
1595 if (objects[c1].frame >= object_anims[objects[c1].anim].num_frames)
1596 objects[c1].frame = object_anims[objects[c1].anim].restart_frame;
1598 objects[c1].ticks = object_anims[objects[c1].anim].frame[objects[c1].frame].ticks;
1599 objects[c1].image = object_anims[objects[c1].anim].frame[objects[c1].frame].image;
1602 if (objects[c1].used == 1)
1603 add_pob(main_info.draw_page, objects[c1].x >> 16, objects[c1].y >> 16, objects[c1].image, object_gobs);
1607 add_object(OBJ_FLESH_TRACE, objects[c1].x >> 16, objects[c1].y >> 16, 0, 0, OBJ_ANIM_FLESH_TRACE, 0);
1608 if (ban_map[objects[c1].y >> 20][objects[c1].x >> 20] == 0) {
1609 objects[c1].y_add += 3072;
1610 if (objects[c1].y_add > 196608L)
1611 objects[c1].y_add = 196608L;
1612 } else if (ban_map[objects[c1].y >> 20][objects[c1].x >> 20] == 2) {
1613 if (objects[c1].x_add < 0) {
1614 if (objects[c1].x_add < -65536L)
1615 objects[c1].x_add = -65536L;
1616 objects[c1].x_add += 1024;
1617 if (objects[c1].x_add > 0)
1618 objects[c1].x_add = 0;
1620 if (objects[c1].x_add > 65536L)
1621 objects[c1].x_add = 65536L;
1622 objects[c1].x_add -= 1024;
1623 if (objects[c1].x_add < 0)
1624 objects[c1].x_add = 0;
1626 objects[c1].y_add += 1024;
1627 if (objects[c1].y_add < -65536L)
1628 objects[c1].y_add = -65536L;
1629 if (objects[c1].y_add > 65536L)
1630 objects[c1].y_add = 65536L;
1632 objects[c1].x += objects[c1].x_add;
1633 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)) {
1634 if (objects[c1].x_add < 0) {
1635 objects[c1].x = (((objects[c1].x >> 16) + 16) & 0xfff0) << 16;
1636 objects[c1].x_add = -objects[c1].x_add >> 2;
1638 objects[c1].x = ((((objects[c1].x >> 16) - 16) & 0xfff0) + 15) << 16;
1639 objects[c1].x_add = -objects[c1].x_add >> 2;
1642 objects[c1].y += objects[c1].y_add;
1643 if ((objects[c1].x >> 16) < -5 || (objects[c1].x >> 16) > 405 || (objects[c1].y >> 16) > 260)
1644 objects[c1].used = 0;
1645 if ((objects[c1].y >> 16) > 0 && (ban_map[objects[c1].y >> 20][objects[c1].x >> 20] != 0)) {
1646 if (objects[c1].y_add < 0) {
1647 if (ban_map[objects[c1].y >> 20][objects[c1].x >> 20] != 2) {
1648 objects[c1].y = (((objects[c1].y >> 16) + 16) & 0xfff0) << 16;
1649 objects[c1].x_add >>= 2;
1650 objects[c1].y_add = -objects[c1].y_add >> 2;
1653 if (ban_map[objects[c1].y >> 20][objects[c1].x >> 20] == 1) {
1654 if (objects[c1].y_add > 131072L) {
1655 objects[c1].y = ((((objects[c1].y >> 16) - 16) & 0xfff0) + 15) << 16;
1656 objects[c1].x_add >>= 2;
1657 objects[c1].y_add = -objects[c1].y_add >> 2;
1659 objects[c1].used = 0;
1660 } else if (ban_map[objects[c1].y >> 20][objects[c1].x >> 20] == 3) {
1661 objects[c1].y = ((((objects[c1].y >> 16) - 16) & 0xfff0) + 15) << 16;
1662 if (objects[c1].y_add > 131072L)
1663 objects[c1].y_add = -objects[c1].y_add >> 2;
1665 objects[c1].y_add = 0;
1669 if (objects[c1].x_add < 0 && objects[c1].x_add > -16384)
1670 objects[c1].x_add = -16384;
1671 if (objects[c1].x_add > 0 && objects[c1].x_add < 16384)
1672 objects[c1].x_add = 16384;
1673 if (objects[c1].used == 1) {
1674 s1 = atan2(objects[c1].y_add, objects[c1].x_add) * 4 / M_PI;
1681 add_pob(main_info.draw_page, objects[c1].x >> 16, objects[c1].y >> 16, objects[c1].frame + s1, object_gobs);
1685 if (rnd(100) < 30) {
1686 if (objects[c1].frame == 76)
1687 add_object(OBJ_FLESH_TRACE, objects[c1].x >> 16, objects[c1].y >> 16, 0, 0, OBJ_ANIM_FLESH_TRACE, 1);
1688 else if (objects[c1].frame == 77)
1689 add_object(OBJ_FLESH_TRACE, objects[c1].x >> 16, objects[c1].y >> 16, 0, 0, OBJ_ANIM_FLESH_TRACE, 2);
1690 else if (objects[c1].frame == 78)
1691 add_object(OBJ_FLESH_TRACE, objects[c1].x >> 16, objects[c1].y >> 16, 0, 0, OBJ_ANIM_FLESH_TRACE, 3);
1693 if (ban_map[objects[c1].y >> 20][objects[c1].x >> 20] == 0) {
1694 objects[c1].y_add += 3072;
1695 if (objects[c1].y_add > 196608L)
1696 objects[c1].y_add = 196608L;
1697 } else if (ban_map[objects[c1].y >> 20][objects[c1].x >> 20] == 2) {
1698 if (objects[c1].x_add < 0) {
1699 if (objects[c1].x_add < -65536L)
1700 objects[c1].x_add = -65536L;
1701 objects[c1].x_add += 1024;
1702 if (objects[c1].x_add > 0)
1703 objects[c1].x_add = 0;
1705 if (objects[c1].x_add > 65536L)
1706 objects[c1].x_add = 65536L;
1707 objects[c1].x_add -= 1024;
1708 if (objects[c1].x_add < 0)
1709 objects[c1].x_add = 0;
1711 objects[c1].y_add += 1024;
1712 if (objects[c1].y_add < -65536L)
1713 objects[c1].y_add = -65536L;
1714 if (objects[c1].y_add > 65536L)
1715 objects[c1].y_add = 65536L;
1717 objects[c1].x += objects[c1].x_add;
1718 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)) {
1719 if (objects[c1].x_add < 0) {
1720 objects[c1].x = (((objects[c1].x >> 16) + 16) & 0xfff0) << 16;
1721 objects[c1].x_add = -objects[c1].x_add >> 2;
1723 objects[c1].x = ((((objects[c1].x >> 16) - 16) & 0xfff0) + 15) << 16;
1724 objects[c1].x_add = -objects[c1].x_add >> 2;
1727 objects[c1].y += objects[c1].y_add;
1728 if ((objects[c1].x >> 16) < -5 || (objects[c1].x >> 16) > 405 || (objects[c1].y >> 16) > 260)
1729 objects[c1].used = 0;
1730 if ((objects[c1].y >> 16) > 0 && (ban_map[objects[c1].y >> 20][objects[c1].x >> 20] != 0)) {
1731 if (objects[c1].y_add < 0) {
1732 if (ban_map[objects[c1].y >> 20][objects[c1].x >> 20] != 2) {
1733 objects[c1].y = (((objects[c1].y >> 16) + 16) & 0xfff0) << 16;
1734 objects[c1].x_add >>= 2;
1735 objects[c1].y_add = -objects[c1].y_add >> 2;
1738 if (ban_map[objects[c1].y >> 20][objects[c1].x >> 20] == 1) {
1739 if (objects[c1].y_add > 131072L) {
1740 objects[c1].y = ((((objects[c1].y >> 16) - 16) & 0xfff0) + 15) << 16;
1741 objects[c1].x_add >>= 2;
1742 objects[c1].y_add = -objects[c1].y_add >> 2;
1744 if (rnd(100) < 10) {
1746 add_leftovers(0, objects[c1].x >> 16, (objects[c1].y >> 16) + s1, objects[c1].frame, object_gobs);
1747 add_leftovers(1, objects[c1].x >> 16, (objects[c1].y >> 16) + s1, objects[c1].frame, object_gobs);
1749 objects[c1].used = 0;
1751 } else if (ban_map[objects[c1].y >> 20][objects[c1].x >> 20] == 3) {
1752 objects[c1].y = ((((objects[c1].y >> 16) - 16) & 0xfff0) + 15) << 16;
1753 if (objects[c1].y_add > 131072L)
1754 objects[c1].y_add = -objects[c1].y_add >> 2;
1756 objects[c1].y_add = 0;
1760 if (objects[c1].x_add < 0 && objects[c1].x_add > -16384)
1761 objects[c1].x_add = -16384;
1762 if (objects[c1].x_add > 0 && objects[c1].x_add < 16384)
1763 objects[c1].x_add = 16384;
1764 if (objects[c1].used == 1)
1765 add_pob(main_info.draw_page, objects[c1].x >> 16, objects[c1].y >> 16, objects[c1].frame, object_gobs);
1767 case OBJ_FLESH_TRACE:
1768 objects[c1].ticks--;
1769 if (objects[c1].ticks <= 0) {
1770 objects[c1].frame++;
1771 if (objects[c1].frame >= object_anims[objects[c1].anim].num_frames)
1772 objects[c1].used = 0;
1774 objects[c1].ticks = object_anims[objects[c1].anim].frame[objects[c1].frame].ticks;
1775 objects[c1].image = object_anims[objects[c1].anim].frame[objects[c1].frame].image;
1778 if (objects[c1].used == 1)
1779 add_pob(main_info.draw_page, objects[c1].x >> 16, objects[c1].y >> 16, objects[c1].image, object_gobs);
1788 char add_pob(char page, short x, short y, short image, char *pob_data)
1791 if (main_info.page_info[page].num_pobs >= NUM_POBS)
1794 main_info.page_info[page].pobs[main_info.page_info[page].num_pobs].x = x;
1795 main_info.page_info[page].pobs[main_info.page_info[page].num_pobs].y = y;
1796 main_info.page_info[page].pobs[main_info.page_info[page].num_pobs].image = image;
1797 main_info.page_info[page].pobs[main_info.page_info[page].num_pobs].pob_data = pob_data;
1798 main_info.page_info[page].num_pobs++;
1805 void draw_pobs(char page)
1812 for (c1 = main_info.page_info[page].num_pobs - 1; c1 >= 0; c1--) {
1813 main_info.page_info[page].pobs[c1].back_buf_ofs = back_buf_ofs;
1814 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));
1815 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);
1816 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);
1822 void redraw_pob_backgrounds(char page)
1826 for (c1 = 0; c1 < main_info.page_info[page].num_pobs; c1++)
1827 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));
1832 char add_leftovers(char page, short x, short y, short image, char *pob_data)
1835 if (leftovers.page[page].num_pobs >= NUM_LEFTOVERS)
1838 leftovers.page[page].pobs[leftovers.page[page].num_pobs].x = x;
1839 leftovers.page[page].pobs[leftovers.page[page].num_pobs].y = y;
1840 leftovers.page[page].pobs[leftovers.page[page].num_pobs].image = image;
1841 leftovers.page[page].pobs[leftovers.page[page].num_pobs].pob_data = pob_data;
1842 leftovers.page[page].num_pobs++;
1849 void draw_leftovers(char page)
1854 for (c1 = leftovers.page[page].num_pobs - 1; c1 >= 0; c1--)
1855 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);
1857 leftovers.page[page].num_pobs = 0;
1862 char init_level(short level)
1869 if ((handle = dat_open("level.pcx", datfile_name, "rb")) == 0) {
1870 strcpy(main_info.error_str, "Error loading 'level.pcx', aborting...\n");
1873 if (read_pcx(handle, background_pic, 102400L, pal) != 0) {
1874 strcpy(main_info.error_str, "Error loading 'level.pcx', aborting...\n");
1878 if ((handle = dat_open("mask.pcx", datfile_name, "rb")) == 0) {
1879 strcpy(main_info.error_str, "Error loading 'mask.pcx', aborting...\n");
1882 if (read_pcx(handle, mask_pic, 102400L, 0) != 0) {
1883 strcpy(main_info.error_str, "Error loading 'mask.pcx', aborting...\n");
1887 memset(cur_pal, 0, 768);
1889 for (c1 = 0; c1 < 4; c1++) {
1890 if (player[c1].enabled == 1) {
1891 player[c1].bumps = 0;
1892 player[c1].bumped[0] = 0;
1893 player[c1].bumped[1] = 0;
1894 player[c1].bumped[2] = 0;
1895 player[c1].bumped[3] = 0;
1896 position_player(c1);
1900 for (c1 = 0; c1 < 300; c1++)
1901 objects[c1].used = 0;
1903 for (c1 = 0; c1 < 16; c1++) {
1904 for (c2 = 0; c2 < 22; c2++) {
1905 if (ban_map[c1][c2] == 4)
1906 add_object(OBJ_SPRING, c2 << 4, c1 << 4, 0, 0, OBJ_ANIM_SPRING, 5);
1913 if (ban_map[s2][s1] == 0) {
1914 add_object(OBJ_YEL_BUTFLY, (s1 << 4) + 8, (s2 << 4) + 8, (rnd(65535) - 32768) * 2, (rnd(65535) - 32768) * 2, 0, 0);
1921 if (ban_map[s2][s1] == 0) {
1922 add_object(OBJ_YEL_BUTFLY, (s1 << 4) + 8, (s2 << 4) + 8, (rnd(65535) - 32768) * 2, (rnd(65535) - 32768) * 2, 0, 0);
1929 if (ban_map[s2][s1] == 0) {
1930 add_object(OBJ_PINK_BUTFLY, (s1 << 4) + 8, (s2 << 4) + 8, (rnd(65535) - 32768) * 2, (rnd(65535) - 32768) * 2, 0, 0);
1937 if (ban_map[s2][s1] == 0) {
1938 add_object(OBJ_PINK_BUTFLY, (s1 << 4) + 8, (s2 << 4) + 8, (rnd(65535) - 32768) * 2, (rnd(65535) - 32768) * 2, 0, 0);
1948 void deinit_level(void)
1958 char init_program(int argc, char *argv[])
1963 char force2, force3;
1964 int player_anim_data[] = {
1965 1, 0, 0, 0x7fff, 0, 0, 0, 0, 0, 0,
1966 4, 0, 0, 4, 1, 4, 2, 4, 3, 4,
1967 1, 0, 4, 0x7fff, 0, 0, 0, 0, 0, 0,
1968 4, 2, 5, 8, 6, 10, 7, 3, 6, 3,
1969 1, 0, 6, 0x7fff, 0, 0, 0, 0, 0, 0,
1970 2, 1, 5, 8, 4, 0x7fff, 0, 0, 0, 0,
1971 1, 0, 8, 5, 0, 0, 0, 0, 0, 0
1974 if (__djgpp_nearptr_enable() == 0)
1979 if (hook_keyb_handler() != 0)
1982 memset(&main_info, 0, sizeof(main_info));
1983 main_info.joy_enabled = 1;
1985 strcpy(datfile_name, "jumpbump.dat");
1987 force2 = force3 = 0;
1990 for (c1 = 1; c1 < argc; c1++) {
1991 if (stricmp(argv[c1], "-nosound") == 0)
1992 main_info.no_sound = 1;
1993 else if (stricmp(argv[c1], "-nogore") == 0)
1994 main_info.no_gore = 1;
1995 else if (stricmp(argv[c1], "-nojoy") == 0)
1996 main_info.joy_enabled = 0;
1997 else if (stricmp(argv[c1], "-fireworks") == 0)
1998 main_info.fireworks = 1;
1999 else if (stricmp(argv[c1], "-dat") == 0) {
2000 if (c1 < (argc - 1)) {
2001 if ((handle = fopen(argv[c1 + 1], "rb")) != NULL) {
2003 strcpy(datfile_name, argv[c1 + 1]);
2006 } else if (stricmp(argv[c1], "-mouse") == 0) {
2007 if (c1 < (argc - 1)) {
2008 if (stricmp(argv[c1 + 1], "2") == 0)
2010 if (stricmp(argv[c1 + 1], "3") == 0)
2017 for (c1 = 0; c1 < 7; c1++) {
2018 player_anims[c1].num_frames = player_anim_data[c1 * 10];
2019 player_anims[c1].restart_frame = player_anim_data[c1 * 10 + 1];
2020 for (c2 = 0; c2 < 4; c2++) {
2021 player_anims[c1].frame[c2].image = player_anim_data[c1 * 10 + c2 * 2 + 2];
2022 player_anims[c1].frame[c2].ticks = player_anim_data[c1 * 10 + c2 * 2 + 3];
2026 if ((background_pic = malloc(102400L)) == 0)
2028 if ((mask_pic = malloc(102400L)) == 0)
2030 memset(mask_pic, 0, 102400);
2032 main_info.pob_backbuf[0] = malloc(65535);
2033 main_info.pob_backbuf[1] = malloc(65535);
2034 if (main_info.pob_backbuf[0] == 0 || main_info.pob_backbuf[1] == 0)
2037 if ((handle = dat_open("rabbit.gob", datfile_name, "rb")) == 0) {
2038 strcpy(main_info.error_str, "Error loading 'rabbit.gob', aborting...\n");
2041 if ((rabbit_gobs = malloc(dat_filelen("rabbit.gob", datfile_name))) == 0) {
2042 strcpy(main_info.error_str, "Not enough memory, aborting...\n");
2046 fread(rabbit_gobs, 1, dat_filelen("rabbit.gob", datfile_name), handle);
2049 if ((handle = dat_open("objects.gob", datfile_name, "rb")) == 0) {
2050 strcpy(main_info.error_str, "Error loading 'objects.gob', aborting...\n");
2053 if ((object_gobs = malloc(dat_filelen("objects.gob", datfile_name))) == 0) {
2054 strcpy(main_info.error_str, "Not enough memory, aborting...\n");
2058 fread(object_gobs, 1, dat_filelen("objects.gob", datfile_name), handle);
2061 if ((handle = dat_open("font.gob", datfile_name, "rb")) == 0) {
2062 strcpy(main_info.error_str, "Error loading 'font.gob', aborting...\n");
2065 if ((font_gobs = malloc(dat_filelen("font.gob", datfile_name))) == 0) {
2066 strcpy(main_info.error_str, "Not enough memory, aborting...\n");
2070 fread(font_gobs, 1, dat_filelen("font.gob", datfile_name), handle);
2073 if ((handle = dat_open("numbers.gob", datfile_name, "rb")) == 0) {
2074 strcpy(main_info.error_str, "Error loading 'numbers.gob', aborting...\n");
2077 if ((number_gobs = malloc(dat_filelen("numbers.gob", datfile_name))) == 0) {
2078 strcpy(main_info.error_str, "Not enough memory, aborting...\n");
2082 fread(number_gobs, 1, dat_filelen("numbers.gob", datfile_name), handle);
2085 if (read_level() != 0) {
2086 strcpy(main_info.error_str, "Error loading 'levelmap.txt', aborting...\n");
2092 if (main_info.no_sound == 0) {
2094 dj_set_mixing_freq(20000);
2098 dj_set_num_sfx_channels(5);
2099 dj_set_sfx_volume(64);
2103 if ((handle = dat_open("jump.mod", datfile_name, "rb")) == 0) {
2104 strcpy(main_info.error_str, "Error loading 'jump.mod', aborting...\n");
2107 if (dj_load_mod(handle, 0, MOD_MENU) != 0) {
2108 strcpy(main_info.error_str, "Error loading 'jump.mod', aborting...\n");
2113 if ((handle = dat_open("bump.mod", datfile_name, "rb")) == 0) {
2114 strcpy(main_info.error_str, "Error loading 'bump.mod', aborting...\n");
2117 if (dj_load_mod(handle, 0, MOD_GAME) != 0) {
2118 strcpy(main_info.error_str, "Error loading 'bump.mod', aborting...\n");
2123 if ((handle = dat_open("scores.mod", datfile_name, "rb")) == 0) {
2124 strcpy(main_info.error_str, "Error loading 'scores.mod', aborting...\n");
2127 if (dj_load_mod(handle, 0, MOD_SCORES) != 0) {
2128 strcpy(main_info.error_str, "Error loading 'scores.mod', aborting...\n");
2133 if ((handle = dat_open("jump.smp", datfile_name, "rb")) == 0) {
2134 strcpy(main_info.error_str, "Error loading 'jump.smp', aborting...\n");
2137 if (dj_load_sfx(handle, 0, dat_filelen("jump.smp", datfile_name), DJ_SFX_TYPE_SMP, SFX_JUMP) != 0) {
2138 strcpy(main_info.error_str, "Error loading 'jump.smp', aborting...\n");
2143 if ((handle = dat_open("death.smp", datfile_name, "rb")) == 0) {
2144 strcpy(main_info.error_str, "Error loading 'death.smp', aborting...\n");
2147 if (dj_load_sfx(handle, 0, dat_filelen("death.smp", datfile_name), DJ_SFX_TYPE_SMP, SFX_DEATH) != 0) {
2148 strcpy(main_info.error_str, "Error loading 'death.smp', aborting...\n");
2153 if ((handle = dat_open("spring.smp", datfile_name, "rb")) == 0) {
2154 strcpy(main_info.error_str, "Error loading 'spring.smp', aborting...\n");
2157 if (dj_load_sfx(handle, 0, dat_filelen("spring.smp", datfile_name), DJ_SFX_TYPE_SMP, SFX_SPRING) != 0) {
2158 strcpy(main_info.error_str, "Error loading 'spring.smp', aborting...\n");
2163 if ((handle = dat_open("splash.smp", datfile_name, "rb")) == 0) {
2164 strcpy(main_info.error_str, "Error loading 'splash.smp', aborting...\n");
2167 if (dj_load_sfx(handle, 0, dat_filelen("splash.smp", datfile_name), DJ_SFX_TYPE_SMP, SFX_SPLASH) != 0) {
2168 strcpy(main_info.error_str, "Error loading 'splash.smp', aborting...\n");
2173 if ((handle = dat_open("fly.smp", datfile_name, "rb")) == 0) {
2174 strcpy(main_info.error_str, "Error loading 'fly.smp', aborting...\n");
2177 if (dj_load_sfx(handle, 0, dat_filelen("fly.smp", datfile_name), DJ_SFX_TYPE_SMP, SFX_FLY) != 0) {
2178 strcpy(main_info.error_str, "Error loading 'fly.smp', aborting...\n");
2183 dj_get_sfx_settings(SFX_FLY, &fly);
2185 fly.default_freq = SFX_FLY_FREQ;
2188 fly.loop_length = fly.length;
2189 dj_set_sfx_settings(SFX_FLY, &fly);
2194 if ((handle = dat_open("menu.pcx", datfile_name, "rb")) == 0) {
2195 strcpy(main_info.error_str, "Error loading 'menu.pcx', aborting...\n");
2198 if (read_pcx(handle, background_pic, 102400L, pal) != 0) {
2199 strcpy(main_info.error_str, "Error loading 'menu.pcx', aborting...\n");
2205 for (c1 = 0; c1 < 768; c1++)
2206 outportb(0x3c9, pal[c1]);
2208 if (main_info.joy_enabled == 1 && main_info.fireworks == 0) {
2211 while (c1 < 0x7fff) {
2212 if ((inportb(0x201) & 1) == 0)
2217 main_info.joy_enabled = 1;
2219 put_text(0, 200, 40, "JOYSTICK CALIBRATION", 2);
2220 put_text(0, 200, 100, "Move the joystick to the", 2);
2221 put_text(0, 200, 115, "UPPER LEFT", 2);
2222 put_text(0, 200, 130, "and press button A", 2);
2223 put_text(0, 200, 200, "Or press ESC to use", 2);
2224 put_text(0, 200, 215, "previous settings", 2);
2225 if (calib_joy(0) != 0)
2228 outportw(0x3c4, 0x0f02);
2229 memset((char *) (0xa0000 + 32768 + __djgpp_conventional_base), 0, 32768);
2230 main_info.view_page = 1;
2231 outportw(0x3d4, (1 << 23) + 0x0d);
2232 outportw(0x3d4, ((1 << 15) & 0xff00) + 0x0c);
2235 put_text(1, 200, 40, "JOYSTICK CALIBRATION", 2);
2236 put_text(1, 200, 100, "Move the joystick to the", 2);
2237 put_text(1, 200, 115, "LOWER RIGHT", 2);
2238 put_text(1, 200, 130, "and press button A", 2);
2239 put_text(1, 200, 200, "Or press ESC to use", 2);
2240 put_text(1, 200, 215, "previous settings", 2);
2241 if (calib_joy(1) != 0)
2244 outportw(0x3c4, 0x0f02);
2245 memset((char *) (0xa0000 + __djgpp_conventional_base), 0, 32768);
2246 outportw(0x3d4, (0 << 23) + 0x0d);
2247 outportw(0x3d4, ((0 << 15) & 0xff00) + 0x0c);
2250 put_text(0, 200, 40, "JOYSTICK CALIBRATION", 2);
2251 put_text(0, 200, 100, "Move the joystick to the", 2);
2252 put_text(0, 200, 115, "CENTER", 2);
2253 put_text(0, 200, 130, "and press button A", 2);
2254 put_text(0, 200, 200, "Or press ESC to use", 2);
2255 put_text(0, 200, 215, "previous settings", 2);
2256 if (calib_joy(2) != 0)
2259 if (joy.calib_data.x1 == joy.calib_data.x2)
2260 joy.calib_data.x1 -= 10;
2261 if (joy.calib_data.x3 == joy.calib_data.x2)
2262 joy.calib_data.x3 += 10;
2263 if (joy.calib_data.y1 == joy.calib_data.y2)
2264 joy.calib_data.y1 -= 10;
2265 if (joy.calib_data.y3 == joy.calib_data.y2)
2266 joy.calib_data.y3 += 10;
2271 if (load_flag == 1) {
2272 if ((handle = dat_open("calib.dat", datfile_name, "rb")) == 0) {
2273 strcpy(main_info.error_str, "Error loading 'calib.dat', aborting...\n");
2276 joy.calib_data.x1 = fgetc(handle) + (fgetc(handle) << 8) + (fgetc(handle) << 16) + (fgetc(handle) << 24);
2277 joy.calib_data.x2 = fgetc(handle) + (fgetc(handle) << 8) + (fgetc(handle) << 16) + (fgetc(handle) << 24);
2278 joy.calib_data.x3 = fgetc(handle) + (fgetc(handle) << 8) + (fgetc(handle) << 16) + (fgetc(handle) << 24);
2279 joy.calib_data.y1 = fgetc(handle) + (fgetc(handle) << 8) + (fgetc(handle) << 16) + (fgetc(handle) << 24);
2280 joy.calib_data.y2 = fgetc(handle) + (fgetc(handle) << 8) + (fgetc(handle) << 16) + (fgetc(handle) << 24);
2281 joy.calib_data.y3 = fgetc(handle) + (fgetc(handle) << 8) + (fgetc(handle) << 16) + (fgetc(handle) << 24);
2285 main_info.joy_enabled = 0;
2290 __dpmi_int(0x33, ®s);
2291 if (regs.x.ax == 0xffff) {
2292 main_info.mouse_enabled = 1;
2293 main_info.num_mouse_buttons = regs.x.bx;
2295 main_info.num_mouse_buttons = 2;
2297 main_info.num_mouse_buttons = 3;
2299 main_info.mouse_enabled = 0;
2306 void deinit_program(void)
2311 dj_free_mod(MOD_MENU);
2312 dj_free_mod(MOD_GAME);
2313 dj_free_sfx(SFX_DEATH);
2314 dj_free_sfx(SFX_SPRING);
2315 dj_free_sfx(SFX_SPLASH);
2318 if (rabbit_gobs != 0)
2320 if (object_gobs != 0)
2322 if (number_gobs != 0)
2325 if (main_info.pob_backbuf[0] != 0)
2326 free(main_info.pob_backbuf[0]);
2327 if (main_info.pob_backbuf[1] != 0)
2328 free(main_info.pob_backbuf[1]);
2330 if (background_pic != 0)
2331 free(background_pic);
2335 remove_keyb_handler();
2338 __dpmi_int(0x10, ®s);
2340 if (main_info.error_str[0] != 0) {
2341 printf(main_info.error_str);
2356 c1 = x = y = flag = 0;
2361 s1 = inportb(0x201);
2371 if (x != 0 && y != 0)
2386 if (joy.raw_x < joy.calib_data.x2)
2387 joy.x = ((long) (joy.raw_x - joy.calib_data.x2) << 10) / (joy.calib_data.x2 - joy.calib_data.x1);
2389 joy.x = ((long) (joy.raw_x - joy.calib_data.x2) << 10) / (joy.calib_data.x3 - joy.calib_data.x2);
2390 if (joy.raw_y < joy.calib_data.y2)
2391 joy.y = ((long) (joy.raw_y - joy.calib_data.y2) << 10) / (joy.calib_data.y2 - joy.calib_data.y1);
2393 joy.y = ((long) (joy.raw_y - joy.calib_data.y2) << 10) / (joy.calib_data.y3 - joy.calib_data.y2);
2404 s1 = inportb(0x201);
2405 joy.but1 = (((s1 >> 4) & 1) ^ 1);
2406 joy.but2 = (((s1 >> 5) & 1) ^ 1);
2408 joy.raw_x = joy.calib_data.x2;
2409 joy.raw_y = joy.calib_data.y2;
2413 joy.but1 = joy.but2 = 0;
2419 char calib_joy(char type)
2427 while (joy.but1 == 1) {
2428 s1 = inportb(0x201);
2429 joy.but1 = (((s1 >> 4) & 1) ^ 1);
2430 if (key_pressed(1) == 1) {
2431 while (key_pressed(1) == 1);
2438 while (joy.but1 == 0) {
2440 c1 = x = y = flag = 0;
2445 s1 = inportb(0x201);
2455 if (x != 0 && y != 0)
2469 s1 = inportb(0x201);
2470 joy.but1 = (((s1 >> 4) & 1) ^ 1);
2472 if (num_times < 0x7fffffff)
2478 if (key_pressed(1) == 1) {
2479 while (key_pressed(1) == 1);
2492 joy.calib_data.x1 = joy.raw_x;
2493 joy.calib_data.y1 = joy.raw_y;
2496 joy.calib_data.x3 = joy.raw_x;
2497 joy.calib_data.y3 = joy.raw_y;
2500 joy.calib_data.x2 = joy.raw_x;
2501 joy.calib_data.y2 = joy.raw_y;
2505 while (joy.but1 == 1) {
2506 s1 = inportb(0x201);
2507 joy.but1 = (((s1 >> 4) & 1) ^ 1);
2517 void read_mouse(void)
2521 __dpmi_int(0x33, ®s);
2522 mouse.but1 = regs.x.bx & 1;
2523 mouse.but2 = (regs.x.bx & 2) >> 1;
2524 mouse.but3 = (regs.x.bx & 4) >> 2;
2529 unsigned short rnd(unsigned short max)
2533 l1 = ((random() >> 16) * max) / 0x7fff;
2540 char read_level(void)
2546 if ((handle = dat_open("levelmap.txt", datfile_name, "rb")) == 0) {
2547 strcpy(main_info.error_str, "Error loading 'levelmap.txt', aborting...\n");
2551 for (c1 = 0; c1 < 16; c1++) {
2552 for (c2 = 0; c2 < 22; c2++) {
2554 chr = fgetc(handle);
2559 if (chr >= '0' && chr <= '4')
2562 ban_map[c1][c2] = chr - '0';
2566 for (c2 = 0; c2 < 22; c2++)
2567 ban_map[16][c2] = 1;
2575 FILE *dat_open(char *file_name, char *dat_name, char *mode)
2583 if ((handle = fopen(dat_name, mode)) == NULL)
2586 num = fgetc(handle) + (fgetc(handle) << 8) + (fgetc(handle) << 16) + (fgetc(handle) << 24);
2587 for (c1 = 0; c1 < num; c1++) {
2588 fread(name, 1, 12, handle);
2589 if (strnicmp(name, file_name, strlen(file_name)) == 0) {
2590 ofs = fgetc(handle) + (fgetc(handle) << 8) + (fgetc(handle) << 16) + (fgetc(handle) << 24);
2591 fseek(handle, ofs, SEEK_SET);
2594 fseek(handle, 8, SEEK_CUR);
2601 int dat_filelen(char *file_name, char *dat_name)
2609 if ((handle = fopen(dat_name, "rb")) == NULL)
2612 num = fgetc(handle) + (fgetc(handle) << 8) + (fgetc(handle) << 16) + (fgetc(handle) << 24);
2613 for (c1 = 0; c1 < num; c1++) {
2614 fread(name, 1, 12, handle);
2615 if (strnicmp(name, file_name, strlen(file_name)) == 0) {
2616 fseek(handle, 4, SEEK_CUR);
2617 len = fgetc(handle) + (fgetc(handle) << 8) + (fgetc(handle) << 16) + (fgetc(handle) << 24);
2620 fseek(handle, 8, SEEK_CUR);
2626 void write_calib_data(void)
2634 if ((handle = fopen(datfile_name, "rb")) == NULL)
2636 len = filelength(fileno(handle));
2637 if ((mem = malloc(len)) == NULL)
2639 fread(mem, 1, len, handle);
2643 num = *(int *) (&mem[0]);
2644 for (c1 = 0; c1 < num; c1++) {
2645 if (strnicmp(&mem[ofs], "calib.dat", strlen("calib.dat")) == 0) {
2646 ofs = *(int *) (&mem[ofs + 12]);
2652 mem[ofs] = joy.calib_data.x1 & 0xff;
2653 mem[ofs + 1] = (joy.calib_data.x1 >> 8) & 0xff;
2654 mem[ofs + 2] = (joy.calib_data.x1 >> 16) & 0xff;
2655 mem[ofs + 3] = (joy.calib_data.x1 >> 24) & 0xff;
2656 mem[ofs + 4] = joy.calib_data.x2 & 0xff;
2657 mem[ofs + 5] = (joy.calib_data.x2 >> 8) & 0xff;
2658 mem[ofs + 6] = (joy.calib_data.x2 >> 16) & 0xff;
2659 mem[ofs + 7] = (joy.calib_data.x2 >> 24) & 0xff;
2660 mem[ofs + 8] = joy.calib_data.x3 & 0xff;
2661 mem[ofs + 9] = (joy.calib_data.x3 >> 8) & 0xff;
2662 mem[ofs + 10] = (joy.calib_data.x3 >> 16) & 0xff;
2663 mem[ofs + 11] = (joy.calib_data.x3 >> 24) & 0xff;
2664 mem[ofs + 12] = joy.calib_data.y1 & 0xff;
2665 mem[ofs + 13] = (joy.calib_data.y1 >> 8) & 0xff;
2666 mem[ofs + 14] = (joy.calib_data.y1 >> 16) & 0xff;
2667 mem[ofs + 15] = (joy.calib_data.y1 >> 24) & 0xff;
2668 mem[ofs + 16] = joy.calib_data.y2 & 0xff;
2669 mem[ofs + 17] = (joy.calib_data.y2 >> 8) & 0xff;
2670 mem[ofs + 18] = (joy.calib_data.y2 >> 16) & 0xff;
2671 mem[ofs + 19] = (joy.calib_data.y2 >> 24) & 0xff;
2672 mem[ofs + 20] = joy.calib_data.y3 & 0xff;
2673 mem[ofs + 21] = (joy.calib_data.y3 >> 8) & 0xff;
2674 mem[ofs + 22] = (joy.calib_data.y3 >> 16) & 0xff;
2675 mem[ofs + 23] = (joy.calib_data.y3 >> 24) & 0xff;
2677 if ((handle = fopen(datfile_name, "wb")) == NULL)
2679 fwrite(mem, 1, len, handle);