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

Last change on this file since 494 was 494, checked in by Sam Hocevar, 11 years ago

style: remove trailing spaces, fix copyright statements.

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