1
0
mirror of https://github.com/cc65/cc65.git synced 2025-01-10 19:29:45 +00:00

Add Atari version of of doesclrscrafterexit().

- Update documentation.
- Update atari.h and apple2.h header files.
- Adapt Atari test/target programs.
- Fix a typo in "div" entry in funcref.sgml.
This commit is contained in:
Christian Groessler 2016-06-07 00:42:51 +02:00
parent 13482984ca
commit c7874b9f60
8 changed files with 71 additions and 39 deletions

View File

@ -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>
@ -2572,8 +2552,8 @@ used in presence of a prototype.
<descrip>
<tag/Function/Divide two ints and return quotient and remainder.
<tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
<tag/Declaration/<tt/div_t __fastcall__ div (int numer, int denom);/
<tag/Description/<tt/div/ divides <tt/numer/ by <tt/denom/ and returns the
<tag/Declaration/<tt/div_t __fastcall__ div (int number, int denom);/
<tag/Description/<tt/div/ divides <tt/number/ by <tt/denom/ and returns the
quotient and remainder in a <tt/div_t/ structure.
<tag/Notes/<itemize>
<item>The function is only available as fastcall function, so it may only
@ -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="atari.h" name="atari.h">, <ref id="apple2.h" name="apple2.h">/
<tag/Declaration/<tt/unsigned char doesclrscrafterexit (void);/
<tag/Description/The function returns 0 if the screen won't be cleared immediately after
program termination. It returns 1 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 (<tt/atari/, <tt/atarixl/, <tt/apple2/, and <tt/apple2enh/ platforms)
<tag/Example/<verb>
/* Hello World */
#include <stdio.h>
#include <unistd.h>
#include <atari.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>

View File

@ -177,6 +177,9 @@ 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.

View File

@ -161,12 +161,13 @@ extern void __fastcall__ _scroll (signed char numlines);
/* numlines < 0 scrolls down */
/* misc. functions */
extern unsigned char get_ostype(void); /* get ROM version */
extern unsigned char get_tv(void); /* get TV system */
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 get_ostype(void); /* get ROM version */
extern unsigned char get_tv(void); /* get TV system */
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 */

19
libsrc/atari/doesclrscr.s Normal file
View 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

View File

@ -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

View File

@ -35,7 +35,7 @@ static struct __iocb *findfreeiocb(void)
static void exitfn(void)
{
/* if DOS will automatically clear the screen, after the program exits, wait for a keypress... */
if (! _is_cmdline_dos())
if (doesclrscrafterexit())
cgetc();
}

View File

@ -13,6 +13,6 @@ extern char _defdev[];
int main(void)
{
printf("default device: %s\n", _defdev);
if (! _is_cmdline_dos()) cgetc();
if (doesclrscrafterexit()) cgetc();
return 0;
}

View File

@ -41,6 +41,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);
}