delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1996/12/29/10:12:53

Message-Id: <199612291502.AAA06801@mail.st.rim.or.jp>
From: "Daisuke Aoyama" <jack AT st DOT rim DOT or DOT jp>
To: "DJ Delorie" <dj AT delorie DOT com>
Cc: "DJGPP WORKERS" <djgpp-workers AT delorie DOT com>
Subject: conio's patch for DOS/V virtual VRAM
Date: Mon, 30 Dec 1996 00:02:17 +0900
MIME-Version: 1.0

After applying this patch, we can use conio function under DOS/V.
(DOS/V is japanese version of MS-DOS. it has virtual consol under
VGA; same as text mode except manual updating)
I tested with less.exe under Win95's DOS box and full screen.

Daisuke Aoyama
jack AT st DOT rim DOT or DOT jp


*** src/libc/pc_hw/co80/conio.c-orig	Tue Jul 23 23:37:22 1996
--- src/libc/pc_hw/co80/conio.c	Sun Dec 29 23:26:58 1996
***************
*** 36,45 ****
--- 36,66 ----
  static unsigned last_mode = 0xffff; /* video mode when before program
start */
  static int oldattrib =  -1;         /* text attribute before program
start */
  
+ #define USE_DOSV		/* support DOS/V virtual VRAM */
+ #if defined (USE_DOSV)
+ static unsigned short ScreenVirtualSegment = 0;
+ static unsigned short ScreenVirtualOffset = 0;
+ #define VOFFSET(r,c) (ScreenVirtualOffset + 2 * (((r) *
txinfo.screenwidth) + (c)))
+ #endif
+ 
  static int conio_count = -1;
  
  #define VIDADDR(r,c) (ScreenAddress + 2*(((r) * txinfo.screenwidth) +
(c)))
  
+ #if defined (USE_DOSV)
+ static void
+ refreshscreen (int c, int r, int count)
+ {
+   __dpmi_regs regs;
+ 
+   regs.x.es = ScreenVirtualSegment;
+   regs.x.di = VOFFSET(r, c);
+   regs.h.ah = 0xff;	/* Refresh Screen */
+   regs.x.cx = count;	/* number of characters */
+   __dpmi_int (0x10, &regs);
+ }
+ #endif
+ 
  int
  puttext(int c, int r, int c2, int r2, void *buf)
  {
***************
*** 50,55 ****
--- 71,80 ----
    {
      dosmemput(cbuf, (c2-c+1)*2, VIDADDR(r, c));
      cbuf += c2-c+1;
+ #if defined (USE_DOSV)
+     if (ScreenVirtualSegment != 0)
+       refreshscreen (c, r, c2-c+1);
+ #endif
    }
    return 1;
  }
***************
*** 256,261 ****
--- 281,290 ----
    for (col = left; col <= right; col++)
      filler[col-left] = fill;
    dosmemput(filler, (right-left+1)*2, VIDADDR(row, left));
+ #if defined (USE_DOSV)
+   if (ScreenVirtualSegment != 0)
+     refreshscreen (left, row, right-left+1);
+ #endif
  }
  
  void
***************
*** 266,273 ****
--- 295,310 ----
    for (col=0; col < txinfo.winright - txinfo.winleft + 1; col++)
      filler[col] = ' ' | (ScreenAttrib << 8);
    for (row=txinfo.wintop-1; row < txinfo.winbottom; row++)
+ #if defined (USE_DOSV)
+     {
+ #endif
      dosmemput(filler, (txinfo.winright - txinfo.winleft + 1)*2,
       VIDADDR(row, txinfo.winleft - 1));
+ #if defined (USE_DOSV)
+     if (ScreenVirtualSegment != 0)
+       refreshscreen (txinfo.winleft - 1, row, txinfo.winright -
txinfo.winleft + 1);
+     }
+ #endif
    gotoxy(1, 1);
  }
  
***************
*** 304,309 ****
--- 341,350 ----
      bell();
    else {
      ScreenPutChar(c, ScreenAttrib, col, row);
+ #if defined (USE_DOSV)
+     if (ScreenVirtualSegment != 0)
+       refreshscreen (col, row, 1);
+ #endif
      col++;
    }
    
***************
*** 436,441 ****
--- 477,486 ----
      movedata(_dos_ds, VIDADDR(bot-1, left),
  	     _dos_ds, VIDADDR(bot, left),
  	     nbytes);
+ #if defined (USE_DOSV)
+     if (ScreenVirtualSegment != 0)
+       refreshscreen (left, bot-1, nbytes/2);
+ #endif
      bot--;
    }
    fillrow(row,left,right,fill);
***************
*** 457,462 ****
--- 502,511 ----
      movedata(_dos_ds, VIDADDR(row+1, left),
  	     _dos_ds, VIDADDR(row, left),
  	     nbytes);
+ #if defined (USE_DOSV)
+     if (ScreenVirtualSegment != 0)
+       refreshscreen (left, row, nbytes/2);
+ #endif
      row++;
    }
    fillrow(bot,left,right,fill);
