From 346d88a6a77fd0fa7bd5972991e101640d97f040 Mon Sep 17 00:00:00 2001 From: Christian Groessler Date: Tue, 7 Jun 2016 12:05:28 +0200 Subject: [PATCH] Add issues from pull request #307. --- doc/funcref.sgml | 12 ++++++------ include/apple2.h | 3 --- include/atari.h | 1 - include/cc65.h | 5 +++++ libsrc/atari/targetutil/w2cas.c | 12 ++++-------- libsrc/common/doesclrscr.s | 14 ++++++++++++++ testcode/lib/atari/defdev.c | 1 + testcode/lib/atari/mem.c | 1 + 8 files changed, 31 insertions(+), 18 deletions(-) create mode 100644 libsrc/common/doesclrscr.s diff --git a/doc/funcref.sgml b/doc/funcref.sgml index 5b529b822..ff32a2960 100644 --- a/doc/funcref.sgml +++ b/doc/funcref.sgml @@ -2552,8 +2552,8 @@ used in presence of a prototype. / - The function is only available as fastcall function, so it may only @@ -2574,8 +2574,8 @@ ldiv , / Some systems, maybe depending on configuration, immediately clear the screen after a program exits. Therefore it might be difficult to read @@ -2583,12 +2583,12 @@ the last messages printed by the program prior to its exit. This function can be to decide if a delay or wait for a key press should be executed when then program exits. - /* Hello World */ #include #include -#include +#include int main(void) { printf("Hello World\n"); diff --git a/include/apple2.h b/include/apple2.h index 97a2f124f..a1b094d4d 100644 --- a/include/apple2.h +++ b/include/apple2.h @@ -177,9 +177,6 @@ unsigned char get_ostype (void); void rebootafterexit (void); /* Reboot machine after program termination has completed. */ -unsigned char doesclrscrafterexit (void); -/* Will the screen automatically be cleared after program termination. */ - #define ser_apple2_slot(num) ser_ioctl (0, (void*) (num)) /* Select a slot number from 1 to 7 prior to ser_open. ** The default slot number is 2. diff --git a/include/atari.h b/include/atari.h index 76684c624..eedd814e0 100644 --- a/include/atari.h +++ b/include/atari.h @@ -167,7 +167,6 @@ extern void _save_vecs(void); /* save system vectors */ extern void _rest_vecs(void); /* restore system vectors */ extern char *_getdefdev(void); /* get default floppy device */ extern unsigned char _is_cmdline_dos(void); /* does DOS support command lines */ -extern unsigned char doesclrscrafterexit (void); /* will DOS clear the screen after program termination */ /* global variables */ extern unsigned char _dos_type; /* the DOS flavour */ diff --git a/include/cc65.h b/include/cc65.h index 4f9f3067f..9b7b69a0e 100644 --- a/include/cc65.h +++ b/include/cc65.h @@ -85,6 +85,11 @@ int __fastcall__ cc65_cos (unsigned x); ** is in 8.8 fixed point format, which means that 1.0 = $100 and -1.0 = $FF00. */ +unsigned char doesclrscrafterexit (void); +/* Indicates whether the screen automatically be cleared after program +** termination. +*/ + /* End of cc65.h */ diff --git a/libsrc/atari/targetutil/w2cas.c b/libsrc/atari/targetutil/w2cas.c index c1dd0cfcc..1381a49a0 100644 --- a/libsrc/atari/targetutil/w2cas.c +++ b/libsrc/atari/targetutil/w2cas.c @@ -14,6 +14,7 @@ #include #include <6502.h> #include +#include #include static int verbose = 1; @@ -32,13 +33,6 @@ static struct __iocb *findfreeiocb(void) return NULL; } -static void exitfn(void) -{ - /* if DOS will automatically clear the screen, after the program exits, wait for a keypress... */ - if (doesclrscrafterexit()) - cgetc(); -} - int main(int argc, char **argv) { char *filename, *x; @@ -50,7 +44,9 @@ int main(int argc, char **argv) struct __iocb *iocb = findfreeiocb(); int iocb_num; - atexit(exitfn); + /* if DOS will automatically clear the screen after the program exits, wait for a keypress... */ + if (doesclrscrafterexit()) + atexit((void (*)(void))cgetc); if (! iocb) { fprintf(stderr, "couldn't find a free iocb\n"); diff --git a/libsrc/common/doesclrscr.s b/libsrc/common/doesclrscr.s new file mode 100644 index 000000000..71f7ab70e --- /dev/null +++ b/libsrc/common/doesclrscr.s @@ -0,0 +1,14 @@ +; +; Christian Groessler, June-2016 +; +; unsigned char doesclrscr(void); +; +; returns 0/1 if after program termination the screen isn't/is cleared +; + + .export _doesclrscrafterexit + +_doesclrscrafterexit: + ldx #$00 + txa + rts diff --git a/testcode/lib/atari/defdev.c b/testcode/lib/atari/defdev.c index 851d87106..9b14e97fc 100644 --- a/testcode/lib/atari/defdev.c +++ b/testcode/lib/atari/defdev.c @@ -7,6 +7,7 @@ #include #include #include +#include extern char _defdev[]; diff --git a/testcode/lib/atari/mem.c b/testcode/lib/atari/mem.c index 04978c77e..bc70aded6 100644 --- a/testcode/lib/atari/mem.c +++ b/testcode/lib/atari/mem.c @@ -8,6 +8,7 @@ #include #include #include +#include extern int getsp(void); /* comes from ../getsp.s */ -- 2.39.2