From 2bf3a37ffe2c83ec801479e391828066566ab9f2 Mon Sep 17 00:00:00 2001 From: xdd Date: Mon, 2 Sep 2002 23:46:32 +0000 Subject: [PATCH] =?utf8?q?CPU=E3=81=8C=E9=AB=98=E8=B2=A0=E8=8D=B7=E3=81=AB?= =?utf8?q?=E3=81=AA=E3=82=8B=E5=95=8F=E9=A1=8C=E3=81=AE=E4=BF=AE=E6=AD=A3?= =?utf8?q?=E3=80=82=20=E3=82=BF=E3=82=A4=E3=83=AB=E5=B9=85=E9=AB=98?= =?utf8?q?=E3=81=AE=E9=81=B8=E6=8A=9E=E3=81=A7=E3=82=AF=E3=83=A9=E3=83=83?= =?utf8?q?=E3=82=B7=E3=83=A5=E3=81=97=E3=81=A6=E3=81=84=E3=81=9F=E5=95=8F?= =?utf8?q?=E9=A1=8C=E3=81=AE=E4=BF=AE=E6=AD=A3=E3=80=82=20=E3=82=B2?= =?utf8?q?=E3=83=BC=E3=83=A0=E4=B8=AD=E3=80=81=E3=82=A6=E3=82=A7=E3=82=A4?= =?utf8?q?=E3=83=88=E3=82=92=E5=A4=A7=E3=81=8D=E3=81=8F=E3=81=97=E3=81=A6?= =?utf8?q?=E3=82=82=E3=82=A2=E3=83=8B=E3=83=A1=E3=83=BC=E3=82=B7=E3=83=A7?= =?utf8?q?=E3=83=B3=E3=81=97=E3=81=A6=E3=81=84=E3=81=AA=E3=81=8B=E3=81=A3?= =?utf8?q?=E3=81=9F=E5=95=8F=E9=A1=8C=E3=81=AE=E4=BF=AE=E6=AD=A3=20?= =?utf8?q?=E9=80=8F=E9=81=8E=E5=87=A6=E7=90=86=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/main-mac-carbon.c | 357 ++++++++++---------------------------------------- 1 file changed, 72 insertions(+), 285 deletions(-) diff --git a/src/main-mac-carbon.c b/src/main-mac-carbon.c index 55363873b..492644af9 100644 --- a/src/main-mac-carbon.c +++ b/src/main-mac-carbon.c @@ -309,10 +309,6 @@ struct term_data #endif /* ANGBAND_LITE_MAC */ - GWorldPtr bufferPort; - PixMapHandle bufferPixHndl; - PixMapPtr bufferPix; - Str15 title; s16b oops; @@ -826,6 +822,8 @@ static void PathNameFromDirID(long dirID, short vRefNum, StringPtr fullPathName) #endif +#if TARGET_API_MAC_CARBON + static OSErr ChooseFile( StringPtr filename, FSSpec selfld ) { NavReplyRecord reply; @@ -871,6 +869,7 @@ static OSErr ChooseFile( StringPtr filename, FSSpec selfld ) return err; } +#endif /* * Activate a given window, if necessary @@ -1126,7 +1125,6 @@ static void term_data_check_size(term_data *td) } } -static OSErr XDDSWUpDateGWorldFromPict( term_data *td ); /* * Hack -- resize a term_data * @@ -1136,8 +1134,6 @@ static void term_data_resize(term_data *td) { /* Actually resize the window */ SizeWindow(td->w, td->size_wid, td->size_hgt, 0); - - XDDSWUpDateGWorldFromPict( td ); } @@ -1245,20 +1241,6 @@ static void BenSWLockFrame(FrameRec *srcFrameP) } -/* - * Lock a frame - */ -static void XDDSWLockFrame( term_data *td ) -{ - PixMapHandle pixMapH; - - pixMapH = GetGWorldPixMap(td->bufferPort); - (void)LockPixels(pixMapH); - HLockHi((Handle)pixMapH); - td->bufferPixHndl = pixMapH; - td->bufferPix = (PixMapPtr)*(Handle)pixMapH; -} - /* * Unlock a frame @@ -1275,20 +1257,6 @@ static void BenSWUnlockFrame(FrameRec *srcFrameP) } -/* - * Unlock a frame - */ -static void XDDSWUnlockFrame( term_data *td ) -{ - if (td->bufferPort != NULL) - { - HUnlock((Handle)td->bufferPixHndl); - UnlockPixels(td->bufferPixHndl); - } - - td->bufferPix = NULL; -} - static OSErr BenSWCreateGWorldFromPict( GWorldPtr *pictGWorld, PicHandle pictH) @@ -1347,119 +1315,7 @@ static OSErr BenSWCreateGWorldFromPict( } -static OSErr XDDSWCreateGWorldFromPict( - GWorldPtr *pictGWorld, - term_data *td ) -{ - OSErr err; - GWorldPtr saveGWorld; - GDHandle saveGDevice; - GWorldPtr tempGWorld; - Rect pictRect; - short depth; - GDHandle theGDH; - - tempGWorld = NULL; - - /* Reset */ - *pictGWorld = NULL; - - /* Get depth */ - depth = td->pixelDepth; - - /* Get GDH */ - theGDH = td->theGDH; - - /* Obtain size rectangle */ - pictRect.left = 0; - pictRect.right = td->size_wid; - pictRect.top = 0; - pictRect.bottom = td->tile_hgt; - - /* Create a GWorld */ - err = NewGWorld(&tempGWorld, 0, &pictRect, 0, 0, 0); - - /* Success */ - if (err != noErr) - { - return (err); - } - - /* Save pointer */ - *pictGWorld = tempGWorld; - - /* Save GWorld */ - GetGWorld(&saveGWorld, &saveGDevice); - - /* Activate */ - SetGWorld(tempGWorld, nil); - - /* Dump the pict into the GWorld - (void)LockPixels(GetGWorldPixMap(tempGWorld)); - EraseRect(&pictRect); -// DrawPicture(pictH, &pictRect); - UnlockPixels(GetGWorldPixMap(tempGWorld)); - - /* Restore GWorld */ - SetGWorld(saveGWorld, saveGDevice); - - return (0); -} - - -static OSErr XDDSWUpDateGWorldFromPict( term_data *td ) -{ - GWorldPtr saveGWorld; - GDHandle saveGDevice; - Rect pictRect; - short depth; - GDHandle theGDH; - - GWorldFlags errflag; - - /* */ - - if( td->bufferPort == NULL ) - return; - /* Get depth */ - depth = td->pixelDepth; - - /* Get GDH */ - theGDH = td->theGDH; - - /* Obtain size rectangle */ - pictRect.top = 0; - pictRect.left = 0; - pictRect.right = td->size_wid; - pictRect.bottom = td->tile_hgt; - - XDDSWUnlockFrame(td); - - errflag = UpdateGWorld( &td->bufferPort, depth, &pictRect, 0, 0, 0); - XDDSWLockFrame(td); - if( errflag & gwFlagErr ){ - //SysBeep(0); - return; - } - -#if 0 - /* Save GWorld */ - GetGWorld(&saveGWorld, &saveGDevice); - - /* Activate */ - SetGWorld(td->bufferPort, nil); - - /* Dump the pict into the GWorld */ - (void)LockPixels(GetGWorldPixMap(td->bufferPort)); - EraseRect(&td->bufferPort->portRect); - - UnlockPixels(GetGWorldPixMap(td->bufferPort)); - /* Restore GWorld */ - SetGWorld(saveGWorld, saveGDevice); -#endif - -} /* * Init the global "frameP" @@ -1683,10 +1539,6 @@ static void Term_init_mac(term *t) /* Forget color */ td->last = -1; - XDDSWCreateGWorldFromPict( &td->bufferPort, td ); - - XDDSWLockFrame( td ); - } /* Oops */ /* if (err == noErr) @@ -1890,7 +1742,7 @@ static errr Term_xtra_mac(int n, int v) case TERM_XTRA_BORED: { /* Process an event */ - (void)CheckEvents(0); + (void)CheckEvents(FALSE); /* Success */ return (0); @@ -1977,10 +1829,27 @@ static errr Term_xtra_mac(int n, int v) /* If needed */ if (v > 0) { +#if TARGET_API_MAC_CARBON + EventRecord tmp; + UInt32 ticks; + + /* Convert millisecs to ticks */ + ticks = (v * 60L) / 1000; + + /* + * Hack? - Put the programme into sleep. + * No events match ~everyEvent, so nothing + * should be lost in Angband's event queue. + * Even if ticks are 0, it's worth calling for + * the above mentioned reasons. + */ + WaitNextEvent(~everyEvent, &tmp, ticks, nil); +#else long m = TickCount() + (v * 60L) / 1000; /* Wait for it */ while (TickCount() < m) /* loop */; +#endif } /* Success */ @@ -2100,38 +1969,22 @@ static errr Term_pict_mac(int x, int y, int n, const byte *ap, const char *cp) { int i; Rect r2; - bool use_buffer = false; term_data *td = (term_data*)(Term->data); GDHandle saveGDevice; GWorldPtr saveGWorld; PixMapHandle PortPix; - /* Save GWorld */ GetGWorld(&saveGWorld, &saveGDevice); + r2.left = x * td->tile_wid + td->size_ow1; + r2.right = r2.left + td->tile_wid; + r2.top = y * td->tile_hgt + td->size_oh1; + r2.bottom = r2.top + td->tile_hgt; + if( n > 1 ) { - Rect portRect; - -#if TARGET_API_MAC_CARBON - GetPortBounds( (CGrafPtr)td->bufferPort, &portRect ); -#else - portRect = td->bufferPort->portRect; -#endif - - /* Destination rectangle */ - r2.left = x * td->tile_wid + td->size_ow1; - r2.right = r2.left + td->tile_wid; - r2.top = 0; - r2.bottom = r2.top + td->tile_hgt; - - /* Activate */ - SetGWorld(td->bufferPort, nil); - PortPix = GetGWorldPixMap(td->bufferPort ); - LockPixels( PortPix ); - /* Instantiate font */ TextFont(td->font_id); TextSize(td->font_size); @@ -2140,22 +1993,14 @@ static errr Term_pict_mac(int x, int y, int n, const byte *ap, const char *cp) /* Restore colors */ BackColor(blackColor); ForeColor(whiteColor); - - /* Erase */ - EraseRect(&portRect); - - use_buffer = true; } else { /* Destination rectangle */ - r2.left = x * td->tile_wid + td->size_ow1; +/* r2.left = x * td->tile_wid + td->size_ow1; r2.top = y * td->tile_hgt + td->size_oh1; - r2.bottom = r2.top + td->tile_hgt; + r2.bottom = r2.top + td->tile_hgt;*/ - /* no buffering, so we use the normal current port */ - - use_buffer = false; } /* Scan the input */ @@ -2236,14 +2081,10 @@ static errr Term_pict_mac(int x, int y, int n, const byte *ap, const char *cp) ForeColor(blackColor); /* Draw the picture */ - - if (use_buffer) - destBitMap = (BitMapPtr)(td->bufferPix); - else #if TARGET_API_MAC_CARBON - destBitMap = GetPortPixMap(GetWindowPort( td->w )); + destBitMap = GetPortPixMap(GetWindowPort( td->w )); #else - destBitMap = (BitMapPtr)&(td->w->portBits); + destBitMap = (BitMapPtr)&(td->w->portBits); #endif if (use_bigtile) r2.right += td->tile_wid; @@ -2261,15 +2102,22 @@ static errr Term_pict_mac(int x, int y, int n, const byte *ap, const char *cp) * assign this relative amount of background * color to the destination pixel */ +#if TARGET_API_MAC_CARBON + CopyBits( (BitMap *) *srcBitMap, (BitMap *) *destBitMap, &terrain_r, &r2, srcCopy, NULL); +#else CopyBits( srcBitMap, destBitMap, &terrain_r, &r2, srcCopy, NULL ); - +#endif /* * Draw transparent tile * BackColor is ignored and the destination is * left untouched */ BackColor(blackColor); +#if TARGET_API_MAC_CARBON + CopyBits( (BitMap *) *srcBitMap, (BitMap *) *destBitMap, &r1, &r2, transparent, NULL); +#else CopyBits( srcBitMap, destBitMap, &r1, &r2, transparent, NULL ); +#endif } else #endif /* USE_TRANSPARENCY */ @@ -2339,63 +2187,12 @@ static errr Term_pict_mac(int x, int y, int n, const byte *ap, const char *cp) /* Advance */ r2.left += td->tile_wid; } - - if( use_buffer ) - { - /* Now we blast the buffer pixmap onto the screen in the right place */ - BitMapPtr srcBitMap = (BitMapPtr)(td->bufferPix); -#if TARGET_API_MAC_CARBON - BitMapPtr destBitMap = GetPortPixMap(GetWindowPort( td->w )); -#else - BitMapPtr destBitMap = (BitMapPtr)&(td->w->portBits); -#endif - - Rect srcRect; - Rect destRect; - - srcRect.left = x * td->tile_wid + td->size_ow1; - srcRect.top = 0; - srcRect.right = srcRect.left + (td->tile_wid * n); - srcRect.bottom = td->tile_hgt; - - destRect.left = x * td->tile_wid + td->size_ow1; - destRect.right = destRect.left + (td->tile_wid * n); - destRect.top = y * td->tile_hgt + td->size_oh1; - destRect.bottom = destRect.top + td->tile_hgt; - - /* Double width rectangle */ - if (use_bigtile) - { - srcRect.right += td->tile_wid * n; - destRect.right += td->tile_wid * n; - } - - UnlockPixels( PortPix ); - - /* Restore GWorld */ - SetGWorld(saveGWorld, saveGDevice); - - /* Hardwire CopyBits */ - BackColor(whiteColor); - ForeColor(blackColor); - - CopyBits( srcBitMap, destBitMap, &srcRect, &destRect, srcCopy, NULL ); - - /* Restore colors */ - BackColor(blackColor); - ForeColor(whiteColor); - } - /* Success */ return (0); } - - - - /* * Create and initialize window number "i" */ @@ -2648,7 +2445,7 @@ static void load_prefs(void) soundmode[i] = getshort(); /* Special menu */ - m = GetMenuHandle(134); //m = GetMHandle(134); + m = GetMenuHandle(134); #if TARGET_API_MAC_CARBON /* Item "arg_sound" */ @@ -3306,7 +3103,7 @@ static pascal Boolean ynfilter(DialogPtr dialog, EventRecord *event, short *ip) Rect r; /* Get the button */ - GetDialogItem(dialog, i, &type, (Handle*)&control, &r); //GetDItem(dialog, i, &type, (Handle*)&control, &r); + GetDialogItem(dialog, i, &type, (Handle*)&control, &r); /* Blink button for 1/10 second */ HiliteControl(control, 1); @@ -3625,7 +3422,7 @@ static void init_menubar(void) TextSize(12); /* Add the fonts to the menu */ - AppendResMenu(m, 'FONT'); //AddResMenu(m, 'FONT'); + AppendResMenu(m, 'FONT'); /* Size of menu */ #if TARGET_API_MAC_CARBON @@ -3641,8 +3438,7 @@ static void init_menubar(void) short fontNum; /* Acquire the font name */ - /* GetMenuItemText(m, i, tmpName); */ - GetMenuItemText(m, i, tmpName); //GetItem(m, i, tmpName); + GetMenuItemText(m, i, tmpName); /* Acquire the font index */ #if TARGET_API_MAC_CARBON @@ -3658,8 +3454,7 @@ static void init_menubar(void) if ((CharWidth('i') != CharWidth('W')) || (CharWidth('W') == 0)) { /* Delete the menu item XXX XXX XXX */ - /* DeleteMenuItem(m, i); */ - DeleteMenuItem (m, i); //DelMenuItem(m, i); + DeleteMenuItem (m, i); } } @@ -3670,7 +3465,7 @@ static void init_menubar(void) AppendMenu(m, "\p-"); /* Add the fonts to the menu */ - AppendResMenu (m, 'FONT'); //AddResMenu(m, 'FONT'); + AppendResMenu (m, 'FONT'); /* Make the "Size" menu */ @@ -3906,7 +3701,7 @@ static void setup_menus(void) /* Edit menu */ - m = GetMenuHandle(130); //m = GetMHandle(130); + m = GetMenuHandle(130); /* Get menu size */ #if TARGET_API_MAC_CARBON @@ -3948,7 +3743,7 @@ static void setup_menus(void) /* Font menu */ - m = GetMenuHandle(131); //m = GetMHandle(131); + m = GetMenuHandle(131); /* Get menu size */ #if TARGET_API_MAC_CARBON @@ -3999,8 +3794,7 @@ static void setup_menus(void) EnableMenuItem(m, i); /* Analyze font */ - /* GetMenuItemText(m,i,s); */ - GetMenuItemText(m, i, s); //GetItem(m, i, s); + GetMenuItemText(m, i, s); GetFNum(s, &value); /* Check active font */ @@ -4026,8 +3820,7 @@ static void setup_menus(void) EnableItem(m, i); /* Analyze font */ - /* GetMenuItemText(m,i,s); */ - GetMenuItemText(m, i, s); //GetItem(m, i, s); + GetMenuItemText(m, i, s); GetFNum(s, &value); /* Check active font */ @@ -4038,7 +3831,7 @@ static void setup_menus(void) /* Size menu */ - m = GetMenuHandle(132); //m = GetMHandle(132); + m = GetMenuHandle(132); /* Get menu size */ #if TARGET_API_MAC_CARBON @@ -4068,7 +3861,6 @@ static void setup_menus(void) { #if TARGET_API_MAC_CARBON /* Analyze size */ - /* GetMenuItemText(m,i,s); */ GetMenuItemText(m, i, s); s[s[0]+1] = '\0'; value = atoi((char*)(s+1)); @@ -4080,8 +3872,7 @@ static void setup_menus(void) if (td->font_size == value) CheckMenuItem(m, i, TRUE); #else /* Analyze size */ - /* GetMenuItemText(m,i,s); */ - GetMenuItemText(m, i, s); //GetItem(m, i, s); + GetMenuItemText(m, i, s); s[s[0]+1] = '\0'; value = atoi((char*)(s+1)); @@ -4096,7 +3887,7 @@ static void setup_menus(void) /* Windows menu */ - m = GetMenuHandle(133); //m = GetMHandle(133); + m = GetMenuHandle(133); /* Get menu size */ #if TARGET_API_MAC_CARBON @@ -4118,7 +3909,7 @@ static void setup_menus(void) /* Special menu */ - m = GetMenuHandle(134); //m = GetMHandle(134); + m = GetMenuHandle(134); /* Get menu size */ #if TARGET_API_MAC_CARBON @@ -4197,7 +3988,7 @@ static void setup_menus(void) #endif /* TileWidth menu */ - m = GetMenuHandle(135); //m = GetMHandle(135); + m = GetMenuHandle(135); /* Get menu size */ #if TARGET_API_MAC_CARBON @@ -4227,7 +4018,7 @@ static void setup_menus(void) { /* Analyze size */ /* GetMenuItemText(m,i,s); */ - GetMenuItemText(m, i, s); //GetItem(m, i, s); + GetMenuItemText(m, i, s); s[s[0]+1] = '\0'; value = atoi((char*)(s+1)); @@ -4249,7 +4040,7 @@ static void setup_menus(void) /* TileHeight menu */ - m = GetMenuHandle(136); //m = GetMHandle(136); + m = GetMenuHandle(136); /* Get menu size */ #if TARGET_API_MAC_CARBON @@ -4278,8 +4069,7 @@ static void setup_menus(void) for (i = 1; i <= n; i++) { /* Analyze size */ - /* GetMenuItemText(m,i,s); */ - GetMenuItemText(m, i, s); //GetItem(m, i, s); + GetMenuItemText(m, i, s); s[s[0]+1] = '\0'; value = atoi((char*)(s+1)); @@ -4571,8 +4361,7 @@ static void menu(long mc) } /* Get a new font name */ - /* GetMenuItemText(GetMHandle(131), selection, s); */ - GetMenuItemText(GetMenuHandle(131), selection, s); //GetItem(GetMHandle(131), selection, s); + GetMenuItemText(GetMenuHandle(131), selection, s); GetFNum(s, &fid); /* Save the new font id */ @@ -4634,8 +4423,7 @@ static void menu(long mc) /* Activate */ activate(td->w); - /* GetMenuItemText(GetMHandle(132), selection, s); */ - GetMenuItemText(GetMenuHandle(132), selection, s); //GetItem(GetMHandle(132), selection, s); + GetMenuItemText(GetMenuHandle(132), selection, s); s[s[0]+1]=0; td->font_size = atoi((char*)(s+1)); @@ -4793,8 +4581,7 @@ static void menu(long mc) /* Activate */ activate(td->w); - /* GetMenuItemText(GetMHandle(135), selection, s); */ - GetMenuItemText(GetMenuHandle(135), selection, s); //GetItem(GetMHandle(135), selection, s); + GetMenuItemText(GetMenuHandle(135), selection, s); s[s[0]+1]=0; td->tile_wid = atoi((char*)(s+1)); @@ -4822,8 +4609,7 @@ static void menu(long mc) /* Activate */ activate(td->w); - /* GetMenuItemText(GetMHandle(136), selection, s); */ - GetMenuItemText(GetMenuHandle(136), selection, s); //GetItem(GetMHandle(136), selection, s); + GetMenuItemText(GetMenuHandle(136), selection, s); s[s[0]+1]=0; td->tile_hgt = atoi((char*)(s+1)); @@ -5105,18 +4891,19 @@ static bool CheckEvents(bool wait) /* Timestamp last check */ lastTicks = curTicks; -#ifndef TARGET_API_MAC_CARBON +#if TARGET_API_MAC_CARBON + WaitNextEvent( everyEvent, &event, 1L, nil ); +#else /* Let the "system" run */ SystemTask(); -#endif /* Get an event (or null) */ GetNextEvent(everyEvent, &event); +#endif /* Hack -- Nothing is ready yet */ if (event.what == nullEvent) return (FALSE); - /* Analyze the event */ switch (event.what) { @@ -5266,7 +5053,7 @@ static bool CheckEvents(bool wait) HiliteMenu(0); break; } -#ifndef TARGET_API_MAC_CARBON +#if !TARGET_API_MAC_CARBON case inSysWindow: { SystemClick(&event, w); @@ -5309,7 +5096,7 @@ static bool CheckEvents(bool wait) #endif p.h = portRect.left; p.v = portRect.top; -#ifndef TARGET_API_MAC_CARBON +#if !TARGET_API_MAC_CARBON LocalToGlobal(&p); #endif td->r.left = p.h; @@ -5871,7 +5658,7 @@ void main(void) EventRecord tempEvent; int numberOfMasters = 10; -#ifndef TARGET_API_MAC_CARBON +#if !TARGET_API_MAC_CARBON /* Increase stack space by 64K */ SetApplLimit(GetApplLimit() - 131072L);//65536L); @@ -5882,7 +5669,7 @@ void main(void) /* Get more Masters */ while (numberOfMasters--) MoreMasters(); -#ifndef TARGET_API_MAC_CARBON +#if !TARGET_API_MAC_CARBON /* Set up the Macintosh */ InitGraf(&qd.thePort); InitFonts(); @@ -5983,7 +5770,7 @@ void main(void) #ifdef USE_SFL_CODE -#if TARGET_API_MAC_CARBON +#if ( TARGET_API_MAC_CARBON ) || ( !MAC_MPW ) /* Obtain a "Universal Procedure Pointer" */ AEH_Start_UPP = NewAEEventHandlerUPP(AEH_Start); /* Install the hook (ignore error codes) */ @@ -6132,11 +5919,11 @@ void main(void) #endif /* Prompt the user */ - #ifdef JP +#ifdef JP prt("'¥Õ¥¡¥¤¥ë'¥á¥Ë¥å¡¼¤è¤ê'¿·µ¬'¤Þ¤¿¤Ï'³«¤¯...'¤òÁªÂò¤·¤Æ¤¯¤À¤µ¤¤¡£", 23, 10); - #else +#else prt("[Choose 'New' or 'Open' from the 'File' menu]", 23, 15); - #endif +#endif /* Flush the prompt */ Term_fresh(); -- 2.11.0