void main() { int F(void); int i; ctrlbrk (F); /* Habilita a la funcion F(), para ser ejecutada cuando se opriman las teclas Ctrl-C */ /* Para salir de este loop, se deben oprimir las teclas Ctrl-C */ for (i=0;;i++) { printf ("%3d Ejecutando ciclo infinito...\n",i); } }
int init_tty (void) /*{{{*/ { union REGS r; struct SREGS s; if (TTY_Initialized) return 0; bios_key_f = peekb(0x40,0x96) & 0x10; /* enhanced keyboard flag */ /* Check for system type */ delay_ptr = delay; r.x.ax = 0xC000; int86x (0x15, &r, &r, &s); if ((r.x.cflag == 0) && (r.h.al == 0)) { unsigned char *table; table = MK_FP(s.es, r.x.bx); switch (table[2]) { case 0xFF: /* pc */ case 0xFE: /* xt */ case 0xFB: /* xt */ case 0xFD: /* pc-jr */ break; /* AT and higher */ default: delay_ptr = my_delay; } } set_ctrl_break(0); ctrlbrk(ctrl_break); init_int9_handler(); TTY_Initialized = 1; if (Batch == 0) { if (X_Open_Mouse_Hook != NULL) (*X_Open_Mouse_Hook) (); } X_Set_Abort_Char_Hook = ibmpc_set_abort_char; return 0; }
void main() { byte c; int handle_sf; /*,handle_cf;*/ unsigned outval,i; double alfa,sinval; puts(sign); ctrlbreaksignal=0; ctrlbrk(c_break); _fmode=O_BINARY; if (access(sintabfilename,0)==0) { printf("\nWarning : %s exists. Overwrite (Y,y/any key)?",sintabfilename); for(c=getch();!c;c=getch()); if (toupper(c)!='Y') quit("\nAbort on user request!",1); } if ((handle_sf=creat(sintabfilename,S_IWRITE))==-1) quit(ERR_FC,1); lseek(handle_sf,0,SEEK_SET); /* if (access(costabfilename,0)==0) { printf("\nWarning : %s exists. Overwrite (Y,y/any key)?",costabfilename); for(c=getch();!c;c=getch()); if (toupper(c)!='Y') quit("\nAbort on user request!",1); } if ((handle_cf=creat(costabfilename,S_IWRITE))==-1) quit(ERR_FC,1); lseek(handle_cf,0,SEEK_SET); } */ for(alfa=0,i=0;i<16384;alfa+=(2*M_PI)/(double)65536,i++) { sinval=sin(alfa)*32767+0.5; outval=sinval; if (write(handle_sf,&outval,2)!=2) quit(ERR_FW,1); } close(handle_sf); /* close(handle_cf);*/ }
int main(void) { if (setjmp(abortBuffer)) return 3; ctrlbrk(exit_program); // Set up to handle CTRL-Break from user setcbrk(1); // Attempt to remove the trace file, so that it doesn't grow out of control remove ("TRACEQP.TXT"); try { BrewerCMDINI ini(10); // Initialization file Display display(&ini); // All window functions are here Brewer brewer(&ini, &display); // All Brewer functions are here char* userCommand; // Command typed by user char* parameter; // Parameter to command typed by user char* result; // Response to command from Brewer char temp[200]; // Buffer ostrstream* s; // Stream to fill buffer int index; // Command index (-1 if not a built-in command) int loop, loop2; // Loop indeces do { // Clear Brewer status. VERY IMPORTANT!! brewer.status(); display.updateStatusWindow(R_OK); userCommand = display.getUserInput(); display.updateStatusWindow(R_ACK); parameter = userCommand; if((index = findCommand(userCommand)) != -1) { parameter += strlen(cmdList[index]); while(isspace(*parameter)) parameter++; } // s = new ostrstream(temp, 200); // *s << "Decoded message as " << index; // if(index == -1) // *s << ": Unknown command " << userCommand; // else // *s << ": " << cmdList[index] << " with parameter " << parameter; // *s << ends; // delete s; // display.bossMessage(temp); switch(index) { case 0: // COSMACMODE if(*parameter) brewer.switchTo(cosmacMode, SerialPort::BaudRate(atoi(parameter))); else brewer.switchTo(cosmacMode, SerialPort::baud1200); break; case 1: // GETCFG: Write Brewer configuration if(brewer.mode() == loadMode) brewer.wrongMode(); else if(!*parameter) display.bossMessage(missingParam); else if(brewer.isAllowed()) { ifstream ifile(parameter); ofstream ofile("brewcmd.tmp"); while(kbhit()) // ensure that kbhit is cleared getch(); while(ifile.good() && !kbhit()) { temp[0] = '?'; // We want to read values from the Brewer do { temp[1] = ifile.get(); ofile.put(temp[1]); } while(isspace(temp[1])); if(temp[1] == ';') { ifile.getline(temp, 200, '\n'); ofile << temp << endl; } else if(ifile.good()) { // Save the second character, which we read already ifile.getline(&temp[2], 198, '='); // Convert to uppercase for(loop = 0; loop < strlen(temp); loop++) temp[loop] = toupper(temp[loop]); ofile << (&temp[2]) << '='; result = brewer.commandWithReply(temp); ofile << result << endl; ifile.getline(temp, 200, '\n'); } } ifile.close(); ofile.close(); remove("brewcmd.bak"); rename(parameter, "brewcmd.bak"); rename("brewcmd.tmp", parameter); } break; case 2: // HELP if(*parameter) { if((index = findCommand(parameter)) == -1) display.write(" Unknown command\n"); else { display.write(" "); display.write(cmdHelp[index]); display.write("\n"); } } else { display.write("Valid commands are:\n"); for(loop = 0; *cmdList[loop]; loop++) { s = new ostrstream(temp, 200); *s << " " << cmdList[loop]; for(loop2 = strlen(cmdList[loop]); loop2 < 12; loop2++) *s << " "; if((loop + 1) % 5 == 0 || !*cmdList[loop + 1]) *s << endl; *s << ends; delete s; display.write(temp); } } break; case 3: // INIT: Redetect communications brewer.reset(); break; case 4: // LOAD: Load top code if(!*parameter) display.bossMessage(missingParam); else brewer.loadTopCode(parameter); break; case 5: // LOADMODE if(*parameter) brewer.switchTo(loadMode, SerialPort::BaudRate(atoi(parameter))); else brewer.switchTo(loadMode, SerialPort::baud9600); break; case 6: // OPMODE if(*parameter) brewer.switchTo(operatingMode, SerialPort::BaudRate(atoi(parameter))); else brewer.switchTo(operatingMode, SerialPort::baud9600); break; case 7: // PUTCFG: Read Brewer configuration if(brewer.mode() == loadMode) brewer.wrongMode(); else if(!*parameter) display.bossMessage(missingParam); else if(brewer.isAllowed()) { ifstream ifile(parameter); while(kbhit()) // ensure that kbhit is cleared getch(); while(ifile.good() && !kbhit()) { temp[0] = '!'; // We want to write values to the Brewer do { temp[1] = ifile.get(); } while(isspace(temp[1])); if(temp[1] == ';') ifile.getline(temp, 200, '\n'); else if(ifile.good()) { // Save the second character, which we read already ifile.getline(&temp[2], 198, '='); strcat(temp, " "); // Separator ifile.getline(&temp[strlen(temp)], 200 - strlen(temp), '\n'); // Convert to uppercase for(loop = 0; loop < strlen(temp); loop++) temp[loop] = toupper(temp[loop]); brewer.command(temp); } } ifile.close(); brewer.testSerialNumber(); } break; case 8: // QUIT break; case 9: // READLOG if(brewer.mode() == loadMode) brewer.wrongMode(); else if(brewer.isAllowed()) { do { result = brewer.commandWithReply("LOGENTRY"); display.brewerMessage(result); } while(strcmp(result, " All log items reported.") != 0 && !kbhit()); } break; case 10: // REPEAT if(brewer.mode() == loadMode) brewer.wrongMode(); else if(!*parameter) display.bossMessage(missingParam); else do { result = brewer.commandWithReply(parameter); display.brewerMessage(result); } while(!kbhit()); break; case 11: // RESET brewer.warmReset(); break; case 12: // RUN if(brewer.mode() == loadMode) brewer.wrongMode(); else if(!*parameter) display.bossMessage(missingParam); else { ifstream ifile(parameter); while(kbhit()) // ensure that kbhit is cleared getch(); while(ifile.good() && !kbhit()) { do { temp[0] = ifile.get(); } while(isspace(temp[0])); // Save the first character, which we read already ifile.getline(&temp[1], 199, '\n'); // Convert to uppercase for(loop = 0; loop < strlen(temp); loop++) temp[loop] = toupper(temp[loop]); if(temp[0] == ';') display.brewerMessage(temp); else if(strlen(temp) > 0) { result = brewer.commandWithReply(temp); if(strlen(result) > 0) display.brewerMessage(result); } } ifile.close(); } break; case 13: // SAVE brewer.save(); break; case 14: // SEND if(!*parameter) display.bossMessage(missingParam); else { s = new ostrstream(temp, 200); *s << brewer.lowLevelCommandWithReply(parameter) << ends; display.brewerMessage(temp); delete s; } break; case 15: // STATUS brewer.status(); brewer.showSetup(); break; case 16: // SYN if(brewer.mode() == cosmacMode) brewer.wrongMode(); else { s = new ostrstream(temp, 200); *s << brewer.lowLevelCommandWithReply("\x16") << ends; display.brewerMessage(temp); delete s; } break; case 17: // ZERO if(brewer.mode() == cosmacMode) brewer.wrongMode(); else brewer.lowLevelCommand("\x1e"); // RS (^^): zero reset counter break; default: if(strcmp(userCommand, "") == 0) brewer.status(); else if(brewer.mode() == loadMode) brewer.wrongMode(); else if(userCommand[strlen(userCommand) - 1] == 'A' && !isalpha(userCommand[strlen(userCommand) - 2])) display.bossMessage("Do not use the A command, use the REPEAT command instead"); else { result = brewer.commandWithReply(userCommand); display.brewerMessage(result); } break; } while(kbhit()) getch(); } while(index != 8); // QUIT return 0; } catch(BaseException& err) { cout << "An exception occurred" << endl; err.display(); cout << "Hit a key to terminate program" << endl; while (!kbhit()) continue; return 3; } }
/*------------------------------------------------------------------------------ FUNCTION NAME: Main_Init DESCRIPTION: Main init function PARAMETERS: - INPUT: - OUTPUT: RETURN: NOTES: Don't try to change the order of the function calls! ------------------------------------------------------------------------------*/ void Main_Init (void) { t_uchar Lines[2] = {9,END_OF_LINES}; char Msg[40]; #ifdef PC_TERMINAL int RetVal; t_uchar PrinterIndex, NumPrinters, Type, Port, Model; t_boolean InvertScreen; int LCDContrastOffset; #endif /* MAEL Version */ #if defined (FEDORA_VERSION) srand48((long) time(NULL)); #else #if !defined (NT_VERSION) /* Standart Random generation init */ randomize (); #else /* Seed the random-number generator with current time so that * the numbers will be different every time we run. */ srand( (unsigned)time( NULL ) ); #endif #endif /* MAEL Version */ /*---------------------------------------------------*/ /* Set dos verify option to on and other DOS options */ /*---------------------------------------------------*/ #if !defined (NT_VERSION) #if !defined (FEDORA_VERSION) /* In Linux Verify is always on */ /* And cbreak does nothing */ setverify (1); setcbrk (0); #endif /* FEDORA_VERSION */ /* Set new Ctrl-Break handler */ #if defined (DOSX286) DosSetPassToProtVec (0x1B, (PIHANDLER) Main_HandlerCtrlBreak, &OldCtrlBrkProt, &OldCtrlBrkReal); DosSetPassToProtVec (0x23, (PIHANDLER) Main_HandlerCtrlBreak, &OldCtrlCProt, &OldCtrlCReal); #else #if defined (FEDORA_VERSION) signal(SIGINT,SIG_IGN); #else ctrlbrk (Main_HandlerCtrlBreak); #endif /* MAEL VERSION */ #endif #endif /*-------------*/ /* Nosdos Init */ /*-------------*/ /*----------*/ /* Init. Kb */ /*----------*/ #if defined (FEDORA_VERSION) Kb_Init (KEYBOARD_STANDART); #else #if defined (TERMINAL_WT9602) Kb_Init (KEYBOARD_WT9602); #else #if defined (TERMINAL_WT9603) Kb_Init (KEYBOARD_WT9603); #else Kb_Init (KEYBOARD_STANDART); #endif #endif #endif /* MAEL Version */ /*-----------------------*/ /* Init. display modules */ /*-----------------------*/ #if defined(FEDORA_VERSION) #if defined(SVGALIB_MODE) || defined(XLIB_MODE) GrphDisp_Init (240, 128, 8); #else GrphDisp_Init (40, 14, 8); #endif #else #if defined(NT_VERSION) GrphDisp_Init (40, 14, 8); #else GrphDisp_Init (240, 128, 8); #endif #endif /* MAEL Version */ GrphText_Init (240, 128, 8); #if defined (TERMINAL_WT9602) || defined (TERMINAL_WT9603) #if defined (LNSE) GrphDisp_SetInvertScreen (FALSE); #else GrphDisp_SetInvertScreen (TRUE); #endif Util_SetLCDContrast (INITIAL_LCD_CONTRAST); #endif /* Init message */ GrphText_PopUp (54, 0, 240, Lines, TRUE); strcpy (Msg, S0252); GrphText_Cls (TRUE); GrphText_Write (1, (t_uchar) ((40-strlen (Msg))/2*6), Msg, FONT_7X5, (t_uchar) strlen (Msg), TRUE, FALSE); /*-------------------------------------------------------*/ /* Ramdisk init (includes error handler for disk access) */ /*-------------------------------------------------------*/ RamDisk_Init (); /* Init. Error logger */ Errlog_Init (); /*------------*/ /* Init. UART */ /*------------*/ Uart_Init (); /*----------------------*/ /* Init. Parallel ports */ /*----------------------*/ Parallel_Init (); /*-----------------*/ /* End nosdos Init */ /*-----------------*/ /*-----------*/ /* App. Init */ /*-----------*/ /* Database Init */ DB_InitStaticData (); RetVal = DB_LoadDBGlobal (); if (RetVal != DB_OK) { /* ??? Disk error: ends application ??? */ } /* endif */ DB_InitDynamicData (); /* Communication Init */ Comm_Init (); #if defined (FEDORA_VERSION) /* Ping IP address to initialize vpn */ TCPIP_Init_Tunnel(); /* Get and Apply last contrast value configured */ Display_GetAndApplyContrast(); #endif /* Comm_Init for backup line if it is configured */ { t_uchar CurrentLineType, OperationMode; DB_OperationMode (&OperationMode); if (OperationMode == OPERATIONMODE_REALONLINEBACKUP) { DB_CurrentLineType (&CurrentLineType); /* Change current line type to backup line */ DB_GLOBAL_DYNAMIC.DB_CURRENT_LINETYPE = LINETYPE_BACKUP; /* Init backup line */ Comm_PhysInitComm (); /* Restore main line type */ DB_GLOBAL_DYNAMIC.DB_CURRENT_LINETYPE = CurrentLineType; } /* endif */ } /* Comm_Init for main line */ Comm_PhysInitComm (); Comm_CommDeviceInit (); /* App. protocol */ Prot_Init (); #if defined(ENABLE_HOTLINE) /* Init. Answer logger of hotline */ Hotline_Init (); #endif /* Devices init */ Devices_Init (); /* Enable OMR device */ Devices_SetState (DEVCODE_OMR, DEVSTATE_ENABLED); /*----------------------*/ /* Init. printer module */ /*----------------------*/ DB_NumPrinters (&NumPrinters); for (PrinterIndex = 0; PrinterIndex < NumPrinters; PrinterIndex++) { DB_PrinterInfo (PrinterIndex, &Type, &Port, &Model); Printer_Init (PrinterIndex, Type, Port, Model, TRUE); } /* endfor */ /* Invert screen option */ DB_GetInvertScreen (&InvertScreen); GrphDisp_SetInvertScreen (InvertScreen); /* LCD Contrast */ DB_GetLCDContrastOffset (&LCDContrastOffset); Util_SetLCDContrast (LCDContrastOffset); /*----------------------*/ /* App. crc error check */ /*----------------------*/ DB_ChkAppCrcError (); /*---------------*/ /* End App. Init */ /*---------------*/ /* Clear message from virtual display */ GrphText_Cls (FALSE); GrphText_PopDown (FALSE); } /* Main_Init */
void main(){ int i, j, xinc, yinc, Margin; char ch; WORD curr_x=0, curr_y=0; pal = (char far *) farmalloc(256*3); pal2 = (char far *) farmalloc(256*3); userfnt1 = (char far *) farmalloc(256*16+4); /* INITIALIZE XLIB */ /* we set up Mode X 360x200x256 with a logical width of ~ 500 */ /* pixels; we actually get 496 due to the fact that the width */ /* must be divisible by 8 */ x_text_mode(); /* make sure VGA is in color mode, if possible */ x_set_mode(X_MODE_360x200,500); /* actually is set to 496 */ x_install_vsync_handler(2); x_set_splitscreen(ScrnPhysicalHeight-60); /* split screen 60 pixels high */ x_set_doublebuffer(220); x_text_init(); x_hide_splitscreen(); x_mouse_init(); MouseColor=2; atexit(exitfunc); /* DRAW BACKGROUND LINES */ for(j=0;j<ScrnPhysicalHeight;j++){ x_line(0,j,ScrnLogicalPixelWidth,j,16+(j%239),VisiblePageOffs); } ctrlbrk(terminate); x_get_pal_struc(pal, 240,16); load_user_fonts(); intro_1(); x_set_font(2); x_hide_mouse(); x_printf(textwindow_x+5,50 ,VisiblePageOffs,9, " Hi, folks. This is yet another FREEWARE Mode X"); x_printf(textwindow_x+5,50+8 ,VisiblePageOffs,9, " graphics library. It is by no means complete,"); x_printf(textwindow_x+5,50+16,VisiblePageOffs,9, " but I believe it contains a rich enough set of"); x_printf(textwindow_x+5,50+24,VisiblePageOffs,9, " functions to achieve its design goal - to be"); x_printf(textwindow_x+5,50+32,VisiblePageOffs,9, " a game development oriented library for"); x_printf(textwindow_x+5,50+40,VisiblePageOffs,9, " Borland TC/BC/BC++ and TASM programmers."); x_printf(textwindow_x+5,50+48,VisiblePageOffs,9, " This library comes with TASM and C sources."); x_printf(textwindow_x+5,50+56,VisiblePageOffs,9, " It was inspired by the DDJ Graphics column and"); x_printf(textwindow_x+5,50+64,VisiblePageOffs,9, " many INTERNET and USENET authors who, unlike the"); x_printf(textwindow_x+5,50+72,VisiblePageOffs,9, " majority of programmers (you know who you are!),"); x_printf(textwindow_x+5,50+80,VisiblePageOffs,9, " willingly share their code and ideas with others."); x_printf(textwindow_x+5,50+88,VisiblePageOffs,9, " I can't afford, nor do I want, to copyright"); x_printf(textwindow_x+5,50+96,VisiblePageOffs,9, " this code - but if you use it, some credit would "); x_printf(textwindow_x+5,50+104,VisiblePageOffs,9," be appreciated. "); wait_for_keypress(); subsequent_page(); x_set_font(0); x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6,"Supported 256 colour resolutions."); x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3,"Supported 256 colour resolutions."); x_set_font(2); x_printf(textwindow_x+5,50 ,VisiblePageOffs,9, " 320x200 Standard for games ~ 4 pages"); x_printf(textwindow_x+5,50+8 ,VisiblePageOffs,9, " 320x240 DDJ Mode X square pixels ~ 3.5 pages"); x_printf(textwindow_x+5,50+16,VisiblePageOffs,9, " 360x200 My favourite for games ~ 3 pages "); x_printf(textwindow_x+5,50+24,VisiblePageOffs,9, " 360x240 ~ 2.8 pages"); x_printf(textwindow_x+5,50+32,VisiblePageOffs,9, " 320x400 ~ 2 pages "); x_printf(textwindow_x+5,50+40,VisiblePageOffs,9, " 320x480 All subsequent modes support"); x_printf(textwindow_x+5,50+48,VisiblePageOffs,9, " 360x400 less than two pages."); x_printf(textwindow_x+5,50+56,VisiblePageOffs,9, " 360x480"); x_printf(textwindow_x+5,50+64,VisiblePageOffs,9, " 376x282,360x360,376x308,376x564,256x200,256x240"); x_printf(textwindow_x+5,50+72,VisiblePageOffs,9, " Phew! and they'll run on all VGA cards and "); x_printf(textwindow_x+5,50+80,VisiblePageOffs,9, " monitors (some of the weird ones are best suited"); x_printf(textwindow_x+5,50+88,VisiblePageOffs,9, " to monitors with both vert & horiz adjustments)"); x_printf(textwindow_x+5,50+98,VisiblePageOffs,2, " "); x_printf(textwindow_x+5,50+106,VisiblePageOffs,2," Overkill? Maybe!! "); wait_for_keypress(); subsequent_page(); x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6," Text display functions."); x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3," Text display functions."); x_set_font(2); x_printf(textwindow_x+5,50 ,VisiblePageOffs,9, " Several text printing functions are provided."); x_printf(textwindow_x+5,50+8 ,VisiblePageOffs,9, " They support the VGA ROM 8x14 and 8x8 fonts as"); x_printf(textwindow_x+5,50+16,VisiblePageOffs,9, " well as user-defined fonts (like this 6x8 font)."); x_printf(textwindow_x+5,50+24,VisiblePageOffs,9, " Furthermore, a function similar to printf is"); x_printf(textwindow_x+5,50+32,VisiblePageOffs,9, " included which provides formatted text output."); x_printf(textwindow_x+5,50+40,VisiblePageOffs,9, " User defined fonts may be proportionally spaced"); x_printf(textwindow_x+5,50+58,VisiblePageOffs,9, " but have a maximum width of 8 pixels."); wait_for_keypress(); subsequent_page(); x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6," Advanced screen functions."); x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3," Advanced screen functions."); x_set_font(2); x_printf(textwindow_x+5,50 ,VisiblePageOffs,9, " The library supports virtual screens larger"); x_printf(textwindow_x+5,50+8 ,VisiblePageOffs,9, " than the physical screen, panning of such"); x_printf(textwindow_x+5,50+16,VisiblePageOffs,9, " screens, and a split screen option."); x_printf(textwindow_x+5,50+24,VisiblePageOffs,9, " These functions can be used together or"); x_printf(textwindow_x+5,50+32,VisiblePageOffs,9, " in isolation, and in the lower resolutions"); x_printf(textwindow_x+5,50+40,VisiblePageOffs,9, " double buffering can also be accomplished."); x_rect_fill(0, 0, ScrnPhysicalPixelWidth,60,SplitScrnOffs,5); x_line(0,0,ScrnPhysicalPixelWidth,0,2,SplitScrnOffs); x_set_font(1); x_printf(10,10,SplitScrnOffs,2, " This is a split screen, tops for scores."); x_set_font(0); for (i=ScrnPhysicalHeight;i>ScrnPhysicalHeight-60;i--){ x_adjust_splitscreen(i); } x_printf(10,25,SplitScrnOffs,2, " Even better for scrolling games etc."); x_cp_vid_rect(0,0,ScrnLogicalPixelWidth,ScrnLogicalHeight,0,0, VisiblePageOffs,HiddenPageOffs, ScrnLogicalPixelWidth,ScrnLogicalPixelWidth); x_show_mouse(); wait_for_keypress(); curr_x=curr_y=0; init_object(60,90,4, 12, -1, 1, MK_FP(FP_SEG(bm2),FP_OFF(bm2))); init_object(30,30,4, 12, 1, 1, MK_FP(FP_SEG(bm),FP_OFF(bm))); init_object(80,120,4, 12, 2, 1, MK_FP(FP_SEG(bm),FP_OFF(bm))); init_object(300,200,4, 12, 1, -2, MK_FP(FP_SEG(bm),FP_OFF(bm))); init_object(360,30,4, 12, -1, -1, MK_FP(FP_SEG(bm),FP_OFF(bm))); init_object(360,10,4, 12, -2, 2, MK_FP(FP_SEG(bm),FP_OFF(bm))); x_hide_mouse(); while (!kbhit()&& !(MouseButtonStatus==LEFT_PRESSED)){ animate(); if (objects[0].X>=curr_x+ScrnPhysicalPixelWidth-32 && curr_x < MaxScrollX) curr_x++; else if (objects[0].X < curr_x+16 && curr_x > 0) curr_x--; if (objects[0].Y>=curr_y+ScrnPhysicalHeight-92 && curr_y < MaxScrollY) curr_y++; else if (objects[0].Y < curr_y+16 && curr_y > 0) curr_y--; x_page_flip(curr_x,curr_y); while(StartAddressFlag); } while(MouseButtonStatus==LEFT_PRESSED); while(kbhit()) getch(); clear_objects(); x_page_flip(curr_x,curr_y); while(StartAddressFlag); x_set_start_addr(0,0); for (j=0;j<4;j++){ x_hide_splitscreen(); delay(100); x_show_splitscreen(); delay(100); } for (i=ScrnPhysicalHeight-60;i<=ScrnPhysicalHeight;i++){ x_adjust_splitscreen(i); } x_hide_mouse(); subsequent_page(); x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6," Palette functions."); x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3," Palette functions."); x_set_font(2); x_printf(textwindow_x+5,50 ,VisiblePageOffs,9, " A number of palette manipulation functions"); x_printf(textwindow_x+5,50+8 ,VisiblePageOffs,9, " are provided. You have already seen some of"); x_printf(textwindow_x+5,50+16,VisiblePageOffs,9, " them in action. Another common operation is"); x_printf(textwindow_x+5,50+24,VisiblePageOffs,9, " palette fading. "); i=0; ch=255; while (x_cpcontrast_pal_struc(pal, pal2,ch-=2)){ x_put_pal_struc(pal2); x_rot_pal_struc(pal,palscrolldir); i++; }; for (j=0;j<i;j++){ x_cpcontrast_pal_struc(pal, pal2,ch+=2); x_put_pal_struc(pal2); x_rot_pal_struc(pal,palscrolldir); }; wait_for_keypress(); subsequent_page(); x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6," NEW Version 3.0 Functions!"); x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3," NEW Version 3.0 Functions!"); x_set_font(2); x_printf(textwindow_x+5,50 ,VisiblePageOffs,9, " NEW functions not demonstrated here include:"); x_printf(textwindow_x+5,50+10,VisiblePageOffs,9, " - RLE data compression"); x_printf(textwindow_x+5,50+20,VisiblePageOffs,9, " - FAST compiled masked bitmaps"); x_printf(textwindow_x+5,50+30,VisiblePageOffs,9, " - Hardware detection"); x_show_mouse(); wait_for_keypress(); x_hide_mouse(); for (i = 0; i < 150; i++) { x_circle(0, 0, i, 181 - i, VisiblePageOffs); x_circle(360 - i, 0, i, i + 30, VisiblePageOffs); x_circle(0, 200 - i, i, i + 30, VisiblePageOffs); x_circle(360 - i, 200 - i, i, 181 - i, VisiblePageOffs); } for (i = 0; i < 100; i++) x_filled_circle(80 + i, i, 201 - (i << 1), 30+i, VisiblePageOffs); x_show_mouse(); wait_for_keypress(); subsequent_page(); x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6," NEW Version 4.0 Functions!"); x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3," NEW Version 4.0 Functions!"); x_set_font(2); x_printf(textwindow_x+5,50 ,VisiblePageOffs,9, " NEW functions not demonstrated here include:"); x_printf(textwindow_x+5,50+10,VisiblePageOffs,9, " - FAST VRAM-based masked bitmaps, including"); x_printf(textwindow_x+5,50+18,VisiblePageOffs,9, " support for clipping regions"); x_printf(textwindow_x+5,50+28,VisiblePageOffs,9, " - Faster, smaller compiled bitmaps"); x_printf(textwindow_x+5,50+38,VisiblePageOffs,9, " - Improved planar bitmap performance and"); x_printf(textwindow_x+5,50+46,VisiblePageOffs,9, " additional support for clipping"); x_printf(textwindow_x+5,50+56,VisiblePageOffs,9, " - mouse module"); x_printf(textwindow_x+5,50+66,VisiblePageOffs,9, " - Detection of math co-processor and mouse"); x_printf(textwindow_x+5,50+76,VisiblePageOffs,9, " - Bezier curve module"); x_printf(textwindow_x+5,50+86,VisiblePageOffs,9, " - Four new resolutions, including one with"); x_printf(textwindow_x+5,50+94,VisiblePageOffs,9, " square pixels (376x282)"); x_printf(textwindow_x+5,50+104,VisiblePageOffs,9, " - More bug fixes"); wait_for_keypress(); subsequent_page(); x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6," NEW Version 5.0 Functions!"); x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3," NEW Version 5.0 Functions!"); x_set_font(2); x_printf(textwindow_x+5,50 ,VisiblePageOffs,9, " - *FAST* filled and clipped triangles ideal for"); x_printf(textwindow_x+5,50+10,VisiblePageOffs,9, " 3D work. Thanks to S. Dollins for the code."); x_printf(textwindow_x+5,50+20,VisiblePageOffs,9, " - Filled and clipped polygons, C++ Compatible"); x_printf(textwindow_x+5,50+30,VisiblePageOffs,9, " - header files, and of course bug fixes!"); x_show_mouse(); wait_for_keypress(); subsequent_page(); x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6," NEW Version 6.0 Functions!"); x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3," NEW Version 6.0 Functions!"); x_set_font(2); x_printf(textwindow_x+5,50 ,VisiblePageOffs,9, " - Fast flood filling functions "); x_printf(textwindow_x+5,50+10,VisiblePageOffs,9, " - New pbm flipping put functions."); x_printf(textwindow_x+5,50+20,VisiblePageOffs,9, " - Timer synchronized vertical retrace"); x_printf(textwindow_x+5,50+30,VisiblePageOffs,9, " - Tripple buffering extensions"); x_printf(textwindow_x+5,50+40,VisiblePageOffs,9, " Checkout demo 9 and 10 for previews"); x_show_mouse(); wait_for_keypress(); randomize(); x_hide_mouse(); while(kbhit()) getch(); palscrolldir^=1; do { int x0,x1,x2,y0,y1,y2,i; i=random(256); x0=random(ScrnLogicalPixelWidth); x1=random(ScrnLogicalPixelWidth); x2=random(ScrnLogicalPixelWidth); y0=random(ScrnPhysicalHeight); y1=random(ScrnPhysicalHeight); y2=random(ScrnPhysicalHeight); x_triangle(x0,y0,x1,y1,x2,y2,i,VisiblePageOffs); } while (!kbhit() && !(MouseButtonStatus==LEFT_PRESSED)); while(MouseButtonStatus==LEFT_PRESSED); while(kbhit()) getch(); x_show_mouse(); subsequent_page(); x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6," PLEASE..."); x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3," PLEASE..."); x_set_font(2); x_printf(textwindow_x+5,50 ,VisiblePageOffs,9, " Please mention my name in programs that use XLIB"); x_printf(textwindow_x+5,50+8 ,VisiblePageOffs,9, " just to make me feel it was worth the effort."); x_printf(textwindow_x+5,50+16,VisiblePageOffs,9, " If you have any bug to report please feel free to"); x_printf(textwindow_x+5,50+24,VisiblePageOffs,9, " mail me a message. Any hints, suggestions and"); x_printf(textwindow_x+5,50+32,VisiblePageOffs,9, " contributions are welcome and encouraged."); x_printf(textwindow_x+5,50+52,VisiblePageOffs,9, " I have contributed this code to the public domain."); x_printf(textwindow_x+5,50+60,VisiblePageOffs,9, " Please respect my wishes and leave it there."); x_printf(textwindow_x+5,50+80,VisiblePageOffs,9, " Finally, I hope you all find this stuff useful,"); x_printf(textwindow_x+5,50+96,VisiblePageOffs,9, " Themie Gouthas - [email protected]"); wait_for_keypress(); x_hide_mouse(); x_shift_rect (27, 27, 360-27, 177, 27, 23, VisiblePageOffs); x_rect_fill(25, 173, 335, 176, VisiblePageOffs, 1); for (i = 0; i < 50; i++) { x_shift_rect (27, 26, 360-27, 177 - (i * 3), 27, 23, VisiblePageOffs); } }
CROSSCUT_NLS_DATA int main (int argc, char *argv[]) { int memkind, handle; char loop1, loop2; struct dfree free; char buf[BUFFERSIZE]; char cmpbuf[BUFFERSIZE]; unsigned long sector, total, disksize, allocated, beginsector, endsector; unsigned long FilledDiskSize, FilledTotal, FileSize = 0; int Arg1IsFile, Arg2IsFile; int UseImageFile, ImageModus, Overwrite; int i, enable; int audible, verify, fallthrough, askdisk, asktdisk; char sdrive, tdrive; int HardDiskOk; int informative, copyfast; char switchchar; int tocopysectors; unsigned tobuffer; #ifndef ALL_RECOVERY_MODE int recoverymode; #endif int bytespersector; int CopyingToSameDisk = FALSE; int action, success; struct LFNAttribute attr; struct IniParserStruct *ParsedData; struct TwoDriveCopyData tdrvdata; attr.output = TRUE; memkind = UNALLOCATED; UseImageFile = FALSE; SetExePath (argv[0]); /* Remember executable's path. */ CriticalHandlerOn (); /* Install critical handler. */ InitLFNAPI (); /* Initialise LFN API. */ CROSSCUT_NLS_OPEN switchchar = SwitchChar (); /* Check arguments */ if ((argc == 2) && ((argv[1][0] == '/') || (argv[1][0] == switchchar)) && (argv[1][1] == '?') && (argv[1][2] == '\0')) { ShowHelp (switchchar); return COPYSUCCESS; } if (argc > 2) { Arg1IsFile = IsFile (argv[1]); Arg2IsFile = IsFile (argv[2]); } #ifdef DEF_HELP if (argc < 3) { /* The way we do it. */ ShowHelp (switchchar); return INITERROR; } else if ((!HasFloppyForm (argv[1]) && !Arg1IsFile) || (!HasFloppyForm (argv[2]) && !Arg2IsFile)) #else if ((argc < 3) || (!HasFloppyForm (argv[1]) && !Arg1IsFile) || (!HasFloppyForm (argv[2]) && !Arg2IsFile)) #endif { /* The way (DR and MS) DOS does it. */ NLS_PUTSTRING (1, 0, "Invalid drive specification or non removable media."); return INITERROR; } if (ParseIniFile (NULL) < 0) /* Parse .ini file. */ { NLS_PUTSTRING (1, 1, "Error reading configuration file."); return INITERROR; } ParsedData = GetParsedData (); audible = ParsedData->audible; verify = ParsedData->verify; HardDiskOk = ParsedData->UseSWAP; informative = ParsedData->informative; Overwrite = ParsedData->overwrite; fallthrough = ParsedData->autoexit; askdisk = ParsedData->askdisk; asktdisk = ParsedData->asktdisk; copyfast = (ParsedData->speed == FAST); #ifndef ALL_RECOVERY_MODE recoverymode = ParsedData->mode; #endif /* Check arguments. */ for (i = 3; i < argc; i++) { if (strlen (argv[i]) > 3) { NLS_PRINTSTRING (1, 2, "Invalid switch:"); printf (" %s\n", argv[i]); return INITERROR; } enable = TRUE; if (strlen (argv[i]) == 3) { if (argv[i][2] == '-') { enable = FALSE; } else { NLS_PRINTSTRING (1, 2, "Invalid switch"); printf (" %s\n", argv[i]); return INITERROR; } } if ((argv[i][0] == switchchar) || (argv[i][0] == '/')) switch (argv[i][1]) { case 'a': /* DOS is case insensitive. */ case 'A': audible = enable; break; case 'v': case 'V': verify = enable; break; case 'm': case 'M': HardDiskOk = !enable; break; case 'i': case 'I': informative = enable; break; case 'o': case 'O': Overwrite = enable; break; case 'x': case 'X': fallthrough = enable; break; case 'd': case 'D': askdisk = !enable; break; case 'f': case 'F': copyfast = enable; break; #ifndef ALL_RECOVERY_MODE case 'r': case 'R': recoverymode = enable; break; #else case 'r': case 'R': #endif case 't': case 'T': asktdisk = !enable; break; case '1': NLS_PRINTSTRING (2, 0, "Warning: option"); printf (" %s ", argv[i]); NLS_PUTSTRING (2, 1, "doesn't do anything!"); break; default: NLS_PRINTSTRING (1, 2, "Invalid switch"); printf (" %s\n", argv[i]); return INITERROR; } else { NLS_PRINTSTRING (1, 3, "Too many parameters:"); printf (" %s\n", argv[i]); return INITERROR; } } if (Arg1IsFile && Arg2IsFile) { ConvertToSFN (argv[1], INFILE_ID); ConvertToSFN (argv[2], OUTFILE_ID); SetLFNAttribute (&attr, OUTFILE_ID); if ((access (GetSFN (OUTFILE_ID), EXISTS) == 0) && Overwrite && (remove (GetSFN (OUTFILE_ID)) == -1)) { NLS_PUTSTRING (1, 4, "File is write protected!"); return INITERROR; } if (CopyFile (GetSFN (INFILE_ID), GetSFN (OUTFILE_ID))) { printf ("%s ", argv[1]); NLS_PRINTSTRING (1, 5, "copied to"); printf (" %s", argv[2]); if (audible) Beep (); SynchronizeLFNs (); return COPYSUCCESS; } else { NLS_PRINTSTRING (3, 0, "Problem copying"); printf (" %s ", argv[1]); NLS_PRINTSTRING (3, 1, "to"); printf (" %s.\n", argv[2]); return CRITICAL; } } else if (Arg1IsFile) { ConvertToSFN (argv[1], INFILE_ID); if (access (GetSFN (INFILE_ID), READPERMISSION) != 0) { NLS_PRINTSTRING (1, 6, "File not found:"); printf (" %s\n", argv[1]); return INITERROR; } CopyingToSameDisk = IsCopyToSameDisk (argv[1], argv[2]); UseImageFile = TRUE; ImageModus = READIMAGE; } else if (Arg2IsFile) { CopyingToSameDisk = IsCopyToSameDisk (argv[2], argv[1]); ConvertToSFN (argv[2], OUTFILE_ID); SetLFNAttribute (&attr, OUTFILE_ID); if (!CopyingToSameDisk) { if (access (GetSFN (OUTFILE_ID), EXISTS) == 0) { if (Overwrite) { if (remove (GetSFN (OUTFILE_ID)) != 0) { NLS_PRINTSTRING (1, 4, "File is write protected!"); return INITERROR; } } else { NLS_PRINTSTRING (1, 7, "File already exists!"); return INITERROR; } } } if (CopyingToSameDisk) copyfast = TRUE; UseImageFile = TRUE; ImageModus = WRITEIMAGE; } sdrive = (char) toupper (argv[1][0]) - 65; tdrive = (char) toupper (argv[2][0]) - 65; loop1 = CatYES; /* initialize loop1 */ loop2 = CatYES; /* initialize loop2 */ ctrlbrk (OnCBreak); SavedCBreak = getcbrk (); setcbrk (1); /* set control-break to ON */ atexit (OnExit); /* make sure that all allocated memory is released when program stops. */ if ((sdrive != tdrive) && (!UseImageFile) && BiosReportsTwoDrives ()) { tdrvdata.sourcedrv = sdrive; tdrvdata.destdrv = tdrive; tdrvdata.cpybuf = buf; tdrvdata.cmpbuf = cmpbuf; tdrvdata.bufsize = BUFFERSIZE; tdrvdata.bel = audible; tdrvdata.fallthrough = fallthrough; tdrvdata.askdisk = askdisk; tdrvdata.copyfast = copyfast; tdrvdata.verify = verify; #ifndef ALL_RECOVERY_MODE tdrvdata.recoverymode = recoverymode; #endif #ifdef UPDATE_SERIALNUM tdrvdata.updateserial = ParsedData->serialnumber; #endif TwoDriveCopy (&tdrvdata); return COPYSUCCESS; } endsector = 0; while (!NLS_TEST_NO (loop1)) /* loop1 */ { if (!UseImageFile || (ImageModus == WRITEIMAGE)) { if (askdisk) { puts (""); NLS_PRINTSTRING (1, 8, "Insert SOURCE diskette into drive"); printf (" %s\n\n", argv[1]); NLS_PRINTSTRING (1, 9, "Press any key to continue . . ."); WaitForInput (); puts (""); } else askdisk = TRUE; /* Always ask after the first run. */ } if (endsector == 0) { if (!UseImageFile || (ImageModus == WRITEIMAGE)) { if (!DiskReadBootInfo (sdrive, &free) || (DetermineFATType() != FAT12)) { puts (""); NLS_PUTSTRING (1, 10, "Disk not ready!"); return CRITICAL; } } else { /* Remember file size */ handle = open (GetSFN (INFILE_ID), O_RDONLY | O_BINARY); if (handle < 0) { puts (""); NLS_PUTSTRING (1, 11, "Unable to open image file."); return INITERROR; } FileSize = filelength (handle); close (handle); if (!FileReadBootInfo (GetSFN (INFILE_ID), &free)) { puts (""); NLS_PUTSTRING (1, 11, "Unable to open image file."); return INITERROR; } } total = free.df_total * free.df_sclus; bytespersector = free.df_bsec; disksize = total * bytespersector; if (disksize == 0) { puts (""); NLS_PUTSTRING (1, 0, "Invalid drive specification or non removable media."); return INITERROR; } /* Initialize fast copy: - After checking if disk in drive is ok, BUT - before initializing memory */ /* In case of writing an image file to disk. We'd like the program to succeed regardless of wether we used the /f switch or corresponding .ini file entry */ if (((copyfast) || ((UseImageFile && (ImageModus == READIMAGE)) && disksize != FileSize)) && (disksize != FileSize)) { SetCopySpeed (FAST); if (!UseImageFile || (ImageModus == WRITEIMAGE)) { if (!DiskReadFatInfo (sdrive)) SetCopySpeed (FULL); } else if (!FileReadFatInfo (GetSFN (INFILE_ID))) { NLS_PUTSTRING (1, 32, "Can not copy image file"); return INITERROR; } } else SetCopySpeed (FULL); } puts (""); /* Get the size of the meaningfull data on the disk */ FilledDiskSize = GetDiskFilledSize (BUFFERSIZE); FilledTotal = (FilledDiskSize / free.df_bsec) / free.df_sclus; if ((UseImageFile) && (!CopyingToSameDisk)) switch (SetImageFile (GetSFN (ImageModus - 1), ImageModus, FilledDiskSize)) { case EZERO: allocated = disksize; break; case DISKTOSMALL: puts (""); NLS_PUTSTRING (1, 12, "Not enough disk space on target drive!"); return INITERROR; default: NLS_PRINTSTRING (1, 13, "Error accessing image file:"); printf (" %s\n", argv[ImageModus]); return INITERROR; } else { if (CopyingToSameDisk) switch (ImageModus) { case READIMAGE: memkind = InitializeFittingMemory (FilledDiskSize, HardDiskOk, &allocated, '\0', argv[2][0]); break; case WRITEIMAGE: memkind = InitializeFittingMemory (FilledDiskSize, HardDiskOk, &allocated, argv[1][0], '\0'); break; } else memkind = InitializeFittingMemory (FilledDiskSize, HardDiskOk, &allocated, argv[1][0], argv[2][0]); if (memkind == 0) { NLS_PUTSTRING (1, 14, "Insufficient memory for disk copy.\n"); return INITERROR; } } if (CopyingToSameDisk) { if (allocated != FilledDiskSize) { NLS_PUTSTRING (1, 14, "Insufficient memory for disk copy.\n"); return INITERROR; } if (ImageModus == READIMAGE) { PrepareForWriting (); if (!ReadFileIntoMemory (GetSFN (INFILE_ID), buf, BUFFERSIZE)) { NLS_PUTSTRING (1, 33, "Problem reading image file."); return CRITICAL; } } else /* ImageModus == WRITEIMAGE */ if (!asktdisk) { if (!DiskLargeEnough (GetSFN (OUTFILE_ID), FilledDiskSize)) { puts (""); NLS_PUTSTRING (1, 12, "Not enough disk space on target drive!"); return INITERROR; } } } if (!UseImageFile || (ImageModus == WRITEIMAGE)) { beginsector = endsector; endsector += allocated / BYTESPERSECTOR; if ((endsector > total) || (allocated == FilledDiskSize)) endsector = total; } if (!UseImageFile || (ImageModus == WRITEIMAGE)) { NLS_PRINTSTRING (4, 0, "Copying"); printf (" %d ", (int) FilledTotal); NLS_PRINTSTRING (4, 1, "clusters"); printf (", %d ", free.df_sclus); NLS_PRINTSTRING (4, 2, "sectors per cluster"); printf (", %d ", free.df_bsec); NLS_PRINTSTRING (4, 3, "bytes per sector"); puts ("."); NLS_PRINTSTRING (4, 4, "Relevant drive size is"); printf (" %lu ", FilledDiskSize); NLS_PRINTSTRING (4, 5, "bytes"); printf ("."); } if (informative && (!UseImageFile)) { printf (" "); NLS_PRINTSTRING (1, 15, "Using"); printf (" "); switch (memkind) { case EMS: puts ("EMS.\n"); break; case XMS: puts ("XMS.\n"); break; case HARDDISK: NLS_PUTSTRING (1, 16, "temporary file"); puts (""); break; case BUFFERS: NLS_PRINTSTRING (5, 0, "buffer of"); printf (" %ld ", allocated); NLS_PUTSTRING (5, 1, "bytes."); puts (""); break; } } else if (!UseImageFile || (ImageModus == WRITEIMAGE)) puts ("\n"); if (!UseImageFile || (ImageModus == WRITEIMAGE)) { for (action = DISKREADING; (verify) ? (action <= VERIFICATION) : (action < VERIFICATION); action++) { if (action == DISKREADING) { if (!UseImageFile) { NLS_PRINTSTRING (1, 17, "Reading SOURCE diskette . . ."); } else NLS_PRINTSTRING (1, 34, "Creating image file . . ."); PrepareForWriting (); } else { puts (""); NLS_PRINTSTRING (1, 38, "Verifying . . ."); PrepareForReading (); } for (sector = beginsector; sector < endsector; sector = sector + TOCOPYSECTORS) { if (sector < endsector - TOCOPYSECTORS) tocopysectors = TOCOPYSECTORS; else tocopysectors = (int) (endsector - sector); tobuffer = (unsigned) (tocopysectors * BYTESPERSECTOR); if (IsDiskReadRequired (sector, tocopysectors)) /* Fast copy */ { #ifndef ALL_RECOVERY_MODE if (recoverymode) #endif ReadSectors (sdrive, tocopysectors, (int) sector, buf, bytespersector); #ifndef ALL_RECOVERY_MODE else if (absread (sdrive, tocopysectors, (int) sector, buf) != 0) { puts (""); NLS_PRINTSTRING (1, 18, "Media error reading from sector"); printf (" %ld.\n", sector); } #endif if (action == DISKREADING) success = WriteMemoryBlock (buf, tobuffer); else success = ReadMemoryBlock (cmpbuf, tobuffer); if (!success) { puts (""); NLS_PUTSTRING (1, 20, "Unsuspected memory error."); SetErrorStopped (); return CRITICAL; } if (action == VERIFICATION) { if (memcmp (buf, cmpbuf, 5 /*tobuffer */ ) != 0) { puts (""); NLS_PRINTSTRING (1, 37, "Compare error on sector"); printf (" %ld.\n", sector); } } } } } } if (audible && (!UseImageFile)) Beep (); if (!UseImageFile || (ImageModus == READIMAGE)) { while (!NLS_TEST_NO (loop2)) /* loop2 */ { if (askdisk) { if (!UseImageFile) puts ("\n"); NLS_PRINTSTRING (1, 21, "Insert TARGET diskette into drive"); printf (" %s\n\n", argv[2]); NLS_PRINTSTRING (1, 9, "Press any key to continue . . ."); WaitForInput (); } else askdisk = TRUE; /* Check disk capacity is the same as that of the original diskette. */ for (;;) { if (!DiskReadBootInfo (tdrive, &free)) { puts (""); NLS_PUTSTRING (1, 10, "Disk not ready!"); total = 0; } else total = free.df_total * free.df_sclus; if (((UseImageFile) && (FileSize != FilledDiskSize)) || (disksize != total * free.df_bsec)) { puts (""); NLS_PUTSTRING (1, 22, "Diskette does not have the same capacity as the original."); if (fallthrough) return NONFATAL; puts (""); NLS_PRINTSTRING (1, 23, "Put a diskette with the right capacity in drive"); printf (" %s, \n", argv[2]); NLS_PUTSTRING (1, 24, "or press CTRL-C to cancel."); WaitForInput (); /* When the user presses CTRL-C this function does not return */ } else break; } if (UseImageFile) { puts ("\n"); NLS_PRINTSTRING (4, 0, "Copying"); printf (" %d ", (int) FilledTotal); NLS_PRINTSTRING (4, 1, "clusters"); printf (", %d ", free.df_sclus); NLS_PRINTSTRING (4, 2, "sectors per cluster"); printf (", %d ", free.df_bsec); NLS_PRINTSTRING (4, 3, "bytes per sector"); puts ("."); NLS_PRINTSTRING (4, 4, "Relevant drive size is"); printf (" %lu ", FilledDiskSize); NLS_PRINTSTRING (4, 5, "bytes"); puts ("."); beginsector = endsector; endsector += allocated / BYTESPERSECTOR; if (endsector > total) endsector = total; } for (action = DISKWRITING; (verify) ? (action <= VERIFICATION) : (action < VERIFICATION); action++) { if (action == DISKWRITING) { if (UseImageFile) { puts (""); NLS_PRINTSTRING (1, 35, "Writing image file . . ."); } else { puts ("\n"); NLS_PRINTSTRING (1, 25, "Writing to TARGET diskette in drive . . ."); } PrepareForReading (); } else /* VERIFICATION */ { puts (""); NLS_PRINTSTRING (1, 38, "Verifying . . ."); PrepareForReading (); /* Rewind */ } for (sector = beginsector; sector < endsector; sector = sector + TOCOPYSECTORS) { if (sector < endsector - TOCOPYSECTORS) tocopysectors = TOCOPYSECTORS; else tocopysectors = (int) (endsector - sector); tobuffer = (unsigned) (tocopysectors * BYTESPERSECTOR); if (IsDiskReadRequired (sector, tocopysectors)) { if (!ReadMemoryBlock (buf, tobuffer)) { puts (""); NLS_PUTSTRING (1, 20, "Unsuspected memory error."); SetErrorStopped (); return CRITICAL; } if (action == DISKWRITING) { #ifdef UPDATE_SERIALNUM if (sector == 0) { if (ParsedData->serialnumber == UPDATE) UpdateDiskSerialNumber (buf); } #endif if (abswrite (tdrive, tocopysectors, (int) sector, buf) != 0) { if (sector == 0) { if (abswrite(tdrive, 1, 0, buf) != 0) { puts("\n"); NLS_PRINTSTRING(1, 41, "Sector 0 unwritable! Write protected?"); if (FilledDiskSize == allocated) break; else return CRITICAL; } } puts (""); NLS_PRINTSTRING (1, 27, "Media error writing to sector"); printf (" %ld.\n", sector); } } else { if (absread (tdrive, tocopysectors, (int) sector, cmpbuf) != 0) { puts (""); NLS_PRINTSTRING (1, 18, "Media error reading from sector"); printf (" %ld.\n", sector); } if (sector == 0) { if (ParsedData->serialnumber == UPDATE) { ClearDiskSerialNumber (buf); ClearDiskSerialNumber (cmpbuf); } } if (memcmp (buf, cmpbuf, tobuffer) != 0) { puts (""); NLS_PRINTSTRING (1, 37, "Compare error on sector"); printf (" %ld.\n", sector); } } } } } if (!UseImageFile) puts (""); if (UseImageFile || (FilledDiskSize == allocated)) /* If everything fitted in memory */ { loop2 = (fallthrough) ? CatNO : CatNO + 1; if (loop2 == CatYES) loop2++; while (!NLS_TEST_YES_NO (loop2)) { ClrKbd (); if (audible) Beep (); puts (""); if (UseImageFile) puts (""); NLS_PRINTSTRING (1, 28, "Do you want another copy of this "); if (UseImageFile) { endsector = 0; NLS_PRINTSTRING (1, 29, "image file (Y/N)?"); } else NLS_PRINTSTRING (1, 30, "disk (Y/N)?"); loop2 = toupper (getch ()); puts (""); } if (UseImageFile && (NLS_TEST_YES (loop2))) puts (""); } else { puts (""); loop2 = CatNO; } /* Change the serial number of the target disk. */ #ifdef UPDATE_SERIALNUM if (ParsedData->serialnumber == UPDATE) { puts (""); PrintDiskSerialNumber (); puts (""); } #endif } /* loop2 */ loop2 = CatYES; if (loop2 == CatNO) loop2++; ReleaseMemory (); } else { if (CopyingToSameDisk) { PrepareForReading (); if (!WriteFileFromMemory (GetSFN (OUTFILE_ID), buf, BUFFERSIZE, FilledDiskSize, asktdisk, fallthrough, Overwrite)) { NLS_PUTSTRING (1, 36, "Problem writing image file."); return CRITICAL; } } } loop1 = CatYES + 1; if (loop1 == CatNO) loop1++; if (!UseImageFile && !fallthrough && (endsector == total)) { while (!NLS_TEST_YES_NO (loop1)) { ClrKbd (); puts (""); NLS_PRINTSTRING (1, 31, "Copy another disk (Y/N)?"); loop1 = toupper (getch ()); puts (""); endsector = 0; } } else if (UseImageFile || (fallthrough && (endsector == total))) { loop1 = CatNO; if (fallthrough) puts (""); else if (audible && (ImageModus == WRITEIMAGE)) Beep (); } } /* end loop1 */ if ((UseImageFile) && (ImageModus == WRITEIMAGE)) puts (""); return COPYSUCCESS; }
void tcp_cbrk( int mode ) { cbrkmode = mode; ctrlbrk(handler); }