K, 133
=
    i:0;{while[1;1">> ";a:0:0;{i{$[max(r:y x)~/:-1,256;0;r]}/d{x@&x in y}[x;!d:"ixdskoc"!,/(2#(1+);-1+;2#{x*x};2#{-1@$i::x;})]}'" "\:a]}`

.


    C:\q>q deadfish.k -q
    >> xiskso
    0
    >> xiskisc
    289
    >> ddddo ddddo
    285
    281
    >> ddddo ddddo
    277
    273
    >> dddddddo
    266
    >> dddddddddo
    257
    >> do
    0
    >> do
    0
    >> io
    1
    >>