Talk:DO/CTL/OpCodes

From Dark Omen Wiki

(Difference between revisions)
Jump to: navigation, search
(ctl magic)
(stack machine?)
Line 1: Line 1:
 +
__TOC__
 +
 +
==Raising and teleporting==
 +
Will be added later to the table:
Will be added later to the table:
Line 48: Line 52:
--[[User:Ghabry|Ghabry]] 02:02, 23 February 2010 (UTC)
--[[User:Ghabry|Ghabry]] 02:02, 23 February 2010 (UTC)
 +
 +
==CTL is a stack machine?==
 +
Checking the opcodes and reading the snippets, I get the feeling that CTL is a [http://en.wikipedia.org/wiki/Stack_machine stack machine], that is, all operations are pushed and popped through the stack. Therefore, all operations push their result to the stack, and f.i. while and whilenot does not check the last operation, as said in the article, but rather the top item of the stack (which usually is the same thing as the last operation, though). I don't know, just thought I'd throw it here and see what you think.
 +
So the last code example would be interpreted like this:
 +
do
 +
    set_wait_time 6
 +
    wait
 +
    #b5 0, 15, 8192  ; Check if player hit node 15, push result
 +
    iftrue          ; ?pop stack?, cmp value
 +
        set_r_i 6, 0
 +
    endif
 +
    #d6 0            ; ? cmp current value ?
 +
    iffalse
 +
        set_r_i 6, 0
 +
    endif
 +
    test_r_eq_i 6, 0 ; Test reg6 against false (0)
 +
                      ; ? Does this push result or set current value ?
 +
  whilenot            ; if ??stack top or current value?? is false goto do
 +
--[[User:Mikademus|Mikademus]] 11:06, 23 February 2010 (UTC)

Revision as of 11:06, 23 February 2010

Contents


Raising and teleporting

Will be added later to the table:

#b5 0, nodeid, 8192

True if one of the players regiments is in the circle defined by nodeid.
What the 0 and 8192 (a flag?) checks is unknown. Only tested in B1_07 (Attack Helmgart). Every #b5 uses 0 and 8192 there...


#53 nodeid

(necromancer in helmgart has #54 nodeid, not tested if this is the same)

Teleports a regiment. This is used as a part of unit activation (=teleport on the map)
Attention: #53 must be followed by either #55 or #71 or the unit will glitch to the node!
#71 does a simple teleport and #55 does a zombie-raise-animation (only works for zombie sprite)

Basic Unit activation (Trading Post Goblins), not always used:

set_unit_flag 2048 ; Activates the Banner graphic (not needed but really useful ;))
#53 24             ; Teleport node (see above)
#71                ; Normal Teleport
#50                ; Rest Unknown
#3c 240, 0
#2c 8

Typical way to block a regiment until the player reaches a special point:

set_r_i 6, 1 ; Set register 6 to 1
do 
    set_wait_time 6
    wait 
    #b5 0, 15, 8192 ; Check if player hit node 15
    iftrue 
        set_r_i 6, 0
    endif 
    #d6 0           ; Unknown, but works with only #b5 of course too...
    iffalse 
        set_r_i 6, 0
    endif 
    test_r_eq_i 6, 0 ; If one of the two above events happened the unit will be spawned
 whilenot
 set_unit_flag 2048 (rest see above)
 

The above code is often shared for lots of regiments to allow simultanious spawning of them (at different node id of course ;))

Hm stupid wiki converts # to a enumeration... (1., 2., 3.)

--Ghabry 02:02, 23 February 2010 (UTC)

CTL is a stack machine?

Checking the opcodes and reading the snippets, I get the feeling that CTL is a stack machine, that is, all operations are pushed and popped through the stack. Therefore, all operations push their result to the stack, and f.i. while and whilenot does not check the last operation, as said in the article, but rather the top item of the stack (which usually is the same thing as the last operation, though). I don't know, just thought I'd throw it here and see what you think. So the last code example would be interpreted like this:

do 
    set_wait_time 6
    wait 
    #b5 0, 15, 8192  ; Check if player hit node 15, push result
    iftrue           ; ?pop stack?, cmp value
        set_r_i 6, 0
    endif 
    #d6 0            ; ? cmp current value ?
    iffalse 
        set_r_i 6, 0
    endif 
    test_r_eq_i 6, 0 ; Test reg6 against false (0)
                     ; ? Does this push result or set current value ?
 whilenot            ; if ??stack top or current value?? is false goto do

--Mikademus 11:06, 23 February 2010 (UTC)

Personal tools
communication