annotate code_part1/OSTC_code_asm_part1/dive_icons.asm @ 644:420e62cd88ad

point to correct diluent location
author heinrichsweikamp
date Wed, 03 Oct 2012 13:12:02 +0200
parents 8bda2452a532
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
110
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
1 ;=============================================================================
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
2 ;
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
3 ; File dive_icons.asm
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
4 ;
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
5 ; Draw Air/Nitrox/Trimix colored icon on surface mode.
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
6 ;
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
7 ; This program is free software: you can redistribute it and/or modify
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
8 ; it under the terms of the GNU General Public License as published by
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
9 ; the Free Software Foundation, either version 3 of the License, or
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
10 ; (at your option) any later version.
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
11 ;
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
12 ; This program is distributed in the hope that it will be useful,
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
13 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
14 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
15 ; GNU General Public License for more details.
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
16 ;
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
17 ; You should have received a copy of the GNU General Public License
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
18 ; along with this program. If not, see <http://www.gnu.org/licenses/>.
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
19 ;
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
20 ; Copyright (c) 2010, JD Gascuel.
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
21 ;=============================================================================
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
22 ; HISTORY
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
23 ; 2010-12-21 : [jDG] Creation
121
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
24 ; 2011-01-03 : [jDG] Force first gas to be active from depth=0.
110
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
25 ;
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
26 ; RATIONALS: Enabled gazes are used to predict TTS in divemode, hence they
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
27 ; are a critical aspect that should be double-checked before dive.
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
28 ;
121
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
29 ; Known bug:
110
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
30 ;=============================================================================
123
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 121
diff changeset
31 mixtype_icons code
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 121
diff changeset
32
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 121
diff changeset
33 ;=============================================================================
110
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
34 ; Display either Air, Nitrox, or Trimix icon (in surface mode).
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
35 ; Inputs: None: explore the gaz list.
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
36 ; Ouputs: None.
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
37 ; Trashed: hi:lo, PROD, and registers trashed by color_processor.asm
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
38 dive_type_icons:
121
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
39 ;---- Don't display when not in the right deco mode --------------
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
40 btfsc FLAG_apnoe_mode ; Apnoe selected ?
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
41 return ; YES: just return.
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
42 btfsc gauge_mode ; gauge mode ?
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
43 return ; YES: also return.
644
420e62cd88ad point to correct diluent location
heinrichsweikamp
parents: 145
diff changeset
44 btfsc FLAG_const_ppO2_mode; Not in CC modes
420e62cd88ad point to correct diluent location
heinrichsweikamp
parents: 145
diff changeset
45 return
121
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
46
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
47 ;---- Don't display CF#41 is false -------------------------------
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
48 GETCUSTOM8 d'41' ; Read CF#41
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
49 btfss WREG,0 ; Set ?
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
50 return ; NO: return
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
51
110
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
52 ;---- Common setup -----------------------------------------------
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
53 movlw .170
123
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 121
diff changeset
54 movff WREG, win_top
110
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
55 movlw .110
123
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 121
diff changeset
56 movff WREG, win_leftx2
110
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
57 movlw UPPER(dive_air_block)
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
58 movwf TBLPTRU
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
59
121
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
60 ;---- Explore gas list -------------------------------------------
145
8bda2452a532 FIX bad mix icon when active gas in not G1.
JeanDo
parents: 123
diff changeset
61 ; EEADR <-- 4*gas# + 6
121
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
62 ; EEADR-2 = default O2%
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
63 ; EEADR-1 = default He%
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
64 ; EEADR+0 = current O2%
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
65 ; EEADR+1 = current He%
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
66 ; EEADR+4 = next gaz current O2%
110
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
67
145
8bda2452a532 FIX bad mix icon when active gas in not G1.
JeanDo
parents: 123
diff changeset
68 clrf EEADRH ; read gas flag register --> hi
8bda2452a532 FIX bad mix icon when active gas in not G1.
JeanDo
parents: 123
diff changeset
69 movlw .27
8bda2452a532 FIX bad mix icon when active gas in not G1.
JeanDo
parents: 123
diff changeset
70 movwf EEADR
8bda2452a532 FIX bad mix icon when active gas in not G1.
JeanDo
parents: 123
diff changeset
71 call read_eeprom
110
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
72 movff EEDATA,hi
145
8bda2452a532 FIX bad mix icon when active gas in not G1.
JeanDo
parents: 123
diff changeset
73 rlcf hi,F ; Push a dummy bit.
121
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
74 setf lo ; Start with gas# -1
110
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
75 clrf PRODL ; =0 : no nitrox found yet.
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
76
121
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
77 movlw .33 ; Read first gas #.
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
78 movwf EEADR
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
79 call read_eeprom
145
8bda2452a532 FIX bad mix icon when active gas in not G1.
JeanDo
parents: 123
diff changeset
80 movff EEDATA,PRODH ; first --> PRODH (1..5)
8bda2452a532 FIX bad mix icon when active gas in not G1.
JeanDo
parents: 123
diff changeset
81
8bda2452a532 FIX bad mix icon when active gas in not G1.
JeanDo
parents: 123
diff changeset
82 dive_type_loop:
8bda2452a532 FIX bad mix icon when active gas in not G1.
JeanDo
parents: 123
diff changeset
83 incf lo,F ; Next gaz number. Range 0..4
8bda2452a532 FIX bad mix icon when active gas in not G1.
JeanDo
parents: 123
diff changeset
84
8bda2452a532 FIX bad mix icon when active gas in not G1.
JeanDo
parents: 123
diff changeset
85 rrcf hi,F ; Rotate BEFORE checking active gas!
8bda2452a532 FIX bad mix icon when active gas in not G1.
JeanDo
parents: 123
diff changeset
86
121
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
87 incf lo,W ; Current gas# 1..5
145
8bda2452a532 FIX bad mix icon when active gas in not G1.
JeanDo
parents: 123
diff changeset
88 subwf PRODH,W ; == first gas ?
121
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
89 bz dive_type_loop_2 ; YES: analyse that gas !
145
8bda2452a532 FIX bad mix icon when active gas in not G1.
JeanDo
parents: 123
diff changeset
90
8bda2452a532 FIX bad mix icon when active gas in not G1.
JeanDo
parents: 123
diff changeset
91 btfss hi,0 ; Is this gas enabled ?
8bda2452a532 FIX bad mix icon when active gas in not G1.
JeanDo
parents: 123
diff changeset
92 bra dive_type_loop_9 ; No: disabled.
121
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
93
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
94 movlw .28 ; Switch depth is at gas#+28
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
95 addwf lo,W
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
96 movwf EEADR ; address in EEPROM.
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
97 call read_eeprom ; Read depth
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
98 clrf WREG
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
99 cpfsgt EEDATA ; is depth > 0 ?
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
100 bra dive_type_loop_9 ; NO: disabled too.
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
101
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
102 dive_type_loop_2:
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
103 rlncf lo,W ; Gas# times 4
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
104 rlncf WREG
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
105 addlw 4+2 ; 6 + 4 * gas#
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
106 movwf EEADR ; address in EEPROM for current O2.
110
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
107 call read_eeprom ; Read O2 %
121
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
108
110
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
109 movlw .21
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
110 cpfseq EEDATA ; O2 == 21% ?
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
111 setf PRODL ; NO: not simple air !
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
112
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
113 incf EEADR ; Read He %
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
114 call read_eeprom
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
115 decf EEADR
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
116 clrf WREG ; H2 == 0% ?
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
117 cpfseq EEDATA
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
118 bra dive_trimix_icon ; No: go for the Tx icon, now.
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
119
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
120 dive_type_loop_9:
121
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
121 movlw 4 ; Already done all gas ? (index 0..4)
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
122 cpfseq lo ; gas# == 4 ?
e0f29e20bd24 Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents: 110
diff changeset
123 bra dive_type_loop ; NO: loop...
110
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
124
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
125 btfsc PRODL,0 ; Did we find a nitrox gaz ?
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
126 bra dive_nitrox_icon ; YES: display nitrox icon.;.
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
127
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
128 ;---- Draw air ---------------------------------------------------
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
129 dive_air_icon:
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
130 movlw HIGH(dive_air_block)
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
131 movwf TBLPTRH
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
132 movlw LOW(dive_air_block)
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
133 movwf TBLPTRL
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
134 bra dive_gaz_99
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
135
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
136 dive_nitrox_icon:
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
137 movlw HIGH(dive_nitrox_block)
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
138 movwf TBLPTRH
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
139 movlw LOW(dive_nitrox_block)
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
140 movwf TBLPTRL
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
141 bra dive_gaz_99
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
142
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
143 dive_trimix_icon:
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
144 movlw HIGH(dive_trimix_block)
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
145 movwf TBLPTRH
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
146 movlw LOW(dive_trimix_block)
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
147 movwf TBLPTRL
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
148
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
149 dive_gaz_99:
123
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 121
diff changeset
150 call color_image
110
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
151 movlb 1 ; Back to bank 1.
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
152 return
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
153
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
154 ;=============================================================================
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
155
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
156 #include dive_air.inc
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
157 #include dive_nitrox.inc
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
158 #include dive_trimix.inc
8aa8acada0fd Display deco-type icon in surface mode.
JeanDo
parents:
diff changeset
159