ADDED class.c Index: class.c ================================================================== --- /dev/null +++ class.c @@ -0,0 +1,228 @@ +#if 0 +gcc -s -O2 -c -Wno-unused-result class.c `sdl-config --cflags` +exit +#endif + +/* + This program is part of Free Hero Mesh and is public domain. +*/ + +#define HEROMESH_CLASS +#include "SDL.h" +#include +#include +#include +#include "sqlite3.h" +#include "smallxrm.h" +#include "heromesh.h" + +#define TF_COMMA 0x0001 +#define TF_EQUAL 0x0002 +#define TF_ABNORMAL 0x0004 +#define TF_COMPAT 0x0008 +#define TF_DIR 0x0010 +#define TF_DROP 0x0020 +#define TF_NAME 0x0080 +#define TF_KEY 0x0100 +#define TF_STRING 0x0200 +#define TF_OPEN 0x0400 +#define TF_CLOSE 0x0800 +#define TF_INT 0x1000 +#define TF_MACRO 0x4000 +#define TF_EOF 0x8000 +typedef struct { + const char*txt; + Uint32 num; +} Op_Names; +#include "instruc.h" + +Class*classes[0x4000]; +const char*messages[0x4000]; +int max_animation=32; +Sint32 max_volume=10000; + +static FILE*classfp; +static Uint16 tokent; +static Uint32 tokenv; +static int linenum=1; +static char tokenstr[0x2000]; +static int undef_class=1; +static int undef_message=0; + +#define ParseError(a,...) fatal("On line %d: " a,linenum,##__VA_ARGS__) + +static const unsigned char chkind[256]={ + ['$']=1, ['!']=1, ['\'']=1, ['#']=1, ['@']=1, ['%']=1, ['&']=1, [':']=1, + ['0'...'9']=2, ['-']=2, ['+']=2, + ['A'...'Z']=3, ['a'...'z']=3, ['_']=3, ['?']=3, ['.']=3, ['*']=3, ['/']=3, +}; + +static void read_quoted_string(void) { + int c,i,n; + int isimg=0; + for(i=0;i<0x1FFD;) { + c=fgetc(classfp); + if(c==EOF) { + ParseError("Unterminated string literal\n"); + } else if(c=='\\') { + if(isimg) { + isimg=0; + tokenstr[i++]=c; + } else switch(c=fgetc(classfp)) { + case '"': case '\\': tokenstr[i++]=c; break; + case '0' ... '7': tokenstr[i++]=c+1-'0'; break; + case 'b': tokenstr[i++]=15; break; + case 'c': tokenstr[i++]=12; break; + case 'i': tokenstr[i++]=14; isimg=1; break; + case 'l': tokenstr[i++]=11; break; + case 'n': tokenstr[i++]=10; break; + case 'q': tokenstr[i++]=16; break; + case 'x': + c=fgetc(classfp); + if(c>='0' && c<='9') n=c-'0'; + else if(c>='A' && c<='F') n=c+10-'A'; + else if(c>='a' && c<='f') n=c+10-'a'; + else ParseError("Invalid string escape: \\x%c\n",c); + n<<=4; + c=fgetc(classfp); + if(c>='0' && c<='9') n|=c-'0'; + else if(c>='A' && c<='F') n|=c+10-'A'; + else if(c>='a' && c<='f') n|=c+10-'a'; + else ParseError("Invalid string escape: \\x%X%c\n",n>>4,c); + if(n<32) tokenstr[i++]=31; + tokenstr[i++]=n; + break; + default: ParseError("Invalid string escape: \\%c\n",c); + } + } else if(c=='"') { + if(isimg) ParseError("Unterminated \\i escape in string literal\n"); + tokenstr[i]=0; + return; + } else if(c!='\r') { + tokenstr[i++]=c; + if(c=='\n') ++linenum; + } + } + ParseError("Too long string literal\n"); +} + +static int name_compar(const void*a,const void*b) { + const Op_Names*x=a; + const Op_Names*y=b; + return strcmp(x->txt,y->txt); +} + +#define ReturnToken(x,y) do{ tokent=x; tokenv=y; return; }while(0) +static void nxttok(void) { + int c,i; + int fl=0; + int n=0; + int pr=0; + tokent=tokenv=0; + *tokenstr=0; +again: + c=fgetc(classfp); + while(c==' ' || c=='\t' || c=='\r' || c=='\n') { + if(c=='\n') ++linenum; + c=fgetc(classfp); + } + if(c==EOF) ReturnToken(TF_EOF,0); + if(c==';') { + while(c!=EOF && c!='\n') c=fgetc(classfp); + ++linenum; + goto again; + } + if(c=='(') ReturnToken(TF_OPEN,0); + if(c==')') ReturnToken(TF_CLOSE,0); + if(c=='"') { + tokent=TF_STRING; + read_quoted_string(); + return; + } + if(c=='=') { + fl|=TF_EQUAL; + c=fgetc(classfp); + } + if(c==',') { + fl|=TF_COMMA; + c=fgetc(classfp); + } + if(c==EOF) ParseError("Unexpected end of file\n"); + if(chkind[c]==1) { + pr=c; + c=fgetc(classfp); + if(c==EOF) ParseError("Unexpected end of file\n"); + } + while(c>0 && (chkind[c]&2)) { + if(n==256) { + tokenstr[256]=0; + ParseError("Identifier too long: %s\n",tokenstr); + } + tokenstr[n++]=c; + c=fgetc(classfp); + } + tokenstr[n]=0; + if(!n) fatal("Expected identifier\n"); + if(c!=EOF) ungetc(c,classfp); + switch(pr) { + case 0: + if(chkind[c=*tokenstr]==2) { + char*e; + if(c=='-' || c=='+') n=1; else n=0; + if(n && !tokenstr[1]) goto norm; + tokent=TF_INT; + if(fl) ParseError("Invalid use of , and = in a numeric token\n"); + if(c=='0' && tokenstr[1]=='x') { + tokenv=strtol(tokenstr+2,&e,16); + } else if(c=='0' && tokenstr[1]=='o') { + tokenv=strtol(tokenstr+2,&e,8); + } else { + tokenv=strtol(tokenstr+n,&e,10); + } + if(e && *e) ParseError("Invalid token: %s\n",tokenstr); + if(c=='-') tokenv=-tokenv; + } else { + static Op_Names key={tokenstr}; + const Op_Names*op; + norm: + op=bsearch(&key,op_names,N_OP_NAMES,sizeof(Op_Names),name_compar); + if(!op) ParseError("Invalid token: %s\n",tokenstr); + tokenv=op->num&0xFFFF; + tokent=op->num>>16; + if(fl&~tokent) ParseError("Invalid use of , and = in token: %s\n",tokenstr); + + } + break; + case '$': + + break; + case '!': + // Just ignore sounds for now + if(fl) ParseError("Invalid use of , and = in user sound token\n"); + tokent=TF_NAME; + tokenv=0x0400; + break; + case '%': + + break; + case '@': + + break; + case '#': + + break; + case ':': + + break; + case '&': + + break; + case '\'': + + break; + } +} + +void load_classes(void) { + +} Index: instruc ================================================================== --- instruc +++ instruc @@ -55,14 +55,21 @@ #bit28 #bit29 #bit30 #bit31 +; Animation constants +STOP (0000) +ONCE (0001) +LOOP (0002) +OSC (0008) +OSCLOOP (000A) + (8000) ; Stack ops -drop "." +.drop "." ,dup swap nip tuck @@ -74,10 +81,12 @@ -begin -again -until -while -repeat +-for +-next *goto *CallSub ret ; Arithmetic @@ -147,23 +156,76 @@ ,=Invisible ,=KeyCleared ,=UserSignal ,=VisualOnly ,=Stealthy +,=Moved ,IsPlayer ,Compatible -,Msg -,From -,=Arg1 -,=Arg2 -,=Arg3 -,MoveNumber -,Level +Self +Msg +From +=Arg1 +=Arg2 +=Arg3 +MoveNumber +Level +Key ; Class definitions -Quiz -InPlace -DefaultImage -Help -EditorHelp -SUBS + +; Main operations +Animate +,Assassinate +.Broadcast +*BroadcastClass +.BroadcastEx +BroadcastSum +BroadcastSumEx +.Create +DelInventory +Delta +.,Destroy +FlushClass +FlushObj +GetInventory +HeightAt +IgnoreKey +.,IntMove +,JumpTo +,Loc +LocateMe +LoseLevel +MaxInventory +.,Move +.,MovePlus "Move+" +.,MoveTo +NewX +NewY +,ObjAbove +ObjClassAt +,ObjBelow +,ObjDir +PopUp +*PopUpArgs +.,Send +.,SendEx +SetInventory +Sound +Trace +VolumeAt +WinLevel +,XDir +,YDir + +; Specials +*Function +*Local +*Label +*String Index: instruc.h ================================================================== --- instruc.h +++ instruc.h @@ -1,7 +1,13 @@ #define OP_BITCONSTANT 34792 +#define OP_STOP 0 +#define OP_ONCE 1 +#define OP_LOOP 2 +#define OP_OSC 8 +#define OP_OSCLOOP 10 #define OP_DROP 32768 +#define OP_DROP_D 40960 #define OP_DUP 32769 #define OP_DUP_C 34817 #define OP_SWAP 32770 #define OP_NIP 32771 #define OP_TUCK 32772 @@ -12,456 +18,582 @@ #define OP_BEGIN 32777 #define OP_AGAIN 32778 #define OP_UNTIL 32779 #define OP_WHILE 32780 #define OP_REPEAT 32781 -#define OP_GOTO 32782 -#define OP_CALLSUB 32783 -#define OP_RET 32784 -#define OP_ADD 32785 -#define OP_SUB 32786 -#define OP_MUL 32787 -#define OP_MUL_C 34835 -#define OP_DIV 32788 -#define OP_DIV_C 34836 -#define OP_MOD 32789 -#define OP_MOD_C 34837 -#define OP_NEG 32790 -#define OP_LSH 32791 -#define OP_RSH 32792 -#define OP_RSH_C 34840 -#define OP_BAND 32793 -#define OP_BOR 32794 -#define OP_BXOR 32795 -#define OP_BNOT 32796 -#define OP_BIT 32797 -#define OP_LAND 32798 -#define OP_LOR 32799 -#define OP_LXOR 32800 -#define OP_LNOT 32801 -#define OP_EQ 32802 -#define OP_NE 32803 -#define OP_GT 32804 -#define OP_GT_C 34852 -#define OP_LT 32805 -#define OP_LT_C 34853 -#define OP_GE 32806 -#define OP_GE_C 34854 -#define OP_LE 32807 -#define OP_LE_C 34855 -#define OP_IS 32808 -#define OP_CLASS 32809 -#define OP_CLASS_C 34857 -#define OP_TEMPERATURE 32810 -#define OP_TEMPERATURE_C 34858 -#define OP_TEMPERATURE_E 36906 -#define OP_TEMPERATURE_EC 38954 -#define OP_TEMPERATURE_EC16 34859 -#define OP_TEMPERATURE_E16 36907 -#define OP_SHAPE 32812 -#define OP_SHAPE_C 34860 -#define OP_SHAPE_E 36908 -#define OP_SHAPE_EC 38956 -#define OP_XLOC 32813 -#define OP_XLOC_C 34861 -#define OP_YLOC 32814 -#define OP_YLOC_C 34862 -#define OP_DIR 32815 -#define OP_DIR_C 34863 -#define OP_DIR_E 36911 -#define OP_DIR_EC 38959 -#define OP_IMAGE 32816 -#define OP_IMAGE_C 34864 -#define OP_IMAGE_E 36912 -#define OP_IMAGE_EC 38960 -#define OP_INERTIA 32817 -#define OP_INERTIA_C 34865 -#define OP_INERTIA_E 36913 -#define OP_INERTIA_EC 38961 -#define OP_INERTIA_EC16 34866 -#define OP_INERTIA_E16 36914 -#define OP_DISTANCE 32819 -#define OP_DISTANCE_C 34867 -#define OP_DISTANCE_E 36915 -#define OP_DISTANCE_EC 38963 -#define OP_DISTANCE_EC16 34868 -#define OP_DISTANCE_E16 36916 -#define OP_DENSITY 32821 -#define OP_DENSITY_C 34869 -#define OP_DENSITY_E 36917 -#define OP_DENSITY_EC 38965 -#define OP_DENSITY_EC16 34870 -#define OP_DENSITY_E16 36918 -#define OP_VOLUME 32823 -#define OP_VOLUME_C 34871 -#define OP_VOLUME_E 36919 -#define OP_VOLUME_EC 38967 -#define OP_VOLUME_EC16 34872 -#define OP_VOLUME_E16 36920 -#define OP_WEIGHT 32825 -#define OP_WEIGHT_C 34873 -#define OP_WEIGHT_E 36921 -#define OP_WEIGHT_EC 38969 -#define OP_WEIGHT_EC16 34874 -#define OP_WEIGHT_E16 36922 -#define OP_HEIGHT 32827 -#define OP_HEIGHT_C 34875 -#define OP_HEIGHT_E 36923 -#define OP_HEIGHT_EC 38971 -#define OP_HEIGHT_EC16 34876 -#define OP_HEIGHT_E16 36924 -#define OP_CLIMB 32829 -#define OP_CLIMB_C 34877 -#define OP_CLIMB_E 36925 -#define OP_CLIMB_EC 38973 -#define OP_CLIMB_EC16 34878 -#define OP_CLIMB_E16 36926 -#define OP_STRENGTH 32831 -#define OP_STRENGTH_C 34879 -#define OP_STRENGTH_E 36927 -#define OP_STRENGTH_EC 38975 -#define OP_STRENGTH_EC16 34880 -#define OP_STRENGTH_E16 36928 -#define OP_HARD 32833 -#define OP_HARD_C 34881 -#define OP_HARD_E 36929 -#define OP_HARD_EC 38977 -#define OP_SHARP 32834 -#define OP_SHARP_C 34882 -#define OP_SHARP_E 36930 -#define OP_SHARP_EC 38978 -#define OP_SHAPEDIR 32835 -#define OP_SHAPEDIR_C 34883 -#define OP_SHAPEDIR_E 36931 -#define OP_SHAPEDIR_EC 38979 -#define OP_SHOVABLE 32836 -#define OP_SHOVABLE_C 34884 -#define OP_SHOVABLE_E 36932 -#define OP_SHOVABLE_EC 38980 -#define OP_MISC1 32837 -#define OP_MISC1_C 34885 -#define OP_MISC1_E 36933 -#define OP_MISC1_EC 38981 -#define OP_MISC1_EC16 34886 -#define OP_MISC1_E16 36934 -#define OP_MISC2 32839 -#define OP_MISC2_C 34887 -#define OP_MISC2_E 36935 -#define OP_MISC2_EC 38983 -#define OP_MISC2_EC16 34888 -#define OP_MISC2_E16 36936 -#define OP_MISC3 32841 -#define OP_MISC3_C 34889 -#define OP_MISC3_E 36937 -#define OP_MISC3_EC 38985 -#define OP_MISC3_EC16 34890 -#define OP_MISC3_E16 36938 -#define OP_MISC4 32843 -#define OP_MISC4_C 34891 -#define OP_MISC4_E 36939 -#define OP_MISC4_EC 38987 -#define OP_MISC4_EC16 34892 -#define OP_MISC4_E16 36940 -#define OP_MISC5 32845 -#define OP_MISC5_C 34893 -#define OP_MISC5_E 36941 -#define OP_MISC5_EC 38989 -#define OP_MISC5_EC16 34894 -#define OP_MISC5_E16 36942 -#define OP_MISC6 32847 -#define OP_MISC6_C 34895 -#define OP_MISC6_E 36943 -#define OP_MISC6_EC 38991 -#define OP_MISC6_EC16 34896 -#define OP_MISC6_E16 36944 -#define OP_MISC7 32849 -#define OP_MISC7_C 34897 -#define OP_MISC7_E 36945 -#define OP_MISC7_EC 38993 -#define OP_MISC7_EC16 34898 -#define OP_MISC7_E16 36946 -#define OP_ARRIVED 32851 -#define OP_ARRIVED_C 34899 -#define OP_ARRIVED_E 36947 -#define OP_ARRIVED_EC 38995 -#define OP_DEPARTED 32852 -#define OP_DEPARTED_C 34900 -#define OP_DEPARTED_E 36948 -#define OP_DEPARTED_EC 38996 -#define OP_ARRIVALS 32853 -#define OP_ARRIVALS_C 34901 -#define OP_ARRIVALS_E 36949 -#define OP_ARRIVALS_EC 38997 -#define OP_DEPARTURES 32854 -#define OP_DEPARTURES_C 34902 -#define OP_DEPARTURES_E 36950 -#define OP_DEPARTURES_EC 38998 -#define OP_BUSY 32855 -#define OP_BUSY_C 34903 -#define OP_BUSY_E 36951 -#define OP_BUSY_EC 38999 -#define OP_INVISIBLE 32856 -#define OP_INVISIBLE_C 34904 -#define OP_INVISIBLE_E 36952 -#define OP_INVISIBLE_EC 39000 -#define OP_KEYCLEARED 32857 -#define OP_KEYCLEARED_C 34905 -#define OP_KEYCLEARED_E 36953 -#define OP_KEYCLEARED_EC 39001 -#define OP_USERSIGNAL 32858 -#define OP_USERSIGNAL_C 34906 -#define OP_USERSIGNAL_E 36954 -#define OP_USERSIGNAL_EC 39002 -#define OP_VISUALONLY 32859 -#define OP_VISUALONLY_C 34907 -#define OP_VISUALONLY_E 36955 -#define OP_VISUALONLY_EC 39003 -#define OP_STEALTHY 32860 -#define OP_STEALTHY_C 34908 -#define OP_STEALTHY_E 36956 -#define OP_STEALTHY_EC 39004 -#define OP_ISPLAYER 32861 -#define OP_ISPLAYER_C 34909 -#define OP_COMPATIBLE 32862 -#define OP_COMPATIBLE_C 34910 -#define OP_MSG 32863 -#define OP_MSG_C 34911 -#define OP_FROM 32864 -#define OP_FROM_C 34912 -#define OP_ARG1 32865 -#define OP_ARG1_C 34913 -#define OP_ARG1_E 36961 -#define OP_ARG1_EC 39009 -#define OP_ARG2 32866 -#define OP_ARG2_C 34914 -#define OP_ARG2_E 36962 -#define OP_ARG2_EC 39010 -#define OP_ARG3 32867 -#define OP_ARG3_C 34915 -#define OP_ARG3_E 36963 -#define OP_ARG3_EC 39011 -#define OP_MOVENUMBER 32868 -#define OP_MOVENUMBER_C 34916 -#define OP_LEVEL 32869 -#define OP_LEVEL_C 34917 -#define OP_QUIZ 32870 -#define OP_INPLACE 32871 -#define OP_DEFAULTIMAGE 32872 -#define OP_HELP 32873 -#define OP_EDITORHELP 32874 -#define OP_SUBS 32875 +#define OP_FOR 32782 +#define OP_NEXT 32783 +#define OP_GOTO 32784 +#define OP_CALLSUB 32785 +#define OP_RET 32786 +#define OP_ADD 32787 +#define OP_SUB 32788 +#define OP_MUL 32789 +#define OP_MUL_C 34837 +#define OP_DIV 32790 +#define OP_DIV_C 34838 +#define OP_MOD 32791 +#define OP_MOD_C 34839 +#define OP_NEG 32792 +#define OP_LSH 32793 +#define OP_RSH 32794 +#define OP_RSH_C 34842 +#define OP_BAND 32795 +#define OP_BOR 32796 +#define OP_BXOR 32797 +#define OP_BNOT 32798 +#define OP_BIT 32799 +#define OP_LAND 32800 +#define OP_LOR 32801 +#define OP_LXOR 32802 +#define OP_LNOT 32803 +#define OP_EQ 32804 +#define OP_NE 32805 +#define OP_GT 32806 +#define OP_GT_C 34854 +#define OP_LT 32807 +#define OP_LT_C 34855 +#define OP_GE 32808 +#define OP_GE_C 34856 +#define OP_LE 32809 +#define OP_LE_C 34857 +#define OP_IS 32810 +#define OP_CLASS 32811 +#define OP_CLASS_C 34859 +#define OP_TEMPERATURE 32812 +#define OP_TEMPERATURE_C 34860 +#define OP_TEMPERATURE_E 36908 +#define OP_TEMPERATURE_EC 38956 +#define OP_TEMPERATURE_EC16 34861 +#define OP_TEMPERATURE_E16 36909 +#define OP_SHAPE 32814 +#define OP_SHAPE_C 34862 +#define OP_SHAPE_E 36910 +#define OP_SHAPE_EC 38958 +#define OP_XLOC 32815 +#define OP_XLOC_C 34863 +#define OP_YLOC 32816 +#define OP_YLOC_C 34864 +#define OP_DIR 32817 +#define OP_DIR_C 34865 +#define OP_DIR_E 36913 +#define OP_DIR_EC 38961 +#define OP_IMAGE 32818 +#define OP_IMAGE_C 34866 +#define OP_IMAGE_E 36914 +#define OP_IMAGE_EC 38962 +#define OP_INERTIA 32819 +#define OP_INERTIA_C 34867 +#define OP_INERTIA_E 36915 +#define OP_INERTIA_EC 38963 +#define OP_INERTIA_EC16 34868 +#define OP_INERTIA_E16 36916 +#define OP_DISTANCE 32821 +#define OP_DISTANCE_C 34869 +#define OP_DISTANCE_E 36917 +#define OP_DISTANCE_EC 38965 +#define OP_DISTANCE_EC16 34870 +#define OP_DISTANCE_E16 36918 +#define OP_DENSITY 32823 +#define OP_DENSITY_C 34871 +#define OP_DENSITY_E 36919 +#define OP_DENSITY_EC 38967 +#define OP_DENSITY_EC16 34872 +#define OP_DENSITY_E16 36920 +#define OP_VOLUME 32825 +#define OP_VOLUME_C 34873 +#define OP_VOLUME_E 36921 +#define OP_VOLUME_EC 38969 +#define OP_VOLUME_EC16 34874 +#define OP_VOLUME_E16 36922 +#define OP_WEIGHT 32827 +#define OP_WEIGHT_C 34875 +#define OP_WEIGHT_E 36923 +#define OP_WEIGHT_EC 38971 +#define OP_WEIGHT_EC16 34876 +#define OP_WEIGHT_E16 36924 +#define OP_HEIGHT 32829 +#define OP_HEIGHT_C 34877 +#define OP_HEIGHT_E 36925 +#define OP_HEIGHT_EC 38973 +#define OP_HEIGHT_EC16 34878 +#define OP_HEIGHT_E16 36926 +#define OP_CLIMB 32831 +#define OP_CLIMB_C 34879 +#define OP_CLIMB_E 36927 +#define OP_CLIMB_EC 38975 +#define OP_CLIMB_EC16 34880 +#define OP_CLIMB_E16 36928 +#define OP_STRENGTH 32833 +#define OP_STRENGTH_C 34881 +#define OP_STRENGTH_E 36929 +#define OP_STRENGTH_EC 38977 +#define OP_STRENGTH_EC16 34882 +#define OP_STRENGTH_E16 36930 +#define OP_HARD 32835 +#define OP_HARD_C 34883 +#define OP_HARD_E 36931 +#define OP_HARD_EC 38979 +#define OP_SHARP 32836 +#define OP_SHARP_C 34884 +#define OP_SHARP_E 36932 +#define OP_SHARP_EC 38980 +#define OP_SHAPEDIR 32837 +#define OP_SHAPEDIR_C 34885 +#define OP_SHAPEDIR_E 36933 +#define OP_SHAPEDIR_EC 38981 +#define OP_SHOVABLE 32838 +#define OP_SHOVABLE_C 34886 +#define OP_SHOVABLE_E 36934 +#define OP_SHOVABLE_EC 38982 +#define OP_MISC1 32839 +#define OP_MISC1_C 34887 +#define OP_MISC1_E 36935 +#define OP_MISC1_EC 38983 +#define OP_MISC1_EC16 34888 +#define OP_MISC1_E16 36936 +#define OP_MISC2 32841 +#define OP_MISC2_C 34889 +#define OP_MISC2_E 36937 +#define OP_MISC2_EC 38985 +#define OP_MISC2_EC16 34890 +#define OP_MISC2_E16 36938 +#define OP_MISC3 32843 +#define OP_MISC3_C 34891 +#define OP_MISC3_E 36939 +#define OP_MISC3_EC 38987 +#define OP_MISC3_EC16 34892 +#define OP_MISC3_E16 36940 +#define OP_MISC4 32845 +#define OP_MISC4_C 34893 +#define OP_MISC4_E 36941 +#define OP_MISC4_EC 38989 +#define OP_MISC4_EC16 34894 +#define OP_MISC4_E16 36942 +#define OP_MISC5 32847 +#define OP_MISC5_C 34895 +#define OP_MISC5_E 36943 +#define OP_MISC5_EC 38991 +#define OP_MISC5_EC16 34896 +#define OP_MISC5_E16 36944 +#define OP_MISC6 32849 +#define OP_MISC6_C 34897 +#define OP_MISC6_E 36945 +#define OP_MISC6_EC 38993 +#define OP_MISC6_EC16 34898 +#define OP_MISC6_E16 36946 +#define OP_MISC7 32851 +#define OP_MISC7_C 34899 +#define OP_MISC7_E 36947 +#define OP_MISC7_EC 38995 +#define OP_MISC7_EC16 34900 +#define OP_MISC7_E16 36948 +#define OP_ARRIVED 32853 +#define OP_ARRIVED_C 34901 +#define OP_ARRIVED_E 36949 +#define OP_ARRIVED_EC 38997 +#define OP_DEPARTED 32854 +#define OP_DEPARTED_C 34902 +#define OP_DEPARTED_E 36950 +#define OP_DEPARTED_EC 38998 +#define OP_ARRIVALS 32855 +#define OP_ARRIVALS_C 34903 +#define OP_ARRIVALS_E 36951 +#define OP_ARRIVALS_EC 38999 +#define OP_DEPARTURES 32856 +#define OP_DEPARTURES_C 34904 +#define OP_DEPARTURES_E 36952 +#define OP_DEPARTURES_EC 39000 +#define OP_BUSY 32857 +#define OP_BUSY_C 34905 +#define OP_BUSY_E 36953 +#define OP_BUSY_EC 39001 +#define OP_INVISIBLE 32858 +#define OP_INVISIBLE_C 34906 +#define OP_INVISIBLE_E 36954 +#define OP_INVISIBLE_EC 39002 +#define OP_KEYCLEARED 32859 +#define OP_KEYCLEARED_C 34907 +#define OP_KEYCLEARED_E 36955 +#define OP_KEYCLEARED_EC 39003 +#define OP_USERSIGNAL 32860 +#define OP_USERSIGNAL_C 34908 +#define OP_USERSIGNAL_E 36956 +#define OP_USERSIGNAL_EC 39004 +#define OP_VISUALONLY 32861 +#define OP_VISUALONLY_C 34909 +#define OP_VISUALONLY_E 36957 +#define OP_VISUALONLY_EC 39005 +#define OP_STEALTHY 32862 +#define OP_STEALTHY_C 34910 +#define OP_STEALTHY_E 36958 +#define OP_STEALTHY_EC 39006 +#define OP_MOVED 32863 +#define OP_MOVED_C 34911 +#define OP_MOVED_E 36959 +#define OP_MOVED_EC 39007 +#define OP_ISPLAYER 32864 +#define OP_ISPLAYER_C 34912 +#define OP_COMPATIBLE 32865 +#define OP_COMPATIBLE_C 34913 +#define OP_SELF 32866 +#define OP_MSG 32867 +#define OP_FROM 32868 +#define OP_ARG1 32869 +#define OP_ARG1_E 36965 +#define OP_ARG2 32870 +#define OP_ARG2_E 36966 +#define OP_ARG3 32871 +#define OP_ARG3_E 36967 +#define OP_MOVENUMBER 32872 +#define OP_LEVEL 32873 +#define OP_KEY 32874 +#define OP_QUIZ 32875 +#define OP_INPLACE 32876 +#define OP_DEFAULTIMAGE 32877 +#define OP_HELP 32878 +#define OP_EDITORHELP 32879 +#define OP_SUBS 32880 +#define OP_ANIMATE 32881 +#define OP_ASSASSINATE 32882 +#define OP_ASSASSINATE_C 34930 +#define OP_BROADCAST 32883 +#define OP_BROADCAST_D 41075 +#define OP_BROADCASTCLASS 32884 +#define OP_BROADCASTEX 32885 +#define OP_BROADCASTEX_D 41077 +#define OP_BROADCASTSUM 32886 +#define OP_BROADCASTSUMEX 32887 +#define OP_CREATE 32888 +#define OP_CREATE_D 41080 +#define OP_DELINVENTORY 32889 +#define OP_DELTA 32890 +#define OP_DESTROY 32891 +#define OP_DESTROY_C 34939 +#define OP_DESTROY_D 41083 +#define OP_DESTROY_CD 43131 +#define OP_FLUSHCLASS 32892 +#define OP_FLUSHOBJ 32893 +#define OP_GETINVENTORY 32894 +#define OP_HEIGHTAT 32895 +#define OP_IGNOREKEY 32896 +#define OP_INTMOVE 32897 +#define OP_INTMOVE_C 34945 +#define OP_INTMOVE_D 41089 +#define OP_INTMOVE_CD 43137 +#define OP_JUMPTO 32898 +#define OP_JUMPTO_C 34946 +#define OP_LOC 32899 +#define OP_LOC_C 34947 +#define OP_LOCATEME 32900 +#define OP_LOSELEVEL 32901 +#define OP_MAXINVENTORY 32902 +#define OP_MOVE 32903 +#define OP_MOVE_C 34951 +#define OP_MOVE_D 41095 +#define OP_MOVE_CD 43143 +#define OP_MOVEPLUS 32904 +#define OP_MOVEPLUS_C 34952 +#define OP_MOVEPLUS_D 41096 +#define OP_MOVEPLUS_CD 43144 +#define OP_MOVETO 32905 +#define OP_MOVETO_C 34953 +#define OP_MOVETO_D 41097 +#define OP_MOVETO_CD 43145 +#define OP_NEWX 32906 +#define OP_NEWY 32907 +#define OP_OBJABOVE 32908 +#define OP_OBJABOVE_C 34956 +#define OP_OBJCLASSAT 32909 +#define OP_OBJBELOW 32910 +#define OP_OBJBELOW_C 34958 +#define OP_OBJDIR 32911 +#define OP_OBJDIR_C 34959 +#define OP_POPUP 32912 +#define OP_POPUPARGS 32913 +#define OP_SEND 32914 +#define OP_SEND_C 34962 +#define OP_SEND_D 41106 +#define OP_SEND_CD 43154 +#define OP_SENDEX 32915 +#define OP_SENDEX_C 34963 +#define OP_SENDEX_D 41107 +#define OP_SENDEX_CD 43155 +#define OP_SETINVENTORY 32916 +#define OP_SOUND 32917 +#define OP_TRACE 32918 +#define OP_VOLUMEAT 32919 +#define OP_WINLEVEL 32920 +#define OP_XDIR 32921 +#define OP_XDIR_C 34969 +#define OP_YDIR 32922 +#define OP_YDIR_C 34970 +#define OP_FUNCTION 32923 +#define OP_LOCAL 32924 +#define OP_LABEL 32925 +#define OP_STRING 32926 #ifdef HEROMESH_CLASS static const Op_Names op_names[]={ -{"*",98323}, -{"+",32785}, -{"-",32786}, -{".",32768}, -{"/",98324}, -{"ANHH",786}, -{"ARRIVED",516}, -{"Arg1",229473}, -{"Arg2",229474}, -{"Arg3",229475}, -{"Arrivals",229461}, -{"Arrived",229459}, -{"B",1048588}, -{"BANG",772}, -{"BEDOINGNG",798}, -{"BEEDEEP",796}, -{"BEGIN_TURN",515}, -{"BOOOM",802}, -{"BOUNCE",807}, -{"BRRREEET",788}, -{"BRRRT",787}, -{"BUZZER",812}, -{"BWEEP",789}, -{"Busy",229463}, -{"CHEEP",785}, -{"CHYEW",784}, -{"CLEANUP",532}, -{"CLICK",780}, -{"COLLIDE",534}, -{"COLLIDING",533}, -{"CREATE",513}, -{"CREATED",529}, -{"Class",98345}, -{"Climb",753725}, -{"Compatible",98398}, -{"DEEP_POP",809}, -{"DEPARTED",517}, -{"DESTROY",514}, -{"DESTROYED",528}, -{"DINK",782}, -{"DOOR",770}, -{"DRLRLRINK",790}, -{"DYUPE",805}, -{"DefaultImage",295016}, -{"Density",753717}, -{"Departed",229460}, -{"Departures",229462}, -{"Dir",229423}, -{"Distance",753715}, -{"E",1048576}, -{"END_TURN",531}, -{"EditorHelp",295018}, -{"F",1048584}, -{"FAROUT",813}, -{"FFFFTT",791}, -{"FLOATED",524}, -{"FROG",775}, -{"From",98400}, -{"GLASS",771}, -{"GLISSANT",811}, -{"HAWK",817}, -{"HEARTBEAT",799}, -{"HIT",526}, -{"HITBY",527}, -{"Hard",229441}, -{"Height",753723}, -{"Help",295017}, -{"INIT",512}, -{"Image",229424}, -{"InPlace",295015}, -{"Inertia",753713}, -{"Invisible",229464}, -{"IsPlayer",98397}, -{"JAYAYAYNG",808}, -{"JUMPED",520}, -{"KEWEL",814}, -{"KEY",521}, -{"KLECK",779}, -{"KLINKK",777}, -{"KeyCleared",229465}, -{"L",1048586}, -{"LASTIMAGE",518}, -{"LB",1048587}, -{"LF",1048585}, -{"LOCK",800}, -{"Level",98405}, -{"MOVED",519}, -{"MOVING",522}, -{"Misc1",753733}, -{"Misc2",753735}, -{"Misc3",753737}, -{"Misc4",753739}, -{"Misc5",753741}, -{"Misc6",753743}, -{"Misc7",753745}, -{"MoveNumber",98404}, -{"Msg",98399}, -{"N",1048578}, -{"NE",1048577}, -{"NW",1048579}, -{"OLDPHONE",794}, -{"PLAYERMOVING",525}, -{"POSTINIT",530}, -{"POUR",769}, -{"POWER",778}, -{"Quiz",295014}, -{"R",1048590}, -{"RATCHET1",810}, -{"RATCHET2",804}, -{"RATTLE",795}, -{"RB",1048589}, -{"RF",1048591}, -{"S",1048582}, -{"SE",1048583}, -{"SMALL_POP",781}, -{"SPLASH",768}, -{"STEAM",816}, -{"SUBS",295019}, -{"SUNK",523}, -{"SW",1048581}, -{"Shape",229420}, -{"ShapeDir",229443}, -{"Sharp",229442}, -{"Shovable",229444}, -{"Stealthy",229468}, -{"Strength",753727}, -{"TAHTASHH",801}, -{"THMP_thmp",797}, -{"THWIT",776}, -{"TICK",783}, -{"Temperature",753706}, -{"UH_OH",774}, -{"UNCORK",806}, -{"UNHH",773}, -{"UserSignal",229466}, -{"VACUUM",803}, -{"VisualOnly",229467}, -{"Volume",753719}, -{"W",1048580}, -{"WAHOO",792}, -{"WHACK",815}, -{"Weight",753721}, -{"Xloc",98349}, -{"YEEHAW",793}, -{"Yloc",98350}, -{"again",294922}, -{"band",32793}, -{"begin",294921}, -{"bit",294941}, -{"bit0",1}, -{"bit1",2}, -{"bit10",34794}, -{"bit11",34795}, -{"bit12",34796}, -{"bit13",34797}, -{"bit14",34798}, -{"bit15",34799}, -{"bit16",34800}, -{"bit17",34801}, -{"bit18",34802}, -{"bit19",34803}, -{"bit2",4}, -{"bit20",34804}, -{"bit21",34805}, -{"bit22",34806}, -{"bit23",34807}, -{"bit24",34808}, -{"bit25",34809}, -{"bit26",34810}, -{"bit27",34811}, -{"bit28",34812}, -{"bit29",34813}, -{"bit3",8}, -{"bit30",34814}, -{"bit31",34815}, -{"bit4",16}, -{"bit5",32}, -{"bit6",64}, -{"bit7",128}, -{"bit8",34792}, -{"bit9",34793}, -{"bnot",32796}, -{"bor",32794}, -{"bxor",32795}, -{"dup",98305}, -{"el",294920}, -{"else",294918}, -{"eq",32802}, -{"ge",98342}, -{"gt",98340}, -{"if",294917}, -{"is",32808}, -{"land",32798}, -{"le",98343}, -{"lnot",32801}, -{"lor",32799}, -{"lsh",32791}, -{"lt",98341}, -{"lxor",32800}, -{"mod",98325}, -{"ne",32803}, -{"neg",32790}, -{"nip",32771}, -{"repeat",294925}, -{"ret",32784}, -{"rsh",98328}, -{"swap",32770}, -{"then",294919}, -{"tuck",32772}, -{"until",294923}, -{"while",294924}, +{"*",8486933}, +{"+",8421395}, +{"-",8421396}, +{".",10518528}, +{"/",8486934}, +{"ANHH",8389394}, +{"ARRIVED",8389124}, +{"Animate",8421489}, +{"Arg1",8552549}, +{"Arg2",8552550}, +{"Arg3",8552551}, +{"Arrivals",8618071}, +{"Arrived",8618069}, +{"Assassinate",8487026}, +{"B",9437196}, +{"BANG",8389380}, +{"BEDOINGNG",8389406}, +{"BEEDEEP",8389404}, +{"BEGIN_TURN",8389123}, +{"BOOOM",8389410}, +{"BOUNCE",8389415}, +{"BRRREEET",8389396}, +{"BRRRT",8389395}, +{"BUZZER",8389420}, +{"BWEEP",8389397}, +{"Broadcast",10518643}, +{"BroadcastEx",10518645}, +{"BroadcastSum",8421494}, +{"BroadcastSumEx",8421495}, +{"Busy",8618073}, +{"CHEEP",8389393}, +{"CHYEW",8389392}, +{"CLEANUP",8389140}, +{"CLICK",8389388}, +{"COLLIDE",8389142}, +{"COLLIDING",8389141}, +{"CREATE",8389121}, +{"CREATED",8389137}, +{"Class",8486955}, +{"Climb",9142335}, +{"Compatible",8487009}, +{"Create",10518648}, +{"DEEP_POP",8389417}, +{"DEPARTED",8389125}, +{"DESTROY",8389122}, +{"DESTROYED",8389136}, +{"DINK",8389390}, +{"DOOR",8389378}, +{"DRLRLRINK",8389398}, +{"DYUPE",8389413}, +{"DefaultImage",8683629}, +{"DelInventory",8421497}, +{"Delta",8421498}, +{"Density",9142327}, +{"Departed",8618070}, +{"Departures",8618072}, +{"Destroy",10584187}, +{"Dir",8618033}, +{"Distance",9142325}, +{"E",9437184}, +{"END_TURN",8389139}, +{"EditorHelp",8683631}, +{"F",9437192}, +{"FAROUT",8389421}, +{"FFFFTT",8389399}, +{"FLOATED",8389132}, +{"FROG",8389383}, +{"FlushClass",8421500}, +{"FlushObj",8421501}, +{"From",8421476}, +{"GLASS",8389379}, +{"GLISSANT",8389419}, +{"GetInventory",8421502}, +{"HAWK",8389425}, +{"HEARTBEAT",8389407}, +{"HIT",8389134}, +{"HITBY",8389135}, +{"Hard",8618051}, +{"Height",9142333}, +{"HeightAt",8421503}, +{"Help",8683630}, +{"INIT",8389120}, +{"IgnoreKey",8421504}, +{"Image",8618034}, +{"InPlace",8683628}, +{"Inertia",9142323}, +{"IntMove",10584193}, +{"Invisible",8618074}, +{"IsPlayer",8487008}, +{"JAYAYAYNG",8389416}, +{"JUMPED",8389128}, +{"JumpTo",8487042}, +{"KEWEL",8389422}, +{"KEY",8389129}, +{"KLECK",8389387}, +{"KLINKK",8389385}, +{"Key",8421482}, +{"KeyCleared",8618075}, +{"L",9437194}, +{"LASTIMAGE",8389126}, +{"LB",9437195}, +{"LF",9437193}, +{"LOCK",8389408}, +{"LOOP",8388610}, +{"Level",8421481}, +{"Loc",8487043}, +{"LocateMe",8421508}, +{"LoseLevel",8421509}, +{"MOVED",8389127}, +{"MOVING",8389130}, +{"MaxInventory",8421510}, +{"Misc1",9142343}, +{"Misc2",9142345}, +{"Misc3",9142347}, +{"Misc4",9142349}, +{"Misc5",9142351}, +{"Misc6",9142353}, +{"Misc7",9142355}, +{"Move",10584199}, +{"Move+",10584200}, +{"MoveNumber",8421480}, +{"MoveTo",10584201}, +{"Moved",8618079}, +{"Msg",8421475}, +{"N",9437186}, +{"NE",9437185}, +{"NW",9437187}, +{"NewX",8421514}, +{"NewY",8421515}, +{"OLDPHONE",8389402}, +{"ONCE",8388609}, +{"OSC",8388616}, +{"OSCLOOP",8388618}, +{"ObjAbove",8487052}, +{"ObjBelow",8487054}, +{"ObjClassAt",8421517}, +{"ObjDir",8487055}, +{"PLAYERMOVING",8389133}, +{"POSTINIT",8389138}, +{"POUR",8389377}, +{"POWER",8389386}, +{"PopUp",8421520}, +{"Quiz",8683627}, +{"R",9437198}, +{"RATCHET1",8389418}, +{"RATCHET2",8389412}, +{"RATTLE",8389403}, +{"RB",9437197}, +{"RF",9437199}, +{"S",9437190}, +{"SE",9437191}, +{"SMALL_POP",8389389}, +{"SPLASH",8389376}, +{"STEAM",8389424}, +{"STOP",8388608}, +{"SUBS",8683632}, +{"SUNK",8389131}, +{"SW",9437189}, +{"Self",8421474}, +{"Send",10584210}, +{"SendEx",10584211}, +{"SetInventory",8421524}, +{"Shape",8618030}, +{"ShapeDir",8618053}, +{"Sharp",8618052}, +{"Shovable",8618054}, +{"Sound",8421525}, +{"Stealthy",8618078}, +{"Strength",9142337}, +{"TAHTASHH",8389409}, +{"THMP_thmp",8389405}, +{"THWIT",8389384}, +{"TICK",8389391}, +{"Temperature",9142316}, +{"Trace",8421526}, +{"UH_OH",8389382}, +{"UNCORK",8389414}, +{"UNHH",8389381}, +{"UserSignal",8618076}, +{"VACUUM",8389411}, +{"VisualOnly",8618077}, +{"Volume",9142329}, +{"VolumeAt",8421527}, +{"W",9437188}, +{"WAHOO",8389400}, +{"WHACK",8389423}, +{"Weight",9142331}, +{"WinLevel",8421528}, +{"XDir",8487065}, +{"Xloc",8486959}, +{"YDir",8487066}, +{"YEEHAW",8389401}, +{"Yloc",8486960}, +{"again",8683530}, +{"band",8421403}, +{"begin",8683529}, +{"bit",8683551}, +{"bit0",8388609}, +{"bit1",8388610}, +{"bit10",8423402}, +{"bit11",8423403}, +{"bit12",8423404}, +{"bit13",8423405}, +{"bit14",8423406}, +{"bit15",8423407}, +{"bit16",8423408}, +{"bit17",8423409}, +{"bit18",8423410}, +{"bit19",8423411}, +{"bit2",8388612}, +{"bit20",8423412}, +{"bit21",8423413}, +{"bit22",8423414}, +{"bit23",8423415}, +{"bit24",8423416}, +{"bit25",8423417}, +{"bit26",8423418}, +{"bit27",8423419}, +{"bit28",8423420}, +{"bit29",8423421}, +{"bit3",8388616}, +{"bit30",8423422}, +{"bit31",8423423}, +{"bit4",8388624}, +{"bit5",8388640}, +{"bit6",8388672}, +{"bit7",8388736}, +{"bit8",8423400}, +{"bit9",8423401}, +{"bnot",8421406}, +{"bor",8421404}, +{"bxor",8421405}, +{"dup",8486913}, +{"el",8683528}, +{"else",8683526}, +{"eq",8421412}, +{"for",8683534}, +{"ge",8486952}, +{"gt",8486950}, +{"if",8683525}, +{"is",8421418}, +{"land",8421408}, +{"le",8486953}, +{"lnot",8421411}, +{"lor",8421409}, +{"lsh",8421401}, +{"lt",8486951}, +{"lxor",8421410}, +{"mod",8486935}, +{"ne",8421413}, +{"neg",8421400}, +{"next",8683535}, +{"nip",8421379}, +{"repeat",8683533}, +{"ret",8421394}, +{"rsh",8486938}, +{"swap",8421378}, +{"then",8683527}, +{"tuck",8421380}, +{"until",8683531}, +{"while",8683532}, }; -#define N_OP_NAMES 211 +#define N_OP_NAMES 261 #endif Index: instruc.js ================================================================== --- instruc.js +++ instruc.js @@ -21,18 +21,19 @@ }; names_file.forEach(x=>f(x)); // not .forEach(f); the function to use varies let curnum=0; const names=Object.create(null); data_file.forEach((line,linenum)=>{ - const reg=/^[ \t]*([-,=!+*#]*)[ \t]*([A-Za-z0-9_]+)?[ \t]*(?:"([^" \t]+)")?[ \t]*(?:\(([0-9A-Fa-f]+)\))?[ \t]*(?:;.*)?$/.exec(line); + const reg=/^[ \t]*([-,=!+*#.]*)[ \t]*([A-Za-z0-9_]+)?[ \t]*(?:"([^" \t]+)")?[ \t]*(?:\(([0-9A-Fa-f]+)\))?[ \t]*(?:;.*)?$/.exec(line); if(!reg) throw "Syntax error on line "+(linenum+1); - let flags=0; + let flags=128; if(reg[1].includes(",")) flags|=1; if(reg[1].includes("=")) flags|=2; if(reg[1].includes("-")) flags|=4; if(reg[1].includes("!")) flags|=8; if(reg[1].includes("+")) flags|=16; + if(reg[1].includes(".")) flags|=32; if(reg[4]) curnum=parseInt(reg[4],16); if(reg[2] && !reg[1].includes("#")) { console.log("#define OP_"+reg[2].toUpperCase()+" "+curnum); if(flags&1) console.log("#define OP_"+reg[2].toUpperCase()+"_C "+(curnum+0x0800)); if(flags&2) console.log("#define OP_"+reg[2].toUpperCase()+"_E "+(curnum+0x1000)); @@ -39,13 +40,17 @@ if(3==(flags&3)) console.log("#define OP_"+reg[2].toUpperCase()+"_EC "+(curnum+0x1800)); if(10==(flags&10)) { if(flags&1) console.log("#define OP_"+reg[2].toUpperCase()+"_EC16 "+(curnum+0x0801)); console.log("#define OP_"+reg[2].toUpperCase()+"_E16 "+(curnum+0x1001)); } + if(flags&32) { + console.log("#define OP_"+reg[2].toUpperCase()+"_D "+(curnum+0x2000)); + if(flags&1) console.log("#define OP_"+reg[2].toUpperCase()+"_CD "+(curnum+0x2800)); + } } if(reg[2] && !reg[1].includes("*")) names[reg[3]||reg[2]]=curnum|(flags<<16); if(reg[2]) ++curnum; if(flags&8) ++curnum; }); console.log("#ifdef HEROMESH_CLASS\nstatic const Op_Names op_names[]={"); Object.keys(names).sort().forEach(x=>console.log("{\""+x+"\","+names[x]+"},")); console.log("};\n#define N_OP_NAMES "+Object.keys(names).length+"\n#endif"); Index: mbtofhm.c ================================================================== --- mbtofhm.c +++ mbtofhm.c @@ -619,11 +619,11 @@ case 67: fprintf(fp," Broadcast"); break; case 68: if(*op==255) fprintf(fp," Move"); - else fprintf(fp," (Move %s)",direction[*op]); + else fprintf(fp," %s Move+",direction[*op]); break; case 69: if(*op==255) fprintf(fp," ,Move"); else fprintf(fp," %s ,Move",direction[*op]); break; @@ -654,11 +654,11 @@ case 83: fprintf(fp," Broadcast ."); st=0; break; case 84: if(*op==255) fprintf(fp," Move ."); - else fprintf(fp," (Move %s) .",direction[*op]); + else fprintf(fp," %s Move+ .",direction[*op]); st=0; break; case 85: if(*op==255) fprintf(fp," ,Move ."); else fprintf(fp," %s ,Move .",direction[*op]); st=0; break;