PyDC converter (was: dragon 32 cassette format ?)

Hardware Hacking, Programming and Game Solutions/Cheats
Post Reply
jedie
Posts: 655
Joined: Wed Aug 14, 2013 12:23 pm
Location: germany
Contact:

PyDC converter (was: dragon 32 cassette format ?)

Post by jedie »

Ì found py-kcs a Encode/Decode "Kansas City Standard Cassette Audio Data": http://dabeaz.blogspot.de/2010/08/using ... sette.html

I tested it with WAV files from dragon 32... It doesn't work.
Think some "config" settings are wrong.

Seems that dragon cassettes are not "Kansas City Standard"...

Somebody have information about the cassette format?
Last edited by jedie on Tue Oct 22, 2013 8:57 am, edited 1 time in total.
... too many ideas and too little time ... Related stuff written in Python:
Dragon 32 emulator / PyDC - Python Dragon 32 converter: https://github.com/jedie/DragonPy
DWLOAD server / Dragon-Lib and other stuff: https://github.com/6809
User avatar
tormod
Posts: 416
Joined: Sat Apr 27, 2013 12:06 pm
Location: Switzerland
Contact:

Re: dragon 32 cassette format ?

Post by tormod »

Most of it is explained in http://www.onastick.clara.net/cosio.htm and http://www.cs.unc.edu/~yakowenk/coco/te ... ormat.html

The source code of "makewav" in Toolshed might also be of interest. makewav can generate WAV from binaries or from CAS files.

See also Tape/Disk Preservation in the wiki.
jedie
Posts: 655
Joined: Wed Aug 14, 2013 12:23 pm
Location: germany
Contact:

Re: dragon 32 cassette format ?

Post by jedie »

Thanks very much!

Than CoCo and dragon saves in the same way?

Is not an official standard? Like the "Kansas City Standard" ?
... too many ideas and too little time ... Related stuff written in Python:
Dragon 32 emulator / PyDC - Python Dragon 32 converter: https://github.com/jedie/DragonPy
DWLOAD server / Dragon-Lib and other stuff: https://github.com/6809
sixxie
Posts: 1346
Joined: Fri Jul 18, 2008 8:36 am
Location: Hertfordshire
Contact:

Re: dragon 32 cassette format ?

Post by sixxie »

The CoCo and Dragon tape formats are the same, yes - with perhaps later CoCos supporting a chunked variant? Haven't actually investigated that yet.

Not sure anyone *ever* used the Kansas City "Standard" - it's terribly inefficient. Wikipedia suggests Acorn used a variant of it, still not the actual standard though.
jedie
Posts: 655
Joined: Wed Aug 14, 2013 12:23 pm
Location: germany
Contact:

Re: dragon 32 cassette format ?

Post by jedie »

My current state of a python decode is here: https://github.com/jedie/python-code-sn ... _decode.py

But now i get only the bit stream. The output of my script looks like this:

Code: Select all

