Index: class.doc
==================================================================
--- class.doc
+++ class.doc
@@ -674,10 +674,11 @@
 
 Standard messages:
   ARRIVED
   BEGIN_TURN
   BLOCKED
+  CLICK
   COLLIDE
   COLLIDEBY
   COLLIDING
   CONFLICT
   CONNECT
@@ -798,11 +799,10 @@
   BRRRT
   BUZZER
   BWEEP
   CHEEP
   CHYEW
-  CLICK
   DEEP_POP
   DINK
   DOOR
   DRLRLRINK
   DYUPE
@@ -836,10 +836,14 @@
   UNHH
   VACUUM
   WAHOO
   WHACK
   YEEHAW
+
+Note: Some messages can also be used as sounds. Some sounds might later be
+changed to messages (they can still be used as sounds, although a sound
+file with that name is not guaranteed to be available).
 
 
 === Variables ===
 
 These are the variables which each object has. Some are marked [ro] below

Index: game.c
==================================================================
--- game.c
+++ game.c
@@ -395,13 +395,13 @@
       if(sz-replay_count>=4) replay_mark=(buf[replay_count]<<8)|buf[replay_count+1]; else replay_mark=0;
       if(sz-replay_count>=6) {
         i=(buf[replay_count+2]<<8)|buf[replay_count+3];
         if(i==level_version) solved=1;
       }
-      replay_list=malloc(replay_size=sizeof(MoveItem)*replay_count+1);
+      replay_list=malloc(replay_size=sizeof(MoveItem)*(replay_count+1));
       if(!replay_list) fatal("Allocation failed\n");
