2 #if( ! @defined( fsm_hhf ))
5 #includeonce( "hla.hhf" )
10 current_state : dword;
13 #macro fsm_callback ( _cbfunc_, _extname_ ) ;
21 @external( _extname_ );
25 #macro fsm_callback2 ( _cbfunc_, _extname_ ) ;
32 @external( _extname_ );
36 #macro fsm_start ( _fsm_, _advance_func_, _ext_ ) :
42 #print ( "digraph myfsm_mindrot_org {" )
43 #print ( " rankdir = LR;" )
45 procedure _advance_func_
53 #keyword init_state ( _state_ ) ;
56 ?_state_id_ := _state_id_ + 1;
59 #print ( " node [shape = doublecircle];" )
60 #print ( " ", @string:_state_, " ;" )
62 #keyword state ( _state_ ) ;
64 const _state_ := _state_id_;
65 ?_state_id_ := _state_id_ + 1;
67 #print ( " node [shape = circle];" )
68 #print ( " ", @string:_state_, " ;" )
70 #keyword event ( _ev_ ) ;
72 const _ev_ := _event_;
73 ?_event_ := _event_ + 1;
75 #keyword fsm_advance ;
77 procedure _advance_func_
91 mov ( (type myfsm [ebx]).current_state, eax );
97 #keyword tr ( _state_, _ev_, _new_state_, _cbfunc_ ) :
100 #print ( " ", @string:_state_, " -> ", @string:_new_state_ )
101 #print ( " [ label = """, @string:_ev_, """];" )
103 cmp ( eax, _state_ );
109 mov ( _new_state_, eax );
111 mov ( eax, (type myfsm [ebx]).current_state );
121 #keyword tr2 ( _state_, _ev_, _new_state_, _cbfunc_ ) :
124 #print ( " ", @string:_state_, " -> ", @string:_new_state_ )
125 #print ( " [ label = """, @string:_ev_, """];" )
127 cmp ( eax, _state_ );
133 mov ( eax, (type myfsm [ebx]).current_state );
135 push ( edx ); // _ctx_
136 push ( ecx ); // _ev_
137 call ( _cbfunc_ ); // _cb_func_ ( _ev_, _ctx_ );