Add emuname for telling apart multiple emulators
[jpcrr.git] / org / jpc / plugins / PCMonitor.java
blobf95ccb4f6c184e3f53fd1cc2a8abd01360e1eecb
1 /*
2 JPC-RR: A x86 PC Hardware Emulator
3 Release 1
5 Copyright (C) 2007-2009 Isis Innovation Limited
6 Copyright (C) 2009-2010 H. Ilari Liusvaara
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License version 2 as published by
10 the Free Software Foundation.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License along
18 with this program; if not, write to the Free Software Foundation, Inc.,
19 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 Based on JPC x86 PC Hardware emulator,
22 A project from the Physics Dept, The University of Oxford
24 Details about original JPC can be found at:
26 www-jpc.physics.ox.ac.uk
30 package org.jpc.plugins;
32 import java.awt.*;
33 import java.awt.event.ActionListener;
34 import java.awt.event.ActionEvent;
35 import javax.swing.*;
36 import org.jpc.pluginsbase.Plugins;
37 import org.jpc.pluginsbase.Plugin;
38 import org.jpc.pluginsaux.HUDRenderer;
39 import org.jpc.pluginsaux.PCMonitorPanel;
40 import org.jpc.pluginsaux.PCMonitorPanelEmbedder;
41 import org.jpc.Misc;
42 import java.io.*;
43 import java.awt.image.BufferedImage;
44 import java.awt.image.DataBufferInt;
45 import org.jpc.emulator.VGADigitalOut;
46 import org.jpc.emulator.*;
47 import static org.jpc.Misc.moveWindow;
48 import static org.jpc.Misc.errorDialog;
49 import org.jpc.pluginsaux.PNGSaver;
51 /**
53 * @author Rhys Newman
55 public class PCMonitor implements Plugin, PCMonitorPanelEmbedder
57 private static final long serialVersionUID = 7;
58 private int nativeWidth;
59 private int nativeHeight;
60 private JFrame monitorWindow;
61 private PCMonitorPanel panel;
63 public PCMonitor(Plugins manager)
65 panel = new PCMonitorPanel(this);
66 manager.addSlaveObject(this, panel);
68 monitorWindow = new JFrame("VGA Monitor" + Misc.emuname);
69 monitorWindow.getContentPane().add("Center", panel.getMonitorPanel());
70 JMenuBar bar = new JMenuBar();
71 for(JMenu menu : panel.getMenusNeeded())
72 bar.add(menu);
73 monitorWindow.setJMenuBar(bar);
74 monitorWindow.pack();
75 monitorWindow.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
76 Dimension d = monitorWindow.getSize();
77 nativeWidth = d.width;
78 nativeHeight = d.height;
79 panel.startThread();
80 monitorWindow.setVisible(true);
83 public void eci_pcmonitor_setwinpos(Integer x, Integer y)
85 moveWindow(monitorWindow, x.intValue(), y.intValue(), nativeWidth, nativeHeight);
88 public boolean systemShutdown()
90 //JVM will kill us.
91 return true;
94 public void pcStopping()
96 //Not interesting.
99 public void pcStarting()
101 //Not interesting.
104 public void reconnect(PC pc)
106 panel.reconnect(pc);
109 public void notifySizeChange(int w, int h)
111 //Run it in AWT event thread to avoid deadlocking.
112 SwingUtilities.invokeLater(new Runnable() { public void run() {
113 monitorWindow.pack();
114 Dimension d = monitorWindow.getSize();
115 nativeWidth = d.width;
116 nativeHeight = d.height;
117 }});
120 public void notifyFrameReceived(int w, int h)
124 public void main()
126 //Panel has its own thread.