Add SETUP.SYSTEM and build .SETUP files

This is an alternate approach proposed by Sean Nolan in 1987 which
allows placing the driver files in a subdirectory of the root volume
to avoid clutter and file ordering issues. Only a SETUP.SYSTEM file is
needed at the top level, and the drivers go into a SETUPS/ directory.

All drivers here (except QUIT.SYSTEM and SETUP.SYSTEM itself) have
alternate forms built into the /DRIVERS/SETUPS/ directory as XYZ.SETUP
instead of XYZ.SYSTEM. If you choose to use SETUP.SYSTEM, place these
.SETUP files in your SETUPS/ directory. The naming doesn't matter -
any SYS or BIN file can be used - but this convention makes
distribution easier. These .SETUP files do **NOT** chain to the next
file - that's handled by SETUP.SYSTEM itself.

Resolves #16
This commit is contained in:
Joshua Bell 2024-01-30 21:16:32 -08:00
parent 537d79810b
commit 7bbc96924b
26 changed files with 532 additions and 52 deletions

View File

@ -1,4 +1,4 @@
targets := clocks selectors accelerators ram.drv util textcolors
targets := clocks selectors accelerators ram.drv setup util textcolors
.PHONY: all $(targets) package

View File

@ -71,6 +71,10 @@ The intent is that you use a tool like Copy II Plus or [Apple II DeskTop](https:
Alternately, you might want to install some drivers then immediately launch into BASIC. In that case, put `BASIC.SYSTEM` after the drivers in place of `QUIT.SYSTEM`.
## Alternate Approach
If you want to keep your volume directory tidier, consider using [SETUP.SYSTEM](./setups/README.md) instead.
# Building
Fetch, build, and install [cc65](http://cc65.github.io/cc65/):

View File

@ -7,7 +7,8 @@ OUTDIR = ../../out
HEADERS = $(wildcard *.inc) $(wildcard ../inc/*.inc)
TARGETS = \
$(OUTDIR)/zipchip.system.SYS
$(OUTDIR)/zipchip.system.SYS \
$(OUTDIR)/zipchip.setup.SYS
LOG_SUCCESS=1
LOG_FAILURE=1
@ -35,6 +36,9 @@ clean:
$(OUTDIR)/%.o: %.s $(HEADERS)
ca65 $(CAFLAGS) $(DEFINES) --listing $(basename $@).list -o $@ $<
$(OUTDIR)/%.setup.o: %.system.s $(HEADERS)
ca65 $(CAFLAGS) $(DEFINES) -D BUILD_SETUP_FILE --listing $(basename $@).list -o $@ $<
$(OUTDIR)/%.BIN $(OUTDIR)/%.SYS: $(OUTDIR)/%.o
ld65 $(LDFLAGS) -o $@ $<
ifdef XATTR

View File

@ -10,6 +10,7 @@ HEADERS = $(wildcard *.inc) $(wildcard ../../inc/*.inc)
TARGETS = \
$(UTILDIR)/prodos.mod.BIN \
$(OUTDIR)/cricket.system.SYS \
$(OUTDIR)/cricket.setup.SYS \
$(UTILDIR)/test.BIN \
$(UTILDIR)/set.datetime.BIN \
$(UTILDIR)/set.time.BIN \
@ -43,6 +44,9 @@ clean:
$(OUTDIR)/%.o $(UTILDIR)/%.o: %.s $(HEADERS)
ca65 $(CAFLAGS) $(DEFINES) --listing $(basename $@).list -o $@ $<
$(OUTDIR)/%.setup.o: %.system.s $(HEADERS)
ca65 $(CAFLAGS) $(DEFINES) -D BUILD_SETUP_FILE --listing $(basename $@).list -o $@ $<
$(OUTDIR)/%.SYS: $(OUTDIR)/%.o
ld65 $(LDFLAGS) -o $@ $<

View File

@ -42,6 +42,8 @@ These `BRUN`able files are also built:
* [SET.DATE](set.date.s) sets the Cricket's current date.
* [SET.TIME](set.time.s) sets the Cricket's current time.
`CRICKET.SETUP` is for use with [SETUP.SYSTEM](../../setup/README.md)
## Resources
Cricket disks on Asimov:

View File

@ -7,7 +7,8 @@ OUTDIR = ../../out
HEADERS = $(wildcard *.inc) $(wildcard ../../inc/*.inc)
TARGETS = \
$(OUTDIR)/dclock.system.SYS
$(OUTDIR)/dclock.system.SYS \
$(OUTDIR)/dclock.setup.SYS
LOG_SUCCESS=1
LOG_FAILURE=1
@ -35,6 +36,9 @@ clean:
$(OUTDIR)/%.o: %.s $(HEADERS)
ca65 $(CAFLAGS) $(DEFINES) --listing $(basename $@).list -o $@ $<
$(OUTDIR)/%.setup.o: %.system.s $(HEADERS)
ca65 $(CAFLAGS) $(DEFINES) -D BUILD_SETUP_FILE --listing $(basename $@).list -o $@ $<
$(OUTDIR)/%.SYS: $(OUTDIR)/%.o
ld65 $(LDFLAGS) -o $@ $<
ifdef XATTR

View File

@ -11,3 +11,5 @@ Like other drivers here, this one will:
* Only attempts detection if the system is a an Apple IIc
* If detected, installs into ProDOS directly, following Technical Reference Manual requirements.
* Chains to the next `.SYSTEM` file in the directory.
`DCLOCK.SETUP` is for use with [SETUP.SYSTEM](../../setup/README.md).

View File

@ -7,7 +7,8 @@ OUTDIR = ../../out
HEADERS = $(wildcard *.inc) $(wildcard ../../inc/*.inc)
TARGETS = \
$(OUTDIR)/fn.clock.system.SYS
$(OUTDIR)/fn.clock.system.SYS \
$(OUTDIR)/fn.clock.setup.SYS
LOG_SUCCESS=1
LOG_FAILURE=1
@ -35,6 +36,9 @@ clean:
$(OUTDIR)/%.o: %.s $(HEADERS)
ca65 $(CAFLAGS) $(DEFINES) --listing $(basename $@).list -o $@ $<
$(OUTDIR)/%.setup.o: %.system.s $(HEADERS)
ca65 $(CAFLAGS) $(DEFINES) -D BUILD_SETUP_FILE --listing $(basename $@).list -o $@ $<
$(OUTDIR)/%.BIN $(OUTDIR)/%.SYS: $(OUTDIR)/%.o
ld65 $(LDFLAGS) -o $@ $<
ifdef XATTR

View File

@ -4,6 +4,4 @@
This driver is an adaptation of the other drivers in https://github.com/a2stuff/prodos-drivers
`FN.CLOCK.SETUP` is for use with [SETUP.SYSTEM](../../setup/README.md).

View File

@ -12,9 +12,9 @@ HEADERS = $(wildcard *.inc) $(wildcard ../../inc/*.inc) \
../fujinet/smartport.inc \
../cricket/cricket.system.s
TARGETS = \
$(OUTDIR)/clock.system.SYS
$(OUTDIR)/clock.system.SYS \
$(OUTDIR)/clock.setup.SYS
LOG_SUCCESS=1
LOG_FAILURE=1
@ -42,6 +42,9 @@ clean:
$(OUTDIR)/%.o: %.s $(HEADERS)
ca65 $(CAFLAGS) $(DEFINES) --listing $(basename $@).list -o $@ $<
$(OUTDIR)/%.setup.o: %.system.s $(HEADERS)
ca65 $(CAFLAGS) $(DEFINES) -D BUILD_SETUP_FILE --listing $(basename $@).list -o $@ $<
$(OUTDIR)/%.SYS: $(OUTDIR)/%.o
ld65 $(LDFLAGS) -o $@ $<
ifdef XATTR

View File

@ -13,3 +13,5 @@ The drivers are (in order):
By default, the installer logs on success so you can tell what clock was detected, but you can build with `LOG_SUCCESS=0` to prevent that.
If ProDOS _already_ has a clock driver installed, the driver is checked for common Thunderclock year tables. If found, the table is updated in memory to cover 2023-2028.
`CLOCK.SETUP` is for use with [SETUP.SYSTEM](../../setup/README.md).

View File

@ -9,6 +9,7 @@ HEADERS = $(wildcard *.inc) $(wildcard ../../inc/*.inc)
TARGETS = \
$(OUTDIR)/ns.clock.system.SYS \
$(OUTDIR)/ns.clock.setup.SYS \
$(UTILDIR)/set.datetime.BIN
LOG_SUCCESS=1
@ -39,6 +40,9 @@ clean:
$(OUTDIR)/%.o $(UTILDIR)/%.o: %.s $(HEADERS)
ca65 $(CAFLAGS) $(DEFINES) --listing $(basename $@).list -o $@ $<
$(OUTDIR)/%.setup.o: %.system.s $(HEADERS)
ca65 $(CAFLAGS) $(DEFINES) -D BUILD_SETUP_FILE --listing $(basename $@).list -o $@ $<
$(OUTDIR)/%.SYS: $(OUTDIR)/%.o
ld65 $(LDFLAGS) -o $@ $<

View File

@ -12,3 +12,5 @@ Adapted from `NS.CLOCK.SYSTEM` (by "CAP"), with these changes:
These `BRUN`able files are also built:
* [SET.DATETIME](set.datetime.s) sets the No Slot Clock date/time.
`NS.CLOCK.SETUP` is for use with [SETUP.SYSTEM](../../setup/README.md).

View File

@ -7,7 +7,8 @@ OUTDIR = ../../out
HEADERS = $(wildcard *.inc) $(wildcard ../../inc/*.inc)
TARGETS = \
$(OUTDIR)/romxrtc.system.SYS
$(OUTDIR)/romxrtc.system.SYS \
$(OUTDIR)/romxrtc.setup.SYS
LOG_SUCCESS=1
LOG_FAILURE=1
@ -35,6 +36,9 @@ clean:
$(OUTDIR)/%.o: %.s $(HEADERS)
ca65 $(CAFLAGS) $(DEFINES) --listing $(basename $@).list -o $@ $<
$(OUTDIR)/%.setup.o: %.system.s $(HEADERS)
ca65 $(CAFLAGS) $(DEFINES) -D BUILD_SETUP_FILE --listing $(basename $@).list -o $@ $<
$(OUTDIR)/%.SYS: $(OUTDIR)/%.o
ld65 $(LDFLAGS) -o $@ $<
ifdef XATTR

View File

@ -1,3 +1,5 @@
# ROMX ProDOS Clock Driver
Original source c/o Jeff Mazur.
`ROMXRTC.SETUP` is for use with [SETUP.SYSTEM](../../setup/README.md).

View File

@ -1,3 +1,6 @@
.ifndef BUILD_SETUP_FILE
poporg
reloc_end := *
.endif

View File

@ -4,14 +4,17 @@
;; SYS files load at $2000; relocates self to $1000
.org SYS_ADDR
.ifndef BUILD_SETUP_FILE
dst_addr := $1000
;;; ------------------------------------------------------------
jmp relocate
.else
jmp main
.endif
.byte MM, DD, YY ; version date stamp
.ifndef BUILD_SETUP_FILE
;;; ------------------------------------------------------------
;;; Relocate this code from $2000 (.SYSTEM start location) to $1000
;;; and start executing there. This is done so that the next .SYSTEM
@ -389,6 +392,23 @@ suffix:
found_self_flag:
.byte 0
.else
;;; ============================================================
;;; Main routine
;;; ============================================================
.proc main
jsr maybe_install_driver
MLI_CALL QUIT, quit_params
brk ; crash if QUIT fails
DEFINE_QUIT_PARAMS quit_params
.endproc
.endif
;;; ============================================================
;;; Common Routines
;;; ============================================================

View File

@ -11,39 +11,47 @@ VOLNAME="drivers"
rm -f "$IMGFILE"
cadius CREATEVOLUME "$IMGFILE" "$VOLNAME" 140KB --no-case-bits --quiet
cadius CREATEFOLDER "$IMGFILE" "/$VOLNAME/CRICKET.UTIL" --no-case-bits --quiet
cadius CREATEFOLDER "$IMGFILE" "/$VOLNAME/NSCLOCK.UTIL" --no-case-bits --quiet
cadius CREATEFOLDER "$IMGFILE" "/$VOLNAME/SETUPS" --no-case-bits --quiet
add_file () {
cp "$1" "$PACKDIR/$2"
cadius ADDFILE "$IMGFILE" "$3" "$PACKDIR/$2" --no-case-bits --quiet
}
add_file "out/cricket.system.SYS" "cricket.system#FF0000" "/$VOLNAME"
add_file "out/cricket.util/set.datetime.BIN" "set.datetime#062000" "/$VOLNAME/CRICKET.UTIL"
add_file "out/cricket.util/set.date.BIN" "set.date#062000" "/$VOLNAME/CRICKET.UTIL"
add_file "out/cricket.util/set.time.BIN" "set.time#062000" "/$VOLNAME/CRICKET.UTIL"
add_file "out/cricket.util/test.BIN" "test#062000" "/$VOLNAME/CRICKET.UTIL"
add_file "out/dclock.system.SYS" "dclock.system#FF0000" "/$VOLNAME"
add_file "out/ns.clock.system.SYS" "ns.clock.system#FF0000" "/$VOLNAME"
add_file "out/nsclock.util/set.datetime.BIN" "set.datetime#062000" "/$VOLNAME/NSCLOCK.UTIL"
add_file "out/romxrtc.system.SYS" "romxrtc.system#FF0000" "/$VOLNAME"
add_file "out/fn.clock.system.SYS" "fn.clock.system#FF0000" "/$VOLNAME"
add_file "out/clock.system.SYS" "clock.system#FF0000" "/$VOLNAME"
add_file "out/ram.drv.system.SYS" "ram.drv.system#FF0000" "/$VOLNAME"
add_file "out/bbb.system.SYS" "bbb.system#FF0000" "/$VOLNAME"
add_file "out/buhbye.system.SYS" "buhbye.system#FF0000" "/$VOLNAME"
add_file "out/bye.system.SYS" "bye.system#FF0000" "/$VOLNAME"
add_file "out/selector.system.SYS" "selector.system#FF0000" "/$VOLNAME"
add_file "out/zipchip.system.SYS" "zipchip.system#FF0000" "/$VOLNAME"
add_file "out/quit.system.SYS" "quit.system#FF0000" "/$VOLNAME"
add_file "out/pause.system.SYS" "pause.system#FF0000" "/$VOLNAME"
add_file "out/me.first.system.SYS" "me.first.system#FF0000" "/$VOLNAME"
add_file "out/date.BIN" "date#062000" "/$VOLNAME"
# Drivers
for file in \
"bbb" "buhbye" "bye" "selector" \
"clock" "cricket" "dclock" "fn.clock" "ns.clock" "romxrtc" \
"ram.drv" \
"zipchip" \
"me.first" "pause"; do
add_file "out/$file.system.SYS" "$file.system#FF0000" "/$VOLNAME"
add_file "out/$file.setup.SYS" "$file.setup#FF0000" "/$VOLNAME/SETUPS"
done
add_file "out/setup.system.SYS" "setup.system#FF0000" "/$VOLNAME"
add_file "out/quit.system.SYS" "quit.system#FF0000" "/$VOLNAME"
# Utilities
add_file "out/date.BIN" "date#062000" "/$VOLNAME"
cadius CREATEFOLDER "$IMGFILE" "/$VOLNAME/CRICKET.UTIL" --no-case-bits --quiet
add_file "out/cricket.util/set.datetime.BIN" "set.datetime#062000" "/$VOLNAME/CRICKET.UTIL"
add_file "out/cricket.util/set.date.BIN" "set.date#062000" "/$VOLNAME/CRICKET.UTIL"
add_file "out/cricket.util/set.time.BIN" "set.time#062000" "/$VOLNAME/CRICKET.UTIL"
add_file "out/cricket.util/test.BIN" "test#062000" "/$VOLNAME/CRICKET.UTIL"
cadius CREATEFOLDER "$IMGFILE" "/$VOLNAME/NSCLOCK.UTIL" --no-case-bits --quiet
add_file "out/nsclock.util/set.datetime.BIN" "set.datetime#062000" "/$VOLNAME/NSCLOCK.UTIL"
cadius CREATEFOLDER "$IMGFILE" "/$VOLNAME/TEXTCOLORS" --no-case-bits --quiet
cadius CREATEFOLDER "$IMGFILE" "/$VOLNAME/SETUPS/TEXTCOLORS" --no-case-bits --quiet
for file in a2green bw deepblue gray gsblue mint pink wb; do
add_file "out/${file}.system.SYS" "${file}.system#FF0000" "/$VOLNAME/TEXTCOLORS"
add_file "out/${file}.system.SYS" "${file}.system#FF0000" "/$VOLNAME/TEXTCOLORS"
add_file "out/${file}.setup.SYS" "${file}.setup#FF0000" "/$VOLNAME/TEXTCOLORS/SETUPS"
done
rm -r "$PACKDIR"

View File

@ -7,7 +7,8 @@ OUTDIR = ../out
HEADERS = $(wildcard *.inc) $(wildcard ../inc/*.inc)
TARGETS = \
$(OUTDIR)/ram.drv.system.SYS
$(OUTDIR)/ram.drv.system.SYS \
$(OUTDIR)/ram.drv.setup.SYS
export LOG_SUCCESS=1
export LOG_FAILURE=1
@ -35,8 +36,8 @@ clean:
$(OUTDIR)/%.o: %.s $(HEADERS)
ca65 $(CAFLAGS) $(DEFINES) --listing $(basename $@).list -o $@ $<
$(OUTDIR)/%.setup.o: %.system.s $(HEADERS)
ca65 $(CAFLAGS) $(DEFINES) -D BUILD_SETUP_FILE --listing $(basename $@).list -o $@ $<
$(OUTDIR)/%.SYS: $(OUTDIR)/%.o
ld65 $(LDFLAGS) -o $@ $<
ifdef XATTR
xattr -wx prodos.AuxType '00 20' $@
endif

View File

@ -38,7 +38,6 @@ zp_sig_addr := $06
zpproc_addr := $B0
zpproc_relay_addr := $2D0
data_buf := $1C00 ; I/O when chaining to next SYS file
driver_target := $FF00 ; Install location in ProDOS
@ -711,8 +710,6 @@ map2 := *+2+$80 ; len: $80
stash_00 := *+2+$100 ; len: $80
stash_01 := *+2+$180 ; len: $80
.assert stash_01+$80 < data_buf, error, "Too long"
;;; ************************************************************
.include "../inc/driver_postamble.inc"
;;; ************************************************************

View File

@ -8,9 +8,13 @@ HEADERS = $(wildcard *.inc) $(wildcard ../inc/*.inc)
TARGETS = \
$(OUTDIR)/selector.system.SYS \
$(OUTDIR)/selector.setup.SYS \
$(OUTDIR)/bye.system.SYS \
$(OUTDIR)/bye.setup.SYS \
$(OUTDIR)/bbb.system.SYS \
$(OUTDIR)/buhbye.system.SYS
$(OUTDIR)/bbb.setup.SYS \
$(OUTDIR)/buhbye.system.SYS \
$(OUTDIR)/buhbye.setup.SYS
# For timestamps
MM = $(shell date "+%-m")
@ -34,8 +38,8 @@ clean:
$(OUTDIR)/%.o: %.s $(HEADERS)
ca65 $(CAFLAGS) $(DEFINES) --listing $(basename $@).list -o $@ $<
$(OUTDIR)/%.setup.o: %.system.s $(HEADERS)
ca65 $(CAFLAGS) $(DEFINES) -D BUILD_SETUP_FILE --listing $(basename $@).list -o $@ $<
$(OUTDIR)/%.SYS: $(OUTDIR)/%.o
ld65 $(LDFLAGS) -o $@ $<
ifdef XATTR
xattr -wx prodos.AuxType '00 20' $@
endif

35
setup/Makefile Normal file
View File

@ -0,0 +1,35 @@
CAFLAGS = --target apple2enh --list-bytes 0
LDFLAGS = --config apple2-asm.cfg
OUTDIR = ../out
HEADERS = $(wildcard *.inc) $(wildcard ../inc/*.inc)
TARGETS = \
$(OUTDIR)/setup.system.SYS
# For timestamps
MM = $(shell date "+%-m")
DD = $(shell date "+%-d")
YY = $(shell date "+%-y")
DEFINES = -D DD=$(DD) -D MM=$(MM) -D YY=$(YY)
XATTR := $(shell command -v xattr 2> /dev/null)
.PHONY: clean all
all: $(OUTDIR) $(TARGETS)
$(OUTDIR):
mkdir -p $(OUTDIR)
clean:
rm -f $(OUTDIR)/*.o
rm -f $(OUTDIR)/*.list
rm -f $(TARGETS)
$(OUTDIR)/%.o: %.s $(HEADERS)
ca65 $(CAFLAGS) $(DEFINES) --listing $(basename $@).list -o $@ $<
$(OUTDIR)/%.SYS: $(OUTDIR)/%.o
ld65 $(LDFLAGS) -o $@ $<

30
setup/README.md Normal file
View File

@ -0,0 +1,30 @@
# SETUP.SYSTEM
The November 1987 edition of Call-A.P.P.L.E features an article by Sean Nolan, ["SYSTEM.SETUP - A Proposed Startup File Standard"](https://www.callapple.org/magazines-4/call-a-p-p-l-e/setup-system-a-proposed-startup-file-standard/). The article was reprinted in [Beneath Apple DOS ProDOS 2020](https://archive.org/details/beneath-apple-dos-prodos-2020). The proposal combines the ProDOS-8 notion of running the first .SYSTEM file found on disk and the convention of chaining to the next .SYSTEM file, with the ProDOS-16 notion of enumerating a directory of startup files. A main `SETUP.SYSTEM` file is provided which enumerates all files in a `SETUPS/` directory. These "setup files" are BIN or SYS files which work like standard ProDOS-8 drivers. The advantages of this approach are:
* The top level directory only needs one SYSTEM file plus `SETUPS/`, which reduces clutter.
* Each individual setup file is simpler than stand-alone SYSTEM files, as they don't need to implement chaining.
Which approach you use is a matter of taste.
## How do you use these?
If you choose this approach, use a tool like Copy II Plus or [Apple II DeskTop](https://github.com/a2stuff/a2d) to copy and arrange `SETUP.SYSTEM` as the first `.SYSTEM` file in your root directory. Create a `SETUPS/` directory, and copy the appropriate `.SETUPS` files there. A boot disk image catalog that is used on multiple different hardware configurations might include:
* `PRODOS` - the operating system, e.g. [ProDOS 2.4](https://prodos8.com/)
* `SETUP.SYSTEM` - install No-Slot clock driver, if present
* `QUIT.SYSTEM` - invoke the Quit handler immediately, as a program selector
* `BASIC.SYSTEM` - which will not be automatically invoked, but is available to manually invoke
* `SETUPS/NS.CLOCK.SYSTEM` - install No-Slot clock driver, if present
* `SETUPS/ROMXRTC.SYSTEM` - install ROMX clock driver, if present
* `SETUPS/FN.CLOCK.SYSTEM` - install FujiNet clock driver, if present
* `SETUPS/DCLOCK.SYSTEM` - install DClock clock driver, if present
* `SETUPS/CRICKET.SYSTEM` - install Cricket! clock driver, if present
* `SETUPS/ZIPCHIP.SYSTEM` - slow the ZIP CHIP on speaker access, if present
* `SETUPS/RAM.DRV.SYSTEM` - install RamWorks RAM disk driver, if present
* `SETUPS/BUHBYE.SYSTEM` - install a customized Quit handler to replace the built-in one
* `SETUPS/PAUSE.SYSTEM` - pause for a moment, so that you can inspect the output of the above
## Notes
The `SETUP.SYSTEM` program is not modified from the published version except that it no longer clears the screen between running each file in `SETUPS/`, so that any logged output remains visible.

329
setup/setup.system.s Normal file
View File

@ -0,0 +1,329 @@
;;;
;;; SETUP.SYSTEM by Sean Nolan
;;;
;;; A Proposed Startup File Standard
;;;
;;; Published in Call-APPLE, November, 1987
;;; This program is in the public domain.
;;;
;;; This program mimics the ProDOS 16
;;; SYSTEM.SETUP convention. It can be used
;;; to install RAM disk drivers, clock
;;; drivers, and IIGS Classic Desk
;;; Accessories on bootup under ProDOS 8.
;;;
;;; This program loads and calls all BINary
;;; and SYStem files in a subdirectory named
;;; SETUPS. It then looks for the second
;;; system program in the volume directory
;;; whose name ends in ".SYSTEM", and runs
;;; that.
;;;
;;;
;;; Original code clears the screen before/after each driver. Skip it.
NO_HOME = 1
.define ORG .org
.define DFB .byte
.define DA .addr
.define DS .res
.define ASC .byte
.define ASCH scrcode
.feature labels_without_colons +
.feature loose_string_term +
.include "apple2.mac"
.if 0
TYP $FF ;save as a system file
.endif
ORG $BD00 ;load at $2000, but run at $BD00
;;; ****************** equates
CH = $24
IN2 = $280
FILETYPE = IN2+16
AUXCODE = IN2+31
RESET = $3F2
IOBUFFER = $B900
PRODOS = $BF00
QUITVECT = $BF03
DEVNUM = $BF30
BITMAP = $BF58
INIT = $FB2F
VTABZ = $FC24
HOME = $FC58
RDKEY = $FD0C
SETVID = $FE93
SETKBD = $FE89
SETNORM = $FE84
;;; ****************** boot code
VOLNAME = * ;The first 17 bytes are overwritten with the
;name of the volume from which this was run.
LDX #1 ;mark page $BD as free in the system bitmap
STX BITMAP+23 ;so we can put Online result in our code.
DEX ;relocate this program to $BD00-BEFF
LOOP1 LDA $2000,X
STA $BD00,X
LDA $2100,X
STA $BE00,X
INX
BNE LOOP1
DEX
TXS ;init stack pointer
JMP ENTER ;jump to relocated code
DIRNAME DFB 6 ;DirName and VolName must be in the same page
ASCH "SETUPS"
;;; ****** Get name of boot volume
ENTER LDA DEVNUM ;get name of last volume accessed
STA ONLINEN
JSR PRODOS
DFB $C5 ;ONLINE
DA ONLINEP
LDA VOLNAME+1 ;insert a slash nefore the name
AND #$0F
TAX
INX
STX VOLNAME
LDA #$2F ;/
STA VOLNAME+1
LDA QUITVECT+1 ;save original quit vector
STA QUITMOD1+1
LDA QUITVECT+2
STA QUITMOD2+1
;;; ****** Clean up before &amp; after calling files
MAINLOOP LDX #2 ;point Reset vector and ProDOS
LOOP3 LDA JUMP+1,X ;Quit vectors to MainLoop
STA RESET,X
LDA JUMP,X
STA QUITVECT,X
DEX
BPL LOOP3
TXS ;fix stack pointer (X=$FF)
JSR CLOSE ;close all open files
LDX #23 ;clear system bit map
LDA #0
LOOP2 STA BITMAP,X
DEX
BPL LOOP2
LDA #$CF ;mark pages 0,1,4-7 as used
STA BITMAP
LDA #%111 ;mark pages $BD-$BF as used
STA BITMAP+23
LDA $C082 ;Language card off
STA $C00C ;40-column
STA $C00E ;normal character set
STA $C000 ;80STORE off
JSR SETNORM ;normal
JSR INIT ;display text page 1
JSR SETVID ;PR#0
JSR SETKBD ;IN#0
;;; Make sure boot volume is around
;;; AND set prefix to the boot volume
.if NO_HOME
VOLMOUNT
.else
VOLMOUNT JSR HOME
.endif
JSR PRODOS ;set prefix to volume
DFB $C6 ;SET PREFIX
DA PFX2P
BCC VOLOK
LDX #13
LOOP6 LDA VOLTEXT-1,X ;print message "insert volume"
STA $5A8+4,X
DEX
BNE LOOP6
LOOP7 LDA VOLNAME+1,X ;print volume name
ORA #$80
STA $5A8+19,X
INX
CPX VOLNAME
BCC LOOP7
LDA #35 ;go to CH=35, CV=11
STA CH
LDA #11
JSR VTABZ
JSR RDKEY ;wait for keypress
JMP VOLMOUNT
;;; ****** Get name of next file at IN2
VOLOK JSR NEXTFILE ;get name of next file at IN2
BCS EXITLOOP ;if error, we're done with setup files
;;; ****** Load and call setup file
JSR PRODOS ;set prefix to SETUPS
DFB $C6 ;SET PREFIX
DA PFX1P
JSR READFILE ;read in file whose name is at IN@
;and call it if there was no error.
JUMP JMP MAINLOOP ;3 bytes here copied into ProDOS quit vector
DFB $BD^$A5 ;3 bytes here are copied into reset vector
EXITLOOP INC RESET+2 ;scramble reset vector
QUITMOD1 LDA #0 ;restore original quit vector
STA QUITVECT+1
QUITMOD2 LDA #0
STA QUITVECT+2
;;; ****** Look for second system program on disk
LDA #0 ;modify NextFile routine so that it searches
STA NUMBER+1 ;the volume directory for system files only.
STA CHEKTYPE+1
LDA #<VOLNAME ;NamePtr+1 does not bneed to be changed
STA NAMEPTR ;since VolName and DirName are in the same page
NEXTSYS JSR NEXTFILE
BCS QUIT
LDX IN2 ;see if file ends with ".SYSTEM"
LDY #6
LOOP4 LDA IN2,X ;I expect pathname at IN2 in low ASCII
CMP SYSTEXT,Y
BNE NEXTSYS
DEX
DEY
BPL LOOP4
INC MOD+1
MOD LDA #$FF ;the first .SYSTEM program we find is this
BEQ NEXTSYS ;one, so skip it and look for next one.
JSR READFILE ;if successful, never come back
QUIT JSR PRODOS
DFB $65 ;QUIT
DA QUITP
SYSTEXT ASC '.SYSTEM'
;;; Get name of next system file or binary file
;;;
;;; This routine is set up to look for both SYSTEM and
;;; BINary files in the SETUPs subdirectory. It is later
;;; modified to search for SYSTEM files only in the
;;; volume directory. The locations which are changed
;;; are ChekType+1, Number+1, and NamePtr (in the Open
;;; parametr list)
;;;
;;; Returns carry if not found, clear if found.
NEXTFILE JSR PRODOS
DFB $C8 ;OPEN
DA OPENP
BCS CLOSE
LDA OPENN
STA MARKN
STA READN
JSR PRODOS ;Read in first 39 bytes of directory to
DFB $CA ;IN2. This gets the number of entries per
DA READP ;block and number of bytes per entry.
BCS CLOSE
LDA IN2+35 ;save number of bytes per directory entry
STA ENTSIZE+1
LDA IN2+36 ;save number of entries per directory block
STA ENTRIES+1
NEXTENT INC NUMBER+1
NUMBER LDA #0 ;self-modified operand
;;; Retrieve catalog entry #A
LDX #$FE ;build page index in X
LOOP5 INX
INX
ENTRIES CMP #13
BCC OK
SBC ENTRIES+1
BCS LOOP5 ;always
OK TAY
LDA #4 ;1st entry per directory block starts 4 bytes in
LOOP10 DEY
BMI OK2
CLC
ENTSIZE ADC #39 ;add size of directory entry
BCC LOOP10
INX
BNE LOOP10 ;always
OK2 STA MARK ;save mark in file
STX MARK+1
JSR PRODOS ;set the mark
DFB $CE ;SET_MARK
DA MARKP
BCS CLOSE
JSR PRODOS ;read in directory info
DFB $CA ;READ
DA READP
BCS CLOSE
LDA IN2 ;make sure that file is not deleted
BEQ NEXTENT
AND #$0F
STA IN2
LDA FILETYPE ;make sure file type is correct
EOR #$FF ;we look for system programs...
BEQ CLOSE
CHEKTYPE EOR 6^$FF ;...and binary ones.
BNE NEXTENT
CLOSE PHP ;close all files - do not change carry
JSR PRODOS
DFB $CC ;CLOSE
DA CLOSEP
PLP
ANRTS RTS
;;; Read file and call it.
;;; Name should be found at IN2
;;; Prefix must be set.
READFILE LDX FILETYPE ;if a system program, set to read to $2000
LDA #$20
INX
BEQ SETDEST
LDX AUXCODE ;else, set to read in file at address
LDA AUXCODE+1 ;found in auxcode
SETDEST STX READ2D
STA READ2D+1
JSR PRODOS ;Open file
DFB $C8 ;OPEN
DA OPEN2P
BCS CLOSE
LDA OPEN2N
STA READ2N
JSR PRODOS ;Read file into memory
DFB $CA ;READ
DA READ2P
JSR CLOSE
BCS ANRTS
JMP (READ2D) ;call the file just loaded
;;; ****** ProDOS MLI parameter lists
ONLINEP DFB 2 ;Online parameter list
ONLINEN DS 1
DA VOLNAME+1
;;;
PFX1P DFB 1 ;to set prefix to SETUP
DA DIRNAME
;;;
PFX2P DFB 1 ;to set prefix to volume directory
DA VOLNAME
;;;
QUITP DFB 4,0,0,0,0,0,0
;;;
CLOSEP DFB 1,0 ;close all files
;;;
OPENP DFB 3 ;open directory
NAMEPTR DA DIRNAME ;pathname pointer
DA IOBUFFER
OPENN DS 1 ;reference number
;;;
MARKP DFB 2 ;set mark in directory
MARKN DS 1
MARK DS 3
;;;
READP DFB 4 ;read directory
READN DS 1
DA IN2 ;target address
DA 39 ;length
DS 2
;;;
OPEN2P DFB 3 ;open setup or system file
DA IN2
DA IOBUFFER
OPEN2N DS 1
;;;
READ2P DFB 4 ;read setup or system file
READ2N DS 1
READ2D DS 2 ;destination of file is self-mod here
DA $B900-$800 ;ask for largest possible that will fit
DS 2
;;;
VOLTEXT ASCH "INSERT VOLUME"
.if 0
CHK ;checksum - eor for all previous bytes
.else
.byte $E8
.endif

View File

@ -8,13 +8,22 @@ HEADERS = $(wildcard *.inc) $(wildcard ../inc/*.inc)
TARGETS = \
$(OUTDIR)/a2green.system.SYS \
$(OUTDIR)/a2green.setup.SYS \
$(OUTDIR)/bw.system.SYS \
$(OUTDIR)/bw.setup.SYS \
$(OUTDIR)/deepblue.system.SYS \
$(OUTDIR)/deepblue.setup.SYS \
$(OUTDIR)/gray.system.SYS \
$(OUTDIR)/gray.setup.SYS \
$(OUTDIR)/gsblue.system.SYS \
$(OUTDIR)/gsblue.setup.SYS \
$(OUTDIR)/mint.system.SYS \
$(OUTDIR)/mint.setup.SYS \
$(OUTDIR)/pink.system.SYS \
$(OUTDIR)/wb.system.SYS
$(OUTDIR)/pink.setup.SYS \
$(OUTDIR)/wb.system.SYS \
$(OUTDIR)/wb.setup.SYS
# For timestamps
MM = $(shell date "+%-m")
DD = $(shell date "+%-d")
@ -37,8 +46,8 @@ clean:
$(OUTDIR)/%.o: %.s $(HEADERS)
ca65 $(CAFLAGS) $(DEFINES) --listing $(basename $@).list -o $@ $<
$(OUTDIR)/%.setup.o: %.system.s $(HEADERS)
ca65 $(CAFLAGS) $(DEFINES) -D BUILD_SETUP_FILE --listing $(basename $@).list -o $@ $<
$(OUTDIR)/%.BIN $(OUTDIR)/%.SYS: $(OUTDIR)/%.o
ld65 $(LDFLAGS) -o $@ $<
ifdef XATTR
xattr -wx prodos.AuxType '00 20' $@
endif

View File

@ -9,7 +9,9 @@ HEADERS = $(wildcard *.inc) $(wildcard ../inc/*.inc)
TARGETS = \
$(OUTDIR)/quit.system.SYS \
$(OUTDIR)/pause.system.SYS \
$(OUTDIR)/pause.setup.SYS \
$(OUTDIR)/me.first.system.SYS \
$(OUTDIR)/me.first.setup.SYS \
$(OUTDIR)/date.BIN
# For timestamps
@ -34,6 +36,9 @@ clean:
$(OUTDIR)/%.o: %.s $(HEADERS)
ca65 $(CAFLAGS) $(DEFINES) --listing $(basename $@).list -o $@ $<
$(OUTDIR)/%.setup.o: %.system.s $(HEADERS)
ca65 $(CAFLAGS) $(DEFINES) -D BUILD_SETUP_FILE --listing $(basename $@).list -o $@ $<
$(OUTDIR)/%.BIN $(OUTDIR)/%.SYS: $(OUTDIR)/%.o
ld65 $(LDFLAGS) -o $@ $<
ifdef XATTR