Skip to content

Commit e57ad22

Browse files
authored
Merge pull request #248 from davidgiven/c64
Add a CMD FD-2000 Vic20 port.
2 parents b1fcc24 + ff1f5c9 commit e57ad22

File tree

15 files changed

+211
-125
lines changed

15 files changed

+211
-125
lines changed

.github/workflows/ccpp.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
repository: 'davidgiven/cpm65'
1212

1313
- name: apt
14-
run: sudo apt update && sudo apt install cc1541 cpmtools libfmt-dev fp-compiler moreutils mame srecord 64tass libreadline-dev libelf-dev
14+
run: sudo apt update && sudo apt install cpmtools libfmt-dev fp-compiler moreutils mame srecord 64tass libreadline-dev libelf-dev vice
1515

1616
- name: install llvm-mos
1717
run: |
@@ -70,6 +70,7 @@ jobs:
7070
images/pet8096.d64
7171
images/snes.smc
7272
images/x16.zip
73-
images/vic20_iec.d64
74-
images/vic20_yload.d64
73+
images/vic20_iec_1541.d64
74+
images/vic20_iec_fd2000.d64
75+
images/vic20_yload_1541.d64
7576

.github/workflows/release.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
path: 'cpm65'
1616

1717
- name: apt
18-
run: sudo apt update && sudo apt install cc1541 cpmtools libfmt-dev fp-compiler moreutils srecord 64tass libreadline-dev libelf-dev
18+
run: sudo apt update && sudo apt install cpmtools libfmt-dev fp-compiler moreutils srecord 64tass libreadline-dev libelf-dev vice
1919

2020
- name: install llvm-mos
2121
run: |
@@ -81,8 +81,9 @@ jobs:
8181
pet8032.d64
8282
pet8096.d64
8383
snes.smc
84-
vic20_iec.d64
85-
vic20_yload.d64
84+
vic20_iec_1541.d64
85+
vic20_iec_fd2000.d64
86+
vic20_yload_1541.d64
8687
x16.zip
8788
fail-if-no-assets: false
8889

@@ -126,8 +127,9 @@ jobs:
126127
cpm65/images/pet8032.d64
127128
cpm65/images/pet8096.d64
128129
cpm65/images/snes.smc
129-
cpm65/images/vic20_iec.d64
130-
cpm65/images/vic20_yload.d64
130+
cpm65/images/vic20_iec_1541.d64
131+
cpm65/images/vic20_iec_fd2000.d64
132+
cpm65/images/vic20_yload_1541.d64
131133
cpm65/images/x16.zip
132134
tag_name: dev
133135
env:

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,13 @@ the same time.
185185
- See the Commodore 64 above. There are several versions available (built with
186186
different options):
187187
188-
- `vic20_yload.d64`: uses the fastloader. Only works on a 1541 (or compatible).
189-
- `vic20_iec.d64`: uses old-fashioned IEC code. Should work anywhere which
190-
supports `d64` images, although very, very slowly.
188+
- `vic20_yload_1541.d64`: 1541 format, with the fastloader. Only works on a
189+
1541 (or compatible).
190+
- `vic20_iec_1541.d64`: 1541 format, uses old-fashioned IEC code. Should
191+
work anywhere which supports `d64` images, although very, very slowly.
192+
- `vic20_iec_fd2000.d2m`: CMD FD-2000 format, uses old-fashioned IEC code.
193+
Faster that the `d64` IEC version, but still pretty slow. But you do
194+
get lots of disk space.
191195
192196
- You need a fully expanded VIC-20 with all memory banks populated, for the
193197
full 35kB.

build.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@
4747
"images/pet8032.d64": "src/arch/commodore+pet8032_diskimage",
4848
"images/pet8096.d64": "src/arch/commodore+pet8096_diskimage",
4949
"images/snes.smc": "src/arch/snes+snes_cartridge",
50-
"images/vic20_yload.d64": "src/arch/commodore+vic20_yload_diskimage",
51-
"images/vic20_iec.d64": "src/arch/commodore+vic20_iec_diskimage",
50+
"images/vic20_yload_1541.d64": "src/arch/commodore+vic20_yload_1541_diskimage",
51+
"images/vic20_iec_1541.d64": "src/arch/commodore+vic20_iec_1541_diskimage",
52+
"images/vic20_iec_fd2000.d2m": "src/arch/commodore+vic20_iec_fd2000_diskimage",
5253
"images/x16.zip": "src/arch/x16+diskimage",
5354
"images/sorbus.zip": "src/arch/sorbus+diskimage",
5455
"images/nano6502.img": "src/arch/nano6502+diskimage",

