-
Notifications
You must be signed in to change notification settings - Fork 4
/
movement.py
64 lines (55 loc) · 1.31 KB
/
movement.py
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
# coding: utf-8
from new import classobj
from script import *
movements = [
'step_00',
'step_01',
'step_02',
'step_03',
'slow_step_down',
'slow_step_up',
'slow_step_left',
'slow_step_right',
'step_down',
'step_up',
'step_left',
'step_right',
'fast_step_down',
'fast_step_up',
'fast_step_left',
'fast_step_right',
'step_10',
'step_11',
'step_12',
'step_13',
]
movement_commands = {
0x91: { 'name': 'step_91', },
0x92: { 'name': 'step_92', },
0x96: { 'name': 'step_96', },
0xfe: { 'name': 'step_end', 'end': True, },
}
num_movement_commands = 0x64
def make_movement_command_classes():
classes = {}
for byte, name in enumerate(movements):
movement_commands[byte] = {
'name': name,
}
for byte in xrange(byte, num_movement_commands):
movement_commands[byte] = {
'name': 'step_{:02x}'.format(byte)
}
for byte, command in movement_commands.items():
class_name = 'Movement_' + command['name']
attributes = {}
attributes['id'] = byte
attributes['param_classes'] = [Byte] + command.get('param_types', list())
attributes.update(command)
classes[byte] = classobj(class_name, (Command,), attributes)
return classes
movement_command_classes = make_movement_command_classes()
class Movement(Script):
commands = movement_command_classes
class MovementPointer(Pointer):
target = Movement