program matrix2
dim colonnes, hazards, vitesses as byte[8]
dim x, vitesse, flag_vitesse as byte
main:
ADCON0 = %00000001 ADCON1 = %00001110 TrisA = %00000001 TrisB = %00000000 TrisC = %00000000 TrisD = %00000000 TrisE = %00000000 PortA = %00000000 PortB = %00000000 PortC = %00000000 PortD = %00000000 PortE = %00000000 vitesses[0]=0
vitesses[1]=0
vitesses[2]=0
vitesses[3]=0
vitesses[4]=0
vitesses[5]=0
vitesses[6]=0
vitesses[7]=0
vitesse = 0
flag_vitesse = 1
while true
PortB = colonnes[0]
PortD = %00000001
ADCON0.GO = 1 delay_ms(1)
hazards[0] = hazards[0] + ADRESL + PCL
PortB = colonnes[1]
PortD = %00000010
ADCON0.GO = 1 delay_ms(1)
hazards[1] = hazards[1] + ADRESL + PCL
PortB = colonnes[2]
PortD = %00000100
ADCON0.GO = 1 delay_ms(1)
hazards[2] = hazards[2] + ADRESL + PCL
PortB = colonnes[3]
PortD = %00001000
ADCON0.GO = 1
delay_ms(1)
hazards[3] = hazards[3] + ADRESL + PCL
PortB = colonnes[4]
PortD = %00010000
ADCON0.GO = 1
delay_ms(1)
hazards[4] = hazards[4] + ADRESL + PCL
PortB = colonnes[5]
PortD = %00100000
ADCON0.GO = 1
delay_ms(1)
hazards[5] = hazards[5] + ADRESL + PCL
PortB = colonnes[6]
PortD = %01000000
ADCON0.GO = 1
delay_ms(1)
hazards[6] = hazards[6] + ADRESL + PCL
PortB = colonnes[7]
PortD = %10000000
ADCON0.GO = 1
delay_ms(1)
hazards[7] = hazards[7] + ADRESL + PCL
inc(vitesse)
if vitesse = 31 then
if vitesses[0] < flag_vitesse then
colonnes[0]=colonnes[0]<<1
x = hazards[0] mod 7
if x = 0 then
colonnes[0].0 = 1
if colonnes[0]=1 then
vitesses[0]=hazards[1] mod 3
end if
end if
end if
if vitesses[1] < flag_vitesse then
colonnes[1]=colonnes[1]<<1
x = hazards[1] mod 7
if x = 0 then
colonnes[1].0 = 1
if colonnes[1]=1 then
vitesses[1]=hazards[2] mod 3
end if
end if
end if
if vitesses[2] < flag_vitesse then
colonnes[2]=colonnes[2]<<1
x = hazards[2] mod 7
if x = 0 then
colonnes[2].0 = 1
if colonnes[2]=1 then
vitesses[2]=hazards[3] mod 3
end if
end if
end if
if vitesses[3] < flag_vitesse then
colonnes[3]=colonnes[3]<<1
x = hazards[3] mod 7
if x = 0 then
colonnes[3].0 = 1
if colonnes[3]=1 then
vitesses[3]=hazards[4] mod 3
end if
end if
end if
if vitesses[4] < flag_vitesse then
colonnes[4]=colonnes[4]<<1
x = hazards[4] mod 7
if x = 0 then
colonnes[4].0 = 1
if colonnes[4]=1 then
vitesses[4]=hazards[5] mod 3
end if
end if
end if
if vitesses[5] < flag_vitesse then
colonnes[5]=colonnes[5]<<1
x = hazards[5] mod 7
if x = 0 then
colonnes[5].0 = 1
if colonnes[5]=1 then
vitesses[5]=hazards[6] mod 3
end if
end if
end if
if vitesses[6] < flag_vitesse then
colonnes[6]=colonnes[6]<<1
x = hazards[6] mod 7
if x = 0 then
colonnes[6].0 = 1
if colonnes[6]=1 then
vitesses[6]=hazards[7] mod 3
end if
end if
end if
if vitesses[7] < flag_vitesse then
colonnes[7]=colonnes[7]<<1
x = hazards[7] mod 7
if x = 0 then
colonnes[7].0 = 1
if colonnes[7]=1 then
vitesses[7]=hazards[0] mod 3
end if
end if
end if
inc(flag_vitesse)
if flag_vitesse=4 then flag_vitesse=0 end if
vitesse = 0
end if
wend
end.