aboutsummaryrefslogtreecommitdiff
path: root/sys/gio/cursor/gtrdelete.x
blob: 97f418a0f77bdd30529fa93978b163af19873a89 (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
40
41
42
43
44
45
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

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

# GTR_DELETE -- Delete an instruction from the frame buffer.  This prevents
# the instruction from being executed if the frame is redrawn.

procedure gtr_delete (tr, gki)

pointer	tr			#I giotr descriptor
pointer	gki			#I instruction to be deleted

pointer	inext
int	nwords, shift, ilen

begin
	ilen = Mems[gki+GKI_HDR_LENGTH-1]
	inext = gki + ilen

	if (inext >= TR_OP(tr)) {
	    # Instruction is the last one in the buffer.
	    TR_OP(tr) = gki
	    TR_LASTOP(tr) = TR_OP(tr)
	    if (TR_IP(tr) >= gki)
		TR_IP(tr) = gki

	} else {
	    # If the instruction is small and would be expensive to delete
	    # just change the opcode to disable it, otherwise shift the
	    # buffer contents back to overwrite the deleted instruction.

	    nwords = TR_OP(tr) - inext
	    if (ilen < 32 && nwords > 2048)
		Mems[gki+GKI_HDR_OPCODE-1] = GKI_UNKNOWN
	    else {
		call amovs (Mems[inext], Mems[gki], nwords)
		shift = inext - gki
		TR_IP(tr) = TR_IP(tr) - shift
		TR_OP(tr) = TR_OP(tr) - shift
		TR_LASTOP(tr) = TR_OP(tr)
	    }
	}
end