diff --git a/justwindow b/justwindow new file mode 100755 index 0000000..18ec258 Binary files /dev/null and b/justwindow differ diff --git a/justwindow.c b/justwindow.c new file mode 100644 index 0000000..090a826 --- /dev/null +++ b/justwindow.c @@ -0,0 +1,17 @@ +#include +#include + +int main(void) { + struct Window *window; + + window = OpenWindowTags(NULL, + WA_Title, "Wow", + TAG_END + ); + + Delay(200); + + CloseWindow(window); + + return 0; +} diff --git a/justwindow.lnk b/justwindow.lnk new file mode 100644 index 0000000..1f7bbea --- /dev/null +++ b/justwindow.lnk @@ -0,0 +1,4 @@ +FROM LIB:c.o "justwindow.o" +TO "justwindow" +LIB LIB:sc.lib LIB:amiga.lib + diff --git a/main b/main index 5abd520..6954eb3 100755 Binary files a/main and b/main differ diff --git a/main.c b/main.c index 11c15cd..ec693e8 100644 --- a/main.c +++ b/main.c @@ -17,8 +17,9 @@ #include // handle images and sound -#include +#include #include +#include // timer stuff. using proto/timer.h did not work well, likely // because of how you have to open the device. @@ -107,6 +108,7 @@ struct MsgPort *timerPort; #define BELL_FILENAME "bell.8svx" APTR bellSound = NULL; +struct Library *DataTypesBase; // our business logic // for how long should I cook this pizza? @@ -177,6 +179,11 @@ int setup(void) { // to get the current time. TimerBase = TimerIO->tr_node.io_Device; + if (NULL == (DataTypesBase = OpenLibrary("datatypes.library", 40))) { + // this is ok, we just won't play sound + printf("no sound!"); + } + return 1; } @@ -185,6 +192,9 @@ int setup(void) { */ void teardown(void) { // http://amigadev.elowar.com/read/ADCD_2.1/Devices_Manual_guide/node0196.html + if (DataTypesBase) { + CloseLibrary(DataTypesBase); + } if (TimerIO) { CloseDevice((struct IORequest *)TimerIO); DeleteExtIO((struct IORequest *)TimerIO); @@ -508,7 +518,7 @@ int openAboutWindow(void) { WA_DepthGadget, TRUE, WA_CloseGadget, TRUE, WA_Activate, TRUE, - WA_Title, "Acout Pizza Timer", + WA_Title, "About Pizza Timer", TAG_END ); @@ -698,17 +708,29 @@ void handleIntuitionMessage(struct IntuiMessage *iMessage) { } } +BYTE waitForSoundSignalNumber; /** - * Start playing a bell sound, and start a timer to tear down - * the bell data once it's done. + * Start playing a bell sound, then wait for it to finish. */ void startBellSound(void) { struct dtTrigger myTrigger; struct MsgPort *TimerPort; ULONG soundPlayResult; - if (bellSound = NewDTObject(BELL_FILENAME, DTA_GroupID, GID_SOUND, TAG_END)) { + // https://amigaworld.net/modules/newbb/viewtopic.php?forum=15&topic_id=39094&post_id=735120&viewmode=thread&order=0#735120 + waitForSoundSignalNumber = AllocSignal(-1); + + if (bellSound = NewDTObject( + BELL_FILENAME, + DTA_GroupID, GID_SOUND, + // ourselves + SDTA_SignalTask, (ULONG)FindTask(NULL), + // ideally we should use this, but my headers aren't new enough? + // SDTA_SignalBitNumber, waitForSoundSignalNumber, + // so we'll do it this way + SDTA_SignalBit, 1 << waitForSoundSignalNumber, + TAG_END)) { myTrigger.MethodID = DTM_TRIGGER; myTrigger.dtt_GInfo = NULL; myTrigger.dtt_Function = STM_PLAY; @@ -717,6 +739,7 @@ void startBellSound(void) { // 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 @@ -724,6 +747,7 @@ void startBellSound(void) { TimerIO->tr_time.tv_secs = 2; TimerIO->tr_time.tv_micro = 0; SendIO((struct IORequest *)TimerIO); + */ } } @@ -735,6 +759,7 @@ void waitForBellToFinish(void) { ULONG timerSignal; if (bellSound) { + /** TimerPort = TimerIO->tr_node.io_Message.mn_ReplyPort; // TODO: move this into the main event loop, so that @@ -743,7 +768,8 @@ void waitForBellToFinish(void) { // or do we need two timer.devices with two separate IOs? // https://amigadev.elowar.com/read/ADCD_2.1/Devices_Manual_guide/node00C4.html timerSignal = 1L << TimerPort->mp_SigBit; - Wait(timerSignal); + */ + Wait(1 << waitForSoundSignalNumber); DisposeDTObject(bellSound); }