forked from reticulatedpines/magiclantern_hg_02
-
Notifications
You must be signed in to change notification settings - Fork 6
/
state-object.h
92 lines (76 loc) · 2.01 KB
/
state-object.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#ifndef _dryos_state_object_h_
#define _dryos_state_object_h_
/** \file
* DryOS finite-state machine objects.
*/
/*
* Copyright (C) 2009 Trammell Hudson <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "arm-mcr.h"
/** State objects.
*
* Size 0x20
*/
typedef struct state_object * (*state_function_t)(
void * arg1,
void * arg2,
void * arg3
);
struct state_callback
{
uint32_t next_state;
state_function_t handler;
};
struct state_object
{
const char * type; // off 0x00, "StateObject"
const char * name; // off 0x04, arg 0
uint32_t auto_sequence; // off 0x08, arg 1
// off 0x0c, always 0xff99a228 ?
void (*callback)(
struct state_object * self,
void * arg1,
uint32_t input,
void * arg3,
void * arg4
);
// Points to an array of size [max_inputs][max_states]
struct state_callback * callbacks; // off 0x10
uint32_t max_inputs; // off 0x14, arg 2
uint32_t max_states; // off 0x18, arg 3
uint32_t state; // off 0x1c, initially 0
};
SIZE_CHECK_STRUCT( state_object, 0x20 );
extern struct state_object *
state_object_create(
const char * name,
int auto_sequence,
state_function_t * callbacks,
int max_inputs,
int max_states
);
extern void
state_object_dispatchc(
struct state_object * self,
int input,
int arg0,
int arg1,
int arg2
);
#endif