Read 'HelloWorld1 origin.wav'...
Numer of audio frames: 109923
Framerate: 44100
samplewidth: 2
channels: 1
struct_unpack_str: <h
00100000001010101010101010101010101010101010101010101010101010101010101
01010101010101010101010101010101010101010101010101010101010101010101010
10101010101010101010101010101010101010101010101010101010101010101010101
01010101010101010101010101010101010101010101010101010101010101010101010
10101010101010101010101010101010101010101010101010101010101010101010101
01010101010101010101010101010101010101010101010101010101010101010101010
10101010101010101010101010101010101010101010101010101010101010101010101
01010101010101010101010101010101010101010101010101010101010101010101010
10101010101010101010101010101010101010101010101010101010101010101010101
01010101010101010101010101010101010101010101010101010101010101010101010
10101010101010101010101010101010101010101010101010101010101010101010101
01010101010101010101010101010101010101010101010101010101010101010101010
10101010101010101010101010101010101010101010101010101010101010101010101
01010101010101010101010101010101010101010101010101010101010101010101010
10101010101010101010101010101010101010001111000000000011110000000001000
00001000000010000000100000001000000010000000100000001000000000000000000
00000000000000000000000000000000000000001111000010101010000000000000000
00000000010101010101010101010101010101010101010101010101010101010101010
10101010101010101010101010101010101010101010101010101010101010101010101
01010101010101010101010101010101010101010101010101010101010101010101010
10101010101010101010101010101010101010101010101010101010101010101010101
01010101010101010101010101010101010101010101010101010101010101010101010
10101010101010101010101010101010101010101010101010101010101010101010101
01010101010101010101010101010101010101010101010101010101010101010101010
10101010101010101010101010101010101010101010101010101010101010101010101
01010101010101010101010101010101010101010101010101010101010101010101010
10101010101010101010101010101010101010101010101010101010101010101010101
01010101010101010101010101010101010101010101010101010101010101010101010
10101010101010101010101010101010101010101010101010101010101010101010101
01010101010101010101010101010101010101010101010101010101010101010101010
10101010101010101010101010101010101010101010101010101010101010101010101
01010101010101010101010101010101010101010101010001111001000000001001100
01111000010010000000000001010000000000010000010010010010000001001101001
10000010010001100000001000011110000000100100011000000110000000000011110
00100101000000000000101000111000000000010010010010110111000100010000010
01010100010001100100011001011110010000001001110101011110010010010100011
00100010001010000100010001000000000001111000100011000000000001111000110
10000000001001001001000000000000000000000000011101010101010101010101000
2734 bits decoded.
One problem: I don't know how to automatic the EVEN/ODD startpoint (Variable 'even_odd')
If a wrong "start point" given, i get wrong data :(
... too many ideas and too little time ... Related stuff written in Python:
Dragon 32 emulator / PyDC - Python Dragon 32 converter: https://github.com/jedie/DragonPy
DWLOAD server / Dragon-Lib and other stuff: https://github.com/6809
User avatar
robcfg
Posts: 1529
Joined: Sat Apr 04, 2009 10:16 pm
Location: Stockholm, Sweden
Contact:

Re: dragon 32 cassette format ?

Post by robcfg »

From my experience, it's difficult to make a full-automatic wav to cas translation, as tapes usually contain errors or incorrect pulses.

For difficult tapes, I made a program that outputs the bit stream, as yours do, and then I manually try to fix the errors.

As for converting the stream to a cas file, you'll have to emulate the Dragon behaviour or check for start of blocks by taking 8 bits, check if it's a block start marker, continue reading bytes until end of block, or discard the first bit, get another from the stream and check again.

That will do for tapes without copy protection.
jedie
Posts: 655
Joined: Wed Aug 14, 2013 12:23 pm
Location: germany
Contact:

Re: dragon 32 cassette format ?

Post by jedie »

A little bit future:

HelloWorld1 origin.wav

Code: Select all

Numer of audio frames: 109923
read...
Framerate: 44100
samplewidth: 2
channels: 1
struct_unpack_str: <h
2735 bits decoded.
Start leader '01010101' found at position: 9
bits before header: 001000000
Block pos: 1016-192 len: 192bits rest: 1518bits
-------------------------------------------------------------------------------
  *** file info block data:
01010100 01111000 00000001 11100000 00001000 00001000 00001000 00001000
00001000 00001000 00001000 00001000 00000000 00000000 00000000 00000000
00000000 00000000 00000001 11100001 01010100 00000000 00000000 00000001
-------------------------------------------------------------------------------
  *** data block 1
  Block pos: 1024-440 len: 192bits rest: 54bits
01010100 01111001 00000000 10011000 11110000 10010000 00000000 10100000
00000010 00001001 00100100 00001001 10100110 00001001 00011000 00001000
01111000 00001001 00011000 00011000 00000000 11110001 00101000 00000000
01010001 11000000 00001001 00100101 10111000 10001000 00100101 01000100
01100100 01100101 11100100 00001001 11010101 11100100 10010100 01100100
01000101 00001000 10001000 00000000 11110001 00011000 00000000 11110001
10100000 00001001 00100100 00000000 00000000 00000001 11010101
-------------------------------------------------------------------------------
  *** data block 2
  Block pos: 8-0 len: 192bits rest: 0bits
01010100 01111001 11111110 00000001 11111111 010101
-------------------------------------------------------------------------------
HelloWorld1 xroar.wav

Code: Select all

Numer of audio frames: 75025
read...
Framerate: 22050
samplewidth: 1
channels: 1
struct_unpack_str: b
4760 bits decoded.
Start leader '01010101' found at position: 2
bits before header: 11
Block pos: 2048-160 len: 160bits rest: 2550bits
-------------------------------------------------------------------------------
  *** file info block data:
01010100 01111000 00000001 11100000 00001000 00001000 00001000 00001000
00001000 00001000 00001000 00001000 00000000 00000000 00000000 00000000
00000000 00000000 00000001 11100001
-------------------------------------------------------------------------------
  *** data block 1
  Block pos: 2056-440 len: 160bits rest: 54bits
01010100 01111001 00000000 10011000 11110000 10010000 00000000 10100000
00000010 00001001 00100100 00001001 10100110 00001001 00011000 00001000
01111010 00001001 00011000 00011000 00000000 11110001 00101000 00000000
01010001 11000010 00001001 00100101 10111000 10001000 00100101 01000100
01100100 01100101 11100100 00001001 11010101 11100100 10010100 01100100
01000101 00001000 10001000 00000000 11110001 00011000 00000000 11110001
10100010 00001001 00100100 00000000 00000000 00000001 11010101
-------------------------------------------------------------------------------
  *** data block 2
  Block pos: 8-0 len: 160bits rest: 0bits
01010100 01111001 11111110 00000001 11111111 010101
-------------------------------------------------------------------------------
Source: https://github.com/jedie/python-code-sn ... _decode.py

EDIT: Have reload the two test WAV files in XRoar and the listing ist the same:

Code: Select all

10 FOR I = 1 TO 10
20 PRINT I;"HELLO WORLD!"
30 NEXT I
Seems that "data block 1" is ok, isn't it?

Now i whanted to know how to convert the bits into ASCII...
... too many ideas and too little time ... Related stuff written in Python:
Dragon 32 emulator / PyDC - Python Dragon 32 converter: https://github.com/jedie/DragonPy
DWLOAD server / Dragon-Lib and other stuff: https://github.com/6809
User avatar
robcfg
Posts: 1529
Joined: Sat Apr 04, 2009 10:16 pm
Location: Stockholm, Sweden
Contact:

Re: dragon 32 cassette format ?

Post by robcfg »

That is easy,

Code: Select all

from array import *

bits = array('B',[1,0,1,0,1,0,1,0])
byte = 0

for bit in range(8):
    byte = byte | (bits[bit] << bit)

print '%#X' % byte
jedie
Posts: 655
Joined: Wed Aug 14, 2013 12:23 pm
Location: germany
Contact:

Re: dragon 32 cassette format ?

Post by jedie »

Have try this, without success...

Maybe my binary data is wrong...

Exist somewhere a binary<->ascii table ?
... too many ideas and too little time ... Related stuff written in Python:
Dragon 32 emulator / PyDC - Python Dragon 32 converter: https://github.com/jedie/DragonPy
DWLOAD server / Dragon-Lib and other stuff: https://github.com/6809
Rink
Posts: 236
Joined: Mon Sep 05, 2011 7:01 pm

Re: dragon 32 cassette format ?

Post by Rink »

AsciiTable.com lists the codes for the ASCII character set, and there's a good character map in Inside The Dragon if I remember correctly.

Edit: Link - http://dragondata.worldofdragon.org/Pub ... Dragon.pdf
Edit: Damn. Wrong book. I was thinking of The Dragon Companion but that's not in the archive by the looks of it. I have a PDF at home if needed.

Edit: I give up. Can't think straight this morning (or read apparently).
Post Reply