2 JPC-RR: A x86 PC Hardware Emulator
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
;
33 import java
.awt
.event
.ActionListener
;
34 import java
.awt
.event
.ActionEvent
;
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
;
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
;
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
;
62 private Plugins pManager
;
64 public PCMonitor(Plugins manager
)
67 panel
= new PCMonitorPanel(this, manager
.getOutputConnector());
68 manager
.addSlaveObject(this, panel
);
70 monitorWindow
= new JFrame("VGA Monitor" + Misc
.emuname
);
71 monitorWindow
.getContentPane().add("Center", panel
.getMonitorPanel());
72 JMenuBar bar
= new JMenuBar();
73 for(JMenu menu
: panel
.getMenusNeeded())
75 monitorWindow
.setJMenuBar(bar
);
77 monitorWindow
.setDefaultCloseOperation(JFrame
.DO_NOTHING_ON_CLOSE
);
78 Dimension d
= monitorWindow
.getSize();
79 nativeWidth
= d
.width
;
80 nativeHeight
= d
.height
;
82 monitorWindow
.setVisible(true);
85 public void sendMessage(String msg
)
87 pManager
.invokeExternalCommand("luaplugin-sendmessage", new Object
[]{msg
});
90 public void eci_pcmonitor_setwinpos(Integer x
, Integer y
)
92 moveWindow(monitorWindow
, x
.intValue(), y
.intValue(), nativeWidth
, nativeHeight
);
95 public boolean systemShutdown()
101 public void pcStopping()
106 public void pcStarting()
111 public void reconnect(PC pc
)
116 public void notifySizeChange(int w
, int h
)
118 //Run it in AWT event thread to avoid deadlocking.
119 SwingUtilities
.invokeLater(new Runnable() { public void run() {
120 monitorWindow
.pack();
121 Dimension d
= monitorWindow
.getSize();
122 nativeWidth
= d
.width
;
123 nativeHeight
= d
.height
;
127 public void notifyRenderer(HUDRenderer r
)
129 pManager
.addRenderer(r
);
132 public void notifyFrameReceived(int w
, int h
)
138 //Panel has its own thread.