


/*
search candle in room.
function need to be called when robot already in the room.
*/
int extinguish_fire(void)
{
/* go to fire */
while(!GetPort(white_line) && !GetPort(big_fire) && (GetPort(ir_front) < 33))
{
follow_wall_left_furniture();
if (GetPort(ir_front) < 28 )
turn90();
}/*end while*/
stop_motor();
fan_on(); /* built-in delay */
/* go to door */
turn180();
while(!GetPort(white_line) && (GetPort(ir_front)<47))
{
follow_wall_right_furniture();
if (GetPort(ir_front) < 28 )
turn090();
}/*end while*/
stop_motor();
}




; Squares A (A*A). Returns result in D.
; Size:4 Cycles: 10
SQR_A_D:
TAB
MUL
RTS
; Calculates the power of A and B (A^B). Returns result in D.
; Assumes: A and B unsigned, B>1.
; Result is trimmed to first 16-bits (upto 65,535).
; Size: 18 Cycles: 33.
; Written by Erez Shinan.
POWER_AB_D:
PSHX
PSHY
DECB
TFR B,X
TAB
CLRA
PSHD ; Push 16-bit base into stack
POWER_AB_D_1:
LDY 0,SP ; Load 16-bit base from stack, instead of pull.
EMUL ;Y*D->Y:D
DBNE X,POWER_AB_D_1
PULY
PULX
RTS
ADDX:
LEAX d,x
RTS
ADDY:
LEAY d,y
RTS
;* ---------------------------------------------------------------------------
;Recieves A,B, or D
;according to If X = 0 {A}, 1 {B}, 2 {C}
;Meaning - if in x there's a zero, ABS will absolute accumlator A. etc.
;
;Returns - Absolute value of A,B or D
; 0 or FFFF in X where : 0 - no errors
; FFFF- error
;
;
ABS:
PSHD
XGDX
LSLB
CLRA
JMP [d,pc]
DC.W ABS_A
DC.W ABS_B
DC.W ABS_D
DC.W ABS_OUT_ERR
DC.W ABS_OUT_ERR
DC.W ABS_OUT_ERR
DC.W ABS_OUT_ERR
DC.W ABS_OUT_ERR
DC.W ABS_OUT_ERR
DC.W ABS_OUT_ERR
;--------------------------------------------
ABS_A:
LDX #0
PULD
TSTA
BPL ABS_OUT
NEGA
BRA ABS_OUT
;--------------------------------------------
ABS_B:
LDX #0
PULD
TSTB
BPL ABS_OUT
NEGB
BRA ABS_OUT
;--------------------------------------------
ABS_D:
LDX #0
PULD
TSTA
BPL ABS_OUT
EORA #$FF
EORB #$FF
;--------------------------------------------
ABS_OUT_ERR:
LDX #$FFFF ;Idication of some Error in input
;--------------------------------------------
ABS_OUT:
RTS
משתמשים הגולשים בפורום זה: Google [Bot], xalmek ו 27 אורחים