long change(char *to,char *ton) /* find out what is in current auto */ { long ok; /* ok = Fopen(nm_a,0); if (ok>0) return Fclose(ok), change_mint(nn,ton)|change_auto(nm,to); ok = Fopen(xm_a,0); if (ok>0) return Fclose(ok), change_mint(nx,ton)|change_auto(xm,to); ok = Fopen(tm_a,0); if (ok>0) return Fclose(ok), change_mint(nt,ton)|change_auto(tm,to); */ ok = Fopen(nc_a,0); if (ok>0) return Fclose(ok), change_mint(nn,ton)|change_auto(nc,to); ok = Fopen(xc_a,0); if (ok>0) return Fclose(ok), change_mint(nx,ton)|change_auto(xc,to); ok = Fopen(tc_a,0); if (ok>0) return Fclose(ok), change_mint(nt,ton)|change_auto(tc,to); printf("auto &| mint names messed up\n"); if (!(MagX|MiNT)) Bconin(2); return 1; }
main() { register int i,j; /* use em for FOR loops */ point3d pointi; /* declare one instance of our point3d struct */ int color =1; /* color to draw triangle */ char com; /* for user input */ puts("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); puts("1-Spin Y 2-Spin X 3-Spin Z 9-Quit\n"); theport = a_init(); /* line a invokage */ theport -> plane0 = 1; theport -> plane1 = 0; theport -> plane2 = 0; theport -> plane3 = 0; for(i=0;i<nlines;i++) /* set up points-to-connect lookup table*/ { drawpt1[i] = point_[linefrom[i]]; drawpt2[i] = point_[lineto[i]]; } com = 0x32; /* set to spin about x */ while( com != 0x39) { if( Bconstat(2) ) /* if keypress */ com = Bconin(2); /* get input */ /* The main loop */ for(i=0;i<npts;i++) { pointi = point_[i]; /* get current point data. We do this for efficiency, since we will use this value many times within one loop it's more efficient to compute it's value only once */ if(com == 0x31) { /* spin y */ point_[i].x =( mu_global_c(pointi.x) - mu_global_s(pointi.z))>>BITSH; /* since our points are scaled AND or trig angles, sin&cos values are scaled we must divide by scale once here*/ point_[i].z =( mu_global_s(pointi.x) + mu_global_c(pointi.z))>>BITSH; } if(com == 0x32) { /* spin x */ point_[i].y =( mu_global_c(pointi.y) + mu_global_s(pointi.z))>>BITSH; point_[i].z =( -(mu_global_s(pointi.y)) + mu_global_c(pointi.z))>>BITSH; } if(com == 0x33) { /* spin z */ point_[i].x =( mu_global_c(pointi.x) + mu_global_s(pointi.y))>>BITSH; point_[i].y =( mu_global_c(pointi.y) - mu_global_s(pointi.x))>>BITSH; }
main () { int c; while ('\033' NE (0x00FF & (c = Bconin (CON_DEV)))) { printf ("%08x\n", c); } }
int main(void) { float a,b,c,x; adr=Malloc(4096); ability=Dsp_RequestUniqueAbility(); status=Dsp_LoadProg(file,ability,adr); if (!status) { printf("\n\nComparaison SIN/DSP_SIN\n\n"); for(i=0;i<360;i+=36) { x=i; a=sin((double)(x*2.0*M_PI)/360.0); b=dsp_sin(x); c=0; if (fabs(a)>0.00001) c=fabs(100.0*(a-b)/a); /* calcul de l'erreur */ printf("SIN(%f)=%f DSP_SIN(%f)=%f Erreur=%f %%\n",x,a,x,b,c); } printf("\n\nComparaison COS/DSP_COS\n\n"); for(i=0;i<360;i+=36) { x=i; a=cos((double)(x*2.0*M_PI)/360.0); b=dsp_cos(x); c=0; if (fabs(a)>0.00001) c=fabs(100.0*(a-b)/a); /* calcul de l'erreur */ printf("COS(%f)=%f DSP_COS(%f)=%f Erreur=%f %%\n",x,a,x,b,c); } printf("\n\nComparaison SQRT/DSP_SQR\n\n"); for(i=0;i<10;i++) { x=i/10.0; a=sqrt(x); b=dsp_sqr(x); c=0; if (fabs(a)>0.00001) c=fabs(100.0*(a-b)/a); /* calcul de l'erreur */ printf("SQRT(%f)=%f DSP_SQR(%f)=%f Erreur=%f %%\n",x,a,x,b,c); } } else printf("Fichier %s introuvable.\n",file); printf("Appuyez sur une touche\n"); Bconin(2); Mfree(adr); return 0; }
long end_ren(long ok, char *now, char *to) { if (ok) if (!(MagX|MiNT)) Bconin(2); else ; else { printf("%s --> %s\n",now,to); /* Bconin(2); */ } return ok; }
void main(void) { int Hdl; void *OldScreen; int dummy; long i; /* d‚termine la base line A pour la position souris */ linea_init(); /* charge l'image et la duplique en largeur */ Hdl=Fopen("MORETA.NEO",0); if (Hdl<0) { appl_exit(); Pterm0(); } Fseek(4L,Hdl,0); Fread(Hdl,32L,NewPalette); Fseek(128L,Hdl,0); for (i=0;i<200;i++) { LINE1 *p=(LINE1 *)&picbuf[0].line[i]; Fread(Hdl,sizeof(LINE1),p); p[1]=p[0]; } Fclose(Hdl); /* Duplique l'image en hauteur */ picbuf[1]=picbuf[0]; /* Installe la pallette et sauve l'ancienne */ InsPalette(); /* Sauve l'adresse de l'‚cran courant */ OldScreen=GetScreenPtr(); /* Installe la routine de scrolling en VBL */ InsVBL(Scrolling); /* Boucle en attendant un Ctrl-C */ while (1) if (Bconstat(2)<0 && (char)Bconin(2)==3) break; /* Remet tout en ordre et sort de l… */ RmvVBL(); SetScreenPtr(OldScreen); SetScroll(0); SetLineStride(0); RestPalette(); }
int main(int argc, char *argv[]) { long fl; MagX=get_cookie('MagX',0L); MiNT=get_cookie('MiNT',0L); if (argc > 1) { strlwr(argv[1]); printf("name -=%s=-\n",argv[1]); if ( strncmp(argv[1],autonam,strlen(autonam)) == 0 && *(argv[1] + strlen(autonam)) == '.' ) { char *s = argv[1]; while (*s && *s != '.') s++; s++; /* The argv tells what we want to have. that name must change to "auto". But before that we must look what is in the current "auto" && change that "auto" to what's mentioned within it. This is determined in 'change()' */ if (*(s+2) == 0 || *(s+2) == '\\') { /* if (*s == 'n' && *(s+1) == 'a') /* N.AES */ return change(nm,nn); if (*s == 'x' && *(s+1) == 'a') /* XaAES */ return change(xm,nx); if (*s == 't' && *(s+1) == 'o') /* tos */ return change(tm,nt); */ if (*s == 'n' && *(s+1) == 'a') /* N.AES */ return change(nc,nn); if (*s == 'x' && *(s+1) == 'a') /* XaAES */ return change(xc,nx); if (*s == 't' && *(s+1) == 'o') /* tos */ return change(tc,nt); } printf("needs one of .na, .xa, || .to\n"); if (!(MagX|MiNT)) Bconin(2); return 1; }
ssize_t CharHandle::ReadAt(void *cookie, off_t pos, void *buffer, size_t bufferSize) { char *string = (char *)buffer; int i; // can't seek for (i = 0; i < bufferSize; i++) { if (Bconstat(fHandle) == 0) return i; string[i] = (char)Bconin(fHandle); } return bufferSize; }
main() { int key; Supexec(doit); for (;;) { while (Bconstat(2)!=-1); key=Bconin(2); if (key=='r') Supexec(inner_loop); if (key=='c') Supexec(outer_loop); if (key=='s') Supexec(monitor_sound); if (key=='d') Supexec(disable_loop); if (key=='e') Supexec(enable_loop); if (key==' ') break; } }
void AtariBios_PumpEvents(_THIS) { int i; SDL_keysym keysym; SDL_AtariMint_BackgroundTasks(); /* Update pressed keys */ SDL_memset(bios_currentkeyboard, 0, ATARIBIOS_MAXKEYS); while (Bconstat(_CON)) { unsigned long key_pressed; key_pressed=Bconin(_CON); bios_currentkeyboard[(key_pressed>>16)&(ATARIBIOS_MAXKEYS-1)]=0xFF; } /* Read special keys */ UpdateSpecialKeys(Kbshift(-1)); /* Now generate events */ for (i=0; i<ATARIBIOS_MAXKEYS; i++) { /* Key pressed ? */ if (bios_currentkeyboard[i] && !bios_previouskeyboard[i]) SDL_PrivateKeyboard(SDL_PRESSED, SDL_Atari_TranslateKey(i, &keysym, SDL_TRUE)); /* Key unpressed ? */ if (bios_previouskeyboard[i] && !bios_currentkeyboard[i]) SDL_PrivateKeyboard(SDL_RELEASED, SDL_Atari_TranslateKey(i, &keysym, SDL_FALSE)); } if (use_dev_mouse) { SDL_AtariDevMouse_PostMouseEvents(this, SDL_TRUE); } else { SDL_AtariXbios_PostMouseEvents(this, SDL_TRUE); } /* Will be previous table */ SDL_memcpy(bios_previouskeyboard, bios_currentkeyboard, sizeof(bios_previouskeyboard)); }
void AtariBios_PumpEvents(_THIS) { int i; SDL_keysym keysym; SDL_memset(bios_currentkeyboard, 0, ATARIBIOS_MAXKEYS); while (Bconstat(_CON)) { unsigned long key_pressed; key_pressed=Bconin(_CON); bios_currentkeyboard[(key_pressed>>16)&(ATARIBIOS_MAXKEYS-1)]=0xFF; } UpdateSpecialKeys(Kbshift(-1)); for (i=0; i<ATARIBIOS_MAXKEYS; i++) { if (bios_currentkeyboard[i] && !bios_previouskeyboard[i]) SDL_PrivateKeyboard(SDL_PRESSED, SDL_Atari_TranslateKey(i, &keysym, SDL_TRUE)); if (bios_previouskeyboard[i] && !bios_currentkeyboard[i]) SDL_PrivateKeyboard(SDL_RELEASED, SDL_Atari_TranslateKey(i, &keysym, SDL_FALSE)); } if (use_dev_mouse) { SDL_AtariDevMouse_PostMouseEvents(this, SDL_TRUE); } else { SDL_AtariXbios_PostMouseEvents(this, SDL_TRUE); } SDL_memcpy(bios_previouskeyboard, bios_currentkeyboard, sizeof(bios_previouskeyboard)); }
void edit_at(int row, int col, int max_length, int screen_length, char *string_to_edit, char filler, int fixed, int (*check_func)( char ), int convert_upper) { #define BLINK 2 #define NOBLINK 3 char *edit_string; int blink,logical_cursor, cursor, last_char, insert; int first_char_on_screen; int finished; long key; int upper,lower; char asc; int loop,loop2/*,delete_loop*/; char *blank=(char *)malloc(screen_length+1); edit_bottom_title(); for(loop=0;loop<=screen_length;loop++) blank[loop]=' '; blank[loop]='\0'; /* set up the string - create space, copy old, pad out new with filler */ edit_string=(char *)malloc(max_length+1); strcpy(edit_string,string_to_edit); logical_cursor=0; while(edit_string[logical_cursor]!='\0') logical_cursor++; last_char=logical_cursor; /* for(;logical_cursor<max_length;logical_cursor++) edit_string[logical_cursor]=filler; */ edit_string[logical_cursor]='\0'; cursor=0; logical_cursor=0; first_char_on_screen=0; insert=1; if(insert==1) { blink=BLINK; Cursconf(blink,0); } else { blink=NOBLINK; Cursconf(blink,0); } /* print string */ print_at_from(row,col,first_char_on_screen,screen_length,edit_string); SHOW_CURSOR AT(row,col) finished=0; while(!finished) { /* AT(0,0) printf(" %d ",last_char); */ while(!Bconstat(2)) ; key=Bconin(2); upper=(int)(key>>16); lower=(int)(key%256); asc=(char)lower&0x00FF; switch(upper) { case 0x4D: /* right arrow */ if(logical_cursor<last_char/*max_length*/) { logical_cursor++; if(cursor<screen_length) { cursor++; } else { cursor=screen_length; if(first_char_on_screen+screen_length<last_char /*max_length*/ && !fixed) { first_char_on_screen++; print_at_from(row,col,first_char_on_screen,screen_length,edit_string); } } } else { BELL logical_cursor=last_char/*max_length*/; } break; case 0x4B: /* left arrow */ if(logical_cursor>0) { logical_cursor--; } else { BELL logical_cursor=0; } if(cursor>0) { cursor--; } else { cursor=0; if(first_char_on_screen>0 && !fixed) { first_char_on_screen--; print_at_from(row,col,first_char_on_screen,screen_length,edit_string); } } /* logical_cursor--; cursor--; if(logical_cursor<0) { BELL logical_cursor=0; cursor=0; } else if(cursor<0) { cursor=0; if(first_char_on_screen>0 && !fixed) { first_char_on_screen--; print_at_from(row,col,first_char_on_screen,screen_length,edit_string); } }*/ break; case 0x1C: /* return */ finished=1; /* print_at_from(row,col,0,screen_length,blank); */ AT(row,col) printf("%s",blank+1); /* printf("%s",blank);*/ AT(row,col) strcpy(string_to_edit,edit_string); print_at_from(row,col,0,screen_length,string_to_edit); break; case 0x0E: /* backspace */ if(logical_cursor>0) { loop=logical_cursor-1; loop2=logical_cursor; while(loop2<=last_char) { edit_string[loop]=edit_string[loop2]; loop++; loop2++; } edit_string[last_char]='\0'; last_char--; logical_cursor--; if(cursor>0 && last_char<screen_length) { cursor--; } else { if(cursor==0) { first_char_on_screen--; if(first_char_on_screen<0) first_char_on_screen=0; } else { cursor--; } } if(first_char_on_screen+screen_length>last_char) { /* for(delete_loop=0;cursor+delete_loop<screen_length;delete_loop++) { AT(row,delete_loop+col) Bconout(2,' '); }*/ AT(row,col+cursor) printf("%s",blank+cursor+1); } } else BELL break; case 0x53: /* delete */ if(logical_cursor<last_char) { loop=logical_cursor; loop2=logical_cursor+1; while(loop2<=last_char) { edit_string[loop]=edit_string[loop2]; loop++; loop2++; } edit_string[last_char]='\0'; last_char--; if(first_char_on_screen+screen_length>last_char) { /* for(delete_loop=0;cursor+delete_loop<=screen_length;delete_loop++) { AT(row,delete_loop+col) Bconout(2,' '); } */ AT(row,col+cursor) printf("%s",blank+cursor+1); } } else BELL break; case 0x01: /* escape */ finished=1; /* print_at_from(row,col,0,screen_length,blank); *//* AT(row,col) CLEAR_EOL */ AT(row,col) printf("%s",blank+1); /* printf("%s",blank); */ AT(row,col) print_at_from(row,col,0,screen_length,string_to_edit); break; case 0x52: /* insert */ BELL if(insert==1) insert=0; else insert=1; if(insert==1) { blink=BLINK; Cursconf(blink,0); } else { blink=NOBLINK; Cursconf(blink,0); } break; default: if((*check_func)(asc)) { if(insert==1) { if(last_char<max_length) { loop=last_char-1; loop2=last_char; while(loop2>logical_cursor) { edit_string[loop2]=edit_string[loop]; loop--; loop2--; } last_char++; edit_string[last_char]='\0'; if(convert_upper) edit_string[logical_cursor]=toupper(asc); else edit_string[logical_cursor]=asc; logical_cursor++; cursor++; if(cursor>screen_length) { cursor=screen_length; if(first_char_on_screen+screen_length<last_char) first_char_on_screen++; } } else BELL } else { if(logical_cursor<last_char) { if(convert_upper) edit_string[logical_cursor]=toupper(asc); else edit_string[logical_cursor]=asc; logical_cursor++; cursor++; if(cursor>screen_length) { first_char_on_screen++; cursor=screen_length; } } else { if(logical_cursor>=last_char && last_char<max_length) { if(convert_upper) edit_string[last_char]=toupper(asc); else edit_string[last_char]=asc; logical_cursor=last_char; last_char++; logical_cursor++; if(logical_cursor>max_length) logical_cursor=max_length; edit_string[last_char]='\0'; cursor++; if(cursor>screen_length) { cursor=screen_length; if(first_char_on_screen+screen_length<max_length) first_char_on_screen++; } } else BELL } } } break; } if(finished!=1) { /* if(last_char<screen_length) { AT(row,col) CLEAR_EOL }*/ print_at_from(row,col,first_char_on_screen,screen_length,edit_string); AT(row,col+cursor) }
int midi_in () { return ((int) Bconin (3) & 0x00ff); }
main() { int x, y; /* Coordinates of the player's move */ void init(); /* Initialises global variables. */ void get_move(); /* Gets a move from the player. */ void show_board(); /* Displays Othello Board. */ int make_move(); /* Make the move specified. */ init(); /* Initialise Othello. */ /* Main loop - repeats until end_othello takes a non-zero value */ while ( !end_othello ) { /* Read in a move from the player. * * Note that the player's move, translated into coordinates in the * Othello Board, is "returned" via pointers to (int)x and (int)y . */ get_move ( &x, &y ); /* The first thing we check is whether or not the player has quit, * skipped a go or restarted the game. x is set to -1 to indicate * the latter two options. */ if ( !end_othello && x != -1 ) { if ( make_move ( x, y ) ) { /* Switch to next player if the move given was legal. */ if ( player == 0 ) player = 1; else player = 0; /* Re-display the Othello Board. */ show_board(); } else { /* Move was illegal, so try again. */ printf ( ": Illegal Move: Press a Key" ); Bconin ( 2 ); /* Back space over previous message, erase * it and then backspace back again. */ printf ("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"); printf ("\b\b\b\b\b\b\b\b\b\b\b\b\b\b"); printf ( " " ); printf ("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"); printf ("\b\b\b\b\b\b\b\b\b\b\b\b\b\b"); }; }; }; /* Handle error codes. */ printf ( "\n\n%s\nPress a Key\n", errors[end_othello - 1] ); Bconin ( 2 ); /* Free block of memory used by Othello Board if necessary. */ if ( board != NULL ) free ( board ); };
void options_screen() { /* options are */ /* 17 Lines -7 -1025 0 New Progs ON OFF SAME 1 New Accs ON OFF SAME 2 Auto Window PAGING SCROLLING 3 Accs Window PAGING SCROLLING 4 Sets Window PAGING SCROLLING 5 Other Window PAGING SCROLLING 6 Auto Path -------------------------------------- 7 Accs Path -------------------------------------- 8 <Set Keys> 9 <Resolution Info> 10 [ OK ] 11[ CANCEL ] 12[ SAVE ] */ #define MAX_OPTIONS 12 int options_y, options_x, curr_option, old_option, exit_options; long key; int upk,lowk; /*char temp[60]; */ /* local defaults */ int lnew_progs_flag; /* 1 = ON, 2 = OFF, 3 = SAME */ int lnew_accs_flag; int lauto_paging; /* 1 = paging, 2 = scrolling */ int laccs_paging; int lsets_paging; int lother_paging; char lauto_path[FILENAME_MAX]; char laccs_path[FILENAME_MAX]; curr_option=0; old_option=11; lnew_progs_flag=prog_defaults.new_progs_flag; lnew_accs_flag=prog_defaults.new_accs_flag; lauto_paging=prog_defaults.auto_paging; laccs_paging=prog_defaults.accs_paging; lsets_paging=prog_defaults.sets_paging; lother_paging=prog_defaults.other_paging; strcpy(lauto_path,prog_defaults.auto_path); strcpy(laccs_path,prog_defaults.accs_path); options_y=prog_defaults.rows-3-17+1; if(options_y>0) options_y=options_y/2; else options_y=1; options_x=prog_defaults.columns-40; if(options_x>0) options_x=options_x/2; else options_x=0; CLEAR_SCREEN centre_text("OPTIONS",line_buffer,prog_defaults.columns,' '); DISCARD_EOL AT(title_row,0) REVERSE_VIDEO printf("%s",line_buffer); NORMAL_VIDEO options_bottom_title(); AT(options_y,options_x+1) printf("New Progs"); print_on_off_same(options_y,options_x+1,lnew_progs_flag); AT(options_y+1,options_x+1) printf("New Accs"); print_on_off_same(options_y+1,options_x+1,lnew_accs_flag); AT(options_y+3,options_x+1) printf("Auto Window"); print_paging_scrolling(options_y+3,options_x+1,lauto_paging); AT(options_y+4,options_x+1) printf("Accs Window"); print_paging_scrolling(options_y+4,options_x+1,laccs_paging); AT(options_y+5,options_x+1) printf("Sets Window"); print_paging_scrolling(options_y+5,options_x+1,lsets_paging); AT(options_y+6,options_x+1) printf("Other Window"); print_paging_scrolling(options_y+6,options_x+1,lother_paging); remove_extension(lauto_path); AT(options_y+8,options_x+1) printf("Auto Path"); /* AT(options_y+9,options_x+1) printf("--------------------------------------"); */ AT(options_y+9,options_x+1) printf("%s",lauto_path); remove_extension(laccs_path); AT(options_y+11,options_x+1) printf("Accs Path"); /* AT(options_y+12,options_x+1) printf("--------------------------------------"); */ AT(options_y+12,options_x+1) printf("%s",laccs_path); AT(options_y+14,options_x+1) printf("<Set Keys>"); AT(options_y+14,options_x+22) printf("<Resolution Info>"); AT(options_y+16,options_x+3) printf("[ OK ]"); AT(options_y+16,options_x+15) printf("[ CANCEL ]"); AT(options_y+16,options_x+27) printf("[ SAVE ]"); upk=0;lowk=0;exit_options=0; print_option(options_y,options_x,old_option, curr_option); while(exit_options==0) { while(!Bconstat(2)) ; key=Bconin(2); upk=(int)(key>>16); lowk=(int)(key%256); if(upk==0x48 ) /* up arrow */ { old_option=curr_option; switch(curr_option) { case 11: case 10: curr_option=8; break; case 12: curr_option=9; break; case 9: curr_option=7; break; default: curr_option=curr_option-1; break; } if(curr_option<0) curr_option=MAX_OPTIONS; print_option(options_y,options_x,old_option, curr_option); } else { if(upk==0x50) /* down arrow */ { old_option=curr_option; switch(curr_option) { case 8: curr_option=10; break; case 9: curr_option =12; break; case 10: case 11: case 12: curr_option=0; break; default: curr_option=curr_option+1; break; } if(curr_option>MAX_OPTIONS) curr_option=0; print_option(options_y,options_x,old_option, curr_option); } else { if(upk==0x4D) /* right arrow */ { old_option=curr_option; switch(curr_option) { case 0: lnew_progs_flag++; if(lnew_progs_flag>3) lnew_progs_flag=1; print_on_off_same(options_y,options_x+1,lnew_progs_flag); break; case 1: lnew_accs_flag++; if(lnew_accs_flag>3) lnew_accs_flag=1; print_on_off_same(options_y+1,options_x+1,lnew_accs_flag); break; case 2: lauto_paging++; if(lauto_paging>SCROLLING) lauto_paging=PAGING; print_paging_scrolling(options_y+3,options_x+1,lauto_paging); break; case 3: laccs_paging++; if(laccs_paging>SCROLLING) laccs_paging=PAGING; print_paging_scrolling(options_y+4,options_x+1,laccs_paging); break; case 4: lsets_paging++; if(lsets_paging>SCROLLING) lsets_paging=PAGING; print_paging_scrolling(options_y+5,options_x+1,lsets_paging); break; case 5: lother_paging++; if(lother_paging>SCROLLING) lother_paging=PAGING; print_paging_scrolling(options_y+6,options_x+1,lother_paging); break; case 8: case 10: case 11: curr_option++; break; } if(curr_option>MAX_OPTIONS) curr_option=0; print_option(options_y,options_x,old_option, curr_option); } else { if(upk==0x4B) /* left arrow */ { old_option=curr_option; switch(curr_option) { case 0: lnew_progs_flag--; if(lnew_progs_flag<1) lnew_progs_flag=3; print_on_off_same(options_y,options_x+1,lnew_progs_flag); break; case 1: lnew_accs_flag--; if(lnew_accs_flag<1) lnew_accs_flag=3; print_on_off_same(options_y+1,options_x+1,lnew_accs_flag); break; case 2: lauto_paging--; if(lauto_paging<PAGING) lauto_paging=SCROLLING; print_paging_scrolling(options_y+3,options_x+1,lauto_paging); break; case 3: laccs_paging--; if(laccs_paging<PAGING) laccs_paging=SCROLLING; print_paging_scrolling(options_y+4,options_x+1,laccs_paging); break; case 4: lsets_paging--; if(lsets_paging<PAGING) lsets_paging=SCROLLING; print_paging_scrolling(options_y+5,options_x+1,lsets_paging); break; case 5: lother_paging--; if(lother_paging<PAGING) lother_paging=SCROLLING; print_paging_scrolling(options_y+6,options_x+1,lother_paging); break; case 9: case 11: case 12: curr_option--; break; } if(curr_option<0) curr_option=MAX_OPTIONS; print_option(options_y,options_x,old_option, curr_option); } else { if(upk==0x1C) /* return */ { switch(curr_option) { case 6: edit_at(options_y+9,options_x+1,FILENAME_MAX,37,lauto_path,'-',0,valid_filename_char,1); options_bottom_title(); break; case 7: edit_at(options_y+12,options_x+1,FILENAME_MAX,37,laccs_path,'-',0,valid_filename_char,1); options_bottom_title(); break; case 8: /* set keys */ break; case 9: /* set res stuff */ break; case 10: /* set defaults */ prog_defaults.new_progs_flag=lnew_progs_flag; prog_defaults.new_accs_flag=lnew_accs_flag; prog_defaults.auto_paging=lauto_paging; prog_defaults.accs_paging=laccs_paging; prog_defaults.sets_paging=lsets_paging; prog_defaults.other_paging=lother_paging; strcpy(prog_defaults.auto_path,lauto_path); strcpy(prog_defaults.accs_path,laccs_path); exit_options=1; break; case 11: exit_options=1; break; case 12: /* save defaults */ break; } } else { if(upk==prog_defaults.toggle_key_high) { switch(curr_option) { case 0: lnew_progs_flag++; if(lnew_progs_flag>3) lnew_progs_flag=1; print_on_off_same(options_y,options_x+1,lnew_progs_flag); break; case 1: lnew_accs_flag++; if(lnew_accs_flag>3) lnew_accs_flag=1; print_on_off_same(options_y+1,options_x+1,lnew_accs_flag); break; case 2: lauto_paging++; if(lauto_paging>SCROLLING) lauto_paging=PAGING; print_paging_scrolling(options_y+3,options_x+1,lauto_paging); break; case 3: laccs_paging++; if(laccs_paging>SCROLLING) laccs_paging=PAGING; print_paging_scrolling(options_y+4,options_x+1,laccs_paging); break; case 4: lsets_paging++; if(lsets_paging>SCROLLING) lsets_paging=PAGING; print_paging_scrolling(options_y+5,options_x+1,lsets_paging); break; case 5: lother_paging++; if(lother_paging>SCROLLING) lother_paging=PAGING; print_paging_scrolling(options_y+6,options_x+1,lother_paging); break; } } } } } } } } }
int midi_in () { return ((int) Bconin (3) & 0X00FF); }
/* wait for the response from the newsserver */ int news_receive(int cn, char *file, int file_reqd) { /* copied from http_get in CABCOVL.C */ int16 x, bytes_available, eof=0; long bytes_read=0,rc; int return_code=0; int file_handle, status=0, header_pos=0; time_t timeout,kicker,total; int bug=0; int sbuf=sizeof(buffer); if (file_reqd) { file_handle=(int) Fcreate(file, 0); if (bug) { fprintf( log, "news_receive - opening file = %d\n", file_handle ); fflush( log ); } if (file_handle<0) { #ifdef ERR_MSGS printf("Couldn't create %s!\n", file); #endif return(1); } } total=clock(); /* total time in routine */ timeout=clock()+max_to*CLK_TCK; /* timeout */ kicker=clock()+kick*CLK_TCK; /* conversation kicker */ if (file_reqd) { browser->msg_status(2,0); /* Getting data... */ } if (file_reqd==2) { status=2; } while (eof==0) { bytes_available=CNbyte_count(cn); /* printf("received %d bytes \n", (long)bytes_available ); */ if (handle_escape_events()==27) { eof=4; } /* if (Bconstat(2)==-1 && (Bconin(2) & 0xFF)==27) { eof=4; } */ if (clock()>timeout) { #ifdef MDEBUG printf("Timeout!\n"); #endif eof=2; } else if (clock()>kicker) { #ifdef MDEBUG printf("Kick Connection!\n"); #endif CNkick(cn); kicker=clock()+kick*CLK_TCK; /* conversation kicker */ } else if (bytes_available==E_EOF) { #ifdef MDEBUG printf("EOF!\n"); #endif eof=1; } else if (bytes_available<E_NODATA) { #ifdef ERR_MSGS printf("CNbyte_count() returns: %s\n", get_err_text(bytes_available)); #endif eof=3; } else if (bytes_available>0) { timeout=clock()+char_to*CLK_TCK; /* timeout after last char */ kicker=clock()+kick*CLK_TCK; /* conversation kicker */ if (status==2) { if (bytes_available>sbuf) { bytes_available=sbuf; } if (CNget_block(cn, buffer, bytes_available)>=E_NODATA) { rc = Fwrite(file_handle, bytes_available, &buffer); if (rc!=bytes_available) { /* didn't write everything */ file_write_error(rc); Fclose(file_handle); return(1); } bytes_read+=bytes_available; if (bug) { fprintf( log, "received %d bytes, total %ld\n", bytes_available , bytes_read); fflush( log ); } else { browser->msg_status(2, bytes_read); } /* look for period (.) on a line by itself */ if (strncmp(&buffer[bytes_available-5], "\r\n.\r\n", 5)==0 || strncmp(&buffer[bytes_available-5], "\n\r.\n\r", 5)==0 || strncmp(&buffer[bytes_available-3], "\r.\r", 3)==0 || strncmp(&buffer[bytes_available-3], "\n.\n", 3)==0) eof=1; if (bytes_read==3 && strncmp(&buffer[bytes_available-3], ".\r\n", 3)==0) eof=1; } else { #ifdef ERR_MSGS printf("Error in CNget_block()!\n"); #endif eof=3; } } else { x = CNget_char(cn); if (x<E_NODATA) { #ifdef ERR_MSGS printf("CNget_char() returns: %s\n", get_err_text(x)); #endif eof=3; } else header[header_pos++]=(char) x; } /* only an empty line and response line in NNTP responses */ /* when status = 0, drop until valid non-control, when = 1, store in header */ if (status==0) { if (strncmp(&header[header_pos-1], " ", 1)<0) { header_pos = 0; } else { status++;} } if (status==1) { if (strncmp(&header[header_pos-2], "\r\n", 2)==0 || strncmp(&header[header_pos-2], "\n\r", 2)==0) { /* strncmp(&header[header_pos-1], "\r", 1)==0 || strncmp(&header[header_pos-1], "\n", 1)==0) { */ header[header_pos-2]=0; if (log_resp=='Y') { fprintf( log, "%s\n", header ); fflush(log); } #ifdef MDEBUG printf("Header: %s\n", header ); printf("End of header.\n"); #endif if (!file_reqd) { eof=1; } else { status++; } if (memcmp(header,"423",3)==0) { eof=1; } } else if (header_pos>2000) { rc = Fwrite(file_handle, header_pos, header); if (rc!=header_pos) { /* didn't write everything */ file_write_error(rc); Fclose(file_handle); return(1); } status++; } } } } #ifdef MDEBUG printf("EOF= %d \n", (long)eof ); #endif if (eof>1) { /* timeout or worse*/ /* x = (int16)TCP_close(cn, 2); if (x < 0) { #ifdef MDEBUG printf("TCP_close() returns: %s\n", get_err_text(x)); #endif } */ if (bug) { fprintf( log, "news_receive - error - eof = %d\n", eof ); fflush( log ); } if (file_reqd) { #ifdef MDEBUG printf("Fclose returns %i\n", Fclose(file_handle)); #else /**** I might get a bug here! ****/ if((x=(int16)Fclose(file_handle))<0) { #ifdef ERR_MSGS printf("Error with Fclose! (%i)\n", x); #endif } #endif if (bug) { fprintf( log, "news_receive - error - closing file = %d\n", x ); fflush( log ); } } if (eof==3) { eof=bytes_available; } /* return negative value */ return(eof); } if (file_reqd) { if (log_data=='Y') { total=clock()-total; /* total time in clock ticks */ if (total) { fprintf( log, "Transfer Rate = %ld cps\n", (bytes_read*CLK_TCK)/total ); fflush(log); } } #ifdef MDEBUG printf("Fclose returns %d\n", Fclose(file_handle)); #else if((x=(int16)Fclose(file_handle))<0) browser->msg_error(x); #endif if (bug) { fprintf( log, "news_receive - good - closing file = %d\n", x ); fflush( log ); } } #ifdef MDEBUG printf("Hit a key.\n"); Bconin(2); #endif return(return_code); /* return(0) if getting data was successful, */ /* return(errno) if it fails, return an error number */ }