Skip to main content

Emulator for 6809 CPU based system like Dragon 32 / CoCo written in Python...

Project description

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)…

The MC6809 project is used to emulate the 6809 CPU.

Build Status on travis-ci.org

travis-ci.org/jedie/DragonPy

Coverage Status on coveralls.io

coveralls.io/r/jedie/DragonPy

Requirements Status on requires.io

requires.io/github/jedie/DragonPy/requirements/

Dragon 32 with CPython 3 under Linux:

screenshot Dragon 32

Tandy TRS-80 Color Computer 2b with CPython 2 under Windows:

screenshot CoCo under Windows

DragonPy is written in Python. It’s platform independent and runs with Python and PyPy under Linux/Windows/OSX/… It’s tested with Python 2.7.x and 3.4, PyPy2 and PyPy3.

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.:

(DragonPy_env)~/DragonPy_env$ bin/python src/dragonpy/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:

(DragonPy_env)~/DragonPy_env$ bin/python src/dragonpy/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.

installation

IMPORTANT: The PyPi package name is DragonPyEmulator and not only “DragonPy”!!!

by foot

e.g.:

# Create virtualenv:
.../$ python3 -Im venv DragonPy

# activate created virtualenv:
.../$ cd DragonPy
.../DragonPy$ source bin/activate

# update pip before install:
(DragonPy) .../DragonPy$ pip install -U pip
...

# Install DragonPy:
(DragonPy) .../DragonPy$ pip install DragonPyEmulator
Collecting DragonPyEmulator
...
Installing collected packages: click, six, dragonlib, pygments, MC6809, DragonPyEmulator
Successfully installed DragonPyEmulator-0.5.3 MC6809-0.5.0 click-6.7 dragonlib-0.1.7 pygments-2.2.0 six-1.11.0

# start Emulator
(DragonPy) .../DragonPy$ DragonPy

Linux

The is a virtualenv bootstrap file, created with bootstrap_env, for easy installation.

Get the bootstrap file:

/home/FooBar$ wget https://raw.githubusercontent.com/jedie/DragonPy/master/boot_dragonpy.py

There are tree types of installation:

option

desciption

pypi

use Python Package Index (for all normal user!)

git_readonly

use git to get the sourcecode (for developer without write access)

dev

use git with write access

e.g.:

/home/FooBar$ python3 boot_dragonpy.py ~/DragonPy_env --install_type git_readonly

This creates a virtualenv in ``~/DragonPy_env`` and used git to checkout the needed repositories.

In this case (using –install_type=**git_readonly**) the git repository are in: …/DragonPy_env/src/ So you can easy update them e.g.:

/home/FooBar$ cd ~/DragonPy_env/src/dragonpy
/home/FooBar/DragonPy_env/src/dragonpy$ git pull

start DragonPy

The is a simple “starter GUI”, just call the cli without arguments:

~/DragonPy_env/bin/DragonPy

Or call it in a activated environment, e.g.:

/home/FooBar$ cd DragonPy_env
/home/FooBar/DragonPy_env$ source bin/activate
(DragonPy_env)~/DragonPy_env$ DragonPy

It is possible to start machines directly:

(DragonPy_env)~/DragonPy_env$ DragonPy --machine=Dragon32 run

more info:

(DragonPy_env)~/DragonPy_env$ DragonPy --help

Windows

There are several ways to install the project under windows.

The following is hopeful the easiest one:

The default boot_dragonpy.cmd will install via Python Package Index (PyPi) into %APPDATA%\DragonPy_env

start DragonPy

The is a simple “starter GUI”, just call the cli without arguments:

%APPDATA%\DragonPy_env\Scripts\DragonPy.exe

It looks like this:

starter GUI

ROMs

All needed ROM files, will be downloaded automatically.

The files will be downloaded from:

Dragon 32 + 64

http://archive.worldofdragon.org/archive/index.php?dir=Roms/Dragon/

