Free Hero Mesh

Check-in [e895c451ce]
Login
This is a mirror of the main repository for Free Hero Mesh. New tickets and changes will not be accepted at this mirror.
Overview
Comment:Implement the one-based array operators.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e895c451ce21c41463b69d29ee024bd173e993b7
User & Date: user on 2022-04-30 23:18:57
Other Links: manifest | tags
Context
2022-05-01
19:49
Allow the ,CollisionLayers to access classes as well as objects. check-in: 7d82163fa3 user: user tags: trunk
2022-04-30
23:18
Implement the one-based array operators. check-in: e895c451ce user: user tags: trunk
2022-04-29
05:04
A change to the parsing of strings in a level table definition block. check-in: 80dc8e429b user: user tags: trunk
Changes

Modified class.doc from [2b0f0507f9] to [0fe9aa62ea].

1266
1267
1268
1269
1270
1271
1272



1273
1274
1275
1276
1277
1278
1279
  allows Arg3 to be used as a mutable local variable.

ArrayCell  ( array row column -- array )
  Make a reference to a single cell of an array. The new reference is
  treated as a reference to a 1x1 array, which aliases the original array.
  Coordinates are zero-based.




ArraySlice  ( array start count -- array )
  Make a slice of an array. The new reference aliases the original array.
  Coordinates are zero-based.

Assassinate  ( -- ) **
  Destroy this object without sending any messages. The object is marked
  as destroyed, but its variables are still accessible until the garbage







>
>
>







1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
  allows Arg3 to be used as a mutable local variable.

ArrayCell  ( array row column -- array )
  Make a reference to a single cell of an array. The new reference is
  treated as a reference to a 1x1 array, which aliases the original array.
  Coordinates are zero-based.

,ArrayCell  ( array row column -- array )
  Same as ArrayCell but using 1-based coordinates instead.

ArraySlice  ( array start count -- array )
  Make a slice of an array. The new reference aliases the original array.
  Coordinates are zero-based.

Assassinate  ( -- ) **
  Destroy this object without sending any messages. The object is marked
  as destroyed, but its variables are still accessible until the garbage
1530
1531
1532
1533
1534
1535
1536



1537
1538
1539
1540
1541
1542
1543

,ge  ( in1 in2 -- bool )
  Test if first input is greater or equal to second input (signed).

GetArray  ( array row column -- value )
  Read a value from an array. Coordinates are zero-based.




GetInventory  ( class image -- value true | false )
  Read from the inventory, with true if it exists or false if not.

gt  ( in1 in2 -- bool )
  Test if first input is greater than second input (unsigned).

,gt  ( in1 in2 -- bool )







>
>
>







1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549

,ge  ( in1 in2 -- bool )
  Test if first input is greater or equal to second input (signed).

GetArray  ( array row column -- value )
  Read a value from an array. Coordinates are zero-based.

,GetArray  ( array row column -- value )
  Same as GetArray but using 1-based coordinates instead.

GetInventory  ( class image -- value true | false )
  Read from the inventory, with true if it exists or false if not.

gt  ( in1 in2 -- bool )
  Test if first input is greater than second input (unsigned).

,gt  ( in1 in2 -- bool )
1916
1917
1918
1919
1920
1921
1922



1923
1924
1925
1926
1927
1928
1929

,SendEx ( obj message arg1 arg2 arg3 -- value )
  Send a message to the specified object.

SetArray  ( array row column value -- ) **
  Write a value to an array. Coordinates are zero-based.




SetInventory  ( class image value -- ) **
  Sets an inventory item with the specified class and image number to the
  specified value (which must be a number). If there is no inventory item
  with that exact class and image, an inventory item will be added,
  otherwise the existing one is updated to the new value. Inventory values
  are always unsigned 16-bit numbers.








>
>
>







1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938

,SendEx ( obj message arg1 arg2 arg3 -- value )
  Send a message to the specified object.

SetArray  ( array row column value -- ) **
  Write a value to an array. Coordinates are zero-based.

,SetArray  ( array row column value -- ) **
  Same as SetArray but using 1-based coordinates instead.

SetInventory  ( class image value -- ) **
  Sets an inventory item with the specified class and image number to the
  specified value (which must be a number). If there is no inventory item
  with that exact class and image, an inventory item will be added,
  otherwise the existing one is updated to the new value. Inventory values
  are always unsigned 16-bit numbers.

Modified exec.c from [89f1dc5e15] to [ca08defffa].

