mirror of
https://github.com/cc65/cc65.git
synced 2025-01-26 17:36:57 +00:00
Merge pull request #307 from groessler/something_to_pull2
Add Atari version of of doesclrscrafterexit().
This commit is contained in:
commit
2f486b6201
@ -949,27 +949,7 @@ id="malloc" name="malloc"> may still return <tt/NULL/.
|
||||
<tag/Declaration/<tt/unsigned char _is_cmdline_dos (void);/
|
||||
<tag/Description/The function returns 0 if the DOS doesn't support command line arguments.
|
||||
It returns 1 if it does.
|
||||
<tag/Notes/<itemize>
|
||||
<item>Many Atari DOSes which don't support command line arguments immediately clear the screen
|
||||
and display their menu after a program exits. Therefore it might be difficult to read
|
||||
the last messages printed by the program prior to its exit. This function can be used
|
||||
to decide if a delay or wait for a key press should be executed when then program
|
||||
exits.
|
||||
</itemize>
|
||||
<tag/Availability/cc65 (<tt/atari/ and <tt/atarixl/ platforms)
|
||||
<tag/Example/<verb>
|
||||
/* Hello World for Atari */
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <atari.h>
|
||||
int main(void)
|
||||
{
|
||||
printf("Hello World\n");
|
||||
if (! _is_cmdline_dos())
|
||||
sleep(5);
|
||||
return 0;
|
||||
}
|
||||
</verb>
|
||||
</descrip>
|
||||
</quote>
|
||||
|
||||
@ -2587,6 +2567,40 @@ ldiv
|
||||
</quote>
|
||||
|
||||
|
||||
<sect1>doesclrscrafterexit<label id="doesclrscrafterexit"><p>
|
||||
|
||||
<quote>
|
||||
<descrip>
|
||||
<tag/Function/Determines whether the screen is going to be cleared after program exit.
|
||||
<tag/Header/<tt/<ref id="cc65.h" name="cc65.h">/
|
||||
<tag/Declaration/<tt/unsigned char doesclrscrafterexit (void);/
|
||||
<tag/Description/The function returns zero if the screen won't be cleared immediately after
|
||||
program termination. It returns a non-zero value if it will.
|
||||
<tag/Notes/<itemize>
|
||||
<item>Some systems, maybe depending on configuration, immediately clear the screen
|
||||
after a program exits. Therefore it might be difficult to read
|
||||
the last messages printed by the program prior to its exit. This function can be used
|
||||
to decide if a delay or wait for a key press should be executed when then program
|
||||
exits.
|
||||
</itemize>
|
||||
<tag/Availability/cc65
|
||||
<tag/Example/<verb>
|
||||
/* Hello World */
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <cc65.h>
|
||||
int main(void)
|
||||
{
|
||||
printf("Hello World\n");
|
||||
if (doesclrscrafterexit())
|
||||
sleep(5);
|
||||
return 0;
|
||||
}
|
||||
</verb>
|
||||
</descrip>
|
||||
</quote>
|
||||
|
||||
|
||||
<sect1>em_commit<label id="em_commit"><p>
|
||||
|
||||
<quote>
|
||||
|
@ -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 */
|
||||
|
19
libsrc/atari/doesclrscr.s
Normal file
19
libsrc/atari/doesclrscr.s
Normal file
@ -0,0 +1,19 @@
|
||||
;
|
||||
; Christian Groessler, June-2016
|
||||
;
|
||||
; unsigned char doesclrscr(void);
|
||||
;
|
||||
; returns 0/1 if after program termination the screen isn't/is cleared
|
||||
;
|
||||
|
||||
.export _doesclrscrafterexit
|
||||
.import __dos_type
|
||||
.include "atari.inc"
|
||||
|
||||
_doesclrscrafterexit:
|
||||
ldx #0
|
||||
lda __dos_type
|
||||
cmp #MAX_DOS_WITH_CMDLINE + 1
|
||||
txa
|
||||
rol a
|
||||
rts
|
@ -7,14 +7,9 @@
|
||||
;
|
||||
|
||||
.export __is_cmdline_dos
|
||||
.import __dos_type
|
||||
.include "atari.inc"
|
||||
.import _doesclrscrafterexit
|
||||
|
||||
__is_cmdline_dos:
|
||||
ldx #0
|
||||
lda __dos_type
|
||||
cmp #MAX_DOS_WITH_CMDLINE + 1
|
||||
txa
|
||||
rol a
|
||||
eor #$01
|
||||
jsr _doesclrscrafterexit ; currently (unless a DOS behaving differently is popping up)
|
||||
eor #$01 ; we can get by with the inverse of _doesclrscrafterexit
|
||||
rts
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <errno.h>
|
||||
#include <6502.h>
|
||||
#include <atari.h>
|
||||
#include <cc65.h>
|
||||
#include <conio.h>
|
||||
|
||||
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 (! _is_cmdline_dos())
|
||||
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");
|
||||
|
12
libsrc/common/doesclrscr.s
Normal file
12
libsrc/common/doesclrscr.s
Normal file
@ -0,0 +1,12 @@
|
||||
;
|
||||
; Christian Groessler, June-2016
|
||||
;
|
||||
; unsigned char doesclrscr(void);
|
||||
;
|
||||
; returns 0/1 if after program termination the screen isn't/is cleared
|
||||
;
|
||||
|
||||
.export _doesclrscrafterexit
|
||||
.import return0
|
||||
|
||||
_doesclrscrafterexit = return0
|
@ -7,12 +7,13 @@
|
||||
#include <stdio.h>
|
||||
#include <conio.h>
|
||||
#include <atari.h>
|
||||
#include <cc65.h>
|
||||
|
||||
extern char _defdev[];
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf("default device: %s\n", _defdev);
|
||||
if (! _is_cmdline_dos()) cgetc();
|
||||
if (doesclrscrafterexit()) cgetc();
|
||||
return 0;
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <conio.h>
|
||||
#include <atari.h>
|
||||
#include <cc65.h>
|
||||
|
||||
extern int getsp(void); /* comes from ../getsp.s */
|
||||
|
||||
@ -41,6 +42,6 @@ int main(void)
|
||||
printf(" sp: $%04X (stack ptr)\n", getsp());
|
||||
|
||||
if (allocmem) free(allocmem);
|
||||
if (! _is_cmdline_dos()) cgetc();
|
||||
if (doesclrscrafterexit()) cgetc();
|
||||
return(0);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user