CoCo 2b

http://mess.oldos.net/

Multicomp

http://searle.hostei.com/grant/Multicomp/

Simple6809

http://searle.hostei.com/grant/6809/Simple6809.html

sbc09 and vectrex ROMs are included.

All ROM files and download will be checked by SHA1 value, before use.

unittests

run unittests

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

(DragonPy_env)~/DragonPy_env/src/dragonpy$ python -m unittest discover

or:

(DragonPy_env)~/DragonPy_env/src/dragonpy$ ./setup.py test

create coverage report

install coverage for python 2:

~$ sudo pip2 install coverage
...path/to/env/src/dragonpy$ coverage2 run --source=dragonpy setup.py test
...path/to/env/src/dragonpy$ coverage2 coverage2 html
# e.g.:
...path/to/env/src/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:

https://raw.githubusercontent.com/jedie/jedie.github.io/master/screenshots/DragonPy/20140805_DragonPy_Dragon32_Listing.png

Then just RUN and then it looks like this:

https://raw.githubusercontent.com/jedie/jedie.github.io/master/screenshots/DragonPy/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.

TODO:

  1. implement more Dragon 32 periphery

missing 6809 unittests after coverage run:

  • MUL

  • BVS

PyDragon32

Some Python/BASIC tools/scripts around Dragon32/64 / CoCo homecomputer.

All script are copyleft 2013-2014 by Jens Diemer and license unter GNU GPL v3 or above, see LICENSE for more details.

Python scripts:

BASIC programms:

Input/Output Tests

/BASIC/InputOutput/keyboard.bas Display memory Locations $0152 - $0159 (Keyboard matrix state table)

Example screenshow with the “Y” key is pressed down. You see that this is saved in $0153:

KeyBoard Screenshot 01

Example with “U” is hold down:

KeyBoard Screenshot 02

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

requirements

dragonlib Dragon/CoCO Python Library

MC6809 Implementation of the MC6809 CPU in Python

pygments generic syntax highlighter

History

donation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

DragonPyEmulator-0.6.0rc1.tar.gz (1.6 MB view details)

Uploaded Source

Built Distributions

DragonPyEmulator-0.6.0rc1-py3.6.egg (352.2 kB view details)

Uploaded Source

DragonPyEmulator-0.6.0rc1-py2.py3-none-any.whl (368.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file DragonPyEmulator-0.6.0rc1.tar.gz.

File metadata

File hashes

Hashes for DragonPyEmulator-0.6.0rc1.tar.gz
Algorithm Hash digest
SHA256 c10e1ad0dad3449c4882ca55e24c8358b3912159e1bc5b5aafcca4e1ea41de17
MD5 cd3b34551b1cee28d30dd0bbf3bf0a7e
BLAKE2b-256 ef45006c2c86a58848132deea7d621d7b286c001e444008cb0be01f7b25d006f

See more details on using hashes here.

Provenance

File details

Details for the file DragonPyEmulator-0.6.0rc1-py3.6.egg.

File metadata

File hashes

Hashes for DragonPyEmulator-0.6.0rc1-py3.6.egg
Algorithm Hash digest
SHA256 17384fb743295a7cc936fee8ae093404ac870b4a6731bfbdcd023b3639f4dce5
MD5 8cc97f572ceaf95c671a67f9626f00fb
BLAKE2b-256 09279bb54279dec9d5977699084d4a44cacf4be7e2746c1822e2e81585138be9

See more details on using hashes here.

Provenance

File details

Details for the file DragonPyEmulator-0.6.0rc1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for DragonPyEmulator-0.6.0rc1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7c8ef27469ccf1bd5987d8e6cad8e105b1833eeac16d6e4b95893abaf86ab601
MD5 1c858097ad53b3b81df4c66ec40d9db0
BLAKE2b-256 b659bff5ddda4715bde8048227cb3639c63d32babacbe5be477d685bda8cec3a

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page