***************
*** 485,492 ****
--- 534,551 ----
    const unsigned char *ss = (const unsigned char *)s;
    short *viaddr;
    short sa = ScreenAttrib << 8;
+ #if defined (USE_DOSV)
+   int srow, scol, ecol;
+ #endif
    ScreenGetCursor(&row, &col);
    viaddr = (short *)VIDADDR(row,col);
+ #if defined (USE_DOSV)
+   /*
+    * DOS/V: simply it refreshes screen between scol and ecol when cursor
moving.
+    */
+   srow = row;
+   scol = ecol = col;
+ #endif
    /* 
     * Instead of just calling putch; we do everything by hand here,
     * This is much faster. We don't move the cursor after each character,
***************
*** 501,511 ****
--- 560,588 ----
      {
        row++;
        viaddr += txinfo.screenwidth;
+ #if defined (USE_DOSV)
+       if (ScreenVirtualSegment != 0)
+ 	{
+ 	  if (ecol != scol)
+ 	    refreshscreen (scol, srow, ecol-scol);
+ 	  srow = row;
+ 	  scol = ecol = col;
+ 	}
+ #endif
      }
      else if (c == '\r')
      {
        col = txinfo.winleft - 1;
        viaddr = (short *)VIDADDR(row,col);
+ #if defined (USE_DOSV)
+       if (ScreenVirtualSegment != 0)
+ 	{
+ 	  if (ecol != scol)
+ 	    refreshscreen (scol, srow, ecol-scol);
+ 	  srow = row;
+ 	  scol = ecol = col;
+ 	}
+ #endif
      }
      else if (c == '\b')
      {
***************
*** 525,530 ****
--- 602,616 ----
  	col = txinfo.winright-1;
  	viaddr = (short *)VIDADDR(row,col);
        }
+ #if defined (USE_DOSV)
+       if (ScreenVirtualSegment != 0)
+ 	{
+ 	  if (ecol != scol)
+ 	    refreshscreen (scol, srow, ecol-scol);
+ 	  srow = row;
+ 	  scol = ecol = col;
+ 	}
+ #endif
      }
      else if (c == 0x07)
        bell();
***************
*** 533,538 ****
--- 619,627 ----
        dosmemput(&q, 2, (int)viaddr);
        viaddr++;
        col++;
+ #if defined (USE_DOSV)
+       ecol++;
+ #endif
      }
        
      /* now, readjust the window     */
***************
*** 541,549 ****
--- 630,653 ----
        col = txinfo.winleft - 1;
        row++;
        viaddr = (short *)VIDADDR(row,col);
+ #if defined (USE_DOSV)
+       if (ScreenVirtualSegment != 0)
+ 	{
+ 	  if (ecol != scol)
+ 	    refreshscreen (scol, srow, ecol-scol);
+ 	  srow = row;
+ 	  scol = ecol = col;
+ 	}
+ #endif
      }
        
      if (row >= txinfo.winbottom) {
+ #if defined (USE_DOSV)
+       /* refresh before scroll */
+       if (ScreenVirtualSegment != 0)
+ 	if (ecol != scol)
+ 	  refreshscreen (scol, srow, ecol-scol);
+ #endif
        if (_wscroll)
        {
  	ScreenSetCursor(txinfo.wintop-1,0); /* goto first line in window */
***************
*** 551,559 ****
--- 655,680 ----
        }
        row--;
        viaddr -= txinfo.screenwidth;
+ #if defined (USE_DOSV)
+       if (ScreenVirtualSegment != 0)
+ 	{
+ 	  srow = row;
+ 	  scol = ecol = col;
+ 	}
+ #endif
      }
    }
    
+ #if defined (USE_DOSV)
+   /* refresh the rest of cols */
+   if (ScreenVirtualSegment != 0)
+     {
+       if (ecol != scol)
+ 	refreshscreen (scol, srow, ecol-scol);
+       srow = row;
+       scol = ecol = col;
+     }
+ #endif
    ScreenSetCursor(row, col);
    txinfo.cury = row - txinfo.wintop + 2;
    txinfo.curx = col - txinfo.winleft + 2;
***************
*** 984,989 ****
--- 1105,1124 ----
      ScreenAddress = 0xb0000UL;
    else
      ScreenAddress = 0xb8000UL;
+ 
+ #if defined (USE_DOSV)
+   {
+     __dpmi_regs regs;
+ 
+     regs.x.es = regs.x.di = 0;	/* Dummy for checking */
+     regs.h.ah = 0xfe;	/* Get Video Buffer */
+     __dpmi_int (0x10, &regs);
+     ScreenVirtualSegment = regs.x.es;
+     ScreenVirtualOffset = regs.x.di;
+     if (ScreenVirtualSegment != 0)
+       ScreenAddress = (ScreenVirtualSegment << 4UL) +
ScreenVirtualOffset;
+   }
+ #endif
  
  #if 0
    /* Why should gppconio_init() restore OLDATTRIB?  I think it

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019