/* > arlibmain.c

 * SJ Middleton, 1992

 * this gives top-level routines for ARLib being used as a library
 * to a large C application. The library routines themselves are written so as to use
 * the smallest amounts of library code.

 */

#include "kernel.h"
#include "win.h"

#include <stdlib.h>

#include "armovie.h"
#include "arsound.h"
#include "utils.h"

static int  screen_mode;

static BOOL unknown_events(wimp_eventstr *e, void *handle)
{
    switch (e->e)
    {
        case wimp_ESEND:
        case wimp_ESENDWANTACK:
            if (e->data.msg.hdr.action == wimp_MMODECHANGE)
            {
                int val = (_kernel_osbyte(135, 0, 0) >> 8) & 0xff;
                if (screen_mode != val)
                {
                    screen_mode = val;
                    armovie_modechange();
                }
            }
            break;
    }
    return FALSE;
    handle = handle;

}

void armovie_init(void)
{
    screen_mode = (_kernel_osbyte(135, 0, 0) >> 8) & 0xff;

    armovie_setreleasefn(armovie_abort, NULL);

    win_add_unknown_event_processor(unknown_events, NULL);
    atexit(armovie_cleanup);
}

/* eof arlibmain.c */