-      for(i=0;i<replay_size;i++) replay_list[i]=buf[i];
+      for(i=0;i<replay_count;i++) replay_list[i]=buf[i];
     } else {
       // New format
       fgetc(fp); // skip first null byte
       while((i=fgetc(fp))!=EOF) switch(i) {
         case 0x01: // Replay list

Index: heromesh.h
==================================================================
--- heromesh.h
+++ heromesh.h
@@ -36,11 +36,12 @@
 #define ZVALUE(x) UVALUE(x,TY_STRING)
 #define OVALUE(x) ((x)==VOIDLINK?NVALUE(0):UVALUE(x,objects[x]->generation))
 #define ValueTo64(v) (((sqlite3_int64)((v).u))|(((sqlite3_int64)((v).t))<<32))
 #define ValueEq(x,y) ((x).t==(y).t && (x).u==(y).u)
 
-#define N_MESSAGES 27
+#define N_MESSAGES 28
+#define N_STANDARD_SOUNDS 49
 extern const char*const standard_message_names[];
 extern const char*const standard_sound_names[];
 extern const char*const heromesh_key_names[256];
 
 extern sqlite3*userdb;
@@ -240,10 +241,13 @@
 #define ANI_STOP 0x00
 #define ANI_ONCE 0x01
 #define ANI_LOOP 0x02
 #define ANI_OSC 0x08
 #define ANI_SYNC 0x80
+
+// Special key codes; used in encoded move lists and in some cases also values for Key
+#define KEY_XY 1
 
 typedef struct {
   Uint8 flag,start,end;
   union {
     Uint8 speed; // unsynchronized

Index: instruc
==================================================================
--- instruc
+++ instruc
@@ -206,10 +206,11 @@
 -Background
 -CodePage
 -Order
 Control
 -LevelTable
+-InputXY
 
 ; Class definitions
 -Input
 -Quiz
 -InPlace

Index: instruc.h
==================================================================
--- instruc.h
+++ instruc.h
@@ -301,472 +301,474 @@
 #define OP_BACKGROUND 32904
 #define OP_CODEPAGE 32905
 #define OP_ORDER 32906
 #define OP_CONTROL 32907
 #define OP_LEVELTABLE 32908
-#define OP_INPUT 32909
-#define OP_QUIZ 32910
-#define OP_INPLACE 32911
-#define OP_DEFAULTIMAGE 32912
-#define OP_HELP 32913
-#define OP_EDITORHELP 32914
-#define OP_OTHERS 32915
-#define OP_SUBS 32916
-#define OP_ANIMATE 32917
-#define OP_ANIMATE_E 37013
-#define OP_ANIMATEDEAD 32918
-#define OP_ANIMATEDEAD_E 37014
-#define OP_ASSASSINATE 32919
-#define OP_ASSASSINATE_C 34967
-#define OP_BROADCAST 32920
-#define OP_BROADCAST_D 41112
-#define OP_BROADCASTAND 32921
-#define OP_BROADCASTANDEX 32922
-#define OP_BROADCASTCLASS 32923
-#define OP_BROADCASTEX 32924
-#define OP_BROADCASTEX_D 41116
-#define OP_BROADCASTLIST 32925
-#define OP_BROADCASTLISTEX 32926
-#define OP_BROADCASTSUM 32927
-#define OP_BROADCASTSUMEX 32928
-#define OP_CHAIN 32929
-#define OP_CHEBYSHEV 32930
-#define OP_CHEBYSHEV_C 34978
-#define OP_COLOC 32931
-#define OP_COLOC_C 34979
-#define OP_CONNECT 32932
-#define OP_CONNECT_C 34980
-#define OP_CREATE 32933
-#define OP_CREATE_D 41125
-#define OP_DATA 32934
-#define OP_DELINVENTORY 32935
-#define OP_DELTA 32936
-#define OP_DESTROY 32937
-#define OP_DESTROY_C 34985
-#define OP_DESTROY_D 41129
-#define OP_DESTROY_CD 43177
-#define OP_FAKEMOVE 32938
-#define OP_FAKEMOVE_C 34986
-#define OP_FINDCONNECTION 32939
-#define OP_FINDCONNECTION_C 34987
-#define OP_FLUSHCLASS 32940
-#define OP_FLUSHOBJ 32941
-#define OP_FLUSHOBJ_C 34989
-#define OP_GETINVENTORY 32942
-#define OP_HEIGHTAT 32943
-#define OP_HITME 32944
-#define OP_IGNOREKEY 32945
-#define OP_INTMOVE 32946
-#define OP_INTMOVE_C 34994
-#define OP_INTMOVE_D 41138
-#define OP_INTMOVE_CD 43186
-#define OP_JUMPTO 32947
-#define OP_JUMPTO_C 34995
-#define OP_JUMPTO_D 41139
-#define OP_JUMPTO_CD 43187
-#define OP_LOC 32948
-#define OP_LOC_C 34996
-#define OP_LOCATEME 32949
-#define OP_LOCATEME_C 34997
-#define OP_LOSELEVEL 32950
-#define OP_MANHATTAN 32951
-#define OP_MANHATTAN_C 34999
-#define OP_MAXINVENTORY 32952
-#define OP_MORTON 32953
-#define OP_MORTON_C 35001
-#define OP_MOVE 32954
-#define OP_MOVE_C 35002
-#define OP_MOVE_D 41146
-#define OP_MOVE_CD 43194
-#define OP_MOVEPLUS 32955
-#define OP_MOVEPLUS_C 35003
-#define OP_MOVEPLUS_D 41147
-#define OP_MOVEPLUS_CD 43195
-#define OP_MOVETO 32956
-#define OP_MOVETO_C 35004
-#define OP_MOVETO_D 41148
-#define OP_MOVETO_CD 43196
-#define OP_PLUSMOVE 32957
-#define OP_PLUSMOVE_C 35005
-#define OP_PLUSMOVE_D 41149
-#define OP_PLUSMOVE_CD 43197
-#define OP_MINUSMOVE 32958
-#define OP_MINUSMOVE_C 35006
-#define OP_MINUSMOVE_D 41150
-#define OP_MINUSMOVE_CD 43198
-#define OP_NEWX 32959
-#define OP_NEWXY 32960
-#define OP_NEWY 32961
-#define OP_OBJABOVE 32962
-#define OP_OBJABOVE_C 35010
-#define OP_OBJBELOW 32963
-#define OP_OBJBELOW_C 35011
-#define OP_OBJBOTTOMAT 32964
-#define OP_OBJCLASSAT 32965
-#define OP_OBJDIR 32966
-#define OP_OBJDIR_C 35014
-#define OP_OBJLAYERAT 32967
-#define OP_OBJMOVINGTO 32968
-#define OP_OBJTOPAT 32969
-#define OP_POPUP 32970
-#define OP_POPUPARGS 32971
-#define OP_REL 32972
-#define OP_REL_C 35020
-#define OP_SEEK 32973
-#define OP_SEEK_C 35021
-#define OP_SEND 32974
-#define OP_SEND_C 35022
-#define OP_SEND_D 41166
-#define OP_SEND_CD 43214
-#define OP_SENDEX 32975
-#define OP_SENDEX_C 35023
-#define OP_SENDEX_D 41167
-#define OP_SENDEX_CD 43215
-#define OP_SETINVENTORY 32976
-#define OP_SOUND 32977
-#define OP_SWEEP 32978
-#define OP_SWEEPEX 32979
-#define OP_SYNCHRONIZE 32980
-#define OP_TARGET 32981
-#define OP_TARGET_C 35029
-#define OP_TRACE 32982
-#define OP_TRACESTACK 32983
-#define OP_TRACESTACK_C 35031
-#define OP_TRIGGER 32984
-#define OP_TRIGGERAT 32985
-#define OP_VOLUMEAT 32986
-#define OP_WALKABLE 32987
-#define OP_WALKABLE_C 35035
-#define OP_WINLEVEL 32988
-#define OP_WINLEVEL_C 35036
-#define OP_XDIR 32989
-#define OP_XDIR_C 35037
-#define OP_XSTEP 32990
-#define OP_XSTEP_C 35038
-#define OP_XYDIR 32991
-#define OP_YDIR 32992
-#define OP_YDIR_C 35040
-#define OP_YSTEP 32993
-#define OP_YSTEP_C 35041
-#define OP_MARK 32994
-#define OP_TMARK 32995
-#define OP_IN 32996
-#define OP_NIN 32997
-#define OP_MBEGIN 32998
-#define OP_FLIP 32999
-#define OP_COUNT 33000
-#define OP_CLEAR 33001
-#define OP_UNIQ 33002
-#define OP_ARRAY 33003
-#define OP_GETARRAY 33004
-#define OP_GETARRAY_C 35052
-#define OP_INITARRAY 33005
-#define OP_SETARRAY 33006
-#define OP_SETARRAY_C 35054
-#define OP_ARRAYCELL 33007
-#define OP_ARRAYCELL_C 35055
-#define OP_ARRAYSLICE 33008
-#define OP_COPYARRAY 33009
-#define OP_DOTPRODUCT 33010
-#define OP_PATTERN 33011
-#define OP_PATTERN_C 35059
-#define OP_PATTERN_E 37107
-#define OP_PATTERN_EC 39155
-#define OP_PATTERNS 33012
-#define OP_PATTERNS_C 35060
-#define OP_PATTERNS_E 37108
-#define OP_PATTERNS_EC 39156
-#define OP_ROOK 33013
-#define OP_BISHOP 33014
-#define OP_QUEEN 33015
-#define OP_CUT 33016
-#define OP_BIZARRO 33017
-#define OP_BIZARRO_C 35065
-#define OP_BIZARRO_E 37113
-#define OP_BIZARRO_EC 39161
-#define OP_BIZARROSWAP 33018
-#define OP_BIZARROSWAP_D 41210
-#define OP_SWAPWORLD 33019
-#define OP_ABSTRACT 33020
-#define OP_SUPER 33021
-#define OP_SUPER_C 35069
-#define OP_FUNCTION 33022
-#define OP_LOCAL 33023
-#define OP_LABEL 33024
-#define OP_STRING 33025
-#define OP_INT16 33026
-#define OP_INT32 33027
-#define OP_DISPATCH 33028
-#define OP_USERFLAG 33029
+#define OP_INPUTXY 32909
+#define OP_INPUT 32910
+#define OP_QUIZ 32911
+#define OP_INPLACE 32912
+#define OP_DEFAULTIMAGE 32913
+#define OP_HELP 32914
+#define OP_EDITORHELP 32915
+#define OP_OTHERS 32916
+#define OP_SUBS 32917
+#define OP_ANIMATE 32918
+#define OP_ANIMATE_E 37014
+#define OP_ANIMATEDEAD 32919
+#define OP_ANIMATEDEAD_E 37015
+#define OP_ASSASSINATE 32920
+#define OP_ASSASSINATE_C 34968
+#define OP_BROADCAST 32921
+#define OP_BROADCAST_D 41113
+#define OP_BROADCASTAND 32922
+#define OP_BROADCASTANDEX 32923
+#define OP_BROADCASTCLASS 32924
+#define OP_BROADCASTEX 32925
+#define OP_BROADCASTEX_D 41117
+#define OP_BROADCASTLIST 32926
+#define OP_BROADCASTLISTEX 32927
+#define OP_BROADCASTSUM 32928
+#define OP_BROADCASTSUMEX 32929
+#define OP_CHAIN 32930
+#define OP_CHEBYSHEV 32931
+#define OP_CHEBYSHEV_C 34979
+#define OP_COLOC 32932
+#define OP_COLOC_C 34980
+#define OP_CONNECT 32933
+#define OP_CONNECT_C 34981
+#define OP_CREATE 32934
+#define OP_CREATE_D 41126
+#define OP_DATA 32935
+#define OP_DELINVENTORY 32936
+#define OP_DELTA 32937
+#define OP_DESTROY 32938
+#define OP_DESTROY_C 34986
+#define OP_DESTROY_D 41130
+#define OP_DESTROY_CD 43178
+#define OP_FAKEMOVE 32939
+#define OP_FAKEMOVE_C 34987
+#define OP_FINDCONNECTION 32940
+#define OP_FINDCONNECTION_C 34988
+#define OP_FLUSHCLASS 32941
+#define OP_FLUSHOBJ 32942
+#define OP_FLUSHOBJ_C 34990
+#define OP_GETINVENTORY 32943
+#define OP_HEIGHTAT 32944
+#define OP_HITME 32945
+#define OP_IGNOREKEY 32946
+#define OP_INTMOVE 32947
+#define OP_INTMOVE_C 34995
+#define OP_INTMOVE_D 41139
+#define OP_INTMOVE_CD 43187
+#define OP_JUMPTO 32948
+#define OP_JUMPTO_C 34996
+#define OP_JUMPTO_D 41140
+#define OP_JUMPTO_CD 43188
+#define OP_LOC 32949
+#define OP_LOC_C 34997
+#define OP_LOCATEME 32950
+#define OP_LOCATEME_C 34998
+#define OP_LOSELEVEL 32951
+#define OP_MANHATTAN 32952
+#define OP_MANHATTAN_C 35000
+#define OP_MAXINVENTORY 32953
+#define OP_MORTON 32954
+#define OP_MORTON_C 35002
+#define OP_MOVE 32955
+#define OP_MOVE_C 35003
+#define OP_MOVE_D 41147
+#define OP_MOVE_CD 43195
+#define OP_MOVEPLUS 32956
+#define OP_MOVEPLUS_C 35004
+#define OP_MOVEPLUS_D 41148
+#define OP_MOVEPLUS_CD 43196
+#define OP_MOVETO 32957
+#define OP_MOVETO_C 35005
+#define OP_MOVETO_D 41149
+#define OP_MOVETO_CD 43197
+#define OP_PLUSMOVE 32958
+#define OP_PLUSMOVE_C 35006
+#define OP_PLUSMOVE_D 41150
+#define OP_PLUSMOVE_CD 43198
+#define OP_MINUSMOVE 32959
+#define OP_MINUSMOVE_C 35007
+#define OP_MINUSMOVE_D 41151
+#define OP_MINUSMOVE_CD 43199
+#define OP_NEWX 32960
+#define OP_NEWXY 32961
+#define OP_NEWY 32962
+#define OP_OBJABOVE 32963
+#define OP_OBJABOVE_C 35011
+#define OP_OBJBELOW 32964
+#define OP_OBJBELOW_C 35012
+#define OP_OBJBOTTOMAT 32965
+#define OP_OBJCLASSAT 32966
+#define OP_OBJDIR 32967
+#define OP_OBJDIR_C 35015
+#define OP_OBJLAYERAT 32968
+#define OP_OBJMOVINGTO 32969
+#define OP_OBJTOPAT 32970
+#define OP_POPUP 32971
+#define OP_POPUPARGS 32972
+#define OP_REL 32973
+#define OP_REL_C 35021
+#define OP_SEEK 32974
+#define OP_SEEK_C 35022
+#define OP_SEND 32975
+#define OP_SEND_C 35023
+#define OP_SEND_D 41167
+#define OP_SEND_CD 43215
+#define OP_SENDEX 32976
+#define OP_SENDEX_C 35024
+#define OP_SENDEX_D 41168
+#define OP_SENDEX_CD 43216
+#define OP_SETINVENTORY 32977
+#define OP_SOUND 32978
+#define OP_SWEEP 32979
+#define OP_SWEEPEX 32980
+#define OP_SYNCHRONIZE 32981
+#define OP_TARGET 32982
+#define OP_TARGET_C 35030
+#define OP_TRACE 32983
+#define OP_TRACESTACK 32984
+#define OP_TRACESTACK_C 35032
+#define OP_TRIGGER 32985
+#define OP_TRIGGERAT 32986
+#define OP_VOLUMEAT 32987
+#define OP_WALKABLE 32988
+#define OP_WALKABLE_C 35036
+#define OP_WINLEVEL 32989
+#define OP_WINLEVEL_C 35037
+#define OP_XDIR 32990
+#define OP_XDIR_C 35038
+#define OP_XSTEP 32991
+#define OP_XSTEP_C 35039
+#define OP_XYDIR 32992
+#define OP_YDIR 32993
+#define OP_YDIR_C 35041
+#define OP_YSTEP 32994
+#define OP_YSTEP_C 35042
+#define OP_MARK 32995
+#define OP_TMARK 32996
+#define OP_IN 32997
+#define OP_NIN 32998
+#define OP_MBEGIN 32999
+#define OP_FLIP 33000
+#define OP_COUNT 33001
+#define OP_CLEAR 33002
+#define OP_UNIQ 33003
+#define OP_ARRAY 33004
+#define OP_GETARRAY 33005
+#define OP_GETARRAY_C 35053
+#define OP_INITARRAY 33006
+#define OP_SETARRAY 33007
+#define OP_SETARRAY_C 35055
+#define OP_ARRAYCELL 33008
+#define OP_ARRAYCELL_C 35056
+#define OP_ARRAYSLICE 33009
+#define OP_COPYARRAY 33010
+#define OP_DOTPRODUCT 33011
+#define OP_PATTERN 33012
+#define OP_PATTERN_C 35060
+#define OP_PATTERN_E 37108
+#define OP_PATTERN_EC 39156
+#define OP_PATTERNS 33013
+#define OP_PATTERNS_C 35061
+#define OP_PATTERNS_E 37109
+#define OP_PATTERNS_EC 39157
+#define OP_ROOK 33014
+#define OP_BISHOP 33015
+#define OP_QUEEN 33016
+#define OP_CUT 33017
+#define OP_BIZARRO 33018
+#define OP_BIZARRO_C 35066
+#define OP_BIZARRO_E 37114
+#define OP_BIZARRO_EC 39162
+#define OP_BIZARROSWAP 33019
+#define OP_BIZARROSWAP_D 41211
+#define OP_SWAPWORLD 33020
+#define OP_ABSTRACT 33021
+#define OP_SUPER 33022
+#define OP_SUPER_C 35070
+#define OP_FUNCTION 33023
+#define OP_LOCAL 33024
+#define OP_LABEL 33025
+#define OP_STRING 33026
+#define OP_INT16 33027
+#define OP_INT32 33028
+#define OP_DISPATCH 33029
+#define OP_USERFLAG 33030
 #ifdef HEROMESH_CLASS
 static const Op_Names op_names[]={
 {"*",8486943},
 {"+",8421405},
-{"+Move",10584253},
+{"+Move",10584254},
 {"-",8421406},
-{"-Move",10584254},
+{"-Move",10584255},
 {"-rot",8421382},
 {".",10518528},
 {"/",8486944},
-{"ANHH",8389394},
+{"ANHH",8389393},
 {"ARRIVED",8389124},
-{"Abstract",8683772},
-{"Animate",8552597},
-{"AnimateDead",8552598},
+{"Abstract",8683773},
+{"Animate",8552598},
+{"AnimateDead",8552599},
 {"Arg1",8552577},
 {"Arg2",8552578},
 {"Arg3",8552579},
-{"Array",8683755},
-{"ArrayCell",8487151},
-{"ArraySlice",8421616},
+{"Array",8683756},
+{"ArrayCell",8487152},
+{"ArraySlice",8421617},
 {"Arrivals",8618092},
 {"Arrived",8618090},
-{"Assassinate",8487063},
+{"Assassinate",8487064},
 {"B",9437196},
 {"BANG",8389380},
-{"BEDOINGNG",8389406},
-{"BEEDEEP",8389404},
+{"BEDOINGNG",8389405},
+{"BEEDEEP",8389403},
 {"BEGIN_TURN",8389123},
 {"BLOCKED",8389144},
-{"BOOOM",8389410},
-{"BOUNCE",8389415},
-{"BRRREEET",8389396},
-{"BRRRT",8389395},
-{"BUZZER",8389420},
-{"BWEEP",8389397},
+{"BOOOM",8389409},
+{"BOUNCE",8389414},
+{"BRRREEET",8389395},
+{"BRRRT",8389394},
+{"BUZZER",8389419},
+{"BWEEP",8389396},
 {"Background",8683656},
-{"Bishop",8683766},
-{"Bizarro",8618233},
-{"BizarroSwap",10518778},
-{"Broadcast",10518680},
-{"BroadcastAnd",8421529},
-{"BroadcastAndEx",8421530},
-{"BroadcastEx",10518684},
-{"BroadcastList",8421533},
-{"BroadcastListEx",8421534},
-{"BroadcastSum",8421535},
-{"BroadcastSumEx",8421536},
+{"Bishop",8683767},
+{"Bizarro",8618234},
+{"BizarroSwap",10518779},
+{"Broadcast",10518681},
+{"BroadcastAnd",8421530},
+{"BroadcastAndEx",8421531},
+{"BroadcastEx",10518685},
+{"BroadcastList",8421534},
+{"BroadcastListEx",8421535},
+{"BroadcastSum",8421536},
+{"BroadcastSumEx",8421537},
 {"Busy",8618094},
-{"CHEEP",8389393},
-{"CHYEW",8389392},
-{"CLICK",8389388},
+{"CHEEP",8389392},
+{"CHYEW",8389391},
+{"CLICK",8389147},
 {"COLLIDE",8389142},
 {"COLLIDEBY",8389141},
 {"COLLIDING",8389143},
 {"CONFLICT",8389140},
 {"CONNECT",8389145},
 {"CREATE",8389121},
 {"CREATED",8389137},
-{"Chebyshev",8487074},
+{"Chebyshev",8487075},
 {"Class",8486976},
 {"Climb",9142356},
 {"CodePage",8683657},
 {"CollisionLayers",8487036},
-{"Coloc",8487075},
+{"Coloc",8487076},
 {"Compatible",8487035},
-{"Connect",8487076},
+{"Connect",8487077},
 {"Connection",8618104},
 {"Control",8421515},
-{"CopyArray",8421617},
-{"Create",10518693},
+{"CopyArray",8421618},
+{"Create",10518694},
 {"Crush",8618109},
-{"DEEP_POP",8389417},
+{"DEEP_POP",8389416},
 {"DEPARTED",8389125},
 {"DESTROY",8389122},
 {"DESTROYED",8389136},
-{"DINK",8389390},
+{"DINK",8389389},
 {"DOOR",8389378},
-{"DRLRLRINK",8389398},
-{"DYUPE",8389413},
-{"Data",8421542},
-{"DefaultImage",8683664},
-{"DelInventory",8421543},
-{"Delta",8421544},
+{"DRLRLRINK",8389397},
+{"DYUPE",8389412},
+{"Data",8421543},
+{"DefaultImage",8683665},
+{"DelInventory",8421544},
+{"Delta",8421545},
 {"Density",9142348},
 {"Departed",8618091},
 {"Departures",8618093},
-{"Destroy",10584233},
+{"Destroy",10584234},
 {"Destroyed",8487033},
 {"Dir",8618054},
 {"Distance",9142346},
 {"Done",8618103},
-{"DotProduct",8421618},
+{"DotProduct",8421619},
 {"E",9437184},
 {"END_TURN",8389139},
-{"EditorHelp",8683666},
+{"EditorHelp",8683667},
 {"F",9437192},
-{"FAROUT",8389421},
-{"FFFFTT",8389399},
+{"FAROUT",8389420},
+{"FFFFTT",8389398},
 {"FLOATED",8389132},
 {"FROG",8389383},
-{"FakeMove",8487082},
-{"FindConnection",8487083},
+{"FakeMove",8487083},
+{"FindConnection",8487084},
 {"Finished",8552583},
-{"FlushClass",8421548},
-{"FlushObj",8487085},
+{"FlushClass",8421549},
+{"FlushObj",8487086},
 {"From",8421504},
 {"GLASS",8389379},
-{"GLISSANT",8389419},
-{"GetArray",8487148},
-{"GetInventory",8421550},
-{"HAWK",8389425},
-{"HEARTBEAT",8389407},
+{"GLISSANT",8389418},
+{"GetArray",8487149},
+{"GetInventory",8421551},
+{"HAWK",8389424},
+{"HEARTBEAT",8389406},
 {"HIT",8389134},
 {"HITBY",8389135},
 {"Hard",8618072},
 {"Height",9142354},
-{"HeightAt",8421551},
-{"Help",8683665},
-{"HitMe",8421552},
+{"HeightAt",8421552},
+{"Help",8683666},
+{"HitMe",8421553},
 {"INIT",8389120},
-{"IgnoreKey",8421553},
+{"IgnoreKey",8421554},
 {"Image",8618055},
-{"InPlace",8683663},
+{"InPlace",8683664},
 {"Inertia",9142344},
-{"InitArray",8421613},
-{"Input",8683661},
-{"IntMove",10584242},
+{"InitArray",8421614},
+{"Input",8683662},
+{"InputXY",8683661},
+{"IntMove",10584243},
 {"Invisible",8618095},
-{"JAYAYAYNG",8389416},
+{"JAYAYAYNG",8389415},
 {"JUMPED",8389128},
-{"JumpTo",10584243},
-{"KEWEL",8389422},
+{"JumpTo",10584244},
+{"KEWEL",8389421},
 {"KEY",8389129},
 {"KLECK",8389387},
 {"KLINKK",8389385},
 {"Key",8421510},
 {"KeyCleared",8618096},
 {"L",9437194},
 {"LASTIMAGE",8389126},
 {"LB",9437195},
 {"LF",9437193},
-{"LOCK",8389408},
+{"LOCK",8389407},
 {"LOOP",8388610},
 {"Level",8421509},
 {"LevelTable",8683660},
-{"Loc",8487092},
-{"LocateMe",8487093},
-{"LoseLevel",8421558},
+{"Loc",8487093},
+{"LocateMe",8487094},
+{"LoseLevel",8421559},
 {"MOVED",8389127},
 {"MOVING",8389130},
-{"Manhattan",8487095},
-{"MaxInventory",8421560},
+{"Manhattan",8487096},
+{"MaxInventory",8421561},
 {"Misc1",9142364},
 {"Misc2",9142366},
 {"Misc3",9142368},
 {"Misc4",9142370},
 {"Misc5",9142372},
 {"Misc6",9142374},
 {"Misc7",9142376},
-{"Morton",8487097},
-{"Move",10584250},
-{"Move+",10584251},
+{"Morton",8487098},
+{"Move",10584251},
+{"Move+",10584252},
 {"MoveNumber",8552580},
-{"MoveTo",10584252},
+{"MoveTo",10584253},
 {"Moved",8618101},
 {"Moving",8618102},
 {"Msg",8421503},
 {"N",9437186},
 {"NE",9437185},
 {"NEXTWARP",8389146},
 {"NW",9437187},
-{"NewX",8421567},
-{"NewXY",8421568},
-{"NewY",8421569},
-{"OLDPHONE",8389402},
+{"NewX",8421568},
+{"NewXY",8421569},
+{"NewY",8421570},
+{"OLDPHONE",8389401},
 {"ONCE",8388609},
 {"OSC",8388616},
 {"OSCLOOP",8388618},
-{"ObjAbove",8487106},
-{"ObjBelow",8487107},
-{"ObjBottomAt",8421572},
-{"ObjClassAt",8421573},
-{"ObjDir",8487110},
-{"ObjLayerAt",8421575},
-{"ObjMovingTo",8421576},
-{"ObjTopAt",8421577},
+{"ObjAbove",8487107},
+{"ObjBelow",8487108},
+{"ObjBottomAt",8421573},
+{"ObjClassAt",8421574},
+{"ObjDir",8487111},
+{"ObjLayerAt",8421576},
+{"ObjMovingTo",8421577},
+{"ObjTopAt",8421578},
 {"Order",8683658},
-{"Others",8683667},
-{"P",8880371},
-{"P*",8880372},
+{"Others",8683668},
+{"P",8880372},
+{"P*",8880373},
 {"PLAYERMOVING",8389133},
 {"POSTINIT",8389138},
 {"POUR",8389377},
 {"POWER",8389386},
 {"Player",8487034},
-{"PopUp",8421578},
-{"Queen",8683767},
-{"Quiz",8683662},
+{"PopUp",8421579},
+{"Queen",8683768},
+{"Quiz",8683663},
 {"R",9437198},
-{"RATCHET1",8389418},
-{"RATCHET2",8389412},
-{"RATTLE",8389403},
+{"RATCHET1",8389417},
+{"RATCHET2",8389411},
+{"RATTLE",8389402},
 {"RB",9437197},
 {"RF",9437199},
-{"Rel",8487116},
-{"Rook",8683765},
+{"Rel",8487117},
+{"Rook",8683766},
 {"S",9437190},
 {"SE",9437191},
-{"SMALL_POP",8389389},
+{"SMALL_POP",8389388},
 {"SPLASH",8389376},
-{"STEAM",8389424},
+{"STEAM",8389423},
 {"STOP",8388608},
-{"SUBS",8683668},
+{"SUBS",8683669},
 {"SUNK",8389131},
 {"SW",9437189},
-{"Seek",8487117},
+{"Seek",8487118},
 {"Self",8421502},
-{"Send",10584270},
-{"SendEx",10584271},
-{"SetArray",8487150},
-{"SetInventory",8421584},
+{"Send",10584271},
+{"SendEx",10584272},
+{"SetArray",8487151},
+{"SetInventory",8421585},
 {"Shape",8618051},
 {"ShapeDir",8618074},
 {"Sharp",8618073},
 {"Shovable",8618075},
-{"Sound",8421585},
+{"Sound",8421586},
 {"Stealthy",8618100},
 {"Strength",9142358},
-{"Super",8487165},
-{"SwapWorld",8421627},
-{"Sweep",8421586},
-{"SweepEx",8421587},
-{"Synchronize",8421588},
-{"TAHTASHH",8389409},
-{"THMP_thmp",8389405},
+{"Super",8487166},
+{"SwapWorld",8421628},
+{"Sweep",8421587},
+{"SweepEx",8421588},
+{"Synchronize",8421589},
+{"TAHTASHH",8389408},
+{"THMP_thmp",8389404},
 {"THWIT",8389384},
-{"TICK",8389391},
-{"Target",8487125},
+{"TICK",8389390},
+{"Target",8487126},
 {"Temperature",9142337},
-{"Trace",8421590},
-{"TraceStack",8487127},
-{"Trigger",8421592},
-{"TriggerAt",8421593},
+{"Trace",8421591},
+{"TraceStack",8487128},
+{"Trigger",8421593},
+{"TriggerAt",8421594},
 {"UH_OH",8389382},
-{"UNCORK",8389414},
+{"UNCORK",8389413},
 {"UNHH",8389381},
 {"UserSignal",8618097},
 {"UserState",8618098},
-{"VACUUM",8389411},
+{"VACUUM",8389410},
 {"VisualOnly",8618099},
 {"Volume",9142350},
-{"VolumeAt",8421594},
+{"VolumeAt",8421595},
 {"W",9437188},
-{"WAHOO",8389400},
-{"WHACK",8389423},
-{"Walkable",8487131},
+{"WAHOO",8389399},
+{"WHACK",8389422},
+{"Walkable",8487132},
 {"Weight",9142352},
-{"WinLevel",8487132},
-{"XDir",8487133},
-{"XStep",8487134},
-{"XYDir",8421599},
+{"WinLevel",8487133},
+{"XDir",8487134},
+{"XStep",8487135},
+{"XYDir",8421600},
 {"Xloc",8486980},
-{"YDir",8487136},
-{"YEEHAW",8389401},
-{"YStep",8487137},
+{"YDir",8487137},
+{"YEEHAW",8389400},
+{"YStep",8487138},
 {"Yloc",8486981},
-{"_",8421602},
+{"_",8421603},
 {"a?",8421439},
 {"again",8683533},
 {"and",8683544},
 {"band",8421415},
 {"begin",8683532},
@@ -806,27 +808,27 @@
 {"bnot",8421418},
 {"bor",8421416},
 {"bxor",8421417},
 {"c?",8421433},
 {"case",8683542},
-{"chain",8421537},
-{"clear",8421609},
-{"count",8421608},
-{"cut",8683768},
+{"chain",8421538},
+{"clear",8421610},
+{"count",8421609},
+{"cut",8683769},
 {"cz?",8421434},
 {"dup",8421377},
 {"else",8683530},
 {"eq",8421424},
 {"eq2",8421425},
 {"exec",8486940},
-{"flip",8421607},
+{"flip",8421608},
 {"for",8683537},
 {"fork",8683545},
 {"ge",8486965},
 {"gt",8486963},
 {"if",8683529},
-{"in",8421604},
+{"in",8421605},
 {"is",8421431},
 {"land",8421420},
 {"le",8486966},
 {"link",8683547},
 {"lnot",8421423},
@@ -834,18 +836,18 @@
 {"lsh",8421413},
 {"lt",8486964},
 {"lxor",8421422},
 {"m?",8421435},
 {"max",8486948},
-{"mbegin",8683750},
+{"mbegin",8683751},
 {"min",8486947},
 {"mod",8486945},
 {"n?",8421432},
 {"ne",8421426},
 {"neg",8421410},
 {"next",8683538},
-{"nin",8421605},
+{"nin",8421606},
 {"nip",8421379},
 {"o?",8421437},
 {"or",8683543},
 {"over",8421384},
 {"oz?",8421438},
@@ -856,13 +858,13 @@
 {"rsh",8486950},
 {"rtn",8683546},
 {"s?",8421436},
 {"swap",8421378},
 {"then",8683531},
-{"tmark",8421603},
+{"tmark",8421604},
 {"tuck",8421380},
-{"uniq",8421610},
+{"uniq",8421611},
 {"until",8683534},
 {"while",8683535},
 };
-#define N_OP_NAMES 364
+#define N_OP_NAMES 365
 #endif

Index: instruc.js
==================================================================
--- instruc.js
+++ instruc.js
@@ -1,22 +1,26 @@
 "use strict";
 const fs=require("fs");
 const names_file=fs.readFileSync("names.js","ascii").split("\n");
 const data_file=fs.readFileSync("instruc","ascii").split("\n");
+const msgkeys=Object.create(null);
 const do_sound_names=x=>{
   if(!x || x[0]=="`") return;
   if(x[0]=="c") return f=()=>0;
   let y=/^ *([A-Za-z_0-9]+) *$/.exec(x);
-  if(y) return data_file.push("#"+y[1]);
+  if(y && !msgkeys[y[1]]) return data_file.push("#"+y[1]);
 };
 const do_message_names=x=>{
   if(x.startsWith("const standard_sound_names=")) {
     data_file.push("(0300)");
     return f=do_sound_names;
   }
   let y=/^ *([0-9]+) = ([^ ]*) *$/.exec(x);
-  if(y) data_file.push("#"+y[2]+" ("+(Number(y[1])+0x0200).toString(16)+")");
+  if(y) {
+    msgkeys[y[2]]=true;
+    data_file.push("#"+y[2]+" ("+(Number(y[1])+0x0200).toString(16)+")");
+  }
 };
 let f=x=>{
   if(x.startsWith("const standard_message_names=")) f=do_message_names;
 };
 names_file.forEach(x=>f(x)); // not .forEach(f); the function to use varies

Index: main.c
==================================================================
--- main.c
+++ main.c
@@ -25,10 +25,11 @@
 #include "heromesh.h"
 
 typedef struct {
   char a[(N_MESSAGES==sizeof(standard_message_names)/sizeof(*standard_message_names))?1:-9];
   char b[('\1\0'*'x'+'\0\1'*'y'=='xy')?1:-9];
+  char c[(N_STANDARD_SOUNDS==sizeof(standard_sound_names)/sizeof(*standard_sound_names))?1:-9];
 } ASSERTION;
 
 static const char schema[]=
   "BEGIN;"
   "PRAGMA APPLICATION_ID(1296388936);"

Index: mbtofhm.c
==================================================================
--- mbtofhm.c
+++ mbtofhm.c
@@ -7,10 +7,11 @@
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #define HEROMESH_MAIN
+#define HEROMESH_CONV_MAIN
 #include "names.h"
 
 #define fatal(...) do{ fprintf(stderr,__VA_ARGS__); exit(1); }while(0)
 
 // Pictures

Index: names.h
==================================================================
--- names.h
+++ names.h
@@ -24,10 +24,11 @@
 #define MSG_COLLIDE 22
 #define MSG_COLLIDING 23
 #define MSG_BLOCKED 24
 #define MSG_CONNECT 25
 #define MSG_NEXTWARP 26
+#define MSG_CLICK 27
 #ifdef HEROMESH_MAIN
 const char*const standard_message_names[]={
  "INIT",
  "CREATE",
  "DESTROY",
@@ -53,63 +54,12 @@
  "COLLIDE",
  "COLLIDING",
  "BLOCKED",
  "CONNECT",
  "NEXTWARP",
+ "CLICK",
 };
-#endif
-#define SND_SPLASH 0
-#define SND_POUR 1
-#define SND_DOOR 2
-#define SND_GLASS 3
-#define SND_BANG 4
-#define SND_UNHH 5
-#define SND_UH_OH 6
-#define SND_FROG 7
-#define SND_THWIT 8
-#define SND_KLINKK 9
-#define SND_POWER 10
-#define SND_KLECK 11
-#define SND_CLICK 12
-#define SND_SMALL_POP 13
-#define SND_DINK 14
-#define SND_TICK 15
-#define SND_CHYEW 16
-#define SND_CHEEP 17
-#define SND_ANHH 18
-#define SND_BRRRT 19
-#define SND_BRRREEET 20
-#define SND_BWEEP 21
-#define SND_DRLRLRINK 22
-#define SND_FFFFTT 23
-#define SND_WAHOO 24
-#define SND_YEEHAW 25
-#define SND_OLDPHONE 26
-#define SND_RATTLE 27
-#define SND_BEEDEEP 28
-#define SND_THMP_thmp 29
-#define SND_BEDOINGNG 30
-#define SND_HEARTBEAT 31
-#define SND_LOCK 32
-#define SND_TAHTASHH 33
-#define SND_BOOOM 34
-#define SND_VACUUM 35
-#define SND_RATCHET2 36
-#define SND_DYUPE 37
-#define SND_UNCORK 38
-#define SND_BOUNCE 39
-#define SND_JAYAYAYNG 40
-#define SND_DEEP_POP 41
-#define SND_RATCHET1 42
-#define SND_GLISSANT 43
-#define SND_BUZZER 44
-#define SND_FAROUT 45
-#define SND_KEWEL 46
-#define SND_WHACK 47
-#define SND_STEAM 48
-#define SND_HAWK 49
-#ifdef HEROMESH_MAIN
 const char*const standard_sound_names[]={
  "SPLASH",
  "POUR",
  "DOOR",
  "GLASS",
@@ -119,11 +69,13 @@
  "FROG",
  "THWIT",
  "KLINKK",
  "POWER",
  "KLECK",
+#ifdef HEROMESH_CONV_MAIN
  "CLICK",
+#endif
  "SMALL_POP",
  "DINK",
  "TICK",
  "CHYEW",
  "CHEEP",

Index: names.js
==================================================================
--- names.js
+++ names.js
@@ -29,10 +29,11 @@
  22 = COLLIDE
  23 = COLLIDING
  24 = BLOCKED
  25 = CONNECT
  26 = NEXTWARP
+ 27 = CLICK
 `.split("\n").map(x=>/^ *([0-9]+) = ([^ ]*) *$/.exec(x)).filter(x=>x);
 const standard_sound_names=[];
 `
  SPLASH
  POUR
@@ -139,21 +140,26 @@
   heromesh_key_names[y]=z;
 });
 [..."ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"].forEach(x=>{
   heromesh_key_names[x.charCodeAt()]=x;
 });
+const msgkeys=Object.create(null); // In case some message names are also sound names
 console.log("// Auto-generated! Do not modify directly!");
-standard_message_names.forEach(([a,b,c])=>console.log("#define MSG_"+c+" "+b));
+standard_message_names.forEach(([a,b,c])=>{
+  msgkeys[c]=true;
+  console.log("#define MSG_"+c+" "+b);
+});
 console.log("#ifdef HEROMESH_MAIN");
 console.log("const char*const standard_message_names[]={");
 standard_message_names.forEach(([a,b,c])=>console.log(" \""+c+"\","));
 console.log("};");
-console.log("#endif");
-standard_sound_names.forEach((x,y)=>console.log("#define SND_"+x+" "+y));
-console.log("#ifdef HEROMESH_MAIN");
 console.log("const char*const standard_sound_names[]={");
-standard_sound_names.forEach(x=>console.log(" \""+x+"\","));
+standard_sound_names.forEach(x=>{
+  if(msgkeys[x]) console.log("#ifdef HEROMESH_CONV_MAIN");
+  console.log(" \""+x+"\",");
+  if(msgkeys[x]) console.log("#endif");
+});
 console.log("};");
 console.log("const char*const heromesh_key_names[256]={");
 Object.keys(heromesh_key_names).forEach(x=>console.log(" ["+x+"]=\""+heromesh_key_names[x]+"\","));
 console.log("};");
 console.log("#endif");

Index: sound.c
==================================================================
--- sound.c
+++ sound.c
@@ -12,12 +12,10 @@
 #include "smallxrm.h"
 #include "quarks.h"
 #include "heromesh.h"
 #include "cursorshapes.h"
 
-#define N_STANDARD_SOUNDS 50
-
 typedef struct {
   Uint8*data;
   Uint32 len; // length in bytes
 } WaveSound;