Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user ediman ! (Registered 2019-07-15) You are not logged in 
CSDb User Forums


Forums > CSDb Entries > Release id #178591 : Dataliner - Native Python 2.7 Script
2019-06-22 11:48
Moloch

Registered: Jan 2002
Posts: 2052
Release id #178591 : Dataliner - Native Python 2.7 Script

Submitted by zzarko [PM] on 22 June 2019
I have modified dataliner script to work with Python 2 and Python 3, so no two versions are needed. You can find it at:

https://pastebin.com/18VzwuPg

I have tested the output of original Python 2 script and modified-one with Python 2 and Python 3, and diff says that the outputs are identical (although, I tested with only one input file, so maybe more testing is needed).
2019-06-23 11:03
ChristopherJam

Registered: Aug 2004
Posts: 941
And here's a shorter version, with the multiple passes over the data removed and the temporary file with one text line per data byte optimised out.

from __future__ import print_function
import sys

print()

if len(sys.argv)<4:
    print("Please enter all needed parameters:")
    print("Example: dataliner file.prg data.txt 100")
    print()
    print("This converts the binary data of file.prg into C64 V2 Basic data lines beginning "+
        "with line 100, stored in the file data.txt, which you can integrate in your Basic "+
        "listing with any text editor and copy and paste into VICE.")
    sys.exit()

with open(sys.argv[1], "rb") as f:
    if sys.version_info < (3, 0):
        src=[ord(v) for v in f.read()]
    else:
        src= f.read()

length=len(src)

if length < 3:
    print("Aborting. Selected binary file is too small!")
    sys.exit()

load_addr = src[1]*256+src[0]
line_number = int(sys.argv[3])

with open(sys.argv[2],'w+') as h:
    for i in range(2,length,16): # Die ersten beiden Adressbytes des C64 PRGs fliegen raus
        print("{} data {}".format(line_number, ",".join(str(x) for x in src[i:i+16])), file=h)
        line_number += 1

print("No. of bytes in DATA stream, omiting the first  2 address-bytes:", length-2)
print("File is loading in C64 memory at ${:04x}".format(load_addr))
print("Read into C64 memory from {} to {} + {}".format(load_addr, load_addr, length-3))
print("Location of text file with C64 Basic DATAs:   " + sys.argv[2])
print()

2019-06-25 16:01
Mr.Ammo

Registered: Oct 2002
Posts: 195
Nice one, Christopher Jam.
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
raphis/HF
Mibri/ATL
E$G/HoKuTo FOrCE
Guests online: 32
Top Demos
1 Unboxed  (9.7)
2 Uncensored  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 The Shores of Reflec..  (9.6)
7 Lunatico  (9.6)
8 Wonderland XII  (9.5)
9 C=Bit 18  (9.5)
10 X Marks the Spot  (9.5)
Top onefile Demos
1 Smile to the Sky  (9.5)
2 Dawnfall V1.1  (9.5)
3 Crystal Gazer  (9.5)
4 Daah, Those Acid Pil..  (9.5)
5 Rewind  (9.5)
6 Instinct  (9.5)
7 Pandemoniac Part 5 o..  (9.5)
8 Innervasion  (9.4)
9 Bad Boy  (9.4)
10 Arok 20 Invitation  (9.4)
Top Groups
1 Fossil  (9.8)
2 PriorArt  (9.7)
3 Performers  (9.6)
4 Oxyron  (9.4)
5 Booze Design  (9.4)
Top Original Suppliers
1 hedning  (9.8)
2 Derbyshire Ram  (9.1)
3 Jazzcat  (9.1)
4 Irata  (9.0)
5 Fungus  (9.0)

Home - Disclaimer
Copyright © No Name 2001-2019
Page generated in: 0.052 sec.