Skip to content

Commit

Permalink
Make the first disk image build with ab.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgiven committed Sep 8, 2024
1 parent 49e609d commit 149b6a7
Show file tree
Hide file tree
Showing 20 changed files with 1,637 additions and 10 deletions.
15 changes: 5 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
all:
bazel test -c dbg //...
bazel build -c opt //:diskimages
for a in $$(dirname bazel-bin/arch/*/diskimage.img bazel-bin/arch/*/*/diskimage.img); do \
f=$$(basename $$a); cp $$a/diskimage.img $$f.img; chmod +rw $$f.img; done
export OBJ = .obj

verbose:
bazel test -s -c dbg //...
bazel build -s -c opt //:diskimages
.PHONY: all
all: +all

clean:
bazel clean
TARGETS = +all
include build/ab.mk
157 changes: 157 additions & 0 deletions arch/brother/pn8510/build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
from build.ab import simplerule
from build.cpm import cpm_addresses, binslice, diskimage
from third_party.zmac.build import zmac
from third_party.ld80.build import ld80
from utils.build import unix2cpm

# Memory layout configuration -----------------------------------------------

# Configure the BIOS size here; this will then emit an addresses.lib file
# which contains the position of the BDOS and CCP.

top_of_memory = 0x10000
(cbase, fbase, bbase) = cpm_addresses(
name="addresses", top_of_memory=top_of_memory, bios_size=0x0900
)

# Generated tables ----------------------------------------------------------

simplerule(
name="keytab_inc",
outs=["=keytab.inc"],
deps=["arch/brother/pn8510/utils+mkkeytab"],
commands=["{deps[0]} > {outs[0]}"],
label="MKKEYTAB",
)

# Object files --------------------------------------------------------------

for name in [
"boot",
"floppy",
"tty",
"keyboard",
]:
zmac(
name=name + "_o",
z180=True,
src=f"./{name}.z80",
deps=[
"include/cpm.lib",
"include/cpmish.lib",
"include/z180.lib",
".+keytab_inc",
"arch/brother/pn8510/include/pn8510.lib",
"arch/common/utils/tty.lib",
"arch/common/utils/print.lib",
".+addresses",
],
)

# Bootstrapper --------------------------------------------------------------

# This is the .APL file which the Brother OS loads. It's responsible for
# remapping the memory, doing some device setup, and loading the BIOS into
# the top of memory.

ld80(
name="boot_img",
address=0x8000,
objs={
0: [
".+boot_o",
]
},
)

# BIOS ----------------------------------------------------------------------

# The CP/M BIOS itself.

zmac(
name="bios_o",
z180=True,
src="./bios.z80",
deps=[
"include/cpm.lib",
"include/cpmish.lib",
"include/z180.lib",
"arch/brother/pn8510/include/pn8510.lib",
".+addresses",
],
)

# This is a 64kB file containing the entire CP/M memory image.

ld80(
name="memory_img",
address=0,
objs={
cbase: ["third_party/zcpr1"],
fbase: ["third_party/zsdos"],
bbase: [
".+bios_o",
".+tty_o",
".+floppy_o",
".+keyboard_o",
],
},
)

# Currently only used for debugging.
binslice(
name="bios_img", src=".+memory_img", start=bbase, length=0x10000 - bbase
)

binslice(
name="systemtrack_img",
src=".+memory_img",
start=cbase,
length=0x10000 - cbase,
)

# FAT file system -----------------------------------------------------------

# Produces the FAT bit of the disk image.

zmac(
name="bootfile_img",
src="./fat.z80",
deps=[
".+boot_img",
".+bios_img",
".+systemtrack_img",
],
relocatable=False,
z180=True,
)

# Disk image ----------------------------------------------------------------

# Assembles the bootable disk which you can actually run.

unix2cpm(name="readme", src="README.md")

diskimage(
name="diskimage",
format="brother-powernote",
bootfile=".+bootfile_img",
map={
"-readme.txt": ".+readme",
#"dump.com": "cpmtools+dump",
#"stat.com": "cpmtools+stat",
#"asm.com": "cpmtools+asm",
#"copy.com": "cpmtools+copy",
#"submit.com": "cpmtools+submit",
#"asm80.com": "third_party/dr/asm80",
#"camel80.com": "third_party/camelforth",
#"bbcbasic.com": "third_party/bbcbasic+bbcbasic_ADM3A",
#"mkfs.com": "cpmtools+mkfs",
#"rawdisk.com": "cpmtools+rawdisk",
#"qe.com": "cpmtools+qe_BROTHER_POWERNOTE",
#"z8e.com": "third_party/z8e+z8e_POWERNOTE",
#"ted.com": "third_party/ted+ted_POWERNOTE",
},
)

# vim: ts=4 sw=4 et
3 changes: 3 additions & 0 deletions arch/brother/pn8510/utils/build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from build.c import cprogram

cprogram(name="mkkeytab", srcs=["./mkkeytab.c"])
7 changes: 7 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from build.ab import export

export(
name="all",
items={
"pn8510.img": "arch/brother/pn8510+diskimage"
})
19 changes: 19 additions & 0 deletions build/_objectify.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import sys
from functools import partial

if len(sys.argv) != 3:
sys.exit("Usage: %s <file> <symbol>" % sys.argv[0])
filename = sys.argv[1]
symbol = sys.argv[2]

print("const uint8_t " + symbol + "[] = {")
n = 0
with open(filename, "rb") as in_file:
for c in iter(partial(in_file.read, 1), b""):
print("0x%02X," % ord(c), end="")
n += 1
if n % 16 == 0:
print()
print("};")

print("const size_t " + symbol + "_len = sizeof(" + symbol + ");")
Loading

0 comments on commit 149b6a7

Please sign in to comment.