comparison code_part1/OSTC_code_asm_part1/simulator.asm @ 278:17aab4ca0547

BUGFIX CCR decoplan fails (bug bb42). Make decoplaning faster (just update tissue during bottomtime). Animate ascent depth during decoplaning.
author JeanDo
date Tue, 19 Apr 2011 02:26:41 +0200
parents 5c17b2b4b9dd
children 8514588eb6a2
comparison
equal deleted inserted replaced
277:46d1012d096a 278:17aab4ca0547
374 movff sim_pressure+1,amb_pressure+1 374 movff sim_pressure+1,amb_pressure+1
375 375
376 call divemode_check_decogases ; Checks for decogases and sets the gases 376 call divemode_check_decogases ; Checks for decogases and sets the gases
377 call divemode_prepare_flags_for_deco 377 call divemode_prepare_flags_for_deco
378 378
379 ; First minute is special: init everything.
379 movlw d'3' ; Begin of deco cycle (reset table). 380 movlw d'3' ; Begin of deco cycle (reset table).
380 movff WREG,char_O_deco_status ; Reset Deco module. 381 movff WREG,char_O_deco_status ; Reset Deco module.
381 382
383 movlw d'1'
384 movff WREG,char_I_step_is_1min ; 1 minute mode.
385
386 call deco_calc_hauptroutine ; Reset table + sim one minute for descent.
387 movlb b'00000001' ; rambank 1 selected
388
389 decf logbook_temp1,F ; One minute done.
390
391 ; Loop for bottom time duration
392 simulator_calc_deco_loop2:
393 call PLED_simulator_data ; Update display of bottom time.
394
395 call deco_calc_tissue ; JUST calc tissue (faster).
396 movlb b'00000001' ; rambank 1 selected
397 ostc_debug 'C' ; Sends debug-information to screen if debugmode active
398
399 decfsz logbook_temp1,F ; Decrement bottom time,
400 bra simulator_calc_deco_loop2 ; and loop while not finished.
401
402 ; No the bottom time is finish, restart a full ascent simulation,
382 movlw d'0' 403 movlw d'0'
383 movff WREG,char_I_step_is_1min ; 2 second deco mode for descent. 404 movff WREG,char_I_step_is_1min ; Back to 2 second deco mode
384 405
385 simulator_calc_deco_loop1: 406 clrf timeout_counter2 ; timeout used as maxloop here
386 call deco_calc_hauptroutine ; calc_tissue 407 movff char_I_bottom_depth,char_O_deco_last_stop
387 movlb b'00000001' ; rambank 1 selected 408
388 409 simulator_calc_deco2:
389 movff char_O_deco_status,WREG
390 tstfsz WREG ; deco_status=0 if decompression calculation done
391 bra simulator_calc_deco_loop1 ; Not finished
392
393 movlw d'1'
394 movff WREG,char_I_step_is_1min ; 1 minute mode for bottom time.
395
396 simulator_calc_deco_loop2:
397 call PLED_simulator_data
398
399 call deco_calc_hauptroutine ; calc_tissue 410 call deco_calc_hauptroutine ; calc_tissue
400 movlb b'00000001' ; rambank 1 selected 411 movlb b'00000001' ; rambank 1 selected
401 ostc_debug 'C' ; Sends debug-information to screen if debugmode active 412
402 413 movff char_O_deco_last_stop,logbook_temp2
403 decfsz logbook_temp1,F ; Decrement bottom time. 414 call PLED_simulator_data ; Animate ascent simu.
404 bra simulator_calc_deco_loop2
405
406 movlw d'0'
407 movff WREG,char_I_step_is_1min ; 2 second deco mode
408
409 clrf timeout_counter2 ; timeout used as maxloop here
410 simulator_calc_deco2:
411
412 call deco_calc_hauptroutine ; calc_tissue
413 movlb b'00000001' ; rambank 1 selected
414 415
415 dcfsnz timeout_counter2,F ; Abort loop (max. 256 tries)? 416 dcfsnz timeout_counter2,F ; Abort loop (max. 256 tries)?
416 bra simulator_calc_deco3 ; Yes... 417 bra simulator_calc_deco3 ; Yes...
417 418
418 movff char_O_deco_status,WREG 419 movff char_O_deco_status,WREG
419 tstfsz WREG ; deco_status=0 if decompression calculation done 420 iorwf WREG ; deco_status=0 if decompression calculation done
420 bra simulator_calc_deco2 ; Not finished 421 bnz simulator_calc_deco2 ; Not finished
421 422
422 simulator_calc_deco3: 423 simulator_calc_deco3:
423 ; Finished 424 ; Finished
424 rcall simulator_restore_tissue_data ; Restore 32 floats "pre_tissue" from bank3 425 rcall simulator_restore_tissue_data ; Restore 32 floats "pre_tissue" from bank3
425 426
431 WAITMS d'250' 432 WAITMS d'250'
432 WAITMS d'250' ; Wait for Pressure Sensor to get real pressure again... 433 WAITMS d'250' ; Wait for Pressure Sensor to get real pressure again...
433 434
434 movlw d'5' ; Pre-Set Cursor to "Show Decoplan" 435 movlw d'5' ; Pre-Set Cursor to "Show Decoplan"
435 movwf menupos 436 movwf menupos
436 movff char_I_bottom_time,logbook_temp1; restore bottom time. 437 movff char_I_bottom_time,logbook_temp1 ; Restore bottom time,
438 movff char_I_bottom_depth,logbook_temp2 ; and depth.
437 bra menu_simulator1 ; Done. 439 bra menu_simulator1 ; Done.
438 440
439 simulator_save_tissue_data: 441 simulator_save_tissue_data:
440 bsf restore_deco_data ; Set restore flag 442 bsf restore_deco_data ; Set restore flag
441 ostc_debug 'S' ; Sends debug-information to screen if debugmode active 443 ostc_debug 'S' ; Sends debug-information to screen if debugmode active