Overview
Comment: | Implement all of the rest of the (LevelTable) block and its displaying and processing, except the string matching, which will be implemented later. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
d24dfda327826d0f68667fe7d95afd27 |
User & Date: | user on 2021-12-29 00:29:24 |
Other Links: | manifest | tags |
Context
2021-12-30
| ||
21:49 | Implement pattern strings and some other commands, an da few more corrections, in the (LevelTable) block implementation. check-in: b629fea66f user: user tags: trunk | |
2021-12-29
| ||
00:29 | Implement all of the rest of the (LevelTable) block and its displaying and processing, except the string matching, which will be implemented later. check-in: d24dfda327 user: user tags: trunk | |
00:04 | Add a entry to the Frequently Asked Questions section about use of Free Hero Mesh with gdb. check-in: b3b7b53f2b user: user tags: trunk | |
Changes
Modified class.c from [7cb8ff67cc] to [7243e8c48b].
︙ | |||
2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 | 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 | + + + + + + + + + + + + + + + + + + | free(aggrc); ll_disp=realloc(dispc,(ll_ndisp)*sizeof(DisplayColumn))?:dispc; // The next line will result in an invalid pointer if ptr is zero, // but this is harmless, since ll_code is never accessed if ptr is zero. ll_code=realloc(ll_code,ptr*sizeof(Uint16))?:ll_code; for(i=0;i<LOCAL_HASH_SIZE;i++) free(hash[i].txt); free(hash); if(main_options['C']) { printf("<<<LevelTable>>>\n Data/Aggregate:\n"); for(i=0;i<ll_ndata+ll_naggregate;i++) { printf(" %d: ",i); if(i<ll_ndata) printf(" \"%s\"",ll_data[i].name); else printf(" (%d)",ll_data[i].ag); printf(" 0x%04X %c\n",ll_data[i].ptr,ll_data[i].sgn?'s':'u'); } printf(" Display:\n"); for(i=0;i<ll_ndisp;i++) printf(" %d: data=%d width=%d format=%c%c color=%d flag=%d ptr=0x%04X\n",i ,ll_disp[i].data,ll_disp[i].width,ll_disp[i].form[0]?:' ',ll_disp[i].form[1]?:' ',ll_disp[i].color,ll_disp[i].flag,ll_disp[i].ptr); printf(" Codes:"); for(i=0;i<ptr;i++) { if(!(i&15)) printf("\n [%04X]",i); printf(" %04X",ll_code[i]); } putchar('\n'); printf("---\n\n"); } } void load_classes(void) { int i; int gloptr=0; Hash*glolocalhash; char*nam=sqlite3_mprintf("%s.class",basefilename); |
︙ |
Modified class.doc from [e3fcdbff9c] to [6d0262fd53].
︙ | |||
2603 2604 2605 2606 2607 2608 2609 | 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 | + - + | no colums are fill width). The <format> is a string of exactly one or two characters; see the below list of possible formats. The <color> is the text colour, and is optional; it can be a number from 1 to 255, or it can be a sequence of parenthesized pairs of a number (-127 to +127) and colour, to mean use those colour if the value of this column is in range. It uses the colour for all values up to and including the specified number, so the numbers should be listed in ascending order, in order to work. If the last number is 127 then it is also use for all |
︙ | |||
2630 2631 2632 2633 2634 2635 2636 | 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 | - + + + + + + + + + + + + + + + + + + + + + + | (right aligned) as signed decimal (d), hexadecimal (x/X), octal (o), unsigned decimal (u). The ones with "0" will pad by 0 instead of spaces, and the "d-" and "d+" will display a left aligned sign. If a numeric format is specified but it is a text value, then it is treated as "L" instead, unless format is "R*" in which case it is treated as "R". |
Modified function.c from [3ae0a5eecb] to [89407dfd1e].
1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | - + + | #if 0 |
︙ | |||
1208 1209 1210 1211 1212 1213 1214 | 1209 1210 1211 1212 1213 1214 1215 1216 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 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | typedef struct { Value misc1,misc2,misc3; Uint8 x,y,dir,bizarro; Uint16 class; } ObjInfo; #define ArithOp1(aa) ({ if(sp<1 || stack[sp-1].t) goto bad; Value t1=stack[sp-1]; stack[sp-1]=NVALUE(aa); }) #define ArithOp2(aa) ({ if(sp<2 || stack[sp-1].t || stack[sp-2].t) goto bad; Value t1=stack[sp-2]; Value t2=stack[sp-1]; sp--; stack[sp-1]=NVALUE(aa); }) #define ArithDivOp2(aa) ({ if(sp<2 || stack[sp-1].t || stack[sp-2].t || !stack[sp-1].u) goto bad; Value t1=stack[sp-2]; Value t2=stack[sp-1]; sp--; stack[sp-1]=NVALUE(aa); }) #define OtherOp1(aa) ({ if(sp<1) goto bad; Value t1=stack[sp-1]; stack[sp-1]=(aa); }) #define OtherOp2(aa) ({ if(sp<2) goto bad; Value t1=stack[sp-2]; Value t2=stack[sp-1]; sp--; stack[sp-1]=(aa); }) static inline Uint32 ll_in(Value*stack,Sint16 top,Sint16 m) { while(--top>m) if(stack[top].t==stack[m-1].t && stack[top].u==stack[m-1].u) return 1; return 0; } static Sint16 level_table_exec(Uint16 ptr,const unsigned char*lvl,long sz,ObjInfo*ob,Value*stack,Value*agg) { Sint16 sp=0; Uint32 k,m; while(sp<62) switch(ll_code[ptr++]) { case 0 ... 255: stack[sp++]=NVALUE(ll_code[ptr-1]); break; case 0x0200 ... 0x02FF: stack[sp++]=MVALUE(ll_code[ptr-1]&255); break; case 0x4000 ... 0x7FFF: stack[sp++]=CVALUE(ll_code[ptr-1]&0x3FFF); break; case 0xC000 ... 0xFFFF: stack[sp++]=MVALUE((ll_code[ptr-1]&0x3FFF)+256); break; case OP_ADD: ArithOp2(t1.u+t2.u); break; case OP_BAND: ArithOp2(t1.u&t2.u); break; case OP_BIZARRO: if(!ob) goto bad; stack[sp++]=NVALUE(ob->bizarro); break; case OP_BNOT: ArithOp1(~t1.u); break; case OP_BOR: ArithOp2(t1.u|t2.u); break; case OP_BXOR: ArithOp2(t1.u^t2.u); break; case OP_CLASS: if(!ob) goto bad; stack[sp++]=CVALUE(ob->class); break; case OP_COLLISIONLAYERS: if(!ob) goto bad; stack[sp++]=NVALUE(classes[ob->class]->collisionLayers); break; case OP_DELTA: ArithOp2(t1.u>t2.u?t1.u-t2.u:t2.u-t1.u); break; case OP_DENSITY: if(!ob) goto bad; stack[sp++]=NVALUE(classes[ob->class]->density); break; case OP_DIR: if(!ob) goto bad; stack[sp++]=NVALUE(ob->dir); break; case OP_DIV: ArithDivOp2(t1.u/t2.u); break; case OP_DIV_C: ArithDivOp2(t1.s/t2.s); break; case OP_EQ: OtherOp2(NVALUE((t1.u==t2.u && t1.t==t2.t)?1:0)); break; case OP_GE: ArithOp2(t1.u>=t2.u?1:0); break; case OP_GE_C: ArithOp2(t1.s>=t2.s?1:0); break; case OP_GOTO: ptr=ll_code[ptr]; break; case OP_GT: ArithOp2(t1.u>t2.u?1:0); break; case OP_GT_C: ArithOp2(t1.s>t2.s?1:0); break; case OP_IF: if(!sp--) goto bad; if(stack[sp].t || stack[sp].u) ptr++; else ptr=ll_code[ptr]; break; case OP_IN: case OP_NIN: if(sp<2) goto bad; for(m=sp-1;m;m--) if(stack[m].t==TY_MARK) { k=ll_in(stack,sp,m); sp=m; stack[sp-1].t=TY_NUMBER; stack[sp-1].u=(ll_code[ptr-1]==OP_IN?0:1)^k; } if(!m) goto bad; break; case OP_INPUT: if(!ob) goto bad; stack[sp++]=NVALUE(classes[ob->class]->cflags&CF_INPUT?1:0); break; case OP_INT16: stack[sp++]=NVALUE(ll_code[ptr]); ptr++; break; case OP_INT32: stack[sp++]=NVALUE(ll_code[ptr+1]); stack[sp-1].u|=ll_code[ptr]<<16; ptr+=2; break; case OP_LAND: OtherOp2(NVALUE(((t1.u || t1.t) && (t2.u || t2.t))?1:0)); break; case OP_LE: ArithOp2(t1.u<=t2.u?1:0); break; case OP_LE_C: ArithOp2(t1.s<=t2.s?1:0); break; case OP_LEVEL: stack[sp++]=NVALUE(lvl[2]|(lvl[3]<<8)); break; case OP_LNOT: OtherOp1(NVALUE((t1.u || t1.t)?0:1)); break; case OP_LOCAL: if(!agg) goto bad; stack[sp++]=agg[ll_code[ptr++]]; break; case OP_LOR: OtherOp2(NVALUE((t1.u || t1.t || t2.u || t2.t)?1:0)); break; case OP_LSH: ArithOp2(t2.u&~31?0:t1.u<<t2.u); break; case OP_LT: ArithOp2(t1.u<t2.u?1:0); break; case OP_LT_C: ArithOp2(t1.s<t2.s?1:0); break; case OP_LXOR: OtherOp2(NVALUE(((t1.u || t1.t)?1:0)^((t2.u || t2.t)?1:0))); break; case OP_MARK: stack[sp++]=UVALUE(0,TY_MARK); break; case OP_MAX: ArithOp2(t1.u<t2.u?t2.u:t1.u); break; case OP_MAX_C: ArithOp2(t1.s<t2.s?t2.s:t1.s); break; case OP_MIN: ArithOp2(t1.u>t2.u?t2.u:t1.u); break; case OP_MIN_C: ArithOp2(t1.s>t2.s?t2.s:t1.s); break; case OP_MISC1: if(!ob) goto bad; stack[sp++]=ob->misc1; break; case OP_MISC2: if(!ob) goto bad; stack[sp++]=ob->misc2; break; case OP_MISC3: if(!ob) goto bad; stack[sp++]=ob->misc3; break; case OP_MISC4: if(!ob) goto bad; stack[sp++]=NVALUE(classes[ob->class]->misc4); break; case OP_MISC5: if(!ob) goto bad; stack[sp++]=NVALUE(classes[ob->class]->misc5); break; case OP_MISC6: if(!ob) goto bad; stack[sp++]=NVALUE(classes[ob->class]->misc6); break; case OP_MISC7: if(!ob) goto bad; stack[sp++]=NVALUE(classes[ob->class]->misc7); break; case OP_MOD: ArithDivOp2(t1.u%t2.u); break; case OP_MOD_C: ArithDivOp2(t1.s%t2.s); break; case OP_MUL: ArithOp2(t1.u*t2.u); break; case OP_MUL_C: ArithOp2(t1.s*t2.s); break; case OP_NE: OtherOp2(NVALUE((t1.u==t2.u && t1.t==t2.t)?0:1)); break; case OP_NEG: ArithOp1(-t1.s); break; case OP_PLAYER: if(!ob) goto bad; stack[sp++]=NVALUE(classes[ob->class]->cflags&CF_PLAYER?1:0); break; case OP_RET: return sp; case OP_RSH: ArithOp2(t2.u&~31?0:t1.u>>t2.u); break; case OP_RSH_C: ArithOp2(t2.u&~31?(t1.s<0?-1:0):t1.s>>t2.u); break; case OP_STRING: // If starting with @ then a literal string, otherwise match a part of the level title. //TODO break; case OP_SUB: ArithOp2(t1.u-t2.u); break; case OP_TEMPERATURE: if(!ob) goto bad; stack[sp++]=NVALUE(classes[ob->class]->temperature); break; case OP_USERFLAG: if(!ob) goto bad; if(ll_code[ptr]<0x1020) k=classes[ob->class]->misc4; else if(ll_code[ptr]<0x1040) k=classes[ob->class]->misc5; else if(ll_code[ptr]<0x1060) k=classes[ob->class]->misc6; else if(ll_code[ptr]<0x1080) k=classes[ob->class]->misc7; else k=classes[ob->class]->collisionLayers; stack[sp].t=TY_NUMBER; stack[sp].u=(k&(1LL<<(ll_code[ptr++]&31)))?1:0; sp++; break; case OP_XLOC: if(!ob) goto bad; stack[sp++]=NVALUE(ob->x); break; case OP_YLOC: if(!ob) goto bad; stack[sp++]=NVALUE(ob->y); break; default: goto bad; } bad: if(main_options['v']) fprintf(stderr,"Error in LevelTable definition (at 0x%04X)\n",ptr); return -1; } |
︙ | |||
1256 1257 1258 1259 1260 1261 1262 | 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 | - + | if(n<7 || !d) continue; sqlite3_bind_int(st2,2,d[2]|(d[3]<<8)); sqlite3_bind_int(st2,3,(d[4]&63)+1); sqlite3_bind_int(st2,4,(d[5]&63)+1); for(i=6;i<n && d[i];i++); j=d[0]|(d[1]<<8); sqlite3_bind_blob(st2,5,d+6,i-6,0); |
︙ |
Modified game.c from [b19cf21fe8] to [7219595d81].
︙ | |||
735 736 737 738 739 740 741 | 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 | - + + + + + | if(dc->form[0]=='R') a=w-i; if(dc->flag&2) co=0xFF; } else { // This implementation does not check that the format is necessarily valid. // You should not rely on the use of any undocumented format. v=sqlite3_column_int64(st,nc); if(dc->flag&2) { |
︙ |