Make use of doesclrscrafterexit().
This commit is contained in:
parent
520641890d
commit
9bc096d9b0
8 changed files with 57 additions and 20 deletions
|
@ -36,6 +36,7 @@
|
||||||
#include <conio.h>
|
#include <conio.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <cc65.h>
|
||||||
#include <dio.h>
|
#include <dio.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -123,6 +124,11 @@ int main (int argc, const char* argv[])
|
||||||
clrscr ();
|
clrscr ();
|
||||||
screensize (&ScreenX, &ScreenY);
|
screensize (&ScreenX, &ScreenY);
|
||||||
|
|
||||||
|
/* Allow user to read exit messages */
|
||||||
|
if (doesclrscrafterexit ()) {
|
||||||
|
atexit ((void (*)) cgetc);
|
||||||
|
}
|
||||||
|
|
||||||
cputs ("Floppy Disk Copy\r\n");
|
cputs ("Floppy Disk Copy\r\n");
|
||||||
chline (16);
|
chline (16);
|
||||||
cputs ("\r\n");
|
cputs ("\r\n");
|
||||||
|
|
|
@ -8,12 +8,12 @@
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <conio.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <device.h>
|
#include <device.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
#include <cc65.h>
|
||||||
|
|
||||||
|
|
||||||
void printdir (char *newdir)
|
void printdir (char *newdir)
|
||||||
|
@ -97,5 +97,7 @@ void main (void)
|
||||||
device = getnextdevice (device);
|
device = getnextdevice (device);
|
||||||
}
|
}
|
||||||
|
|
||||||
cgetc ();
|
if (doesclrscrafterexit ()) {
|
||||||
|
getchar ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,11 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
|
||||||
|
#ifdef __CC65__
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <cc65.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef __CC65__
|
#ifndef __CC65__
|
||||||
/*
|
/*
|
||||||
** Emulate inflatemem() if using original zlib.
|
** Emulate inflatemem() if using original zlib.
|
||||||
|
@ -191,6 +196,13 @@ int main(void)
|
||||||
FILE* fp;
|
FILE* fp;
|
||||||
unsigned length;
|
unsigned length;
|
||||||
|
|
||||||
|
#ifdef __CC65__
|
||||||
|
/* allow user to read exit messages */
|
||||||
|
if (doesclrscrafterexit()) {
|
||||||
|
atexit((void (*)) getchar);
|
||||||
|
}
|
||||||
|
#endif /* __CC65__ */
|
||||||
|
|
||||||
/* read GZIP file */
|
/* read GZIP file */
|
||||||
puts("GZIP file name:");
|
puts("GZIP file name:");
|
||||||
fp = fopen(get_fname(), "rb");
|
fp = fopen(get_fname(), "rb");
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <conio.h>
|
#include <conio.h>
|
||||||
#include <tgi.h>
|
#include <tgi.h>
|
||||||
|
#include <cc65.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -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 xs, ys, xx, yy;
|
||||||
register signed short x, y;
|
register signed short x, y;
|
||||||
|
|
||||||
/* calc stepwidth */
|
/* Calc stepwidth */
|
||||||
xs = ((x2 - x1) / (SCREEN_X));
|
xs = ((x2 - x1) / (SCREEN_X));
|
||||||
ys = ((y2 - y1) / (SCREEN_Y));
|
ys = ((y2 - y1) / (SCREEN_Y));
|
||||||
|
|
||||||
|
@ -61,7 +62,7 @@ void mandelbrot (signed short x1, signed short y1, signed short x2,
|
||||||
xx = x1;
|
xx = x1;
|
||||||
for (x = 0; x < (SCREEN_X); x++) {
|
for (x = 0; x < (SCREEN_X); x++) {
|
||||||
xx += xs;
|
xx += xs;
|
||||||
/* do iterations */
|
/* Do iterations */
|
||||||
r = 0;
|
r = 0;
|
||||||
i = 0;
|
i = 0;
|
||||||
for (count = 0; (count < maxiterations) &&
|
for (count = 0; (count < maxiterations) &&
|
||||||
|
@ -75,12 +76,13 @@ void mandelbrot (signed short x1, signed short y1, signed short x2,
|
||||||
if (count == maxiterations) {
|
if (count == maxiterations) {
|
||||||
tgi_setcolor (0);
|
tgi_setcolor (0);
|
||||||
} else {
|
} else {
|
||||||
if (MAXCOL == 2)
|
if (MAXCOL == 2) {
|
||||||
tgi_setcolor (1);
|
tgi_setcolor (1);
|
||||||
else
|
} else {
|
||||||
tgi_setcolor (count % MAXCOL);
|
tgi_setcolor (count % MAXCOL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* set pixel */
|
/* Set pixel */
|
||||||
tgi_setpixel (x, y);
|
tgi_setpixel (x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,6 +109,9 @@ int main (void)
|
||||||
if (err != TGI_ERR_OK) {
|
if (err != TGI_ERR_OK) {
|
||||||
cprintf ("Error #%d initializing graphics.\r\n%s\r\n",
|
cprintf ("Error #%d initializing graphics.\r\n%s\r\n",
|
||||||
err, tgi_geterrormsg (err));
|
err, tgi_geterrormsg (err));
|
||||||
|
if (doesclrscrafterexit ()) {
|
||||||
|
cgetc ();
|
||||||
|
}
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
};
|
};
|
||||||
cprintf ("ok.\n\r");
|
cprintf ("ok.\n\r");
|
||||||
|
@ -117,15 +122,15 @@ int main (void)
|
||||||
|
|
||||||
t = clock ();
|
t = clock ();
|
||||||
|
|
||||||
/* calc mandelbrot set */
|
/* Calc mandelbrot set */
|
||||||
mandelbrot (tofp (-2), tofp (-2), tofp (2), tofp (2));
|
mandelbrot (tofp (-2), tofp (-2), tofp (2), tofp (2));
|
||||||
|
|
||||||
t = clock () - t;
|
t = clock () - t;
|
||||||
|
|
||||||
/* Fetch the character from the keyboard buffer and discard it */
|
/* 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 ();
|
tgi_done ();
|
||||||
|
|
||||||
/* Calculate stats */
|
/* Calculate stats */
|
||||||
|
@ -136,9 +141,11 @@ int main (void)
|
||||||
/* Output stats */
|
/* Output stats */
|
||||||
cprintf ("time : %lu.%us\n\r", sec, sec10);
|
cprintf ("time : %lu.%us\n\r", sec, sec10);
|
||||||
|
|
||||||
/* Wait for a key, then end */
|
if (doesclrscrafterexit ()) {
|
||||||
cputs ("Press any key when done...\n\r");
|
/* Wait for a key, then end */
|
||||||
(void) cgetc ();
|
cputs ("Press any key when done...\n\r");
|
||||||
|
cgetc ();
|
||||||
|
}
|
||||||
|
|
||||||
/* Done */
|
/* Done */
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <conio.h>
|
#include <conio.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <dbg.h>
|
#include <dbg.h>
|
||||||
|
#include <cc65.h>
|
||||||
|
|
||||||
#define max(a,b) (((a) > (b)) ? (a) : (b))
|
#define max(a,b) (((a) > (b)) ? (a) : (b))
|
||||||
#define min(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
|
/* Wait for a key-press, so that some platforms can show the error
|
||||||
** message before they remove the current screen.
|
** message before they remove the current screen.
|
||||||
*/
|
*/
|
||||||
cgetc();
|
if (doesclrscrafterexit ()) {
|
||||||
|
cgetc ();
|
||||||
|
}
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,11 +11,11 @@
|
||||||
|
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <conio.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <em.h>
|
#include <em.h>
|
||||||
|
#include <cc65.h>
|
||||||
#ifndef __CBM__
|
#ifndef __CBM__
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -229,7 +229,7 @@ void main (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
log ("Press any key...");
|
log ("Press any key...");
|
||||||
cgetc ();
|
getchar ();
|
||||||
|
|
||||||
if (loadoverlay (1)) {
|
if (loadoverlay (1)) {
|
||||||
log ("Calling overlay 1 from main");
|
log ("Calling overlay 1 from main");
|
||||||
|
@ -254,6 +254,8 @@ void main (void)
|
||||||
foobar ();
|
foobar ();
|
||||||
}
|
}
|
||||||
|
|
||||||
log ("Press any key...");
|
if (doesclrscrafterexit ()) {
|
||||||
cgetc ();
|
log ("Press any key...");
|
||||||
|
getchar ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <conio.h>
|
#include <cc65.h>
|
||||||
#ifndef __CBM__
|
#ifndef __CBM__
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -130,5 +130,7 @@ void main (void)
|
||||||
foobar ();
|
foobar ();
|
||||||
}
|
}
|
||||||
|
|
||||||
cgetc ();
|
if (doesclrscrafterexit ()) {
|
||||||
|
getchar ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,9 @@ static void CheckError (const char* S)
|
||||||
unsigned char Error = tgi_geterror ();
|
unsigned char Error = tgi_geterror ();
|
||||||
if (Error != TGI_ERR_OK) {
|
if (Error != TGI_ERR_OK) {
|
||||||
printf ("%s: %d\n", S, Error);
|
printf ("%s: %d\n", S, Error);
|
||||||
|
if (doesclrscrafterexit ()) {
|
||||||
|
cgetc ();
|
||||||
|
}
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue