| 1 |
/* |
| 2 |
$Header: d:/cvsroot/tads/TADS2/atari/OSATARI.H,v 1.2 1999/05/17 02:52:16 MJRoberts Exp $ |
| 3 |
*/ |
| 4 |
|
| 5 |
/* |
| 6 |
* Copyright (c) 1991, 2002 Michael J. Roberts. All Rights Reserved. |
| 7 |
* |
| 8 |
* Please see the accompanying license file, LICENSE.TXT, for information |
| 9 |
* on using and copying this software. |
| 10 |
*/ |
| 11 |
/* |
| 12 |
Name |
| 13 |
os(atari).h - operating system definitions for Atari ST running GCC 2.3.1 P1 |
| 14 |
Function |
| 15 |
Definitions that vary by operating system |
| 16 |
Notes |
| 17 |
None |
| 18 |
Modified |
| 19 |
20/01/93 David Baggett - rewrote for v2.0 |
| 20 |
08/13/91 MJRoberts - creation |
| 21 |
*/ |
| 22 |
|
| 23 |
#ifndef OS_INCLUDED |
| 24 |
#define OS_INCLUDED |
| 25 |
|
| 26 |
/* |
| 27 |
* Declare memicmp -- not a std library function |
| 28 |
*/ |
| 29 |
int memicmp(char *, char *, int); |
| 30 |
|
| 31 |
/* far pointer type qualifier (null on most platforms) */ |
| 32 |
# define osfar_t |
| 33 |
|
| 34 |
/* maximum theoretical size of malloc argument */ |
| 35 |
# define OSMALMAX ((size_t)0xffffffff) |
| 36 |
|
| 37 |
# include <stdlib.h> |
| 38 |
# include <stdio.h> |
| 39 |
# include <stddef.h> |
| 40 |
|
| 41 |
/* void a return value */ |
| 42 |
#define DISCARD (void) |
| 43 |
|
| 44 |
/* |
| 45 |
* If long cache-manager macros are NOT allowed, define |
| 46 |
* OS_MCM_NO_MACRO. This forces certain cache manager operations to be |
| 47 |
* functions, which results in substantial memory savings. |
| 48 |
*/ |
| 49 |
#define OS_MCM_NO_MACRO |
| 50 |
|
| 51 |
/* likewise for the error handling subsystem */ |
| 52 |
#define OS_ERR_NO_MACRO |
| 53 |
|
| 54 |
/* |
| 55 |
* If error messages are to be included in the executable, define |
| 56 |
* OS_ERR_LINK_MESSAGES. Otherwise, they'll be read from an external |
| 57 |
* file that is to be opened with oserrop(). |
| 58 |
*/ |
| 59 |
#define ERR_LINK_MESSAGES |
| 60 |
|
| 61 |
/* round a size to worst-case alignment boundary */ /* DMB */ |
| 62 |
#define osrndsz(s) (ushort) (((s)+1) & ~1L) |
| 63 |
|
| 64 |
/* round a pointer to worst-case alignment boundary */ /* DMB */ |
| 65 |
#define osrndpt(p) ((uchar *)((((ulong)(p)) + 1) & ~1L)) |
| 66 |
|
| 67 |
/* void pointer type */ |
| 68 |
typedef void dvoid; |
| 69 |
|
| 70 |
/* service macros for osrp2 etc. */ |
| 71 |
#define osc2u(p, i) ((uint)(((uchar *)(p))[i])) |
| 72 |
#define osc2l(p, i) ((ulong)(((uchar *)(p))[i])) |
| 73 |
|
| 74 |
/* read unaligned portable 2-byte value, returning int */ |
| 75 |
#define osrp2(p) (osc2u(p, 0) + (osc2u(p, 1) << 8)) |
| 76 |
|
| 77 |
/* write int to unaligned portable 2-byte value */ |
| 78 |
#define oswp2(p, i) ((((uchar *)(p))[1] = (uchar) ((i)>>8)), \ |
| 79 |
(((uchar *)(p))[0] = (uchar) ((i)&255))) |
| 80 |
|
| 81 |
/* read unaligned portable 4-byte value, returning long */ |
| 82 |
#define osrp4(p) \ |
| 83 |
(osc2l(p, 0) + (osc2l(p, 1) << 8) + (osc2l(p, 2) << 16) + (osc2l(p, 3) << 24)) |
| 84 |
|
| 85 |
/* write long to unaligned portable 4-byte value */ |
| 86 |
#define oswp4(p, i) \ |
| 87 |
((((uchar *)(p))[0] = (i)), (((uchar *)(p))[1] = (i)>>8),\ |
| 88 |
(((uchar *)(p))[2] = (i)>>16, (((uchar *)(p))[3] = (i)>>24))) |
| 89 |
|
| 90 |
/* |
| 91 |
* Be sure to get correct parameter and return type for memory functions. |
| 92 |
*/ |
| 93 |
#include <alloc.h> |
| 94 |
|
| 95 |
/* allocate storage - malloc where supported */ |
| 96 |
/* dvoid *osmalloc(size_t siz); */ |
| 97 |
#define osmalloc(siz) malloc(siz) |
| 98 |
|
| 99 |
/* free storage allocated with osmalloc */ |
| 100 |
/* void osfree(dvoid *block); */ |
| 101 |
#define osfree(block) free(block) |
| 102 |
|
| 103 |
/* copy a structure - dst and src are structures, not pointers */ |
| 104 |
#define OSCPYSTRUCT(dst, src) ((dst) = (src)) |
| 105 |
|
| 106 |
/* ANSI compiler */ |
| 107 |
#define OSANSI |
| 108 |
|
| 109 |
/* maximum length of a filename */ |
| 110 |
#define OSFNMAX 255 |
| 111 |
|
| 112 |
/* normal path separator character */ |
| 113 |
#define OSPATHCHAR '\\' |
| 114 |
|
| 115 |
/* alternate path separator characters */ |
| 116 |
#define OSPATHALT "/:" |
| 117 |
|
| 118 |
/* URL path separator */ |
| 119 |
#define OSPATHURL "\\/" |
| 120 |
|
| 121 |
/* os file structure */ |
| 122 |
typedef FILE osfildef; |
| 123 |
|
| 124 |
/* main program exit codes */ |
| 125 |
#define OSEXSUCC 0 /* successful completion */ |
| 126 |
#define OSEXFAIL 1 /* error occurred */ |
| 127 |
|
| 128 |
/* open text file for reading; returns NULL on error */ |
| 129 |
/* osfildef *osfoprt(char *fname); */ |
| 130 |
#define osfoprt(fname) fopen(fname, "r") |
| 131 |
|
| 132 |
/* open binary file for writing; returns NULL on error */ |
| 133 |
/* osfildef *osfopwb(char *fname); */ |
| 134 |
#define osfopwb(fname) fopen(fname, "wb") |
| 135 |
|
| 136 |
/* open SOURCE file for reading - use appropriate text/binary mode */ |
| 137 |
#define osfoprs(fname) fopen(fname, "rb") |
| 138 |
|
| 139 |
/* open binary file for reading; returns NULL on erorr */ |
| 140 |
/* osfildef *osfoprb(char *fname); */ |
| 141 |
#define osfoprb(fname) fopen(fname, "rb") |
| 142 |
|
| 143 |
/* get a line of text from a text file (fgets semantics) */ |
| 144 |
/* char *osfgets(char *buf, size_t len, osfildef *fp); */ |
| 145 |
#define osfgets(buf, len, fp) fgets(buf, len, fp) |
| 146 |
|
| 147 |
/* open binary file for reading/writing; truncate; returns NULL on error */ |
| 148 |
/* osfildef *osfoprwtb(char *fname); */ |
| 149 |
#define osfoprwtb(fname) fopen(fname, "w+b") |
| 150 |
|
| 151 |
/* write bytes to file; TRUE ==> error */ |
| 152 |
/* int osfwb(osfildef *fp, uchar *buf, int bufl); */ |
| 153 |
#define osfwb(fp, buf, bufl) (fwrite(buf, bufl, 1, fp) != 1) |
| 154 |
|
| 155 |
/* read bytes from file; TRUE ==> error */ |
| 156 |
/* int osfrb(osfildef *fp, uchar *buf, int bufl); */ |
| 157 |
#define osfrb(fp, buf, bufl) (fread(buf, bufl, 1, fp) != 1) |
| 158 |
|
| 159 |
/* get position in file */ |
| 160 |
/* long osfpos(osfildef *fp); */ |
| 161 |
#define osfpos(fp) ftell(fp) |
| 162 |
|
| 163 |
/* seek position in file; TRUE ==> error */ |
| 164 |
/* int osfseek(osfildef *fp, long pos, int mode); */ |
| 165 |
#define osfseek(fp, pos, mode) fseek(fp, pos, mode) |
| 166 |
#define OSFSK_SET SEEK_SET |
| 167 |
#define OSFSK_CUR SEEK_CUR |
| 168 |
#define OSFSK_END SEEK_END |
| 169 |
|
| 170 |
/* close a file */ |
| 171 |
/* void osfcls(osfildef *fp); */ |
| 172 |
#define osfcls(fp) fclose(fp) |
| 173 |
|
| 174 |
/* delete a file - TRUE if error */ |
| 175 |
/* int osfdel(char *fname); */ |
| 176 |
#define osfdel(fname) remove(fname) |
| 177 |
|
| 178 |
|
| 179 |
/* open error file, returning file handle, or null if not found */ |
| 180 |
osfildef *oserrop(/*_ void _*/); |
| 181 |
|
| 182 |
|
| 183 |
/* yield CPU; returns TRUE if user requested interrupt, FALSE to continue */ |
| 184 |
#define os_yield() FALSE |
| 185 |
|
| 186 |
/* |
| 187 |
* Options for this operating system |
| 188 |
*/ |
| 189 |
# define USE_MORE /* assume more-mode is desired (undef if not true) */ |
| 190 |
# define USEDOSCOMMON |
| 191 |
|
| 192 |
/* #define USE_STDIO */ |
| 193 |
#define USE_DOSEXT |
| 194 |
/* #define USE_NULLINIT */ |
| 195 |
/* #define USE_NULLPAUSE */ |
| 196 |
#define USE_EXPAUSE |
| 197 |
#define USE_TIMERAND |
| 198 |
/* #define STD_ASKFILE */ |
| 199 |
/* #define USE_NULLSTAT do-nothing os_status */ |
| 200 |
/* #define USE_NULLSCORE - use a do-nothing os_score function */ |
| 201 |
#define USE_OVWCHK |
| 202 |
#define USE_NULLSTYPE |
| 203 |
|
| 204 |
#ifndef USE_STDIO |
| 205 |
|
| 206 |
/* |
| 207 |
* Output options for VT52 output. |
| 208 |
*/ |
| 209 |
#define RUNTIME |
| 210 |
/* #define USE_FSDBUG */ |
| 211 |
#define USE_STATLINE |
| 212 |
#define USE_HISTORY |
| 213 |
/* #define USE_SCROLLBACK */ |
| 214 |
|
| 215 |
#define OS_SBSTAT \ |
| 216 |
"(Review Mode) Arrows=Up/Down F9=Page Up F10=Page Down F1=Exit" |
| 217 |
|
| 218 |
#define HISTBUFSIZE 4096 |
| 219 |
|
| 220 |
#ifndef STAT_TYPE |
| 221 |
#define STAT_TYPE 0 |
| 222 |
#endif |
| 223 |
|
| 224 |
|
| 225 |
/* |
| 226 |
* Some global variables needed for console implementation |
| 227 |
*/ |
| 228 |
# ifdef OSGEN_INIT |
| 229 |
# define E |
| 230 |
# define I(a) =(a) |
| 231 |
# else /* OSGEN_INIT */ |
| 232 |
# define E extern |
| 233 |
# define I(a) |
| 234 |
# endif /* OSGEN_INIT */ |
| 235 |
|
| 236 |
E int status_mode; |
| 237 |
E int score_column I(70); |
| 238 |
E int sdesc_line I(0), sdesc_column I(0), sdesc_color I(23); |
| 239 |
E int ldesc_line I(1), ldesc_column I(0), ldesc_color I(112); |
| 240 |
E int debug_color I(0xe); |
| 241 |
|
| 242 |
E int text_line I(1); |
| 243 |
E int text_column I(0); |
| 244 |
E int text_color I(7), text_bold_color I(15), text_normal_color I(7); |
| 245 |
E int max_line I(24), max_column I(79); |
| 246 |
E int ldesc_curline; |
| 247 |
E int text_lastcol; |
| 248 |
|
| 249 |
# undef E |
| 250 |
# undef I |
| 251 |
|
| 252 |
#endif /* USE_STDIO */ |
| 253 |
|
| 254 |
#endif /* OS_INCLUDED */ |