comparison code_part1/OSTC_code_asm_part1/pled_outputs.asm @ 476:7779bfa89171

Cave bailout prediction.
author JeanDo
date Sun, 09 Oct 2011 23:37:59 +0200
parents 32e1174fb89e
children fd8266b511cc
comparison
equal deleted inserted replaced
475:472bccc39aeb 476:7779bfa89171
3346 PLED_show_@5_wait: 3346 PLED_show_@5_wait:
3347 STRCPY_PRINT "--- " 3347 STRCPY_PRINT "--- "
3348 return 3348 return
3349 3349
3350 ;============================================================================= 3350 ;=============================================================================
3351 ; Display cave consomation prediction (and warning).
3352 ;
3353 PLED_show_cave_bailout:
3354 WIN_FONT FT_SMALL
3355 WIN_LEFT .160-.70 ; 10 chars aligned right.
3356 WIN_TOP .170
3357 call PLED_divemask_color ; Set Color for Divemode mask
3358 lfsr FSR2,letter
3359
3360 OUTPUTTEXTH .311 ; "Cave Bail."
3361 call word_processor
3362
3363 ; WIN_TOP .240 - 24 ; DO NOT display liter units, as this
3364 ; WIN_LEFT .160 - 7 ; can be Bars also...
3365 ; STRCPY_PRINT "l"
3366
3367 WIN_FONT FT_MEDIUM
3368 WIN_LEFT .90
3369 WIN_TOP .201 ; 170 + 24 + 14/2 + 32 + 14/2 = 240.
3370 call PLED_standard_color
3371 lfsr FSR2,letter
3372
3373 ;---- Compute divetime in seconds
3374 movff divemins+0,xA+0
3375 movff divemins+1,xA+1
3376 movlw d'60'
3377 movwf xB+0
3378 clrf xB+1
3379 call mult16x16 ; xC:4=xA:2*xB:2
3380 movf divesecs,W
3381 addwf xC+0,W
3382 movwf xA+0
3383 movlw d'0'
3384 addwfc xC+1,W
3385 movwf xA+1 ; xA:2 holds total dive seconds
3386
3387 ;---- Multiply by SAC, and divide by 600 (SAC in 0.1 liters per minutes)
3388 GETCUSTOM8 d'56' ; Get bottom SAC
3389 movwf xB+0
3390 clrf xB+1
3391 call mult16x16 ; xC:4=xA:2*xB:2
3392
3393 movlw LOW(.600)
3394 movwf xB+0
3395 movlw HIGH(.600)
3396 movwf xB+1
3397 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
3398
3399 ;---- Multiply by average pressure [absolute, in bar]
3400 movff xC+0,xA+0 ; Get result (in xC+0, noy xC+2 !) into xA
3401 movff xC+1,xA+1
3402
3403 movf avr_rel_pressure_total+0,W ; Add surface pressure to get absolute pressure
3404 addwf last_surfpressure_30min+0,W
3405 movwf xB+0
3406 movf avr_rel_pressure_total+1,W
3407 addwfc last_surfpressure_30min+1,W
3408 movwf xB+1 ; --> Into xB
3409
3410 call mult16x16 ; xC:4=xA:2*xB:2
3411
3412 movlw LOW(.1000) ; Pressure was in milibar, so divide by 1000.
3413 movwf xB+0
3414 movlw HIGH(.1000)
3415 movwf xB+1
3416 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
3417
3418 ;---- Go RED when limit is exceeded
3419 movff xC+0,sub_a+0
3420 movff xC+1,sub_a+1
3421 GETCUSTOM15 d'59' ; Get Cave bailout alarm threshold
3422 movff lo, sub_b+0
3423 movff hi, sub_b+1
3424 call sub16 ; Computes prediction - limit
3425 btfss neg_flag ; Negativ ?
3426 call PLED_warnings_color ; NO: go RED.
3427
3428 ;---- Then display...
3429 movff xC+0,lo
3430 movff xC+1,hi
3431
3432 bcf leftbind
3433 output_16
3434 call word_processor
3435 WIN_FONT FT_SMALL
3436 return
3437
3438 ;=============================================================================
3351 3439
3352 PLED_show_leading_tissue: 3440 PLED_show_leading_tissue:
3353 call PLED_divemask_color ; Set Color for Divemode mask 3441 call PLED_divemask_color ; Set Color for Divemode mask
3354 DISPLAYTEXTH .282 ; L. Tissue: 3442 DISPLAYTEXTH .282 ; L. Tissue:
3355 PLED_show_leading_tissue_2: 3443 PLED_show_leading_tissue_2: