1 /* CVS: Last edit by $Author$ on $Date$ */
4 /* Purpose: Simple support for MACINTOSH Angband */
7 * This file should only be compiled with the "Macintosh" version
9 * This file written by "Ben Harrison (benh@phial.com)".
11 * Some code adapted from "MacAngband 2.6.1" by Keith Randall
13 * Maarten Hazewinkel (mmhazewi@cs.ruu.nl) provided some initial
14 * suggestions for the PowerMac port.
16 * Steve Linberg (slinberg@crocker.com) provided the code surrounded
19 * The graphics code is adapted from an extremely minimal subset of
20 * the code from "Sprite World II", an amazing animation package.
22 * See "z-term.c" for info on the concept of the "generic terminal"
24 * The preference file is now a text file named "Angband preferences".
26 * Note that the "preference" file is now a simple text file called
27 * "Angband preferences", which contains the versions information, so
28 * that obsolete preference files can be ignored (this may be bad).
30 * Note that "init1.c", "init2.c", "load1.c", "load2.c", and "birth.c"
31 * should probably be "unloaded" as soon as they are no longer needed,
32 * to save space, but I do not know how to do this.
34 * Stange bug -- The first "ClipRect()" call crashes if the user closes
35 * all the windows, switches to another application, switches back, and
36 * then re-opens the main window, for example, using "command-a".
38 * By default, this file assumes that you will be using a 68020 or better
39 * machine, running System 7 and Color Quickdraw. In fact, the game will
40 * refuse to run unless these features are available. This allows the use
41 * of a variety of interesting features such as graphics and sound.
43 * To create a version which can be used on 68000 machines, or on machines
44 * which are not running System 7 or Color Quickdraw, simply activate the
45 * "ANGBAND_LITE_MAC" compilation flag in the proper header file. This
46 * will disable all "modern" features used in this file, including support
47 * for multiple sub-windows, color, graphics, and sound.
49 * When compiling with the "ANGBAND_LITE_MAC" flag, the "ANGBAND_LITE"
50 * flag will be automatically defined, which will disable many of the
51 * advanced features of the game itself, reducing the total memory usage.
53 * If you are never going to use "graphics" (especially if you are not
54 * compiling support for graphics anyway) then you can delete the "pict"
55 * resource with id "1001" with no dangerous side effects.
60 * Important Resources in the resource file:
62 * FREF 130 = 'A271' / 'APPL' (application)
63 * FREF 129 = 'A271' / 'SAVE' (save file)
64 * FREF 130 = 'A271' / 'TEXT' (bone file, generic text file)
65 * FREF 131 = 'A271' / 'DATA' (binary image file, score file)
67 * DLOG 128 = "About Angband..."
69 * ALRT 128 = unused (?)
70 * ALRT 129 = "Warning..."
71 * ALRT 130 = "Are you sure you want to quit without saving?"
73 * DITL 128 = body for DLOG 128
74 * DITL 129 = body for ALRT 129
75 * DITL 130 = body for ALRT 130
77 * ICON 128 = "warning" icon
79 * MENU 128 = apple (about, -, ...)
80 * MENU 129 = File (new, open, close, save, -, exit, quit)
81 * MENU 130 = Edit (undo, -, cut, copy, paste, clear)
83 * PICT 1001 = Graphics tile set
89 * all 'APEX' files have a filename of the form "*:apex:*" (?)
90 * all 'BONE' files have a filename of the form "*:bone:*" (?)
91 * all 'DATA' files have a filename of the form "*:data:*"
92 * all 'SAVE' files have a filename of the form "*:save:*"
93 * all 'USER' files have a filename of the form "*:user:*" (?)
95 * Perhaps we should attempt to set the "_ftype" flag inside this file,
96 * to avoid nasty file type information being spread all through the
97 * rest of the code. (?) This might require adding hooks into the
98 * "fd_open()" and "my_fopen()" functions in "util.c". XXX XXX XXX
103 * Reasons for each header file:
105 * angband.h = Angband header file
107 * Types.h = (included anyway)
108 * Gestalt.h = gestalt code
109 * QuickDraw.h = (included anyway)
110 * OSUtils.h = (included anyway)
111 * Files.h = file code
112 * Fonts.h = font code
113 * Menus.h = menu code
114 * Dialogs.h = dialog code
115 * Windows.h = (included anyway)
116 * Palettes.h = palette code
117 * StandardFile.h = file dialog box
118 * DiskInit.h = disk initialization
119 * ToolUtils.h = HiWord() / LoWord()
120 * Desk.h = OpenDeskAcc()
121 * Devices.h = OpenDeskAcc()
122 * Events.h = event code
123 * Resources.h = resource code
124 * Controls.h = button code
125 * SegLoad.h = ExitToShell(), AppFile, etc
126 * Memory.h = SetApplLimit(), NewPtr(), etc
127 * QDOffscreen.h = GWorld code
128 * Sound.h = Sound code
130 * For backwards compatibility:
131 * Use GestaltEqu.h instead of Gestalt.h
132 * Add Desk.h to include simply includes Menus.h, Devices.h, Events.h
140 #include <QuickDraw.h>
146 #include <Palettes.h>
147 #include <StandardFile.h>
148 #include <DiskInit.h>
149 #include <ToolUtils.h>
152 #include <Resources.h>
153 #include <Controls.h>
156 #include <QDOffscreen.h>
166 * Use "malloc()" instead of "NewPtr()"
168 /* #define USE_MALLOC */
171 #if defined(powerc) || defined(__powerc)
174 * Disable "LITE" version
176 # undef ANGBAND_LITE_MAC
181 #ifdef ANGBAND_LITE_MAC
184 * Maximum number of windows
186 # define MAX_TERM_DATA 1
188 #else /* ANGBAND_LITE_MAC */
191 * Maximum number of windows
193 # define MAX_TERM_DATA 8
196 * Activate some special code
198 # define USE_SFL_CODE
200 #endif /* ANGBAND_LITE_MAC */
207 * Include the necessary header files
209 #include <AppleEvents.h>
219 * The Angband Color Set (0 to 15):
220 * Black, White, Slate, Orange, Red, Blue, Green, Umber
221 * D-Gray, L-Gray, Violet, Yellow, L-Red, L-Blue, L-Green, L-Umber
223 * Colors 8 to 15 are basically "enhanced" versions of Colors 0 to 7.
225 * On the Macintosh, we use color quickdraw, and we use actual "RGB"
226 * values below to choose the 16 colors.
228 * If we are compiled for ancient machines, we bypass color and simply
229 * draw everything in white (letting "z-term.c" automatically convert
230 * "black" into "wipe" calls).
232 static RGBColor foo[16] =
234 {0x0000, 0x0000, 0x0000}, /* TERM_DARK */
235 {0xFFFF, 0xFFFF, 0xFFFF}, /* TERM_WHITE */
236 {0x8080, 0x8080, 0x8080}, /* TERM_SLATE */
237 {0xFFFF, 0x8080, 0x0000}, /* TERM_ORANGE */
238 {0xC0C0, 0x0000, 0x0000}, /* TERM_RED */
239 {0x0000, 0x8080, 0x4040}, /* TERM_GREEN */
240 {0x0000, 0x0000, 0xFFFF}, /* TERM_BLUE */
241 {0x8080, 0x4040, 0x0000}, /* TERM_UMBER */
242 {0x4040, 0x4040, 0x4040}, /* TERM_L_DARK */
243 {0xC0C0, 0xC0C0, 0xC0C0}, /* TERM_L_WHITE */
244 {0xFFFF, 0x0000, 0xFFFF}, /* TERM_VIOLET */
245 {0xFFFF, 0xFFFF, 0x0000}, /* TERM_YELLOW */
246 {0xFFFF, 0x0000, 0x0000}, /* TERM_L_RED */
247 {0x0000, 0xFFFF, 0x0000}, /* TERM_L_GREEN */
248 {0x0000, 0xFFFF, 0xFFFF}, /* TERM_L_BLUE */
249 {0xC0C0, 0x8080, 0x4040} /* TERM_L_UMBER */
258 typedef struct term_data term_data;
271 #ifdef ANGBAND_LITE_MAC
275 #else /* ANGBAND_LITE_MAC */
287 #endif /* ANGBAND_LITE_MAC */
290 GWorldPtr bufferPort;
291 PixMapHandle bufferPixHndl;
336 * Forward declare -- see below
338 static bool CheckEvents(bool wait);
342 * Hack -- location of the main directory
344 static short app_vol;
349 * Delay handling of double-clicked savefiles
351 Boolean open_when_ready = FALSE;
354 * Delay handling of pre-emptive "quit" event
356 Boolean quit_when_ready = FALSE;
360 * Hack -- game in progress
362 static int game_in_progress = 0;
366 * Only do "SetPort()" when needed
368 static WindowPtr active = NULL;
373 * An array of term_data's
375 static term_data data[MAX_TERM_DATA];
380 * Note when "open"/"new" become valid
382 static bool initialized = FALSE;
387 * CodeWarrior uses Universal Procedure Pointers
389 static ModalFilterUPP ynfilterUPP;
396 AEEventHandlerUPP AEH_Start_UPP;
397 AEEventHandlerUPP AEH_Quit_UPP;
398 AEEventHandlerUPP AEH_Print_UPP;
399 AEEventHandlerUPP AEH_Open_UPP;
407 static int ext_sound = 0;
415 #define SND_CMD_ERROR 6
417 static int soundchoice[] = {
485 static int soundmode[8];
494 * Convert refnum+vrefnum+fname into a full file name
495 * Store this filename in 'buf' (make sure it is long enough)
496 * Note that 'fname' looks to be a "pascal" string
498 static void refnum_to_name(char *buf, long refnum, short vrefnum, char *fname)
514 for (j=1; j<=fname[0]; j++)
516 res[i-fname[0]+j] = fname[j];
523 /* pb.ioCompletion=NULL;
525 pb.ioVRefNum=vrefnum;
531 pb.ioDrDirID=pb.ioDrParID;
532 // err = PBGetCatInfo((CInfoPBPtr)&pb, FALSE);
533 err = FSMakeFSSpec( vref, dirID, "\p", &spec );
539 for (j=1; j<=spec.name[0]; j++)
541 res[i-spec.name[0]+j] = spec.name[j];
546 // if (pb.ioDrDirID == fsRtDirID) break;
549 /* Extract the result */
550 for (j = 0, i++; res[i]; j++, i++) buf[j] = res[i];
554 pascal OSErr FSpLocationFromFullPath(short fullPathLength,
555 const void *fullPath,
563 /* Create a minimal alias from the full pathname */
564 nullString[0] = 0; /* null string to indicate no zone or server name */
565 result = NewAliasMinimalFromFullPath(fullPathLength, fullPath, nullString, nullString, &alias);
566 if ( result == noErr )
568 /* Let the Alias Manager resolve the alias. */
569 result = ResolveAlias(NULL, alias, spec, &wasChanged);
571 /* work around Alias Mgr sloppy volume matching bug */
572 if ( spec->vRefNum == 0 )
574 /* invalidate wrong FSSpec */
579 DisposeHandle((Handle)alias); /* Free up memory used */
588 * XXX XXX XXX Allow the system to ask us for a filename
590 static bool askfor_file(char *buf, int len)
598 /* Default file name */
599 sprintf((char*)dflt + 1, "%s's description", buf);
600 dflt[0] = strlen((char*)dflt + 1);
602 /* Ask for a file name */
603 topleft.h=(qd.screenBits.bounds.left+qd.screenBits.bounds.right)/2-344/2;
604 topleft.v=(2*qd.screenBits.bounds.top+qd.screenBits.bounds.bottom)/3-188/2;
605 SFPutFile(topleft, "\pSelect a filename:", dflt, NULL, &reply);
606 /* StandardPutFile("\pSelect a filename:", dflt, &reply); */
614 GetWDInfo(reply.vRefNum, &vrefnum, &drefnum, &junk);
616 /* Extract the name */
617 refnum_to_name(buf, drefnum, vrefnum, (char*)reply.fName);
629 static void local_to_global( Rect *r )
636 LocalToGlobal( &temp );
644 LocalToGlobal( &temp );
650 static void global_to_local( Rect *r )
657 GlobalToLocal( &temp );
665 GlobalToLocal( &temp );
672 * Center a rectangle inside another rectangle
674 static void center_rect(Rect *r, Rect *s)
676 int centerx = (s->left + s->right)/2;
677 int centery = (2*s->top + s->bottom)/3;
678 int dx = centerx - (r->right - r->left)/2 - r->left;
679 int dy = centery - (r->bottom - r->top)/2 - r->top;
688 * Convert a pascal string in place
690 * This function may be defined elsewhere, but since it is so
691 * small, it is not worth finding the proper function name for
692 * all the different platforms.
694 static void ptocstr(StringPtr src)
698 /* Hack -- pointer */
699 char *s = (char*)(src);
701 /* Hack -- convert the string */
702 for (i = s[0]; i; i--, s++) s[0] = s[1];
704 /* Hack -- terminate the string */
709 #if defined(USE_SFL_CODE)
713 * The following three routines (pstrcat, pstrinsert, and PathNameFromDirID)
714 * were taken from the Think Reference section called "Getting a Full Pathname"
715 * (under the File Manager section). We need PathNameFromDirID to get the
716 * full pathname of the opened savefile, making no assumptions about where it
719 * I had to hack PathNameFromDirID a little for MetroWerks, but it's awfully
722 static void pstrcat(StringPtr dst, StringPtr src)
725 BlockMove(src + 1, dst + *dst + 1, *src);
727 /* adjust length byte */
732 * pstrinsert - insert string 'src' at beginning of string 'dst'
734 static void pstrinsert(StringPtr dst, StringPtr src)
736 /* make room for new string */
737 BlockMove(dst + 1, dst + *src + 1, *dst);
739 /* copy new string in */
740 BlockMove(src + 1, dst + 1, *src);
742 /* adjust length byte */
746 static void PathNameFromDirID(long dirID, short vRefNum, StringPtr fullPathName)
749 Str255 directoryName;
752 fullPathName[0] = '\0';
754 block.dirInfo.ioDrParID = dirID;
755 block.dirInfo.ioNamePtr = directoryName;
759 block.dirInfo.ioVRefNum = vRefNum;
760 block.dirInfo.ioFDirIndex = -1;
761 block.dirInfo.ioDrDirID = block.dirInfo.ioDrParID;
762 err = PBGetCatInfo(&block, FALSE);
763 pstrcat(directoryName, (StringPtr)"\p:");
764 pstrinsert(fullPathName, directoryName);
765 if (block.dirInfo.ioDrDirID == 2) break;
771 static OSType GetProcessSignature( void )
773 ProcessSerialNumber thePSN;
777 thePSN.highLongOfPSN = 0;
778 thePSN.lowLongOfPSN = kCurrentProcess;
780 info.processInfoLength = sizeof(ProcessInfoRec);
781 info.processName = nil;
782 info.processAppSpec = nil;
784 err = GetProcessInformation(&thePSN, &info);
787 quit( "Internal System Error. Process Information could not be found." );
789 return info.processSignature;
792 static OSErr ChooseFile( StringPtr filename, FSSpec selfld )
794 NavReplyRecord reply;
795 NavDialogOptions dialogOptions;
796 NavTypeListHandle navTypeList = NULL;
800 AECreateDesc( typeFSS, &selfld, sizeof(FSSpec), &deffld );
802 err = NavGetDefaultDialogOptions( &dialogOptions );
806 err = NavChooseFile( &deffld, &reply, &dialogOptions, NULL, NULL, NULL, navTypeList, NULL );
808 if ( reply.validRecord && err == noErr ){
809 // grab the target FSSpec from the AEDesc:
815 // retrieve the returned selection:
816 // there is only one selection here we get only the first AEDescList:
817 if (( err = AEGetNthPtr( &(reply.selection), 1, typeFSS, &keyWord, &typeCode, &finalFSSpec, sizeof( FSSpec ), &actualSize )) == noErr )
819 refnum_to_name( filename, finalFSSpec.parID, finalFSSpec.vRefNum, &finalFSSpec.name );
820 // 'finalFSSpec' is the chosen file
\8eÉ
823 err = NavDisposeReply( &reply );
825 if( navTypeList != NULL )
827 DisposeHandle( (Handle)navTypeList );
832 AEDisposeDesc( &deffld );
838 * Activate a given window, if necessary
840 static void activate(WindowPtr w)
847 if (w) SetPortWindowPort(w);
859 * Display a warning message
861 static void mac_warning(cptr warning)
866 /* Limit of 250 chars */
867 len = strlen(warning);
868 if (len > 250) len = 250;
870 /* Make a "Pascal" string */
872 for (i=0; i<len; i++) text[i+1] = warning[i];
874 /* Prepare the dialog box values */
875 ParamText(text, "\p", "\p", "\p");
877 /* Display the Alert, wait for Okay */
883 /*** Some generic functions ***/
886 #ifdef ANGBAND_LITE_MAC
889 * Hack -- activate a color (0 to 255)
891 #define term_data_color(TD,A) /* Nothing */
893 #else /* ANGBAND_LITE_MAC */
896 * Hack -- activate a color (0 to 255)
898 static void term_data_color(term_data *td, int a)
905 /* Extract the R,G,B data */
906 rv = angband_color_table[a][1];
907 gv = angband_color_table[a][2];
908 bv = angband_color_table[a][3];
911 color.red = (rv | (rv << 8));
912 color.green = (gv | (gv << 8));
913 color.blue = (bv | (bv << 8));
915 /* Activate the color */
916 RGBForeColor(&color);
921 /* Activate the color */
928 /* Extract the R,G,B data */
929 rv = angband_color_table[a][1];
930 gv = angband_color_table[a][2];
931 bv = angband_color_table[a][3];
934 color.red = (rv | (rv << 8));
935 color.green = (gv | (gv << 8));
936 color.blue = (bv | (bv << 8));
938 /* Activate the color */
939 RGBForeColor(&color);
947 #endif /* ANGBAND_LITE_MAC */
951 * Hack -- Apply and Verify the "font" info
953 * This should usually be followed by "term_data_check_size()"
955 static void term_data_check_font(term_data *td)
961 WindowPtr old = active;
967 /* Instantiate font */
968 TextFont(td->font_id);
969 TextSize(td->font_size);
970 TextFace(td->font_face);
972 /* Extract the font info */
975 /* Assume monospaced */
976 td->font_mono = TRUE;
978 /* Extract the font sizing values XXX XXX XXX */
979 td->font_wid = CharWidth('@'); /* info.widMax; */
980 td->font_hgt = info.ascent + info.descent;
982 td->font_o_y = info.ascent;
984 /* Check important characters */
985 for (i = 33; i < 127; i++)
987 /* Hack -- notice non-mono-space */
988 if (td->font_wid != CharWidth(i)) td->font_mono = FALSE;
990 /* Hack -- collect largest width */
991 if (td->font_wid < CharWidth(i)) td->font_wid = CharWidth(i);
994 /* Set default offsets */
995 td->tile_o_x = td->font_o_x;
996 td->tile_o_y = td->font_o_y;
998 /* Set default tile size */
1000 if( td->tile_wid == 0 && td->tile_hgt == 0 ){
1001 td->tile_wid = td->font_wid;
1002 td->tile_hgt = td->font_hgt;
1005 td->tile_wid = td->font_wid;
1006 td->tile_hgt = td->font_hgt;
1009 /* Re-activate the old window */
1015 * Hack -- Apply and Verify the "size" info
1017 static void term_data_check_size(term_data *td)
1021 #ifdef TARGET_CARBON
1022 GetQDGlobalsScreenBits( &screen );
1024 screen = qd.screenBits;
1027 /* Minimal window size */
1028 if (td->cols < 1) td->cols = 1;
1029 if (td->rows < 1) td->rows = 1;
1031 /* Minimal tile size */
1032 if (td->tile_wid < 4) td->tile_wid = 4;
1033 if (td->tile_hgt < 4) td->tile_hgt = 4;
1035 /* Default tile offsets */
1036 td->tile_o_x = (td->tile_wid - td->font_wid) / 2;
1037 td->tile_o_y = (td->tile_hgt - td->font_hgt) / 2;
1039 /* Minimal tile offsets */
1040 if (td->tile_o_x < 0) td->tile_o_x = 0;
1041 if (td->tile_o_y < 0) td->tile_o_y = 0;
1043 /* Apply font offsets */
1044 td->tile_o_x += td->font_o_x;
1045 td->tile_o_y += td->font_o_y;
1047 /* Calculate full window size */
1048 td->size_wid = td->cols * td->tile_wid + td->size_ow1 + td->size_ow2;
1049 td->size_hgt = td->rows * td->tile_hgt + td->size_oh1 + td->size_oh2;
1051 /* Verify the top */
1052 if (td->r.top > screen.bounds.bottom - td->size_hgt)
1054 td->r.top = screen.bounds.bottom - td->size_hgt;
1057 /* Verify the top */
1058 if (td->r.top < screen.bounds.top + 30)
1060 td->r.top = screen.bounds.top + 30;
1063 /* Verify the left */
1064 if (td->r.left > screen.bounds.right - td->size_wid)
1066 td->r.left = screen.bounds.right - td->size_wid;
1069 /* Verify the left */
1070 if (td->r.left < screen.bounds.left)
1072 td->r.left = screen.bounds.left;
1075 /* Calculate bottom right corner */
1076 td->r.right = td->r.left + td->size_wid;
1077 td->r.bottom = td->r.top + td->size_hgt;
1079 /* Assume no graphics */
1080 td->t->always_pict = FALSE;
1082 #ifdef ANGBAND_LITE_MAC
1086 #else /* ANGBAND_LITE_MAC */
1088 /* Handle graphics */
1089 if (use_graphics && (td == &data[0]))
1091 td->t->always_pict = TRUE;
1094 #endif /* ANGBAND_LITE_MAC */
1096 /* Fake mono-space */
1097 if (!td->font_mono ||
1098 (td->font_wid != td->tile_wid) ||
1099 (td->font_hgt != td->tile_hgt))
1101 /* Handle fake monospace */
1102 td->t->always_pict = TRUE;
1106 //static OSErr XDDSWUpDateGWorldFromPict( term_data *td );
1108 * Hack -- resize a term_data
1110 * This should normally be followed by "term_data_resize()"
1112 static void term_data_resize(term_data *td)
1114 /* Actually resize the window */
1115 SizeWindow(td->w, td->size_wid, td->size_hgt, 0);
1118 XDDSWUpDateGWorldFromPict( td );
1125 * Hack -- redraw a term_data
1127 * Note that "Term_redraw()" calls "TERM_XTRA_CLEAR"
1129 static void term_data_redraw(term_data *td)
1133 /* Activate the term */
1134 Term_activate(td->t);
1136 /* Redraw the contents */
1139 /* Flush the output */
1142 /* Restore the old term */
1145 /* No need to redraw */
1146 #ifdef TARGET_CARBON
1148 RgnHandle theRgn = NewRgn();
1149 GetWindowRegion( td->w, kWindowContentRgn, theRgn );
1150 ValidWindowRgn( (WindowRef)(td->w), theRgn );
1151 DisposeRgn( theRgn );
1154 ValidRect( &(td->w->portRect) );
1162 #ifdef ANGBAND_LITE_MAC
1166 #else /* ANGBAND_LITE_MAC */
1173 #define kPictID 1001 /* Graf 'pict' resource */
1175 #define kGrafWidth 8 /* Graf Size (X) */
1176 #define kGrafHeight 8 /* Graf Size (Y) */
1182 typedef struct FrameRec FrameRec;
1187 * - GWorld for the frame image
1188 * - Handle to pix map (saved for unlocking/locking)
1189 * - Pointer to color pix map (valid only while locked)
1193 GWorldPtr framePort;
1194 PixMapHandle framePixHndl;
1201 * The global picture data
1203 static FrameRec *frameP = NULL;
1209 static void BenSWLockFrame(FrameRec *srcFrameP)
1211 PixMapHandle pixMapH;
1213 pixMapH = GetGWorldPixMap(srcFrameP->framePort);
1214 (void)LockPixels(pixMapH);
1215 HLockHi((Handle)pixMapH);
1216 srcFrameP->framePixHndl = pixMapH;
1217 srcFrameP->framePix = (PixMapPtr)*(Handle)pixMapH;
1225 static void XDDSWLockFrame( term_data *td )
1227 PixMapHandle pixMapH;
1229 pixMapH = GetGWorldPixMap(td->bufferPort);
1230 (void)LockPixels(pixMapH);
1231 HLockHi((Handle)pixMapH);
1232 td->bufferPixHndl = pixMapH;
1233 td->bufferPix = (PixMapPtr)*(Handle)pixMapH;
1241 static void BenSWUnlockFrame(FrameRec *srcFrameP)
1243 if (srcFrameP->framePort != NULL)
1245 HUnlock((Handle)srcFrameP->framePixHndl);
1246 UnlockPixels(srcFrameP->framePixHndl);
1249 srcFrameP->framePix = NULL;
1257 static void XDDSWUnlockFrame( term_data *td )
1259 if (td->bufferPort != NULL)
1261 HUnlock((Handle)td->bufferPixHndl);
1262 UnlockPixels(td->bufferPixHndl);
1265 td->bufferPix = NULL;
1269 static OSErr BenSWCreateGWorldFromPict(
1270 GWorldPtr *pictGWorld,
1274 GWorldPtr saveGWorld;
1275 GDHandle saveGDevice;
1276 GWorldPtr tempGWorld;
1285 depth = data[0].pixelDepth;
1288 theGDH = data[0].theGDH;
1290 /* Obtain size rectangle */
1291 pictRect = (**pictH).picFrame;
1292 OffsetRect(&pictRect, -pictRect.left, -pictRect.top);
1294 /* Create a GWorld */
1295 err = NewGWorld(&tempGWorld, depth, &pictRect, nil,
1296 theGDH, noNewDevice);
1305 *pictGWorld = tempGWorld;
1308 GetGWorld(&saveGWorld, &saveGDevice);
1311 SetGWorld(tempGWorld, nil);
1313 /* Dump the pict into the GWorld */
1314 (void)LockPixels(GetGWorldPixMap(tempGWorld));
1315 EraseRect(&pictRect);
1316 DrawPicture(pictH, &pictRect);
1317 UnlockPixels(GetGWorldPixMap(tempGWorld));
1319 /* Restore GWorld */
1320 SetGWorld(saveGWorld, saveGDevice);
1328 static OSErr XDDSWCreateGWorldFromPict(
1329 GWorldPtr *pictGWorld,
1333 GWorldPtr saveGWorld;
1334 GDHandle saveGDevice;
1335 GWorldPtr tempGWorld;
1346 depth = td->pixelDepth;
1349 theGDH = td->theGDH;
1351 /* Obtain size rectangle */
1353 pictRect.right = td->size_wid;
1355 pictRect.bottom = td->tile_hgt;
1357 /* Create a GWorld */
1358 err = NewGWorld(&tempGWorld, 0, &pictRect, 0, 0, 0);
1367 *pictGWorld = tempGWorld;
1370 GetGWorld(&saveGWorld, &saveGDevice);
1373 SetGWorld(tempGWorld, nil);
1375 /* Dump the pict into the GWorld */
1376 (void)LockPixels(GetGWorldPixMap(tempGWorld));
1377 EraseRect(&pictRect);
1378 //DrawPicture(pictH, &pictRect);
1379 UnlockPixels(GetGWorldPixMap(tempGWorld));
1381 /* Restore GWorld */
1382 SetGWorld(saveGWorld, saveGDevice);
1388 static OSErr XDDSWUpDateGWorldFromPict( term_data *td )
1390 GWorldPtr saveGWorld;
1391 GDHandle saveGDevice;
1396 GWorldFlags errflag;
1400 if( td->bufferPort == NULL )
1403 depth = td->pixelDepth;
1406 theGDH = td->theGDH;
1408 /* Obtain size rectangle */
1411 pictRect.right = td->size_wid;
1412 pictRect.bottom = td->tile_hgt;
1414 XDDSWUnlockFrame(td);
1416 errflag = UpdateGWorld( &td->bufferPort, depth, &pictRect, 0, 0, 0);
1418 if( errflag & gwFlagErr ){
1424 // GetGWorld(&saveGWorld, &saveGDevice);
1427 // SetGWorld(td->bufferPort, nil);
1429 /* Dump the pict into the GWorld */
1430 // (void)LockPixels(GetGWorldPixMap(td->bufferPort));
1431 // EraseRect(&td->bufferPort->portRect);
1433 // UnlockPixels(GetGWorldPixMap(td->bufferPort));
1435 /* Restore GWorld */
1436 // SetGWorld(saveGWorld, saveGDevice);
1442 * Init the global "frameP"
1445 static errr globe_init(void)
1449 GWorldPtr tempPictGWorldP;
1453 /* Use window XXX XXX XXX */
1454 #ifdef TARGET_CARBON
1455 SetPortWindowPort(data[0].w);
1460 /* Get the pict resource */
1461 newPictH = GetPicture(kPictID);
1463 /* Analyze result */
1464 err = (newPictH ? 0 : -1);
1471 err = BenSWCreateGWorldFromPict(&tempPictGWorldP, newPictH);
1473 /* Release resource */
1474 ReleaseResource((Handle)newPictH);
1479 /* Create the frame */
1480 frameP = (FrameRec*)NewPtrClear((Size)sizeof(FrameRec));
1482 /* Analyze result */
1483 err = (frameP ? 0 : -1);
1489 frameP->framePort = tempPictGWorldP;
1492 BenSWLockFrame(frameP);
1503 * Nuke the global "frameP"
1505 static errr globe_nuke(void)
1511 BenSWUnlockFrame(frameP);
1513 /* Dispose of the GWorld */
1514 DisposeGWorld(frameP->framePort);
1516 /* Dispose of the memory */
1517 DisposePtr((Ptr)frameP);
1524 FlushEvents(everyEvent, 0);
1531 #endif /* ANGBAND_LITE_MAC */
1535 /*** Support for the "z-term.c" package ***/
1539 * Initialize a new Term
1541 * Note also the "window type" called "noGrowDocProc", which might be more
1542 * appropriate for the main "screen" window.
1544 * Note the use of "srcCopy" mode for optimized screen writes.
1546 static void Term_init_mac(term *t)
1548 term_data *td = (term_data*)(t->data);
1550 static RGBColor black = {0x0000,0x0000,0x0000};
1551 static RGBColor white = {0xFFFF,0xFFFF,0xFFFF};
1554 WindowAttributes wattrs;
1556 #ifdef ANGBAND_LITE_MAC
1558 /* Make the window */
1559 td->w = NewWindow(0, &td->r, td->title, 0, noGrowDocProc, (WindowPtr)-1, 1, 0L);
1561 #else /* ANGBAND_LITE_MAC */
1563 /* Make the window */
1564 // td->w = NewCWindow(0, &td->r, td->title, 0, documentProc, (WindowPtr)-1, 1, 0L);
1565 wattrs = kWindowCloseBoxAttribute |
1566 kWindowCollapseBoxAttribute |
1567 kWindowResizableAttribute;
1568 /* Make the window */
1570 kDocumentWindowClass,
1575 MoveWindow(td->w, td->r.left, td->r.top, 0 );
1577 #endif /* ANGBAND_LITE_MAC */
1579 /* Activate the window */
1582 /* Erase behind words */
1585 /* Apply and Verify */
1586 term_data_check_font(td);
1587 term_data_check_size(td);
1589 /* Resize the window */
1590 term_data_resize(td);
1592 #ifdef ANGBAND_LITE_MAC
1594 /* Prepare the colors (base colors) */
1595 BackColor(blackColor);
1596 ForeColor(whiteColor);
1598 #else /* ANGBAND_LITE_MAC */
1600 /* Prepare the colors (real colors) */
1601 RGBBackColor(&black);
1602 RGBForeColor(&white);
1609 GDHandle currentGDH;
1610 GWorldPtr windowGWorld;
1611 PixMapHandle basePixMap;
1613 /* Obtain the rect */
1614 #ifdef TARGET_CARBON
1615 GetWindowBounds( (WindowRef)td->w, kWindowContentRgn, &globalRect );
1617 globalRect = td->w->portRect;
1618 local_to_global( &globalRect );
1621 /* Obtain the proper GDH */
1622 mainGDH = GetMaxDevice(&globalRect);
1624 /* Extract GWorld and GDH */
1625 GetGWorld(&windowGWorld, ¤tGDH);
1627 /* Obtain base pixmap */
1628 basePixMap = (**mainGDH).gdPMap;
1630 /* Save pixel depth */
1631 td->pixelDepth = (**basePixMap).pixelSize;
1633 /* Save Window GWorld */
1634 td->theGWorld = windowGWorld;
1636 /* Save Window GDH */
1637 td->theGDH = currentGDH;
1640 td->mainSWGDH = mainGDH;
1643 #endif /* ANGBAND_LITE_MAC */
1647 #ifdef TARGET_CARBON
1648 GetWindowBounds( (WindowRef)td->w, kWindowContentRgn, &portRect );
1649 global_to_local( &portRect );
1651 portRect = td->w->portRect;
1654 /* Clip to the window */
1655 ClipRect(&portRect);
1657 /* Erase the window */
1658 EraseRect(&portRect);
1660 /* Invalidate the window */
1661 #ifdef TARGET_CARBON
1662 InvalWindowRect((WindowRef)(td->w), (const Rect *)(&portRect));
1664 InvalRect( &portRect );
1666 /* Display the window if needed */
1667 if (td->mapped)ShowWindow(td->w);
1669 /* Hack -- set "mapped" flag */
1670 t->mapped_flag = td->mapped;
1675 XDDSWCreateGWorldFromPict( &td->bufferPort , td );
1677 XDDSWLockFrame( td );
1687 static void Term_nuke_mac(term *t)
1700 static errr Term_user_mac(int n)
1714 static errr Term_xtra_mac_react(void)
1716 term_data *td = (term_data*)(Term->data);
1722 #ifdef ANGBAND_LITE_MAC
1726 #else /* ANGBAND_LITE_MAC */
1729 if (use_sound != arg_sound)
1732 use_sound = arg_sound;
1735 /* Handle graphics */
1736 if ((td == &data[0]) && (use_graphics != arg_graphics))
1738 /* Initialize graphics */
1740 if (!use_graphics && !frameP && (globe_init() != 0))
1743 plog("¥°¥é¥Õ¥£¥Ã¥¯¤Î½é´ü²½¤Ï½ÐÍè¤Þ¤»¤ó¤Ç¤·¤¿.");
1745 plog("Cannot initialize graphics!");
1747 arg_graphics = FALSE;
1751 use_graphics = arg_graphics;
1753 /* Apply and Verify */
1754 term_data_check_size(td);
1756 /* Resize the window */
1757 term_data_resize(td);
1763 #endif /* ANGBAND_LITE_MAC */
1771 * Do a "special thing"
1773 static errr Term_xtra_mac(int n, int v)
1775 term_data *td = (term_data*)(Term->data);
1783 case TERM_XTRA_NOISE:
1792 #ifdef ANGBAND_LITE_MAC
1796 #else /* ANGBAND_LITE_MAC */
1799 case TERM_XTRA_SOUND:
1809 /* Open the resource file */
1810 oldResFile = CurResFile();
1811 newResFile = OpenResFile(sound);
1813 /* Close the resource file */
1814 CloseResFile(newResFile);
1815 UseResFile(oldResFile);
1818 /* Get the proper sound name */
1819 sprintf((char*)sound + 1, "%.16s.wav", angband_sound_name[v]);
1820 sound[0] = strlen((char*)sound + 1);
1822 /* Obtain resource XXX XXX XXX */
1824 handle = Get1NamedResource('snd ', sound);
1825 if( handle == NULL || ext_sound )
1826 handle = GetNamedResource('snd ', sound);
1829 if (handle && soundmode[soundchoice[v]] == true)
1832 LoadResource(handle);
1835 /* Play sound (wait for completion) */
1836 SndPlay(nil, (SndListHandle)handle, true);
1838 /* Unlock and release */
1840 ReleaseResource(handle);
1843 handle = GetNamedResource('snd ', sound);
1849 LoadResource(handle);
1852 /* Play sound (wait for completion) */
1853 SndPlay(nil, (SndListHandle)handle, true);
1855 /* Unlock and release */
1857 ReleaseResource(handle);
1865 #endif /* ANGBAND_LITE_MAC */
1867 /* Process random events */
1868 case TERM_XTRA_BORED:
1870 /* Process an event */
1871 (void)CheckEvents(0);
1877 /* Process pending events */
1878 case TERM_XTRA_EVENT:
1880 /* Process an event */
1881 (void)CheckEvents(v);
1887 /* Flush all pending events (if any) */
1888 case TERM_XTRA_FLUSH:
1890 /* Hack -- flush all events */
1891 while (CheckEvents(TRUE)) /* loop */;
1897 /* Hack -- Change the "soft level" */
1898 case TERM_XTRA_LEVEL:
1900 /* Activate if requested */
1901 if (v) activate(td->w);
1907 /* Clear the screen */
1908 case TERM_XTRA_CLEAR:
1912 #ifdef TARGET_CARBON
1913 GetWindowBounds( (WindowRef)td->w, kWindowContentRgn, &portRect );
1914 global_to_local( &portRect );
1916 portRect = td->w->portRect;
1919 /* No clipping XXX XXX XXX */
1920 ClipRect(&portRect);
1922 /* Erase the window */
1923 EraseRect(&portRect);
1926 term_data_color(td, TERM_WHITE);
1928 /* Frame the window in white */
1930 LineTo(0, td->size_hgt-1);
1931 LineTo(td->size_wid-1, td->size_hgt-1);
1932 LineTo(td->size_wid-1, 0);
1934 /* Clip to the new size */
1935 r.left = portRect.left + td->size_ow1;
1936 r.top = portRect.top + td->size_oh1;
1937 r.right = portRect.right - td->size_ow2;
1938 r.bottom = portRect.bottom - td->size_oh2;
1945 /* React to changes */
1946 case TERM_XTRA_REACT:
1948 /* React to changes */
1949 return (Term_xtra_mac_react());
1952 /* Delay (milliseconds) */
1953 case TERM_XTRA_DELAY:
1958 long m = TickCount() + (v * 60L) / 1000;
1961 while (TickCount() < m) /* loop */;
1977 * Low level graphics (Assumes valid input).
1978 * Draw a "cursor" at (x,y), using a "yellow box".
1979 * We are allowed to use "Term_grab()" to determine
1980 * the current screen contents (for inverting, etc).
1982 static errr Term_curs_mac(int x, int y)
1986 term_data *td = (term_data*)(Term->data);
1989 term_data_color(td, TERM_YELLOW);
1991 /* Frame the grid */
1992 r.left = x * td->tile_wid + td->size_ow1;
1993 r.right = r.left + td->tile_wid;
1994 r.top = y * td->tile_hgt + td->size_oh1;
1995 r.bottom = r.top + td->tile_hgt;
2004 * Low level graphics (Assumes valid input)
2006 * Erase "n" characters starting at (x,y)
2008 static errr Term_wipe_mac(int x, int y, int n)
2012 term_data *td = (term_data*)(Term->data);
2014 /* Erase the block of characters */
2015 r.left = x * td->tile_wid + td->size_ow1;
2016 r.right = r.left + n * td->tile_wid;
2017 r.top = y * td->tile_hgt + td->size_oh1;
2018 r.bottom = r.top + td->tile_hgt;
2027 * Low level graphics. Assumes valid input.
2029 * Draw several ("n") chars, with an attr, at a given location.
2031 static errr Term_text_mac(int x, int y, int n, byte a, const char *cp)
2035 term_data *td = (term_data*)(Term->data);
2038 term_data_color(td, (a & 0x0F));
2040 /* Starting pixel */
2041 xp = x * td->tile_wid + td->tile_o_x + td->size_ow1;
2042 yp = y * td->tile_hgt + td->tile_o_y + td->size_oh1;
2044 /* Move to the correct location */
2047 /* Draw the character */
2048 if (n == 1) DrawChar(*cp);
2050 /* Draw the string */
2051 else DrawText(cp, 0, n);
2053 // QDFlushPortBuffer( GetQDGlobalsThePort(), NULL );
2061 * Low level graphics (Assumes valid input)
2063 * Erase "n" characters starting at (x,y)
2065 static errr Term_pict_mac(int x, int y, int n, const byte *ap, const char *cp)
2075 term_data *td = (term_data*)(Term->data);
2077 /* Destination rectangle */
2078 r2.left = x * td->tile_wid + td->size_ow1;
2079 r2.right = r2.left + td->tile_wid;
2080 r2.top = y * td->tile_hgt + td->size_oh1;
2081 r2.bottom = r2.top + td->tile_hgt;
2083 /* Scan the input */
2084 for (i = 0; i < n; i++)
2091 #ifdef ANGBAND_LITE_MAC
2095 #else /* ANGBAND_LITE_MAC */
2097 /* Graphics -- if Available and Needed */
2098 if (use_graphics && (td == &data[0]) &&
2099 ((byte)a & 0x80) && ((byte)c & 0x80))
2106 row = ((byte)a & 0x7F);
2107 col = ((byte)c & 0x7F);
2109 /* Source rectangle */
2110 r1.left = col * kGrafWidth;
2111 r1.top = row * kGrafHeight;
2112 r1.right = r1.left + kGrafWidth;
2113 r1.bottom = r1.top + kGrafHeight;
2115 /* Hardwire CopyBits */
2116 BackColor(whiteColor);
2117 ForeColor(blackColor);
2120 #ifdef TARGET_CARBON
2122 PixMapHandle srcBitMap;
2123 PixMapHandle destBitMap;
2125 srcBitMap = GetGWorldPixMap(frameP->framePort);
2126 destBitMap = GetPortPixMap(GetWindowPort( td->w ));
2127 /* Draw the picture */
2128 CopyBits( (BitMap *) *srcBitMap, (BitMap *) *destBitMap, &r1, &r2, srcCopy, NULL);
2130 BitMapPtr srcBitMap = (BitMapPtr)(frameP->framePix);
2131 BitMapPtr destBitMap = (BitMapPtr)&(td->w->portBits);
2133 /* Draw the picture */
2134 CopyBits( srcBitMap, destBitMap, &r1, &r2, srcCopy, NULL);
2138 /* Restore colors */
2139 BackColor(blackColor);
2140 ForeColor(whiteColor);
2149 #endif /* ANGBAND_LITE_MAC */
2160 term_data_color(td, (a & 0x0F));
2162 /* Starting pixel */
2163 xp = r2.left + td->tile_o_x;
2164 yp = r2.top + td->tile_o_y;
2166 /* Move to the correct location */
2172 KnjRec.top = r2.top;
2173 KnjRec.left = r2.left;
2174 KnjRec.bottom = r2.bottom;
2175 KnjRec.right = r2.right + td->tile_wid;
2180 term_data_color(td, a-0x10);
2182 /* Starting pixel */
2183 xp = r2.left + td->tile_o_x;
2184 yp = r2.top + td->tile_o_y;
2186 /* Move to the correct location */
2193 r2.left += td->tile_wid;
2194 r2.right += td->tile_wid;
2200 term_data_color(td, a & 0x0F);
2202 /* Starting pixel */
2203 xp = r2.left + td->tile_o_x;
2204 yp = r2.top + td->tile_o_y;
2206 /* Move to the correct location */
2209 /* Draw the character */
2213 /* Draw the character */
2219 r2.left += td->tile_wid;
2220 r2.right += td->tile_wid;
2228 * Create and initialize window number "i"
2230 static void term_data_link(int i)
2234 term_data *td = &data[i];
2239 /* Require mapped */
2240 if (!td->mapped) return;
2245 /* Initialize the term */
2246 term_init(td->t, td->cols, td->rows, td->keys);
2248 /* Use a "software" cursor */
2249 td->t->soft_cursor = TRUE;
2251 /* Erase with "white space" */
2252 td->t->attr_blank = TERM_WHITE;
2253 td->t->char_blank = ' ';
2255 /* Prepare the init/nuke hooks */
2256 td->t->init_hook = Term_init_mac;
2257 td->t->nuke_hook = Term_nuke_mac;
2259 /* Prepare the function hooks */
2260 td->t->user_hook = Term_user_mac;
2261 td->t->xtra_hook = Term_xtra_mac;
2262 td->t->wipe_hook = Term_wipe_mac;
2263 td->t->curs_hook = Term_curs_mac;
2264 td->t->text_hook = Term_text_mac;
2265 td->t->pict_hook = Term_pict_mac;
2267 /* Link the local structure */
2268 td->t->data = (vptr)(td);
2271 Term_activate(td->t);
2273 /* Global pointer */
2274 angband_term[i] = td->t;
2284 * Set the "current working directory" (also known as the "default"
2285 * volume/directory) to the location of the current application.
2287 * Code by: Maarten Hazewinkel (mmhazewi@cs.ruu.nl)
2289 * This function does not appear to work correctly with System 6.
2291 static void SetupAppDir(void)
2295 char errString[100];
2297 /* Get the location of the Angband executable */
2298 fcbBlock.ioCompletion = NULL;
2299 fcbBlock.ioNamePtr = NULL;
2300 fcbBlock.ioVRefNum = 0;
2301 fcbBlock.ioRefNum = CurResFile();
2302 fcbBlock.ioFCBIndx = 0;
2303 err = PBGetFCBInfo(&fcbBlock, FALSE);
2307 sprintf(errString, "PBGetFCBInfo ¥¨¥é¡¼ #%d.\r ½ªÎ»¤·¤Þ¤¹.", err);
2309 sprintf(errString, "Fatal PBGetFCBInfo Error #%d.\r Exiting.", err);
2311 mac_warning(errString);
2315 /* Extract the Vol and Dir */
2316 app_vol = fcbBlock.ioFCBVRefNum;
2317 app_dir = fcbBlock.ioFCBParID;
2319 /* Set the current working directory to that location */
2320 err = HSetVol(NULL, app_vol, app_dir);
2324 sprintf(errString, "HSetVol ¥¨¥é¡¼ #%d.\r ½ªÎ»¤·¤Þ¤¹.", err);
2326 sprintf(errString, "Fatal HSetVol Error #%d.\r Exiting.", err);
2328 mac_warning(errString);
2337 * Global "preference" file pointer
2342 * Read a "short" from the file
2344 static int getshort(void)
2348 if (0 == my_fgets(fff, buf, 256)) x = atoi(buf);
2353 * Dump a "short" to the file
2355 static void putshort(int x)
2357 fprintf(fff, "%d\n", x);
2363 * Write the "preference" data to the current "file"
2365 static void save_prefs(void)
2372 /*** The current version ***/
2374 putshort(VERSION_MAJOR);
2375 putshort(VERSION_MINOR);
2376 putshort(VERSION_PATCH);
2377 putshort(VERSION_EXTRA);
2379 putshort(arg_sound);
2380 putshort(arg_graphics);
2383 for( i = 0 ; i < 7 ; i++ )
2384 putshort(soundmode[i]);
2387 for (i = 0; i < MAX_TERM_DATA; i++)
2392 putshort(td->mapped);
2394 putshort(td->font_id);
2395 putshort(td->font_size);
2396 putshort(td->font_face);
2399 putshort(td->tile_wid);
2400 putshort(td->tile_hgt);
2406 putshort(td->r.left);
2407 putshort(td->r.top);
2413 * Load the preferences from the current "file"
2415 * XXX XXX XXX Being able to undefine various windows is
2416 * slightly bizarre, and may cause problems.
2418 static void load_prefs(void)
2422 int old_major, old_minor, old_patch, old_extra;
2427 /*** Version information ***/
2429 /* Preferences version */
2430 old_major = getshort();
2431 old_minor = getshort();
2432 old_patch = getshort();
2433 old_extra = getshort();
2435 /* Hack -- Verify or ignore */
2436 if ((old_major != VERSION_MAJOR) ||
2437 (old_minor != VERSION_MINOR) ||
2438 (old_patch != VERSION_PATCH) ||
2439 (old_extra != VERSION_EXTRA))
2443 mac_warning("¸Å¤¤½é´üÀßÄê¥Õ¥¡¥¤¥ë¤ò̵»ë¤·¤Þ¤¹.");
2445 mac_warning("Ignoring old preferences.");
2451 arg_sound = getshort();
2452 arg_graphics = getshort();
2455 for( i = 0 ; i < 7 ; i++ )
2456 soundmode[i] = getshort();
2459 m = GetMenuHandle(134); //m = GetMHandle(134);
2461 /* Item "arg_sound" */
2462 CheckMenuItem(m, 1, arg_sound);
2464 /* Item "arg_graphics" */
2465 CheckMenuItem(m, 2, arg_graphics);
2468 for (i = 0; i < MAX_TERM_DATA; i++)
2473 td->mapped = getshort();
2475 td->font_id = getshort();
2476 td->font_size = getshort();
2477 td->font_face = getshort();
2480 td->tile_wid = getshort();
2481 td->tile_hgt = getshort();
2484 td->cols = getshort();
2485 td->rows = getshort();
2487 td->r.left = getshort();
2488 td->r.top = getshort();
2491 if (feof(fff)) break;
2499 * Hack -- default data for a window
2501 static void term_data_hack(term_data *td)
2506 #ifdef TARGET_CARBON
2507 /* Default to Monaco font */
2508 fid = FMGetFontFamilyFromName( "\pOsaka¡ÝÅùÉý" );
2510 GetFNum( "\pÅùÉýÌÀÄ«", &fid); /* ¥Õ¥©¥ó¥È̾¤«¤éIDÈÖ¹æ¤òÄ´¤Ù¤ë */
2511 SetFScaleDisable( true );
2515 /* Default to Monaco font */
2516 GetFNum("\pmonaco", &fid);
2519 WIPE(td, term_data);
2524 /* Default borders */
2535 /* Default font size */
2538 /* Default font face */
2545 /* Default position */
2555 * Read the preference file, Create the windows.
2557 * We attempt to use "FindFolder()" to track down the preference file,
2558 * but if this fails, for any reason, we will try the "SysEnvirons()"
2559 * method, which may work better with System 6.
2561 static void init_windows(void)
2574 /*** Default values ***/
2576 /* Initialize (backwards) */
2577 for (i = MAX_TERM_DATA - 1; i >= 0; i--)
2590 s = angband_term_name[i];
2595 /* Maximal length */
2598 /* Copy the title */
2599 strncpy((char*)(td->title) + 1, s, n);
2601 /* Save the length */
2604 /* Tile the windows */
2605 td->r.left += (b * 30);
2606 td->r.top += (b * 30);
2613 /*** Load preferences ***/
2615 /* Assume failure */
2618 /* Assume failure */
2631 /* Find the folder */
2632 err = FindFolder(kOnSystemDisk, kPreferencesFolderType, kCreateFolder,
2638 /* Extract a path name */
2639 PathNameFromDirID(dirID, vref, (StringPtr)foo);
2641 /* Convert the string */
2642 ptocstr((StringPtr)foo);
2644 /* Append the preference file name */
2646 strcat(foo, "Hengband Preferences");
2648 strcat(foo, "Angband Preferences");
2650 /* Open the preference file */
2651 fff = fopen(foo, "r");
2665 #endif /* USE_SFL_CODE */
2667 /* Load preferences */
2670 /* Load a real preference file */
2673 /* Close the file */
2678 /*** Instantiate ***/
2689 /* Link (backwards, for stacking order) */
2690 for (i = MAX_TERM_DATA - 1; i >= 0; i--)
2699 Term_activate(td->t);
2703 static void init_sound( void )
2707 SignedByte permission = fsRdPerm;
2713 /* Descend into "lib" folder */
2714 pb.ioCompletion = NULL;
2715 pb.ioNamePtr = "\plib";
2716 pb.ioVRefNum = app_vol;
2717 pb.ioDrDirID = app_dir;
2720 for( i = 0 ; i < 7 ; i++ )
2721 soundmode[i] = true;
2723 /* Check for errors */
2724 err = PBGetCatInfo((CInfoPBPtr)&pb, FALSE);
2727 if ((err == noErr) && (pb.ioFlAttrib & 0x10))
2729 /* Descend into "lib/save" folder */
2730 pb.ioCompletion = NULL;
2731 pb.ioNamePtr = "\pxtra";
2732 pb.ioVRefNum = app_vol;
2733 pb.ioDrDirID = pb.ioDrDirID;
2736 /* Check for errors */
2737 err = PBGetCatInfo((CInfoPBPtr)&pb, FALSE);
2740 if ((err == noErr) && (pb.ioFlAttrib & 0x10))
2742 /* Descend into "lib/save" folder */
2743 pb.ioCompletion = NULL;
2744 pb.ioNamePtr = "\psound";
2745 pb.ioVRefNum = app_vol;
2746 pb.ioDrDirID = pb.ioDrDirID;
2749 /* Check for errors */
2750 err = PBGetCatInfo((CInfoPBPtr)&pb, FALSE);
2753 if ((err == noErr) && (pb.ioFlAttrib & 0x10))
2755 ret = HOpenResFile( app_vol , pb.ioDrDirID , "\psound.rsrc" , permission );
2759 for( i = 0 ; i < 7 ; i++ )
2760 soundmode[i] = false;
2762 for( i = 1 ; i < SOUND_MAX ; i++ ){
2763 /* Get the proper sound name */
2764 sprintf((char*)sound + 1, "%.16s.wav", angband_sound_name[i]);
2765 sound[0] = strlen((char*)sound + 1);
2767 /* Obtain resource XXX XXX XXX */
2768 handle = Get1NamedResource('snd ', sound);
2769 if( handle == NULL || ext_sound )
2770 handle = GetNamedResource('snd ', sound);
2773 soundmode[soundchoice[i]] = true;
2786 static void init_chuukei( void )
2792 path_build(path, 1024, ANGBAND_DIR_XTRA, "chuukei.txt");
2794 fp = fopen(path, "r");
2799 if (fgets(tmp, 1024, fp)){
2801 int n = strlen(tmp);
2807 chuukei_server = TRUE;
2808 if(connect_chuukei_server(&tmp[2])<0){
2809 msg_print("connect fail");
2812 msg_print("connect");
2820 chuukei_client = TRUE;
2821 connect_chuukei_server(&tmp[2]);
2837 short InevrtCheck( DialogPtr targetDlg, short check )
2844 GetDialogItem( targetDlg, check, &itemType, &checkH, &box );
2845 result = (GetControlValue( (ControlHandle)checkH ) + 1 ) % 2;
2846 SetControlValue( (ControlHandle)checkH , result );
2854 short SetCheck( DialogPtr targetDlg, short check, long result )
2861 GetDialogItem( targetDlg, check, &itemType, &checkH, &box );
2862 SetControlValue( (ControlHandle)checkH , result );
2870 short GetCheck( DialogPtr targetDlg, short check )
2877 GetDialogItem( targetDlg, check, &itemType, &checkH, &box );
2878 result = GetControlValue( (ControlHandle)checkH );
2882 void SoundConfigDLog(void)
2889 dialog=GetNewDialog(131, 0, (WindowPtr)-1);
2890 SetDialogDefaultItem( dialog, ok );
2891 SetDialogCancelItem( dialog, cancel );
2892 for( i = 1 ; i < 7 ; i++ )
2893 SetCheck( dialog, i+2 , soundmode[i] );
2896 for( item_hit = 100 ; cancel < item_hit ; ){
2897 ModalDialog(0, &item_hit);
2901 for( i = 1 ; i < 7 ; i++ )
2902 soundmode[i] = GetCheck( dialog, i+2 );
2907 InevrtCheck( dialog, item_hit );
2910 DisposeDialog(dialog);
2919 static void save_pref_file(void)
2928 /* Assume failure */
2931 /* Assume failure */
2934 #if defined(MACINTOSH) && !defined(applec)
2950 /* Find the folder */
2951 err = FindFolder(kOnSystemDisk, kPreferencesFolderType, kCreateFolder,
2957 /* Extract a path name */
2958 PathNameFromDirID(dirID, vref, (StringPtr)foo);
2960 /* Convert the string */
2961 ptocstr((StringPtr)foo);
2963 /* Append the preference file name */
2965 strcat(foo, "Hengband Preferences");
2967 strcat(foo, "Angband Preferences");
2969 /* Open the preference file */
2970 fff = fopen(foo, "w");
2977 #endif /* USE_SFL_CODE */
2979 /* Save preferences */
2982 /* Write the preferences */
2993 * A simple "Yes/No" filter to parse "key press" events in dialog windows
2995 static pascal Boolean ynfilter(DialogPtr dialog, EventRecord *event, short *ip)
2997 /* Parse key press events */
2998 if (event->what == keyDown)
3003 /* Extract the pressed key */
3004 c = (event->message & charCodeMask);
3006 /* Accept "no" and <return> and <enter> */
3007 if ((c=='n') || (c=='N') || (c==13) || (c==3)) i = 1;
3010 else if ((c=='y') || (c=='Y')) i = 2;
3012 /* Handle "yes" or "no" */
3016 ControlHandle control;
3019 /* Get the button */
3020 GetDialogItem(dialog, i, &type, (Handle*)&control, &r); //GetDItem(dialog, i, &type, (Handle*)&control, &r);
3022 /* Blink button for 1/10 second */
3023 HiliteControl(control, 1);
3024 Term_xtra_mac(TERM_XTRA_DELAY, 100);
3025 HiliteControl(control, 0);
3039 * Handle menu: "File" + "New"
3041 static void do_menu_file_new(void)
3046 /* Game is in progress */
3047 game_in_progress = 1;
3061 * Handle menu: "File" + "Open"
3063 static void do_menu_file_open(bool all)
3077 refnum_to_name(path, app_dir, app_vol, (char*)("\plib:save:"));
3079 FSpLocationFromFullPath( strlen(path), path, &fsp );
3082 err = ChooseFile( savefile, fsp );
3085 if (err != noErr) return;
3087 /* Extract textual file name for save file */
3088 /* GetWDInfo(reply.vRefNum, &vrefnum, &drefnum, &junk);
3089 refnum_to_name(savefile, drefnum, vrefnum, (char*)reply.fName);
3094 /* Game is in progress */
3095 game_in_progress = 1;
3109 * Handle the "open_when_ready" flag
3111 static void handle_open_when_ready(void)
3113 /* Check the flag XXX XXX XXX make a function for this */
3114 if (open_when_ready && initialized && !game_in_progress)
3117 open_when_ready = FALSE;
3119 /* Game is in progress */
3120 game_in_progress = 1;
3139 * Initialize the menus
3141 * Verify menus 128, 129, 130
3142 * Create menus 131, 132, 133, 134
3144 * The standard menus are:
3146 * Apple (128) = { About, -, ... }
3147 * File (129) = { New,Open,Import,Close,Save,-,Exit,Quit }
3148 * Edit (130) = { Cut, Copy, Paste, Clear } (?)
3149 * Font (131) = { Bold, Extend, -, Monaco, ..., -, ... }
3150 * Size (132) = { ... }
3151 * Window (133) = { Angband, Mirror, Recall, Choice,
3152 * Term-4, Term-5, Term-6, Term-7 }
3153 * Special (134) = { arg_sound, arg_graphics, -,
3154 * arg_fiddle, arg_wizard }
3156 static void init_menubar(void)
3167 /* Get the "apple" menu */
3170 /* Insert the menu */
3173 /* Add the DA's to the "apple" menu */
3174 // AppendResMenu (m, 'DRVR'); //AddResMenu(m, 'DRVR');
3177 /* Get the "File" menu */
3178 #ifdef TARGET_CARBON
3180 err = Gestalt( gestaltSystemVersion, &response );
3181 if ( (err == noErr) && (response >= 0x00000A00) )
3183 DeleteMenuItem( m, 7 );
3188 /* Insert the menu */
3192 /* Get the "Edit" menu */
3195 /* Insert the menu */
3199 /* Make the "Font" menu */
3201 m = NewMenu(131, "\p¥Õ¥©¥ó¥È");
3203 m = NewMenu(131, "\pFont");
3206 /* Insert the menu */
3210 AppendMenu(m, "\pBold");
3213 AppendMenu(m, "\pWide");
3215 /* Add a separator */
3216 AppendMenu(m, "\p-");
3219 r.left = r.right = r.top = r.bottom = 0;
3221 /* Make the fake window */
3222 tmpw = NewWindow(0, &r, "\p", false, documentProc, 0, 0, 0);
3224 /* Activate the "fake" window */
3225 #ifdef TARGET_CARBON
3226 SetPortWindowPort(tmpw);
3237 /* Add the fonts to the menu */
3238 AppendResMenu(m, 'FONT'); //AddResMenu(m, 'FONT');
3241 n = CountMenuItems(m);
3244 for (i = n; i >= 4; i--)
3249 /* Acquire the font name */
3250 /* GetMenuItemText(m, i, tmpName); */
3251 GetMenuItemText(m, i, tmpName); //GetItem(m, i, tmpName);
3253 /* Acquire the font index */
3254 #ifdef TARGET_CARBON
3255 fontNum = FMGetFontFamilyFromName( tmpName );
3257 GetFNum(tmpName, &fontNum);
3260 /* Apply the font index */
3263 /* Remove non-mono-spaced fonts */
3264 if ((CharWidth('i') != CharWidth('W')) || (CharWidth('W') == 0))
3266 /* Delete the menu item XXX XXX XXX */
3267 /* DeleteMenuItem(m, i); */
3268 DeleteMenuItem (m, i); //DelMenuItem(m, i);
3272 /* Destroy the old window */
3273 DisposeWindow(tmpw);
3275 /* Add a separator */
3276 AppendMenu(m, "\p-");
3278 /* Add the fonts to the menu */
3279 AppendResMenu (m, 'FONT'); //AddResMenu(m, 'FONT');
3282 /* Make the "Size" menu */
3284 m = NewMenu(132, "\p¥µ¥¤¥º");
3286 m = NewMenu(132, "\pSize");
3289 /* Insert the menu */
3292 /* Add some sizes (stagger choices) */
3293 for (i = 8; i <= 32; i += ((i / 16) + 1))
3298 sprintf((char*)buf + 1, "%d", i);
3299 buf[0] = strlen((char*)buf + 1);
3306 /* Make the "Windows" menu */
3308 m = NewMenu(133, "\p¥¦¥¤¥ó¥É¥¦");
3310 m = NewMenu(133, "\pWindows");
3313 /* Insert the menu */
3316 /* Default choices */
3317 for (i = 0; i < MAX_TERM_DATA; i++)
3321 /* Describe the item */
3322 sprintf((char*)buf + 1, "%.15s", angband_term_name[i]);
3323 buf[0] = strlen((char*)buf + 1);
3328 /* Command-Key shortcuts */
3329 if (i < 8) SetItemCmd(m, i + 1, '0' + i);
3333 /* Make the "Special" menu */
3335 m = NewMenu(134, "\pÆÃÊÌ");
3337 m = NewMenu(134, "\pSpecial");
3340 /* Insert the menu */
3343 /* Append the choices */
3345 AppendMenu(m, "\p¥µ¥¦¥ó¥É»ÈÍÑ");
3346 AppendMenu(m, "\p¥°¥é¥Õ¥£¥Ã¥¯»ÈÍÑ");
3347 AppendMenu(m, "\p-");
3348 AppendMenu(m, "\parg_fiddle");
3349 AppendMenu(m, "\parg_wizard");
3350 AppendMenu(m, "\p-");
3351 AppendMenu(m, "\p¥µ¥¦¥ó¥ÉÀßÄê...");
3353 AppendMenu(m, "\parg_sound");
3354 AppendMenu(m, "\parg_graphics");
3355 AppendMenu(m, "\p-");
3356 AppendMenu(m, "\parg_fiddle");
3357 AppendMenu(m, "\parg_wizard");
3360 /* Make the "TileWidth" menu */
3362 m = NewMenu(135, "\p¥¿¥¤¥ëÉý");
3364 m = NewMenu(135, "\pTileWidth");
3367 /* Insert the menu */
3370 /* Add some sizes */
3371 for (i = 4; i <= 32; i++)
3376 sprintf((char*)buf + 1, "%d", i);
3377 buf[0] = strlen((char*)buf + 1);
3384 /* Make the "TileHeight" menu */
3386 m = NewMenu(136, "\p¥¿¥¤¥ë¹â");
3388 m = NewMenu(136, "\pTileHeight");
3391 /* Insert the menu */
3394 /* Add some sizes */
3395 for (i = 4; i <= 32; i++)
3400 sprintf((char*)buf + 1, "%d", i);
3401 buf[0] = strlen((char*)buf + 1);
3408 /* Update the menu bar */
3416 static void setup_menus(void)
3426 term_data *td = NULL;
3429 /* Relevant "term_data" */
3430 for (i = 0; i < MAX_TERM_DATA; i++)
3433 if (!data[i].t) continue;
3435 /* Notice the matching window */
3436 if (data[i].w == FrontWindow()) td = &data[i];
3441 m = GetMenuHandle(129); //m = GetMHandle(129);
3444 n = CountMenuItems(m);
3447 for (i = 1; i <= n; i++)
3450 DisableMenuItem(m, i);
3451 CheckMenuItem(m, i, FALSE);
3454 /* Enable "new"/"open..."/"import..." */
3455 if (initialized && !game_in_progress)
3457 EnableMenuItem(m, 1);
3458 EnableMenuItem(m, 2);
3459 EnableMenuItem(m, 3);
3462 /* Enable "close" */
3465 EnableMenuItem(m, 4);
3469 if (initialized && character_generated)
3471 EnableMenuItem(m, 5);
3477 EnableMenuItem(m, 7);
3482 m = GetMenuHandle(130); //m = GetMHandle(130);
3485 n = CountMenuItems(m);
3488 for (i = 1; i <= n; i++)
3491 DisableMenuItem(m, i);
3492 CheckMenuItem(m, i, FALSE);
3495 /* Enable "edit" options if "needed" */
3498 EnableMenuItem(m, 1);
3499 EnableMenuItem(m, 3);
3500 EnableMenuItem(m, 4);
3501 EnableMenuItem(m, 5);
3502 EnableMenuItem(m, 6);
3507 m = GetMenuHandle(131); //m = GetMHandle(131);
3510 n = CountMenuItems(m);
3513 for (i = 1; i <= n; i++)
3516 DisableMenuItem(m, i);
3517 CheckMenuItem(m, i, FALSE);
3520 /* Hack -- look cute XXX XXX */
3521 /* SetItemStyle(m, 1, bold); */
3523 /* Hack -- look cute XXX XXX */
3524 /* SetItemStyle(m, 2, extend); */
3530 EnableMenuItem(m, 1);
3532 /* Enable "extend" */
3533 EnableMenuItem(m, 2);
3535 /* Check the appropriate "bold-ness" */
3536 if (td->font_face & bold) CheckMenuItem(m, 1, TRUE);
3538 /* Check the appropriate "wide-ness" */
3539 if (td->font_face & extend) CheckMenuItem(m, 2, TRUE);
3542 for (i = 4; i <= n; i++)
3545 EnableMenuItem(m, i);
3548 /* GetMenuItemText(m,i,s); */
3549 GetMenuItemText(m, i, s); //GetItem(m, i, s);
3550 #ifdef TARGET_CARBON
3551 value = FMGetFontFamilyFromName( s );
3556 /* Check active font */
3557 if (td->font_id == value) CheckMenuItem(m, i, TRUE);
3563 m = GetMenuHandle(132); //m = GetMHandle(132);
3566 n = CountMenuItems(m);
3569 for (i = 1; i <= n; i++)
3572 DisableMenuItem(m, i);
3573 CheckMenuItem(m, i, FALSE);
3580 for (i = 1; i <= n; i++)
3583 /* GetMenuItemText(m,i,s); */
3584 GetMenuItemText(m, i, s); //GetItem(m, i, s);
3586 value = atoi((char*)(s+1));
3588 /* Enable the "real" sizes */
3589 if (RealFont(td->font_id, value)) EnableMenuItem(m, i);
3591 /* Check the current size */
3592 if (td->font_size == value) CheckMenuItem(m, i, TRUE);
3598 m = GetMenuHandle(133); //m = GetMHandle(133);
3601 n = CountMenuItems(m);
3603 /* Check active windows */
3604 for (i = 1; i <= n; i++)
3606 /* Check if needed */
3607 CheckMenuItem(m, i, data[i-1].mapped);
3612 m = GetMenuHandle(134); //m = GetMHandle(134);
3615 n = CountMenuItems(m);
3618 for (i = 1; i <= n; i++)
3621 DisableMenuItem(m, i);
3622 CheckMenuItem(m, i, FALSE);
3625 /* Item "arg_sound" */
3626 EnableMenuItem(m, 1);
3627 CheckMenuItem(m, 1, arg_sound);
3629 /* Item "arg_graphics" */
3630 EnableMenuItem(m, 2);
3631 CheckMenuItem(m, 2, arg_graphics);
3633 /* Item "arg_fiddle" */
3634 EnableMenuItem(m, 4);
3635 CheckMenuItem(m, 4, arg_fiddle);
3637 /* Item "arg_wizard" */
3638 EnableMenuItem(m, 5);
3639 CheckMenuItem(m, 5, arg_wizard);
3642 /* Item "SoundSetting" */
3643 EnableMenuItem(m, 7);
3646 /* EnableItem(m, 9); */
3649 /* TileWidth menu */
3650 m = GetMenuHandle(135); //m = GetMHandle(135);
3653 n = CountMenuItems(m);
3656 for (i = 1; i <= n; i++)
3659 DisableMenuItem(m, i);
3660 CheckMenuItem(m, i, FALSE);
3667 for (i = 1; i <= n; i++)
3670 /* GetMenuItemText(m,i,s); */
3671 GetMenuItemText(m, i, s); //GetItem(m, i, s);
3673 value = atoi((char*)(s+1));
3676 EnableMenuItem(m, i);
3678 /* Check the current size */
3679 if (td->tile_wid == value) CheckMenuItem(m, i, TRUE);
3684 /* TileHeight menu */
3685 m = GetMenuHandle(136); //m = GetMHandle(136);
3688 n = CountMenuItems(m);
3691 for (i = 1; i <= n; i++)
3694 DisableMenuItem(m, i);
3695 CheckMenuItem(m, i, FALSE);
3702 for (i = 1; i <= n; i++)
3705 /* GetMenuItemText(m,i,s); */
3706 GetMenuItemText(m, i, s); //GetItem(m, i, s);
3708 value = atoi((char*)(s+1));
3711 EnableMenuItem(m, i);
3713 /* Check the current size */
3714 if (td->tile_hgt == value) CheckMenuItem(m, i, TRUE);
3721 * Process a menu selection (see above)
3723 * Hack -- assume that invalid menu selections are disabled above,
3724 * which I have been informed may not be reliable. XXX XXX XXX
3726 static void menu(long mc)
3730 int menuid, selection;
3732 static unsigned char s[1000];
3736 term_data *td = NULL;
3741 /* Analyze the menu command */
3742 menuid = HiWord(mc);
3743 selection = LoWord(mc);
3746 /* Find the window */
3747 for (i = 0; i < MAX_TERM_DATA; i++)
3749 /* Skip dead windows */
3750 if (!data[i].t) continue;
3752 /* Notice matches */
3753 if (data[i].w == FrontWindow()) td = &data[i];
3757 /* Branch on the menu */
3763 /* About Angband... */
3770 char errString[100];
3773 dialog = GetNewDialog(128, 0, (WindowPtr)-1);
3774 // GetPortBounds( dialog->portRect, kWindowContentRgn, &r );
3775 // r=dialog->portRect;
3776 // center_rect(&r, &qd.screenBits.bounds);
3777 // MoveWindow(dialog, r.left, r.top, 1);
3778 // ShowWindow(dialog);
3779 // GetPort(&savePort);
3781 // window = GetDialogWindow( dialog );
3782 // SetPort( (GrafPtr)GetWindowPort( window ));
3785 ModalDialog(0, &item_hit);
3787 /* sprintf(errString, "%d", item_hit);
3788 if( 1000 > item_hit )
3789 mac_warning(errString);
3790 if( item_hit == 128 )
3793 SetPort(savePort);*/
3794 DisposeDialog(dialog); //DisposDialog(dialog);
3798 #ifdef TARGET_CARBON
3800 /* Desk accessory */
3801 GetMenuItemText(GetMenuHandle(128),selection,s);
3802 /* GetMenuItem(GetMenuHandle(128), selection, s); */
3823 do_menu_file_open(FALSE);
3830 do_menu_file_open(TRUE);
3844 td->t->mapped_flag = FALSE;
3846 /* Hide the window */
3857 plog("º£¤Ï¥»¡¼¥Ö¤¹¤ë¤³¤È¤Ï½ÐÍè¤Þ¤»¤ó¡£");
3859 plog("You may not do that right now.");
3864 /* Hack -- Forget messages */
3867 /* Hack -- Save the game */
3868 do_cmd_save_game(FALSE);
3873 /* Quit (with save) */
3876 /* Save the game (if necessary) */
3877 if (game_in_progress && character_generated)
3881 plog("º£¤Ï¥»¡¼¥Ö¤¹¤ë¤³¤È¤Ï½ÐÍè¤Þ¤»¤ó¡£");
3883 plog("You may not do that right now.");
3888 /* Hack -- Forget messages */
3892 do_cmd_save_game(FALSE);
3913 /* Require a window */
3922 /* Toggle the "bold" setting */
3925 /* Toggle the setting */
3926 if (td->font_face & bold)
3928 td->font_face &= ~bold;
3932 td->font_face |= bold;
3936 /* Tile Width Hight Init */
3937 td->tile_wid = td->tile_hgt = 0;
3939 /* Apply and Verify */
3940 term_data_check_font(td);
3941 term_data_check_size(td);
3943 /* Resize and Redraw */
3944 term_data_resize(td);
3945 term_data_redraw(td);
3950 /* Toggle the "wide" setting */
3953 /* Toggle the setting */
3954 if (td->font_face & extend)
3956 td->font_face &= ~extend;
3960 td->font_face |= extend;
3964 /* Tile Width Hight Init */
3965 td->tile_wid = td->tile_hgt = 0;
3967 /* Apply and Verify */
3968 term_data_check_font(td);
3969 term_data_check_size(td);
3971 /* Resize and Redraw */
3972 term_data_resize(td);
3973 term_data_redraw(td);
3978 /* Get a new font name */
3979 /* GetMenuItemText(GetMHandle(131), selection, s); */
3980 GetMenuItemText(GetMenuHandle(131), selection, s); //GetItem(GetMHandle(131), selection, s);
3981 #ifdef TARGET_CARBON
3982 fid = FMGetFontFamilyFromName( s );
3987 /* Save the new font id */
3990 /* Current size is bad for new font */
3991 if (!RealFont(td->font_id, td->font_size))
3993 /* Find similar size */
3994 for (i = 1; i <= 32; i++)
3996 /* Adjust smaller */
3997 if (td->font_size - i >= 8)
3999 if (RealFont(td->font_id, td->font_size - i))
4007 if (td->font_size + i <= 128)
4009 if (RealFont(td->font_id, td->font_size + i))
4019 /* Tile Width Hight Init */
4020 td->tile_wid = td->tile_hgt = 0;
4022 /* Apply and Verify */
4023 term_data_check_font(td);
4024 term_data_check_size(td);
4026 /* Resize and Redraw */
4027 term_data_resize(td);
4028 term_data_redraw(td);
4030 /* Restore the window */
4047 /* GetMenuItemText(GetMHandle(132), selection, s); */
4048 GetMenuItemText(GetMenuHandle(132), selection, s); //GetItem(GetMHandle(132), selection, s);
4050 td->font_size = atoi((char*)(s+1));
4053 /* Tile Width Hight Init */
4054 td->tile_wid = td->tile_hgt = 0;
4056 /* Apply and Verify */
4057 term_data_check_font(td);
4058 term_data_check_size(td);
4060 /* Resize and Redraw */
4061 term_data_resize(td);
4062 term_data_redraw(td);
4076 /* Check legality of choice */
4077 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
4079 /* Obtain the window */
4089 td->t->mapped_flag = TRUE;
4091 /* Show the window */
4094 /* Bring to the front */
4095 SelectWindow(td->w);
4107 /* Toggle arg_sound */
4108 arg_sound = !arg_sound;
4110 /* React to changes */
4111 Term_xtra(TERM_XTRA_REACT, 0);
4118 /* Toggle arg_graphics */
4119 arg_graphics = !arg_graphics;
4121 /* Hack -- Force redraw */
4122 Term_key_push(KTRL('R'));
4129 arg_fiddle = !arg_fiddle;
4135 arg_wizard = !arg_wizard;
4149 /* TileWidth menu */
4160 /* GetMenuItemText(GetMHandle(135), selection, s); */
4161 GetMenuItemText(GetMenuHandle(135), selection, s); //GetItem(GetMHandle(135), selection, s);
4163 td->tile_wid = atoi((char*)(s+1));
4165 /* Apply and Verify */
4166 term_data_check_size(td);
4168 /* Resize and Redraw */
4169 term_data_resize(td);
4170 term_data_redraw(td);
4178 /* TileHeight menu */
4189 /* GetMenuItemText(GetMHandle(136), selection, s); */
4190 GetMenuItemText(GetMenuHandle(136), selection, s); //GetItem(GetMHandle(136), selection, s);
4192 td->tile_hgt = atoi((char*)(s+1));
4194 /* Apply and Verify */
4195 term_data_check_size(td);
4197 /* Resize and Redraw */
4198 term_data_resize(td);
4199 term_data_redraw(td);
4209 /* Clean the menu */
4218 * Check for extra required parameters -- From "Maarten Hazewinkel"
4220 static OSErr CheckRequiredAEParams(const AppleEvent *theAppleEvent)
4223 DescType returnedType;
4226 aeError = AEGetAttributePtr(theAppleEvent, keyMissedKeywordAttr, typeWildCard,
4227 &returnedType, NULL, 0, &actualSize);
4229 if (aeError == errAEDescNotFound) return (noErr);
4231 if (aeError == noErr) return (errAEParamMissed);
4238 * Apple Event Handler -- Open Application
4240 static pascal OSErr AEH_Start(const AppleEvent *theAppleEvent,
4241 const AppleEvent *reply, long handlerRefCon)
4243 #pragma unused(reply, handlerRefCon)
4245 return (CheckRequiredAEParams(theAppleEvent));
4250 * Apple Event Handler -- Quit Application
4252 static pascal OSErr AEH_Quit(const AppleEvent *theAppleEvent,
4253 const AppleEvent *reply, long handlerRefCon)
4255 #pragma unused(reply, handlerRefCon)
4256 #ifdef TARGET_CARBON
4257 /* Save the game (if necessary) */
4258 if (game_in_progress && character_generated)
4260 /* Hack -- Forget messages */
4264 do_cmd_save_game(FALSE);
4271 quit_when_ready = TRUE;
4273 /* Check arguments */
4274 return (CheckRequiredAEParams(theAppleEvent));
4279 * Apple Event Handler -- Print Documents
4281 static pascal OSErr AEH_Print(const AppleEvent *theAppleEvent,
4282 const AppleEvent *reply, long handlerRefCon)
4284 #pragma unused(theAppleEvent, reply, handlerRefCon)
4286 return (errAEEventNotHandled);
4291 * Apple Event Handler by Steve Linberg (slinberg@crocker.com).
4293 * The old method of opening savefiles from the finder does not work
4294 * on the Power Macintosh, because CountAppFiles and GetAppFiles,
4295 * used to return information about the selected document files when
4296 * an application is launched, are part of the Segment Loader, which
4297 * is not present in the RISC OS due to the new memory architecture.
4299 * The "correct" way to do this is with AppleEvents. The following
4300 * code is modeled on the "Getting Files Selected from the Finder"
4301 * snippet from Think Reference 2.0. (The prior sentence could read
4302 * "shamelessly swiped & hacked")
4304 static pascal OSErr AEH_Open(AppleEvent *theAppleEvent,
4305 AppleEvent* reply, long handlerRefCon)
4307 #pragma unused(reply, handlerRefCon)
4314 DescType returnedType;
4318 /* Put the direct parameter (a descriptor list) into a docList */
4319 err = AEGetParamDesc(theAppleEvent, keyDirectObject, typeAEList, &docList);
4320 if (err) return err;
4323 * We ignore the validity check, because we trust the FInder, and we only
4324 * allow one savefile to be opened, so we ignore the depth of the list.
4327 err = AEGetNthPtr(&docList, 1L, typeFSS, &keywd,
4328 &returnedType, (Ptr) &myFSS, sizeof(myFSS), &actualSize);
4329 if (err) return err;
4331 /* Only needed to check savefile type below */
4332 err = FSpGetFInfo(&myFSS, &myFileInfo);
4335 sprintf(foo, "Arg! FSpGetFInfo failed with code %d", err);
4340 /* Ignore non 'SAVE' files */
4341 if (myFileInfo.fdType != 'SAVE') return noErr;
4343 /* XXX XXX XXX Extract a file name */
4344 PathNameFromDirID(myFSS.parID, myFSS.vRefNum, (StringPtr)savefile);
4345 pstrcat((StringPtr)savefile, (StringPtr)&myFSS.name);
4347 /* Convert the string */
4348 ptocstr((StringPtr)savefile);
4350 /* Delay actual open */
4351 open_when_ready = TRUE;
4354 err = AEDisposeDesc(&docList);
4366 * Macintosh modifiers (event.modifier & ccc):
4367 * cmdKey, optionKey, shiftKey, alphaLock, controlKey
4370 * Macintosh Keycodes (0-63 normal, 64-95 keypad, 96-127 extra):
4415 * Optimize non-blocking calls to "CheckEvents()"
4416 * Idea from "Maarten Hazewinkel <mmhazewi@cs.ruu.nl>"
4418 #define EVENT_TICKS 6
4422 * Check for Events, return TRUE if we process any
4424 * Hack -- Handle AppleEvents if appropriate (ignore result code).
4426 static bool CheckEvents(bool wait)
4442 term_data *td = NULL;
4446 static huge lastTicks = 0L;
4449 /* Access the clock */
4450 curTicks = TickCount();
4452 /* Hack -- Allow efficient checking for non-pending events */
4453 if (!wait && (curTicks < lastTicks + EVENT_TICKS)) return (FALSE);
4455 /* Timestamp last check */
4456 lastTicks = curTicks;
4458 #ifndef TARGET_CARBON
4459 /* Let the "system" run */
4463 /* Get an event (or null) */
4464 WaitNextEvent( everyEvent, &event, 1L, 0L );
4465 //GetNextEvent(everyEvent, &event);
4467 /* Hack -- Nothing is ready yet */
4468 if (event.what == nullEvent) return (FALSE);
4471 /* Analyze the event */
4479 w = (WindowPtr)event.message;
4490 /* Extract the window */
4491 w = (WindowPtr)event.message;
4493 /* Find the window */
4494 for (i = 0; i < MAX_TERM_DATA; i++)
4496 /* Skip dead windows */
4497 if (!data[i].t) continue;
4499 /* Notice matches */
4500 if (data[i].w == w) td = &data[i];
4503 /* Hack XXX XXX XXX */
4507 /* Redraw the window */
4508 if (td) term_data_redraw(td);
4516 /* Extract some modifiers */
4517 mc = (event.modifiers & controlKey) ? TRUE : FALSE;
4518 ms = (event.modifiers & shiftKey) ? TRUE : FALSE;
4519 mo = (event.modifiers & optionKey) ? TRUE : FALSE;
4520 mx = (event.modifiers & cmdKey) ? TRUE : FALSE;
4522 /* Keypress: (only "valid" if ck < 96) */
4523 ch = (event.message & charCodeMask) & 255;
4525 /* Keycode: see table above */
4526 ck = ((event.message & keyCodeMask) >> 8) & 255;
4528 /* Command + "normal key" -> menu action */
4529 if (mx && (ck < 64))
4531 /* Hack -- Prepare the menus */
4534 /* Mega-Hack -- allow easy exit if nothing to save */
4535 // if (!character_generated && (ch=='Q' || ch=='q')) ch = 'e';
4537 /* Run the Menu-Handler */
4540 /* Turn off the menus */
4548 /* Hide the mouse pointer */
4551 /* Normal key -> simple keypress */
4554 /* Enqueue the keypress */
4558 /* Hack -- normal "keypad keys" -> special keypress */
4559 else if (!mc && !ms && !mo && !mx && (ck < 96))
4561 /* Hack -- "enter" is confused */
4562 if (ck == 76) ch = '\n';
4564 /* Send control-caret as a trigger */
4567 /* Send the "ascii" keypress */
4571 /* Bizarre key -> encoded keypress */
4574 /* Hack -- introduce with control-underscore */
4577 /* Send some modifier keys */
4578 if (mc) Term_keypress('C');
4579 if (ms) Term_keypress('S');
4580 if (mo) Term_keypress('O');
4581 if (mx) Term_keypress('X');
4583 /* Hack -- Downshift and encode the keycode */
4584 Term_keypress('0' + (ck - 64) / 10);
4585 Term_keypress('0' + (ck - 64) % 10);
4587 /* Hack -- Terminate the sequence */
4598 /* Analyze click location */
4599 code = FindWindow(event.where, &w);
4601 /* Find the window */
4602 for (i = 0; i < MAX_TERM_DATA; i++)
4604 /* Skip dead windows */
4605 if (!data[i].t) continue;
4607 /* Notice matches */
4608 if (data[i].w == w) td = &data[i];
4617 menu(MenuSelect(event.where));
4621 #ifndef TARGET_CARBON
4624 SystemClick(&event, w);
4637 #ifdef TARGET_CARBON
4638 GetQDGlobalsScreenBits( &screen );
4640 screen = qd.screenBits;
4644 r.top += 20; /* GetMBarHeight() XXX XXX XXX */
4645 InsetRect(&r, 4, 4);
4646 DragWindow(w, event.where, &r);
4658 #ifdef TARGET_CARBON
4659 GetWindowBounds( (WindowRef)td->w, kWindowContentRgn, &portRect );
4661 portRect = td->w->portRect;
4662 local_to_global( &portRect );
4664 p.h = portRect.left;
4666 #ifndef TARGET_CARBON
4675 /* Apply and Verify */
4676 term_data_check_size(td);
4686 /* Track the go-away box */
4687 if (TrackGoAway(w, event.where))
4693 td->t->mapped_flag = FALSE;
4695 /* Hide the window */
4711 /* Fake rectangle */
4712 r.left = 20 * td->tile_wid + td->size_ow1;
4713 r.right = 80 * td->tile_wid + td->size_ow1 + td->size_ow2 + 1;
4714 r.top = 1 * td->tile_hgt + td->size_oh1;
4715 r.bottom = 24 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
4717 /* Grow the rectangle */
4718 newsize = GrowWindow(w, event.where, &r);
4721 if (!newsize) break;
4723 /* Extract the new size in pixels */
4724 y = HiWord(newsize) - td->size_oh1 - td->size_oh2;
4725 x = LoWord(newsize) - td->size_ow1 - td->size_ow2;
4727 /* Extract a "close" approximation */
4728 td->rows = y / td->tile_hgt;
4729 td->cols = x / td->tile_wid;
4731 /* Apply and Verify */
4732 term_data_check_size(td);
4735 Term_activate(td->t);
4737 /* Hack -- Resize the term */
4738 Term_resize(td->cols, td->rows);
4740 /* Resize and Redraw */
4741 term_data_resize(td);
4742 term_data_redraw(td);
4761 /* Disk Event -- From "Maarten Hazewinkel" */
4764 /* check for error when mounting the disk */
4766 #ifdef TARGET_CARBON
4768 if (HiWord(event.message) != noErr)
4774 DIBadMount(p, event.message);
4781 /* OS Event -- From "Maarten Hazewinkel" */
4784 switch ((event.message >> 24) & 0x000000FF)
4786 case suspendResumeMessage:
4788 /* Resuming: activate the front window */
4789 if (event.message & resumeFlag)
4792 #ifdef TARGET_CARBON
4796 SetPortWindowPort( FrontWindow() );
4798 GetQDGlobalsArrow( &arrow );
4802 SetPort(FrontWindow());
4804 SetCursor( &qd.arrow );
4808 /* Suspend: deactivate the front window */
4822 /* From "Steve Linberg" and "Maarten Hazewinkel" */
4823 case kHighLevelEvent:
4825 #ifdef TARGET_CARBON
4826 AEProcessAppleEvent(&event);
4828 /* Process apple events */
4829 if (AEProcessAppleEvent(&event) != noErr)
4832 plog("Apple Event Handler¤Î¥¨¥é¡¼¤Ç¤¹.");
4834 plog("Error in Apple Event Handler!");
4838 /* Handle "quit_when_ready" */
4839 if (quit_when_ready)
4842 quit_when_ready = FALSE;
4844 /* Do the menu key */
4847 /* Turn off the menus */
4851 /* Handle "open_when_ready" */
4852 handle_open_when_ready();
4862 /* Something happened */
4869 /*** Some Hooks for various routines ***/
4873 * Mega-Hack -- emergency lifeboat
4875 static vptr lifeboat = NULL;
4879 * Hook to "release" memory
4881 static vptr hook_rnfree(vptr v, huge size)
4884 #pragma unused (size)
4888 /* Alternative method */
4903 * Hook to "allocate" memory
4905 static vptr hook_ralloc(huge size)
4910 /* Make a new pointer */
4911 return (malloc(size));
4915 /* Make a new pointer */
4916 return (NewPtr(size));
4923 * Hook to handle "out of memory" errors
4925 static vptr hook_rpanic(huge size)
4928 #pragma unused (size)
4932 /* Free the lifeboat */
4935 /* Free the lifeboat */
4936 DisposePtr(lifeboat);
4938 /* Forget the lifeboat */
4941 /* Mega-Hack -- Warning */
4943 mac_warning("¥á¥â¥ê¡¼¤¬Â¤ê¤Þ¤»¤ó!\rº£¤¹¤°½ªÎ»¤·¤Æ²¼¤µ¤¤!");
4945 mac_warning("Running out of Memory!\rAbort this process now!");
4948 /* Mega-Hack -- Never leave this function */
4949 while (TRUE) CheckEvents(TRUE);
4952 /* Mega-Hack -- Crash */
4958 * Hook to tell the user something important
4960 static void hook_plog(cptr str)
4962 /* Warning message */
4967 * Hook to tell the user something, and then quit
4969 static void hook_quit(cptr str)
4971 /* Warning if needed */
4972 if (str) mac_warning(str);
4974 /* Write a preference file */
4982 * Hook to tell the user something, and then crash
4984 static void hook_core(cptr str)
4986 /* XXX Use the debugger */
4987 /* DebugStr(str); */
4990 if (str) mac_warning(str);
4992 /* Warn, then save player */
4994 mac_warning("Ã×̿Ū¤Ê¥¨¥é¡¼¤Ç¤¹.\r¶¯À©Åª¤Ë¥»¡¼¥Ö¤·¤Æ½ªÎ»¤·¤Þ¤¹.");
4996 mac_warning("Fatal error.\rI will now attempt to save and quit.");
4999 /* Attempt to save */
5001 if (!save_player()) mac_warning("·Ù¹ð -- ¥»¡¼¥Ö¤Ë¼ºÇÔ¤·¤Þ¤·¤¿!");
5003 if (!save_player()) mac_warning("Warning -- save failed!");
5012 /*** Main program ***/
5018 * XXX XXX XXX Hack -- This function attempts to "fix" the nasty
5019 * "Macintosh Save Bug" by using "absolute" path names, since on
5020 * System 7 machines anyway, the "current working directory" often
5021 * "changes" due to background processes, invalidating any "relative"
5022 * path names. Note that the Macintosh is limited to 255 character
5023 * path names, so be careful about deeply embedded directories...
5025 * XXX XXX XXX Hack -- This function attempts to "fix" the nasty
5026 * "missing lib folder bug" by allowing the user to help find the
5027 * "lib" folder by hand if the "application folder" code fails...
5029 static void init_stuff(void)
5047 /* Fake rectangle */
5054 #ifdef TARGET_CARBON
5055 GetQDGlobalsScreenBits( &screen );
5057 screen = qd.screenBits;
5059 center_rect(&r, &screen.bounds);
5061 /* Extract corner */
5066 /* Default to the "lib" folder with the application */
5067 refnum_to_name(path, app_dir, app_vol, (char*)("\plib:"));
5069 /* Check until done */
5072 /* Prepare the paths */
5073 init_file_paths(path);
5075 /* Build the filename */
5077 path_build(path, 1024, ANGBAND_DIR_FILE, "news_j.txt");
5079 path_build(path, 1024, ANGBAND_DIR_FILE, "news.txt");
5082 /* Attempt to open and close that file */
5083 if (0 == fd_close(fd_open(path, O_RDONLY))) break;
5087 plog_fmt("'%s' ¥Õ¥¡¥¤¥ë¤ò¥ª¡¼¥×¥ó½ÐÍè¤Þ¤»¤ó.", path);
5089 plog_fmt("Unable to open the '%s' file.", path);
5094 plog("Hengband¥Õ¥©¥ë¥ÀÆâ¤Î'lib'¥Õ¥©¥ë¥À¤¬Â¸ºß¤·¤Ê¤¤¤«Àµ¤·¤¯Ìµ¤¤²ÄǽÀ¤¬¤¢¤ê¤Þ¤¹.");
5096 plog("The Angband 'lib' folder is probably missing or misplaced.");
5100 plog("Please 'open' any file in any sub-folder of the 'lib' folder.");
5108 refnum_to_name(path, app_dir, app_vol, (char*)("\plib:file:"));
5110 FSpLocationFromFullPath( strlen(path), path, &fsp );
5112 err = ChooseFile( path, fsp );
5120 /* Hack -- Remove the "filename" */
5121 i = strlen(path) - 1;
5122 while ((i > 0) && (path[i] != ':')) i--;
5123 if (path[i] == ':') path[i+1] = '\0';
5125 /* Hack -- allow "lib" folders */
5126 if (suffix(path, "lib:")) continue;
5128 /* Hack -- Remove the "sub-folder" */
5130 while ((i > 1) && (path[i] != ':')) i--;
5131 if (path[i] == ':') path[i+1] = '\0';
5137 * Macintosh Main loop
5141 EventRecord tempEvent;
5142 int numberOfMasters = 10;
5144 #ifndef TARGET_CARBON
5145 /* Increase stack space by 64K */
5146 SetApplLimit(GetApplLimit() - 65536L);
5148 /* Stretch out the heap to full size */
5152 /* Get more Masters */
5153 while (numberOfMasters--) MoreMasters();
5155 #ifndef TARGET_CARBON
5156 /* Set up the Macintosh */
5157 InitGraf(&qd.thePort);
5171 FlushEvents(everyEvent, 0);
5173 /* Flush events some more (?) */
5174 (void)EventAvail(everyEvent, &tempEvent);
5175 (void)EventAvail(everyEvent, &tempEvent);
5176 (void)EventAvail(everyEvent, &tempEvent);
5179 #ifdef ANGBAND_LITE_MAC
5183 #else /* ANGBAND_LITE_MAC */
5185 # if defined(powerc) || defined(__powerc)
5187 /* Assume System 7 */
5189 /* Assume Color Quickdraw */
5193 #ifndef TARGET_CARBON
5200 /* Check the Gestalt */
5201 err = Gestalt(gestaltSystemVersion, &versionNumber);
5203 /* Check the version */
5204 if ((err != noErr) || (versionNumber < 0x0700))
5207 quit("¤³¤Î¥×¥í¥°¥é¥à¤Ï´Á»úTalk7.x.x°Ê¹ß¤ÇÆ°ºî¤·¤Þ¤¹.");
5209 quit("You must have System 7 to use this program.");
5219 /* Check the environs */
5220 if (SysEnvirons(1, &env) != noErr)
5223 quit("SysEnvirons ¥³¡¼¥ë¤Ï¼ºÇÔ¤·¤Þ¤·¤¿¡ª");
5225 quit("The SysEnvirons call failed!");
5229 /* Check for System Seven Stuff */
5230 if (env.systemVersion < 0x0700)
5233 quit("¤³¤Î¥×¥í¥°¥é¥à¤Ï´Á»úTalk7.x.x°Ê¹ß¤ÇÆ°ºî¤·¤Þ¤¹.");
5235 quit("You must have System 7 to use this program.");
5239 /* Check for Color Quickdraw */
5240 if (!env.hasColorQD)
5243 quit("¤³¤Î¥×¥í¥°¥é¥à¤ÏColor Quickdraw¤¬Ìµ¤¤¤ÈÆ°ºî¤·¤Þ¤»¤ó.");
5245 quit("You must have Color Quickdraw to use this program.");
5249 #endif /* !Carbon */
5253 #endif /* ANGBAND_LITE_MAC */
5258 /* Obtain a "Universal Procedure Pointer" */
5259 // AEH_Start_UPP = NewAEEventHandlerProc(AEH_Start);
5260 AEH_Start_UPP = NewAEEventHandlerUPP(AEH_Start);
5261 /* Install the hook (ignore error codes) */
5262 AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, AEH_Start_UPP,
5265 /* Obtain a "Universal Procedure Pointer" */
5266 // AEH_Quit_UPP = NewAEEventHandlerProc(AEH_Quit);
5267 AEH_Quit_UPP = NewAEEventHandlerUPP(AEH_Quit);
5268 /* Install the hook (ignore error codes) */
5269 AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, AEH_Quit_UPP,
5272 /* Obtain a "Universal Procedure Pointer" */
5273 // AEH_Print_UPP = NewAEEventHandlerProc(AEH_Print);
5274 AEH_Print_UPP = NewAEEventHandlerUPP(AEH_Print);
5275 /* Install the hook (ignore error codes) */
5276 AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments, AEH_Print_UPP,
5279 /* Obtain a "Universal Procedure Pointer" */
5280 // AEH_Open_UPP = NewAEEventHandlerProc(AEH_Open);
5281 AEH_Open_UPP = NewAEEventHandlerUPP(AEH_Open);
5282 /* Install the hook (ignore error codes) */
5283 AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, AEH_Open_UPP,
5289 /* Find the current application */
5293 #if defined(MACINTOSH) && !defined(applec)
5295 /* Mark ourself as the file creator */
5298 /* Default to saving a "text" file */
5304 #if defined(__MWERKS__)
5306 /* Obtian a "Universal Procedure Pointer" */
5307 //ynfilterUPP = NewModalFilterProc(ynfilter);
5308 ynfilterUPP = NewModalFilterUPP(ynfilter);
5312 /* Hook in some "z-virt.c" hooks */
5313 rnfree_aux = hook_rnfree;
5314 ralloc_aux = hook_ralloc;
5315 rpanic_aux = hook_rpanic;
5317 /* Hooks in some "z-util.c" hooks */
5318 plog_aux = hook_plog;
5319 quit_aux = hook_quit;
5320 core_aux = hook_core;
5322 BackColor(blackColor);
5323 ForeColor(whiteColor);
5325 /* Show the "watch" cursor */
5326 SetCursor(*(GetCursor(watchCursor)));
5328 /* Prepare the menubar */
5331 /* Prepare the windows */
5338 /* Hack -- process all events */
5339 while (CheckEvents(TRUE)) /* loop */;
5341 /* Reset the cursor */
5342 #ifdef TARGET_CARBON
5345 GetQDGlobalsArrow( &arrow );
5349 SetCursor( &qd.arrow );
5353 /* Mega-Hack -- Allocate a "lifeboat" */
5354 lifeboat = NewPtr(16384);
5356 /* Note the "system" */
5357 ANGBAND_SYS = "mac";
5358 ANGBAND_GRAF = "new";
5366 /* Hack -- process all events */
5367 while (CheckEvents(TRUE)) /* loop */;
5370 /* We are now initialized */
5374 /* Handle "open_when_ready" */
5375 handle_open_when_ready();
5381 /* Prompt the user */
5383 prt("'¥Õ¥¡¥¤¥ë'¥á¥Ë¥å¡¼¤è¤ê'¿·µ¬'¤Þ¤¿¤Ï'³«¤¯...'¤òÁªÂò¤·¤Æ¤¯¤À¤µ¤¤¡£", 23, 10);
5385 prt("[Choose 'New' or 'Open' from the 'File' menu]", 23, 15);
5388 /* Flush the prompt */
5392 /* Hack -- Process Events Forever */
5393 while (TRUE) CheckEvents(TRUE);