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

Last change on this file since 682 was 636, checked in by Sam Hocevar, 9 years ago

lisp: merge the Lisp and LispGC classes and improve coding style.

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