2853
2854
2855
2856
2857
2858
2859

2860
2861
2862
2863
2864
2865
2866
    case OP_ARG1: StackReq(0,1); Push(msgvars.arg1); break;
    case OP_ARG1_E: StackReq(1,0); msgvars.arg1=Pop(); break;
    case OP_ARG2: StackReq(0,1); Push(msgvars.arg2); break;
    case OP_ARG2_E: StackReq(1,0); msgvars.arg2=Pop(); break;
    case OP_ARG3: StackReq(0,1); Push(msgvars.arg3); break;
    case OP_ARG3_E: StackReq(1,0); msgvars.arg3=Pop(); break;
    case OP_ARRAYCELL: StackReq(3,1); t3=Pop(); Numeric(t3); t2=Pop(); Numeric(t2); t1=Pop(); Push(v_array_cell(t1,t2.u,t3.u)); break;

    case OP_ARRAYSLICE: StackReq(3,1); t3=Pop(); Numeric(t3); t2=Pop(); Numeric(t2); t1=Pop(); Push(v_array_slice(t1,t2.u,t3.u)); break;
    case OP_ARRIVALS: StackReq(0,1); Push(NVALUE(o->arrivals&0x1FFFFFF)); break;
    case OP_ARRIVALS_C: StackReq(1,1); Push(GetVariableOrAttributeOf(arrivals&0x1FFFFFF,NVALUE)); break;
    case OP_ARRIVALS_E: NoIgnore(); StackReq(1,0); t1=Pop(); Numeric(t1); o->arrivals=t1.u; break;
    case OP_ARRIVALS_EC: NoIgnore(); StackReq(2,0); t1=Pop(); Numeric(t1); i=v_object(Pop()); if(i!=VOIDLINK) objects[i]->arrivals=t1.u; break;
    case OP_ARRIVED: StackReq(0,1); Push(NVALUE(o->arrived&0x1FFFFFF)); break;
    case OP_ARRIVED_C: StackReq(1,1); Push(GetVariableOf(arrived&0x1FFFFFF,NVALUE)); break;







>







2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
    case OP_ARG1: StackReq(0,1); Push(msgvars.arg1); break;
    case OP_ARG1_E: StackReq(1,0); msgvars.arg1=Pop(); break;
    case OP_ARG2: StackReq(0,1); Push(msgvars.arg2); break;
    case OP_ARG2_E: StackReq(1,0); msgvars.arg2=Pop(); break;
    case OP_ARG3: StackReq(0,1); Push(msgvars.arg3); break;
    case OP_ARG3_E: StackReq(1,0); msgvars.arg3=Pop(); break;
    case OP_ARRAYCELL: StackReq(3,1); t3=Pop(); Numeric(t3); t2=Pop(); Numeric(t2); t1=Pop(); Push(v_array_cell(t1,t2.u,t3.u)); break;
    case OP_ARRAYCELL_C: StackReq(3,1); t3=Pop(); Numeric(t3); t2=Pop(); Numeric(t2); t1=Pop(); Push(v_array_cell(t1,t2.u-1,t3.u-1)); break;
    case OP_ARRAYSLICE: StackReq(3,1); t3=Pop(); Numeric(t3); t2=Pop(); Numeric(t2); t1=Pop(); Push(v_array_slice(t1,t2.u,t3.u)); break;
    case OP_ARRIVALS: StackReq(0,1); Push(NVALUE(o->arrivals&0x1FFFFFF)); break;
    case OP_ARRIVALS_C: StackReq(1,1); Push(GetVariableOrAttributeOf(arrivals&0x1FFFFFF,NVALUE)); break;
    case OP_ARRIVALS_E: NoIgnore(); StackReq(1,0); t1=Pop(); Numeric(t1); o->arrivals=t1.u; break;
    case OP_ARRIVALS_EC: NoIgnore(); StackReq(2,0); t1=Pop(); Numeric(t1); i=v_object(Pop()); if(i!=VOIDLINK) objects[i]->arrivals=t1.u; break;
    case OP_ARRIVED: StackReq(0,1); Push(NVALUE(o->arrived&0x1FFFFFF)); break;
    case OP_ARRIVED_C: StackReq(1,1); Push(GetVariableOf(arrived&0x1FFFFFF,NVALUE)); break;
2983
2984
2985
2986
2987
2988
2989

2990
2991
2992
2993
2994
2995
2996
    case OP_FOR: NoIgnore(); StackReq(3,1); t3=Pop(); t2=Pop(); t1=Pop(); ptr=v_for(code,ptr,t1,t2,t3); break;
    case OP_FORK: execute_program(code,ptr+1,obj); ptr=code[ptr]; break;
    case OP_FROM: StackReq(0,1); Push(OVALUE(msgvars.from)); break;
    case OP_FUNCTION: execute_program(classes[0]->codes,functions[code[ptr++]],obj); 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_GETARRAY: StackReq(3,1); t3=Pop(); Numeric(t3); t2=Pop(); Numeric(t2); t1=Pop(); Push(v_get_array(t1,t2.u,t3.u)); break;

    case OP_GETINVENTORY: StackReq(2,2); t2=Pop(); t1=Pop(); v_get_inventory(t1,t2); 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;
    case OP_HARD_C: StackReq(2,1); j=v_sh_dir(Pop()); Push(GetVariableOrAttributeOf(hard[j],NVALUE)); break;
    case OP_HARD_E: NoIgnore(); StackReq(2,0); j=v_sh_dir(Pop()); t1=Pop(); Numeric(t1); o->hard[j]=t1.u; break;







>







2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
    case OP_FOR: NoIgnore(); StackReq(3,1); t3=Pop(); t2=Pop(); t1=Pop(); ptr=v_for(code,ptr,t1,t2,t3); break;
    case OP_FORK: execute_program(code,ptr+1,obj); ptr=code[ptr]; break;
    case OP_FROM: StackReq(0,1); Push(OVALUE(msgvars.from)); break;
    case OP_FUNCTION: execute_program(classes[0]->codes,functions[code[ptr++]],obj); 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_GETARRAY: StackReq(3,1); t3=Pop(); Numeric(t3); t2=Pop(); Numeric(t2); t1=Pop(); Push(v_get_array(t1,t2.u,t3.u)); break;
    case OP_GETARRAY_C: StackReq(3,1); t3=Pop(); Numeric(t3); t2=Pop(); Numeric(t2); t1=Pop(); Push(v_get_array(t1,t2.u-1,t3.u-1)); break;
    case OP_GETINVENTORY: StackReq(2,2); t2=Pop(); t1=Pop(); v_get_inventory(t1,t2); 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;
    case OP_HARD_C: StackReq(2,1); j=v_sh_dir(Pop()); Push(GetVariableOrAttributeOf(hard[j],NVALUE)); break;
    case OP_HARD_E: NoIgnore(); StackReq(2,0); j=v_sh_dir(Pop()); t1=Pop(); Numeric(t1); o->hard[j]=t1.u; break;
3154
3155
3156
3157
3158
3159
3160

3161
3162
3163
3164
3165
3166
3167
    case OP_SEND_D: StackReq(3,0); t4=Pop(); t3=Pop(); t2=Pop(); v_send_self(obj,t2,t3,t4,NVALUE(0)); break;
    case OP_SEND_CD: StackReq(4,0); t4=Pop(); t3=Pop(); t2=Pop(); t1=Pop(); v_send_message(obj,t1,t2,t3,t4,NVALUE(0)); break;
    case OP_SENDEX: StackReq(4,1); t5=Pop(); t4=Pop(); t3=Pop(); t2=Pop(); Push(v_send_self(obj,t2,t3,t4,t5)); break;
    case OP_SENDEX_C: StackReq(5,1); t5=Pop(); t4=Pop(); t3=Pop(); t2=Pop(); t1=Pop(); Push(v_send_message(obj,t1,t2,t3,t4,t5)); break;
    case OP_SENDEX_D: StackReq(4,0); t5=Pop(); t4=Pop(); t3=Pop(); t2=Pop(); v_send_self(obj,t2,t3,t4,t5); break;
    case OP_SENDEX_CD: StackReq(5,0); t5=Pop(); t4=Pop(); t3=Pop(); t2=Pop(); t1=Pop(); v_send_message(obj,t1,t2,t3,t4,t5); break;
    case OP_SETARRAY: NoIgnore(); StackReq(4,0); t4=Pop(); t3=Pop(); Numeric(t3); t2=Pop(); Numeric(t2); t1=Pop(); v_set_array(t1,t2.u,t3.u,t4); break;

    case OP_SETINVENTORY: StackReq(3,0); t3=Pop(); t2=Pop(); t1=Pop(); v_set_inventory(t1,t2,t3); break;
    case OP_SHAPE: StackReq(0,1); Push(NVALUE(o->shape)); break;
    case OP_SHAPE_C: StackReq(1,1); Push(GetVariableOrAttributeOf(shape,NVALUE)); break;
    case OP_SHAPE_E: NoIgnore(); StackReq(1,0); t1=Pop(); Numeric(t1); o->shape=t1.u; break;
    case OP_SHAPE_EC: NoIgnore(); StackReq(2,0); t1=Pop(); Numeric(t1); i=v_object(Pop()); if(i!=VOIDLINK) objects[i]->shape=t1.u; break;
    case OP_SHAPEDIR: StackReq(1,1); j=v_sh_dir(Pop()); Push(NVALUE((o->shape>>(j+j))&3)); break;
    case OP_SHAPEDIR_C: StackReq(2,1); j=v_sh_dir(Pop()); t1=GetVariableOrAttributeOf(sharp[j],NVALUE); t1.u=(t1.u>>(j+j))&3; Push(t1); break;







