From: Radical NetSurfer Newsgroups: comp.os.msdos.djgpp Subject: Teleprompter Crashes :( Date: Wed, 01 Nov 2000 07:48:40 -0500 Message-ID: X-Newsreader: Forte Agent 1.8/32.548 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 216.202.140.73 X-Original-NNTP-Posting-Host: 216.202.140.73 X-Trace: 1 Nov 2000 07:53:03 -0500, 216.202.140.73 Lines: 65 X-Original-NNTP-Posting-Host: 64.31.79.51 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com WHY does the following code (??) cause my program to Seg-Fault upon termination ?? PLEASE help me to understand this once and for all. Using Allegro 3.12 This program is functional, works with keyboard input or taking input from a text file ( Charg < text.txt ) /********************************************** When the Lower-Right corner is reached, the screen is Scrolled and the Cursor Homed ONLY _after_ the next keypress is received! (desired) Input: Using Keyboard, Output: Display CharGen Text Uses: LocX, LocY for INITIAL Positions Features:Actually performs a functional scroll! ***********************************************/ void bmptty(void) { char temp[10]; int xs, ys, ch; int line; xs = LocX; //Initial Cursor Starting Position ys = LocY; //Coords are 0,0 based line = 0; for(;;) { ch = getch(); if ( ch == 27 ) break; if ( ch==13 ) { xs = 0; ys += 64; ++line; } if ( ch == 8 ) { if ( xs > 41 ) { xs -= 42; } } if ( ch==12 ) { clear_to_color(screen, 0); } if ( ch < 32 ) continue; if ( ys > 512 ) { xs = 0; ys = 8*64; //clear_to_color(screen, 0); bmpscroll(); //<-- rem this out won't matter! } sprintf(temp,"G:\\DJGPP\\CharGen\\Courier44\\Char%d.bmp", ch ); // sprintf(temp,"Char%d.bmp", ch ); //if ( ) { continue; } //Check for existance of specific FontBMP !! the_image = load_bitmap(temp, the_pallete); if ( the_image == NULL ) { sound( 1440 ); delay(500); nosound(); } set_pallete(the_pallete); //might be needed for 256BMP's blit(the_image, screen, 0, 0, xs, ys, the_image->w, the_image->h); destroy_bitmap(the_image); //NECESSARY? // the_image = NULL; xs+=42; //Next whole-char position if ( xs >= 798 ) { xs = 0; ys += 64; } } }