summaryrefslogtreecommitdiff
path: root/sys/arch/amiga/dev/ite_rt.c
blob: f4ba9cebb94a29ad246d0262a5105a41f7859df7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
/*	$OpenBSD: ite_rt.c,v 1.2 1996/05/02 06:44:14 niklas Exp $	*/
/*	$NetBSD: ite_rt.c,v 1.16 1996/04/23 22:53:12 veego Exp $	*/

/*
 * Copyright (c) 1993 Markus Wild
 * Copyright (c) 1993 Lutz Vieweg
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *      This product includes software developed by Lutz Vieweg.
 * 4. The name of the author may not be used to endorse or promote products
 *    derived from this software without specific prior written permission
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
#include "grfrt.h"
#if NGRFRT > 0

#include <sys/param.h>
#include <sys/conf.h>
#include <sys/proc.h>
#include <sys/device.h>
#include <sys/ioctl.h>
#include <sys/tty.h>
#include <sys/systm.h>
#include <dev/cons.h>
#include <machine/cpu.h>
#include <amiga/amiga/device.h>
#include <amiga/dev/itevar.h>
#include <amiga/dev/grfioctl.h>
#include <amiga/dev/grfvar.h>
#include <amiga/dev/grf_rtreg.h>

int retina_console = 1;

void retina_cursor __P((struct ite_softc *,int));
void retina_scroll __P((struct ite_softc *,int,int,int,int));
void retina_deinit __P((struct ite_softc *));
void retina_clear __P((struct ite_softc *,int,int,int,int));
void retina_putc __P((struct ite_softc *,int,int,int,int));
void retina_init __P((struct ite_softc *));

#ifdef RETINA_SPEED_HACK
static void screen_up __P((struct ite_softc *, int, int, int));
static void screen_down __P((struct ite_softc *, int, int, int));
#endif

/*
 * this function is called from grf_rt to init the grf_softc->g_conpri
 * field each time a retina is attached.
 */
int
grfrt_cnprobe()
{
	static int done;
	int rv;

	if (retina_console && done == 0)
		rv = CN_INTERNAL;
	else
		rv = CN_NORMAL;
	done = 1;
	return(rv);
}

/* 
 * init the required fields in the grf_softc struct for a
 * grf to function as an ite.
 */
void
grfrt_iteinit(gp)
	struct grf_softc *gp;
{
	gp->g_iteinit = retina_init;
	gp->g_itedeinit = retina_deinit;
	gp->g_iteclear = retina_clear;
	gp->g_iteputc = retina_putc;
	gp->g_itescroll = retina_scroll;
	gp->g_itecursor = retina_cursor;
}


void
retina_init(ip)
	struct ite_softc *ip;
{
	struct MonDef *md;

	ip->priv = ip->grf->g_data;
	md = (struct MonDef *) ip->priv;
 
	ip->cols = md->TX;
	ip->rows = md->TY;
}


void
retina_cursor(ip, flag)
	struct ite_softc *ip;
	int flag;
{
      volatile caddr_t ba = ip->grf->g_regkva;
      
      if (flag == ERASE_CURSOR)
        {
	  /* disable cursor */
          WCrt (ba, CRT_ID_CURSOR_START, RCrt (ba, CRT_ID_CURSOR_START) | 0x20);
        }
      else
	{
	  int pos = ip->curx + ip->cury * ip->cols;

	  /* make sure to enable cursor */
          WCrt (ba, CRT_ID_CURSOR_START, RCrt (ba, CRT_ID_CURSOR_START) & ~0x20);

	  /* and position it */
	  WCrt (ba, CRT_ID_CURSOR_LOC_HIGH, (u_char) (pos >> 8));
	  WCrt (ba, CRT_ID_CURSOR_LOC_LOW,  (u_char) pos);

	  ip->cursorx = ip->curx;
	  ip->cursory = ip->cury;
	}
}



#ifdef	RETINA_SPEED_HACK
static void
screen_up(ip, top, bottom, lines)
	struct ite_softc *ip;
	int top;
	int bottom;
	int lines;
{	
	volatile caddr_t ba = ip->grf->g_regkva;
	volatile caddr_t fb = ip->grf->g_fbkva;
	const struct MonDef * md = (struct MonDef *) ip->priv;
#ifdef BANKEDDEVPAGER
	int bank;
#endif

	/* do some bounds-checking here.. */
	if (top >= bottom)
	  return;
	  
	if (top + lines >= bottom)
	  {
	    retina_clear (ip, top, 0, bottom - top, ip->cols);
	    return;
	  }


#ifdef BANKEDDEVPAGER
	/* make sure to save/restore active bank (and if it's only
	   for tests of the feature in text-mode..) */
	bank = (RSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO) 
		| (RSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI) << 8));
