2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
7 #include <proto/graphics.h>
8 #include "intuition_intern.h"
10 #define BEEPTICKS 3 /* in 1/10th sec units */
12 static inline ULONG
beepcolor(ULONG x
)
14 return x
< 0x88888888 ? 0xCCCCCCCC : 0x55555555;
18 /*****************************************************************************
21 #include <proto/intuition.h>
23 AROS_LH1(void, DisplayBeep
,
26 AROS_LHA(struct Screen
*, screen
, A0
),
29 struct IntuitionBase
*, IntuitionBase
, 16, Intuition
)
32 The Amiga has no internal speaker, so it flashes the background
33 color of the specified screen as a signal. If the argument is
34 NULL all screens will be flashed.
37 screen - The Screen that will be flashed.
38 If NULL all screens will flash.
51 Hardware with a speaker should make an audible beep, too.
52 Maybe even leave out the flashing on those architectures.
56 *****************************************************************************/
60 #if USE_NEWDISPLAYBEEP
62 BOOL AllScreens
= FALSE
;
65 //dprintf("INT_DisplayBeep: entry, screen 0x%lx\n", (ULONG) screen);
68 ObtainSemaphore(&GetPrivIBase(IntuitionBase
)->WindowLock
);
70 return; //RenderScreenBar NOT safe without this
72 //jDc: screenlist will NOT be modified while we hold WINDOWLOCK!
73 //lock = LockIBase(0);
76 if (screen
== (struct Screen
*) -1 || screen
== NULL
)
78 screen
= IntuitionBase
->FirstScreen
;
84 //dprintf("INT_DisplayBeep: screen 0x%lx\n", (ULONG) screen);
86 if (screen
->Flags
& BEEPING
)
88 GetPrivScreen(screen
)->BeepingCounter
= BEEPTICKS
;
92 screen
->Flags
|= BEEPING
;
94 RenderScreenBar(screen
, FALSE
, IntuitionBase
);
95 //dprintf("INT_DisplayBeep: RenderScreenBar done for screen 0x%lx\n", (ULONG) screen);
97 GetPrivIBase(IntuitionBase
)->BeepingScreens
++;
98 GetPrivScreen(screen
)->BeepingCounter
= BEEPTICKS
;
101 screen
= AllScreens
? screen
->NextScreen
: NULL
;
107 ReleaseSemaphore(&GetPrivIBase(IntuitionBase
)->WindowLock
);
109 //dprintf("INT_DisplayBeep: done\n");
111 #else /* USE_NEWDISPLAYBEEP */
113 struct MsgPort
*TimerMsgPort
;
114 struct timerequest
*BeepTimerIO
;
115 BOOL VisualBeep
= TRUE
;
116 BOOL AllScreens
= FALSE
;
119 TimerMsgPort
= CreateMsgPort();
125 BeepTimerIO
= (struct timerequest
*) CreateIORequest (TimerMsgPort
, sizeof (struct timerequest
));
128 DeleteMsgPort(TimerMsgPort
);
132 if (OpenDevice ("timer.device", UNIT_VBLANK
, (struct IORequest
*) BeepTimerIO
, 0) != 0)
134 DeleteIORequest((struct IORequest
*) BeepTimerIO
);
135 DeleteMsgPort(TimerMsgPort
);
139 BeepTimerIO
->tr_node
.io_Command
= TR_ADDREQUEST
;
140 BeepTimerIO
->tr_time
.tv_secs
= 0;
141 BeepTimerIO
->tr_time
.tv_micro
= 200000; // 250000
147 if (screen
== (struct Screen
*) -1 || screen
== NULL
)
150 screen
= IntuitionBase
->FirstScreen
;
158 if (!(screen
->Flags
& BEEPING
))
160 screen
->Flags
|= BEEPING
;
163 if (GetBitMapAttr(screen
->RastPort
.BitMap
, BMA_DEPTH
) <= 8)
164 // visual beep on CLUT-screen
167 struct DrawInfo *DInfo = NULL;
171 DInfo = GetScreenDrawInfo (screen);
172 BGPen = DInfo->dri_Pens[BACKGROUNDPEN];
175 GetRGB32 (screen
->ViewPort
.ColorMap
, 0, 1, GetPrivScreen(screen
)->DisplayBeepColor0
);
176 screen
->SaveColor0
= GetRGB4 (screen
->ViewPort
.ColorMap
, 0);
178 SetRGB32 (&screen
->ViewPort
, 0,
179 beepcolor(GetPrivScreen(screen
)->DisplayBeepColor0
[0]),
180 beepcolor(GetPrivScreen(screen
)->DisplayBeepColor0
[1]),
181 beepcolor(GetPrivScreen(screen
)->DisplayBeepColor0
[2])
184 // FreeScreenDrawInfo (screen, DInfo);
188 // visual beep on hi- and truecolor screens
190 // struct Window *BeepWindow;
191 struct TagItem window_tags
[] =
197 {WA_Flags
, WFLG_SIMPLE_REFRESH
| WFLG_BORDERLESS
},
198 {WA_CustomScreen
, (IPTR
) screen
},
199 //{WA_Priority , 50 }, // Place in front of all other windows!
203 GetPrivScreen(screen
)->DisplayBeepWindow
= (struct Window
*) OpenWindowTagList (NULL
, window_tags
);
204 screen
->Flags
|= BEEPING
;
209 if (AllScreens
) screen
= screen
->NextScreen
;
216 while (AllScreens
&& screen
);
222 DoIO ((struct IORequest
*) BeepTimerIO
);
231 screen
= IntuitionBase
->FirstScreen
;
239 if (screen
->Flags
& BEEPING
)
243 if (GetBitMapAttr(screen
->RastPort
.BitMap
, BMA_DEPTH
) <= 8)
244 // visual beep on CLUT-screen
246 // SetRGB4 (&screen->ViewPort, 0, screen->SaveColor0 & 0x000F, (screen->SaveColor0 & 0x00F0) >> 4, (screen->SaveColor0 & 0x0F00) >> 8);
247 SetRGB32 (&screen
->ViewPort
, 0,
248 GetPrivScreen(screen
)->DisplayBeepColor0
[0],
249 GetPrivScreen(screen
)->DisplayBeepColor0
[1],
250 GetPrivScreen(screen
)->DisplayBeepColor0
[2]
254 // visual beep on hi- and truecolor screens
256 if (GetPrivScreen(screen
)->DisplayBeepWindow
)
258 CloseWindow (GetPrivScreen(screen
)->DisplayBeepWindow
);
259 GetPrivScreen(screen
)->DisplayBeepWindow
= NULL
;
263 screen
->Flags
&= (UWORD
) ~BEEPING
;
269 if (AllScreens
) screen
= screen
->NextScreen
;
273 while (AllScreens
&& screen
);
276 CloseDevice((struct IORequest
*) BeepTimerIO
);
277 DeleteIORequest((struct IORequest
*) BeepTimerIO
);
278 DeleteMsgPort(TimerMsgPort
);
280 #warning TODO: Make this "multitasking proof"!
281 #warning TODO: Produce beep according to prefs
282 #warning TODO: Check if BEEPING flag is handled correctly
283 #warning TODO: Make BeepWindow 50% transparent! :-)
284 #warning TODO: Use TimerIO (IntuitionBase->TimerIO) instead of self-made BeepTimerIO?
286 #endif /* USE_NEWDISPLAYBEEP */