21 uint32_t branch_displacement = 0;
22 uint8_t *operand_cursor = &(*script_cursor_inout)[2];
24 *script_cursor_inout = operand_cursor;
25 branch_displacement = (uint32_t)(operand_cursor[-2]) << 8;
26 branch_displacement |= operand_cursor[-1];
27 *script_cursor_inout = &operand_cursor[1];
29 uint8_t wanted_event_type = *(uint8_t *)operand_cursor;
31 *script_cursor_inout = &operand_cursor[5];
33 char unused_operand_byte = operand_cursor[2];
37 (void)unused_operand_byte;
39 int16_t wanted_signal_id = (uint32_t)(operand_cursor[3]) << 8;
41 wanted_signal_id |= operand_cursor[4];
44 event_buffer.
signal_id = wanted_signal_id;
47 *script_cursor_inout = &operand_cursor[branch_displacement];
49 *script_cursor_inout = &operand_cursor[branch_displacement];
56 int32_t terminator_opcode = 0;
57 uint8_t *current_cursor = *script_cursor_inout;
59 *script_cursor_inout = current_cursor;
60 terminator_opcode = (uint8_t)(current_cursor[-1]);
62 if (terminator_opcode - 1 > 3)
65 switch (terminator_opcode)
69 *script_cursor_inout = NULL;
77 int32_t default_behavior_offset = (uint32_t)(script_base_ptr[4]) << 24;
79 default_behavior_offset |= (uint32_t)(script_base_ptr[6]) << 8;
80 default_behavior_offset |= (uint32_t)(script_base_ptr[5]) << 16;
81 default_behavior_offset |= script_base_ptr[7];
83 if (current_cursor != (default_behavior_offset) + script_base_ptr)
87 uint8_t *nested_operand_cursor = &(*script_cursor_inout)[1];
88 char nested_opcode = *(uint8_t *)((
char *)nested_operand_cursor - 1);
92 uint32_t nested_block_delta = (uint32_t)(*(uint8_t *)((
char *)nested_operand_cursor + 1)) << 8;
94 nested_block_delta |= *(uint8_t *)((
char *)nested_operand_cursor + 2);
95 *script_cursor_inout = nested_block_delta + (uint8_t *)nested_operand_cursor + 3;
102 uint32_t skip_block_delta = (uint32_t)(*(uint8_t *)nested_operand_cursor) << 8;
104 skip_block_delta |= *(uint8_t *)((
char *)nested_operand_cursor + 1);
105 *script_cursor_inout = skip_block_delta + (uint8_t *)nested_operand_cursor + 2;
113 int32_t entry_offset = (uint32_t)(*(uint8_t *)script_base_ptr) << 24;
115 entry_offset |= (uint32_t)(script_base_ptr[2]) << 8;
116 entry_offset |= (uint32_t)(script_base_ptr[1]) << 16;
117 entry_offset |= script_base_ptr[3];
119 if ((entry_offset) != 8)
126 *script_cursor_inout = &script_base_ptr[(behavior_index << 2) + 4];
128 int32_t behavior_offset = (uint32_t)(script_base_ptr[behavior_index << 2]) << 24;
130 behavior_offset |= (uint32_t)(script_base_ptr[(behavior_index << 2) + 2]) << 8;
131 behavior_offset |= (uint32_t)(script_base_ptr[(behavior_index << 2) + 1]) << 16;
132 behavior_offset |= script_base_ptr[(behavior_index << 2) + 3];
133 *script_cursor_inout =
140 *script_cursor_inout = NULL;
151 *script_cursor_inout = NULL;
162 *script_cursor_inout = NULL;
173 int32_t selector_value = 0;
174 uint32_t branch_delta = 0;
176 uint8_t *operand_cursor = &(*script_cursor_inout)[2];
178 *script_cursor_inout = operand_cursor;
179 branch_delta = (uint32_t)(operand_cursor[-2]) << 8;
180 branch_delta |= operand_cursor[-1];
181 *script_cursor_inout = &operand_cursor[1];
183 uint8_t selector_byte = *operand_cursor;
185 selector_value = (uint8_t)(selector_byte);
193 uint32_t effective_behavior_index;
195 effective_behavior_index = !behavior_index ? 1 : (uint32_t)behavior_index;
197 if ((uint32_t)(uint8_t)selector_value != effective_behavior_index)
198 *script_cursor_inout = &operand_cursor[branch_delta];
205 uint8_t **cursor_inout = script_cursor_inout;
206 int32_t *resolved_storage;
207 int32_t **value_storage_inout = &resolved_storage;
208 uint32_t branch_delta = 0;
209 uint8_t *operand_cursor = (*cursor_inout + 2);
211 *cursor_inout = (operand_cursor);
212 branch_delta = (uint32_t)(operand_cursor[-2]) << 8;
213 branch_delta |= operand_cursor[-1];
215 uint8_t *fail_target = &operand_cursor[branch_delta];
217 *cursor_inout = (&operand_cursor[1]);
219 char reference_or_arithmetic_opcode = *(uint8_t *)operand_cursor;
221 *cursor_inout = (&operand_cursor[2]);
223 char lhs_ref_id = reference_or_arithmetic_opcode;
224 uint8_t compare_opcode = operand_cursor[1];
226 *cursor_inout = (&operand_cursor[3]);
228 uint8_t rhs_reference_id = operand_cursor[2];
230 resolved_storage = (int32_t *)(((uintptr_t)script_cursor_inout & ~UINT32_C(0xff)) | rhs_reference_id);
231 *cursor_inout = (&operand_cursor[4]);
232 reference_or_arithmetic_opcode = operand_cursor[3];
233 *cursor_inout = (&operand_cursor[8]);
236 int32_t rhs = (uint32_t)(((
const volatile uint8_t *)operand_cursor)[4]) << 24;
238 rhs |= (uint32_t)(((
const volatile uint8_t *)operand_cursor)[5]) << 16;
239 rhs |= (uint32_t)(((
const volatile uint8_t *)operand_cursor)[6]) << 8;
240 rhs |= ((
const volatile uint8_t *)operand_cursor)[7];
242 int32_t rhs_encoded = rhs;
250 rhs_value = (uint32_t)rhs_encoded >> 8;
271 rhs_value = rhs_value_1;
274 rhs_value = (uint32_t)rhs_encoded >> 8;
276 switch ((uint32_t)reference_or_arithmetic_opcode)
280 rhs_value += lhs_value;
287 rhs_value = rhs_value < lhs_value ? lhs_value - rhs_value : 0;
294 rhs_value *= lhs_value;
302 rhs_value = (uint32_t)lhs_value / rhs_value;
309 uint32_t lhs_value_final =
311 uint32_t compare_opcode_1 = (uint32_t)compare_opcode;
315 *cursor_inout = (fail_target);
320 switch (compare_opcode_1)
324 if (lhs_value_final >= rhs_value)
325 *cursor_inout = (fail_target);
332 if (lhs_value_final > rhs_value)
333 *cursor_inout = (fail_target);
340 if (lhs_value_final != rhs_value)
341 *cursor_inout = (fail_target);
348 if (lhs_value_final < rhs_value)
349 *cursor_inout = (fail_target);
356 if (lhs_value_final <= rhs_value)
357 *cursor_inout = (fail_target);
364 if (lhs_value_final == rhs_value)
365 *cursor_inout = (fail_target);
376 const uint8_t *operands = *script_cursor_inout;
377 uint8_t destination_ref = operands[0], source_ref = operands[1], operation = operands[2];
378 uint32_t encoded = ((uint32_t)operands[3] << 24) | ((uint32_t)operands[4] << 16) | ((uint32_t)operands[5] << 8) | operands[6];
381 int32_t *destination = (int32_t *)(((uintptr_t)script_cursor_inout & ~(uintptr_t)
SCRIPT_VALUE_BYTE_MASK) | destination_ref);
382 int32_t *source = (int32_t *)entity;
384 *script_cursor_inout += 7;
390 *destination = encoded >> 8;
412 right = encoded >> 8;
425 *destination = left / right;
435 uint8_t **cursor_inout = script_cursor_inout;
436 uint8_t *operand_cursor = (*cursor_inout + 1);
438 *cursor_inout = (operand_cursor);
440 int32_t ref_id = (uint8_t)(operand_cursor[-1]);
441 int32_t *resolved_storage = (int32_t *)script_cursor_inout;
442 int32_t **value_storage_inout = &resolved_storage;
446 int32_t *value_storage = *value_storage_inout;
448 *(uint32_t *)value_storage += 1;
455 uint8_t **cursor_inout = script_cursor_inout;
456 uint8_t *operand_cursor = (*cursor_inout + 1);
458 *cursor_inout = operand_cursor;
460 int32_t ref_id = (uint8_t)(operand_cursor[-1]);
461 int32_t *resolved_storage = (int32_t *)script_cursor_inout;
462 int32_t **value_storage_inout = &resolved_storage;
466 int32_t *value_storage = *value_storage_inout;
467 int32_t current_value = *(uint32_t *)value_storage;
470 *(uint32_t *)value_storage = current_value - 1;
501 uint8_t *operand_cursor = (*script_cursor_inout + 1);
503 *script_cursor_inout = operand_cursor;
505 char signal_type = operand_cursor[-1];
507 *script_cursor_inout = &operand_cursor[2];
508 signal_id = (uint32_t)(*(uint8_t *)operand_cursor) << 8;
513 *script_cursor_inout = &operand_cursor[6];
519 *script_cursor_inout = &operand_cursor[6];
521 int32_t payload = (uint32_t)(operand_cursor[2]) << 24;
523 payload |= (uint32_t)(operand_cursor[4]) << 8;
524 payload |= (uint32_t)(operand_cursor[3]) << 16;
525 payload |= operand_cursor[5];
527 uint32_t value_encoded = payload;
528 uint16_t signal_value;
531 signal_value = (int16_t)(value_encoded >> 8);
534 int32_t **value_storage_inout = (int32_t **)(&entity);