package screen;

import javax.imageio.ImageIO;
import java.io.File;
import java.io.IOException;
import java.util.Timer;
import java.util.TimerTask;

/**
 * Starts the Emulator with a path to a game to load in.
 */
public class WhiteRavenLauncher {
    public static void main(String[] args) {
        final nes.Console console = new nes.Console("/Users/rparanjpe/WhiteRaven/donkeykong.nes");
        final MainScreen screen = new MainScreen();
        final Timer timer = new Timer();

        int FRAME_TIME = 17;
        timer.scheduleAtFixedRate(new TimerTask() {
            @Override
            public void run() {
                for (int i = 0; i < (1789773.0 / 60.0); i++) {
                    console.cpu.executeCycle();
                    console.ppu.executeCycles(3);
                    if (console.ppu.triggerVerticalBlank) {
                        console.cpu.triggerInterrupt(nes.Interrupt.NMI);
                        console.ppu.triggerVerticalBlank = false;
                    }
                    if (console.ppu.imageReady) {
                        screen.redraw(console.ppu.getImage());
                    }
                }
            }
        }, 0, FRAME_TIME);
    }
}

@@ -298,96 +298,240 @@
     
-final nes.Console console = new nes.Console(%22/Users/rparanjpe/WhiteRaven/donkeykong.nes%22
+if (args.length %3C 1) %7B%0A            System.err.println(%22Provide a file path to a game!%22);%0A            System.exit(1);%0A        %7D%0A        final String pathToGame = args%5B0%5D;%0A        final nes.Console console = new nes.Console(pathToGame
 );%0A 

Provide game path with a string