#ifndef __MYTYPES_H
#define __MYTYPES_H

// Argumente der Interrupt-Routine
#ifdef __cplusplus
#define CPPARGS ...
#else
#define CPPARGS void
#endif

// Typen fr Funktionszeiger
typedef void near (*nearfunc)(CPPARGS);
typedef void far  (* farfunc)(CPPARGS);

// Abkrzengen fr signed, unsigned, long
typedef signed char sc;
typedef unsigned char uc;
typedef signed int si;
typedef unsigned int ui;
typedef signed long sl;
typedef unsigned long ul;
// Der Typ eines OldInts
typedef void interrupt (*isr)(CPPARGS);
// Verschieden String-Pointer
typedef char * str;
typedef sc * sstr;
typedef uc * ustr;
typedef char far * fstr;
typedef sc far * sfstr;
typedef uc far * ufstr;
typedef char huge * hstr;
typedef sc huge * shstr;
typedef uc huge * uhstr;
// Und ein paar void-Pointer
typedef void far * fp;
typedef void near * np;
typedef void huge * hp;
typedef void * ptr;
// Makros fr dynamische Arrays
#ifndef __cplusplus
#define pmalloc(y,x)  ((y) = malloc((x)*sizeof(*(y))))
#define pfarmalloc(y,x)  ((y) = farmalloc((x)*sizeof(*(y))))
#define prealloc(y,x) ((y) = realloc((y),(x)*sizeof(*(y))))
#define pfarrealloc(y,x) ((y) = farrealloc((y),(x)*sizeof(*(y))))
#else
#define pmalloc(y,x,t)  ((y) = (t*)malloc((x)*sizeof(t)))
#define pfarmalloc(y,x,t)  ((y) = (t far *)farmalloc((x)*sizeof(t)))
#define prealloc(y,x,t) ((y) = (t *)realloc((y),(x)*sizeof(t)))
#define pfarrealloc(y,x,t) ((y) = (t far *)farrealloc((y),(x)*sizeof(t)))
#endif
// Makros fr Motorola-Werte
#define wswap(a) ((((ui)(a) << 8) | ((ui)(a) >> 8)) & 0xFFFF)
#define lswap(a) (((ul)(a) << 24) | (((ul)(a) << 8) & 0xFF0000L) | (((ul)(a) >> 8) & 0xFF00) | ((ul)(a) >> 24))

// Definition von NEAR/FAR-DATA/CODE
#if sizeof(ptr) == 2
#define NEARDATA
#else
#define FARDATA
#endif
#if sizeof(void (*)(void)) == 2
#define NEARCODE
#else
#define FARCODE
#endif
#endif

//Makro fr FAR-Pointer
#define FP_ABS(x) (((ul)FP_SEG(x))*16+FP_OFF(x))
