home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / Information / Stuart's Tech Notes / StuTypes.h < prev   
Encoding:
Text File  |  1995-06-14  |  2.2 KB  |  74 lines  |  [TEXT/R*ch]

  1. // This header file defines standard types and constants
  2. // that all of my programs tend to assume
  3. // (C) 1993-1995 Stuart Cheshire <cheshire@cs.stanford.edu>
  4.  
  5. // ************************************************************
  6. // Basic C definitions
  7.  
  8. #define local static
  9. #define import extern
  10. #define export
  11. #define until(A) while(!(A))
  12. #define elementsof(A) (sizeof(A)/sizeof((A)[0]))
  13. #define semiconst const
  14.  
  15. typedef unsigned char  u_char;
  16. typedef unsigned short u_short;
  17. typedef unsigned long  u_long;
  18.  
  19. typedef u_char  NIBBLE;    // to be interpreted as four bits
  20. typedef u_char  BYTE;
  21. typedef u_short WORD;
  22. typedef u_long  DWORD;
  23. typedef union { DWORD dword[2]; WORD word[4]; BYTE byte[ 8]; } QWORD;
  24. typedef union { DWORD dword[4]; WORD word[8]; BYTE byte[16]; } OCTWORD;
  25.  
  26. typedef struct {   char c[  4]; }   char4;
  27. typedef struct { u_char c[  4]; } u_char4;
  28. typedef struct {   char c[ 32]; }   char32;
  29. typedef struct { u_char c[ 32]; } u_char32;
  30. typedef struct {   char c[ 36]; }   char36;
  31. typedef struct { u_char c[ 36]; } u_char36;
  32. typedef struct {   char c[ 64]; }   char64;
  33. typedef struct { u_char c[ 64]; } u_char64;
  34. typedef struct {   char c[256]; }   char256;
  35. typedef struct { u_char c[256]; } u_char256;
  36.  
  37. // ************************************************************
  38. // 68000 processor related definitions
  39.  
  40. #pragma parameter __D0 DisableInterrupts()    // MOVE SR,D0  ORI.W #$0700,SR
  41. local short DisableInterrupts(void) = { 0x40C0, 0x007C, 0x0700 };
  42.  
  43. #pragma parameter RestoreInterrupts(__D0)    // MOVE D0,SR
  44. local void RestoreInterrupts(short oldval) = { 0x46C0 };
  45.  
  46. // ************************************************************
  47. // Macintosh OS related definitions
  48.  
  49. // Serial Driver
  50. #define SerHShake_V2 14
  51.  
  52. // Baud rate constants: formula is (115200/baud)-2
  53. #define baud38400 1
  54. #define baud28800 2
  55.  
  56. // Time Manager
  57. #define TMTaskActiveBit 0x8000
  58.  
  59. // File Manager
  60. #define fsNoCache 0x20
  61.  
  62. // ************************************************************
  63. // Symantec compiler related definitions
  64.  
  65. #if __option(a4_globals)
  66. #define GLOBREG A4
  67. #pragma parameter __A0 GetGlobalsRegister()    // MOVEA.L A4,A0
  68. local void* GetGlobalsRegister(void) = { 0x204C };
  69. #else
  70. #define GLOBREG A5
  71. #pragma parameter __A0 GetGlobalsRegister()    // MOVEA.L A5,A0
  72. local void* GetGlobalsRegister(void) = { 0x204D };
  73. #endif
  74.