From: Kevin M. Rosenberg Date: Mon, 19 Jun 2000 18:49:00 +0000 (+0000) Subject: r108: merged files X-Git-Tag: debian-4.5.3-3~909 X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=commitdiff_plain;h=0fe37e9c318904715493dc9c894f658c43e6178e r108: merged files --- diff --git a/include/cio.h b/include/cio.h deleted file mode 100644 index 4e83202..0000000 --- a/include/cio.h +++ /dev/null @@ -1,65 +0,0 @@ -/***************************************************************************** -** This is part of the CTSim program -** Copyright (C) 1983-2000 Kevin Rosenberg -** -** $Id: cio.h,v 1.9 2000/06/13 16:20:31 kevin Exp $ -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License (version 2) as -** published by the Free Software Foundation. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -******************************************************************************/ -#ifndef __CIO_H -#define __CIO_H - - -#define C_BLACK 0 /* color codes */ -#define C_BLUE 1 -#define C_GREEN 2 -#define C_CYAN 3 -#define C_RED 4 -#define C_MAGENTA 5 -#define C_BROWN 6 -#define C_WHITE 7 -#define C_GREY 8 -#define C_LTBLUE 9 -#define C_LTGREEN 10 -#define C_LTCYAN 11 -#define C_LTRED 12 -#define C_LTMAGENTA 13 -#define C_YELLOW 14 -#define C_LTWHITE 15 - -/*----------------------------------------------------------------------*/ - -/* screen character codes */ - -#define SC_BKSP 8 -#define SC_TAB 9 -#define SC_BLANK ' ' - - -/* audio.cpp */ -void cio_beep(void); -void cio_tone(double freq, double length); - -/* crtput.cpp */ -void cio_put_c(int c); -void cio_put_cc(int c, int count); -void cio_put_str(const char *str); - -/* kbget.cpp */ -unsigned int cio_kb_getc(void); -void cio_kb_ungetc(unsigned int c); -char *cio_kb_gets(char *str, int maxlen); -unsigned int cio_kb_waitc(const char *astr, int beep); - -#endif diff --git a/include/ctsupport.h b/include/ctsupport.h new file mode 100644 index 0000000..708d161 --- /dev/null +++ b/include/ctsupport.h @@ -0,0 +1,322 @@ +/***************************************************************************** +** FILE IDENTIFICATION +** +** File Name: ctsupport.h +** Author: Kevin Rosenberg +** Purpose: Header file for CT support library +** Date Started: Dec. 83 +** +** This is part of the CTSim program +** Copyright (C) 1983-2000 Kevin Rosenberg +** +** $Id: ctsupport.h,v 1.1 2000/06/19 18:49:00 kevin Exp $ +** +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License (version 2) as +** published by the Free Software Foundation. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +******************************************************************************/ + +#ifndef CTSUPPORT_H +#define CTSUPPORT_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifdef _WIN32 +#define snprintf _snprintf +#endif + +#define STR_MAX_LEN 255 +#define STR_SIZE STR_MAX_LEN+1 + +#include +#include +#include +#include + +#define TRUE 1 +#define FALSE 0 +#define OK TRUE +#define ERROR FALSE +#define YES TRUE +#define NO FALSE + +/*----------------------------------------------------------------------*/ + +#define SHOW(var, fmt) { cerr << "var = " << var << endl; } + +/*----------------------------------------------------------------------*/ + +#define NEWLINE '\n' +#define TAB '\t' +#define EOS '\0' +#define BLANK ' ' + +/*----------------------------------------------------------------------*/ + +struct time_st { + int hour, minute, second, ms; +}; + +struct date_st { + int year, month, date, dow; +}; + +struct timedate_st { + struct time_st t; + struct date_st d; +}; + +typedef struct time_st TIME; +typedef struct date_st DATE; +typedef struct timedate_st TIMEDATE; + +/*----------------------------------------------------------------------*/ + +#define ERR_WARNING 0 +#define ERR_SEVERE 1 +#define ERR_FATAL 2 + +/*----------------------------------------------------------------------*/ + + +/* codes for open command */ +#if MICROSOFT +#define OPEN_RDONLY O_RDONLY /* other system use standard codes */ +#define OPEN_WRONLY O_WRONLY /* for binary */ +#define OPEN_RDWR O_RDWR +#else +#define OPEN_RDONLY 0 /* other system use standard codes */ +#define OPEN_WRONLY 1 /* for binary */ +#define OPEN_RDWR 2 +#endif + +/*----------------------------------------------------------------------*/ + +#ifndef O_BINARY +#define O_BINARY (0) +#endif + +#ifndef S_IWRITE +#define S_IWRITE S_IWUSR +#endif + +/*----------------------------------------------------------------------*/ + +#if defined(MICROSOFT) || ! defined(SIZEOF_INT) + #define SIZEOF_INT 4 + #define SIZEOF_LONG 4 + #define SIZEOF_SHORT 2 + #define SIZEOF_FLOAT 4 + #define SIZEOF_DOUBLE 8 +#endif + +typedef signed char kint8; +typedef unsigned char kuint8; + +#if SIZEOF_INT == 4 + typedef int kint32; + typedef unsigned int kuint32; +#elif SIZEOF_LONG == 4 + typedef long int kint32; + typedef unsigned int kuint32; +#endif + +#if SIZEOF_SHORT == 2 + typedef short int kint16; + typedef unsigned short int kuint16; +#elif SIZEOF_INT == 2 + typedef int kint16; + typedef unsigned int kuint16; +#endif + +#if SIZEOF_FLOAT == 4 + typedef float kfloat32; +#endif +#if SIZEOF_DOUBLE == 8 + typedef double kfloat64; +#endif + + +/* filefuncs.cpp */ +bool file_exists(const char* fname); +const char* fileBasename(const char* filename); +FILE *sys_fopen(const char *filename, const char *mode, const char *progname); + +/* strfuncs.cpp */ +char* str_skip_head(const char* str, const char* const charlist); +char* str_skip_head(const char* str, char* charlist); +char *str_lower(char *s); +char *str_wrm_tail(char *str); +char *str_rm_tail(char *str, const char* const charlist); +char *str_upper(char *str); + +/* syserror.cpp */ +void sys_error(int severity, const char *msg, ...); +void sys_verror(int severity, const char *msg, va_list arg); +void sys_error_level(int severity); + +/* timedate.cpp */ +DATE *td_get_date(DATE *d); +TIME *td_get_time(TIME *t); +double td_current_sec(void); +double td_time_to_sec(TIME *t); +TIME *td_time_sub(const TIME *t1, const TIME *t2, TIME *tdiff); +TIME *td_time_add(const TIME *t1, const TIME *t2, TIME *tsum); +TIME *td_time_copy(TIME *to, const TIME *from); +TIME *td_time_norm(TIME *t); +void td_get_tmdt(TIMEDATE *td); +const char *td_str_tmdt(const TIMEDATE *td); +const char *td_str_time(const TIME *t); +const char *td_str_stime(const TIME *t); +const char *td_str_date(const DATE *d); +char *td_str_cdate(DATE *d); +char *td_month_name(int n); +char *td_day_name(int n); + + +// Math Section + +#include + +#define PI 3.14159265358979323846 +#define HALFPI 1.57079632679489661923 /* PI divided by 2 */ +#define QUARTPI 0.78539816339744830962 /* PI divided by 4 */ +#define I_PI 0.31830988618379067154 /* Inverse of PI */ +#define I_PID2 0.63661977236758134308 /* Inverse of PID2 */ + +#define TWOPI 6.28318530717958647692 +#define SQRT2 1.414213562373095049 + +#define F_EPSILON 1.0E-6 +#define D_EPSILON 1.0E-10 + +#define ASSUMEDZERO 1E-10 + +typedef double GRFMTX_2D[3][3]; +typedef double GRFMTX_3D[4][4]; + +inline double +convertDegreesToRadians (double x) +{ return (x * (PI/180.)); } + +inline double +convertRadiansToDegrees (double x) +{ return (x*(180./PI)); } + +template +inline T nearest (double x) +{ return (x > 0 ? static_cast(x+0.5) : static_cast(x-0.5)); } + +template +inline T clamp (T value, T lowerBounds, T upperBounds) +{ return (value >= upperBounds ? upperBounds : (value <= lowerBounds ? lowerBounds : value )); } + +template +inline T lineLength (T x1, T y1, T x2, T y2) +{ return static_cast( sqrt ((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)) ); } + +template +inline void minmax_array (const T* array, const int n, T& min, T& max) +{ + max = min = array[0]; + + for (int i = 1; i < n; i++) + if (array[i] < min) + min = array[i]; + else if (array[i] > max) + max = array[i]; +} + + +////////////////////////////////////////////////////////////// +// FUNTION DECLARATIONS +////////////////////////////////////////////////////////////// + +// clip.cpp +int clip_rect(double& x1, double& y1, double& x2, double& y2, const double rect[4]); +int clip_segment(double& x1, double& y1, double& x2, double& y2, const double u, const double v); +int clip_sector(double& x1, double& y1, double& x2, double& y2, const double u, const double v); +int clip_circle(double& x1, double& y1, double& x2, double& y2, const double cx, const double cy, const double radius, double t1, double t2); +int clip_triangle(double& x1, double& y1, double& x2, double& y2, const double u, const double v, const int clip_xaxis); + +// norm_ang.cpp +double norm_ang (double theta); + +// xform.cpp +void indent_mtx2(GRFMTX_2D m); +void xlat_mtx2(GRFMTX_2D m, const double x, const double y); +void scale_mtx2(GRFMTX_2D m, const double sx, const double sy); +void rot_mtx2(GRFMTX_2D m, const double theta); +void mult_mtx2(GRFMTX_2D m1, GRFMTX_2D m2, GRFMTX_2D result); +void xform_mtx2(GRFMTX_2D m, double& x, double& y); +void rotate2d(double x[], double y[], int pts, double angle); +void xlat2d(double x[], double y[], int pts, double xoffset, double yoffset); +void scale2d(double x[], double y[], int pts, double xfact, double yfact); + +// simpson.cpp +double integrateSimpson (const double xmin, const double xmax, const double *y, const int np); + + +// Console I/O Section + +#define C_BLACK 0 /* color codes */ +#define C_BLUE 1 +#define C_GREEN 2 +#define C_CYAN 3 +#define C_RED 4 +#define C_MAGENTA 5 +#define C_BROWN 6 +#define C_WHITE 7 +#define C_GREY 8 +#define C_LTBLUE 9 +#define C_LTGREEN 10 +#define C_LTCYAN 11 +#define C_LTRED 12 +#define C_LTMAGENTA 13 +#define C_YELLOW 14 +#define C_LTWHITE 15 + +/*----------------------------------------------------------------------*/ + +/* screen character codes */ + +#define SC_BKSP 8 +#define SC_TAB 9 +#define SC_BLANK ' ' + + +/* audio.cpp */ +void cio_beep(void); +void cio_tone(double freq, double length); + +/* crtput.cpp */ +void cio_put_c(int c); +void cio_put_cc(int c, int count); +void cio_put_str(const char *str); + +/* kbget.cpp */ +unsigned int cio_kb_getc(void); +void cio_kb_ungetc(unsigned int c); +char *cio_kb_gets(char *str, int maxlen); +unsigned int cio_kb_waitc(const char *astr, int beep); + +// Keyboard Section + +#define KEY_BKSP 8 +#define KEY_TAB 9 +#define KEY_RETURN 13 +#define KEY_ESCAPE 27 + +#endif diff --git a/include/keyboard.h b/include/keyboard.h deleted file mode 100644 index 5025e57..0000000 --- a/include/keyboard.h +++ /dev/null @@ -1,50 +0,0 @@ -/***************************************************************************** -** This is part of the CTSim program -** Copyright (C) 1983-2000 Kevin Rosenberg -** -** $Id: keyboard.h,v 1.3 2000/04/30 19:17:35 kevin Exp $ -** $Log: keyboard.h,v $ -** Revision 1.3 2000/04/30 19:17:35 kevin -** Set up include files for conditional INTERACTIVE_GRAPHICS -** -** Revision 1.2 2000/04/28 14:14:16 kevin -** *** empty log message *** -** -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License (version 2) as -** published by the Free Software Foundation. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -******************************************************************************/ -/****************************************************************************** - * - * FILE IDENTIFICATION - * - * File Name: KEYBOARD.H - * Author: Kevin Rosenberg - * Purpose: Header file for IBM-PC keyboard definitions - * Date Started: Jan 85 - * - * DESCRIPTION - * - * MODIFICATION LOG - * - *****************************************************************************/ - -#ifndef KEYBOARD_H -#define KEYBOARD_H - -#define KEY_BKSP 8 -#define KEY_TAB 9 -#define KEY_RETURN 13 -#define KEY_ESCAPE 27 - -#endif diff --git a/include/kmath.h b/include/kmath.h deleted file mode 100644 index e4c577b..0000000 --- a/include/kmath.h +++ /dev/null @@ -1,112 +0,0 @@ -/***************************************************************************** -** FILE IDENTIFICATION -** -** Name: kmath.h -** Purpose: Header file containing definitions for numerical app -** Programmer: Kevin Rosenberg -** Date Started: Nov 84 -** -** This is part of the CTSim program -** Copyright (C) 1983-2000 Kevin Rosenberg -** -** $Id: kmath.h,v 1.16 2000/06/19 15:48:23 kevin Exp $ -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License (version 2) as -** published by the Free Software Foundation. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -******************************************************************************/ - -#ifndef _H_kmath -#define _H_kmath - -#include -#include - -#define PI 3.14159265358979323846 -#define HALFPI 1.57079632679489661923 /* PI divided by 2 */ -#define QUARTPI 0.78539816339744830962 /* PI divided by 4 */ -#define I_PI 0.31830988618379067154 /* Inverse of PI */ -#define I_PID2 0.63661977236758134308 /* Inverse of PID2 */ - -#define TWOPI 6.28318530717958647692 -#define SQRT2 1.414213562373095049 - -#define F_EPSILON 1.0E-6 -#define D_EPSILON 1.0E-10 - -#define ASSUMEDZERO 1E-10 - -typedef double GRFMTX_2D[3][3]; -typedef double GRFMTX_3D[4][4]; - -inline double -convertDegreesToRadians (double x) -{ return (x * (PI/180.)); } - -inline double -convertRadiansToDegrees (double x) -{ return (x*(180./PI)); } - -template -inline T nearest (double x) -{ return (x > 0 ? static_cast(x+0.5) : static_cast(x-0.5)); } - -template -inline T clamp (T value, T lowerBounds, T upperBounds) -{ return (value >= upperBounds ? upperBounds : (value <= lowerBounds ? lowerBounds : value )); } - -template -inline T lineLength (T x1, T y1, T x2, T y2) -{ return static_cast( sqrt ((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)) ); } - -template -inline void minmax_array (const T* array, const int n, T& min, T& max) -{ - max = min = array[0]; - - for (int i = 1; i < n; i++) - if (array[i] < min) - min = array[i]; - else if (array[i] > max) - max = array[i]; -} - - -////////////////////////////////////////////////////////////// -// FUNTION DECLARATIONS -////////////////////////////////////////////////////////////// - -// clip.cpp -int clip_rect(double& x1, double& y1, double& x2, double& y2, const double rect[4]); -int clip_segment(double& x1, double& y1, double& x2, double& y2, const double u, const double v); -int clip_sector(double& x1, double& y1, double& x2, double& y2, const double u, const double v); -int clip_circle(double& x1, double& y1, double& x2, double& y2, const double cx, const double cy, const double radius, double t1, double t2); -int clip_triangle(double& x1, double& y1, double& x2, double& y2, const double u, const double v, const int clip_xaxis); - -// norm_ang.cpp -double norm_ang (double theta); - -// xform.cpp -void indent_mtx2(GRFMTX_2D m); -void xlat_mtx2(GRFMTX_2D m, const double x, const double y); -void scale_mtx2(GRFMTX_2D m, const double sx, const double sy); -void rot_mtx2(GRFMTX_2D m, const double theta); -void mult_mtx2(GRFMTX_2D m1, GRFMTX_2D m2, GRFMTX_2D result); -void xform_mtx2(GRFMTX_2D m, double& x, double& y); -void rotate2d(double x[], double y[], int pts, double angle); -void xlat2d(double x[], double y[], int pts, double xoffset, double yoffset); -void scale2d(double x[], double y[], int pts, double xfact, double yfact); - -// simpson.cpp -double integrateSimpson (const double xmin, const double xmax, const double *y, const int np); - -#endif diff --git a/include/kstddef.h b/include/kstddef.h deleted file mode 100644 index 75cde29..0000000 --- a/include/kstddef.h +++ /dev/null @@ -1,188 +0,0 @@ -/***************************************************************************** -** FILE IDENTIFICATION -** -** File Name: kstddef.h -** Author: Kevin Rosenberg -** Purpose: Header file containing KRL standard C definitions -** Date Started: Dec. 83 -** -** This is part of the CTSim program -** Copyright (C) 1983-2000 Kevin Rosenberg -** -** $Id: kstddef.h,v 1.18 2000/06/19 18:18:13 kevin Exp $ -** -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License (version 2) as -** published by the Free Software Foundation. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -******************************************************************************/ - -#ifndef STDDEF_H -#define STDDEF_H - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#ifdef _WIN32 -#define snprintf _snprintf -#endif - -#define STR_MAX_LEN 255 -#define STR_SIZE STR_MAX_LEN+1 - -#include -#include -#include -#include - -#define TRUE 1 -#define FALSE 0 -#define OK TRUE -#define ERROR FALSE -#define YES TRUE -#define NO FALSE - -/*----------------------------------------------------------------------*/ - -#define SHOW(var, fmt) { cerr << "var = " << var << endl; } - -/*----------------------------------------------------------------------*/ - -#define NEWLINE '\n' -#define TAB '\t' -#define EOS '\0' -#define BLANK ' ' - -/*----------------------------------------------------------------------*/ - -struct time_st { - int hour, minute, second, ms; -}; - -struct date_st { - int year, month, date, dow; -}; - -struct timedate_st { - struct time_st t; - struct date_st d; -}; - -typedef struct time_st TIME; -typedef struct date_st DATE; -typedef struct timedate_st TIMEDATE; - -/*----------------------------------------------------------------------*/ - -#define ERR_WARNING 0 -#define ERR_SEVERE 1 -#define ERR_FATAL 2 - -/*----------------------------------------------------------------------*/ - - -/* codes for open command */ -#if MICROSOFT -#define OPEN_RDONLY O_RDONLY /* other system use standard codes */ -#define OPEN_WRONLY O_WRONLY /* for binary */ -#define OPEN_RDWR O_RDWR -#else -#define OPEN_RDONLY 0 /* other system use standard codes */ -#define OPEN_WRONLY 1 /* for binary */ -#define OPEN_RDWR 2 -#endif - -/*----------------------------------------------------------------------*/ - -#ifndef O_BINARY -#define O_BINARY (0) -#endif - -#ifndef S_IWRITE -#define S_IWRITE S_IWUSR -#endif - -/*----------------------------------------------------------------------*/ - -#if defined(MICROSOFT) || ! defined(SIZEOF_INT) - #define SIZEOF_INT 4 - #define SIZEOF_LONG 4 - #define SIZEOF_SHORT 2 - #define SIZEOF_FLOAT 4 - #define SIZEOF_DOUBLE 8 -#endif - -typedef signed char kint8; -typedef unsigned char kuint8; - -#if SIZEOF_INT == 4 - typedef int kint32; - typedef unsigned int kuint32; -#elif SIZEOF_LONG == 4 - typedef long int kint32; - typedef unsigned int kuint32; -#endif - -#if SIZEOF_SHORT == 2 - typedef short int kint16; - typedef unsigned short int kuint16; -#elif SIZEOF_INT == 2 - typedef int kint16; - typedef unsigned int kuint16; -#endif - -#if SIZEOF_FLOAT == 4 - typedef float kfloat32; -#endif -#if SIZEOF_DOUBLE == 8 - typedef double kfloat64; -#endif - - -/* filefuncs.cpp */ -bool file_exists(const char* fname); -const char* fileBasename(const char* filename); -FILE *sys_fopen(const char *filename, const char *mode, const char *progname); - -/* strfuncs.cpp */ -char* str_skip_head(const char* str, const char* const charlist); -char* str_skip_head(const char* str, char* charlist); -char *str_lower(char *s); -char *str_wrm_tail(char *str); -char *str_rm_tail(char *str, const char* const charlist); -char *str_upper(char *str); - -/* syserror.cpp */ -void sys_error(int severity, const char *msg, ...); -void sys_verror(int severity, const char *msg, va_list arg); -void sys_error_level(int severity); - -/* timedate.cpp */ -DATE *td_get_date(DATE *d); -TIME *td_get_time(TIME *t); -double td_current_sec(void); -double td_time_to_sec(TIME *t); -TIME *td_time_sub(const TIME *t1, const TIME *t2, TIME *tdiff); -TIME *td_time_add(const TIME *t1, const TIME *t2, TIME *tsum); -TIME *td_time_copy(TIME *to, const TIME *from); -TIME *td_time_norm(TIME *t); -void td_get_tmdt(TIMEDATE *td); -const char *td_str_tmdt(const TIMEDATE *td); -const char *td_str_time(const TIME *t); -const char *td_str_stime(const TIME *t); -const char *td_str_date(const DATE *d); -char *td_str_cdate(DATE *d); -char *td_month_name(int n); -char *td_day_name(int n); - -#endif