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];
509 * Convert refnum+vrefnum+fname into a full file name
510 * Store this filename in 'buf' (make sure it is long enough)
511 * Note that 'fname' looks to be a "pascal" string
513 static void refnum_to_name(char *buf, long refnum, short vrefnum, char *fname)
525 for (j=1; j<=fname[0]; j++)
527 res[i-fname[0]+j] = fname[j];
531 pb.ioCompletion=NULL;
533 pb.ioVRefNum=vrefnum;
539 pb.ioDrDirID=pb.ioDrParID;
540 err = PBGetCatInfo((CInfoPBPtr)&pb, FALSE);
542 for (j=1; j<=name[0]; j++)
544 res[i-name[0]+j] = name[j];
548 if (pb.ioDrDirID == fsRtDirID) break;
551 /* Extract the result */
552 for (j = 0, i++; res[i]; j++, i++) buf[j] = res[i];
560 * XXX XXX XXX Allow the system to ask us for a filename
562 static bool askfor_file(char *buf, int len)
570 /* Default file name */
571 sprintf((char*)dflt + 1, "%s's description", buf);
572 dflt[0] = strlen((char*)dflt + 1);
574 /* Ask for a file name */
575 topleft.h=(qd.screenBits.bounds.left+qd.screenBits.bounds.right)/2-344/2;
576 topleft.v=(2*qd.screenBits.bounds.top+qd.screenBits.bounds.bottom)/3-188/2;
577 SFPutFile(topleft, "\pSelect a filename:", dflt, NULL, &reply);
578 /* StandardPutFile("\pSelect a filename:", dflt, &reply); */
586 GetWDInfo(reply.vRefNum, &vrefnum, &drefnum, &junk);
588 /* Extract the name */
589 refnum_to_name(buf, drefnum, vrefnum, (char*)reply.fName);
604 * Center a rectangle inside another rectangle
606 static void center_rect(Rect *r, Rect *s)
608 int centerx = (s->left + s->right)/2;
609 int centery = (2*s->top + s->bottom)/3;
610 int dx = centerx - (r->right - r->left)/2 - r->left;
611 int dy = centery - (r->bottom - r->top)/2 - r->top;
620 * Convert a pascal string in place
622 * This function may be defined elsewhere, but since it is so
623 * small, it is not worth finding the proper function name for
624 * all the different platforms.
626 static void ptocstr(StringPtr src)
630 /* Hack -- pointer */
631 char *s = (char*)(src);
633 /* Hack -- convert the string */
634 for (i = s[0]; i; i--, s++) s[0] = s[1];
636 /* Hack -- terminate the string */
641 #if defined(USE_SFL_CODE)
645 * The following three routines (pstrcat, pstrinsert, and PathNameFromDirID)
646 * were taken from the Think Reference section called "Getting a Full Pathname"
647 * (under the File Manager section). We need PathNameFromDirID to get the
648 * full pathname of the opened savefile, making no assumptions about where it
651 * I had to hack PathNameFromDirID a little for MetroWerks, but it's awfully
654 static void pstrcat(StringPtr dst, StringPtr src)
657 BlockMove(src + 1, dst + *dst + 1, *src);
659 /* adjust length byte */
664 * pstrinsert - insert string 'src' at beginning of string 'dst'
666 static void pstrinsert(StringPtr dst, StringPtr src)
668 /* make room for new string */
669 BlockMove(dst + 1, dst + *src + 1, *dst);
671 /* copy new string in */
672 BlockMove(src + 1, dst + 1, *src);
674 /* adjust length byte */
678 static void PathNameFromDirID(long dirID, short vRefNum, StringPtr fullPathName)
681 Str255 directoryName;
684 fullPathName[0] = '\0';
686 block.dirInfo.ioDrParID = dirID;
687 block.dirInfo.ioNamePtr = directoryName;
691 block.dirInfo.ioVRefNum = vRefNum;
692 block.dirInfo.ioFDirIndex = -1;
693 block.dirInfo.ioDrDirID = block.dirInfo.ioDrParID;
694 err = PBGetCatInfo(&block, FALSE);
695 pstrcat(directoryName, (StringPtr)"\p:");
696 pstrinsert(fullPathName, directoryName);
697 if (block.dirInfo.ioDrDirID == 2) break;
706 * Activate a given window, if necessary
708 static void activate(WindowPtr w)
723 * Display a warning message
725 static void mac_warning(cptr warning)
730 /* Limit of 250 chars */
731 len = strlen(warning);
732 if (len > 250) len = 250;
734 /* Make a "Pascal" string */
736 for (i=0; i<len; i++) text[i+1] = warning[i];
738 /* Prepare the dialog box values */
739 ParamText(text, "\p", "\p", "\p");
741 /* Display the Alert, wait for Okay */
747 /*** Some generic functions ***/
750 #ifdef ANGBAND_LITE_MAC
753 * Hack -- activate a color (0 to 255)
755 #define term_data_color(TD,A) /* Nothing */
757 #else /* ANGBAND_LITE_MAC */
760 * Hack -- activate a color (0 to 255)
762 static void term_data_color(term_data *td, int a)
768 /* Extract the R,G,B data */
769 rv = angband_color_table[a][1];
770 gv = angband_color_table[a][2];
771 bv = angband_color_table[a][3];
774 color.red = (rv | (rv << 8));
775 color.green = (gv | (gv << 8));
776 color.blue = (bv | (bv << 8));
778 /* Activate the color */
779 RGBForeColor(&color);
785 #endif /* ANGBAND_LITE_MAC */
789 * Hack -- Apply and Verify the "font" info
791 * This should usually be followed by "term_data_check_size()"
793 static void term_data_check_font(term_data *td)
799 WindowPtr old = active;
805 /* Instantiate font */
806 TextFont(td->font_id);
807 TextSize(td->font_size);
808 TextFace(td->font_face);
810 /* Extract the font info */
813 /* Assume monospaced */
814 td->font_mono = TRUE;
816 /* Extract the font sizing values XXX XXX XXX */
817 td->font_wid = CharWidth('@'); /* info.widMax; */
818 td->font_hgt = info.ascent + info.descent;
820 td->font_o_y = info.ascent;
822 /* Check important characters */
823 for (i = 33; i < 127; i++)
825 /* Hack -- notice non-mono-space */
826 if (td->font_wid != CharWidth(i)) td->font_mono = FALSE;
828 /* Hack -- collect largest width */
829 if (td->font_wid < CharWidth(i)) td->font_wid = CharWidth(i);
832 /* Set default offsets */
833 td->tile_o_x = td->font_o_x;
834 td->tile_o_y = td->font_o_y;
836 /* Set default tile size */
837 if( td->tile_wid == 0 && td->tile_hgt == 0 ){
838 td->tile_wid = td->font_wid;
839 td->tile_hgt = td->font_hgt;
842 /* Re-activate the old window */
848 * Hack -- Apply and Verify the "size" info
850 static void term_data_check_size(term_data *td)
852 /* Minimal window size */
855 /* Enforce minimal size */
856 if (td->cols < 80) td->cols = 80;
857 if (td->rows < 24) td->rows = 24;
860 /* Allow small windows for the rest */
863 if (td->cols < 1) td->cols = 1;
864 if (td->rows < 1) td->rows = 1;
867 /* Minimal tile size */
868 if (td->tile_wid < 4) td->tile_wid = 4;
869 if (td->tile_hgt < 4) td->tile_hgt = 4;
871 /* Default tile offsets */
872 td->tile_o_x = (td->tile_wid - td->font_wid) / 2;
873 td->tile_o_y = (td->tile_hgt - td->font_hgt) / 2;
875 /* Minimal tile offsets */
876 if (td->tile_o_x < 0) td->tile_o_x = 0;
877 if (td->tile_o_y < 0) td->tile_o_y = 0;
879 /* Apply font offsets */
880 td->tile_o_x += td->font_o_x;
881 td->tile_o_y += td->font_o_y;
883 /* Calculate full window size */
884 td->size_wid = td->cols * td->tile_wid + td->size_ow1 + td->size_ow2;
885 td->size_hgt = td->rows * td->tile_hgt + td->size_oh1 + td->size_oh2;
888 if (td->r.top > qd.screenBits.bounds.bottom - td->size_hgt)
890 td->r.top = qd.screenBits.bounds.bottom - td->size_hgt;
894 if (td->r.top < qd.screenBits.bounds.top + 30)
896 td->r.top = qd.screenBits.bounds.top + 30;
899 /* Verify the left */
900 if (td->r.left > qd.screenBits.bounds.right - td->size_wid)
902 td->r.left = qd.screenBits.bounds.right - td->size_wid;
905 /* Verify the left */
906 if (td->r.left < qd.screenBits.bounds.left)
908 td->r.left = qd.screenBits.bounds.left;
911 /* Calculate bottom right corner */
912 td->r.right = td->r.left + td->size_wid;
913 td->r.bottom = td->r.top + td->size_hgt;
915 /* Assume no graphics */
916 td->t->higher_pict = FALSE;
917 td->t->always_pict = FALSE;
919 #ifdef ANGBAND_LITE_MAC
923 #else /* ANGBAND_LITE_MAC */
925 /* Handle graphics */
928 /* Use higher_pict whenever possible */
929 if (td->font_mono) td->t->higher_pict = TRUE;
931 /* Use always_pict only when necessary */
932 else td->t->always_pict = TRUE;
935 #endif /* ANGBAND_LITE_MAC */
937 /* Fake mono-space */
938 if (!td->font_mono ||
939 (td->font_wid != td->tile_wid) ||
940 (td->font_hgt != td->tile_hgt))
942 /* Handle fake monospace -- this is SLOW */
943 if (td->t->higher_pict) td->t->higher_pict = FALSE;
944 td->t->always_pict = TRUE;
948 static OSErr XDDSWUpDateGWorldFromPict( term_data *td );
950 * Hack -- resize a term_data
952 * This should normally be followed by "term_data_resize()"
954 static void term_data_resize(term_data *td)
956 /* Actually resize the window */
957 SizeWindow(td->w, td->size_wid, td->size_hgt, 0);
959 XDDSWUpDateGWorldFromPict( td );
965 * Hack -- redraw a term_data
967 * Note that "Term_redraw()" calls "TERM_XTRA_CLEAR"
969 static void term_data_redraw(term_data *td)
973 /* Activate the term */
974 Term_activate(td->t);
976 /* Redraw the contents */
979 /* Flush the output */
982 /* Restore the old term */
985 /* No need to redraw */
986 ValidRect(&td->w->portRect);
992 #ifdef ANGBAND_LITE_MAC
996 #else /* ANGBAND_LITE_MAC */
1003 static int pictID = 1001; /* 8x8 tiles; 16x16 tiles are 1002 */
1005 static int grafWidth = 8; /* Always equal to grafHeight */
1006 static int grafHeight = 8; /* Either 8 or 16 */
1008 static bool arg_newstyle_graphics;
1009 static bool use_newstyle_graphics;
1014 typedef struct FrameRec FrameRec;
1019 * - GWorld for the frame image
1020 * - Handle to pix map (saved for unlocking/locking)
1021 * - Pointer to color pix map (valid only while locked)
1025 GWorldPtr framePort;
1026 PixMapHandle framePixHndl;
1033 * The global picture data
1035 static FrameRec *frameP = NULL;
1041 static void BenSWLockFrame(FrameRec *srcFrameP)
1043 PixMapHandle pixMapH;
1045 pixMapH = GetGWorldPixMap(srcFrameP->framePort);
1046 (void)LockPixels(pixMapH);
1047 HLockHi((Handle)pixMapH);
1048 srcFrameP->framePixHndl = pixMapH;
1049 srcFrameP->framePix = (PixMapPtr)StripAddress(*(Handle)pixMapH);
1056 static void XDDSWLockFrame( term_data *td )
1058 PixMapHandle pixMapH;
1060 pixMapH = GetGWorldPixMap(td->bufferPort);
1061 (void)LockPixels(pixMapH);
1062 HLockHi((Handle)pixMapH);
1063 td->bufferPixHndl = pixMapH;
1064 td->bufferPix = (PixMapPtr)*(Handle)pixMapH;
1071 static void BenSWUnlockFrame(FrameRec *srcFrameP)
1073 if (srcFrameP->framePort != NULL)
1075 HUnlock((Handle)srcFrameP->framePixHndl);
1076 UnlockPixels(srcFrameP->framePixHndl);
1079 srcFrameP->framePix = NULL;
1086 static void XDDSWUnlockFrame( term_data *td )
1088 if (td->bufferPort != NULL)
1090 HUnlock((Handle)td->bufferPixHndl);
1091 UnlockPixels(td->bufferPixHndl);
1094 td->bufferPix = NULL;
1097 static OSErr BenSWCreateGWorldFromPict(
1098 GWorldPtr *pictGWorld,
1102 GWorldPtr saveGWorld;
1103 GDHandle saveGDevice;
1104 GWorldPtr tempGWorld;
1113 depth = data[0].pixelDepth;
1116 theGDH = data[0].theGDH;
1118 /* Obtain size rectangle */
1119 pictRect = (**pictH).picFrame;
1120 OffsetRect(&pictRect, -pictRect.left, -pictRect.top);
1122 /* Create a GWorld */
1123 err = NewGWorld(&tempGWorld, depth, &pictRect, nil,
1124 theGDH, noNewDevice);
1133 *pictGWorld = tempGWorld;
1136 GetGWorld(&saveGWorld, &saveGDevice);
1139 SetGWorld(tempGWorld, nil);
1141 /* Dump the pict into the GWorld */
1142 (void)LockPixels(GetGWorldPixMap(tempGWorld));
1143 EraseRect(&pictRect);
1144 DrawPicture(pictH, &pictRect);
1145 UnlockPixels(GetGWorldPixMap(tempGWorld));
1147 /* Restore GWorld */
1148 SetGWorld(saveGWorld, saveGDevice);
1155 static OSErr XDDSWCreateGWorldFromPict(
1156 GWorldPtr *pictGWorld,
1160 GWorldPtr saveGWorld;
1161 GDHandle saveGDevice;
1162 GWorldPtr tempGWorld;
1173 depth = td->pixelDepth;
1176 theGDH = td->theGDH;
1178 /* Obtain size rectangle */
1180 pictRect.right = td->size_wid;
1182 pictRect.bottom = td->tile_hgt;
1184 /* Create a GWorld */
1185 err = NewGWorld(&tempGWorld, 0, &pictRect, 0, 0, 0);
1194 *pictGWorld = tempGWorld;
1197 GetGWorld(&saveGWorld, &saveGDevice);
1200 SetGWorld(tempGWorld, nil);
1202 /* Dump the pict into the GWorld
1203 (void)LockPixels(GetGWorldPixMap(tempGWorld));
1204 EraseRect(&pictRect);
1205 // DrawPicture(pictH, &pictRect);
1206 UnlockPixels(GetGWorldPixMap(tempGWorld));
1208 /* Restore GWorld */
1209 SetGWorld(saveGWorld, saveGDevice);
1215 static OSErr XDDSWUpDateGWorldFromPict( term_data *td )
1217 GWorldPtr saveGWorld;
1218 GDHandle saveGDevice;
1223 GWorldFlags errflag;
1227 if( td->bufferPort == NULL )
1230 depth = td->pixelDepth;
1233 theGDH = td->theGDH;
1235 /* Obtain size rectangle */
1238 pictRect.right = td->size_wid;
1239 pictRect.bottom = td->tile_hgt;
1241 XDDSWUnlockFrame(td);
1243 errflag = UpdateGWorld( &td->bufferPort, depth, &pictRect, 0, 0, 0);
1245 if( errflag & gwFlagErr ){
1252 GetGWorld(&saveGWorld, &saveGDevice);
1255 SetGWorld(td->bufferPort, nil);
1257 /* Dump the pict into the GWorld */
1258 (void)LockPixels(GetGWorldPixMap(td->bufferPort));
1259 EraseRect(&td->bufferPort->portRect);
1261 UnlockPixels(GetGWorldPixMap(td->bufferPort));
1263 /* Restore GWorld */
1264 SetGWorld(saveGWorld, saveGDevice);
1270 * Init the global "frameP"
1273 static errr globe_init(void)
1277 GWorldPtr tempPictGWorldP;
1281 /* Use window XXX XXX XXX */
1285 /* Get the pict resource */
1286 newPictH = GetPicture(pictID);
1288 /* Analyze result */
1289 err = (newPictH ? 0 : -1);
1296 err = BenSWCreateGWorldFromPict(&tempPictGWorldP, newPictH);
1298 /* Release resource */
1299 ReleaseResource((Handle)newPictH);
1304 /* Create the frame */
1305 frameP = (FrameRec*)NewPtrClear((Size)sizeof(FrameRec));
1307 /* Analyze result */
1308 err = (frameP ? 0 : -1);
1314 frameP->framePort = tempPictGWorldP;
1317 BenSWLockFrame(frameP);
1328 * Nuke the global "frameP"
1330 static errr globe_nuke(void)
1336 BenSWUnlockFrame(frameP);
1338 /* Dispose of the GWorld */
1339 DisposeGWorld(frameP->framePort);
1341 /* Dispose of the memory */
1342 DisposePtr((Ptr)frameP);
1349 FlushEvents(everyEvent, 0);
1356 #endif /* ANGBAND_LITE_MAC */
1360 /*** Support for the "z-term.c" package ***/
1364 * Initialize a new Term
1366 * Note also the "window type" called "noGrowDocProc", which might be more
1367 * appropriate for the main "screen" window.
1369 * Note the use of "srcCopy" mode for optimized screen writes.
1371 static void Term_init_mac(term *t)
1373 term_data *td = (term_data*)(t->data);
1375 static RGBColor black = {0x0000,0x0000,0x0000};
1376 static RGBColor white = {0xFFFF,0xFFFF,0xFFFF};
1378 #ifdef ANGBAND_LITE_MAC
1380 /* Make the window */
1381 td->w = NewWindow(0, &td->r, td->title, 0, noGrowDocProc, (WindowPtr)-1, 1, 0L);
1383 #else /* ANGBAND_LITE_MAC */
1385 /* Make the window */
1386 td->w = NewCWindow(0, &td->r, td->title, 0, documentProc, (WindowPtr)-1, 1, 0L);
1388 #endif /* ANGBAND_LITE_MAC */
1390 /* Activate the window */
1393 /* Erase behind words */
1396 /* Apply and Verify */
1397 term_data_check_font(td);
1398 term_data_check_size(td);
1400 /* Resize the window */
1401 term_data_resize(td);
1403 #ifdef ANGBAND_LITE_MAC
1405 /* Prepare the colors (base colors) */
1406 BackColor(blackColor);
1407 ForeColor(whiteColor);
1409 #else /* ANGBAND_LITE_MAC */
1411 /* Prepare the colors (real colors) */
1412 RGBBackColor(&black);
1413 RGBForeColor(&white);
1420 GDHandle currentGDH;
1421 GWorldPtr windowGWorld;
1422 PixMapHandle basePixMap;
1424 /* Obtain the rect */
1425 tempRect = td->w->portRect;
1427 /* Obtain the global rect */
1428 globalRect = tempRect;
1429 LocalToGlobal((Point*)&globalRect.top);
1430 LocalToGlobal((Point*)&globalRect.bottom);
1432 /* Obtain the proper GDH */
1433 mainGDH = GetMaxDevice(&globalRect);
1435 /* Extract GWorld and GDH */
1436 GetGWorld(&windowGWorld, ¤tGDH);
1438 /* Obtain base pixmap */
1439 basePixMap = (**mainGDH).gdPMap;
1441 /* Save pixel depth */
1442 td->pixelDepth = (**basePixMap).pixelSize;
1444 /* Save Window GWorld */
1445 td->theGWorld = windowGWorld;
1447 /* Save Window GDH */
1448 td->theGDH = currentGDH;
1451 td->mainSWGDH = mainGDH;
1454 #endif /* ANGBAND_LITE_MAC */
1456 /* Clip to the window */
1457 ClipRect(&td->w->portRect);
1459 /* Erase the window */
1460 EraseRect(&td->w->portRect);
1462 /* Invalidate the window */
1463 InvalRect(&td->w->portRect);
1465 /* Display the window if needed */
1466 if (td->mapped) ShowWindow(td->w);
1468 /* Hack -- set "mapped" flag */
1469 t->mapped_flag = td->mapped;
1473 XDDSWCreateGWorldFromPict( &td->bufferPort, td );
1475 XDDSWLockFrame( td );
1477 /* if (err == noErr)
1488 static void Term_nuke_mac(term *t)
1501 static errr Term_user_mac(int n)
1515 static errr Term_xtra_mac_react(void)
1517 term_data *td = (term_data*)(Term->data);
1523 #ifdef ANGBAND_LITE_MAC
1527 #else /* ANGBAND_LITE_MAC */
1530 if (use_sound != arg_sound)
1533 use_sound = arg_sound;
1537 /* Handle transparency */
1538 if (use_newstyle_graphics != arg_newstyle_graphics)
1542 if (globe_init() != 0)
1544 plog("Cannot initialize graphics!");
1545 arg_graphics = FALSE;
1546 arg_newstyle_graphics = FALSE;
1550 use_newstyle_graphics = arg_newstyle_graphics;
1552 /* Apply and Verify */
1553 term_data_check_size(td);
1555 /* Resize the window */
1556 term_data_resize(td);
1562 /* Handle graphics */
1563 if (use_graphics != arg_graphics)
1565 /* Initialize graphics */
1567 if (!use_graphics && !frameP && (globe_init() != 0))
1570 plog("¥°¥é¥Õ¥£¥Ã¥¯¤Î½é´ü²½¤Ï½ÐÍè¤Þ¤»¤ó¤Ç¤·¤¿.");
1572 plog("Cannot initialize graphics!");
1574 arg_graphics = FALSE;
1578 use_graphics = arg_graphics;
1580 /* Apply and Verify */
1581 term_data_check_size(td);
1583 /* Resize the window */
1584 term_data_resize(td);
1590 #endif /* ANGBAND_LITE_MAC */
1598 * Do a "special thing"
1600 static errr Term_xtra_mac(int n, int v)
1602 term_data *td = (term_data*)(Term->data);
1610 case TERM_XTRA_NOISE:
1619 #ifdef ANGBAND_LITE_MAC
1623 #else /* ANGBAND_LITE_MAC */
1626 case TERM_XTRA_SOUND:
1636 /* Open the resource file */
1637 oldResFile = CurResFile();
1638 newResFile = OpenResFile(sound);
1640 /* Close the resource file */
1641 CloseResFile(newResFile);
1642 UseResFile(oldResFile);
1645 /* Get the proper sound name */
1646 sprintf((char*)sound + 1, "%.16s.wav", angband_sound_name[v]);
1647 sound[0] = strlen((char*)sound + 1);
1649 /* Obtain resource XXX XXX XXX */
1650 handle = Get1NamedResource('snd ', sound);
1651 if( handle == NULL || ext_sound )
1652 handle = GetNamedResource('snd ', sound);
1655 if (handle && soundmode[soundchoice[v]] == true)
1658 LoadResource(handle);
1661 /* Play sound (wait for completion) */
1662 SndPlay(nil, (SndListHandle)handle, true);
1664 /* Unlock and release */
1666 ReleaseResource(handle);
1672 #endif /* ANGBAND_LITE_MAC */
1674 /* Process random events */
1675 case TERM_XTRA_BORED:
1677 /* Process an event */
1678 (void)CheckEvents(0);
1684 /* Process pending events */
1685 case TERM_XTRA_EVENT:
1687 /* Process an event */
1688 (void)CheckEvents(v);
1694 /* Flush all pending events (if any) */
1695 case TERM_XTRA_FLUSH:
1697 /* Hack -- flush all events */
1698 while (CheckEvents(TRUE)) /* loop */;
1704 /* Hack -- Change the "soft level" */
1705 case TERM_XTRA_LEVEL:
1707 /* Activate if requested */
1708 if (v) activate(td->w);
1714 /* Clear the screen */
1715 case TERM_XTRA_CLEAR:
1717 /* No clipping XXX XXX XXX */
1718 ClipRect(&td->w->portRect);
1720 /* Erase the window */
1721 EraseRect(&td->w->portRect);
1724 term_data_color(td, TERM_WHITE);
1726 /* Frame the window in white */
1728 LineTo(0, td->size_hgt-1);
1729 LineTo(td->size_wid-1, td->size_hgt-1);
1730 LineTo(td->size_wid-1, 0);
1732 /* Clip to the new size */
1733 r.left = td->w->portRect.left + td->size_ow1;
1734 r.top = td->w->portRect.top + td->size_oh1;
1735 r.right = td->w->portRect.right - td->size_ow2;
1736 r.bottom = td->w->portRect.bottom - td->size_oh2;
1743 /* React to changes */
1744 case TERM_XTRA_REACT:
1746 /* React to changes */
1747 return (Term_xtra_mac_react());
1750 /* Delay (milliseconds) */
1751 case TERM_XTRA_DELAY:
1756 long m = TickCount() + (v * 60L) / 1000;
1759 while (TickCount() < m) /* loop */;
1774 * Low level graphics (Assumes valid input).
1775 * Draw a "cursor" at (x,y), using a "yellow box".
1776 * We are allowed to use "Term_grab()" to determine
1777 * the current screen contents (for inverting, etc).
1779 static errr Term_curs_mac(int x, int y)
1783 term_data *td = (term_data*)(Term->data);
1786 term_data_color(td, TERM_YELLOW);
1788 /* Frame the grid */
1789 r.left = x * td->tile_wid + td->size_ow1;
1790 r.right = r.left + td->tile_wid;
1791 r.top = y * td->tile_hgt + td->size_oh1;
1792 r.bottom = r.top + td->tile_hgt;
1795 if (x + 1 < Term->wid &&
1796 ((use_bigtile && Term->old->a[y][x+1] == 255)
1797 || (iskanji(Term->old->c[y][x]) && !(Term->old->a[y][x] & 0x80))))
1799 if (use_bigtile && x + 1 < Term->wid && Term->old->a[y][x+1] == 255)
1801 r.right += td->tile_wid;
1811 * Low level graphics (Assumes valid input)
1813 * Erase "n" characters starting at (x,y)
1815 static errr Term_wipe_mac(int x, int y, int n)
1819 term_data *td = (term_data*)(Term->data);
1821 /* Erase the block of characters */
1822 r.left = x * td->tile_wid + td->size_ow1;
1823 r.right = r.left + n * td->tile_wid;
1824 r.top = y * td->tile_hgt + td->size_oh1;
1825 r.bottom = r.top + td->tile_hgt;
1834 * Low level graphics. Assumes valid input.
1836 * Draw several ("n") chars, with an attr, at a given location.
1838 static errr Term_text_mac(int x, int y, int n, byte a, const char *cp)
1842 term_data *td = (term_data*)(Term->data);
1845 term_data_color(td, (a & 0x0F));
1847 /* Starting pixel */
1848 xp = x * td->tile_wid + td->tile_o_x + td->size_ow1;
1849 yp = y * td->tile_hgt + td->tile_o_y + td->size_oh1;
1851 /* Move to the correct location */
1854 /* Draw the character */
1855 if (n == 1) DrawChar(*cp);
1857 /* Draw the string */
1858 else DrawText(cp, 0, n);
1866 * Low level graphics (Assumes valid input)
1868 * Erase "n" characters starting at (x,y)
1870 #ifdef USE_TRANSPARENCY
1871 static errr Term_pict_mac(int x, int y, int n, const byte *ap, const char *cp,
1872 const byte *tap, const char *tcp)
1874 static errr Term_pict_mac(int x, int y, int n, const byte *ap, const char *cp)
1879 bool use_buffer = false;
1880 term_data *td = (term_data*)(Term->data);
1881 GDHandle saveGDevice;
1882 GWorldPtr saveGWorld;
1884 PixMapHandle PortPix;
1888 GetGWorld(&saveGWorld, &saveGDevice);
1892 /* Destination rectangle */
1893 r2.left = x * td->tile_wid + td->size_ow1;
1894 r2.right = r2.left + td->tile_wid;
1896 r2.bottom = r2.top + td->tile_hgt;
1899 SetGWorld(td->bufferPort, nil);
1900 PortPix = GetGWorldPixMap(td->bufferPort );
1901 LockPixels( PortPix );
1903 /* Instantiate font */
1904 TextFont(td->font_id);
1905 TextSize(td->font_size);
1906 TextFace(td->font_face);
1908 /* Restore colors */
1909 BackColor(blackColor);
1910 ForeColor(whiteColor);
1913 EraseRect(&td->bufferPort->portRect);
1919 /* Destination rectangle */
1920 r2.left = x * td->tile_wid + td->size_ow1;
1921 r2.top = y * td->tile_hgt + td->size_oh1;
1922 r2.bottom = r2.top + td->tile_hgt;
1924 /* no buffering, so we use the normal current port */
1929 /* Scan the input */
1930 for (i = 0; i < n; i++)
1937 /* Second byte of bigtile */
1938 if (use_bigtile && a == 255)
1941 r2.left += td->tile_wid;
1946 /* Prepare right of rectangle now */
1947 r2.right = r2.left + td->tile_wid;
1949 #ifdef ANGBAND_LITE_MAC
1953 #else /* ANGBAND_LITE_MAC */
1955 /* Graphics -- if Available and Needed */
1956 if (use_graphics && ((byte)a & 0x80) && ((byte)c & 0x80))
1958 BitMapPtr srcBitMap = (BitMapPtr)(frameP->framePix);
1959 BitMapPtr destBitMap;
1964 #ifdef USE_TRANSPARENCY
1966 bool terrain_flag = FALSE;
1970 if (a != ta || c != tc)
1973 row = ((byte)ta & 0x7F);
1974 col = ((byte)tc & 0x7F);
1976 /* Terrain Source rectangle */
1977 terrain_r.left = col * grafWidth;
1978 terrain_r.top = row * grafHeight;
1979 terrain_r.right = terrain_r.left + grafWidth;
1980 terrain_r.bottom = terrain_r.top + grafHeight;
1982 terrain_flag = TRUE;
1987 row = ((byte)a & 0x7F);
1988 col = ((byte)c & 0x7F);
1990 /* Source rectangle */
1991 r1.left = col * grafWidth;
1992 r1.top = row * grafHeight;
1993 r1.right = r1.left + grafWidth;
1994 r1.bottom = r1.top + grafHeight;
1996 /* Hardwire CopyBits */
1997 BackColor(whiteColor);
1998 ForeColor(blackColor);
2000 /* Draw the picture */
2003 destBitMap = (BitMapPtr)(td->bufferPix);
2005 destBitMap = (BitMapPtr)&(td->w->portBits);
2007 if (use_bigtile) r2.right += td->tile_wid;
2009 #ifdef USE_TRANSPARENCY
2013 * Source mode const = srcCopy:
2015 * determine how close the color of the source
2016 * pixel is to black, and assign this relative
2017 * amount of foreground color to the
2018 * destination pixel; determine how close the
2019 * color of the source pixel is to white, and
2020 * assign this relative amount of background
2021 * color to the destination pixel
2023 CopyBits( srcBitMap, destBitMap, &terrain_r, &r2, srcCopy, NULL );
2026 * Draw transparent tile
2027 * BackColor is ignored and the destination is
2030 BackColor(blackColor);
2031 CopyBits( srcBitMap, destBitMap, &r1, &r2, transparent, NULL );
2034 #endif /* USE_TRANSPARENCY */
2036 CopyBits( srcBitMap, destBitMap, &r1, &r2, srcCopy, NULL );
2039 /* Restore colors */
2040 BackColor(blackColor);
2041 ForeColor(whiteColor);
2050 #endif /* ANGBAND_LITE_MAC */
2058 term_data_color(td, (a & 0x0F));
2060 /* Starting pixel */
2061 xp = r2.left + td->tile_o_x;
2062 yp = r2.top + td->tile_o_y;
2064 /* Move to the correct location */
2070 /* Double width rectangle */
2071 r2.right += td->tile_wid;
2076 /* Draw the character */
2081 r2.left += td->tile_wid;
2089 /* Draw the character */
2095 r2.left += td->tile_wid;
2100 /* Now we blast the buffer pixmap onto the screen in the right place */
2101 BitMapPtr srcBitMap = (BitMapPtr)(td->bufferPix);
2103 BitMapPtr destBitMap = (BitMapPtr)&(td->w->portBits);
2109 srcRect.left = x * td->tile_wid + td->size_ow1;
2111 srcRect.right = srcRect.left + (td->tile_wid * n);
2112 srcRect.bottom = td->tile_hgt;
2114 destRect.left = x * td->tile_wid + td->size_ow1;
2115 destRect.right = destRect.left + (td->tile_wid * n);
2116 destRect.top = y * td->tile_hgt + td->size_oh1;
2117 destRect.bottom = destRect.top + td->tile_hgt;
2119 /* Double width rectangle */
2122 srcRect.right += td->tile_wid * n;
2123 destRect.right += td->tile_wid * n;
2126 UnlockPixels( PortPix );
2128 /* Restore GWorld */
2129 SetGWorld(saveGWorld, saveGDevice);
2131 /* Hardwire CopyBits */
2132 BackColor(whiteColor);
2133 ForeColor(blackColor);
2135 CopyBits( srcBitMap, destBitMap, &srcRect, &destRect, srcCopy, NULL );
2137 /* Restore colors */
2138 BackColor(blackColor);
2139 ForeColor(whiteColor);
2152 * Create and initialize window number "i"
2154 static void term_data_link(int i)
2158 term_data *td = &data[i];
2163 /* Require mapped */
2164 if (!td->mapped) return;
2169 /* Initialize the term */
2170 term_init(td->t, td->cols, td->rows, td->keys);
2172 /* Use a "software" cursor */
2173 td->t->soft_cursor = TRUE;
2175 /* Erase with "white space" */
2176 td->t->attr_blank = TERM_WHITE;
2177 td->t->char_blank = ' ';
2179 /* Prepare the init/nuke hooks */
2180 td->t->init_hook = Term_init_mac;
2181 td->t->nuke_hook = Term_nuke_mac;
2183 /* Prepare the function hooks */
2184 td->t->user_hook = Term_user_mac;
2185 td->t->xtra_hook = Term_xtra_mac;
2186 td->t->wipe_hook = Term_wipe_mac;
2187 td->t->curs_hook = Term_curs_mac;
2188 td->t->text_hook = Term_text_mac;
2189 td->t->pict_hook = Term_pict_mac;
2191 /* Link the local structure */
2192 td->t->data = (vptr)(td);
2195 Term_activate(td->t);
2197 /* Global pointer */
2198 angband_term[i] = td->t;
2208 * Set the "current working directory" (also known as the "default"
2209 * volume/directory) to the location of the current application.
2211 * Code by: Maarten Hazewinkel (mmhazewi@cs.ruu.nl)
2213 * This function does not appear to work correctly with System 6.
2215 static void SetupAppDir(void)
2219 char errString[100];
2221 /* Get the location of the Angband executable */
2222 fcbBlock.ioCompletion = NULL;
2223 fcbBlock.ioNamePtr = NULL;
2224 fcbBlock.ioVRefNum = 0;
2225 fcbBlock.ioRefNum = CurResFile();
2226 fcbBlock.ioFCBIndx = 0;
2227 err = PBGetFCBInfo(&fcbBlock, FALSE);
2231 sprintf(errString, "PBGetFCBInfo ¥¨¥é¡¼ #%d.\r ½ªÎ»¤·¤Þ¤¹.", err);
2233 sprintf(errString, "Fatal PBGetFCBInfo Error #%d.\r Exiting.", err);
2235 mac_warning(errString);
2239 /* Extract the Vol and Dir */
2240 app_vol = fcbBlock.ioFCBVRefNum;
2241 app_dir = fcbBlock.ioFCBParID;
2243 /* Set the current working directory to that location */
2244 err = HSetVol(NULL, app_vol, app_dir);
2248 sprintf(errString, "HSetVol ¥¨¥é¡¼ #%d.\r ½ªÎ»¤·¤Þ¤¹.", err);
2250 sprintf(errString, "Fatal HSetVol Error #%d.\r Exiting.", err);
2252 mac_warning(errString);
2261 * Global "preference" file pointer
2266 * Read a "short" from the file
2268 static int getshort(void)
2272 if (0 == my_fgets(fff, buf, 256)) x = atoi(buf);
2277 * Dump a "short" to the file
2279 static void putshort(int x)
2281 fprintf(fff, "%d\n", x);
2287 * Write the "preference" data to the current "file"
2289 static void save_prefs(void)
2296 /*** The current version ***/
2298 putshort(FAKE_VERSION);
2299 putshort(FAKE_VER_MAJOR);
2300 putshort(FAKE_VER_MINOR);
2301 putshort(FAKE_VER_PATCH);
2303 putshort(arg_sound);
2304 putshort(arg_graphics);
2305 putshort(arg_newstyle_graphics);
2306 putshort(arg_bigtile);
2309 for( i = 0 ; i < 7 ; i++ )
2310 putshort(soundmode[i]);
2313 for (i = 0; i < MAX_TERM_DATA; i++)
2318 putshort(td->mapped);
2320 putshort(td->font_id);
2321 putshort(td->font_size);
2322 putshort(td->font_face);
2324 putshort(td->tile_wid);
2325 putshort(td->tile_hgt);
2330 putshort(td->r.left);
2331 putshort(td->r.top);
2337 * Load the preferences from the current "file"
2339 * XXX XXX XXX Being able to undefine various windows is
2340 * slightly bizarre, and may cause problems.
2342 static void load_prefs(void)
2346 int old_version, old_major, old_minor, old_patch;
2351 /*** Version information ***/
2353 /* Preferences version */
2354 old_version = getshort();
2355 old_major = getshort();
2356 old_minor = getshort();
2357 old_patch = getshort();
2359 /* Hack -- Verify or ignore */
2360 if ((old_version != FAKE_VERSION) ||
2361 (old_major != FAKE_VER_MAJOR) ||
2362 (old_minor != FAKE_VER_MINOR) ||
2363 (old_patch != FAKE_VER_PATCH))
2367 mac_warning("¸Å¤¤½é´üÀßÄê¥Õ¥¡¥¤¥ë¤ò̵»ë¤·¤Þ¤¹.");
2369 mac_warning("Ignoring old preferences.");
2375 arg_sound = getshort();
2376 arg_graphics = getshort();
2377 arg_newstyle_graphics = getshort();
2378 use_newstyle_graphics = arg_newstyle_graphics;
2380 if (use_newstyle_graphics == true)
2382 ANGBAND_GRAF = "new";
2383 arg_newstyle_graphics = true;
2384 grafWidth = grafHeight = 16;
2389 ANGBAND_GRAF = "old";
2390 arg_newstyle_graphics = false;
2391 grafWidth = grafHeight = 8;
2395 arg_bigtile = getshort();
2396 use_bigtile = arg_bigtile;
2399 for( i = 0 ; i < 7 ; i++ )
2400 soundmode[i] = getshort();
2403 m = GetMenuHandle(134); //m = GetMHandle(134);
2405 /* Item "arg_sound" */
2406 CheckItem(m, 1, arg_sound);
2408 /* Item "arg_graphics" */
2409 CheckItem(m, 2, arg_graphics);
2411 /* Item "arg_newstyle_graphics"*/
2412 CheckItem(m, 8, arg_newstyle_graphics);
2415 for (i = 0; i < MAX_TERM_DATA; i++)
2420 td->mapped = getshort();
2422 td->font_id = getshort();
2423 td->font_size = getshort();
2424 td->font_face = getshort();
2426 td->tile_wid = getshort();
2427 td->tile_hgt = getshort();
2429 td->cols = getshort();
2430 td->rows = getshort();
2432 td->r.left = getshort();
2433 td->r.top = getshort();
2436 if (feof(fff)) break;
2444 * Hack -- default data for a window
2446 static void term_data_hack(term_data *td)
2451 GetFNum( "\pÅùÉýÌÀÄ«", &fid); /* ¥Õ¥©¥ó¥È̾¤«¤éIDÈÖ¹æ¤òÄ´¤Ù¤ë */
2452 SetFScaleDisable( true );
2454 /* Default to Monaco font */
2455 GetFNum("\pmonaco", &fid);
2458 WIPE(td, term_data);
2463 /* Default borders */
2474 /* Default font size */
2477 /* Default font face */
2484 /* Default position */
2494 * Read the preference file, Create the windows.
2496 * We attempt to use "FindFolder()" to track down the preference file,
2497 * but if this fails, for any reason, we will try the "SysEnvirons()"
2498 * method, which may work better with System 6.
2500 static void init_windows(void)
2513 /*** Default values ***/
2515 /* Initialize (backwards) */
2516 for (i = MAX_TERM_DATA - 1; i >= 0; i--)
2529 s = angband_term_name[i];
2534 /* Maximal length */
2537 /* Copy the title */
2538 strncpy((char*)(td->title) + 1, s, n);
2540 /* Save the length */
2543 /* Tile the windows */
2544 td->r.left += (b * 30);
2545 td->r.top += (b * 30);
2552 /*** Load preferences ***/
2554 /* Assume failure */
2557 /* Assume failure */
2570 /* Find the folder */
2571 err = FindFolder(kOnSystemDisk, kPreferencesFolderType, kCreateFolder,
2577 /* Extract a path name */
2578 PathNameFromDirID(dirID, vref, (StringPtr)foo);
2580 /* Convert the string */
2581 ptocstr((StringPtr)foo);
2583 /* Append the preference file name */
2584 strcat(foo, PREF_FILE_NAME);
2586 /* Open the preference file */
2587 fff = fopen(foo, "r");
2594 #endif /* USE_SFL_CODE */
2600 HGetVol(0, &savev, &saved);
2602 /* Go to the "system" folder */
2603 SysEnvirons(curSysEnvVers, &env);
2604 SetVol(0, env.sysVRefNum);
2607 fff = fopen(PREF_FILE_NAME, "r");
2610 HSetVol(0, savev, saved);
2613 /* Load preferences */
2616 /* Load a real preference file */
2619 /* Close the file */
2624 /*** Instantiate ***/
2635 /* Link (backwards, for stacking order) */
2636 for (i = MAX_TERM_DATA - 1; i >= 0; i--)
2645 Term_activate(td->t);
2648 static void init_sound( void )
2652 SignedByte permission = fsRdPerm;
2658 /* Descend into "lib" folder */
2659 pb.ioCompletion = NULL;
2660 pb.ioNamePtr = "\plib";
2661 pb.ioVRefNum = app_vol;
2662 pb.ioDrDirID = app_dir;
2665 /* Check for errors */
2666 err = PBGetCatInfo((CInfoPBPtr)&pb, FALSE);
2669 if ((err == noErr) && (pb.ioFlAttrib & 0x10))
2671 /* Descend into "lib/save" folder */
2672 pb.ioCompletion = NULL;
2673 pb.ioNamePtr = "\pxtra";
2674 pb.ioVRefNum = app_vol;
2675 pb.ioDrDirID = pb.ioDrDirID;
2678 /* Check for errors */
2679 err = PBGetCatInfo((CInfoPBPtr)&pb, FALSE);
2682 if ((err == noErr) && (pb.ioFlAttrib & 0x10))
2684 /* Descend into "lib/save" folder */
2685 pb.ioCompletion = NULL;
2686 pb.ioNamePtr = "\psound";
2687 pb.ioVRefNum = app_vol;
2688 pb.ioDrDirID = pb.ioDrDirID;
2691 /* Check for errors */
2692 err = PBGetCatInfo((CInfoPBPtr)&pb, FALSE);
2695 if ((err == noErr) && (pb.ioFlAttrib & 0x10))
2697 ret = HOpenResFile( app_vol , pb.ioDrDirID , "\psound.rsrc" , permission );
2701 for( i = 0 ; i < 7 ; i++ )
2702 soundmode[i] = false;
2704 for( i = 1 ; i < SOUND_MAX ; i++ ){
2705 /* Get the proper sound name */
2706 sprintf((char*)sound + 1, "%.16s.wav", angband_sound_name[i]);
2707 sound[0] = strlen((char*)sound + 1);
2709 /* Obtain resource XXX XXX XXX */
2710 handle = Get1NamedResource('snd ', sound);
2711 if( handle == NULL || ext_sound )
2712 handle = GetNamedResource('snd ', sound);
2715 soundmode[soundchoice[i]] = true;
2728 static void init_chuukei( void )
2734 path_build(path, 1024, ANGBAND_DIR_XTRA, "chuukei.txt");
2736 fp = fopen(path, "r");
2741 if (fgets(tmp, 1024, fp)){
2743 int n = strlen(tmp);
2749 chuukei_server = TRUE;
2750 if(connect_chuukei_server(&tmp[2])<0){
2751 msg_print("connect fail");
2754 msg_print("connect");
2761 chuukei_client = TRUE;
2762 connect_chuukei_server(&tmp[2]);
2778 short InevrtCheck( DialogPtr targetDlg, short check )
2785 GetDialogItem( targetDlg, check, &itemType, &checkH, &box );
2786 result = (GetControlValue( (ControlHandle)checkH ) + 1 ) % 2;
2787 SetControlValue( (ControlHandle)checkH , result );
2795 short SetCheck( DialogPtr targetDlg, short check, long result )
2802 GetDialogItem( targetDlg, check, &itemType, &checkH, &box );
2803 SetControlValue( (ControlHandle)checkH , result );
2811 short GetCheck( DialogPtr targetDlg, short check )
2818 GetDialogItem( targetDlg, check, &itemType, &checkH, &box );
2819 result = GetControlValue( (ControlHandle)checkH );
2823 void SoundConfigDLog(void)
2830 dialog=GetNewDialog(131, 0, (WindowPtr)-1);
2831 SetDialogDefaultItem( dialog, ok );
2832 SetDialogCancelItem( dialog, cancel );
2833 for( i = 1 ; i < 7 ; i++ )
2834 SetCheck( dialog, i+2 , soundmode[i] );
2837 for( item_hit = 100 ; cancel < item_hit ; ){
2838 ModalDialog(0, &item_hit);
2842 for( i = 1 ; i < 7 ; i++ )
2843 soundmode[i] = GetCheck( dialog, i+2 );
2848 InevrtCheck( dialog, item_hit );
2851 DisposeDialog(dialog);
2859 static void save_pref_file(void)
2868 /* Assume failure */
2871 /* Assume failure */
2888 /* Find the folder */
2889 err = FindFolder(kOnSystemDisk, kPreferencesFolderType, kCreateFolder,
2895 /* Extract a path name */
2896 PathNameFromDirID(dirID, vref, (StringPtr)foo);
2898 /* Convert the string */
2899 ptocstr((StringPtr)foo);
2901 /* Append the preference file name */
2902 strcat(foo, PREF_FILE_NAME);
2904 /* Open the preference file */
2905 /* my_fopen set file type and file creator for MPW */
2906 fff = my_fopen(foo, "w");
2913 #endif /* USE_SFL_CODE */
2919 HGetVol(0, &savev, &saved);
2921 /* Go to "system" folder */
2922 SysEnvirons(curSysEnvVers, &env);
2923 SetVol(0, env.sysVRefNum);
2925 /* Open the preference file */
2926 /* my_fopen set file type and file creator for MPW */
2927 fff = fopen(PREF_FILE_NAME, "w");
2930 HSetVol(0, savev, saved);
2933 /* Save preferences */
2936 /* Write the preferences */
2947 * A simple "Yes/No" filter to parse "key press" events in dialog windows
2949 static pascal Boolean ynfilter(DialogPtr dialog, EventRecord *event, short *ip)
2951 /* Parse key press events */
2952 if (event->what == keyDown)
2957 /* Extract the pressed key */
2958 c = (event->message & charCodeMask);
2960 /* Accept "no" and <return> and <enter> */
2961 if ((c=='n') || (c=='N') || (c==13) || (c==3)) i = 1;
2964 else if ((c=='y') || (c=='Y')) i = 2;
2966 /* Handle "yes" or "no" */
2970 ControlHandle control;
2973 /* Get the button */
2974 GetDialogItem(dialog, i, &type, (Handle*)&control, &r); //GetDItem(dialog, i, &type, (Handle*)&control, &r);
2976 /* Blink button for 1/10 second */
2977 HiliteControl(control, 1);
2978 Term_xtra_mac(TERM_XTRA_DELAY, 100);
2979 HiliteControl(control, 0);
2993 * Handle menu: "File" + "New"
2995 static void do_menu_file_new(void)
3000 /* Game is in progress */
3001 game_in_progress = 1;
3015 * Handle menu: "File" + "Open"
3017 static void do_menu_file_open(bool all)
3031 /* vrefnum = GetSFCurVol(); */
3032 vrefnum = -*((short*)0x214);
3034 /* drefnum = GetSFCurDir(); */
3035 drefnum = *((long*)0x398);
3037 /* Descend into "lib" folder */
3038 pb.ioCompletion = NULL;
3039 pb.ioNamePtr = "\plib";
3040 pb.ioVRefNum = vrefnum;
3041 pb.ioDrDirID = drefnum;
3044 /* Check for errors */
3045 err = PBGetCatInfo((CInfoPBPtr)&pb, FALSE);
3048 if ((err == noErr) && (pb.ioFlAttrib & 0x10))
3050 /* Descend into "lib/save" folder */
3051 pb.ioCompletion = NULL;
3052 pb.ioNamePtr = "\psave";
3053 pb.ioVRefNum = vrefnum;
3054 pb.ioDrDirID = pb.ioDrDirID;
3057 /* Check for errors */
3058 err = PBGetCatInfo((CInfoPBPtr)&pb, FALSE);
3061 if ((err == noErr) && (pb.ioFlAttrib & 0x10))
3063 /* SetSFCurDir(pb.ioDrDirID); */
3064 *((long*)0x398) = pb.ioDrDirID;
3068 /* Window location */
3069 topleft.h = (qd.screenBits.bounds.left+qd.screenBits.bounds.right)/2-344/2;
3070 topleft.v = (2*qd.screenBits.bounds.top+qd.screenBits.bounds.bottom)/3-188/2;
3072 /* Allow "all" files */
3076 SFGetFile(topleft, "\p", NULL, -1, types, NULL, &reply);
3079 /* Allow "save" files */
3086 SFGetFile(topleft, "\p", NULL, 1, types, NULL, &reply);
3090 if (!reply.good) return;
3092 /* Extract textual file name for save file */
3093 GetWDInfo(reply.vRefNum, &vrefnum, &drefnum, &junk);
3094 refnum_to_name(savefile, drefnum, vrefnum, (char*)reply.fName);
3099 /* Game is in progress */
3100 game_in_progress = 1;
3114 * Handle the "open_when_ready" flag
3116 static void handle_open_when_ready(void)
3118 /* Check the flag XXX XXX XXX make a function for this */
3119 if (open_when_ready && initialized && !game_in_progress)
3122 open_when_ready = FALSE;
3124 /* Game is in progress */
3125 game_in_progress = 1;
3144 * Initialize the menus
3146 * Verify menus 128, 129, 130
3147 * Create menus 131, 132, 133, 134
3149 * The standard menus are:
3151 * Apple (128) = { About, -, ... }
3152 * File (129) = { New,Open,Import,Close,Save,-,Exit,Quit }
3153 * Edit (130) = { Cut, Copy, Paste, Clear } (?)
3154 * Font (131) = { Bold, Extend, -, Monaco, ..., -, ... }
3155 * Size (132) = { ... }
3156 * Window (133) = { Angband, Mirror, Recall, Choice,
3157 * Term-4, Term-5, Term-6, Term-7 }
3158 * Special (134) = { arg_sound, arg_graphics, -,
3159 * arg_fiddle, arg_wizard }
3161 static void init_menubar(void)
3172 /* Get the "apple" menu */
3175 /* Insert the menu */
3178 /* Add the DA's to the "apple" menu */
3179 AppendResMenu (m, 'DRVR'); //AddResMenu(m, 'DRVR');
3182 /* Get the "File" menu */
3185 /* Insert the menu */
3189 /* Get the "Edit" menu */
3192 /* Insert the menu */
3196 /* Make the "Font" menu */
3198 m = NewMenu(131, "\p¥Õ¥©¥ó¥È");
3200 m = NewMenu(131, "\pFont");
3203 /* Insert the menu */
3207 AppendMenu(m, "\pBold");
3210 AppendMenu(m, "\pWide");
3212 /* Add a separator */
3213 AppendMenu(m, "\p-");
3216 r.left = r.right = r.top = r.bottom = 0;
3218 /* Make the fake window */
3219 tmpw = NewWindow(0, &r, "\p", false, documentProc, 0, 0, 0);
3221 /* Activate the "fake" window */
3230 /* Add the fonts to the menu */
3231 AppendResMenu(m, 'FONT'); //AddResMenu(m, 'FONT');
3237 for (i = n; i >= 4; i--)
3242 /* Acquire the font name */
3243 /* GetMenuItemText(m, i, tmpName); */
3244 GetMenuItemText(m, i, tmpName); //GetItem(m, i, tmpName);
3246 /* Acquire the font index */
3247 GetFNum(tmpName, &fontNum);
3249 /* Apply the font index */
3252 /* Remove non-mono-spaced fonts */
3253 if ((CharWidth('i') != CharWidth('W')) || (CharWidth('W') == 0))
3255 /* Delete the menu item XXX XXX XXX */
3256 /* DeleteMenuItem(m, i); */
3257 DeleteMenuItem (m, i); //DelMenuItem(m, i);
3261 /* Destroy the old window */
3262 DisposeWindow(tmpw);
3264 /* Add a separator */
3265 AppendMenu(m, "\p-");
3267 /* Add the fonts to the menu */
3268 AppendResMenu (m, 'FONT'); //AddResMenu(m, 'FONT');
3271 /* Make the "Size" menu */
3273 m = NewMenu(132, "\p¥µ¥¤¥º");
3275 m = NewMenu(132, "\pSize");
3278 /* Insert the menu */
3281 /* Add some sizes (stagger choices) */
3282 for (i = 8; i <= 32; i += ((i / 16) + 1))
3287 sprintf((char*)buf + 1, "%d", i);
3288 buf[0] = strlen((char*)buf + 1);
3295 /* Make the "Windows" menu */
3297 m = NewMenu(133, "\p¥¦¥¤¥ó¥É¥¦");
3299 m = NewMenu(133, "\pWindows");
3302 /* Insert the menu */
3305 /* Default choices */
3306 for (i = 0; i < MAX_TERM_DATA; i++)
3310 /* Describe the item */
3311 sprintf((char*)buf + 1, "%.15s", angband_term_name[i]);
3312 buf[0] = strlen((char*)buf + 1);
3317 /* Command-Key shortcuts */
3318 if (i < 8) SetItemCmd(m, i + 1, '0' + i);
3322 /* Make the "Special" menu */
3324 m = NewMenu(134, "\pÆÃÊÌ");
3326 m = NewMenu(134, "\pSpecial");
3329 /* Insert the menu */
3332 /* Append the choices */
3334 AppendMenu(m, "\p¥µ¥¦¥ó¥É»ÈÍÑ");
3335 AppendMenu(m, "\p¥°¥é¥Õ¥£¥Ã¥¯»ÈÍÑ");
3336 AppendMenu(m, "\p-");
3337 AppendMenu(m, "\parg_fiddle");
3338 AppendMenu(m, "\parg_wizard");
3339 AppendMenu(m, "\p-");
3340 AppendMenu(m, "\p¥µ¥¦¥ó¥ÉÀßÄê...");
3341 AppendMenu(m, "\p16X16¥°¥é¥Õ¥£¥Ã¥¯");
3342 AppendMenu(m, "\p£²ÇÜÉý¥¿¥¤¥ëɽ¼¨");
3344 AppendMenu(m, "\parg_sound");
3345 AppendMenu(m, "\parg_graphics");
3346 AppendMenu(m, "\p-");
3347 AppendMenu(m, "\parg_fiddle");
3348 AppendMenu(m, "\parg_wizard");
3349 AppendMenu(m, "\p-");
3350 AppendMenu(m, "\pSound config");
3351 AppendMenu(m, "\pAdam Bolt tile");
3352 AppendMenu(m, "\pBigtile Mode");
3355 /* Make the "TileWidth" menu */
3357 m = NewMenu(135, "\p¥¿¥¤¥ëÉý");
3359 m = NewMenu(135, "\pTileWidth");
3362 /* Insert the menu */
3365 /* Add some sizes */
3366 for (i = 4; i <= 32; i++)
3371 sprintf((char*)buf + 1, "%d", i);
3372 buf[0] = strlen((char*)buf + 1);
3379 /* Make the "TileHeight" menu */
3381 m = NewMenu(136, "\p¥¿¥¤¥ë¹â");
3383 m = NewMenu(136, "\pTileHeight");
3386 /* Insert the menu */
3389 /* Add some sizes */
3390 for (i = 4; i <= 32; i++)
3395 sprintf((char*)buf + 1, "%d", i);
3396 buf[0] = strlen((char*)buf + 1);
3403 /* Update the menu bar */
3411 static void setup_menus(void)
3421 term_data *td = NULL;
3424 /* Relevant "term_data" */
3425 for (i = 0; i < MAX_TERM_DATA; i++)
3428 if (!data[i].t) continue;
3430 /* Notice the matching window */
3431 if (data[i].w == FrontWindow()) td = &data[i];
3436 m = GetMenuHandle(129); //m = GetMHandle(129);
3442 for (i = 1; i <= n; i++)
3446 CheckItem(m, i, FALSE);
3449 /* Enable "new"/"open..."/"import..." */
3450 if (initialized && !game_in_progress)
3457 /* Enable "close" */
3464 if (initialized && character_generated)
3477 m = GetMenuHandle(130); //m = GetMHandle(130);
3483 for (i = 1; i <= n; i++)
3487 CheckItem(m, i, FALSE);
3490 /* Enable "edit" options if "needed" */
3502 m = GetMenuHandle(131); //m = GetMHandle(131);
3508 for (i = 1; i <= n; i++)
3512 CheckItem(m, i, FALSE);
3515 /* Hack -- look cute XXX XXX */
3516 /* SetItemStyle(m, 1, bold); */
3518 /* Hack -- look cute XXX XXX */
3519 /* SetItemStyle(m, 2, extend); */
3527 /* Enable "extend" */
3530 /* Check the appropriate "bold-ness" */
3531 if (td->font_face & bold) CheckItem(m, 1, TRUE);
3533 /* Check the appropriate "wide-ness" */
3534 if (td->font_face & extend) CheckItem(m, 2, TRUE);
3537 for (i = 4; i <= n; i++)
3543 /* GetMenuItemText(m,i,s); */
3544 GetMenuItemText(m, i, s); //GetItem(m, i, s);
3547 /* Check active font */
3548 if (td->font_id == value) CheckItem(m, i, TRUE);
3554 m = GetMenuHandle(132); //m = GetMHandle(132);
3560 for (i = 1; i <= n; i++)
3564 CheckItem(m, i, FALSE);
3571 for (i = 1; i <= n; i++)
3574 /* GetMenuItemText(m,i,s); */
3575 GetMenuItemText(m, i, s); //GetItem(m, i, s);
3577 value = atoi((char*)(s+1));
3579 /* Enable the "real" sizes */
3580 if (RealFont(td->font_id, value)) EnableItem(m, i);
3582 /* Check the current size */
3583 if (td->font_size == value) CheckItem(m, i, TRUE);
3589 m = GetMenuHandle(133); //m = GetMHandle(133);
3594 /* Check active windows */
3595 for (i = 1; i <= n; i++)
3597 /* Check if needed */
3598 CheckItem(m, i, data[i-1].mapped);
3603 m = GetMenuHandle(134); //m = GetMHandle(134);
3609 for (i = 1; i <= n; i++)
3613 CheckItem(m, i, FALSE);
3616 /* Item "arg_sound" */
3618 CheckItem(m, 1, arg_sound);
3620 /* Item "arg_graphics" */
3622 CheckItem(m, 2, arg_graphics);
3624 /* Item "arg_fiddle" */
3626 CheckItem(m, 4, arg_fiddle);
3628 /* Item "arg_wizard" */
3630 CheckItem(m, 5, arg_wizard);
3632 /* Item "SoundSetting" */
3635 /* Item NewStyle Graphics */
3637 CheckItem(m, 8, use_newstyle_graphics);
3639 /* Item Bigtile Mode */
3641 CheckItem(m, 9, arg_bigtile);
3644 /* TileWidth menu */
3645 m = GetMenuHandle(135); //m = GetMHandle(135);
3651 for (i = 1; i <= n; i++)
3655 CheckItem(m, i, FALSE);
3662 for (i = 1; i <= n; i++)
3665 /* GetMenuItemText(m,i,s); */
3666 GetMenuItemText(m, i, s); //GetItem(m, i, s);
3668 value = atoi((char*)(s+1));
3673 /* Check the current size */
3674 if (td->tile_wid == value) CheckItem(m, i, TRUE);
3679 /* TileHeight menu */
3680 m = GetMenuHandle(136); //m = GetMHandle(136);
3686 for (i = 1; i <= n; i++)
3690 CheckItem(m, i, FALSE);
3697 for (i = 1; i <= n; i++)
3700 /* GetMenuItemText(m,i,s); */
3701 GetMenuItemText(m, i, s); //GetItem(m, i, s);
3703 value = atoi((char*)(s+1));
3708 /* Check the current size */
3709 if (td->tile_hgt == value) CheckItem(m, i, TRUE);
3716 * Process a menu selection (see above)
3718 * Hack -- assume that invalid menu selections are disabled above,
3719 * which I have been informed may not be reliable. XXX XXX XXX
3721 static void menu(long mc)
3725 int menuid, selection;
3727 static unsigned char s[1000];
3731 term_data *td = NULL;
3736 /* Analyze the menu command */
3737 menuid = HiWord(mc);
3738 selection = LoWord(mc);
3741 /* Find the window */
3742 for (i = 0; i < MAX_TERM_DATA; i++)
3744 /* Skip dead windows */
3745 if (!data[i].t) continue;
3747 /* Notice matches */
3748 if (data[i].w == FrontWindow()) td = &data[i];
3752 /* Branch on the menu */
3758 /* About Angband... */
3765 dialog=GetNewDialog(128, 0, (WindowPtr)-1);
3768 center_rect(&r, &qd.screenBits.bounds);
3769 MoveWindow(dialog, r.left, r.top, 1);
3771 ModalDialog(0, &item_hit);
3772 DisposeDialog(dialog); //DisposDialog(dialog);
3776 /* Desk accessory */
3777 /* GetMenuItemText(GetMHandle(128),selection,s); */
3778 GetMenuItemText(GetMenuHandle(128), selection, s); //GetItem(GetMHandle(128), selection, s);
3798 do_menu_file_open(FALSE);
3805 do_menu_file_open(TRUE);
3819 td->t->mapped_flag = FALSE;
3821 /* Hide the window */
3832 plog("º£¤Ï¥»¡¼¥Ö¤¹¤ë¤³¤È¤Ï½ÐÍè¤Þ¤»¤ó¡£");
3834 plog("You may not do that right now.");
3839 /* Hack -- Forget messages */
3842 /* Hack -- Save the game */
3843 do_cmd_save_game(FALSE);
3848 /* Quit (with save) */
3851 /* Save the game (if necessary) */
3852 if (game_in_progress && character_generated)
3856 plog("º£¤Ï¥»¡¼¥Ö¤¹¤ë¤³¤È¤Ï½ÐÍè¤Þ¤»¤ó¡£");
3858 plog("You may not do that right now.");
3862 /* Hack -- Forget messages */
3866 // do_cmd_save_game(FALSE);
3867 Term_key_push(KTRL('X'));
3889 /* Require a window */
3898 /* Toggle the "bold" setting */
3901 /* Toggle the setting */
3902 if (td->font_face & bold)
3904 td->font_face &= ~bold;
3908 td->font_face |= bold;
3911 /* Tile Width Hight Init */
3912 td->tile_wid = td->tile_hgt = 0;
3914 /* Apply and Verify */
3915 term_data_check_font(td);
3916 term_data_check_size(td);
3918 /* Resize and Redraw */
3919 term_data_resize(td);
3920 term_data_redraw(td);
3925 /* Toggle the "wide" setting */
3928 /* Toggle the setting */
3929 if (td->font_face & extend)
3931 td->font_face &= ~extend;
3935 td->font_face |= extend;
3938 /* Tile Width Hight Init */
3939 td->tile_wid = td->tile_hgt = 0;
3941 /* Apply and Verify */
3942 term_data_check_font(td);
3943 term_data_check_size(td);
3945 /* Resize and Redraw */
3946 term_data_resize(td);
3947 term_data_redraw(td);
3952 /* Get a new font name */
3953 /* GetMenuItemText(GetMHandle(131), selection, s); */
3954 GetMenuItemText(GetMenuHandle(131), selection, s); //GetItem(GetMHandle(131), selection, s);
3957 /* Save the new font id */
3960 /* Current size is bad for new font */
3961 if (!RealFont(td->font_id, td->font_size))
3963 /* Find similar size */
3964 for (i = 1; i <= 32; i++)
3966 /* Adjust smaller */
3967 if (td->font_size - i >= 8)
3969 if (RealFont(td->font_id, td->font_size - i))
3977 if (td->font_size + i <= 128)
3979 if (RealFont(td->font_id, td->font_size + i))
3988 /* Tile Width Hight Init */
3989 td->tile_wid = td->tile_hgt = 0;
3991 /* Apply and Verify */
3992 term_data_check_font(td);
3993 term_data_check_size(td);
3995 /* Resize and Redraw */
3996 term_data_resize(td);
3997 term_data_redraw(td);
3999 /* Restore the window */
4016 /* GetMenuItemText(GetMHandle(132), selection, s); */
4017 GetMenuItemText(GetMenuHandle(132), selection, s); //GetItem(GetMHandle(132), selection, s);
4019 td->font_size = atoi((char*)(s+1));
4021 /* Tile Width Hight Init */
4022 td->tile_wid = td->tile_hgt = 0;
4024 /* Apply and Verify */
4025 term_data_check_font(td);
4026 term_data_check_size(td);
4028 /* Resize and Redraw */
4029 term_data_resize(td);
4030 term_data_redraw(td);
4044 /* Check legality of choice */
4045 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
4047 /* Obtain the window */
4057 td->t->mapped_flag = TRUE;
4059 /* Show the window */
4062 /* Bring to the front */
4063 SelectWindow(td->w);
4075 /* Toggle arg_sound */
4076 arg_sound = !arg_sound;
4078 /* React to changes */
4079 Term_xtra(TERM_XTRA_REACT, 0);
4086 /* Toggle arg_graphics */
4087 arg_graphics = !arg_graphics;
4089 /* Hack -- Force redraw */
4090 Term_key_push(KTRL('R'));
4097 arg_fiddle = !arg_fiddle;
4103 arg_wizard = !arg_wizard;
4114 if (streq(ANGBAND_GRAF, "old"))
4116 ANGBAND_GRAF = "new";
4117 arg_newstyle_graphics = true;
4118 grafWidth = grafHeight = 16;
4123 ANGBAND_GRAF = "old";
4124 arg_newstyle_graphics = false;
4125 grafWidth = grafHeight = 8;
4129 /* Hack -- Force redraw */
4130 Term_key_push(KTRL('R'));
4134 case 9: /* bigtile mode */
4136 term_data *td = &data[0];
4140 plog("º£¤ÏÊѹ¹½ÐÍè¤Þ¤»¤ó¡£");
4142 plog("You may not do that right now.");
4147 /* Toggle "arg_bigtile" */
4148 arg_bigtile = !arg_bigtile;
4151 Term_activate(td->t);
4153 /* Resize the term */
4154 Term_resize(td->cols, td->rows);
4164 /* TileWidth menu */
4175 /* GetMenuItemText(GetMHandle(135), selection, s); */
4176 GetMenuItemText(GetMenuHandle(135), selection, s); //GetItem(GetMHandle(135), selection, s);
4178 td->tile_wid = atoi((char*)(s+1));
4180 /* Apply and Verify */
4181 term_data_check_size(td);
4183 /* Resize and Redraw */
4184 term_data_resize(td);
4185 term_data_redraw(td);
4193 /* TileHeight menu */
4204 /* GetMenuItemText(GetMHandle(136), selection, s); */
4205 GetMenuItemText(GetMenuHandle(136), selection, s); //GetItem(GetMHandle(136), selection, s);
4207 td->tile_hgt = atoi((char*)(s+1));
4209 /* Apply and Verify */
4210 term_data_check_size(td);
4212 /* Resize and Redraw */
4213 term_data_resize(td);
4214 term_data_redraw(td);
4224 /* Clean the menu */
4233 * Check for extra required parameters -- From "Maarten Hazewinkel"
4235 static OSErr CheckRequiredAEParams(const AppleEvent *theAppleEvent)
4238 DescType returnedType;
4241 aeError = AEGetAttributePtr(theAppleEvent, keyMissedKeywordAttr, typeWildCard,
4242 &returnedType, NULL, 0, &actualSize);
4244 if (aeError == errAEDescNotFound) return (noErr);
4246 if (aeError == noErr) return (errAEParamMissed);
4253 * Apple Event Handler -- Open Application
4255 static pascal OSErr AEH_Start(const AppleEvent *theAppleEvent,
4256 const AppleEvent *reply, long handlerRefCon)
4258 #pragma unused(reply, handlerRefCon)
4260 return (CheckRequiredAEParams(theAppleEvent));
4265 * Apple Event Handler -- Quit Application
4267 static pascal OSErr AEH_Quit(const AppleEvent *theAppleEvent,
4268 const AppleEvent *reply, long handlerRefCon)
4270 #pragma unused(reply, handlerRefCon)
4273 quit_when_ready = TRUE;
4275 /* Check arguments */
4276 return (CheckRequiredAEParams(theAppleEvent));
4281 * Apple Event Handler -- Print Documents
4283 static pascal OSErr AEH_Print(const AppleEvent *theAppleEvent,
4284 const AppleEvent *reply, long handlerRefCon)
4286 #pragma unused(theAppleEvent, reply, handlerRefCon)
4288 return (errAEEventNotHandled);
4293 * Apple Event Handler by Steve Linberg (slinberg@crocker.com).
4295 * The old method of opening savefiles from the finder does not work
4296 * on the Power Macintosh, because CountAppFiles and GetAppFiles,
4297 * used to return information about the selected document files when
4298 * an application is launched, are part of the Segment Loader, which
4299 * is not present in the RISC OS due to the new memory architecture.
4301 * The "correct" way to do this is with AppleEvents. The following
4302 * code is modeled on the "Getting Files Selected from the Finder"
4303 * snippet from Think Reference 2.0. (The prior sentence could read
4304 * "shamelessly swiped & hacked")
4306 static pascal OSErr AEH_Open(AppleEvent *theAppleEvent,
4307 AppleEvent* reply, long handlerRefCon)
4309 #pragma unused(reply, handlerRefCon)
4316 DescType returnedType;
4320 /* Put the direct parameter (a descriptor list) into a docList */
4321 err = AEGetParamDesc(theAppleEvent, keyDirectObject, typeAEList, &docList);
4322 if (err) return err;
4325 * We ignore the validity check, because we trust the FInder, and we only
4326 * allow one savefile to be opened, so we ignore the depth of the list.
4329 err = AEGetNthPtr(&docList, 1L, typeFSS, &keywd,
4330 &returnedType, (Ptr) &myFSS, sizeof(myFSS), &actualSize);
4331 if (err) return err;
4333 /* Only needed to check savefile type below */
4334 err = FSpGetFInfo(&myFSS, &myFileInfo);
4337 sprintf(foo, "Arg! FSpGetFInfo failed with code %d", err);
4342 /* Ignore non 'SAVE' files */
4343 if (myFileInfo.fdType != 'SAVE') return noErr;
4345 /* XXX XXX XXX Extract a file name */
4346 PathNameFromDirID(myFSS.parID, myFSS.vRefNum, (StringPtr)savefile);
4347 pstrcat((StringPtr)savefile, (StringPtr)&myFSS.name);
4349 /* Convert the string */
4350 ptocstr((StringPtr)savefile);
4352 /* Delay actual open */
4353 open_when_ready = TRUE;
4356 err = AEDisposeDesc(&docList);
4368 * Macintosh modifiers (event.modifier & ccc):
4369 * cmdKey, optionKey, shiftKey, alphaLock, controlKey
4372 * Macintosh Keycodes (0-63 normal, 64-95 keypad, 96-127 extra):
4417 * Optimize non-blocking calls to "CheckEvents()"
4418 * Idea from "Maarten Hazewinkel <mmhazewi@cs.ruu.nl>"
4420 #define EVENT_TICKS 6
4424 * Check for Events, return TRUE if we process any
4426 * Hack -- Handle AppleEvents if appropriate (ignore result code).
4428 static bool CheckEvents(bool wait)
4444 term_data *td = NULL;
4448 static huge lastTicks = 0L;
4451 /* Access the clock */
4452 curTicks = TickCount();
4454 /* Hack -- Allow efficient checking for non-pending events */
4455 if (!wait && (curTicks < lastTicks + EVENT_TICKS)) return (FALSE);
4457 /* Timestamp last check */
4458 lastTicks = curTicks;
4460 /* Let the "system" run */
4463 /* Get an event (or null) */
4464 GetNextEvent(everyEvent, &event);
4466 /* Hack -- Nothing is ready yet */
4467 if (event.what == nullEvent) return (FALSE);
4470 /* Analyze the event */
4478 w = (WindowPtr)event.message;
4489 /* Extract the window */
4490 w = (WindowPtr)event.message;
4492 /* Find the window */
4493 for (i = 0; i < MAX_TERM_DATA; i++)
4495 /* Skip dead windows */
4496 if (!data[i].t) continue;
4498 /* Notice matches */
4499 if (data[i].w == w) td = &data[i];
4502 /* Hack XXX XXX XXX */
4506 /* Redraw the window */
4507 if (td) term_data_redraw(td);
4515 /* Extract some modifiers */
4516 mc = (event.modifiers & controlKey) ? TRUE : FALSE;
4517 ms = (event.modifiers & shiftKey) ? TRUE : FALSE;
4518 mo = (event.modifiers & optionKey) ? TRUE : FALSE;
4519 mx = (event.modifiers & cmdKey) ? TRUE : FALSE;
4521 /* Keypress: (only "valid" if ck < 96) */
4522 ch = (event.message & charCodeMask) & 255;
4524 /* Keycode: see table above */
4525 ck = ((event.message & keyCodeMask) >> 8) & 255;
4527 /* Command + "normal key" -> menu action */
4528 if (mx && (ck < 64))
4530 /* Hack -- Prepare the menus */
4533 /* Run the Menu-Handler */
4536 /* Turn off the menus */
4544 /* Hide the mouse pointer */
4547 /* Normal key -> simple keypress */
4550 /* Enqueue the keypress */
4554 /* Hack -- normal "keypad keys" -> special keypress */
4555 else if (!mc && !ms && !mo && !mx && (ck < 96))
4557 /* Hack -- "enter" is confused */
4558 if (ck == 76) ch = '\n';
4560 /* Send control-caret as a trigger */
4563 /* Send the "ascii" keypress */
4567 /* Bizarre key -> encoded keypress */
4570 /* Hack -- introduce with control-underscore */
4573 /* Send some modifier keys */
4574 if (mc) Term_keypress('C');
4575 if (ms) Term_keypress('S');
4576 if (mo) Term_keypress('O');
4577 if (mx) Term_keypress('X');
4579 /* Hack -- Downshift and encode the keycode */
4580 Term_keypress('0' + (ck - 64) / 10);
4581 Term_keypress('0' + (ck - 64) % 10);
4583 /* Hack -- Terminate the sequence */
4584 /* MPW can generate 10 or 13 for keycode of '\r' */
4585 /* -noMapCR option swaps '\r' and '\n' */
4586 Term_keypress('\r');
4596 /* Analyze click location */
4597 code = FindWindow(event.where, &w);
4599 /* Find the window */
4600 for (i = 0; i < MAX_TERM_DATA; i++)
4602 /* Skip dead windows */
4603 if (!data[i].t) continue;
4605 /* Notice matches */
4606 if (data[i].w == w) td = &data[i];
4615 menu(MenuSelect(event.where));
4622 SystemClick(&event, w);
4632 r = qd.screenBits.bounds;
4633 r.top += 20; /* GetMBarHeight() XXX XXX XXX */
4634 InsetRect(&r, 4, 4);
4635 DragWindow(w, event.where, &r);
4647 p.h = td->w->portRect.left;
4648 p.v = td->w->portRect.top;
4656 /* Apply and Verify */
4657 term_data_check_size(td);
4667 /* Track the go-away box */
4668 if (TrackGoAway(w, event.where))
4674 td->t->mapped_flag = FALSE;
4676 /* Hide the window */
4692 /* Fake rectangle */
4693 r.left = 20 * td->tile_wid + td->size_ow1;
4694 r.right = qd.screenBits.bounds.right;
4695 r.top = 1 * td->tile_hgt + td->size_oh1;
4696 r.bottom = qd.screenBits.bounds.bottom;
4698 /* Grow the rectangle */
4699 newsize = GrowWindow(w, event.where, &r);
4702 if (!newsize) break;
4704 /* Extract the new size in pixels */
4705 y = HiWord(newsize) - td->size_oh1 - td->size_oh2;
4706 x = LoWord(newsize) - td->size_ow1 - td->size_ow2;
4708 /* Extract a "close" approximation */
4709 td->rows = y / td->tile_hgt;
4710 td->cols = x / td->tile_wid;
4712 /* Apply and Verify */
4713 term_data_check_size(td);
4715 Term_activate(td->t);
4717 /* Hack -- Resize the term */
4718 Term_resize(td->cols, td->rows);
4720 /* Resize and Redraw */
4721 term_data_resize(td);
4722 term_data_redraw(td);
4741 /* Disk Event -- From "Maarten Hazewinkel" */
4744 /* check for error when mounting the disk */
4745 if (HiWord(event.message) != noErr)
4751 DIBadMount(p, event.message);
4758 /* OS Event -- From "Maarten Hazewinkel" */
4761 switch ((event.message >> 24) & 0x000000FF)
4763 case suspendResumeMessage:
4765 /* Resuming: activate the front window */
4766 if (event.message & resumeFlag)
4768 SetPort(FrontWindow());
4769 SetCursor(&qd.arrow);
4772 /* Suspend: deactivate the front window */
4786 /* From "Steve Linberg" and "Maarten Hazewinkel" */
4787 case kHighLevelEvent:
4789 /* Process apple events */
4790 if (AEProcessAppleEvent(&event) != noErr)
4793 plog("Apple Event Handler¤Î¥¨¥é¡¼¤Ç¤¹.");
4795 plog("Error in Apple Event Handler!");
4799 /* Handle "quit_when_ready" */
4800 if (quit_when_ready)
4803 quit_when_ready = FALSE;
4805 /* Do the menu key */
4808 /* Turn off the menus */
4812 /* Handle "open_when_ready" */
4813 handle_open_when_ready();
4823 /* Something happened */
4830 /*** Some Hooks for various routines ***/
4834 * Mega-Hack -- emergency lifeboat
4836 static vptr lifeboat = NULL;
4840 * Hook to "release" memory
4842 static vptr hook_rnfree(vptr v, huge size)
4845 #pragma unused (size)
4849 /* Alternative method */
4864 * Hook to "allocate" memory
4866 static vptr hook_ralloc(huge size)
4871 /* Make a new pointer */
4872 return (malloc(size));
4876 /* Make a new pointer */
4877 return (NewPtr(size));
4884 * Hook to handle "out of memory" errors
4886 static vptr hook_rpanic(huge size)
4889 #pragma unused (size)
4893 /* Free the lifeboat */
4896 /* Free the lifeboat */
4897 DisposePtr(lifeboat);
4899 /* Forget the lifeboat */
4902 /* Mega-Hack -- Warning */
4904 mac_warning("¥á¥â¥ê¡¼¤¬Â¤ê¤Þ¤»¤ó!\rº£¤¹¤°½ªÎ»¤·¤Æ²¼¤µ¤¤!");
4906 mac_warning("Running out of Memory!\rAbort this process now!");
4909 /* Mega-Hack -- Never leave this function */
4910 while (TRUE) CheckEvents(TRUE);
4913 /* Mega-Hack -- Crash */
4919 * Hook to tell the user something important
4921 static void hook_plog(cptr str)
4923 /* Warning message */
4928 * Hook to tell the user something, and then quit
4930 static void hook_quit(cptr str)
4932 /* Warning if needed */
4933 if (str) mac_warning(str);
4935 /* Write a preference file */
4943 * Hook to tell the user something, and then crash
4945 static void hook_core(cptr str)
4947 /* XXX Use the debugger */
4948 /* DebugStr(str); */
4951 if (str) mac_warning(str);
4953 /* Warn, then save player */
4955 mac_warning("Ã×̿Ū¤Ê¥¨¥é¡¼¤Ç¤¹.\r¶¯À©Åª¤Ë¥»¡¼¥Ö¤·¤Æ½ªÎ»¤·¤Þ¤¹.");
4957 mac_warning("Fatal error.\rI will now attempt to save and quit.");
4960 /* Attempt to save */
4962 if (!save_player()) mac_warning("·Ù¹ð -- ¥»¡¼¥Ö¤Ë¼ºÇÔ¤·¤Þ¤·¤¿!");
4964 if (!save_player()) mac_warning("Warning -- save failed!");
4973 /*** Main program ***/
4979 * XXX XXX XXX Hack -- This function attempts to "fix" the nasty
4980 * "Macintosh Save Bug" by using "absolute" path names, since on
4981 * System 7 machines anyway, the "current working directory" often
4982 * "changes" due to background processes, invalidating any "relative"
4983 * path names. Note that the Macintosh is limited to 255 character
4984 * path names, so be careful about deeply embedded directories...
4986 * XXX XXX XXX Hack -- This function attempts to "fix" the nasty
4987 * "missing lib folder bug" by allowing the user to help find the
4988 * "lib" folder by hand if the "application folder" code fails...
4990 static void init_stuff(void)
5007 /* Fake rectangle */
5014 center_rect(&r, &qd.screenBits.bounds);
5016 /* Extract corner */
5021 /* Default to the "lib" folder with the application */
5022 refnum_to_name(path, app_dir, app_vol, (char*)("\plib:"));
5025 /* Check until done */
5028 /* Prepare the paths */
5029 init_file_paths(path);
5031 /* Build the filename */
5033 path_build(path, 1024, ANGBAND_DIR_FILE, "news_j.txt");
5035 path_build(path, 1024, ANGBAND_DIR_FILE, "news.txt");
5038 /* Attempt to open and close that file */
5039 if (0 == fd_close(fd_open(path, O_RDONLY))) break;
5043 plog_fmt("'%s' ¥Õ¥¡¥¤¥ë¤ò¥ª¡¼¥×¥ó½ÐÍè¤Þ¤»¤ó.", path);
5045 plog_fmt("Unable to open the '%s' file.", path);
5050 plog("Hengband¤Î'lib'¥Õ¥©¥ë¥À¤¬Â¸ºß¤·¤Ê¤¤¤«Àµ¤·¤¯Ìµ¤¤²ÄǽÀ¤¬¤¢¤ê¤Þ¤¹.");
5052 plog("The Angband 'lib' folder is probably missing or misplaced.");
5056 plog("Please 'open' any file in any sub-folder of the 'lib' folder.");
5058 /* Allow "text" files */
5061 /* Allow "save" files */
5064 /* Allow "data" files */
5068 SFGetFile(topleft, "\p", NULL, 3, types, NULL, &reply);
5071 if (!reply.good) quit(NULL);
5073 /* Extract textual file name for given file */
5074 GetWDInfo(reply.vRefNum, &vrefnum, &drefnum, &junk);
5075 refnum_to_name(path, drefnum, vrefnum, (char*)reply.fName);
5077 /* Hack -- Remove the "filename" */
5078 i = strlen(path) - 1;
5079 while ((i > 0) && (path[i] != ':')) i--;
5080 if (path[i] == ':') path[i+1] = '\0';
5082 /* Hack -- allow "lib" folders */
5083 if (suffix(path, "lib:")) continue;
5085 /* Hack -- Remove the "sub-folder" */
5087 while ((i > 1) && (path[i] != ':')) i--;
5088 if (path[i] == ':') path[i+1] = '\0';
5094 * Macintosh Main loop
5098 EventRecord tempEvent;
5099 int numberOfMasters = 10;
5101 /* Increase stack space by 64K */
5102 SetApplLimit(GetApplLimit() - 131072L);//65536L);
5104 /* Stretch out the heap to full size */
5107 /* Get more Masters */
5108 while (numberOfMasters--) MoreMasters();
5110 /* Set up the Macintosh */
5111 InitGraf(&qd.thePort);
5124 FlushEvents(everyEvent, 0);
5126 /* Flush events some more (?) */
5127 (void)EventAvail(everyEvent, &tempEvent);
5128 (void)EventAvail(everyEvent, &tempEvent);
5129 (void)EventAvail(everyEvent, &tempEvent);
5132 #ifdef ANGBAND_LITE_MAC
5136 #else /* ANGBAND_LITE_MAC */
5138 # if defined(powerc) || defined(__powerc)
5140 /* Assume System 7 */
5142 /* Assume Color Quickdraw */
5152 /* Check the Gestalt */
5153 err = Gestalt(gestaltSystemVersion, &versionNumber);
5155 /* Check the version */
5156 if ((err != noErr) || (versionNumber < 0x0700))
5159 quit("¤³¤Î¥×¥í¥°¥é¥à¤Ï´Á»úTalk7.x.x°Ê¹ß¤ÇÆ°ºî¤·¤Þ¤¹.");
5161 quit("You must have System 7 to use this program.");
5171 /* Check the environs */
5172 if (SysEnvirons(1, &env) != noErr)
5175 quit("SysEnvirons ¥³¡¼¥ë¤Ï¼ºÇÔ¤·¤Þ¤·¤¿¡ª");
5177 quit("The SysEnvirons call failed!");
5181 /* Check for System Seven Stuff */
5182 if (env.systemVersion < 0x0700)
5185 quit("¤³¤Î¥×¥í¥°¥é¥à¤Ï´Á»úTalk7.x.x°Ê¹ß¤ÇÆ°ºî¤·¤Þ¤¹.");
5187 quit("You must have System 7 to use this program.");
5191 /* Check for Color Quickdraw */
5192 if (!env.hasColorQD)
5195 quit("¤³¤Î¥×¥í¥°¥é¥à¤ÏColor Quickdraw¤¬Ìµ¤¤¤ÈÆ°ºî¤·¤Þ¤»¤ó.");
5197 quit("You must have Color Quickdraw to use this program.");
5204 #endif /* ANGBAND_LITE_MAC */
5209 /* Obtain a "Universal Procedure Pointer" */
5210 AEH_Start_UPP = NewAEEventHandlerProc(AEH_Start);
5212 /* Install the hook (ignore error codes) */
5213 AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, AEH_Start_UPP,
5216 /* Obtain a "Universal Procedure Pointer" */
5217 AEH_Quit_UPP = NewAEEventHandlerProc(AEH_Quit);
5219 /* Install the hook (ignore error codes) */
5220 AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, AEH_Quit_UPP,
5223 /* Obtain a "Universal Procedure Pointer" */
5224 AEH_Print_UPP = NewAEEventHandlerProc(AEH_Print);
5226 /* Install the hook (ignore error codes) */
5227 AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments, AEH_Print_UPP,
5230 /* Obtain a "Universal Procedure Pointer" */
5231 AEH_Open_UPP = NewAEEventHandlerProc(AEH_Open);
5233 /* Install the hook (ignore error codes) */
5234 AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, AEH_Open_UPP,
5240 /* Find the current application */
5244 /* Mark ourself as the file creator */
5247 /* Default to saving a "text" file */
5251 #if defined(__MWERKS__)
5253 /* Obtian a "Universal Procedure Pointer" */
5254 ynfilterUPP = NewModalFilterProc(ynfilter);
5259 /* Hook in some "z-virt.c" hooks */
5260 rnfree_aux = hook_rnfree;
5261 ralloc_aux = hook_ralloc;
5262 rpanic_aux = hook_rpanic;
5264 /* Hooks in some "z-util.c" hooks */
5265 plog_aux = hook_plog;
5266 quit_aux = hook_quit;
5267 core_aux = hook_core;
5269 BackColor(blackColor);
5270 ForeColor(whiteColor);
5272 /* Show the "watch" cursor */
5273 SetCursor(*(GetCursor(watchCursor)));
5275 /* Prepare the menubar */
5278 /* Prepare the windows */
5283 /* Hack -- process all events */
5284 while (CheckEvents(TRUE)) /* loop */;
5286 /* Reset the cursor */
5287 SetCursor(&qd.arrow);
5290 /* Mega-Hack -- Allocate a "lifeboat" */
5291 lifeboat = NewPtr(16384);
5293 /* Note the "system" */
5294 ANGBAND_SYS = "mac";
5303 /* Hack -- process all events */
5304 while (CheckEvents(TRUE)) /* loop */;
5307 /* We are now initialized */
5311 /* Handle "open_when_ready" */
5312 handle_open_when_ready();
5318 /* Prompt the user */
5320 prt("'¥Õ¥¡¥¤¥ë'¥á¥Ë¥å¡¼¤è¤ê'¿·µ¬'¤Þ¤¿¤Ï'³«¤¯...'¤òÁªÂò¤·¤Æ¤¯¤À¤µ¤¤¡£", 23, 10);
5322 prt("[Choose 'New' or 'Open' from the 'File' menu]", 23, 15);
5325 /* Flush the prompt */
5329 /* Hack -- Process Events Forever */
5330 while (TRUE) CheckEvents(TRUE);