git @ Cat's Eye Technologies JaC64 / master
Merge pull request #6 from catseye/command-line-arguments Command line arguments Chris Pressey authored 4 years ago GitHub committed 4 years ago
1 changed file(s) with 79 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
254254
255255 private boolean readDisk(String name) {
256256 System.out.println("READING FROM: " + name);
257
257258 if ((name.toLowerCase()).endsWith(".d64"))
258259 reader.readDiskFromFile(name);
259260 else if ((name.toLowerCase()).endsWith(".t64"))
280281 return false;
281282 }
282283
284 private boolean readDisk(URL url) {
285 String name = url.toString();
286
287 System.out.println("READING FROM URL: " + name);
288
289 if ((name.toLowerCase()).endsWith(".d64"))
290 reader.readDiskFromURL(url);
291 else if ((name.toLowerCase()).endsWith(".t64"))
292 reader.readTapeFromURL(url);
293 else if (name.toLowerCase().endsWith(".prg") ||
294 name.toLowerCase().endsWith(".p00")) {
295 cpu.reset();
296 try {
297 Thread.sleep(10);
298 }catch (Exception e2) {
299 System.out.println("Exception while sleeping...");
300 }
301 while(!scr.ready()) {
302 try {
303 Thread.sleep(100);
304 }catch (Exception e2) {
305 System.out.println("Exception while sleeping...");
306 }
307 }
308 reader.readPGM(url, -1);
309 cpu.runBasic();
310 return true;
311 }
312 return false;
313 }
314
283315 private void setFull(boolean full) {
284316 // JWindow jw = full ? C64Scr : null;
285317 // java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().
291323 // fullscreen = full;
292324 }
293325
294
295 public static void main(String[] name) {
296 JaC64 test = new JaC64();
297 test.cpu.start();
298 }
299 }
326 private void waitForKernal() {
327 while(!scr.ready()) {
328 try {
329 Thread.sleep(100);
330 } catch (Exception e2) {
331 System.out.println("Exception while sleeping...");
332 }
333 }
334 }
335
336 private void autoStart(String filename) {
337 Thread t = new Thread(new Runnable() {
338 public void run() {
339 waitForKernal();
340 System.out.println("Kernal READY!");
341 URL url = getClass().getResource(filename);
342 if (url != null) {
343 readDisk(url);
344 } else {
345 readDisk(filename);
346 }
347 }
348 });
349 t.start();
350 }
351
352 public static void main(String[] args) {
353 String autostart = null;
354
355 for (int i = 0; i < args.length; i++) {
356 if (args[i].equals("-a")) {
357 i++;
358 autostart = args[i];
359 } else {
360 System.out.println("Usage: java [-cp <classpath>] JaC64 [-a <autostart(.d64|.t64|.prg|.p00)>]");
361 System.exit(1);
362 }
363 }
364
365 JaC64 emu = new JaC64();
366 if (autostart != null) {
367 emu.autoStart(autostart);
368 }
369
370 emu.cpu.start();
371 }
372 }