home *** CD-ROM | disk | FTP | other *** search
Wrap
import java.applet.Applet; import java.awt.Container; import java.awt.Dimension; import java.awt.Event; import java.awt.Graphics; import java.awt.LayoutManager; import java.io.InputStream; import java.net.URL; import java.net.URLConnection; public class Jasper extends Applet implements Runnable { Spectrum spectrum; Thread thread; public String getAppletInfo() { return "Jasper V1.1 by Adam Davidson and Andrew Pollard"; } public String[][] getParameterInfo() { String[][] var1 = new String[][]{{"snapshot", "filename", "name of SNA or Z80 snapshot to load"}, {"rom", "filename", "filename of ROM (default=spectrum.rom)"}, {"borderWidth", "integer", "width of spectrum border (default=20)"}, {"refreshRate", "integer", "refresh screen every 'X' interrupts (default=1)"}, {"sleepHack", "integer", "sleep per interrupt in ms, for old VMs (default=0)"}, {"showStats", "Yes/No", "show progress bar (default=Yes)"}}; return var1; } public void init() { ((Container)this).setLayout((LayoutManager)null); } public void start() { if (this.thread == null) { this.thread = new Thread(this, "Jasper"); this.thread.start(); } } public void stop() { if (this.thread != null) { this.thread.stop(); this.thread = null; } } public void readParameters() throws Exception { String var1 = ((Applet)this).getParameter("rom"); if (var1 == null) { var1 = "spectrum.rom"; } this.spectrum.setBorderWidth(this.getIntParameter("borderWidth", this.spectrum.borderWidth, 0, 100)); this.spectrum.refreshRate = this.getIntParameter("refreshRate", this.spectrum.refreshRate, 1, 100); this.spectrum.sleepHack = this.getIntParameter("sleepHack", this.spectrum.sleepHack, 0, 100); ((Applet)this).resize(this.preferredSize()); String var2 = ((Applet)this).getParameter("showStats"); if (var2 != null) { if (var2.equals("Yes")) { this.spectrum.showStats = true; } else if (var2.equals("No")) { this.spectrum.showStats = false; } } URL var3 = ((Applet)this).getDocumentBase(); this.spectrum.urlField.setText(var3.toString()); URL var4 = new URL(var3, var1); this.spectrum.loadROM(var4.toString(), var4.openStream()); String var5 = ((Applet)this).getParameter("snapshot"); var5 = var5 == null ? ((Applet)this).getParameter("sna") : var5; var5 = var5 == null ? ((Applet)this).getParameter("z80") : var5; if (var5 != null) { URL var6 = new URL(var3, var5); URLConnection var7 = var6.openConnection(); InputStream var8 = var7.getInputStream(); this.spectrum.loadSnapshot(var6.toString(), var8, var7.getContentLength()); var8.close(); } else { this.spectrum.reset(); this.spectrum.refreshWholeScreen(); } } public void run() { ((Applet)this).showStatus(this.getAppletInfo()); if (this.spectrum == null) { try { this.spectrum = new Spectrum(this); this.readParameters(); } catch (Exception var2) { ((Applet)this).showStatus("Caught IO Error: " + ((Throwable)var2).toString()); } } if (this.spectrum != null) { this.spectrum.execute(); } } public int getIntParameter(String var1, int var2, int var3, int var4) { String var5 = ((Applet)this).getParameter(var1); if (var5 == null) { return var2; } else { try { int var6 = Integer.parseInt(var5); if (var6 < var3) { return var3; } else { return var6 > var4 ? var4 : var6; } } catch (Exception var7) { return var2; } } } public void update(Graphics var1) { this.paint(var1); } public void paint(Graphics var1) { if (this.spectrum != null) { this.spectrum.repaint(); } } public boolean handleEvent(Event var1) { return this.spectrum != null ? this.spectrum.handleEvent(var1) : super.handleEvent(var1); } public Dimension minimumSize() { int var1 = this.spectrum == null ? 20 : this.spectrum.borderWidth; return new Dimension(256 + var1 * 2, 192 + var1 * 2); } public Dimension preferredSize() { return this.minimumSize(); } }