home *** CD-ROM | disk | FTP | other *** search
/ APDL Public Domain 1 / APDL_PD1A.iso / fractal / tesseract / !Tesseract / source / c / plotc next >
Encoding:
Text File  |  1991-12-17  |  2.4 KB  |  124 lines

  1. /* > plotc */
  2.  
  3. #include <stdio.h>
  4. #include "swis.h"
  5. #include "kernel.h"
  6. #include "ploth.h"
  7.  
  8. #define LineLength 6
  9. #define ScreenSize 7
  10. #define XWindLimit 11
  11. #define YWindLimit 12
  12.  
  13. #define ScreenStart 148
  14.  
  15. static int screen_mode = 128+9;  /* or 20 */
  16.  
  17. static int swapn = 0;
  18. static int screen_adr0;
  19. int screen_adr;
  20.  
  21. static const int InBlock[] = {ScreenStart, -1};
  22. static int linelen;
  23. static int screenlen;
  24.  
  25. static volatile int vsync = 0;
  26.  
  27. extern void plot_begin(void)
  28. {
  29.     _kernel_osbyte(112, 1+swapn, 0);
  30.  
  31.     screen_adr = (swapn==0 ? 0 : screenlen) + screen_adr0;
  32.  
  33.     do {} while (vsync != 0);
  34.  
  35.     clg9(screen_adr);
  36.  
  37.     plotdata((char*)screen_adr);
  38. }
  39.  
  40. extern int plot_show(void)
  41. {
  42.     _kernel_osbyte(113, 1+swapn, 0);
  43.  
  44.     vsync = 1;
  45.  
  46.     swapn = 1 - swapn;
  47.  
  48.     return _kernel_escape_seen();
  49. }
  50.  
  51. extern int plot_init(void)
  52. {
  53.     _kernel_swi_regs regs;
  54.     int OutBlock[1];
  55.  
  56.     _kernel_oswrch(22);
  57.     _kernel_oswrch(screen_mode);
  58.  
  59.     _kernel_oswrch(18);           /* background colour 2 */
  60.     _kernel_oswrch(0);
  61.     _kernel_oswrch(130);
  62.  
  63.     _kernel_swi(OS_RemoveCursors, ®s, ®s);
  64.  
  65.     _kernel_osbyte(112, 1, 0);
  66.     _kernel_oswrch(16);           /* clg */
  67.     _kernel_osbyte(112, 2, 0);
  68.     _kernel_oswrch(16);
  69.  
  70.     _kernel_oswrch(29);           /* origin at centre */
  71.     _kernel_oswrch(640 % 256);
  72.     _kernel_oswrch(640 / 256);
  73.     _kernel_oswrch(512 % 256);
  74.     _kernel_oswrch(512 / 256);
  75.  
  76.     _kernel_osbyte(106, 1, 0);    /* mouse on */
  77.  
  78.     regs.r[0] = screen_mode;
  79.     regs.r[1] = LineLength;
  80.     _kernel_swi(OS_ReadModeVariable, ®s, ®s);
  81.     linelen = regs.r[2];
  82.  
  83.     regs.r[0] = screen_mode;
  84.     regs.r[1] = ScreenSize;
  85.     _kernel_swi(OS_ReadModeVariable, ®s, ®s);
  86.     screenlen = regs.r[2];
  87.  
  88.     regs.r[0] = (int)&InBlock;
  89.     regs.r[1] = (int)&OutBlock;
  90.     _kernel_swi(OS_ReadVduVariables, ®s, ®s);
  91.     screen_adr0 = OutBlock[0] - screenlen;
  92.  
  93.     regs.r[0] = 0x10;
  94.     regs.r[1] = (int)&vsync_event;
  95.     regs.r[2] = (int)&vsync;
  96.     _kernel_swi(OS_Claim, ®s, ®s);
  97.  
  98.     _kernel_osbyte(14, 4, 0);
  99.  
  100.  
  101.     plot_begin();
  102.     plot_show();
  103.  
  104.     return _kernel_escape_seen();
  105. }
  106.  
  107. extern void plot_end(void)
  108. {
  109.     _kernel_swi_regs regs;
  110.  
  111.     _kernel_osbyte(13, 4, 0);
  112.  
  113.     regs.r[0] = 0x10;
  114.     regs.r[1] = (int)&vsync_event;
  115.     regs.r[2] = (int)&vsync;
  116.     _kernel_swi(OS_Release, ®s, ®s);
  117.  
  118.     _kernel_swi(OS_RestoreCursors, ®s, ®s);
  119.  
  120.     _kernel_oswrch(22);
  121.     _kernel_oswrch(12);
  122.  
  123. }
  124.