; v33Ef .. 2nd edition (Peek fix, PECs added)
; Second Edition patch kit for Autostar 497 with PECs for LXD models
; 
; This 3 Jan 2005 patch33f4504.txt patch file contains:

;  Editing of Training Values
; (an EDIT menu item under Setup>Train Drives)
;  Adds 4504/114eq to Known Models (replaces DS-70)(a GEM scope!)
; this also allows DS motors to be used on a GEM mount.
; PEEK ...... adds :EPxxxxx# command, returns 16-bit contents. Decimal args/results.
;
; OPTIONAL patches: (edit this file to invoke or supress)
;  Automatic Satellite Track starting at down-count=zero 
;  CordWrap control 
;  Allow LPI to autoguide in Alt/Az <----
;  Skip time/date/daylight at power-up (disabled by default)
;-----------------------

;  Version number change from 33Ef  to 33f4 (so Initialization shows 33f )

; adjusted to work with Autostar Suite

; rseymour@wolfenet.com 13-Dec-2004

; Here are the Four optional patches:
;   Cord Wrap control, Automatic Satellite Tracking, Alt/Az Autoguide, Skip Time/date

; ADD semicolons (;) in front of the next three ";R" lines to BLOCK permitting of
; Cord Wrap ON/OFF in hard-stopped scopes (ETX90/105/125,LXD55)
; This only -allows- turning Cord Wrap OFF, it does not change its current setting.