diskdefs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ diskdef c1541
2828
os 2.2
2929
end
3030

31+
# The CMD FD-2000 for the Commodore ecosystem.
32+
33+
diskdef fd2000
34+
seclen 128
35+
tracks 157 # Skips the last two tracks which contain the partition table
36+
sectrk 80
37+
blocksize 4096
38+
maxdir 128
39+
boottrk 3
40+
os 2.2
41+
end
42+
3143
# This produces .po files, so there's implicit soft sector skewing intended to
3244
# be done in the backend. Note that the boot are read in physical sector order
3345
# and so need to be specially skewed so that one they're ProDOS skewed each

extras/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Making blank D2M images seems to be pretty hard --- VICE can do it through the
2+
GUI, but c1541 can't (even though c1541 is part of VICE? I think?).
3+
`empty.d2m.gz` is a compressed blank image containing an empty CBMFS filesystem
4+
which has been hand edited to also an empty CPMFS filesystem. It's not a true
5+
combifs like the D64 images.

extras/empty.d2m.gz

1.76 KB
Binary file not shown.

src/arch/commodore/build.py

Lines changed: 55 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from build.ab import simplerule, TargetsMap, filenameof, Rule, Target
2-
from tools.build import mkcpmfs, mametest
2+
from tools.build import mkcpmfs, mametest, mkcbmfs
33
from build.llvm import llvmrawprogram, llvmclibrary
44
from config import (
55
MINIMAL_APPS,
@@ -21,39 +21,6 @@
2121
COMMODORE_ITEMS_WITH_SCREEN = COMMODORE_ITEMS | SCREEN_APPS | SCREEN_APPS_SRCS
2222

2323

24-
@Rule
25-
def mkcbmfs(self, name, items: TargetsMap = {}, title="CBMFS", id=None):
26-
cs = ["rm -f $[outs[0]]"]
27-
ins = []
28-
29-
cmd = "chronic cc1541 -q "
30-
if id:
31-
cmd += "-i %d " % id
32-
cmd += '-n "%s" $[outs[0]]' % title
33-
cs += [cmd]
34-
35-
for k, v in items.items():
36-
t = "PRG"
37-
if k.startswith("&"):
38-
t = "USR"
39-
40-
cs += [
41-
"chronic cc1541 -q -t -u 0 -r 18 -f '%s' -T '%s' -w '%s' $[outs[0]]"
42-
% (k, t, filenameof(v))
43-
]
44-
ins += [v]
45-
46-
cs += ["$[deps[0]] -f $[outs[0]]"]
47-
simplerule(
48-
replaces=self,
49-
ins=ins,
50-
outs=[f"={name}.img"],
51-
deps=["tools+mkcombifs"],
52-
commands=cs,
53-
label="MKCBMFS",
54-
)
55-
56-
5724
@Rule
5825
def mkusr(self, name, src: Target):
5926
simplerule(
@@ -174,7 +141,7 @@ def mkusr(self, name, src: Target):
174141
)
175142

176143
llvmrawprogram(
177-
name="vic20_yload_bios",
144+
name="vic20_yload_1541_bios",
178145
srcs=[
179146
"./vic20/vic20.S",
180147
"./diskaccess/bios_1541.S",
@@ -189,11 +156,12 @@ def mkusr(self, name, src: Target):
189156
".+commodore_lib",
190157
],
191158
cflags=["-DVIC20"],
159+
ldflags=["--gc-sections"],
192160
linkscript="./vic20/vic20.ld",
193161
)
194162

195163
llvmrawprogram(
196-
name="vic20_iec_bios",
164+
name="vic20_iec_1541_bios",
197165
srcs=[
198166
"./vic20/vic20.S",
199167
"./diskaccess/bios_1541.S",
@@ -209,6 +177,28 @@ def mkusr(self, name, src: Target):
209177
".+commodore_lib",
210178
],
211179
cflags=["-DVIC20"],
180+
ldflags=["--gc-sections"],
181+
linkscript="./vic20/vic20.ld",
182+
)
183+
184+
llvmrawprogram(
185+
name="vic20_iec_fd2000_bios",
186+
srcs=[
187+
"./vic20/vic20.S",
188+
"./diskaccess/bios_fd2000.S",
189+
"./diskaccess/io_ieee488.S",
190+
"./diskaccess/io_ieee488_vic20.S",
191+
"./diskaccess/rw_ieee488.S",
192+
"./vic20/vic20.inc",
193+
],
194+
deps=[
195+
"include",
196+
"src/lib+bioslib",
197+
"third_party/tomsfonts+4x8",
198+
".+commodore_lib",
199+
],
200+
cflags=["-DVIC20"],
201+
ldflags=["--gc-sections"],
212202
linkscript="./vic20/vic20.ld",
213203
)
214204

@@ -223,21 +213,31 @@ def mkusr(self, name, src: Target):
223213
)
224214

225215
mkcbmfs(
226-
name="vic20_yload_cbmfs",
216+
name="vic20_yload_1541_cbmfs",
227217
title="cp/m-65: vic20",
228218
items={
229219
"cpm": ".+vic20_yload_loader",
230220
"&yload1541": ".+usr_yload1541",
231-
"bios": ".+vic20_yload_bios",
221+
"bios": ".+vic20_yload_1541_bios",
232222
},
233223
)
234224

235225
mkcbmfs(
236-
name="vic20_iec_cbmfs",
226+
name="vic20_iec_1541_cbmfs",
237227
title="cp/m-65: vic20",
238228
items={
239229
"cpm": ".+vic20_iec_loader",
240-
"bios": ".+vic20_iec_bios",
230+
"bios": ".+vic20_iec_1541_bios",
231+
},
232+
)
233+
234+
mkcbmfs(
235+
name="vic20_iec_fd2000_cbmfs",
236+
title="cp/m-65: vic20",
237+
type="d2m",
238+
items={
239+
"cpm": ".+vic20_iec_loader",
240+
"bios": ".+vic20_iec_fd2000_bios",
241241
},
242242
)
243243

@@ -248,14 +248,28 @@ def mkusr(self, name, src: Target):
248248
items={"cpm": ".+%s_bios" % target},
249249
)
250250

251-
for target in ["pet4032", "pet8032", "pet8096", "c64", "vic20_yload", "vic20_iec"]:
251+
for target in [
252+
"pet4032",
253+
"pet8032",
254+
"pet8096",
255+
"c64",
256+
"vic20_yload_1541",
257+
"vic20_iec_1541",
258+
]:
252259
mkcpmfs(
253260
name=target + "_diskimage",
254261
format="c1541",
255262
template=".+%s_cbmfs" % target,
256263
items=COMMODORE_ITEMS_WITH_SCREEN,
257264
)
258265

266+
mkcpmfs(
267+
name="vic20_iec_fd2000_diskimage",
268+
format="fd2000",
269+
template=".+vic20_iec_fd2000_cbmfs",
270+
items=COMMODORE_ITEMS_WITH_SCREEN,
271+
)
272+
259273
mametest(
260274
name="c64_mametest",
261275
target="c64",
Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
This is extremely heavily based on MagerValp's uload3, which is BSD licensed;
2-
see https://www.lemon64.com/forum/viewtopic.php?t=80458. However, I have
3-
rewritten and modified basically every line of it so that calling it derived
4-
from uload3 is probably an insult to uload3.
1+
rw_*: read/write layer, i.e. read_sector and write_sector.
2+
3+
io_*: protocol layer, which does the work.
4+
5+
In addition there's some common stuff, like io_ieee488.S which contains a
6+
platform-independent IEE488 layer on top of PET/C64/Vic20 etc.
7+
8+
9+
The *yload* files contain a fastloader which is extremely heavily based on
10+
MagerValp's uload3, which is BSD licensed; see
11+
https://www.lemon64.com/forum/viewtopic.php?t=80458. However, I have rewritten
12+
and modified basically every line of it so that calling it derived from uload3
13+
is probably an insult to uload3.

src/arch/commodore/diskaccess/bios_1541.S

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,32 @@
1313
.data
1414
define_dpb dpb_1541, 136*10, 1024, 64, 0
1515
define_dph dph, dpb_1541
16+
17+
; Converts an LBA sector number in XA to track/sector in Y, A.
18+
19+
zproc convert_to_ts, .text.tsconvert, weak
20+
ldy #0
21+
zloop
22+
cpx #0
23+
zif eq
24+
cmp track_size_table, y
25+
zif cc
26+
iny ; tracks are one-based.
27+
rts
28+
zendif
29+
zendif
30+
31+
sec
32+
sbc track_size_table, y
33+
zif cc
34+
dex
35+
zendif
36+
iny
37+
zendloop
38+
39+
track_size_table:
40+
.fill 17, 1, 21
41+
.fill 7, 1, 19
42+
.fill 6, 1, 18
43+
.fill 10, 1, 17
44+
zendproc

0 commit comments

Comments
 (0)