nabaztag_hack_kit 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +7 -0
- data/.travis.yml +3 -0
- data/CHANGELOG.md +11 -0
- data/Gemfile +4 -0
- data/README.md +119 -0
- data/Rakefile +21 -0
- data/bin/mtl_comp +41 -0
- data/bin/mtl_merge +22 -0
- data/bin/mtl_simu +40 -0
- data/bytecode/lib/buffer.mtl +109 -0
- data/bytecode/lib/button.mtl +27 -0
- data/bytecode/lib/data_helper.mtl +88 -0
- data/bytecode/lib/ear.mtl +90 -0
- data/bytecode/lib/led.mtl +33 -0
- data/bytecode/lib/rfid.mtl +50 -0
- data/bytecode/main.mtl +129 -0
- data/config.ru +6 -0
- data/ext/bytecode/Commands.md +172 -0
- data/ext/bytecode/Docs.md +488 -0
- data/ext/bytecode/README.md +5 -0
- data/ext/bytecode/lib/arp.mtl +159 -0
- data/ext/bytecode/lib/cfg.mtl +74 -0
- data/ext/bytecode/lib/choreos.mtl +1487 -0
- data/ext/bytecode/lib/dhcp.mtl +152 -0
- data/ext/bytecode/lib/dns.mtl +89 -0
- data/ext/bytecode/lib/http.mtl +84 -0
- data/ext/bytecode/lib/tcp.mtl +340 -0
- data/ext/bytecode/lib/udp.mtl +49 -0
- data/ext/bytecode/lib/util.mtl +74 -0
- data/ext/bytecode/lib/var.mtl +15 -0
- data/ext/bytecode/lib/wifi.mtl +243 -0
- data/ext/bytecode/nominal-ping.mtl +5828 -0
- data/ext/mtl/Makefile +42 -0
- data/ext/mtl/README.md +13 -0
- data/ext/mtl/bc.cpp +1891 -0
- data/ext/mtl/conf.bin.sans_password +0 -0
- data/ext/mtl/config.txt +5 -0
- data/ext/mtl/dumpbc.c +2566 -0
- data/ext/mtl/extconf.rb +1 -0
- data/ext/mtl/linux_simu.c +271 -0
- data/ext/mtl/linux_simuaudio.c +16 -0
- data/ext/mtl/linux_simuaudio.h +18 -0
- data/ext/mtl/linux_simunet.c +620 -0
- data/ext/mtl/linux_simunet.h +7 -0
- data/ext/mtl/log.c +297 -0
- data/ext/mtl/log.h +20 -0
- data/ext/mtl/main_compiler.cpp +104 -0
- data/ext/mtl/main_simu.cpp +221 -0
- data/ext/mtl/mp3/GTKANAL.H +97 -0
- data/ext/mtl/mp3/LAYER3.C +2090 -0
- data/ext/mtl/mp3/TABINIT.C +82 -0
- data/ext/mtl/mp3/common.c +265 -0
- data/ext/mtl/mp3/dct64_i386.c +316 -0
- data/ext/mtl/mp3/decode_i386.c +155 -0
- data/ext/mtl/mp3/huffman.h +332 -0
- data/ext/mtl/mp3/interface.c +258 -0
- data/ext/mtl/mp3/mpg123.h +182 -0
- data/ext/mtl/mp3/mpglib.h +44 -0
- data/ext/mtl/properties.c +293 -0
- data/ext/mtl/properties.h +10 -0
- data/ext/mtl/simu.c +750 -0
- data/ext/mtl/simuaudio.c +662 -0
- data/ext/mtl/simuaudio.h +74 -0
- data/ext/mtl/simunet.c +400 -0
- data/ext/mtl/simunet.h +30 -0
- data/ext/mtl/utils/correct_const.sh +34 -0
- data/ext/mtl/vaudio.c +677 -0
- data/ext/mtl/vaudio.h +46 -0
- data/ext/mtl/vbc.h +160 -0
- data/ext/mtl/vbc_str.h +166 -0
- data/ext/mtl/vcomp/Makefile +29 -0
- data/ext/mtl/vcomp/bootstrap.cpp +89 -0
- data/ext/mtl/vcomp/compiler.cpp +470 -0
- data/ext/mtl/vcomp/compiler.h +200 -0
- data/ext/mtl/vcomp/compiler_file.cpp +929 -0
- data/ext/mtl/vcomp/compiler_prog.cpp +250 -0
- data/ext/mtl/vcomp/compiler_term.cpp +1053 -0
- data/ext/mtl/vcomp/compiler_type.cpp +872 -0
- data/ext/mtl/vcomp/compiler_var.cpp +289 -0
- data/ext/mtl/vcomp/file.cpp +79 -0
- data/ext/mtl/vcomp/file.h +39 -0
- data/ext/mtl/vcomp/filesystem.h +14 -0
- data/ext/mtl/vcomp/interpreter.cpp +85 -0
- data/ext/mtl/vcomp/interpreter.h +121 -0
- data/ext/mtl/vcomp/memory.cpp +241 -0
- data/ext/mtl/vcomp/memory.h +326 -0
- data/ext/mtl/vcomp/param.h +95 -0
- data/ext/mtl/vcomp/parser.cpp +427 -0
- data/ext/mtl/vcomp/parser.h +97 -0
- data/ext/mtl/vcomp/parser_xml.cpp +124 -0
- data/ext/mtl/vcomp/prodbuffer.cpp +125 -0
- data/ext/mtl/vcomp/prodbuffer.h +42 -0
- data/ext/mtl/vcomp/resource.h +17 -0
- data/ext/mtl/vcomp/stdlib_core.cpp +122 -0
- data/ext/mtl/vcomp/terminal.cpp +73 -0
- data/ext/mtl/vcomp/terminal.h +30 -0
- data/ext/mtl/vcomp/util.cpp +48 -0
- data/ext/mtl/vcomp/util.h +31 -0
- data/ext/mtl/vinterp.c +1349 -0
- data/ext/mtl/vinterp.h +11 -0
- data/ext/mtl/vloader.c +127 -0
- data/ext/mtl/vloader.h +31 -0
- data/ext/mtl/vlog.c +589 -0
- data/ext/mtl/vlog.h +69 -0
- data/ext/mtl/vmem.c +424 -0
- data/ext/mtl/vmem.h +107 -0
- data/ext/mtl/vnet.c +255 -0
- data/ext/mtl/vnet.h +19 -0
- data/lib/nabaztag_hack_kit/message/api.rb +39 -0
- data/lib/nabaztag_hack_kit/message/helper.rb +39 -0
- data/lib/nabaztag_hack_kit/message.rb +36 -0
- data/lib/nabaztag_hack_kit/server.rb +50 -0
- data/lib/nabaztag_hack_kit/version.rb +3 -0
- data/lib/nabaztag_hack_kit.rb +4 -0
- data/nabaztag_hack_kit.gemspec +29 -0
- data/public/bytecode.bin +0 -0
- data/test/bytecode/helper.mtl +60 -0
- data/test/bytecode/native.mtl +28 -0
- data/test/bytecode/test.mtl +221 -0
- data/test/spec_helper.rb +5 -0
- data/test/unit/message_spec.rb +56 -0
- metadata +209 -0
data/ext/mtl/vinterp.c
ADDED
@@ -0,0 +1,1349 @@
|
|
1
|
+
// VLISP Virtual Machine - 2006 - by Sylvain Huet
|
2
|
+
// Lowcost IS Powerfull
|
3
|
+
|
4
|
+
#include"vmem.h"
|
5
|
+
#include"vloader.h"
|
6
|
+
#include"vinterp.h"
|
7
|
+
#include"vlog.h"
|
8
|
+
#include"vaudio.h"
|
9
|
+
#ifdef VSIMU
|
10
|
+
#include<stdio.h>
|
11
|
+
#include<string.h>
|
12
|
+
#include"simunet.h"
|
13
|
+
#else
|
14
|
+
#include "common.h"
|
15
|
+
#endif
|
16
|
+
#include"vnet.h"
|
17
|
+
|
18
|
+
/*
|
19
|
+
#include"vbc_str.h"
|
20
|
+
|
21
|
+
void displaybc(int off,int base)
|
22
|
+
{
|
23
|
+
int v;
|
24
|
+
char *p=bytecode+off;
|
25
|
+
char* spaces=" ";
|
26
|
+
int ind=off;
|
27
|
+
int i=*p;
|
28
|
+
printf("%4d]",base);
|
29
|
+
if ((i<0)||(i>=MaxOpcode)) printf("%4d ??\n",ind);
|
30
|
+
else if ((i==OPint))
|
31
|
+
{
|
32
|
+
p++;
|
33
|
+
v=(p[0]&255)+((p[1]&255)<<8)+((p[2]&255)<<16)+((p[3]&255)<<24);
|
34
|
+
printf("%4d %s%s %d\n",ind,strbytecod[i],spaces+strlen(strbytecod[i]),v);
|
35
|
+
ind+=4;
|
36
|
+
p+=3;
|
37
|
+
}
|
38
|
+
else if ((i==OPgoto)||(i==OPelse))
|
39
|
+
{
|
40
|
+
p++;
|
41
|
+
v=(p[0]&255)+((p[1]&255)<<8);
|
42
|
+
printf("%4d %s%s %d\n",ind,strbytecod[i],spaces+strlen(strbytecod[i]),v);
|
43
|
+
ind+=2;
|
44
|
+
p+=1;
|
45
|
+
}
|
46
|
+
else if ((i==OPgetlocalb)||(i==OPgetglobalb)||(i==OPfetchb)||(i==OPdeftabb)||(i==OPsetlocalb)||
|
47
|
+
(i==OPmktabb)||(i==OPsetstructb)||(i==OPcallrb)||(i==OPintb))
|
48
|
+
{
|
49
|
+
p++;
|
50
|
+
v=p[0]&255;
|
51
|
+
printf("%4d %s%s %d\n",ind,strbytecod[i],spaces+strlen(strbytecod[i]),v);
|
52
|
+
ind++;
|
53
|
+
}
|
54
|
+
else if (i==OPret)
|
55
|
+
{
|
56
|
+
printf("%4d %s%s\n",ind,strbytecod[i],spaces+strlen(strbytecod[i]));
|
57
|
+
return;
|
58
|
+
}
|
59
|
+
else printf("%4d %s%s\n",ind,strbytecod[i],spaces+strlen(strbytecod[i]));
|
60
|
+
}
|
61
|
+
*/
|
62
|
+
|
63
|
+
// test si dernier appel ?
|
64
|
+
int TFCtest(int p,int pbase)
|
65
|
+
{
|
66
|
+
int i;
|
67
|
+
while(bytecode[p]!=OPret)
|
68
|
+
{
|
69
|
+
if (bytecode[p]==OPgoto)
|
70
|
+
{
|
71
|
+
p++;
|
72
|
+
i=(bytecode[p]&255)+((bytecode[p+1]&255)<<8);
|
73
|
+
p=pbase+i;
|
74
|
+
}
|
75
|
+
else return 0;
|
76
|
+
}
|
77
|
+
return 1;
|
78
|
+
}
|
79
|
+
|
80
|
+
|
81
|
+
int currentop=-1;
|
82
|
+
int tron=0;
|
83
|
+
|
84
|
+
// execute une fonction
|
85
|
+
// la pile doit contenir la liste d'argument, puis la fonction
|
86
|
+
// la fonction est soit un num�ro, soit un tuple [num�ro liste]
|
87
|
+
// on distingue le cas selon le fait que la valeur empil�e est un pointeur ou un entier
|
88
|
+
void interpGo()
|
89
|
+
{
|
90
|
+
int pc=-1;
|
91
|
+
int pcbase=-1;
|
92
|
+
int callstack=1;
|
93
|
+
int callstackres=1;
|
94
|
+
int op=OPexec;
|
95
|
+
int cont;
|
96
|
+
if (tron)
|
97
|
+
{
|
98
|
+
consolestr("go:");
|
99
|
+
consoleint(VSTACKGET(0));consolestr(".");
|
100
|
+
consoleint(vmem_stack);consolestr("/");
|
101
|
+
}
|
102
|
+
|
103
|
+
if (vmem_broken) return;
|
104
|
+
while(1)
|
105
|
+
{
|
106
|
+
do
|
107
|
+
{
|
108
|
+
cont=0;
|
109
|
+
currentop=op;
|
110
|
+
if (tron)
|
111
|
+
{
|
112
|
+
// displaybc(pc-1,pcbase);
|
113
|
+
/*
|
114
|
+
consoleint(pc);consolestr(":");
|
115
|
+
consoleint(op);
|
116
|
+
if (op) {consolestr(":");consoleint(255&bytecode[pc]);}
|
117
|
+
consolestr("\n");
|
118
|
+
*/
|
119
|
+
// if (bytecode[0x2450]==0) tron=0;
|
120
|
+
// dump(&bytecode[0x2440],32);
|
121
|
+
}
|
122
|
+
CLR_WDT;
|
123
|
+
switch(op)
|
124
|
+
{
|
125
|
+
case OPexec:
|
126
|
+
{
|
127
|
+
int p,npc,narg,nloc,i,fun;
|
128
|
+
p=VSTACKGET(0);
|
129
|
+
if (ISVALPNT(p))
|
130
|
+
{
|
131
|
+
p=VALTOPNT(p);
|
132
|
+
fun=VALTOINT(VFETCH(p,0));
|
133
|
+
VSTACKSET(0,VFETCH(p,1));
|
134
|
+
while(VSTACKGET(0)!=NIL)
|
135
|
+
{
|
136
|
+
VPUSH(VFETCH(VALTOPNT(VSTACKGET(0)),1));
|
137
|
+
VSTACKSET(1,VFETCH(VALTOPNT(VSTACKGET(1)),0));
|
138
|
+
}
|
139
|
+
// VPULL();
|
140
|
+
}
|
141
|
+
else fun=VALTOINT(p);
|
142
|
+
VPULL();
|
143
|
+
if (fun<0)
|
144
|
+
{
|
145
|
+
op=-fun;
|
146
|
+
cont=1;
|
147
|
+
break;
|
148
|
+
}
|
149
|
+
npc=loaderFunstart(fun);
|
150
|
+
narg=bytecode[npc];
|
151
|
+
nloc=loaderGetShort(bytecode+npc+1);
|
152
|
+
npc+=3;
|
153
|
+
|
154
|
+
if (callstack<=0)
|
155
|
+
{
|
156
|
+
if (TFCtest(pc,pcbase))
|
157
|
+
{
|
158
|
+
int ncall;
|
159
|
+
pc=VALTOINT(VCALLSTACKGET(callstackres,-3));
|
160
|
+
pcbase=VALTOINT(VCALLSTACKGET(callstackres,-2));
|
161
|
+
ncall=VALTOINT(VCALLSTACKGET(callstackres,-1));
|
162
|
+
callstackres=VALTOINT(VCALLSTACKGET(callstackres,0));
|
163
|
+
for(i=0;i<narg;i++) VCALLSTACKSET(callstack,i,VSTACKGET(narg-i-1));
|
164
|
+
vmem_stack=callstack-narg+1;
|
165
|
+
callstack=ncall;
|
166
|
+
}
|
167
|
+
}
|
168
|
+
|
169
|
+
for(i=0;i<nloc;i++)VPUSH(NIL);
|
170
|
+
VPUSH(INTTOVAL(pc));
|
171
|
+
VPUSH(INTTOVAL(pcbase));
|
172
|
+
VPUSH(INTTOVAL(callstack));
|
173
|
+
VPUSH(INTTOVAL(callstackres));
|
174
|
+
callstack=vmem_stack+3+nloc+narg;
|
175
|
+
callstackres=vmem_stack;
|
176
|
+
pcbase=pc=npc;
|
177
|
+
}
|
178
|
+
break;
|
179
|
+
case OPret:
|
180
|
+
{
|
181
|
+
int ncall;
|
182
|
+
pc=VALTOINT(VSTACKGET(4));
|
183
|
+
pcbase=VALTOINT(VSTACKGET(3));
|
184
|
+
ncall=VALTOINT(VSTACKGET(2));
|
185
|
+
callstackres=VALTOINT(VSTACKGET(1));
|
186
|
+
VCALLSTACKSET(callstack,0,VSTACKGET(0)); // recopie le r�sultat
|
187
|
+
vmem_stack=callstack;
|
188
|
+
callstack=ncall;
|
189
|
+
}
|
190
|
+
break;
|
191
|
+
case OPintb:
|
192
|
+
VPUSH(INTTOVAL(255&bytecode[pc++]));
|
193
|
+
// if (VSTACKGET(0)==INTTOVAL(0xd5)) tron=1;
|
194
|
+
break;
|
195
|
+
case OPint:
|
196
|
+
VPUSH(INTTOVAL(loaderGetInt(&bytecode[pc])));
|
197
|
+
pc+=4;
|
198
|
+
break;
|
199
|
+
case OPnil:
|
200
|
+
VPUSH(NIL);
|
201
|
+
break;
|
202
|
+
case OPdrop:
|
203
|
+
VDROPN(1);
|
204
|
+
break;
|
205
|
+
case OPdup:
|
206
|
+
VPUSH(VSTACKGET(0));
|
207
|
+
break;
|
208
|
+
case OPgetlocalb:
|
209
|
+
VPUSH(VCALLSTACKGET(callstack,255&bytecode[pc++]));
|
210
|
+
break;
|
211
|
+
case OPgetlocal:
|
212
|
+
VSTACKSET(0,VCALLSTACKGET(callstack,VALTOINT(VSTACKGET(0))));
|
213
|
+
break;
|
214
|
+
case OPadd:
|
215
|
+
VSTACKSET(1,INTTOVAL(VALTOINT(VSTACKGET(1))+VALTOINT(VSTACKGET(0))));
|
216
|
+
VDROPN(1);
|
217
|
+
break;
|
218
|
+
case OPsub:
|
219
|
+
VSTACKSET(1,INTTOVAL(VALTOINT(VSTACKGET(1))-VALTOINT(VSTACKGET(0))));
|
220
|
+
VDROPN(1);
|
221
|
+
break;
|
222
|
+
case OPmul:
|
223
|
+
VSTACKSET(1,INTTOVAL(VALTOINT(VSTACKGET(1))*VALTOINT(VSTACKGET(0))));
|
224
|
+
VDROPN(1);
|
225
|
+
break;
|
226
|
+
case OPdiv:
|
227
|
+
VSTACKSET(1,INTTOVAL(VALTOINT(VSTACKGET(1))/VALTOINT(VSTACKGET(0))));
|
228
|
+
VDROPN(1);
|
229
|
+
break;
|
230
|
+
case OPmod:
|
231
|
+
VSTACKSET(1,INTTOVAL(VALTOINT(VSTACKGET(1))%VALTOINT(VSTACKGET(0))));
|
232
|
+
VDROPN(1);
|
233
|
+
break;
|
234
|
+
case OPand:
|
235
|
+
VSTACKSET(1,INTTOVAL(VALTOINT(VSTACKGET(1))&VALTOINT(VSTACKGET(0))));
|
236
|
+
VDROPN(1);
|
237
|
+
break;
|
238
|
+
case OPor:
|
239
|
+
VSTACKSET(1,INTTOVAL(VALTOINT(VSTACKGET(1))|VALTOINT(VSTACKGET(0))));
|
240
|
+
VDROPN(1);
|
241
|
+
break;
|
242
|
+
case OPeor:
|
243
|
+
VSTACKSET(1,INTTOVAL(VALTOINT(VSTACKGET(1))^VALTOINT(VSTACKGET(0))));
|
244
|
+
VDROPN(1);
|
245
|
+
break;
|
246
|
+
case OPshl:
|
247
|
+
VSTACKSET(1,INTTOVAL(VALTOINT(VSTACKGET(1))<<VALTOINT(VSTACKGET(0))));
|
248
|
+
VDROPN(1);
|
249
|
+
break;
|
250
|
+
case OPshr:
|
251
|
+
VSTACKSET(1,INTTOVAL(VALTOINT(VSTACKGET(1))>>VALTOINT(VSTACKGET(0))));
|
252
|
+
VDROPN(1);
|
253
|
+
break;
|
254
|
+
case OPneg:
|
255
|
+
VSTACKSET(0,INTTOVAL(-VALTOINT(VSTACKGET(0))));
|
256
|
+
break;
|
257
|
+
case OPnot:
|
258
|
+
VSTACKSET(0,INTTOVAL(~VALTOINT(VSTACKGET(0))));
|
259
|
+
break;
|
260
|
+
case OPnon:
|
261
|
+
VSTACKSET(0,INTTOVAL(VALTOINT(VSTACKGET(0))?0:1));
|
262
|
+
break;
|
263
|
+
case OPeq:
|
264
|
+
VSTACKSET(1,INTTOVAL((VSTACKGET(1)==VSTACKGET(0))?1:0));
|
265
|
+
VDROPN(1);
|
266
|
+
break;
|
267
|
+
case OPne:
|
268
|
+
VSTACKSET(1,INTTOVAL((VSTACKGET(1)!=VSTACKGET(0))?1:0));
|
269
|
+
VDROPN(1);
|
270
|
+
break;
|
271
|
+
case OPlt:
|
272
|
+
VSTACKSET(1,INTTOVAL((VALTOINT(VSTACKGET(1))<VALTOINT(VSTACKGET(0)))?1:0));
|
273
|
+
VDROPN(1);
|
274
|
+
break;
|
275
|
+
case OPgt:
|
276
|
+
VSTACKSET(1,INTTOVAL((VALTOINT(VSTACKGET(1))>VALTOINT(VSTACKGET(0)))?1:0));
|
277
|
+
VDROPN(1);
|
278
|
+
break;
|
279
|
+
case OPle:
|
280
|
+
VSTACKSET(1,INTTOVAL((VALTOINT(VSTACKGET(1))<=VALTOINT(VSTACKGET(0)))?1:0));
|
281
|
+
VDROPN(1);
|
282
|
+
break;
|
283
|
+
case OPge:
|
284
|
+
VSTACKSET(1,INTTOVAL((VALTOINT(VSTACKGET(1))>=VALTOINT(VSTACKGET(0)))?1:0));
|
285
|
+
VDROPN(1);
|
286
|
+
break;
|
287
|
+
case OPgoto:
|
288
|
+
pc=pcbase+loaderGetShort(&bytecode[pc]);
|
289
|
+
break;
|
290
|
+
case OPelse:
|
291
|
+
if (!VPULL()) pc=pcbase+loaderGetShort(&bytecode[pc]);
|
292
|
+
else pc+=2;
|
293
|
+
break;
|
294
|
+
case OPmktabb:
|
295
|
+
VPUSH(PNTTOVAL(VMALLOCCLEAR(255&bytecode[pc++])));
|
296
|
+
break;
|
297
|
+
case OPmktab:
|
298
|
+
VPUSH(PNTTOVAL(VMALLOCCLEAR(VALTOINT(VPULL()))));
|
299
|
+
break;
|
300
|
+
case OPdeftabb:
|
301
|
+
VMKTAB(255&bytecode[pc++]);
|
302
|
+
break;
|
303
|
+
case OPdeftab:
|
304
|
+
VMKTAB(VALTOINT(VPULL()));
|
305
|
+
break;
|
306
|
+
case OPfetchb:
|
307
|
+
{
|
308
|
+
int i=255&bytecode[pc++];
|
309
|
+
int p=VSTACKGET(0);
|
310
|
+
if (p!=NIL) VSTACKSET(0,VFETCH(VALTOPNT(p),i));
|
311
|
+
}
|
312
|
+
break;
|
313
|
+
case OPfetch:
|
314
|
+
{
|
315
|
+
int i=VPULL();
|
316
|
+
int p=VSTACKGET(0);
|
317
|
+
if ((p==NIL)||(i==NIL)) VSTACKSET(0,NIL);
|
318
|
+
else
|
319
|
+
{
|
320
|
+
i=VALTOINT(i);
|
321
|
+
p=VALTOPNT(p);
|
322
|
+
if ((i<0)||(i>=VSIZE(p))) VSTACKSET(0,NIL);
|
323
|
+
else VSTACKSET(0,VFETCH(p,i));
|
324
|
+
}
|
325
|
+
}
|
326
|
+
break;
|
327
|
+
case OPgetglobalb:
|
328
|
+
VPUSH(VCALLSTACKGET(global_start,255&bytecode[pc++]));
|
329
|
+
break;
|
330
|
+
case OPgetglobal:
|
331
|
+
VSTACKSET(0,VCALLSTACKGET(global_start,VALTOINT(VSTACKGET(0))));
|
332
|
+
break;
|
333
|
+
case OPSecho:
|
334
|
+
logSecho(VSTACKGET(0),0);
|
335
|
+
break;
|
336
|
+
case OPIecho:
|
337
|
+
logIecho(VSTACKGET(0),0);
|
338
|
+
break;
|
339
|
+
case OPsetlocalb:
|
340
|
+
VCALLSTACKSET(callstack,255&bytecode[pc++],VPULL());
|
341
|
+
break;
|
342
|
+
case OPsetlocal:
|
343
|
+
{
|
344
|
+
int v=VALTOINT(VPULL());
|
345
|
+
VCALLSTACKSET(callstack,v,VPULL());
|
346
|
+
}
|
347
|
+
break;
|
348
|
+
case OPsetglobal:
|
349
|
+
VCALLSTACKSET(global_start,VALTOINT(VSTACKGET(1)),VSTACKGET(0));
|
350
|
+
VSTACKSET(1,VSTACKGET(0));
|
351
|
+
VPULL();
|
352
|
+
break;
|
353
|
+
case OPsetstructb:
|
354
|
+
{
|
355
|
+
int i=255&bytecode[pc++];
|
356
|
+
int v=VPULL();
|
357
|
+
int p=VSTACKGET(0);
|
358
|
+
if ((p!=NIL)&&(i!=NIL))
|
359
|
+
{
|
360
|
+
p=VALTOPNT(p);
|
361
|
+
if ((i>=0)||(i<VSIZE(p))) VSTORE(p,i,v);
|
362
|
+
}
|
363
|
+
}
|
364
|
+
break;
|
365
|
+
case OPsetstruct:
|
366
|
+
{
|
367
|
+
int i=VPULL();
|
368
|
+
int v=VPULL();
|
369
|
+
int p=VSTACKGET(0);
|
370
|
+
if ((p!=NIL)&&(i!=NIL))
|
371
|
+
{
|
372
|
+
i=VALTOINT(i);
|
373
|
+
p=VALTOPNT(p);
|
374
|
+
if ((i>=0)||(i<VSIZE(p))) VSTORE(p,i,v);
|
375
|
+
}
|
376
|
+
}
|
377
|
+
break;
|
378
|
+
case OPhd:
|
379
|
+
{
|
380
|
+
int p=VSTACKGET(0);
|
381
|
+
if (p!=NIL) VSTACKSET(0,VFETCH(VALTOPNT(p),0));
|
382
|
+
}
|
383
|
+
break;
|
384
|
+
case OPtl:
|
385
|
+
{
|
386
|
+
int p=VSTACKGET(0);
|
387
|
+
if (p!=NIL) VSTACKSET(0,VFETCH(VALTOPNT(p),1));
|
388
|
+
}
|
389
|
+
break;
|
390
|
+
case OPsetlocal2:
|
391
|
+
VCALLSTACKSET(callstack,VALTOINT(VSTACKGET(1)),VSTACKGET(0));
|
392
|
+
VSTACKSET(1,VSTACKGET(0));
|
393
|
+
VPULL();
|
394
|
+
break;
|
395
|
+
case OPstore:
|
396
|
+
{
|
397
|
+
int v=VPULL();
|
398
|
+
int i=VPULL();
|
399
|
+
int p=VSTACKGET(0);
|
400
|
+
if ((p!=NIL)&&(i!=NIL))
|
401
|
+
{
|
402
|
+
i=VALTOINT(i);
|
403
|
+
p=VALTOPNT(p);
|
404
|
+
if ((i>=0)||(i<VSIZE(p))) VSTORE(p,i,v);
|
405
|
+
}
|
406
|
+
VSTACKSET(0,v);
|
407
|
+
}
|
408
|
+
break;
|
409
|
+
case OPcall:
|
410
|
+
{
|
411
|
+
int p=VSTACKGET(0);
|
412
|
+
if (p==NIL)
|
413
|
+
{
|
414
|
+
VSTACKSET(1,NIL);
|
415
|
+
VPULL();
|
416
|
+
}
|
417
|
+
else
|
418
|
+
{
|
419
|
+
int n;
|
420
|
+
n=VSIZE(VALTOPNT(p));
|
421
|
+
if (n==0) VPULL();
|
422
|
+
else
|
423
|
+
{
|
424
|
+
int i;
|
425
|
+
for(i=1;i<n;i++) VPUSH(NIL);
|
426
|
+
p=VALTOPNT(VSTACKGET(n-1));
|
427
|
+
for(i=0;i<n;i++) VSTACKSET(n-1-i,VFETCH(p,i));
|
428
|
+
}
|
429
|
+
VPUSH(INTTOVAL(n));
|
430
|
+
op=OPcallr;
|
431
|
+
cont=1;
|
432
|
+
}
|
433
|
+
}
|
434
|
+
break;
|
435
|
+
case OPcallrb:
|
436
|
+
{
|
437
|
+
int n=255&bytecode[pc++];
|
438
|
+
int valn=VSTACKGET(n);
|
439
|
+
if (valn==NIL) VDROPN(n);
|
440
|
+
else
|
441
|
+
{
|
442
|
+
int i;
|
443
|
+
for(i=n;i>0;i--) VSTACKSET(i,VSTACKGET(i-1));
|
444
|
+
VSTACKSET(0,valn);
|
445
|
+
op=OPexec;
|
446
|
+
cont=1;
|
447
|
+
}
|
448
|
+
}
|
449
|
+
break;
|
450
|
+
case OPcallr:
|
451
|
+
{
|
452
|
+
int n=VALTOINT(VPULL());
|
453
|
+
int valn=VSTACKGET(n);
|
454
|
+
if (valn==NIL) VDROPN(n);
|
455
|
+
else
|
456
|
+
{
|
457
|
+
int i;
|
458
|
+
for(i=n;i>0;i--) VSTACKSET(i,VSTACKGET(i-1));
|
459
|
+
VSTACKSET(0,valn);
|
460
|
+
op=OPexec;
|
461
|
+
cont=1;
|
462
|
+
}
|
463
|
+
}
|
464
|
+
break;
|
465
|
+
case OPfirst:
|
466
|
+
{
|
467
|
+
int p=VSTACKGET(0);
|
468
|
+
if (p!=NIL) VPUSH(VFETCH(VALTOPNT(p),0));
|
469
|
+
else VPUSH(NIL);
|
470
|
+
}
|
471
|
+
break;
|
472
|
+
case OPtime_ms:
|
473
|
+
VPUSH(INTTOVAL(sysTimems()));
|
474
|
+
break;
|
475
|
+
case OPtabnew:
|
476
|
+
{
|
477
|
+
int v=VPULL();
|
478
|
+
if (v==NIL) VSTACKSET(0,NIL);
|
479
|
+
else
|
480
|
+
{
|
481
|
+
int p,i,v0;
|
482
|
+
v=VALTOINT(v);
|
483
|
+
p=VMALLOC(v);
|
484
|
+
v0=VSTACKGET(0);
|
485
|
+
for(i=0;i<v;i++) VSTORE(p,i,v0);
|
486
|
+
VSTACKSET(0,PNTTOVAL(p));
|
487
|
+
}
|
488
|
+
}
|
489
|
+
break;
|
490
|
+
case OPfixarg:
|
491
|
+
{
|
492
|
+
int v=VSTACKGET(1);
|
493
|
+
if (v==NIL) VPULL();
|
494
|
+
else
|
495
|
+
{
|
496
|
+
if (ISVALPNT(v))
|
497
|
+
{
|
498
|
+
VPUSH(VFETCH(VALTOPNT(v),1));
|
499
|
+
VSTACKSET(2,VFETCH(VALTOPNT(VSTACKGET(2)),0));
|
500
|
+
}
|
501
|
+
else VPUSH(NIL);
|
502
|
+
VMKTAB(2);
|
503
|
+
VMKTAB(2);
|
504
|
+
}
|
505
|
+
}
|
506
|
+
break;
|
507
|
+
case OPabs:
|
508
|
+
{
|
509
|
+
int v=VALTOINT(VSTACKGET(0));
|
510
|
+
if (v<0) v=-v;
|
511
|
+
VSTACKSET(0,INTTOVAL(v));
|
512
|
+
}
|
513
|
+
break;
|
514
|
+
case OPmax:
|
515
|
+
{
|
516
|
+
int v=VALTOINT(VPULL());
|
517
|
+
int w=VALTOINT(VSTACKGET(0));
|
518
|
+
VSTACKSET(0,INTTOVAL(v<w?w:v));
|
519
|
+
}
|
520
|
+
break;
|
521
|
+
case OPmin:
|
522
|
+
{
|
523
|
+
int v=VALTOINT(VPULL());
|
524
|
+
int w=VALTOINT(VSTACKGET(0));
|
525
|
+
VSTACKSET(0,INTTOVAL(v>w?w:v));
|
526
|
+
}
|
527
|
+
break;
|
528
|
+
case OPrand:
|
529
|
+
VPUSH(INTTOVAL(sysRand()));
|
530
|
+
break;
|
531
|
+
case OPsrand:
|
532
|
+
sysSrand(VALTOINT(VSTACKGET(0)));
|
533
|
+
break;
|
534
|
+
case OPtime:
|
535
|
+
VPUSH(INTTOVAL(sysTime()));
|
536
|
+
break;
|
537
|
+
case OPstrnew:
|
538
|
+
{
|
539
|
+
int n=VALTOINT(VSTACKGET(0));
|
540
|
+
if (n<0) VSTACKSET(0,NIL);
|
541
|
+
else VSTACKSET(0,PNTTOVAL(VMALLOCBIN(n)));
|
542
|
+
}
|
543
|
+
break;
|
544
|
+
case OPstrset:
|
545
|
+
{
|
546
|
+
int v=VALTOINT(VPULL());
|
547
|
+
int n=VALTOINT(VPULL());
|
548
|
+
int p=VALTOPNT(VSTACKGET(0));
|
549
|
+
if ((p!=NIL)&&(n>=0)&&(n<VSIZEBIN(p)))
|
550
|
+
(VSTARTBIN(p))[n]=v;
|
551
|
+
}
|
552
|
+
break;
|
553
|
+
case OPstrcpy:
|
554
|
+
{
|
555
|
+
int len=VPULL();
|
556
|
+
int start=VALTOINT(VPULL());
|
557
|
+
int q=VALTOPNT(VPULL());
|
558
|
+
int index=VALTOINT(VPULL());
|
559
|
+
int p=VALTOPNT(VSTACKGET(0));
|
560
|
+
if ((p!=NIL)&&(q!=NIL))
|
561
|
+
{
|
562
|
+
if (len==NIL) len=VSIZEBIN(q)-start; else len=VALTOINT(len);
|
563
|
+
sysCpy(VSTARTBIN(p),index,VSIZEBIN(p),VSTARTBIN(q),start,VSIZEBIN(q),len);
|
564
|
+
}
|
565
|
+
}
|
566
|
+
break;
|
567
|
+
case OPvstrcmp:
|
568
|
+
{
|
569
|
+
int len=VPULL();
|
570
|
+
int start=VALTOINT(VPULL());
|
571
|
+
int q=VALTOPNT(VPULL());
|
572
|
+
int index=VALTOINT(VPULL());
|
573
|
+
int p=VALTOPNT(VSTACKGET(0));
|
574
|
+
if ((p!=NIL)&&(q!=NIL))
|
575
|
+
{
|
576
|
+
if (len==NIL)
|
577
|
+
{
|
578
|
+
len=VSIZEBIN(q)-start;
|
579
|
+
if (len<VSIZEBIN(p)-index) len=VSIZEBIN(p)-index;
|
580
|
+
}
|
581
|
+
else len=VALTOINT(len);
|
582
|
+
VSTACKSET(0,INTTOVAL(sysCmp(VSTARTBIN(p),index,VSIZEBIN(p),VSTARTBIN(q),start,VSIZEBIN(q),len)));
|
583
|
+
}
|
584
|
+
else VSTACKSET(0,INTTOVAL((p!=NIL)?1:(q!=NIL)?-1:0));
|
585
|
+
}
|
586
|
+
break;
|
587
|
+
case OPstrfind:
|
588
|
+
{
|
589
|
+
int len=VPULL();
|
590
|
+
int start=VALTOINT(VPULL());
|
591
|
+
int q=VALTOPNT(VPULL());
|
592
|
+
int index=VALTOINT(VPULL());
|
593
|
+
int p=VALTOPNT(VSTACKGET(0));
|
594
|
+
if ((p!=NIL)&&(q!=NIL))
|
595
|
+
{
|
596
|
+
if (len==NIL) len=VSIZEBIN(q)-start; else len=VALTOINT(len);
|
597
|
+
VSTACKSET(0,sysFind(VSTARTBIN(p),index,VSIZEBIN(p),VSTARTBIN(q),start,VSIZEBIN(q),len));
|
598
|
+
}
|
599
|
+
else VSTACKSET(0,NIL);
|
600
|
+
}
|
601
|
+
break;
|
602
|
+
case OPstrfindrev:
|
603
|
+
{
|
604
|
+
int len=VPULL();
|
605
|
+
int start=VALTOINT(VPULL());
|
606
|
+
int q=VALTOPNT(VPULL());
|
607
|
+
int index=VPULL();
|
608
|
+
int p=VALTOPNT(VSTACKGET(0));
|
609
|
+
if ((p!=NIL)&&(q!=NIL))
|
610
|
+
{
|
611
|
+
if (len==NIL) len=VSIZEBIN(q)-start; else len=VALTOINT(len);
|
612
|
+
if (index==NIL) index=VSIZEBIN(p)-1; else index=VALTOINT(index);
|
613
|
+
VSTACKSET(0,sysFindrev(VSTARTBIN(p),index,VSIZEBIN(p),VSTARTBIN(q),start,VSIZEBIN(q),len));
|
614
|
+
}
|
615
|
+
else VSTACKSET(0,NIL);
|
616
|
+
}
|
617
|
+
break;
|
618
|
+
case OPstrlen:
|
619
|
+
{
|
620
|
+
int p=VALTOPNT(VSTACKGET(0));
|
621
|
+
if (p!=NIL) VSTACKSET(0,INTTOVAL(VSIZEBIN(p)));
|
622
|
+
}
|
623
|
+
break;
|
624
|
+
case OPstrget:
|
625
|
+
{
|
626
|
+
int n=VALTOINT(VPULL());
|
627
|
+
int p=VALTOPNT(VSTACKGET(0));
|
628
|
+
if ((p==NIL)||(n<0)||(n>=VSIZEBIN(p))) VSTACKSET(0,NIL);
|
629
|
+
else VSTACKSET(0,INTTOVAL(((VSTARTBIN(p))[n]&255)));
|
630
|
+
}
|
631
|
+
break;
|
632
|
+
case OPstrsub:
|
633
|
+
// vmemDump();
|
634
|
+
{
|
635
|
+
int len=VPULL();
|
636
|
+
int start=VALTOINT(VPULL());
|
637
|
+
int q=VALTOPNT(VSTACKGET(0));
|
638
|
+
if (q!=NIL)
|
639
|
+
{
|
640
|
+
if (len==NIL) len=VSIZEBIN(q)-start; else len=VALTOINT(len);
|
641
|
+
if (start+len>VSIZEBIN(q)) len=VSIZEBIN(q)-start;
|
642
|
+
if ((start>=0)&&(len>=0))
|
643
|
+
{
|
644
|
+
int p=VMALLOCBIN(len);
|
645
|
+
mystrcpy(VSTARTBIN(p),VSTARTBIN(VALTOPNT(VSTACKGET(0)))+start,len);
|
646
|
+
VSTACKSET(0,PNTTOVAL(p));
|
647
|
+
}
|
648
|
+
else VSTACKSET(0,NIL);
|
649
|
+
}
|
650
|
+
else VSTACKSET(0,NIL);
|
651
|
+
}
|
652
|
+
// vmemDump();
|
653
|
+
break;
|
654
|
+
case OPstrcat:
|
655
|
+
{
|
656
|
+
int r;
|
657
|
+
int len=0;
|
658
|
+
int q=VALTOPNT(VSTACKGET(0));
|
659
|
+
int p=VALTOPNT(VSTACKGET(1));
|
660
|
+
if (p!=NIL) len+=VSIZEBIN(p);
|
661
|
+
if (q!=NIL) len+=VSIZEBIN(q);
|
662
|
+
r=VMALLOCBIN(len);
|
663
|
+
len=0;
|
664
|
+
q=VALTOPNT(VPULL());
|
665
|
+
p=VALTOPNT(VSTACKGET(0));
|
666
|
+
if (p!=NIL)
|
667
|
+
{
|
668
|
+
len=VSIZEBIN(p);
|
669
|
+
mystrcpy(VSTARTBIN(r),VSTARTBIN(p),len);
|
670
|
+
}
|
671
|
+
if (q!=NIL) mystrcpy(VSTARTBIN(r)+len,VSTARTBIN(q),VSIZEBIN(q));
|
672
|
+
VSTACKSET(0,PNTTOVAL(r));
|
673
|
+
}
|
674
|
+
break;
|
675
|
+
case OPtablen:
|
676
|
+
{
|
677
|
+
int p=VALTOPNT(VSTACKGET(0));
|
678
|
+
if (p!=NIL) VSTACKSET(0,INTTOVAL(VSIZE(p)));
|
679
|
+
}
|
680
|
+
break;
|
681
|
+
case OPstrcatlist:
|
682
|
+
{
|
683
|
+
int r,q;
|
684
|
+
int len=0;
|
685
|
+
int p=VALTOPNT(VSTACKGET(0));
|
686
|
+
while(p!=NIL)
|
687
|
+
{
|
688
|
+
q=VALTOPNT(VFETCH(p,0));
|
689
|
+
if (q!=NIL) len+=VSIZEBIN(q);
|
690
|
+
p=VALTOPNT(VFETCH(p,1));
|
691
|
+
}
|
692
|
+
r=VMALLOCBIN(len);
|
693
|
+
if (r<0) return;
|
694
|
+
len=0;
|
695
|
+
p=VALTOPNT(VSTACKGET(0));
|
696
|
+
while(p!=NIL)
|
697
|
+
{
|
698
|
+
q=VALTOPNT(VFETCH(p,0));
|
699
|
+
if (q!=NIL)
|
700
|
+
{
|
701
|
+
mystrcpy(VSTARTBIN(r)+len,VSTARTBIN(q),VSIZEBIN(q));
|
702
|
+
len+=VSIZEBIN(q);
|
703
|
+
}
|
704
|
+
p=VALTOPNT(VFETCH(p,1));
|
705
|
+
}
|
706
|
+
VSTACKSET(0,PNTTOVAL(r));
|
707
|
+
}
|
708
|
+
break;
|
709
|
+
case OPled:
|
710
|
+
sysLed(VALTOINT(VSTACKGET(1)),VALTOINT(VSTACKGET(0)));
|
711
|
+
VPULL();
|
712
|
+
break;
|
713
|
+
case OPmotorset:
|
714
|
+
sysMotorset(VALTOINT(VSTACKGET(1)),VALTOINT(VSTACKGET(0)));
|
715
|
+
VPULL();
|
716
|
+
break;
|
717
|
+
case OPmotorget:
|
718
|
+
VSTACKSET(0,INTTOVAL(sysMotorget(VALTOINT(VSTACKGET(0)))));
|
719
|
+
break;
|
720
|
+
case OPbutton2:
|
721
|
+
VPUSH(INTTOVAL(sysButton2()));
|
722
|
+
break;
|
723
|
+
case OPbutton3:
|
724
|
+
VPUSH(INTTOVAL(sysButton3()));
|
725
|
+
break;
|
726
|
+
case OPplayStart:
|
727
|
+
{
|
728
|
+
int k;
|
729
|
+
VCALLSTACKSET(sys_start,SYS_CBPLAY,VPULL());
|
730
|
+
k=VALTOINT(VPULL());
|
731
|
+
VPUSH(INTTOVAL(0));
|
732
|
+
audioPlayStart(44100,16,2,k);
|
733
|
+
}
|
734
|
+
break;
|
735
|
+
case OPplayFeed:
|
736
|
+
{
|
737
|
+
int len=VPULL();
|
738
|
+
int start=VALTOINT(VPULL());
|
739
|
+
int q=VALTOPNT(VSTACKGET(0));
|
740
|
+
if (q!=NIL)
|
741
|
+
{
|
742
|
+
if (len==NIL) len=VSIZEBIN(q)-start; else len=VALTOINT(len);
|
743
|
+
if (start+len>VSIZEBIN(q)) len=VSIZEBIN(q)-start;
|
744
|
+
if ((start>=0)&&(len>=0))
|
745
|
+
{
|
746
|
+
len=audioPlayFeed(VSTARTBIN(q)+start,len);
|
747
|
+
VSTACKSET(0,INTTOVAL(len));
|
748
|
+
}
|
749
|
+
else VSTACKSET(0,NIL);
|
750
|
+
}
|
751
|
+
else
|
752
|
+
{
|
753
|
+
audioPlayFeed(NULL,0);
|
754
|
+
VSTACKSET(0,NIL);
|
755
|
+
}
|
756
|
+
}
|
757
|
+
break;
|
758
|
+
case OPplayStop:
|
759
|
+
audioPlayStop();
|
760
|
+
VPUSH(INTTOVAL(0));
|
761
|
+
break;
|
762
|
+
case OPrecStart:
|
763
|
+
{
|
764
|
+
int freq,gain;
|
765
|
+
VCALLSTACKSET(sys_start,SYS_CBREC,VPULL());
|
766
|
+
gain=VALTOINT(VPULL());
|
767
|
+
freq=VALTOINT(VPULL());
|
768
|
+
VPUSH(INTTOVAL(0));
|
769
|
+
audioRecStart(freq,gain);
|
770
|
+
}
|
771
|
+
break;
|
772
|
+
case OPrecStop:
|
773
|
+
audioRecStop();
|
774
|
+
VPUSH(INTTOVAL(0));
|
775
|
+
break;
|
776
|
+
case OPrecVol:
|
777
|
+
{
|
778
|
+
int start=VALTOINT(VPULL());
|
779
|
+
int q=VALTOPNT(VSTACKGET(0));
|
780
|
+
if (q!=NIL)
|
781
|
+
{
|
782
|
+
VSTACKSET(0,INTTOVAL(audioRecVol((unsigned char*)VSTARTBIN(q),VSIZEBIN(q),start)));
|
783
|
+
}
|
784
|
+
}
|
785
|
+
break;
|
786
|
+
case OPload:
|
787
|
+
{
|
788
|
+
int len=VPULL();
|
789
|
+
int start=VALTOINT(VPULL());
|
790
|
+
int q=VALTOPNT(VPULL());
|
791
|
+
int index=VALTOINT(VPULL());
|
792
|
+
int p=VALTOPNT(VSTACKGET(0));
|
793
|
+
if ((p!=NIL)&&(q!=NIL))
|
794
|
+
{
|
795
|
+
if (len==NIL) len=VSIZEBIN(p)-index; else len=VALTOINT(len);
|
796
|
+
len=sysLoad(VSTARTBIN(p),index,VSIZEBIN(p),VSTARTBIN(q),start,len);
|
797
|
+
VSTACKSET(0,INTTOVAL(len));
|
798
|
+
}
|
799
|
+
else VSTACKSET(0,NIL);
|
800
|
+
}
|
801
|
+
break;
|
802
|
+
case OPgc:
|
803
|
+
vmemGC();
|
804
|
+
VPUSH(INTTOVAL((vmem_heapindex-vmem_stack)*100/VMEM_LENGTH));
|
805
|
+
break;
|
806
|
+
case OPsave:
|
807
|
+
{
|
808
|
+
int len=VPULL();
|
809
|
+
int start=VALTOINT(VPULL());
|
810
|
+
int q=VALTOPNT(VPULL());
|
811
|
+
int index=VALTOINT(VPULL());
|
812
|
+
int p=VALTOPNT(VSTACKGET(0));
|
813
|
+
if ((p!=NIL)&&(q!=NIL))
|
814
|
+
{
|
815
|
+
if (len==NIL) len=VSIZEBIN(p)-index; else len=VALTOINT(len);
|
816
|
+
len=sysSave(VSTARTBIN(p),index,VSIZEBIN(p),VSTARTBIN(q),start,len);
|
817
|
+
VSTACKSET(0,INTTOVAL(len));
|
818
|
+
}
|
819
|
+
else VSTACKSET(0,NIL);
|
820
|
+
}
|
821
|
+
break;
|
822
|
+
case OPbytecode:
|
823
|
+
consolestr("#################### OPbytecode"ENDLINE);
|
824
|
+
if (VSTACKGET(0)!=NIL)
|
825
|
+
{
|
826
|
+
char* q;
|
827
|
+
int env=-1;
|
828
|
+
int p=VALTOPNT(VCALLSTACKGET(sys_start,SYS_ENV));
|
829
|
+
audioPlayStop();
|
830
|
+
audioRecStop();
|
831
|
+
if (p!=NIL)
|
832
|
+
{
|
833
|
+
env=VSIZEBIN(p);
|
834
|
+
memcpy(audioFifoPlay,VSTARTBIN(p),env);
|
835
|
+
}
|
836
|
+
|
837
|
+
q=VSTARTBIN(VALTOPNT(VSTACKGET(0)));
|
838
|
+
// dump(q+0x2df0,128);
|
839
|
+
|
840
|
+
loaderInit(q);
|
841
|
+
// dump(&bytecode[0x2440],32);
|
842
|
+
|
843
|
+
if (env>=0)
|
844
|
+
{
|
845
|
+
// dump(audioFifoPlay,env);
|
846
|
+
VCALLSTACKSET(sys_start,SYS_ENV,
|
847
|
+
PNTTOVAL(VMALLOCSTR(audioFifoPlay,env)));
|
848
|
+
}
|
849
|
+
VPUSH(INTTOVAL(0));
|
850
|
+
// tron=1;
|
851
|
+
interpGo();
|
852
|
+
// VPULL();
|
853
|
+
consolestr("#################### OPbytecode done"ENDLINE);
|
854
|
+
// tron=0;
|
855
|
+
// tron=1;
|
856
|
+
|
857
|
+
return;
|
858
|
+
}
|
859
|
+
break;
|
860
|
+
case OPloopcb:
|
861
|
+
VCALLSTACKSET(sys_start,SYS_CBLOOP,VSTACKGET(0));
|
862
|
+
break;
|
863
|
+
#ifdef VSIMU
|
864
|
+
case OPudpStart:
|
865
|
+
VSTACKSET(0,INTTOVAL(udpcreate(VALTOINT(VSTACKGET(0)))));
|
866
|
+
break;
|
867
|
+
case OPudpCb:
|
868
|
+
VCALLSTACKSET(sys_start,SYS_CBUDP,VSTACKGET(0));
|
869
|
+
break;
|
870
|
+
case OPudpStop:
|
871
|
+
VSTACKSET(0,INTTOVAL(udpclose(VALTOINT(VSTACKGET(0)))));
|
872
|
+
break;
|
873
|
+
case OPudpSend:
|
874
|
+
{
|
875
|
+
int len=VPULL();
|
876
|
+
int start=VALTOINT(VPULL());
|
877
|
+
int q=VALTOPNT(VPULL());
|
878
|
+
int dstport=VALTOINT(VPULL());
|
879
|
+
int p=VALTOPNT(VPULL());
|
880
|
+
int localport=VALTOINT(VSTACKGET(0));
|
881
|
+
if ((p!=NIL)&&(q!=NIL))
|
882
|
+
{
|
883
|
+
if (len==NIL) len=VSIZEBIN(q)-start; else len=VALTOINT(len);
|
884
|
+
if (start+len>VSIZEBIN(q)) len=VSIZEBIN(q)-start;
|
885
|
+
if ((start>=0)&&(len>=0))
|
886
|
+
{
|
887
|
+
int k=udpsend(localport,VSTARTBIN(p),dstport,VSTARTBIN(q)+start,len);
|
888
|
+
VSTACKSET(0,INTTOVAL(k));
|
889
|
+
}
|
890
|
+
else VSTACKSET(0,NIL);
|
891
|
+
}
|
892
|
+
else VSTACKSET(0,NIL);
|
893
|
+
|
894
|
+
}
|
895
|
+
break;
|
896
|
+
case OPtcpOpen:
|
897
|
+
{
|
898
|
+
int port=VALTOINT(VPULL());
|
899
|
+
int p=VALTOPNT(VSTACKGET(0));
|
900
|
+
if (p!=NIL) VSTACKSET(0,INTTOVAL(tcpopen(VSTARTBIN(p),port)));
|
901
|
+
}
|
902
|
+
break;
|
903
|
+
case OPtcpClose:
|
904
|
+
VSTACKSET(0,INTTOVAL(tcpclose(VALTOINT(VSTACKGET(0)))));
|
905
|
+
break;
|
906
|
+
case OPtcpSend:
|
907
|
+
{
|
908
|
+
int len=VPULL();
|
909
|
+
int start=VPULL();
|
910
|
+
int q=VALTOPNT(VPULL());
|
911
|
+
int tcp=VALTOINT(VSTACKGET(0));
|
912
|
+
if (start==NIL) start=0;
|
913
|
+
else start=VALTOINT(start);
|
914
|
+
if (q!=NIL)
|
915
|
+
{
|
916
|
+
if (len==NIL) len=VSIZEBIN(q)-start; else len=VALTOINT(len);
|
917
|
+
if (start+len>VSIZEBIN(q)) len=VSIZEBIN(q)-start;
|
918
|
+
if ((start>=0)&&(len>=0))
|
919
|
+
{
|
920
|
+
int k;
|
921
|
+
k=tcpsend(tcp,VSTARTBIN(q)+start,len);
|
922
|
+
if (k>=0) start+=k;
|
923
|
+
VSTACKSET(0,INTTOVAL(start));
|
924
|
+
}
|
925
|
+
else VSTACKSET(0,NIL);
|
926
|
+
}
|
927
|
+
else VSTACKSET(0,NIL);
|
928
|
+
}
|
929
|
+
break;
|
930
|
+
case OPtcpCb:
|
931
|
+
VCALLSTACKSET(sys_start,SYS_CBTCP,VSTACKGET(0));
|
932
|
+
break;
|
933
|
+
case OPtcpListen:
|
934
|
+
{
|
935
|
+
int port=VALTOINT(VSTACKGET(0));
|
936
|
+
VSTACKSET(0,INTTOVAL(tcpservercreate(port)));
|
937
|
+
}
|
938
|
+
break;
|
939
|
+
case OPtcpEnable:
|
940
|
+
{
|
941
|
+
int enable=VALTOINT(VPULL());
|
942
|
+
tcpenable(VALTOINT(VSTACKGET(0)),enable);
|
943
|
+
}
|
944
|
+
break;
|
945
|
+
#endif
|
946
|
+
case OPSecholn:
|
947
|
+
logSecho(VSTACKGET(0),1);
|
948
|
+
// if (tron)dump(&bytecode[0x2440],32);
|
949
|
+
break;
|
950
|
+
case OPIecholn:
|
951
|
+
logIecho(VSTACKGET(0),1);
|
952
|
+
break;
|
953
|
+
case OPenvget:
|
954
|
+
VPUSH(VCALLSTACKGET(sys_start,SYS_ENV));
|
955
|
+
break;
|
956
|
+
case OPenvset:
|
957
|
+
VCALLSTACKSET(sys_start,SYS_ENV,VSTACKGET(0));
|
958
|
+
break;
|
959
|
+
case OPsndVol:
|
960
|
+
audioVol(VALTOINT(VSTACKGET(0)));
|
961
|
+
break;
|
962
|
+
case OPrfidGet:
|
963
|
+
{
|
964
|
+
char *p;
|
965
|
+
p=sysRfidget();
|
966
|
+
if (!p) VPUSH(NIL);
|
967
|
+
else VPUSH(PNTTOVAL(VMALLOCSTR(p,8)));
|
968
|
+
}
|
969
|
+
break;
|
970
|
+
case OPplayTime:
|
971
|
+
VPUSH(INTTOVAL(audioPlayTime()));
|
972
|
+
break;
|
973
|
+
case OPnetCb:
|
974
|
+
VCALLSTACKSET(sys_start,SYS_CBTCP,VSTACKGET(0));
|
975
|
+
break;
|
976
|
+
case OPnetSend:
|
977
|
+
{
|
978
|
+
int speed=VALTOINT(VPULL());
|
979
|
+
int indmac=VALTOINT(VPULL());
|
980
|
+
int q=VALTOPNT(VPULL());
|
981
|
+
int len=VPULL();
|
982
|
+
int index=VALTOINT(VPULL());
|
983
|
+
int p=VALTOPNT(VSTACKGET(0));
|
984
|
+
if ((p!=NIL)&&(q!=NIL))
|
985
|
+
{
|
986
|
+
if (len==NIL) len=VSIZEBIN(p)-index; else len=VALTOINT(len);
|
987
|
+
VSTACKSET(0,INTTOVAL(netSend(VSTARTBIN(p),index,len,VSIZEBIN(p),VSTARTBIN(q),indmac,VSIZEBIN(q),speed)));
|
988
|
+
}
|
989
|
+
else VSTACKSET(0,NIL);
|
990
|
+
}
|
991
|
+
break;
|
992
|
+
case OPnetState:
|
993
|
+
VPUSH(INTTOVAL(netState()));
|
994
|
+
break;
|
995
|
+
case OPnetMac:
|
996
|
+
VPUSH(PNTTOVAL(VMALLOCSTR(netMac(),6)));
|
997
|
+
break;
|
998
|
+
case OPnetChk:
|
999
|
+
{
|
1000
|
+
int val=VALTOINT(VPULL());
|
1001
|
+
int len=VPULL();
|
1002
|
+
int index=VALTOINT(VPULL());
|
1003
|
+
int p=VALTOPNT(VSTACKGET(0));
|
1004
|
+
if (p!=NIL)
|
1005
|
+
{
|
1006
|
+
if (len==NIL) len=VSIZEBIN(p)-index; else len=VALTOINT(len);
|
1007
|
+
VSTACKSET(0,INTTOVAL(netChk(VSTARTBIN(p),index,len,VSIZEBIN(p),val)));
|
1008
|
+
}
|
1009
|
+
else VSTACKSET(0,INTTOVAL(val));
|
1010
|
+
}
|
1011
|
+
break;
|
1012
|
+
case OPnetSetmode:
|
1013
|
+
{
|
1014
|
+
int chn=VALTOINT(VPULL());
|
1015
|
+
int p=VALTOPNT(VPULL());
|
1016
|
+
int md=VALTOINT(VSTACKGET(0));
|
1017
|
+
char* ssid=(p==NIL)?NULL:VSTARTBIN(p);
|
1018
|
+
netSetmode(md,ssid,chn);
|
1019
|
+
}
|
1020
|
+
break;
|
1021
|
+
case OPnetScan:
|
1022
|
+
{
|
1023
|
+
int p=VALTOPNT(VPULL());
|
1024
|
+
char* ssid=(p==NIL)?NULL:VSTARTBIN(p);
|
1025
|
+
netScan(ssid);
|
1026
|
+
}
|
1027
|
+
break;
|
1028
|
+
case OPnetAuth:
|
1029
|
+
{
|
1030
|
+
int key=VALTOPNT(VPULL());
|
1031
|
+
int encrypt=VALTOINT(VPULL());
|
1032
|
+
int authmode=VALTOINT(VPULL());
|
1033
|
+
int scan=VALTOPNT(VSTACKGET(0));
|
1034
|
+
if (scan!=NIL)
|
1035
|
+
{
|
1036
|
+
int ssid=VALTOPNT(VFETCH(scan,0));
|
1037
|
+
int mac=VALTOPNT(VFETCH(scan,1));
|
1038
|
+
int bssid=VALTOPNT(VFETCH(scan,2));
|
1039
|
+
int chn=VALTOINT(VFETCH(scan,4));
|
1040
|
+
int rate=VALTOINT(VFETCH(scan,5));
|
1041
|
+
if ((mac!=NIL)&&(bssid!=NIL))
|
1042
|
+
{
|
1043
|
+
netAuth((ssid==NIL)?NULL:VSTARTBIN(ssid),VSTARTBIN(mac),
|
1044
|
+
VSTARTBIN(bssid),chn,rate,authmode,
|
1045
|
+
encrypt,(key==NIL)?NULL:VSTARTBIN(key));
|
1046
|
+
}
|
1047
|
+
}
|
1048
|
+
}
|
1049
|
+
break;
|
1050
|
+
case OPnetSeqAdd:
|
1051
|
+
{
|
1052
|
+
int inc=VALTOINT(VPULL());
|
1053
|
+
int seq=VALTOPNT(VPULL());
|
1054
|
+
if ((seq==NIL)||(VSIZEBIN(seq)<4)) VPUSH(NIL);
|
1055
|
+
else netSeqAdd((unsigned char*)VSTARTBIN(seq),inc);
|
1056
|
+
}
|
1057
|
+
break;
|
1058
|
+
case OPstrgetword:
|
1059
|
+
{
|
1060
|
+
int ind=VALTOINT(VPULL());
|
1061
|
+
int src=VALTOPNT(VSTACKGET(0));
|
1062
|
+
if (src!=NIL) VSTACKSET(0,INTTOVAL(sysStrgetword((unsigned char*)VSTARTBIN(src),VSIZEBIN(src),ind)));
|
1063
|
+
}
|
1064
|
+
break;
|
1065
|
+
case OPstrputword:
|
1066
|
+
{
|
1067
|
+
int val=VALTOINT(VPULL());
|
1068
|
+
int ind=VALTOINT(VPULL());
|
1069
|
+
int src=VALTOPNT(VSTACKGET(0));
|
1070
|
+
if (src!=NIL) sysStrputword((unsigned char*)VSTARTBIN(src),VSIZEBIN(src),ind,val);
|
1071
|
+
}
|
1072
|
+
break;
|
1073
|
+
case OPatoi:
|
1074
|
+
{
|
1075
|
+
int src=VALTOPNT(VSTACKGET(0));
|
1076
|
+
if (src!=NIL) VSTACKSET(0,INTTOVAL(sysAtoi(VSTARTBIN(src))));
|
1077
|
+
}
|
1078
|
+
break;
|
1079
|
+
case OPhtoi:
|
1080
|
+
{
|
1081
|
+
int src=VALTOPNT(VSTACKGET(0));
|
1082
|
+
if (src!=NIL)
|
1083
|
+
{
|
1084
|
+
VSTACKSET(0,INTTOVAL(sysHtoi(VSTARTBIN(src))));
|
1085
|
+
}
|
1086
|
+
}
|
1087
|
+
break;
|
1088
|
+
case OPitoa:
|
1089
|
+
sysItoa(VALTOINT(VPULL()));
|
1090
|
+
break;
|
1091
|
+
case OPctoa:
|
1092
|
+
{
|
1093
|
+
int val=VALTOINT(VPULL());
|
1094
|
+
sysCtoa(val);
|
1095
|
+
}
|
1096
|
+
break;
|
1097
|
+
case OPitoh:
|
1098
|
+
sysItoh(VALTOINT(VPULL()));
|
1099
|
+
break;
|
1100
|
+
case OPctoh:
|
1101
|
+
sysCtoh(VALTOINT(VPULL()));
|
1102
|
+
break;
|
1103
|
+
case OPitobin2:
|
1104
|
+
sysItobin2(VALTOINT(VPULL()));
|
1105
|
+
break;
|
1106
|
+
case OPlistswitch:
|
1107
|
+
{
|
1108
|
+
int key=VPULL();
|
1109
|
+
int p=VALTOPNT(VSTACKGET(0));
|
1110
|
+
VSTACKSET(0,sysListswitch(p,key));
|
1111
|
+
}
|
1112
|
+
break;
|
1113
|
+
case OPlistswitchstr:
|
1114
|
+
{
|
1115
|
+
int key=VPULL();
|
1116
|
+
int p=VALTOPNT(VSTACKGET(0));
|
1117
|
+
if (key==NIL) VSTACKSET(0,sysListswitch(p,key));
|
1118
|
+
else VSTACKSET(0,sysListswitchstr(p,VSTARTBIN(VALTOPNT(key))));
|
1119
|
+
}
|
1120
|
+
break;
|
1121
|
+
case OPsndRefresh:
|
1122
|
+
audioRefresh();
|
1123
|
+
VPUSH(NIL);
|
1124
|
+
break;
|
1125
|
+
case OPsndWrite:
|
1126
|
+
{
|
1127
|
+
int val=VALTOINT(VPULL());
|
1128
|
+
audioWrite(VALTOINT(VSTACKGET(0)),val);
|
1129
|
+
}
|
1130
|
+
break;
|
1131
|
+
case OPsndRead:
|
1132
|
+
VSTACKSET(0,INTTOVAL(audioRead(VALTOINT(VSTACKGET(0)))));
|
1133
|
+
break;
|
1134
|
+
case OPsndFeed:
|
1135
|
+
{
|
1136
|
+
int len=VPULL();
|
1137
|
+
int start=VPULL();
|
1138
|
+
int q=VALTOPNT(VSTACKGET(0));
|
1139
|
+
if (start==NIL) start=0;
|
1140
|
+
else start=VALTOINT(start);
|
1141
|
+
if (q!=NIL)
|
1142
|
+
{
|
1143
|
+
if (len==NIL) len=VSIZEBIN(q)-start; else len=VALTOINT(len);
|
1144
|
+
if (start+len>VSIZEBIN(q)) len=VSIZEBIN(q)-start;
|
1145
|
+
if ((start>=0)&&(len>=0))
|
1146
|
+
{
|
1147
|
+
int k=audioFeed(VSTARTBIN(q)+start,len);
|
1148
|
+
VSTACKSET(0,INTTOVAL(k));
|
1149
|
+
}
|
1150
|
+
else VSTACKSET(0,NIL);
|
1151
|
+
}
|
1152
|
+
else VSTACKSET(0,NIL);
|
1153
|
+
}
|
1154
|
+
break;
|
1155
|
+
case OPsndAmpli:
|
1156
|
+
audioAmpli(VALTOINT(VSTACKGET(0)));
|
1157
|
+
break;
|
1158
|
+
case OPcorePP:
|
1159
|
+
VPUSH(INTTOVAL(vmem_stack));
|
1160
|
+
break;
|
1161
|
+
case OPcorePush:
|
1162
|
+
VPUSH(VSTACKGET(0));
|
1163
|
+
break;
|
1164
|
+
case OPcorePull:
|
1165
|
+
VSTACKSET(1,VSTACKGET(0));
|
1166
|
+
VPULL();
|
1167
|
+
break;
|
1168
|
+
case OPcoreBit0:
|
1169
|
+
{
|
1170
|
+
int v=VALTOINT(VPULL());
|
1171
|
+
VSTACKSET(0,(VSTACKGET(0)&0xfffffffe)|(v&1));
|
1172
|
+
}
|
1173
|
+
break;
|
1174
|
+
case OPreboot:
|
1175
|
+
{
|
1176
|
+
int w=VALTOINT(VPULL());
|
1177
|
+
int v=VALTOINT(VSTACKGET(0));
|
1178
|
+
consolestr("reboot ");
|
1179
|
+
consolehx(v);
|
1180
|
+
consolestr(".");
|
1181
|
+
consolehx(w);
|
1182
|
+
consolestr("\n");
|
1183
|
+
if ((v==0x0407FE58)&&(w==0x13fb6754))
|
1184
|
+
{
|
1185
|
+
consolestr("************REBOOT NOW");
|
1186
|
+
sysReboot();
|
1187
|
+
}
|
1188
|
+
}
|
1189
|
+
break;
|
1190
|
+
case OPstrcmp:
|
1191
|
+
{
|
1192
|
+
int q=VALTOPNT(VPULL());
|
1193
|
+
int p=VALTOPNT(VSTACKGET(0));
|
1194
|
+
if ((p!=NIL)&&(q!=NIL))
|
1195
|
+
{
|
1196
|
+
int pl=VSIZEBIN(p);
|
1197
|
+
int ql=VSIZEBIN(q);
|
1198
|
+
|
1199
|
+
VSTACKSET(0,INTTOVAL(memcmp(VSTARTBIN(p),VSTARTBIN(q),(pl>ql)?pl:ql)));
|
1200
|
+
}
|
1201
|
+
else VSTACKSET(0,INTTOVAL((p!=NIL)?1:(q!=NIL)?-1:0));
|
1202
|
+
}
|
1203
|
+
break;
|
1204
|
+
case OPadp2wav:
|
1205
|
+
{
|
1206
|
+
int len=VPULL();
|
1207
|
+
int start=VALTOINT(VPULL());
|
1208
|
+
int q=VALTOPNT(VPULL());
|
1209
|
+
int index=VALTOINT(VPULL());
|
1210
|
+
int p=VALTOPNT(VSTACKGET(0));
|
1211
|
+
if ((p!=NIL)&&(q!=NIL))
|
1212
|
+
{
|
1213
|
+
if (len==NIL) len=VSIZEBIN(q)-start; else len=VALTOINT(len);
|
1214
|
+
AudioAdp2wav(VSTARTBIN(p),index,VSIZEBIN(p),VSTARTBIN(q),start,VSIZEBIN(q),len);
|
1215
|
+
}
|
1216
|
+
}
|
1217
|
+
break;
|
1218
|
+
case OPwav2adp:
|
1219
|
+
{
|
1220
|
+
int len=VPULL();
|
1221
|
+
int start=VALTOINT(VPULL());
|
1222
|
+
int q=VALTOPNT(VPULL());
|
1223
|
+
int index=VALTOINT(VPULL());
|
1224
|
+
int p=VALTOPNT(VSTACKGET(0));
|
1225
|
+
if ((p!=NIL)&&(q!=NIL))
|
1226
|
+
{
|
1227
|
+
if (len==NIL) len=VSIZEBIN(q)-start; else len=VALTOINT(len);
|
1228
|
+
AudioWav2adp(VSTARTBIN(p),index,VSIZEBIN(p),VSTARTBIN(q),start,VSIZEBIN(q),len);
|
1229
|
+
}
|
1230
|
+
}
|
1231
|
+
break;
|
1232
|
+
case OPalaw2wav:
|
1233
|
+
{
|
1234
|
+
int mu=VALTOINT(VPULL());
|
1235
|
+
int len=VPULL();
|
1236
|
+
int start=VALTOINT(VPULL());
|
1237
|
+
int q=VALTOPNT(VPULL());
|
1238
|
+
int index=VALTOINT(VPULL());
|
1239
|
+
int p=VALTOPNT(VSTACKGET(0));
|
1240
|
+
if ((p!=NIL)&&(q!=NIL))
|
1241
|
+
{
|
1242
|
+
if (len==NIL) len=VSIZEBIN(q)-start; else len=VALTOINT(len);
|
1243
|
+
AudioAlaw2wav(VSTARTBIN(p),index,VSIZEBIN(p),VSTARTBIN(q),start,VSIZEBIN(q),len,mu);
|
1244
|
+
}
|
1245
|
+
}
|
1246
|
+
break;
|
1247
|
+
case OPwav2alaw:
|
1248
|
+
{
|
1249
|
+
int mu=VALTOINT(VPULL());
|
1250
|
+
int len=VPULL();
|
1251
|
+
int start=VALTOINT(VPULL());
|
1252
|
+
int q=VALTOPNT(VPULL());
|
1253
|
+
int index=VALTOINT(VPULL());
|
1254
|
+
int p=VALTOPNT(VSTACKGET(0));
|
1255
|
+
if ((p!=NIL)&&(q!=NIL))
|
1256
|
+
{
|
1257
|
+
if (len==NIL) len=VSIZEBIN(q)-start; else len=VALTOINT(len);
|
1258
|
+
AudioWav2alaw(VSTARTBIN(p),index,VSIZEBIN(p),VSTARTBIN(q),start,VSIZEBIN(q),len,mu);
|
1259
|
+
}
|
1260
|
+
}
|
1261
|
+
break;
|
1262
|
+
case OPnetPmk:
|
1263
|
+
{
|
1264
|
+
int key=VALTOPNT(VPULL());
|
1265
|
+
int ssid=VALTOPNT(VPULL());
|
1266
|
+
if ((key==NIL)||(ssid==NIL)) VPUSH(NIL);
|
1267
|
+
else
|
1268
|
+
{
|
1269
|
+
char pmk[32];
|
1270
|
+
netPmk(VSTARTBIN(ssid),VSTARTBIN(key),pmk);
|
1271
|
+
VPUSH(PNTTOVAL(VMALLOCSTR(pmk,32)));
|
1272
|
+
}
|
1273
|
+
}
|
1274
|
+
break;
|
1275
|
+
case OPflashFirmware:
|
1276
|
+
{
|
1277
|
+
int w=VALTOINT(VPULL());
|
1278
|
+
int v=VALTOINT(VPULL());
|
1279
|
+
int firmware=VALTOPNT(VSTACKGET(0));
|
1280
|
+
consolestr("flash firmware ");
|
1281
|
+
consolehx(v);
|
1282
|
+
consolestr(".");
|
1283
|
+
consolehx(w);
|
1284
|
+
consolestr("\n");
|
1285
|
+
if ((firmware!=NIL)&&(v==0x13fb6754)&&(w==0x0407FE58))
|
1286
|
+
{
|
1287
|
+
consolestr("************FLASH AND REBOOT NOW");
|
1288
|
+
sysFlash(VSTARTBIN(firmware),VSIZEBIN(firmware));
|
1289
|
+
}
|
1290
|
+
}
|
1291
|
+
break;
|
1292
|
+
case OPcrypt:
|
1293
|
+
{
|
1294
|
+
int alpha=VALTOINT(VPULL());
|
1295
|
+
int key=VALTOINT(VPULL());
|
1296
|
+
int len=VPULL();
|
1297
|
+
int index=VALTOINT(VPULL());
|
1298
|
+
int p=VALTOPNT(VSTACKGET(0));
|
1299
|
+
if (p!=NIL)
|
1300
|
+
{
|
1301
|
+
if (len==NIL) len=VSIZEBIN(p)-index; else len=VALTOINT(len);
|
1302
|
+
VSTACKSET(0,INTTOVAL(sysCrypt(VSTARTBIN(p),index,len,VSIZEBIN(p),key,alpha)));
|
1303
|
+
}
|
1304
|
+
else VSTACKSET(0,NIL);
|
1305
|
+
}
|
1306
|
+
break;
|
1307
|
+
case OPuncrypt:
|
1308
|
+
{
|
1309
|
+
int alpha=VALTOINT(VPULL());
|
1310
|
+
int key=VALTOINT(VPULL());
|
1311
|
+
int len=VPULL();
|
1312
|
+
int index=VALTOINT(VPULL());
|
1313
|
+
int p=VALTOPNT(VSTACKGET(0));
|
1314
|
+
if (p!=NIL)
|
1315
|
+
{
|
1316
|
+
if (len==NIL) len=VSIZEBIN(p)-index; else len=VALTOINT(len);
|
1317
|
+
VSTACKSET(0,INTTOVAL(sysUncrypt(VSTARTBIN(p),index,len,VSIZEBIN(p),key,alpha)));
|
1318
|
+
}
|
1319
|
+
else VSTACKSET(0,NIL);
|
1320
|
+
}
|
1321
|
+
break;
|
1322
|
+
case OPnetRssi:
|
1323
|
+
VPUSH(INTTOVAL(netRssi()));
|
1324
|
+
break;
|
1325
|
+
default:
|
1326
|
+
consolestr("unknown opcode ");consoleint(op);
|
1327
|
+
consolestr(" at ");consoleint(pc-1);consolestr("\n");
|
1328
|
+
// dump(bytecode,256);
|
1329
|
+
return;
|
1330
|
+
}
|
1331
|
+
/* if (bytecode[8]==0x48)
|
1332
|
+
{
|
1333
|
+
consolestr("bytecode erase ");consoleint(op);
|
1334
|
+
consolestr(" at ");consoleint(pc-1);consolestr("\n");
|
1335
|
+
dump(bytecode,256);
|
1336
|
+
}
|
1337
|
+
*/ }while(cont);
|
1338
|
+
currentop=-1;
|
1339
|
+
if (callstack>0)return;
|
1340
|
+
if(pc>=0)
|
1341
|
+
{
|
1342
|
+
// vmemDumpStack();
|
1343
|
+
// displaybc(pc);
|
1344
|
+
|
1345
|
+
// getchar();
|
1346
|
+
}
|
1347
|
+
op=255&bytecode[pc++];
|
1348
|
+
}
|
1349
|
+
}
|