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
;
32 import org
.jpc
.emulator
.PC
;
33 import org
.jpc
.emulator
.Clock
;
34 import org
.jpc
.emulator
.EventRecorder
;
36 import org
.jpc
.pluginsbase
.Plugins
;
37 import org
.jpc
.pluginsbase
.Plugin
;
38 import static org
.jpc
.Misc
.moveWindow
;
43 public class TimeDisplay
implements Plugin
45 private JFrame window
;
47 private JLabel display
;
49 private Plugins pluginManager
;
50 private int nativeWidth
, nativeHeight
;
52 public void eci_timedisplay_setwinpos(Integer x
, Integer y
)
54 moveWindow(window
, x
.intValue(), y
.intValue(), nativeWidth
, nativeHeight
);
58 public TimeDisplay(Plugins _pluginManager
)
60 pluginManager
= _pluginManager
;
62 window
= new JFrame("Time Display" + Misc
.emuname
);
65 display
= new JLabel("Time: <NO PC CONNECTED> ");
69 window
.setDefaultCloseOperation(JFrame
.DO_NOTHING_ON_CLOSE
);
70 Dimension d
= window
.getSize();
71 nativeWidth
= d
.width
;
72 nativeHeight
= d
.height
;
73 window
.setVisible(true);
78 //This runs entierely in other threads
81 public boolean systemShutdown()
83 //OK to proceed with JVM shutdown.
87 private void updateTime(long timeNow
, long timeEnd
)
91 text1
= "Time: " + (timeNow
/ 1000000) + " / " + (timeEnd
/ 1000000);
92 else if(timeNow
== -1)
93 text1
= "Time: <NO PC CONNECTED>";
95 text1
= "Time: <N/A>";
96 final String text
= text1
;
98 if(pluginManager
.isShuttingDown())
99 return; //Too much of deadlock risk.
101 if(!SwingUtilities
.isEventDispatchThread())
103 SwingUtilities
.invokeAndWait(new Thread() { public void run() { display
.setText(text
); }});
104 } catch(Exception e
) {
107 display
.setText(text
);
110 public void pcStarting()
115 public void pcStopping()
117 PC
.ResetButton brb
= (PC
.ResetButton
)pc
.getComponent(PC
.ResetButton
.class);
118 EventRecorder rec
= brb
.getRecorder();
119 long lastTime
= rec
.getLastEventTime();
120 updateTime(((Clock
)pc
.getComponent(Clock
.class)).getTime(), lastTime
);
123 public void reconnect(org
.jpc
.emulator
.PC _pc
)
127 PC
.ResetButton brb
= (PC
.ResetButton
)pc
.getComponent(PC
.ResetButton
.class);
128 EventRecorder rec
= brb
.getRecorder();
129 long lastTime
= rec
.getLastEventTime();
130 updateTime(((Clock
)pc
.getComponent(Clock
.class)).getTime(), lastTime
);