Overview
Comment: | Add and implement the Trigger and TriggerAt instructions. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
f36f18a600c8ca01be83eb681adc63d6 |
User & Date: | user on 2021-06-24 21:25:08 |
Other Links: | manifest | tags |
Context
2021-06-25
| ||
04:17 | Fix a bug in writing message numbers into CLASS.DEF lump check-in: a0a2d667be user: user tags: trunk | |
2021-06-24
| ||
21:25 | Add and implement the Trigger and TriggerAt instructions. check-in: f36f18a600 user: user tags: trunk | |
06:15 | Add misc/har.c and misc/mbform.doc (previously named fileform1.txt) and improve the README file check-in: db4b88bbcd user: user tags: trunk | |
Changes
Modified class.doc from [7a70ef22fc] to [69aafde67b].
︙ | |||
1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 | 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 | + + + + + + + + + + + + + + + + | If the input is a mark, then it is removed and the result is false. Otherwise, the value remains and true is added above it on the stack. Trace ( obj arg1 arg2 -- ) If tracing is enabled, sends the three values and some other information on stdout. If tracing is disabled, does nothing. This is intended to be used for debugging class codes. Trigger ( obj message -- ) ** Call a message for a pending trigger for the specified object immediately instead of waiting for its turn in the trigger phase. Only has an effect if the object does not have the Compatible flag. The message must be MOVED, DEPARTED, or ARRIVED; otherwise it is an error. If that trigger is pending, it will clear the trigger and send it like it does during the trigger phase, setting Arg1 as appropriate, but From is set to the object calling it instead of 0, and Arg2 and Arg3 will be inherited from the current values of those variables. The return value is ignored. Since the trigger is cleared before it is sent, it is safe for objects to call the triggers of objects in a loop. TriggerAt ( x ymessage -- ) ** Works like Trigger on all objects at the specified location, from the bottom to the top. tuck ( x y -- y x y ) uniq ( mark ... value -- mark ... value true | mark ... false ) Check if the top value matches any others in the list above the mark. If it doesn't match any, then the value remains and it pushes true; if it does match, then the top value is removed and it pushes false instead. |
︙ |
Modified exec.c from [94a86764bd] to [8a32008878].
︙ | |||
2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 | 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | Push(v); } } } else { Throw("Type mismatch"); } } static void v_trigger(Uint32 from,Uint32 to,Value v) { Object*o; Uint32 n; if(v.t!=TY_MESSAGE) Throw("Type mismatch"); o=objects[to]; if(classes[o->class]->cflags&CF_COMPATIBLE) return; switch(v.u) { case MSG_MOVED: if(o->oflags&OF_MOVED2) { o->oflags&=~OF_MOVED2; send_message(from,to,MSG_MOVED,NVALUE(0),msgvars.arg2,msgvars.arg3); } break; case MSG_DEPARTED: if(o->departed2) { n=o->departed2; o->departed2=0; send_message(from,to,MSG_DEPARTED,NVALUE(n),msgvars.arg2,msgvars.arg3); } break; case MSG_ARRIVED: if(o->arrived2) { n=o->arrived2; o->arrived2=0; send_message(from,to,MSG_ARRIVED,NVALUE(n),msgvars.arg2,msgvars.arg3); } break; default: Throw("Invalid message for Trigger"); } } static void v_trigger_at(Uint32 from,Uint32 x,Uint32 y,Value v) { Uint32 m,n; if(x<1 || x>pfwidth || y<1 || y>pfheight) return; n=playfield[x+y*64-65]; while(n!=VOIDLINK) { m=objects[n]->up; v_trigger(from,n,v); n=m; } } // 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) |
︙ | |||
2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 | 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 | + + | 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_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_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; case OP_UNIQ: StackReq(2,3); t1=Pop(); i=v_uniq(t1); if(i) Push(t1); Push(NVALUE(i)); break; case OP_USERSIGNAL: StackReq(0,1); if(o->oflags&OF_USERSIGNAL) Push(NVALUE(1)); else Push(NVALUE(0)); break; case OP_USERSIGNAL_C: StackReq(1,1); GetFlagOf(OF_USERSIGNAL); break; case OP_USERSIGNAL_E: NoIgnore(); StackReq(1,0); if(v_bool(Pop())) o->oflags|=OF_USERSIGNAL; else o->oflags&=~OF_USERSIGNAL; break; case OP_USERSIGNAL_EC: NoIgnore(); StackReq(2,0); SetFlagOf(OF_USERSIGNAL); break; case OP_USERSTATE: StackReq(0,1); if(o->oflags&OF_USERSTATE) Push(NVALUE(1)); else Push(NVALUE(0)); break; |
︙ |
Modified instruc from [e1be2aa284] to [aab337b9e7].
︙ | |||
264 265 266 267 268 269 270 271 272 273 274 275 276 277 | 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | + + | .,Send .,SendEx ; send with three arguments SetInventory Sound Synchronize ,Target Trace Trigger TriggerAt VolumeAt WinLevel ,XDir XYDir ,YDir ; Operations with marks |
︙ |
Modified instruc.h from [89714eb101] to [5e8cd36f5b].
︙ | |||
394 395 396 397 398 399 400 | 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 | + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - + + + - + | #define OP_SENDEX_CD 43201 #define OP_SETINVENTORY 32962 #define OP_SOUND 32963 #define OP_SYNCHRONIZE 32964 #define OP_TARGET 32965 #define OP_TARGET_C 35013 #define OP_TRACE 32966 #define OP_TRIGGER 32967 #define OP_TRIGGERAT 32968 |
︙ | |||
504 505 506 507 508 509 510 | 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 | - + | {"Chebyshev",8487065}, {"Class",8486972}, {"Climb",9142352}, {"CodePage",8683651}, {"CollisionLayers",8487031}, {"Coloc",8487066}, {"Compatible",8487030}, |
︙ | |||
526 527 528 529 530 531 532 | 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 | - + - + - + | {"Departed",8618087}, {"Departures",8618089}, {"Destroy",10584223}, {"Destroyed",8487028}, {"Dir",8618050}, {"Distance",9142342}, {"Done",8618099}, |
︙ | |||
616 617 618 619 620 621 622 | 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 | - - + + - + - + - + - + + + - + - - - + + + - + - + | {"ObjBottomAt",8421558}, {"ObjClassAt",8421559}, {"ObjDir",8487096}, {"ObjLayerAt",8421561}, {"ObjMovingTo",8421562}, {"ObjTopAt",8421563}, {"Others",8683658}, |
︙ | |||
730 731 732 733 734 735 736 | 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 | - - - + + + - + - + - + - + - + - + - + | {"bit9",8423401}, {"bnot",8421414}, {"bor",8421412}, {"bxor",8421413}, {"c?",8421429}, {"case",8683542}, {"chain",8421528}, |