OSDN Git Service

最初のコミット
[winaudioj/stedx.git] / disp.cpp
1 /*
2  * STed: disp.c (input and output subroutine)
3  */
4
5 #include        "sted.h"
6
7 unsigned char   fnc_dat[9*10][9]={
8
9   /*edit*/
10   N_("  TOP   "),N_(" BOTTOM "),N_("REPLACE "),N_("  FIND  "),N_(" F.NEXT "),
11   N_("  MARK  "),N_(" DELETE "),N_("  COPY  "),N_("  PASTE "),N_(" DOUBLE "),
12
13   /*edit shift*/
14   N_(" NOTES  "),N_(" OPTIM. "),N_(" S.DEL  "),N_(" F.BACK "),N_(" F.PREV "),
15   N_("SET UNDO"),N_("DO UNDO "),N_("MIX PST."),N_("REV.PST."),N_("        "),
16
17   /*one touch st/gt*/
18   N_("  192   "),N_("  144   "),N_("   96   "),N_("   72   "),N_("   48   "),
19   N_("   36   "),N_("   24   "),N_("   18   "),N_("   12   "),N_("    6   "),
20
21   /*cm64 con*/
22   N_(" SYSTEM "),N_("LA PATCH"),N_("PCM PAT."),N_("RHY.PAT."),N_(" TIMBRE "),
23   N_("LOAD CM6"),N_("SAVE CM6"),N_("  PLAY  "),N_("CM6 INIT"),N_("  EXIT  "),
24
25   /*trk.exclu. edit*/
26   N_("SEND GT "),N_("SEND VEL"),N_("SEND CH."),N_("CLR SUM "),N_("SEND SUM"),
27   N_("END EXCL"),N_("        "),N_("CHEK.SUM"),N_("EXC LOAD"),N_("EXC SAVE"),
28
29   /*visual edit*/
30   N_("TOP POSI"),N_("LAST POS"),N_("  LINE  "),N_("        "),N_(" WAVE-A "),
31   N_(" WAVE-B "),N_("SIN +CRV"),N_("SIN WAVE"),N_("TRIANGLE"),N_(" SQUARE "),
32
33   /*visual edit shift*/
34   N_("REV. U&D"),N_("REV. L&R"),N_(" RANDOM "),N_("        "),N_("R.WAVE-A"),
35   N_("R.WAVE-B"),N_("SIN -CRV"),N_("SIN WA/C"),N_("TRIANG/C"),N_("SQUARE/C"),
36
37   /*user exclu. edit*/
38   N_("SEND GT "),N_("SEND VEL"),N_("SEND CH."),N_("CLR SUM "),N_("SEND SUM"),
39   N_("END EXCL"),N_("        "),N_("CHEK.SUM"),N_("REX LOAD"),N_("REX SAVE"),
40
41   /*one touch velo*/
42   N_("        "),N_("  ppp   "),N_("   pp   "),N_("   p    "),N_("   mp   "),
43   N_("   mf   "),N_("   f    "),N_("   ff   "),N_("  fff   "),N_("        ")};
44
45 char    hex_code[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
46
47 int     meas_add(int me);
48
49 int isinputmode=0;
50
51 /***************************/
52 int     vinput(int l,int ln)
53 {
54   char  sb[256];
55   char  *pp=(char *)sb;
56
57   if(ln & 0x2000){strcpy(sb,hex_s(l,ln&0xff));}else{b_striS(sb,256,l);}
58
59   while(*pp=='0'){pp++;}
60   strcpy(sb,pp);
61
62   if( l==0 ){sb[0]=0;}
63
64 re_vinp:
65   sinput(sb,0x1400|ln);if(ecode==14){goto re_vinp;}
66   if( sb[0]==0 ){return(0);}
67   if(ln & 0x2000){strcat(sb,"H");}
68   return(str_val(sb));
69 }
70
71 /***************************/
72 /*
73   im  exc  len
74   0000 0000 0000 0000
75   |||| ||||
76   |||| |||+-return/space
77   |||| ||+--not return 
78   |||| |+---cursor last p.
79   |||| +----over write
80   | |+------chr.type(0=all/1=hex)
81   | +-------hex mode(vinput only)
82   +---------space nocut
83   -----------point move
84   */
85 void    sinput(char *sb,int ln)
86 {
87   int   a,x,y,xx,p=0,o=0,exc,im,sln;
88   char  ke[4],st[256],tmp0[256];
89
90   x=B_LOCATE(-1,0);y=x&0xffff;x=x>>16;
91   exc=ln>>8;ln=ln&0xff;im=(exc>>4)&3;
92   if((exc&0x80)==0){spcut(sb);}
93
94   if( (exc & 8)!=0 ){st[0]=0;o=1;}else{strcpy(st,sb);}
95   if( (exc & 4)!=0 ){p=strlen(st);}
96
97   if((exc&0x100)!=0){
98     int c=str_search(sb,"$<");
99     if(c){p=c-1;strcpy(&sb[c-1],&sb[c+1]);}
100   }
101
102   xx=x*8;if(edit_scr==1){xx=xx+56*8;}
103   /*c=point(xx,y*16+scyp);*/
104   fill(xx-1,y*16+scyp,xx+(ln)*8+1,y*16+15+scyp,7);
105   /*tdis(x,y,sb,ln,3);*/ /* Aug.28.1998 Daisuke Nagano */
106   tdis(x,y,eucconv(sb),ln,3); /* code converted! */
107
108   isinputmode=1;
109
110   while(1){
111     B_LOCATE(x+p,y);C_CURON();/*while(INPOUT(0xfe)==0){}*/ /* Jun.28.1998 Daisuke Nagano */
112     key_wait();
113     a=INPOUT(0xff);ecode=a;ke[0]=a;ke[1]=0;
114     sln=strlen(st);st[sln+1]=0;
115
116     if( (127<a && 161>a) || 224<a ){ke[1]=INPOUT(0xff);ke[2]=0;}
117     C_CUROFF();
118     if((a>=13 && a<=15)||((a==0x13||a==0x04||a==0x18||a==0x05||a==32)&&(exc&1)!=0)){
119       if((cmdflag&0x2)!=0 && (exc&1)!=0){
120         if(a==32){a=13;}else{if(a==13){a=32;}}
121       }
122       if(a==32||a==15){a=0x04;}
123       es=0;ecode=a;
124       if( st[0]==0 && o==1 ){break;}
125       if((exc&0x80)==0){spcut(st);}
126       strcpy(sb,st);break;
127     }
128
129     if( a==27 ){es= 1;break;}
130     if( a==0x18 && (exc&2)!=0 ){es= 0;break;}
131     if( a==0x13 && p>0 ){if(p==1){p=0;}else{if(knck(st,p-2)){p=p-2;}else{p=p-1;}}}
132     if( a==0x04 ){if( knck(st,p) ){p=p+(p+2<=ln)*2;}else{p=p+(p+1<=ln);}}
133
134     if( a==0x10 ){p=sln;}
135     if( a==0x11 ){p=0;}
136     if( a==0x15 ){strcpy(st,&st[p]);p=0;}
137
138     if( p>sln ){p=sln;}
139
140     if( a==0x0c ){p=0;st[0]=0;}
141
142     if( st[0]!=0 ){
143       if( a==8 && p>0 ){
144         int i=1+knck(st,p-2);
145         strcpy(tmp0,&st[p]);st[p-i]=0;strcat(st,tmp0);
146         p=p-i;
147       }
148       if( a==0x07 ){
149         strcpy(tmp0,&st[p+1+knck(st,p)]);st[p]=0;strcat(st,tmp0);
150       }
151       if( a==0x0b ){
152         st[p]=0;
153       }
154     }
155
156     if( im!=1 || (im==1 && str_search("0123456789ABCDEFabcdef.-Hh$",ke)>0) ){
157
158       if( a>31 && a!=127 ){
159         if( (B_SFTSNS()&4096)==0 && st[0]!=0 ){
160           strcpy(tmp0,&st[p+1+knck(st,p)]);st[p]=0;strcat(st,tmp0);
161         }
162         sln=strlen(st);
163         if( (sln+strlen(ke))<=ln ){
164           if( sln==p ){
165             strcat(st,ke);
166           }else{
167             strcpy(tmp0,&st[p]);st[p]=0;strcat(st,ke);strcat(st,tmp0);
168           }
169           p=p+strlen(ke);
170         }
171       }
172     }
173     /*tdis(x,y,st,ln,3);*/ /* Aug.28.1998 Daisuke nagano */
174     tdis(x,y,eucconv(st),ln,3); /* code converted! */
175   }
176   /*
177   tdis(x,y,sb,ln,3);B_LOCATE(x,y);
178   fill(xx-1,y*16+scyp,xx+ln*8+1,y*16+15+scyp,0);
179   */ /* Aug.28.1998 Daisuke Nagano */
180   fill(xx-1,y*16+scyp,xx+ln*8+1,y*16+15+scyp,0);
181   tdis(x,y,eucconv(sb),ln,3);B_LOCATE(x,y); /* code converted! */
182
183   isinputmode=0;
184 }
185
186 /***************************/
187 int     inkey2()
188 {
189   int   ke=0;
190   while(INPOUT(0xfe)!=0){INPOUT(0xff);}
191   /*while(ke==0){ke=INPOUT(0xff);}*/
192   key_wait();ke=INPOUT(0xff);
193   /*    if(ke>='a' && ke<='z'){ke-=32;}*/
194   return(ke);
195 }
196
197 /***************************/
198 int     inkey3(void)
199 {
200   int   ke=0,ex,sh;
201
202   while(INPOUT(0xfe)!=0){INPOUT(0xff);}
203   /*  while(ke==0){*/
204     key_wait();
205     ke=INPOUT(0xff);sh=B_SFTSNS()&15;
206
207     ex=BITSNS(0xa);
208     if( (ex&32)!=0 ){ke=0xe0;}
209     if( (ex&64)!=0 ){ke=0xe1;}
210     if( (ex&128)!=0 && sh==0){rcd->sts=0;}
211     ex=BITSNS(0xb);
212     if( (ex&1)!=0 && sh==0){rcd->sts=1;}
213     if( (ex&2)!=0 && sh==0){all_note_off(1);}
214     ex=BITSNS(0xc);
215     if( (ex&8)!=0 ){ke=0xf0;}
216     if( (ex&16)!=0 ){ke=0xf1;}
217     if( (ex&32)!=0 ){ke=0xf2;}
218     if( (ex&64)!=0 ){ke=0xf3;}
219     if( (ex&128)!=0 ){ke=0xf4;}
220     ex=BITSNS(0xd);
221     if( (ex&1)!=0 ){ke=0xf5;}
222     if( (ex&2)!=0 ){ke=0xf6;}
223     if( (ex&4)!=0 ){ke=0xf7;}
224     if( (ex&8)!=0 ){ke=0xf8;}
225     if( (ex&16)!=0 ){ke=0xf9;}
226     /*  }*/
227   while(INPOUT(0xfe)!=0){INPOUT(0xff);}
228   return(ke+(sh*256));
229 }
230
231 /***************************/
232 void    snsclr()
233 {
234   while(B_KEYSNS()){B_KEYINP();}
235 }
236
237 /***************************/
238 void    spcut(char *st)
239 {
240   int   p;
241
242   p= strlen(st);
243   while(1){
244     if( p<1 ){st[0]=0;return;}
245     if( st[p-1]!=32 && st[p-1]!=9 ){break;}
246     p--;
247   }
248   if( knck(st,p) ){p++;}
249   st[p]=0;
250 }
251
252 /***************************/
253 int     knck(char *st,int p)
254 {
255   int   i,f=0,a;
256
257   if( p<0 ){return(0);}
258   for(i=0 ;i<=p;i++){a=st[i];if( 127<a && (161>a || 224<a) ){f=(i==p);i++;}}
259   return(f);
260 }
261
262 /***************************/
263 int     str_search(char *tmp0,char *tmp1)
264 {
265   int   i=0;
266   unsigned char a;
267
268   while(tmp0[i]!=0){
269     a=tmp0[i];
270     if(a==tmp1[0]){
271       int j=0;
272       while(1){
273         if(tmp0[i+j]!=tmp1[j]){break;}
274         j++;
275         if(tmp1[j]==0){return(i+1);}
276       }
277     }
278     i++;
279     if( a>127 && (a<161 || a>224) ){i++;}
280   }
281   return(0);
282 }
283
284 /***************************/
285 int     str_last(unsigned char *tmp0)
286 {
287   int   i,a;
288
289   i=strlen((char*)tmp0);
290   if(i<2){return(tmp0[0]);}
291
292   a=tmp0[i-1];
293   if(knck((char*)tmp0,i-2)){a=tmp0[i-2]*256+a;}
294   return(a);
295 }
296
297 /***************************/
298 char    *jstrupr(char *st)
299 {
300   char  a;
301   char  *ss;
302   ss = st;
303
304   while(*st!=0){
305     a=*st;
306     if( 127<a && (161>a || 224<a) ){
307       st++;
308     }else{
309       if('a'<=a && 'z'>=a){*st=a-32;}
310     }
311     st++;
312   }
313   return(ss);
314 }
315
316 /***************************/
317 char    *spadd(char *s,int c)
318 {
319   static char   tmp0[128];
320   int   i;
321
322   strcpy(tmp0,s);for(i=strlen(s);i<=127;i++){tmp0[i]=32;}
323   tmp0[c]=0;return(tmp0);
324 }
325
326 /***************************/
327 char    *fstr(int v,int c)
328 {
329   static        char    tmp0[64];
330   char  tmp1[64];
331
332   b_striS(tmp1,64,v);strcpy(tmp0,"                ");strcat(tmp0,tmp1);
333   return(&tmp0[strlen(tmp0)-c]);
334 }
335
336 char    *nstr(int v)
337 {
338   static        char    tmp0[64];
339
340   b_striS(tmp0,64,v);
341   return(tmp0);
342 }
343
344 /***************************/
345 int     str_val(char *s)
346 {
347   int   v=0;
348   unsigned char a;
349
350   while(*s==' '){s++;}
351
352   jstrupr(s);
353   if(str_last((uint8*)s)!='H' && s[0]!='$' ){return atoi(s);}
354
355   while(*s!=0){
356     a=*s++;
357     if(a==' '||a==',' || a=='='){break;}
358     if(a>='0' && a<='9'){v=v<<4;v=v+(a-'0');}
359     if(a>='A' && a<='F'){v=v<<4;v=v+(a-'A')+10;}
360   }
361
362   return v;
363 }
364
365 /***************************/
366 char    *hex_s(int a,int c)
367 {
368   static        char    s[16];
369
370   s[c]=0;
371   while(c){c--;s[c]=hex_code[a&15];a=a>>4;}
372   return(s);
373 }
374
375 static int last_fncdis=-1;
376
377 /***************************/
378 void    fnc_dis(int n)
379 {
380   int   i,j;
381   char  tmp[64];
382
383   if (n==last_fncdis) return;
384   last_fncdis = n;
385
386   KNJCTRL(1,0);
387   if( n<0 ){
388     TXRASCPY((30*4)*256+(31*4),4,3);
389     for(i=1;i<=20;i++){FNCKEYST(i,"");}
390   }else{
391     if( n==2 ){
392       for(i=0;i<10;i++){
393         strcpy(tmp,fstr(stgt_tbl[i],4));
394         strcat(tmp,fstr(stgt_tbl[i+10],5));
395         for(j=0;j<9;j++){if(tmp[j]==32){tmp[j]='\\';}}
396
397         tmp[0]=0x0c;tmp[4]=0x0f;
398         tmp[5]=0x0c;tmp[9]=0x0e;tmp[10]=0;
399         FNCKEYST(i+1,tmp);
400         tmp[6]='0';tmp[7]=0xe;tmp[8]=0;
401
402         FNCKEYST(i+1+10,tmp);
403       }
404     }
405     if( n==8 ){
406       for(i=0;i<10;i++){
407         strcpy(tmp,fstr(stgt_tbl[i+20],3));
408         for(j=0;j<2;j++){if(tmp[j]==32){tmp[j]='\\';}}
409
410         tmp[3]=0x0d;tmp[4]=0;
411         FNCKEYST(i+1,tmp);
412         FNCKEYST(i+11,tmp);
413       }
414     }
415
416     tmp[0]=32;tmp[1]=0;if(n==1){tmp[0]='*';}
417     B_PUTMES(3,0,31,1,tmp);
418
419     for(i=0;i<=9;i++){
420       j=i*9+2;if(i>4){j+=3;}
421       B_PUTMES(11,j,31,7,_((const char *)fnc_dat[n*10+i]));
422     }
423     if ( (B_SFTSNS()&16)!=0 )
424       B_PUTMES( 3, 47, 31, 0, "*" );
425     else
426       B_PUTMES( 3, 47, 31, 0, " " );
427   }
428 }
429
430 /***************************/
431 void    home2(int y)
432 {
433   HOME(0,0,y);scyp=y;
434 }
435
436 /***************************/
437 void    edfield(int m)
438 {
439   if(m<1){fill(0,544,767,1023,0);if(m!=0){return;}}
440   if(edit_scr<2 ){
441     int xx;
442
443     if(m!=0){
444       if(edit_scr==0){fill(0,544,312,1001,0);}else{fill(455,544,767,1001,0);}
445     }
446     if(edit_scr==0){xx=1;box(7,603,312,999,4,65535);
447     }else{xx=57;box(455,603,760,999,4,65535);}
448
449     sdis(xx,556,"M:",3,15,8);
450     sdis2(xx,572," TR.:   MEAS:      CH.:    USED:",0,15,-1);
451     sdis(xx,589," MEAS STEP:NOTE K#    ST    GT   VEL",38,15,14);
452   }else{
453     sdis(21,556,"MEMO:",41,15,8);sdis(64,556,"TR.:",6,15,8);
454     sdis(72,556,"CH.:",7,15,8);sdis(80,556,"USED:",10,15,8);
455
456     box(0,630,688,1001,14,65535);
457     box(2,632,26,903,14,65535);box(28,632,148,903,14,65535);
458     box(2,905,148,999,14,65535);box(150,632,686,999,14,65535);
459
460     sdis(0,599+16,"    RHYTHM NAME   :STEP    4       8      12      16      20      24      28      32",86,15,14);
461     sdis(2,512+26*16,"VEL :",4,15,-1);sdis(2,512+27*16," GT :",4,15,-1);
462
463     sdis(46,592,"VEL",3,15,0);
464     box(397,590,642,608,14,65535);box(363,588,644,610,14,65535);
465   }
466   trk_free(tr_pos[track][edit_scr][0]+tr_pos[track][edit_scr][2]*4);trk_no();snsclr();
467 }
468
469 /***************************/
470 void    noed_cls()
471 {
472   if(edit_scr!=0){fill(0,544,454,1001,0);}else{fill(313,544,767,1001,0);}
473 }
474
475 void    noed_cls_t()
476 {
477   if(edit_scr!=0){txerase(0,32,454,489-32);}else{txerase(313,32,767-313,489-32);}
478 }
479
480 /***************************/
481 void    cons_md(int x)
482 {
483   if(edit_scr==1 && x!=0){B_CONSOL(56*8,0,95-56,30);}else{B_CONSOL(0,0,95,30);}
484 }
485
486 /***************************/
487 void    trk_free(int ad)
488 {
489   int   xx,yy,cc;
490   char  tmp[10];
491
492   if(edit_scr>=2){
493     xx=66;yy=556;cc=8;
494   }else{
495     if(edit_scr==0){xx=13+1;}else{xx=69+1;}
496     yy=572;cc=0;
497
498     vdis2(xx,yy,meas_no(ad),4,15,cc);
499   }
500
501   strcpy(tmp,chstr(channel_no(ad)));
502   sdis2(xx+10,yy,tmp,3,15,cc);
503
504   vdis2(xx+19,yy,(tr_len[track]>>2)-1,5,15,cc);
505
506   trksize(-2);
507 }
508
509 /***************************/
510 void    trk_no()
511 {
512   int   xx=31-8;
513
514   trk_no_dis();
515   if(edit_scr<2){
516     if(edit_scr==0){xx=0;}else{xx=56;}
517     vdis2(xx+6,572,track+1,2,15,0);
518   }else{
519     vdis2(68,556,track+1,2,15,8);
520   }
521   /*sdis(xx+3,556,trkmemo[track],36,15,8);*/
522   sdis(xx+3,556,eucconv(trkmemo[track]),36,15,8); /* Jul.02.1998 Daisuke Nagano */
523 }
524
525 /***************************/
526 void    sdis(int x,int y,char *s,int c,int c1,int c2)
527 {
528   x=x*8;
529   if( c2>=0 ){fill(x-1,y-1,x+c*8,y+15,c2);}
530   g_print(x,y,s,c1);
531 }
532
533 /***************************/
534 void    sdis2(int x,int y,char *s,int c,int c1,int c2)
535 {
536   x=x*8;
537   if( c2>=0 ){fill(x-1,y,x+c*8,y+15,c2);}
538   g_print(x,y,s,c1);
539 }
540
541 /***************************/
542 void    sdis3(int x,int y,char *s,int c,int c1,int c2)
543 {
544   x=x*8;
545   if( c2>=0 ){fill(x-1,y,x+c*8,y+7,c2);}
546   g_print2(x,y,s,c1);
547 }
548
549 /***************************/
550 void    vdis(int x,int y,int v,int c,int c1,int c2)
551 {
552   sdis(x,y,fstr(v,c),c,c1,c2);
553 }
554
555 /***************************/
556 void    vdis2(int x,int y,int v,int c,int c1,int c2)
557 {
558   sdis2(x,y,fstr(v,c),c,c1,c2);
559 }
560
561 /***************************/
562 void    vdis3(int x,int y,int v,int c,int c1,int c2)
563 {
564   sdis3(x,y,fstr(v,c),c,c1,c2);
565 }
566
567 /***************************/
568 void    g_print2(int x,int y,char *s,int c1)
569 {
570   char  tmp2[256];
571   int i=0;
572
573   while(*s!=0){tmp2[i++]=0xf0;tmp2[i++]=*s++;}
574   tmp2[i]=0;
575
576   g_print(x,y,tmp2,c1);
577 }
578
579 /***************************/
580 void    tdis(int x,int y,char *s,int c,int c1)
581 {
582   if(c1>=0){B_COLOR(c1);}
583   B_LOCATE(x,y);B_PRINT(spadd(s,c));B_COLOR(3);
584 }
585
586 /***************************/
587 void    msg(char *s)
588 {
589   msg_clr();B_LOCATE(0,1);B_PRINT(s);
590 }
591
592 void    msg_clr()
593 {
594 /*  TXRASCPY((30*4)*256+(1*4),4,3);*/
595   B_LOCATE(0,1);B_PRINT("                                                                                                ");
596 }
597
598 /***************************/
599 int     help(int md)
600 {
601   int   k,y,n,pg=0,ad,page=0,ln;
602   int   poi[128];
603   char  li[1024];
604   FILE  *fp;
605
606   if(!(fp= fopen2(hlp_path,"rb"))){
607     msg(_("Cannot find help file."));return(1);}
608   ln=fread(dat,1,63*1024,fp);fclose(fp);
609
610   ad=0;poi[0]=0;dat[ln]=0x1a;
611   while(ad<ln && page<127){
612     if(dat[ad]==12 || dat[ad]==0x1a ){
613       if( dat[ad]==12 ){ad=ad+2;}
614       page++;poi[page]=ad+1;
615       if( dat[ad]==0x1a){break;}
616     }
617     ad++;
618   }
619   if(page>0){page--;}
620
621   fill(0,544,767,1001,0);box(0,564,767,1001,14,65535);
622   sdis(0,548," COMMAND HELP",14,15,8);home2(512);
623   C_WINDOW(0,32);
624   B_LOCATE(0,31);B_PRINT(_(" [SPC]/[R.UP] NEXT PAGE  [BS]/[R.DOWN] PREV. PAGE  [TAB] SPECIFY PAGE  [ESC] EXIT"));
625
626   C_WINDOW(0,31);
627
628   while(1){
629     B_CLR_AL();
630     B_LOCATE(80,2);B_PRINT("PAGE:");B_PRINT(fstr(pg+1,3));
631     B_PRINT("/");B_PRINT(fstr(page+1,3));
632
633     y=4;ad=poi[pg];
634     while( dat[ad]!=0x1a && dat[ad]!=0 && dat[ad]!=12){
635       n=0;
636       while(dat[ad]>31||dat[ad]==9||dat[ad]==27){li[n]=dat[ad];n++;ad++;}
637       li[n]=0;if( li[0]!='*' ){B_LOCATE(0,y);B_PRINT(li);y++;}
638
639       ad++;
640       if(dat[ad]==0x0d){ad++;}
641       if(dat[ad]==0x0a){ad++;}
642     }
643     while(1){
644       k=inkey2();
645       if(k==27){break;}
646       if(k==0x12||k==32){
647         pg++;if(pg>page){pg=0;}
648         break;
649       }
650       if(k==0x17||k==8){
651         pg--;if(pg<0){pg=page;}
652         break;
653       }
654
655       if( k==9 ){
656         int n;
657         msg("Page No.=");n=vinput(pg+1,0x803);msg_clr();
658
659         if( es==0 && n>0 && n<=page+1){
660           pg=n-1;break;
661         }
662       }
663
664     }
665     if(k==27){break;}
666   }
667   C_WINDOW(0,32);B_CLR_AL();C_WINDOW(0,31);return(0);
668 }
669
670 /***************************/