[comp.unix.xenix] Patch to speedup Xenix version of MGR window system

chain@paul.rutgers.edu (Chain Lee) (02/02/90)

I have finished some more patches on Xenix version of MGR to speed up
window update. Machine language code is used for fast scrolling and 
window scrolling on multiple line basis is used to further enhance the
performance. Depending on the content of output to a window, a speedup 
factor between 2 to 5 will be achieved by these new patches. For 
none-interlaced video controllers, the factor will generally be
even larger. This makes the user interface much more responsive and 
comfortable.

To install the patches, you need to install my previous part00 to part06
of diffs of MGR for Xenix posted in this group first. Then at the directory
where top level mgr directory resides, run the following.

	patch -p < THIS_FILE

Cd to mgr/src, rebuild the mgr with

	make install

Chain Lee
======================
chain@datacube.com
chain@paul.rutgers.edu


*** mgr.old/src/defines.h	Sun Jan 21 11:54:35 1990
--- mgr/src/defines.h	Sun Jan 28 00:10:42 1990
***************
*** 17,24 ****
  #define MAXCLIENT	25		/* max number of client windows */
  #define MAXESC		20		/* max number of leading esc. digits */
  #define TEXT_COUNT	MAXESC-1	/* text download index */
! #define MAXBUF		80		/* max chars put to window per cycle */
! #define MAXSHELL	128		/* max chars read from shell at once */
  #define POLL_INT	0		/* us's of pause at each select */
  #define MAXNAME		35		/* max argv[0] length */
  #define MAXTTY		35		/* max tty device name length */
--- 17,24 ----
  #define MAXCLIENT	25		/* max number of client windows */
  #define MAXESC		20		/* max number of leading esc. digits */
  #define TEXT_COUNT	MAXESC-1	/* text download index */
! #define MAXBUF		1024		/* max chars put to window per cycle */
! #define MAXSHELL	1024		/* max chars read from shell at once */
  #define POLL_INT	0		/* us's of pause at each select */
  #define MAXNAME		35		/* max argv[0] length */
  #define MAXTTY		35		/* max tty device name length */
*** mgr.old/src/put_window.c	Sun Oct 22 01:22:06 1989
--- mgr/src/put_window.c	Sun Jan 28 00:46:40 1990
***************
*** 25,30 ****
--- 25,31 ----
  #include "menu.h"
  #include "event.h"
  #include <stdio.h>
+ #include <ctype.h>
  #include "window.h"
  #include "clip.h"
  
***************
*** 91,97 ****
     char *malloc(), *binary();
     struct menu_state *do_menu();
     char *trans();
