Skip to main content

Dragon/CoCO emulator written in Python

DragonPy is a Open source (GPL v3 or later) emulator for the 30 years old homecomputer Dragon 32 and Tandy TRS-80 Color Computer (CoCo)…

Dragon 32 and 64 ROMs in Text mode:

screenshot Dragon 64

CoCo with Extended Color Basic v1.1 in Text mode (running with PyPy):

screenshot CoCo Extended Color BASIC

DragonPy is written in Python. It’s platform independent and runs with Python v2 and v3 and PyPy. It’s tested with Python 2.7.x and 3.4 and PyPy2.

DragonPy will not be a second XRoar written in Python. This project is primarily to lean and understand.

Future goals are:

  • Implement a integrated development environment for BASIC programs

A full featured Dragon / CoCo emulator is XRoar.

Current state

The Dragon 32 / 64 and CoCo ROMs works in Text mode. Also the “single board computer” ROMs sbc09, Simple6809 and Multicomp6809 works well.

There is a rudimentary BASIC editor with save/load BASIC programm listings direct into RAM.

Looks like this:

old screenshot BASIC Editor (older version of the editor)

Vectrex

The Vectrex (Wikipedia) is a vector display-based video game console. The Hardware are only the 6809 CPU, a 6522 Versatile Interface Adapter and the AY-3-8912 sound chip.

Current state is completely not usable. The 6522 is only a dummy implementation. It makes only sense to display some trace lines, e.g.:

...path/to/DragonPy$ python2 DragonPy_CLI.py --verbosity 5 --machine=Vectrex run --trace --max_ops 1

BASIC Editor

Use “BASIC editor / open” in the main menu to open the editor.

You can load/save ASCII .bas files from you local drive or just type a BASIC listing ;) With “inject into DragonPy” you send the current listing from the Editor to the Emulator and with “load from DragonPy” back from emulator to editor. Note: The is currently no “warning” that un-saved content will be “overwritten” and there is no “auto-backup” ;)

The “renumbering” tool can be found in the editor window under “tools”

You can also run the BASIC Editor without the Emulator:

...path/to/DragonPy$ python2 DragonPy_CLI.py editor

A rudimentary BASIC source code highlighting is available and looks like this:

screenshot BASIC Editor

Special feature: The Line number that are used in GOTO, SOGUB etc. are extra marked on the left side.

Currently the code are only differate into:

  • DATA

  • Strings

  • Comments

  • Code

TODO: parse the code, to coloring it differently.

ROMs

The Dragon ROMs can be downloaded here:

There is a simple shell script to automatic download and extract the Dragon ROMs:

...path/to/DragonPy$ ./download_ROMs.sh

Quick start:

# clone the repro:
~$ git clone https://github.com/jedie/DragonPy.git

# Alternative download as .zip: https://github.com/jedie/DragonPy/archive/master.zip

~$ cd DragonPy

# Download all ROM files:
~/DragonPy$ ./download_ROMs.sh

# Start Dragon 32
~/DragonPy$ python2 DragonPy_CLI.py --machine=Dragon32 run

example

start Dragon 32:

...path/to/DragonPy$ python2 DragonPy_CLI.py --machine=Dragon32 run

start Dragon 64:

...path/to/DragonPy$ python2 DragonPy_CLI.py --machine=Dragon64 run

start CoCo with Extended Color Basic v1.1:

...path/to/DragonPy$ python2 DragonPy_CLI.py --machine=CoCo2b run

start Multicomp 6809:

...path/to/DragonPy$ python2 DragonPy_CLI.py --machine=Multicomp6809 run

start Lennart’s 6809 single board computer:

...path/to/DragonPy$ python2 DragonPy_CLI.py --machine=sbc09 run

unittests

Travis CI Status: DragonPy build status on travis-ci.org

run unittests

You can run tests with PyPy, Python 2 and Python 3:

...path/to/DragonPy$ python -m unittest discover

All variants:

...path/to/DragonPy$ python2 -m unittest discover
...path/to/DragonPy$ python3 -m unittest discover
...path/to/DragonPy$ pypy -m unittest discover

create coverage report

install coverage for python 2:

~$ sudo pip2 install coverage
...path/to/DragonPy$ coverage2 run --source=dragonpy setup.py test
...path/to/DragonPy$ coverage2 coverage2 html
# e.g.:
...path/to/DragonPy$ firefox htmlcov/index.html

more screenshots

“sbc09” ROM in Tkinter window:

screenshot sbc09

“Simple6809” ROM in Tkinter window:

screenshot simple6809

Dragon Keyboard

The keyboard mapping is stored into dragonpy/Dragon32/keyboard_map.py.

Some notes:

  • “CLEAR” is mapped to “Home” / “Pos 1” key

  • “BREAK” is mapped to “Escape” button

  • “LEFT” is mapped to left cursor key and to normal backspace, too.

A “auto shift” mode is implemented. So normal lowercase letters would be automaticly converted to uppercase letters.

paste clipboard

It is possible to paste the content of the clipboard as user input in the machine. Just copy (Ctrl-C) the follow content:

10 CLS
20 FOR I = 0 TO 255:
30 POKE 1024+(I*2),I
40 NEXT I
50 I$ = INKEY$:IF I$="" THEN 50

Focus the DragonPy window and use Ctrl-V to paste the content.

Looks like:

http://www.jensdiemer.de/static/jensdiemer.de/screenshots/20140805_DragonPy_Dragon32_Listing.png

Then just RUN and then it looks like this:

http://www.jensdiemer.de/static/jensdiemer.de/screenshots/20140805_DragonPy_Dragon32_CharMap.png

DragonPy schematic

+------------------+                         +---------------------+
|                  |                         |                     |
| +-------------+  |                         |       6809 CPU      |
| |             |  |                         |       +     ^       |
| |     GUI     |  |                         |       |     |       |
| |             |  | Display RAM callback    |    +--v-----+--+    |
| |  .--------------------------------------------+   Memory  |    |
| |  |          |  |                         |    +--+-----^--+    |
| |  |          |  |                         |       |     |       |
| |  |          |  |                         | +-----v-----+-----+ |
| |  |          |  |                         | |    Periphery    | |
| |  |          |  |     Keyboard queue      | |   MC6883 SAM    | |
| |  |          +--------------------------------->MC6821 PIA    | |
| |  |          |  |                         | |                 | |
| +--+-----^----+  |                         | |                 | |
|    |     |       |                         | +-----------------+ |
|    |     |       |                         |                     |
| +--v-----+----+  |                         |                     |
| |             |  |                         |                     |
| |   Display   |  |                         |                     |
| |             |  |                         |                     |
| +-------------+  |                         |                     |
+------------------+                         +---------------------+

performance

The current implementation is not really optimized.

With CPython there is round about 490.000 CPU cycles/sec. in console version. This is half as fast as the real Hardware.

With PyPy round about 6.900.000 - 8.000.000 CPU cycles/sec. In other words with PyPy it’s 8 times faster as the real Hardware.

e.g. The Dragon 32 6809 machine with a 14.31818 MHz crystal runs with: 0,895MHz (14,31818Mhz/16=0,895MHz) in other words: 895.000 CPU-cycles/sec.

There is a simple benchmark. Run e.g.:

...path/to/DragonPy$ python2 DragonPy_CLI.py benchmark
...path/to/DragonPy$ python3 DragonPy_CLI.py benchmark
...path/to/DragonPy$ pypy DragonPy_CLI.py benchmark
...path/to/DragonPy$ pypy3 DragonPy_CLI.py benchmark --loops 10

TODO:

  1. Use bottle for http control server part

  2. implement more Dragon 32 periphery

unimplemented OPs:

  • RESET

  • SWI / SWI2 / SWI3

  • SYNC

missing 6809 unittests after coverage run:

  • MUL

  • BVS

Credits

Some code based on:

ApplePy

An Apple ][ emulator in Python

XRoar A really cool Dragon / CoCo emulator

included Python modules:

python-pager Page output and find dimensions of console.

srecutils.py Motorola S-Record utilities

six Six is a Python 2 and 3 compatibility library.

History

Metadata

Release files for DragonPyEmulator 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for DragonPyEmulator 0.3.0
File Size Uploaded
DragonPyEmulator-0.3.0.tar.gz 462.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for DragonPyEmulator 0.3.0
File Interpreter ABI Platform
DragonPyEmulator-0.3.0-py2-none-any.whl Python 2 none any Details

Total release size: 972.8 kB

Release files / DragonPyEmulator-0.3.0.tar.gz

Download URL DragonPyEmulator-0.3.0.tar.gz
Size 462.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8e3621c5bd5afc464317d14e37967b118e090d83d02031f602ac1c0f1e239879
BLAKE2b-256 checksum
How to use checksums
0671d1e2d66607763c1d7e6715b6474dcacd2c05c341bdbe3d431a846a4a12e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / DragonPyEmulator-0.3.0-py2-none-any.whl

Download URL DragonPyEmulator-0.3.0-py2-none-any.whl
Size 510.0 kB
Tags Python 2
SHA-256 checksum
How to use checksums
3636a8957e86e4b30dd241d2ac2222f95afb7c7e45ce5739aa5f216291642512
BLAKE2b-256 checksum
How to use checksums
5dc83c531e5d10f7548fd3f1373781f1f1c01d3262df03bec003665722cf1030
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page