3 -- Macintosh initializations, then call real main
5 Note: compile this segment as Main for generic 68000 processor, so it won't
18 #include <Quickdraw.h>
21 #include <ToolUtils.h>
25 #include <StandardFile.h>
35 if (EventAvail( keyDownMask+autoKeyMask, &ev)) {
36 if ( (ev.modifiers & cmdKey)
37 && ((char)(ev.message & charCodeMask) == '.') ) {
39 (void) GetNextEvent( keyDownMask+autoKeyMask, &ev);
46 Boolean cmdKeyIsDown()
49 return BitTst(kmap, (sizeof(KeyMap)*8) - 55);
52 Boolean shiftKeyIsDown()
55 return BitTst(kmap, (sizeof(KeyMap)*8) - 56);
58 Boolean capsLockIsDown()
61 return BitTst(kmap, (sizeof(KeyMap)*8) - 57);
64 Boolean optionKeyIsDown()
67 return BitTst(kmap, (sizeof(KeyMap)*8) - 58);
77 return EventAvail( keyDownMask+keyUpMask+autoKeyMask, &ev);
87 Point wher; /*where to display dialog*/
88 SFReply reply; /*reply record*/
90 static char filename[80] = "\0";
94 if (optionKeyIsDown()) nFileTypes=0;
96 SFGetFile(wher, prompt, nil, nFileTypes, fileTypes, nil, &reply);
99 len = SetVol(nil, reply.vRefNum);
100 len = reply.fName[0];
101 strncpy(filename, (char *)(&reply.fName[1]), len);
110 int readCmdOptions(FILE *cl, char *progname, char ***argv)
111 /* command line reader for Mac/MPW -- dgg */
114 #define addarg(sptr) if (strlen(sptr)>0) { \
115 targv = (char **) realloc( targv, (argc+1) * sizeof(char *)); \
116 targv[argc] = (char *) malloc(1+strlen(sptr) * sizeof(char)); \
117 strcpy( targv[argc], sptr); \
120 char *pword, st[MAXS];
124 targv = (char **) malloc(1);
125 if (progname==NULL) progname = "program";
127 fgets( st, MAXS, cl);
128 if (!feof(cl) && st!=NULL && *st!=0) {
129 pword = strtok( st, "\ \n");
130 while (pword!=NULL) {
132 pword = strtok( NULL, "\ \n");
140 int ccommand(char ***argv)
145 argc = readCmdOptions(stdin, *argv[0], &targv);
155 //#define VERSION curSysEnvVers
156 #define nocolorID 130
169 UnloadSeg(_DataInit);
171 InitGraf((Ptr)&qd.thePort);
179 /*______________________________________________________*/
180 /* If not right Machine then stop */
181 /*______________________________________________________*/
182 OSys = SysEnvirons( curSysEnvVers,&theWorld);
184 /*if(!theWorld.hasColorQD) {
185 crashDia = GetNewDialog (nocolorID, nil, (WindowPtr) -1);
186 DrawDialog (crashDia);
190 /*if(theWorld.processor < env68020) {
191 crashDia = GetNewDialog (no68020, nil, (WindowPtr) -1);
192 DrawDialog (crashDia);
196 /*if(!theWorld.hasFPU) {
197 crashDia = GetNewDialog (no68881, nil, (WindowPtr) -1);
198 DrawDialog (crashDia);
202 if(theWorld.systemVersion < 0x0600) {
203 crashDia = GetNewDialog (nosys6, nil, (WindowPtr) -1);
204 DrawDialog (crashDia);
210 /*______________________________________________________*/
212 /*______________________________________________________*/
213 screenRect = qd.screenBits.bounds;
216 offRight = screenRect.right;
217 offBottom = screenRect.bottom;
218 SetRect(&BaseRect, 40, 60, 472, 282);
219 tempRgn = GetGrayRgn();
220 HLock ((Handle) tempRgn);
221 TotalRect = (**tempRgn).rgnBBox;
222 SetRect(&minRect, 80, 80, (**tempRgn).rgnBBox.right - 40,
223 (**tempRgn).rgnBBox.bottom - 40);
224 HUnlock ((Handle) tempRgn);
226 /*______________________________________________________*/
227 /* Open Window & set Palette & Picture */
228 /*______________________________________________________*/
229 theGDevice = GetMainDevice();
230 HLock ((Handle) theGDevice);
231 mycolors = (**(**theGDevice).gdPMap).pmTable;
232 numcolor = (**(**theGDevice).gdPMap).pixelSize;
233 HUnlock((Handle) theGDevice);
249 myWindow = NewCWindow(nil, &BaseRect, "", true, zoomDocProc,
250 (WindowPtr) -1, true, 150);
251 SetPort((WindowPtr) myWindow);
252 DrawGrowIcon (myWindow);
254 srcPalette = NewPalette (numcolor, mycolors, pmCourteous, 0);
255 SetPalette ((WindowPtr) myWindow, srcPalette, true);
257 /*______________________________________________________*/
259 /*______________________________________________________*/
260 mymenu0 = GetMenu(appleID);
261 AddResMenu(mymenu0, 'DRVR');
262 InsertMenu(mymenu0,0);
263 mymenu1 = newmenu(129,"File");
264 appendmenu(mymenu1,"Start;Quit");
265 InsertMenu(mymenu1,0);
266 mymenu2 = newmenu(130,"Edit");
267 InsertMenu(mymenu2,0);
270 /*______________________________________________________*/
272 /*______________________________________________________*/
283 main(int argc, char *argv[])
289 /* MacInit(); -- SIOW library handles this */
291 fprintf(stderr,"\nEnter command line for %s [cmd-Q to quit]\n", argv[0]);
292 fprintf(stderr,"-> %s ",argv[0]);
294 myargc = ccommand(&myargv);
296 siow_main(myargc, myargv);