annotate level2/modules/clock2_swatch.asm @ 556:28a203bbd2cc

findstr and signal finished.
author roug
date Tue, 22 Oct 2002 19:09:04 +0000
parents 6641a883d6b0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
1 ********************************************************************
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
2 * Clock2 - Dallas Semiconductor 1216E SmartWatch clock driver
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
3 *
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
4 * $Id$
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
5 *
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
6 * Ed. Comments Who YY/MM/DD
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
7 * ------------------------------------------------------------------
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
8 * 1 Created BGP 98/10/04
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
9
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
10 nam Clock2
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
11 ttl Dallas Semiconductor 1216E SmartWatch clock driver
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
12
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
13 ifp1
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
14 use defsfile
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
15 endc
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
16
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
17 rev set 1
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
18 edition set 1
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
19
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
20 RTC.Base equ $2000 We map the clock into this addr
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
21 RTC.Blok equ $FFA1 Address corresponding to map RTC ROM block into
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
22 RTCMPSlt equ $33 MPI Slot ($00-$33) where RTC is
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
23
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
24 mod CSize,CNam,Systm+Objct,ReEnt+rev,Entry,RTC.Base
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
25
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
26 CNam fcs "Clock2"
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
27 fcb edition edition byte
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
28 SlotSlct fcb RTCMPSlt slot constant for MPI select code
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
29
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
30 Entry bra Init clock hardware initialization
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
31 nop maintain 3 byte entry table spacing
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
32 * bra GetTime get hardware time
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
33 bra ReadSW get hardware time
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
34 nop save a couple cycles with short branch a
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
35 bra SetTime set hardware time
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
36
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
37 * SetTime is not implemented yet
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
38 SetTime clrb
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
39 rts
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
40
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
41 GetTime ldb <D.Sec get seconds
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
42 incb
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
43 cmpb #60
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
44 beq ReadSW if zero, get SmartWatch time
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
45 stb <D.Sec else update second
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
46 rts
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
47
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
48 Init
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
49 ReadSW pshs d,x,y,u save regs which will be altered
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
50
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
51 ldx #$003E
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
52 ldb #1
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
53 os9 F$MapBlk
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
54 * lbcs exx
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
55
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
56 pshs cc
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
57
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
58 * orcc #IntMasks disable interrupts
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
59 lda MPI.Slct get MPI slot
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
60 ldb <D.HINIT get GIME shadow of $FF90
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
61 pshs d
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
62 lda SlotSlct,pcr
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
63 sta MPI.Slct and select it
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
64 andb #$FC
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
65 stb $FF90 ROM mapping = 16k internal, 16k external
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
66 leay SWKey,pcr
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
67 *ROMRAM sta >$FFDE put CC3 in ROM mode
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
68 * Loop to write 64 bit key to SmartWatch
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
69 MapSW lda $04,u read ROM block (trigger SW)
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
70 LoopTop ldb #8 B = bit counter (8)
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
71 lda ,y+ get byte in key
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
72 beq ReadTime if zero, exit
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
73 BitLoop lsra move bit 0 to Carry
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
74 bcs Write1 if Carry set, write a 1 to SmartWatch
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
75 tst ,u else write 0 to SmartWatch
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
76 bra LoopCntl
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
77 Write1 tst 1,u
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
78 LoopCntl decb dec bit counter
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
79 beq LoopTop if more bits, continue
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
80 bra BitLoop else move to top of loop and get next byte in key
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
81
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
82 * Read Time from SmartWatch
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
83 ReadTime lda #8
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
84 L00CF ldb #8
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
85 pshs d
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
86 L00D3 ldb 4,u
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
87 lsrb
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
88 rora
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
89 dec 1,s dec count (B) on stack
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
90 bne L00D3
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
91
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
92 * Convert BCD to a normal number
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
93 BCD2Dec clrb
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
94 B2DLoop cmpa #$10
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
95 bcs B2DDone
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
96 suba #$10
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
97 addb #$0A
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
98 bra B2DLoop
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
99 B2DDone pshs a
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
100 addb ,s+
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
101
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
102 stb 1,s
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
103 puls a
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
104 deca
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
105 bne L00CF
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
106 * sta >$FFDF
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
107 * Restore original values and unmask interrupts ASAP
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
108 ldx #D.Time
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
109 ldd ,s get year/Month
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
110 std ,x save year/month
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
111 lda 2,s get day
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
112 sta 2,x save day
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
113 ldd 4,s get hour/min
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
114 std 3,x save hour/min
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
115 lda 6,s get seconds
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
116 sta 5,x save seconds
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
117 leas 8,s clean stack
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
118 puls d get DINIT/MPI slot
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
119 sta >MPI.Slct restore org MPI slot
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
120 stb >$FF90 restore org GIME INT0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
121
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
122 puls cc
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
123
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
124 ldb #1
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
125 os9 F$ClrBlk
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
126
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
127 exx
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
128 puls pc,d,x,y,u
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
129
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
130 SWKey fcb %11000101,%00111010,%10100011,%01011100
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
131 fcb %11000101,%00111010,%10100011,%01011100
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
132 fcb $00
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
133
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
134 ifeq 1
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
135
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
136
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
137 * Read SmartWatch time
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
138 * Entry: Y=copy of stack pointer
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
139 ReadSW pshs cc Save interrupt status
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
140 orcc #IntMasks Disable interupts
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
141
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
142 lda >MPI.Slct Get current MPak slot
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
143 ldb <D.HINIT Get current GIME init register
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
144 pshs d Save current MPak slot & GIME init register
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
145 lda #RTCMPSlt Set MPak to slot 4 (both ROM & IRQ select)
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
146 sta >MPI.Slct
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
147 andb #$FC Set GIME to use 16K Internal/16K External ROM
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
148 stb $FF90
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
149 lda <D.TINIT Get task side
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
150 bita #$01 We in task 1? (either GRFDRV or user task)
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
151 bne L0207 Yes, adjust myself for it
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
152 * If we are in system state, map ROM block into block 2 of Task 0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
153 ldb RTC.Blok Get current memory block to swap out
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
154 pshs d Save it
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
155 lda #$3E Get Disk ROM block #
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
156 sta RTC.Blok Swap it in
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
157 bra ROMRAM Go find Smart watch
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
158 * If we are in user state, map ROM block into block 2 of Task 1
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
159 L0207 ldb RTC.Blok+8 Get block # to save
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
160 pshs d Preserve Init1 register & block # currently mapped
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
161 lda #$3E Get Disk ROM block #
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
162 sta RTC.Blok+8 Swap it in
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
163
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
164 * Now, switch to ROM mode and swap Smartwatch in
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
165 ROMRAM clr $FFDE Switch to all ROM mode
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
166 * pshs dp Preserve DP
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
167 * lda #$20 Point DP to ROM/Smartwatch block
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
168 * tfr a,dp
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
169 lbsr MapSW Swap Smarwatch into beginning of ROM block
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
170 ldx #D.Sec Point to system seconds
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
171 lda #8 Get # registers to read
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
172 sta ,-s Save it on stack
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
173 * Read bits from SmartWatch
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
174 ReadSW ldb #8 Get # of bits
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
175 GetBit lda >RTC.Base+4 Get a bit off the smartwatch
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
176 lsra Shift it to carry
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
177 ror ,x Move it location
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
178 decb Done?
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
179 bne GetBit No, keep going
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
180 lda ,s Get register #
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
181 cmpa #$08 Was it the 1/10th second register?
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
182 beq L023D Yes skip it and do it again
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
183 cmpa #$04 Was it day of week register?
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
184 bne L0239 No, go on to next register
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
185 ldb ,x Get the day of week
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
186 stb <D.Daywk Save it
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
187 bra L023D Move to next register
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
188
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
189 L0239 leax -1,x Move time packet pointer back
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
190 bsr BCD2Dec Convert BCD to hex for current register
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
191 L023D dec ,s Done all registers?
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
192 bne ReadSW No, go back
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
193 leas 1,s Purge stack
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
194 * puls dp Get back real DP
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
195 clr $FFDF Swap back to all RAM mode
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
196 puls d Restore block #
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
197 bita #$01 In task 1?
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
198 bne L0251 Yes, save block to task 1
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
199 stb RTC.Blok Save block to task 0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
200 bra L0254 Continue on
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
201 L0251 stb RTC.Blok+8 Save block to task 1
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
202 L0254 puls d Restore MPak slot # & GIME init register
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
203 sta >MPI.Slct Switch MPak back
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
204 stb $FF90 Restore GIME
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
205 puls cc,pc Restore interupts & return
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
206
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
207 * Convert BCD to Hex
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
208 BCD2Dec lda 1,x Get BCD byte
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
209 clrb Clear out destination byte
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
210 L0261 cmpa #16 0-15?
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
211 blo L026B Yes, it's fine
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
212 suba #16 Subtract 16 from BCD byte
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
213 addb #10 Add 10 to destination byte
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
214 bra L0261 keep doing until we are done
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
215 L026B pshs a Push leftover onto stack
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
216 addb ,s+ Add to current destination byte
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
217 stb 1,x Store it back
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
218 rts return
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
219
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
220
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
221
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
222
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
223
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
224
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
225
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
226
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
227
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
228
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
229
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
230
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
231
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
232
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
233
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
234
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
235 * Enable SmartWatch
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
236 * Entry: S is a new stack ptr for temporary use. ROM has been mapped into
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
237 * block 2, which will have the Smartwatch mapped into the beginning of
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
238 * it after we send out the 'map in Smartwatch' 64 bit sequence
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
239 * Y=original stack pointer, DO NOT MODIFY!
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
240 * DP must be $20, for direct page addressing
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
241 *
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
242 * 6809 optomization: Preserve DP on the stack, and then set it for $20
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
243 * Use for $2000/$2001 ops in direct page mode, saving 50+ cycles
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
244 * (especially considering interrupts are disabled this whole time!)
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
245 * NOTE: all accesses to smartwatch except the init pattern have to be
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
246 * READS ONLY, not writes
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
247 * 6309: do above, and use LDE instead of TST, as well as F as the counter
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
248 * instead of the stack
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
249 *
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
250
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
251 SWBits fcb %11000101,%00111010,%10100011,%01011100
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
252 fcb %11000101,%00111010,%10100011,%01011100
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
253
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
254 MapSW leax SWBits,pc point to coding table
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
255 lda >RTC.Base+4 Reset Smarwatch to expect the map in sequence
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
256 lda #8 byte counter
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
257 sta ,-s onto stack
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
258
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
259 ByteLoop ldb #8 bit counter
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
260 lda ,x+ get code byte
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
261 BitLoop lsra shift LSBit out
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
262 bcs Write1 if a 1 bit, skip ahead
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
263 tst >RTC.Base if 0, test 1st byte of ROM we mapped in
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
264 bra DecLoop
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
265 Write1 tst >RTC.Base+1 if 1 bit, test 2nd byte of ROM we mapped in
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
266 DecLoop decb dec bit counter
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
267 bne BitLoop keep reading alternate signals until byte is done
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
268 dec ,s dec byte counter
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
269 bne ByteLoop keep going until entire 64 bit read pattern done
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
270 puls a,pc restore regs & return
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
271
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
272
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
273
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
274 endc
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
275
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
276 emod
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
277 CSize equ *
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
278 end
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
279
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
280