From: Oliver Schmidt Date: Sat, 18 Jun 2016 21:35:57 +0000 (+0200) Subject: Make use of doesclrscrafterexit(). X-Git-Tag: V2.16~102 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9bc096d9b02255cab6d4225e28c0685714ca3ae3;p=cc65 Make use of doesclrscrafterexit(). --- diff --git a/samples/diodemo.c b/samples/diodemo.c index 752c2f78a..3e52f2fa9 100644 --- a/samples/diodemo.c +++ b/samples/diodemo.c @@ -36,6 +36,7 @@ #include #include #include +#include #include @@ -123,6 +124,11 @@ int main (int argc, const char* argv[]) clrscr (); screensize (&ScreenX, &ScreenY); + /* Allow user to read exit messages */ + if (doesclrscrafterexit ()) { + atexit ((void (*)) cgetc); + } + cputs ("Floppy Disk Copy\r\n"); chline (16); cputs ("\r\n"); diff --git a/samples/enumdevdir.c b/samples/enumdevdir.c index f270b43af..ce2dc99ec 100644 --- a/samples/enumdevdir.c +++ b/samples/enumdevdir.c @@ -8,12 +8,12 @@ #include -#include #include #include #include #include #include +#include void printdir (char *newdir) @@ -97,5 +97,7 @@ void main (void) device = getnextdevice (device); } - cgetc (); + if (doesclrscrafterexit ()) { + getchar (); + } } diff --git a/samples/gunzip65.c b/samples/gunzip65.c index 2ad029467..9d21c2137 100644 --- a/samples/gunzip65.c +++ b/samples/gunzip65.c @@ -14,6 +14,11 @@ #include #include +#ifdef __CC65__ +#include +#include +#endif + #ifndef __CC65__ /* ** Emulate inflatemem() if using original zlib. @@ -191,6 +196,13 @@ int main(void) FILE* fp; unsigned length; +#ifdef __CC65__ + /* allow user to read exit messages */ + if (doesclrscrafterexit()) { + atexit((void (*)) getchar); + } +#endif /* __CC65__ */ + /* read GZIP file */ puts("GZIP file name:"); fp = fopen(get_fname(), "rb"); diff --git a/samples/mandelbrot.c b/samples/mandelbrot.c index 5d3d661c9..d7291c5b5 100644 --- a/samples/mandelbrot.c +++ b/samples/mandelbrot.c @@ -10,6 +10,7 @@ #include #include #include +#include @@ -51,7 +52,7 @@ void mandelbrot (signed short x1, signed short y1, signed short x2, register signed short xs, ys, xx, yy; register signed short x, y; - /* calc stepwidth */ + /* Calc stepwidth */ xs = ((x2 - x1) / (SCREEN_X)); ys = ((y2 - y1) / (SCREEN_Y)); @@ -61,7 +62,7 @@ void mandelbrot (signed short x1, signed short y1, signed short x2, xx = x1; for (x = 0; x < (SCREEN_X); x++) { xx += xs; - /* do iterations */ + /* Do iterations */ r = 0; i = 0; for (count = 0; (count < maxiterations) && @@ -75,12 +76,13 @@ void mandelbrot (signed short x1, signed short y1, signed short x2, if (count == maxiterations) { tgi_setcolor (0); } else { - if (MAXCOL == 2) + if (MAXCOL == 2) { tgi_setcolor (1); - else + } else { tgi_setcolor (count % MAXCOL); + } } - /* set pixel */ + /* Set pixel */ tgi_setpixel (x, y); } } @@ -107,6 +109,9 @@ int main (void) if (err != TGI_ERR_OK) { cprintf ("Error #%d initializing graphics.\r\n%s\r\n", err, tgi_geterrormsg (err)); + if (doesclrscrafterexit ()) { + cgetc (); + } exit (EXIT_FAILURE); }; cprintf ("ok.\n\r"); @@ -117,15 +122,15 @@ int main (void) t = clock (); - /* calc mandelbrot set */ + /* Calc mandelbrot set */ mandelbrot (tofp (-2), tofp (-2), tofp (2), tofp (2)); t = clock () - t; /* Fetch the character from the keyboard buffer and discard it */ - (void) cgetc (); + cgetc (); - /* shut down gfx mode and return to textmode */ + /* Shut down gfx mode and return to textmode */ tgi_done (); /* Calculate stats */ @@ -136,9 +141,11 @@ int main (void) /* Output stats */ cprintf ("time : %lu.%us\n\r", sec, sec10); - /* Wait for a key, then end */ - cputs ("Press any key when done...\n\r"); - (void) cgetc (); + if (doesclrscrafterexit ()) { + /* Wait for a key, then end */ + cputs ("Press any key when done...\n\r"); + cgetc (); + } /* Done */ return EXIT_SUCCESS; diff --git a/samples/mousetest.c b/samples/mousetest.c index 4a849cb98..3910d5a0a 100644 --- a/samples/mousetest.c +++ b/samples/mousetest.c @@ -17,6 +17,7 @@ #include #include #include +#include #define max(a,b) (((a) > (b)) ? (a) : (b)) #define min(a,b) (((a) < (b)) ? (a) : (b)) @@ -57,7 +58,9 @@ static void __fastcall__ CheckError (const char* S, unsigned char Error) /* Wait for a key-press, so that some platforms can show the error ** message before they remove the current screen. */ - cgetc(); + if (doesclrscrafterexit ()) { + cgetc (); + } exit (EXIT_FAILURE); } } diff --git a/samples/multidemo.c b/samples/multidemo.c index 74039cfd6..038b74d64 100644 --- a/samples/multidemo.c +++ b/samples/multidemo.c @@ -11,11 +11,11 @@ #include -#include #include #include #include #include +#include #ifndef __CBM__ #include #include @@ -229,7 +229,7 @@ void main (void) } log ("Press any key..."); - cgetc (); + getchar (); if (loadoverlay (1)) { log ("Calling overlay 1 from main"); @@ -254,6 +254,8 @@ void main (void) foobar (); } - log ("Press any key..."); - cgetc (); + if (doesclrscrafterexit ()) { + log ("Press any key..."); + getchar (); + } } diff --git a/samples/overlaydemo.c b/samples/overlaydemo.c index 42e757153..a4dc53931 100644 --- a/samples/overlaydemo.c +++ b/samples/overlaydemo.c @@ -10,7 +10,7 @@ #include -#include +#include #ifndef __CBM__ #include #include @@ -130,5 +130,7 @@ void main (void) foobar (); } - cgetc (); + if (doesclrscrafterexit ()) { + getchar (); + } } diff --git a/samples/tgidemo.c b/samples/tgidemo.c index a08020640..d8c2a6f50 100644 --- a/samples/tgidemo.c +++ b/samples/tgidemo.c @@ -40,6 +40,9 @@ static void CheckError (const char* S) unsigned char Error = tgi_geterror (); if (Error != TGI_ERR_OK) { printf ("%s: %d\n", S, Error); + if (doesclrscrafterexit ()) { + cgetc (); + } exit (EXIT_FAILURE); } }