Mail Archives: djgpp/1992/06/06/17:38:03
I just found and fixed a couple of bugs in the window scrolling code
in the gppconio.c module in libpc.a. There are a few other changes
which are not bug fixes, but which tidy up the code a little.
The diffs follow...
--------------------
Nigel Stephens
Algorithmics Ltd UUCP: nigel AT algor DOT co DOT uk
3 Drayton Park OLDUUCP:..!mcsun!uknet!algor!nigel
London PHONE: (+44) 71 700 3301
N5 1NU FAX: (+44) 71 700 3400
England
*** gppconio.c Sun Mar 29 21:21:46 1992
--- gppconio.c.new Sat Jun 6 21:34:41 1992
***************
*** 11,16 ****
--- 11,17 ----
* when who what
* -------------------------------------------------------------------
* 10/27/91 J. Alan Eldridge created
+ * 6/ 6/92 Nigel Stephens fixed scrolling and VIDADDR macro
*
*********************************************************************/
***************
*** 24,30 ****
static struct text_info txinfo;
! #define VIDADDR(r,c) (ScreenPrimary + r * txinfo.screenwidth + c)
int puttext(int c, int r, int c2, int r2, void *buf)
{
--- 25,31 ----
static struct text_info txinfo;
! #define VIDADDR(r,c) (ScreenPrimary + (r) * txinfo.screenwidth + (c))
int puttext(int c, int r, int c2, int r2, void *buf)
{
***************
*** 146,172 ****
*VIDADDR(row, col) = fill;
}
! static void scrollwin(int t, int b, int l)
{
int top = txinfo.wintop + t - 1, left = txinfo.winleft - 1,
! bot = txinfo.wintop + b - 1, right = txinfo.winright - 1;
int row, col, nbytes, fill, nlines;
! if (!l)
return;
nbytes = (right - left + 1) * 2;
- nlines = (bot - top + 1) - l;
fill = ' ' | (ScreenAttrib << 8);
if (l > 0) {
! for (row = top; nlines > 0; row++, nlines--)
memcpy(VIDADDR(row, left), VIDADDR(row + l, left), nbytes);
for (; row <= bot; row++)
fillrow(row, left, right, fill);
} else {
for (row = bot; nlines > 0; row--, nlines--)
memcpy(VIDADDR(row, left), VIDADDR(row + l, left), nbytes);
for (; row >= top; row--)
--- 147,174 ----
*VIDADDR(row, col) = fill;
}
! static void scrollwin(int t, int l)
{
int top = txinfo.wintop + t - 1, left = txinfo.winleft - 1,
! bot = txinfo.winbottom - 1, right = txinfo.winright - 1;
int row, col, nbytes, fill, nlines;
! if (l == 0)
return;
nbytes = (right - left + 1) * 2;
fill = ' ' | (ScreenAttrib << 8);
if (l > 0) {
! nlines = (bot - top + 1) - l;
! for (row = top; nlines > 0; row++, nlines--)
memcpy(VIDADDR(row, left), VIDADDR(row + l, left), nbytes);
for (; row <= bot; row++)
fillrow(row, left, right, fill);
} else {
+ nlines = (bot - top + 1) + l;
for (row = bot; nlines > 0; row--, nlines--)
memcpy(VIDADDR(row, left), VIDADDR(row + l, left), nbytes);
for (; row >= top; row--)
***************
*** 176,182 ****
void clrscr(void)
{
! scrollwin(0, txinfo.winbottom - txinfo.wintop, 32000);
}
int putch(int c)
--- 178,184 ----
void clrscr(void)
{
! scrollwin (0, 1000);
}
int putch(int c)
***************
*** 192,205 ****
else if (c == '\r')
col = txinfo.winleft - 1;
else {
! short val = c | (ScreenAttrib << 8);
!
! puttext(col + 1, row + 1, col + 1, row + 1, &val);
col++;
}
/* now, readjust the window */
-
if (col >= txinfo.winright) {
col = txinfo.winleft - 1;
row++;
--- 194,204 ----
else if (c == '\r')
col = txinfo.winleft - 1;
else {
! *VIDADDR(row,col) = c | (ScreenAttrib << 8);
col++;
}
/* now, readjust the window */
if (col >= txinfo.winright) {
col = txinfo.winleft - 1;
row++;
***************
*** 206,212 ****
}
if (row >= txinfo.winbottom) {
! scrollwin(0, txinfo.winbottom - txinfo.wintop, 1);
row--;
}
--- 205,211 ----
}
if (row >= txinfo.winbottom) {
! scrollwin(0, 1);
row--;
}
***************
*** 226,237 ****
void delline(void)
{
! scrollwin(wherey() - 1, txinfo.winbottom - txinfo.wintop, 1);
}
void insline(void)
{
! scrollwin(wherey() - 1, txinfo.winbottom - txinfo.wintop, -1);
}
void window(int left, int top, int right, int bottom)
--- 225,236 ----
void delline(void)
{
! scrollwin(wherey() - 1, 1);
}
void insline(void)
{
! scrollwin(wherey() - 1, -1);
}
void window(int left, int top, int right, int bottom)
- Raw text -