00001
00002
00003
00004
00005 #ifndef SP_LEV_H
00006 #define SP_LEV_H
00007
00008
00009 #define W_NORTH 1
00010 #define W_SOUTH 2
00011 #define W_EAST 4
00012 #define W_WEST 8
00013 #define W_ANY (W_NORTH|W_SOUTH|W_EAST|W_WEST)
00014
00015
00016 #define MAP_X_LIM 76
00017 #define MAP_Y_LIM 21
00018
00019
00020 #define NOTELEPORT 0x00000001L
00021 #define HARDFLOOR 0x00000002L
00022 #define NOMMAP 0x00000004L
00023 #define SHORTSIGHTED 0x00000008L
00024 #define ARBOREAL 0x00000010L
00025 #define NOFLIPX 0x00000020L
00026 #define NOFLIPY 0x00000040L
00027 #define MAZELEVEL 0x00000080L
00028 #define PREMAPPED 0x00000100L
00029 #define SHROUD 0x00000200L
00030 #define STORMY 0x00000400L
00031 #define GRAVEYARD 0x00000800L
00032
00033
00034 #define LVLINIT_NONE 0
00035 #define LVLINIT_SOLIDFILL 1
00036 #define LVLINIT_MAZEGRID 2
00037 #define LVLINIT_MINES 3
00038
00039
00040 #define MAX_CONTAINMENT 10
00041
00042
00043 #define MAX_REGISTERS 10
00044
00045
00046 #define MAX_NESTED_ROOMS 5
00047
00048
00049 #define SPCODER_MAX_RUNTIME 65536
00050
00051
00052
00053
00054 enum opcode_defs {
00055 SPO_NULL = 0,
00056 SPO_MESSAGE,
00057 SPO_MONSTER,
00058 SPO_OBJECT,
00059 SPO_ENGRAVING,
00060 SPO_ROOM,
00061 SPO_SUBROOM,
00062 SPO_DOOR,
00063 SPO_STAIR,
00064 SPO_LADDER,
00065 SPO_ALTAR,
00066 SPO_FOUNTAIN,
00067 SPO_SINK,
00068 SPO_POOL,
00069 SPO_TRAP,
00070 SPO_GOLD,
00071 SPO_CORRIDOR,
00072 SPO_LEVREGION,
00073 SPO_DRAWBRIDGE,
00074 SPO_MAZEWALK,
00075 SPO_NON_DIGGABLE,
00076 SPO_NON_PASSWALL,
00077 SPO_WALLIFY,
00078 SPO_MAP,
00079 SPO_ROOM_DOOR,
00080 SPO_REGION,
00081 SPO_CMP,
00082 SPO_JMP,
00083 SPO_JL,
00084 SPO_JLE,
00085 SPO_JG,
00086 SPO_JGE,
00087 SPO_JE,
00088 SPO_JNE,
00089 SPO_SPILL,
00090 SPO_TERRAIN,
00091 SPO_REPLACETERRAIN,
00092 SPO_EXIT,
00093 SPO_ENDROOM,
00094 SPO_POP_CONTAINER,
00095 SPO_PUSH,
00096 SPO_POP,
00097 SPO_RN2,
00098 SPO_DEC,
00099 SPO_INC,
00100 SPO_MATH_ADD,
00101 SPO_MATH_SUB,
00102 SPO_MATH_MUL,
00103 SPO_MATH_DIV,
00104 SPO_MATH_MOD,
00105 SPO_COPY,
00106 SPO_MON_GENERATION,
00107 SPO_END_MONINVENT,
00108 SPO_GRAVE,
00109 SPO_FRAME_PUSH,
00110 SPO_FRAME_POP,
00111 SPO_CALL,
00112 SPO_RETURN,
00113 SPO_INITLEVEL,
00114 SPO_LEVEL_FLAGS,
00115 SPO_LEVEL_SOUNDS,
00116 SPO_WALLWALK,
00117 SPO_VAR_INIT,
00118 SPO_SHUFFLE_ARRAY,
00119 SPO_DICE,
00120
00121 SPO_SEL_ADD,
00122 SPO_SEL_POINT,
00123 SPO_SEL_RECT,
00124 SPO_SEL_FILLRECT,
00125 SPO_SEL_LINE,
00126 SPO_SEL_RNDLINE,
00127 SPO_SEL_GROW,
00128 SPO_SEL_FLOOD,
00129 SPO_SEL_RNDCOORD,
00130 SPO_SEL_ELLIPSE,
00131 SPO_SEL_FILTER,
00132
00133 MAX_SP_OPCODES
00134 };
00135
00136
00137
00138
00139
00140
00141
00142 #define SP_M_V_PEACEFUL 0
00143 #define SP_M_V_ALIGN 1
00144 #define SP_M_V_ASLEEP 2
00145 #define SP_M_V_APPEAR 3
00146 #define SP_M_V_NAME 4
00147
00148 #define SP_M_V_FEMALE 5
00149 #define SP_M_V_INVIS 6
00150 #define SP_M_V_CANCELLED 7
00151 #define SP_M_V_REVIVED 8
00152 #define SP_M_V_AVENGE 9
00153 #define SP_M_V_FLEEING 10
00154 #define SP_M_V_BLINDED 11
00155 #define SP_M_V_PARALYZED 12
00156 #define SP_M_V_STUNNED 13
00157 #define SP_M_V_CONFUSED 14
00158 #define SP_M_V_SEENTRAPS 15
00159
00160 #define SP_M_V_END 16
00161
00162
00163 #define SP_O_V_SPE 0
00164 #define SP_O_V_CURSE 1
00165 #define SP_O_V_CORPSENM 2
00166 #define SP_O_V_NAME 3
00167 #define SP_O_V_QUAN 4
00168 #define SP_O_V_BURIED 5
00169 #define SP_O_V_LIT 6
00170 #define SP_O_V_ERODED 7
00171 #define SP_O_V_LOCKED 8
00172 #define SP_O_V_TRAPPED 9
00173 #define SP_O_V_RECHARGED 10
00174 #define SP_O_V_INVIS 11
00175 #define SP_O_V_GREASED 12
00176 #define SP_O_V_BROKEN 13
00177 #define SP_O_V_COORD 14
00178 #define SP_O_V_END 15
00179
00180
00181
00182
00183
00184 #define SP_OBJ_CONTENT 0x1
00185 #define SP_OBJ_CONTAINER 0x2
00186
00187
00188
00189 #define SPOVAR_NULL 0x00
00190 #define SPOVAR_INT 0x01
00191 #define SPOVAR_STRING 0x02
00192 #define SPOVAR_VARIABLE 0x03
00193 #define SPOVAR_COORD 0x04
00194 #define SPOVAR_REGION 0x05
00195 #define SPOVAR_MAPCHAR 0x06
00196 #define SPOVAR_MONST 0x07
00197 #define SPOVAR_OBJ 0x08
00198 #define SPOVAR_SEL 0x09
00199 #define SPOVAR_ARRAY 0x40
00200
00201 #define SP_COORD_X(l) (l & 0xff)
00202 #define SP_COORD_Y(l) ((l >> 16) & 0xff)
00203 #define SP_COORD_PACK(x,y) ((( x ) & 0xff) + ((( y ) & 0xff) << 16))
00204
00205 #define SP_REGION_X1(l) (l & 0xff)
00206 #define SP_REGION_Y1(l) ((l >> 8) & 0xff)
00207 #define SP_REGION_X2(l) ((l >> 16) & 0xff)
00208 #define SP_REGION_Y2(l) ((l >> 24) & 0xff)
00209 #define SP_REGION_PACK(x1,y1,x2,y2) ((( x1 ) & 0xff) + ((( y1 ) & 0xff) << 8) + ((( x2 ) & 0xff) << 16) + ((( y2 ) & 0xff) << 24))
00210
00211 #define SP_MONST_CLASS(l) (l & 0xff)
00212 #define SP_MONST_PM(l) ((l >> 8) & 0xffff)
00213 #define SP_MONST_PACK(m,c) ((( m ) << 8) + ((char)( c )))
00214
00215 #define SP_OBJ_CLASS(l) (l & 0xff)
00216 #define SP_OBJ_TYP(l) ((l >> 8) & 0xffff)
00217 #define SP_OBJ_PACK(o,c) ((( o ) << 8) + ((char)( c )))
00218
00219 #define SP_MAPCHAR_TYP(l) (l & 0xff)
00220 #define SP_MAPCHAR_LIT(l) ((l >> 8) & 0xff)
00221 #define SP_MAPCHAR_PACK(typ,lit) ((( lit ) << 8) + ((char)( typ )))
00222
00223 struct opvar {
00224 xchar spovartyp;
00225 union {
00226 char *str;
00227 long l;
00228 } vardata;
00229 };
00230
00231 struct splev_var {
00232 struct splev_var *next;
00233 char *name;
00234 xchar svtyp;
00235 union {
00236 struct opvar *value;
00237 struct opvar **arrayvalues;
00238 } data;
00239 long array_len;
00240 };
00241
00242 struct splevstack {
00243 long depth;
00244 long depth_alloc;
00245 struct opvar **stackdata;
00246 };
00247
00248
00249 struct sp_frame {
00250 struct sp_frame *next;
00251 struct splevstack *stack;
00252 struct splev_var *variables;
00253 long n_opcode;
00254 };
00255
00256
00257 struct sp_coder {
00258 struct splevstack *stack;
00259 struct sp_frame *frame;
00260 int allow_flips;
00261 int premapped;
00262 struct mkroom *croom;
00263 struct mkroom *tmproomlist[MAX_NESTED_ROOMS+1];
00264 boolean failed_room[MAX_NESTED_ROOMS+1];
00265 int n_subroom;
00266 boolean exit_script;
00267 int lvl_is_joined;
00268
00269 int opcode;
00270 struct opvar *opdat;
00271 };
00272
00273
00274 #define SP_CPUFLAG_LT 1
00275 #define SP_CPUFLAG_GT 2
00276 #define SP_CPUFLAG_EQ 4
00277 #define SP_CPUFLAG_ZERO 8
00278
00279
00280
00281
00282
00283 typedef struct {
00284 xchar x1,y1,x2,y2;
00285 xchar fg, lit;
00286 int roughness;
00287 xchar thick;
00288 } randline;
00289
00290 typedef struct {
00291 int cmp_what;
00292 int cmp_val;
00293 } opcmp;
00294
00295 typedef struct {
00296 long jmp_target;
00297 } opjmp;
00298
00299 typedef union str_or_len {
00300 char *str;
00301 int len;
00302 } Str_or_Len;
00303
00304 typedef struct {
00305 xchar init_style;
00306 char fg, bg;
00307 boolean smoothed, joined;
00308 xchar lit, walled;
00309 long flags;
00310 schar filling;
00311 } lev_init;
00312
00313 typedef struct {
00314 xchar x, y, mask;
00315 } door;
00316
00317 typedef struct {
00318 xchar wall, pos, secret, mask;
00319 } room_door;
00320
00321 typedef struct {
00322 xchar x, y, type;
00323 } trap;
00324
00325 typedef struct {
00326 Str_or_Len name, appear_as;
00327 short id;
00328 aligntyp align;
00329 xchar x, y, class, appear;
00330 schar peaceful, asleep;
00331 short female, invis, cancelled, revived, avenge, fleeing, blinded, paralyzed, stunned, confused;
00332 long seentraps;
00333 short has_invent;
00334 } monster;
00335
00336 typedef struct {
00337 Str_or_Len name;
00338 int corpsenm;
00339 short id, spe;
00340 xchar x, y, class, containment;
00341 schar curse_state;
00342 int quan;
00343 short buried;
00344 short lit;
00345 short eroded, locked, trapped, recharged, invis, greased, broken;
00346 } object;
00347
00348 typedef struct {
00349 xchar x, y;
00350 aligntyp align;
00351 xchar shrine;
00352 } altar;
00353
00354 typedef struct {
00355 xchar x, y, dir, db_open;
00356 } drawbridge;
00357
00358 typedef struct {
00359 xchar x, y, dir, stocked, typ;
00360 } walk;
00361
00362 typedef struct {
00363 xchar x1, y1, x2, y2;
00364 } digpos;
00365
00366 typedef struct {
00367 xchar x, y, up;
00368 } lad;
00369
00370 typedef struct {
00371 xchar x, y, up;
00372 } stair;
00373
00374 typedef struct {
00375 xchar x1, y1, x2, y2;
00376 xchar rtype, rlit, rirreg;
00377 } region;
00378
00379 typedef struct {
00380 xchar areatyp;
00381 xchar x1,y1,x2,y2;
00382 xchar ter, tlit;
00383 } terrain;
00384
00385 typedef struct {
00386 xchar chance;
00387 xchar x1,y1,x2,y2;
00388 xchar fromter, toter, tolit;
00389 } replaceterrain;
00390
00391
00392 typedef struct {
00393 struct { xchar x1, y1, x2, y2; } inarea;
00394 struct { xchar x1, y1, x2, y2; } delarea;
00395 boolean in_islev, del_islev;
00396 xchar rtype, padding;
00397 Str_or_Len rname;
00398 } lev_region;
00399
00400 typedef struct {
00401 xchar x, y;
00402 int amount;
00403 } gold;
00404
00405 typedef struct {
00406 xchar x, y;
00407 Str_or_Len engr;
00408 xchar etype;
00409 } engraving;
00410
00411 typedef struct {
00412 xchar x, y;
00413 } fountain;
00414
00415 typedef struct {
00416 xchar x, y;
00417 } sink;
00418
00419 typedef struct {
00420 xchar x, y;
00421 } pool;
00422
00423 typedef struct _room {
00424 Str_or_Len name;
00425 Str_or_Len parent;
00426 xchar x, y, w, h;
00427 xchar xalign, yalign;
00428 xchar rtype, chance, rlit, filled;
00429 } room;
00430
00431 typedef struct {
00432 schar zaligntyp;
00433 schar keep_region;
00434 schar halign, valign;
00435 char xsize, ysize;
00436 char **map;
00437 } mazepart;
00438
00439 typedef struct {
00440 struct {
00441 xchar room;
00442 xchar wall;
00443 xchar door;
00444 } src, dest;
00445 } corridor;
00446
00447 typedef struct {
00448 int opcode;
00449 struct opvar *opdat;
00450 } _opcode;
00451
00452 typedef struct {
00453 _opcode *opcodes;
00454 long n_opcodes;
00455 } sp_lev;
00456
00457 typedef struct {
00458 xchar x, y, direction, count, lit;
00459 char typ;
00460 } spill;
00461
00462
00463
00464
00465 struct lc_funcdefs {
00466 struct lc_funcdefs *next;
00467 char *name;
00468 long addr;
00469 sp_lev code;
00470 long n_called;
00471 };
00472
00473 struct lc_vardefs {
00474 struct lc_vardefs *next;
00475 char *name;
00476 long var_type;
00477 };
00478
00479 #endif