home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Games / NetHack 3.1.3 / source / include / macconf.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-01  |  9.0 KB  |  377 lines  |  [TEXT/R*ch]

  1. /*    SCCS Id: @(#)macconf.h    3.1    91/07/14    */
  2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  3. /* NetHack may be freely redistributed.  See license for details. */
  4.  
  5. #ifdef MAC
  6. # ifndef MACCONF_H
  7. #  define MACCONF_H
  8.  
  9. /*
  10.  * Select your compiler...
  11.  * This could probably be automagic later on - I believe there's
  12.  * a unique symbol for MPW at least (it's "macintosh")
  13.  */
  14. #  ifdef applec
  15. #   define MAC_MPW32        /* Headers, and for avoiding a bug */
  16. #  endif
  17.  
  18. #  define RANDOM
  19. #  define NO_SIGNAL    /* You wouldn't believe our signals ... */
  20. #  define FILENAME 256
  21. #  define NO_TERMS /* For tty port */
  22.  
  23. #  define TEXTCOLOR /* For Mac TTY interface */
  24. #  define CHANGE_COLOR
  25.  
  26. #  include "system.h"
  27.  
  28. typedef long off_t ;
  29.  
  30. /*
  31.  * Try and keep the number of files here to an ABSOLUTE minimum !
  32.  * include the relevant files in the relevant .c files instead !
  33.  */
  34. #  include <segload.h>
  35. #  include <stdlib.h>
  36. #  include <windows.h>
  37. #  include <memory.h>
  38. #  include <quickdraw.h>
  39. #  include <events.h>
  40. #  include <controls.h>
  41. #  include <dialogs.h>
  42. #  include <fonts.h>
  43.  
  44. /*
  45.  * Turn off the Macsbug calls for the production version.
  46.  */
  47. #if 0
  48. #  undef Debugger
  49. #  undef DebugStr
  50. #  define Debugger()
  51. #  define DebugStr(aStr)
  52. #endif
  53.  
  54. /* askname dialog defines (shared between macmain.c and macmenu.c) */
  55. enum
  56. {
  57.     dlog_start = 6000,
  58.     dlogAskName = dlog_start,
  59.     dlog_limit
  60. };
  61.  
  62. /* askname dialog item list */
  63. enum
  64. {
  65.     bttnANPlay = 1,
  66.     bttnANQuit,
  67.     uitmANOutlineDefault,
  68.     uitmANRole,
  69.     uitmANSex,
  70.     uitmANMode,
  71.     stxtANRole,
  72.     stxtANSex,
  73.     stxtANMode,
  74.     stxtANWho,
  75.     etxtANWho
  76. };
  77.  
  78. typedef struct asknameRec
  79. {
  80.     short        anMenu[3];
  81.     unsigned char    anWho[32];    /* player name Pascal string */
  82. } asknameRec, *asknamePtr;
  83.  
  84. /* askname menus */
  85. enum
  86. {
  87.     anRole,
  88.     anSex,
  89.     anMode
  90. };
  91.  
  92. enum
  93. {
  94.     /* role */
  95.     askn_role_start,    /* 0 */
  96.     asknArcheologist = askn_role_start,
  97.     asknBarbarian,
  98.     asknCaveman,        /* Cavewoman */
  99.     asknElf,
  100.     asknHealer,
  101.     asknKnight,
  102.     asknPriest,        /* Priestess */
  103.     asknRogue,
  104.     asknSamurai,
  105.     asknTourist,
  106.     asknValkyrie,        /* female only */
  107.     asknWizard,
  108.     askn_role_end,
  109.  
  110.     /* sex */
  111.     asknMale = 0,
  112.     asknFemale,
  113.  
  114.     /* mode */
  115.     asknRegular = 0,
  116.     asknExplore,
  117.     asknDebug,
  118.     asknQuit        /* special token */
  119. };
  120.  
  121. /*
  122.  * We could use the PSN under sys 7 here ...
  123.  */
  124. #  define getpid() 1
  125. #  define getuid() 1
  126. #  define index strchr
  127. #  define rindex strrchr
  128.  
  129. #  define Rand random
  130.  
  131. #  define error progerror
  132.  
  133. # if defined(VISION_TABLES) && defined(BRACES)
  134. #  undef BRACES
  135. # endif
  136.  
  137. /*
  138.  * macfile.c
  139.  * MAC file I/O routines
  140.  */
  141.  
  142. extern int maccreat ( const char * name , long fileType ) ;
  143. extern int macopen ( const char * name , int flags , long fileType ) ;
  144. extern int macclose ( int fd ) ;
  145. extern int macread ( int fd , void * ptr , unsigned ) ;
  146. extern int macwrite ( int fd , void * ptr , unsigned ) ;
  147. extern long macseek ( int fd , long pos , short whence ) ;
  148.  
  149. extern char * macgets ( int fd , char * ptr , unsigned len ) ;
  150.  
  151.  
  152. # if !defined(O_WRONLY)
  153. #  include <fcntl.h>
  154. # endif
  155.  
  156. #if !defined(SPEC_LEV) && !defined(DGN_COMP)
  157. # define creat maccreat
  158. # define open macopen
  159. # define close macclose
  160. # define read macread
  161. # define write macwrite
  162. # define lseek macseek
  163. #endif
  164.  
  165. # define TEXT_TYPE 'TEXT'
  166. # define LEVL_TYPE 'LEVL'
  167. # define BONE_TYPE 'BONE'
  168. # define SAVE_TYPE 'SAVE'
  169. # define PREF_TYPE 'PREF'
  170. # define DATA_TYPE 'DATA'
  171. # define MAC_CREATOR 'nh31' /* Registered with DTS ! */
  172.  
  173. typedef struct macdirs {
  174.     Str32        dataName ;
  175.     short        dataRefNum ;
  176.     long        dataDirID ;
  177.  
  178.     Str32        saveName ;
  179.     short        saveRefNum ;
  180.     long        saveDirID ;
  181.  
  182.     Str32        levelName ;
  183.     short        levelRefNum ;
  184.     long        levelDirID ;
  185. } MacDirs ;
  186.  
  187. typedef struct macflags {
  188.     Bitfield ( processes , 1 ) ;
  189.     Bitfield ( color , 1 ) ;
  190.     Bitfield ( folders , 1 ) ;
  191.     Bitfield ( tempMem , 1 ) ;
  192.     Bitfield ( help , 1 ) ;
  193.     Bitfield ( fsSpec , 1 ) ;
  194.     Bitfield ( trueType , 1 ) ;
  195.     Bitfield ( aux , 1 ) ;
  196.     Bitfield ( alias , 1 ) ;
  197.     Bitfield ( standardFile , 1 ) ;
  198. } MacFlags ;
  199.  
  200. extern MacDirs theDirs ;
  201. extern MacFlags macFlags ;
  202.  
  203. /*
  204.  * Mac windows
  205.  */
  206. #define NUM_MACWINDOWS 15
  207. #define TEXT_BLOCK 512L
  208. #define WIN_BASE_RES 128
  209. #define WIN_BASE_KIND 128
  210. #define NUM_MENU_ITEMS 60 /* We've run out of letters by then ... */
  211. #define CHAR_ENTER ((char)3)
  212. #define CHAR_BS ((char)8)
  213. #define CHAR_LF ((char)10)
  214. #define CHAR_CR ((char)13)
  215. #define CHAR_ESC ((char)27)
  216. #define CHAR_BLANK ((char)32)
  217. #define CHAR_DELETE ((char)127)
  218.  
  219. #define MAC_GRAPHICS_ENV
  220.  
  221. /* Window constants */
  222. #define kMapWindow 0
  223. #define kStatusWindow 1
  224. #define kMessageWindow 2
  225. #define kTextWindow 3
  226. #define kMenuWindow 4
  227. #define kLastWindowKind kMenuWindow
  228.  
  229. extern Boolean RetrievePosition ( short , short * , short * ) ;
  230. extern Boolean RetrieveSize ( short , short , short , short * , short * ) ;
  231. extern void SavePosition ( short , short , short ) ;
  232. extern void SaveSize ( short , short , short ) ;
  233. extern void SaveWindowPos ( WindowPtr ) ;
  234. extern void SaveWindowSize ( WindowPtr ) ;
  235.  
  236. /*
  237.  * This determines the minimum logical line length in text windows
  238.  * That is; even if physical width is less, this is where line breaks
  239.  * go at the minimum. 350 is about right for score lines with a
  240.  * geneva 10 pt font.
  241.  */
  242. #define MIN_RIGHT 350
  243.  
  244. #define NUM_CANCEL_ITEMS 10
  245.  
  246.  
  247. typedef struct NhWindow {
  248.     WindowPtr        theWindow ;
  249.     short            kind ;
  250.     void            ( * keyFunc ) ( EventRecord * , WindowPtr ) ;
  251.     void            ( * clickFunc ) ( EventRecord * , WindowPtr ) ;
  252.     void            ( * updateFunc ) ( EventRecord * , WindowPtr ) ;
  253.     void            ( * cursorFunc ) ( EventRecord * , WindowPtr , RgnHandle ) ;
  254.     Handle            windowText ;
  255.     long            windowTextLen ;
  256.     Point            cursor ;        /* In CHARS / LINES */
  257.     short            leading ;
  258.     short            charHeight ;
  259.     short            charWidth ;
  260.     short            fontNum ;
  261.     short            fontSize ;
  262.     short            last_more_lin ;    /* Used by message window */
  263.     short            save_lin ;        /* Used by message window */
  264.     short            lin ;            /* Used by menus */
  265.     short            wid ;            /* Used by menus */
  266.     char            itemChars [ NUM_MENU_ITEMS ] ;
  267.     char            cancelStr [ NUM_CANCEL_ITEMS ] ;
  268.     char            cancelChar ;
  269.     char            clear ;
  270.     short            scrollPos ;
  271.     ControlHandle    scrollBar ;
  272. } NhWindow ;
  273.  
  274. extern NhWindow *GetNhWin(WindowPtr mac_win);
  275.  
  276.  
  277. #define NUM_STAT_ROWS 2
  278. #define NUM_ROWS 22
  279. #define NUM_COLS 81 /* We shouldn't use column 0 */
  280.  
  281. typedef struct MapData {
  282.     char        map [ NUM_ROWS ] [ NUM_COLS ] ;
  283. } MapData ;
  284.  
  285. typedef struct StatusData {
  286.     char        map [ NUM_STAT_ROWS ] [ NUM_COLS ] ;
  287. } StatusData ;
  288.  
  289. extern NhWindow * theWindows ;
  290.  
  291. extern struct window_procs mac_procs ;
  292.  
  293. extern short text_wind_font;
  294. #define set_text_wind_font(fnt) (text_wind_font = fnt)
  295. #define mono_font()    set_text_wind_font(monaco)
  296. #define normal_font()    set_text_wind_font(geneva)
  297.  
  298. #define E extern
  299.  
  300. /*
  301.  * Define PORT_HELP to be the name of the port-specfic help file.
  302.  * This file is included into the resource fork of the application. 
  303.  */
  304. #define PORT_HELP "MacHelp"
  305.  
  306. E void NDECL(port_help);
  307.  
  308. E void NDECL(mac_init_nhwindows);
  309. E void NDECL(mac_player_selection);
  310. E void NDECL(mac_askname);
  311. E void NDECL(mac_get_nh_event) ;
  312. E void FDECL(mac_exit_nhwindows, (const char *));
  313. E void FDECL(mac_suspend_nhwindows, (const char *));
  314. E void NDECL(mac_resume_nhwindows);
  315. E winid FDECL(mac_create_nhwindow, (int));
  316. E void FDECL(mac_clear_nhwindow, (winid));
  317. E void FDECL(mac_display_nhwindow, (winid, BOOLEAN_P));
  318. E void FDECL(mac_destroy_nhwindow, (winid));
  319. E void FDECL(mac_curs, (winid,int,int));
  320. E void FDECL(mac_putstr, (winid, int, const char *));
  321. E void FDECL(mac_display_file, (const char *, BOOLEAN_P));
  322. E void FDECL(mac_start_menu, (winid));
  323. E void FDECL(mac_add_menu, (winid, CHAR_P, int, const char *));
  324. E void FDECL(mac_end_menu, (winid, CHAR_P, const char *, const char *));
  325. E char FDECL(mac_select_menu, (winid));
  326. E void NDECL(mac_update_inventory);
  327. E void NDECL(mac_mark_synch);
  328. E void NDECL(mac_wait_synch);
  329. #ifdef CLIPPING
  330. E void FDECL(mac_cliparound, (int, int));
  331. #endif
  332. E void FDECL(mac_print_glyph, (winid,XCHAR_P,XCHAR_P,int));
  333. E void FDECL(mac_raw_print, (const char *));
  334. E void FDECL(mac_raw_print_bold, (const char *));
  335. E int NDECL(mac_nhgetch);
  336. E int FDECL(mac_nh_poskey, (int *, int *, int *));
  337. E void NDECL(mac_nhbell);
  338. E int NDECL(mac_doprev_message);
  339. E char FDECL(mac_yn_function, (const char *, const char *, CHAR_P));
  340. E void FDECL(mac_getlin, (const char *,char *));
  341. #ifdef COM_COMPL
  342. E void FDECL(mac_get_ext_cmd, (char *));
  343. #endif /* COM_COMPL */
  344. E void FDECL(mac_number_pad, (int));
  345. E void NDECL(mac_delay_output);
  346.  
  347. /* defined in macwin.c and exported for used in mmodal.c */
  348. E void        FDECL(HandleEvent, (EventRecord *));
  349.  
  350. /* defined in mmodal.c */
  351. E DialogPtr FDECL(mv_get_new_dialog, (short));
  352. E void        FDECL(mv_close_dialog, (DialogPtr));
  353. E void        FDECL(mv_modal_dialog, (ModalFilterProcPtr, short *));
  354.  
  355. #undef E
  356.  
  357. extern void DimMenuBar ( void ) ;
  358. extern void UndimMenuBar ( void ) ;
  359. extern int SanePositions ( void ) ;
  360.  
  361. #define NHW_BASE 0
  362. extern winid BASE_WINDOW , WIN_MAP , WIN_MESSAGE , WIN_INVEN , WIN_STATUS ;
  363.  
  364. extern Boolean itworked( short );
  365. extern void mustwork( short );
  366. extern void VDECL(progerror, (const char *,...));
  367. extern void attemptingto( char *  );
  368. extern void pushattemptingto( char *  );
  369. extern void popattempt( void );
  370. extern void UnloadAllSegments( void );
  371. extern void InitSegMgmt( void * );
  372. extern void IsResident ( void * );
  373. extern void NotResident ( void * );
  374.  
  375. # endif /* ! MACCONF_H */
  376. #endif /* MAC */
  377.