Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user maak ! (Registered 2024-04-18) You are not logged in - nap
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: 2891
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: 1370
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
Account closed

Registered: Oct 2002
Posts: 228
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
Mason/Unicess
TheRyk/MYD!
WVL/Xenon
Oswald/Resource
Guests online: 137
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 The Ghost  (9.6)
10 Bromance  (9.6)
Top onefile Demos
1 It's More Fun to Com..  (9.9)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 Rainbow Connection  (9.5)
6 TRSAC, Gabber & Pebe..  (9.5)
7 Onscreen 5k  (9.5)
8 Dawnfall V1.1  (9.5)
9 Quadrants  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Coders
1 Axis  (9.8)
2 Graham  (9.8)
3 Lft  (9.8)
4 Crossbow  (9.8)
5 HCL  (9.8)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.047 sec.