From f2ea11fcde294fdc3a5a91f328f206dc3da74a0d Mon Sep 17 00:00:00 2001 From: Joshua Bell Date: Sat, 26 Nov 2022 20:29:38 -0800 Subject: [PATCH] Add "jumbo" clock driver, an amalgamation of the others This one driver pulls in the installers for each other clock driver, and invokes each in turn: * No-Slot Clock * ROMX * FujiNet * DClock * Cricket! This requires adding `.ifndef JUMBO` guards in the other drivers for when they pull in include files (symbols, macros, etc). The other drivers are adjusted to return with carry clear on successful install, failure otherwise. --- clocks/Makefile | 2 +- clocks/README.md | 2 + clocks/cricket/cricket.system.s | 15 +++++++ clocks/dclock/dclock.system.s | 25 ++++++++++- clocks/fujinet/fn.clock.system.s | 20 +++++++-- clocks/jumbo/Makefile | 38 ++++++++++++++++ clocks/jumbo/README.md | 13 ++++++ clocks/jumbo/clock.system.s | 75 +++++++++++++++++++++++++++++++ clocks/ns.clock/ns.clock.system.s | 14 ++++++ clocks/romx/romxrtc.system.s | 14 ++++++ 10 files changed, 212 insertions(+), 6 deletions(-) create mode 100644 clocks/jumbo/Makefile create mode 100644 clocks/jumbo/README.md create mode 100644 clocks/jumbo/clock.system.s diff --git a/clocks/Makefile b/clocks/Makefile index d6db28f..2e5d3bd 100644 --- a/clocks/Makefile +++ b/clocks/Makefile @@ -1,4 +1,4 @@ -targets := ns.clock cricket dclock romx fujinet +targets := ns.clock cricket dclock romx fujinet jumbo .PHONY: all $(targets) diff --git a/clocks/README.md b/clocks/README.md index 846f31a..6355b99 100644 --- a/clocks/README.md +++ b/clocks/README.md @@ -30,3 +30,5 @@ This directory includes drivers for the following real-time clocks: * Cricket! All follow the above protocol: install only if there is not already a clock, probe for the clock before installing, and chain to the next driver. + +In addition, the "jumbo" directory combines the other driver installers to create a single unified clock driver installer. See its [README](jumbo/README.md) for more details. diff --git a/clocks/cricket/cricket.system.s b/clocks/cricket/cricket.system.s index c55e3fc..92d5d93 100644 --- a/clocks/cricket/cricket.system.s +++ b/clocks/cricket/cricket.system.s @@ -6,6 +6,7 @@ ;;; Original by "CAP" 04/21/91 ;;; http://www.apple2.org.za/gswv/a2zine/GS.WorldView/v1999/Oct/MISC/NSC.Disk.TXT +.ifndef JUMBO_CLOCK_DRIVER .setcpu "6502" .linecont + .feature string_escapes @@ -18,9 +19,12 @@ .include "../../inc/macros.inc" .include "../../inc/prodos.inc" .include "../../inc/ascii.inc" +.endif ; JUMBO_CLOCK_DRIVER ;;; ************************************************************ +.ifndef JUMBO_CLOCK_DRIVER .include "../../inc/driver_preamble.inc" +.endif ; JUMBO_CLOCK_DRIVER ;;; ************************************************************ ;;; ============================================================ @@ -31,7 +35,9 @@ read_delay_hi = $3 * 3 ; ($300 iterations is normal * 3.6MHz) +.ifndef JUMBO_CLOCK_DRIVER .define PRODUCT "Cricket Clock" +.endif ; JUMBO_CLOCK_DRIVER ;;; ============================================================ ;;; Ensure there is not a previous clock driver installed. @@ -115,10 +121,14 @@ cricket_not_found: ;; fall through... not_found: +.ifndef JUMBO_CLOCK_DRIVER ;; Show failure message jsr log_message scrcode PRODUCT, " - Not Found." .byte 0 +.endif ; JUMBO_CLOCK_DRIVER + + sec ; failure rts restore_cmd_ctl: @@ -204,6 +214,7 @@ loop: lda driver,y lda ROMIN2 +.ifndef JUMBO_CLOCK_DRIVER ;; Display success message jsr log_message scrcode PRODUCT, " - " @@ -211,7 +222,9 @@ loop: lda driver,y ;; Display the current date jsr cout_date +.endif ; JUMBO_CLOCK_DRIVER + clc ; success rts ; done! .endproc @@ -310,5 +323,7 @@ done: pla ; restore saved command state .assert sizeof_driver <= 125, error, "Clock code must be <= 125 bytes" ;;; ************************************************************ +.ifndef JUMBO_CLOCK_DRIVER .include "../../inc/driver_postamble.inc" +.endif ; JUMBO_CLOCK_DRIVER ;;; ************************************************************ diff --git a/clocks/dclock/dclock.system.s b/clocks/dclock/dclock.system.s index 0e95578..dffa715 100644 --- a/clocks/dclock/dclock.system.s +++ b/clocks/dclock/dclock.system.s @@ -12,7 +12,8 @@ ; - John Brooks spotted this, [M.G.] totally missed this. ; This version of the code has fixes permanently applied. - .setcpu "65C02" +.ifndef JUMBO_CLOCK_DRIVER + .setcpu "6502" ; changed below .linecont + .feature string_escapes @@ -23,6 +24,7 @@ .include "../../inc/apple2.inc" .include "../../inc/macros.inc" .include "../../inc/prodos.inc" +.endif ; JUMBO_CLOCK_DRIVER ; zero page locations SCRATCH := $0B ; scratch value for BCD range checks @@ -43,7 +45,9 @@ DPTRH := SLOT4IO+2 ; Slinky data ptr high DATA := SLOT4IO+3 ; Slinky data byte ;;; ************************************************************ +.ifndef JUMBO_CLOCK_DRIVER .include "../../inc/driver_preamble.inc" +.endif ; JUMBO_CLOCK_DRIVER ;;; ************************************************************ ;;; ============================================================ @@ -52,11 +56,14 @@ DATA := SLOT4IO+3 ; Slinky data byte ;;; ;;; ============================================================ +.ifndef JUMBO_CLOCK_DRIVER .define PRODUCT "DClock" +.endif ; JUMBO_CLOCK_DRIVER ;;; ============================================================ ;;; Ensure there is not a previous clock driver installed. ;;; And that this is a IIc. And that the clock is present. +;;; NOTE: Safe to run on a non-IIc (6502 opcodes, etc) .proc maybe_install_driver lda MACHID @@ -70,16 +77,23 @@ DATA := SLOT4IO+3 ; Slinky data byte cmp #$00 bne done +;;; Since this is a IIc, okay to rely on 65C02 opcodes from here. + .pushcpu + .setcpu "65C02" + jsr ClockRead jsr ValidTime bcc InstallDriver +.ifndef JUMBO_CLOCK_DRIVER ;; Show failure message jsr log_message scrcode PRODUCT, " - Not Found." .byte 0 +.endif ; JUMBO_CLOCK_DRIVER -done: rts +done: sec ; failure + rts .endproc ; ---------------------------------------------------------------------------- @@ -124,6 +138,7 @@ loop: lda driver,y lda ROMIN2 +.ifndef JUMBO_CLOCK_DRIVER ;; Display success message jsr log_message scrcode PRODUCT, " - " @@ -131,7 +146,9 @@ loop: lda driver,y ;; Display the current date jsr cout_date +.endif ; JUMBO_CLOCK_DRIVER + clc ; success rts ; done! .endproc @@ -379,6 +396,10 @@ regulk = * - 1 sizeof_driver := * - driver .assert sizeof_driver <= 125, error, "Clock code must be <= 125 bytes" + .popcpu + ;;; ************************************************************ +.ifndef JUMBO_CLOCK_DRIVER .include "../../inc/driver_postamble.inc" +.endif ; JUMBO_CLOCK_DRIVER ;;; ************************************************************ diff --git a/clocks/fujinet/fn.clock.system.s b/clocks/fujinet/fn.clock.system.s index c3d1fcc..ffa2d00 100644 --- a/clocks/fujinet/fn.clock.system.s +++ b/clocks/fujinet/fn.clock.system.s @@ -1,6 +1,7 @@ ;;; ProDOS driver for the Fujinet clock ;;; Adapted from: https://github.com/a2stuff/prodos-drivers/blob/main/cricket/cricket.system.s +.ifndef JUMBO_CLOCK_DRIVER .setcpu "6502" .linecont + .feature string_escapes @@ -13,22 +14,27 @@ .include "../../inc/macros.inc" .include "../../inc/prodos.inc" .include "../../inc/ascii.inc" +.endif ; JUMBO_CLOCK_DRIVER ;;; ************************************************************ +.ifndef JUMBO_CLOCK_DRIVER .include "../../inc/driver_preamble.inc" - .include "./smartport.inc" +.endif ; JUMBO_CLOCK_DRIVER ;;; ************************************************************ + .include "./smartport.inc" + FN_CLOCK_DEVICE_TYPE := $13 ; As defined on the Fujinet firmware - ;;; ============================================================ ;;; ;;; Driver Installer ;;; ;;; ============================================================ +.ifndef JUMBO_CLOCK_DRIVER .define PRODUCT "Fujinet Clock" +.endif ; JUMBO_CLOCK_DRIVER ;;; ============================================================ ;;; Ensure there is not a previous clock driver installed. @@ -115,12 +121,15 @@ found: jmp install_driver not_found: +.ifndef JUMBO_CLOCK_DRIVER ;; Show failure message jsr log_message scrcode PRODUCT, " - Not Found." .byte 0 - rts +.endif ; JUMBO_CLOCK_DRIVER + sec ; failure + rts .endproc ;;; ------------------------------------------------------------ @@ -169,6 +178,7 @@ loop: lda driver,y lda ROMIN2 +.ifndef JUMBO_CLOCK_DRIVER ;; Display success message jsr log_message scrcode PRODUCT, " - " @@ -176,11 +186,15 @@ loop: lda driver,y ;; Display the current date jsr cout_date +.endif ; JUMBO_CLOCK_DRIVER + clc ; success rts ; done! .endproc ;;; ************************************************************ +.ifndef JUMBO_CLOCK_DRIVER .include "../../inc/driver_postamble.inc" +.endif ; JUMBO_CLOCK_DRIVER ;;; ************************************************************ diff --git a/clocks/jumbo/Makefile b/clocks/jumbo/Makefile new file mode 100644 index 0000000..1384855 --- /dev/null +++ b/clocks/jumbo/Makefile @@ -0,0 +1,38 @@ + +CAFLAGS = --target apple2enh --list-bytes 0 +LDFLAGS = --config apple2-asm.cfg + +OUTDIR = out + +HEADERS = $(wildcard *.inc) $(wildcard ../inc/*.inc) + +TARGETS = \ + $(OUTDIR)/clock.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 $@ $< +ifdef XATTR + xattr -wx prodos.AuxType '00 20' $@ +endif diff --git a/clocks/jumbo/README.md b/clocks/jumbo/README.md new file mode 100644 index 0000000..e04dfcd --- /dev/null +++ b/clocks/jumbo/README.md @@ -0,0 +1,13 @@ +# "Jumbo" ProDOS Clock Driver + +This is an amalgamation of the other clock driver installers. Each one is tried in turn, until one successfully installs a clock driver. + +The drivers are (in order): + +* No-Slot Clock +* ROMX +* FujiNet +* DClock +* Cricket! + +The installer is silent - no output is shown on either failure or success. diff --git a/clocks/jumbo/clock.system.s b/clocks/jumbo/clock.system.s new file mode 100644 index 0000000..a475927 --- /dev/null +++ b/clocks/jumbo/clock.system.s @@ -0,0 +1,75 @@ +;;; "Jumbo" Clock Driver +;;; +;;; Pulls in several clock drivers sources and tries each one in sequence. +;;; + + JUMBO_CLOCK_DRIVER = 1 + + .setcpu "6502" + .linecont + + .feature string_escapes + + .include "apple2.inc" + .include "apple2.mac" + .include "opcodes.inc" + + .include "../../inc/apple2.inc" + .include "../../inc/macros.inc" + .include "../../inc/prodos.inc" + .include "../../inc/ascii.inc" + +;;; ************************************************************ + .include "../../inc/driver_preamble.inc" +;;; ************************************************************ + +.scope ns_clock + .include "../ns.clock/ns.clock.system.s" +.endscope +.scope romx + .include "../romx/romxrtc.system.s" +.endscope +.scope dclock + .include "../dclock/dclock.system.s" +.endscope +.scope fujinet + .include "../fujinet/fn.clock.system.s" +.endscope +.scope cricket + .include "../cricket/cricket.system.s" +.endscope + +;;; ============================================================ +;;; +;;; Driver Installer +;;; +;;; ============================================================ + + .define PRODUCT "Jumbo Clock Driver" + +.proc maybe_install_driver + lda MACHID + and #$01 ; existing clock card? + bne ret + + jsr ns_clock::maybe_install_driver + bcc ret + + jsr romx::maybe_install_driver + bcc ret + + jsr dclock::maybe_install_driver + bcc ret + + jsr fujinet::maybe_install_driver + bcc ret + + jsr cricket::maybe_install_driver + bcc ret + +ret: rts +.endproc + + +;;; ************************************************************ + .include "../../inc/driver_postamble.inc" +;;; ************************************************************ diff --git a/clocks/ns.clock/ns.clock.system.s b/clocks/ns.clock/ns.clock.system.s index 58d8af5..3d87418 100644 --- a/clocks/ns.clock/ns.clock.system.s +++ b/clocks/ns.clock/ns.clock.system.s @@ -5,6 +5,7 @@ ;;; Modification history available at: ;;; https://github.com/a2stuff/prodos-drivers +.ifndef JUMBO_CLOCK_DRIVER .setcpu "6502" .linecont + .feature string_escapes @@ -16,9 +17,12 @@ .include "../../inc/apple2.inc" .include "../../inc/macros.inc" .include "../../inc/prodos.inc" +.endif ; JUMBO_CLOCK_DRIVER ;;; ************************************************************ +.ifndef JUMBO_CLOCK_DRIVER .include "../../inc/driver_preamble.inc" +.endif ; JUMBO_CLOCK_DRIVER ;;; ************************************************************ ;;; ============================================================ @@ -27,7 +31,9 @@ ;;; ;;; ============================================================ +.ifndef JUMBO_CLOCK_DRIVER .define PRODUCT "No-Slot Clock" +.endif ; JUMBO_CLOCK_DRIVER ;;; ============================================================ ;;; Ensure there is not a previous clock driver installed. @@ -126,11 +132,14 @@ not_found: dey bpl :- +.ifndef JUMBO_CLOCK_DRIVER ;; Show failure message jsr log_message scrcode PRODUCT, " - Not Found." .byte 0 +.endif ; JUMBO_CLOCK_DRIVER + sec ; failure rts saved: .byte 0, 0, 0, 0 @@ -180,6 +189,7 @@ loop: lda driver,y lda ROMIN2 +.ifndef JUMBO_CLOCK_DRIVER ;; Display success message jsr log_message scrcode PRODUCT, " - " @@ -187,7 +197,9 @@ loop: lda driver,y ;; Display the current date jsr cout_date +.endif ; JUMBO_CLOCK_DRIVER + clc ; success rts ; done! .endproc @@ -289,5 +301,7 @@ unlock: ;;; ************************************************************ +.ifndef JUMBO_CLOCK_DRIVER .include "../../inc/driver_postamble.inc" +.endif ; JUMBO_CLOCK_DRIVER ;;; ************************************************************ diff --git a/clocks/romx/romxrtc.system.s b/clocks/romx/romxrtc.system.s index 1a492e2..5bdea6f 100644 --- a/clocks/romx/romxrtc.system.s +++ b/clocks/romx/romxrtc.system.s @@ -8,6 +8,7 @@ ;;; Modifications by Joshua Bell inexorabletash@gmail.com ;;; * Converted to ca65 syntax and adapted to driver wrapper. +.ifndef JUMBO_CLOCK_DRIVER .setcpu "6502" .linecont + .feature string_escapes @@ -19,13 +20,16 @@ .include "../../inc/apple2.inc" .include "../../inc/macros.inc" .include "../../inc/prodos.inc" +.endif ; JUMBO_CLOCK_DRIVER ;;; Uncomment the following to "fake" a clock with a fixed date. ;;; Used for testing without a real ROMX around. ;;; FAKE_CLOCK = 1 ;;; ************************************************************ +.ifndef JUMBO_CLOCK_DRIVER .include "../../inc/driver_preamble.inc" +.endif ; JUMBO_CLOCK_DRIVER ;;; ************************************************************ ZipSlo := $C0E0 ; ZIP CHIP slowdown @@ -41,7 +45,9 @@ SEL_MBANK := $F851 ; Select Main bank reg ;;; ;;; ============================================================ +.ifndef JUMBO_CLOCK_DRIVER .define PRODUCT "ROMX Clock" +.endif ; JUMBO_CLOCK_DRIVER ;;; ============================================================ ;;; Ensure there is not a previous clock driver installed. @@ -85,11 +91,14 @@ nope: sec ; not found : bit SEL_MBANK ; restore original bank (unconditionally) bcc install_driver ; found clock! +.ifndef JUMBO_CLOCK_DRIVER ;; Show failure message jsr log_message scrcode PRODUCT, " - Not Found." .byte 0 +.endif ; JUMBO_CLOCK_DRIVER + sec ; failure rts .endproc @@ -148,6 +157,7 @@ loop: lda ClockDrv,y lda ROMIN2 +.ifndef JUMBO_CLOCK_DRIVER ;; Display success message jsr log_message scrcode PRODUCT, " - " @@ -155,7 +165,9 @@ loop: lda ClockDrv,y ;; Display the current date jsr cout_date +.endif ; JUMBO_CLOCK_DRIVER + clc ; success rts ; done! .endproc @@ -313,5 +325,7 @@ ClockDrvSize = ClockDrvEnd - ClockDrv .sprintf("Clock driver must be <= 125 bytes, was %d bytes", ClockDrvSize) ;;; ************************************************************ +.ifndef JUMBO_CLOCK_DRIVER .include "../../inc/driver_postamble.inc" +.endif ; JUMBO_CLOCK_DRIVER ;;; ************************************************************