#endif

	/* the trick here is to use a feature of the NCR chip. It can
	   optimize data access in various read/write modes. One of
	   the modes is able to read/write from/to different zones.

	   Thus, by setting the read-offset to lineN, and the write-offset
	   to line0, we just cause read/write cycles for all characters
	   up to the last line, and have the chip transfer the data. The
	   `addqb' are the cheapest way to cause read/write cycles (DONT
	   use `tas' on the Amiga!), their results are completely ignored
	   by the NCR chip, it just replicates what it just read. */
	
		/* write to primary, read from secondary */
	WSeq (ba, SEQ_ID_EXTENDED_MEM_ENA,
		(RSeq(ba, SEQ_ID_EXTENDED_MEM_ENA) & 0x1f) | 0 ); 
		/* clear extended chain4 mode */
	WSeq (ba, SEQ_ID_EXT_VIDEO_ADDR, RSeq(ba, SEQ_ID_EXT_VIDEO_ADDR) & ~0x02);  
	
		/* set write mode 1, "[...] data in the read latches is written
		   to memory during CPU memory write cycles. [...]" */
	WGfx (ba, GCT_ID_GRAPHICS_MODE,
		(RGfx(ba, GCT_ID_GRAPHICS_MODE) & 0xfc) | 1); 
	
	{
		/* write to line TOP */	
		long toploc = top * (md->TX / 16);
		WSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO, ((unsigned char)toploc)); 
		WSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI, ((unsigned char)(toploc >> 8))); 
	}
	{
		/* read from line TOP + LINES */
		long fromloc = (top+lines) * (md->TX / 16);
		WSeq (ba, SEQ_ID_SEC_HOST_OFF_LO, ((unsigned char)fromloc)) ; 
		WSeq (ba, SEQ_ID_SEC_HOST_OFF_HI, ((unsigned char)(fromloc >> 8))) ; 
	}
	{
		caddr_t p = (caddr_t)fb;
		/* transfer all characters but LINES lines, unroll by 16 */
		short x = (1 + bottom - (top + lines)) * (md->TX / 16) - 1;
		do {
			asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p)); 
			asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p)); 
			asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p)); 
			asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p)); 
			asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p)); 
			asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p)); 
			asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p)); 
			asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p)); 
			asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p)); 
			asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p)); 
			asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p)); 
			asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p)); 
			asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p)); 
			asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p)); 
			asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p)); 
			asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p)); 
		} while (x--);
	}
	
		/* reset to default values */
	WSeq (ba, SEQ_ID_SEC_HOST_OFF_HI, 0); 
	WSeq (ba, SEQ_ID_SEC_HOST_OFF_LO, 0); 
	WSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI, 0); 
	WSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO, 0); 
		/* write mode 0 */
	WGfx (ba, GCT_ID_GRAPHICS_MODE,
		(RGfx(ba, GCT_ID_GRAPHICS_MODE) & 0xfc) | 0);
		/* extended chain4 enable */
	WSeq (ba, SEQ_ID_EXT_VIDEO_ADDR,
		RSeq(ba, SEQ_ID_EXT_VIDEO_ADDR) | 0x02);  
		/* read/write to primary on A0, secondary on B0 */
	WSeq (ba, SEQ_ID_EXTENDED_MEM_ENA,
		(RSeq(ba, SEQ_ID_EXTENDED_MEM_ENA) & 0x1f) | 0x40);


	/* fill the free lines with spaces */

	{  /* feed latches with value */
		unsigned short * f = (unsigned short *) fb;

		f += (1 + bottom - lines) * md->TX * 2;
		*f = 0x2010;
	}

	   /* clear extended chain4 mode */
	WSeq (ba, SEQ_ID_EXT_VIDEO_ADDR, RSeq(ba, SEQ_ID_EXT_VIDEO_ADDR) & ~0x02);  
	   /* set write mode 1, "[...] data in the read latches is written
	      to memory during CPU memory write cycles. [...]" */
	WGfx (ba, GCT_ID_GRAPHICS_MODE, (RGfx(ba, GCT_ID_GRAPHICS_MODE) & 0xfc) | 1); 

	{
		unsigned long * p = (unsigned long *) fb;
		short x = (lines * (md->TX/16)) - 1;
		const unsigned long dummyval = 0;

		p += (1 + bottom - lines) * (md->TX/4);

		do {
			*p++ = dummyval;
			*p++ = dummyval;
			*p++ = dummyval;
			*p++ = dummyval;
		} while (x--);
	}

	   /* write mode 0 */
	WGfx (ba, GCT_ID_GRAPHICS_MODE, (RGfx(ba, GCT_ID_GRAPHICS_MODE) & 0xfc) | 0);
	   /* extended chain4 enable */
	WSeq (ba, SEQ_ID_EXT_VIDEO_ADDR , RSeq(ba, SEQ_ID_EXT_VIDEO_ADDR) | 0x02);  

