Overview
Comment: | The syntax of for/next loops has been changed; also added some codes for dealing with user cache data |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
8b26cd42e7982e56257639dfadbeef1b |
User & Date: | user on 2018-06-03 22:43:48 |
Other Links: | manifest | tags |
Context
2018-06-08
| ||
21:15 | More class loading codes; correction to user cache check-in: 81d74d79e1 user: user tags: trunk | |
2018-06-03
| ||
22:43 | The syntax of for/next loops has been changed; also added some codes for dealing with user cache data check-in: 8b26cd42e7 user: user tags: trunk | |
2018-05-27
| ||
22:33 | More class loading code check-in: 9d448767e4 user: user tags: trunk | |
Changes
Modified class.c from [d60d73f095] to [38d08ac889].
︙ | |||
873 874 875 876 877 878 879 | 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 | - + | #define ChangeInst(x) (cl->codes[ptr-1]x,prflag=0) #define InstFlag(x) (peep<ptr && (prflag&(x))) #define Inst7bit() (peep<ptr && cl->codes[ptr-1]<0x0080) #define Inst8bit() (peep<ptr && cl->codes[ptr-1]<0x0100) #define AbbrevOp(x,y) case x: if(Inst7bit()) ChangeInst(+=0x1000|((y)<<4)); else AddInstF(x,tokent); break #define FlowPush(x) do{ if(flowdepth==64) ParseError("Too much flow control nesting\n"); flowop[flowdepth]=x; flowptr[flowdepth++]=ptr; }while(0) #define FlowPop(x) do{ if(!flowdepth || flowop[--flowdepth]!=(x)) ParseError("Flow control mismatch\n"); }while(0) |
︙ | |||
1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 | 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 | + + + + + + + + - - - - - - - - - - - - - - - | case OP_REPEAT: FlowPop(OP_WHILE); x=flowptr[flowdepth]; FlowPop(OP_BEGIN); AddInst2(OP_GOTO,flowptr[flowdepth]); cl->codes[x]=ptr; break; case OP_FOR: if(cl->uservars>=0x07FF || num_globals>=0x07FF) ParseError("Too many user variables\n"); if(cla) x=cl->uservars++|0x2000; else x=num_globals++|0x2800; AddInst2(OP_FOR,x); FlowPush(OP_FOR); peep=++ptr; break; case OP_NEXT: FlowPop(OP_FOR); AddInst(OP_NEXT); cl->codes[flowptr[flowdepth]]=ptr; break; default: if(Tokenf(TF_ABNORMAL)) ParseError("Invalid instruction token\n"); if(compat && Tokenf(TF_COMPAT)) ++tokenv; AddInstF(tokenv,tokent); } } else if(Tokenf(TF_FUNCTION)) { AddInst2(OP_FUNCTION,tokenv&0x3FFF); } else if(tokent==TF_OPEN) { nxttok(); if(Tokenf(TF_MACRO) || !Tokenf(TF_NAME)) ParseError("Invalid parenthesized instruction\n"); switch(tokenv) { |
︙ | |||
1076 1077 1078 1079 1080 1081 1082 1083 1084 | 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | } if(ptr>=0xFFEF) ParseError("Out of code space\n"); } if(flowdepth) ParseError("Unterminated flow control blocks (%d levels)\n",flowdepth); cl->codes=realloc(cl->codes,ptr*sizeof(Uint16))?:cl->codes; return ptr; } static void dump_class(int cla,int endptr,const Hash*hash) { const Class*cl=classes[cla]; int i,j; if(!cl) return; printf("<<<Class %d>>>\n",cla); printf(" Name: %c%s\n",cla?'$':'(',cla?cl->name:"Global)"); printf(" Flags: 0x%02X 0x%04X\n",cl->cflags,cl->oflags); printf(" Ht=%d Wt=%d Clm=%d Den=%d Vol=%d Str=%d Arr=%d Dep=%d\n",cl->height,cl->weight,cl->climb,cl->density,cl->volume,cl->strength,cl->arrivals,cl->departures); printf(" Temp=%d M4=%d M5=%d M6=%d M7=%d Shape=%d Shov=%d Coll=%d Img=%d\n",cl->temperature,cl->misc4,cl->misc5,cl->misc6,cl->misc7,cl->shape,cl->shovable,cl->collisionLayers,cl->nimages); printf(" Hard: %d %d %d %d\n",cl->hard[0],cl->hard[1],cl->hard[2],cl->hard[3]); printf(" Sharp: %d %d %d %d\n",cl->sharp[0],cl->sharp[1],cl->sharp[2],cl->sharp[3]); if(cl->nimages && cl->images) { printf(" Images:"); for(i=0;i<cl->nimages;i++) printf(" %d%c",cl->images[i]&0x7FFF,cl->images[i]&0x8000?'*':'.'); putchar('\n'); } if(cl->nmsg && cl->messages) { printf(" Messages:\n"); for(i=0;i<cl->nmsg;i++) { if(cl->messages[i]!=0xFFFF) { if(i<256) printf(" %s: 0x%04X\n",standard_message_names[i],cl->messages[i]); else printf(" #%s: 0x%04X\n",messages[i-256],cl->messages[i]); } } } if(hash && cl->uservars) { printf(" Variables:\n"); for(i=0;i<LOCAL_HASH_SIZE;i++) { if(hash[i].id>=0x2000 && hash[i].id<0x3000) printf(" %%%s = 0x%04X\n",hash[i].txt,hash[i].id); } } if(endptr && cl->codes) { printf(" Codes:\n"); for(i=0;i<endptr;i++) { if(!(i&16)) printf(" [%04X]",i); printf(" %04X",cl->codes[i]); } putchar('\n'); } printf("---\n\n"); } static void class_definition(int cla) { Hash*hash=calloc(LOCAL_HASH_SIZE,sizeof(Hash)); Class*cl=classes[cla]; int ptr=0; int compat=0; int i; if(!hash) fatal("Allocation failed\n"); if(!cl) fatal("Confusion of class definition somehow\n"); if(cl->cflags&(CF_NOCLASS1|CF_NOCLASS2)) { cl->cflags=0; } else { ParseError("Duplicate definition of class $%s\n",cl->name); |
︙ | |||
1134 1135 1136 1137 1138 1139 1140 | 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 | - + - + | nxttok(); if(tokent==TF_EOF) goto done; if(tokent!=TF_OPEN) ParseError("Expected open parenthesis\n"); nxttok(); if(Tokenf(TF_FUNCTION)) { functions[tokenv&0x3FFF]=gloptr; begin_label_stack(); |
︙ | |||
1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 | 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 | + + | } } else { ParseError("Invalid top level definition\n"); } } done: fclose(classfp); if(main_options['C']) dump_class(0,gloptr,glolocalhash); if(main_options['H']) { for(i=0;i<HASH_SIZE;i++) if(glohash[i].id) printf("\"%s\": %04X\n",glohash[i].txt,glohash[i].id); for(i=0;i<LOCAL_HASH_SIZE;i++) if(glolocalhash[i].id) printf(" \"%s\": %04X\n",glolocalhash[i].txt,glolocalhash[i].id); } for(i=0;i<LOCAL_HASH_SIZE;i++) free(glolocalhash[i].txt); free(glolocalhash); for(i=0;i<num_functions;i++) if(functions[i]==0xFFFF) { int j; for(j=0;j<HASH_SIZE;j++) if(glohash[j].id==i+0x8000) fatal("Function &%s mentioned but not defined\n",glohash[j].txt); fatal("Function mentioned but not defined\n"); |
︙ |
Modified heromesh.h from [a6cc7a9107] to [89943d20fd].
︙ | |||
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | + + + + + + | 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]; unsigned char*read_lump(int sol,int lvl,long*sz,sqlite3_value**us); void set_cursor(int id); #define FIL_SOLUTION 1 #define FIL_LEVEL 0 #define LUMP_LEVEL_IDX (-1) #define LUMP_CLASS_DEF (-2) // == picture == extern SDL_Surface*screen; extern Uint16 picture_size; void draw_picture(int x,int y,Uint16 img); void draw_text(int x,int y,const unsigned char*t,int bg,int fg); |
︙ |
Modified main.c from [00241b77ff] to [e806b2d7f2].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 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 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | #if 0 gcc ${CFLAGS:--s -O2} -o ${EXE:-~/bin/heromesh} main.c class.o picture.o bindings.o smallxrm.o sqlite3.o `sdl-config --cflags --libs` -ldl -lpthread exit #endif /* This program is part of Free Hero Mesh and is public domain. */ #define _BSD_SOURCE #define HEROMESH_MAIN #include "SDL.h" #include <limits.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/file.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> #include "sqlite3.h" #include "smallxrm.h" #include "names.h" #include "quarks.h" #include "cursorshapes.h" #include "heromesh.h" static const char schema[]= "BEGIN;" "PRAGMA APPLICATION_ID(1296388936);" "PRAGMA RECURSIVE_TRIGGERS(1);" "CREATE TABLE IF NOT EXISTS `USERCACHEINDEX`(`ID` INTEGER PRIMARY KEY, `NAME` TEXT, `TIME` INT);" "CREATE TABLE IF NOT EXISTS `USERCACHEDATA`(`ID` INTEGER PRIMARY KEY, `FILE` INT, `LEVEL` INT, `NAME` TEXT, `OFFSET` INT, `DATA` BLOB, `USERSTATE` BLOB);" |
︙ |
Modified mbtofhm.c from [12639d272e] to [4ebc9c7d4a].
︙ | |||
744 745 746 747 748 749 750 | 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 | - + | case 132: fprintf(fp," SetInventory 5 MaxInventory"); st=0; break; case 133: fprintf(fp," DelInventory"); st=0; break; case 134: |
︙ |