]> git.sur5r.net Git - cc65/commitdiff
Factored out target specific inclusion of target header.
authorOliver Schmidt <ol.sc@web.de>
Fri, 2 Feb 2018 11:59:05 +0000 (12:59 +0100)
committerOliver Schmidt <ol.sc@web.de>
Fri, 2 Feb 2018 11:59:05 +0000 (12:59 +0100)
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.

include/conio.h
include/joystick.h
include/target.h [new file with mode: 0644]
include/tgi.h

index 9cd505766113ce9971f357a2b884b449d28b2632..72421af86ac7d8742706fbaadba50e08b116760d 100644 (file)
 
 
 
-#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
 
index 26f339fe4f392227accca399d7f35ee8d424a881..b6771c38158cf2eec3b7159981fb52b24b7c910c 100644 (file)
 
 
 
+#include <target.h>
+
+
+
 /*****************************************************************************/
 /*                                  Definitions                              */
 /*****************************************************************************/
@@ -103,6 +107,3 @@ unsigned char __fastcall__ joy_read (unsigned char joystick);
 
 /* End of joystick.h */
 #endif
-
-
-
diff --git a/include/target.h b/include/target.h
new file mode 100644 (file)
index 0000000..af401ec
--- /dev/null
@@ -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
index 02dff8868768b93ae7f2ec6f3a8caa22332449cf..f458180c51a8c62f91b938e958bf7ea9c3de01cc 100644 (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
-
-
-