aboutsummaryrefslogtreecommitdiff
path: root/sys/gio/cursor/gtrtrunc.x
blob: 6abda3ba11fd6bff512f06e1b78a8015366adbe2 (plain) (blame)
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
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include	<gio.h>
include	<gki.h>
include	"gtr.h"

# GTR_TRUNCATE -- Truncate the frame buffer, which has grown larger than
# the limit set by the user (or the system default).  This is done by moving
# the metacode data at the end of the buffer (beginning with the word pointed
# to by gki) to the maximum upper limit of the buffer and adjusting the input
# and output pointers accordingly.

procedure gtr_truncate (tr, gki)

pointer	tr			# giotr descriptor
pointer	gki			# pointer to first word to be preserved
pointer	top
int	nwords

begin
	# Find the first instruction preceding the soft upper limit on the
	# size of the buffer.

	top = TR_FRAMEBUF(tr) + TR_MAXLENFRAMEBUF(tr)
	while (Mems[top] != BOI && top > TR_FRAMEBUF(tr))
	    top = top - 1

	# Move the partial instruction likely to be at the end of the buffer
	# to the new "top".  Note that we can only truncate (discard)
	# instructions which have already been executed, hence the partial
	# instruction at the end of the buffer must be preserved.

	if (gki != top) {
	    nwords = TR_OP(tr) - gki
	    call amovs (Mems[gki], Mems[top], nwords)
	    TR_IP(tr) = top
	    TR_OP(tr) = top + nwords
	}
end