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
data/bytecode/src/mtl/simu.c
DELETED
@@ -1,750 +0,0 @@
|
|
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(){ return 0;}
|
46
|
-
int simuDoLoop(){ return 0;}
|
47
|
-
void simuSetLed(vub i,vub val){}
|
48
|
-
void simuSetMotor(vub i,vub val){}
|
49
|
-
|
50
|
-
#else
|
51
|
-
#include<stdio.h>
|
52
|
-
#include<stdlib.h>
|
53
|
-
#include<string.h>
|
54
|
-
#include<io.h>
|
55
|
-
#include<time.h>
|
56
|
-
|
57
|
-
#include"my_simuaudio.h"
|
58
|
-
#include"my_simunet.h"
|
59
|
-
|
60
|
-
// d�finition de l'�chelle d'affichage de la simulation
|
61
|
-
#define SCALE 2
|
62
|
-
|
63
|
-
#define NBHOLES 20
|
64
|
-
#define MASKEDHOLES 3
|
65
|
-
// MAXMOTORVAL doit �tre inf�rieur � 256
|
66
|
-
#define MAXMOTORVAL 100
|
67
|
-
|
68
|
-
int motorwheel[256];
|
69
|
-
|
70
|
-
// gestion des couleurs
|
71
|
-
// ---------------------
|
72
|
-
uchar coloradd[256*256];
|
73
|
-
uchar colormul[256*256];
|
74
|
-
|
75
|
-
#define COLORADD(x,y) (coloradd[(x)+((y)<<8)])
|
76
|
-
#define COLORMUL(x,y) (colormul[(x)+((y)<<8)])
|
77
|
-
|
78
|
-
#define RGBTOINT(r,g,b) (( (((int)r)&255)<<16)+((((int)g)&255)<<8)+(((int)b)&255))
|
79
|
-
#define INTTOR(c) ((c>>16)&255)
|
80
|
-
#define INTTOG(c) ((c>>8)&255)
|
81
|
-
#define INTTOB(c) (c&255)
|
82
|
-
|
83
|
-
// initialisation des tables de couleur
|
84
|
-
void colortabInit()
|
85
|
-
{
|
86
|
-
int i,j,k;
|
87
|
-
|
88
|
-
for(i=0;i<256;i++)
|
89
|
-
for(j=0;j<256;j++)
|
90
|
-
{
|
91
|
-
k=i+j;
|
92
|
-
coloradd[i+(j<<8)]=(k<=255)?k:255;
|
93
|
-
|
94
|
-
k=i*j/255;
|
95
|
-
colormul[i+(j<<8)]=k;
|
96
|
-
}
|
97
|
-
}
|
98
|
-
|
99
|
-
// d�finition physique des leds
|
100
|
-
|
101
|
-
int diodeval[NBLED];
|
102
|
-
#ifdef VL_MOTORS
|
103
|
-
int motorval[NBMOTOR];
|
104
|
-
int motorcount[NBMOTOR];
|
105
|
-
int motordir[NBMOTOR];
|
106
|
-
#endif
|
107
|
-
|
108
|
-
int xclicsimu=-1;
|
109
|
-
int yclicsimu=-1;
|
110
|
-
int rclicsimu=0;
|
111
|
-
int movesimu=0;
|
112
|
-
|
113
|
-
int lastmovex=0;
|
114
|
-
int lastmovey=0;
|
115
|
-
|
116
|
-
#ifdef PROTORABBIT
|
117
|
-
int diodex[NBLED]={80,80,80,40,40,40,80,80,80,120,120,120,80,80,80};
|
118
|
-
int diodey[NBLED]={40,40,40,90,90,90,90,90,90,90,90,90,130,130,130};
|
119
|
-
int diodergb[NBLED]=
|
120
|
-
{0x0000ff,0x00ff00,0xff0000,
|
121
|
-
0x0000ff,0x00ff00,0xff0000,
|
122
|
-
0x0000ff,0x00ff00,0xff0000,
|
123
|
-
0x0000ff,0x00ff00,0xff0000,
|
124
|
-
0x0000ff,0x00ff00,0xff0000
|
125
|
-
};
|
126
|
-
HWND buttoncheck;
|
127
|
-
HWND button3;
|
128
|
-
HWND buttonrfid;
|
129
|
-
#define SUPP_HIGH 60
|
130
|
-
int width=160*SCALE;
|
131
|
-
int height=160*SCALE;
|
132
|
-
#endif
|
133
|
-
|
134
|
-
#ifdef PROTODAL
|
135
|
-
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};
|
136
|
-
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};
|
137
|
-
int diodergb[NBLED]=
|
138
|
-
{0x0000ff,0x00ff00,0xff0000,
|
139
|
-
0x0000ff,0x00ff00,0xff0000,
|
140
|
-
0x0000ff,0x00ff00,0xff0000,
|
141
|
-
0x0000ff,0x00ff00,0xff0000,
|
142
|
-
0x0000ff,0x00ff00,0xff0000,
|
143
|
-
0x0000ff,0x00ff00,0xff0000,
|
144
|
-
0x0000ff,0x00ff00,0xff0000,
|
145
|
-
0x0000ff,0x00ff00,0xff0000,
|
146
|
-
0x0000ff,0x00ff00,0xff0000
|
147
|
-
};
|
148
|
-
HWND buttoncheck;
|
149
|
-
#define SUPP_HIGH 20
|
150
|
-
int width=160*SCALE;
|
151
|
-
int height=160*SCALE;
|
152
|
-
#endif
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
#define FlagMainWindow (WS_VISIBLE|WS_CAPTION)
|
157
|
-
#define V_FONT ANSI_FIXED_FONT
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
HWND mainwin;
|
162
|
-
HBITMAP mainbmp;
|
163
|
-
char * mainbmppnt ;
|
164
|
-
int mainbmpnextline ;
|
165
|
-
DIBSECTION mainbmpinfo ;
|
166
|
-
|
167
|
-
|
168
|
-
void winrepaint()
|
169
|
-
{
|
170
|
-
|
171
|
-
HDC Dcw , Dcb ;
|
172
|
-
HBITMAP OldBitmap ;
|
173
|
-
PAINTSTRUCT ps;
|
174
|
-
|
175
|
-
Dcw=BeginPaint(mainwin,&ps);
|
176
|
-
Dcb=CreateCompatibleDC(Dcw);
|
177
|
-
OldBitmap=SelectObject(Dcb,mainbmp);
|
178
|
-
BitBlt(Dcw,0,0,width,height,Dcb,0,0,SRCCOPY);
|
179
|
-
SelectObject(Dcb,OldBitmap);
|
180
|
-
DeleteDC(Dcb);
|
181
|
-
|
182
|
-
EndPaint(mainwin,&ps);
|
183
|
-
}
|
184
|
-
|
185
|
-
void winupdate()
|
186
|
-
{
|
187
|
-
InvalidateRect(mainwin,NULL,FALSE);
|
188
|
-
UpdateWindow(mainwin);
|
189
|
-
}
|
190
|
-
|
191
|
-
void mire()
|
192
|
-
{
|
193
|
-
int i,j;
|
194
|
-
char *pnt,*pnt0;
|
195
|
-
int next;
|
196
|
-
int increment=4;
|
197
|
-
|
198
|
-
pnt0=mainbmppnt;
|
199
|
-
next=mainbmpnextline;
|
200
|
-
|
201
|
-
for(i=0;i<height;i++)
|
202
|
-
{
|
203
|
-
pnt=pnt0;
|
204
|
-
for(j=0;j<width;j++)
|
205
|
-
{
|
206
|
-
pnt[0]=i&255;
|
207
|
-
pnt[1]=j&255;
|
208
|
-
pnt[2]=(i+j)&255;
|
209
|
-
pnt+=increment;
|
210
|
-
}
|
211
|
-
pnt0+=next;
|
212
|
-
}
|
213
|
-
}
|
214
|
-
|
215
|
-
void erasebmp()
|
216
|
-
{
|
217
|
-
int i;
|
218
|
-
char *pnt;
|
219
|
-
int next;
|
220
|
-
int increment=4;
|
221
|
-
|
222
|
-
pnt=mainbmppnt;
|
223
|
-
next=mainbmpnextline;
|
224
|
-
|
225
|
-
for(i=0;i<height;i++)
|
226
|
-
{
|
227
|
-
memset(pnt,0,increment*width);
|
228
|
-
pnt+=next;
|
229
|
-
}
|
230
|
-
}
|
231
|
-
|
232
|
-
#define DIODELEN (20*SCALE)
|
233
|
-
|
234
|
-
void plot(int x,int y,int rgb)
|
235
|
-
{
|
236
|
-
int r,g,b;
|
237
|
-
uchar *pnt;
|
238
|
-
int next;
|
239
|
-
int increment=4;
|
240
|
-
x*=SCALE;
|
241
|
-
y*=SCALE;
|
242
|
-
r=INTTOR(rgb);
|
243
|
-
g=INTTOG(rgb);
|
244
|
-
b=INTTOB(rgb);
|
245
|
-
if ((x<0)||(y<0)||(x>=width)||(y>=height)) return;
|
246
|
-
pnt=mainbmppnt;
|
247
|
-
next=mainbmpnextline;
|
248
|
-
pnt+=y*mainbmpnextline+x*increment;
|
249
|
-
pnt[0]=r;
|
250
|
-
pnt[1]=g;
|
251
|
-
pnt[2]=b;
|
252
|
-
}
|
253
|
-
|
254
|
-
void diodedraw(int num,int val)
|
255
|
-
{
|
256
|
-
int i,j,x,y,r,g,b,rgb;
|
257
|
-
uchar *pnt,*pnt0;
|
258
|
-
int next;
|
259
|
-
int increment=4;
|
260
|
-
|
261
|
-
if ((num<0)||(num>=NBLED)) return;
|
262
|
-
x=diodex[num]*SCALE-DIODELEN/2;
|
263
|
-
y=diodey[num]*SCALE-DIODELEN/2;
|
264
|
-
rgb=diodergb[num];
|
265
|
-
r=COLORMUL(INTTOR(rgb),(uchar)val);
|
266
|
-
g=COLORMUL(INTTOG(rgb),(uchar)val);
|
267
|
-
b=COLORMUL(INTTOB(rgb),(uchar)val);
|
268
|
-
|
269
|
-
if ((x<0)||(y<0)||(x+DIODELEN>width)||(y+DIODELEN>height)) return;
|
270
|
-
|
271
|
-
pnt0=mainbmppnt;
|
272
|
-
next=mainbmpnextline;
|
273
|
-
pnt0+=y*mainbmpnextline+x*increment;
|
274
|
-
|
275
|
-
for(i=0;i<DIODELEN;i++)
|
276
|
-
{
|
277
|
-
pnt=pnt0;
|
278
|
-
for(j=0;j<DIODELEN;j++)
|
279
|
-
{
|
280
|
-
pnt[0]=COLORADD(r,pnt[0]);
|
281
|
-
pnt[1]=COLORADD(g,pnt[1]);
|
282
|
-
pnt[2]=COLORADD(b,pnt[2]);
|
283
|
-
pnt+=increment;
|
284
|
-
}
|
285
|
-
pnt0+=next;
|
286
|
-
}
|
287
|
-
}
|
288
|
-
|
289
|
-
#define MOTORLEN (20*SCALE)
|
290
|
-
|
291
|
-
void motordraw(int x0,int val)
|
292
|
-
{
|
293
|
-
int i,j,x,y,r,g,b,rgb;
|
294
|
-
uchar *pnt,*pnt0;
|
295
|
-
int next;
|
296
|
-
int increment=4;
|
297
|
-
|
298
|
-
x=x0*SCALE-MOTORLEN/2;
|
299
|
-
y=(height*(val+128)>>9)-MOTORLEN/2;
|
300
|
-
rgb=0xc0c0c0;
|
301
|
-
r=INTTOR(rgb);
|
302
|
-
g=INTTOG(rgb);
|
303
|
-
b=INTTOB(rgb);
|
304
|
-
|
305
|
-
if ((x<0)||(y<0)||(x+MOTORLEN>width)||(y+MOTORLEN>height)) return;
|
306
|
-
|
307
|
-
pnt0=mainbmppnt;
|
308
|
-
next=mainbmpnextline;
|
309
|
-
pnt0+=y*mainbmpnextline+x*increment;
|
310
|
-
|
311
|
-
for(i=0;i<MOTORLEN;i++)
|
312
|
-
{
|
313
|
-
pnt=pnt0;
|
314
|
-
for(j=0;j<MOTORLEN;j++)
|
315
|
-
{
|
316
|
-
if (!((j+i+1)&3))
|
317
|
-
{
|
318
|
-
pnt[0]=COLORADD(r,pnt[0]);
|
319
|
-
pnt[1]=COLORADD(g,pnt[1]);
|
320
|
-
pnt[2]=COLORADD(b,pnt[2]);
|
321
|
-
}
|
322
|
-
pnt+=increment;
|
323
|
-
}
|
324
|
-
pnt0+=next;
|
325
|
-
}
|
326
|
-
}
|
327
|
-
|
328
|
-
HWND crText (char *text,HWND Parent,int x, int y, int w,int h)
|
329
|
-
{
|
330
|
-
HWND hwnd;
|
331
|
-
int Flags=ES_READONLY|WS_CHILD | ES_RIGHT ;
|
332
|
-
|
333
|
-
hwnd=CreateWindowEx ( 0 ,
|
334
|
-
"Edit" ,
|
335
|
-
text , Flags ,
|
336
|
-
x,y,w,h,
|
337
|
-
Parent , NULL ,
|
338
|
-
NULL/*thisinst*/ , NULL ) ;
|
339
|
-
SendMessage(hwnd,WM_SETFONT,(WPARAM)GetStockFont(V_FONT),(LPARAM)TRUE);
|
340
|
-
|
341
|
-
ShowWindow(hwnd,SW_SHOW);
|
342
|
-
UpdateWindow(hwnd);
|
343
|
-
return hwnd;
|
344
|
-
}
|
345
|
-
|
346
|
-
HWND crEdit (char *text,HWND Parent,int x, int y, int w,int h)
|
347
|
-
{
|
348
|
-
HWND hwnd;
|
349
|
-
int Flags=WS_CHILD ;
|
350
|
-
|
351
|
-
hwnd=CreateWindowEx ( WS_EX_CLIENTEDGE ,
|
352
|
-
"Edit" ,
|
353
|
-
text , Flags ,
|
354
|
-
x,y,w,h,
|
355
|
-
Parent , NULL ,
|
356
|
-
NULL/*thisinst*/ , NULL ) ;
|
357
|
-
SendMessage(hwnd,WM_SETFONT,(WPARAM)GetStockFont(V_FONT),(LPARAM)TRUE);
|
358
|
-
ShowWindow(hwnd,SW_SHOW);
|
359
|
-
UpdateWindow(hwnd);
|
360
|
-
return hwnd;
|
361
|
-
}
|
362
|
-
|
363
|
-
void setText(HWND h,int v)
|
364
|
-
{
|
365
|
-
char buf[32];
|
366
|
-
sprintf(buf,"%d",v);
|
367
|
-
SetWindowText(h,buf);
|
368
|
-
}
|
369
|
-
|
370
|
-
char* getTextStr(HWND h,char *buf)
|
371
|
-
{
|
372
|
-
int s;
|
373
|
-
*(int*)buf=255;
|
374
|
-
s=SendMessage(h,EM_GETLINE,0,(LPARAM)buf);
|
375
|
-
buf[s]=0;
|
376
|
-
return buf;
|
377
|
-
}
|
378
|
-
|
379
|
-
int getText(HWND h)
|
380
|
-
{
|
381
|
-
char buf[256];
|
382
|
-
int s;
|
383
|
-
*(int*)buf=255;
|
384
|
-
s=SendMessage(h,EM_GETLINE,0,(LPARAM)buf);
|
385
|
-
buf[s]=0;
|
386
|
-
return atoi(buf);
|
387
|
-
}
|
388
|
-
|
389
|
-
|
390
|
-
HWND crCheck (char *text,HWND Parent,int x, int y, int w,int h)
|
391
|
-
{
|
392
|
-
HWND hwnd;
|
393
|
-
int Flags=WS_CHILD|BS_AUTOCHECKBOX ;
|
394
|
-
|
395
|
-
hwnd=CreateWindowEx ( 0 ,
|
396
|
-
"button" ,
|
397
|
-
text , Flags ,
|
398
|
-
x,y,w,h,
|
399
|
-
Parent , NULL ,
|
400
|
-
NULL/*thisinst*/ , NULL ) ;
|
401
|
-
ShowWindow(hwnd,SW_SHOW);
|
402
|
-
UpdateWindow(hwnd);
|
403
|
-
return hwnd;
|
404
|
-
}
|
405
|
-
|
406
|
-
void setCheck(HWND h,int v)
|
407
|
-
{
|
408
|
-
SendMessage(h,BM_SETCHECK,v,0);
|
409
|
-
}
|
410
|
-
|
411
|
-
int getCheck(HWND h)
|
412
|
-
{
|
413
|
-
return SendMessage(h,BM_GETCHECK,0,0);
|
414
|
-
}
|
415
|
-
#ifdef PROTORABBIT
|
416
|
-
void setButton(int v)
|
417
|
-
{
|
418
|
-
setCheck(buttoncheck,v);
|
419
|
-
}
|
420
|
-
int getButton()
|
421
|
-
{
|
422
|
-
return getCheck(buttoncheck);
|
423
|
-
}
|
424
|
-
#endif
|
425
|
-
|
426
|
-
#ifdef PROTODAL
|
427
|
-
void setButton(int v)
|
428
|
-
{
|
429
|
-
setCheck(buttoncheck,v);
|
430
|
-
}
|
431
|
-
int getButton()
|
432
|
-
{
|
433
|
-
return getCheck(buttoncheck);
|
434
|
-
}
|
435
|
-
#endif
|
436
|
-
|
437
|
-
LRESULT CALLBACK WindowProc( HWND hwnd, unsigned msg,
|
438
|
-
UINT wParam, LONG lParam )
|
439
|
-
{
|
440
|
-
int d,v,k,last;
|
441
|
-
|
442
|
-
switch( msg ) {
|
443
|
-
|
444
|
-
case WM_DESTROY:
|
445
|
-
exit(0);//PostQuitMessage(0);
|
446
|
-
break;
|
447
|
-
case WM_PAINT:
|
448
|
-
winrepaint();
|
449
|
-
break;
|
450
|
-
case WM_MOUSEMOVE :
|
451
|
-
d=LOWORD(lParam)-lastmovex;
|
452
|
-
movesimu+=(d>0)?d:-d;
|
453
|
-
d=HIWORD(lParam)-lastmovey;
|
454
|
-
movesimu+=(d>0)?d:-d;
|
455
|
-
lastmovex=LOWORD(lParam);
|
456
|
-
lastmovey=HIWORD(lParam);
|
457
|
-
if (rclicsimu)
|
458
|
-
{
|
459
|
-
xclicsimu=LOWORD(lParam)*1000/width;
|
460
|
-
yclicsimu=HIWORD(lParam)*1000/height;
|
461
|
-
d=-1;
|
462
|
-
if ((yclicsimu>=250)&&(yclicsimu<750))
|
463
|
-
{
|
464
|
-
if (xclicsimu<150) d=0;
|
465
|
-
if (xclicsimu>850) d=1;
|
466
|
-
}
|
467
|
-
if (d>=0)
|
468
|
-
{
|
469
|
-
v=MAXMOTORVAL*(yclicsimu-250)/500;
|
470
|
-
if (v<motorval[d])
|
471
|
-
for(k=motorval[d];k>v;k--)
|
472
|
-
{
|
473
|
-
last=motorwheel[motorval[d]];
|
474
|
-
motorval[d]--;
|
475
|
-
if (last<motorwheel[motorval[d]]) motorcount[d]++;
|
476
|
-
}
|
477
|
-
else
|
478
|
-
for(k=motorval[d];k<v;k++)
|
479
|
-
{
|
480
|
-
last=motorwheel[motorval[d]];
|
481
|
-
motorval[d]++;
|
482
|
-
if (last<motorwheel[motorval[d]]) motorcount[d]++;
|
483
|
-
}
|
484
|
-
// printf("move ear %d - %d\n",motorval[d],motorcount[d]);
|
485
|
-
}
|
486
|
-
}
|
487
|
-
break;
|
488
|
-
case WM_LBUTTONDOWN :
|
489
|
-
rclicsimu=1;
|
490
|
-
xclicsimu=LOWORD(lParam)*1000/width;
|
491
|
-
yclicsimu=HIWORD(lParam)*1000/height;
|
492
|
-
if ((xclicsimu>150)&&(xclicsimu<850))
|
493
|
-
{
|
494
|
-
setButton(1);
|
495
|
-
}
|
496
|
-
break;
|
497
|
-
case WM_LBUTTONUP :
|
498
|
-
rclicsimu=0;
|
499
|
-
setButton(0);
|
500
|
-
xclicsimu=-1;
|
501
|
-
yclicsimu=-1;
|
502
|
-
break;
|
503
|
-
case MM_WOM_DONE:
|
504
|
-
audioEventPlayData(msg,wParam,lParam);
|
505
|
-
break;
|
506
|
-
case MM_WIM_DATA:
|
507
|
-
audioEventRecData(msg,wParam,lParam);
|
508
|
-
break;
|
509
|
-
case UDPEVENT:
|
510
|
-
udpevent(msg,wParam,lParam);
|
511
|
-
break;
|
512
|
-
case TCPEVENT:
|
513
|
-
tcpevent(msg,wParam,lParam);
|
514
|
-
break;
|
515
|
-
|
516
|
-
default:
|
517
|
-
return( DefWindowProc( hwnd, msg, wParam, lParam ) );
|
518
|
-
}
|
519
|
-
|
520
|
-
return 0;
|
521
|
-
}
|
522
|
-
|
523
|
-
|
524
|
-
int initWindow()
|
525
|
-
{
|
526
|
-
char buf[256];
|
527
|
-
|
528
|
-
RECT r;
|
529
|
-
r.bottom=height+SUPP_HIGH;
|
530
|
-
r.right=width;
|
531
|
-
r.left=0;
|
532
|
-
r.top=0;
|
533
|
-
|
534
|
-
AdjustWindowRect(&r,FlagMainWindow,FALSE);
|
535
|
-
|
536
|
-
mainwin = CreateWindow("GenericClass",TEXT("Vlisp - "VLISP_HARDWARE), FlagMainWindow,
|
537
|
-
600,0,r.right-r.left,r.bottom-r.top,
|
538
|
-
NULL,NULL,NULL,NULL);
|
539
|
-
|
540
|
-
if (!mainwin)
|
541
|
-
{
|
542
|
-
wsprintf(buf,TEXT("%d"),GetLastError());
|
543
|
-
MessageBox(NULL,TEXT("window error"),buf,MB_OK);
|
544
|
-
return -1;
|
545
|
-
}
|
546
|
-
|
547
|
-
ShowWindow(mainwin,SW_SHOW);
|
548
|
-
UpdateWindow(mainwin);
|
549
|
-
#ifdef PROTORABBIT
|
550
|
-
crText("button=",mainwin,0,height,width/2,20);
|
551
|
-
buttoncheck=crCheck("",mainwin,width/2,height,width/2,20);
|
552
|
-
crText("b3=",mainwin,0,height+20,width/2,20);
|
553
|
-
button3=crEdit("0",mainwin,width/2,height+20,width/2,20);
|
554
|
-
crText("rfid=",mainwin,0,height+40,width/2,20);
|
555
|
-
buttonrfid=crEdit("",mainwin,width/2,height+40,width/2,20);
|
556
|
-
#endif
|
557
|
-
#ifdef PROTODAL
|
558
|
-
crText("button=",mainwin,0,height,width/2,20);
|
559
|
-
buttoncheck=crCheck("",mainwin,width/2,height,width/2,20);
|
560
|
-
#endif
|
561
|
-
return 0;
|
562
|
-
}
|
563
|
-
|
564
|
-
int initBitmap ( )
|
565
|
-
{
|
566
|
-
BITMAPINFO Bi ;
|
567
|
-
int tf ;
|
568
|
-
HDC dc ;
|
569
|
-
char buf[256];
|
570
|
-
|
571
|
-
dc = NULL ;
|
572
|
-
|
573
|
-
Bi.bmiHeader.biSize = sizeof ( BITMAPINFOHEADER ) ;
|
574
|
-
Bi.bmiHeader.biWidth = width ;
|
575
|
-
|
576
|
-
Bi.bmiHeader.biHeight = - height ;
|
577
|
-
|
578
|
-
Bi.bmiHeader.biPlanes = 1 ;
|
579
|
-
Bi.bmiHeader.biBitCount = 32 ;
|
580
|
-
Bi.bmiHeader.biCompression = BI_RGB ;
|
581
|
-
Bi.bmiHeader.biSizeImage = 0 ;
|
582
|
-
Bi.bmiHeader.biXPelsPerMeter = 0 ;
|
583
|
-
Bi.bmiHeader.biYPelsPerMeter = 0 ;
|
584
|
-
Bi.bmiHeader.biClrUsed = 0 ;
|
585
|
-
tf = DIB_RGB_COLORS ;
|
586
|
-
Bi.bmiHeader.biClrImportant = Bi.bmiHeader.biClrUsed ;
|
587
|
-
|
588
|
-
// Bi.bmiColors[0] = NULL ;
|
589
|
-
|
590
|
-
mainbmp = CreateDIBSection ( dc , (BITMAPINFO * ) & Bi , tf , & mainbmppnt , NULL , 0 ) ;
|
591
|
-
|
592
|
-
if (mainbmp == NULL )
|
593
|
-
{
|
594
|
-
wsprintf(buf,TEXT("%d"),GetLastError());
|
595
|
-
MessageBox(NULL,TEXT("bitmap error"),buf,MB_OK);
|
596
|
-
return -1;
|
597
|
-
}
|
598
|
-
|
599
|
-
GetObject ( mainbmp , sizeof( DIBSECTION ) , &mainbmpinfo ) ;
|
600
|
-
mainbmpnextline=mainbmpinfo.dsBm.bmWidthBytes ;
|
601
|
-
return 0 ;
|
602
|
-
}
|
603
|
-
|
604
|
-
static BOOL FirstInstance()
|
605
|
-
{
|
606
|
-
WNDCLASS wc;
|
607
|
-
BOOL rc;
|
608
|
-
|
609
|
-
wc.style = CS_HREDRAW | CS_VREDRAW;
|
610
|
-
wc.lpfnWndProc = (LPVOID) WindowProc;
|
611
|
-
wc.cbClsExtra = 0;
|
612
|
-
wc.cbWndExtra = 0;
|
613
|
-
wc.hInstance = NULL;
|
614
|
-
wc.hIcon = 0;
|
615
|
-
wc.hCursor = LoadCursor( NULL, IDC_ARROW );
|
616
|
-
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
|
617
|
-
wc.lpszMenuName = 0;
|
618
|
-
wc.lpszClassName = "GenericClass";
|
619
|
-
rc = RegisterClass( &wc );
|
620
|
-
|
621
|
-
return( rc );
|
622
|
-
}
|
623
|
-
|
624
|
-
// fonction d'affichage des diodes
|
625
|
-
int simuDisplay(int* intensity)
|
626
|
-
{
|
627
|
-
int i;
|
628
|
-
erasebmp();
|
629
|
-
for(i=0;i<NBLED;i++)
|
630
|
-
{
|
631
|
-
diodedraw(i,intensity[i]);
|
632
|
-
#ifdef VL_MOTORS
|
633
|
-
plot(2,(160*128)>>9,0xffffff);
|
634
|
-
plot(2,(160*(128+256))>>9,0xffffff);
|
635
|
-
plot(160-2,(160*128)>>9,0xffffff);
|
636
|
-
plot(160-2,(160*(128+256))>>9,0xffffff);
|
637
|
-
motordraw(15,motorval[0]*256/MAXMOTORVAL);
|
638
|
-
motordraw(160-15,motorval[1]*256/MAXMOTORVAL);
|
639
|
-
#endif
|
640
|
-
// VPRINT("led %d = %d\n",i,intensity[i]);
|
641
|
-
}
|
642
|
-
|
643
|
-
winupdate();
|
644
|
-
return 0;
|
645
|
-
}
|
646
|
-
|
647
|
-
|
648
|
-
// initialisation du simulateur
|
649
|
-
vsd simuInit()
|
650
|
-
{
|
651
|
-
int i;
|
652
|
-
colortabInit();
|
653
|
-
|
654
|
-
for(i=0;i<NBLED;i++) diodeval[i]=255;
|
655
|
-
srand(GetTickCount());
|
656
|
-
#ifdef VL_MOTORS
|
657
|
-
for(i=0;i<NBMOTOR;i++)
|
658
|
-
{
|
659
|
-
motorval[i]=60;//(rand()&255)*MAXMOTORVAL/256;
|
660
|
-
motorcount[i]=motordir[i]=0;
|
661
|
-
}
|
662
|
-
for(i=0;i<256;i++) motorwheel[i]=0;
|
663
|
-
for(i=0;i<MAXMOTORVAL;i++)
|
664
|
-
{
|
665
|
-
if ((i*2*NBHOLES/MAXMOTORVAL)&1) motorwheel[i]=1;
|
666
|
-
if (i*NBHOLES/MAXMOTORVAL>=NBHOLES-MASKEDHOLES) motorwheel[i]=1;
|
667
|
-
}
|
668
|
-
#endif
|
669
|
-
FirstInstance();
|
670
|
-
if (initBitmap ( )) return FALSE;
|
671
|
-
mire();
|
672
|
-
if (initWindow()) return FALSE;
|
673
|
-
winupdate();
|
674
|
-
// setButton(1);
|
675
|
-
simuaudioinit();
|
676
|
-
simunetinit();
|
677
|
-
return 0;
|
678
|
-
}
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
// fonction � appeler r�guli�rement, pour traiter les messages de la fen�tre du simulateur
|
683
|
-
vsd simuDoLoop()
|
684
|
-
{
|
685
|
-
MSG msg;
|
686
|
-
#ifdef VL_MOTORS
|
687
|
-
int i,last;
|
688
|
-
#endif
|
689
|
-
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
|
690
|
-
{
|
691
|
-
TranslateMessage( &msg );
|
692
|
-
DispatchMessage( &msg );
|
693
|
-
}
|
694
|
-
|
695
|
-
#ifdef VL_MOTORS
|
696
|
-
for(i=0;i<NBMOTOR;i++)
|
697
|
-
{
|
698
|
-
last=motorwheel[motorval[i]];
|
699
|
-
if (1) motorval[i]+=motordir[i];
|
700
|
-
if (motorval[i]<0) motorval[i]+=MAXMOTORVAL;
|
701
|
-
if (motorval[i]>=MAXMOTORVAL) motorval[i]-=MAXMOTORVAL;
|
702
|
-
if (last<motorwheel[motorval[i]]) motorcount[i]++;
|
703
|
-
}
|
704
|
-
#endif
|
705
|
-
simuDisplay(diodeval);
|
706
|
-
return 0;
|
707
|
-
}
|
708
|
-
|
709
|
-
// r�glagle d'une led
|
710
|
-
void simuSetLed(int i,int val)
|
711
|
-
{
|
712
|
-
i*=3;
|
713
|
-
if ((i<0)||(i>=NBLED)) return;
|
714
|
-
diodeval[i]=(val>>16)&255;
|
715
|
-
diodeval[i+1]=(val>>8)&255;
|
716
|
-
diodeval[i+2]=(val)&255;
|
717
|
-
}
|
718
|
-
|
719
|
-
#ifdef VL_MOTORS
|
720
|
-
// r�glagle d'un moteur
|
721
|
-
void set_motor_dir(int num_motor, int sens)
|
722
|
-
{
|
723
|
-
motordir[num_motor?1:0]=(sens==0)?0:((sens==1)?1:-1);
|
724
|
-
}
|
725
|
-
|
726
|
-
int get_motor_val(int i)
|
727
|
-
{
|
728
|
-
return motorcount[i?1:0];
|
729
|
-
}
|
730
|
-
#else
|
731
|
-
int get_motor_val(int i)
|
732
|
-
{
|
733
|
-
return 128;
|
734
|
-
}
|
735
|
-
#endif
|
736
|
-
|
737
|
-
int get_button3()
|
738
|
-
{
|
739
|
-
return getText(button3);
|
740
|
-
}
|
741
|
-
|
742
|
-
char buf_rfid[256];
|
743
|
-
|
744
|
-
char* get_rfid()
|
745
|
-
{
|
746
|
-
getTextStr(buttonrfid,buf_rfid);
|
747
|
-
if (strlen(buf_rfid)) return buf_rfid;
|
748
|
-
return NULL;
|
749
|
-
}
|
750
|
-
#endif
|