play a bell sound
This commit is contained in:
parent
e4a570b247
commit
329921ff32
BIN
264594__cdrk__reception-bell.wav
Normal file
BIN
264594__cdrk__reception-bell.wav
Normal file
Binary file not shown.
38
main.c
38
main.c
@ -16,6 +16,10 @@
|
||||
// allow us to load and scale fonts
|
||||
#include <proto/diskfont.h>
|
||||
|
||||
// handle images and sound
|
||||
#include <proto/datatypes.h>
|
||||
#include <datatypes/datatypesclass.h>
|
||||
|
||||
// timer stuff. using proto/timer.h did not work well, likely
|
||||
// because of how you have to open the device.
|
||||
#include <clib/timer_protos.h>
|
||||
@ -110,6 +114,10 @@ struct Device *TimerBase;
|
||||
struct timerequest *TimerIO;
|
||||
struct timeval currentSystemTime;
|
||||
|
||||
// sound stuff
|
||||
// get that bell
|
||||
#define BELL_FILENAME "bell.8svx"
|
||||
|
||||
// our business logic
|
||||
// for how long should I cook this pizza?
|
||||
unsigned int uiHours = 0;
|
||||
@ -562,6 +570,29 @@ void handleIntuitionMessage(struct IntuiMessage *iMessage) {
|
||||
|
||||
void endTimer(void) {
|
||||
// TODO: play an included IFF 8SVX sound
|
||||
APTR bellSound = NULL;
|
||||
struct dtTrigger myTrigger;
|
||||
struct MsgPort *TimerPort;
|
||||
ULONG soundPlayResult, timerSignal;
|
||||
|
||||
if (bellSound = NewDTObject(BELL_FILENAME, DTA_GroupID, GID_SOUND, TAG_END)) {
|
||||
myTrigger.MethodID = DTM_TRIGGER;
|
||||
myTrigger.dtt_GInfo = NULL;
|
||||
myTrigger.dtt_Function = STM_PLAY;
|
||||
myTrigger.dtt_Data = NULL;
|
||||
|
||||
// https://github.com/khval/AmosKittens/blob/79f00ba3b81805b54fd4e437f667ea2eecab740d/OS/AmigaOS/animation.cpp#L128
|
||||
soundPlayResult = DoDTMethodA(bellSound, NULL, NULL, (Msg) &myTrigger);
|
||||
|
||||
TimerPort = TimerIO->tr_node.io_Message.mn_ReplyPort;
|
||||
|
||||
// eventually wait for the sound to stop playing
|
||||
TimerIO->tr_node.io_Command = TR_ADDREQUEST;
|
||||
TimerIO->tr_time.tv_secs = 3;
|
||||
TimerIO->tr_time.tv_micro = 0;
|
||||
SendIO((struct IORequest *)TimerIO);
|
||||
}
|
||||
|
||||
DisplayBeep(screen);
|
||||
|
||||
uiHours = uiMinutes = uiSeconds = 0;
|
||||
@ -572,6 +603,13 @@ void endTimer(void) {
|
||||
|
||||
clearUI();
|
||||
renderUI();
|
||||
|
||||
if (bellSound) {
|
||||
timerSignal = 1L << TimerPort->mp_SigBit;
|
||||
Wait(timerSignal);
|
||||
|
||||
DisposeDTObject(bellSound);
|
||||
}
|
||||
}
|
||||
|
||||
void handleTimerMessage(void) {
|
||||
|
Loading…
Reference in New Issue
Block a user