home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 1 / ARM_CLUB_CD.iso / contents / apps / clib / progs / haswinlib / c / kernel < prev    next >
Encoding:
Text File  |  1991-02-04  |  3.0 KB  |  94 lines

  1. /* > $.CLIB.C.kernel
  2.  *
  3.  *      HASWIN Graphics Library
  4.  *     =========================
  5.  *
  6.  *      Copyright (C) H.A.Shaw 1990.
  7.  *              Howard A. Shaw.
  8.  *              The Unit for Space Sciences,
  9.  *              Room 165,
  10.  *              Physics Building,
  11.  *              University of Kent at Canterbury.
  12.  *              Canterbury.
  13.  *              Kent.  CT2 7NJ
  14.  *      You may use and distribute this code freely, however please leave
  15.  *      it alone.  If you find bugs (and there will be many) please contact
  16.  *      me and the master source can be modified.  If you keep me informed
  17.  *      of who you give copies of this to then I can get release upgrades
  18.  *      to them.
  19.  *
  20.  *     routines to interface HASWIN to the kernel.  This is so designed that
  21.  *     ALL kernel calls go via code in this file.  Therefore if this file
  22.  *     compiles under both Release 2 and 3 of C then the whole library is
  23.  *     OK.  This is in fact the case!
  24.  */
  25. #include "includes.h"
  26.  
  27. int haswin_setexittrap(int (*code)(int)) {
  28.         haswin_exittrap = code;
  29.         return(HASWIN_TRUE);
  30. }
  31.  
  32. void haswin_exit(int code) {
  33.  
  34.         if (haswin_exittrap)
  35.                 (*haswin_exittrap)(code);
  36.         while (haswin_poptemplate())
  37.                 ;
  38.         while (haswin_popcaret())
  39.                 ;
  40.         while (haswin_poppointer(HASWIN_FALSE))
  41.                 ;
  42.         haswin_pdriverclosedown();
  43.         haswin_restoreerrorhandlers();
  44.         haswin_finishedfonts();
  45.         haswin_taskclosedown();
  46.         haswin_killmemorymanager();
  47.         exit(code);
  48. }
  49.  
  50. /*
  51.  *      run a command under the WIMP.
  52.  */
  53. void haswin_execcommand(char *comm) {
  54.  
  55.         _kernel_swi_regs  regs;
  56.  
  57.         regs.r[0] = (int)comm;
  58.         haswin_swi(HASWIN_Start_task, ®s);
  59. }
  60.  
  61. int haswin_swi(int swi, _kernel_swi_regs *regs) {
  62.  
  63.         _kernel_swi_regs        ans;
  64.         _kernel_oserror         *err;
  65.  
  66.         if (regs == 0) {
  67. #ifdef DEBUG
  68. fprintf(stderr, "\nhaswin_swi(%8.8X, regs=0)\n", swi);
  69. #endif
  70.                 if ((err = _kernel_swi(SWI_X|swi, &ans, &ans)) == 0)
  71.                         return(HASWIN_TRUE);
  72.                 else {
  73.                         haswin_interrorprintf("SWI %8.8X: %s", swi,
  74.                                 err->errmess);
  75.                         return(HASWIN_FALSE);
  76.                 }
  77.         }
  78. #ifdef DEBUG
  79. fprintf(stderr, "\nhaswin_swi(%8.8X, (%X %X %X %X))\n", swi, regs->r[0], regs->r[1], regs->r[2], regs->r[3]);
  80. #endif
  81.         if ((err = _kernel_swi(SWI_X|swi, regs, &ans)) == 0) {
  82.                 regs->r[0] = ans.r[0];        regs->r[1] = ans.r[1];
  83.                 regs->r[2] = ans.r[2];        regs->r[3] = ans.r[3];
  84.                 regs->r[4] = ans.r[4];        regs->r[5] = ans.r[5];
  85.                 regs->r[6] = ans.r[6];        regs->r[7] = ans.r[7];
  86.                 regs->r[8] = ans.r[8];        regs->r[9] = ans.r[9];
  87.                 return(HASWIN_TRUE);
  88.         } else {
  89.                 haswin_interrorprintf("SWI %8.8X: %s", swi, err->errmess);
  90.                 return(HASWIN_FALSE);
  91.         }
  92. }
  93.  
  94.