; DirTimerA.asm
; Copyright Xerox Corporation 1979
; Last modified August 28, 1979  9:21 PM by Taft

.ent InterceptDoDiskCommand, InterceptGetCb, timerItem
.ent RealDoDiskCommand, RealGetCb
.ent Mul32x16, Div32x16, DoubleSubtract

	.srel

InterceptDoDiskCommand: .InterceptDoDiskCommand
InterceptGetCb: .InterceptGetCb
Mul32x16: .Mul32x16
Div32x16: .Div32x16
DoubleSubtract: .DoubleSubtract

	.zrel

timerItem:	0
RealDoDiskCommand:	0
RealGetCb:	0

	.nrel

tiNext = 0
tiTimeH = 1
tiTimeL = 2
tiPage = 3
tiDA = 4
tiAction = 5
tiSN = 6
tiType = 8.


.InterceptDoDiskCommand:
	sta 3 1 2
	sta 0 ac0
	sta 1 ac1
	lda 3 3 2
	add 2 3
	lda 0 4 3
	lda 1 6 3
	lda 3 timerItem
	sta 0 tiDA 3
	sta 1 tiPage 3
	lda 3 3 2
	add 2 3
	lda 0 5 3
	lda 1 7 3
	lda 3 timerItem
	sta 1 tiAction 3
	mov 0 3
	lda 0 0 3
	lda 1 1 3
	lda 3 timerItem
	sta 0 tiSN 3
	sta 1 tiSN+1 3
	rclk
	sta 0 tiTimeH 3
	sta 1 tiTimeL 3
	mkzero 0 0
	sta 0 tiType 3
	lda 3 0 3
	sta 3 timerItem
	lda 0 ac0
	lda 1 ac1
	lda 3 RealDoDiskCommand
	jmp 1 3

.InterceptGetCb:
	sta 3 1 2
	lda 3 1 2
	sta 3 ac3
	lda 3 0 3
	sta 3 nargs
	jsr @RealGetCb
nargs:	 0
	sta 0 ac0
	lda 3 timerItem
	mkone 0 0
	sta 0 tiType 3
	rclk
	sta 0 tiTimeH 3
	sta 1 tiTimeL 3
	lda 3 tiNext 3
	sta 3 timerItem
	lda 0 ac0
	lda 3 ac3
	jmp 1 3

ac0:	.blk 1
ac1:	.blk 1
ac3:	.blk 1

.Mul32x16:
	sta 3 1 2
	sta 0 2 2
	isz 2 2
	mov 2 3
	mov 1 2
	lda 1 @2 3
	mkzero 0 0
	mul
	sta 1 @2 3
	dsz 2 3
	lda 1 @2 3
	mul
	sta 1 @2 3
	mov 3 2
	lda 3 1 2
	jmp 1 3

.Div32x16:
	sta 3 1 2
	mov 2 3
	sta 0 2 3
	mov 1 2
	mkzero 0 0
	lda 1 @2 3
	div
	 #77400
	sta 1 @2 3
	isz 2 3
	lda 1 @2 3
	div
	 #77400
	sta 1 @2 3
	mov 3 2
	lda 3 1 2
	jmp 1 3


.DoubleSubtract:
	sta 3 1 2
	sta 1 2 2
	mov 1 3
	lda 1 1 3
	mov 0 3
	lda 0 1 3
	subz 1 0
	sta 0 1 3
	lda 0 0 3
	lda 1 @2 2
	mov# 0 0 szc
	 sub 1 0 skp
	 adc 1 0
	sta 0 0 3
	lda 3 1 2
	jmp 1 3

	.end