DO/CTL/OpCodes

From Dark Omen Wiki

(Difference between revisions)
Jump to: navigation, search
(Add #4E and small updates)
(remove table. Working on a new documentation.)
Line 1: Line 1:
-
{|class="wikitable" style="border-collapse: separate; "
+
== init_unit (00) ==
-
! Op !! Mnemonic !! Parameter !! Explanation
+
 
 +
{|class="wikitable"
 +
! Argument !! Explanation
|-
|-
-
| 00
+
|unk
-
| {{a-likely|init_unit}}
+
|unknown purpose
-
| unknown
+
|}
-
| At the start of every regiment script.
+
This function initializes some data structures of the unit to it's default values. It should be used as the first function called by a unit script.
 +
 
 +
== wait_for_deploy (01) ==
 +
 
 +
Blocks the execution of the units script until the deployment phase is finished.
 +
 
 +
In the deployment phase it sets bit 31 of unit flag 1. At the end of the phase it clears the bit.
 +
 
 +
== reset_call_stack (02) ==
 +
 
 +
Resets the units stack. Don't call this when you have to return from a function or are in a loop.
 +
 
 +
== restore_ip (03) ==
 +
 
 +
Restores the state saved with save_ip (execution continues after the save_ip call). All events get marked as handled so unhandled events are lost.
 +
 
 +
== save_ip (04) ==
 +
 
 +
Stores the current state of the instruction pointer (current function, position in function, number of free stack slots). Note that the stack itself is not saved!
 +
 
 +
== do (05) ==
 +
 
 +
Begins a do-loop (pushes position of next opcode on the stack). This loop is always executed at least once.
 +
 
 +
== always (06) ==
 +
 
 +
Usually used at the end of a do-loop. Pops from the stack and continues script execution at this position (this is usually the command following the do-statement).
 +
 
 +
== while (07) ==
 +
 
 +
Usually used at the end of a do-loop. Pops from the stack and checks the conditional flag:
 +
 
 +
{|class="wikitable"
 +
! Condition !! Result
|-
|-
-
| 01
+
|true
-
| {{a-certain|wait_for_deploy}}
+
|Continue execution at stack position
-
| -
+
-
| Pause script until deployment is finished
+
|-
|-
-
| 02
+
|false
-
| {{a-certain|reset_call_stack}}
+
|Continue execution with command after while
-
| -
+
-
| Resets the stack that keeps track of loops and function calls.
+
-
|-
+
-
| 03
+
-
| {{a-guess|restoreip}}
+
-
| -
+
-
| Jumps to last saveip-call
+
-
|-
+
-
| 04
+
-
| {{a-guess|saveip}}
+
-
| -
+
-
| Saves Instruction Pointer
+
-
|-
+
-
| 05
+
-
| {{a-certain|do}}
+
-
| -
+
-
|
+
-
|-
+
-
| 06
+
-
| {{a-likely|always}}
+
-
| -
+
-
| Jump to last do statement
+
-
|-
+
-
| 07
+
-
| {{a-likely|while}}
+
-
| -
+
-
| Jump to do if previous statement is true
+
-
|-
+
-
| 08
+
-
| {{a-likely|whilenot}}
+
-
| -
+
-
| Jump to do if previous statement is false
+
-
|-
+
-
| 09
+
-
| {{a-likely|for}}
+
-
| -
+
-
|
+
-
|-
+
-
| 0A
+
-
| {{a-likely|next}}
+
-
| -
+
-
|
+
-
|-
+
-
| 0B
+
-
| {{a-certain|goto}}
+
-
| func_id
+
-
| Jump to func_id
+
-
|-
+
-
| 0C
+
-
| {{a-certain|branch1}}
+
-
| func_id
+
-
| Used in eventhandler, Jump to func_id
+
-
|-
+
-
| 0D
+
-
| {{a-certain|branch2}}
+
-
| func_id
+
-
| Used in eventhandler, Jump to func_id
+
-
|-
+
-
| 0E
+
-
| {{a-certain|branch3}}
+
-
| func_id
+
-
| Used in eventhandler, Jump to func_id
+
-
|-
+
-
| 0F
+
-
| {{a-certain|branch4}}
+
-
| func_id
+
-
| Used in eventhandler, Jump to func_id
+
-
|-
+
-
| 10
+
-
| {{a-certain|branch5}}
+
-
| func_id
+
-
| Used in eventhandler, Jump to func_id
+
-
|-
+
-
| 11
+
-
| {{a-certain|call}}
+
-
| func_id
+
-
| Jump to func_id (return pos saved)
+
-
|-
+
-
| 12
+
-
| {{a-likely|return}}
+
-
| -
+
-
| Continue from last call statement
+
-
|-
+
-
| 13
+
-
| {{a-guess|return_from_event_handler}}
+
-
| -
+
-
| Continue from last event call?
+
-
|-
+
-
| 15
+
-
| {{a-certain|sleep}}
+
-
| -
+
-
|
+
-
|-
+
-
| 16
+
-
| {{a-certain|sleep_iftrue}}
+
-
| -
+
-
|
+
-
|-
+
-
| 17
+
-
| {{a-likely|cond_skip}}
+
-
| value
+
-
| Skip value number of opcodes followed by this command
+
-
|-
+
-
| 18
+
-
| {{a-likely|set_timer}}
+
-
| time
+
-
| set timer to time
+
-
|-
+
-
| 19
+
-
| {{a-likely|test_waiting_for_timer}}
+
-
| -
+
-
| true if timer is set and is not 0
+
-
|-
+
-
| 1A
+
-
| {{a-likely|wait_for_timer"}}
+
-
| -
+
-
| Waits for the amount of time set by set_timer
+
-
|-
+
-
| 1B
+
-
| {{a-guess|set_x_i}}
+
-
| value
+
-
| ?
+
-
|-
+
-
| 1C
+
-
| {{a-guess|add_x_i}}
+
-
| value
+
-
| ?
+
-
|-
+
-
| 1D
+
-
| {{a-guess|test_x_eq_0}}
+
-
| -
+
-
| true if value == 0
+
-
|-
+
-
| 1E
+
-
| {{a-certain|set_unit_r_i}}
+
-
| register, value
+
-
| Set register to value
+
-
|-
+
-
| 1F
+
-
| {{a-certain|add_unit_r_i}}
+
-
| register, value
+
-
| reg_value = reg_value + value
+
-
|-
+
-
| 20
+
-
| {{a-certain|test_unit_r_eq_i}}
+
-
| register, value
+
-
| true if register == value
+
-
|-
+
-
| 21
+
-
| {{a-certain|test_unit_r_eq_r}}
+
-
| register1, register2
+
-
| true if register1 == register2
+
-
|-
+
-
| 22
+
-
| {{a-certain|set_unit_r_random1to10}}
+
-
| register
+
-
| loads a value from 1-10 in a register<br />The value changes every ~2seconds
+
-
|-
+
-
| 23
+
-
| {{a-guess|set_global_r_i}}
+
-
| register, value
+
-
| Set global register to value
+
-
|-
+
-
| 24
+
-
| {{a-guess|add_global_r_i}}
+
-
| register, value
+
-
| global_reg_value = global_reg_value + value
+
-
|-
+
-
| 25
+
-
| {{a-guess|test_global_r_eq_i}}
+
-
| register, value
+
-
| true if global register == value
+
-
|-
+
-
| 28
+
-
| {{a-certain|move_to_node}}
+
-
| node_id
+
-
| Unit moves to node with id node_id
+
-
|-
+
-
| 29
+
-
| {{a-certain|retreat_to_node}}
+
-
| node_id
+
-
| Caller tries to reach node_id when retreating.<br /> If it's near the boundaries the unit will escape.
+
-
|-
+
-
| 2A
+
-
| {{a-certain|patrol_to_waypoint}}
+
-
| waypoint_id (<11>)
+
-
| Unit patrols between all circles that have the correct waypoint_id
+
-
|-
+
-
| 2B
+
-
| {{a-guess|block_movement}}
+
-
| -
+
-
| Unit can't move anymore
+
-
|-
+
-
| 2C
+
-
| {{a-likely|wait_unit_flag1_clear}}
+
-
| bitmask
+
-
| Wait until flag 1 bits of caller are cleared
+
-
|-
+
-
| 2D
+
-
| {{a-likely|wait_unit_flag1_set}}
+
-
| bitmask
+
-
| Wait until flag 1 bits of caller are set
+
-
|-
+
-
| 2E
+
-
| {{a-likely|test_unit_flag1}}
+
-
| bitmask
+
-
| true if flag 1 bits of caller are set
+
-
|-
+
-
| 2F
+
-
| {{a-likely|set_unit_flag1}}
+
-
| bitmask
+
-
| Set flag 1 bits of caller
+
-
|-
+
-
| 30
+
-
| {{a-likely|clear_unit_flag1}}
+
-
| bitmask
+
-
| Clear flag 1 bits of caller
+
-
|-
+
-
| 31
+
-
| {{a-likely|wait_unit_flag2_clear}}
+
-
| bitmask
+
-
| Wait until flag 2 bits of caller are cleared
+
-
|-
+
-
| 32
+
-
| {{a-likely|wait_unit_flag2_set}}
+
-
| bitmask
+
-
| Wait until flag 2 bits of caller are set
+
-
|-
+
-
| 33
+
-
| {{a-likely|test_unit_flag2}}
+
-
| bitmask
+
-
| true if flag 2 bits of caller are set
+
-
|-
+
-
| 34
+
-
| {{a-likely|set_unit_flag2}}
+
-
| bitmask
+
-
| Set flag 2 bits of caller
+
-
|-
+
-
| 35
+
-
| {{a-likely|clear_unit_flag2}}
+
-
| bitmask
+
-
| Clear flag 2 bits of caller
+
-
|-
+
-
| 36
+
-
| {{a-likely|wait_unit_flag3_clear}}
+
-
| bitmask
+
-
| Wait until flag 3 bits of caller are cleared
+
-
|-
+
-
| 37
+
-
| {{a-likely|wait_unit_flag3_set}}
+
-
| bitmask
+
-
| Wait until flag 3 bits of caller are set
+
-
|-
+
-
| 38
+
-
| {{a-likely|test_unit_flag3}}
+
-
| bitmask
+
-
| true if flag 3 bits of caller are set
+
-
|-
+
-
| 39
+
-
| {{a-guess|set_ctrl_flag}}
+
-
| bitmask
+
-
| Set flag bits of CTL-Engine
+
-
|-
+
-
| 3A
+
-
| {{a-guess|clear_ctrl_flag}}
+
-
| bitmask
+
-
| Clear flag bits of CTL-Engine
+
-
|-
+
-
| 3B
+
-
| {{a-guess|test_ctrl_flag}}
+
-
| bitmask
+
-
| true if CTL-Engine-Flag flag bits are set
+
-
|-
+
-
| 3D
+
-
| {{a-certain|set_event_handler}}
+
-
| func
+
-
| Registers func as an event handler
+
-
|-
+
-
| 3F
+
-
| {{a-certain|set_label}}
+
-
| label
+
-
| Sets label of a unit to label
+
-
|-
+
-
| 41
+
-
| {{a-guess|test_label_exists}}
+
-
| label
+
-
| true if unit with thread_id is alive
+
-
|-
+
-
| 4E
+
-
| {{a-certain|goto_iftrue}}
+
-
| func
+
-
| Continues execution at the specified func is previous statement was true
+
-
|-
+
-
| 52
+
-
| {{a-certain|move_rand_in_radius}}
+
-
| waypoint_id (<11>)
+
-
| Move to a random position in the radius of the waypoint<br />Used for Peasants
+
-
|-
+
-
| 53
+
-
| {{a-likely|init_teleport}}
+
-
| node_id
+
-
| Sets the target of the next teleport call
+
-
|-
+
-
| 55
+
-
| {{a-likely|teleport_to}}
+
-
| -
+
-
| Moves the unit to the node_it set by init_teleport
+
-
|-
+
-
| 5C
+
-
| {{a-certain|retreat}}
+
-
| -
+
-
| Caller retreats (yellow arrow) but without white flag
+
-
|-
+
-
| 69
+
-
| {{a-guess|send_event_to_this}}
+
-
| event_id
+
-
| executes event of caller
+
-
|-
+
-
| 6b
+
-
| {{a-guess|raise_event2}}
+
-
| event_id
+
-
| executes event of caller
+
-
|-
+
-
| 6d
+
-
| {{a-guess|raise_event3}}
+
-
| event_id
+
-
| executes event of caller
+
-
|-
+
-
| 6e
+
-
| {{a-guess|raise_event4}}
+
-
| event_id
+
-
| executes event of caller
+
-
|-
+
-
| 70
+
-
| {{a-guess|raise_event5}}
+
-
| event_id
+
-
| executes event of caller
+
-
|-
+
-
| 71
+
-
| {{a-likely|teleport_to2}}
+
-
| -
+
-
| Moves the unit to the node_it set by init_teleport
+
-
|-
+
-
| 72
+
-
| {{a-certain|get_event}}
+
-
| -
+
-
| Get the next event from the unit's event queue
+
-
|-
+
-
| 73
+
-
| {{a-certain|test_more_events}}
+
-
| -
+
-
| True if there are more events in the unit's event queue
+
-
|-
+
-
| 74
+
-
| {{a-certain|on_event}}
+
-
| event_id
+
-
| If the current event matches event_id then continue, otherwise skip this event handler.
+
-
|-
+
-
| 75
+
-
| {{a-likely|end_event}}
+
-
| value
+
-
| leave the event-statement. Value is 0x1abc to skip to the next 0xabc label, or 0xdef to fall through to next event handler.
+
-
|-
+
-
| 76
+
-
| {{a-certain|iftrue}}
+
-
| -
+
-
|
+
-
|-
+
-
| 77
+
-
| {{a-certain|iffalse}}
+
-
| -
+
-
|
+
-
|-
+
-
| 78
+
-
| {{a-certain|else}}
+
-
| -
+
-
|
+
-
|-
+
-
| 79
+
-
| {{a-certain|endif}}
+
-
| -
+
-
|
+
-
|-
+
-
| 97
+
-
| {{a-guess|init_teleport_spell}}
+
-
| node_id
+
-
| Used by B1_04 Necromancer. Caller teleports to node_id
+
-
|-
+
-
| A2
+
-
| {{a-guess|search_and_attack_enemy}}
+
-
| unk, unk, unk
+
-
| Searches for an enemy in a specific radius and attacks it.<br/>True if enemy was found.
+
-
|-
+
-
| AC
+
-
| {{a-guess|search_and_shoot_enemy}}
+
-
| unk, unk, unk
+
-
| Searches for an enemy in a specific radius and shoots at him.<br/>True if enemy was found.
+
-
|-
+
-
| AE
+
-
| {{a-certain|play}}
+
-
| voice_id
+
-
| display portrait of caller and say text voice_id
+
-
|-
+
-
| AF
+
-
| {{a-certain|play_other_unit}}
+
-
| unit_id, voice_id
+
-
| display portrait of unit_id and say text voice_id
+
-
|-
+
-
| B2
+
-
| {{a-likely|test_unit_afraid}}
+
-
| -
+
-
| true if unit has fear
+
-
|-
+
-
| B3
+
-
| {{a-certain|test_unit_at_node}}
+
-
| node_id
+
-
| true if unit reached node_id
+
-
|-
+
-
| B3
+
-
| {{a-likely|test_unit_at_node2}}
+
-
| node_id
+
-
| true if unit reached node_id
+
-
|-
+
-
| B6
+
-
| {{a-guess|send_event_to_labelled}}
+
-
| label_id, event
+
-
| Calls event in unit with label_id
+
-
|-
+
-
| B8
+
-
| {{a-likely|test_event_from_enemy}}
+
-
| -
+
-
| true if event was caused by an enemy
+
-
|-
+
-
| BA
+
-
| {{a-certain|test_unit_class}}
+
-
| unit_class
+
-
| true if unit has unit type unit_class (ignores first 3 bits)
+
-
|-
+
-
| C1
+
-
| {{a-certain|test_unit_label}}
+
-
| label_id
+
-
| true if unit with label_id is on the map (= deployed) and alive
+
-
|-
+
-
| D8
+
-
| {{a-guess|test_other_unit_alive}}
+
-
| unit_id
+
-
| true if unit_id is still alive?
+
-
|-
+
-
| D9
+
-
| {{a-likely|test_user_action}}
+
-
| action_id
+
-
| Used in the tutorial map to check for player events.<br />True if the specific action was done.
+
-
|- 
+
-
| DA
+
-
| {{a-certain|ui_indicate}}
+
-
| x, y, size
+
-
| display 4 arrows that are placed around a rectangle<br />If x and y are -1, size is the unit_id
+
-
|-
+
-
| DE
+
-
| {{a-likely|test_other_unit_at_node}}
+
-
| node_id
+
-
| True if unit_id reached node
+
-
|-
+
-
| DF
+
-
| {{a-likely|test_other_unit_attacking}}
+
-
| unit_id
+
-
| True if unit_id is fighting
+
-
|-
+
-
| E0
+
-
| {{a-likely|test_other_unit_flags}}
+
-
| unit_id, flag
+
-
| true if flag of unit_id is set
+
-
|-
+
-
| E2
+
-
| {{a-likely|test_other_unit_selected}}
+
-
| unit_id
+
-
| true if unit with unit_id is selected
+
-
|-
+
-
| E6
+
-
| {{a-certain|test_mapmode}}
+
-
| -
+
-
| true if worldmap (spacebar) has been displayed
+
-
|-
+
-
| E7
+
-
| {{a-guess|test_other_unit_status}}
+
-
| unit_id
+
-
| true if ?
+
-
|-
+
-
| EA
+
-
| {{a-likely|test_sound_playing}}
+
-
| -
+
-
| true if last "play" is still playing
+
-
|-
+
-
| ED
+
-
| {{a-likely|end_mission}}
+
-
| -
+
-
| Display "End Mission" message
+
-
|-
+
-
| EE
+
-
| {{a-guess|test_other_unit_dead}}
+
-
| unit_id
+
-
| true if unit_id is dead
+
-
|-
+
-
|colspan="4"|<div style="color:green;">likely and tested</div>
+
-
<div style="color:brown;">Highly likely but not tested</div>
+
-
<!--<div style="color:orange;">Function basically undeterminable... :(</div>-->
+
-
<div style="color:red;">Guess and/or untested</div>
+
|}
|}
-
 
-
Note: node_id can be calculated by counting the subsections (starting from 0)
 

Revision as of 11:40, 8 April 2012

Contents

init_unit (00)

Argument Explanation
unk unknown purpose

This function initializes some data structures of the unit to it's default values. It should be used as the first function called by a unit script.

wait_for_deploy (01)

Blocks the execution of the units script until the deployment phase is finished.

In the deployment phase it sets bit 31 of unit flag 1. At the end of the phase it clears the bit.

reset_call_stack (02)

Resets the units stack. Don't call this when you have to return from a function or are in a loop.

restore_ip (03)

Restores the state saved with save_ip (execution continues after the save_ip call). All events get marked as handled so unhandled events are lost.

save_ip (04)

Stores the current state of the instruction pointer (current function, position in function, number of free stack slots). Note that the stack itself is not saved!

do (05)

Begins a do-loop (pushes position of next opcode on the stack). This loop is always executed at least once.

always (06)

Usually used at the end of a do-loop. Pops from the stack and continues script execution at this position (this is usually the command following the do-statement).

while (07)

Usually used at the end of a do-loop. Pops from the stack and checks the conditional flag:

Condition Result
true Continue execution at stack position
false Continue execution with command after while
Personal tools
communication