home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <signal.h>
- #include <setjmp.h>
- #include <kernel.h>
- #include <swis.h>
- #include "ROsound.h"
- #include "ROsupport.h"
- #include "gfxlibs/keyboard.h"
-
- void goshutdown (void);
- void findMachineType (void);
- void desktop (void);
- const char *Initialise (void);
- const char *SelMode (int);
-
-
- typedef void (*SIGNAL) (int);
-
- /*#define x(m) { const char *foo; foo=m; if (foo) { godesktop(); return foo; }}
- void (x) (const char *msg);*/
- #define x(m) { const char *foo; foo=m; if (foo) { fprintf (stderr, "%s\n", foo); goshutdown (); exit (2); }}
- void (x) (const char *msg);
-
-
- static jmp_buf jump;
- static _kernel_oserror sigerr;
-
- static void
- sighandler (int sig)
- {
- sigerr = *_kernel_last_oserror ();
- goshutdown ();
- longjmp (jump, sig);
- exit (2);
- }
-
-
-
- void
- mm_sys_init (void)
- {
- #ifdef UNIXLIB
- __uname_control = __UNAME_NO_PROCESS;
- #endif
-
- switch (setjmp (jump)) {
- case 0:
- break;
- case SIGINT:
- x ("Escape");
- default:
- {
- int *regdump, *os_regdump;
- const char *msg = 0;
- char buf[64];
- _swix (0x40, 15 | 1 << 28, 7, 0, 0, 0, ®dump);
- _swix (0x40, 15 | 1 << 30, 13, 0, 0, 0, &os_regdump);
- if (regdump && os_regdump)
- memcpy (os_regdump, regdump, 64);
- switch (sigerr.errnum & 0xFFFFFF) {
- case 0:
- msg = "Illegal instruction";
- break;
- case 1:
- msg = "Prefetch abort";
- break;
- case 2:
- msg = "Data abort";
- break;
- case 3:
- msg = "Address exception";
- break;
- case 5:
- msg = "Branch through zero";
- break;
- }
- if (msg) {
- sprintf (buf, "Internal error: %s at &%08X", msg, regdump[15]);
- x (buf);
- }
- else
- x (sigerr.errmess);
- }
- }
-
- signal (SIGABRT, sighandler);
- signal (SIGFPE, sighandler);
- signal (SIGILL, sighandler);
- signal (SIGINT, sighandler);
- signal (SIGSEGV, sighandler);
- signal (SIGTERM, sighandler);
- #ifdef SIGSTAK
- signal (SIGSTAK, sighandler);
- #endif
- #ifdef SIGOSERROR
- signal (SIGOSERROR, sighandler);
- #endif
-
- findMachineType ();
-
- desktop ();
- }
-
- void
- mm_sys_shutdown (void)
- {
- goshutdown ();
- }
-
-
- void
- mm_gfx_init (void)
- {
- /*
- x (Initialise ());
- x (SelMode (VidMode));
- */
- }
-
- void
- mm_gfx_shutdown (void)
- {
- }
-
-
- void
- mm_snd_init (void)
- {
- /*
- if (!sampleptr[0].ptr)
- x (loadSamples ());
- if (initmusic (SOUND & 2 ? 0 : "<Manic$Dir>.mm-music"))
- x ("Failed to load the music");
- if (initsfx (SOUND & 2))
- x ("Failed to initialise the sound effects");
- */
- }
-
- void
- mm_snd_shutdown (void)
- {
- }
-