cscg22-gearboy

CSCG 2022 Challenge 'Gearboy'
git clone https://git.sinitax.com/sinitax/cscg22-gearboy
Log | Files | Refs | sfeed.txt

types.h (1606B)


      1/** @file asm/types.h
      2    Shared types definitions.
      3*/
      4#ifndef ASM_TYPES_INCLUDE
      5#define ASM_TYPES_INCLUDE
      6
      7#if defined(__PORT_sm83)
      8#include <asm/sm83/types.h>
      9#elif defined(__PORT_z80)
     10#include <asm/z80/types.h>
     11#else
     12#error Unrecognised port
     13#endif
     14
     15#ifndef OLDCALL
     16#if __SDCC_REVISION >= 12608
     17#define OLDCALL __sdcccall(0)
     18#else
     19#define OLDCALL
     20#endif
     21#endif
     22
     23#ifdef __SDCC
     24#define PRESERVES_REGS(...) __preserves_regs(__VA_ARGS__)
     25#define NAKED   __naked
     26#define SFR     __sfr
     27#define AT(A)   __at(A)
     28#else
     29#define PRESERVES_REGS(...)
     30#define NAKED
     31#define SFR
     32#define AT(A)
     33#endif
     34
     35#ifndef NONBANKED
     36#define NONBANKED
     37#endif
     38#ifndef BANKED
     39#define BANKED
     40#endif
     41#ifndef CRITICAL
     42#define CRITICAL
     43#endif
     44#ifndef INTERRUPT
     45#define INTERRUPT
     46#endif
     47
     48/** TRUE or FALSE.
     49    @anchor file_asm_types_h
     50 */
     51typedef INT8    BOOLEAN;
     52
     53/** Signed 8 bit.
     54 */
     55typedef INT8    BYTE;
     56/** Unsigned 8 bit.
     57 */
     58typedef UINT8   UBYTE;
     59/** Signed 16 bit */
     60typedef INT16   WORD;
     61/** Unsigned 16 bit */
     62typedef UINT16  UWORD;
     63/** Signed 32 bit */
     64typedef INT32   LWORD;
     65/** Unsigned 32 bit */
     66typedef UINT32  ULWORD;
     67/** Signed 32 bit */
     68typedef INT32	  DWORD;
     69/** Unsigned 32 bit */
     70typedef UINT32	UDWORD;
     71
     72/** Useful definition for working with 8 bit + 8 bit fixed point values
     73
     74    Use `.w` to access the variable as unsigned 16 bit type.
     75
     76    Use `.b.h` and `.b.l` (or just `.h` and `.l`) to directly access it's high and low unsigned 8 bit values.
     77 */
     78typedef union _fixed {
     79    struct {
     80        UBYTE l;
     81        UBYTE h;
     82    };
     83    struct {
     84        UBYTE l;
     85        UBYTE h;
     86    } b;
     87    UWORD w;
     88} fixed;
     89
     90#endif