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;
1796 if (x + 1 < Term->wid &&
1797 ((use_bigtile && Term->old->a[y][x+1] == 255)
1798 || (iskanji(Term->old->c[y][x]) && !(Term->old->a[y][x] & 0x80))))
1800 if (use_bigtile && x + 1 < Term->wid && Term->old->a[y][x+1] == 255)
1802 r.right += td->tile_wid;
1812 * Low level graphics (Assumes valid input)
1814 * Erase "n" characters starting at (x,y)
1816 static errr Term_wipe_mac(int x, int y, int n)
1820 term_data *td = (term_data*)(Term->data);
1822 /* Erase the block of characters */
1823 r.left = x * td->tile_wid + td->size_ow1;
1824 r.right = r.left + n * td->tile_wid;
1825 r.top = y * td->tile_hgt + td->size_oh1;
1826 r.bottom = r.top + td->tile_hgt;
1835 * Low level graphics. Assumes valid input.
1837 * Draw several ("n") chars, with an attr, at a given location.
1839 static errr Term_text_mac(int x, int y, int n, byte a, const char *cp)
1843 term_data *td = (term_data*)(Term->data);
1846 term_data_color(td, (a & 0x0F));
1848 /* Starting pixel */
1849 xp = x * td->tile_wid + td->tile_o_x + td->size_ow1;
1850 yp = y * td->tile_hgt + td->tile_o_y + td->size_oh1;
1852 /* Move to the correct location */
1855 /* Draw the character */
1856 if (n == 1) DrawChar(*cp);
1858 /* Draw the string */
1859 else DrawText(cp, 0, n);
1867 * Low level graphics (Assumes valid input)
1869 * Erase "n" characters starting at (x,y)
1871 #ifdef USE_TRANSPARENCY
1872 static errr Term_pict_mac(int x, int y, int n, const byte *ap, const char *cp,
1873 const byte *tap, const char *tcp)
1875 static errr Term_pict_mac(int x, int y, int n, const byte *ap, const char *cp)
1880 bool use_buffer = false;
1881 term_data *td = (term_data*)(Term->data);
1882 GDHandle saveGDevice;
1883 GWorldPtr saveGWorld;
1885 PixMapHandle PortPix;
1889 GetGWorld(&saveGWorld, &saveGDevice);
1893 /* Destination rectangle */
1894 r2.left = x * td->tile_wid + td->size_ow1;
1895 r2.right = r2.left + td->tile_wid;
1897 r2.bottom = r2.top + td->tile_hgt;
1900 SetGWorld(td->bufferPort, nil);
1901 PortPix = GetGWorldPixMap(td->bufferPort );
1902 LockPixels( PortPix );
1904 /* Instantiate font */
1905 TextFont(td->font_id);
1906 TextSize(td->font_size);
1907 TextFace(td->font_face);
1909 /* Restore colors */
1910 BackColor(blackColor);
1911 ForeColor(whiteColor);
1914 EraseRect(&td->bufferPort->portRect);
1920 /* Destination rectangle */
1921 r2.left = x * td->tile_wid + td->size_ow1;
1922 r2.top = y * td->tile_hgt + td->size_oh1;
1923 r2.bottom = r2.top + td->tile_hgt;
1925 /* no buffering, so we use the normal current port */
1930 /* Scan the input */
1931 for (i = 0; i < n; i++)
1938 /* Second byte of bigtile */
1939 if (use_bigtile && a == 255)
1942 r2.left += td->tile_wid;
1947 /* Prepare right of rectangle now */
1948 r2.right = r2.left + td->tile_wid;
1950 #ifdef ANGBAND_LITE_MAC
1954 #else /* ANGBAND_LITE_MAC */
1956 /* Graphics -- if Available and Needed */
1957 if (use_graphics && ((byte)a & 0x80) && ((byte)c & 0x80))
1959 BitMapPtr srcBitMap = (BitMapPtr)(frameP->framePix);
1960 BitMapPtr destBitMap;
1965 #ifdef USE_TRANSPARENCY
1967 bool terrain_flag = FALSE;
1971 if ((a != ta || c != tc) &&
1972 ((byte)ta & 0x80) && ((byte)tc & 0x80))
1975 row = ((byte)ta & 0x7F);
1976 col = ((byte)tc & 0x7F);
1978 /* Terrain Source rectangle */
1979 terrain_r.left = col * grafWidth;
1980 terrain_r.top = row * grafHeight;
1981 terrain_r.right = terrain_r.left + grafWidth;
1982 terrain_r.bottom = terrain_r.top + grafHeight;
1984 terrain_flag = TRUE;
1989 row = ((byte)a & 0x7F);
1990 col = ((byte)c & 0x7F);
1992 /* Source rectangle */
1993 r1.left = col * grafWidth;
1994 r1.top = row * grafHeight;
1995 r1.right = r1.left + grafWidth;
1996 r1.bottom = r1.top + grafHeight;
1998 /* Hardwire CopyBits */
1999 BackColor(whiteColor);
2000 ForeColor(blackColor);
2002 /* Draw the picture */
2005 destBitMap = (BitMapPtr)(td->bufferPix);
2007 destBitMap = (BitMapPtr)&(td->w->portBits);
2009 if (use_bigtile) r2.right += td->tile_wid;
2011 #ifdef USE_TRANSPARENCY
2015 * Source mode const = srcCopy:
2017 * determine how close the color of the source
2018 * pixel is to black, and assign this relative
2019 * amount of foreground color to the
2020 * destination pixel; determine how close the
2021 * color of the source pixel is to white, and
2022 * assign this relative amount of background
2023 * color to the destination pixel
2025 CopyBits( srcBitMap, destBitMap, &terrain_r, &r2, srcCopy, NULL );
2028 * Draw transparent tile
2029 * BackColor is ignored and the destination is
2032 BackColor(blackColor);
2033 CopyBits( srcBitMap, destBitMap, &r1, &r2, transparent, NULL );
2036 #endif /* USE_TRANSPARENCY */
2038 CopyBits( srcBitMap, destBitMap, &r1, &r2, srcCopy, NULL );
2041 /* Restore colors */
2042 BackColor(blackColor);
2043 ForeColor(whiteColor);
2052 #endif /* ANGBAND_LITE_MAC */
2060 term_data_color(td, (a & 0x0F));
2062 /* Starting pixel */
2063 xp = r2.left + td->tile_o_x;
2064 yp = r2.top + td->tile_o_y;
2066 /* Move to the correct location */
2072 /* Double width rectangle */
2073 r2.right += td->tile_wid;
2078 /* Draw the character */
2083 r2.left += td->tile_wid;
2091 /* Draw the character */
2097 r2.left += td->tile_wid;
2102 /* Now we blast the buffer pixmap onto the screen in the right place */
2103 BitMapPtr srcBitMap = (BitMapPtr)(td->bufferPix);
2105 BitMapPtr destBitMap = (BitMapPtr)&(td->w->portBits);
2111 srcRect.left = x * td->tile_wid + td->size_ow1;
2113 srcRect.right = srcRect.left + (td->tile_wid * n);
2114 srcRect.bottom = td->tile_hgt;
2116 destRect.left = x * td->tile_wid + td->size_ow1;
2117 destRect.right = destRect.left + (td->tile_wid * n);
2118 destRect.top = y * td->tile_hgt + td->size_oh1;
2119 destRect.bottom = destRect.top + td->tile_hgt;
2121 /* Double width rectangle */
2124 srcRect.right += td->tile_wid * n;
2125 destRect.right += td->tile_wid * n;
2128 UnlockPixels( PortPix );
2130 /* Restore GWorld */
2131 SetGWorld(saveGWorld, saveGDevice);
2133 /* Hardwire CopyBits */
2134 BackColor(whiteColor);
2135 ForeColor(blackColor);
2137 CopyBits( srcBitMap, destBitMap, &srcRect, &destRect, srcCopy, NULL );
2139 /* Restore colors */
2140 BackColor(blackColor);
2141 ForeColor(whiteColor);
2154 * Create and initialize window number "i"
2156 static void term_data_link(int i)
2160 term_data *td = &data[i];
2165 /* Require mapped */
2166 if (!td->mapped) return;
2171 /* Initialize the term */
2172 term_init(td->t, td->cols, td->rows, td->keys);
2174 /* Use a "software" cursor */
2175 td->t->soft_cursor = TRUE;
2177 /* Erase with "white space" */
2178 td->t->attr_blank = TERM_WHITE;
2179 td->t->char_blank = ' ';
2181 /* Prepare the init/nuke hooks */
2182 td->t->init_hook = Term_init_mac;
2183 td->t->nuke_hook = Term_nuke_mac;
2185 /* Prepare the function hooks */
2186 td->t->user_hook = Term_user_mac;
2187 td->t->xtra_hook = Term_xtra_mac;
2188 td->t->wipe_hook = Term_wipe_mac;
2189 td->t->curs_hook = Term_curs_mac;
2190 td->t->text_hook = Term_text_mac;
2191 td->t->pict_hook = Term_pict_mac;
2193 /* Link the local structure */
2194 td->t->data = (vptr)(td);
2197 Term_activate(td->t);
2199 /* Global pointer */
2200 angband_term[i] = td->t;
2210 * Set the "current working directory" (also known as the "default"
2211 * volume/directory) to the location of the current application.
2213 * Code by: Maarten Hazewinkel (mmhazewi@cs.ruu.nl)
2215 * This function does not appear to work correctly with System 6.
2217 static void SetupAppDir(void)
2221 char errString[100];
2223 /* Get the location of the Angband executable */
2224 fcbBlock.ioCompletion = NULL;
2225 fcbBlock.ioNamePtr = NULL;
2226 fcbBlock.ioVRefNum = 0;
2227 fcbBlock.ioRefNum = CurResFile();
2228 fcbBlock.ioFCBIndx = 0;
2229 err = PBGetFCBInfo(&fcbBlock, FALSE);
2233 sprintf(errString, "PBGetFCBInfo ¥¨¥é¡¼ #%d.\r ½ªÎ»¤·¤Þ¤¹.", err);
2235 sprintf(errString, "Fatal PBGetFCBInfo Error #%d.\r Exiting.", err);
2237 mac_warning(errString);
2241 /* Extract the Vol and Dir */
2242 app_vol = fcbBlock.ioFCBVRefNum;
2243 app_dir = fcbBlock.ioFCBParID;
2245 /* Set the current working directory to that location */
2246 err = HSetVol(NULL, app_vol, app_dir);
2250 sprintf(errString, "HSetVol ¥¨¥é¡¼ #%d.\r ½ªÎ»¤·¤Þ¤¹.", err);
2252 sprintf(errString, "Fatal HSetVol Error #%d.\r Exiting.", err);
2254 mac_warning(errString);
2263 * Global "preference" file pointer
2268 * Read a "short" from the file
2270 static int getshort(void)
2274 if (0 == my_fgets(fff, buf, sizeof(buf))) x = atoi(buf);
2279 * Dump a "short" to the file
2281 static void putshort(int x)
2283 fprintf(fff, "%d\n", x);
2289 * Write the "preference" data to the current "file"
2291 static void save_prefs(void)
2298 /*** The current version ***/
2300 putshort(FAKE_VERSION);
2301 putshort(FAKE_VER_MAJOR);
2302 putshort(FAKE_VER_MINOR);
2303 putshort(FAKE_VER_PATCH);
2305 putshort(arg_sound);
2306 putshort(arg_graphics);
2307 putshort(arg_newstyle_graphics);
2308 putshort(arg_bigtile);
2311 for( i = 0 ; i < 7 ; i++ )
2312 putshort(soundmode[i]);
2315 for (i = 0; i < MAX_TERM_DATA; i++)
2320 putshort(td->mapped);
2322 putshort(td->font_id);
2323 putshort(td->font_size);
2324 putshort(td->font_face);
2326 putshort(td->tile_wid);
2327 putshort(td->tile_hgt);
2332 putshort(td->r.left);
2333 putshort(td->r.top);
2339 * Load the preferences from the current "file"
2341 * XXX XXX XXX Being able to undefine various windows is
2342 * slightly bizarre, and may cause problems.
2344 static void load_prefs(void)
2348 int old_version, old_major, old_minor, old_patch;
2353 /*** Version information ***/
2355 /* Preferences version */
2356 old_version = getshort();
2357 old_major = getshort();
2358 old_minor = getshort();
2359 old_patch = getshort();
2361 /* Hack -- Verify or ignore */
2362 if ((old_version != FAKE_VERSION) ||
2363 (old_major != FAKE_VER_MAJOR) ||
2364 (old_minor != FAKE_VER_MINOR) ||
2365 (old_patch != FAKE_VER_PATCH))
2369 mac_warning("¸Å¤¤½é´üÀßÄê¥Õ¥¡¥¤¥ë¤ò̵»ë¤·¤Þ¤¹.");
2371 mac_warning("Ignoring old preferences.");
2377 arg_sound = getshort();
2378 arg_graphics = getshort();
2379 arg_newstyle_graphics = getshort();
2380 use_newstyle_graphics = arg_newstyle_graphics;
2382 if (use_newstyle_graphics == true)
2384 ANGBAND_GRAF = "new";
2385 arg_newstyle_graphics = true;
2386 grafWidth = grafHeight = 16;
2391 ANGBAND_GRAF = "old";
2392 arg_newstyle_graphics = false;
2393 grafWidth = grafHeight = 8;
2397 arg_bigtile = getshort();
2398 use_bigtile = arg_bigtile;
2401 for( i = 0 ; i < 7 ; i++ )
2402 soundmode[i] = getshort();
2405 m = GetMenuHandle(134); //m = GetMHandle(134);
2407 /* Item "arg_sound" */
2408 CheckItem(m, 1, arg_sound);
2410 /* Item "arg_graphics" */
2411 CheckItem(m, 2, arg_graphics);
2413 /* Item "arg_newstyle_graphics"*/
2414 CheckItem(m, 8, arg_newstyle_graphics);
2417 for (i = 0; i < MAX_TERM_DATA; i++)
2422 td->mapped = getshort();
2424 td->font_id = getshort();
2425 td->font_size = getshort();
2426 td->font_face = getshort();
2428 td->tile_wid = getshort();
2429 td->tile_hgt = getshort();
2431 td->cols = getshort();
2432 td->rows = getshort();
2434 td->r.left = getshort();
2435 td->r.top = getshort();
2438 if (feof(fff)) break;
2446 * Hack -- default data for a window
2448 static void term_data_hack(term_data *td)
2453 GetFNum( "\pÅùÉýÌÀÄ«", &fid); /* ¥Õ¥©¥ó¥È̾¤«¤éIDÈÖ¹æ¤òÄ´¤Ù¤ë */
2454 SetFScaleDisable( true );
2456 /* Default to Monaco font */
2457 GetFNum("\pmonaco", &fid);
2460 WIPE(td, term_data);
2465 /* Default borders */
2476 /* Default font size */
2479 /* Default font face */
2486 /* Default position */
2496 * Read the preference file, Create the windows.
2498 * We attempt to use "FindFolder()" to track down the preference file,
2499 * but if this fails, for any reason, we will try the "SysEnvirons()"
2500 * method, which may work better with System 6.
2502 static void init_windows(void)
2515 /*** Default values ***/
2517 /* Initialize (backwards) */
2518 for (i = MAX_TERM_DATA - 1; i >= 0; i--)
2531 s = angband_term_name[i];
2536 /* Maximal length */
2539 /* Copy the title */
2540 strncpy((char*)(td->title) + 1, s, n);
2542 /* Save the length */
2545 /* Tile the windows */
2546 td->r.left += (b * 30);
2547 td->r.top += (b * 30);
2554 /*** Load preferences ***/
2556 /* Assume failure */
2559 /* Assume failure */
2572 /* Find the folder */
2573 err = FindFolder(kOnSystemDisk, kPreferencesFolderType, kCreateFolder,
2579 /* Extract a path name */
2580 PathNameFromDirID(dirID, vref, (StringPtr)foo);
2582 /* Convert the string */
2583 ptocstr((StringPtr)foo);
2585 /* Append the preference file name */
2586 strcat(foo, PREF_FILE_NAME);
2588 /* Open the preference file */
2589 fff = fopen(foo, "r");
2596 #endif /* USE_SFL_CODE */
2602 HGetVol(0, &savev, &saved);
2604 /* Go to the "system" folder */
2605 SysEnvirons(curSysEnvVers, &env);
2606 SetVol(0, env.sysVRefNum);
2609 fff = fopen(PREF_FILE_NAME, "r");
2612 HSetVol(0, savev, saved);
2615 /* Load preferences */
2618 /* Load a real preference file */
2621 /* Close the file */
2626 /*** Instantiate ***/
2637 /* Link (backwards, for stacking order) */
2638 for (i = MAX_TERM_DATA - 1; i >= 0; i--)
2647 Term_activate(td->t);
2650 static void init_sound( void )
2654 SignedByte permission = fsRdPerm;
2660 /* Descend into "lib" folder */
2661 pb.ioCompletion = NULL;
2662 pb.ioNamePtr = "\plib";
2663 pb.ioVRefNum = app_vol;
2664 pb.ioDrDirID = app_dir;
2667 /* Check for errors */
2668 err = PBGetCatInfo((CInfoPBPtr)&pb, FALSE);
2671 if ((err == noErr) && (pb.ioFlAttrib & 0x10))
2673 /* Descend into "lib/save" folder */
2674 pb.ioCompletion = NULL;
2675 pb.ioNamePtr = "\pxtra";
2676 pb.ioVRefNum = app_vol;
2677 pb.ioDrDirID = pb.ioDrDirID;
2680 /* Check for errors */
2681 err = PBGetCatInfo((CInfoPBPtr)&pb, FALSE);
2684 if ((err == noErr) && (pb.ioFlAttrib & 0x10))
2686 /* Descend into "lib/save" folder */
2687 pb.ioCompletion = NULL;
2688 pb.ioNamePtr = "\psound";
2689 pb.ioVRefNum = app_vol;
2690 pb.ioDrDirID = pb.ioDrDirID;
2693 /* Check for errors */
2694 err = PBGetCatInfo((CInfoPBPtr)&pb, FALSE);
2697 if ((err == noErr) && (pb.ioFlAttrib & 0x10))
2699 ret = HOpenResFile( app_vol , pb.ioDrDirID , "\psound.rsrc" , permission );
2703 for( i = 0 ; i < 7 ; i++ )
2704 soundmode[i] = false;
2706 for( i = 1 ; i < SOUND_MAX ; i++ ){
2707 /* Get the proper sound name */
2708 sprintf((char*)sound + 1, "%.16s.wav", angband_sound_name[i]);
2709 sound[0] = strlen((char*)sound + 1);
2711 /* Obtain resource XXX XXX XXX */
2712 handle = Get1NamedResource('snd ', sound);
2713 if( handle == NULL || ext_sound )
2714 handle = GetNamedResource('snd ', sound);
2717 soundmode[soundchoice[i]] = true;
2726 static void init_graf( void )
2730 SignedByte permission = fsRdPerm;
2736 /* Descend into "lib" folder */
2737 pb.ioCompletion = NULL;
2738 pb.ioNamePtr = "\plib";
2739 pb.ioVRefNum = app_vol;
2740 pb.ioDrDirID = app_dir;
2743 /* Check for errors */
2744 err = PBGetCatInfo((CInfoPBPtr)&pb, FALSE);
2747 if ((err == noErr) && (pb.ioFlAttrib & 0x10))
2749 /* Descend into "lib/xtra" folder */
2750 pb.ioCompletion = NULL;
2751 pb.ioNamePtr = "\pxtra";
2752 pb.ioVRefNum = app_vol;
2753 pb.ioDrDirID = pb.ioDrDirID;
2756 /* Check for errors */
2757 err = PBGetCatInfo((CInfoPBPtr)&pb, FALSE);
2760 if ((err == noErr) && (pb.ioFlAttrib & 0x10))
2762 /* Descend into "lib/xtra/graf" folder */
2763 pb.ioCompletion = NULL;
2764 pb.ioNamePtr = "\pgraf";
2765 pb.ioVRefNum = app_vol;
2766 pb.ioDrDirID = pb.ioDrDirID;
2769 /* Check for errors */
2770 err = PBGetCatInfo((CInfoPBPtr)&pb, FALSE);
2773 if ((err == noErr) && (pb.ioFlAttrib & 0x10))
2775 ret = HOpenResFile( app_vol , pb.ioDrDirID , "\pgraf.rsrc" , permission );
2780 /* Obtain resource XXX XXX XXX */
2781 handle = Get1NamedResource('PICT', graf);
2782 if ( handle == NULL || ext_graf )
2783 handle = GetNamedResource('PICT', graf);
2794 static void init_chuukei( void )
2800 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "chuukei.txt");
2802 fp = fopen(path, "r");
2807 if (fgets(tmp, 1024, fp)){
2809 int n = strlen(tmp);
2815 chuukei_server = TRUE;
2816 if(connect_chuukei_server(&tmp[2])<0){
2817 msg_print("connect fail");
2820 msg_print("connect");
2827 chuukei_client = TRUE;
2828 connect_chuukei_server(&tmp[2]);
2844 short InevrtCheck( DialogPtr targetDlg, short check )
2851 GetDialogItem( targetDlg, check, &itemType, &checkH, &box );
2852 result = (GetControlValue( (ControlHandle)checkH ) + 1 ) % 2;
2853 SetControlValue( (ControlHandle)checkH , result );
2861 short SetCheck( DialogPtr targetDlg, short check, long result )
2868 GetDialogItem( targetDlg, check, &itemType, &checkH, &box );
2869 SetControlValue( (ControlHandle)checkH , result );
2877 short GetCheck( DialogPtr targetDlg, short check )
2884 GetDialogItem( targetDlg, check, &itemType, &checkH, &box );
2885 result = GetControlValue( (ControlHandle)checkH );
2889 void SoundConfigDLog(void)
2896 dialog=GetNewDialog(131, 0, (WindowPtr)-1);
2897 SetDialogDefaultItem( dialog, ok );
2898 SetDialogCancelItem( dialog, cancel );
2899 for( i = 1 ; i < 7 ; i++ )
2900 SetCheck( dialog, i+2 , soundmode[i] );
2903 for( item_hit = 100 ; cancel < item_hit ; ){
2904 ModalDialog(0, &item_hit);
2908 for( i = 1 ; i < 7 ; i++ )
2909 soundmode[i] = GetCheck( dialog, i+2 );
2914 InevrtCheck( dialog, item_hit );
2917 DisposeDialog(dialog);
2925 static void save_pref_file(void)
2934 /* Assume failure */
2937 /* Assume failure */
2954 /* Find the folder */
2955 err = FindFolder(kOnSystemDisk, kPreferencesFolderType, kCreateFolder,
2961 /* Extract a path name */
2962 PathNameFromDirID(dirID, vref, (StringPtr)foo);
2964 /* Convert the string */
2965 ptocstr((StringPtr)foo);
2967 /* Append the preference file name */
2968 strcat(foo, PREF_FILE_NAME);
2970 /* Open the preference file */
2971 /* my_fopen set file type and file creator for MPW */
2972 fff = my_fopen(foo, "w");
2979 #endif /* USE_SFL_CODE */
2985 HGetVol(0, &savev, &saved);
2987 /* Go to "system" folder */
2988 SysEnvirons(curSysEnvVers, &env);
2989 SetVol(0, env.sysVRefNum);
2991 /* Open the preference file */
2992 /* my_fopen set file type and file creator for MPW */
2993 fff = fopen(PREF_FILE_NAME, "w");
2996 HSetVol(0, savev, saved);
2999 /* Save preferences */
3002 /* Write the preferences */
3013 * A simple "Yes/No" filter to parse "key press" events in dialog windows
3015 static pascal Boolean ynfilter(DialogPtr dialog, EventRecord *event, short *ip)
3017 /* Parse key press events */
3018 if (event->what == keyDown)
3023 /* Extract the pressed key */
3024 c = (event->message & charCodeMask);
3026 /* Accept "no" and <return> and <enter> */
3027 if ((c=='n') || (c=='N') || (c==13) || (c==3)) i = 1;
3030 else if ((c=='y') || (c=='Y')) i = 2;
3032 /* Handle "yes" or "no" */
3036 ControlHandle control;
3039 /* Get the button */
3040 GetDialogItem(dialog, i, &type, (Handle*)&control, &r); //GetDItem(dialog, i, &type, (Handle*)&control, &r);
3042 /* Blink button for 1/10 second */
3043 HiliteControl(control, 1);
3044 Term_xtra_mac(TERM_XTRA_DELAY, 100);
3045 HiliteControl(control, 0);
3059 * Handle menu: "File" + "New"
3061 static void do_menu_file_new(void)
3066 /* Game is in progress */
3067 game_in_progress = 1;
3081 * Handle menu: "File" + "Open"
3083 static void do_menu_file_open(bool all)
3097 /* vrefnum = GetSFCurVol(); */
3098 vrefnum = -*((short*)0x214);
3100 /* drefnum = GetSFCurDir(); */
3101 drefnum = *((long*)0x398);
3103 /* Descend into "lib" folder */
3104 pb.ioCompletion = NULL;
3105 pb.ioNamePtr = "\plib";
3106 pb.ioVRefNum = vrefnum;
3107 pb.ioDrDirID = drefnum;
3110 /* Check for errors */
3111 err = PBGetCatInfo((CInfoPBPtr)&pb, FALSE);
3114 if ((err == noErr) && (pb.ioFlAttrib & 0x10))
3116 /* Descend into "lib/save" folder */
3117 pb.ioCompletion = NULL;
3118 pb.ioNamePtr = "\psave";
3119 pb.ioVRefNum = vrefnum;
3120 pb.ioDrDirID = pb.ioDrDirID;
3123 /* Check for errors */
3124 err = PBGetCatInfo((CInfoPBPtr)&pb, FALSE);
3127 if ((err == noErr) && (pb.ioFlAttrib & 0x10))
3129 /* SetSFCurDir(pb.ioDrDirID); */
3130 *((long*)0x398) = pb.ioDrDirID;
3134 /* Window location */
3135 topleft.h = (qd.screenBits.bounds.left+qd.screenBits.bounds.right)/2-344/2;
3136 topleft.v = (2*qd.screenBits.bounds.top+qd.screenBits.bounds.bottom)/3-188/2;
3138 /* Allow "all" files */
3142 SFGetFile(topleft, "\p", NULL, -1, types, NULL, &reply);
3145 /* Allow "save" files */
3152 SFGetFile(topleft, "\p", NULL, 1, types, NULL, &reply);
3156 if (!reply.good) return;
3158 /* Extract textual file name for save file */
3159 GetWDInfo(reply.vRefNum, &vrefnum, &drefnum, &junk);
3160 refnum_to_name(savefile, drefnum, vrefnum, (char*)reply.fName);
3165 /* Game is in progress */
3166 game_in_progress = 1;
3180 * Handle the "open_when_ready" flag
3182 static void handle_open_when_ready(void)
3184 /* Check the flag XXX XXX XXX make a function for this */
3185 if (open_when_ready && initialized && !game_in_progress)
3188 open_when_ready = FALSE;
3190 /* Game is in progress */
3191 game_in_progress = 1;
3210 * Initialize the menus
3212 * Verify menus 128, 129, 130
3213 * Create menus 131, 132, 133, 134
3215 * The standard menus are:
3217 * Apple (128) = { About, -, ... }
3218 * File (129) = { New,Open,Import,Close,Save,-,Exit,Quit }
3219 * Edit (130) = { Cut, Copy, Paste, Clear } (?)
3220 * Font (131) = { Bold, Extend, -, Monaco, ..., -, ... }
3221 * Size (132) = { ... }
3222 * Window (133) = { Angband, Mirror, Recall, Choice,
3223 * Term-4, Term-5, Term-6, Term-7 }
3224 * Special (134) = { arg_sound, arg_graphics, -,
3225 * arg_fiddle, arg_wizard }
3227 static void init_menubar(void)
3238 /* Get the "apple" menu */
3241 /* Insert the menu */
3244 /* Add the DA's to the "apple" menu */
3245 AppendResMenu (m, 'DRVR'); //AddResMenu(m, 'DRVR');
3248 /* Get the "File" menu */
3251 /* Insert the menu */
3255 /* Get the "Edit" menu */
3258 /* Insert the menu */
3262 /* Make the "Font" menu */
3264 m = NewMenu(131, "\p¥Õ¥©¥ó¥È");
3266 m = NewMenu(131, "\pFont");
3269 /* Insert the menu */
3273 AppendMenu(m, "\pBold");
3276 AppendMenu(m, "\pWide");
3278 /* Add a separator */
3279 AppendMenu(m, "\p-");
3282 r.left = r.right = r.top = r.bottom = 0;
3284 /* Make the fake window */
3285 tmpw = NewWindow(0, &r, "\p", false, documentProc, 0, 0, 0);
3287 /* Activate the "fake" window */
3296 /* Add the fonts to the menu */
3297 AppendResMenu(m, 'FONT'); //AddResMenu(m, 'FONT');
3303 for (i = n; i >= 4; i--)
3308 /* Acquire the font name */
3309 /* GetMenuItemText(m, i, tmpName); */
3310 GetMenuItemText(m, i, tmpName); //GetItem(m, i, tmpName);
3312 /* Acquire the font index */
3313 GetFNum(tmpName, &fontNum);
3315 /* Apply the font index */
3318 /* Remove non-mono-spaced fonts */
3319 if ((CharWidth('i') != CharWidth('W')) || (CharWidth('W') == 0))
3321 /* Delete the menu item XXX XXX XXX */
3322 /* DeleteMenuItem(m, i); */
3323 DeleteMenuItem (m, i); //DelMenuItem(m, i);
3327 /* Destroy the old window */
3328 DisposeWindow(tmpw);
3330 /* Add a separator */
3331 AppendMenu(m, "\p-");
3333 /* Add the fonts to the menu */
3334 AppendResMenu (m, 'FONT'); //AddResMenu(m, 'FONT');
3337 /* Make the "Size" menu */
3339 m = NewMenu(132, "\p¥µ¥¤¥º");
3341 m = NewMenu(132, "\pSize");
3344 /* Insert the menu */
3347 /* Add some sizes (stagger choices) */
3348 for (i = 8; i <= 32; i += ((i / 16) + 1))
3353 sprintf((char*)buf + 1, "%d", i);
3354 buf[0] = strlen((char*)buf + 1);
3361 /* Make the "Windows" menu */
3363 m = NewMenu(133, "\p¥¦¥¤¥ó¥É¥¦");
3365 m = NewMenu(133, "\pWindows");
3368 /* Insert the menu */
3371 /* Default choices */
3372 for (i = 0; i < MAX_TERM_DATA; i++)
3376 /* Describe the item */
3377 sprintf((char*)buf + 1, "%.15s", angband_term_name[i]);
3378 buf[0] = strlen((char*)buf + 1);
3383 /* Command-Key shortcuts */
3384 if (i < 8) SetItemCmd(m, i + 1, '0' + i);
3388 /* Make the "Special" menu */
3390 m = NewMenu(134, "\pÆÃÊÌ");
3392 m = NewMenu(134, "\pSpecial");
3395 /* Insert the menu */
3398 /* Append the choices */
3400 AppendMenu(m, "\p¥µ¥¦¥ó¥É»ÈÍÑ");
3401 AppendMenu(m, "\p¥°¥é¥Õ¥£¥Ã¥¯»ÈÍÑ");
3402 AppendMenu(m, "\p-");
3403 AppendMenu(m, "\parg_fiddle");
3404 AppendMenu(m, "\parg_wizard");
3405 AppendMenu(m, "\p-");
3406 AppendMenu(m, "\p¥µ¥¦¥ó¥ÉÀßÄê...");
3407 AppendMenu(m, "\p16X16¥°¥é¥Õ¥£¥Ã¥¯");
3408 AppendMenu(m, "\p£²ÇÜÉý¥¿¥¤¥ëɽ¼¨");
3410 AppendMenu(m, "\parg_sound");
3411 AppendMenu(m, "\parg_graphics");
3412 AppendMenu(m, "\p-");
3413 AppendMenu(m, "\parg_fiddle");
3414 AppendMenu(m, "\parg_wizard");
3415 AppendMenu(m, "\p-");
3416 AppendMenu(m, "\pSound config");
3417 AppendMenu(m, "\pAdam Bolt tile");
3418 AppendMenu(m, "\pBigtile Mode");
3421 /* Make the "TileWidth" menu */
3423 m = NewMenu(135, "\p¥¿¥¤¥ëÉý");
3425 m = NewMenu(135, "\pTileWidth");
3428 /* Insert the menu */
3431 /* Add some sizes */
3432 for (i = 4; i <= 32; i++)
3437 sprintf((char*)buf + 1, "%d", i);
3438 buf[0] = strlen((char*)buf + 1);
3445 /* Make the "TileHeight" menu */
3447 m = NewMenu(136, "\p¥¿¥¤¥ë¹â");
3449 m = NewMenu(136, "\pTileHeight");
3452 /* Insert the menu */
3455 /* Add some sizes */
3456 for (i = 4; i <= 32; i++)
3461 sprintf((char*)buf + 1, "%d", i);
3462 buf[0] = strlen((char*)buf + 1);
3469 /* Update the menu bar */
3477 static void setup_menus(void)
3487 term_data *td = NULL;
3490 /* Relevant "term_data" */
3491 for (i = 0; i < MAX_TERM_DATA; i++)
3494 if (!data[i].t) continue;
3496 /* Notice the matching window */
3497 if (data[i].w == FrontWindow()) td = &data[i];
3502 m = GetMenuHandle(129); //m = GetMHandle(129);
3508 for (i = 1; i <= n; i++)
3512 CheckItem(m, i, FALSE);
3515 /* Enable "new"/"open..."/"import..." */
3516 if (initialized && !game_in_progress)
3523 /* Enable "close" */
3530 if (initialized && character_generated)
3543 m = GetMenuHandle(130); //m = GetMHandle(130);
3549 for (i = 1; i <= n; i++)
3553 CheckItem(m, i, FALSE);
3556 /* Enable "edit" options if "needed" */
3568 m = GetMenuHandle(131); //m = GetMHandle(131);
3574 for (i = 1; i <= n; i++)
3578 CheckItem(m, i, FALSE);
3581 /* Hack -- look cute XXX XXX */
3582 /* SetItemStyle(m, 1, bold); */
3584 /* Hack -- look cute XXX XXX */
3585 /* SetItemStyle(m, 2, extend); */
3593 /* Enable "extend" */
3596 /* Check the appropriate "bold-ness" */
3597 if (td->font_face & bold) CheckItem(m, 1, TRUE);
3599 /* Check the appropriate "wide-ness" */
3600 if (td->font_face & extend) CheckItem(m, 2, TRUE);
3603 for (i = 4; i <= n; i++)
3609 /* GetMenuItemText(m,i,s); */
3610 GetMenuItemText(m, i, s); //GetItem(m, i, s);
3613 /* Check active font */
3614 if (td->font_id == value) CheckItem(m, i, TRUE);
3620 m = GetMenuHandle(132); //m = GetMHandle(132);
3626 for (i = 1; i <= n; i++)
3630 CheckItem(m, i, FALSE);
3637 for (i = 1; i <= n; i++)
3640 /* GetMenuItemText(m,i,s); */
3641 GetMenuItemText(m, i, s); //GetItem(m, i, s);
3643 value = atoi((char*)(s+1));
3645 /* Enable the "real" sizes */
3646 if (RealFont(td->font_id, value)) EnableItem(m, i);
3648 /* Check the current size */
3649 if (td->font_size == value) CheckItem(m, i, TRUE);
3655 m = GetMenuHandle(133); //m = GetMHandle(133);
3660 /* Check active windows */
3661 for (i = 1; i <= n; i++)
3663 /* Check if needed */
3664 CheckItem(m, i, data[i-1].mapped);
3669 m = GetMenuHandle(134); //m = GetMHandle(134);
3675 for (i = 1; i <= n; i++)
3679 CheckItem(m, i, FALSE);
3682 /* Item "arg_sound" */
3684 CheckItem(m, 1, arg_sound);
3686 /* Item "arg_graphics" */
3688 CheckItem(m, 2, arg_graphics);
3690 /* Item "arg_fiddle" */
3692 CheckItem(m, 4, arg_fiddle);
3694 /* Item "arg_wizard" */
3696 CheckItem(m, 5, arg_wizard);
3698 /* Item "SoundSetting" */
3701 /* Item NewStyle Graphics */
3703 CheckItem(m, 8, use_newstyle_graphics);
3705 /* Item Bigtile Mode */
3707 CheckItem(m, 9, arg_bigtile);
3710 /* TileWidth menu */
3711 m = GetMenuHandle(135); //m = GetMHandle(135);
3717 for (i = 1; i <= n; i++)
3721 CheckItem(m, i, FALSE);
3728 for (i = 1; i <= n; i++)
3731 /* GetMenuItemText(m,i,s); */
3732 GetMenuItemText(m, i, s); //GetItem(m, i, s);
3734 value = atoi((char*)(s+1));
3739 /* Check the current size */
3740 if (td->tile_wid == value) CheckItem(m, i, TRUE);
3745 /* TileHeight menu */
3746 m = GetMenuHandle(136); //m = GetMHandle(136);
3752 for (i = 1; i <= n; i++)
3756 CheckItem(m, i, FALSE);
3763 for (i = 1; i <= n; i++)
3766 /* GetMenuItemText(m,i,s); */
3767 GetMenuItemText(m, i, s); //GetItem(m, i, s);
3769 value = atoi((char*)(s+1));
3774 /* Check the current size */
3775 if (td->tile_hgt == value) CheckItem(m, i, TRUE);
3782 * Process a menu selection (see above)
3784 * Hack -- assume that invalid menu selections are disabled above,
3785 * which I have been informed may not be reliable. XXX XXX XXX
3787 static void menu(long mc)
3791 int menuid, selection;
3793 static unsigned char s[1000];
3797 term_data *td = NULL;
3802 /* Analyze the menu command */
3803 menuid = HiWord(mc);
3804 selection = LoWord(mc);
3807 /* Find the window */
3808 for (i = 0; i < MAX_TERM_DATA; i++)
3810 /* Skip dead windows */
3811 if (!data[i].t) continue;
3813 /* Notice matches */
3814 if (data[i].w == FrontWindow()) td = &data[i];
3818 /* Branch on the menu */
3824 /* About Angband... */
3831 dialog=GetNewDialog(128, 0, (WindowPtr)-1);
3834 center_rect(&r, &qd.screenBits.bounds);
3835 MoveWindow(dialog, r.left, r.top, 1);
3837 ModalDialog(0, &item_hit);
3838 DisposeDialog(dialog); //DisposDialog(dialog);
3842 /* Desk accessory */
3843 /* GetMenuItemText(GetMHandle(128),selection,s); */
3844 GetMenuItemText(GetMenuHandle(128), selection, s); //GetItem(GetMHandle(128), selection, s);
3864 do_menu_file_open(FALSE);
3871 do_menu_file_open(TRUE);
3885 td->t->mapped_flag = FALSE;
3887 /* Hide the window */
3898 plog("º£¤Ï¥»¡¼¥Ö¤¹¤ë¤³¤È¤Ï½ÐÍè¤Þ¤»¤ó¡£");
3900 plog("You may not do that right now.");
3905 /* Hack -- Forget messages */
3908 /* Hack -- Save the game */
3909 do_cmd_save_game(FALSE);
3914 /* Quit (with save) */
3917 /* Save the game (if necessary) */
3918 if (game_in_progress && character_generated)
3922 plog("º£¤Ï¥»¡¼¥Ö¤¹¤ë¤³¤È¤Ï½ÐÍè¤Þ¤»¤ó¡£");
3924 plog("You may not do that right now.");
3928 /* Hack -- Forget messages */
3933 do_cmd_save_game(FALSE);
3935 Term_key_push(SPECIAL_KEY_QUIT);
3957 /* Require a window */
3966 /* Toggle the "bold" setting */
3969 /* Toggle the setting */
3970 if (td->font_face & bold)
3972 td->font_face &= ~bold;
3976 td->font_face |= bold;
3979 /* Tile Width Hight Init */
3980 td->tile_wid = td->tile_hgt = 0;
3982 /* Apply and Verify */
3983 term_data_check_font(td);
3984 term_data_check_size(td);
3986 /* Resize and Redraw */
3987 term_data_resize(td);
3988 term_data_redraw(td);
3993 /* Toggle the "wide" setting */
3996 /* Toggle the setting */
3997 if (td->font_face & extend)
3999 td->font_face &= ~extend;
4003 td->font_face |= extend;
4006 /* Tile Width Hight Init */
4007 td->tile_wid = td->tile_hgt = 0;
4009 /* Apply and Verify */
4010 term_data_check_font(td);
4011 term_data_check_size(td);
4013 /* Resize and Redraw */
4014 term_data_resize(td);
4015 term_data_redraw(td);
4020 /* Get a new font name */
4021 /* GetMenuItemText(GetMHandle(131), selection, s); */
4022 GetMenuItemText(GetMenuHandle(131), selection, s); //GetItem(GetMHandle(131), selection, s);
4025 /* Save the new font id */
4028 /* Current size is bad for new font */
4029 if (!RealFont(td->font_id, td->font_size))
4031 /* Find similar size */
4032 for (i = 1; i <= 32; i++)
4034 /* Adjust smaller */
4035 if (td->font_size - i >= 8)
4037 if (RealFont(td->font_id, td->font_size - i))
4045 if (td->font_size + i <= 128)
4047 if (RealFont(td->font_id, td->font_size + i))
4056 /* Tile Width Hight Init */
4057 td->tile_wid = td->tile_hgt = 0;
4059 /* Apply and Verify */
4060 term_data_check_font(td);
4061 term_data_check_size(td);
4063 /* Resize and Redraw */
4064 term_data_resize(td);
4065 term_data_redraw(td);
4067 /* Restore the window */
4084 /* GetMenuItemText(GetMHandle(132), selection, s); */
4085 GetMenuItemText(GetMenuHandle(132), selection, s); //GetItem(GetMHandle(132), selection, s);
4087 td->font_size = atoi((char*)(s+1));
4089 /* Tile Width Hight Init */
4090 td->tile_wid = td->tile_hgt = 0;
4092 /* Apply and Verify */
4093 term_data_check_font(td);
4094 term_data_check_size(td);
4096 /* Resize and Redraw */
4097 term_data_resize(td);
4098 term_data_redraw(td);
4112 /* Check legality of choice */
4113 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
4115 /* Obtain the window */
4125 td->t->mapped_flag = TRUE;
4127 /* Show the window */
4130 /* Bring to the front */
4131 SelectWindow(td->w);
4143 /* Toggle arg_sound */
4144 arg_sound = !arg_sound;
4146 /* React to changes */
4147 Term_xtra(TERM_XTRA_REACT, 0);
4154 /* Toggle arg_graphics */
4155 arg_graphics = !arg_graphics;
4157 /* Hack -- Force redraw */
4158 Term_key_push(KTRL('R'));
4165 arg_fiddle = !arg_fiddle;
4171 arg_wizard = !arg_wizard;
4182 if (streq(ANGBAND_GRAF, "old"))
4184 ANGBAND_GRAF = "new";
4185 arg_newstyle_graphics = true;
4186 grafWidth = grafHeight = 16;
4191 ANGBAND_GRAF = "old";
4192 arg_newstyle_graphics = false;
4193 grafWidth = grafHeight = 8;
4197 /* Hack -- Force redraw */
4198 Term_key_push(KTRL('R'));
4202 case 9: /* bigtile mode */
4204 term_data *td = &data[0];
4208 plog("º£¤ÏÊѹ¹½ÐÍè¤Þ¤»¤ó¡£");
4210 plog("You may not do that right now.");
4215 /* Toggle "arg_bigtile" */
4216 arg_bigtile = !arg_bigtile;
4219 Term_activate(td->t);
4221 /* Resize the term */
4222 Term_resize(td->cols, td->rows);
4232 /* TileWidth menu */
4243 /* GetMenuItemText(GetMHandle(135), selection, s); */
4244 GetMenuItemText(GetMenuHandle(135), selection, s); //GetItem(GetMHandle(135), selection, s);
4246 td->tile_wid = atoi((char*)(s+1));
4248 /* Apply and Verify */
4249 term_data_check_size(td);
4251 /* Resize and Redraw */
4252 term_data_resize(td);
4253 term_data_redraw(td);
4261 /* TileHeight menu */
4272 /* GetMenuItemText(GetMHandle(136), selection, s); */
4273 GetMenuItemText(GetMenuHandle(136), selection, s); //GetItem(GetMHandle(136), selection, s);
4275 td->tile_hgt = atoi((char*)(s+1));
4277 /* Apply and Verify */
4278 term_data_check_size(td);
4280 /* Resize and Redraw */
4281 term_data_resize(td);
4282 term_data_redraw(td);
4292 /* Clean the menu */
4301 * Check for extra required parameters -- From "Maarten Hazewinkel"
4303 static OSErr CheckRequiredAEParams(const AppleEvent *theAppleEvent)
4306 DescType returnedType;
4309 aeError = AEGetAttributePtr(theAppleEvent, keyMissedKeywordAttr, typeWildCard,
4310 &returnedType, NULL, 0, &actualSize);
4312 if (aeError == errAEDescNotFound) return (noErr);
4314 if (aeError == noErr) return (errAEParamMissed);
4321 * Apple Event Handler -- Open Application
4323 static pascal OSErr AEH_Start(const AppleEvent *theAppleEvent,
4324 const AppleEvent *reply, long handlerRefCon)
4326 #pragma unused(reply, handlerRefCon)
4328 return (CheckRequiredAEParams(theAppleEvent));
4333 * Apple Event Handler -- Quit Application
4335 static pascal OSErr AEH_Quit(const AppleEvent *theAppleEvent,
4336 const AppleEvent *reply, long handlerRefCon)
4338 #pragma unused(reply, handlerRefCon)
4341 quit_when_ready = TRUE;
4343 /* Check arguments */
4344 return (CheckRequiredAEParams(theAppleEvent));
4349 * Apple Event Handler -- Print Documents
4351 static pascal OSErr AEH_Print(const AppleEvent *theAppleEvent,
4352 const AppleEvent *reply, long handlerRefCon)
4354 #pragma unused(theAppleEvent, reply, handlerRefCon)
4356 return (errAEEventNotHandled);
4361 * Apple Event Handler by Steve Linberg (slinberg@crocker.com).
4363 * The old method of opening savefiles from the finder does not work
4364 * on the Power Macintosh, because CountAppFiles and GetAppFiles,
4365 * used to return information about the selected document files when
4366 * an application is launched, are part of the Segment Loader, which
4367 * is not present in the RISC OS due to the new memory architecture.
4369 * The "correct" way to do this is with AppleEvents. The following
4370 * code is modeled on the "Getting Files Selected from the Finder"
4371 * snippet from Think Reference 2.0. (The prior sentence could read
4372 * "shamelessly swiped & hacked")
4374 static pascal OSErr AEH_Open(AppleEvent *theAppleEvent,
4375 AppleEvent* reply, long handlerRefCon)
4377 #pragma unused(reply, handlerRefCon)
4384 DescType returnedType;
4388 /* Put the direct parameter (a descriptor list) into a docList */
4389 err = AEGetParamDesc(theAppleEvent, keyDirectObject, typeAEList, &docList);
4390 if (err) return err;
4393 * We ignore the validity check, because we trust the FInder, and we only
4394 * allow one savefile to be opened, so we ignore the depth of the list.
4397 err = AEGetNthPtr(&docList, 1L, typeFSS, &keywd,
4398 &returnedType, (Ptr) &myFSS, sizeof(myFSS), &actualSize);
4399 if (err) return err;
4401 /* Only needed to check savefile type below */
4402 err = FSpGetFInfo(&myFSS, &myFileInfo);
4405 sprintf(foo, "Arg! FSpGetFInfo failed with code %d", err);
4410 /* Ignore non 'SAVE' files */
4411 if (myFileInfo.fdType != 'SAVE') return noErr;
4413 /* XXX XXX XXX Extract a file name */
4414 PathNameFromDirID(myFSS.parID, myFSS.vRefNum, (StringPtr)savefile);
4415 pstrcat((StringPtr)savefile, (StringPtr)&myFSS.name);
4417 /* Convert the string */
4418 ptocstr((StringPtr)savefile);
4420 /* Delay actual open */
4421 open_when_ready = TRUE;
4424 err = AEDisposeDesc(&docList);
4436 * Macintosh modifiers (event.modifier & ccc):
4437 * cmdKey, optionKey, shiftKey, alphaLock, controlKey
4440 * Macintosh Keycodes (0-63 normal, 64-95 keypad, 96-127 extra):
4485 * Optimize non-blocking calls to "CheckEvents()"
4486 * Idea from "Maarten Hazewinkel <mmhazewi@cs.ruu.nl>"
4488 #define EVENT_TICKS 6
4492 * Check for Events, return TRUE if we process any
4494 * Hack -- Handle AppleEvents if appropriate (ignore result code).
4496 static bool CheckEvents(bool wait)
4512 term_data *td = NULL;
4516 static huge lastTicks = 0L;
4519 /* Access the clock */
4520 curTicks = TickCount();
4522 /* Hack -- Allow efficient checking for non-pending events */
4523 if (!wait && (curTicks < lastTicks + EVENT_TICKS)) return (FALSE);
4525 /* Timestamp last check */
4526 lastTicks = curTicks;
4528 /* Let the "system" run */
4531 /* Get an event (or null) */
4532 GetNextEvent(everyEvent, &event);
4534 /* Hack -- Nothing is ready yet */
4535 if (event.what == nullEvent) return (FALSE);
4538 /* Analyze the event */
4546 w = (WindowPtr)event.message;
4557 /* Extract the window */
4558 w = (WindowPtr)event.message;
4560 /* Find the window */
4561 for (i = 0; i < MAX_TERM_DATA; i++)
4563 /* Skip dead windows */
4564 if (!data[i].t) continue;
4566 /* Notice matches */
4567 if (data[i].w == w) td = &data[i];
4570 /* Hack XXX XXX XXX */
4574 /* Redraw the window */
4575 if (td) term_data_redraw(td);
4583 /* Extract some modifiers */
4584 mc = (event.modifiers & controlKey) ? TRUE : FALSE;
4585 ms = (event.modifiers & shiftKey) ? TRUE : FALSE;
4586 mo = (event.modifiers & optionKey) ? TRUE : FALSE;
4587 mx = (event.modifiers & cmdKey) ? TRUE : FALSE;
4589 /* Keypress: (only "valid" if ck < 96) */
4590 ch = (event.message & charCodeMask) & 255;
4592 /* Keycode: see table above */
4593 ck = ((event.message & keyCodeMask) >> 8) & 255;
4595 /* Command + "normal key" -> menu action */
4596 if (mx && (ck < 64))
4598 /* Hack -- Prepare the menus */
4601 /* Run the Menu-Handler */
4604 /* Turn off the menus */
4612 /* Hide the mouse pointer */
4615 /* Normal key -> simple keypress */
4618 /* Enqueue the keypress */
4622 /* Hack -- normal "keypad keys" -> special keypress */
4623 else if (!mc && !ms && !mo && !mx && (ck < 96))
4625 /* Hack -- "enter" is confused */
4626 if (ck == 76) ch = '\n';
4628 /* Send control-caret as a trigger */
4631 /* Send the "ascii" keypress */
4635 /* Bizarre key -> encoded keypress */
4638 /* Hack -- introduce with control-underscore */
4641 /* Send some modifier keys */
4642 if (mc) Term_keypress('C');
4643 if (ms) Term_keypress('S');
4644 if (mo) Term_keypress('O');
4645 if (mx) Term_keypress('X');
4647 /* Hack -- Downshift and encode the keycode */
4648 Term_keypress('0' + (ck - 64) / 10);
4649 Term_keypress('0' + (ck - 64) % 10);
4651 /* Hack -- Terminate the sequence */
4652 /* MPW can generate 10 or 13 for keycode of '\r' */
4653 /* -noMapCR option swaps '\r' and '\n' */
4654 Term_keypress('\r');
4664 /* Analyze click location */
4665 code = FindWindow(event.where, &w);
4667 /* Find the window */
4668 for (i = 0; i < MAX_TERM_DATA; i++)
4670 /* Skip dead windows */
4671 if (!data[i].t) continue;
4673 /* Notice matches */
4674 if (data[i].w == w) td = &data[i];
4683 menu(MenuSelect(event.where));
4690 SystemClick(&event, w);
4700 r = qd.screenBits.bounds;
4701 r.top += 20; /* GetMBarHeight() XXX XXX XXX */
4702 InsetRect(&r, 4, 4);
4703 DragWindow(w, event.where, &r);
4715 p.h = td->w->portRect.left;
4716 p.v = td->w->portRect.top;
4724 /* Apply and Verify */
4725 term_data_check_size(td);
4735 /* Track the go-away box */
4736 if (TrackGoAway(w, event.where))
4742 td->t->mapped_flag = FALSE;
4744 /* Hide the window */
4760 /* Fake rectangle */
4761 r.left = 20 * td->tile_wid + td->size_ow1;
4762 r.right = qd.screenBits.bounds.right;
4763 r.top = 1 * td->tile_hgt + td->size_oh1;
4764 r.bottom = qd.screenBits.bounds.bottom;
4766 /* Grow the rectangle */
4767 newsize = GrowWindow(w, event.where, &r);
4770 if (!newsize) break;
4772 /* Extract the new size in pixels */
4773 y = HiWord(newsize) - td->size_oh1 - td->size_oh2;
4774 x = LoWord(newsize) - td->size_ow1 - td->size_ow2;
4776 /* Extract a "close" approximation */
4777 td->rows = y / td->tile_hgt;
4778 td->cols = x / td->tile_wid;
4780 /* Apply and Verify */
4781 term_data_check_size(td);
4783 Term_activate(td->t);
4785 /* Hack -- Resize the term */
4786 Term_resize(td->cols, td->rows);
4788 /* Resize and Redraw */
4789 term_data_resize(td);
4790 term_data_redraw(td);
4809 /* Disk Event -- From "Maarten Hazewinkel" */
4812 /* check for error when mounting the disk */
4813 if (HiWord(event.message) != noErr)
4819 DIBadMount(p, event.message);
4826 /* OS Event -- From "Maarten Hazewinkel" */
4829 switch ((event.message >> 24) & 0x000000FF)
4831 case suspendResumeMessage:
4833 /* Resuming: activate the front window */
4834 if (event.message & resumeFlag)
4836 SetPort(FrontWindow());
4837 SetCursor(&qd.arrow);
4840 /* Suspend: deactivate the front window */
4854 /* From "Steve Linberg" and "Maarten Hazewinkel" */
4855 case kHighLevelEvent:
4857 /* Process apple events */
4858 if (AEProcessAppleEvent(&event) != noErr)
4861 plog("Apple Event Handler¤Î¥¨¥é¡¼¤Ç¤¹.");
4863 plog("Error in Apple Event Handler!");
4867 /* Handle "quit_when_ready" */
4868 if (quit_when_ready)
4871 quit_when_ready = FALSE;
4873 /* Do the menu key */
4876 /* Turn off the menus */
4880 /* Handle "open_when_ready" */
4881 handle_open_when_ready();
4891 /* Something happened */
4898 /*** Some Hooks for various routines ***/
4902 * Mega-Hack -- emergency lifeboat
4904 static vptr lifeboat = NULL;
4908 * Hook to "release" memory
4910 static vptr hook_rnfree(vptr v, huge size)
4913 #pragma unused (size)
4917 /* Alternative method */
4932 * Hook to "allocate" memory
4934 static vptr hook_ralloc(huge size)
4939 /* Make a new pointer */
4940 return (malloc(size));
4944 /* Make a new pointer */
4945 return (NewPtr(size));
4952 * Hook to handle "out of memory" errors
4954 static vptr hook_rpanic(huge size)
4957 #pragma unused (size)
4961 /* Free the lifeboat */
4964 /* Free the lifeboat */
4965 DisposePtr(lifeboat);
4967 /* Forget the lifeboat */
4970 /* Mega-Hack -- Warning */
4972 mac_warning("¥á¥â¥ê¡¼¤¬Â¤ê¤Þ¤»¤ó!\rº£¤¹¤°½ªÎ»¤·¤Æ²¼¤µ¤¤!");
4974 mac_warning("Running out of Memory!\rAbort this process now!");
4977 /* Mega-Hack -- Never leave this function */
4978 while (TRUE) CheckEvents(TRUE);
4981 /* Mega-Hack -- Crash */
4987 * Hook to tell the user something important
4989 static void hook_plog(cptr str)
4991 /* Warning message */
4996 * Hook to tell the user something, and then quit
4998 static void hook_quit(cptr str)
5000 /* Warning if needed */
5001 if (str) mac_warning(str);
5003 /* Write a preference file */
5011 * Hook to tell the user something, and then crash
5013 static void hook_core(cptr str)
5015 /* XXX Use the debugger */
5016 /* DebugStr(str); */
5019 if (str) mac_warning(str);
5021 /* Warn, then save player */
5023 mac_warning("Ã×̿Ū¤Ê¥¨¥é¡¼¤Ç¤¹.\r¶¯À©Åª¤Ë¥»¡¼¥Ö¤·¤Æ½ªÎ»¤·¤Þ¤¹.");
5025 mac_warning("Fatal error.\rI will now attempt to save and quit.");
5028 /* Attempt to save */
5030 if (!save_player()) mac_warning("·Ù¹ð -- ¥»¡¼¥Ö¤Ë¼ºÇÔ¤·¤Þ¤·¤¿!");
5032 if (!save_player()) mac_warning("Warning -- save failed!");
5041 /*** Main program ***/
5047 * XXX XXX XXX Hack -- This function attempts to "fix" the nasty
5048 * "Macintosh Save Bug" by using "absolute" path names, since on
5049 * System 7 machines anyway, the "current working directory" often
5050 * "changes" due to background processes, invalidating any "relative"
5051 * path names. Note that the Macintosh is limited to 255 character
5052 * path names, so be careful about deeply embedded directories...
5054 * XXX XXX XXX Hack -- This function attempts to "fix" the nasty
5055 * "missing lib folder bug" by allowing the user to help find the
5056 * "lib" folder by hand if the "application folder" code fails...
5058 static void init_stuff(void)
5075 /* Fake rectangle */
5082 center_rect(&r, &qd.screenBits.bounds);
5084 /* Extract corner */
5089 /* Default to the "lib" folder with the application */
5090 refnum_to_name(path, app_dir, app_vol, (char*)("\plib:"));
5093 /* Check until done */
5096 /* Prepare the paths */
5097 init_file_paths(path);
5099 /* Build the filename */
5101 path_build(path, sizeof(path), ANGBAND_DIR_FILE, "news_j.txt");
5103 path_build(path, sizeof(path), ANGBAND_DIR_FILE, "news.txt");
5106 /* Attempt to open and close that file */
5107 if (0 == fd_close(fd_open(path, O_RDONLY))) break;
5111 plog_fmt("'%s' ¥Õ¥¡¥¤¥ë¤ò¥ª¡¼¥×¥ó½ÐÍè¤Þ¤»¤ó.", path);
5113 plog_fmt("Unable to open the '%s' file.", path);
5118 plog("Hengband¤Î'lib'¥Õ¥©¥ë¥À¤¬Â¸ºß¤·¤Ê¤¤¤«Àµ¤·¤¯Ìµ¤¤²ÄǽÀ¤¬¤¢¤ê¤Þ¤¹.");
5120 plog("The Angband 'lib' folder is probably missing or misplaced.");
5124 plog("Please 'open' any file in any sub-folder of the 'lib' folder.");
5126 /* Allow "text" files */
5129 /* Allow "save" files */
5132 /* Allow "data" files */
5136 SFGetFile(topleft, "\p", NULL, 3, types, NULL, &reply);
5139 if (!reply.good) quit(NULL);
5141 /* Extract textual file name for given file */
5142 GetWDInfo(reply.vRefNum, &vrefnum, &drefnum, &junk);
5143 refnum_to_name(path, drefnum, vrefnum, (char*)reply.fName);
5145 /* Hack -- Remove the "filename" */
5146 i = strlen(path) - 1;
5147 while ((i > 0) && (path[i] != ':')) i--;
5148 if (path[i] == ':') path[i+1] = '\0';
5150 /* Hack -- allow "lib" folders */
5151 if (suffix(path, "lib:")) continue;
5153 /* Hack -- Remove the "sub-folder" */
5155 while ((i > 1) && (path[i] != ':')) i--;
5156 if (path[i] == ':') path[i+1] = '\0';
5162 * Macintosh Main loop
5166 EventRecord tempEvent;
5167 int numberOfMasters = 10;
5169 /* Increase stack space by 64K */
5170 SetApplLimit(GetApplLimit() - 131072L);//65536L);
5172 /* Stretch out the heap to full size */
5175 /* Get more Masters */
5176 while (numberOfMasters--) MoreMasters();
5178 /* Set up the Macintosh */
5179 InitGraf(&qd.thePort);
5192 FlushEvents(everyEvent, 0);
5194 /* Flush events some more (?) */
5195 (void)EventAvail(everyEvent, &tempEvent);
5196 (void)EventAvail(everyEvent, &tempEvent);
5197 (void)EventAvail(everyEvent, &tempEvent);
5200 #ifdef ANGBAND_LITE_MAC
5204 #else /* ANGBAND_LITE_MAC */
5206 # if defined(powerc) || defined(__powerc)
5208 /* Assume System 7 */
5210 /* Assume Color Quickdraw */
5220 /* Check the Gestalt */
5221 err = Gestalt(gestaltSystemVersion, &versionNumber);
5223 /* Check the version */
5224 if ((err != noErr) || (versionNumber < 0x0700))
5227 quit("¤³¤Î¥×¥í¥°¥é¥à¤Ï´Á»úTalk7.x.x°Ê¹ß¤ÇÆ°ºî¤·¤Þ¤¹.");
5229 quit("You must have System 7 to use this program.");
5239 /* Check the environs */
5240 if (SysEnvirons(1, &env) != noErr)
5243 quit("SysEnvirons ¥³¡¼¥ë¤Ï¼ºÇÔ¤·¤Þ¤·¤¿¡ª");
5245 quit("The SysEnvirons call failed!");
5249 /* Check for System Seven Stuff */
5250 if (env.systemVersion < 0x0700)
5253 quit("¤³¤Î¥×¥í¥°¥é¥à¤Ï´Á»úTalk7.x.x°Ê¹ß¤ÇÆ°ºî¤·¤Þ¤¹.");
5255 quit("You must have System 7 to use this program.");
5259 /* Check for Color Quickdraw */
5260 if (!env.hasColorQD)
5263 quit("¤³¤Î¥×¥í¥°¥é¥à¤ÏColor Quickdraw¤¬Ìµ¤¤¤ÈÆ°ºî¤·¤Þ¤»¤ó.");
5265 quit("You must have Color Quickdraw to use this program.");
5272 #endif /* ANGBAND_LITE_MAC */
5277 /* Obtain a "Universal Procedure Pointer" */
5278 AEH_Start_UPP = NewAEEventHandlerProc(AEH_Start);
5280 /* Install the hook (ignore error codes) */
5281 AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, AEH_Start_UPP,
5284 /* Obtain a "Universal Procedure Pointer" */
5285 AEH_Quit_UPP = NewAEEventHandlerProc(AEH_Quit);
5287 /* Install the hook (ignore error codes) */
5288 AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, AEH_Quit_UPP,
5291 /* Obtain a "Universal Procedure Pointer" */
5292 AEH_Print_UPP = NewAEEventHandlerProc(AEH_Print);
5294 /* Install the hook (ignore error codes) */
5295 AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments, AEH_Print_UPP,
5298 /* Obtain a "Universal Procedure Pointer" */
5299 AEH_Open_UPP = NewAEEventHandlerProc(AEH_Open);
5301 /* Install the hook (ignore error codes) */
5302 AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, AEH_Open_UPP,
5308 /* Find the current application */
5312 /* Mark ourself as the file creator */
5315 /* Default to saving a "text" file */
5319 #if defined(__MWERKS__)
5321 /* Obtian a "Universal Procedure Pointer" */
5322 ynfilterUPP = NewModalFilterProc(ynfilter);
5327 /* Hook in some "z-virt.c" hooks */
5328 rnfree_aux = hook_rnfree;
5329 ralloc_aux = hook_ralloc;
5330 rpanic_aux = hook_rpanic;
5332 /* Hooks in some "z-util.c" hooks */
5333 plog_aux = hook_plog;
5334 quit_aux = hook_quit;
5335 core_aux = hook_core;
5337 BackColor(blackColor);
5338 ForeColor(whiteColor);
5340 /* Show the "watch" cursor */
5341 SetCursor(*(GetCursor(watchCursor)));
5343 /* Prepare the menubar */
5346 /* Prepare the windows */
5353 /* Hack -- process all events */
5354 while (CheckEvents(TRUE)) /* loop */;
5356 /* Reset the cursor */
5357 SetCursor(&qd.arrow);
5360 /* Mega-Hack -- Allocate a "lifeboat" */
5361 lifeboat = NewPtr(16384);
5363 /* Note the "system" */
5364 ANGBAND_SYS = "mac";
5373 /* Hack -- process all events */
5374 while (CheckEvents(TRUE)) /* loop */;
5377 /* We are now initialized */
5381 /* Handle "open_when_ready" */
5382 handle_open_when_ready();
5388 /* Prompt the user */
5390 prt("'¥Õ¥¡¥¤¥ë'¥á¥Ë¥å¡¼¤è¤ê'¿·µ¬'¤Þ¤¿¤Ï'³«¤¯...'¤òÁªÂò¤·¤Æ¤¯¤À¤µ¤¤¡£", 23, 10);
5392 prt("[Choose 'New' or 'Open' from the 'File' menu]", 23, 15);
5395 /* Flush the prompt */
5399 /* Hack -- Process Events Forever */
5400 while (TRUE) CheckEvents(TRUE);