*** Selected sectors must consist of four walls. They will be split by the shortest diagonal.

mov r00 0
getsectornumber r05
while r00 < r05
  getselsector r00 r06
  if r06 != 0
    getsector r00 wallnum r01
    if r01 == 4
      getsector r00 wallptr r01
      getwall r01 point2 r02
      getwall r02 point2 r03
      getwall r03 point2 r04
      getwall r01 x r10  getwall r01 y r11
      getwall r03 x r12  getwall r03 y r13
      sub r10 r12  sub r11 r13
      hypot r20 r10 r11
      getwall r02 x r14  getwall r02 y r15
      getwall r04 x r16  getwall r04 y r17
      sub r14 r16  sub r15 r17
      hypot r21 r14 r15
      if r20 < r21
        getwall r01 x r10  getwall r01 y r11
        getwall r03 x r12  getwall r03 y r13
      else
        getwall r02 x r10  getwall r02 y r11
        getwall r04 x r12  getwall r04 y r13
      endif
      sethitpoint r10 r11
      hitspace
      sethitpoint r12 r13
      hitspace
      settool 0
      getsectornumber r05
      dec r00
    endif
  endif
  inc r00
continue