Overview
Comment: | Implement LastR, NextR, ThisR; this is not tested and not fully complete; it will be used in future to implement replacing objects with new ones in COLLIDE and COLLIDEBY messages. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
1114ae75d54a3f365cc5816689769bbd |
User & Date: | user on 2022-10-05 23:26:45 |
Other Links: | manifest | tags |
Context
2022-10-19
| ||
22:28 | Implement returning classes/objects from COLLIDEBY message to transform objects. (Not fully tested yet) check-in: 60b09ee8e4 user: user tags: trunk | |
2022-10-05
| ||
23:26 | Implement LastR, NextR, ThisR; this is not tested and not fully complete; it will be used in future to implement replacing objects with new ones in COLLIDE and COLLIDEBY messages. check-in: 1114ae75d5 user: user tags: trunk | |
2022-09-14
| ||
23:14 | Do not hard code number of pictures per row in the internal representation; use macros instead. This number is increased from 16 to 128 in order to avoid coordinate overflows for puzzle sets with large number of pictures if a large picture size is selected. check-in: 0a234d4210 user: user tags: trunk | |
Changes
Modified class.doc from [b11e8f2620] to [8db1014969].
︙ | |||
1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 | 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 | + + + + + + + | move or to not trigger even though it did move. Moving : bool This flag indicates that a deferred movement is scheduled for this object. The direction of movement is specified by the Dir variable. This flag is also used for connected movement, for a different purpose. NextR : any This variable is normally zero, but when there is a collision by the CollisionLayers, it can be programmed to destroy an object and create another one which represents the combination of the two. In this case, the NextR variable of the destroyed object points to the new one. (Note: This feature is not yet fully implemented.) Player : bool [c] [ro] If this object is the player. This is used implicitly as the From of some messages sent by the game engine, and has a few other purposes. (Normally, a level should have exactly one object of such a class, although this is not mandatory; any number (including zero) is allowed.) Shape : int16 [c] |
︙ | |||
1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 | 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 | + + + + + + + | When this object's code tries to move this or other objects by the use of the Move instruction, the Strength must be greater than or equal to the total Weight of all objects being moved, or else it won't move. Temperature : int16/int32 [c] The game engine does not use this variable; use it for your own use. ThisR : any This variable is related to NextR, and setting either variable will also affect the other one. If NextR is zero, then this variable points to the object itself, and setting this variable to point to itself will cause NextR to be set to zero. (They are actually the same variable, but are just different ways to access it.) UserSignal : bool This variable has the same effect as Busy; see Busy for details. It is still a separate variable though. UserState : bool [c] The game engine does not use this variable; use it for your own use. |
︙ | |||
1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 | 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 | + + + + + + + | ,Key ( -- number true | false ) If the key (as for Key command) is '1 to '9 or 'A to 'Z then it will be the corresponding array index (as for %Q) and true, otherwise false. land ( in1 in2 -- out ) Logical AND. LastR ( -- obj ) Follows the NextR chain of this object to other objects, and the result is the last object of the chain. ,LastR ( obj -- obj ) Similar to LastR but for a specified object instead of this one. le ( in1 in2 -- bool ) Test if first input is less or equal to second input (unsigned). ,le ( in1 in2 -- bool ) Test if first input is less or equal to second input (signed). Level ( -- number ) |
︙ |
Modified exec.c from [70385a14e1] to [e8eae091e5].
︙ | |||
2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 | 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 | + + + + + + + + + + + + | if(v.t==TY_CLASS) { return NVALUE(classes[v.u]->collisionLayers); } else { i=v_object(v); if(i==VOIDLINK) return NVALUE(0); else return NVALUE(classes[objects[i]->class]->collisionLayers); } } static Value v_lastr(Uint32 n) { Uint32 m; Uint32 x=0; if(n==VOIDLINK) return NVALUE(0); while(x++<nobjects) { m=v_object(objects[n]->replacement); if(m==VOIDLINK || m==n) return OVALUE(n); n=m; } Throw("Circular reference in LastR"); } // Here is where the execution of a Free Hero Mesh bytecode subroutine is executed. #define NoIgnore() do{ changed=1; }while(0) #define GetVariableOf(a,b) (i=v_object(Pop()),i==VOIDLINK?NVALUE(0):b(objects[i]->a)) #define GetVariableOrAttributeOf(a,b) (t2=Pop(),t2.t==TY_CLASS?NVALUE(classes[t2.u]->a):(i=v_object(t2),i==VOIDLINK?NVALUE(0):b(objects[i]->a))) #define Numeric(a) do{ if((a).t!=TY_NUMBER) Throw("Type mismatch"); }while(0) #define DivideBy(a) do{ Numeric(a); if(!(a).u) Throw("Division by zero"); }while(0) |
︙ | |||
3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 | 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 | + + | case OP_KEY: StackReq(0,1); Push(NVALUE(current_key)); break; case OP_KEY_C: StackReq(0,2); i=current_key; if((i>='1' && i<='9') || (i>='A' && i<='Z')) Push(NVALUE(i&64?i+9-'A':i-'1')),Push(NVALUE(1)); else Push(NVALUE(0)); break; case OP_KEYCLEARED: StackReq(0,1); if(o->oflags&OF_KEYCLEARED) Push(NVALUE(1)); else Push(NVALUE(0)); break; case OP_KEYCLEARED_C: StackReq(1,1); GetFlagOf(OF_KEYCLEARED); break; case OP_KEYCLEARED_E: StackReq(1,0); if(v_bool(Pop())) o->oflags|=OF_KEYCLEARED; else o->oflags&=~OF_KEYCLEARED; break; case OP_KEYCLEARED_EC: StackReq(2,0); SetFlagOf(OF_KEYCLEARED); break; case OP_LAND: StackReq(2,1); t1=Pop(); t2=Pop(); if(v_bool(t1) && v_bool(t2)) Push(NVALUE(1)); else Push(NVALUE(0)); break; case OP_LASTR: StackReq(0,1); t1=v_lastr(obj); Push(t1); break; case OP_LASTR_C: StackReq(1,1); i=v_object(Pop()); t1=v_lastr(i); Push(t1); break; case OP_LE: StackReq(2,1); t2=Pop(); t1=Pop(); Push(NVALUE(v_unsigned_greater(t1,t2)?0:1)); break; case OP_LE_C: StackReq(2,1); t2=Pop(); t1=Pop(); Push(NVALUE(v_signed_greater(t1,t2)?0:1)); break; case OP_LEVEL: StackReq(0,1); Push(NVALUE(level_code)); break; case OP_LINK: StackReq(0,1); Push(UVALUE((ptr+2)|(code[ptr+1]<<16),TY_CODE)); ptr=code[ptr]; break; case OP_LNOT: StackReq(1,1); if(v_bool(Pop())) Push(NVALUE(0)); else Push(NVALUE(1)); break; case OP_LOC: StackReq(0,2); Push(NVALUE(o->x)); Push(NVALUE(o->y)); break; case OP_LOC_C: StackReq(1,2); i=v_object(Pop()); Push(NVALUE(i==VOIDLINK?0:objects[i]->x)); Push(NVALUE(i==VOIDLINK?0:objects[i]->y)); break; |
︙ | |||
3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 | 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 | + + + + | case OP_MUL_C: StackReq(2,1); t2=Pop(); Numeric(t2); t1=Pop(); Numeric(t1); Push(NVALUE(t1.s*t2.s)); break; case OP_NE: StackReq(2,1); t2=Pop(); t1=Pop(); Push(NVALUE(v_equal(t1,t2)?0:1)); break; case OP_NEG: StackReq(1,1); t1=Pop(); Numeric(t1); t1.s=-t1.s; Push(t1); break; case OP_NEWX: StackReq(2,1); t2=Pop(); Numeric(t2); t1=Pop(); Numeric(t1); Push(NVALUE(new_x(t1.u,t2.u))); break; case OP_NEWXY: StackReq(3,1); t3=Pop(); Numeric(t3); t2=Pop(); Numeric(t2); t1=Pop(); Numeric(t1); Push(NVALUE(new_x(t1.u,t3.u))); Push(NVALUE(new_y(t2.u,t3.u))); break; case OP_NEWY: StackReq(2,1); t2=Pop(); Numeric(t2); t1=Pop(); Numeric(t1); Push(NVALUE(new_y(t1.u,t2.u))); break; case OP_NEXT: StackReq(0,1); ptr=v_next(code,ptr); break; case OP_NEXTR: StackReq(0,1); Push(o->replacement); break; case OP_NEXTR_C: StackReq(1,1); i=v_object(Pop()); if(i!=VOIDLINK) Push(objects[i]->replacement); else Push(NVALUE(0)); break; case OP_NEXTR_E: StackReq(1,0); o->replacement=Pop(); break; case OP_NEXTR_EC: StackReq(2,1); t1=Pop(); i=v_object(Pop()); if(i!=VOIDLINK) objects[i]->replacement=t1; break; case OP_NIN: StackReq(2,1); i=v_in(); Push(NVALUE(i?0:1)); break; case OP_NIP: StackReq(2,1); t1=Pop(); Pop(); Push(t1); break; case OP_OBJABOVE: StackReq(0,1); i=obj_above(obj); Push(OVALUE(i)); break; case OP_OBJABOVE_C: StackReq(1,1); i=obj_above(v_object(Pop())); Push(OVALUE(i)); break; case OP_OBJBELOW: StackReq(0,1); i=obj_below(obj); Push(OVALUE(i)); break; case OP_OBJBELOW_C: StackReq(1,1); i=obj_below(v_object(Pop())); Push(OVALUE(i)); break; case OP_OBJBOTTOMAT: StackReq(2,1); t2=Pop(); Numeric(t2); t1=Pop(); Numeric(t1); i=obj_bottom_at(t1.u,t2.u); Push(OVALUE(i)); break; |
︙ | |||
3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 | 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 | + + + + | case OP_TARGET_C: StackReq(1,1); i=v_object(Pop()); Push(NVALUE(v_target(i)?1:0)); break; case OP_TEMPERATURE: StackReq(0,1); Push(NVALUE(o->temperature)); break; case OP_TEMPERATURE_C: StackReq(1,1); Push(GetVariableOrAttributeOf(temperature,NVALUE)); break; case OP_TEMPERATURE_E: NoIgnore(); StackReq(1,0); t1=Pop(); Numeric(t1); o->temperature=t1.u; break; case OP_TEMPERATURE_E16: NoIgnore(); StackReq(1,0); t1=Pop(); Numeric(t1); o->temperature=t1.u&0xFFFF; break; case OP_TEMPERATURE_EC: NoIgnore(); StackReq(2,0); t1=Pop(); Numeric(t1); i=v_object(Pop()); if(i!=VOIDLINK) objects[i]->temperature=t1.u; break; case OP_TEMPERATURE_EC16: NoIgnore(); StackReq(2,0); t1=Pop(); Numeric(t1); i=v_object(Pop()); if(i!=VOIDLINK) objects[i]->temperature=t1.u&0xFFFF; break; case OP_THISR: StackReq(0,1); t1=o->replacement; if(v_bool(t1)) Push(t1); else Push(OVALUE(obj)); break; case OP_THISR_C: StackReq(1,1); t2=Pop(); i=v_object(t2); if(i!=VOIDLINK) t1=objects[i]->replacement; else t1=NVALUE(0); if(!v_bool(t1)) t1=t2; Push(t2); break; case OP_THISR_E: StackReq(1,0); t1=Pop(); if(t1.u==obj && t1.t==o->generation) t1=NVALUE(0); o->replacement=t1; break; case OP_THISR_EC: StackReq(2,1); t1=Pop(); t2=Pop(); i=v_object(t2); if(i!=VOIDLINK) { if(t1.t==t2.t && t1.u==t2.u) t1=NVALUE(0); objects[i]->replacement=t1; } break; case OP_TMARK: StackReq(1,2); t1=Pop(); if(t1.t==TY_MARK) { Push(NVALUE(0)); } else { Push(t1); Push(NVALUE(1)); } break; case OP_TRACE: StackReq(3,0); trace_stack(obj); break; case OP_TRACESTACK: trace_stack_list(vstackptr); break; case OP_TRACESTACK_C: StackReq(1,0); t1=Pop(); Numeric(t1); trace_stack_list(t1.u); break; case OP_TRIGGER: NoIgnore(); StackReq(2,0); t1=Pop(); i=v_object(Pop()); if(i!=VOIDLINK) v_trigger(obj,i,t1); break; case OP_TRIGGERAT: NoIgnore(); StackReq(3,0); t3=Pop(); t2=Pop(); Numeric(t2); t1=Pop(); Numeric(t1); v_trigger_at(obj,t1.u,t2.u,t3); break; case OP_TUCK: StackReq(2,3); t2=Pop(); t1=Pop(); Push(t2); Push(t1); Push(t2); break; |
︙ |
Modified game.c from [c6efffb6bc] to [522c906303].
︙ | |||
618 619 620 621 622 623 624 625 626 | 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 | + - + | exam_value("Departures:",20,NVALUE(o->departures)); exam_value("Shape:",21,NVALUE(o->shape)); exam_value("Shovable:",22,NVALUE(o->shovable)); exam_value("Distance:",23,NVALUE(o->distance)); exam_value("Inertia:",24,NVALUE(o->inertia)); exam_hardsharp("Hardness:",25,o->hard); exam_hardsharp("Sharpness:",26,o->sharp); exam_value("NextR:",27,o->replacement); while(sqlite3_step(st)==SQLITE_ROW) { i=sqlite3_column_int(st,1); |
︙ |
Modified heromesh.h from [f41b1c99d8] to [3c737c4009].
︙ | |||
285 286 287 288 289 290 291 | 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | - + | Uint32 arrived,departed,arrived2,departed2,generation; Uint32 up,down,prev,next; // links to other objects Uint16 class,oflags,distance,shape,shovable,image; Uint16 sharp[4]; Uint16 hard[4]; Uint8 x,y,dir; Animation*anim; |
︙ |
Modified instruc from [ea8898a518] to [ff5a0f1f93].
︙ | |||
200 201 202 203 204 205 206 207 208 209 210 211 212 213 | 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | + + + + + | =Arg1 =Arg2 =Arg3 =MoveNumber Level ,Key =Finished ; Standard variables related to object replacements ,=ThisR ,=NextR ,LastR ; Top level definitions -Background -CodePage -Order Control -LevelTable |
︙ |
Modified instruc.h from [62a01ab909] to [ee33348f38].
︙ | |||
299 300 301 302 303 304 305 | 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 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 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 | + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - + + + - - - + + + - + - - - - - - - - - - - - + + + + + + + + + + + + - + - + - + - + - - - + + + - - - - + + + + - + - + - + - - + + - - + + - - + + - - - + + + - + - + - - - - + + + + - + + - - - - + + + + - - + + - - - + + + - + - - - + + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - + + + - - - + + + - + - + - - - - + + + + - + - - - - - + + + + + - + + - - - - + + + + - + - + - - - - + + + + - + - + - + | #define OP_MOVENUMBER 32903 #define OP_MOVENUMBER_E 36999 #define OP_LEVEL 32904 #define OP_KEY 32905 #define OP_KEY_C 34953 #define OP_FINISHED 32906 #define OP_FINISHED_E 37002 #define OP_THISR 32907 #define OP_THISR_C 34955 #define OP_THISR_E 37003 #define OP_THISR_EC 39051 #define OP_NEXTR 32908 #define OP_NEXTR_C 34956 #define OP_NEXTR_E 37004 #define OP_NEXTR_EC 39052 #define OP_LASTR 32909 #define OP_LASTR_C 34957 |
︙ | |||
816 817 818 819 820 821 822 | 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 | - - - - + + + + - + - + - + - + - + - + - + | {"bit8",8423400}, {"bit9",8423401}, {"bnot",8421421}, {"bor",8421419}, {"bxor",8421420}, {"c?",8421436}, {"case",8683544}, |