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 old (1981) homecomputer Dragon 32 and Tandy TRS-80 Color Computer (CoCo)...

The MC6809 project is used to emulate the 6809 CPU.

tests codecov dragonpy @ PyPi Python Versions License GPL-3.0-or-later

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

(Note: Python 2 support was removed)

DragonPy is written in Python. It's platform independent and runs with Python and PyPy under Linux/Windows/OSX/... It's tested with Python 3.x, PyPy

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$ poetry run DragonPy --verbosity 0 --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$ make editor
# or:
.../DragonPy$ poetry run DragonPy 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"!!!

pip install DragonPyEmulator

from source

~$ git clone https://github.com/jedie/DragonPy.git
~$ cd DragonPy/
~/DragonPy$ ./cli.py --help

The output of ./cli.py --help looks like:

Usage: ./cli.py [OPTIONS] COMMAND [ARGS]...

╭─ Options ────────────────────────────────────────────────────────────────────────────────────────╮
│ --help      Show this message and exit.                                                          │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ───────────────────────────────────────────────────────────────────────────────────────╮
│ check-code-style            Check code style by calling darker + flake8                          │
│ coverage                    Run and show coverage.                                               │
│ download-roms               Download/Test only ROM files                                         │
│ editor                      Run only the BASIC editor                                            │
│ fix-code-style              Fix code style of all dragonpy source code files via darker          │
│ gui                         Start the DragonPy tkinter starter GUI                               │
│ install                     Run pip-sync and install 'dragonpy' via pip as editable.             │
│ log-list                    List all exiting loggers and exit.                                   │
│ mypy                        Run Mypy (configured in pyproject.toml)                              │
│ publish                     Build and upload this project to PyPi                                │
│ run                         Run a machine emulation                                              │
│ safety                      Run safety check against current requirements files                  │
│ test                        Run unittests                                                        │
│ tox                         Run tox                                                              │
│ update                      Update "requirements*.txt" dependencies files                        │
│ update-test-snapshot-files  Update all test snapshot files (by remove and recreate all snapshot  │
│                             files)                                                               │
│ version                     Print version and exit                                               │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯

The output of ./cli.py run --help looks like:

Usage: ./cli.py run [OPTIONS]

 Run a machine emulation

╭─ Options ────────────────────────────────────────────────────────────────────────────────────────╮
│ --verbosity           [1|10|20|30|40|50|99|100]            1:hardcode DEBUG ;), 10:DEBUG,        │
│                                                            20:INFO, 30:WARNING, 40:ERROR,        │
│                                                            50:CRITICAL/FATAL, 99:nearly all off, │
│                                                            100:all off                           │
│                                                            [default: 100]                        │
│ --trace/--no-trace                                         Create trace lines                    │
│                                                            [default: no-trace]                   │
│ --max-ops             INTEGER                              If given: Stop CPU after given cycles │
│                                                            else: run forever                     │
│ --machine             [CoCo2b|Dragon32|Dragon64|Multicomp  Used machine configuration            │
│                       6809|Simple6809|Vectrex|sbc09]       [default: Dragon32]                   │
│ --help                                                     Show this message and exit.           │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯

Usage e.g.:

~/DragonPy$ ./cli.py run
~/DragonPy$ ./cli.py editor

ROMs

All needed ROM files, will be downloaded automatically.

The files will be downloaded from:

Machine download url
Dragon 32 + 64 http://archive.worldofdragon.org/archive/index.php?dir=Software/Dragon/Dragon%20Data%20Ltd/Dragon%20Firmware/
CoCo 2b http://www.roust-it.dk/coco/roms/
Multicomp http://searle.x10host.com/Multicomp/index.html
Simple6809 http://searle.x10host.com/6809/Simple6809.html

sbc09 and Vectrex ROMs are included.

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

run tests

e.g.:

~/DragonPy$ ./devshell.py pytest

or

~/DragonPy$ ./devshell.py tox

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:

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

Then just RUN and then it looks like this:

raw.githubusercontent.com/jedie/jedie.github.io/master/screenshots/DragonPy/20140805_DragonPy_Dragon32_CharMap.png

DragonPy schematic

        Main Thread                                     Sub Thread
       (Tkinter GUI)
    +------------------+                         +---------------------+
    |                  |                         |                     |
    | +-------------+  |  CPU cycles/sec queue   |                     |
    | |            <------------------------------------+6809 CPU      |
    | |             |  |                         |       +     ^       |
    | |     GUI     |  |                         |       |     |       |
    | |             |  | Display RAM write queue |    +--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:

  • 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-2020 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

Links

Some links:

Source codes:

Dragon 32 resources:

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

Links:

| Forum | http://forum.pylucid.org/ | | IRC | #pylucid on freenode.net | | Jabber | pylucid@conference.jabber.org | | PyPi | pypi.org/project/DragonPyEmulator/ | | Github | github.com/jedie/DragonPy |

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.8.0.tar.gz (128.3 kB view details)

Uploaded Source

Built Distribution

DragonPyEmulator-0.8.0-py3-none-any.whl (98.7 kB view details)

Uploaded Python 3

File details

Details for the file DragonPyEmulator-0.8.0.tar.gz.

File metadata

  • Download URL: DragonPyEmulator-0.8.0.tar.gz
  • Upload date:
  • Size: 128.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for DragonPyEmulator-0.8.0.tar.gz
Algorithm Hash digest
SHA256 e60b0a90514e4c3faf59357c6db1139a0870a8aa68ba8ed70d57e7913be8c2b0
MD5 d4942ec79b9097b95f82a8b2a0782e99
BLAKE2b-256 1442c32efe9d05d3713201a8db611136d3d4701686077755648d016771648b11

See more details on using hashes here.

Provenance

File details

Details for the file DragonPyEmulator-0.8.0-py3-none-any.whl.

File metadata

File hashes

Hashes for DragonPyEmulator-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a1c1fa161968820bb2dff6da2bbf0dbfe4a48f03b2504d6e97acb47ef254462e
MD5 2f8e2f34d780e83a0d4c7f7bedff0843
BLAKE2b-256 dcd0d98b11fe99dcd7f4b1970b162b7d26aff811812009127804fc33ee687df3

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