# Two questions video.sh cannot ask of a picture that moves. # # Grid scrolls a pixel a frame, so nothing can be asked about a particular pixel: whether # pixel 4 is a grid line depends on which frame this is. Both questions below are true of the # picture whatever the fine scroll offset happens to be. # # grid - is this a grid of one repeated tile? Periodic every eight pixels across, and # not all one colour. # bands - does the attribute nibble recolour each cell row? The colours found in one band # of eight rows differ from those in the next, whatever the ground is doing. import sys data = open(sys.argv[1], "rb").read() fields = data.split(b"\n", 3) width = int(fields[1].split()[0]) body = fields[3] def pixel(x, y): at = (y * width + x) * 3 return tuple(body[at:at + 3]) if sys.argv[2] == "grid": # ---- The WHOLE scanline, not the first few cells ---- # # This looked at 32 pixels, which is four cells at the left edge, and so could not see a # program that had filled part of the map and scrolled off the end of what it filled. The # gap was on the right and nothing was looking there. A gap anywhere breaks periodicity at # its two edges, so the full width finds it wherever it is. row = [pixel(x, 4) for x in range(width)] bad = [x for x in range(width - 8) if row[x] != row[x + 8]] varied = len(set(row)) > 1 print("yes" if not bad and varied else "breaks at column %d" % bad[0] if bad else "all one colour") else: # A band is eight rows, which is one cell row wherever the boundary has slid to. The # ground is the same under every scheme, so what tells them apart is the line colour - # and looking at the whole band finds it without knowing where in the band it is. first = set(pixel(0, y) for y in range(8)) second = set(pixel(0, y) for y in range(8, 16)) print("yes" if first != second else "the same in both: %s" % sorted(first))