diff --git a/264594__cdrk__reception-bell.wav b/264594__cdrk__reception-bell.wav new file mode 100644 index 0000000..aed92d0 Binary files /dev/null and b/264594__cdrk__reception-bell.wav differ diff --git a/bell.8svx b/bell.8svx new file mode 100644 index 0000000..d322b1d Binary files /dev/null and b/bell.8svx differ diff --git a/main b/main index bad21ae..b1040bd 100755 Binary files a/main and b/main differ diff --git a/main.c b/main.c index 0f7d3ec..901fa91 100644 --- a/main.c +++ b/main.c @@ -16,6 +16,10 @@ // allow us to load and scale fonts #include +// handle images and sound +#include +#include + // timer stuff. using proto/timer.h did not work well, likely // because of how you have to open the device. #include @@ -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) {