#ifdef BANKEDDEVPAGER
	/* restore former bank */
	WSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO, (unsigned char) bank);
	bank >>= 8;
	WSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI, (unsigned char) bank);
#endif
};


static void
screen_down(ip, top, bottom, lines)
	struct ite_softc *ip;
	int top;
	int bottom;
	int lines;
{
	volatile caddr_t ba = ip->grf->g_regkva;
	volatile caddr_t fb = ip->grf->g_fbkva;
	const struct MonDef * md = (struct MonDef *) ip->priv;
#ifdef BANKEDDEVPAGER
	int bank;
#endif

	/* do some bounds-checking here.. */
	if (top >= bottom)
	  return;
 
	if (top + lines >= bottom)
	  {
	    retina_clear (ip, top, 0, bottom - top, ip->cols);
	    return;
	  }

#ifdef BANKEDDEVPAGER
	/* make sure to save/restore active bank (and if it's only
	   for tests of the feature in text-mode..) */
	bank = (RSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO) 
		| (RSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI) << 8));
#endif
	/* see screen_up() for explanation of chip-tricks */

		/* write to primary, read from secondary */
	WSeq (ba, SEQ_ID_EXTENDED_MEM_ENA,
		(RSeq(ba, SEQ_ID_EXTENDED_MEM_ENA) & 0x1f) | 0 ); 
		/* clear extended chain4 mode */
	WSeq (ba, SEQ_ID_EXT_VIDEO_ADDR, RSeq(ba, SEQ_ID_EXT_VIDEO_ADDR) & ~0x02);  

		/* set write mode 1, "[...] data in the read latches is written
		   to memory during CPU memory write cycles. [...]" */
	WGfx (ba, GCT_ID_GRAPHICS_MODE, (RGfx(ba, GCT_ID_GRAPHICS_MODE) & 0xfc) | 1); 

	{
		/* write to line TOP + LINES */	
		long toloc = (top + lines) * (md->TX / 16);
		WSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO, ((unsigned char)toloc)); 
		WSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI, ((unsigned char)(toloc >> 8))); 
	}
	{
		/* read from line TOP */
		long fromloc = top * (md->TX / 16);
		WSeq (ba, SEQ_ID_SEC_HOST_OFF_LO, ((unsigned char)fromloc)); 
		WSeq (ba, SEQ_ID_SEC_HOST_OFF_HI, ((unsigned char)(fromloc >> 8))) ; 
	}

	{
		caddr_t p = (caddr_t)fb;
		short x = (1 + bottom - (top + lines)) * (md->TX / 16) - 1;
		p += (1 + bottom - (top + lines)) * md->TX;
		do {
			asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p)); 
			asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p)); 
			asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p)); 
			asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p)); 
			asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p)); 
			asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p)); 
			asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p)); 
			asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p)); 
			asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p)); 
			asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p)); 
			asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p)); 
			asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p)); 
			asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p)); 
			asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p)); 
			asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p)); 
			asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p)); 
		} while (x--);
	}

	WSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI, 0); 
	WSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO, 0); 
	WSeq (ba, SEQ_ID_SEC_HOST_OFF_HI, 0); 
	WSeq (ba, SEQ_ID_SEC_HOST_OFF_LO, 0); 

		/* write mode 0 */
	WGfx (ba, GCT_ID_GRAPHICS_MODE,
		(RGfx(ba, GCT_ID_GRAPHICS_MODE) & 0xfc) | 0);
		/* extended chain4 enable */
	WSeq (ba, SEQ_ID_EXT_VIDEO_ADDR , RSeq(ba, SEQ_ID_EXT_VIDEO_ADDR) | 0x02);  
		/* read/write to primary on A0, secondary on B0 */
	WSeq (ba, SEQ_ID_EXTENDED_MEM_ENA,
		(RSeq(ba, SEQ_ID_EXTENDED_MEM_ENA) & 0x1f) | 0x40 ); 

	/* fill the free lines with spaces */

	{  /* feed latches with value */
		unsigned short * f = (unsigned short *) fb;

		f += top * md->TX * 2;
		*f = 0x2010;
	}

	   /* clear extended chain4 mode */
	WSeq (ba, SEQ_ID_EXT_VIDEO_ADDR, RSeq(ba, SEQ_ID_EXT_VIDEO_ADDR) & ~0x02);  
	   /* set write mode 1, "[...] data in the read latches is written
	      to memory during CPU memory write cycles. [...]" */
	WGfx (ba, GCT_ID_GRAPHICS_MODE, (RGfx(ba, GCT_ID_GRAPHICS_MODE) & 0xfc) | 1); 

	{
		unsigned long * p = (unsigned long *) fb;
		short x = (lines * (md->TX/16)) - 1;
		const unsigned long dummyval = 0;

		p += top * (md->TX/4);

		do {
			*p++ = dummyval;
			*p++ = dummyval;
			*p++ = dummyval;
			*p++ = dummyval;
		} while (x--);
	}

	   /* write mode 0 */
	WGfx (ba, GCT_ID_GRAPHICS_MODE, (RGfx(ba, GCT_ID_GRAPHICS_MODE) & 0xfc) | 0);
	   /* extended chain4 enable */
	WSeq (ba, SEQ_ID_EXT_VIDEO_ADDR , RSeq(ba, SEQ_ID_EXT_VIDEO_ADDR) | 0x02);  

