;-----------------------------------------
PS2000		EQU	$
		STZ	<WORK0
		RTS
;
PSERC2		EQU	$
		STA	<WORK1
		CMP	#00H
		BEQ	PS2000
		PHX
		PHY
;
		JSR	EPYCHK
		STY	<WORK2
;
		LDA	<WORKE
		BPL	PS00
		EOR	#0FFH
		INC	A
PS00		EQU	$
		STA	<WORKC
;
		JSR	EPXCHK
		STY	<WORK3
;
		LDA	<WORKF
		BPL	PS10
		EOR	#0FFH
		INC	A
PS10		EQU	$
		STA	<WORKD
;
		LDY	#00H
		LDA	<WORKD
		CMP	<WORKC
		BCS	PS20
		INY
		PHA
		LDA	<WORKC
		STA	<WORKD
		PLA
		STA	<WORKC
PS20		EQU	$
		STZ	<WORKB
		STZ	<WORK0
;
		LDX	<WORK1		; Base speed
PS30		EQU	$
		LDA	<WORKB
		CLC
		ADC	<WORKC
		CMP	<WORKD
		BCC	PS40
;
		SBC	<WORKD
		INC	<WORK0
PS40		EQU	$
		STA	<WORKB
		DEX
		BNE	PS30
;
		TYA
		BEQ	PS50
;
		LDA	<WORK0
		PHA
		LDA	<WORK1
		STA	<WORK0
		PLA
		STA	<WORK1
PS50		EQU	$
		LDA	<WORK0
		LDY	<WORK2
		BEQ	PS60
		EOR	#0FFH
 		INC	A
		STA	<WORK0
PS60		EQU	$
		LDA	<WORK1
		LDY	<WORK3
		BEQ	PS70
		EOR	#0FFH
		INC	A
		STA	<WORK1
PS70		EQU	$
		PLY
		PLX
		RTS
;----------------------------
PSERCH		EQU	$
		JSR	PSERC2
;----------------------------
PS80		EQU	$
		LDA	<WORK0
		STA	ENYSPD,X
		LDA	<WORK1
		STA	ENXSPD,X
		RTS
