home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue4 / IYONIX / MANICMINER / SOURCE.ZIP / manicminer-1.6.3 / systems / riscos / c / init < prev    next >
Encoding:
Text File  |  2000-12-08  |  2.4 KB  |  145 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <signal.h>
  5. #include <setjmp.h>
  6. #include <kernel.h>
  7. #include <swis.h>
  8. #include "ROsound.h"
  9. #include "ROsupport.h"
  10. #include "gfxlibs/keyboard.h"
  11.  
  12. void goshutdown (void);
  13. void findMachineType (void);
  14. void desktop (void);
  15. const char *Initialise (void);
  16. const char *SelMode (int);
  17.  
  18.  
  19. typedef void (*SIGNAL) (int);
  20.  
  21. /*#define x(m) { const char *foo; foo=m; if (foo) { godesktop(); return foo; }}
  22. void (x) (const char *msg);*/
  23. #define x(m) { const char *foo; foo=m; if (foo) { fprintf (stderr, "%s\n", foo); goshutdown (); exit (2); }}
  24. void (x) (const char *msg);
  25.  
  26.  
  27. static jmp_buf jump;
  28. static _kernel_oserror sigerr;
  29.  
  30. static void
  31. sighandler (int sig)
  32. {
  33.   sigerr = *_kernel_last_oserror ();
  34.   goshutdown ();
  35.   longjmp (jump, sig);
  36.   exit (2);
  37. }
  38.  
  39.  
  40.  
  41. void
  42. mm_sys_init (void)
  43. {
  44. #ifdef UNIXLIB
  45.   __uname_control = __UNAME_NO_PROCESS;
  46. #endif
  47.  
  48.   switch (setjmp (jump)) {
  49.   case 0:
  50.     break;
  51.   case SIGINT:
  52.     x ("Escape");
  53.   default:
  54.     {
  55.       int *regdump, *os_regdump;
  56.       const char *msg = 0;
  57.       char buf[64];
  58.       _swix (0x40, 15 | 1 << 28, 7, 0, 0, 0, ®dump);
  59.       _swix (0x40, 15 | 1 << 30, 13, 0, 0, 0, &os_regdump);
  60.       if (regdump && os_regdump)
  61.     memcpy (os_regdump, regdump, 64);
  62.       switch (sigerr.errnum & 0xFFFFFF) {
  63.       case 0:
  64.     msg = "Illegal instruction";
  65.     break;
  66.       case 1:
  67.     msg = "Prefetch abort";
  68.     break;
  69.       case 2:
  70.     msg = "Data abort";
  71.     break;
  72.       case 3:
  73.     msg = "Address exception";
  74.     break;
  75.       case 5:
  76.     msg = "Branch through zero";
  77.     break;
  78.       }
  79.       if (msg) {
  80.     sprintf (buf, "Internal error: %s at &%08X", msg, regdump[15]);
  81.     x (buf);
  82.       }
  83.       else
  84.     x (sigerr.errmess);
  85.     }
  86.   }
  87.  
  88.   signal (SIGABRT, sighandler);
  89.   signal (SIGFPE, sighandler);
  90.   signal (SIGILL, sighandler);
  91.   signal (SIGINT, sighandler);
  92.   signal (SIGSEGV, sighandler);
  93.   signal (SIGTERM, sighandler);
  94. #ifdef SIGSTAK
  95.   signal (SIGSTAK, sighandler);
  96. #endif
  97. #ifdef SIGOSERROR
  98.   signal (SIGOSERROR, sighandler);
  99. #endif
  100.  
  101.   findMachineType ();
  102.  
  103.   desktop ();
  104. }
  105.  
  106. void
  107. mm_sys_shutdown (void)
  108. {
  109.   goshutdown ();
  110. }
  111.  
  112.  
  113. void
  114. mm_gfx_init (void)
  115. {
  116. /*
  117.   x (Initialise ());
  118.   x (SelMode (VidMode));
  119.  */
  120. }
  121.  
  122. void
  123. mm_gfx_shutdown (void)
  124. {
  125. }
  126.  
  127.  
  128. void
  129. mm_snd_init (void)
  130. {
  131. /*
  132.   if (!sampleptr[0].ptr)
  133.     x (loadSamples ());
  134.   if (initmusic (SOUND & 2 ? 0 : "<Manic$Dir>.mm-music"))
  135.     x ("Failed to load the music");
  136.   if (initsfx (SOUND & 2))
  137.     x ("Failed to initialise the sound effects");
  138.  */
  139. }
  140.  
  141. void
  142. mm_snd_shutdown (void)
  143. {
  144. }
  145.