Browse Source

day 10 funny mouse :)

master
mid-kid 2 years ago
parent
commit
a76d949dd7
  1. 8
      d10.cc
  2. BIN
      d10_mick.txt.xz

8
d10.cc

@ -93,18 +93,20 @@ unsigned p1(const Input &input)
return sum;
}
#define WIDTH 40
void p2(const Input &input)
{
Cpu cpu(&input);
while (cpu.running()) {
// Calculate current CRT line
int X = cpu.cycle % 40;
if (X == 0) X += 40;
int X = cpu.cycle % WIDTH;
if (X == 0) X += WIDTH;
// Draw pixel
if (cpu.X <= X && X <= cpu.X + 2) cout << '#';
else cout << '.';
if (X == 40) cout << endl;
if (X == WIDTH) cout << endl;
cpu.tick();
}

BIN
d10_mick.txt.xz

Binary file not shown.
Loading…
Cancel
Save