comparison code_part1/OSTC_code_asm_part1/simulator.asm @ 430:f36b93f2fbed

Minor logbook cleanups. Created a 20byte tmp area, safe from C-library footprint.
author JeanDo
date Thu, 04 Aug 2011 18:54:26 +0200
parents d022c62a1df5
children b9cf06de8aca
comparison
equal deleted inserted replaced
429:1da600c4e139 430:f36b93f2fbed
21 ; written: 081210 21 ; written: 081210
22 ; last updated: 081210 22 ; last updated: 081210
23 ; known bugs: 23 ; known bugs:
24 ; ToDo: 24 ; ToDo:
25 25
26 ;=============================================================================
27 ; Temp data, local to this module, moved to ACCES0 area.
28 ;
29 CBLOCK tmp ; Into safe (from C library) area.
30 sim_btm_time ; Simulated bottom time
31 sim_btm_depth ; Simulated max depth
32 sim_CNS ; Backup CNS value during decoplanning.
33 ENDC
34
35 ;=============================================================================
36
26 menu_simulator: 37 menu_simulator:
27 movlw d'3' 38 movlw d'3'
28 movwf logbook_temp1 ; Bottom time 39 movwf sim_btm_time ; Bottom time
29 movlw d'15' 40 movlw d'15'
30 movwf logbook_temp2 ; Max. Depth 41 movwf sim_btm_depth ; Max. Depth
31 movlw d'1' 42 movlw d'1'
32 movwf menupos 43 movwf menupos
33 clrf WREG ; Interval 44 clrf WREG ; Interval
34 movff WREG,char_I_dive_interval 45 movff WREG,char_I_dive_interval
35 46
107 movwf menupos 118 movwf menupos
108 bra menu_simulator2 119 bra menu_simulator2
109 120
110 simulator_inc_bottomtime: 121 simulator_inc_bottomtime:
111 movlw d'2' 122 movlw d'2'
112 addwf logbook_temp1,F ; Here: Bottomtime in m 123 addwf sim_btm_time,F ; Here: Bottomtime in m
113 movlw d'199' 124 movlw d'199'
114 cpfslt logbook_temp1 125 cpfslt sim_btm_time
115 movwf logbook_temp1 126 movwf sim_btm_time
116 movlw d'3' 127 movlw d'3'
117 movwf menupos 128 movwf menupos
118 bra menu_simulator2 129 bra menu_simulator2
119 130
120 simulator_inc_maxdepth: 131 simulator_inc_maxdepth:
121 movlw d'3' 132 movlw d'3'
122 addwf logbook_temp2,F ; Here: Maxdepth in m 133 addwf sim_btm_depth,F ; Here: Maxdepth in m
123 movlw d'120' 134 movlw d'120'
124 cpfslt logbook_temp2 135 cpfslt sim_btm_depth
125 movwf logbook_temp2 136 movwf sim_btm_depth
126 movlw d'4' 137 movlw d'4'
127 movwf menupos 138 movwf menupos
128 bra menu_simulator2 139 bra menu_simulator2
129 140
130 ;============================================================================= 141 ;=============================================================================
134 ; Set standalone_simulator flag (Displays Simulator menu during simulation by pressing ENTER button) 145 ; Set standalone_simulator flag (Displays Simulator menu during simulation by pressing ENTER button)
135 ; Clear standalone_simulator after (any) dive 146 ; Clear standalone_simulator after (any) dive
136 bsf simulatormode_active ; normal simulator mode 147 bsf simulatormode_active ; normal simulator mode
137 bsf standalone_simulator ; Standalone Simulator active 148 bsf standalone_simulator ; Standalone Simulator active
138 149
139 movff logbook_temp2,xA+0 150 movff sim_btm_depth,xA+0
140 clrf xA+1 151 clrf xA+1
141 movlw d'100' 152 movlw d'100'
142 movwf xB+0 153 movwf xB+0
143 clrf xB+1 154 clrf xB+1
144 call mult16x16 ;xA*xB=xC ; Depth in m*100 155 call mult16x16 ;xA*xB=xC ; Depth in m*100
208 STRCPY "CNS:" 219 STRCPY "CNS:"
209 movff char_O_CNS_fraction,lo ; Current CNS, before dive. 220 movff char_O_CNS_fraction,lo ; Current CNS, before dive.
210 output_8 221 output_8
211 222
212 STRCAT "%\x92" ; Right-arrow 223 STRCAT "%\x92" ; Right-arrow
213 movff logbook_temp3,lo ; Get back CNS value. 224 movff sim_CNS,lo ; Get back CNS value.
214 output_8 ; CNS after dive. 225 output_8 ; CNS after dive.
215 STRCAT_PRINT "%" 226 STRCAT_PRINT "%"
216 227
217 WIN_INVERT .1 ; Init new Wordprocessor 228 WIN_INVERT .1 ; Init new Wordprocessor
218 DISPLAYTEXT .188 ; Sim. Results: 229 DISPLAYTEXT .188 ; Sim. Results:
350 clrf TMR3H 361 clrf TMR3H
351 362
352 call diveloop_boot ; configure gases, etc. 363 call diveloop_boot ; configure gases, etc.
353 364
354 ; Save dive parameters for gas volume estimation: 365 ; Save dive parameters for gas volume estimation:
355 movff logbook_temp2,char_I_bottom_depth 366 movff sim_btm_depth,char_I_bottom_depth
356 movff logbook_temp1,char_I_bottom_time 367 movff sim_btm_time,char_I_bottom_time
357 368
358 movff logbook_temp2,xA+0 ; Bottom depth. 369 movff sim_btm_depth,xA+0 ; Bottom depth.
359 clrf xA+1 370 clrf xA+1
360 movlw d'100' 371 movlw d'100'
361 movwf xB+0 372 movwf xB+0
362 clrf xB+1 373 clrf xB+1
363 call mult16x16 ;xA*xB=xC, Depth in m*100 374 call mult16x16 ;xA*xB=xC, Depth in m*100
393 404
394 call deco_calc_hauptroutine ; Reset table + sim one minute for descent. 405 call deco_calc_hauptroutine ; Reset table + sim one minute for descent.
395 call deco_calc_CNS_fraction ; Also calculate CNS (in 1min loop) 406 call deco_calc_CNS_fraction ; Also calculate CNS (in 1min loop)
396 movlb b'00000001' ; rambank 1 selected 407 movlb b'00000001' ; rambank 1 selected
397 408
398 decf logbook_temp1,F ; One minute done. 409 decf sim_btm_time,F ; One minute done.
399 410
400 ; Loop for bottom time duration 411 ; Loop for bottom time duration
401 simulator_calc_deco_loop2: 412 simulator_calc_deco_loop2:
402 call PLED_simulator_data ; Update display of bottom time. 413 call PLED_simulator_data ; Update display of bottom time.
403 414
404 call deco_calc_tissue ; JUST calc tissue (faster). 415 call deco_calc_tissue ; JUST calc tissue (faster).
405 call deco_calc_CNS_fraction ; Also calculate CNS (in 1min loop) 416 call deco_calc_CNS_fraction ; Also calculate CNS (in 1min loop)
406 movlb b'00000001' ; rambank 1 selected 417 movlb b'00000001' ; rambank 1 selected
407 ostc_debug 'C' ; Sends debug-information to screen if debugmode active 418 ostc_debug 'C' ; Sends debug-information to screen if debugmode active
408 419
409 decfsz logbook_temp1,F ; Decrement bottom time, 420 decfsz sim_btm_time,F ; Decrement bottom time,
410 bra simulator_calc_deco_loop2 ; and loop while not finished. 421 bra simulator_calc_deco_loop2 ; and loop while not finished.
411 422
412 ; No the bottom time is finish, restart a full ascent simulation, 423 ; No the bottom time is finish, restart a full ascent simulation,
413 movlw d'0' 424 movlw d'0'
414 movff WREG,char_I_step_is_1min ; Back to 2 second deco mode 425 movff WREG,char_I_step_is_1min ; Back to 2 second deco mode
418 429
419 simulator_calc_deco2: 430 simulator_calc_deco2:
420 call deco_calc_hauptroutine ; calc_tissue 431 call deco_calc_hauptroutine ; calc_tissue
421 movlb b'00000001' ; rambank 1 selected 432 movlb b'00000001' ; rambank 1 selected
422 433
423 movff char_O_deco_last_stop,logbook_temp2 434 movff char_O_deco_last_stop,sim_btm_depth
424 call PLED_simulator_data ; Animate ascent simu. 435 call PLED_simulator_data ; Animate ascent simu.
425 436
426 dcfsnz timeout_counter2,F ; Abort loop (max. 256 tries)? 437 dcfsnz timeout_counter2,F ; Abort loop (max. 256 tries)?
427 bra simulator_calc_deco3 ; Yes... 438 bra simulator_calc_deco3 ; Yes...
428 439
430 iorwf WREG ; deco_status=0 if decompression calculation done 441 iorwf WREG ; deco_status=0 if decompression calculation done
431 bnz simulator_calc_deco2 ; Not finished 442 bnz simulator_calc_deco2 ; Not finished
432 443
433 ; Finished 444 ; Finished
434 simulator_calc_deco3: 445 simulator_calc_deco3:
435 movff char_O_CNS_fraction,logbook_temp3 ; Save calculated CNS. 446 movff char_O_CNS_fraction,sim_CNS ; Save calculated CNS.
436 rcall simulator_restore_tissue_data ; Restore CNS & 32 floats "pre_tissue" from vault 447 rcall simulator_restore_tissue_data ; Restore CNS & 32 floats "pre_tissue" from vault
437 448
438 bcf simulatormode_active ; normal simulator mode 449 bcf simulatormode_active ; normal simulator mode
439 bcf standalone_simulator ; Standalone Simulator active 450 bcf standalone_simulator ; Standalone Simulator active
440 bcf no_sensor_int ; Re-enable sensor interrupt 451 bcf no_sensor_int ; Re-enable sensor interrupt
443 WAITMS d'250' 454 WAITMS d'250'
444 WAITMS d'250' ; Wait for Pressure Sensor to get real pressure again... 455 WAITMS d'250' ; Wait for Pressure Sensor to get real pressure again...
445 456
446 movlw d'5' ; Pre-Set Cursor to "Show Decoplan" 457 movlw d'5' ; Pre-Set Cursor to "Show Decoplan"
447 movwf menupos 458 movwf menupos
448 movff char_I_bottom_time,logbook_temp1 ; Restore bottom time, 459 movff char_I_bottom_time,sim_btm_time ; Restore bottom time,
449 movff char_I_bottom_depth,logbook_temp2 ; and depth. 460 movff char_I_bottom_depth,sim_btm_depth ; and depth.
450 461
451 clrf timeout_counter2 ; Restart menu timeout. 462 clrf timeout_counter2 ; Restart menu timeout.
452 bra simulator_show_decoplan ; Done. 463 bra simulator_show_decoplan ; Done.
453 464
454 simulator_save_tissue_data: 465 simulator_save_tissue_data: