-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
8,037 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
#!/usr/bin/env python2 | ||
# encoding:utf-8 | ||
|
||
""" | ||
Dragon 64 console | ||
~~~~~~~~~~~~~~~~~ | ||
:created: 2014 by Jens Diemer - www.jensdiemer.de | ||
:copyleft: 2014 by the DragonPy team, see AUTHORS for more details. | ||
:license: GNU GPL v3 or above, see LICENSE for more details. | ||
""" | ||
|
||
import Queue | ||
import sys | ||
import threading | ||
import time | ||
|
||
from dragonpy.Dragon64.config import Dragon64Cfg | ||
from dragonpy.Dragon32.periphery_dragon import Dragon32Periphery | ||
from dragonpy.components.cpu6809 import CPU | ||
from dragonpy.components.memory import Memory | ||
from dragonpy.utils.logging_utils import log | ||
from dragonpy.utils.logging_utils import setup_logging | ||
|
||
|
||
CFG_DICT = { | ||
"verbosity":None, | ||
"display_cycle":False, | ||
|
||
"trace":None, | ||
# "trace":True, | ||
|
||
"max_ops":None, | ||
# "max_ops":5000, | ||
|
||
"bus_socket_host":None, | ||
"bus_socket_port":None, | ||
"ram":None, | ||
"rom":None, | ||
|
||
"use_bus":False, | ||
} | ||
|
||
|
||
class Dragon32Periphery2(Dragon32Periphery): | ||
def update(self, cpu_cycles): | ||
super(Dragon32Periphery2, self).update(cpu_cycles) | ||
if self.running: | ||
self._handle_events() | ||
else: | ||
self.exit() | ||
|
||
def mainloop(self, cpu): | ||
log.critical("Pygame mainloop started.") | ||
while cpu.running: | ||
self._handle_events() | ||
|
||
self.exit() | ||
log.critical("Pygame mainloop stopped.") | ||
|
||
|
||
class Dragon64(object): | ||
def __init__(self): | ||
self.cfg = Dragon64Cfg(CFG_DICT) | ||
|
||
self.periphery = Dragon32Periphery2(self.cfg) | ||
self.cfg.periphery = self.periphery | ||
|
||
memory = Memory(self.cfg) | ||
self.cpu = CPU(memory, self.cfg) | ||
memory.cpu = self.cpu # FIXME | ||
|
||
self.last_update = None | ||
self.last_cycles = None | ||
self.display_cycle_interval() | ||
|
||
def display_cycle_interval(self): | ||
if self.last_update is not None: # Skip the first time call. | ||
cycles = self.cpu.cycles - self.last_cycles | ||
duration = time.time() - self.last_update | ||
log.critical( | ||
"%i cycles/sec (%i cycles in last %isec)", | ||
int(cycles / duration), cycles, duration | ||
) | ||
|
||
self.last_cycles = self.cpu.cycles | ||
self.last_update = time.time() | ||
if self.periphery.running and self.cpu.running: | ||
t = threading.Timer(5.0, self.display_cycle_interval) | ||
t.deamon = True | ||
t.start() | ||
|
||
def update_display_interval(self): | ||
self.periphery.update(self.cpu.cycles) | ||
if self.periphery.running and self.cpu.running: | ||
t = threading.Timer(0.25, self.update_display_interval) | ||
t.deamon = True | ||
t.start() | ||
|
||
def run(self): | ||
self.update_display_interval() | ||
|
||
cpu = self.cpu | ||
cpu.reset() | ||
max_ops = self.cfg.cfg_dict["max_ops"] | ||
if max_ops: | ||
log.critical("Running only %i ops!", max_ops) | ||
for __ in xrange(max_ops): | ||
cpu.get_and_call_next_op() | ||
if not cpu.running: | ||
break | ||
log.critical("Quit CPU after given 'max_ops' %i ops.", max_ops) | ||
cpu.quit() | ||
else: | ||
while cpu.running: | ||
cpu.get_and_call_next_op() | ||
|
||
self.periphery.exit() | ||
|
||
|
||
if __name__ == '__main__': | ||
print "Startup Dragon 64 machine..." | ||
setup_logging(log, | ||
# level=1 # hardcore debug ;) | ||
# level=10 # DEBUG | ||
# level=20 # INFO | ||
# level=30 # WARNING | ||
# level=40 # ERROR | ||
# level=50 # CRITICAL/FATAL | ||
level=60 | ||
) | ||
c = Dragon64() | ||
c.run() | ||
|
||
print " --- END --- " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
# https://github.com/jedie/PyDragon32/tree/master/misc#readme | ||
|
||
( | ||
set -x | ||
python2 Dragon64_test.py | python ../PyDragon32/misc/filter_xroar_trace.py --display --start-stop=B3D9-ffff | tee Dragon64_test_trace.txt | ||
#~ python2 Dragon64_test.py | python ../PyDragon32/misc/filter_xroar_trace.py --unique | tee Dragon64_test_trace.txt | ||
#~ python2 Dragon64_test.py > Dragon64_test_trace.txt | ||
#~ python2 Dragon64_test.py | tee Dragon64_test_trace.txt | ||
) | ||
echo | ||
read -n1 -p "Start bash? [y,n]" doit | ||
echo | ||
case $doit in | ||
y|Y) | ||
bash -i | ||
exit 0 | ||
;; | ||
n|N) | ||
echo "bye bye" | ||
;; | ||
*) | ||
echo "input, don't know, bye." | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.