But of course, it gets run 4 times.
Between the first and second time,
POKE 32840,177:POKE 32841,8
is called which means that, the second time around, instead of zeros being written to the screen like
mem[w1 + Y] = 0
above, we instead have a copying operation:
mem[w1 + Y] = mem[w2 + Y]
where:
w2 = w1 + 0x2000
So this effectively copies from hires page two to hires page one.
Prior to doing this, we've loaded AKA2
into page one and AKA5
into the two, so this is a transformation from AKA2
into AKA5
.