>







3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
    case OP_SEND_D: StackReq(3,0); t4=Pop(); t3=Pop(); t2=Pop(); v_send_self(obj,t2,t3,t4,NVALUE(0)); break;
    case OP_SEND_CD: StackReq(4,0); t4=Pop(); t3=Pop(); t2=Pop(); t1=Pop(); v_send_message(obj,t1,t2,t3,t4,NVALUE(0)); break;
    case OP_SENDEX: StackReq(4,1); t5=Pop(); t4=Pop(); t3=Pop(); t2=Pop(); Push(v_send_self(obj,t2,t3,t4,t5)); break;
    case OP_SENDEX_C: StackReq(5,1); t5=Pop(); t4=Pop(); t3=Pop(); t2=Pop(); t1=Pop(); Push(v_send_message(obj,t1,t2,t3,t4,t5)); break;
    case OP_SENDEX_D: StackReq(4,0); t5=Pop(); t4=Pop(); t3=Pop(); t2=Pop(); v_send_self(obj,t2,t3,t4,t5); break;
    case OP_SENDEX_CD: StackReq(5,0); t5=Pop(); t4=Pop(); t3=Pop(); t2=Pop(); t1=Pop(); v_send_message(obj,t1,t2,t3,t4,t5); break;
    case OP_SETARRAY: NoIgnore(); StackReq(4,0); t4=Pop(); t3=Pop(); Numeric(t3); t2=Pop(); Numeric(t2); t1=Pop(); v_set_array(t1,t2.u,t3.u,t4); break;
    case OP_SETARRAY_C: NoIgnore(); StackReq(4,0); t4=Pop(); t3=Pop(); Numeric(t3); t2=Pop(); Numeric(t2); t1=Pop(); v_set_array(t1,t2.u-1,t3.u-1,t4); break;
    case OP_SETINVENTORY: StackReq(3,0); t3=Pop(); t2=Pop(); t1=Pop(); v_set_inventory(t1,t2,t3); break;
    case OP_SHAPE: StackReq(0,1); Push(NVALUE(o->shape)); break;
    case OP_SHAPE_C: StackReq(1,1); Push(GetVariableOrAttributeOf(shape,NVALUE)); break;
    case OP_SHAPE_E: NoIgnore(); StackReq(1,0); t1=Pop(); Numeric(t1); o->shape=t1.u; break;
    case OP_SHAPE_EC: NoIgnore(); StackReq(2,0); t1=Pop(); Numeric(t1); i=v_object(Pop()); if(i!=VOIDLINK) objects[i]->shape=t1.u; break;
    case OP_SHAPEDIR: StackReq(1,1); j=v_sh_dir(Pop()); Push(NVALUE((o->shape>>(j+j))&3)); break;
    case OP_SHAPEDIR_C: StackReq(2,1); j=v_sh_dir(Pop()); t1=GetVariableOrAttributeOf(sharp[j],NVALUE); t1.u=(t1.u>>(j+j))&3; Push(t1); break;

Modified instruc from [73aaa87d9d] to [edac0d30f7].

306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
flip
count
clear
uniq

; Arrays
-Array
GetArray
InitArray
SetArray
ArrayCell
ArraySlice
CopyArray
DotProduct

; Pattern matching
-,=Pattern "P"
-,=PatternS "P*"







|

|
|







306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
flip
count
clear
uniq

; Arrays
-Array
,GetArray
InitArray
,SetArray
,ArrayCell
ArraySlice
CopyArray
DotProduct

