source: abuse/trunk/src/compiled.cpp @ 129

Last change on this file since 129 was 129, checked in by Sam Hocevar, 15 years ago
  • Get rid of jmalloc and replace it with standard malloc. Modern operating systems certainly perform a lot better than this custom implementation, and we have superior tools (eg. valgrind) to debug and profile memory usage without interfering with the code itself.
File size: 4.9 KB
Line 
1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 1995 Crack dot Com
4 *
5 *  This software was released into the Public Domain. As with most public
6 *  domain software, no warranty is made or implied by Crack dot Com or
7 *  Jonathan Clark.
8 */
9
10#include "config.h"
11
12#include <string.h>
13
14#include "lisp.hpp"
15#include "macs.hpp"
16
17extern int total_objects;
18
19uint8_t *bad_guy_array=NULL;  // list flaging each character saying they are a bad bug or not
20                              // mainly used by the rocket to find targets
21
22int32_t S_fall_start,S_falling,S_landing,S_pounce_wait,
23     S_turn_around,S_fire_wait,S_ceil_fire,S_top_walk,
24     S_blown_back_dead,S_jump_up,S_hiding,S_weapon_fire,
25     S_hanging,S_blocking,S_rotate,S_climbing,S_climb_off,
26     S_fly_stopped,S_fast_stopped,S_fast_running,S_fly_running,
27     S_fly_start_run_jump,S_fly_run_jump,S_fly_run_jump_fall,S_fly_end_run_jump,
28     S_fast_start_run_jump,S_fast_run_jump,S_fast_run_jump_fall,S_fast_end_run_jump,
29     S_bright_tint,S_climb_on,
30     S_ASCREAM_SND,S_ALAND_SND,S_ASLASH_SND,S_ROCKET_TOP,S_BFG_TOP,
31     S_GRENADE_TOP,S_FIREBOMB_TOP,S_DFRIS_TOP,S_ANT_ROOF,
32     S_MGUN_TOP,S_CLOUD,S_HIDDEN_ANT,
33     S_health_image,S_fly_image,S_fast_image,
34     S_sneaky_image,S_EXPLODE3,S_EXPLODE5,S_ROCKET,S_SCARE_SND,
35     S_TRACK_GUN,S_SPRAY_GUN,S_LPING_SND,S_FLY_SND,S_SPEED_SND,S_LOW_HEALTH_SND,
36     S_BUTTON_PRESS_SND,
37     S_LINK_SND,S_DELETE_SND;
38
39int compile_error=0;
40
41static int32_t c_state(char const *name)
42{
43  void *sym=find_symbol(name);
44  if (sym)
45  {
46    if (item_type(((lisp_symbol *)sym)->value)!=L_NUMBER)
47      compile_error=1;
48    else
49      return lnumber_value(((lisp_symbol *)sym)->value);
50  } else compile_error=1;
51  return 0;
52}
53
54extern int last_save_game_number;
55
56void compiled_init()
57{
58  S_fall_start=  c_state("fall_start");
59  S_falling=     c_state("falling");
60  S_landing=     c_state("landing");
61  S_pounce_wait= c_state("pounce_wait");
62  S_turn_around= c_state("turn_around");
63  S_fire_wait=   c_state("fire_wait");
64  S_ceil_fire=   c_state("ceil_fire");
65  S_top_walk=    c_state("top_walk");
66  S_jump_up=     c_state("jump_up");
67  S_rotate=      c_state("rotate");
68  S_hiding=      c_state("hiding");
69  S_weapon_fire= c_state("weapon_fire");
70  S_climbing=    c_state("climbing");
71  S_climb_off=   c_state("climb_off");
72  S_blown_back_dead=c_state("blown_back_dead");
73  S_hanging=     c_state("hanging");
74  S_blocking=     c_state("blocking");
75
76  S_fly_stopped= c_state("fly_stopped");
77  S_fast_stopped=c_state("fast_stopped");
78  S_fast_running=c_state("fast_running");
79  S_fly_running= c_state("fly_running");
80
81  S_fly_start_run_jump=     c_state("fly_start_run_jump");
82  S_fly_run_jump=           c_state("fly_run_jump");
83  S_fly_run_jump_fall=      c_state("fly_run_jump_fall");
84  S_fly_end_run_jump=       c_state("fly_end_run_jump");
85
86  S_fast_start_run_jump=    c_state("fast_start_run_jump");
87  S_fast_run_jump=          c_state("fast_run_jump");
88  S_fast_run_jump_fall=     c_state("fast_run_jump_fall");
89  S_fast_end_run_jump=      c_state("fast_end_run_jump");
90  S_bright_tint=            c_state("bright_tint");
91  S_climb_on=               c_state("climb_on");
92
93  S_ALAND_SND=   c_state("ALAND_SND");
94  S_ASCREAM_SND= c_state("ASCREAM_SND");
95  S_ASLASH_SND=  c_state("ASLASH_SND");
96  S_GRENADE_TOP= c_state("GRENADE_TOP");
97  S_FIREBOMB_TOP=c_state("FIREBOMB_TOP");
98  S_ANT_ROOF=    c_state("ANT_ROOF");
99  S_MGUN_TOP=    c_state("MGUN_TOP");
100  S_DFRIS_TOP=   c_state("DFRIS_TOP");
101  S_ROCKET_TOP=  c_state("ROCKET_TOP");
102  S_BFG_TOP=     c_state("BFG_TOP");
103  S_CLOUD=       c_state("CLOUD");
104  S_HIDDEN_ANT=  c_state("HIDDEN_ANT");
105  S_health_image=c_state("health_image");
106  S_fly_image=   c_state("fly_image");
107  S_sneaky_image=c_state("sneaky_image");
108  S_fast_image  =c_state("fast_image");
109  S_EXPLODE5=    c_state("EXPLODE5");
110  S_EXPLODE3=    c_state("EXPLODE3");
111  S_ROCKET=      c_state("ROCKET");
112  S_TRACK_GUN=   c_state("TRACK_GUN");
113  S_SPRAY_GUN=   c_state("SPRAY_GUN");
114  S_LPING_SND=   c_state("LPING_SND");
115  S_FLY_SND=     c_state("FLY_SND");
116  S_SPEED_SND=   c_state("SPEED_SND");
117  S_LOW_HEALTH_SND=c_state("LOW_HEALTH_SND");
118  S_SCARE_SND=   c_state("SCARE_SND");
119  S_BUTTON_PRESS_SND=c_state("BUTTON_PRESS_SND");
120  S_LINK_SND=    c_state("LINK_OBJECT_SND");
121  S_DELETE_SND=  c_state("DEL_OBJECT_SND");
122
123  void *b=make_find_symbol("bad_guy_list");
124  if (b && DEFINEDP(symbol_value(b)))
125  {
126    b=symbol_value(b);
127    bad_guy_array=(uint8_t *)malloc(total_objects);
128    memset(bad_guy_array,0,total_objects);
129    while (b)
130    {
131      int32_t x=lnumber_value(CAR(b));
132      if (x>=0 && x<total_objects)
133        bad_guy_array[x]=1;
134      else { lbreak("objetc number out of range %d\n",x); }
135      b=lcdr(b);
136    }
137  }
138
139  void *v=symbol_value(make_find_symbol("last_save_game"));
140  if (DEFINEDP(v))
141    last_save_game_number=lnumber_value(v);
142  else last_save_game_number=0;
143}
144
145
146
147
148void compiled_uninit()
149{
150  if (bad_guy_array)
151    free(bad_guy_array);
152}
Note: See TracBrowser for help on using the repository browser.