Factored out target specific inclusion of target header.

So far conio.h included the target header to get the CH_... and COLOR_... macros. However tgi.h never did the same to get the TGI_COLOR_... macros. And some time ago the JOY_..._MASK macros moved from joystick.h into the target header yet joystick.h didn't include the target header.

Why wasn't that issue detected so far? Because about every program using TGI and/or the joystick uses CONIO too and therefore includes the target header that way.

However, conceptually it's clean to factor out the target header inclusion and have tgi.h and joystick.h do it like conio.h.

Apart from that user code may make direct use of target.h too.
This commit is contained in:
Oliver Schmidt 2018-02-02 12:59:05 +01:00
parent 2cf1bb89be
commit d7afadb2fe
4 changed files with 84 additions and 46 deletions

View File

@ -54,40 +54,8 @@
#if !defined(_STDARG_H)
# include <stdarg.h>
#endif
/* Include the correct machine-specific file */
#if defined(__APPLE2ENH__)
# include <apple2enh.h>
#elif defined(__APPLE2__)
# include <apple2.h>
#elif defined(__ATARI5200__)
# include <atari5200.h>
#elif defined(__ATARI__)
# include <atari.h>
#elif defined(__ATMOS__)
# include <atmos.h>
#elif defined(__CBM__)
# include <cbm.h>
#elif defined(__CREATIVISION__)
# include <creativision.h>
#elif defined(__GAMATE__)
# include <gamate.h>
#elif defined(__GEOS__)
# include <geos.h>
#elif defined(__LUNIX__)
# include <lunix.h>
#elif defined(__LYNX__)
# include <lynx.h>
#elif defined(__NES__)
# include <nes.h>
#elif defined(__OSIC1P__)
# include <osic1p.h>
#elif defined(__PCE__)
# include <pce.h>
#endif
#include <stdarg.h>
#include <target.h>
@ -232,16 +200,16 @@ void __fastcall__ cputhex16 (unsigned val);
** the macro will give access to the actual function.
*/
#if defined(_textcolor)
#ifdef _textcolor
# define textcolor(x) _textcolor(x)
#endif
#if defined(_bgcolor)
#ifdef _bgcolor
# define bgcolor(x) _bgcolor(x)
#endif
#if defined(_bordercolor)
#ifdef _bordercolor
# define bordercolor(x) _bordercolor(x)
#endif
#if defined(_cpeekcolor)
#ifdef _cpeekcolor
# define cpeekcolor(x) _cpeekcolor(x)
#endif

View File

@ -38,6 +38,10 @@
#include <target.h>
/*****************************************************************************/
/* Definitions */
/*****************************************************************************/
@ -103,6 +107,3 @@ unsigned char __fastcall__ joy_read (unsigned char joystick);
/* End of joystick.h */
#endif

73
include/target.h Normal file
View File

@ -0,0 +1,73 @@
/*****************************************************************************/
/* */
/* target.h */
/* */
/* Target specific definitions */
/* */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
/* warranty. In no event will the authors be held liable for any damages */
/* arising from the use of this software. */
/* */
/* Permission is granted to anyone to use this software for any purpose, */
/* including commercial applications, and to alter it and redistribute it */
/* freely, subject to the following restrictions: */
/* */
/* 1. The origin of this software must not be misrepresented; you must not */
/* claim that you wrote the original software. If you use this software */
/* in a product, an acknowledgment in the product documentation would be */
/* appreciated but is not required. */
/* 2. Altered source versions must be plainly marked as such, and must not */
/* be misrepresented as being the original software. */
/* 3. This notice may not be removed or altered from any source */
/* distribution. */
/* */
/*****************************************************************************/
#ifndef _TARGET_H
#define _TARGET_H
/* Include the correct target specific file */
#if defined(__APPLE2ENH__)
# include <apple2enh.h>
#elif defined(__APPLE2__)
# include <apple2.h>
#elif defined(__ATARI__)
# include <atari.h>
#elif defined(__ATARI2600__)
# include <atari2600.h>
#elif defined(__ATARI5200__)
# include <atari5200.h>
#elif defined(__ATMOS__)
# include <atmos.h>
#elif defined(__CBM__)
# include <cbm.h>
#elif defined(__CREATIVISION__)
# include <creativision.h>
#elif defined(__GAMATE__)
# include <gamate.h>
#elif defined(__GEOS__)
# include <geos.h>
#elif defined(__LYNX__)
# include <lynx.h>
#elif defined(__NES__)
# include <nes.h>
#elif defined(__OSIC1P__)
# include <osic1p.h>
#elif defined(__PCE__)
# include <pce.h>
#elif defined(__SUPERVISION__)
# include <supervision.h>
#elif defined(__TELESTRAT__)
# include <telestrat.h>
#endif
/* End of target.h */
#endif

View File

@ -38,9 +38,8 @@
#ifndef _TGI_ERROR_H
#include <tgi/tgi-error.h>
#endif
#include <target.h>
@ -284,6 +283,3 @@ int __fastcall__ tgi_imulround (int rhs, int lhs);
/* End of tgi.h */
#endif