R   23302    27  20    cordwrap [ 33ef: 4-a302 23302
R   233e2    26  21      cordwrap [ 33ef:    4-a3e2
R   23306    17  23      chksum   cordwrap [ 33ef 4-a306

; ADD semicolons to the following three "R" lines to -prevent- Automatic
;  Start-of-tracking during a Satellite pass.  
;            Satellite  AutoTrack

R   4d37e  bd      20 (-9d)      AutoTrack  [ 33ef: 9=c37e (4dxxx))
R   4d37f  00      21  (+21)=-7c  AutoTrack  [ 33ef
R   4d381  08   84  (chksum) 7c+8  AutoStart  [ 33ef

; ADD semicolons to BLOCK:  (but why?)
; Allow LPI Autoguiding for Alt/Az as well as polar. Field Rotation issues.
;
R  467bb  1f  20 autoguide alt/az too [(brclr->bra+02) 33: 8-d7bb
R  467bc  00  02    autoguide for alt/az too [33ef 
R  467bd  08  05    autoguide for alt/az too [33ef (chksum)

;
; Skip-date/time/daylight:   v33ef
; **WARNING: This optional patch should not be used with StarGPS 
;   removing semicolons totally skips time/date/daylight
;       prompt at startup.
; R 2bce8   bd  7e   ; jmp to after time/date/daylight  33ef: 5-ace8
; R 2bce9   00  ad    ; jmp   ->8bC6 > ad43
; R 2bcea   40  43   ; (04 97 05)
; R 2bcec   97  26   ; checksum ;

; Except for customizing PEC for various final drive gear tooth-counts,
;  there are NO further "optional" patches in this file.
;  changing any further "R" lines will cause the Updater to refuse to load the file.

; BUT: if you wish to change the PEC timing to match various output
; final drive tooth-counts, scroll down to the =end= of this file,
; and read the instructios.

;=== make no changes below this line ====

; Autostar Menu items added by this patch:
;
;  Training results Display and Edit:

; Under Setup > Telescope > Train Drive 
; are now (scroll up or down from the "Az/RA Train" or "Alt/Dec Train")
;  Edit: > Az/RA Train
;    and
;  Edit: > Alt/Dec Train
; press [enter] to allow direct display and manipulation of the results of training.
;    a power cycle (without using Park Scope) is needed for 
;     the  new values to be fully implemented.
; =======

;  4504/114eq replaces DS-70  (use the DS-60 for -70 if you need to)
;   The upper lower travel limits are 4800/-600 arcmin (+60 deg, - 10 deg)
;   ... values taken from the LXD55 series.  Please inform me if they're
;  too restrictive (too many Check Mount messages) or too loose (hits tripod)
;

;  For installation instructions, see:
;   READMEpatch.txt  which should have come with this kit.
;  the last line of -this- file says "; end of patch 32h4"
;  "Have fun" (tm) -- Dick Seymour   23-Aug-2004

;  there are NO further "optional" patches in this file.
;  changing any further lines will cause the Updater to refuse to load the file.

;  patch region:   33Ef: 9-b55d  

;
R       0004    91      c3       chksum  [33ef
R       0005    ca      19       chksum
R       0006    35      35      ;chksum
;R      0007    07      07 

R       000A    45      66      (E->f) [33Ef] version
R       0142FE  45      66      (33ff) [33Ef] version
R       000b    66      34      (i->4) [33Ef] version 33f4
R       0142Ff  66      34      (33ff) [33Ef] version
;=================================
; automatic menu patches v33ef
R      13D6C    2D    2D     CityDwn to Street
R      13D6D    88    58     CityDwn to Street

R      13D5E    2D    2D     StrtUp to City
R      13D5F    78    68     StrtUp to City

R      13D78    02    02     ZipAddr->Tr Drv msg
R      13D79    EC    D0     ZipAddr->Tr Drv msg
R      13D7A    02    01     Zip->AzTrnMsg(postal)
R      13D7B    F0    8D     Zip->AzTrnMsg(postal)
R      13D7E    2D    2C     Zip(AzEd) up to AltTrn
R      13D7F    88    08     Zip(AzEd) up to AltTrn
R      13D80    2D    2B     ZipMode to TrnDrvs
R      13D81    48    98     ZipMode to TrnDrvs
R      13D85    05    9      action page to Patch page
R      13D86    83    B5     ZipAct adr to Ptch adr
R      13D87    32    5D     ZipAct adr to Ptch adr

R      13C0C    2B    2D     AltTrnDwn to AzEd/Zip
R      13C0D    F8    78     AltTrnDwn to AzEd/Zip

R      13D88    02    02     StateAddr->Tr Drv msg
R      13D89    EC    D0     StateAddr->Tr Dev msg
R      13D8A    02     1     State->AltTrnMsg(DoB)
R      13D8B    EF    8E     State->AltTrnMsg(DoB)
R      13D8C    2D    2B     SteDwn to AzTrn
R      13D8D    78    F8     SteDwn to AzTrn
R      13D8E    2D    2D     SteUp to Zip(AzEd)
R      13D8F    68    78     SteUp to Zip(AzEd)
R      13D90    2D    2B     SteMode to TrnDrvs
R      13D91    48    98     SteMode to TrnDrvs
R      13D95    05    9      action page to Patch page
R      13D96    82    B5     act adr to Patch adr
R      13D97    EB    89     act adr to Patch adr

R      13BFE    2C    2D      AzTrnUp to AltEdit/State
R      13BFF    08    88      AzTrnUp to AltEdit

R      13D7C    2D    2D     Zip(AzEdit)dn->State(AltEdit)
R      13D7D    58    88     Zip(AzEdit)dn->State(AltEdit)


R      A1A83  50  45 ; P->E
R      A1A84  6F  64 ; o->d
R      A1A85  73  69 ; s->i
R      A1A86  74  74 ; t->t
R      A1A87  61  20 ; a-> 
R      A1A88  6C  41 ; l->A
R      A1A89  2F  7A ; /->z
R      A1A8A  5A  20 ; Z-> 
R      A1A8B  69  54 ; i->T
R      A1A8C  70  72 ; p->r
R      A1A8D  20  61 ;  ->a
R      A1A8E  43  69 ; C->i
R      A1A8F  6F  6E ; o->n
R      A1A90  64  3A ; d->:
R      A1A91  65  20 ; e-> 
R      A1A93  44  45 ; D->E
R      A1A94  61  64 ; a->d
R      A1A95  74  69 ; t->i
R      A1A96  65  74 ; e->t
R      A1A97  20  20 ;  -> 
R      A1A98  6F  41 ; o->A
R      A1A99  66  6C ; f->l
R      A1A9A  20  74 ;  ->t
R      A1A9B  42  20 ; B-> 
R      A1A9C  69  54 ; i->T
R      A1A9D  72  72 ; r->r
R      A1A9E  74  6E ; t->n
R      A1A9F  68  3A ; h->:

R      A2012  72  34 ; r->4
R      A2013  65  35 ; e->5
R      A2014  61  30 ; a->0
R      A2015  6B  34 ; k->4
R      A2016  6D  2F ; m->/
R      A2017  61  31 ; a->1
R      A2018  73  31 ; s->1
R      A2019  6B  34 ; k->4
R      A201A  20  65 ;  ->e
R      A201B  5B  71 ; [->q

;=======================================
; Az: 8-b55d Alt: 8-b589, 8-b is 044xxx 9-b is 04Cxxx
;       [8-b55d]   AZ   Train display [32Ei] x67 bytes [31ee:8-b55d 32Ei: 
R       04c55d  FF      3C      pshx
R       04c55e  FF      BD      jsr
R       04c55f  FF      08      clrscrn [32Ei: 07f5 33Ef: L0840
R       04c560  FF      40      clrscrn [32Ei: 07f5 33Ef: L0840
R       04c561  FF      FC      ldd
R       04c562  FF      B6      azTrain  
R       04c563  FF      0B      azTrain  [b60b
R       04c564  FF      30      tsx
R       04c565  FF      ED      std
R       04c566  FF      00      0.x
R       04c567  FF      CC      ldd
R       04c568  FF      01      msgNum [Postal: 32Ei: 017e 018d
R       04c569  FF      8d      az     [Postal: 32Ei: 017e 018d
R       04c56a  FF      BD      jsr
R       04c56b  FF      00      dispatch
R       04c56c  FF      40      dispatch [32Ei: 0040
R       04c56d  FF      0a      page
R       04c56e  FF      ca      d->msg [[32Ei: a-8113  a-cabc
R       04c56f  FF      bc      d->msg [[32Ei: a-8113]  a-cabc
R       04c570  FF      BD      jsr
R       04c571  FF      08      msg->scrn [32Ei: 0825 0870
R       04c572  FF      70      msg->scrn [32Ei: 0825 0870
R       04c573  FF      C6      lda#01
R       04c574  FF      01      #01
R       04c575  FF      37      pshb
R       04c576  FF      5C      incb
R       04c577  FF      BD      jsr
R       04c578  FF      07      cursor [32Ei: 07a9  07f4
R       04c579  FF      f4      cursor [32Ei: 07a9  07f4
R       04c57a  FF      31      ins
R       04c57b  FF      30      tsx
R       04c57c  FF      8F      xgdx
R       04c57d  FF      BD      jsr
R       04c57e  FF      00      dispatch
R       04c57f  FF      40      dispatch [32Ei: 0040
R       04c580  FF      08      page
R       04c581  FF      93      IntegerInput [33Ef:  8-9396
R       04c582  FF      96      IntegerInput [33Ef:  8-9396
R       04c583  FF      CE      ldx#
R       04c584  FF      B6      azTrain
R       04c585  FF      0B      azTrain [32Ei]
; variation: jump to common exit code. (could branch, jump's easier)
R       04c586  ff    7e   jmp
R       04c587  ff    b5   [30Ed-32: common: b5b2 ]
R       04c588  ff    b2   [30Ed-32: common: b5b2 ]

;              ALT Train display [8-b589]
R       04c589  FF      3C      pshx
R       04c58A  FF      BD      jsr
R       04c58B  FF      08      clrscrn [32Ei: 07f5 33Ef: L0840
R       04c58C  FF      40      clrscrn [32Ei: 07f5 33Ef: L0840
R       04c58D  FF      FC      ldd
R       04c58E  FF      B6      altTrain
R       04c58F  FF      09      altTrain [332Ei
R       04c590  FF      30      tsx
R       04c591  FF      ED      std
R       04c592  FF      00      0,x
R       04c593  FF      CC      ldd#
R       04c594  FF      01      msg:Alt
R       04c595  FF      8e      Alt [32Ei: (DoB)17f  018e
R       04c596  FF      BD      jsr
R       04c597  FF      00      dispatch
R       04c598  FF      40      dispatch [32Ei: 0040
R       04c599  FF      0a      page
R       04c59A  FF      ca      d->msg [[32Ei: a-8113 a-cabc
R       04c59B  FF      bc      msg [[32Ei: a-8113]  a-cabc
R       04c59C  FF      BD      jsr
R       04c59D  FF      08      d->scrn [32Ei: 0825 0870
R       04c59E  FF      70      scr [32Ei: 0825  0870
R       04c59F  FF      C6      ldb#
R       04c5a0  FF      01      #01
R       04c5a1  FF      37      pshb
R       04c5a2  FF      5C      incb
R       04c5a3  FF      BD      jsr
R       04c5a4  FF      07      cursor [32Ei: 07a9  07f4
R       04c5a5  FF      f4      curs  [32Ei: 07a9  07f4
R       04c5a6  FF      31      ins
R       04c5a7  FF      30      tsx
R       04c5a8  FF      8F      xgdx
R       04c5a9  FF      BD      jsr
R       04c5aA  FF      00      dispatch
R       04c5aB  FF      40      dispatch [32Ei: 0040
R       04c5aC  FF      08      page
R       04c5aD  FF      93      IntInput [33Ef:  8-9396
R       04c5aE  FF      96      IntIn [33Ef:  8-9396
R       04c5aF  FF      CE      ldx#
R       04c5b0  FF      B6      altTrain
R       04c5b1  FF      09      altTrain [32Ei]
R       04c5b2  FF      3C      pshx   <-- common  [32Ei: b5b2
R       04c5b3  FF      30      tsx
R       04c5b4  FF      EC      ldd
R       04c5b5  FF      02      2,x
R       04c5b6  FF      BD      jsr
R       04c5b7  FF      04      burnWd
R       04c5b8  FF      d9      burn [32ei: 04d9 33Ef: L04D9
R       04c5b9  FF      38      pulx
R       04c5bA  FF      38      pulx
R       04c5bB  FF      39      rts
; 8-b5bc next free byte
; 4504
; 4504/114eq replacing DS-70  23xxx=4-a000 [32Ei:

R       242ac   01  02   DS-70->4504msg [33ef:4-b2ad 01ac->020c
R       242ad   ac  0c   DS-70->4504msg [32ef:4-b2ad

R       23bf6   02      03     900 FL [33ef:4-abf6/7
R       23bf7   bc      84   [32Ei]
R       23c01   0f      12      4800_max_elev [33ef:4-ac01/2
R       23c02   78      c0   [32Ei]
R       23c0c   fe      fd     -600_min_elev [33ef:4-ac0c/d
R       23c0d   5c      a8   [32Ei]
R       23c15   04      09    3-f05a_branch [33ef:4-ac15/6/7)
R       23c16   a8     B5    3-f05a_branch  [32Ei] 09-b5-bc 
R       23c17   d8     bc    3-f05a_branch  [32Ei: 09-b5-bc

; patch requires x4f bytes  ..from (32Ei)8-b5bc..
R       04c5bc   ff      3c  at   [33Ef:9-b5bc
R       04c5bd   ff      3c   pshx,pshx
R       04c5be   ff      cc   ldd_03ca 4504 ratio  4.562963
R       04c5bf   ff      03
R       04c5c0   ff      CA
R       04c5c1   ff      30   tsx
R       04c5c2   ff      ed   std_2,x
R       04c5c3   ff      02
R       04c5c4   ff      cc   ldd_4092
R       04c5c5   ff      40
R       04c5c6   ff      92
R       04c5c7   ff      ed   std_0,x
R       04c5c8   ff      00
R       04c5c9   ff      bd   dispatch [32ei: 0040
R       04c5ca   ff      00
R       04c5cb   ff      40   [32ei: 0040]
R       04c5cc   ff      0a  setAzratio [33Ef: a-D66E
R       04c5cd   ff      d6   [33Ef: a-D66E
R       04c5ce   ff      6e   [33Ef: a-D66E
R       04c5cf   ff      cc   ldd_0194 4504 ratio=4.562693
R       04c5d0   ff      01
R       04c5d1   ff      94
R       04c5d2   ff      30   tsx
R       04c5d3   ff      ed   std_2,x
R       04c5d4   ff      02
R       04c5d5   ff      cc   ldd_4092
R       04c5d6   ff      40
R       04c5d7   ff      92
R       04c5d8   ff      ed   std_0,x
R       04c5d9   ff      00
R       04c5da   ff      bd   dispatch  ([32ei: 0040
R       04c5db   ff      00   [32ei: 0040
R       04c5dc   ff      40   [32ei: 0040
R       04c5dd   ff      0a   setALTratio [33Ef: a-d6a3
R       04c5de   ff      d6    [33Ef: a-d6a3
R       04c5df   ff      a3    [33Ef: a-d6a3
R       04c5e0   ff      cc   ldd_B73E_(status_bits)[31ee]
R       04c5e1   ff      b7
R       04c5e2   ff      3e
R       04c5e3   ff      30   tsx
R       04c5e4   ff      ed   std_0,x
R       04c5e5   ff      00
R       04c5e6   ff      f6   ldab_B73e [31ee]
R       04c5e7   ff      b7
R       04c5e8   ff      3e
R       04c5e9   ff      ca   orab_x18_(GEM,Polar)
R       04c5ea   ff      18
R       04c5eb   ff      bd   jst_burn_Byte   ([32Ei: 04ed L04ED
R       04c5ec   ff      04   [32Ei: 04ed
R       04c5ed   ff      ed   [32Ei: 04ed
R       04c5ee   ff      cc   ldd_B73d_(more_status)
R       04c5ef   ff      b7
R       04c5f0   ff      3d   [32Ei]
R       04c5f1   ff      30   tsx
R       04c5f2   ff      ed   std_0,x
R       04c5f3   ff      00
R       04c5f4   ff      f6   ldab_b73d [32Ei]
R       04c5f5   ff      b7
R       04c5f6   ff      3d
R       04c5f7   ff      ca    orab_x08_(cord_wrap)
R       04c5f8   ff      08
R       04c5f9   ff      bd   jsr burnByte (32Ei: 04ed L04ED
R       04c5fa   ff      04   [32Ei: 04ed
R       04c5fb   ff      ed   [32Ei: 04ed
R       04c5fc   ff      38   pulx
R       04c5fd   ff      38   pulx
R       04c5fe   ff      39   rts
; end of 4504 patch

; start of PeekPatch
;  at line immediately after "cmpb "R": (33f:8-c975)  (32i:8-8090)
R 45975  26 7e   old: bne +3 ; jmp [33f: 8-ff1c
R 45976  03 ff   new: jmp {patch}  [32Ei: 8-ff1c] 45xxx 8-c
R 45977  7e 1c                     [32Ei: 8-ff1c]

; R 30xxx  ff1c=65308  8-ff=48xxx
R	48F1C	ff	26	bne+3
R	48f1D	ff	3	
R	48f1E	ff	7e	jmp (:ER) 32a:825a 32h:8276 i:825a
R	48f1F	ff	cb  c9 82	  [32:8276  <<return1 (c977)
R	48f20	ff	3f  77  5a	  [32:8276
R	48f21	ff	c1	cmp "P"
R	48f22	ff	50	
R	48f23	ff	27	beq+3
R	48f24	ff	3	
R	48f25	ff	7e	jmp (:E??) [33f:c97a 32i:8095
R	48f26	ff	c9 80	  [<< patch return2
R	48f27	ff	7a  95	  [
R	48f28	ff	30	tsx
R	48f29	ff	ec	ldd 38,x  (buffer)
R	48f2A	ff	38	
R	48f2B	ff	c3	addd 3   (past the EP)
R	48f2C	ff	0	
R	48f2D	ff	3	
R	48f2E	ff	bd	dispatch  [32:0040
R	48f2F	ff	00	 [32:0040
R	48f30	ff	40	 [32:0040
R	48f31	ff	8	   ParseNumericFPString [33f:8-c49e
R	48f32	ff	c4  fb	 [33f:8-c49e
R	48f33	ff	9e  86	 [33f:8-c49e
R	48f34	ff	bd	jsr  Flt->Int32    [32:204B h:200a  :204B
R	48f35	ff	20	  [32:200a  33f:206c
R	48f36	ff	6c  4b	  [32:200a
R	48f37	ff	30	tsx
R	48f38	ff	ee	ldx 2,x
R	48f39	ff	2	
R	48f3A	ff	ec	ldd 0,x
R	48f3B	ff	0	
R	48f3C	ff	30	tsx
R	48f3D	ff	bd	dispatch   Int16->rs32 [32h: 5-b446 b445
R	48f3E	ff	00	 [32:0040
R	48f3F	ff	40	 [32:0040
R	48f40	ff	5	[33f:5-fcb6
R	48f41	ff	fc 	[33f:5-fcb6
R	48f42	ff	b6 	[33f:5-fcb6
R	48f43	ff	7e	jmp dc7d (end of :EQ code)  [32h:826f 8253
R	48f44	ff	cb 82	   [32:826f  33f: cb38
R	48f45	ff	38  53	   [32:826f
;; end of 497 peek patch
	

;  33f:5-b156 cmpb 11; beq xxxx -> jmp 33f:5-b5bc
;  or 4-9df9
R 2c156 c1  7e         33ef finished to here  dick
R 2c157 11  b5
R 2c158 27  bc 

; here: cmpb 11, bne +3, jmp 9225, cmpb 3, beq +3, jmp 9286
-----------------------------
;  the three PEC factors:
R	2C5BC	ff	c1	cmpb 11	(5-b5bc)
R	2C5BD	ff	11		
R	2C5BE	ff	26	bne +3		32eh  32ei
R	2C5BF	ff	03		
R	2C5C0	ff	7e  jmp [33ef: b15d
R	2C5C1	ff	b1		[33ef: b15d
R	2C5C2	ff	5d		[33ef: b15d
R	2C5C3	ff	c1	cmpb 3	(DS-70 scope type)
R	2C5C4	ff	03		
R	2C5C5	ff	27	beq+3	
R	2C5C6	ff	03		
R	2C5C7	ff	7e  jmp [33ef: b223
R	2C5C8	ff	b2		[33ef: b223
R	2C5C9	ff	23	[33ef: b223
; more: load 4504/100 tooth fac2: 64800. (fd20) fac3: 12960. (32a0) fac4: 5		
R	2C5CA	ff	cc	fac2.msw	ldd 0000
R	2C5CB	ff	00		
R	2C5CC	ff	00		
R	2C5CD	ff	fd	std (32i:36cf) (33f:36df
R	2C5CE	ff	36		
R	2C5CF	ff	df		
R	2C5D0	ff	cc	fac2.lsw	ldd fd20
R	2C5D1	ff	fd		
R	2C5D2	ff	20		
R	2C5D3	ff	fd	std (32i:36d1) (33f:36e1
R	2C5D4	ff	36		
R	2C5D5	ff	e1		
R	2C5D6	ff	cc	fac3.msw	ldd 0000
R	2C5D7	ff	00		
R	2C5D8	ff	00		
R	2C5D9	ff	fd	std (32i:36d7) (33f:36e7
R	2C5DA	ff	36		
R	2C5DB	ff	e7		
R	2C5DC	ff	cc	fac3.lsw	ldd 32a0
R	2C5DD	ff	32		
R	2C5DE	ff	a0		
R	2C5DF	ff	fd	std (32i:36d9)(33f:36e9
R	2C5E0	ff	36		
R	2C5E1	ff	e9		
R	2C5E2	ff	cc	fac4.msw	ldd 0000
R	2C5E3	ff	00		
R	2C5E4	ff	00		
R	2C5E5	ff	fd	std (32i:36d3)(33f:36e3
R	2C5E6	ff	36		
R	2C5E7	ff	e3		
R	2C5E8	ff	cc	fac4.lsw	ldd 0005
R	2C5E9	ff	00		
R	2C5EA	ff	05		
R	2C5EB	ff	fd	std (32i:36d5)(33f:36e5
R	2C5EC	ff	36		
R	2C5ED	ff	e5		
R	2C5EE	ff	7e	jmp 928e 92a9 92a8
R	2C5EF	ff	b1		(33f:b1ff
R	2C5F0	ff	ff		(33f:b1ff

------------------------------		
;  4504patchTOO  32i:3-ecb5 33f: 4-9de9  22de9
;   cmpb 1 ; beq ecc9 -> jmp here (4-ffb8) ecb5 ffb8
R	22de9 	c1	7e		
R	22dea 	01	ff		to 4-ffb8 28fb8
R	22deb 	27	b8		

; cmpb 1 ; bne +3; jmp ecc9 ; cmpb 3 ; beq +3; jmp ecb9	
R	28FB8	ff	c1		cmb 01
R	28FB9	ff	01		
R	28FBA	ff	26		bne +3
R	28FBB	ff	03		
R	28FBC	ff	7e	jmp (33f:9dfd  9-ecc5 ecc9
R	28FBD	ff	9d  	<patch return1	
R	28FBE	ff	fd  		
R	28FBF	ff	c1		cmb 03  ds70
R	28FC0	ff	03		
R	28FC1	ff	27		beq +3
R	28FC2	ff	03		
R	28FC3	ff	7e	jmp (33f:9ded  
R	28FC4	ff	9d 		<patch return2
R	28FC5	ff	ed 		
; ((loadtime)) jmp ece5 ;  time: 1402.407422 (44AF 4D0A)	
R	28FC6	ff	cc		ldd 44af
R	28FC7	ff	44		
R	28FC8	ff	af		
R	28FC9	ff	ed		std b2,x
R	28FCA	ff	b2		
R	28FCB	ff	cc		ldd 4d0a
R	28FCC	ff	4d		
R	28FCD	ff	0a		
R	28FCE	ff	7e	jmp (33f:9e19  ece5 ece1 ece5
R	28FCF	ff	9e 		<patch return3
R	28FD0	ff	19 		
; end of 4504/100 tooth PEC patch
--------------------------	
; start of LXD substitute patches
;  replaces LXD PEC insertions  5-b1e2  2c1e2
;  Time Interval is patched directly in-line
;  PEC Factors are patched out-line (here) 5-b4ca 2c4ca
R   2c1e2  5f  7e   clrb, clra, std -> jmp b4ca
R   2c1e3  4f  b4
R   2c1e4  fd  ca
;  values here are for LXD.  Optional patches cause changes
R	2C4CA	ff	cc	fac2.msw	ldd 0000
R	2C4CB	ff	00	fac2.msw	
R	2C4CC	ff	00	fac2.msw	
R	2C4CD	ff	fd	std  (33f:36df
R	2C4CE	ff	36		
R	2C4CF	ff	df		
R	2C4D0	ff	cc	fac2.lsw	ldd 2328
R	2C4D1	ff	23	fac2.lsw	
R	2C4D2	ff	28	fac2.lsw	
R	2C4D3	ff	fd	std  (33f:36e1
R	2C4D4	ff	36		
R	2C4D5	ff	e1		
R	2C4D6	ff	cc	fac3.msw	ldd 0000
R	2C4D7	ff	00		
R	2C4D8	ff	00		
R	2C4D9	ff	fd	std  (33f:36e7
R	2C4DA	ff	36		
R	2C4DB	ff	e7		
R	2C4DC	ff	cc	fac3.lsw	ldd 003c
R	2C4DD	ff	00	fac3.lsw	
R	2C4DE	ff	3c	fac3.lsw	
R	2C4DF	ff	fd	std (33f:36e9
R	2C4E0	ff	36		
R	2C4E1	ff	e9		
R	2C4E2	ff	cc	fac4.msw	ldd 0000
R	2C4E3	ff	00		
R	2C4E4	ff	00		
R	2C4E5	ff	fd	std (33f:36e3
R	2C4E6	ff	36		
R	2C4E7	ff	e3		
R	2C4E8	ff	cc	fac4.lsw	ldd 0001
R	2C4E9	ff	00	fac4.lsw	
R	2C4EA	ff	01	fac4.lsw	
R	2C4EB	ff	fd	std (33f:36e5
R	2C4EC	ff	36		
R	2C4ED	ff	e5		
R	2C4EE	ff	7e	jmp 928e 92a9 92a8
R	2C4EF	ff	b1		(33f:b1ff
R	2C4F0	ff	ff		(33f:b1ff
R	2C4F1	ff	00  chksum
R	2C4F2	ff	00  chksum
R	2C4F3	ff	00  chksum

;  PEC -- the following patches change all LXD models to
;  have customized PEC Training parameters.
;=======================================================
;   100 tooth fac2: 64800. (fd20) fac3: 12960. (32a0) fac4: 5
;   100 tooth  time: 1402.407422 (44AF 4D0A)
;R 22E12  44  44	interval.msw  4-9e12
;R 22E13  73  af
;R 22E17  79  4d	interval.lsw
;R 22E18  38  0a
; fac2 5-b4d1
;R	2C4D1	23  fd	fac2.lsw	
;R	2C4D2	28  20	fac2.lsw	
; fac3 5-b4dd 
;R	2C4DD	00  32	fac3.lsw	
;R	2C4DE	3c  a0	fac3.lsw	
; fac4 5-b4e9
;R	2C4E9	00	fac4.lsw	
;R	2C4EA	01  05	fac4.lsw	
; (1f0)(33e)=14e=ff+4f
;R	2C4F1	00  ff  chksum
;R	2C4F2	00  4f  chksum
; end of 100
;=======================================================
;  130-tooth: fac2: 129600 (1fa40)  fac3: 864 (x0360)  fac4: 13 (x0d)
; 130 tooth interval:  1078.775 ( 4486 d8cd )
; 130 tooth ratio:  2.96593  ( 403D D1CC ) or(C03D D1CC)
;R 22E12  44  44	interval.msw  4-9e12
;R 22E13  73  86
;R 22E17  79  d8	interval.lsw
;R 22E18  38  cd
; fac2 5-b4d1
;R	2C4CC	00	01     fac2.msw
;R	2C4D1	23  fa	fac2.lsw	
;R	2C4D2	28  40	fac2.lsw	
; fac3 5-b4dd 
;R	2C4DD	00  03	fac3.lsw	
;R	2C4DE	3c  60	fac3.lsw	
; fac4 5-b4e9
;R	2C4E9	00  00	fac4.lsw	
;R	2C4EA	01  13	fac4.lsw	
;  (1f0)(420)=230=ff+ff+32
;R	2C4F1	00  ff  chksum
;R	2C4F2	00  ff  chksum
;R	2C4F3	00  32  chksum
; end of 130
;=======================================================
;  180 tooth fac2: 1c20  fac3: 30  fac4: 1  
;  180 tooth Interval: 779.1153 4442 c761
;R 22E12  44 44 	interval.msw  4-9e12
;R 22E13  73 42
;R 22E17  79 c7 	interval.lsw
;R 22E18  38 61
; fac2 5-b4d1
;R	2C4D1	23  1c	fac2.lsw	
;R	2C4D2	28  20	fac2.lsw	
; fac3 5-b4dd 
;R	2C4DD	00  00	fac3.lsw	
;R	2C4DE	3c  30	fac3.lsw	
; fac4 5-b4e9
;R	2C4E9	00  00	fac4.lsw	
;R	2C4EA	01  01	fac4.lsw	
;  (1f0)(21b)=2b
;R	2C4F1	00  2b  chksum
; end of 180
;=======================================================
; 359 tooth fac2: 13c680 fac3: 21c0 fac4: 167 
;   Interval: 390.6428  43c3 5246
;R 22E12  44  43	interval.msw  4-9e12
;R 22E13  73  c3
;R 22E17  79  52	interval.lsw
;R 22E18  38  46
; fac2 5-b4d1
;R	2C4CC	00  13	fac2.msw	
;R	2C4D1	23  c6	fac2.lsw	
;R	2C4D2	28  80	fac2.lsw	
; fac3 5-b4dd 
;R	2C4DD	00  21	fac3.lsw	
;R	2C4DE	3c  c0	fac3.lsw	
; fac4 5-b4e9
;R	2C4E9	00  01	fac4.lsw	
;R	2C4EA	01  67	fac4.lsw	
;   (1f0)(440)=250=ff+ff+52
;R	2C4F1	00  ff chksum
;R	2C4F2	00  ff  chksum
;R	2C4F3	00  52  chksum
; end of 359
;=======================================================
;  360 tooth fac2: 0e10  fac3: 18  fac4: 1  float: 43c2 c761
; 360 interval:  389.5576  43c2 c761
;R 22E12  44 43	interval.msw  4-9e12
;R 22E13  73 c2
;R 22E17  79 c7	interval.lsw
;R 22E18  38 61
; fac2 5-b4d1
;R	2C4D1	23  0e	fac2.lsw	
;R	2C4D2	28  10	fac2.lsw	
; fac3 5-b4dd 
;R	2C4DD	00  00	fac3.lsw	
;R	2C4DE	3c  18	fac3.lsw	
;   (1ef)(263)=74
;R	2C4F1	00  74 chksum
; end of 360
;=======================================================
; end 0f variable gearing section
;
; How to set up PEC for different gearing:
;  Above this note are 5 sections of code between labels
;  stating their tooth-count, and "end of XXX" for that count.
; In order to activate your tooth-count section, remove the
;  semicolons (;) in front of all of the letter "R" lines in your 
; section.   Then apply the patch kit.
; When operating your telescope, select -any- LXD model,
;  enter your Ratios directly into the Setup/Telescope/Ratio
; (both RA and DEC) fields from the keypad, and PEC should
; become operational.
;
;  end of patch 33efPEC