Overview
Comment: | Add exec.c (moving some things from main.c); add definitions for exec.c in heromesh.h; also add a macro tracing option. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
9ffad27cd3f3715dcce7329143f1fda0 |
User & Date: | user on 2018-06-22 07:17:54 |
Other Links: | manifest | tags |
Context
2018-06-24
| ||
02:12 | Implement stack overflow protection check-in: 9f57c48591 user: user tags: trunk | |
2018-06-22
| ||
07:17 | Add exec.c (moving some things from main.c); add definitions for exec.c in heromesh.h; also add a macro tracing option. check-in: 9ffad27cd3 user: user tags: trunk | |
2018-06-16
| ||
03:26 | Implement flush_usercache() (completely untested so far, though). check-in: 19b4240efe user: user tags: trunk | |
Changes
Modified class.c from [59aa7eb0cd] to [d86091200c].
︙ | ︙ | |||
33 34 35 36 37 38 39 | typedef struct { const char*txt; Uint32 num; } Op_Names; #include "instruc.h" #define Tokenf(x) (tokent&(x)) | < | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | typedef struct { const char*txt; Uint32 num; } Op_Names; #include "instruc.h" #define Tokenf(x) (tokent&(x)) Value initglobals[0x800]; Class*classes[0x4000]; const char*messages[0x4000]; Uint16 functions[0x4000]; int max_animation=32; Sint32 max_volume=10000; Uint8 back_color=1; |
︙ | ︙ | |||
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 | TokenList*tl=0; pr=0; 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(tokent==TF_MACRO+TF_INT && macstack->n>=0) { if(tokenv&~0xFF) { tokenv-=0x100; } else { if(tokenv<macstack->n) tl=macstack->args[tokenv]; if(tl) ref_macro(tl); pr=1; } } macstack->tok=step_macro(macstack->tok); if(!macstack->tok) { MacroStack*ms=macstack->next; for(i=0;i<macstack->n;i++) free_macro(macstack->args[i]); free(macstack->args); free(macstack); macstack=ms; } if(pr) { if(tl) { MacroStack*ms=malloc(sizeof(MacroStack)); if(!ms) fatal("Allocation failed\n"); ms->tok=tl; ms->n=-1; ms->args=0; ms->next=macstack; macstack=ms; } goto magain; } return; } fl=n=pr=0; tokent=tokenv=0; *tokenstr=0; | > > > > > > > > > > | 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 | TokenList*tl=0; pr=0; 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(tokenv<macstack->n) tl=macstack->args[tokenv]; if(tl) ref_macro(tl); pr=1; } } macstack->tok=step_macro(macstack->tok); if(!macstack->tok) { MacroStack*ms=macstack->next; for(i=0;i<macstack->n;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"); ms->tok=tl; 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; tokent=tokenv=0; *tokenstr=0; |
︙ | ︙ | |||
577 578 579 580 581 582 583 584 585 586 587 588 589 590 | if(!ms) fatal("Allocation failed\n"); ms->tok=mac; ms->n=0; ms->args=0; for(;;) { nxttok1(); if(tokent&TF_EOF) ParseError("Unexpected end of file in macro argument\n"); if(tokent&TF_OPEN) { ++a; if(tokent&TF_MACRO) ++c; } if(tokent&TF_CLOSE) { --a; if(tokent&TF_MACRO) --c; | > > > > > > > > > | 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 | if(!ms) fatal("Allocation failed\n"); ms->tok=mac; 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) { --a; if(tokent&TF_MACRO) --c; |
︙ | ︙ | |||
634 635 636 637 638 639 640 641 642 643 644 645 646 647 | goto again; } } else if(tokent&TF_MACRO) { Uint32 n; char*s; if(tokent&TF_OPEN) { call: switch(glohash[tokenv].id) { case 0xC000 ... MAX_MACRO+0xC000-1: begin_macro(macros[glohash[tokenv].id-0xC000]); goto again; case MAC_ADD: n=0; for(;;) { | > | 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 | goto again; } } 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: n=0; for(;;) { |
︙ | ︙ | |||
812 813 814 815 816 817 818 819 820 821 822 823 824 825 | goto call; case MAC_UNDEFINED: ParseError("Undefined macro: {%s}\n",tokenstr); break; default: ParseError("Strange macro token: 0x%04X\n",glohash[tokenv].id); } } } } static int pool_string(const char*s) { int i; for(i=0;i<num_strings;i++) if(!strcmp(s,stringpool[i])) return i; | > | 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 | goto call; case MAC_UNDEFINED: 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) { int i; for(i=0;i<num_strings;i++) if(!strcmp(s,stringpool[i])) return i; |
︙ | ︙ |
Modified compile from [626fabb32d] to [67c0841242].
1 2 | #!/bin/bash -- test -f CFLAGS || echo xxx > CFLAGS | | | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #!/bin/bash -- test -f CFLAGS || echo xxx > CFLAGS 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 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 version [7c6d309993].
> > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #if 0 gcc ${CFLAGS:--s -O2} -c exec.c `sdl-config --cflags` exit #endif #include "SDL.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include "sqlite3.h" #include "smallxrm.h" #include "heromesh.h" Uint32 generation_number; Object*objects; Uint32 nobjects; Value globals[0x800]; |
Modified heromesh.h from [ba1bd3273a] to [637f2cff6e].
︙ | ︙ | |||
35 36 37 38 39 40 41 | extern const char*const standard_sound_names[]; extern const char*const heromesh_key_names[256]; extern sqlite3*userdb; extern xrm_db*resourcedb; extern const char*basefilename; extern xrm_quark optionquery[16]; | < | 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | extern const char*const standard_sound_names[]; extern const char*const heromesh_key_names[256]; extern sqlite3*userdb; extern xrm_db*resourcedb; extern const char*basefilename; extern xrm_quark optionquery[16]; 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); void set_cursor(int id); |
︙ | ︙ | |||
93 94 95 96 97 98 99 | Sint32 temperature,misc4,misc5,misc6,misc7; Uint16 uservars,oflags,nmsg; Uint16 sharp[4]; Uint16 hard[4]; Uint8 cflags,shape,shovable,collisionLayers,nimages; } Class; | < | 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | Sint32 temperature,misc4,misc5,misc6,misc7; Uint16 uservars,oflags,nmsg; Uint16 sharp[4]; Uint16 hard[4]; Uint8 cflags,shape,shovable,collisionLayers,nimages; } Class; 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) extern Sint32 max_volume; // max total volume to allow moving diagonally (default 10000) extern Uint8 back_color; |
︙ | ︙ | |||
124 125 126 127 128 129 130 | void load_key_bindings(void); const UserCommand*find_key_binding(SDL_Event*ev,int editing); // == function == void init_sql_functions(sqlite3_int64*ptr0,sqlite3_int64*ptr1); | > > > > > > > > > > > > > > > > > > > > > > | 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 | void load_key_bindings(void); const UserCommand*find_key_binding(SDL_Event*ev,int editing); // == 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]; |
Modified main.c from [f367a2dcad] to [8f25720cf2].
︙ | ︙ | |||
37 38 39 40 41 42 43 | "COMMIT;" ; sqlite3*userdb; xrm_db*resourcedb; const char*basefilename; xrm_quark optionquery[16]; | < | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | "COMMIT;" ; sqlite3*userdb; xrm_db*resourcedb; const char*basefilename; xrm_quark optionquery[16]; char main_options[128]; Uint8 message_trace[0x4100/8]; static const char*globalclassname; static SDL_Cursor*cursor[77]; static FILE*levelfp; static FILE*solutionfp; |
︙ | ︙ |