Compare commits

...

2 Commits

Author SHA1 Message Date
29259e36da Replaced build script with Makefile 2020-09-20 20:17:32 +02:00
7fe2758af7 Moved some of the script to tools 2020-09-19 23:06:01 +02:00
5 changed files with 19 additions and 214 deletions

19
Makefile Normal file
View File

@ -0,0 +1,19 @@
BUILDDIR=.build
_BIN= rom_monitor.bin ram_monitor.bin cpm22.bin bios.bin putsys.bin loader.bin MONITOR.COM
BIN = $(patsubst %,$(BUILDDIR)/%,$(_BIN))
$(BUILDDIR)/%.bin: src/%.z80
@zasm -w -i $< -o $@
$(BUILDDIR)/%.COM: src/%.z80
@zasm -w -i $< -o $@
$(BUILDDIR):
@mkdir $(BUILDDIR)
all: $(BUILDDIR) $(BIN)
.PHONE: clean
clean:
@rm -df $(BUILDDIR)/*.bin $(BUILDDIR)/*.COM $(BUILDDIR)/*.lst .build

View File

@ -1,99 +0,0 @@
#!/usr/bin/env python3
import math
pageSize = 128
sectorsPerTrack = 256
blockSize = 16384
maxDirs = 128
dirBlocks = 1
out = open('.build/disk.img', 'wb')
def addBootloader(name):
loader = open(name, 'rb')
b = loader.read()
if len(b) > pageSize:
raise RuntimeError("Bootloader binary cannot be larger than one page")
out.seek(0)
out.write(b)
def addOS(cpmName, biosName):
cpm = open(cpmName, 'rb')
bios = open(biosName, 'rb')
b = cpm.read()
out.seek(pageSize)
out.write(b)
b = bios.read()
out.seek(pageSize + 0x1600)
out.write(b)
def seekBlock(i):
# Blocks start at track 1, sector 0
out.seek(pageSize*sectorsPerTrack + i*blockSize)
def initDirs():
seekBlock(0)
out.write(bytearray(([0xe5] + [0x00] * 31) * maxDirs))
fileCounter = 0
def addFile(filename, n, t):
global fileCounter
if fileCounter > maxDirs:
raise RuntimeError("Max dir entries has been reached")
fileCounter += 1
if len(n) > 8:
raise RuntimeError("Filename cannot be longer than 8")
if len(t) > 3:
raise RuntimeError("Filetype cannot be longer than 3")
f = open(filename, 'rb')
b = f.read()
seekBlock(0)
out.seek(32*fileCounter, 1)
# Write user (assume 0 for now)
out.write(bytearray(1))
# Write the name
out.write(n.upper().encode("ascii"))
out.write((" " * (8-len(n))).encode("ascii"))
# Write the type
out.write(t.upper().encode("ascii"))
out.write((" " * (3-len(t))).encode("ascii"))
# Write extend (assume no extend for now)
out.write(bytearray(2))
# Reserved byte
out.write(bytearray(1))
# Number of records (Again assuming no extends <128)
out.write(math.ceil(len(b)/128).to_bytes(1, byteorder='little'))
# We are assuming one block per file for now, so we can use fileCounter
out.write(fileCounter.to_bytes(2, byteorder='little'))
seekBlock(fileCounter)
out.write(b)
addBootloader('.build/loader.bin')
addOS('.build/cpm22.bin', '.build/bios.bin')
initDirs()
addFile(".build/MONITOR.COM", "MONITOR", "COM")
addFile("bin/STAT.COM", "STAT", "COM")
addFile("../qe/.build/test.com", "test", "COM")
addFile("../qe/.build/qe.com", "qe", "COM")
addFile("../xed/.build/xed.com", "xed", "COM")

View File

@ -1,8 +0,0 @@
#!/bin/bash
mkdir -p .build && zasm -w -i src/rom_monitor.z80 -o .build/rom_monitor.bin
mkdir -p .build && zasm -i src/ram_monitor.z80 -o .build/ram_monitor.bin
mkdir -p .build && zasm -i src/cpm22.z80 -o .build/cpm22.bin
mkdir -p .build && zasm -i src/bios.z80 -o .build/bios.bin
mkdir -p .build && zasm -i src/putsys.z80 -o .build/putsys.bin
mkdir -p .build && zasm -i src/loader.z80 -o .build/loader.bin
mkdir -p .build && zasm -i src/MONITOR.z80 -o .build/MONITOR.COM

View File

@ -1,58 +0,0 @@
#!/usr/bin/env python3
import serial
import os
import sys
import time
def progressbar(it, prefix="", size=60, file=sys.stdout):
count = len(it)
def show(j):
x = int(size*j/count)
file.write("%s[%s%s] %i/%i\r" % (prefix, "#"*x, "."*(size-x), j, count))
file.flush()
show(0)
for i, item in enumerate(it):
yield item
show(i+1)
file.write("\n")
file.flush()
def main():
if len(sys.argv) == 2:
# ser = serial.Serial("COM3", timeout=1, write_timeout=1)
ser = serial.Serial("/dev/ttyUSB0", timeout=1, write_timeout=1, baudrate=115200)
if ser.is_open:
# Clear out any existing input
ser.write(b'\n')
time.sleep(0.002)
# Send the upload command
ser.write(b'#')
time.sleep(0.002)
ser.write(b'u')
time.sleep(0.002)
ser.write(b'\n')
time.sleep(0.002)
path = sys.argv[1]
size = os.path.getsize(path)
ser.write([size & 0xFF])
time.sleep(0.002)
ser.write([(size >> 8) & 0xFF])
time.sleep(0.002)
with open(path, "rb") as f:
for i in progressbar(range(size), "Upload: ", 40):
byte = f.read(1)
ser.write(byte)
time.sleep(0.002)
ser.close()
else:
print("Failed to open serial port")
else:
print("Please provide file to upload")
if "__main__":
main()

View File

@ -1,49 +0,0 @@
#!/usr/bin/env python3
import serial
import os
import sys
import time
def progressbar(it, prefix="", size=60, file=sys.stdout):
count = len(it)
def show(j):
x = int(size*j/count)
file.write("%s[%s%s] %i/%i\r" % (prefix, "#"*x, "."*(size-x), j, count))
file.flush()
show(0)
for i, item in enumerate(it):
yield item
show(i+1)
file.write("\n")
file.flush()
def main():
if len(sys.argv) == 2:
# ser = serial.Serial("COM3", timeout=1, write_timeout=1)
ser = serial.Serial("/dev/ttyUSB0", timeout=1, write_timeout=1, baudrate=115200)
if ser.is_open:
path = sys.argv[1]
size = os.path.getsize(path)
with open(path, "rb") as f:
for i in progressbar(range(size), "Upload: ", 40):
byte = f.read(1)
ser.write(byte)
if byte == b'#':
time.sleep(0.002)
ser.write(b'#')
time.sleep(0.002)
ser.write(b'\n')
time.sleep(0.002)
ser.close()
else:
print("Failed to open serial port")
else:
print("Please provide file to upload")
if "__main__":
main()