00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef GLOBAL_H
00028 #define GLOBAL_H
00029
00030
00031
00032
00033
00034
00035 #define outb(addr, data) outp(data, addr)
00036 #define inb(addr) inp(addr)
00037
00038
00039
00040 #define DDR(x) ((x)-1) // address of data direction register of port x
00041 #define PIN(x) ((x)-2) // address of input register of port x
00042
00043
00044 #define MIN(a,b) ((a<b)?(a):(b))
00045 #define MAX(a,b) ((a>b)?(a):(b))
00046 #define ABS(x) ((x>0)?(x):(-x))
00047
00048
00049 #define PRG_RDW(a) ( (PRG_RDB((unsigned char*)(a)) & 0x00FF) | ((PRG_RDB((unsigned char*)(a)+1))<<8) )
00050
00051
00052 #define PI 3.14159265359
00053
00054 #ifndef WIN32
00055
00056 #define FALSE 0
00057 #define TRUE -1
00058 #endif
00059
00060
00061 typedef unsigned char u08;
00062 typedef char s08;
00063 typedef unsigned short u16;
00064 typedef short s16;
00065 typedef unsigned long u32;
00066 typedef long s32;
00067 typedef unsigned long long u64;
00068 typedef long long s64;
00069
00070
00071
00072 #define MAX_U08 255
00073 #define MAX_U16 65535
00074 #define MAX_U32 4294967296
00075
00076
00077
00078 #define MIN_S08 -128
00079 #define MAX_S08 127
00080 #define MIN_S16 -32768
00081 #define MAX_S16 32767
00082 #define MIN_S32 -2147483648
00083 #define MAX_S32 2147483647
00084
00085 #ifndef WIN32
00086
00087 typedef unsigned char BOOL;
00088 typedef unsigned char BYTE;
00089 typedef unsigned int WORD;
00090 typedef unsigned long DWORD;
00091
00092 typedef unsigned char UCHAR;
00093 typedef unsigned int UINT;
00094 typedef unsigned short USHORT;
00095 typedef unsigned long ULONG;
00096
00097 typedef char CHAR;
00098 typedef int INT;
00099 typedef long LONG;
00100 #endif
00101
00102
00103
00104
00105 #define F_CPU 8000000 // 8MHz processor
00106
00107
00108
00109 #define CYCLES_PER_US ((F_CPU+500000)/1000000) // cpu cycles per microsecond
00110
00111
00112
00113 #define INT_RAM_BASE 0x0060
00114 #define INT_RAM_END 0x0460
00115
00116 #endif