#ifdef BANKEDDEVPAGER
	/* restore former bank */
	WSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO, (unsigned char) bank);
	bank >>= 8;
	WSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI, (unsigned char) bank);
#endif
};
#endif	/* RETINA_SPEED_HACK */


void
retina_deinit(ip)
	struct ite_softc *ip;
{
	ip->flags &= ~ITE_INITED;
}


void
retina_putc(ip, c, dy, dx, mode)
	struct ite_softc *ip;
	int c;
	int dy;
	int dx;
	int mode;
{
	volatile caddr_t fb = ip->grf->g_fbkva;
	register u_char attr;

	attr = (mode & ATTR_INV) ? 0x21 : 0x10;
	if (mode & ATTR_UL)     attr  = 0x01;	/* ???????? */
	if (mode & ATTR_BOLD)   attr |= 0x08;
	if (mode & ATTR_BLINK)	attr |= 0x80;

	fb += 4 * (dy * ip->cols + dx);
	*fb++ = c; *fb = attr;
}


void
retina_clear(ip, sy, sx, h, w)
	struct ite_softc *ip;
	int sy;
	int sx;
	int h;
	int w;
{
	u_short * fb = (u_short *) ip->grf->g_fbkva;
	short x;
	const u_short fillval = 0x2010;

	/* could probably be optimized just like the scrolling functions !! */
	fb += 2 * (sy * ip->cols + sx);
	while (h--)
	  {
	    for (x = 2 * (w - 1); x >= 0; x -= 2)
	      fb[x] = fillval;
	    fb += 2 * ip->cols;
	  }
}


/*
 * RETINA_SPEED_HACK code seems to work on some boards and on others
 * it causes text to smear horizontally
 */
void
retina_scroll(ip, sy, sx, count, dir)
	struct ite_softc *ip;
	int sy;
	int sx;
	int count;
	int dir;
{
	volatile caddr_t ba;
	u_long *fb;

	ba = ip->grf->g_regkva;
	fb = (u_long *)ip->grf->g_fbkva;

	retina_cursor(ip, ERASE_CURSOR);

	if (dir == SCROLL_UP) {
#ifdef	RETINA_SPEED_HACK
		screen_up(ip, sy - count, ip->bottom_margin, count);
#else
		bcopy(fb + sy * ip->cols, fb + (sy - count) * ip->cols,
		    4 * (ip->bottom_margin - sy + 1) * ip->cols);
		retina_clear(ip, ip->bottom_margin + 1 - count, 0, count,
		    ip->cols);
#endif
	} else if (dir == SCROLL_DOWN) {
#ifdef	RETINA_SPEED_HACK
		screen_down(ip, sy, ip->bottom_margin, count);
#else
		bcopy(fb + sy * ip->cols, fb + (sy + count) * ip->cols,
		    4 * (ip->bottom_margin - sy - count + 1) * ip->cols);
		retina_clear(ip, sy, 0, count, ip->cols);
#endif
	} else if (dir == SCROLL_RIGHT) {
		bcopy(fb + sx + sy * ip->cols, fb + sx + sy * ip->cols + count,
		    4 * (ip->cols - (sx + count)));
		retina_clear(ip, sy, sx, 1, count);
	} else {
		bcopy(fb + sx + sy * ip->cols, fb + sx - count + sy * ip->cols,
		    4 * (ip->cols - sx));
		retina_clear(ip, sy, ip->cols - count, 1, count);
	}
#ifndef	RETINA_SPEED_HACK
	retina_cursor(ip, !ERASE_CURSOR);
#endif
}

#endif /* NGRFRT */