public void doFrame() {
        final int cyclesPerLine = 341 / 3;

        int scanline = 0;
        int acc = 0;
        cpu.resetElapsed();
        while (scanline < 262) {
            if (scanline == 240) {
                ppu.run(scanline);
                acc = cpu.run(cyclesPerLine - acc);
            } else {
                acc = cpu.run(cyclesPerLine - acc);
                ppu.run(scanline);
            }
            ++scanline;
        }
    }