2 Copyright © 1995-2003, 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 *****************************************************************************/
59 AROS_LIBBASE_EXT_DECL(struct IntuitionBase
*,IntuitionBase
)
61 #if USE_NEWDISPLAYBEEP
63 BOOL AllScreens
= FALSE
;
66 //dprintf("INT_DisplayBeep: entry, screen 0x%lx\n", (ULONG) screen);
69 ObtainSemaphore(&GetPrivIBase(IntuitionBase
)->WindowLock
);
71 return; //RenderScreenBar NOT safe without this
73 //jDc: screenlist will NOT be modified while we hold WINDOWLOCK!
74 //lock = LockIBase(0);
77 if (screen
== (struct Screen
*) -1 || screen
== NULL
)
79 screen
= IntuitionBase
->FirstScreen
;
85 //dprintf("INT_DisplayBeep: screen 0x%lx\n", (ULONG) screen);
87 if (screen
->Flags
& BEEPING
)
89 GetPrivScreen(screen
)->BeepingCounter
= BEEPTICKS
;
93 screen
->Flags
|= BEEPING
;
95 RenderScreenBar(screen
, FALSE
, IntuitionBase
);
96 //dprintf("INT_DisplayBeep: RenderScreenBar done for screen 0x%lx\n", (ULONG) screen);
98 GetPrivIBase(IntuitionBase
)->BeepingScreens
++;
99 GetPrivScreen(screen
)->BeepingCounter
= BEEPTICKS
;
102 screen
= AllScreens
? screen
->NextScreen
: NULL
;
108 ReleaseSemaphore(&GetPrivIBase(IntuitionBase
)->WindowLock
);
110 //dprintf("INT_DisplayBeep: done\n");
112 #else /* USE_NEWDISPLAYBEEP */
114 struct MsgPort
*TimerMsgPort
;
115 struct timerequest
*BeepTimerIO
;
116 BOOL VisualBeep
= TRUE
;
117 BOOL AllScreens
= FALSE
;
120 TimerMsgPort
= CreateMsgPort();
126 BeepTimerIO
= (struct timerequest
*) CreateIORequest (TimerMsgPort
, sizeof (struct timerequest
));
129 DeleteMsgPort(TimerMsgPort
);
133 if (OpenDevice ("timer.device", UNIT_VBLANK
, (struct IORequest
*) BeepTimerIO
, 0) != 0)
135 DeleteIORequest((struct IORequest
*) BeepTimerIO
);
136 DeleteMsgPort(TimerMsgPort
);
140 BeepTimerIO
->tr_node
.io_Command
= TR_ADDREQUEST
;
141 BeepTimerIO
->tr_time
.tv_secs
= 0;
142 BeepTimerIO
->tr_time
.tv_micro
= 200000; // 250000
148 if (screen
== (struct Screen
*) -1 || screen
== NULL
)
151 screen
= IntuitionBase
->FirstScreen
;
159 if (!(screen
->Flags
& BEEPING
))
161 screen
->Flags
|= BEEPING
;
164 if (GetBitMapAttr(screen
->RastPort
.BitMap
, BMA_DEPTH
) <= 8)
165 // visual beep on CLUT-screen
168 struct DrawInfo *DInfo = NULL;
172 DInfo = GetScreenDrawInfo (screen);
173 BGPen = DInfo->dri_Pens[BACKGROUNDPEN];
176 GetRGB32 (screen
->ViewPort
.ColorMap
, 0, 1, GetPrivScreen(screen
)->DisplayBeepColor0
);
177 screen
->SaveColor0
= GetRGB4 (screen
->ViewPort
.ColorMap
, 0);
179 SetRGB32 (&screen
->ViewPort
, 0,
180 beepcolor(GetPrivScreen(screen
)->DisplayBeepColor0
[0]),
181 beepcolor(GetPrivScreen(screen
)->DisplayBeepColor0
[1]),
182 beepcolor(GetPrivScreen(screen
)->DisplayBeepColor0
[2])
185 // FreeScreenDrawInfo (screen, DInfo);
189 // visual beep on hi- and truecolor screens
191 // struct Window *BeepWindow;
192 struct TagItem window_tags
[] =
198 {WA_Flags
, WFLG_SIMPLE_REFRESH
| WFLG_BORDERLESS
},
199 {WA_CustomScreen
, (IPTR
) screen
},
200 //{WA_Priority , 50 }, // Place in front of all other windows!
204 GetPrivScreen(screen
)->DisplayBeepWindow
= (struct Window
*) OpenWindowTagList (NULL
, window_tags
);
205 screen
->Flags
|= BEEPING
;
210 if (AllScreens
) screen
= screen
->NextScreen
;
217 while (AllScreens
&& screen
);
223 DoIO ((struct IORequest
*) BeepTimerIO
);
232 screen
= IntuitionBase
->FirstScreen
;
240 if (screen
->Flags
& BEEPING
)
244 if (GetBitMapAttr(screen
->RastPort
.BitMap
, BMA_DEPTH
) <= 8)
245 // visual beep on CLUT-screen
247 // SetRGB4 (&screen->ViewPort, 0, screen->SaveColor0 & 0x000F, (screen->SaveColor0 & 0x00F0) >> 4, (screen->SaveColor0 & 0x0F00) >> 8);
248 SetRGB32 (&screen
->ViewPort
, 0,
249 GetPrivScreen(screen
)->DisplayBeepColor0
[0],
250 GetPrivScreen(screen
)->DisplayBeepColor0
[1],
251 GetPrivScreen(screen
)->DisplayBeepColor0
[2]
255 // visual beep on hi- and truecolor screens
257 if (GetPrivScreen(screen
)->DisplayBeepWindow
)
259 CloseWindow (GetPrivScreen(screen
)->DisplayBeepWindow
);
260 GetPrivScreen(screen
)->DisplayBeepWindow
= NULL
;
264 screen
->Flags
&= (UWORD
) ~BEEPING
;
270 if (AllScreens
) screen
= screen
->NextScreen
;
274 while (AllScreens
&& screen
);
277 CloseDevice((struct IORequest
*) BeepTimerIO
);
278 DeleteIORequest((struct IORequest
*) BeepTimerIO
);
279 DeleteMsgPort(TimerMsgPort
);
281 #warning TODO: Make this "multitasking proof"!
282 #warning TODO: Produce beep according to prefs
283 #warning TODO: Check if BEEPING flag is handled correctly
284 #warning TODO: Make BeepWindow 50% transparent! :-)
285 #warning TODO: Use TimerIO (IntuitionBase->TimerIO) instead of self-made BeepTimerIO?
287 #endif /* USE_NEWDISPLAYBEEP */