Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/dive_icons.asm @ 121:e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
author | JeanDo |
---|---|
date | Sun, 26 Dec 2010 23:49:11 +0100 |
parents | 8aa8acada0fd |
children | 6a94f96e9cea |
rev | line source |
---|---|
110 | 1 ;============================================================================= |
2 ; | |
3 ; File dive_icons.asm | |
4 ; | |
5 ; Draw Air/Nitrox/Trimix colored icon on surface mode. | |
6 ; | |
7 ; This program is free software: you can redistribute it and/or modify | |
8 ; it under the terms of the GNU General Public License as published by | |
9 ; the Free Software Foundation, either version 3 of the License, or | |
10 ; (at your option) any later version. | |
11 ; | |
12 ; This program is distributed in the hope that it will be useful, | |
13 ; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 ; GNU General Public License for more details. | |
16 ; | |
17 ; You should have received a copy of the GNU General Public License | |
18 ; along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 ; | |
20 ; Copyright (c) 2010, JD Gascuel. | |
21 ;============================================================================= | |
22 ; HISTORY | |
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 | 25 ; |
26 ; RATIONALS: Enabled gazes are used to predict TTS in divemode, hence they | |
27 ; are a critical aspect that should be double-checked before dive. | |
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 | 30 ;============================================================================= |
31 ; Display either Air, Nitrox, or Trimix icon (in surface mode). | |
32 ; Inputs: None: explore the gaz list. | |
33 ; Ouputs: None. | |
34 ; Trashed: hi:lo, PROD, and registers trashed by color_processor.asm | |
35 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
|
36 ;---- 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
|
37 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
|
38 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
|
39 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
|
40 return ; YES: also return. |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
41 |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
42 ;---- 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
|
43 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
|
44 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
|
45 return ; NO: return |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
46 |
110 | 47 ;---- Common setup ----------------------------------------------- |
48 movlw .170 | |
49 movff WREG, img_top | |
50 movlw .110 | |
51 movff WREG, img_left | |
52 movlw UPPER(dive_air_block) | |
53 movwf TBLPTRU | |
54 | |
121
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
55 ;---- Explore gas list ------------------------------------------- |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
56 ; EEADR <-- gas# + 6 |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
57 ; 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
|
58 ; 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
|
59 ; 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
|
60 ; 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
|
61 ; EEADR+4 = next gaz current O2% |
110 | 62 |
63 read_int_eeprom d'27' ; read gas flag register --> hi | |
64 movff EEDATA,hi | |
121
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
65 rrcf hi ; Dummy shift first... why does it works ? |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
66 setf lo ; Start with gas# -1 |
110 | 67 clrf PRODL ; =0 : no nitrox found yet. |
68 | |
69 dive_type_loop: | |
121
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
70 incf lo,F ; Next gaz number. |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
71 |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
72 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
|
73 movwf EEADR |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
74 call read_eeprom |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
75 incf lo,W ; Current gas# 1..5 |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
76 subwf EEDATA,W ; == first ? |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
77 bz dive_type_loop_2 ; YES: analyse that gas ! |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
78 |
110 | 79 rrcf hi ; Check next enabled flag ? |
80 bnc dive_type_loop_9 ; Disabled. | |
121
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
81 |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
82 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
|
83 addwf lo,W |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
84 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
|
85 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
|
86 clrf WREG |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
87 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
|
88 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
|
89 |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
90 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
|
91 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
|
92 rlncf WREG |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
110
diff
changeset
|
93 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
|
94 movwf EEADR ; address in EEPROM for current O2. |
110 | 95 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
|
96 |
110 | 97 movlw .21 |
98 cpfseq EEDATA ; O2 == 21% ? | |
99 setf PRODL ; NO: not simple air ! | |
100 | |
101 incf EEADR ; Read He % | |
102 call read_eeprom | |
103 decf EEADR | |
104 clrf WREG ; H2 == 0% ? | |
105 cpfseq EEDATA | |
106 bra dive_trimix_icon ; No: go for the Tx icon, now. | |
107 | |
108 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
|
109 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
|
110 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
|
111 bra dive_type_loop ; NO: loop... |
110 | 112 |
113 btfsc PRODL,0 ; Did we find a nitrox gaz ? | |
114 bra dive_nitrox_icon ; YES: display nitrox icon.;. | |
115 | |
116 ;---- Draw air --------------------------------------------------- | |
117 dive_air_icon: | |
118 movlw HIGH(dive_air_block) | |
119 movwf TBLPTRH | |
120 movlw LOW(dive_air_block) | |
121 movwf TBLPTRL | |
122 bra dive_gaz_99 | |
123 | |
124 dive_nitrox_icon: | |
125 movlw HIGH(dive_nitrox_block) | |
126 movwf TBLPTRH | |
127 movlw LOW(dive_nitrox_block) | |
128 movwf TBLPTRL | |
129 bra dive_gaz_99 | |
130 | |
131 dive_trimix_icon: | |
132 movlw HIGH(dive_trimix_block) | |
133 movwf TBLPTRH | |
134 movlw LOW(dive_trimix_block) | |
135 movwf TBLPTRL | |
136 | |
137 dive_gaz_99: | |
138 rcall color_image | |
139 movlb 1 ; Back to bank 1. | |
140 return | |
141 | |
142 ;============================================================================= | |
143 | |
144 #include dive_air.inc | |
145 #include dive_nitrox.inc | |
146 #include dive_trimix.inc | |
147 |