; Pattern matching
-,=Pattern "P"
-,=PatternS "P*"

Modified instruc.h from [fbb0050b59] to [13db57267f].

450
451
452
453
454
455
456

457
458

459

460
461
462
463
464
465
466
#define OP_MBEGIN 32997
#define OP_FLIP 32998
#define OP_COUNT 32999
#define OP_CLEAR 33000
#define OP_UNIQ 33001
#define OP_ARRAY 33002
#define OP_GETARRAY 33003

#define OP_INITARRAY 33004
#define OP_SETARRAY 33005

#define OP_ARRAYCELL 33006

#define OP_ARRAYSLICE 33007
#define OP_COPYARRAY 33008
#define OP_DOTPRODUCT 33009
#define OP_PATTERN 33010
#define OP_PATTERN_C 35058
#define OP_PATTERN_E 37106
#define OP_PATTERN_EC 39154







>


>

>







450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
#define OP_MBEGIN 32997
#define OP_FLIP 32998
#define OP_COUNT 32999
#define OP_CLEAR 33000
#define OP_UNIQ 33001
#define OP_ARRAY 33002
#define OP_GETARRAY 33003
#define OP_GETARRAY_C 35051
#define OP_INITARRAY 33004
#define OP_SETARRAY 33005
#define OP_SETARRAY_C 35053
#define OP_ARRAYCELL 33006
#define OP_ARRAYCELL_C 35054
#define OP_ARRAYSLICE 33007
#define OP_COPYARRAY 33008
#define OP_DOTPRODUCT 33009
#define OP_PATTERN 33010
#define OP_PATTERN_C 35058
#define OP_PATTERN_E 37106
#define OP_PATTERN_EC 39154
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
{"Abstract",8683771},
{"Animate",8552596},
{"AnimateDead",8552597},
{"Arg1",8552576},
{"Arg2",8552577},
{"Arg3",8552578},
{"Array",8683754},
{"ArrayCell",8421614},
{"ArraySlice",8421615},
{"Arrivals",8618092},
{"Arrived",8618090},
{"Assassinate",8487062},
{"B",9437196},
{"BANG",8389380},
{"BEDOINGNG",8389406},







|







508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
{"Abstract",8683771},
{"Animate",8552596},
{"AnimateDead",8552597},
{"Arg1",8552576},
{"Arg2",8552577},
{"Arg3",8552578},
{"Array",8683754},
{"ArrayCell",8487150},
{"ArraySlice",8421615},
{"Arrivals",8618092},
{"Arrived",8618090},
{"Assassinate",8487062},
{"B",9437196},
{"BANG",8389380},
{"BEDOINGNG",8389406},
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
{"FindConnection",8487082},
{"Finished",8552582},
{"FlushClass",8421547},
{"FlushObj",8487084},
{"From",8421503},
{"GLASS",8389379},
{"GLISSANT",8389419},
{"GetArray",8421611},
{"GetInventory",8421549},
{"HAWK",8389425},
{"HEARTBEAT",8389407},
{"HIT",8389134},
{"HITBY",8389135},
{"Hard",8618072},
{"Height",9142354},







|







597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
{"FindConnection",8487082},
{"Finished",8552582},
{"FlushClass",8421547},
{"FlushObj",8487084},
{"From",8421503},
{"GLASS",8389379},
{"GLISSANT",8389419},
{"GetArray",8487147},
{"GetInventory",8421549},
{"HAWK",8389425},
{"HEARTBEAT",8389407},
{"HIT",8389134},
{"HITBY",8389135},
{"Hard",8618072},
{"Height",9142354},
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
{"SUBS",8683667},
{"SUNK",8389131},
{"SW",9437189},
{"Seek",8487116},
{"Self",8421501},
{"Send",10584269},
{"SendEx",10584270},
{"SetArray",8421613},
{"SetInventory",8421583},
{"Shape",8618051},
{"ShapeDir",8618074},
{"Sharp",8618073},
{"Shovable",8618075},
{"Sound",8421584},
{"Stealthy",8618100},







|







708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
{"SUBS",8683667},
{"SUNK",8389131},
{"SW",9437189},
{"Seek",8487116},
{"Self",8421501},
{"Send",10584269},
{"SendEx",10584270},
{"SetArray",8487149},
{"SetInventory",8421583},
{"Shape",8618051},
{"ShapeDir",8618074},
{"Sharp",8618073},
{"Shovable",8618075},
{"Sound",8421584},
{"Stealthy",8618100},