The game of chaos (source code) for the 3b1

Scott S. Bertilson ssb at quest.UUCP
Mon Aug 28 14:55:17 AEST 1989


  It seemed awfully slow.  I wondered what would happen if I
hacked the plot routine to plot only the single short that was
being modified.  The difference is tremendous.


*** chaos.c.orig	Sun Aug 27 03:35:25 1989
--- chaos.c	Sun Aug 27 23:38:53 1989
***************
*** 48,55
  static struct urdata uPC_ur = {(unsigned short *)uPC_display, 2*uPC_XSIZE, 0, 
                          0, 0, 0, 0, 0, uPC_XMAX, uPC_YMAX, SRCSRC, DSTOR, 0};
  
! #define uPC_flush() IfErrOut (ioctl(0, WIOCRASTOP, &uPC_ur), <0, \
!       "ioctl failed", "WIOCRASTOP")
  
  uPC_init()
  {

--- 48,55 -----
  static struct urdata uPC_ur = {(unsigned short *)uPC_display, 2*uPC_XSIZE, 0, 
                          0, 0, 0, 0, 0, uPC_XMAX, uPC_YMAX, SRCSRC, DSTOR, 0};
  
! static struct urdata uPC_urwd = {(unsigned short *)0,  2, 0,
!                         0, 0, 0, 0, 0, 16, 1, SRCSRC, DSTOR, 0};
  
  uPC_init()
  {
***************
*** 91,97
        *j++ = 0;
  
     uPC_ur.ur_dstop = DSTSRC;   /* replace (clear screen). */
!    uPC_flush();
     uPC_ur.ur_dstop = DSTOR;   /* Or in (show text) */
  }
  

--- 91,98 -----
        *j++ = 0;
  
     uPC_ur.ur_dstop = DSTSRC;   /* replace (clear screen). */
!    IfErrOut (ioctl(0, WIOCRASTOP, &uPC_ur), <0,
!       "ioctl failed", "WIOCRASTOP");
     uPC_ur.ur_dstop = DSTOR;   /* Or in (show text) */
  }
  
***************
*** 100,106
  #define uPC_PLOT(a,b)   (*(a)|=(b))
  
  uPC_plot(x,y)
! unsigned int x,y;
  {
  /* This routine plots x,y */
     register Scr_type mask, *a;

--- 101,107 -----
  #define uPC_PLOT(a,b)   (*(a)|=(b))
  
  uPC_plot(x,y)
! register unsigned int x,y;
  {
  /* This routine plots x,y */
     register Scr_type mask, *a;
***************
*** 111,117
        0x1000, 0x2000, 0x4000, 0x8000,
     };
  
!    a = &uPC_display[(uPC_YSIZE - 1) - y][x >> 4];
     mask = lookup[x & 0x0f];
  
     if (!(*(a) & mask)) {

--- 112,119 -----
        0x1000, 0x2000, 0x4000, 0x8000,
     };
  
!    y = (uPC_YSIZE - 1) - y;
!    a = &uPC_display[y][x >> 4];
     mask = lookup[x & 0x0f];
  
     if (!(*(a) & mask)) {
***************
*** 116,122
  
     if (!(*(a) & mask)) {
        uPC_PLOT (a, mask);
!       uPC_flush();
     }
  }
  

--- 118,128 -----
  
     if (!(*(a) & mask)) {
        uPC_PLOT (a, mask);
!       uPC_urwd.ur_srcbase = a;
!       uPC_urwd.ur_dstx = x & ~0x0f;
!       uPC_urwd.ur_dsty = y;
!       IfErrOut (ioctl(0, WIOCRASTOP, &uPC_urwd), <0,
! 	 "ioctl failed", "WIOCRASTOP");
     }
  }
  
***************
*** 311,317
  
  usage()
  {
!    fprintf (stderr, "chaos [3-4]\n");
     uPC_fixwind (0);
     exit(1);
  }

--- 317,323 -----
  
  usage()
  {
!    fprintf (stderr, "chaos [3-5]\n");
     uPC_fixwind (0);
     exit(1);
  }
-- 

Scott S. Bertilson   ...uunet!rosevax!rose3!quest!ssb
			scott at poincare.geom.umn.edu



More information about the Unix-pc.sources mailing list