nabaztag_hack_kit 0.1.0.beta3 → 0.1.0.beta8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +7 -2
- data/.gitmodules +3 -0
- data/.travis.yml +2 -2
- data/CHANGELOG.md +17 -2
- data/LICENSE +21 -0
- data/README.md +115 -44
- data/Rakefile +2 -6
- data/bytecode/{Commands.md → _docs/commands.md} +0 -0
- data/bytecode/{Docs.md → _docs/grammar.md} +0 -0
- data/bytecode/_docs/grammar.pdf +0 -0
- data/bytecode/{src → _original}/README.md +0 -0
- data/bytecode/{src → _original}/lib/arp.mtl +0 -0
- data/bytecode/{src → _original}/lib/cfg.mtl +0 -0
- data/bytecode/{src → _original}/lib/choreos.mtl +0 -0
- data/bytecode/{src → _original}/lib/dhcp.mtl +0 -0
- data/bytecode/{src → _original}/lib/dns.mtl +0 -0
- data/bytecode/{src → _original}/lib/http.mtl +0 -0
- data/bytecode/{src → _original}/lib/tcp.mtl +0 -0
- data/bytecode/{src → _original}/lib/udp.mtl +0 -0
- data/bytecode/{src → _original}/lib/util.mtl +0 -0
- data/bytecode/{src → _original}/lib/var.mtl +0 -0
- data/bytecode/{src → _original}/lib/wav.mtl +0 -0
- data/bytecode/{src → _original}/lib/wifi.mtl +0 -0
- data/bytecode/{src → _original}/nominal-ping.mtl +0 -0
- data/bytecode/main.mtl +11 -11
- data/bytecode/test/test.mtl +8 -8
- data/examples/basic/Gemfile +1 -3
- data/examples/basic/config.ru +14 -4
- data/examples/record/Gemfile +0 -5
- data/examples/record/{config.ru.example → config.ru} +2 -2
- data/examples/record/server.rb +0 -2
- data/ext/Makefile +10 -0
- data/ext/bin/mtl_comp +29 -0
- data/{bytecode → ext}/bin/mtl_merge +0 -0
- data/ext/bin/mtl_simu +29 -0
- data/{bytecode/src/mtl → ext}/extconf.rb +0 -0
- data/ext/mtl_linux/.gitignore +7 -0
- data/ext/mtl_linux/LICENSE +21 -0
- data/ext/mtl_linux/Makefile +116 -0
- data/ext/mtl_linux/MetalC.project +196 -0
- data/ext/mtl_linux/conf.bin +0 -0
- data/{bytecode/src/mtl → ext/mtl_linux}/conf.bin.sans_password +0 -0
- data/{bytecode/src/mtl → ext/mtl_linux}/config.txt +0 -0
- data/ext/mtl_linux/inc/log.h +21 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc}/properties.h +0 -0
- data/{bytecode/src/mtl/linux_simuaudio.h → ext/mtl_linux/inc/simu/linux/simuaudio.h} +0 -0
- data/{bytecode/src/mtl/linux_simunet.h → ext/mtl_linux/inc/simu/linux/simunet.h} +0 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc/simu/win}/simuaudio.h +18 -18
- data/{bytecode/src/mtl → ext/mtl_linux/inc/simu/win}/simunet.h +0 -0
- data/ext/mtl_linux/inc/vcomp/compiler.h +200 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/file.h +11 -11
- data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/filesystem.h +0 -0
- data/ext/mtl_linux/inc/vcomp/interpreter.h +121 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/memory.h +120 -92
- data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/param.h +0 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/parser.h +27 -27
- data/ext/mtl_linux/inc/vcomp/prodbuffer.h +42 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/resource.h +1 -1
- data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/terminal.h +8 -8
- data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/util.h +7 -7
- data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vaudio.h +0 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vbc.h +1 -1
- data/ext/mtl_linux/inc/vm/vbc_str.h +167 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vinterp.h +0 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vloader.h +0 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vlog.h +0 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vmem.h +0 -0
- data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vnet.h +0 -0
- data/ext/mtl_linux/nominal.mtl +3959 -0
- data/ext/mtl_linux/src/comp/main.cpp +123 -0
- data/ext/mtl_linux/src/simu/dumpbc.c +2566 -0
- data/ext/mtl_linux/src/simu/linux/main.cpp +288 -0
- data/ext/mtl_linux/src/simu/linux/simu.c +309 -0
- data/ext/mtl_linux/src/simu/linux/simuaudio.c +44 -0
- data/ext/mtl_linux/src/simu/linux/simunet.c +707 -0
- data/ext/mtl_linux/src/simu/log.c +340 -0
- data/ext/mtl_linux/src/simu/properties.c +368 -0
- data/{bytecode/src/mtl → ext/mtl_linux/src/simu/win}/mp3/GTKANAL.H +0 -0
- data/{bytecode/src/mtl → ext/mtl_linux/src/simu/win}/mp3/LAYER3.C +0 -0
- data/{bytecode/src/mtl → ext/mtl_linux/src/simu/win}/mp3/TABINIT.C +0 -0
- data/ext/mtl_linux/src/simu/win/mp3/common.c +302 -0
- data/ext/mtl_linux/src/simu/win/mp3/dct64_i386.c +316 -0
- data/ext/mtl_linux/src/simu/win/mp3/decode_i386.c +160 -0
- data/ext/mtl_linux/src/simu/win/mp3/huffman.h +332 -0
- data/ext/mtl_linux/src/simu/win/mp3/interface.c +276 -0
- data/{bytecode/src/mtl → ext/mtl_linux/src/simu/win}/mp3/mpg123.h +34 -30
- data/ext/mtl_linux/src/simu/win/mp3/mpglib.h +47 -0
- data/ext/mtl_linux/src/simu/win/simu.c +819 -0
- data/ext/mtl_linux/src/simu/win/simuaudio.c +787 -0
- data/ext/mtl_linux/src/simu/win/simunet.c +489 -0
- data/ext/mtl_linux/src/vcomp/bootstrap.cpp +95 -0
- data/ext/mtl_linux/src/vcomp/compiler.cpp +587 -0
- data/ext/mtl_linux/src/vcomp/compiler_file.cpp +1253 -0
- data/ext/mtl_linux/src/vcomp/compiler_prog.cpp +437 -0
- data/ext/mtl_linux/src/vcomp/compiler_term.cpp +1500 -0
- data/ext/mtl_linux/src/vcomp/compiler_type.cpp +1238 -0
- data/ext/mtl_linux/src/vcomp/compiler_var.cpp +502 -0
- data/ext/mtl_linux/src/vcomp/file.cpp +100 -0
- data/ext/mtl_linux/src/vcomp/interpreter.cpp +93 -0
- data/ext/mtl_linux/src/vcomp/memory.cpp +313 -0
- data/ext/mtl_linux/src/vcomp/parser.cpp +584 -0
- data/ext/mtl_linux/src/vcomp/parser_xml.cpp +137 -0
- data/{bytecode/src/mtl → ext/mtl_linux/src}/vcomp/prodbuffer.cpp +57 -36
- data/ext/mtl_linux/src/vcomp/stdlib_core.cpp +130 -0
- data/ext/mtl_linux/src/vcomp/terminal.cpp +80 -0
- data/{bytecode/src/mtl → ext/mtl_linux/src}/vcomp/util.cpp +18 -11
- data/ext/mtl_linux/src/vm/vaudio.c +830 -0
- data/ext/mtl_linux/src/vm/vinterp.c +1780 -0
- data/ext/mtl_linux/src/vm/vloader.c +139 -0
- data/ext/mtl_linux/src/vm/vlog.c +782 -0
- data/ext/mtl_linux/src/vm/vmem.c +461 -0
- data/ext/mtl_linux/src/vm/vnet.c +298 -0
- data/{bytecode/src/mtl → ext/mtl_linux}/utils/correct_const.sh +0 -0
- data/lib/nabaztag_hack_kit/server.rb +4 -7
- data/lib/nabaztag_hack_kit/version.rb +1 -1
- data/lib/nabaztag_hack_kit.rb +2 -2
- data/nabaztag_hack_kit.gemspec +10 -11
- data/spec/integration/server_spec.rb +3 -3
- data/spec/spec_helper.rb +2 -0
- data/spec/unit/message_spec.rb +12 -18
- data/spec/unit/server_spec.rb +13 -10
- metadata +145 -137
- data/bytecode/bin/mtl_comp +0 -50
- data/bytecode/bin/mtl_simu +0 -49
- data/bytecode/src/mtl/Makefile +0 -42
- data/bytecode/src/mtl/README.md +0 -13
- data/bytecode/src/mtl/bc.cpp +0 -1891
- data/bytecode/src/mtl/dumpbc.c +0 -2566
- data/bytecode/src/mtl/linux_simu.c +0 -271
- data/bytecode/src/mtl/linux_simuaudio.c +0 -16
- data/bytecode/src/mtl/linux_simunet.c +0 -620
- data/bytecode/src/mtl/log.c +0 -297
- data/bytecode/src/mtl/log.h +0 -20
- data/bytecode/src/mtl/main_compiler.cpp +0 -104
- data/bytecode/src/mtl/main_simu.cpp +0 -221
- data/bytecode/src/mtl/mp3/common.c +0 -265
- data/bytecode/src/mtl/mp3/dct64_i386.c +0 -316
- data/bytecode/src/mtl/mp3/decode_i386.c +0 -155
- data/bytecode/src/mtl/mp3/huffman.h +0 -332
- data/bytecode/src/mtl/mp3/interface.c +0 -258
- data/bytecode/src/mtl/mp3/mpglib.h +0 -44
- data/bytecode/src/mtl/properties.c +0 -293
- data/bytecode/src/mtl/simu.c +0 -750
- data/bytecode/src/mtl/simuaudio.c +0 -662
- data/bytecode/src/mtl/simunet.c +0 -400
- data/bytecode/src/mtl/vaudio.c +0 -677
- data/bytecode/src/mtl/vbc_str.h +0 -166
- data/bytecode/src/mtl/vcomp/Makefile +0 -29
- data/bytecode/src/mtl/vcomp/bootstrap.cpp +0 -89
- data/bytecode/src/mtl/vcomp/compiler.cpp +0 -470
- data/bytecode/src/mtl/vcomp/compiler.h +0 -200
- data/bytecode/src/mtl/vcomp/compiler_file.cpp +0 -929
- data/bytecode/src/mtl/vcomp/compiler_prog.cpp +0 -250
- data/bytecode/src/mtl/vcomp/compiler_term.cpp +0 -1053
- data/bytecode/src/mtl/vcomp/compiler_type.cpp +0 -872
- data/bytecode/src/mtl/vcomp/compiler_var.cpp +0 -289
- data/bytecode/src/mtl/vcomp/file.cpp +0 -79
- data/bytecode/src/mtl/vcomp/interpreter.cpp +0 -85
- data/bytecode/src/mtl/vcomp/interpreter.h +0 -121
- data/bytecode/src/mtl/vcomp/memory.cpp +0 -241
- data/bytecode/src/mtl/vcomp/parser.cpp +0 -427
- data/bytecode/src/mtl/vcomp/parser_xml.cpp +0 -124
- data/bytecode/src/mtl/vcomp/prodbuffer.h +0 -42
- data/bytecode/src/mtl/vcomp/stdlib_core.cpp +0 -122
- data/bytecode/src/mtl/vcomp/terminal.cpp +0 -73
- data/bytecode/src/mtl/vinterp.c +0 -1349
- data/bytecode/src/mtl/vloader.c +0 -127
- data/bytecode/src/mtl/vlog.c +0 -589
- data/bytecode/src/mtl/vmem.c +0 -424
- data/bytecode/src/mtl/vnet.c +0 -255
- data/examples/basic/Procfile +0 -2
- data/examples/basic/server.rb +0 -14
@@ -0,0 +1,819 @@
|
|
1
|
+
/*
|
2
|
+
PROJECT VLOWCOST 1.0
|
3
|
+
copyright 2004
|
4
|
+
Sylvain HUET
|
5
|
+
amberMind
|
6
|
+
*/
|
7
|
+
|
8
|
+
#define PROTORABBIT
|
9
|
+
//#define PROTODAL
|
10
|
+
|
11
|
+
// commenter la ligne suivante pour la version windows
|
12
|
+
//#define VMICROCHIP
|
13
|
+
|
14
|
+
|
15
|
+
#define uchar unsigned char
|
16
|
+
#define ulong unsigned long
|
17
|
+
#ifndef uint
|
18
|
+
#define uint unsigned short int
|
19
|
+
#endif
|
20
|
+
#define vub unsigned char
|
21
|
+
#define vsb signed char
|
22
|
+
|
23
|
+
#define vuw unsigned short int
|
24
|
+
#define vsw signed short int
|
25
|
+
|
26
|
+
#define vud unsigned long
|
27
|
+
#define vsd signed long
|
28
|
+
|
29
|
+
#ifdef PROTORABBIT
|
30
|
+
#define VLISP_HARDWARE "NAB2"
|
31
|
+
#define NBLED 15
|
32
|
+
#define VL_MOTORS
|
33
|
+
#define VL_MUSIC
|
34
|
+
#define VL_3STATE
|
35
|
+
#define NBMOTOR 2
|
36
|
+
#endif
|
37
|
+
|
38
|
+
#ifdef PROTODAL
|
39
|
+
#define VLISP_HARDWARE "4"
|
40
|
+
#define NBLED 27
|
41
|
+
#define VL_PRESS
|
42
|
+
#endif
|
43
|
+
|
44
|
+
#ifdef VMICROCHIP
|
45
|
+
int simuInit()
|
46
|
+
{
|
47
|
+
return 0;
|
48
|
+
}
|
49
|
+
int simuDoLoop()
|
50
|
+
{
|
51
|
+
return 0;
|
52
|
+
}
|
53
|
+
void simuSetLed(vub i,vub val) {}
|
54
|
+
void simuSetMotor(vub i,vub val) {}
|
55
|
+
|
56
|
+
#else
|
57
|
+
#include<stdio.h>
|
58
|
+
#include<stdlib.h>
|
59
|
+
#include<string.h>
|
60
|
+
#include<io.h>
|
61
|
+
#include<time.h>
|
62
|
+
|
63
|
+
#include"my_simuaudio.h"
|
64
|
+
#include"my_simunet.h"
|
65
|
+
|
66
|
+
// d�finition de l'�chelle d'affichage de la simulation
|
67
|
+
#define SCALE 2
|
68
|
+
|
69
|
+
#define NBHOLES 20
|
70
|
+
#define MASKEDHOLES 3
|
71
|
+
// MAXMOTORVAL doit �tre inf�rieur � 256
|
72
|
+
#define MAXMOTORVAL 100
|
73
|
+
|
74
|
+
int motorwheel[256];
|
75
|
+
|
76
|
+
// gestion des couleurs
|
77
|
+
// ---------------------
|
78
|
+
uchar coloradd[256*256];
|
79
|
+
uchar colormul[256*256];
|
80
|
+
|
81
|
+
#define COLORADD(x,y) (coloradd[(x)+((y)<<8)])
|
82
|
+
#define COLORMUL(x,y) (colormul[(x)+((y)<<8)])
|
83
|
+
|
84
|
+
#define RGBTOINT(r,g,b) (( (((int)r)&255)<<16)+((((int)g)&255)<<8)+(((int)b)&255))
|
85
|
+
#define INTTOR(c) ((c>>16)&255)
|
86
|
+
#define INTTOG(c) ((c>>8)&255)
|
87
|
+
#define INTTOB(c) (c&255)
|
88
|
+
|
89
|
+
// initialisation des tables de couleur
|
90
|
+
void colortabInit()
|
91
|
+
{
|
92
|
+
int i,j,k;
|
93
|
+
|
94
|
+
for(i=0; i<256; i++)
|
95
|
+
for(j=0; j<256; j++)
|
96
|
+
{
|
97
|
+
k=i+j;
|
98
|
+
coloradd[i+(j<<8)]=(k<=255)?k:255;
|
99
|
+
|
100
|
+
k=i*j/255;
|
101
|
+
colormul[i+(j<<8)]=k;
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
// d�finition physique des leds
|
106
|
+
|
107
|
+
int diodeval[NBLED];
|
108
|
+
#ifdef VL_MOTORS
|
109
|
+
int motorval[NBMOTOR];
|
110
|
+
int motorcount[NBMOTOR];
|
111
|
+
int motordir[NBMOTOR];
|
112
|
+
#endif
|
113
|
+
|
114
|
+
int xclicsimu=-1;
|
115
|
+
int yclicsimu=-1;
|
116
|
+
int rclicsimu=0;
|
117
|
+
int movesimu=0;
|
118
|
+
|
119
|
+
int lastmovex=0;
|
120
|
+
int lastmovey=0;
|
121
|
+
|
122
|
+
#ifdef PROTORABBIT
|
123
|
+
int diodex[NBLED]= {80,80,80,40,40,40,80,80,80,120,120,120,80,80,80};
|
124
|
+
int diodey[NBLED]= {40,40,40,90,90,90,90,90,90,90,90,90,130,130,130};
|
125
|
+
int diodergb[NBLED]=
|
126
|
+
{
|
127
|
+
0x0000ff,0x00ff00,0xff0000,
|
128
|
+
0x0000ff,0x00ff00,0xff0000,
|
129
|
+
0x0000ff,0x00ff00,0xff0000,
|
130
|
+
0x0000ff,0x00ff00,0xff0000,
|
131
|
+
0x0000ff,0x00ff00,0xff0000
|
132
|
+
};
|
133
|
+
HWND buttoncheck;
|
134
|
+
HWND button3;
|
135
|
+
HWND buttonrfid;
|
136
|
+
#define SUPP_HIGH 60
|
137
|
+
int width=160*SCALE;
|
138
|
+
int height=160*SCALE;
|
139
|
+
#endif
|
140
|
+
|
141
|
+
#ifdef PROTODAL
|
142
|
+
int diodex[NBLED]= {40,40,40,80,80,80,120,120,120,40,40,40,80,80,80,120,120,120,40,40,40,80,80,80,120,120,120};
|
143
|
+
int diodey[NBLED]= {40,40,40,40,40,40,40,40,40,80,80,80,80,80,80,80,80,80,120,120,120,120,120,120,120,120,120};
|
144
|
+
int diodergb[NBLED]=
|
145
|
+
{
|
146
|
+
0x0000ff,0x00ff00,0xff0000,
|
147
|
+
0x0000ff,0x00ff00,0xff0000,
|
148
|
+
0x0000ff,0x00ff00,0xff0000,
|
149
|
+
0x0000ff,0x00ff00,0xff0000,
|
150
|
+
0x0000ff,0x00ff00,0xff0000,
|
151
|
+
0x0000ff,0x00ff00,0xff0000,
|
152
|
+
0x0000ff,0x00ff00,0xff0000,
|
153
|
+
0x0000ff,0x00ff00,0xff0000,
|
154
|
+
0x0000ff,0x00ff00,0xff0000
|
155
|
+
};
|
156
|
+
HWND buttoncheck;
|
157
|
+
#define SUPP_HIGH 20
|
158
|
+
int width=160*SCALE;
|
159
|
+
int height=160*SCALE;
|
160
|
+
#endif
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
#define FlagMainWindow (WS_VISIBLE|WS_CAPTION)
|
165
|
+
#define V_FONT ANSI_FIXED_FONT
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
HWND mainwin;
|
170
|
+
HBITMAP mainbmp;
|
171
|
+
char * mainbmppnt ;
|
172
|
+
int mainbmpnextline ;
|
173
|
+
DIBSECTION mainbmpinfo ;
|
174
|
+
|
175
|
+
|
176
|
+
void winrepaint()
|
177
|
+
{
|
178
|
+
|
179
|
+
HDC Dcw, Dcb ;
|
180
|
+
HBITMAP OldBitmap ;
|
181
|
+
PAINTSTRUCT ps;
|
182
|
+
|
183
|
+
Dcw=BeginPaint(mainwin,&ps);
|
184
|
+
Dcb=CreateCompatibleDC(Dcw);
|
185
|
+
OldBitmap=SelectObject(Dcb,mainbmp);
|
186
|
+
BitBlt(Dcw,0,0,width,height,Dcb,0,0,SRCCOPY);
|
187
|
+
SelectObject(Dcb,OldBitmap);
|
188
|
+
DeleteDC(Dcb);
|
189
|
+
|
190
|
+
EndPaint(mainwin,&ps);
|
191
|
+
}
|
192
|
+
|
193
|
+
void winupdate()
|
194
|
+
{
|
195
|
+
InvalidateRect(mainwin,NULL,FALSE);
|
196
|
+
UpdateWindow(mainwin);
|
197
|
+
}
|
198
|
+
|
199
|
+
void mire()
|
200
|
+
{
|
201
|
+
int i,j;
|
202
|
+
char *pnt,*pnt0;
|
203
|
+
int next;
|
204
|
+
int increment=4;
|
205
|
+
|
206
|
+
pnt0=mainbmppnt;
|
207
|
+
next=mainbmpnextline;
|
208
|
+
|
209
|
+
for(i=0; i<height; i++)
|
210
|
+
{
|
211
|
+
pnt=pnt0;
|
212
|
+
for(j=0; j<width; j++)
|
213
|
+
{
|
214
|
+
pnt[0]=i&255;
|
215
|
+
pnt[1]=j&255;
|
216
|
+
pnt[2]=(i+j)&255;
|
217
|
+
pnt+=increment;
|
218
|
+
}
|
219
|
+
pnt0+=next;
|
220
|
+
}
|
221
|
+
}
|
222
|
+
|
223
|
+
void erasebmp()
|
224
|
+
{
|
225
|
+
int i;
|
226
|
+
char *pnt;
|
227
|
+
int next;
|
228
|
+
int increment=4;
|
229
|
+
|
230
|
+
pnt=mainbmppnt;
|
231
|
+
next=mainbmpnextline;
|
232
|
+
|
233
|
+
for(i=0; i<height; i++)
|
234
|
+
{
|
235
|
+
memset(pnt,0,increment*width);
|
236
|
+
pnt+=next;
|
237
|
+
}
|
238
|
+
}
|
239
|
+
|
240
|
+
#define DIODELEN (20*SCALE)
|
241
|
+
|
242
|
+
void plot(int x,int y,int rgb)
|
243
|
+
{
|
244
|
+
int r,g,b;
|
245
|
+
uchar *pnt;
|
246
|
+
int next;
|
247
|
+
int increment=4;
|
248
|
+
x*=SCALE;
|
249
|
+
y*=SCALE;
|
250
|
+
r=INTTOR(rgb);
|
251
|
+
g=INTTOG(rgb);
|
252
|
+
b=INTTOB(rgb);
|
253
|
+
if ((x<0)||(y<0)||(x>=width)||(y>=height))
|
254
|
+
{
|
255
|
+
return;
|
256
|
+
}
|
257
|
+
pnt=mainbmppnt;
|
258
|
+
next=mainbmpnextline;
|
259
|
+
pnt+=y*mainbmpnextline+x*increment;
|
260
|
+
pnt[0]=r;
|
261
|
+
pnt[1]=g;
|
262
|
+
pnt[2]=b;
|
263
|
+
}
|
264
|
+
|
265
|
+
void diodedraw(int num,int val)
|
266
|
+
{
|
267
|
+
int i,j,x,y,r,g,b,rgb;
|
268
|
+
uchar *pnt,*pnt0;
|
269
|
+
int next;
|
270
|
+
int increment=4;
|
271
|
+
|
272
|
+
if ((num<0)||(num>=NBLED))
|
273
|
+
{
|
274
|
+
return;
|
275
|
+
}
|
276
|
+
x=diodex[num]*SCALE-DIODELEN/2;
|
277
|
+
y=diodey[num]*SCALE-DIODELEN/2;
|
278
|
+
rgb=diodergb[num];
|
279
|
+
r=COLORMUL(INTTOR(rgb),(uchar)val);
|
280
|
+
g=COLORMUL(INTTOG(rgb),(uchar)val);
|
281
|
+
b=COLORMUL(INTTOB(rgb),(uchar)val);
|
282
|
+
|
283
|
+
if ((x<0)||(y<0)||(x+DIODELEN>width)||(y+DIODELEN>height))
|
284
|
+
{
|
285
|
+
return;
|
286
|
+
}
|
287
|
+
|
288
|
+
pnt0=mainbmppnt;
|
289
|
+
next=mainbmpnextline;
|
290
|
+
pnt0+=y*mainbmpnextline+x*increment;
|
291
|
+
|
292
|
+
for(i=0; i<DIODELEN; i++)
|
293
|
+
{
|
294
|
+
pnt=pnt0;
|
295
|
+
for(j=0; j<DIODELEN; j++)
|
296
|
+
{
|
297
|
+
pnt[0]=COLORADD(r,pnt[0]);
|
298
|
+
pnt[1]=COLORADD(g,pnt[1]);
|
299
|
+
pnt[2]=COLORADD(b,pnt[2]);
|
300
|
+
pnt+=increment;
|
301
|
+
}
|
302
|
+
pnt0+=next;
|
303
|
+
}
|
304
|
+
}
|
305
|
+
|
306
|
+
#define MOTORLEN (20*SCALE)
|
307
|
+
|
308
|
+
void motordraw(int x0,int val)
|
309
|
+
{
|
310
|
+
int i,j,x,y,r,g,b,rgb;
|
311
|
+
uchar *pnt,*pnt0;
|
312
|
+
int next;
|
313
|
+
int increment=4;
|
314
|
+
|
315
|
+
x=x0*SCALE-MOTORLEN/2;
|
316
|
+
y=(height*(val+128)>>9)-MOTORLEN/2;
|
317
|
+
rgb=0xc0c0c0;
|
318
|
+
r=INTTOR(rgb);
|
319
|
+
g=INTTOG(rgb);
|
320
|
+
b=INTTOB(rgb);
|
321
|
+
|
322
|
+
if ((x<0)||(y<0)||(x+MOTORLEN>width)||(y+MOTORLEN>height))
|
323
|
+
{
|
324
|
+
return;
|
325
|
+
}
|
326
|
+
|
327
|
+
pnt0=mainbmppnt;
|
328
|
+
next=mainbmpnextline;
|
329
|
+
pnt0+=y*mainbmpnextline+x*increment;
|
330
|
+
|
331
|
+
for(i=0; i<MOTORLEN; i++)
|
332
|
+
{
|
333
|
+
pnt=pnt0;
|
334
|
+
for(j=0; j<MOTORLEN; j++)
|
335
|
+
{
|
336
|
+
if (!((j+i+1)&3))
|
337
|
+
{
|
338
|
+
pnt[0]=COLORADD(r,pnt[0]);
|
339
|
+
pnt[1]=COLORADD(g,pnt[1]);
|
340
|
+
pnt[2]=COLORADD(b,pnt[2]);
|
341
|
+
}
|
342
|
+
pnt+=increment;
|
343
|
+
}
|
344
|
+
pnt0+=next;
|
345
|
+
}
|
346
|
+
}
|
347
|
+
|
348
|
+
HWND crText (char *text,HWND Parent,int x, int y, int w,int h)
|
349
|
+
{
|
350
|
+
HWND hwnd;
|
351
|
+
int Flags=ES_READONLY|WS_CHILD | ES_RIGHT ;
|
352
|
+
|
353
|
+
hwnd=CreateWindowEx ( 0,
|
354
|
+
"Edit",
|
355
|
+
text, Flags,
|
356
|
+
x,y,w,h,
|
357
|
+
Parent, NULL,
|
358
|
+
NULL/*thisinst*/, NULL ) ;
|
359
|
+
SendMessage(hwnd,WM_SETFONT,(WPARAM)GetStockFont(V_FONT),(LPARAM)TRUE);
|
360
|
+
|
361
|
+
ShowWindow(hwnd,SW_SHOW);
|
362
|
+
UpdateWindow(hwnd);
|
363
|
+
return hwnd;
|
364
|
+
}
|
365
|
+
|
366
|
+
HWND crEdit (char *text,HWND Parent,int x, int y, int w,int h)
|
367
|
+
{
|
368
|
+
HWND hwnd;
|
369
|
+
int Flags=WS_CHILD ;
|
370
|
+
|
371
|
+
hwnd=CreateWindowEx ( WS_EX_CLIENTEDGE,
|
372
|
+
"Edit",
|
373
|
+
text, Flags,
|
374
|
+
x,y,w,h,
|
375
|
+
Parent, NULL,
|
376
|
+
NULL/*thisinst*/, NULL ) ;
|
377
|
+
SendMessage(hwnd,WM_SETFONT,(WPARAM)GetStockFont(V_FONT),(LPARAM)TRUE);
|
378
|
+
ShowWindow(hwnd,SW_SHOW);
|
379
|
+
UpdateWindow(hwnd);
|
380
|
+
return hwnd;
|
381
|
+
}
|
382
|
+
|
383
|
+
void setText(HWND h,int v)
|
384
|
+
{
|
385
|
+
char buf[32];
|
386
|
+
sprintf(buf,"%d",v);
|
387
|
+
SetWindowText(h,buf);
|
388
|
+
}
|
389
|
+
|
390
|
+
char* getTextStr(HWND h,char *buf)
|
391
|
+
{
|
392
|
+
int s;
|
393
|
+
*(int*)buf=255;
|
394
|
+
s=SendMessage(h,EM_GETLINE,0,(LPARAM)buf);
|
395
|
+
buf[s]=0;
|
396
|
+
return buf;
|
397
|
+
}
|
398
|
+
|
399
|
+
int getText(HWND h)
|
400
|
+
{
|
401
|
+
char buf[256];
|
402
|
+
int s;
|
403
|
+
*(int*)buf=255;
|
404
|
+
s=SendMessage(h,EM_GETLINE,0,(LPARAM)buf);
|
405
|
+
buf[s]=0;
|
406
|
+
return atoi(buf);
|
407
|
+
}
|
408
|
+
|
409
|
+
|
410
|
+
HWND crCheck (char *text,HWND Parent,int x, int y, int w,int h)
|
411
|
+
{
|
412
|
+
HWND hwnd;
|
413
|
+
int Flags=WS_CHILD|BS_AUTOCHECKBOX ;
|
414
|
+
|
415
|
+
hwnd=CreateWindowEx ( 0,
|
416
|
+
"button",
|
417
|
+
text, Flags,
|
418
|
+
x,y,w,h,
|
419
|
+
Parent, NULL,
|
420
|
+
NULL/*thisinst*/, NULL ) ;
|
421
|
+
ShowWindow(hwnd,SW_SHOW);
|
422
|
+
UpdateWindow(hwnd);
|
423
|
+
return hwnd;
|
424
|
+
}
|
425
|
+
|
426
|
+
void setCheck(HWND h,int v)
|
427
|
+
{
|
428
|
+
SendMessage(h,BM_SETCHECK,v,0);
|
429
|
+
}
|
430
|
+
|
431
|
+
int getCheck(HWND h)
|
432
|
+
{
|
433
|
+
return SendMessage(h,BM_GETCHECK,0,0);
|
434
|
+
}
|
435
|
+
#ifdef PROTORABBIT
|
436
|
+
void setButton(int v)
|
437
|
+
{
|
438
|
+
setCheck(buttoncheck,v);
|
439
|
+
}
|
440
|
+
int getButton()
|
441
|
+
{
|
442
|
+
return getCheck(buttoncheck);
|
443
|
+
}
|
444
|
+
#endif
|
445
|
+
|
446
|
+
#ifdef PROTODAL
|
447
|
+
void setButton(int v)
|
448
|
+
{
|
449
|
+
setCheck(buttoncheck,v);
|
450
|
+
}
|
451
|
+
int getButton()
|
452
|
+
{
|
453
|
+
return getCheck(buttoncheck);
|
454
|
+
}
|
455
|
+
#endif
|
456
|
+
|
457
|
+
LRESULT CALLBACK WindowProc( HWND hwnd, unsigned msg,
|
458
|
+
UINT wParam, LONG lParam )
|
459
|
+
{
|
460
|
+
int d,v,k,last;
|
461
|
+
|
462
|
+
switch( msg )
|
463
|
+
{
|
464
|
+
|
465
|
+
case WM_DESTROY:
|
466
|
+
exit(0);//PostQuitMessage(0);
|
467
|
+
break;
|
468
|
+
case WM_PAINT:
|
469
|
+
winrepaint();
|
470
|
+
break;
|
471
|
+
case WM_MOUSEMOVE :
|
472
|
+
d=LOWORD(lParam)-lastmovex;
|
473
|
+
movesimu+=(d>0)?d:-d;
|
474
|
+
d=HIWORD(lParam)-lastmovey;
|
475
|
+
movesimu+=(d>0)?d:-d;
|
476
|
+
lastmovex=LOWORD(lParam);
|
477
|
+
lastmovey=HIWORD(lParam);
|
478
|
+
if (rclicsimu)
|
479
|
+
{
|
480
|
+
xclicsimu=LOWORD(lParam)*1000/width;
|
481
|
+
yclicsimu=HIWORD(lParam)*1000/height;
|
482
|
+
d=-1;
|
483
|
+
if ((yclicsimu>=250)&&(yclicsimu<750))
|
484
|
+
{
|
485
|
+
if (xclicsimu<150)
|
486
|
+
{
|
487
|
+
d=0;
|
488
|
+
}
|
489
|
+
if (xclicsimu>850)
|
490
|
+
{
|
491
|
+
d=1;
|
492
|
+
}
|
493
|
+
}
|
494
|
+
if (d>=0)
|
495
|
+
{
|
496
|
+
v=MAXMOTORVAL*(yclicsimu-250)/500;
|
497
|
+
if (v<motorval[d])
|
498
|
+
for(k=motorval[d]; k>v; k--)
|
499
|
+
{
|
500
|
+
last=motorwheel[motorval[d]];
|
501
|
+
motorval[d]--;
|
502
|
+
if (last<motorwheel[motorval[d]])
|
503
|
+
{
|
504
|
+
motorcount[d]++;
|
505
|
+
}
|
506
|
+
}
|
507
|
+
else
|
508
|
+
for(k=motorval[d]; k<v; k++)
|
509
|
+
{
|
510
|
+
last=motorwheel[motorval[d]];
|
511
|
+
motorval[d]++;
|
512
|
+
if (last<motorwheel[motorval[d]])
|
513
|
+
{
|
514
|
+
motorcount[d]++;
|
515
|
+
}
|
516
|
+
}
|
517
|
+
// printf("move ear %d - %d\n",motorval[d],motorcount[d]);
|
518
|
+
}
|
519
|
+
}
|
520
|
+
break;
|
521
|
+
case WM_LBUTTONDOWN :
|
522
|
+
rclicsimu=1;
|
523
|
+
xclicsimu=LOWORD(lParam)*1000/width;
|
524
|
+
yclicsimu=HIWORD(lParam)*1000/height;
|
525
|
+
if ((xclicsimu>150)&&(xclicsimu<850))
|
526
|
+
{
|
527
|
+
setButton(1);
|
528
|
+
}
|
529
|
+
break;
|
530
|
+
case WM_LBUTTONUP :
|
531
|
+
rclicsimu=0;
|
532
|
+
setButton(0);
|
533
|
+
xclicsimu=-1;
|
534
|
+
yclicsimu=-1;
|
535
|
+
break;
|
536
|
+
case MM_WOM_DONE:
|
537
|
+
audioEventPlayData(msg,wParam,lParam);
|
538
|
+
break;
|
539
|
+
case MM_WIM_DATA:
|
540
|
+
audioEventRecData(msg,wParam,lParam);
|
541
|
+
break;
|
542
|
+
case UDPEVENT:
|
543
|
+
udpevent(msg,wParam,lParam);
|
544
|
+
break;
|
545
|
+
case TCPEVENT:
|
546
|
+
tcpevent(msg,wParam,lParam);
|
547
|
+
break;
|
548
|
+
|
549
|
+
default:
|
550
|
+
return( DefWindowProc( hwnd, msg, wParam, lParam ) );
|
551
|
+
}
|
552
|
+
|
553
|
+
return 0;
|
554
|
+
}
|
555
|
+
|
556
|
+
|
557
|
+
int initWindow()
|
558
|
+
{
|
559
|
+
char buf[256];
|
560
|
+
|
561
|
+
RECT r;
|
562
|
+
r.bottom=height+SUPP_HIGH;
|
563
|
+
r.right=width;
|
564
|
+
r.left=0;
|
565
|
+
r.top=0;
|
566
|
+
|
567
|
+
AdjustWindowRect(&r,FlagMainWindow,FALSE);
|
568
|
+
|
569
|
+
mainwin = CreateWindow("GenericClass",TEXT("Vlisp - "VLISP_HARDWARE), FlagMainWindow,
|
570
|
+
600,0,r.right-r.left,r.bottom-r.top,
|
571
|
+
NULL,NULL,NULL,NULL);
|
572
|
+
|
573
|
+
if (!mainwin)
|
574
|
+
{
|
575
|
+
wsprintf(buf,TEXT("%d"),GetLastError());
|
576
|
+
MessageBox(NULL,TEXT("window error"),buf,MB_OK);
|
577
|
+
return -1;
|
578
|
+
}
|
579
|
+
|
580
|
+
ShowWindow(mainwin,SW_SHOW);
|
581
|
+
UpdateWindow(mainwin);
|
582
|
+
#ifdef PROTORABBIT
|
583
|
+
crText("button=",mainwin,0,height,width/2,20);
|
584
|
+
buttoncheck=crCheck("",mainwin,width/2,height,width/2,20);
|
585
|
+
crText("b3=",mainwin,0,height+20,width/2,20);
|
586
|
+
button3=crEdit("0",mainwin,width/2,height+20,width/2,20);
|
587
|
+
crText("rfid=",mainwin,0,height+40,width/2,20);
|
588
|
+
buttonrfid=crEdit("",mainwin,width/2,height+40,width/2,20);
|
589
|
+
#endif
|
590
|
+
#ifdef PROTODAL
|
591
|
+
crText("button=",mainwin,0,height,width/2,20);
|
592
|
+
buttoncheck=crCheck("",mainwin,width/2,height,width/2,20);
|
593
|
+
#endif
|
594
|
+
return 0;
|
595
|
+
}
|
596
|
+
|
597
|
+
int initBitmap ( )
|
598
|
+
{
|
599
|
+
BITMAPINFO Bi ;
|
600
|
+
int tf ;
|
601
|
+
HDC dc ;
|
602
|
+
char buf[256];
|
603
|
+
|
604
|
+
dc = NULL ;
|
605
|
+
|
606
|
+
Bi.bmiHeader.biSize = sizeof ( BITMAPINFOHEADER ) ;
|
607
|
+
Bi.bmiHeader.biWidth = width ;
|
608
|
+
|
609
|
+
Bi.bmiHeader.biHeight = - height ;
|
610
|
+
|
611
|
+
Bi.bmiHeader.biPlanes = 1 ;
|
612
|
+
Bi.bmiHeader.biBitCount = 32 ;
|
613
|
+
Bi.bmiHeader.biCompression = BI_RGB ;
|
614
|
+
Bi.bmiHeader.biSizeImage = 0 ;
|
615
|
+
Bi.bmiHeader.biXPelsPerMeter = 0 ;
|
616
|
+
Bi.bmiHeader.biYPelsPerMeter = 0 ;
|
617
|
+
Bi.bmiHeader.biClrUsed = 0 ;
|
618
|
+
tf = DIB_RGB_COLORS ;
|
619
|
+
Bi.bmiHeader.biClrImportant = Bi.bmiHeader.biClrUsed ;
|
620
|
+
|
621
|
+
// Bi.bmiColors[0] = NULL ;
|
622
|
+
|
623
|
+
mainbmp = CreateDIBSection ( dc, (BITMAPINFO * ) & Bi, tf, & mainbmppnt, NULL, 0 ) ;
|
624
|
+
|
625
|
+
if (mainbmp == NULL )
|
626
|
+
{
|
627
|
+
wsprintf(buf,TEXT("%d"),GetLastError());
|
628
|
+
MessageBox(NULL,TEXT("bitmap error"),buf,MB_OK);
|
629
|
+
return -1;
|
630
|
+
}
|
631
|
+
|
632
|
+
GetObject ( mainbmp, sizeof( DIBSECTION ), &mainbmpinfo ) ;
|
633
|
+
mainbmpnextline=mainbmpinfo.dsBm.bmWidthBytes ;
|
634
|
+
return 0 ;
|
635
|
+
}
|
636
|
+
|
637
|
+
static BOOL FirstInstance()
|
638
|
+
{
|
639
|
+
WNDCLASS wc;
|
640
|
+
BOOL rc;
|
641
|
+
|
642
|
+
wc.style = CS_HREDRAW | CS_VREDRAW;
|
643
|
+
wc.lpfnWndProc = (LPVOID) WindowProc;
|
644
|
+
wc.cbClsExtra = 0;
|
645
|
+
wc.cbWndExtra = 0;
|
646
|
+
wc.hInstance = NULL;
|
647
|
+
wc.hIcon = 0;
|
648
|
+
wc.hCursor = LoadCursor( NULL, IDC_ARROW );
|
649
|
+
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
|
650
|
+
wc.lpszMenuName = 0;
|
651
|
+
wc.lpszClassName = "GenericClass";
|
652
|
+
rc = RegisterClass( &wc );
|
653
|
+
|
654
|
+
return( rc );
|
655
|
+
}
|
656
|
+
|
657
|
+
// fonction d'affichage des diodes
|
658
|
+
int simuDisplay(int* intensity)
|
659
|
+
{
|
660
|
+
int i;
|
661
|
+
erasebmp();
|
662
|
+
for(i=0; i<NBLED; i++)
|
663
|
+
{
|
664
|
+
diodedraw(i,intensity[i]);
|
665
|
+
#ifdef VL_MOTORS
|
666
|
+
plot(2,(160*128)>>9,0xffffff);
|
667
|
+
plot(2,(160*(128+256))>>9,0xffffff);
|
668
|
+
plot(160-2,(160*128)>>9,0xffffff);
|
669
|
+
plot(160-2,(160*(128+256))>>9,0xffffff);
|
670
|
+
motordraw(15,motorval[0]*256/MAXMOTORVAL);
|
671
|
+
motordraw(160-15,motorval[1]*256/MAXMOTORVAL);
|
672
|
+
#endif
|
673
|
+
// VPRINT("led %d = %d\n",i,intensity[i]);
|
674
|
+
}
|
675
|
+
|
676
|
+
winupdate();
|
677
|
+
return 0;
|
678
|
+
}
|
679
|
+
|
680
|
+
|
681
|
+
// initialisation du simulateur
|
682
|
+
vsd simuInit()
|
683
|
+
{
|
684
|
+
int i;
|
685
|
+
colortabInit();
|
686
|
+
|
687
|
+
for(i=0; i<NBLED; i++)
|
688
|
+
{
|
689
|
+
diodeval[i]=255;
|
690
|
+
}
|
691
|
+
srand(GetTickCount());
|
692
|
+
#ifdef VL_MOTORS
|
693
|
+
for(i=0; i<NBMOTOR; i++)
|
694
|
+
{
|
695
|
+
motorval[i]=60;//(rand()&255)*MAXMOTORVAL/256;
|
696
|
+
motorcount[i]=motordir[i]=0;
|
697
|
+
}
|
698
|
+
for(i=0; i<256; i++)
|
699
|
+
{
|
700
|
+
motorwheel[i]=0;
|
701
|
+
}
|
702
|
+
for(i=0; i<MAXMOTORVAL; i++)
|
703
|
+
{
|
704
|
+
if ((i*2*NBHOLES/MAXMOTORVAL)&1)
|
705
|
+
{
|
706
|
+
motorwheel[i]=1;
|
707
|
+
}
|
708
|
+
if (i*NBHOLES/MAXMOTORVAL>=NBHOLES-MASKEDHOLES)
|
709
|
+
{
|
710
|
+
motorwheel[i]=1;
|
711
|
+
}
|
712
|
+
}
|
713
|
+
#endif
|
714
|
+
FirstInstance();
|
715
|
+
if (initBitmap ( ))
|
716
|
+
{
|
717
|
+
return FALSE;
|
718
|
+
}
|
719
|
+
mire();
|
720
|
+
if (initWindow())
|
721
|
+
{
|
722
|
+
return FALSE;
|
723
|
+
}
|
724
|
+
winupdate();
|
725
|
+
// setButton(1);
|
726
|
+
simuaudioinit();
|
727
|
+
simunetinit();
|
728
|
+
return 0;
|
729
|
+
}
|
730
|
+
|
731
|
+
|
732
|
+
|
733
|
+
// fonction � appeler r�guli�rement, pour traiter les messages de la fen�tre du simulateur
|
734
|
+
vsd simuDoLoop()
|
735
|
+
{
|
736
|
+
MSG msg;
|
737
|
+
#ifdef VL_MOTORS
|
738
|
+
int i,last;
|
739
|
+
#endif
|
740
|
+
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
|
741
|
+
{
|
742
|
+
TranslateMessage( &msg );
|
743
|
+
DispatchMessage( &msg );
|
744
|
+
}
|
745
|
+
|
746
|
+
#ifdef VL_MOTORS
|
747
|
+
for(i=0; i<NBMOTOR; i++)
|
748
|
+
{
|
749
|
+
last=motorwheel[motorval[i]];
|
750
|
+
if (1)
|
751
|
+
{
|
752
|
+
motorval[i]+=motordir[i];
|
753
|
+
}
|
754
|
+
if (motorval[i]<0)
|
755
|
+
{
|
756
|
+
motorval[i]+=MAXMOTORVAL;
|
757
|
+
}
|
758
|
+
if (motorval[i]>=MAXMOTORVAL)
|
759
|
+
{
|
760
|
+
motorval[i]-=MAXMOTORVAL;
|
761
|
+
}
|
762
|
+
if (last<motorwheel[motorval[i]])
|
763
|
+
{
|
764
|
+
motorcount[i]++;
|
765
|
+
}
|
766
|
+
}
|
767
|
+
#endif
|
768
|
+
simuDisplay(diodeval);
|
769
|
+
return 0;
|
770
|
+
}
|
771
|
+
|
772
|
+
// r�glagle d'une led
|
773
|
+
void simuSetLed(int i,int val)
|
774
|
+
{
|
775
|
+
i*=3;
|
776
|
+
if ((i<0)||(i>=NBLED))
|
777
|
+
{
|
778
|
+
return;
|
779
|
+
}
|
780
|
+
diodeval[i]=(val>>16)&255;
|
781
|
+
diodeval[i+1]=(val>>8)&255;
|
782
|
+
diodeval[i+2]=(val)&255;
|
783
|
+
}
|
784
|
+
|
785
|
+
#ifdef VL_MOTORS
|
786
|
+
// r�glagle d'un moteur
|
787
|
+
void set_motor_dir(int num_motor, int sens)
|
788
|
+
{
|
789
|
+
motordir[num_motor?1:0]=(sens==0)?0:((sens==1)?1:-1);
|
790
|
+
}
|
791
|
+
|
792
|
+
int get_motor_val(int i)
|
793
|
+
{
|
794
|
+
return motorcount[i?1:0];
|
795
|
+
}
|
796
|
+
#else
|
797
|
+
int get_motor_val(int i)
|
798
|
+
{
|
799
|
+
return 128;
|
800
|
+
}
|
801
|
+
#endif
|
802
|
+
|
803
|
+
int get_button3()
|
804
|
+
{
|
805
|
+
return getText(button3);
|
806
|
+
}
|
807
|
+
|
808
|
+
char buf_rfid[256];
|
809
|
+
|
810
|
+
char* get_rfid()
|
811
|
+
{
|
812
|
+
getTextStr(buttonrfid,buf_rfid);
|
813
|
+
if (strlen(buf_rfid))
|
814
|
+
{
|
815
|
+
return buf_rfid;
|
816
|
+
}
|
817
|
+
return NULL;
|
818
|
+
}
|
819
|
+
#endif
|