Mercurial > public > hwos_code
comparison src/ghostwriter.asm @ 604:ca4556fb60b9
bump to 2.99beta, work on 3.00 stable
| author | heinrichsweikamp |
|---|---|
| date | Thu, 22 Nov 2018 19:47:26 +0100 |
| parents | 08a0162d3ca1 |
| children | c40025d8e750 |
comparison
equal
deleted
inserted
replaced
| 603:00b24fb4324d | 604:ca4556fb60b9 |
|---|---|
| 1 ;============================================================================= | 1 ;============================================================================= |
| 2 ; | 2 ; |
| 3 ; File ghostwriter.asm REFACTORED VERSION 2.98 | 3 ; File ghostwriter.asm REFACTORED VERSION V2.99a |
| 4 ; | 4 ; |
| 5 ; Ghostwriter (Log profile recorder) | 5 ; Ghostwriter (Log profile recorder) |
| 6 ; | 6 ; |
| 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. |
| 8 ;============================================================================= | 8 ;============================================================================= |
| 18 #include "isr.inc" | 18 #include "isr.inc" |
| 19 #include "tft_outputs.inc" | 19 #include "tft_outputs.inc" |
| 20 #include "divemode.inc" | 20 #include "divemode.inc" |
| 21 #include "rtc.inc" | 21 #include "rtc.inc" |
| 22 | 22 |
| 23 extern deco_pull_tissues_from_vault | |
| 24 | |
| 23 | 25 |
| 24 ;---- Private local variables ------------------------------------------------- | 26 ;---- Private local variables ------------------------------------------------- |
| 25 | 27 |
| 26 CBLOCK local2 ; max size is 16 Byte !!! | 28 CBLOCK local3 ; max size is 16 Byte !!! |
| 27 divisor_temperature ; divisor used to time the sampling of dive data | 29 divisor_temperature ; divisor used to time the sampling of dive data |
| 28 divisor_deco ; divisor used to time the sampling of dive data | 30 divisor_deco ; divisor used to time the sampling of dive data |
| 29 divisor_gf ; divisor used to time the sampling of dive data | 31 divisor_gf ; divisor used to time the sampling of dive data |
| 30 divisor_ppo2_sensors ; divisor used to time the sampling of dive data | 32 divisor_ppo2_sensors ; divisor used to time the sampling of dive data |
| 31 divisor_decoplan ; divisor used to time the sampling of dive data | 33 divisor_decoplan ; divisor used to time the sampling of dive data |
| 38 ghostwriter CODE | 40 ghostwriter CODE |
| 39 | 41 |
| 40 ;============================================================================= | 42 ;============================================================================= |
| 41 | 43 |
| 42 | 44 |
| 43 global init_recording_params ; Initialize profile recording parameters | 45 global init_recording_params ; initialize profile recording parameters |
| 44 init_recording_params: | 46 init_recording_params: |
| 45 movff samplingrate,samplesecs_value; to avoid EEPROM access in the ISR | 47 movff samplingrate,samplesecs_value; to avoid EEPROM access in the ISR |
| 46 movlw div_temperature | 48 movlw div_temperature |
| 47 movwf divisor_temperature ; load divisors for profile storage | 49 movwf divisor_temperature ; load divisors for profile storage |
| 48 movlw div_deco | 50 movlw div_deco |
| 55 movwf divisor_decoplan | 57 movwf divisor_decoplan |
| 56 movlw div_cns | 58 movlw div_cns |
| 57 movwf divisor_cns | 59 movwf divisor_cns |
| 58 movlw div_tank | 60 movlw div_tank |
| 59 movwf divisor_tank | 61 movwf divisor_tank |
| 60 btfss FLAG_apnoe_mode ; In Apnoe mode? | 62 btfss FLAG_apnoe_mode ; in Apnoe mode? |
| 61 bra init_recording_params_1 ; NO | 63 bra init_recording_params_1 ; NO |
| 62 movlw samplingrate_apnoe ; YES - overwrite some parameters in Apnoe mode | 64 movlw samplingrate_apnoe ; YES - overwrite some parameters in Apnoe mode |
| 63 movwf samplesecs_value ; to avoid EEPROM access in the ISR | 65 movwf samplesecs_value ; to avoid EEPROM access in the ISR |
| 64 init_recording_params_1: | 66 init_recording_params_1: |
| 65 btfsc FLAG_ccr_mode ; in CCR mode? | 67 btfsc FLAG_ccr_mode ; in CCR mode? |
| 66 bra init_recording_params_2 ; YES | 68 bra init_recording_params_2 ; YES |
| 67 btfsc FLAG_pscr_mode ; in pSCR mode? | 69 btfsc FLAG_pscr_mode ; in pSCR mode? |
| 68 bra init_recording_params_2 ; YES | 70 bra init_recording_params_2 ; YES |
| 69 ; in OC Mode, disable ppO2 logging | 71 ; in all modes but CCR and pSCR, disable ppO2 logging |
| 70 movlw .0 | 72 movlw .0 |
| 71 movwf divisor_ppo2_sensors | 73 movwf divisor_ppo2_sensors |
| 72 init_recording_params_2: | 74 init_recording_params_2: |
| 73 return | 75 return |
| 74 | 76 |
| 76 global store_dive_data | 78 global store_dive_data |
| 77 store_dive_data: | 79 store_dive_data: |
| 78 bcf store_sample ; clear flag | 80 bcf store_sample ; clear flag |
| 79 | 81 |
| 80 ifndef __DEBUG | 82 ifndef __DEBUG |
| 81 btfsc simulatormode_active ; Are we in simulator mode? | 83 btfsc simulatormode_active ; are we in simulator mode? |
| 82 return ; Yes, discard everything | 84 return ; YES - discard everything |
| 83 endif | 85 endif |
| 84 | 86 |
| 85 btfsc FLAG_apnoe_mode ; In Apnoe mode? | 87 btfsc FLAG_apnoe_mode ; in Apnoe mode? |
| 86 return ; Yes, discard everything | 88 return ; YES - discard everything |
| 87 | 89 |
| 88 SAFE_2BYTE_COPY rel_pressure, lo | 90 SAFE_2BYTE_COPY rel_pressure, lo |
| 89 movf lo,W ; store depth with every sample | 91 movf lo,W ; store depth with every sample |
| 90 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 92 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 91 movf hi,W | 93 movf hi,W |
| 92 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 94 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 93 | 95 |
| 94 ; First, find out how many bytes will append to this sample.... | 96 ; First, find out how many bytes will be appended to this sample set |
| 95 clrf ProfileFlagByte ; clear number of bytes to append | 97 clrf ProfileFlagByte ; clear number of bytes to append |
| 96 | 98 |
| 97 ; Check Extended informations | 99 ; Check Extended informations |
| 98 decfsz divisor_temperature,W ; Check divisor | 100 decfsz divisor_temperature,W ; check divisor |
| 99 bra check_extended1 | 101 bra check_extended1 |
| 100 movlw infolength_temperature | 102 movlw infolength_temperature |
| 101 addwf ProfileFlagByte,F ; add to ProfileFlagByte | 103 addwf ProfileFlagByte,F ; add to ProfileFlagByte |
| 102 check_extended1: | 104 check_extended1: |
| 103 decfsz divisor_deco,W ; Check divisor | 105 decfsz divisor_deco,W ; check divisor |
| 104 bra check_extended2 | 106 bra check_extended2 |
| 105 movlw infolength_deco | 107 movlw infolength_deco |
| 106 addwf ProfileFlagByte,F ; add to ProfileFlagByte | 108 addwf ProfileFlagByte,F ; add to ProfileFlagByte |
| 107 check_extended2: | 109 check_extended2: |
| 108 decfsz divisor_gf,W ; Check divisor | 110 decfsz divisor_gf,W ; check divisor |
| 109 bra check_extended3 | 111 bra check_extended3 |
| 110 movlw infolength_gf | 112 movlw infolength_gf |
| 111 addwf ProfileFlagByte,F ; add to ProfileFlagByte | 113 addwf ProfileFlagByte,F ; add to ProfileFlagByte |
| 112 check_extended3: | 114 check_extended3: |
| 113 decfsz divisor_ppo2_sensors,W ; Check divisor | 115 decfsz divisor_ppo2_sensors,W ; check divisor |
| 114 bra check_extended4 | 116 bra check_extended4 |
| 115 movlw infolength_ppo2_sensors | 117 movlw infolength_ppo2_sensors |
| 116 addwf ProfileFlagByte,F ; add to ProfileFlagByte | 118 addwf ProfileFlagByte,F ; add to ProfileFlagByte |
| 117 check_extended4: | 119 check_extended4: |
| 118 decfsz divisor_decoplan,W ; Check divisor | 120 decfsz divisor_decoplan,W ; check divisor |
| 119 bra check_extended5 | 121 bra check_extended5 |
| 120 movlw infolength_decoplan | 122 movlw infolength_decoplan |
| 121 addwf ProfileFlagByte,F ; add to ProfileFlagByte | 123 addwf ProfileFlagByte,F ; add to ProfileFlagByte |
| 122 check_extended5: | 124 check_extended5: |
| 123 decfsz divisor_cns,W ; Check divisor | 125 decfsz divisor_cns,W ; check divisor |
| 124 bra check_extended6 | 126 bra check_extended6 |
| 125 movlw infolength_cns | 127 movlw infolength_cns |
| 126 addwf ProfileFlagByte,F ; add to ProfileFlagByte | 128 addwf ProfileFlagByte,F ; add to ProfileFlagByte |
| 127 check_extended6: | 129 check_extended6: |
| 128 decfsz divisor_tank,W ; Check divisor | 130 decfsz divisor_tank,W ; check divisor |
| 129 bra check_extended7 | 131 bra check_extended7 |
| 130 movlw infolength_tank | 132 movlw infolength_tank |
| 131 addwf ProfileFlagByte,F ; add to ProfileFlagByte | 133 addwf ProfileFlagByte,F ; add to ProfileFlagByte |
| 132 check_extended7: | 134 check_extended7: |
| 133 | 135 |
| 134 ; Second, check global event flag | 136 ; Second, check global event flag |
| 135 btfss event_occured ; Check global event flag | 137 btfss event_occured ; check global event flag |
| 136 bra store_dive_data3 ; No Event | 138 bra store_dive_data3 ; no event |
| 137 | 139 |
| 138 incf ProfileFlagByte,F ; add one byte (The EventByte1) | 140 incf ProfileFlagByte,F ; add one byte (the EventByte1) |
| 139 | 141 |
| 140 clrf EventByte1 ; reset EventByte1 | 142 clrf EventByte1 ; reset EventByte1 |
| 141 clrf EventByte2 ; reset EventByte2 | 143 clrf EventByte2 ; reset EventByte2 |
| 142 | 144 |
| 143 movf AlarmType,W ; Type of Alarm Bit 0-3 | 145 movf AlarmType,W ; type of Alarm Bit 0-3 |
| 144 addwf EventByte1,F ; Copy to EventByte1 Bit 0-3 | 146 addwf EventByte1,F ; copy to EventByte1 Bit 0-3 |
| 145 clrf AlarmType ; Reset AlarmType | 147 clrf AlarmType ; reset AlarmType |
| 146 | 148 |
| 147 ; Third, check events and add additional bytes | 149 ; Third, check events and add additional bytes |
| 148 btfss gas6_changed ; Check flag | 150 btfss gas6_changed ; check flag |
| 149 bra check_event2 | 151 bra check_event2 |
| 150 movlw d'2' ; Information length | 152 movlw d'2' ; information length |
| 151 addwf ProfileFlagByte,F ; add to ProfileFlagByte | 153 addwf ProfileFlagByte,F ; add to ProfileFlagByte |
| 152 bsf EventByte1,4 ; Also set Flag in EventByte1! | 154 bsf EventByte1,4 ; also set Flag in EventByte1! |
| 153 check_event2: | 155 check_event2: |
| 154 btfss stored_gas_changed ; Check flag | 156 btfss stored_gas_changed ; check flag |
| 155 bra check_event3 | 157 bra check_event3 |
| 156 movlw d'1' ; Information length | 158 movlw d'1' ; information length |
| 157 addwf ProfileFlagByte,F ; add to ProfileFlagByte | 159 addwf ProfileFlagByte,F ; add to ProfileFlagByte |
| 158 bsf EventByte1,5 ; Also set Flag in EventByte1! | 160 bsf EventByte1,5 ; also set Flag in EventByte1! |
| 159 check_event3: | 161 check_event3: |
| 160 btfss setpoint_changed ; Check flag | 162 btfss setpoint_changed ; check flag |
| 161 bra check_event4 | 163 bra check_event4 |
| 162 movlw d'1' ; Information length | 164 movlw d'1' ; information length |
| 163 addwf ProfileFlagByte,F ; add to ProfileFlagByte | 165 addwf ProfileFlagByte,F ; add to ProfileFlagByte |
| 164 bsf EventByte1,6 ; Also set Flag in EventByte1! | 166 bsf EventByte1,6 ; also set Flag in EventByte1! |
| 165 check_event4: | 167 check_event4: |
| 166 btfss bailoutgas_event ; =1: bailout was selected or a gas change during bailout | 168 btfss bailoutgas_event ; =1: bailout was selected or a gas change during bailout |
| 167 bra check_event5 | 169 bra check_event5 |
| 168 movlw d'2' ; Information length | 170 movlw d'2' ; information length |
| 169 addwf ProfileFlagByte,F ; add to ProfileFlagByte | 171 addwf ProfileFlagByte,F ; add to ProfileFlagByte |
| 170 bsf EventByte2,0 ; set flag in EventByte2! | 172 bsf EventByte2,0 ; set flag in EventByte2! |
| 171 bsf EventByte1,7 ; =1: Another EventByte1 is available | 173 bsf EventByte1,7 ; =1: another EventByte1 is available |
| 172 | 174 |
| 173 check_event5: | 175 check_event5: |
| 174 ; more events? | 176 ; more events? |
| 175 | 177 |
| 176 store_dive_data3: | 178 store_dive_data3: |
| 177 btfsc EventByte1,7 ; =1: Another EventByte1 is available | 179 btfsc EventByte1,7 ; =1: Another EventByte1 is available |
| 178 incf ProfileFlagByte,F ; add one byte (The EventByte2) | 180 incf ProfileFlagByte,F ; add one byte (The EventByte2) |
| 179 | 181 |
| 180 btfsc event_occured ; Check global event flag | 182 btfsc event_occured ; check global event flag |
| 181 bsf ProfileFlagByte,7 ; Set EventByte1 Flag in ProfileFlagByte | 183 bsf ProfileFlagByte,7 ; set EventByte1 flag in ProfileFlagByte |
| 182 | 184 |
| 183 movf ProfileFlagByte,W ; finally, write ProfileFlagByte! | 185 movf ProfileFlagByte,W ; finally, write ProfileFlagByte |
| 184 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 186 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 185 | 187 |
| 186 btfss event_occured ; Check global event flag (again) | 188 btfss event_occured ; check global event flag (again) |
| 187 bra store_dive_data4 ; No Event | 189 bra store_dive_data4 ; no event |
| 188 | 190 |
| 189 ; Store the EventByte(s) + additional bytes now | 191 ; Store the EventByte(s) + additional bytes now |
| 190 movf EventByte1,W | 192 movf EventByte1,W |
| 191 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 193 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 192 | 194 |
| 193 movf EventByte2,W ; Write second event byte... | 195 movf EventByte2,W ; write second event byte... |
| 194 btfsc EventByte1,7 ; =1: Another EventByte1 is available | 196 btfsc EventByte1,7 ; =1: another EventByte1 is available |
| 195 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 197 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 196 | 198 |
| 197 btfss gas6_changed ; Check flag | 199 btfss gas6_changed ; check flag |
| 198 bra store_dive_data3b | 200 bra store_dive_data3b |
| 199 movff char_I_O2_ratio,WREG ; store gas 6 o2 ratio | 201 movff char_I_O2_ratio,WREG ; store gas 6 o2 ratio |
| 200 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 202 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 201 movff char_I_He_ratio,WREG ; store gas 6 He ratio | 203 movff char_I_He_ratio,WREG ; store gas 6 He ratio |
| 202 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 204 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 203 bcf gas6_changed ; Clear this event | 205 bcf gas6_changed ; clear this event |
| 204 store_dive_data3b: | 206 store_dive_data3b: |
| 205 btfss stored_gas_changed ; Check flag | 207 btfss stored_gas_changed ; check flag |
| 206 bra store_dive_data3c | 208 bra store_dive_data3c |
| 207 movf active_gas,W ; Store active gas | 209 movf active_dil,W ; store active diluent (default, may be overwritten soon) |
| 208 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 210 btfsc FLAG_oc_mode ; in OC mode? |
| 209 bcf stored_gas_changed ; Clear this event | 211 movf active_gas,W ; YES - store active gas |
| 212 btfsc FLAG_bailout_mode ; in bailout? | |
| 213 movf active_gas,W ; YES - store active OC = bailout gas | |
| 214 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash | |
| 215 bcf stored_gas_changed ; clear this event | |
| 210 store_dive_data3c: | 216 store_dive_data3c: |
| 211 btfss setpoint_changed ; Check flag | 217 btfss setpoint_changed ; check flag |
| 212 bra store_dive_data3d | 218 bra store_dive_data3d |
| 213 movff char_I_const_ppO2,WREG ; store setpoint | 219 movff char_I_const_ppO2,WREG ; store setpoint |
| 214 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 220 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 215 bcf setpoint_changed ; Clear this event | 221 bcf setpoint_changed ; clear this event |
| 216 store_dive_data3d: | 222 store_dive_data3d: |
| 217 btfss bailoutgas_event ; Check flag | 223 btfss bailoutgas_event ; check flag |
| 218 bra store_dive_data4 | 224 bra store_dive_data4 |
| 219 movff char_I_O2_ratio,WREG ; store O2 ratio of bailout gas | 225 movff char_I_O2_ratio,WREG ; store O2 ratio of bailout gas |
| 220 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 226 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 221 movff char_I_He_ratio,WREG ; store He ratio of bailout gas | 227 movff char_I_He_ratio,WREG ; store He ratio of bailout gas |
| 222 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 228 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 223 bcf bailoutgas_event ; Clear this event | 229 bcf bailoutgas_event ; clear this event |
| 224 | 230 |
| 225 store_dive_data4: | 231 store_dive_data4: |
| 226 ; Store extended informations | 232 ; Store extended information |
| 227 decfsz divisor_temperature,F ; Check divisor | 233 decfsz divisor_temperature,F ; check divisor |
| 228 bra store_extended1 | 234 bra store_extended1 |
| 229 rcall store_dive_temperature | 235 rcall store_dive_temperature |
| 230 store_extended1: | 236 store_extended1: |
| 231 decfsz divisor_deco,F ; Check divisor | 237 decfsz divisor_deco,F ; check divisor |
| 232 bra store_extended2 | 238 bra store_extended2 |
| 233 rcall store_dive_decodata | 239 rcall store_dive_decodata |
| 234 store_extended2: | 240 store_extended2: |
| 235 decfsz divisor_gf,F ; Check divisor | 241 decfsz divisor_gf,F ; check divisor |
| 236 bra store_extended3 | 242 bra store_extended3 |
| 237 rcall store_dive_gf | 243 rcall store_dive_gf |
| 238 store_extended3: | 244 store_extended3: |
| 239 decfsz divisor_ppo2_sensors,F ; Check divisor | 245 decfsz divisor_ppo2_sensors,F ; check divisor |
| 240 bra store_extended4 | 246 bra store_extended4 |
| 241 rcall store_dive_ppO2_sensors | 247 rcall store_dive_ppO2_sensors |
| 242 store_extended4: | 248 store_extended4: |
| 243 decfsz divisor_decoplan,F ; Check divisor | 249 decfsz divisor_decoplan,F ; check divisor |
| 244 bra store_extended5 | 250 bra store_extended5 |
| 245 rcall store_dive_decoplan | 251 rcall store_dive_decoplan |
| 246 store_extended5: | 252 store_extended5: |
| 247 decfsz divisor_cns,F ; Check divisor | 253 decfsz divisor_cns,F ; check divisor |
| 248 bra store_extended6 | 254 bra store_extended6 |
| 249 rcall store_dive_cns | 255 rcall store_dive_cns |
| 250 store_extended6: | 256 store_extended6: |
| 251 decfsz divisor_tank,F ; Check divisor | 257 decfsz divisor_tank,F ; check divisor |
| 252 bra store_extended7 | 258 bra store_extended7 |
| 253 rcall store_dive_tank | 259 rcall store_dive_tank |
| 254 store_extended7: | 260 store_extended7: |
| 255 | 261 |
| 256 ; The next block is required to take care of "store never" | 262 ; The next block is required to take care of "store never" |
| 257 btfsc divisor_temperature,7 ; Test highest Bit (Register must have been zero before the "decfsz" command!) | 263 btfsc divisor_temperature,7 ; test highest bit (register must have been zero before the "decfsz" command!) |
| 258 clrf divisor_temperature ; And clear register again, so it will never reach zero... | 264 clrf divisor_temperature ; and clear register again, so it will never reach zero... |
| 259 btfsc divisor_deco,7 | 265 btfsc divisor_deco,7 |
| 260 clrf divisor_deco | 266 clrf divisor_deco |
| 261 btfsc divisor_gf,7 | 267 btfsc divisor_gf,7 |
| 262 clrf divisor_gf | 268 clrf divisor_gf |
| 263 btfsc divisor_ppo2_sensors,7 | 269 btfsc divisor_ppo2_sensors,7 |
| 268 clrf divisor_cns | 274 clrf divisor_cns |
| 269 btfsc divisor_tank,7 | 275 btfsc divisor_tank,7 |
| 270 clrf divisor_tank | 276 clrf divisor_tank |
| 271 | 277 |
| 272 store_dive_data5: | 278 store_dive_data5: |
| 273 bcf event_occured ; Clear the global event flag | 279 bcf event_occured ; clear the global event flag |
| 274 clrf EventByte1 ; reset EventByte1 | 280 clrf EventByte1 ; reset EventByte1 |
| 275 clrf EventByte2 ; reset EventByte2 | 281 clrf EventByte2 ; reset EventByte2 |
| 276 return ; Done. (Sample with all informations written to external flash) | 282 return ; done (sample with all informations written to external flash) |
| 277 | 283 |
| 278 store_dive_cns: | 284 store_dive_cns: |
| 279 movff int_O_CNS_fraction+0,WREG | 285 movff int_O_CNS_fraction+0,WREG |
| 280 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 286 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 281 movff int_O_CNS_fraction+1,WREG | 287 movff int_O_CNS_fraction+1,WREG |
| 282 bcf WREG,int_warning_flag ; clear warning flag | 288 bcf WREG,int_warning_flag ; clear warning flag |
| 283 bcf WREG,int_attention_flag ; clear attention flag | 289 bcf WREG,int_attention_flag ; clear attention flag |
| 284 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 290 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 285 movlw div_cns | 291 movlw div_cns |
| 286 movwf divisor_cns ; Reload divisor from CF | 292 movwf divisor_cns ; reload divisor from CF |
| 287 return | 293 return |
| 288 | 294 |
| 289 store_dive_tank: | 295 store_dive_tank: |
| 296 ; OSTC TR tank pressure logging | |
| 290 movlw div_tank | 297 movlw div_tank |
| 291 movwf divisor_tank ; Reload divisor from CF | 298 movwf divisor_tank ; reload divisor from CF |
| 292 return | 299 return |
| 293 | 300 |
| 294 store_dive_decoplan: | 301 store_dive_decoplan: |
| 295 ; Store the deco plan | 302 ; Store the deco plan |
| 296 lfsr FSR1,char_O_deco_time_for_log+.0 | 303 lfsr FSR1,char_O_deco_time_for_log+.0 |
| 297 movlw .15 | 304 movlw .15 |
| 298 movwf lo | 305 movwf lo |
| 299 store_dive_decoplan_loop: | 306 store_dive_decoplan_loop: |
| 300 movf POSTINC1,W | 307 movf POSTINC1,W |
| 301 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 308 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 302 decfsz lo,F | 309 decfsz lo,F |
| 303 bra store_dive_decoplan_loop | 310 bra store_dive_decoplan_loop |
| 304 movlw div_decoplan | 311 movlw div_decoplan |
| 305 movwf divisor_decoplan ; Reload divisor from CF | 312 movwf divisor_decoplan ; reload divisor from CF |
| 306 return | 313 return |
| 307 | 314 |
| 308 store_dive_ppO2_sensors: | 315 store_dive_ppO2_sensors: |
| 309 movf o2_ppo2_sensor1,W ; Sensor1 ppO2 (in 0.01bar steps) | 316 movf o2_ppo2_sensor1,W ; Sensor1 ppO2 (in 0.01 bar steps) |
| 310 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 317 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 311 SAFE_2BYTE_COPY o2_mv_sensor1,lo ; o2_mv_sensor may be modified via ISR during the two writes here... | 318 SAFE_2BYTE_COPY o2_mv_sensor1,lo ; o2_mv_sensor may be modified via ISR during the two writes here... |
| 312 movf lo,W ; in 0.1mV steps | 319 movf lo,W ; in 0.1 mV steps |
| 313 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 320 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 314 movf hi,W ; in 0.1mV steps | 321 movf hi,W ; in 0.1 mV steps |
| 315 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 322 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 316 | 323 |
| 317 movf o2_ppo2_sensor2,W ; Sensor2 ppO2 (in 0.01bar steps) | 324 movf o2_ppo2_sensor2,W ; Sensor2 ppO2 (in 0.01 bar steps) |
| 318 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 325 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 319 SAFE_2BYTE_COPY o2_mv_sensor2,lo ; o2_mv_sensor may be modified via ISR during the two writes here... | 326 SAFE_2BYTE_COPY o2_mv_sensor2,lo ; o2_mv_sensor may be modified via ISR during the two writes here... |
| 320 movf lo,W ; in 0.1mV steps | 327 movf lo,W ; in 0.1 mV steps |
| 321 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 328 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 322 movf hi,W ; in 0.1mV steps | 329 movf hi,W ; in 0.1 mV steps |
| 323 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 330 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 324 | 331 |
| 325 movf o2_ppo2_sensor3,W ; Sensor3 ppO2 (in 0.01bar steps) | 332 movf o2_ppo2_sensor3,W ; Sensor3 ppO2 (in 0.01 bar steps) |
| 326 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 333 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 327 SAFE_2BYTE_COPY o2_mv_sensor3,lo ; o2_mv_sensor may be modified via ISR during the two writes here... | 334 SAFE_2BYTE_COPY o2_mv_sensor3,lo ; o2_mv_sensor may be modified via ISR during the two writes here... |
| 328 movf lo,W ; in 0.1mV steps | 335 movf lo,W ; in 0.1 mV steps |
| 329 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 336 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 330 movf hi,W ; in 0.1mV steps | 337 movf hi,W ; in 0.1 mV steps |
| 331 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 338 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 332 | 339 |
| 333 movlw div_ppo2_sensors | 340 movlw div_ppo2_sensors |
| 334 movwf divisor_ppo2_sensors ; Reload divisor | 341 movwf divisor_ppo2_sensors ; reload divisor |
| 335 return | 342 return |
| 336 | 343 |
| 337 store_dive_gf: | 344 store_dive_gf: |
| 338 movff int_O_gradient_factor+0,WREG; gradient factor absolute (range is limited to 255, only lower byte used for value) | 345 movff int_O_gradient_factor+0,WREG ; gradient factor absolute (range is limited to 255, only lower byte used for value) |
| 339 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 346 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 340 movlw div_gf | 347 movlw div_gf |
| 341 movwf divisor_gf ; Reload divisor | 348 movwf divisor_gf ; reload divisor |
| 342 return | 349 return |
| 343 | 350 |
| 344 store_dive_decodata: | 351 store_dive_decodata: |
| 345 ; Check if deco stops are necessary | 352 ; Check if deco stops are necessary |
| 346 movff char_O_first_deco_depth,WREG; get ceiling | 353 movff char_O_first_deco_depth,WREG ; get ceiling |
| 347 tstfsz WREG ; ceiling < 0m (aka in deco) ? | 354 tstfsz WREG ; ceiling < 0 m (aka in deco) ? |
| 348 bra store_dive_decodata_deco ; YES | 355 bra store_dive_decodata_deco ; YES |
| 349 ; NO - within NDL | 356 ; NO - within NDL |
| 350 clrf WREG ; =0: no stop dive | 357 clrf WREG ; =0: no stop dive |
| 351 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 358 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 352 movff char_O_nullzeit,WREG ; remaining NDL time | 359 movff char_O_nullzeit,WREG ; remaining NDL time |
| 353 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 360 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 354 bra store_dive_decodata_common | 361 bra store_dive_decodata_common |
| 355 store_dive_decodata_deco: | 362 store_dive_decodata_deco: |
| 356 ; YES - in deco | 363 ; YES - in deco |
| 357 movff char_O_first_deco_depth,WREG; ceiling in m | 364 movff char_O_first_deco_depth,WREG ; ceiling in m |
| 358 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 365 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 359 movff char_O_first_deco_time,WREG ; length of first stop in minutes | 366 movff char_O_first_deco_time,WREG ; length of first stop in minutes |
| 360 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 367 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 361 store_dive_decodata_common: | 368 store_dive_decodata_common: |
| 362 movlw div_deco | 369 movlw div_deco |
| 363 movwf divisor_deco ; Reload divisor | 370 movwf divisor_deco ; Reload divisor |
| 364 return | 371 return |
| 365 | 372 |
| 366 store_dive_temperature: | 373 store_dive_temperature: |
| 367 SAFE_2BYTE_COPY temperature,lo | 374 SAFE_2BYTE_COPY temperature,lo |
| 368 movf lo,W ; append temperature to current sample! | 375 movf lo,W ; append temperature to current sample! |
| 369 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 376 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 370 movf hi,W | 377 movf hi,W |
| 371 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 378 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 372 movlw div_temperature | 379 movlw div_temperature |
| 373 movwf divisor_temperature ; Reload divisor | 380 movwf divisor_temperature ; reload divisor |
| 374 return | 381 return |
| 375 | 382 |
| 376 ghostwrite_byte_header: | 383 ghostwrite_byte_header: |
| 377 goto write_byte_ext_flash_plus_header ; (This call will also delete the 4kB TOC entry first) | 384 goto write_byte_ext_flash_plus_header ; (this call will also delete the 4kB TOC entry first) |
| 378 ; returns... | 385 ; returns... |
| 379 | 386 |
| 380 ghostwrite_byte_profile: | 387 ghostwrite_byte_profile: |
| 381 goto write_byte_ext_flash_plus ; writes byte and increases address with banking at 0x200000 | 388 goto write_byte_ext_flash_plus ; writes byte and increases address with banking at 0x200000 |
| 382 ; returns... | 389 ; returns... |
| 383 | 390 |
| 384 global ghostwriter_end_dive | 391 global ghostwriter_end_dive |
| 385 ghostwriter_end_dive: | 392 ghostwriter_end_dive: |
| 386 movff ext_flash_address+0,ext_flash_log_pointer+0 | 393 movff ext_flash_address+0,ext_flash_log_pointer+0 |
| 387 movff ext_flash_address+1,ext_flash_log_pointer+1 | 394 movff ext_flash_address+1,ext_flash_log_pointer+1 |
| 388 movff ext_flash_address+2,ext_flash_log_pointer+2 ; Save end-of-profile pointer to store in header | 395 movff ext_flash_address+2,ext_flash_log_pointer+2 ; save end-of-profile pointer to store in header |
| 389 | 396 |
| 390 movff menupos3,customview_divemode ; store last custom view | 397 movff menupos3,customview_divemode ; store last custom view |
| 391 | 398 |
| 392 btfss realdive ; dive longer then one minute | 399 btfss realdive ; dive longer then one minute |
| 393 goto ghostwriter_end_dive_common ; No, discard everything | 400 goto ghostwriter_end_dive_common ; NO - discard everything |
| 394 | 401 |
| 395 ; In DEBUG compile, keep all simulated dives in logbook, Desat time, nofly, etc... | 402 ; In DEBUG compile, keep all simulated dives in logbook, Desat time, nofly, etc... |
| 396 ifndef __DEBUG | 403 ifndef __DEBUG |
| 397 btfsc simulatormode_active ; Are we in simulator mode? | 404 btfsc simulatormode_active ; are we in simulator mode? |
| 398 goto ghostwriter_end_dive_common_sim ; Yes, discard everything | 405 goto ghostwriter_end_dive_common_sim ; YES - discard everything |
| 399 endif | 406 endif |
| 400 | 407 |
| 401 btfsc FLAG_apnoe_mode ; In Apnoe mode? | 408 btfsc FLAG_apnoe_mode ; in Apnoe mode? |
| 402 goto ghostwriter_end_dive_common ; Yes, discard everything | 409 goto ghostwriter_end_dive_common ; YES - discard everything |
| 403 | 410 |
| 404 ; Dive finished (and longer then one minute) | 411 ; Dive finished (and longer than one minute) |
| 405 | 412 |
| 406 btfsc FLAG_apnoe_mode ; Calc max. depth (again) for very short apnoe dives | 413 btfsc FLAG_apnoe_mode ; calc max. depth (again) for very short apnoe dives |
| 407 call apnoe_calc_maxdepth | 414 call apnoe_calc_maxdepth |
| 408 | 415 |
| 409 ; calculate desaturation time | 416 ; calculate desaturation time |
| 410 movff last_surfpressure_30min+0,int_I_pres_surface+0 ; Pass surface to desat routine ! | 417 movff last_surfpressure_30min+0,int_I_pres_surface+0 ; pass surface to desat routine ! |
| 411 movff last_surfpressure_30min+1,int_I_pres_surface+1 | 418 movff last_surfpressure_30min+1,int_I_pres_surface+1 |
| 412 | 419 |
| 413 call deco_calc_dive_interval_1min ; calculate deco in surface mode | 420 call deco_calc_dive_interval_1min ; calculate deco in surface mode |
| 414 call deco_calc_desaturation_time ; calculate desaturation time | 421 call deco_calc_desaturation_time ; calculate desaturation time |
| 415 banksel common ; select ram bank 1 | 422 banksel common ; select ram bank 1 |
| 416 | 423 |
| 417 movlw 0xFD ; .... End-of-Profile Bytes | 424 movlw 0xFD ; .... End-of-Profile bytes |
| 418 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 425 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 419 movlw 0xFD | 426 movlw 0xFD |
| 420 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 427 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 421 movff ext_flash_address+0,ext_flash_log_pointer+0 | 428 movff ext_flash_address+0,ext_flash_log_pointer+0 |
| 422 movff ext_flash_address+1,ext_flash_log_pointer+1 | 429 movff ext_flash_address+1,ext_flash_log_pointer+1 |
| 423 movff ext_flash_address+2,ext_flash_log_pointer+2 ; Save end-of-profile pointer to store in header | 430 movff ext_flash_address+2,ext_flash_log_pointer+2 ; save end-of-profile pointer to store in header |
| 424 | 431 |
| 425 ; Set to first address again to store dive length ext_flash_dive_counter:3 | 432 ; Set to first address again to store dive length ext_flash_dive_counter:3 |
| 426 rcall ghostwriter_load_pointer ; Load ext_flash_address:3 from EEPROM .4-.6 | 433 rcall ghostwriter_load_pointer ; load ext_flash_address:3 from EEPROM .4-.6 |
| 427 | 434 |
| 428 incf_ext_flash_address_0x20 d'6' ; Skip internal "0xFA 0xFA #Divenumber:2 0xFA 0xFA" Header | 435 incf_ext_flash_address_0x20 d'6' ; skip internal "0xFA 0xFA #Divenumber:2 0xFA 0xFA" Header |
| 429 ; Store dive length | 436 ; Store dive length |
| 430 movf ext_flash_dive_counter+0,W | 437 movf ext_flash_dive_counter+0,W |
| 431 call write_byte_ext_flash_plus_nodel ; WREG -> Profile in ext. flash (No ext_flash_dive_counter:3 increase) and does NOT delete 4kB page | 438 call write_byte_ext_flash_plus_nodel ; WREG -> profile in ext. flash (No ext_flash_dive_counter:3 increase) and does NOT delete 4kB page |
| 432 movf ext_flash_dive_counter+1,W | 439 movf ext_flash_dive_counter+1,W |
| 433 call write_byte_ext_flash_plus_nodel ; WREG -> Profile in ext. flash (No ext_flash_dive_counter:3 increase) and does NOT delete 4kB page | 440 call write_byte_ext_flash_plus_nodel ; WREG -> profile in ext. flash (No ext_flash_dive_counter:3 increase) and does NOT delete 4kB page |
| 434 movf ext_flash_dive_counter+2,W | 441 movf ext_flash_dive_counter+2,W |
| 435 call write_byte_ext_flash_plus_nodel ; WREG -> Profile in ext. flash (No ext_flash_dive_counter:3 increase) and does NOT delete 4kB page | 442 call write_byte_ext_flash_plus_nodel ; WREG -> profile in ext. flash (No ext_flash_dive_counter:3 increase) and does NOT delete 4kB page |
| 436 | 443 |
| 437 ; profile recording done. | 444 ; profile recording done |
| 438 | 445 |
| 439 ; Load total number of dives | 446 ; Load total number of dives |
| 440 read_int_eeprom .2 | 447 read_int_eeprom .2 |
| 441 movff EEDATA,lo | 448 movff EEDATA,lo |
| 442 read_int_eeprom .3 | 449 read_int_eeprom .3 |
| 469 movf PRODH,W | 476 movf PRODH,W |
| 470 addwfc ext_flash_address+2,F | 477 addwfc ext_flash_address+2,F |
| 471 | 478 |
| 472 ; Now, write header | 479 ; Now, write header |
| 473 | 480 |
| 474 movlw 0xFA ; Header start | 481 movlw 0xFA ; header start |
| 475 rcall ghostwrite_byte_header ; (This call will also delete the 4kB TOC entry first) | 482 rcall ghostwrite_byte_header ; (this call will also delete the 4kB TOC entry first) |
| 476 movlw 0xFA | 483 movlw 0xFA |
| 477 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 484 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 478 | 485 |
| 479 ; store pointer to begin of dive profile | 486 ; store pointer to begin of dive profile |
| 480 read_int_eeprom .4 | 487 read_int_eeprom .4 |
| 481 movf EEDATA,W | 488 movf EEDATA,W |
| 482 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 489 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 483 read_int_eeprom .5 | 490 read_int_eeprom .5 |
| 484 movf EEDATA,W | 491 movf EEDATA,W |
| 485 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 492 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 486 read_int_eeprom .6 | 493 read_int_eeprom .6 |
| 487 movf EEDATA,W | 494 movf EEDATA,W |
| 488 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 495 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 489 | 496 |
| 490 ; store pointer to end of dive profile | 497 ; store pointer to end of dive profile |
| 491 movf ext_flash_log_pointer+0,W | 498 movf ext_flash_log_pointer+0,W |
| 492 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 499 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 493 movf ext_flash_log_pointer+1,W | 500 movf ext_flash_log_pointer+1,W |
| 494 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 501 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 495 movf ext_flash_log_pointer+2,W | 502 movf ext_flash_log_pointer+2,W |
| 496 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 503 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 497 | 504 |
| 498 ; write rest of header | 505 ; write rest of header |
| 499 movlw logbook_profile_version ; Defined in hwos.inc | 506 movlw logbook_profile_version ; defined in hwos.inc |
| 500 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 507 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 501 | 508 |
| 502 ; Store dive length | 509 ; Store dive length |
| 503 movf ext_flash_dive_counter+0,W | 510 movf ext_flash_dive_counter+0,W |
| 504 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 511 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 505 movf ext_flash_dive_counter+1,W | 512 movf ext_flash_dive_counter+1,W |
| 506 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 513 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 507 movf ext_flash_dive_counter+2,W | 514 movf ext_flash_dive_counter+2,W |
| 508 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 515 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 509 | 516 |
| 510 movff start_year,WREG ; Date | 517 lfsr FSR0,start_year ; load base address of start-of-dive data |
| 511 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 518 movf POSTINC0,W ; year |
| 512 movff start_month,WREG | 519 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 513 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 520 movf POSTINC0,W ; month |
| 514 movff start_day,WREG | 521 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 515 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 522 movf POSTINC0,W ; day |
| 516 movff start_hours,WREG ; Start of dive time | 523 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 517 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 524 movf POSTINC0,W ; hour |
| 518 movff start_mins,WREG | 525 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 519 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 526 movf POSTINC0,W ; minute |
| 520 | 527 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 521 btfss FLAG_apnoe_mode ; Store apnoe max or normal max (Which is only max from the last descent) | 528 |
| 522 bra end_dive1 ; Store normal depth | 529 btfss FLAG_apnoe_mode ; store apnoe max or normal max (which is only max from the last descent) |
| 530 bra end_dive1 ; store normal depth | |
| 523 | 531 |
| 524 movff apnoe_max_pressure+0,lo | 532 movff apnoe_max_pressure+0,lo |
| 525 movff apnoe_max_pressure+1,hi | 533 movff apnoe_max_pressure+1,hi |
| 526 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] | 534 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] |
| 527 movff lo,apnoe_max_pressure+0 | 535 movff lo,apnoe_max_pressure+0 |
| 528 movff hi,apnoe_max_pressure+1 | 536 movff hi,apnoe_max_pressure+1 |
| 529 | 537 |
| 530 movf apnoe_max_pressure+0,W ; Max. depth | 538 movf lo,W ; max. depth, low byte |
| 531 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 539 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 532 movf apnoe_max_pressure+1,W | 540 movf hi,W ; max. depth, high byte |
| 533 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 541 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 534 bra end_dive2 ; skip normal max. depth | 542 bra end_dive2 ; skip normal max. depth |
| 535 | 543 |
| 536 end_dive1: | 544 end_dive1: |
| 537 movff max_pressure+0,lo | 545 movff max_pressure+0,lo |
| 538 movff max_pressure+1,hi | 546 movff max_pressure+1,hi |
| 539 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] | 547 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] |
| 540 movff lo,max_pressure+0 | 548 movff lo,max_pressure+0 |
| 541 movff hi,max_pressure+1 | 549 movff hi,max_pressure+1 |
| 542 | 550 |
| 543 movff max_pressure+0,WREG ; Max. depth | 551 movf lo,W ; max. depth, low byte |
| 544 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 552 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 545 movff max_pressure+1,WREG | 553 movf hi,W ; max. depth, high byte |
| 546 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 554 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 547 | 555 |
| 548 end_dive2: | 556 end_dive2: |
| 549 movf divemins+0,W ; dive time minutes | 557 movf divemins+0,W ; dive time minutes |
| 550 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 558 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 551 movf divemins+1,W | 559 movf divemins+1,W |
| 552 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 560 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 553 movf divesecs,W ; dive time seconds | 561 movf divesecs,W ; dive time seconds |
| 554 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 562 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 555 movff minimum_temperature+0,WREG ; minimum temperature | 563 movff minimum_temperature+0,WREG ; minimum temperature |
| 556 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 564 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 557 movff minimum_temperature+1,WREG | 565 movff minimum_temperature+1,WREG |
| 558 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 566 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 559 movff last_surfpressure_30min+0,WREG ; air pressure before dive | 567 movff last_surfpressure_30min+0,WREG ; air pressure before dive |
| 560 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 568 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 561 movff last_surfpressure_30min+1,WREG | 569 movff last_surfpressure_30min+1,WREG |
| 562 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 570 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 563 movff int_O_desaturation_time+0,WREG ; desaturation time in minutes | 571 movff int_O_desaturation_time+0,WREG ; desaturation time in minutes |
| 564 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 572 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 565 movff int_O_desaturation_time+1,WREG | 573 movff int_O_desaturation_time+1,WREG |
| 566 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 574 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 567 | 575 |
| 568 btfss FLAG_ccr_mode ; In CCR mode... | 576 btfsc FLAG_ccr_mode ; in CCR mode? |
| 569 bra end_dive_oc_gaslist ; No, write OC gases | 577 bra end_dive_dil_gaslist ; YES - write diluent gas list |
| 570 ; Write Diluents... | 578 btfsc FLAG_pscr_mode ; in pSCR mode? |
| 571 movff opt_dil_O2_ratio+0,WREG | 579 bra end_dive_dil_gaslist ; YES - write diluent gas list |
| 572 rcall ghostwrite_byte_header ; %O2 | 580 |
| 573 movff opt_dil_He_ratio+0,WREG | 581 end_dive_oc_gaslist: ; write OC gases |
| 574 rcall ghostwrite_byte_header ; %He | 582 lfsr FSR0,opt_gas_O2_ratio-.1 ; set base address to (opt_gas_O2_ratio - 1) because of pre-increment statement |
| 575 movff char_I_dil_change+0,WREG | 583 bra end_dive_gaslist ; write all 5 OC gases |
| 576 rcall ghostwrite_byte_header ; Configured change depth in m | 584 |
| 577 movff opt_dil_type+0,WREG | 585 end_dive_dil_gaslist: ; write diluents |
| 578 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2=Normal | 586 lfsr FSR0,opt_dil_O2_ratio-.1 ; set base address to (opt_dil_O2_ratio - 1) because of pre-increment statement |
| 579 | 587 ;bra end_dive_gaslist ; write all 5 diluents |
| 580 movff opt_dil_O2_ratio+1,WREG | 588 |
| 581 rcall ghostwrite_byte_header ; %O2 | 589 end_dive_gaslist: ; helper function for writing gas list entries |
| 582 movff opt_dil_He_ratio+1,WREG | 590 ; |
| 583 rcall ghostwrite_byte_header ; %He | 591 ; Memory Map: |
| 584 movff char_I_dil_change+1,WREG | 592 ; ------------------------- |
| 585 rcall ghostwrite_byte_header ; Configured change depth in m | 593 ; opt_gas_O2_ratio res 5 |
| 586 movff opt_dil_type+1,WREG | 594 ; opt_dil_O2_ratio res 5 |
| 587 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2=Normal | 595 ; opt_gas_He_ratio res 5 |
| 588 | 596 ; opt_dil_He_ratio res 5 |
| 589 movff opt_dil_O2_ratio+2,WREG | 597 ; opt_gas_type res 5 |
| 590 rcall ghostwrite_byte_header ; %O2 | 598 ; opt_dil_type res 5 |
| 591 movff opt_dil_He_ratio+2,WREG | 599 ; opt_gas_change res 5 |
| 592 rcall ghostwrite_byte_header ; %He | 600 ; opt_dil_change res 5 |
| 593 movff char_I_dil_change+2,WREG | 601 ; |
| 594 rcall ghostwrite_byte_header ; Configured change depth in m | 602 movlw .5 ; 5 gases to store |
| 595 movff opt_dil_type+2,WREG | 603 movwf lo ; use lo as counter |
| 596 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2=Normal | 604 end_dive_gaslist_loop: |
| 597 | 605 movf PREINC0,W ; increment base address and get O2 ratio into WREG |
| 598 movff opt_dil_O2_ratio+3,WREG | 606 rcall ghostwrite_byte_header ; store data |
| 599 rcall ghostwrite_byte_header ; %O2 | 607 movlw .10 ; offset for H2 ratios |
| 600 movff opt_dil_He_ratio+3,WREG | 608 movf PLUSW0,W ; get H2 ratio into WREG |
| 601 rcall ghostwrite_byte_header ; %He | 609 rcall ghostwrite_byte_header ; store data |
| 602 movff char_I_dil_change+3,WREG | 610 movlw .30 ; offset for change depths |
| 603 rcall ghostwrite_byte_header ; Configured change depth in m | 611 movf PLUSW0,W ; get change depth into WREG |
| 604 movff opt_dil_type+3,WREG | 612 rcall ghostwrite_byte_header ; store data |
| 605 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2=Normal | 613 movlw .20 ; offset for types |
| 606 | 614 movf PLUSW0,W ; get type into WREG |
| 607 movff opt_dil_O2_ratio+4,WREG | 615 rcall ghostwrite_byte_header ; store data |
| 608 rcall ghostwrite_byte_header ; %O2 | 616 decfsz lo ; decrement counter, did it became 0 ? |
| 609 movff opt_dil_He_ratio+4,WREG | 617 bra end_dive_gaslist_loop ; NO - loop |
| 610 rcall ghostwrite_byte_header ; %He | 618 ;bra end_dive_oc_cc_common ; YES - done |
| 611 movff char_I_dil_change+4,WREG | |
| 612 rcall ghostwrite_byte_header ; Configured change depth in m | |
| 613 movff opt_dil_type+4,WREG | |
| 614 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2=Normal | |
| 615 bra end_dive_oc_cc_common | |
| 616 | |
| 617 end_dive_oc_gaslist: ; OC Gases... | |
| 618 movff opt_gas_O2_ratio+0,WREG | |
| 619 rcall ghostwrite_byte_header ; %O2 | |
| 620 movff opt_gas_He_ratio+0,WREG | |
| 621 rcall ghostwrite_byte_header ; %He | |
| 622 movff opt_OC_bail_gas_change+0,WREG | |
| 623 rcall ghostwrite_byte_header ; Configured change depth in m | |
| 624 movff opt_gas_type+0,WREG | |
| 625 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2= Travel, 3= Deco | |
| 626 | |
| 627 movff opt_gas_O2_ratio+1,WREG | |
| 628 rcall ghostwrite_byte_header ; %O2 | |
| 629 movff opt_gas_He_ratio+1,WREG | |
| 630 rcall ghostwrite_byte_header ; %He | |
| 631 movff opt_OC_bail_gas_change+1,WREG | |
| 632 rcall ghostwrite_byte_header ; Configured change depth in m | |
| 633 movff opt_gas_type+1,WREG | |
| 634 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2= Travel, 3= Deco | |
| 635 | |
| 636 movff opt_gas_O2_ratio+2,WREG | |
| 637 rcall ghostwrite_byte_header ; %O2 | |
| 638 movff opt_gas_He_ratio+2,WREG | |
| 639 rcall ghostwrite_byte_header ; %He | |
| 640 movff opt_OC_bail_gas_change+2,WREG | |
| 641 rcall ghostwrite_byte_header ; Configured change depth in m | |
| 642 movff opt_gas_type+2,WREG | |
| 643 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2= Travel, 3= Deco | |
| 644 | |
| 645 movff opt_gas_O2_ratio+3,WREG | |
| 646 rcall ghostwrite_byte_header ; %O2 | |
| 647 movff opt_gas_He_ratio+3,WREG | |
| 648 rcall ghostwrite_byte_header ; %He | |
| 649 movff opt_OC_bail_gas_change+3,WREG | |
| 650 rcall ghostwrite_byte_header ; Configured change depth in m | |
| 651 movff opt_gas_type+3,WREG | |
| 652 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2= Travel, 3= Deco | |
| 653 | |
| 654 movff opt_gas_O2_ratio+4,WREG | |
| 655 rcall ghostwrite_byte_header ; %O2 | |
| 656 movff opt_gas_He_ratio+4,WREG | |
| 657 rcall ghostwrite_byte_header ; %He | |
| 658 movff opt_OC_bail_gas_change+4,WREG | |
| 659 rcall ghostwrite_byte_header ; Configured change depth in m | |
| 660 movff opt_gas_type+4,WREG | |
| 661 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2= Travel, 3= Deco | |
| 662 ; bra end_dive_oc_cc_common | |
| 663 | 619 |
| 664 end_dive_oc_cc_common: | 620 end_dive_oc_cc_common: |
| 665 movlw softwareversion_x ; Firmware version | 621 movlw softwareversion_x ; firmware version |
| 666 rcall ghostwrite_byte_header | 622 rcall ghostwrite_byte_header |
| 667 movlw softwareversion_y | 623 movlw softwareversion_y |
| 668 rcall ghostwrite_byte_header | 624 rcall ghostwrite_byte_header |
| 669 movf batt_voltage+0,W ; Battery voltage | 625 movf batt_voltage+0,W ; battery voltage |
| 670 rcall ghostwrite_byte_header | 626 rcall ghostwrite_byte_header |
| 671 movf batt_voltage+1,W | 627 movf batt_voltage+1,W |
| 672 rcall ghostwrite_byte_header | 628 rcall ghostwrite_byte_header |
| 673 | 629 |
| 674 movf samplingrate,W ; Sampling rate | 630 movf samplingrate,W ; Sampling rate |
| 675 btfsc FLAG_apnoe_mode ; Apnoe mode? | 631 btfsc FLAG_apnoe_mode ; Apnoe mode? |
| 676 movlw samplingrate_apnoe ; Apnoe sampling rate | 632 movlw samplingrate_apnoe ; Apnoe sampling rate |
| 677 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 633 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 678 | 634 |
| 679 ; CNS at beginning of dive | 635 ; CNS at beginning of dive |
| 680 movff CNS_start+0,WREG | 636 movff CNS_start+0,WREG |
| 681 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 637 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 682 movff CNS_start+1,WREG | 638 movff CNS_start+1,WREG |
| 683 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 639 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 684 ; Gradient factor | 640 ; Gradient factor |
| 685 movff GF_start,WREG | 641 movff GF_start,WREG |
| 686 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 642 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 687 movff int_O_gradient_factor+0,WREG ; value limited to 255, only lower byte in use | 643 movff int_O_gradient_factor+0,WREG ; value limited to 255, only lower byte in use |
| 688 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 644 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 689 | 645 |
| 690 ; Logbook offset | 646 ; Logbook offset |
| 691 call do_logoffset_common_read ; Read into lo:hi | 647 call do_logoffset_common_read ; Read into lo:hi |
| 692 movf lo,W | 648 movf lo,W |
| 693 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 649 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 694 movf hi,W | 650 movf hi,W |
| 695 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 651 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 696 | 652 |
| 697 ; Battery info at Byte 59 | 653 ; Battery info at Byte 59 |
| 698 movf batt_percent,W ; 0-100 | 654 movf batt_percent,W ; 0-100 |
| 699 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 655 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 700 ; Store 5 Setpoints | 656 |
| 701 movff char_I_setpoint_cbar+0,WREG | 657 ; Store the setpoints |
| 702 rcall ghostwrite_byte_header ; Setpoint in cbar | 658 lfsr FSR0,char_I_setpoint_cbar ; base address of ppO2 values |
| 703 movff char_I_setpoint_change+0,WREG | 659 lfsr FSR1,char_I_setpoint_change ; base address of change depths |
| 704 rcall ghostwrite_byte_header ; Change depth | 660 movlw .5 ; 5 setpoints to store |
| 705 movff char_I_setpoint_cbar+1,WREG | 661 movwf lo ; use lo as counter |
| 706 rcall ghostwrite_byte_header ; Setpoint in cbar | 662 end_dive_sp_loop: |
| 707 movff char_I_setpoint_change+1,WREG | 663 movf POSTINC0,W ; get ppO2 value |
| 708 rcall ghostwrite_byte_header ; Change depth | 664 rcall ghostwrite_byte_header ; store ppO2 value |
| 709 movff char_I_setpoint_cbar+2,WREG | 665 movf POSTINC1,W ; get change depth |
| 710 rcall ghostwrite_byte_header ; Setpoint in cbar | 666 rcall ghostwrite_byte_header ; store change depth |
| 711 movff char_I_setpoint_change+2,WREG | 667 decfsz lo ; decrement counter, did it became 0 ? |
| 712 rcall ghostwrite_byte_header ; Change depth | 668 bra end_dive_sp_loop ; NO - loop |
| 713 movff char_I_setpoint_cbar+3,WREG | 669 |
| 714 rcall ghostwrite_byte_header ; Setpoint in cbar | 670 ; Store further data |
| 715 movff char_I_setpoint_change+3,WREG | 671 movff opt_salinity,WREG ; salinity (0-4%) |
| 716 rcall ghostwrite_byte_header ; Change depth | 672 rcall ghostwrite_byte_header ; store salinity |
| 717 movff char_I_setpoint_cbar+4,WREG | 673 |
| 718 rcall ghostwrite_byte_header ; Setpoint in cbar | 674 movff int_O_CNS_fraction+0,WREG ; CNS value, low byte |
| 719 movff char_I_setpoint_change+4,WREG | 675 rcall ghostwrite_byte_header ; store CNS% |
| 720 rcall ghostwrite_byte_header ; Change depth | 676 movff int_O_CNS_fraction+1,WREG ; CNS value, high byte |
| 721 | 677 bcf WREG,int_warning_flag ; clear warning flag |
| 722 movff opt_salinity,WREG ; Salinity (0-4%) | 678 bcf WREG,int_attention_flag ; clear attention flag |
| 723 rcall ghostwrite_byte_header ; Store Salinity to Dive | 679 rcall ghostwrite_byte_header ; store CNS% |
| 724 | 680 |
| 725 movff int_O_CNS_fraction+0,WREG ; copy into bank1 | 681 movff avg_rel_pressure_total+0,WREG ; average depth |
| 726 rcall ghostwrite_byte_header ; Stores CNS% | 682 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 727 movff int_O_CNS_fraction+1,WREG ; copy into bank1 | 683 movff avg_rel_pressure_total+1,WREG ; average depth |
| 728 bcf WREG,int_warning_flag ; clear warning flag | 684 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 729 bcf WREG,int_attention_flag ; clear attention flag | 685 |
| 730 rcall ghostwrite_byte_header ; Stores CNS% | 686 movff total_divetime_seconds+0,WREG ; total dive time (regardless of start_dive_threshold) |
| 731 | 687 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 732 movff avg_rel_pressure_total+0,WREG ; Average Depth | 688 movff total_divetime_seconds+1,WREG ; total dive time (regardless of start_dive_threshold) |
| 733 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 689 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 734 movff avg_rel_pressure_total+1,WREG ; Average Depth | |
| 735 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
| 736 | |
| 737 movff total_divetime_seconds+0,WREG ; Total dive time (Regardless of start_dive_threshold) | |
| 738 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
| 739 movff total_divetime_seconds+1,WREG ; Total dive time (Regardless of start_dive_threshold) | |
| 740 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
| 741 | 690 |
| 742 movff char_I_GF_Low_percentage,WREG ; GF_lo | 691 movff char_I_GF_Low_percentage,WREG ; GF_lo |
| 743 movff char_I_deco_model,lo | 692 movff char_I_deco_model,lo |
| 744 decfsz lo,F ; jump over next line if char_I_deco_model == 1 | 693 decfsz lo,F ; jump over next line if char_I_deco_model == 1 |
| 745 movff char_I_saturation_multiplier,WREG ; Saturation Multiplier | 694 movff char_I_saturation_multiplier,WREG ; saturation multiplier |
| 746 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 695 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 747 | 696 |
| 748 movff char_I_GF_High_percentage,WREG ; GF_hi | 697 movff char_I_GF_High_percentage,WREG ; GF_hi |
| 749 movff char_I_deco_model,lo | 698 movff char_I_deco_model,lo |
| 750 decfsz lo,F ; jump over next line if char_I_deco_model == 1 | 699 decfsz lo,F ; jump over next line if char_I_deco_model == 1 |
| 751 movff char_I_desaturation_multiplier,WREG ; Desaturation Multiplier | 700 movff char_I_desaturation_multiplier,WREG ; desaturation multiplier |
| 752 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 701 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 753 | 702 |
| 754 movff char_I_deco_model,WREG ; 0 = ZH-L16, 1 = ZH-L16-GF | 703 movff char_I_deco_model,WREG ; 0 = ZH-L16, 1 = ZH-L16-GF |
| 755 rcall ghostwrite_byte_header ; writes byte and increases address (no banking) | 704 rcall ghostwrite_byte_header ; writes byte and increases address (no banking) |
| 756 | 705 |
| 757 read_int_eeprom .2 | 706 read_int_eeprom .2 |
| 758 movf EEDATA,W | 707 movf EEDATA,W |
| 759 rcall ghostwrite_byte_header ; Total dive counter, low | 708 rcall ghostwrite_byte_header ; total dive counter, low |
| 760 read_int_eeprom .3 | 709 read_int_eeprom .3 |
| 761 movf EEDATA,W | 710 movf EEDATA,W |
| 762 rcall ghostwrite_byte_header ; Total dive counter, high | 711 rcall ghostwrite_byte_header ; total dive counter, high |
| 763 | 712 |
| 764 movff opt_dive_mode,WREG | 713 movff opt_dive_mode,WREG |
| 765 rcall ghostwrite_byte_header ; 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=PSCR | 714 rcall ghostwrite_byte_header ; 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=PSCR |
| 766 | 715 |
| 767 ; Store all tissue data available | 716 ; Store all tissue data available |
| 769 movwf lo | 718 movwf lo |
| 770 lfsr FSR1,char_O_tissue_N2_saturation+0 | 719 lfsr FSR1,char_O_tissue_N2_saturation+0 |
| 771 end_dive_store_tissues_N2: | 720 end_dive_store_tissues_N2: |
| 772 movf POSTINC1,W | 721 movf POSTINC1,W |
| 773 bcf WREG,7 ; clear flag bit for ongassing/offgassing | 722 bcf WREG,7 ; clear flag bit for ongassing/offgassing |
| 774 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 723 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 775 decfsz lo,F | 724 decfsz lo,F |
| 776 bra end_dive_store_tissues_N2 ; No | 725 bra end_dive_store_tissues_N2 ; NO |
| 777 | 726 |
| 778 movlw .64 | 727 movlw .64 |
| 779 movwf lo | 728 movwf lo |
| 780 lfsr FSR1,0x700 ; pres_tissue_N2+0 ; 16*4Byte Float = 64Bytes | 729 lfsr FSR1,0x700 ; pres_tissue_N2+0 ; 16*4 Byte Float = 64 Bytes |
| 781 end_dive_store_tissues_N2_2: | 730 end_dive_store_tissues_N2_2: |
| 782 movf POSTINC1,W | 731 movf POSTINC1,W |
| 783 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 732 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 784 decfsz lo,F | 733 decfsz lo,F |
| 785 bra end_dive_store_tissues_N2_2 ; No | 734 bra end_dive_store_tissues_N2_2 ; NO |
| 786 | 735 |
| 787 movlw .16 | 736 movlw .16 |
| 788 movwf lo | 737 movwf lo |
| 789 lfsr FSR1,char_O_tissue_He_saturation+0 | 738 lfsr FSR1,char_O_tissue_He_saturation+0 |
| 790 end_dive_store_tissues_He: | 739 end_dive_store_tissues_He: |
| 791 movf POSTINC1,W | 740 movf POSTINC1,W |
| 792 bcf WREG,7 ; clear flag bit for ongassing/offgassing | 741 bcf WREG,7 ; clear flag bit for ongassing/offgassing |
| 793 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 742 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 794 decfsz lo,F | 743 decfsz lo,F |
| 795 bra end_dive_store_tissues_He ; No | 744 bra end_dive_store_tissues_He ; NO |
| 796 | 745 |
| 797 movlw .64 | 746 movlw .64 |
| 798 movwf lo | 747 movwf lo |
| 799 lfsr FSR1,0x740 ; pres_tissue_He+0 ; 16*4Byte Float = 64Bytes | 748 lfsr FSR1,0x740 ; pres_tissue_He+0 ; 16*4 Byte Float = 64 Bytes |
| 800 end_dive_store_tissues_He_2: | 749 end_dive_store_tissues_He_2: |
| 801 movf POSTINC1,W | 750 movf POSTINC1,W |
| 802 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 751 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 803 decfsz lo,F | 752 decfsz lo,F |
| 804 bra end_dive_store_tissues_He_2 ; No | 753 bra end_dive_store_tissues_He_2 ; NO |
| 805 | 754 |
| 806 ; Some deco stuff | 755 ; Some deco stuff |
| 807 movff char_I_depth_last_deco,WREG ; last stop [m] | 756 movff char_I_depth_last_deco,WREG ; last stop [m] |
| 808 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 757 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 809 movff char_I_deco_distance,WREG ; assumed distance to shown stop | 758 movff char_I_deco_distance,WREG ; assumed distance to shown stop |
| 810 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 759 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 811 | 760 |
| 812 ; Last HUD data | 761 ; Last HUD data |
| 813 movff hud_battery_mv+0,WREG ; Last HUD battery value | 762 movff hud_battery_mv+0,WREG ; last HUD battery value |
| 814 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 763 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 815 movff hud_battery_mv+1,WREG ; Last HUD battery value | 764 movff hud_battery_mv+1,WREG ; last HUD battery value |
| 816 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 765 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 817 movff hud_status_byte,WREG ; Last HUD status | 766 movff hud_status_byte,WREG ; last HUD status |
| 818 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 767 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 819 | 768 |
| 820 ; Battery gauge registers [nAs] | 769 ; Battery gauge registers [nAs] |
| 821 movff battery_gauge+0,WREG ; Battery gauge register | 770 lfsr FSR0,battery_gauge ; load base address of battery gauge register |
| 822 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 771 movf POSTINC0,W ; get byte 0 |
| 823 movff battery_gauge+1,WREG ; Battery gauge register | 772 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 824 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 773 movf POSTINC0,W ; get byte 1 |
| 825 movff battery_gauge+2,WREG ; Battery gauge register | 774 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 826 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 775 movf POSTINC0,W ; get byte 2 |
| 827 movff battery_gauge+3,WREG ; Battery gauge register | 776 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 828 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 777 movf POSTINC0,W ; get byte 3 |
| 829 movff battery_gauge+4,WREG ; Battery gauge register | 778 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 830 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 779 movf POSTINC0,W ; get byte 4 |
| 831 movff battery_gauge+5,WREG ; Battery gauge register | 780 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 832 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 781 movf POSTINC0,W ; get byte 5 |
| 782 rcall ghostwrite_byte_header ; WREG -> header in ext. flash | |
| 833 | 783 |
| 834 ; Header stop | 784 ; Header stop |
| 835 movlw 0xFB | 785 movlw 0xFB |
| 836 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 786 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 837 movlw 0xFB | 787 movlw 0xFB |
| 838 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 788 rcall ghostwrite_byte_header ; WREG -> header in ext. flash |
| 839 | 789 |
| 840 call divemode_store_statistics ; Store/update statistics for this unit | 790 call divemode_store_statistics ; store/update statistics for this unit |
| 841 | 791 |
| 842 clrf surface_interval+0 | 792 clrf surface_interval+0 |
| 843 clrf surface_interval+1 ; Clear surface interval timer | 793 clrf surface_interval+1 ; clear surface interval timer |
| 844 | 794 |
| 845 ghostwriter_end_dive_common: | 795 ghostwriter_end_dive_common: |
| 846 ; Update ext_flash_log_pointer into EEPROM | 796 ; Update ext_flash_log_pointer into EEPROM |
| 847 clrf EEADRH | 797 clrf EEADRH |
| 848 movff ext_flash_log_pointer+0,EEDATA | 798 movff ext_flash_log_pointer+0,EEDATA |
| 853 write_int_eeprom .6 | 803 write_int_eeprom .6 |
| 854 | 804 |
| 855 bcf simulatormode_active ; if we were in simulator mode | 805 bcf simulatormode_active ; if we were in simulator mode |
| 856 | 806 |
| 857 ; In DEBUG compile, keep all simulated dives in logbook, Desat time, nofly, etc... | 807 ; In DEBUG compile, keep all simulated dives in logbook, Desat time, nofly, etc... |
| 858 ifndef __DEBUG | 808 ifndef __DEBUG |
| 859 extern deco_pull_tissues_from_vault | 809 btfsc restore_deco_data ; restore decodata? |
| 860 btfsc restore_deco_data ; Restore decodata? | 810 call deco_pull_tissues_from_vault |
| 861 call deco_pull_tissues_from_vault | 811 banksel common ; bank 1 |
| 862 banksel common ; Bank1 | 812 endif |
| 863 endif | |
| 864 call update_battery_registers ; update battery registers into EEPROM | 813 call update_battery_registers ; update battery registers into EEPROM |
| 865 goto surfloop ; and return to surface loop | 814 goto surfloop ; and return to surface loop |
| 866 | 815 |
| 816 | |
| 867 ghostwriter_end_dive_common_sim: | 817 ghostwriter_end_dive_common_sim: |
| 868 tstfsz surface_interval+0 ; Was interval zero? | 818 tstfsz surface_interval+0 ; was interval zero? |
| 869 bra ghostwriter_end_dive_common_sim2 ; No | 819 bra ghostwriter_end_dive_common_sim2 ; NO |
| 870 tstfsz surface_interval+1 ; Was interval zero? | 820 tstfsz surface_interval+1 ; was interval zero? |
| 871 bra ghostwriter_end_dive_common_sim2 ; No | 821 bra ghostwriter_end_dive_common_sim2 ; NO |
| 872 bra ghostwriter_end_dive_common ; Yes, done. | 822 bra ghostwriter_end_dive_common ; YES - done |
| 873 | |
| 874 ghostwriter_end_dive_common_sim2: | 823 ghostwriter_end_dive_common_sim2: |
| 875 movf divemins+0,W | 824 movf divemins+0,W |
| 876 addwf surface_interval+0,F | 825 addwf surface_interval+0,F |
| 877 movf divemins+1,W | 826 movf divemins+1,W |
| 878 addwfc surface_interval+1 ; Add simulated dive time to surface interval | 827 addwfc surface_interval+1 ; add simulated dive time to surface interval |
| 879 bra ghostwriter_end_dive_common | 828 bra ghostwriter_end_dive_common |
| 880 | 829 |
| 881 ghostwriter_load_pointer: ; Load ext_flash_address:3 from EEPROM .4-.6 | 830 |
| 882 clrf EEADRH ; Make sure to select EEPROM bank 0 | 831 ghostwriter_load_pointer: ; load ext_flash_address:3 from EEPROM .4-.6 |
| 832 clrf EEADRH ; make sure to select EEPROM bank 0 | |
| 883 read_int_eeprom .4 | 833 read_int_eeprom .4 |
| 884 movff EEDATA,ext_flash_address+0 | 834 movff EEDATA,ext_flash_address+0 |
| 885 read_int_eeprom .5 | 835 read_int_eeprom .5 |
| 886 movff EEDATA,ext_flash_address+1 | 836 movff EEDATA,ext_flash_address+1 |
| 887 read_int_eeprom .6 | 837 read_int_eeprom .6 |
| 888 movff EEDATA,ext_flash_address+2 | 838 movff EEDATA,ext_flash_address+2 |
| 889 return | 839 return |
| 890 | 840 |
| 891 ghostwriter_short_header_init: ; Proceed one page forward | 841 ghostwriter_short_header_init: ; proceed one page forward |
| 892 clrf EEDATA | 842 clrf EEDATA |
| 893 write_int_eeprom .4 ; ext_flash_address+0 = 0 | 843 write_int_eeprom .4 ; ext_flash_address+0 = 0 |
| 894 movlw .16 | 844 movlw .16 |
| 895 addwf ext_flash_address+1,F | 845 addwf ext_flash_address+1,F |
| 896 movlw .0 | 846 movlw .0 |
| 897 addwfc ext_flash_address+2,F | 847 addwfc ext_flash_address+2,F |
| 898 movlw 0x20 | 848 movlw 0x20 |
| 899 cpfseq ext_flash_address+2 ; at address 0x200000? | 849 cpfseq ext_flash_address+2 ; at address 0x200000? |
| 900 bra ghostwriter_short_header_init2 ; No | 850 bra ghostwriter_short_header_init2 ; NO |
| 901 clrf ext_flash_address+2 ; Yes, rollover to 0x000000 | 851 clrf ext_flash_address+2 ; YES - rollover to 0x000000 |
| 902 ghostwriter_short_header_init2: | 852 ghostwriter_short_header_init2: |
| 903 movlw 0xF0 | 853 movlw 0xF0 |
| 904 andwf ext_flash_address+1,F ; keep higher nibble, set lower nibble to 0 | 854 andwf ext_flash_address+1,F ; keep higher nibble, set lower nibble to 0 |
| 905 | 855 |
| 906 movff ext_flash_address+1,EEDATA | 856 movff ext_flash_address+1,EEDATA |
| 907 write_int_eeprom .5 ; Write new pointer | 857 write_int_eeprom .5 ; write new pointer |
| 908 movff ext_flash_address+2,EEDATA | 858 movff ext_flash_address+2,EEDATA |
| 909 write_int_eeprom .6 ; Write new pointer | 859 write_int_eeprom .6 ; write new pointer |
| 910 bra ghostwriter_short_header2 ; Done. | 860 bra ghostwriter_short_header2 ; Done |
| 911 | 861 |
| 912 global ghostwriter_short_header | 862 global ghostwriter_short_header |
| 913 ghostwriter_short_header: ; Write short header with dive number into profile memory | 863 ghostwriter_short_header: ; write short header with dive number into profile memory |
| 914 ; load pointer for profile storing into RAM (Updated in EEPROM after the dive) | 864 ; load pointer for profile storing into RAM (Updated in EEPROM after the dive) |
| 915 rcall ghostwriter_load_pointer ; Load ext_flash_address:3 from EEPROM .4-.6 | 865 rcall ghostwriter_load_pointer ; load ext_flash_address:3 from EEPROM .4-.6 |
| 916 | 866 |
| 917 ; The following code is used to write a clean new dive after the previous hasn't been | 867 ; The following code is used to write a clean new dive after the previous hasn't been |
| 918 ; stored correctly. e.g. after a battery fail during the dive | 868 ; stored correctly. e.g. after a battery fail during the dive |
| 919 call ext_flash_byte_read_plus_0x20 ; Into ext_flash_rw | 869 call ext_flash_byte_read_plus_0x20 ; into ext_flash_rw |
| 920 incfsz ext_flash_rw,F | 870 incfsz ext_flash_rw,F |
| 921 bra ghostwriter_short_header_init ; Not 0xFF -> init page | 871 bra ghostwriter_short_header_init ; not 0xFF -> init page |
| 922 call ext_flash_byte_read_plus_0x20 ; Into ext_flash_rw | 872 call ext_flash_byte_read_plus_0x20 ; into ext_flash_rw |
| 923 incfsz ext_flash_rw,F | 873 incfsz ext_flash_rw,F |
| 924 bra ghostwriter_short_header_init ; Not 0xFF -> init page | 874 bra ghostwriter_short_header_init ; not 0xFF -> init page |
| 925 | 875 |
| 926 ghostwriter_short_header2: | 876 ghostwriter_short_header2: |
| 927 ; All ok, reload the pointer and start | 877 ; All ok, reload the pointer and start |
| 928 rcall ghostwriter_load_pointer ; Load ext_flash_address:3 from EEPROM .4-.6 | 878 rcall ghostwriter_load_pointer ; load ext_flash_address:3 from EEPROM .4-.6 |
| 929 | 879 |
| 930 ; Clear dive length counter | 880 ; Clear dive length counter |
| 931 clrf ext_flash_dive_counter+0 | 881 clrf ext_flash_dive_counter+0 |
| 932 clrf ext_flash_dive_counter+1 | 882 clrf ext_flash_dive_counter+1 |
| 933 clrf ext_flash_dive_counter+2 | 883 clrf ext_flash_dive_counter+2 |
| 934 | 884 |
| 935 ; Write short header with dive number into profile memory | 885 ; Write short header with dive number into profile memory |
| 936 movlw 0xFA | 886 movlw 0xFA |
| 937 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 887 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 938 movlw 0xFA | 888 movlw 0xFA |
| 939 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 889 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 940 ; Load total number of dives (low byte only) | 890 ; Load total number of dives (low byte only) |
| 941 read_int_eeprom .2 | 891 read_int_eeprom .2 |
| 942 incf EEDATA,W ;+1 | 892 incf EEDATA,W ; +1 |
| 943 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 893 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 944 read_int_eeprom .3 | 894 read_int_eeprom .3 |
| 945 movf EEDATA,W | 895 movf EEDATA,W |
| 946 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 896 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 947 movlw 0xFA | 897 movlw 0xFA |
| 948 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 898 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 949 movlw 0xFA | 899 movlw 0xFA |
| 950 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 900 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 951 | 901 |
| 952 ; Keep room for dive length ext_flash_dive_counter:3 (Stored at the end of the dive) | 902 ; Keep room for dive length ext_flash_dive_counter:3 (Stored at the end of the dive) |
| 953 ; Writing 0xFF three times here is mandatory | 903 ; Writing 0xFF three times here is mandatory |
| 954 ; - 0xFF can be overwritten after the dive | 904 ; - 0xFF can be overwritten after the dive |
| 955 ; - ghostwrite_byte_profile takes care of 4kB Page switching | 905 ; - ghostwrite_byte_profile takes care of 4kB Page switching |
| 956 ; - fixes an issue when we are at exactly 0xXXX000 here... | 906 ; - fixes an issue when we are at exactly 0xXXX000 here... |
| 957 | 907 |
| 958 movlw 0xFF | 908 movlw 0xFF |
| 959 call write_byte_ext_flash_plus_nocnt ; WREG -> Profile in ext. flash (No ext_flash_dive_counter:3 increase) | 909 call write_byte_ext_flash_plus_nocnt ; WREG -> profile in ext. flash (No ext_flash_dive_counter:3 increase) |
| 960 movlw 0xFF | 910 movlw 0xFF |
| 961 call write_byte_ext_flash_plus_nocnt ; WREG -> Profile in ext. flash (No ext_flash_dive_counter:3 increase) | 911 call write_byte_ext_flash_plus_nocnt ; WREG -> profile in ext. flash (No ext_flash_dive_counter:3 increase) |
| 962 movlw 0xFF | 912 movlw 0xFF |
| 963 call write_byte_ext_flash_plus_nocnt ; WREG -> Profile in ext. flash (No ext_flash_dive_counter:3 increase) | 913 call write_byte_ext_flash_plus_nocnt ; WREG -> profile in ext. flash (No ext_flash_dive_counter:3 increase) |
| 964 | 914 |
| 965 movf samplingrate,W ; Sampling rate | 915 movf samplingrate,W ; sampling rate |
| 966 btfsc FLAG_apnoe_mode ; Apnoe mode? | 916 btfsc FLAG_apnoe_mode ; apnoe mode? |
| 967 movlw samplingrate_apnoe ; Apnoe sampling rate | 917 movlw samplingrate_apnoe ; apnoe sampling rate |
| 968 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 918 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 969 | 919 |
| 970 movlw .7 ; Number of divisors | 920 movlw .7 ; number of divisors |
| 971 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 921 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 972 | 922 |
| 973 movlw .0 ; Type | 923 movlw .0 ; type |
| 974 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 924 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 975 movlw infolength_temperature | 925 movlw infolength_temperature |
| 976 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 926 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 977 movlw div_temperature ; Divisor temperature | 927 movlw div_temperature ; divisor temperature |
| 978 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 928 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 979 | 929 |
| 980 movlw .1 ; Type | 930 movlw .1 ; Type |
| 981 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 931 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 982 movlw infolength_deco | 932 movlw infolength_deco |
| 983 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 933 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 984 movlw div_deco ; Divisor deco data | 934 movlw div_deco ; divisor deco data |
| 985 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 935 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 986 | 936 |
| 987 movlw .2 ; Type | 937 movlw .2 ; type |
| 988 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 938 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 989 movlw infolength_gf | 939 movlw infolength_gf |
| 990 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 940 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 991 movlw div_gf ; Divisor gf | 941 movlw div_gf ; divisor gf |
| 992 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 942 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 993 | 943 |
| 994 movlw .3 ; Type | 944 movlw .3 ; type |
| 995 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 945 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 996 movlw infolength_ppo2_sensors | 946 movlw infolength_ppo2_sensors |
| 997 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 947 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 998 movlw div_ppo2_sensors ; Divisor ppO2 | 948 movlw div_ppo2_sensors ; divisor ppO2 |
| 999 btfss FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active | 949 btfss FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active |
| 1000 movlw .0 ; No ppO2 data in OC mode | 950 movlw .0 ; no ppO2 data in OC mode |
| 1001 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 951 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 1002 | 952 |
| 1003 movlw .4 ; Type | 953 movlw .4 ; type |
| 1004 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 954 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 1005 movlw infolength_decoplan | 955 movlw infolength_decoplan |
| 1006 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 956 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 1007 movlw div_decoplan ; Divisor debug | 957 movlw div_decoplan ; divisor debug |
| 1008 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 958 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 1009 | 959 |
| 1010 movlw .5 ; Type | 960 movlw .5 ; Type |
| 1011 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 961 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 1012 movlw infolength_cns | 962 movlw infolength_cns |
| 1013 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 963 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 1014 movlw div_cns ; Divisor CNS | 964 movlw div_cns ; divisor CNS |
| 1015 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 965 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 1016 | 966 |
| 1017 movlw .6 ; Type | 967 movlw .6 ; Type |
| 1018 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 968 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 1019 movlw infolength_tank | 969 movlw infolength_tank |
| 1020 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 970 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 1021 movlw div_tank ; Divisor Tank | 971 movlw div_tank ; divisor tank |
| 1022 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 972 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash |
| 1023 | 973 |
| 1024 return | 974 return |
| 1025 | 975 |
| 1026 divemode_store_statistics: ; Store/update statistics for this unit | 976 divemode_store_statistics: ; store/update statistics for this unit |
| 1027 call vault_decodata_into_eeprom ; update deco data | 977 call vault_decodata_into_eeprom ; update deco data |
| 1028 call do_logoffset_common_read ; Existing logbook offset into lo:hi | 978 call do_logoffset_common_read ; existing logbook offset into lo:hi |
| 1029 | 979 |
| 1030 tstfsz lo ; lo=0? | 980 tstfsz lo ; lo=0? |
| 1031 bra change_logbook_offset1 ; No, adjust offset | 981 bra change_logbook_offset1 ; NO - adjust offset |
| 1032 tstfsz hi ; hi=0? | 982 tstfsz hi ; hi=0? |
| 1033 bra change_logbook_offset1 ; No, adjust offset | 983 bra change_logbook_offset1 ; NO - adjust offset |
| 1034 bra change_logbook_offset2 ; lo=0 and hi=0 -> skip Offset routine | 984 bra change_logbook_offset2 ; lo=0 and hi=0 -> skip offset routine |
| 1035 | 985 |
| 1036 change_logbook_offset1: | 986 change_logbook_offset1: |
| 1037 movlw d'1' | 987 movlw d'1' |
| 1038 addwf lo | 988 addwf lo |
| 1039 movlw d'0' | 989 movlw d'0' |
