#include "quiz.h" APTR IntuitionBase; APTR GfxBase; extern APTR OpenLibrary (); extern struct IntuiMessage *GetMsg (); extern struct Window *OpenWindow (); static struct NewWindow nw = { 0 , 0 , 640 , 200 , -1 , -1 , GADGETUP | CLOSEWINDOW , WINDOWDEPTH | WINDOWCLOSE | WINDOWDRAG | SMART_REFRESH | NOCAREREFRESH | ACTIVATE , NULL , NULL , (UBYTE *) "Thai Quizer V1.0" , NULL , NULL , 640 , 200 , 640 , 200 , WBENCHSCREEN }; main () { GfxBase = OpenLibrary ( "graphics.library" , 0L ); if ( GfxBase == NULL ) { exit ( 1 ); } IntuitionBase = OpenLibrary ( "intuition.library" , 0L ); if ( IntuitionBase == NULL ) { CloseLibrary ( GfxBase ); exit ( 1 ); } window = OpenWindow ( &nw ); if ( window == NULL ) { CloseLibrary ( GfxBase ); CloseLibrary ( IntuitionBase ); exit ( 1 ); } if ( ! open_thai_font () ) { CloseLibrary ( GfxBase ); CloseLibrary ( IntuitionBase ); CloseWindow ( window ); exit ( 1 ); } if ( ! init_speech () ) { close_thai_font (); CloseLibrary ( GfxBase ); CloseLibrary ( IntuitionBase ); CloseWindow ( window ); exit ( 1 ); } init_thai_keyboard (); init_globals (); if ( load_phrases () ) { do_commands (); } else puts ( "Failed to load phrases" ); unload_phrases (); close_speech (); close_thai_font (); CloseWindow ( window ); CloseLibrary ( GfxBase ); CloseLibrary ( IntuitionBase ); } do_commands () { struct IntuiMessage *msg; int quit; struct Gadget *gadget; quit = FALSE; while ( ! quit ) { WaitPort ( window->UserPort ); while ( msg = GetMsg ( window->UserPort ) ) { switch ( msg->Class ) { case CLOSEWINDOW : quit = TRUE; ReplyMsg ( msg ); break; case GADGETUP : gadget = (struct Gadget *) msg->IAddress; ReplyMsg ( msg ); do_gadget ( gadget ); break; default : ReplyMsg ( msg ); break; } } } }