! 
     /* set up environment */
  
     if (W(flags)&W_ACTIVE) {
--- 92,98 ----
     char *malloc(), *binary();
     struct menu_state *do_menu();
     char *trans();
!    
     /* set up environment */
  
     if (W(flags)&W_ACTIVE) {
***************
*** 1195,1204 ****
  
           case C_NL: 			/* line feed */
                      if (W(y)+fsizehigh > T_HIGH) {
!                        scroll(win,text,0,T_HIGH,fsizehigh,W(background));
!                        done++;
                         }
!                     else
                         W(y) += fsizehigh;
                      break;
           default:			/* print a character */
--- 1196,1219 ----
  
           case C_NL: 			/* line feed */
                      if (W(y)+fsizehigh > T_HIGH) {
!                        int cnt=1, bp, len;
!                        char c;
!                        for (bp=0,len=buff_count-indx-1;c=*(buff+bp),bp<len;++bp) {
!                           if (c == C_NL)
!                              ++cnt;
!                           else { 
!                              if (!(isprint(c) || c == C_RETURN))
!                                 break;
!                              if (fsizehigh * cnt > T_HIGH) {
!                              	--cnt;
!                              	break;
!                              }
!                           }
                         }
!                        scroll(win,text,0,T_HIGH,fsizehigh*cnt,W(background));
!                        done++;
!                        W(y) -= fsizehigh*(cnt-1);
!                     } else
                         W(y) += fsizehigh;
                      break;
           default:			/* print a character */
*** mgr.old/src/fast_scroll.c	Sun Oct 22 10:54:58 1989
--- mgr/src/fast_scroll.c	Sun Jan 28 15:51:43 1990
***************
*** 16,26 ****
   */
  
  #include <stdio.h>
  #include "bitmap.h"
  
- #ifdef sun
  #define BYTESWIDE(x)	((x->primary->wide+7)>>3)
  
  #ifndef mc68020
  
  /* these macros rely upon the proper register assignments */
--- 16,118 ----
   */
  
  #include <stdio.h>
+ #if SYSV && M_XENIX
+ #include "video.h"
+ #endif
  #include "bitmap.h"
  
  #define BYTESWIDE(x)	((x->primary->wide+7)>>3)
  
+ #if SYSV && M_XENIX
+ 
+ #if DEBUG
+ #include <signal.h>
+ #include <setjmp.h>
+ 
+ static  jmp_buf here;
+ static  void    (*ohandler)();
+ static  void    myhandler()
+ {
+         longjmp(here, -1);
+ }
+ #endif 
+ 
+ #define START(x)	v_cnt=0; x: 
+ 
+ #define LOOP(l)		l:	*((short *) dst)++ = *((short *) src)++;\
+ 				if (d0--) goto l
+ #undef	LOOP
+ #define GOTO(x)		if (v_cnt++ < h) goto x
+ #if INTERLACE
+ #define SKIP()		if (is_screen) { \
+ 				dst = (char *)((long) (map->data) \
+ 				      + screen_addr(y+v_cnt) + (x>>3)); \
+ 				src = (char *)((long) (map->data) \
+ 				      + screen_addr(y+delta+v_cnt) + (x>>3)); \
+ 			} else { \
+ 				dst += skip; \
+ 				src += skip; \
+ 			}
+ #else
+ #define	SKIP()		dst += skip; src += skip
+ #endif
+ #define BYTE()		*dst++ = *src++
+ #define ADJ(x)		count -= x
+ 
+ fast_scroll(map,x,y,wide,high,delta)
+ BITMAP *map;
+ int x,y,wide,high,delta;
+    {
+ #if INTERLACE
+    int is_screen = IS_SCREEN(map);
+    register unsigned char *src = is_screen		/* esi */
+       ? (unsigned char *) ((long) (map->data) + (screen_addr(y+delta) + (x>>3)))
+       : (unsigned char *) ((long) (map->data) + ((y+delta)*BYTESWIDE(map)
+                             + (x>>3)));
+    register unsigned char *dst = is_screen		/* edi */
+       ? (unsigned char *) ((long) (map->data) + (screen_addr(y) + (x>>3)))
+       : (unsigned char *) ((long) (map->data) + (y*BYTESWIDE(map) + (x>>3)));
+ #else
+    register unsigned char *src = (unsigned char *) 
+       ((long) (map->data) + ((y+delta)*BYTESWIDE(map) + (x>>3)));  
+    register unsigned char *dst = (unsigned char *)
+       ((long) (map->data) + (y*BYTESWIDE(map) + (x>>3)));
+ #endif
+    register long count =				/* ebx */
+          (wide>>4);			/* # of shorts - 1 for inner dbf */
+    register long skip = 				/*  */
+          BYTESWIDE(map)-(wide>>3);	/* bytes to skip at right edge */
+    register long h = 					/*  */
+          high-delta;			/* # of lines to scroll */
+    int which = (((long) dst)&1) + ((skip&1)<<1);
+    int v_cnt;
+ 
+ #if DEBUG
+    ohandler = (void (*)()) signal(SIGSEGV, myhandler);
+       if (setjmp(here) != 0) {
+       	 signal(SIGSEGV, ohandler);
+ 	 return;
+       }
+ #endif
+ 
+    switch (which) {
+       case 0:			/* skip&1 == 0 */
+ 	 START(C0); LOOP(); SKIP(); GOTO(C0);
+          break;
+       case 1:
+          ADJ(1); START(C1); BYTE(); LOOP(); BYTE(); SKIP(); GOTO(C1);
+          break;
+ 
+       case 2:			/* skip&1 == 1 */
+ 	 START(C2); LOOP(); BYTE(); SKIP(); GOTO(C2);
+          break;
+       case 3:
+ 	 START(C3); BYTE(); LOOP(); SKIP(); GOTO(C3);
+          break;
+       }
+    }
+ 
+ #elif sun
  #ifndef mc68020
  
  /* these macros rely upon the proper register assignments */
***************
*** 166,172 ****
  
  /* normal bit-blit version of the above (for testing) */
  
! fast_scroll(map,x,y,wide,high,delta)
  register BITMAP *map;					/* a5 */
  int x,y,wide,high,delta;
     {
--- 258,264 ----
  
  /* normal bit-blit version of the above (for testing) */
  
! Fast_scroll(map,x,y,wide,high,delta)
  register BITMAP *map;					/* a5 */
  int x,y,wide,high,delta;
     {
*** mgr.old/src/Makefile	Sun Jan 21 14:02:43 1990
--- mgr/src/Makefile	Sun Jan 28 21:19:16 1990
***************
*** 56,63 ****
  OTHERLIB =
  INCL = ../lib
  MACHDEP_H =
! MACHDEP_C = #fast_scroll.c
! MACHDEP_O = #fast_scroll.o
  VER = 3.3
  #
  # built-in path names:
--- 56,63 ----
  OTHERLIB =
  INCL = ../lib
  MACHDEP_H =
! MACHDEP_C = fast_scroll.c
! MACHDEP_O = fast_scroll.o
  VER = 3.3
  #
  # built-in path names:
***************
*** 67,73 ****
  FLAG = -O -DSYSV
  ###########################################
  START=.
! DSAME = -DKILL -DCUT -DVI # -DDEBUG #-DBUCKEY -DWHO 
  #	-DBELL -DKBD -DALIGN32 -DFRACCHAR
  #	FONTDIR:	where to find font files  (default: /usr/mgr/font)
  #	ICONDIR:	where to find icons	  (default: /usr/mgr/icon)
--- 67,73 ----
  FLAG = -O -DSYSV
  ###########################################
  START=.
! DSAME = -DALIGN -DKILL -DCUT -DVI # -DDEBUG #-DBUCKEY -DWHO 
  #	-DBELL -DKBD -DALIGN32 -DFRACCHAR
  #	FONTDIR:	where to find font files  (default: /usr/mgr/font)
  #	ICONDIR:	where to find icons	  (default: /usr/mgr/icon)
***************
*** 290,298 ****
  
  # The optimizer botches on this one
  
! fast_scroll.o:	fast_scroll.c
! 		$(CC) -c -I$(BLITDIR) fast_scroll.c
  
  #	put copyright data into text segment
  copyright.o:	copyright.c copyright.h
  		$(CC) -c $(FLAG) $(DFLAGS) -I$(BLITDIR) -R copyright.c
--- 290,306 ----
  
  # The optimizer botches on this one
  
! fast_scroll.o:	Fast_scroll.s
! 		$(CC) -c Fast_scroll.s
! 		mv Fast_scroll.o fast_scroll.o
  
+ Fast_scroll.s:	fast_scroll.s asm.sed
+ 		sed -f asm.sed < fast_scroll.s > Fast_scroll.s
+ 
+ fast_scroll.s:	fast_scroll.c
+ 		$(CC) -DSYSV -O -c -Fa -Fs -I$(BLITDIR) fast_scroll.c
+ 		rm -f fast_scroll.S
+ 
  #	put copyright data into text segment
  copyright.o:	copyright.c copyright.h
  		$(CC) -c $(FLAG) $(DFLAGS) -I$(BLITDIR) -R copyright.c
***************
*** 308,314 ****
  		echo "MGR version log > $(LOG)
  
  clean:		
! 		rm -f *.o version.c $(ALLDOTFILES) .done
  		@for i in $(LIBS); do \
  			(cd $$i; $(MAKE) clean); \
  		done	
--- 316,322 ----
  		echo "MGR version log > $(LOG)
  
  clean:		
! 		rm -f *.o *.s *.S version.c $(ALLDOTFILES) .done
  		@for i in $(LIBS); do \
  			(cd $$i; $(MAKE) clean); \
  		done	
*** mgr.old/src/copyright.c	Sat Jan  6 17:13:48 1990
--- mgr/src/copyright.c	Sun Jan 28 12:17:27 1990
***************
*** 35,41 ****
  	{ &lb_0, &lb_1, &lb_2, &lb_3, &lb_4, &lb_5, &lb_6, &lb_7};
  
  static struct timeval delay = {
!    (long) 0, (long) 120000
     };
  
  /* for "star trek" clip areas */
--- 35,41 ----
  	{ &lb_0, &lb_1, &lb_2, &lb_3, &lb_4, &lb_5, &lb_6, &lb_7};
  
  static struct timeval delay = {
!    (long) 0, (long) 80000
     };
  
  /* for "star trek" clip areas */
*** mgr.old/src/asm.sed	Wed Jan 31 21:03:45 1990
--- mgr/src/asm.sed	Sun Jan 28 06:00:25 1990
***************
*** 0 ****
--- 1,8 ----
+ /^EXTRN	_LOOP/d
+ /^	call[ 	][ 	]*_LOOP/{
+   a\
+ 	mov	ecx,ebx\
+ 	rep	movsw
+   s//;&/
+ }
+ 
*** mgr.old/misc/mgrc.XENIX_HER	Sun Jan  7 14:28:28 1990
--- mgr/misc/mgrc.XENIX_HER	Sun Jan 28 13:43:42 1990
***************
*** 23,29 ****
   shell mclock
  window 643 126 74 74 
   shell iconmail
! window 610 1 110 48 1
   shell clock2 -c
  window 1 32 600 300 3
  window 540 1 58 42
--- 23,29 ----
   shell mclock
  window 643 126 74 74 
   shell iconmail
! window 608 1 110 48 1
   shell clock2 -c
  window 1 32 600 300 3
  window 540 1 58 42