︙ | | | ︙ | |
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
Uint32 nobjects;
Value globals[0x800];
Uint32 firstobj=VOIDLINK;
Uint32 lastobj=VOIDLINK;
Uint32 playfield[64*64];
Uint8 pfwidth,pfheight;
Sint8 gameover,key_ignored;
typedef struct {
Uint16 msg;
Uint32 from;
Value arg1,arg2,arg3;
} MessageVars;
|
>
|
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
Uint32 nobjects;
Value globals[0x800];
Uint32 firstobj=VOIDLINK;
Uint32 lastobj=VOIDLINK;
Uint32 playfield[64*64];
Uint8 pfwidth,pfheight;
Sint8 gameover,key_ignored;
Uint8 generation_number_inc;
typedef struct {
Uint16 msg;
Uint32 from;
Value arg1,arg2,arg3;
} MessageVars;
|
︙ | | | ︙ | |
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
Uint32 n;
Class*cl=classes[c];
Object*o=0;
if(!c || !cl || cl->cflags&(CF_GROUP|CF_NOCLASS2)) goto bad;
o=calloc(1,sizeof(Object)+cl->uservars*sizeof(Value));
if(!o) fatal("Allocation failed\n");
o->class=c;
o->generation=generation_number;
#define C(x) o->x=cl->x;
C(height) C(weight) C(climb) C(density) C(volume) C(strength) C(arrivals) C(departures) C(temperature)
C(shape) C(shovable) C(oflags)
C(sharp[0]) C(sharp[1]) C(sharp[2]) C(sharp[3])
C(hard[0]) C(hard[1]) C(hard[2]) C(hard[3])
#undef C
|
>
>
>
>
>
|
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
Uint32 n;
Class*cl=classes[c];
Object*o=0;
if(!c || !cl || cl->cflags&(CF_GROUP|CF_NOCLASS2)) goto bad;
o=calloc(1,sizeof(Object)+cl->uservars*sizeof(Value));
if(!o) fatal("Allocation failed\n");
o->class=c;
if(generation_number_inc) {
generation_number_inc=0;
++generation_number;
if(generation_number<=TY_MAXTYPE) goto bad;
}
o->generation=generation_number;
#define C(x) o->x=cl->x;
C(height) C(weight) C(climb) C(density) C(volume) C(strength) C(arrivals) C(departures) C(temperature)
C(shape) C(shovable) C(oflags)
C(sharp[0]) C(sharp[1]) C(sharp[2]) C(sharp[3])
C(hard[0]) C(hard[1]) C(hard[2]) C(hard[3])
#undef C
|
︙ | | | ︙ | |
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
}
objects[n]=o;
return n;
bad:
free(o);
return VOIDLINK;
}
static inline int v_bool(Value v) {
switch(v.t) {
case TY_NUMBER: return v.u!=0;
case TY_SOUND: case TY_USOUND: Throw("Cannot convert sound to boolean");
default: return 1;
}
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
}
objects[n]=o;
return n;
bad:
free(o);
return VOIDLINK;
}
void objtrash(Uint32 n) {
Object*o=objects[n];
if(!o) return;
if(o->down==VOIDLINK) playfield[o->x+o->y*64-65]=o->up;
else objects[o->down]->up=o->up;
if(o->up!=VOIDLINK) objects[o->up]->down=o->down;
o->down=o->up=VOIDLINK;
if(firstobj==n) firstobj=o->next;
if(lastobj==n) lastobj=o->prev;
if(o->prev) objects[o->prev]->next=o->next;
if(o->next) objects[o->next]->prev=o->prev;
free(o);
objects[n]=0;
generation_number_inc=1;
}
static inline int v_bool(Value v) {
switch(v.t) {
case TY_NUMBER: return v.u!=0;
case TY_SOUND: case TY_USOUND: Throw("Cannot convert sound to boolean");
default: return 1;
}
|
︙ | | | ︙ | |
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
|
nobjects=0;
free(objects);
objects=0;
gameover=0;
}
const char*execute_turn(int key) {
// Set key=0 for initialization
if(setjmp(my_env)) return my_error;
changed=0;
key_ignored=0;
lastimage_processing=0;
vstackptr=0;
if(key_ignored && changed) return "Invalid use of IgnoreKey";
if(key_ignored && changed) return "Invalid use of IgnoreKey";
return 0;
}
|
<
>
>
>
>
>
>
>
>
>
>
>
>
>
|
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
|
nobjects=0;
free(objects);
objects=0;
gameover=0;
}
const char*execute_turn(int key) {
if(setjmp(my_env)) return my_error;
changed=0;
key_ignored=0;
lastimage_processing=0;
vstackptr=0;
if(key_ignored && changed) return "Invalid use of IgnoreKey";
if(key_ignored && changed) return "Invalid use of IgnoreKey";
if(generation_number<=TY_MAXTYPE) return "Too many generations of objects";
return 0;
}
const char*init_level(void) {
if(setjmp(my_env)) return my_error;
gameover=0;
changed=0;
key_ignored=0;
lastimage_processing=0;
vstackptr=0;
if(generation_number<=TY_MAXTYPE) return "Too many generations of objects";
return 0;
}
|