NEW
  AUTO 3,1
*--------------------------------------
UpdateCursor	lda CUR.T
				cmp #CUR.T.WAIT
				bcc SetCursor.RTS
				inc
				inc
				cmp #CUR.T.WAIT+12
				bne SetCursor

				lda #CUR.T.WAIT
*--------------------------------------
* Set X2,Y2,SrcPtr
*--------------------------------------
SetCursor		sta CUR.T

				lda CUR.bVisible
				bpl .1

				jsr HideCursor.I

.1				ldx CUR.T
				lda L.Cursors,x
				sta CB.PTR+S.CB.SrcPtr
				sta ZPPtr1
				lda L.Cursors+1,x
				sta CB.PTR+S.CB.SrcPtr+1
				sta ZPPtr1+1

				ldy #S.BM.W
				lda (ZPPtr1),y
				sta CB.PTR+S.CB.SrcW

				clc
				adc CB.PTR+S.CB.X1
				pha

				iny
				lda (ZPPtr1),y
				sta CB.PTR+S.CB.SrcW+1
				adc CB.PTR+S.CB.X1+1
				tax
				pla
				bne .2

				dex
				
.2				dec				
				sta CB.PTR+S.CB.X2
				stx CB.PTR+S.CB.X2+1
				
				iny 					S.BM.H
				lda (ZPPtr1),y
				sta CB.PTR+S.CB.SrcH
				
				clc
				adc CB.PTR+S.CB.Y1
				pha

				iny
				lda (ZPPtr1),y
				sta CB.PTR+S.CB.SrcH+1
				adc CB.PTR+S.CB.Y1+1
				tax
				pla
				bne .3

				dex
				
.3				dec				
				sta CB.PTR+S.CB.Y2
				stx CB.PTR+S.CB.Y2+1

				lda CUR.bVisible
				bmi ShowCursor.I
	
SetCursor.RTS	rts
*--------------------------------------
* Set DestX,DestY
*--------------------------------------
SetCursorPos	>PULLW ZPPtr1
				lda CUR.bVisible

				bpl .1
				jsr HideCursor.I

.1				ldy #S.POINT-1

.2				lda (ZPPtr1),y
				sta CUR.Pos,y
				dey
				bpl .2

				lda CUR.bVisible
				bmi ShowCursor.I

				clc
				rts
*--------------------------------------
HideCursor		lda CUR.bVisible
				bpl .9
				jsr HideCursor.I
				stz CUR.bVisible

.9				clc
				rts
*--------------------------------------
ShowCursor		lda CUR.bVisible
				bmi .9

				jsr ShowCursor.I
				dec CUR.bVisible
.9				rts
*--------------------------------------
HideCursor.I	lda #S.CB.OP.RESTORE
				bra DrawCursor.I
*--------------------------------------
ShowCursor.I	ldx CUR.T
				lda CUR.Pos+S.POINT.X
				sec
				sbc CUR.HotPoints,x
				sta CB.PTR+S.CB.X1

				lda CUR.Pos+S.POINT.X+1
				sbc #0
				sta CB.PTR+S.CB.X1+1

				lda CUR.Pos+S.POINT.Y
				sec
				sbc CUR.HotPoints+1,x
				sta CB.PTR+S.CB.Y1

				lda CUR.Pos+S.POINT.Y+1
				sbc #0
				sta CB.PTR+S.CB.Y1+1

				lda #S.CB.OP.ORA+S.CB.OP.MASK+S.CB.OP.SAVE
				
DrawCursor.I	sta CB.PTR+S.CB.OP
				
				>LDYA L.WND.Screen
				jsr OBJ.GetInCache

				>LDYA L.CB.PTR
				jsr CLIP.YA
				bcs .8
			
				jsr GFXWrite.CB
.8				clc

				rts
*--------------------------------------
MAN
SAVE usr/src/lib/libgui.s.cur
LOAD usr/src/lib/libgui.s
ASM
