Skip to content

Commit

Permalink
Merge pull request #74 from craigthomas/save-to-disk
Browse files Browse the repository at this point in the history
Add ability to assemble and save or append to disk image
  • Loading branch information
craigthomas authored Sep 21, 2022
2 parents edacccc + edbee39 commit 6d930e4
Show file tree
Hide file tree
Showing 4 changed files with 723 additions and 17 deletions.
22 changes: 21 additions & 1 deletion assembler.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from cocoasm.virtualfiles.virtual_file import VirtualFileType, VirtualFile
from cocoasm.virtualfiles.source_file import SourceFile, SourceFileType
from cocoasm.virtualfiles.coco_file import CoCoFile
from cocoasm.values import NumericValue

# F U N C T I O N S ###########################################################

Expand Down Expand Up @@ -90,7 +91,10 @@ def main(args):
name=program.name or args.name,
load_addr=program.origin,
exec_addr=program.origin,
data=program.get_binary_array()
data=program.get_binary_array(),
extension="bin",
type=NumericValue(0x02),
data_type=NumericValue(0x00),
)

if args.symbols:
Expand Down Expand Up @@ -132,6 +136,22 @@ def main(args):
print("Unable to save cassette file:")
print(error)

if args.dsk_file:
if not coco_file.name:
print("No name for the program specified, not creating disk file")
return
try:
virtual_file = VirtualFile(
SourceFile(args.dsk_file, file_type=SourceFileType.BINARY),
VirtualFileType.DISK
)
virtual_file.open_virtual_file()
virtual_file.add_coco_file(coco_file)
virtual_file.save_virtual_file(append_mode=args.append)
except Exception as error:
print("Unable to save disk file:")
print(error)

# M A I N #####################################################################


Expand Down
Loading

0 comments on commit 6d930e4

Please sign in to comment.