Overview
Comment: | Implement for/next loops, and add NoIgnore() in some more places where needed |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
ba612cfc1c6eddc7e31619229b53b70e |
User & Date: | user on 2020-12-12 05:56:52 |
Other Links: | manifest | tags |
Context
2020-12-12
| ||
06:30 | Implement lsh, rsh, ObjTopAt, ObjBottomAt, ObjDir, and Xloc/Yloc of non-self. check-in: 3d4fc6dc98 user: user tags: trunk | |
05:56 | Implement for/next loops, and add NoIgnore() in some more places where needed check-in: ba612cfc1c user: user tags: trunk | |
2020-12-11
| ||
22:25 | Add instructions to read/write many of the flags check-in: 862a62fb30 user: user tags: trunk | |
Changes
Modified class.c from [ea28ba8a95] to [26222c9175].
︙ | |||
1037 1038 1039 1040 1041 1042 1043 | 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 | - - + + - - + + | FlowPop(OP_WHILE); x=flowptr[flowdepth]; FlowPop(OP_BEGIN); AddInst2(OP_GOTO,flowptr[flowdepth]); cl->codes[x]=ptr; break; case OP_FOR: |
︙ |
Modified exec.c from [011a08ac28] to [bcf37dd906].
︙ | |||
412 413 414 415 416 417 418 419 420 421 422 423 424 425 | 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 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | static inline Value v_create(Uint32 from,Value cl,Value x,Value y,Value im,Value d) { Uint32 n; if(!cl.t && !cl.u) return NVALUE(0); if(cl.t!=TY_CLASS || x.t || x.t || y.t || im.t || d.t) Throw("Type mismatch"); n=create(from,cl.u,x.u,y.u,im.u,d.u); return OVALUE(n); } static int v_for(Uint16*code,int ptr,Value v,Value xv,Value yv) { int k=code[ptr]; Uint32 n; if(xv.t || yv.t) Throw("Type mismatch"); if(xv.u<1 || xv.u>pfwidth || yv.u<1 || yv.u>pfheight) { globals[k].t=TY_NUMBER; globals[k].u=0; xv.u=yv.u=0; } else { globals[k].t=TY_FOR; globals[k].u=xv.u+yv.u*64-65; if(v_bool(v)) globals[k].u|=0x10000; } if(xv.u || yv.u) { n=playfield[globals[k].u&0xFFFF]; while(n!=VOIDLINK) { objects[n]->oflags&=~OF_DONE; n=objects[n]->up; } } return code[ptr+1]-2; // This will cause "next" to be executed next } static int v_next(Uint16*code,int ptr) { int k=code[code[ptr]-1]; Uint32 n; Uint32 r=VOIDLINK; if(globals[k].t!=TY_FOR) Throw("Uninitialized for/next loop"); n=playfield[globals[k].u&0xFFFF]; while(n!=VOIDLINK) { if(!(objects[n]->oflags&OF_DONE)) { r=n; if(globals[k].u&0x10000) break; } n=objects[n]->up; } if(r==VOIDLINK) return ptr+1; objects[r]->oflags|=OF_DONE; Push(OVALUE(r)); return code[ptr]+1; } static inline Value v_obj_class_at(Value c,Value x,Value y) { Uint32 i; if(c.t==TY_NUMBER && !c.u) return NVALUE(0); if(c.t!=TY_CLASS || x.t!=TY_NUMBER || y.t!=TY_NUMBER) Throw("Type mismatch"); i=obj_class_at(c.u,x.u,y.u); return OVALUE(i); |
︙ | |||
516 517 518 519 520 521 522 | 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 | - - + + | case OP_BROADCASTCLASS: StackReq(3,1); t4=Pop(); t3=Pop(); t2=Pop(); Push(v_broadcast(obj,CVALUE(code[ptr++]),t2,t3,t4,NVALUE(0),0)); break; case OP_BROADCASTEX: StackReq(5,1); t5=Pop(); t4=Pop(); t3=Pop(); t2=Pop(); t1=Pop(); Push(v_broadcast(obj,t1,t2,t3,t4,t5,0)); break; case OP_BROADCASTEX_D: StackReq(5,0); t5=Pop(); t4=Pop(); t3=Pop(); t2=Pop(); t1=Pop(); v_broadcast(obj,t1,t2,t3,t4,t5,0); break; case OP_BROADCASTSUM: StackReq(4,1); t4=Pop(); t3=Pop(); t2=Pop(); t1=Pop(); Push(v_broadcast(obj,t1,t2,t3,t4,NVALUE(0),1)); break; case OP_BROADCASTSUMEX: StackReq(5,1); t5=Pop(); t4=Pop(); t3=Pop(); t2=Pop(); t1=Pop(); Push(v_broadcast(obj,t1,t2,t3,t4,t5,1)); break; case OP_BUSY: StackReq(0,1); if(o->oflags&OF_BUSY) Push(NVALUE(1)); else Push(NVALUE(0)); break; case OP_BUSY_C: StackReq(1,1); GetFlagOf(OF_BUSY); break; |
︙ | |||
561 562 563 564 565 566 567 568 569 570 571 572 573 574 | 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 | + | case OP_DISTANCE_EC: NoIgnore(); StackReq(2,0); t1=Pop(); Numeric(t1); i=v_object(Pop()); if(i!=VOIDLINK) objects[i]->distance=t1.u; break; case OP_DIV: StackReq(2,1); t2=Pop(); DivideBy(t2); t1=Pop(); Numeric(t1); Push(NVALUE(t1.u/t2.u)); break; case OP_DIV_C: StackReq(2,1); t2=Pop(); DivideBy(t2); t1=Pop(); Numeric(t1); Push(NVALUE(t1.s/t2.s)); break; case OP_DROP: StackReq(1,0); Pop(); break; case OP_DROP_D: StackReq(2,0); Pop(); Pop(); break; case OP_DUP: StackReq(1,2); t1=Pop(); Push(t1); Push(t1); break; case OP_EQ: StackReq(2,1); t2=Pop(); t1=Pop(); Push(NVALUE(v_equal(t1,t2)?1:0)); break; case OP_FOR: NoIgnore(); StackReq(3,1); t3=Pop(); t2=Pop(); t1=Pop(); ptr=v_for(code,ptr,t1,t2,t3); break; case OP_FROM: StackReq(0,1); Push(OVALUE(msgvars.from)); break; case OP_GE: StackReq(2,1); t2=Pop(); t1=Pop(); Push(NVALUE(v_unsigned_greater(t2,t1)?0:1)); break; case OP_GE_C: StackReq(2,1); t2=Pop(); t1=Pop(); Push(NVALUE(v_signed_greater(t2,t1)?0:1)); break; case OP_GOTO: ptr=code[ptr]; break; case OP_GT: StackReq(2,1); t2=Pop(); t1=Pop(); Push(NVALUE(v_unsigned_greater(t1,t2)?1:0)); break; case OP_GT_C: StackReq(2,1); t2=Pop(); t1=Pop(); Push(NVALUE(v_signed_greater(t1,t2)?1:0)); break; case OP_HARD: StackReq(1,1); j=v_sh_dir(Pop()); Push(NVALUE(o->hard[j])); break; |
︙ | |||
586 587 588 589 590 591 592 | 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 | - - + + - - + + + | case OP_IMAGE_C: StackReq(1,1); Push(GetVariableOf(image,NVALUE)); break; case OP_IMAGE_E: NoIgnore(); StackReq(1,0); t1=Pop(); Numeric(t1); o->image=t1.u; break; case OP_IMAGE_EC: NoIgnore(); StackReq(2,0); t1=Pop(); Numeric(t1); i=v_object(Pop()); if(i!=VOIDLINK) objects[i]->image=t1.u; break; case OP_INT16: StackReq(0,1); Push(NVALUE(code[ptr++])); break; case OP_INT32: StackReq(0,1); t1=UVALUE(code[ptr++]<<16,TY_NUMBER); t1.u|=code[ptr++]; Push(t1); break; case OP_INVISIBLE: StackReq(0,1); if(o->oflags&OF_INVISIBLE) Push(NVALUE(1)); else Push(NVALUE(0)); break; case OP_INVISIBLE_C: StackReq(1,1); GetFlagOf(OF_INVISIBLE); break; |
︙ | |||
650 651 652 653 654 655 656 | 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 | - - + + - - + + - - + + - - + + | case OP_SHARP_EC: NoIgnore(); StackReq(3,0); j=v_sh_dir(Pop()); t1=Pop(); Numeric(t1); i=v_object(Pop()); if(i!=VOIDLINK) objects[i]->sharp[j]=t1.u; break; case OP_SHOVABLE: StackReq(0,1); Push(NVALUE(o->shovable)); break; case OP_SHOVABLE_C: StackReq(1,1); Push(GetVariableOrAttributeOf(shovable,NVALUE)); break; case OP_SHOVABLE_E: NoIgnore(); StackReq(1,0); t1=Pop(); Numeric(t1); o->shovable=t1.u; break; case OP_SHOVABLE_EC: NoIgnore(); StackReq(2,0); t1=Pop(); Numeric(t1); i=v_object(Pop()); if(i!=VOIDLINK) objects[i]->shovable=t1.u; break; case OP_STEALTHY: StackReq(0,1); if(o->oflags&OF_STEALTHY) Push(NVALUE(1)); else Push(NVALUE(0)); break; case OP_STEALTHY_C: StackReq(1,1); GetFlagOf(OF_STEALTHY); break; |
︙ | |||
823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 | 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 | + | if(generation_number<=TY_MAXTYPE) return "Too many generations of objects"; return 0; } const char*init_level(void) { if(setjmp(my_env)) return my_error; if(main_options['t']) printf("[Level %d restarted]\n",level_id); memcpy(globals,initglobals,sizeof(globals)); gameover=0; changed=0; key_ignored=0; lastimage_processing=0; vstackptr=0; move_number=0; current_key=0; broadcast(VOIDLINK,0,MSG_INIT,NVALUE(0),NVALUE(0),NVALUE(0),0); broadcast(VOIDLINK,0,MSG_POSTINIT,NVALUE(0),NVALUE(0),NVALUE(0),0); if(generation_number<=TY_MAXTYPE) return "Too many generations of objects"; return 0; } |
Modified heromesh.h from [5f07c527d6] to [63c8f5b734].
︙ | |||
10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | + | #define TY_NUMBER 0 #define TY_CLASS 1 #define TY_MESSAGE 2 #define TY_LEVELSTRING 3 #define TY_STRING 4 #define TY_SOUND 5 #define TY_USOUND 6 #define TY_FOR 7 #define TY_MAXTYPE 15 // The level file format requires type codes 0 to 3 to be as is; other codes may change. typedef struct { union { Sint32 s; Uint32 u; |
︙ |