(self, fn, enabled, video_buffer)
PEN: poll the light pen.
PEN: poll the light pen.
PEN : poll the light pen .
def poll(self, fn, enabled, video_buffer):
        """PEN: poll the light pen."""
        fn = values.to_int(fn)
        error.range_check(0, 9, fn)
        if not enabled:
            # should return 0 or char pos 1 if PEN not ON
            return 1 if fn >= 6 else 0
        if fn == 0:
            pen_down_old, self._was_down = self._was_down, False
            return -1 if pen_down_old else 0
        elif fn == 1:
            return self._down_pos[0]
        elif fn == 2:
            return self._down_pos[1]
        elif fn == 3:
            return -1 if self._is_down else 0
        elif fn == 4:
            return self._pos[0]
        elif fn == 5:
            return self._pos[1]
        elif fn == 6:
            row, _ = video_buffer.pixel_to_text_pos(*self._down_pos)
            return row
        elif fn == 7:
            _, col = video_buffer.pixel_to_text_pos(*self._down_pos)
            return col
        elif fn == 8:
            row, _ = video_buffer.pixel_to_text_pos(*self._pos)
            return row
        elif fn == 9:
            _, col = video_buffer.pixel_to_text_pos(*self._pos)
            return col
def poll ( self , fn , enabled , video_buffer ) : fn = values . to_int ( fn ) error . range_check ( 0 , 9 , fn ) if not enabled : # should return 0 or char pos 1 if PEN not ON return 1 if fn >= 6 else 0 if fn == 0 : pen_down_old , self . _was_down = self . _was_down , False return - 1 if pen_down_old else 0 elif fn == 1 : return self . _down_pos [ 0 ] elif fn == 2 : return self . _down_pos [ 1 ] elif fn == 3 : return - 1 if self . _is_down else 0 elif fn == 4 : return self . _pos [ 0 ] elif fn == 5 : return self . _pos [ 1 ] elif fn == 6 : row , _ = video_buffer . pixel_to_text_pos ( * self . _down_pos ) return row elif fn == 7 : _ , col = video_buffer . pixel_to_text_pos ( * self . _down_pos ) return col elif fn == 8 : row , _ = video_buffer . pixel_to_text_pos ( * self . _pos ) return row elif fn == 9 : _ , col = video_buffer . pixel_to_text_pos ( * self . _pos ) return col