Overview
Comment: | Implement the (Control) block to define a global control object. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
665dcd24be3b6869afe0ace54df9b7c2 |
User & Date: | user on 2021-12-10 00:00:13 |
Other Links: | manifest | tags |
Context
2021-12-14
| ||
06:54 | Start to implement the LEVELS table. check-in: c4208ea179 user: user tags: trunk | |
2021-12-10
| ||
00:00 | Implement the (Control) block to define a global control object. check-in: 665dcd24be user: user tags: trunk | |
2021-12-04
| ||
06:13 | Corrections in picedit.c due to recent things added check-in: 33fb27825a user: user tags: trunk | |
Changes
Modified class.c from [0a4452237b] to [170c8e3f92].
︙ | |||
48 49 50 51 52 53 54 55 56 57 58 59 60 61 | 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | + | Uint8 inv_back_color=9; char**stringpool; AnimationSlot anim_slot[8]; Uint8 keymask[256/8]; Uint16 array_size; Uint16*orders; Uint8 norders; Uint16 control_class; #define HASH_SIZE 8888 #define LOCAL_HASH_SIZE 5555 typedef struct { Uint16 id; char*txt; } Hash; |
︙ | |||
2133 2134 2135 2136 2137 2138 2139 | 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 | - + | if(tokent!=TF_OPEN) ParseError("Open or close parenthesis expected\n"); if(ptr>=0x3FFD) ParseError("Out of order memory\n"); nxttok(); if(Tokenf(TF_MACRO|TF_COMMA|TF_EQUAL) || !Tokenf(TF_NAME)) ParseError("Unexpected token in (Order) block\n"); orders[++norders]=ptr; if(norders==beg) ParseError("Too many orders\n"); switch(tokenv) { |
︙ | |||
2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 | 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 | + | case 0x1000 ... 0x101F: if(classes[i]->misc4&(1UL<<(k&0x1F))) goto found; break; case 0x1020 ... 0x103F: if(classes[i]->misc5&(1UL<<(k&0x1F))) goto found; break; case 0x1040 ... 0x105F: if(classes[i]->misc6&(1UL<<(k&0x1F))) goto found; break; case 0x1060 ... 0x107F: if(classes[i]->misc7&(1UL<<(k&0x1F))) goto found; break; case 0x1080 ... 0x1087: if(classes[i]->collisionLayers&(1L<<(k&0x07))) goto found; break; case OP_PLAYER: if(classes[i]->cflags&CF_PLAYER) goto found; break; case OP_INPUT: if(classes[i]->cflags&CF_INPUT) goto found; break; case OP_CONTROL: if(i==control_class) goto found; break; } continue; found: classes[i]->order=j; break; } } } |
︙ | |||
2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 | 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 | + + + + + + + | nxttok(); if(tokent!=TF_CLOSE) ParseError("Expected close parenthesis\n"); break; case OP_ORDER: if(norders) ParseError("Extra (Order) block\n"); parse_order_block(); break; case OP_CONTROL: if(control_class) ParseError("Extra (Control) block\n"); strcpy(tokenstr,"(Control)"); control_class=look_class_name(); if(!(classes[control_class]->cflags&CF_NOCLASS1)) ParseError("Conflicting definition of (Control) class\n"); class_definition(control_class,vst); break; default: ParseError("Invalid top level definition: %s\n",tokenstr); } } else { ParseError("Invalid top level definition\n"); } } |
︙ | |||
2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 | 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 | + + + + | } else { free(glohash[i].txt); } } if(vst) sqlite3_finalize(vst); free(glohash); for(i=1;i<undef_class;i++) if(classes[i] && (classes[i]->cflags&CF_NOCLASS1)) fatal("Class $%s mentioned but not defined\n",classes[i]->name); if(control_class) { if(classes[control_class]->nimages) fatal("Images are not allowed in Control class"); if(classes[control_class]->cflags&CF_GROUP) fatal("Control class is not allowed to be Abstract"); } if(macros) for(i=0;i<MAX_MACRO;i++) if(macros[i]) free_macro(macros[i]); free(macros); if(array_size) { array_data=malloc(array_size*sizeof(Value)); if(!array_data) fatal("Array allocation failed\n"); } if(norders) set_class_orders(); fprintf(stderr,"Done\n"); } |
Modified class.doc from [04a1165740] to [f6921ebc9a].
︙ | |||
267 268 269 270 271 272 273 274 275 276 277 278 279 280 | 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | + + + + + + + + | can optionally specify a second number, which is the background colour for the inventory; if not specified, uses the same colour for both. (CodePage <number>) Define the code page, from 1 to 65535. If not specified, then the default code page is used. (Control <definitions...>) Define the control class. The format is the same like other class definitions, except that Image and Abstract are not allowed. An object of this class is automatically created when initializing the level, at X and Y coordinates both zero, and cannot otherwise be created, destroyed, or moved. It still receives broadcast messages normally, and can also be addressed specifically. (CollisionLayers <userflags...>) Define user flags as CollisionLayers bits; the first defined flag is bit0. Up to 8 flags can be defined in this way. (Misc4 <userflags...>) Define user flags as Misc4 bits; the first defined flag is bit0. Up to 32 flags can be defined in this way. |
︙ | |||
316 317 318 319 320 321 322 | 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 | - + + | the specified dimensions. The maximum number of rows is 64, and the maximum number of columns is 1024, and the maximum number of cells in all arrays in total is 65534. All elements are initialized to zero when the level starts. (<message> <code...>) Defines a default message code for all classes which do not specify |
︙ | |||
1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 | 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 | + + + + | object is in the bizarro world and the other one isn't. ,Coloc ( obj1 obj2 -- bool ) True if the two specified objects are in the same place, or false otherwise. Always false if the object is destroyed, or if one object is in the bizarro world and the other one isn't. Control ( -- obj ) Push the control object to the stack. (If no control class is defined, then there will be no control object and this will be zero.) CopyArray ( src dest -- ) ** Copy one array to another. It is OK if the two references overlap. count ( mark ... -- mark ... count ) Count how many values are above the mark on the stack. Create ( class x y image dir -- obj ) ** |
︙ | |||
2506 2507 2508 2509 2510 2511 2512 | 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 | - - - - - - - - - - - + + + + + + + + + + + + + + + + + + | === Order of execution === You can specify the order of execution of objects by class by a global (Order) block. Inside of this block is a list of sub-lists; each sub-list is delimited by parentheses. Each sub-list starts with a flag name, which may be a user flag, or Input, |
︙ |
Modified exec.c from [484f44c508] to [d3751950c5].
︙ | |||
55 56 57 58 59 60 61 62 63 64 65 66 67 68 | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | + | static Uint8 lastimage_processing,changed,all_flushed; static Value vstack[VSTACKSIZE]; static int vstackptr; static const char*traceprefix; static Uint8 current_key; static Value quiz_obj; static Value traced_obj; static Uint32 control_obj=VOIDLINK; #define Throw(x) (my_error=(x),longjmp(my_env,1)) #define StackReq(x,y) do{ if(vstackptr<(x)) Throw("Stack underflow"); if(vstackptr-(x)+(y)>=VSTACKSIZE) Throw("Stack overflow"); }while(0) #define Push(x) (vstack[vstackptr++]=(x)) #define Pop() (vstack[--vstackptr]) // For arrival/departure masks |
︙ | |||
531 532 533 534 535 536 537 538 539 540 541 542 543 544 | 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 | + + + + | if(!((o->oflags|p->oflags)&(OF_VISUALONLY|OF_DESTROYED))) send_message(y,x,MSG_SUNK,NVALUE(0),NVALUE(0),v); } static void change_density(Uint32 n,Sint32 v) { Object*o=objects[n]; Uint32 i; if(o->oflags&OF_BIZARRO) return; if(n==control_obj) { o->density=v; return; } if(v<o->density) { o->density=v; for(;;) { i=o->up; if(i==VOIDLINK || objects[i]->density<=v) return; sink(i,n); } |
︙ | |||
793 794 795 796 797 798 799 | 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 | - + | static Uint32 create(Uint32 from,Uint16 c,Uint32 x,Uint32 y,Uint32 im,Uint32 d) { Uint32 m,n; int i,xx,yy; Object*o; Object*p; Value v; if(d>7) d=0; |
︙ | |||
838 839 840 841 842 843 844 | 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 | - + | } static Value destroy(Uint32 from,Uint32 to,Uint32 why) { Object*o; Value v; int i,x,y,xx,yy; Uint32 n; |
︙ | |||
875 876 877 878 879 880 881 | 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 | - + | static int move_to(Uint32 from,Uint32 n,Uint32 x,Uint32 y) { Uint32 m; int i,xx,yy; Object*o; Object*p; Value v; |
︙ | |||
1196 1197 1198 1199 1200 1201 1202 | 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 | - + | static int defer_move(Uint32 obj,Uint32 dir,Uint8 plus) { Object*o; Object*q; Uint32 n; Value v; if(StackProtection()) Throw("Call stack overflow during movement"); |
︙ | |||
1280 1281 1282 1283 1284 1285 1286 | 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 | - + | if(current_key) all_flushed=255; flush_class(0); } static void set_bizarro(Uint32 n,Uint32 v) { Object*o; Uint8 b; |
︙ | |||
1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 | 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 | + | Uint8 d=objects[obj]->dir; Uint32 n=VOIDLINK; Uint32 m; Uint16 g; Value v; static ChoicePoint cp[MAXCHOICE]; Uint8 cpi=0; if(!x) return VOIDLINK; cp->depth=vstackptr; again: switch(code[ptr++]) { case 0 ... 7: n=VOIDLINK; x+=x_delta[code[ptr-1]]; y+=y_delta[code[ptr-1]]; if(x<1 || x>pfwidth || y<1 || y>pfheight) goto fail; |
︙ | |||
1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 | 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 | + | if(v.u==1) goto fail; else if(v.u==2) break; else if(v.u) Throw("Invalid return value from message in pattern matching"); } else if(v.t>TY_MAXTYPE) { n=v_object(v); x=objects[n]->x; y=objects[n]->y; if(!x) return VOIDLINK; } else { Throw("Type mismatch"); } m=objects[m]->up; } break; case OP_ADD: |
︙ | |||
1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 | 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 | + | d=v.u&7; } else if(v.t==TY_MARK) { goto fail; } else if(v.t>TY_MAXTYPE) { n=v_object(v); x=objects[n]->x; y=objects[n]->y; if(!x) return VOIDLINK; } else { Throw("Type mismatch"); } break; case OP_HEIGHT: if(playfield[x+y*64-65]==VOIDLINK || height_at(x,y)<=objects[obj]->climb) goto fail; break; |
︙ | |||
2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 | 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 | + | case OP_CLIMB_EC16: NoIgnore(); StackReq(2,0); t1=Pop(); Numeric(t1); i=v_object(Pop()); if(i!=VOIDLINK) o->climb=t1.u&0xFFFF; break; case OP_COLLISIONLAYERS: StackReq(0,1); Push(NVALUE(classes[o->class]->collisionLayers)); break; case OP_COLLISIONLAYERS_C: StackReq(1,1); i=v_object(Pop()); if(i==VOIDLINK) Push(NVALUE(0)); else Push(NVALUE(classes[objects[i]->class]->collisionLayers)); break; case OP_COLOC: StackReq(1,1); t1=Pop(); i=colocation(obj,v_object(t1)); Push(NVALUE(i)); break; case OP_COLOC_C: StackReq(2,1); t1=Pop(); t2=Pop(); i=colocation(v_object(t1),v_object(t2)); Push(NVALUE(i)); break; case OP_COMPATIBLE: StackReq(0,1); if(classes[o->class]->cflags&CF_COMPATIBLE) Push(NVALUE(1)); else Push(NVALUE(0)); break; case OP_COMPATIBLE_C: StackReq(1,1); GetClassFlagOf(CF_COMPATIBLE); break; case OP_CONTROL: StackReq(0,1); Push(OVALUE(control_obj)); break; case OP_COPYARRAY: NoIgnore(); StackReq(2,0); t2=Pop(); t1=Pop(); v_copy_array(t1,t2); break; case OP_COUNT: StackReq(1,2); i=v_count(); Push(NVALUE(i)); break; case OP_CREATE: NoIgnore(); StackReq(5,1); t5=Pop(); t4=Pop(); t3=Pop(); t2=Pop(); t1=Pop(); Push(v_create(obj,t1,t2,t3,t4,t5)); break; case OP_CREATE_D: NoIgnore(); StackReq(5,0); t5=Pop(); t4=Pop(); t3=Pop(); t2=Pop(); t1=Pop(); v_create(obj,t1,t2,t3,t4,t5); break; case OP_DATA: StackReq(2,1); t2=Pop(); t1=Pop(); v_data(t1,t2); break; case OP_DELINVENTORY: StackReq(2,0); t2=Pop(); t1=Pop(); v_delete_inventory(t1,t2); break; case OP_DELTA: StackReq(2,1); t2=Pop(); Numeric(t2); t1=Pop(); Numeric(t1); Push(NVALUE(t1.u>t2.u?t1.u-t2.u:t2.u-t1.u)); break; |
︙ | |||
2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 | 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 | + | gameover=0; clear_inventory(); for(i=0;i<nlevelstrings;i++) free(levelstrings[i]); nlevelstrings=0; free(deadanim); deadanim=0; ndeadanim=0; control_obj=VOIDLINK; } static inline int try_sharp(Uint32 n1,Uint32 n2) { Object*o=objects[n1]; Object*p=objects[n2]; if((o->oflags|p->oflags)&OF_DESTROYED) return 0; if(o->dir&1) return 0; |
︙ | |||
3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 | 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 | + + + + | changed=0; key_ignored=0; all_flushed=0; lastimage_processing=0; vstackptr=0; move_number=0; current_key=0; if(control_class) { control_obj=objalloc(control_class); if(control_obj==VOIDLINK) Throw("Error creating object"); } n=lastobj; while(n!=VOIDLINK && !(objects[n]->oflags&OF_ORDERED)) { send_message(VOIDLINK,n,MSG_INIT,NVALUE(0),NVALUE(0),NVALUE(0)); if(classes[objects[n]->class]->order && !(objects[n]->oflags&OF_DESTROYED)) set_order(n); n=objects[n]->prev; } broadcast(VOIDLINK,0,MSG_POSTINIT,NVALUE(0),NVALUE(0),NVALUE(0),0); if(gameover) return 0; return execute_turn(0); } |
Modified heromesh.h from [c5f496bb05] to [390cfc3e4a].
︙ | |||
174 175 176 177 178 179 180 181 182 183 184 185 186 187 | 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | + | extern Uint8 back_color,inv_back_color; extern char**stringpool; extern AnimationSlot anim_slot[8]; extern Uint8 keymask[256/8]; extern Uint16 array_size; extern Uint16*orders; extern Uint8 norders; extern Uint16 control_class; Uint16 get_message_ptr(int c,int m); void load_classes(void); // == bindings == typedef struct { |
︙ |
Modified instruc from [6d667df7de] to [578644b1e9].
︙ | |||
192 193 194 195 196 197 198 199 | 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | - - - - + + + + + + + | =Arg1 =Arg2 =Arg3 =MoveNumber Level Key =Finished |
︙ |
Modified instruc.h from [b557069e88] to [a3d7764239].
︙ | |||
285 286 287 288 289 290 291 | 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 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 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 | + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - + + + - - - + + + - + - - - - - - - - - - - + + + + + + + + + + + - + - + + - - + + - - - - + + + + - + - + - + - - + + - - + + - - - + + + - + - + - - - + + + - + - - - + + + - - + + - - + + - + - - - + + + - - - - - - - - + + + + + + + + - - - + + + - - - + + + - - + + - + - + - - - - + + + + - + - - - - - + + + + + - + - - - + + + - + - - - + + + - + - + | #define OP_LEVEL 32896 #define OP_KEY 32897 #define OP_FINISHED 32898 #define OP_FINISHED_E 36994 #define OP_BACKGROUND 32899 #define OP_CODEPAGE 32900 #define OP_ORDER 32901 #define OP_CONTROL 32902 |
︙ | |||
756 757 758 759 760 761 762 | 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 | - - - - + + + + - + - + - + - + - + - + - + | {"bit8",8423400}, {"bit9",8423401}, {"bnot",8421415}, {"bor",8421413}, {"bxor",8421414}, {"c?",8421430}, {"case",8683542}, |