Overview
Comment: | Implement the "Data" instruction to read string data. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
21abf7afd30f0896fc918a1519df5577 |
User & Date: | user on 2021-05-27 02:17:14 |
Other Links: | manifest | tags |
Context
2021-05-27
| ||
22:35 | Some improvements to documentation. (No code changes.) check-in: a62361241e user: user tags: trunk | |
02:17 | Implement the "Data" instruction to read string data. check-in: 21abf7afd3 user: user tags: trunk | |
2021-05-26
| ||
05:03 | Implement the \d escape for embedding data in strings. The ability to use this data is not implemented yet. check-in: a9cc459c7a user: user tags: trunk | |
Changes
Modified class.doc from [b18e2bc6a7] to [1f9127ef0c].
︙ | |||
82 83 84 85 86 87 88 | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | + + - + | \c Makes further text centred. \dDATA\ Includes inline data in the string. The data is not displayed, but can be read by class codes, or used in level titles to provide data and delimieters for the auto-generated table of contents. Data items are separated by semicolons; each item can be a underscore to mean a mark, a number (decimal integers only), or a class name with $ at front. |
︙ | |||
1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 | 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 | + + + + + + + | the object cannot be created due to the CollisionLayers, or if the new object is destroyed before its CREATE message returns. cz? ( any -- bool ) True if the value is a class or zero, or false if it is neither a class nor zero. Error if it is a sound. Data ( string index -- ... ) Read string data. If the index is a number, it is the zero-based number of which data block in the string to read; all of the data in that block is pushed to the stack. If there isn't enough data blocks, then nothing will be pushed to the stack. If the index is the KEY message, then all of the key codes of the quiz buttons in the string are push to stack. DelInventory ( class image -- ) ** Delete an item from the inventory; see SetInventory for more details. Delta ( in1 in2 -- out ) Subtracts the smaller input from the larger (unsigned). Destroy ( -- value ) ** |
︙ |
Modified exec.c from [51d82ac75e] to [867f705250].
︙ | |||
1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 | 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | if(v1) Push(UVALUE(v1-1,TY_STRING)); else Push(NVALUE(0)); break; case TY_CODE: return v1; } return ptr+n+n+2; } static void v_data(Value v1,Value v2) { const unsigned char*s; int i; Value v; if(v1.t!=TY_STRING && v1.t!=TY_LEVELSTRING) Throw("Type mismatch"); s=value_string_ptr(v1); if(v2.t==TY_NUMBER) { for(;;) { s+=strcspn(s,"\x1F\x1E"); if(!*s) return; if(*s==31) { s++; if(*s) s++; } else { s++; if(!v2.u) break; v2.u--; } } while(s && *s && *s!='\\') { if(*s=='_') { v.t=TY_MARK; v.u=0; s++; } else if(*s=='$') { s++; v.t=TY_CLASS; i=strcspn(s,";\\"); for(v.u=1;v.u<0x4000;v.u++) { if(classes[v.u] && !(classes[v.u]->cflags&(CF_NOCLASS2|CF_GROUP)) && i==strlen(classes[v.u]->name) && !strncmp(s,classes[v.u]->name,i)) { s+=i; break; } } } else { v.t=TY_NUMBER; v.u=strtol(s,(char**)&s,10); } StackReq(0,1); Push(v); if(*s=='\\') break; if(*s!=';' && *s!='\\') Throw("Invalid string data"); if(*s==';') s++; else break; } } else if(v2.t==TY_MESSAGE && v2.u==MSG_KEY) { v.t=TY_NUMBER; v.u=0; for(;;) { s+=strcspn(s,"\x1F\x10"); if(!*s) return; if(*s==31) { s++; if(*s) s++; } else { s++; StackReq(0,1); if(*s) v.u=*s++; Push(v); } } } else { Throw("Type mismatch"); } } // 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) |
︙ | |||
2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 | 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 | + | 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_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; case OP_DENSITY: StackReq(0,1); Push(NVALUE(o->density)); break; case OP_DENSITY_C: StackReq(1,1); Push(GetVariableOrAttributeOf(density,NVALUE)); break; case OP_DENSITY_E: NoIgnore(); StackReq(1,0); t1=Pop(); Numeric(t1); change_density(obj,t1.s); break; case OP_DENSITY_E16: NoIgnore(); StackReq(1,0); t1=Pop(); Numeric(t1); change_density(obj,t1.s&0xFFFF); break; case OP_DENSITY_EC: NoIgnore(); StackReq(2,0); t1=Pop(); Numeric(t1); change_density(v_object(Pop()),t1.s); break; |
︙ |
Modified instruc from [3f9b18c19d] to [e1be2aa284].
︙ | |||
204 205 206 207 208 209 210 | 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | - + + | -InPlace -DefaultImage -Help -EditorHelp -Others -SUBS |
︙ |
Modified instruc.h from [bdce706361] to [89714eb101].
︙ | |||
312 313 314 315 316 317 318 | 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 | + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - - - + + + - + | #define OP_CHAIN 32920 #define OP_CHEBYSHEV 32921 #define OP_CHEBYSHEV_C 34969 #define OP_COLOC 32922 #define OP_COLOC_C 34970 #define OP_CREATE 32923 #define OP_CREATE_D 41115 #define OP_DATA 32924 |
︙ | |||
503 504 505 506 507 508 509 | 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 | - + + - - + + - + - + - - + + - - + + - + - + - + - + - + - - - + + + - - + + - - + + - + - - - + + + - - - - - - - - + + + + + + + + - - + + - - + + - - + + - + - - - - + + + + - + - - + + - + - + - + - - - + + + - + - + | {"Chebyshev",8487065}, {"Class",8486972}, {"Climb",9142352}, {"CodePage",8683651}, {"CollisionLayers",8487031}, {"Coloc",8487066}, {"Compatible",8487030}, |
︙ | |||
728 729 730 731 732 733 734 | 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 | - - - + + + - + - + - + - + - + - + - + | {"bit9",8423401}, {"bnot",8421414}, {"bor",8421412}, {"bxor",8421413}, {"c?",8421429}, {"case",8683542}, {"chain",8421528}, |