Index: class.c ================================================================== --- class.c +++ class.c @@ -35,11 +35,10 @@ Uint32 num; } Op_Names; #include "instruc.h" #define Tokenf(x) (tokent&(x)) -Value globals[0x800]; Value initglobals[0x800]; Class*classes[0x4000]; const char*messages[0x4000]; Uint16 functions[0x4000]; int max_animation=32; @@ -337,10 +336,18 @@ tokent=macstack->tok->t; if(tokent&TF_EOF) ParseError("Unexpected end of file in macro expansion\n"); tokenv=macstack->tok->v; *tokenstr=0; if(macstack->tok->str) strcpy(tokenstr,macstack->tok->str); + if(main_options['M']) { + printf("M* Macro %04X %08X \"",tokent,tokenv); + for(i=0;tokenstr[i];i++) { + if(tokenstr[i]<32 || tokenstr[i]>126) printf("<%02X>",tokenstr[i]&255); + else putchar(tokenstr[i]); + } + printf("\"\n"); + } if(tokent==TF_MACRO+TF_INT && macstack->n>=0) { if(tokenv&~0xFF) { tokenv-=0x100; } else { if(tokenvn) tl=macstack->args[tokenv]; @@ -353,10 +360,11 @@ MacroStack*ms=macstack->next; for(i=0;in;i++) free_macro(macstack->args[i]); free(macstack->args); free(macstack); macstack=ms; + if(main_options['M']) printf("M.\n"); } if(pr) { if(tl) { MacroStack*ms=malloc(sizeof(MacroStack)); if(!ms) fatal("Allocation failed\n"); @@ -364,10 +372,11 @@ ms->n=-1; ms->args=0; ms->next=macstack; macstack=ms; } + if(main_options['M']) printf("M^ %d\n",tl?1:0); goto magain; } return; } fl=n=pr=0; @@ -579,10 +588,19 @@ ms->n=0; ms->args=0; for(;;) { nxttok1(); if(tokent&TF_EOF) ParseError("Unexpected end of file in macro argument\n"); + if(main_options['M']) { + int i; + printf("M= %c%4d %04X %08X \"",b?'|':a?'^':' ',ms->n,tokent,tokenv); + for(i=0;tokenstr[i];i++) { + if(tokenstr[i]<32 || tokenstr[i]>126) printf("<%02X>",tokenstr[i]&255); + else putchar(tokenstr[i]); + } + printf("\"\n"); + } if(tokent&TF_OPEN) { ++a; if(tokent&TF_MACRO) ++c; } if(tokent&TF_CLOSE) { @@ -636,10 +654,11 @@ } else if(tokent&TF_MACRO) { Uint32 n; char*s; if(tokent&TF_OPEN) { call: + if(main_options['M']) printf("M+ {%s}\n",glohash[tokenv].txt); switch(glohash[tokenv].id) { case 0xC000 ... MAX_MACRO+0xC000-1: begin_macro(macros[glohash[tokenv].id-0xC000]); goto again; case MAC_ADD: @@ -814,10 +833,11 @@ ParseError("Undefined macro: {%s}\n",tokenstr); break; default: ParseError("Strange macro token: 0x%04X\n",glohash[tokenv].id); } + if(main_options['M']) printf("M-\n"); } } } static int pool_string(const char*s) { Index: compile ================================================================== --- compile +++ compile @@ -1,19 +1,20 @@ #!/bin/bash -- test -f CFLAGS || echo xxx > CFLAGS -test "xx$CFLAGS" = "x`cat CFLAGS`" || rm bindings.o class.o picture.o function.o +test "xx$CFLAGS" = "x`cat CFLAGS`" || rm bindings.o class.o picture.o function.o exec.o echo "x$CFLAGS" > CFLAGS test "x$EXE" = "x" && EXE=~/bin/heromesh test instruc -nt instruc.h && node instruc.js > instruc.h test instruc.js -nt instruc.h && node instruc.js > instruc.h test names.js -nt names.h && node names.js > names.h test quarks -nt quarks.h && node quarks.js > quarks.h test quarks.js -nt quarks.h && node quarks.js > quarks.h -test heromesh.h -nt "$EXE" && rm bindings.o class.o picture.o function.o +test heromesh.h -nt "$EXE" && rm bindings.o class.o picture.o function.o exec.o test instruc.h -nt "$EXE" && rm class.o test pcfont.h -nt "$EXE" && rm picture.o test quarks.h -nt "$EXE" && rm bindings.o picture.o test bindings.c -nt bindings.o && bash bindings.c test class.c -nt class.o && bash class.c test function.c -nt function.o && bash function.c test picture.c -nt picture.o && bash picture.c +test exec.c -nt exec.o && bash exec.c bash main.c ADDED exec.c Index: exec.c ================================================================== --- exec.c +++ exec.c @@ -0,0 +1,18 @@ +#if 0 +gcc ${CFLAGS:--s -O2} -c exec.c `sdl-config --cflags` +exit +#endif + +#include "SDL.h" +#include +#include +#include +#include "sqlite3.h" +#include "smallxrm.h" +#include "heromesh.h" + +Uint32 generation_number; +Object*objects; +Uint32 nobjects; +Value globals[0x800]; + Index: heromesh.h ================================================================== --- heromesh.h +++ heromesh.h @@ -37,11 +37,10 @@ extern sqlite3*userdb; extern xrm_db*resourcedb; extern const char*basefilename; extern xrm_quark optionquery[16]; -extern Uint32 generation_number; extern char main_options[128]; extern Uint8 message_trace[0x4100/8]; unsigned char*read_lump(int sol,int lvl,long*sz,sqlite3_value**us); void write_lump(int sol,int lvl,long sz,const unsigned char*data); @@ -95,11 +94,10 @@ Uint16 sharp[4]; Uint16 hard[4]; Uint8 cflags,shape,shovable,collisionLayers,nimages; } Class; -extern Value globals[0x800]; extern Value initglobals[0x800]; extern Class*classes[0x4000]; // 0 isn't a real class extern const char*messages[0x4000]; // index is 256 less than message number extern Uint16 functions[0x4000]; extern int max_animation; // max steps in animation queue (default 32) @@ -126,5 +124,27 @@ // == function == void init_sql_functions(sqlite3_int64*ptr0,sqlite3_int64*ptr1); +// == exec == + +// The following "internal object flags" are part of the "dir" variable: +#define IOF_DEAD 0x10 // object doesn't exist, except to continue an animation +#define IOF_ANIM 0x20 // an animation is being displayed + +typedef struct { + Sint32 height,weight,climb,density,volume,strength,arrivals,departures,temperature; + Uint32 arrived,departed,arrived2,departed2,generation,up; + Uint16 class,oflags; + Uint16 sharp[4]; + Uint16 hard[4]; + Uint8 x,y,shape,shovable,image,dir; + Value misc1,misc2,misc3,misc4,misc5,misc6,misc7; + Value uservars[0]; +} Object; + +extern Uint32 generation_number; +extern Object*objects; +extern Uint32 nobjects; +extern Value globals[0x800]; + Index: main.c ================================================================== --- main.c +++ main.c @@ -39,11 +39,10 @@ sqlite3*userdb; xrm_db*resourcedb; const char*basefilename; xrm_quark optionquery[16]; -Uint32 generation_number; char main_options[128]; Uint8 message_trace[0x4100/8]; static const char*globalclassname; static SDL_Cursor*cursor[77];