Overview
Comment: | Implement the Morton and ,Morton instructions. (On some computers it may be possible to optimize this better; this optimization is not currently implemented.) |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
3532fea85828a5e263234ce2b4a1f505 |
User & Date: | user on 2022-02-16 07:09:32 |
Other Links: | manifest | tags |
Context
2022-02-22
| ||
02:35 | Implement FindConnection instruction. check-in: c49ea7253d user: user tags: trunk | |
2022-02-16
| ||
07:09 | Implement the Morton and ,Morton instructions. (On some computers it may be possible to optimize this better; this optimization is not currently implemented.) check-in: 3532fea858 user: user tags: trunk | |
03:49 | Implement the high 8-bits of Shovable variable. check-in: df0b4678c0 user: user tags: trunk | |
Changes
Modified class.doc from [5e0bfb99d0] to [e1fcb10826].
︙ | |||
1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 | 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 | + + + + + + + + + | mod ( in1 in2 -- out ) Unsigned divide in1 by in2 producing the remainder. ,mod ( in1 in2 -- out ) Signed divide in1 by in2 producing the remainder. Morton ( in -- out ) Like ,Morton but the first input is always zero. ,Morton ( in1 in2 -- out ) Interleave bits of two 16-bit numbers to make a 32-bit number, like the mingle operator of INTERCAL. (One use of this is if you have a class with images for each combination of E/N/W/S directions and will want to convert them to make the appropriate Shovable value.) Move ( dir -- bool ) ** Move this object in the given direction (which may be absolute or relative to the current direction). The result will be true if the move is successful or false if it failed. See the section about movement for details. ,Move ( obj dir -- bool ) ** |
︙ |
Modified exec.c from [b4fc39460c] to [3521db691c].
︙ | |||
2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 | 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 | + + + + + + + + + | case TY_CODE: i=v.u>>16; if(i==objects[obj]->class || !i || code==classes[i]->codes) return v.u; Throw("Link mismatch"); default: Throw("Type mismatch"); } } static Uint32 morton(Uint32 x) { x&=0xFFFF; x|=x<<8; x&=0x00FF00FF; x|=x<<4; x&=0x0F0F0F0F; x|=x<<2; x&=0x33333333; x|=x<<1; x&=0x55555555; return x; } // 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) |
︙ | |||
2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 | 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 | + + | case OP_MIN_C: StackReq(2,1); t1=Pop(); Numeric(t1); t2=Pop(); Numeric(t2); if(t1.s<t2.s) Push(t1); else Push(t2); break; case OP_MINUSMOVE: StackReq(1,1); t1=Pop(); Numeric(t1); i=defer_move(obj,t1.u,0); Push(NVALUE(i)); break; case OP_MINUSMOVE_C: StackReq(2,1); t1=Pop(); Numeric(t1); i=v_object(Pop()); i=defer_move(i,t1.u,0); Push(NVALUE(i)); break; case OP_MINUSMOVE_D: StackReq(1,0); t1=Pop(); Numeric(t1); defer_move(obj,t1.u,0); break; case OP_MINUSMOVE_CD: StackReq(2,1); t1=Pop(); Numeric(t1); i=v_object(Pop()); defer_move(i,t1.u,0); break; case OP_MOD: StackReq(2,1); t2=Pop(); DivideBy(t2); t1=Pop(); Numeric(t1); Push(NVALUE(t1.u%t2.u)); break; case OP_MOD_C: StackReq(2,1); t2=Pop(); DivideBy(t2); t1=Pop(); Numeric(t1); Push(NVALUE(t1.s%t2.s)); break; case OP_MORTON: StackReq(1,1); t1=Pop(); Numeric(t1); Push(NVALUE(morton(t1.u))); break; case OP_MORTON_C: StackReq(2,1); t2=Pop(); Numeric(t2); t1=Pop(); Numeric(t1); Push(NVALUE(morton(t2.u)|(morton(t1.u)<<1))); break; case OP_MOVE: NoIgnore(); StackReq(1,1); t1=Pop(); Numeric(t1); o->inertia=o->strength; Push(NVALUE(move_dir(obj,obj,t1.u))); break; case OP_MOVE_C: NoIgnore(); StackReq(2,1); t1=Pop(); Numeric(t1); i=v_object(Pop()); if(i==VOIDLINK) Push(NVALUE(0)); else { objects[i]->inertia=o->strength; Push(NVALUE(move_dir(obj,i,t1.u))); } break; case OP_MOVE_D: NoIgnore(); StackReq(1,0); t1=Pop(); Numeric(t1); o->inertia=o->strength; move_dir(obj,obj,t1.u); break; case OP_MOVE_CD: NoIgnore(); StackReq(2,0); t1=Pop(); Numeric(t1); i=v_object(Pop()); if(i!=VOIDLINK) { objects[i]->inertia=o->strength; move_dir(obj,i,t1.u); } break; case OP_MOVED: StackReq(0,1); if(o->oflags&OF_MOVED) Push(NVALUE(1)); else Push(NVALUE(0)); break; case OP_MOVED_C: StackReq(1,1); GetFlagOf(OF_MOVED); break; case OP_MOVED_E: NoIgnore(); StackReq(1,0); if(v_bool(Pop())) o->oflags|=OF_MOVED; else o->oflags&=~OF_MOVED; break; |
︙ |
Modified instruc from [67de8ba826] to [e91542e6fc].
︙ | |||
250 251 252 253 254 255 256 257 258 259 260 261 262 263 | 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | + | .,IntMove ; move without initializing Inertia .,JumpTo ,Loc ; same as: Xloc Yloc ,LocateMe LoseLevel ,Manhattan MaxInventory ; error if more than that many slots in inventory ,Morton .,Move .,MovePlus "Move+" ; obj.Inertia+=Strength instead of obj.Inertia=Strength .,MoveTo ; the internal MoveTo() function .,PlusMove "+Move" .,MinusMove "-Move" NewX NewXY |
︙ |
Modified instruc.h from [c6eaacfc4c] to [0651293b43].
︙ | |||
361 362 363 364 365 366 367 | 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 | + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - - - + + + - - - + + + | #define OP_LOC_C 34994 #define OP_LOCATEME 32947 #define OP_LOCATEME_C 34995 #define OP_LOSELEVEL 32948 #define OP_MANHATTAN 32949 #define OP_MANHATTAN_C 34997 #define OP_MAXINVENTORY 32950 #define OP_MORTON 32951 #define OP_MORTON_C 34999 |
︙ | |||
546 547 548 549 550 551 552 | 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 | - + | {"CodePage",8683656}, {"CollisionLayers",8487036}, {"Coloc",8487074}, {"Compatible",8487035}, {"Connect",8487075}, {"Connection",8618104}, {"Control",8421514}, |
︙ | |||
568 569 570 571 572 573 574 | 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 | - + - + - + | {"Departed",8618091}, {"Departures",8618093}, {"Destroy",10584232}, {"Destroyed",8487033}, {"Dir",8618054}, {"Distance",9142346}, {"Done",8618103}, |
︙ | |||
635 636 637 638 639 640 641 | 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 | + - - + + - + - - - + + + - - - - - - - - + + + + + + + + - - + + - - + + - - + + - + - - - - + + + + - + - - - - - + + + + + - + - - - + + + - + - - - - + + + + - + - + - + | {"Misc1",9142364}, {"Misc2",9142366}, {"Misc3",9142368}, {"Misc4",9142370}, {"Misc5",9142372}, {"Misc6",9142374}, {"Misc7",9142376}, {"Morton",8487095}, |
︙ | |||
783 784 785 786 787 788 789 | 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 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 | - - - + + + - + - + - + - + - + - + - + | {"bit9",8423401}, {"bnot",8421418}, {"bor",8421416}, {"bxor",8421417}, {"c?",8421433}, {"case",8683542}, {"chain",8421536}, |