-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathcmd.cpp
More file actions
553 lines (514 loc) · 15.8 KB
/
cmd.cpp
File metadata and controls
553 lines (514 loc) · 15.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
#include "comm.h"
#include "nand.h"
#include "nor.h"
#include <cstdint>
#include <cstdio>
#include <time.h>
#include <mutex>
#include "mem.h"
#include "ram.h"
#include "state.h"
#include "cpu.h"
extern "C" {
#include "ansi/w65c02.h"
}
#include "compare/pc1000bus.h"
#include "nc2000.h"
#include "nor.h"
extern nc2k_states_t nc2k_states;
extern CPUInterface *cpu;
deque<string> udp_msgs;
std::mutex g_mutex;
bool is_nc2600_rom(){
/*if(nand_magic=="ggv nc2010"){
return true;
}*/
if(nand_magic[8]=='1') return true;
return false;
}
bool is_nc2000_rom(){
if(nand_magic[8]=='0' &&nor_buff[2]==0x36) return true;
return false;
}
bool is_nc2010_rom(){
if(nand_magic[8]=='0' &&nor_buff[2]==0x4f) return true;
return false;
}
// call this function when you want to cheat wqx to do a soft boot
// other wise wqx will do cold boot
// this is only a trick, mianly used in this cmd.cpp, not part of emulation
void set_warm_reset_flag(){
/*
lda io_timer0_val
ora io_timer1_val
beq cold_start
*/
// as long as one is non-zero, it will pass the check
ram_io[2]=1;
ram_io[3]=1;
}
void push_message(string msg){
if(msg.empty()) return;
g_mutex.lock();
udp_msgs.push_back(msg);
g_mutex.unlock();
}
string get_message(){
string res;
g_mutex.lock();
if(!udp_msgs.empty()){
res= udp_msgs.front();
udp_msgs.pop_front();
udp_msgs.clear();
}
g_mutex.unlock();
return res;
}
char *peek_message(){
char *p=NULL;
g_mutex.lock();
if(!udp_msgs.empty()){
p= (char *)udp_msgs.front().c_str();
}
g_mutex.unlock();
return p;
}
static deque<char> queue;
static int32_t dummy_io_cnt=-1;
static int put_total_size=0;
bool dummy_io_for_read(uint16_t addr, uint8_t &value){
if(addr!=0x3fff) return false;
if(dummy_io_cnt== -1) return false;
if(queue.empty()) {
value=0;
dummy_io_cnt=-1;
printf("[put] done, total size=%d\n",put_total_size);
put_total_size=0;
//printf("<dummy read %02x>\n",value);
return true;
}
if(dummy_io_cnt++%2==0) {
value=1;
}else{
put_total_size++;
if(put_total_size%10000==0){
printf("[put] sent %d bytes\n",put_total_size);
}
value=queue.front();
queue.pop_front();
}
//printf("<dummy read %02x>\n",value);
return true;
}
static deque<char> queue_for_write;
static string file_name_for_write;
static int32_t dummy_io_write_cnt=-1;
bool dummy_io_for_write(uint16_t addr, uint8_t value){
if(addr!=0x3fff) return false;
if(dummy_io_write_cnt== -1) {
//printf("write value=%02x pc=%04x!!\n",value,mPC);
//printf("but dummy io is closed\n");
return false;
}
if(dummy_io_write_cnt++%2==0) {
if(value==1) {
//printf("continue!!\n");
//do nothing
}
else if(value==0) {
printf("[get] done, total size=%d\n",(int)queue_for_write.size());
if(dummy_io_write_cnt!=-1){
auto fp=fopen(file_name_for_write.c_str(),"wb");
for(auto c: queue_for_write){
fwrite(&c,1,1,fp);
}
fclose(fp);
queue_for_write.clear();
}
dummy_io_write_cnt=-1;
}else{
printf("got invalid value for dummy_io");
assert(false);
}
}else{
//printf("got char %02x, off=%d\n",value,(int)queue_for_write.size());
queue_for_write.push_back(value);
if(queue_for_write.size()%10000==0) {
printf("[get] got %d bytes\n",(int)queue_for_write.size());
}
}
//printf("<dummy read %02x>\n",value);
return true;
}
void copy_to_addr(uint16_t addr, uint8_t * buf,uint16_t size){
for(uint32_t i=0;i<size;i++){
Peek16(addr+i)=buf[i];
}
}
std::string HexToBytes(const std::string& hex) {
std::string bytes;
for (unsigned int i = 0; i < hex.length(); i += 2) {
std::string byteString = hex.substr(i, 2);
char b = (char) strtol(byteString.c_str(), NULL, 16);
bytes.push_back(b);
}
return bytes;
}
void handle_cmd(string str){
printf("handling cmd ");
auto cmds=split_s(str," ");
for(int i=0;i<cmds.size();i++){
printf("<%s>",cmds[i].c_str());
}
printf("\n");
fflush(stdout);
if(cmds.size()==0) return;
if(cmds[0]=="?"||cmds[0]=="/?"||cmds[0]=="h"||cmds[0]=="H"||cmds[0]=="HELP"||cmds[0]=="help")
{
void print_help();
print_help();
return;
}
if(cmds[0]=="wr") cmds[0]="warm_reset";
if(cmds[0]=="cr") cmds[0]="cold_reset";
if(cmds[0]=="sf") cmds[0]="save_flash";
if(cmds[0]=="sa") cmds[0]="save_all";
//if(cmds[0]=="ss") cmds[0]="save_state";
if(cmds[0]=="ds") cmds[0]="delete_state";
if(cmds[0]=="f") cmds[0]="file_manager";
if(cmds[0]=="cf") cmds[0]="create_folder";
if(cmds[0]=="cfh") cmds[0]="create_folder_hex";
if(cmds[0]=="st") cmds[0]="sync_time";
if(cmds[0]=="sp") cmds[0]="speed";
if(cmds[0]=="ed"||cmds[0]=="ec") cmds[0]="edit";
if(cmds[0]=="ffl") cmds[0]="fast_forward_limit";
if(cmds[0]=="hack1"){
void hack1_save_nc1020_12m_rom();
hack1_save_nc1020_12m_rom();
return;
}
if(cmds[0]=="warm_reset"){
set_warm_reset_flag();
void warm_reset();
warm_reset();
return;
}
if(cmds[0]=="cold_reset"){
void cold_reset();
cold_reset();
return;
}
if(cmds[0]=="exit"){
exit(-1);
}
if(cmds[0]=="save_flash"||cmds[0]=="save_all"/*||cmds[0]=="save_state"*/){
//pitfall: don't use save_state alone, expecially on nc1020
// since sometimes wqx might modify nor even if you don't change any file. then saved state won't match with nor
// use save_all instead
string file="";
if(cmds.size()>1){
file=cmds[1];
}
if(cmds[0]=="save_flash"||cmds[0]=="save_all"){
save_flash(file);
}
if(/*cmds[0]=="save_state"||*/cmds[0]=="save_all"){
save_state(file);
}
return;
}
if(cmds[0]=="delete_state"||cmds[0]=="del_state"){
string file="";
if(cmds.size()>1){
file=cmds[1];
}
delete_state(file);
return;
}
if(cmds[0]=="dump"){
if(cmds.size()<2){
printf("dump: not enough argument\n");
return;
}
uint32_t start=stoi(cmds[1],0,16);
uint32_t size=stoi(cmds[2],0,10);
for(uint32_t i=start;i<start+size;i++){
printf("%02x ",Peek16(i));
}
printf("\n");
return;
}
if(cmds[0]=="edit"||cmds[0]=="modify"){
uint32_t start=stoi(cmds[1],0,16);
for(uint32_t i=2;i<cmds.size();i++){
Peek16(start++)=stoi(cmds[i],0,16);;
}
printf("ec done\n");
return;
}
if(cmds[0]=="file_manager"||cmds[0]=="f"){
if(!nc2000mode&&!nc3000mode) return;
cpu->PC=0x3000;
/*if(nc1020mode){
uint8_t buf[]={0x00,0x2d,0x93,0x18,0x90,0xfa};
copy_to_addr(0x3000, buf, sizeof buf);
}*/
if(nc2000mode){
if(is_nc2600_rom()){
uint8_t buf[]={0x00,0x27,0x05,0x18,0x90,0xfa};
copy_to_addr(0x3000, buf, sizeof buf);
}else{
uint8_t buf[]={0x00,0x28,0x05,0x18,0x90,0xfa};
copy_to_addr(0x3000, buf, sizeof buf);
}
}
if(nc3000mode){
uint8_t buf[]={0x00,0x28,0x05,0x18,0x90,0xfa};
copy_to_addr(0x3000, buf, sizeof buf);
}
return;
}
if(cmds[0]=="create_dir" || cmds[0]=="create_dir_hex" || cmds[0]=="create_folder" || cmds[0]=="create_folder_hex"){
//printf("<pc=%x>\n",cpu->PC);
cpu->PC=0x3000;
string dir_name=cmds[1];
if(cmds[0]=="create_dir_hex"|| cmds[0]=="create_folder_hex"){
dir_name=HexToBytes(dir_name);
}
if(nc1020mode){
copy_to_addr(0x121c, (uint8_t*)(dir_name+" ").c_str(), 16);
Peek16(0x1219)=0x02;
Peek16(0x121A)=0xF0;
Peek16(0x121B)=0xFF;
Peek16(0x122F)=0xFF;
Peek16(0x1230)=0xFF;
Peek16(0x1231)=0xFF;
if(nc1020tw_mode){
uint8_t buf[]={0x00,0x01,0x10,0x00,0x04,0x83,0x18,0x90,0xfa};
copy_to_addr(0x3000, buf, sizeof buf);
}else {
uint8_t buf[]={0x00,0x01,0x93,0x00,0x04,0x83,0x18,0x90,0xfa};
copy_to_addr(0x3000, buf, sizeof buf);
}
}
if(nc2000mode){
set_warm_reset_flag();
if(is_nc2600_rom()){
copy_to_addr(0x08d6, (uint8_t*)dir_name.c_str(), dir_name.size()+1);
//Peek16(0x0912)=0x02; //not really useful?
uint8_t buf[]={0x00,0x0b,0x05,0x00,0x01,0xc0};
copy_to_addr(0x3000, buf, sizeof buf);
}else{
if(is_nc2000_rom()){
if(debug_level>=1) printf("is nc2000 rom\n");
copy_to_addr(0x08be, (uint8_t*)dir_name.c_str(), dir_name.size()+1);
}else{
if(debug_level>=1) printf("is nc2010 rom\n");
copy_to_addr(0x08ac, (uint8_t*)dir_name.c_str(), dir_name.size()+1);
}
uint8_t buf[]={0x00,0x0b,0x05,0x00,0x01,0xc0};
copy_to_addr(0x3000, buf, sizeof buf);
}
}
if(nc3000mode){
copy_to_addr(0x088d, (uint8_t*)dir_name.c_str(), dir_name.size()+1);
uint8_t buf[]={0x00,0x0b,0x05,0x00,0x28,0x05,0x18,0x90,0xfa};
copy_to_addr(0x3000, buf, sizeof buf);
}
return;
}
if(cmds[0]=="wqxhex"){
vector<char> wqxhex;
read_file("wqxhex.bin", wqxhex);
memcpy(nc2k_states.ext_ram+0x4000, &wqxhex[0], wqxhex.size());
ram_io[0x00]=0x80;
ram_io[0x0a]=0x80;
super_switch();
cpu->PC=0x4018;
return;
}
if(cmds[0]=="speed"){
if(cmds.size()==1) speed_multiplier=1;
else{
sscanf(cmds[1].c_str(),"%lf",&speed_multiplier);
}
printf("change speed to %f\n",speed_multiplier);
return;
}
if(cmds[0]=="log"){
enable_dyn_debug=true;
return;
}
if(cmds[0]=="nolog"){
enable_dyn_debug=false;
return;
}
if(cmds[0]=="fast_forward_limit"){
if(cmds.size()==1) {
fast_forward_limit=0;
}
else{
fast_forward_limit= stod(cmds[1]);
}
printf("set fast forward limit to %f\n",fast_forward_limit);
return;
}
if(cmds[0]=="get"){
//if(!nc2000mode) return;
string src=cmds[1];
string target=cmds[1];
if(cmds.size()>2) target=cmds[2];
file_name_for_write=target;
dummy_io_write_cnt = 0;
if(nc2000mode){
set_warm_reset_flag();
if(is_nc2600_rom()){
copy_to_addr(0x08d6, (uint8_t*)src.c_str(), src.size()+1);
uint8_t buf[]={0xA9,0x80,0x8D,0x12,0x09,0xA9,0xEF,0x8D,0x13,0x09,0x8D,0x14,0x09,0x00,0x14,0x05,
0xA9,0x00,0x8D,0xF6,0x03,0xA9,0x00,0x85,0xDD,0xA9,0x32,0x85,0xDE,0xA9,0x01,0x8D,
0x0F,0x09,0xA9,0x00,0x8D,0x10,0x09,0x8D,0x11,0x09,0x00,0x15,0x05,0xAD,0x0F,0x09,
0xF0,0x0E,0xA9,0x01,0x8D,0xFF,0x3F,0xAD,0x00,0x32,0x8D,0xFF,0x3F,0xB8,0x50,0xD0,
0xA9,0x00,0x8D,0xFF,0x3F,0x00,0x16,0x05,0x00,0x01,0xC0,};
copy_to_addr(0x3000,buf,sizeof(buf));
}else{
if(is_nc2000_rom()){
if(debug_level>=1) printf("is nc2000 rom\n");
copy_to_addr(0x08be, (uint8_t*)src.c_str(), src.size()+1);
}else{
if(debug_level>=1) printf("is nc2010 rom\n");
copy_to_addr(0x08ac, (uint8_t*)src.c_str(), src.size()+1);
}
uint8_t buf[]={0xA9,0x80,0x8D,0xFA,0x08,0xA9,0xEF,0x8D,0xFB,0x08,0x8D,0xFC,0x08,0x00,0x15,0x05,
0xA9,0x00,0x8D,0xF6,0x03,0xA9,0x00,0x85,0xDD,0xA9,0x32,0x85,0xDE,0xA9,0x01,0x8D,
0xF7,0x08,0xA9,0x00,0x8D,0xF8,0x08,0x8D,0xF9,0x09,0x00,0x16,0x05,0xAD,0xF7,0x08,
0xF0,0x0E,0xA9,0x01,0x8D,0xFF,0x3F,0xAD,0x00,0x32,0x8D,0xFF,0x3F,0xB8,0x50,0xD0,
0xA9,0x00,0x8D,0xFF,0x3F,0x00,0x16,0x05,0x00,0x01,0xC0,};
copy_to_addr(0x3000,buf,sizeof(buf));
}
}
if(nc1020mode){
set_warm_reset_flag();
copy_to_addr(0x121c, (uint8_t*)(src+" ").c_str(), 16);
if(nc1020tw_mode){
uint8_t buf[]={0xA9,0x00,0x8D,0x14,0x12,0x00,0x02,0x10,0xB0,0x32,0xA9,0x00,0x8D,0x6E,0x04,0x8D,
0xAE,0x04,0xA9,0x00,0x8D,0x0D,0x12,0xA9,0x32,0x8D,0x0E,0x12,0xA9,0x01,0x8D,0x0F,
0x12,0xA9,0x00,0x8D,0x10,0x12,0x00,0x04,0x10,0xAD,0x0F,0x12,0xF0,0x0E,0xA9,0x01,
0x8D,0xFF,0x3F,0xAD,0x00,0x32,0x8D,0xFF,0x3F,0xB8,0x50,0xCE,0xA9,0x00,0x8D,0xFF,
0x3F,0x00,0x07,0x10,0x00,0x01,0xC0,};
copy_to_addr(0x3000,buf,sizeof(buf));
}else{
uint8_t buf[]={0xA9,0x00,0x8D,0x14,0x12,0x00,0x02,0x93,0xB0,0x32,0xA9,0x00,0x8D,0x6E,0x04,0x8D,
0xAE,0x04,0xA9,0x00,0x8D,0x0D,0x12,0xA9,0x32,0x8D,0x0E,0x12,0xA9,0x01,0x8D,0x0F,
0x12,0xA9,0x00,0x8D,0x10,0x12,0x00,0x04,0x93,0xAD,0x0F,0x12,0xF0,0x0E,0xA9,0x01,
0x8D,0xFF,0x3F,0xAD,0x00,0x32,0x8D,0xFF,0x3F,0xB8,0x50,0xCE,0xA9,0x00,0x8D,0xFF,
0x3F,0x00,0x07,0x93,0x00,0x01,0xC0,};
copy_to_addr(0x3000,buf,sizeof(buf));
}
}
cpu->PC=0x3000;
//enable_dyn_debug=true;
return;
}
if(cmds[0]=="put"){
vector<char> file;
if(read_file_noexit(cmds[1], file)!=0){
return ;
}
string target=split_s(cmds[1],"/").back();
if(cmds.size()>2) target=cmds[2];
queue.clear();
for(int i=0;i<file.size();i++){
queue.push_back(file[i]);
}
dummy_io_cnt=0;
if(nc1020mode){
copy_to_addr(0x121c, (uint8_t*)(target+" ").c_str(), 16);
Peek16(0x1219)=0x61;
Peek16(0x121A)=0xF8;
Peek16(0x121B)=0xFF;
Peek16(0x122F)=0xFF;
Peek16(0x1230)=0xFF;
Peek16(0x1231)=0xFF;
set_warm_reset_flag();
if(nc1020tw_mode){
uint8_t buf[]={0xea,0xea,0xea,0x00,0x01,0x10,0xA9,0x00,0x8D,0x6E,0x04,0x8D,0xAE,0x04,0xAD,0xFF,
0x3F,0xC9,0x00,0xF0,0x20,0xAD,0xFF,0x3F,0x8D,0x00,0x32,0xA9,0x00,0x8D,0x0D,0x12,
0xA9,0x32,0x8D,0x0E,0x12,0xA9,0x01,0x8D,0x0F,0x12,0xA9,0x00,0x8D,0x10,0x12,0x00,
0x05,0x10,0xB8,0x50,0xD1,0x00,0x07,0x10,0x00,0x01,0xC0,};
copy_to_addr(0x3000, buf, sizeof buf);
}else{
uint8_t buf[]={0xea,0xea,0xea,0x00,0x01,0x93,0xA9,0x00,0x8D,0x6E,0x04,0x8D,0xAE,0x04,0xAD,0xFF,
0x3F,0xC9,0x00,0xF0,0x20,0xAD,0xFF,0x3F,0x8D,0x00,0x32,0xA9,0x00,0x8D,0x0D,0x12,
0xA9,0x32,0x8D,0x0E,0x12,0xA9,0x01,0x8D,0x0F,0x12,0xA9,0x00,0x8D,0x10,0x12,0x00,
0x05,0x93,0xB8,0x50,0xD1,0x00,0x07,0x93,0x00,0x01,0xC0,};
copy_to_addr(0x3000, buf, sizeof buf);
}
}
if(nc2000mode){
if(is_nc2600_rom()){
copy_to_addr(0x08d6, (uint8_t*)target.c_str(), target.size()+1);
/*
for(;;){
auto value=Load(0x3fff);
printf("<%02x>",value);
if(value==0) break;
auto value2=Load(0x3fff);
printf("<%02x>",value2);
}
printf("\n");*/
set_warm_reset_flag();
uint8_t buf[]={0x00,0x1C,0x05,0xA9,0x70,0x8D,0x12,0x09,0xA9,0xEF,0x8D,0x13,0x09,0x8D,0x14,0x09,
0x00,0x14,0x05,0xA9,0x00,0x8D,0xF6,0x03,0xAD,0xFF,0x3F,0xC9,0x00,0xF0,0x21,0xAD,
0xFF,0x3F,0x8D,0x00,0x32,0xA9,0x00,0x85,0xDD,0xA9,0x32,0x85,0xDE,0xA9,0x01,0x8D,
0x0F,0x09,0xA9,0x00,0x8D,0x10,0x09,0x8D,0x11,0x09,0x00,0x17,0x05,0xB8,0x50,0xD3,
0x00,0x16,0x05,0x00,0x01,0xC0,};
copy_to_addr(0x3000,buf,sizeof(buf));
}else{
set_warm_reset_flag();
if(is_nc2000_rom()){
if(debug_level>=1) printf("is nc2000 rom\n");
copy_to_addr(0x08be, (uint8_t*)target.c_str(), target.size()+1);
uint8_t buf[]={0x00,0x1D,0x05,0xA9,0x70,0x8D,0xFA,0x08,0xA9,0xEF,0x8D,0xFB,0x08,0x8D,0xFC,0x08,
0x00,0x15,0x05,0xA9,0x00,0x8D,0xF6,0x03,0xAD,0xFF,0x3F,0xC9,0x00,0xF0,0x21,0xAD,
0xFF,0x3F,0x8D,0x00,0x32,0xA9,0x00,0x85,0xDD,0xA9,0x32,0x85,0xDE,0xA9,0x01,0x8D,
0xF7,0x08,0xA9,0x00,0x8D,0xF8,0x08,0x8D,0xF9,0x08,0x00,0x18,0x05,0xB8,0x50,0xD3,
0x00,0x17,0x05,0x00,0x01,0xC0,};
copy_to_addr(0x3000,buf,sizeof(buf));
}else{
if(debug_level>=1) printf("is nc2010 rom\n");
copy_to_addr(0x08ac, (uint8_t*)target.c_str(), target.size()+1);
uint8_t buf[]={0x00,0x1D,0x05,0xA9,0x70,0x8D,0xE8,0x08,0xA9,0xEF,0x8D,0xE9,0x08,0x8D,0xEA,0x08,
0x00,0x15,0x05,0xA9,0x00,0x8D,0xF6,0x03,0xAD,0xFF,0x3F,0xC9,0x00,0xF0,0x21,0xAD,
0xFF,0x3F,0x8D,0x00,0x32,0xA9,0x00,0x85,0xDD,0xA9,0x32,0x85,0xDE,0xA9,0x01,0x8D,
0xE5,0x08,0xA9,0x00,0x8D,0xE6,0x08,0x8D,0xE7,0x08,0x00,0x18,0x05,0xB8,0x50,0xD3,
0x00,0x17,0x05,0x00,0x01,0xC0,};
copy_to_addr(0x3000,buf,sizeof(buf));
}
}
}
if(nc3000mode){
copy_to_addr(0x088d, (uint8_t*)target.c_str(), target.size()+1);
uint8_t buf[]={0xA9,0x70,0x8D,0xC9,0x08,0xA9,0xEF,0x8D,0xCA,0x08,0x8D,0xCB,0x08,0x00,0x15,0x05,
0xA9,0x00,0x8D,0xF6,0x03,0xAD,0xFF,0x3F,0xC9,0x00,0xF0,0x21,0xAD,0xFF,0x3F,0x8D,
0x00,0x32,0xA9,0x00,0x85,0xE0,0xA9,0x32,0x85,0xE1,0xA9,0x01,0x8D,0xC6,0x08,0xA9,
0x00,0x8D,0xC7,0x08,0x8D,0xC8,0x08,0x00,0x18,0x05,0x4C,0x10,0x30,0x00,0x17,0x05,
0x00,0x28,0x05,0x4C,0x40,0x30,};
copy_to_addr(0x3000,buf,sizeof(buf));
}
cpu->PC=0x3000;
return;
}
if(cmds[0]=="sync_time") {
if(nc2000mode){
extern void sync_time_2000();
sync_time_2000();
}
if(nc1020mode){
extern void sync_time_1020();
sync_time_1020();
}
return ;
}
printf("unknow command <%s>\n",cmds[0].c_str());
fflush(stdout);
}