3 /* Purpose: Simple support for MACINTOSH Angband */
6 * This file should only be compiled with the "Macintosh" version
8 * This file written by "Ben Harrison (benh@phial.com)".
10 * Some code adapted from "MacAngband 2.6.1" by Keith Randall
12 * Maarten Hazewinkel (mmhazewi@cs.ruu.nl) provided some initial
13 * suggestions for the PowerMac port.
15 * Steve Linberg (slinberg@crocker.com) provided the code surrounded
18 * The graphics code is adapted from an extremely minimal subset of
19 * the code from "Sprite World II", an amazing animation package.
21 * See "z-term.c" for info on the concept of the "generic terminal"
23 * The preference file is now a text file named "Angband preferences".
25 * Note that the "preference" file is now a simple text file called
26 * "Angband preferences", which contains the versions information, so
27 * that obsolete preference files can be ignored (this may be bad).
29 * Note that "init1.c", "init2.c", "load1.c", "load2.c", and "birth.c"
30 * should probably be "unloaded" as soon as they are no longer needed,
31 * to save space, but I do not know how to do this.
33 * Stange bug -- The first "ClipRect()" call crashes if the user closes
34 * all the windows, switches to another application, switches back, and
35 * then re-opens the main window, for example, using "command-a".
37 * By default, this file assumes that you will be using a 68020 or better
38 * machine, running System 7 and Color Quickdraw. In fact, the game will
39 * refuse to run unless these features are available. This allows the use
40 * of a variety of interesting features such as graphics and sound.
42 * To create a version which can be used on 68000 machines, or on machines
43 * which are not running System 7 or Color Quickdraw, simply activate the
44 * "ANGBAND_LITE_MAC" compilation flag in the proper header file. This
45 * will disable all "modern" features used in this file, including support
46 * for multiple sub-windows, color, graphics, and sound.
48 * When compiling with the "ANGBAND_LITE_MAC" flag, the "ANGBAND_LITE"
49 * flag will be automatically defined, which will disable many of the
50 * advanced features of the game itself, reducing the total memory usage.
52 * If you are never going to use "graphics" (especially if you are not
53 * compiling support for graphics anyway) then you can delete the "pict"
54 * resource with id "1001" with no dangerous side effects.
59 * Important Resources in the resource file:
61 * FREF 130 = 'A271' / 'APPL' (application)
62 * FREF 129 = 'A271' / 'SAVE' (save file)
63 * FREF 130 = 'A271' / 'TEXT' (bone file, generic text file)
64 * FREF 131 = 'A271' / 'DATA' (binary image file, score file)
66 * DLOG 128 = "About Angband..."
68 * ALRT 128 = unused (?)
69 * ALRT 129 = "Warning..."
70 * ALRT 130 = "Are you sure you want to quit without saving?"
72 * DITL 128 = body for DLOG 128
73 * DITL 129 = body for ALRT 129
74 * DITL 130 = body for ALRT 130
76 * ICON 128 = "warning" icon
78 * MENU 128 = apple (about, -, ...)
79 * MENU 129 = File (new, open, close, save, -, exit, quit)
80 * MENU 130 = Edit (undo, -, cut, copy, paste, clear)
82 * PICT 1001 = Graphics tile set
88 * all 'APEX' files have a filename of the form "*:apex:*" (?)
89 * all 'BONE' files have a filename of the form "*:bone:*" (?)
90 * all 'DATA' files have a filename of the form "*:data:*"
91 * all 'SAVE' files have a filename of the form "*:save:*"
92 * all 'USER' files have a filename of the form "*:user:*" (?)
94 * Perhaps we should attempt to set the "_ftype" flag inside this file,
95 * to avoid nasty file type information being spread all through the
96 * rest of the code. (?) This might require adding hooks into the
97 * "fd_open()" and "my_fopen()" functions in "util.c". XXX XXX XXX
102 * Reasons for each header file:
104 * angband.h = Angband header file
106 * Types.h = (included anyway)
107 * Gestalt.h = gestalt code
108 * QuickDraw.h = (included anyway)
109 * OSUtils.h = (included anyway)
110 * Files.h = file code
111 * Fonts.h = font code
112 * Menus.h = menu code
113 * Dialogs.h = dialog code
114 * Windows.h = (included anyway)
115 * Palettes.h = palette code
116 * StandardFile.h = file dialog box
117 * DiskInit.h = disk initialization
118 * ToolUtils.h = HiWord() / LoWord()
119 * Desk.h = OpenDeskAcc()
120 * Devices.h = OpenDeskAcc()
121 * Events.h = event code
122 * Resources.h = resource code
123 * Controls.h = button code
124 * SegLoad.h = ExitToShell(), AppFile, etc
125 * Memory.h = SetApplLimit(), NewPtr(), etc
126 * QDOffscreen.h = GWorld code
127 * Sound.h = Sound code
129 * For backwards compatibility:
130 * Use GestaltEqu.h instead of Gestalt.h
131 * Add Desk.h to include simply includes Menus.h, Devices.h, Events.h
139 #include <QuickDraw.h>
145 #include <Palettes.h>
146 #include <StandardFile.h>
147 #include <DiskInit.h>
148 #include <ToolUtils.h>
151 #include <Resources.h>
152 #include <Controls.h>
155 #include <QDOffscreen.h>
165 * Cleaning up a couple of things to make these easier to change --AR
168 #define PREF_FILE_NAME "Hengband Preferences"
170 #define PREF_FILE_NAME "Hengband-E Preferences"
174 * Use "malloc()" instead of "NewPtr()"
176 /* #define USE_MALLOC */
179 #if defined(powerc) || defined(__powerc)
182 * Disable "LITE" version
184 # undef ANGBAND_LITE_MAC
189 #ifdef ANGBAND_LITE_MAC
192 * Maximum number of windows
194 # define MAX_TERM_DATA 1
196 #else /* ANGBAND_LITE_MAC */
199 * Maximum number of windows
201 # define MAX_TERM_DATA 8
204 * Activate some special code
206 # define USE_SFL_CODE
208 #endif /* ANGBAND_LITE_MAC */
215 * Include the necessary header files
217 #include <AppleEvents.h>
225 * Globals for MPW compilation
239 * The Angband Color Set (0 to 15):
240 * Black, White, Slate, Orange, Red, Blue, Green, Umber
241 * D-Gray, L-Gray, Violet, Yellow, L-Red, L-Blue, L-Green, L-Umber
243 * Colors 8 to 15 are basically "enhanced" versions of Colors 0 to 7.
245 * On the Macintosh, we use color quickdraw, and we use actual "RGB"
246 * values below to choose the 16 colors.
248 * If we are compiled for ancient machines, we bypass color and simply
249 * draw everything in white (letting "z-term.c" automatically convert
250 * "black" into "wipe" calls).
252 static RGBColor foo[16] =
254 {0x0000, 0x0000, 0x0000}, /* TERM_DARK */
255 {0xFFFF, 0xFFFF, 0xFFFF}, /* TERM_WHITE */
256 {0x8080, 0x8080, 0x8080}, /* TERM_SLATE */
257 {0xFFFF, 0x8080, 0x0000}, /* TERM_ORANGE */
258 {0xC0C0, 0x0000, 0x0000}, /* TERM_RED */
259 {0x0000, 0x8080, 0x4040}, /* TERM_GREEN */
260 {0x0000, 0x0000, 0xFFFF}, /* TERM_BLUE */
261 {0x8080, 0x4040, 0x0000}, /* TERM_UMBER */
262 {0x4040, 0x4040, 0x4040}, /* TERM_L_DARK */
263 {0xC0C0, 0xC0C0, 0xC0C0}, /* TERM_L_WHITE */
264 {0xFFFF, 0x0000, 0xFFFF}, /* TERM_VIOLET */
265 {0xFFFF, 0xFFFF, 0x0000}, /* TERM_YELLOW */
266 {0xFFFF, 0x0000, 0x0000}, /* TERM_L_RED */
267 {0x0000, 0xFFFF, 0x0000}, /* TERM_L_GREEN */
268 {0x0000, 0xFFFF, 0xFFFF}, /* TERM_L_BLUE */
269 {0xC0C0, 0x8080, 0x4040} /* TERM_L_UMBER */
278 typedef struct term_data term_data;
291 #ifdef ANGBAND_LITE_MAC
295 #else /* ANGBAND_LITE_MAC */
307 #endif /* ANGBAND_LITE_MAC */
309 GWorldPtr bufferPort;
310 PixMapHandle bufferPixHndl;
354 * Forward declare -- see below
356 static bool CheckEvents(bool wait);
360 * Hack -- location of the main directory
362 static short app_vol;
367 * Delay handling of double-clicked savefiles
369 Boolean open_when_ready = FALSE;
372 * Delay handling of pre-emptive "quit" event
374 Boolean quit_when_ready = FALSE;
378 * Hack -- game in progress
380 static int game_in_progress = 0;
384 * Only do "SetPort()" when needed
386 static WindowPtr active = NULL;
391 * An array of term_data's
393 static term_data data[MAX_TERM_DATA];
398 * Note when "open"/"new" become valid
400 static bool initialized = FALSE;
405 * CodeWarrior uses Universal Procedure Pointers
407 static ModalFilterUPP ynfilterUPP;
414 AEEventHandlerUPP AEH_Start_UPP;
415 AEEventHandlerUPP AEH_Quit_UPP;
416 AEEventHandlerUPP AEH_Print_UPP;
417 AEEventHandlerUPP AEH_Open_UPP;
425 static int ext_sound = 0;
433 #define SND_CMD_ERROR 6
435 static int soundchoice[] = {
503 static int soundmode[8];
505 static int ext_graf = 0;
510 * Convert refnum+vrefnum+fname into a full file name
511 * Store this filename in 'buf' (make sure it is long enough)
512 * Note that 'fname' looks to be a "pascal" string
514 static void refnum_to_name(char *buf, long refnum, short vrefnum, char *fname)
526 for (j=1; j<=fname[0]; j++)
528 res[i-fname[0]+j] = fname[j];
532 pb.ioCompletion=NULL;
534 pb.ioVRefNum=vrefnum;
540 pb.ioDrDirID=pb.ioDrParID;
541 err = PBGetCatInfo((CInfoPBPtr)&pb, FALSE);
543 for (j=1; j<=name[0]; j++)
545 res[i-name[0]+j] = name[j];
549 if (pb.ioDrDirID == fsRtDirID) break;
552 /* Extract the result */
553 for (j = 0, i++; res[i]; j++, i++) buf[j] = res[i];
561 * XXX XXX XXX Allow the system to ask us for a filename
563 static bool askfor_file(char *buf, int len)
571 /* Default file name */
572 sprintf((char*)dflt + 1, "%s's description", buf);
573 dflt[0] = strlen((char*)dflt + 1);
575 /* Ask for a file name */
576 topleft.h=(qd.screenBits.bounds.left+qd.screenBits.bounds.right)/2-344/2;
577 topleft.v=(2*qd.screenBits.bounds.top+qd.screenBits.bounds.bottom)/3-188/2;
578 SFPutFile(topleft, "\pSelect a filename:", dflt, NULL, &reply);
579 /* StandardPutFile("\pSelect a filename:", dflt, &reply); */
587 GetWDInfo(reply.vRefNum, &vrefnum, &drefnum, &junk);
589 /* Extract the name */
590 refnum_to_name(buf, drefnum, vrefnum, (char*)reply.fName);
605 * Center a rectangle inside another rectangle
607 static void center_rect(Rect *r, Rect *s)
609 int centerx = (s->left + s->right)/2;
610 int centery = (2*s->top + s->bottom)/3;
611 int dx = centerx - (r->right - r->left)/2 - r->left;
612 int dy = centery - (r->bottom - r->top)/2 - r->top;
621 * Convert a pascal string in place
623 * This function may be defined elsewhere, but since it is so
624 * small, it is not worth finding the proper function name for
625 * all the different platforms.
627 static void ptocstr(StringPtr src)
631 /* Hack -- pointer */
632 char *s = (char*)(src);
634 /* Hack -- convert the string */
635 for (i = s[0]; i; i--, s++) s[0] = s[1];
637 /* Hack -- terminate the string */
642 #if defined(USE_SFL_CODE)
646 * The following three routines (pstrcat, pstrinsert, and PathNameFromDirID)
647 * were taken from the Think Reference section called "Getting a Full Pathname"
648 * (under the File Manager section). We need PathNameFromDirID to get the
649 * full pathname of the opened savefile, making no assumptions about where it
652 * I had to hack PathNameFromDirID a little for MetroWerks, but it's awfully
655 static void pstrcat(StringPtr dst, StringPtr src)
658 BlockMove(src + 1, dst + *dst + 1, *src);
660 /* adjust length byte */
665 * pstrinsert - insert string 'src' at beginning of string 'dst'
667 static void pstrinsert(StringPtr dst, StringPtr src)
669 /* make room for new string */
670 BlockMove(dst + 1, dst + *src + 1, *dst);
672 /* copy new string in */
673 BlockMove(src + 1, dst + 1, *src);
675 /* adjust length byte */
679 static void PathNameFromDirID(long dirID, short vRefNum, StringPtr fullPathName)
682 Str255 directoryName;
685 fullPathName[0] = '\0';
687 block.dirInfo.ioDrParID = dirID;
688 block.dirInfo.ioNamePtr = directoryName;
692 block.dirInfo.ioVRefNum = vRefNum;
693 block.dirInfo.ioFDirIndex = -1;
694 block.dirInfo.ioDrDirID = block.dirInfo.ioDrParID;
695 err = PBGetCatInfo(&block, FALSE);
696 pstrcat(directoryName, (StringPtr)"\p:");
697 pstrinsert(fullPathName, directoryName);
698 if (block.dirInfo.ioDrDirID == 2) break;
707 * Activate a given window, if necessary
709 static void activate(WindowPtr w)
724 * Display a warning message
726 static void mac_warning(cptr warning)
731 /* Limit of 250 chars */
732 len = strlen(warning);
733 if (len > 250) len = 250;
735 /* Make a "Pascal" string */
737 for (i=0; i<len; i++) text[i+1] = warning[i];
739 /* Prepare the dialog box values */
740 ParamText(text, "\p", "\p", "\p");
742 /* Display the Alert, wait for Okay */
748 /*** Some generic functions ***/
751 #ifdef ANGBAND_LITE_MAC
754 * Hack -- activate a color (0 to 255)
756 #define term_data_color(TD,A) /* Nothing */
758 #else /* ANGBAND_LITE_MAC */
761 * Hack -- activate a color (0 to 255)
763 static void term_data_color(term_data *td, int a)
769 /* Extract the R,G,B data */
770 rv = angband_color_table[a][1];
771 gv = angband_color_table[a][2];
772 bv = angband_color_table[a][3];
775 color.red = (rv | (rv << 8));
776 color.green = (gv | (gv << 8));
777 color.blue = (bv | (bv << 8));
779 /* Activate the color */
780 RGBForeColor(&color);
786 #endif /* ANGBAND_LITE_MAC */
790 * Hack -- Apply and Verify the "font" info
792 * This should usually be followed by "term_data_check_size()"
794 static void term_data_check_font(term_data *td)
800 WindowPtr old = active;
806 /* Instantiate font */
807 TextFont(td->font_id);
808 TextSize(td->font_size);
809 TextFace(td->font_face);
811 /* Extract the font info */
814 /* Assume monospaced */
815 td->font_mono = TRUE;
817 /* Extract the font sizing values XXX XXX XXX */
818 td->font_wid = CharWidth('@'); /* info.widMax; */
819 td->font_hgt = info.ascent + info.descent;
821 td->font_o_y = info.ascent;
823 /* Check important characters */
824 for (i = 33; i < 127; i++)
826 /* Hack -- notice non-mono-space */
827 if (td->font_wid != CharWidth(i)) td->font_mono = FALSE;
829 /* Hack -- collect largest width */
830 if (td->font_wid < CharWidth(i)) td->font_wid = CharWidth(i);
833 /* Set default offsets */
834 td->tile_o_x = td->font_o_x;
835 td->tile_o_y = td->font_o_y;
837 /* Set default tile size */
838 if( td->tile_wid == 0 && td->tile_hgt == 0 ){
839 td->tile_wid = td->font_wid;
840 td->tile_hgt = td->font_hgt;
843 /* Re-activate the old window */
849 * Hack -- Apply and Verify the "size" info
851 static void term_data_check_size(term_data *td)
853 /* Minimal window size */
856 /* Enforce minimal size */
857 if (td->cols < 80) td->cols = 80;
858 if (td->rows < 24) td->rows = 24;
861 /* Allow small windows for the rest */
864 if (td->cols < 1) td->cols = 1;
865 if (td->rows < 1) td->rows = 1;
868 /* Minimal tile size */
869 if (td->tile_wid < 4) td->tile_wid = 4;
870 if (td->tile_hgt < 4) td->tile_hgt = 4;
872 /* Default tile offsets */
873 td->tile_o_x = (td->tile_wid - td->font_wid) / 2;
874 td->tile_o_y = (td->tile_hgt - td->font_hgt) / 2;
876 /* Minimal tile offsets */
877 if (td->tile_o_x < 0) td->tile_o_x = 0;
878 if (td->tile_o_y < 0) td->tile_o_y = 0;
880 /* Apply font offsets */
881 td->tile_o_x += td->font_o_x;
882 td->tile_o_y += td->font_o_y;
884 /* Calculate full window size */
885 td->size_wid = td->cols * td->tile_wid + td->size_ow1 + td->size_ow2;
886 td->size_hgt = td->rows * td->tile_hgt + td->size_oh1 + td->size_oh2;
889 if (td->r.top > qd.screenBits.bounds.bottom - td->size_hgt)
891 td->r.top = qd.screenBits.bounds.bottom - td->size_hgt;
895 if (td->r.top < qd.screenBits.bounds.top + 30)
897 td->r.top = qd.screenBits.bounds.top + 30;
900 /* Verify the left */
901 if (td->r.left > qd.screenBits.bounds.right - td->size_wid)
903 td->r.left = qd.screenBits.bounds.right - td->size_wid;
906 /* Verify the left */
907 if (td->r.left < qd.screenBits.bounds.left)
909 td->r.left = qd.screenBits.bounds.left;
912 /* Calculate bottom right corner */
913 td->r.right = td->r.left + td->size_wid;
914 td->r.bottom = td->r.top + td->size_hgt;
916 /* Assume no graphics */
917 td->t->higher_pict = FALSE;
918 td->t->always_pict = FALSE;
920 #ifdef ANGBAND_LITE_MAC
924 #else /* ANGBAND_LITE_MAC */
926 /* Handle graphics */
929 /* Use higher_pict whenever possible */
930 if (td->font_mono) td->t->higher_pict = TRUE;
932 /* Use always_pict only when necessary */
933 else td->t->always_pict = TRUE;
936 #endif /* ANGBAND_LITE_MAC */
938 /* Fake mono-space */
939 if (!td->font_mono ||
940 (td->font_wid != td->tile_wid) ||
941 (td->font_hgt != td->tile_hgt))
943 /* Handle fake monospace -- this is SLOW */
944 if (td->t->higher_pict) td->t->higher_pict = FALSE;
945 td->t->always_pict = TRUE;
949 static OSErr XDDSWUpDateGWorldFromPict( term_data *td );
951 * Hack -- resize a term_data
953 * This should normally be followed by "term_data_resize()"
955 static void term_data_resize(term_data *td)
957 /* Actually resize the window */
958 SizeWindow(td->w, td->size_wid, td->size_hgt, 0);
960 XDDSWUpDateGWorldFromPict( td );
966 * Hack -- redraw a term_data
968 * Note that "Term_redraw()" calls "TERM_XTRA_CLEAR"
970 static void term_data_redraw(term_data *td)
974 /* Activate the term */
975 Term_activate(td->t);
977 /* Redraw the contents */
980 /* Flush the output */
983 /* Restore the old term */
986 /* No need to redraw */
987 ValidRect(&td->w->portRect);
993 #ifdef ANGBAND_LITE_MAC
997 #else /* ANGBAND_LITE_MAC */
1004 static int pictID = 1001; /* 8x8 tiles; 16x16 tiles are 1002 */
1006 static int grafWidth = 8; /* Always equal to grafHeight */
1007 static int grafHeight = 8; /* Either 8 or 16 */
1009 static bool arg_newstyle_graphics;
1010 static bool use_newstyle_graphics;
1015 typedef struct FrameRec FrameRec;
1020 * - GWorld for the frame image
1021 * - Handle to pix map (saved for unlocking/locking)
1022 * - Pointer to color pix map (valid only while locked)
1026 GWorldPtr framePort;
1027 PixMapHandle framePixHndl;
1034 * The global picture data
1036 static FrameRec *frameP = NULL;
1042 static void BenSWLockFrame(FrameRec *srcFrameP)
1044 PixMapHandle pixMapH;
1046 pixMapH = GetGWorldPixMap(srcFrameP->framePort);
1047 (void)LockPixels(pixMapH);
1048 HLockHi((Handle)pixMapH);
1049 srcFrameP->framePixHndl = pixMapH;
1050 srcFrameP->framePix = (PixMapPtr)StripAddress(*(Handle)pixMapH);
1057 static void XDDSWLockFrame( term_data *td )
1059 PixMapHandle pixMapH;
1061 pixMapH = GetGWorldPixMap(td->bufferPort);
1062 (void)LockPixels(pixMapH);
1063 HLockHi((Handle)pixMapH);
1064 td->bufferPixHndl = pixMapH;
1065 td->bufferPix = (PixMapPtr)*(Handle)pixMapH;
1072 static void BenSWUnlockFrame(FrameRec *srcFrameP)
1074 if (srcFrameP->framePort != NULL)
1076 HUnlock((Handle)srcFrameP->framePixHndl);
1077 UnlockPixels(srcFrameP->framePixHndl);
1080 srcFrameP->framePix = NULL;
1087 static void XDDSWUnlockFrame( term_data *td )
1089 if (td->bufferPort != NULL)
1091 HUnlock((Handle)td->bufferPixHndl);
1092 UnlockPixels(td->bufferPixHndl);
1095 td->bufferPix = NULL;
1098 static OSErr BenSWCreateGWorldFromPict(
1099 GWorldPtr *pictGWorld,
1103 GWorldPtr saveGWorld;
1104 GDHandle saveGDevice;
1105 GWorldPtr tempGWorld;
1114 depth = data[0].pixelDepth;
1117 theGDH = data[0].theGDH;
1119 /* Obtain size rectangle */
1120 pictRect = (**pictH).picFrame;
1121 OffsetRect(&pictRect, -pictRect.left, -pictRect.top);
1123 /* Create a GWorld */
1124 err = NewGWorld(&tempGWorld, depth, &pictRect, nil,
1125 theGDH, noNewDevice);
1134 *pictGWorld = tempGWorld;
1137 GetGWorld(&saveGWorld, &saveGDevice);
1140 SetGWorld(tempGWorld, nil);
1142 /* Dump the pict into the GWorld */
1143 (void)LockPixels(GetGWorldPixMap(tempGWorld));
1144 EraseRect(&pictRect);
1145 DrawPicture(pictH, &pictRect);
1146 UnlockPixels(GetGWorldPixMap(tempGWorld));
1148 /* Restore GWorld */
1149 SetGWorld(saveGWorld, saveGDevice);
1156 static OSErr XDDSWCreateGWorldFromPict(
1157 GWorldPtr *pictGWorld,
1161 GWorldPtr saveGWorld;
1162 GDHandle saveGDevice;
1163 GWorldPtr tempGWorld;
1174 depth = td->pixelDepth;
1177 theGDH = td->theGDH;
1179 /* Obtain size rectangle */
1181 pictRect.right = td->size_wid;
1183 pictRect.bottom = td->tile_hgt;
1185 /* Create a GWorld */
1186 err = NewGWorld(&tempGWorld, 0, &pictRect, 0, 0, 0);
1195 *pictGWorld = tempGWorld;
1198 GetGWorld(&saveGWorld, &saveGDevice);
1201 SetGWorld(tempGWorld, nil);
1203 /* Dump the pict into the GWorld
1204 (void)LockPixels(GetGWorldPixMap(tempGWorld));
1205 EraseRect(&pictRect);
1206 // DrawPicture(pictH, &pictRect);
1207 UnlockPixels(GetGWorldPixMap(tempGWorld));
1209 /* Restore GWorld */
1210 SetGWorld(saveGWorld, saveGDevice);
1216 static OSErr XDDSWUpDateGWorldFromPict( term_data *td )
1218 GWorldPtr saveGWorld;
1219 GDHandle saveGDevice;
1224 GWorldFlags errflag;
1228 if( td->bufferPort == NULL )
1231 depth = td->pixelDepth;
1234 theGDH = td->theGDH;
1236 /* Obtain size rectangle */
1239 pictRect.right = td->size_wid;
1240 pictRect.bottom = td->tile_hgt;
1242 XDDSWUnlockFrame(td);
1244 errflag = UpdateGWorld( &td->bufferPort, depth, &pictRect, 0, 0, 0);
1246 if( errflag & gwFlagErr ){
1253 GetGWorld(&saveGWorld, &saveGDevice);
1256 SetGWorld(td->bufferPort, nil);
1258 /* Dump the pict into the GWorld */
1259 (void)LockPixels(GetGWorldPixMap(td->bufferPort));
1260 EraseRect(&td->bufferPort->portRect);
1262 UnlockPixels(GetGWorldPixMap(td->bufferPort));
1264 /* Restore GWorld */
1265 SetGWorld(saveGWorld, saveGDevice);
1271 * Init the global "frameP"
1274 static errr globe_init(void)
1278 GWorldPtr tempPictGWorldP;
1282 /* Use window XXX XXX XXX */
1286 /* Get the pict resource */
1287 newPictH = GetPicture(pictID);
1289 /* Analyze result */
1290 err = (newPictH ? 0 : -1);
1297 err = BenSWCreateGWorldFromPict(&tempPictGWorldP, newPictH);
1299 /* Release resource */
1300 ReleaseResource((Handle)newPictH);
1305 /* Create the frame */
1306 frameP = (FrameRec*)NewPtrClear((Size)sizeof(FrameRec));
1308 /* Analyze result */
1309 err = (frameP ? 0 : -1);
1315 frameP->framePort = tempPictGWorldP;
1318 BenSWLockFrame(frameP);
1329 * Nuke the global "frameP"
1331 static errr globe_nuke(void)
1337 BenSWUnlockFrame(frameP);
1339 /* Dispose of the GWorld */
1340 DisposeGWorld(frameP->framePort);
1342 /* Dispose of the memory */
1343 DisposePtr((Ptr)frameP);
1350 FlushEvents(everyEvent, 0);
1357 #endif /* ANGBAND_LITE_MAC */
1361 /*** Support for the "z-term.c" package ***/
1365 * Initialize a new Term
1367 * Note also the "window type" called "noGrowDocProc", which might be more
1368 * appropriate for the main "screen" window.
1370 * Note the use of "srcCopy" mode for optimized screen writes.
1372 static void Term_init_mac(term *t)
1374 term_data *td = (term_data*)(t->data);
1376 static RGBColor black = {0x0000,0x0000,0x0000};
1377 static RGBColor white = {0xFFFF,0xFFFF,0xFFFF};
1379 #ifdef ANGBAND_LITE_MAC
1381 /* Make the window */
1382 td->w = NewWindow(0, &td->r, td->title, 0, noGrowDocProc, (WindowPtr)-1, 1, 0L);
1384 #else /* ANGBAND_LITE_MAC */
1386 /* Make the window */
1387 td->w = NewCWindow(0, &td->r, td->title, 0, documentProc, (WindowPtr)-1, 1, 0L);
1389 #endif /* ANGBAND_LITE_MAC */
1391 /* Activate the window */
1394 /* Erase behind words */
1397 /* Apply and Verify */
1398 term_data_check_font(td);
1399 term_data_check_size(td);
1401 /* Resize the window */
1402 term_data_resize(td);
1404 #ifdef ANGBAND_LITE_MAC
1406 /* Prepare the colors (base colors) */
1407 BackColor(blackColor);
1408 ForeColor(whiteColor);
1410 #else /* ANGBAND_LITE_MAC */
1412 /* Prepare the colors (real colors) */
1413 RGBBackColor(&black);
1414 RGBForeColor(&white);
1421 GDHandle currentGDH;
1422 GWorldPtr windowGWorld;
1423 PixMapHandle basePixMap;
1425 /* Obtain the rect */
1426 tempRect = td->w->portRect;
1428 /* Obtain the global rect */
1429 globalRect = tempRect;
1430 LocalToGlobal((Point*)&globalRect.top);
1431 LocalToGlobal((Point*)&globalRect.bottom);
1433 /* Obtain the proper GDH */
1434 mainGDH = GetMaxDevice(&globalRect);
1436 /* Extract GWorld and GDH */
1437 GetGWorld(&windowGWorld, ¤tGDH);
1439 /* Obtain base pixmap */
1440 basePixMap = (**mainGDH).gdPMap;
1442 /* Save pixel depth */
1443 td->pixelDepth = (**basePixMap).pixelSize;
1445 /* Save Window GWorld */
1446 td->theGWorld = windowGWorld;
1448 /* Save Window GDH */
1449 td->theGDH = currentGDH;
1452 td->mainSWGDH = mainGDH;
1455 #endif /* ANGBAND_LITE_MAC */
1457 /* Clip to the window */
1458 ClipRect(&td->w->portRect);
1460 /* Erase the window */
1461 EraseRect(&td->w->portRect);
1463 /* Invalidate the window */
1464 InvalRect(&td->w->portRect);
1466 /* Display the window if needed */
1467 if (td->mapped) ShowWindow(td->w);
1469 /* Hack -- set "mapped" flag */
1470 t->mapped_flag = td->mapped;
1474 XDDSWCreateGWorldFromPict( &td->bufferPort, td );
1476 XDDSWLockFrame( td );
1478 /* if (err == noErr)
1489 static void Term_nuke_mac(term *t)
1502 static errr Term_user_mac(int n)
1516 static errr Term_xtra_mac_react(void)
1518 term_data *td = (term_data*)(Term->data);
1524 #ifdef ANGBAND_LITE_MAC
1528 #else /* ANGBAND_LITE_MAC */
1531 if (use_sound != arg_sound)
1534 use_sound = arg_sound;
1538 /* Handle transparency */
1539 if (use_newstyle_graphics != arg_newstyle_graphics)
1543 if (globe_init() != 0)
1545 plog("Cannot initialize graphics!");
1546 arg_graphics = FALSE;
1547 arg_newstyle_graphics = FALSE;
1551 use_newstyle_graphics = arg_newstyle_graphics;
1553 /* Apply and Verify */
1554 term_data_check_size(td);
1556 /* Resize the window */
1557 term_data_resize(td);
1563 /* Handle graphics */
1564 if (use_graphics != arg_graphics)
1566 /* Initialize graphics */
1568 if (!use_graphics && !frameP && (globe_init() != 0))
1571 plog("¥°¥é¥Õ¥£¥Ã¥¯¤Î½é´ü²½¤Ï½ÐÍè¤Þ¤»¤ó¤Ç¤·¤¿.");
1573 plog("Cannot initialize graphics!");
1575 arg_graphics = FALSE;
1579 use_graphics = arg_graphics;
1581 /* Apply and Verify */
1582 term_data_check_size(td);
1584 /* Resize the window */
1585 term_data_resize(td);
1591 #endif /* ANGBAND_LITE_MAC */
1599 * Do a "special thing"
1601 static errr Term_xtra_mac(int n, int v)
1603 term_data *td = (term_data*)(Term->data);
1611 case TERM_XTRA_NOISE:
1620 #ifdef ANGBAND_LITE_MAC
1624 #else /* ANGBAND_LITE_MAC */
1627 case TERM_XTRA_SOUND:
1637 /* Open the resource file */
1638 oldResFile = CurResFile();
1639 newResFile = OpenResFile(sound);
1641 /* Close the resource file */
1642 CloseResFile(newResFile);
1643 UseResFile(oldResFile);
1646 /* Get the proper sound name */
1647 sprintf((char*)sound + 1, "%.16s.wav", angband_sound_name[v]);
1648 sound[0] = strlen((char*)sound + 1);
1650 /* Obtain resource XXX XXX XXX */
1651 handle = Get1NamedResource('snd ', sound);
1652 if( handle == NULL || ext_sound )
1653 handle = GetNamedResource('snd ', sound);
1656 if (handle && soundmode[soundchoice[v]] == true)
1659 LoadResource(handle);
1662 /* Play sound (wait for completion) */
1663 SndPlay(nil, (SndListHandle)handle, true);
1665 /* Unlock and release */
1667 ReleaseResource(handle);
1673 #endif /* ANGBAND_LITE_MAC */
1675 /* Process random events */
1676 case TERM_XTRA_BORED:
1678 /* Process an event */
1679 (void)CheckEvents(0);
1685 /* Process pending events */
1686 case TERM_XTRA_EVENT:
1688 /* Process an event */
1689 (void)CheckEvents(v);
1695 /* Flush all pending events (if any) */
1696 case TERM_XTRA_FLUSH:
1698 /* Hack -- flush all events */
1699 while (CheckEvents(TRUE)) /* loop */;
1705 /* Hack -- Change the "soft level" */
1706 case TERM_XTRA_LEVEL:
1708 /* Activate if requested */
1709 if (v) activate(td->w);
1715 /* Clear the screen */
1716 case TERM_XTRA_CLEAR:
1718 /* No clipping XXX XXX XXX */
1719 ClipRect(&td->w->portRect);
1721 /* Erase the window */
1722 EraseRect(&td->w->portRect);
1725 term_data_color(td, TERM_WHITE);
1727 /* Frame the window in white */
1729 LineTo(0, td->size_hgt-1);
1730 LineTo(td->size_wid-1, td->size_hgt-1);
1731 LineTo(td->size_wid-1, 0);
1733 /* Clip to the new size */
1734 r.left = td->w->portRect.left + td->size_ow1;
1735 r.top = td->w->portRect.top + td->size_oh1;
1736 r.right = td->w->portRect.right - td->size_ow2;
1737 r.bottom = td->w->portRect.bottom - td->size_oh2;
1744 /* React to changes */
1745 case TERM_XTRA_REACT:
1747 /* React to changes */
1748 return (Term_xtra_mac_react());
1751 /* Delay (milliseconds) */
1752 case TERM_XTRA_DELAY:
1757 long m = TickCount() + (v * 60L) / 1000;
1760 while (TickCount() < m) /* loop */;
1775 * Low level graphics (Assumes valid input).
1776 * Draw a "cursor" at (x,y), using a "yellow box".
1777 * We are allowed to use "Term_grab()" to determine
1778 * the current screen contents (for inverting, etc).
1780 static errr Term_curs_mac(int x, int y)
1784 term_data *td = (term_data*)(Term->data);
1787 term_data_color(td, TERM_YELLOW);
1789 /* Frame the grid */
1790 r.left = x * td->tile_wid + td->size_ow1;
1791 r.right = r.left + td->tile_wid;
1792 r.top = y * td->tile_hgt + td->size_oh1;
1793 r.bottom = r.top + td->tile_hgt;
1803 * Low level graphics (Assumes valid input).
1804 * Draw a "big cursor" at (x,y), using a "yellow box".
1805 * We are allowed to use "Term_grab()" to determine
1806 * the current screen contents (for inverting, etc).
1808 static errr Term_bigcurs_mac(int x, int y)
1812 term_data *td = (term_data*)(Term->data);
1815 term_data_color(td, TERM_YELLOW);
1817 /* Frame the grid */
1818 r.left = x * td->tile_wid + td->size_ow1;
1819 r.right = r.left + 2 * td->tile_wid;
1820 r.top = y * td->tile_hgt + td->size_oh1;
1821 r.bottom = r.top + td->tile_hgt;
1831 * Low level graphics (Assumes valid input)
1833 * Erase "n" characters starting at (x,y)
1835 static errr Term_wipe_mac(int x, int y, int n)
1839 term_data *td = (term_data*)(Term->data);
1841 /* Erase the block of characters */
1842 r.left = x * td->tile_wid + td->size_ow1;
1843 r.right = r.left + n * td->tile_wid;
1844 r.top = y * td->tile_hgt + td->size_oh1;
1845 r.bottom = r.top + td->tile_hgt;
1854 * Low level graphics. Assumes valid input.
1856 * Draw several ("n") chars, with an attr, at a given location.
1858 static errr Term_text_mac(int x, int y, int n, byte a, const char *cp)
1862 term_data *td = (term_data*)(Term->data);
1865 term_data_color(td, (a & 0x0F));
1867 /* Starting pixel */
1868 xp = x * td->tile_wid + td->tile_o_x + td->size_ow1;
1869 yp = y * td->tile_hgt + td->tile_o_y + td->size_oh1;
1871 /* Move to the correct location */
1874 /* Draw the character */
1875 if (n == 1) DrawChar(*cp);
1877 /* Draw the string */
1878 else DrawText(cp, 0, n);
1886 * Low level graphics (Assumes valid input)
1888 * Erase "n" characters starting at (x,y)
1890 #ifdef USE_TRANSPARENCY
1891 static errr Term_pict_mac(int x, int y, int n, const byte *ap, const char *cp,
1892 const byte *tap, const char *tcp)
1894 static errr Term_pict_mac(int x, int y, int n, const byte *ap, const char *cp)
1899 bool use_buffer = false;
1900 term_data *td = (term_data*)(Term->data);
1901 GDHandle saveGDevice;
1902 GWorldPtr saveGWorld;
1904 PixMapHandle PortPix;
1908 GetGWorld(&saveGWorld, &saveGDevice);
1912 /* Destination rectangle */
1913 r2.left = x * td->tile_wid + td->size_ow1;
1914 r2.right = r2.left + td->tile_wid;
1916 r2.bottom = r2.top + td->tile_hgt;
1919 SetGWorld(td->bufferPort, nil);
1920 PortPix = GetGWorldPixMap(td->bufferPort );
1921 LockPixels( PortPix );
1923 /* Instantiate font */
1924 TextFont(td->font_id);
1925 TextSize(td->font_size);
1926 TextFace(td->font_face);
1928 /* Restore colors */
1929 BackColor(blackColor);
1930 ForeColor(whiteColor);
1933 EraseRect(&td->bufferPort->portRect);
1939 /* Destination rectangle */
1940 r2.left = x * td->tile_wid + td->size_ow1;
1941 r2.top = y * td->tile_hgt + td->size_oh1;
1942 r2.bottom = r2.top + td->tile_hgt;
1944 /* no buffering, so we use the normal current port */
1949 /* Scan the input */
1950 for (i = 0; i < n; i++)
1957 /* Second byte of bigtile */
1958 if (use_bigtile && a == 255)
1961 r2.left += td->tile_wid;
1966 /* Prepare right of rectangle now */
1967 r2.right = r2.left + td->tile_wid;
1969 #ifdef ANGBAND_LITE_MAC
1973 #else /* ANGBAND_LITE_MAC */
1975 /* Graphics -- if Available and Needed */
1976 if (use_graphics && ((byte)a & 0x80) && ((byte)c & 0x80))
1978 BitMapPtr srcBitMap = (BitMapPtr)(frameP->framePix);
1979 BitMapPtr destBitMap;
1984 #ifdef USE_TRANSPARENCY
1986 bool terrain_flag = FALSE;
1990 if ((a != ta || c != tc) &&
1991 ((byte)ta & 0x80) && ((byte)tc & 0x80))
1994 row = ((byte)ta & 0x7F);
1995 col = ((byte)tc & 0x7F);
1997 /* Terrain Source rectangle */
1998 terrain_r.left = col * grafWidth;
1999 terrain_r.top = row * grafHeight;
2000 terrain_r.right = terrain_r.left + grafWidth;
2001 terrain_r.bottom = terrain_r.top + grafHeight;
2003 terrain_flag = TRUE;
2008 row = ((byte)a & 0x7F);
2009 col = ((byte)c & 0x7F);
2011 /* Source rectangle */
2012 r1.left = col * grafWidth;
2013 r1.top = row * grafHeight;
2014 r1.right = r1.left + grafWidth;
2015 r1.bottom = r1.top + grafHeight;
2017 /* Hardwire CopyBits */
2018 BackColor(whiteColor);
2019 ForeColor(blackColor);
2021 /* Draw the picture */
2024 destBitMap = (BitMapPtr)(td->bufferPix);
2026 destBitMap = (BitMapPtr)&(td->w->portBits);
2028 if (use_bigtile) r2.right += td->tile_wid;
2030 #ifdef USE_TRANSPARENCY
2034 * Source mode const = srcCopy:
2036 * determine how close the color of the source
2037 * pixel is to black, and assign this relative
2038 * amount of foreground color to the
2039 * destination pixel; determine how close the
2040 * color of the source pixel is to white, and
2041 * assign this relative amount of background
2042 * color to the destination pixel
2044 CopyBits( srcBitMap, destBitMap, &terrain_r, &r2, srcCopy, NULL );
2047 * Draw transparent tile
2048 * BackColor is ignored and the destination is
2051 BackColor(blackColor);
2052 CopyBits( srcBitMap, destBitMap, &r1, &r2, transparent, NULL );
2055 #endif /* USE_TRANSPARENCY */
2057 CopyBits( srcBitMap, destBitMap, &r1, &r2, srcCopy, NULL );
2060 /* Restore colors */
2061 BackColor(blackColor);
2062 ForeColor(whiteColor);
2071 #endif /* ANGBAND_LITE_MAC */
2079 term_data_color(td, (a & 0x0F));
2081 /* Starting pixel */
2082 xp = r2.left + td->tile_o_x;
2083 yp = r2.top + td->tile_o_y;
2085 /* Move to the correct location */
2091 /* Double width rectangle */
2092 r2.right += td->tile_wid;
2097 /* Draw the character */
2102 r2.left += td->tile_wid;
2110 /* Draw the character */
2116 r2.left += td->tile_wid;
2121 /* Now we blast the buffer pixmap onto the screen in the right place */
2122 BitMapPtr srcBitMap = (BitMapPtr)(td->bufferPix);
2124 BitMapPtr destBitMap = (BitMapPtr)&(td->w->portBits);
2130 srcRect.left = x * td->tile_wid + td->size_ow1;
2132 srcRect.right = srcRect.left + (td->tile_wid * n);
2133 srcRect.bottom = td->tile_hgt;
2135 destRect.left = x * td->tile_wid + td->size_ow1;
2136 destRect.right = destRect.left + (td->tile_wid * n);
2137 destRect.top = y * td->tile_hgt + td->size_oh1;
2138 destRect.bottom = destRect.top + td->tile_hgt;
2140 /* Double width rectangle */
2143 srcRect.right += td->tile_wid * n;
2144 destRect.right += td->tile_wid * n;
2147 UnlockPixels( PortPix );
2149 /* Restore GWorld */
2150 SetGWorld(saveGWorld, saveGDevice);
2152 /* Hardwire CopyBits */
2153 BackColor(whiteColor);
2154 ForeColor(blackColor);
2156 CopyBits( srcBitMap, destBitMap, &srcRect, &destRect, srcCopy, NULL );
2158 /* Restore colors */
2159 BackColor(blackColor);
2160 ForeColor(whiteColor);
2173 * Create and initialize window number "i"
2175 static void term_data_link(int i)
2179 term_data *td = &data[i];
2184 /* Require mapped */
2185 if (!td->mapped) return;
2190 /* Initialize the term */
2191 term_init(td->t, td->cols, td->rows, td->keys);
2193 /* Use a "software" cursor */
2194 td->t->soft_cursor = TRUE;
2196 /* Erase with "white space" */
2197 td->t->attr_blank = TERM_WHITE;
2198 td->t->char_blank = ' ';
2200 /* Prepare the init/nuke hooks */
2201 td->t->init_hook = Term_init_mac;
2202 td->t->nuke_hook = Term_nuke_mac;
2204 /* Prepare the function hooks */
2205 td->t->user_hook = Term_user_mac;
2206 td->t->xtra_hook = Term_xtra_mac;
2207 td->t->wipe_hook = Term_wipe_mac;
2208 td->t->curs_hook = Term_curs_mac;
2209 td->t->bigcurs_hook = Term_bigcurs_mac;
2210 td->t->text_hook = Term_text_mac;
2211 td->t->pict_hook = Term_pict_mac;
2213 /* Link the local structure */
2214 td->t->data = (vptr)(td);
2217 Term_activate(td->t);
2219 /* Global pointer */
2220 angband_term[i] = td->t;
2230 * Set the "current working directory" (also known as the "default"
2231 * volume/directory) to the location of the current application.
2233 * Code by: Maarten Hazewinkel (mmhazewi@cs.ruu.nl)
2235 * This function does not appear to work correctly with System 6.
2237 static void SetupAppDir(void)
2241 char errString[100];
2243 /* Get the location of the Angband executable */
2244 fcbBlock.ioCompletion = NULL;
2245 fcbBlock.ioNamePtr = NULL;
2246 fcbBlock.ioVRefNum = 0;
2247 fcbBlock.ioRefNum = CurResFile();
2248 fcbBlock.ioFCBIndx = 0;
2249 err = PBGetFCBInfo(&fcbBlock, FALSE);
2253 sprintf(errString, "PBGetFCBInfo ¥¨¥é¡¼ #%d.\r ½ªÎ»¤·¤Þ¤¹.", err);
2255 sprintf(errString, "Fatal PBGetFCBInfo Error #%d.\r Exiting.", err);
2257 mac_warning(errString);
2261 /* Extract the Vol and Dir */
2262 app_vol = fcbBlock.ioFCBVRefNum;
2263 app_dir = fcbBlock.ioFCBParID;
2265 /* Set the current working directory to that location */
2266 err = HSetVol(NULL, app_vol, app_dir);
2270 sprintf(errString, "HSetVol ¥¨¥é¡¼ #%d.\r ½ªÎ»¤·¤Þ¤¹.", err);
2272 sprintf(errString, "Fatal HSetVol Error #%d.\r Exiting.", err);
2274 mac_warning(errString);
2283 * Global "preference" file pointer
2288 * Read a "short" from the file
2290 static int getshort(void)
2294 if (0 == my_fgets(fff, buf, 256)) x = atoi(buf);
2299 * Dump a "short" to the file
2301 static void putshort(int x)
2303 fprintf(fff, "%d\n", x);
2309 * Write the "preference" data to the current "file"
2311 static void save_prefs(void)
2318 /*** The current version ***/
2320 putshort(FAKE_VERSION);
2321 putshort(FAKE_VER_MAJOR);
2322 putshort(FAKE_VER_MINOR);
2323 putshort(FAKE_VER_PATCH);
2325 putshort(arg_sound);
2326 putshort(arg_graphics);
2327 putshort(arg_newstyle_graphics);
2328 putshort(arg_bigtile);
2331 for( i = 0 ; i < 7 ; i++ )
2332 putshort(soundmode[i]);
2335 for (i = 0; i < MAX_TERM_DATA; i++)
2340 putshort(td->mapped);
2342 putshort(td->font_id);
2343 putshort(td->font_size);
2344 putshort(td->font_face);
2346 putshort(td->tile_wid);
2347 putshort(td->tile_hgt);
2352 putshort(td->r.left);
2353 putshort(td->r.top);
2359 * Load the preferences from the current "file"
2361 * XXX XXX XXX Being able to undefine various windows is
2362 * slightly bizarre, and may cause problems.
2364 static void load_prefs(void)
2368 int old_version, old_major, old_minor, old_patch;
2373 /*** Version information ***/
2375 /* Preferences version */
2376 old_version = getshort();
2377 old_major = getshort();
2378 old_minor = getshort();
2379 old_patch = getshort();
2381 /* Hack -- Verify or ignore */
2382 if ((old_version != FAKE_VERSION) ||
2383 (old_major != FAKE_VER_MAJOR) ||
2384 (old_minor != FAKE_VER_MINOR) ||
2385 (old_patch != FAKE_VER_PATCH))
2389 mac_warning("¸Å¤¤½é´üÀßÄê¥Õ¥¡¥¤¥ë¤ò̵»ë¤·¤Þ¤¹.");
2391 mac_warning("Ignoring old preferences.");
2397 arg_sound = getshort();
2398 arg_graphics = getshort();
2399 arg_newstyle_graphics = getshort();
2400 use_newstyle_graphics = arg_newstyle_graphics;
2402 if (use_newstyle_graphics == true)
2404 ANGBAND_GRAF = "new";
2405 arg_newstyle_graphics = true;
2406 grafWidth = grafHeight = 16;
2411 ANGBAND_GRAF = "old";
2412 arg_newstyle_graphics = false;
2413 grafWidth = grafHeight = 8;
2417 arg_bigtile = getshort();
2418 use_bigtile = arg_bigtile;
2421 for( i = 0 ; i < 7 ; i++ )
2422 soundmode[i] = getshort();
2425 m = GetMenuHandle(134); //m = GetMHandle(134);
2427 /* Item "arg_sound" */
2428 CheckItem(m, 1, arg_sound);
2430 /* Item "arg_graphics" */
2431 CheckItem(m, 2, arg_graphics);
2433 /* Item "arg_newstyle_graphics"*/
2434 CheckItem(m, 8, arg_newstyle_graphics);
2437 for (i = 0; i < MAX_TERM_DATA; i++)
2442 td->mapped = getshort();
2444 td->font_id = getshort();
2445 td->font_size = getshort();
2446 td->font_face = getshort();
2448 td->tile_wid = getshort();
2449 td->tile_hgt = getshort();
2451 td->cols = getshort();
2452 td->rows = getshort();
2454 td->r.left = getshort();
2455 td->r.top = getshort();
2458 if (feof(fff)) break;
2466 * Hack -- default data for a window
2468 static void term_data_hack(term_data *td)
2473 GetFNum( "\pÅùÉýÌÀÄ«", &fid); /* ¥Õ¥©¥ó¥È̾¤«¤éIDÈÖ¹æ¤òÄ´¤Ù¤ë */
2474 SetFScaleDisable( true );
2476 /* Default to Monaco font */
2477 GetFNum("\pmonaco", &fid);
2480 WIPE(td, term_data);
2485 /* Default borders */
2496 /* Default font size */
2499 /* Default font face */
2506 /* Default position */
2516 * Read the preference file, Create the windows.
2518 * We attempt to use "FindFolder()" to track down the preference file,
2519 * but if this fails, for any reason, we will try the "SysEnvirons()"
2520 * method, which may work better with System 6.
2522 static void init_windows(void)
2535 /*** Default values ***/
2537 /* Initialize (backwards) */
2538 for (i = MAX_TERM_DATA - 1; i >= 0; i--)
2551 s = angband_term_name[i];
2556 /* Maximal length */
2559 /* Copy the title */
2560 strncpy((char*)(td->title) + 1, s, n);
2562 /* Save the length */
2565 /* Tile the windows */
2566 td->r.left += (b * 30);
2567 td->r.top += (b * 30);
2574 /*** Load preferences ***/
2576 /* Assume failure */
2579 /* Assume failure */
2592 /* Find the folder */
2593 err = FindFolder(kOnSystemDisk, kPreferencesFolderType, kCreateFolder,
2599 /* Extract a path name */
2600 PathNameFromDirID(dirID, vref, (StringPtr)foo);
2602 /* Convert the string */
2603 ptocstr((StringPtr)foo);
2605 /* Append the preference file name */
2606 strcat(foo, PREF_FILE_NAME);
2608 /* Open the preference file */
2609 fff = fopen(foo, "r");
2616 #endif /* USE_SFL_CODE */
2622 HGetVol(0, &savev, &saved);
2624 /* Go to the "system" folder */
2625 SysEnvirons(curSysEnvVers, &env);
2626 SetVol(0, env.sysVRefNum);
2629 fff = fopen(PREF_FILE_NAME, "r");
2632 HSetVol(0, savev, saved);
2635 /* Load preferences */
2638 /* Load a real preference file */
2641 /* Close the file */
2646 /*** Instantiate ***/
2657 /* Link (backwards, for stacking order) */
2658 for (i = MAX_TERM_DATA - 1; i >= 0; i--)
2667 Term_activate(td->t);
2670 static void init_sound( void )
2674 SignedByte permission = fsRdPerm;
2680 /* Descend into "lib" folder */
2681 pb.ioCompletion = NULL;
2682 pb.ioNamePtr = "\plib";
2683 pb.ioVRefNum = app_vol;
2684 pb.ioDrDirID = app_dir;
2687 /* Check for errors */
2688 err = PBGetCatInfo((CInfoPBPtr)&pb, FALSE);
2691 if ((err == noErr) && (pb.ioFlAttrib & 0x10))
2693 /* Descend into "lib/save" folder */
2694 pb.ioCompletion = NULL;
2695 pb.ioNamePtr = "\pxtra";
2696 pb.ioVRefNum = app_vol;
2697 pb.ioDrDirID = pb.ioDrDirID;
2700 /* Check for errors */
2701 err = PBGetCatInfo((CInfoPBPtr)&pb, FALSE);
2704 if ((err == noErr) && (pb.ioFlAttrib & 0x10))
2706 /* Descend into "lib/save" folder */
2707 pb.ioCompletion = NULL;
2708 pb.ioNamePtr = "\psound";
2709 pb.ioVRefNum = app_vol;
2710 pb.ioDrDirID = pb.ioDrDirID;
2713 /* Check for errors */
2714 err = PBGetCatInfo((CInfoPBPtr)&pb, FALSE);
2717 if ((err == noErr) && (pb.ioFlAttrib & 0x10))
2719 ret = HOpenResFile( app_vol , pb.ioDrDirID , "\psound.rsrc" , permission );
2723 for( i = 0 ; i < 7 ; i++ )
2724 soundmode[i] = false;
2726 for( i = 1 ; i < SOUND_MAX ; i++ ){
2727 /* Get the proper sound name */
2728 sprintf((char*)sound + 1, "%.16s.wav", angband_sound_name[i]);
2729 sound[0] = strlen((char*)sound + 1);
2731 /* Obtain resource XXX XXX XXX */
2732 handle = Get1NamedResource('snd ', sound);
2733 if( handle == NULL || ext_sound )
2734 handle = GetNamedResource('snd ', sound);
2737 soundmode[soundchoice[i]] = true;
2746 static void init_graf( void )
2750 SignedByte permission = fsRdPerm;
2756 /* Descend into "lib" folder */
2757 pb.ioCompletion = NULL;
2758 pb.ioNamePtr = "\plib";
2759 pb.ioVRefNum = app_vol;
2760 pb.ioDrDirID = app_dir;
2763 /* Check for errors */
2764 err = PBGetCatInfo((CInfoPBPtr)&pb, FALSE);
2767 if ((err == noErr) && (pb.ioFlAttrib & 0x10))
2769 /* Descend into "lib/xtra" folder */
2770 pb.ioCompletion = NULL;
2771 pb.ioNamePtr = "\pxtra";
2772 pb.ioVRefNum = app_vol;
2773 pb.ioDrDirID = pb.ioDrDirID;
2776 /* Check for errors */
2777 err = PBGetCatInfo((CInfoPBPtr)&pb, FALSE);
2780 if ((err == noErr) && (pb.ioFlAttrib & 0x10))
2782 /* Descend into "lib/xtra/graf" folder */
2783 pb.ioCompletion = NULL;
2784 pb.ioNamePtr = "\pgraf";
2785 pb.ioVRefNum = app_vol;
2786 pb.ioDrDirID = pb.ioDrDirID;
2789 /* Check for errors */
2790 err = PBGetCatInfo((CInfoPBPtr)&pb, FALSE);
2793 if ((err == noErr) && (pb.ioFlAttrib & 0x10))
2795 ret = HOpenResFile( app_vol , pb.ioDrDirID , "\pgraf.rsrc" , permission );
2800 /* Obtain resource XXX XXX XXX */
2801 handle = Get1NamedResource('PICT', graf);
2802 if ( handle == NULL || ext_graf )
2803 handle = GetNamedResource('PICT', graf);
2814 static void init_chuukei( void )
2820 path_build(path, 1024, ANGBAND_DIR_XTRA, "chuukei.txt");
2822 fp = fopen(path, "r");
2827 if (fgets(tmp, 1024, fp)){
2829 int n = strlen(tmp);
2835 chuukei_server = TRUE;
2836 if(connect_chuukei_server(&tmp[2])<0){
2837 msg_print("connect fail");
2840 msg_print("connect");
2847 chuukei_client = TRUE;
2848 connect_chuukei_server(&tmp[2]);
2864 short InevrtCheck( DialogPtr targetDlg, short check )
2871 GetDialogItem( targetDlg, check, &itemType, &checkH, &box );
2872 result = (GetControlValue( (ControlHandle)checkH ) + 1 ) % 2;
2873 SetControlValue( (ControlHandle)checkH , result );
2881 short SetCheck( DialogPtr targetDlg, short check, long result )
2888 GetDialogItem( targetDlg, check, &itemType, &checkH, &box );
2889 SetControlValue( (ControlHandle)checkH , result );
2897 short GetCheck( DialogPtr targetDlg, short check )
2904 GetDialogItem( targetDlg, check, &itemType, &checkH, &box );
2905 result = GetControlValue( (ControlHandle)checkH );
2909 void SoundConfigDLog(void)
2916 dialog=GetNewDialog(131, 0, (WindowPtr)-1);
2917 SetDialogDefaultItem( dialog, ok );
2918 SetDialogCancelItem( dialog, cancel );
2919 for( i = 1 ; i < 7 ; i++ )
2920 SetCheck( dialog, i+2 , soundmode[i] );
2923 for( item_hit = 100 ; cancel < item_hit ; ){
2924 ModalDialog(0, &item_hit);
2928 for( i = 1 ; i < 7 ; i++ )
2929 soundmode[i] = GetCheck( dialog, i+2 );
2934 InevrtCheck( dialog, item_hit );
2937 DisposeDialog(dialog);
2945 static void save_pref_file(void)
2954 /* Assume failure */
2957 /* Assume failure */
2974 /* Find the folder */
2975 err = FindFolder(kOnSystemDisk, kPreferencesFolderType, kCreateFolder,
2981 /* Extract a path name */
2982 PathNameFromDirID(dirID, vref, (StringPtr)foo);
2984 /* Convert the string */
2985 ptocstr((StringPtr)foo);
2987 /* Append the preference file name */
2988 strcat(foo, PREF_FILE_NAME);
2990 /* Open the preference file */
2991 /* my_fopen set file type and file creator for MPW */
2992 fff = my_fopen(foo, "w");
2999 #endif /* USE_SFL_CODE */
3005 HGetVol(0, &savev, &saved);
3007 /* Go to "system" folder */
3008 SysEnvirons(curSysEnvVers, &env);
3009 SetVol(0, env.sysVRefNum);
3011 /* Open the preference file */
3012 /* my_fopen set file type and file creator for MPW */
3013 fff = fopen(PREF_FILE_NAME, "w");
3016 HSetVol(0, savev, saved);
3019 /* Save preferences */
3022 /* Write the preferences */
3033 * A simple "Yes/No" filter to parse "key press" events in dialog windows
3035 static pascal Boolean ynfilter(DialogPtr dialog, EventRecord *event, short *ip)
3037 /* Parse key press events */
3038 if (event->what == keyDown)
3043 /* Extract the pressed key */
3044 c = (event->message & charCodeMask);
3046 /* Accept "no" and <return> and <enter> */
3047 if ((c=='n') || (c=='N') || (c==13) || (c==3)) i = 1;
3050 else if ((c=='y') || (c=='Y')) i = 2;
3052 /* Handle "yes" or "no" */
3056 ControlHandle control;
3059 /* Get the button */
3060 GetDialogItem(dialog, i, &type, (Handle*)&control, &r); //GetDItem(dialog, i, &type, (Handle*)&control, &r);
3062 /* Blink button for 1/10 second */
3063 HiliteControl(control, 1);
3064 Term_xtra_mac(TERM_XTRA_DELAY, 100);
3065 HiliteControl(control, 0);
3079 * Handle menu: "File" + "New"
3081 static void do_menu_file_new(void)
3086 /* Game is in progress */
3087 game_in_progress = 1;
3101 * Handle menu: "File" + "Open"
3103 static void do_menu_file_open(bool all)
3117 /* vrefnum = GetSFCurVol(); */
3118 vrefnum = -*((short*)0x214);
3120 /* drefnum = GetSFCurDir(); */
3121 drefnum = *((long*)0x398);
3123 /* Descend into "lib" folder */
3124 pb.ioCompletion = NULL;
3125 pb.ioNamePtr = "\plib";
3126 pb.ioVRefNum = vrefnum;
3127 pb.ioDrDirID = drefnum;
3130 /* Check for errors */
3131 err = PBGetCatInfo((CInfoPBPtr)&pb, FALSE);
3134 if ((err == noErr) && (pb.ioFlAttrib & 0x10))
3136 /* Descend into "lib/save" folder */
3137 pb.ioCompletion = NULL;
3138 pb.ioNamePtr = "\psave";
3139 pb.ioVRefNum = vrefnum;
3140 pb.ioDrDirID = pb.ioDrDirID;
3143 /* Check for errors */
3144 err = PBGetCatInfo((CInfoPBPtr)&pb, FALSE);
3147 if ((err == noErr) && (pb.ioFlAttrib & 0x10))
3149 /* SetSFCurDir(pb.ioDrDirID); */
3150 *((long*)0x398) = pb.ioDrDirID;
3154 /* Window location */
3155 topleft.h = (qd.screenBits.bounds.left+qd.screenBits.bounds.right)/2-344/2;
3156 topleft.v = (2*qd.screenBits.bounds.top+qd.screenBits.bounds.bottom)/3-188/2;
3158 /* Allow "all" files */
3162 SFGetFile(topleft, "\p", NULL, -1, types, NULL, &reply);
3165 /* Allow "save" files */
3172 SFGetFile(topleft, "\p", NULL, 1, types, NULL, &reply);
3176 if (!reply.good) return;
3178 /* Extract textual file name for save file */
3179 GetWDInfo(reply.vRefNum, &vrefnum, &drefnum, &junk);
3180 refnum_to_name(savefile, drefnum, vrefnum, (char*)reply.fName);
3185 /* Game is in progress */
3186 game_in_progress = 1;
3200 * Handle the "open_when_ready" flag
3202 static void handle_open_when_ready(void)
3204 /* Check the flag XXX XXX XXX make a function for this */
3205 if (open_when_ready && initialized && !game_in_progress)
3208 open_when_ready = FALSE;
3210 /* Game is in progress */
3211 game_in_progress = 1;
3230 * Initialize the menus
3232 * Verify menus 128, 129, 130
3233 * Create menus 131, 132, 133, 134
3235 * The standard menus are:
3237 * Apple (128) = { About, -, ... }
3238 * File (129) = { New,Open,Import,Close,Save,-,Exit,Quit }
3239 * Edit (130) = { Cut, Copy, Paste, Clear } (?)
3240 * Font (131) = { Bold, Extend, -, Monaco, ..., -, ... }
3241 * Size (132) = { ... }
3242 * Window (133) = { Angband, Mirror, Recall, Choice,
3243 * Term-4, Term-5, Term-6, Term-7 }
3244 * Special (134) = { arg_sound, arg_graphics, -,
3245 * arg_fiddle, arg_wizard }
3247 static void init_menubar(void)
3258 /* Get the "apple" menu */
3261 /* Insert the menu */
3264 /* Add the DA's to the "apple" menu */
3265 AppendResMenu (m, 'DRVR'); //AddResMenu(m, 'DRVR');
3268 /* Get the "File" menu */
3271 /* Insert the menu */
3275 /* Get the "Edit" menu */
3278 /* Insert the menu */
3282 /* Make the "Font" menu */
3284 m = NewMenu(131, "\p¥Õ¥©¥ó¥È");
3286 m = NewMenu(131, "\pFont");
3289 /* Insert the menu */
3293 AppendMenu(m, "\pBold");
3296 AppendMenu(m, "\pWide");
3298 /* Add a separator */
3299 AppendMenu(m, "\p-");
3302 r.left = r.right = r.top = r.bottom = 0;
3304 /* Make the fake window */
3305 tmpw = NewWindow(0, &r, "\p", false, documentProc, 0, 0, 0);
3307 /* Activate the "fake" window */
3316 /* Add the fonts to the menu */
3317 AppendResMenu(m, 'FONT'); //AddResMenu(m, 'FONT');
3323 for (i = n; i >= 4; i--)
3328 /* Acquire the font name */
3329 /* GetMenuItemText(m, i, tmpName); */
3330 GetMenuItemText(m, i, tmpName); //GetItem(m, i, tmpName);
3332 /* Acquire the font index */
3333 GetFNum(tmpName, &fontNum);
3335 /* Apply the font index */
3338 /* Remove non-mono-spaced fonts */
3339 if ((CharWidth('i') != CharWidth('W')) || (CharWidth('W') == 0))
3341 /* Delete the menu item XXX XXX XXX */
3342 /* DeleteMenuItem(m, i); */
3343 DeleteMenuItem (m, i); //DelMenuItem(m, i);
3347 /* Destroy the old window */
3348 DisposeWindow(tmpw);
3350 /* Add a separator */
3351 AppendMenu(m, "\p-");
3353 /* Add the fonts to the menu */
3354 AppendResMenu (m, 'FONT'); //AddResMenu(m, 'FONT');
3357 /* Make the "Size" menu */
3359 m = NewMenu(132, "\p¥µ¥¤¥º");
3361 m = NewMenu(132, "\pSize");
3364 /* Insert the menu */
3367 /* Add some sizes (stagger choices) */
3368 for (i = 8; i <= 32; i += ((i / 16) + 1))
3373 sprintf((char*)buf + 1, "%d", i);
3374 buf[0] = strlen((char*)buf + 1);
3381 /* Make the "Windows" menu */
3383 m = NewMenu(133, "\p¥¦¥¤¥ó¥É¥¦");
3385 m = NewMenu(133, "\pWindows");
3388 /* Insert the menu */
3391 /* Default choices */
3392 for (i = 0; i < MAX_TERM_DATA; i++)
3396 /* Describe the item */
3397 sprintf((char*)buf + 1, "%.15s", angband_term_name[i]);
3398 buf[0] = strlen((char*)buf + 1);
3403 /* Command-Key shortcuts */
3404 if (i < 8) SetItemCmd(m, i + 1, '0' + i);
3408 /* Make the "Special" menu */
3410 m = NewMenu(134, "\pÆÃÊÌ");
3412 m = NewMenu(134, "\pSpecial");
3415 /* Insert the menu */
3418 /* Append the choices */
3420 AppendMenu(m, "\p¥µ¥¦¥ó¥É»ÈÍÑ");
3421 AppendMenu(m, "\p¥°¥é¥Õ¥£¥Ã¥¯»ÈÍÑ");
3422 AppendMenu(m, "\p-");
3423 AppendMenu(m, "\parg_fiddle");
3424 AppendMenu(m, "\parg_wizard");
3425 AppendMenu(m, "\p-");
3426 AppendMenu(m, "\p¥µ¥¦¥ó¥ÉÀßÄê...");
3427 AppendMenu(m, "\p16X16¥°¥é¥Õ¥£¥Ã¥¯");
3428 AppendMenu(m, "\p£²ÇÜÉý¥¿¥¤¥ëɽ¼¨");
3430 AppendMenu(m, "\parg_sound");
3431 AppendMenu(m, "\parg_graphics");
3432 AppendMenu(m, "\p-");
3433 AppendMenu(m, "\parg_fiddle");
3434 AppendMenu(m, "\parg_wizard");
3435 AppendMenu(m, "\p-");
3436 AppendMenu(m, "\pSound config");
3437 AppendMenu(m, "\pAdam Bolt tile");
3438 AppendMenu(m, "\pBigtile Mode");
3441 /* Make the "TileWidth" menu */
3443 m = NewMenu(135, "\p¥¿¥¤¥ëÉý");
3445 m = NewMenu(135, "\pTileWidth");
3448 /* Insert the menu */
3451 /* Add some sizes */
3452 for (i = 4; i <= 32; i++)
3457 sprintf((char*)buf + 1, "%d", i);
3458 buf[0] = strlen((char*)buf + 1);
3465 /* Make the "TileHeight" menu */
3467 m = NewMenu(136, "\p¥¿¥¤¥ë¹â");
3469 m = NewMenu(136, "\pTileHeight");
3472 /* Insert the menu */
3475 /* Add some sizes */
3476 for (i = 4; i <= 32; i++)
3481 sprintf((char*)buf + 1, "%d", i);
3482 buf[0] = strlen((char*)buf + 1);
3489 /* Update the menu bar */
3497 static void setup_menus(void)
3507 term_data *td = NULL;
3510 /* Relevant "term_data" */
3511 for (i = 0; i < MAX_TERM_DATA; i++)
3514 if (!data[i].t) continue;
3516 /* Notice the matching window */
3517 if (data[i].w == FrontWindow()) td = &data[i];
3522 m = GetMenuHandle(129); //m = GetMHandle(129);
3528 for (i = 1; i <= n; i++)
3532 CheckItem(m, i, FALSE);
3535 /* Enable "new"/"open..."/"import..." */
3536 if (initialized && !game_in_progress)
3543 /* Enable "close" */
3550 if (initialized && character_generated)
3563 m = GetMenuHandle(130); //m = GetMHandle(130);
3569 for (i = 1; i <= n; i++)
3573 CheckItem(m, i, FALSE);
3576 /* Enable "edit" options if "needed" */
3588 m = GetMenuHandle(131); //m = GetMHandle(131);
3594 for (i = 1; i <= n; i++)
3598 CheckItem(m, i, FALSE);
3601 /* Hack -- look cute XXX XXX */
3602 /* SetItemStyle(m, 1, bold); */
3604 /* Hack -- look cute XXX XXX */
3605 /* SetItemStyle(m, 2, extend); */
3613 /* Enable "extend" */
3616 /* Check the appropriate "bold-ness" */
3617 if (td->font_face & bold) CheckItem(m, 1, TRUE);
3619 /* Check the appropriate "wide-ness" */
3620 if (td->font_face & extend) CheckItem(m, 2, TRUE);
3623 for (i = 4; i <= n; i++)
3629 /* GetMenuItemText(m,i,s); */
3630 GetMenuItemText(m, i, s); //GetItem(m, i, s);
3633 /* Check active font */
3634 if (td->font_id == value) CheckItem(m, i, TRUE);
3640 m = GetMenuHandle(132); //m = GetMHandle(132);
3646 for (i = 1; i <= n; i++)
3650 CheckItem(m, i, FALSE);
3657 for (i = 1; i <= n; i++)
3660 /* GetMenuItemText(m,i,s); */
3661 GetMenuItemText(m, i, s); //GetItem(m, i, s);
3663 value = atoi((char*)(s+1));
3665 /* Enable the "real" sizes */
3666 if (RealFont(td->font_id, value)) EnableItem(m, i);
3668 /* Check the current size */
3669 if (td->font_size == value) CheckItem(m, i, TRUE);
3675 m = GetMenuHandle(133); //m = GetMHandle(133);
3680 /* Check active windows */
3681 for (i = 1; i <= n; i++)
3683 /* Check if needed */
3684 CheckItem(m, i, data[i-1].mapped);
3689 m = GetMenuHandle(134); //m = GetMHandle(134);
3695 for (i = 1; i <= n; i++)
3699 CheckItem(m, i, FALSE);
3702 /* Item "arg_sound" */
3704 CheckItem(m, 1, arg_sound);
3706 /* Item "arg_graphics" */
3708 CheckItem(m, 2, arg_graphics);
3710 /* Item "arg_fiddle" */
3712 CheckItem(m, 4, arg_fiddle);
3714 /* Item "arg_wizard" */
3716 CheckItem(m, 5, arg_wizard);
3718 /* Item "SoundSetting" */
3721 /* Item NewStyle Graphics */
3723 CheckItem(m, 8, use_newstyle_graphics);
3725 /* Item Bigtile Mode */
3727 CheckItem(m, 9, arg_bigtile);
3730 /* TileWidth menu */
3731 m = GetMenuHandle(135); //m = GetMHandle(135);
3737 for (i = 1; i <= n; i++)
3741 CheckItem(m, i, FALSE);
3748 for (i = 1; i <= n; i++)
3751 /* GetMenuItemText(m,i,s); */
3752 GetMenuItemText(m, i, s); //GetItem(m, i, s);
3754 value = atoi((char*)(s+1));
3759 /* Check the current size */
3760 if (td->tile_wid == value) CheckItem(m, i, TRUE);
3765 /* TileHeight menu */
3766 m = GetMenuHandle(136); //m = GetMHandle(136);
3772 for (i = 1; i <= n; i++)
3776 CheckItem(m, i, FALSE);
3783 for (i = 1; i <= n; i++)
3786 /* GetMenuItemText(m,i,s); */
3787 GetMenuItemText(m, i, s); //GetItem(m, i, s);
3789 value = atoi((char*)(s+1));
3794 /* Check the current size */
3795 if (td->tile_hgt == value) CheckItem(m, i, TRUE);
3802 * Process a menu selection (see above)
3804 * Hack -- assume that invalid menu selections are disabled above,
3805 * which I have been informed may not be reliable. XXX XXX XXX
3807 static void menu(long mc)
3811 int menuid, selection;
3813 static unsigned char s[1000];
3817 term_data *td = NULL;
3822 /* Analyze the menu command */
3823 menuid = HiWord(mc);
3824 selection = LoWord(mc);
3827 /* Find the window */
3828 for (i = 0; i < MAX_TERM_DATA; i++)
3830 /* Skip dead windows */
3831 if (!data[i].t) continue;
3833 /* Notice matches */
3834 if (data[i].w == FrontWindow()) td = &data[i];
3838 /* Branch on the menu */
3844 /* About Angband... */
3851 dialog=GetNewDialog(128, 0, (WindowPtr)-1);
3854 center_rect(&r, &qd.screenBits.bounds);
3855 MoveWindow(dialog, r.left, r.top, 1);
3857 ModalDialog(0, &item_hit);
3858 DisposeDialog(dialog); //DisposDialog(dialog);
3862 /* Desk accessory */
3863 /* GetMenuItemText(GetMHandle(128),selection,s); */
3864 GetMenuItemText(GetMenuHandle(128), selection, s); //GetItem(GetMHandle(128), selection, s);
3884 do_menu_file_open(FALSE);
3891 do_menu_file_open(TRUE);
3905 td->t->mapped_flag = FALSE;
3907 /* Hide the window */
3918 plog("º£¤Ï¥»¡¼¥Ö¤¹¤ë¤³¤È¤Ï½ÐÍè¤Þ¤»¤ó¡£");
3920 plog("You may not do that right now.");
3925 /* Hack -- Forget messages */
3928 /* Hack -- Save the game */
3929 do_cmd_save_game(FALSE);
3934 /* Quit (with save) */
3937 /* Save the game (if necessary) */
3938 if (game_in_progress && character_generated)
3942 plog("º£¤Ï¥»¡¼¥Ö¤¹¤ë¤³¤È¤Ï½ÐÍè¤Þ¤»¤ó¡£");
3944 plog("You may not do that right now.");
3948 /* Hack -- Forget messages */
3953 do_cmd_save_game(FALSE);
3955 Term_key_push(SPECIAL_KEY_QUIT);
3977 /* Require a window */
3986 /* Toggle the "bold" setting */
3989 /* Toggle the setting */
3990 if (td->font_face & bold)
3992 td->font_face &= ~bold;
3996 td->font_face |= bold;
3999 /* Tile Width Hight Init */
4000 td->tile_wid = td->tile_hgt = 0;
4002 /* Apply and Verify */
4003 term_data_check_font(td);
4004 term_data_check_size(td);
4006 /* Resize and Redraw */
4007 term_data_resize(td);
4008 term_data_redraw(td);
4013 /* Toggle the "wide" setting */
4016 /* Toggle the setting */
4017 if (td->font_face & extend)
4019 td->font_face &= ~extend;
4023 td->font_face |= extend;
4026 /* Tile Width Hight Init */
4027 td->tile_wid = td->tile_hgt = 0;
4029 /* Apply and Verify */
4030 term_data_check_font(td);
4031 term_data_check_size(td);
4033 /* Resize and Redraw */
4034 term_data_resize(td);
4035 term_data_redraw(td);
4040 /* Get a new font name */
4041 /* GetMenuItemText(GetMHandle(131), selection, s); */
4042 GetMenuItemText(GetMenuHandle(131), selection, s); //GetItem(GetMHandle(131), selection, s);
4045 /* Save the new font id */
4048 /* Current size is bad for new font */
4049 if (!RealFont(td->font_id, td->font_size))
4051 /* Find similar size */
4052 for (i = 1; i <= 32; i++)
4054 /* Adjust smaller */
4055 if (td->font_size - i >= 8)
4057 if (RealFont(td->font_id, td->font_size - i))
4065 if (td->font_size + i <= 128)
4067 if (RealFont(td->font_id, td->font_size + i))
4076 /* Tile Width Hight Init */
4077 td->tile_wid = td->tile_hgt = 0;
4079 /* Apply and Verify */
4080 term_data_check_font(td);
4081 term_data_check_size(td);
4083 /* Resize and Redraw */
4084 term_data_resize(td);
4085 term_data_redraw(td);
4087 /* Restore the window */
4104 /* GetMenuItemText(GetMHandle(132), selection, s); */
4105 GetMenuItemText(GetMenuHandle(132), selection, s); //GetItem(GetMHandle(132), selection, s);
4107 td->font_size = atoi((char*)(s+1));
4109 /* Tile Width Hight Init */
4110 td->tile_wid = td->tile_hgt = 0;
4112 /* Apply and Verify */
4113 term_data_check_font(td);
4114 term_data_check_size(td);
4116 /* Resize and Redraw */
4117 term_data_resize(td);
4118 term_data_redraw(td);
4132 /* Check legality of choice */
4133 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
4135 /* Obtain the window */
4145 td->t->mapped_flag = TRUE;
4147 /* Show the window */
4150 /* Bring to the front */
4151 SelectWindow(td->w);
4163 /* Toggle arg_sound */
4164 arg_sound = !arg_sound;
4166 /* React to changes */
4167 Term_xtra(TERM_XTRA_REACT, 0);
4174 /* Toggle arg_graphics */
4175 arg_graphics = !arg_graphics;
4176 if( arg_graphics == true ){
4177 ANGBAND_GRAF = "old";
4178 arg_newstyle_graphics = false;
4179 grafWidth = grafHeight = 8;
4182 /* Hack -- Force redraw */
4183 Term_key_push(KTRL('R'));
4190 arg_fiddle = !arg_fiddle;
4196 arg_wizard = !arg_wizard;
4207 if (streq(ANGBAND_GRAF, "old"))
4209 ANGBAND_GRAF = "new";
4210 arg_newstyle_graphics = true;
4211 grafWidth = grafHeight = 16;
4216 ANGBAND_GRAF = "old";
4217 arg_newstyle_graphics = false;
4218 grafWidth = grafHeight = 8;
4222 /* Hack -- Force redraw */
4223 Term_key_push(KTRL('R'));
4227 case 9: /* bigtile mode */
4229 term_data *td = &data[0];
4233 plog("º£¤ÏÊѹ¹½ÐÍè¤Þ¤»¤ó¡£");
4235 plog("You may not do that right now.");
4240 /* Toggle "arg_bigtile" */
4241 arg_bigtile = !arg_bigtile;
4244 Term_activate(td->t);
4246 /* Resize the term */
4247 Term_resize(td->cols, td->rows);
4257 /* TileWidth menu */
4268 /* GetMenuItemText(GetMHandle(135), selection, s); */
4269 GetMenuItemText(GetMenuHandle(135), selection, s); //GetItem(GetMHandle(135), selection, s);
4271 td->tile_wid = atoi((char*)(s+1));
4273 /* Apply and Verify */
4274 term_data_check_size(td);
4276 /* Resize and Redraw */
4277 term_data_resize(td);
4278 term_data_redraw(td);
4286 /* TileHeight menu */
4297 /* GetMenuItemText(GetMHandle(136), selection, s); */
4298 GetMenuItemText(GetMenuHandle(136), selection, s); //GetItem(GetMHandle(136), selection, s);
4300 td->tile_hgt = atoi((char*)(s+1));
4302 /* Apply and Verify */
4303 term_data_check_size(td);
4305 /* Resize and Redraw */
4306 term_data_resize(td);
4307 term_data_redraw(td);
4317 /* Clean the menu */
4326 * Check for extra required parameters -- From "Maarten Hazewinkel"
4328 static OSErr CheckRequiredAEParams(const AppleEvent *theAppleEvent)
4331 DescType returnedType;
4334 aeError = AEGetAttributePtr(theAppleEvent, keyMissedKeywordAttr, typeWildCard,
4335 &returnedType, NULL, 0, &actualSize);
4337 if (aeError == errAEDescNotFound) return (noErr);
4339 if (aeError == noErr) return (errAEParamMissed);
4346 * Apple Event Handler -- Open Application
4348 static pascal OSErr AEH_Start(const AppleEvent *theAppleEvent,
4349 const AppleEvent *reply, long handlerRefCon)
4351 #pragma unused(reply, handlerRefCon)
4353 return (CheckRequiredAEParams(theAppleEvent));
4358 * Apple Event Handler -- Quit Application
4360 static pascal OSErr AEH_Quit(const AppleEvent *theAppleEvent,
4361 const AppleEvent *reply, long handlerRefCon)
4363 #pragma unused(reply, handlerRefCon)
4366 quit_when_ready = TRUE;
4368 /* Check arguments */
4369 return (CheckRequiredAEParams(theAppleEvent));
4374 * Apple Event Handler -- Print Documents
4376 static pascal OSErr AEH_Print(const AppleEvent *theAppleEvent,
4377 const AppleEvent *reply, long handlerRefCon)
4379 #pragma unused(theAppleEvent, reply, handlerRefCon)
4381 return (errAEEventNotHandled);
4386 * Apple Event Handler by Steve Linberg (slinberg@crocker.com).
4388 * The old method of opening savefiles from the finder does not work
4389 * on the Power Macintosh, because CountAppFiles and GetAppFiles,
4390 * used to return information about the selected document files when
4391 * an application is launched, are part of the Segment Loader, which
4392 * is not present in the RISC OS due to the new memory architecture.
4394 * The "correct" way to do this is with AppleEvents. The following
4395 * code is modeled on the "Getting Files Selected from the Finder"
4396 * snippet from Think Reference 2.0. (The prior sentence could read
4397 * "shamelessly swiped & hacked")
4399 static pascal OSErr AEH_Open(AppleEvent *theAppleEvent,
4400 AppleEvent* reply, long handlerRefCon)
4402 #pragma unused(reply, handlerRefCon)
4409 DescType returnedType;
4413 /* Put the direct parameter (a descriptor list) into a docList */
4414 err = AEGetParamDesc(theAppleEvent, keyDirectObject, typeAEList, &docList);
4415 if (err) return err;
4418 * We ignore the validity check, because we trust the FInder, and we only
4419 * allow one savefile to be opened, so we ignore the depth of the list.
4422 err = AEGetNthPtr(&docList, 1L, typeFSS, &keywd,
4423 &returnedType, (Ptr) &myFSS, sizeof(myFSS), &actualSize);
4424 if (err) return err;
4426 /* Only needed to check savefile type below */
4427 err = FSpGetFInfo(&myFSS, &myFileInfo);
4430 sprintf(foo, "Arg! FSpGetFInfo failed with code %d", err);
4435 /* Ignore non 'SAVE' files */
4436 if (myFileInfo.fdType != 'SAVE') return noErr;
4438 /* XXX XXX XXX Extract a file name */
4439 PathNameFromDirID(myFSS.parID, myFSS.vRefNum, (StringPtr)savefile);
4440 pstrcat((StringPtr)savefile, (StringPtr)&myFSS.name);
4442 /* Convert the string */
4443 ptocstr((StringPtr)savefile);
4445 /* Delay actual open */
4446 open_when_ready = TRUE;
4449 err = AEDisposeDesc(&docList);
4461 * Macintosh modifiers (event.modifier & ccc):
4462 * cmdKey, optionKey, shiftKey, alphaLock, controlKey
4465 * Macintosh Keycodes (0-63 normal, 64-95 keypad, 96-127 extra):
4510 * Optimize non-blocking calls to "CheckEvents()"
4511 * Idea from "Maarten Hazewinkel <mmhazewi@cs.ruu.nl>"
4513 #define EVENT_TICKS 6
4517 * Check for Events, return TRUE if we process any
4519 * Hack -- Handle AppleEvents if appropriate (ignore result code).
4521 static bool CheckEvents(bool wait)
4537 term_data *td = NULL;
4541 static huge lastTicks = 0L;
4544 /* Access the clock */
4545 curTicks = TickCount();
4547 /* Hack -- Allow efficient checking for non-pending events */
4548 if (!wait && (curTicks < lastTicks + EVENT_TICKS)) return (FALSE);
4550 /* Timestamp last check */
4551 lastTicks = curTicks;
4553 /* Let the "system" run */
4556 /* Get an event (or null) */
4557 GetNextEvent(everyEvent, &event);
4559 /* Hack -- Nothing is ready yet */
4560 if (event.what == nullEvent) return (FALSE);
4563 /* Analyze the event */
4571 w = (WindowPtr)event.message;
4582 /* Extract the window */
4583 w = (WindowPtr)event.message;
4585 /* Find the window */
4586 for (i = 0; i < MAX_TERM_DATA; i++)
4588 /* Skip dead windows */
4589 if (!data[i].t) continue;
4591 /* Notice matches */
4592 if (data[i].w == w) td = &data[i];
4595 /* Hack XXX XXX XXX */
4599 /* Redraw the window */
4600 if (td) term_data_redraw(td);
4608 /* Extract some modifiers */
4609 mc = (event.modifiers & controlKey) ? TRUE : FALSE;
4610 ms = (event.modifiers & shiftKey) ? TRUE : FALSE;
4611 mo = (event.modifiers & optionKey) ? TRUE : FALSE;
4612 mx = (event.modifiers & cmdKey) ? TRUE : FALSE;
4614 /* Keypress: (only "valid" if ck < 96) */
4615 ch = (event.message & charCodeMask) & 255;
4617 /* Keycode: see table above */
4618 ck = ((event.message & keyCodeMask) >> 8) & 255;
4620 /* Command + "normal key" -> menu action */
4621 if (mx && (ck < 64))
4623 /* Hack -- Prepare the menus */
4626 /* Run the Menu-Handler */
4629 /* Turn off the menus */
4637 /* Hide the mouse pointer */
4640 /* Normal key -> simple keypress */
4643 /* Enqueue the keypress */
4647 /* Hack -- normal "keypad keys" -> special keypress */
4648 else if (!mc && !ms && !mo && !mx && (ck < 96))
4650 /* Hack -- "enter" is confused */
4651 if (ck == 76) ch = '\n';
4653 /* Send control-caret as a trigger */
4656 /* Send the "ascii" keypress */
4660 /* Bizarre key -> encoded keypress */
4663 /* Hack -- introduce with control-underscore */
4666 /* Send some modifier keys */
4667 if (mc) Term_keypress('C');
4668 if (ms) Term_keypress('S');
4669 if (mo) Term_keypress('O');
4670 if (mx) Term_keypress('X');
4672 /* Hack -- Downshift and encode the keycode */
4673 Term_keypress('0' + (ck - 64) / 10);
4674 Term_keypress('0' + (ck - 64) % 10);
4676 /* Hack -- Terminate the sequence */
4677 /* MPW can generate 10 or 13 for keycode of '\r' */
4678 /* -noMapCR option swaps '\r' and '\n' */
4679 Term_keypress('\r');
4689 /* Analyze click location */
4690 code = FindWindow(event.where, &w);
4692 /* Find the window */
4693 for (i = 0; i < MAX_TERM_DATA; i++)
4695 /* Skip dead windows */
4696 if (!data[i].t) continue;
4698 /* Notice matches */
4699 if (data[i].w == w) td = &data[i];
4708 menu(MenuSelect(event.where));
4715 SystemClick(&event, w);
4725 r = qd.screenBits.bounds;
4726 r.top += 20; /* GetMBarHeight() XXX XXX XXX */
4727 InsetRect(&r, 4, 4);
4728 DragWindow(w, event.where, &r);
4740 p.h = td->w->portRect.left;
4741 p.v = td->w->portRect.top;
4749 /* Apply and Verify */
4750 term_data_check_size(td);
4760 /* Track the go-away box */
4761 if (TrackGoAway(w, event.where))
4767 td->t->mapped_flag = FALSE;
4769 /* Hide the window */
4785 /* Fake rectangle */
4786 r.left = 20 * td->tile_wid + td->size_ow1;
4787 r.right = qd.screenBits.bounds.right;
4788 r.top = 1 * td->tile_hgt + td->size_oh1;
4789 r.bottom = qd.screenBits.bounds.bottom;
4791 /* Grow the rectangle */
4792 newsize = GrowWindow(w, event.where, &r);
4795 if (!newsize) break;
4797 /* Extract the new size in pixels */
4798 y = HiWord(newsize) - td->size_oh1 - td->size_oh2;
4799 x = LoWord(newsize) - td->size_ow1 - td->size_ow2;
4801 /* Extract a "close" approximation */
4802 td->rows = y / td->tile_hgt;
4803 td->cols = x / td->tile_wid;
4805 /* Apply and Verify */
4806 term_data_check_size(td);
4808 Term_activate(td->t);
4810 /* Hack -- Resize the term */
4811 Term_resize(td->cols, td->rows);
4813 /* Resize and Redraw */
4814 term_data_resize(td);
4815 term_data_redraw(td);
4834 /* Disk Event -- From "Maarten Hazewinkel" */
4837 /* check for error when mounting the disk */
4838 if (HiWord(event.message) != noErr)
4844 DIBadMount(p, event.message);
4851 /* OS Event -- From "Maarten Hazewinkel" */
4854 switch ((event.message >> 24) & 0x000000FF)
4856 case suspendResumeMessage:
4858 /* Resuming: activate the front window */
4859 if (event.message & resumeFlag)
4861 SetPort(FrontWindow());
4862 SetCursor(&qd.arrow);
4865 /* Suspend: deactivate the front window */
4879 /* From "Steve Linberg" and "Maarten Hazewinkel" */
4880 case kHighLevelEvent:
4882 /* Process apple events */
4883 if (AEProcessAppleEvent(&event) != noErr)
4886 plog("Apple Event Handler¤Î¥¨¥é¡¼¤Ç¤¹.");
4888 plog("Error in Apple Event Handler!");
4892 /* Handle "quit_when_ready" */
4893 if (quit_when_ready)
4896 quit_when_ready = FALSE;
4898 /* Do the menu key */
4901 /* Turn off the menus */
4905 /* Handle "open_when_ready" */
4906 handle_open_when_ready();
4916 /* Something happened */
4923 /*** Some Hooks for various routines ***/
4927 * Mega-Hack -- emergency lifeboat
4929 static vptr lifeboat = NULL;
4933 * Hook to "release" memory
4935 static vptr hook_rnfree(vptr v, huge size)
4938 #pragma unused (size)
4942 /* Alternative method */
4957 * Hook to "allocate" memory
4959 static vptr hook_ralloc(huge size)
4964 /* Make a new pointer */
4965 return (malloc(size));
4969 /* Make a new pointer */
4970 return (NewPtr(size));
4977 * Hook to handle "out of memory" errors
4979 static vptr hook_rpanic(huge size)
4982 #pragma unused (size)
4986 /* Free the lifeboat */
4989 /* Free the lifeboat */
4990 DisposePtr(lifeboat);
4992 /* Forget the lifeboat */
4995 /* Mega-Hack -- Warning */
4997 mac_warning("¥á¥â¥ê¡¼¤¬Â¤ê¤Þ¤»¤ó!\rº£¤¹¤°½ªÎ»¤·¤Æ²¼¤µ¤¤!");
4999 mac_warning("Running out of Memory!\rAbort this process now!");
5002 /* Mega-Hack -- Never leave this function */
5003 while (TRUE) CheckEvents(TRUE);
5006 /* Mega-Hack -- Crash */
5012 * Hook to tell the user something important
5014 static void hook_plog(cptr str)
5016 /* Warning message */
5021 * Hook to tell the user something, and then quit
5023 static void hook_quit(cptr str)
5025 /* Warning if needed */
5026 if (str) mac_warning(str);
5028 /* Write a preference file */
5036 * Hook to tell the user something, and then crash
5038 static void hook_core(cptr str)
5040 /* XXX Use the debugger */
5041 /* DebugStr(str); */
5044 if (str) mac_warning(str);
5046 /* Warn, then save player */
5048 mac_warning("Ã×̿Ū¤Ê¥¨¥é¡¼¤Ç¤¹.\r¶¯À©Åª¤Ë¥»¡¼¥Ö¤·¤Æ½ªÎ»¤·¤Þ¤¹.");
5050 mac_warning("Fatal error.\rI will now attempt to save and quit.");
5053 /* Attempt to save */
5055 if (!save_player()) mac_warning("·Ù¹ð -- ¥»¡¼¥Ö¤Ë¼ºÇÔ¤·¤Þ¤·¤¿!");
5057 if (!save_player()) mac_warning("Warning -- save failed!");
5066 /*** Main program ***/
5072 * XXX XXX XXX Hack -- This function attempts to "fix" the nasty
5073 * "Macintosh Save Bug" by using "absolute" path names, since on
5074 * System 7 machines anyway, the "current working directory" often
5075 * "changes" due to background processes, invalidating any "relative"
5076 * path names. Note that the Macintosh is limited to 255 character
5077 * path names, so be careful about deeply embedded directories...
5079 * XXX XXX XXX Hack -- This function attempts to "fix" the nasty
5080 * "missing lib folder bug" by allowing the user to help find the
5081 * "lib" folder by hand if the "application folder" code fails...
5083 static void init_stuff(void)
5100 /* Fake rectangle */
5107 center_rect(&r, &qd.screenBits.bounds);
5109 /* Extract corner */
5114 /* Default to the "lib" folder with the application */
5115 refnum_to_name(path, app_dir, app_vol, (char*)("\plib:"));
5118 /* Check until done */
5121 /* Prepare the paths */
5122 init_file_paths(path);
5124 /* Build the filename */
5126 path_build(path, 1024, ANGBAND_DIR_FILE, "news_j.txt");
5128 path_build(path, 1024, ANGBAND_DIR_FILE, "news.txt");
5131 /* Attempt to open and close that file */
5132 if (0 == fd_close(fd_open(path, O_RDONLY))) break;
5136 plog_fmt("'%s' ¥Õ¥¡¥¤¥ë¤ò¥ª¡¼¥×¥ó½ÐÍè¤Þ¤»¤ó.", path);
5138 plog_fmt("Unable to open the '%s' file.", path);
5143 plog("Hengband¤Î'lib'¥Õ¥©¥ë¥À¤¬Â¸ºß¤·¤Ê¤¤¤«Àµ¤·¤¯Ìµ¤¤²ÄǽÀ¤¬¤¢¤ê¤Þ¤¹.");
5145 plog("The Angband 'lib' folder is probably missing or misplaced.");
5149 plog("Please 'open' any file in any sub-folder of the 'lib' folder.");
5151 /* Allow "text" files */
5154 /* Allow "save" files */
5157 /* Allow "data" files */
5161 SFGetFile(topleft, "\p", NULL, 3, types, NULL, &reply);
5164 if (!reply.good) quit(NULL);
5166 /* Extract textual file name for given file */
5167 GetWDInfo(reply.vRefNum, &vrefnum, &drefnum, &junk);
5168 refnum_to_name(path, drefnum, vrefnum, (char*)reply.fName);
5170 /* Hack -- Remove the "filename" */
5171 i = strlen(path) - 1;
5172 while ((i > 0) && (path[i] != ':')) i--;
5173 if (path[i] == ':') path[i+1] = '\0';
5175 /* Hack -- allow "lib" folders */
5176 if (suffix(path, "lib:")) continue;
5178 /* Hack -- Remove the "sub-folder" */
5180 while ((i > 1) && (path[i] != ':')) i--;
5181 if (path[i] == ':') path[i+1] = '\0';
5187 * Macintosh Main loop
5191 EventRecord tempEvent;
5192 int numberOfMasters = 10;
5194 /* Increase stack space by 64K */
5195 SetApplLimit(GetApplLimit() - 131072L);//65536L);
5197 /* Stretch out the heap to full size */
5200 /* Get more Masters */
5201 while (numberOfMasters--) MoreMasters();
5203 /* Set up the Macintosh */
5204 InitGraf(&qd.thePort);
5217 FlushEvents(everyEvent, 0);
5219 /* Flush events some more (?) */
5220 (void)EventAvail(everyEvent, &tempEvent);
5221 (void)EventAvail(everyEvent, &tempEvent);
5222 (void)EventAvail(everyEvent, &tempEvent);
5225 #ifdef ANGBAND_LITE_MAC
5229 #else /* ANGBAND_LITE_MAC */
5231 # if defined(powerc) || defined(__powerc)
5233 /* Assume System 7 */
5235 /* Assume Color Quickdraw */
5245 /* Check the Gestalt */
5246 err = Gestalt(gestaltSystemVersion, &versionNumber);
5248 /* Check the version */
5249 if ((err != noErr) || (versionNumber < 0x0700))
5252 quit("¤³¤Î¥×¥í¥°¥é¥à¤Ï´Á»úTalk7.x.x°Ê¹ß¤ÇÆ°ºî¤·¤Þ¤¹.");
5254 quit("You must have System 7 to use this program.");
5264 /* Check the environs */
5265 if (SysEnvirons(1, &env) != noErr)
5268 quit("SysEnvirons ¥³¡¼¥ë¤Ï¼ºÇÔ¤·¤Þ¤·¤¿¡ª");
5270 quit("The SysEnvirons call failed!");
5274 /* Check for System Seven Stuff */
5275 if (env.systemVersion < 0x0700)
5278 quit("¤³¤Î¥×¥í¥°¥é¥à¤Ï´Á»úTalk7.x.x°Ê¹ß¤ÇÆ°ºî¤·¤Þ¤¹.");
5280 quit("You must have System 7 to use this program.");
5284 /* Check for Color Quickdraw */
5285 if (!env.hasColorQD)
5288 quit("¤³¤Î¥×¥í¥°¥é¥à¤ÏColor Quickdraw¤¬Ìµ¤¤¤ÈÆ°ºî¤·¤Þ¤»¤ó.");
5290 quit("You must have Color Quickdraw to use this program.");
5297 #endif /* ANGBAND_LITE_MAC */
5302 /* Obtain a "Universal Procedure Pointer" */
5303 AEH_Start_UPP = NewAEEventHandlerProc(AEH_Start);
5305 /* Install the hook (ignore error codes) */
5306 AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, AEH_Start_UPP,
5309 /* Obtain a "Universal Procedure Pointer" */
5310 AEH_Quit_UPP = NewAEEventHandlerProc(AEH_Quit);
5312 /* Install the hook (ignore error codes) */
5313 AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, AEH_Quit_UPP,
5316 /* Obtain a "Universal Procedure Pointer" */
5317 AEH_Print_UPP = NewAEEventHandlerProc(AEH_Print);
5319 /* Install the hook (ignore error codes) */
5320 AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments, AEH_Print_UPP,
5323 /* Obtain a "Universal Procedure Pointer" */
5324 AEH_Open_UPP = NewAEEventHandlerProc(AEH_Open);
5326 /* Install the hook (ignore error codes) */
5327 AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, AEH_Open_UPP,
5333 /* Find the current application */
5337 /* Mark ourself as the file creator */
5340 /* Default to saving a "text" file */
5344 #if defined(__MWERKS__)
5346 /* Obtian a "Universal Procedure Pointer" */
5347 ynfilterUPP = NewModalFilterProc(ynfilter);
5352 /* Hook in some "z-virt.c" hooks */
5353 rnfree_aux = hook_rnfree;
5354 ralloc_aux = hook_ralloc;
5355 rpanic_aux = hook_rpanic;
5357 /* Hooks in some "z-util.c" hooks */
5358 plog_aux = hook_plog;
5359 quit_aux = hook_quit;
5360 core_aux = hook_core;
5362 BackColor(blackColor);
5363 ForeColor(whiteColor);
5365 /* Show the "watch" cursor */
5366 SetCursor(*(GetCursor(watchCursor)));
5368 /* Prepare the menubar */
5371 /* Prepare the windows */
5378 /* Hack -- process all events */
5379 while (CheckEvents(TRUE)) /* loop */;
5381 /* Reset the cursor */
5382 SetCursor(&qd.arrow);
5385 /* Mega-Hack -- Allocate a "lifeboat" */
5386 lifeboat = NewPtr(16384);
5388 /* Note the "system" */
5389 ANGBAND_SYS = "mac";
5398 /* Hack -- process all events */
5399 while (CheckEvents(TRUE)) /* loop */;
5402 /* We are now initialized */
5406 /* Handle "open_when_ready" */
5407 handle_open_when_ready();
5413 /* Prompt the user */
5415 prt("'¥Õ¥¡¥¤¥ë'¥á¥Ë¥å¡¼¤è¤ê'¿·µ¬'¤Þ¤¿¤Ï'³«¤¯...'¤òÁªÂò¤·¤Æ¤¯¤À¤µ¤¤¡£", 23, 10);
5417 prt("[Choose 'New' or 'Open' from the 'File' menu]", 23, 15);
5420 /* Flush the prompt */
5424 /* Hack -- Process Events Forever */
5425 while (TRUE) CheckEvents(TRUE);