2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
7 #include <aros/debug.h>
8 #include <proto/graphics.h>
9 #include "intuition_intern.h"
11 #define BEEPTICKS 3 /* in 1/10th sec units */
13 static inline ULONG
beepcolor(ULONG x
)
15 return x
< 0x88888888 ? 0xCCCCCCCC : 0x55555555;
19 /*****************************************************************************
22 #include <proto/intuition.h>
24 AROS_LH1(void, DisplayBeep
,
27 AROS_LHA(struct Screen
*, screen
, A0
),
30 struct IntuitionBase
*, IntuitionBase
, 16, Intuition
)
33 The Amiga has no internal speaker, so it flashes the background
34 color of the specified screen as a signal. If the argument is
35 NULL all screens will be flashed.
38 screen - The Screen that will be flashed.
39 If NULL all screens will flash.
52 Hardware with a speaker should make an audible beep, too.
53 Maybe even leave out the flashing on those architectures.
55 *****************************************************************************/
59 #if USE_NEWDISPLAYBEEP
61 BOOL AllScreens
= FALSE
;
64 D(bug("INT_DisplayBeep: entry, screen 0x%p\n", screen
));
67 ObtainSemaphore(&GetPrivIBase(IntuitionBase
)->WindowLock
);
69 return; //RenderScreenBar NOT safe without this
71 //jDc: screenlist will NOT be modified while we hold WINDOWLOCK!
72 //lock = LockIBase(0);
75 if (screen
== (struct Screen
*) -1 || screen
== NULL
)
77 screen
= IntuitionBase
->FirstScreen
;
83 D(bug("INT_DisplayBeep: screen 0x%p\n", screen
));
85 if (screen
->Flags
& BEEPING
)
87 GetPrivScreen(screen
)->BeepingCounter
= BEEPTICKS
;
91 screen
->Flags
|= BEEPING
;
93 RenderScreenBar(screen
, FALSE
, IntuitionBase
);
94 D(bug("INT_DisplayBeep: RenderScreenBar done for screen 0x%p\n", screen
));
96 GetPrivIBase(IntuitionBase
)->BeepingScreens
++;
97 GetPrivScreen(screen
)->BeepingCounter
= BEEPTICKS
;
100 screen
= AllScreens
? screen
->NextScreen
: NULL
;
106 ReleaseSemaphore(&GetPrivIBase(IntuitionBase
)->WindowLock
);
108 D(bug("INT_DisplayBeep: done\n"));
110 #else /* USE_NEWDISPLAYBEEP */
112 struct MsgPort
*TimerMsgPort
;
113 struct timerequest
*BeepTimerIO
;
114 BOOL VisualBeep
= TRUE
;
115 BOOL AllScreens
= FALSE
;
118 TimerMsgPort
= CreateMsgPort();
124 BeepTimerIO
= (struct timerequest
*) CreateIORequest (TimerMsgPort
, sizeof (struct timerequest
));
127 DeleteMsgPort(TimerMsgPort
);
131 if (OpenDevice ("timer.device", UNIT_VBLANK
, (struct IORequest
*) BeepTimerIO
, 0) != 0)
133 DeleteIORequest((struct IORequest
*) BeepTimerIO
);
134 DeleteMsgPort(TimerMsgPort
);
138 BeepTimerIO
->tr_node
.io_Command
= TR_ADDREQUEST
;
139 BeepTimerIO
->tr_time
.tv_secs
= 0;
140 BeepTimerIO
->tr_time
.tv_micro
= 200000; // 250000
146 if (screen
== (struct Screen
*) -1 || screen
== NULL
)
149 screen
= IntuitionBase
->FirstScreen
;
157 if (!(screen
->Flags
& BEEPING
))
159 screen
->Flags
|= BEEPING
;
162 if (GetBitMapAttr(screen
->RastPort
.BitMap
, BMA_DEPTH
) <= 8)
163 // visual beep on CLUT-screen
166 struct DrawInfo *DInfo = NULL;
170 DInfo = GetScreenDrawInfo (screen);
171 BGPen = DInfo->dri_Pens[BACKGROUNDPEN];
174 GetRGB32 (screen
->ViewPort
.ColorMap
, 0, 1, GetPrivScreen(screen
)->DisplayBeepColor0
);
175 screen
->SaveColor0
= GetRGB4 (screen
->ViewPort
.ColorMap
, 0);
177 SetRGB32 (&screen
->ViewPort
, 0,
178 beepcolor(GetPrivScreen(screen
)->DisplayBeepColor0
[0]),
179 beepcolor(GetPrivScreen(screen
)->DisplayBeepColor0
[1]),
180 beepcolor(GetPrivScreen(screen
)->DisplayBeepColor0
[2])
183 // FreeScreenDrawInfo (screen, DInfo);
187 // visual beep on hi- and truecolor screens
189 // struct Window *BeepWindow;
190 struct TagItem window_tags
[] =
196 {WA_Flags
, WFLG_SIMPLE_REFRESH
| WFLG_BORDERLESS
},
197 {WA_CustomScreen
, (IPTR
) screen
},
198 //{WA_Priority , 50 }, // Place in front of all other windows!
202 GetPrivScreen(screen
)->DisplayBeepWindow
= (struct Window
*) OpenWindowTagList (NULL
, window_tags
);
203 screen
->Flags
|= BEEPING
;
208 if (AllScreens
) screen
= screen
->NextScreen
;
215 while (AllScreens
&& screen
);
221 DoIO ((struct IORequest
*) BeepTimerIO
);
230 screen
= IntuitionBase
->FirstScreen
;
238 if (screen
->Flags
& BEEPING
)
242 if (GetBitMapAttr(screen
->RastPort
.BitMap
, BMA_DEPTH
) <= 8)
243 // visual beep on CLUT-screen
245 // SetRGB4 (&screen->ViewPort, 0, screen->SaveColor0 & 0x000F, (screen->SaveColor0 & 0x00F0) >> 4, (screen->SaveColor0 & 0x0F00) >> 8);
246 SetRGB32 (&screen
->ViewPort
, 0,
247 GetPrivScreen(screen
)->DisplayBeepColor0
[0],
248 GetPrivScreen(screen
)->DisplayBeepColor0
[1],
249 GetPrivScreen(screen
)->DisplayBeepColor0
[2]
253 // visual beep on hi- and truecolor screens
255 if (GetPrivScreen(screen
)->DisplayBeepWindow
)
257 CloseWindow (GetPrivScreen(screen
)->DisplayBeepWindow
);
258 GetPrivScreen(screen
)->DisplayBeepWindow
= NULL
;
262 screen
->Flags
&= (UWORD
) ~BEEPING
;
268 if (AllScreens
) screen
= screen
->NextScreen
;
272 while (AllScreens
&& screen
);
275 CloseDevice((struct IORequest
*) BeepTimerIO
);
276 DeleteIORequest((struct IORequest
*) BeepTimerIO
);
277 DeleteMsgPort(TimerMsgPort
);
279 #warning TODO: Make this "multitasking proof"!
280 #warning TODO: Produce beep according to prefs
281 #warning TODO: Check if BEEPING flag is handled correctly
282 #warning TODO: Make BeepWindow 50% transparent! :-)
283 #warning TODO: Use TimerIO (IntuitionBase->TimerIO) instead of self-made BeepTimerIO?
285 #endif /* USE_NEWDISPLAYBEEP */