	with	wi=80,ndmp
*
motortime	equ	$1000
*
*	Programmable Timer Module equates (Motorola 6840)
*
ptmwcr3	equ	$fc2f	Write to control register 3
ptmwcr1	equ	$fc2f	Write to control register 1
ptmwcr2	equ	$fc2e	Write to control register 2
ptmwmsbbr	equ	$fc2d	Write to MSB buffer register
ptmwt1L	equ	$fc2c	Write to Timer #1 latches
ptmwt2L	equ	$fc2a	Write to Timer #2 latches
ptmwt3L	equ	$fc28	Write to Timer #3 latches

ptmrsr	equ	$fc2e	Read status register
ptmrt1c	equ	$fc2d	Read Timer #1 Counter
ptmrlsbbr	equ	$fc2c	Read LSB Buffer Register
ptmrt2c	equ	$fc2b	Read Timer #2 Counter
ptmrt3c	equ	$fc29	Read Timer #1 Counter
	org	$100
start	ldaa	#$a2	tx output enable, irq masked, single shot mode, 16 bits
	staa	ptmwcr2	write to control register #2
	ldaa	#$a2	tx output enable, irq masked, single shot mode, 16 bits
	staa	ptmwcr3	write to control register #3
	ldaa	#$a3	select control register #1 for write
	staa	ptmwcr2	...preserving control register 2's contents
	ldaa	#$82	tx output enable, irq masked, continuous mode, 16 bits
	staa	ptmwcr1	write to control register #1
	ldaa	#motortime/256
	ldab	#motortime\256
	staa	ptmwmsbbr	set timer #1 to motor full cycle time
	stab	ptmwt1L
	ldaa	#0	zero the pulse width for left motor
	ldab	#0
	staa	ptmwmsbbr	set timer #2 to zero
	stab	ptmwt2L
	staa	ptmwmsbbr	set pulse width for right motor
	stab	ptmwt3L
kluge
	ldx	#0	initial speed
	stx	speed
klugewait
	ldx	#0
	inx
	bne	*-1
	ldx	speed
	inx
	stx	speed
	ldaa	speed
	ldab	speed+1
	staa	ptmwmsbbr
	stab	ptmwt2L
	bra	klugewait
speed	fdb	0
	jmp	*

	end	start
