Add ZIPCHIP.SYSTEM

This detects a ZIP CHIP and, if present, configures it to slow down
for speaker access, leaving the other settings alone.

In the future maybe there will be a configuration utility to control
the slots, as was included with the ZIP CHIP back in the day.
This commit is contained in:
Joshua Bell 2023-11-11 14:22:10 -08:00
parent 01175cf573
commit 93e48784b9
6 changed files with 228 additions and 1 deletions

View File

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

View File

@ -32,6 +32,8 @@ This repo includes the following drivers/modifications:
* ROMX Real-Time Clock
* FujiNet Clock
* A "jumbo" driver that includes all of the above (just called `CLOCK.SYSTEM`)
* Accelerators
* ZIP CHIP configuration (sets the chip to slow on speaker access)
* RAM Disk drivers
* RAMWorks Driver by Glen E. Bredon
* Quit dispatcher/selector (`BYE` routines)
@ -60,6 +62,7 @@ The intent is that you use a tool like Copy II Plus or [Apple II DeskTop](https:
* `FN.CLOCK.SYSTEM` - install FujiNet clock driver, if present
* `DCLOCK.SYSTEM` - install DClock clock driver, if present
* `CRICKET.SYSTEM` - install Cricket! clock driver, if present
* `ZIPCHIP.SYSTEM` - slow the ZIP CHIP on speaker access, if present
* `RAM.DRV.SYSTEM` - install RamWorks RAM disk driver, if present
* `BUHBYE.SYSTEM` - install a customized Quit handler to replace the built-in one
* `PAUSE.SYSTEM` - pause for a moment, so that you can inspect the output of the above

22
accelerators/Makefile Normal file
View File

@ -0,0 +1,22 @@
targets := zipchip
.PHONY: all $(targets)
all: $(targets)
export LOG_SUCCESS
export LOG_FAILURE
# Build all targets
$(targets):
@tput setaf 3 && echo "Building: $@" && tput sgr0
@$(MAKE) -C $@ \
&& (tput setaf 2 && echo "make $@ good" && tput sgr0) \
|| (tput blink && tput setaf 1 && echo "MAKE $@ BAD" && tput sgr0 && false)
# Clean all temporary/target files
clean:
@for dir in $(targets); do \
tput setaf 2 && echo "cleaning $$dir" && tput sgr0; \
$(MAKE) -C $$dir clean; \
done

View File

@ -0,0 +1,42 @@
CAFLAGS = --target apple2enh --list-bytes 0
LDFLAGS = --config apple2-asm.cfg
OUTDIR = out
HEADERS = $(wildcard *.inc) $(wildcard ../inc/*.inc)
TARGETS = \
$(OUTDIR)/zipchip.system.SYS
LOG_SUCCESS=1
LOG_FAILURE=1
# For timestamps
MM = $(shell date "+%-m")
DD = $(shell date "+%-d")
YY = $(shell date "+%-y")
DEFINES = -D DD=$(DD) -D MM=$(MM) -D YY=$(YY) \
-D LOG_SUCCESS=$(LOG_SUCCESS) -D LOG_FAILURE=$(LOG_FAILURE)
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)/%.BIN $(OUTDIR)/%.SYS: $(OUTDIR)/%.o
ld65 $(LDFLAGS) -o $@ $<
ifdef XATTR
xattr -wx prodos.AuxType '00 20' $@
endif

View File

@ -0,0 +1,159 @@
;;; ZIPCHIP.SYSTEM
;;; Configures the speaker to be temporarily slow
;;; TODO: Add a configuration utility
.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"
;;; ************************************************************
;; From ZIP Chip Manual v1 1987
ZC_REG_LOCK := $C05A
;; Write:
;; $A5 Locks the ZIP CHIP.
;; 4 consecutive $5A writes unlock ZIP CHIP.
;; While unlocked, any write other than $A5 or
;; $5A will initiate an indefinate syncronous [sic]
;; sequence.
kZCLock = $A5
kZCUnlock = $5A
ZC_REG_ENABLE := $C05B
;; Write - Any hex byte written will enable ZIP CHIP
;;
;; Read - Read the current status of the following:
;; bit 0 & 1 - Ramsize where
;; RAMSIZE1 RAMSIZE0 SIZE
;; 0 0 8K
;; 0 1 16K
;; 1 0 32K
;; 1 1 64K
;; bit 2 - unused
;; bit 3 - Delay (for memory)
;; 0 = Fast Mode - Delay not in effect
;; 1 = Sync Mode - Delay in effect
;; bit 4 - Disabled/enabled
;; 0 = Chip Enabled
;; 1 = Chip Disabled
;; bit 5 - Paddle fast/normal
;; 0 = Fast Mode
;; 1 = Synchronous Mode (Normal)
;; bit 6 = Cache Updated by data read
;; 0 = No update
;; 1 = Yes cache updated
;; bit 7 = Clock Pulse - 1.0035 milliseconds
;; Edges occur at .50175 milliseconds
ZC_REG_SLOTSPKR := $C05C
;; Read/Write - Slow/Speaker set and read
;; 0 = Set slot/speaker Fast
;; 1 = Set slot/speaker Normal
;; bit 0 - Speaker bit 4 - Slot 4
;; bit 1 - Slot 1 bit 5 - Slot 5
;; bit 2 - Slot 2 bit 6 - Slot 6
;; bit 3 - Slot 3 bit 7 - Slot 7
ZC_REG_SYSSPEED := $C05D
;; Write - Set System Speed
;; bit 0 - unused bit 4 - Clk4/5
;; bit 1 - unused bit 5 - Clk5/6
;; bit 2 - Clk2/3 bit 6 - Clk/2
;; bit 3 - Clk3/4 bit 7 - Clk/4
;; NOTE: bit 6 and bit 7 yield Clk/3
ZC_REG_SYNCOP := $C05E
;; Write - Enable/Disable Synchronous Operation
;; for I/O Devices
;; bit 0 through bit 6 - Not Used
;; bit 7 - Enable/Disable Delay
;; 0 = Enable Delay
;; 1 = Disable and Reset Delay
ZC_REG_SOFTSW := $C05E
;; Read - Read Apple softswitches
;; 0 = False
;; 1 = True
;; bit 0 - ROMRD bit 4 - 80STORE
;; bit 1 - RAMBNK bit 5 - MWR
;; bit 2 - PAGE2 bit 6 - MRD
;; bit 3 - HIRES bit 7 - ALTZP
ZC_REG_PDLBSLC := $C05F
;; Write - Paddle Speed, Bank Switch Language Card
;; bit 0 through bit 5 - Not Used
;; bit 6 - Paddle Set
;; 0 = Disable Paddle Delay
;; 1 = Enable Paddle Delay
;; bit 7 - Language Card Enable/Disable
;; 0 = Enable Cache of Language Card Memory
;; 1 = Disable Cache of Language Card Memory
.undef PRODUCT
.define PRODUCT "ZIP CHIP"
.proc maybe_install_driver
php ; timing sensitive
sei
;; Unlock
lda #kZCUnlock
sta ZC_REG_LOCK
sta ZC_REG_LOCK
sta ZC_REG_LOCK
sta ZC_REG_LOCK
;; ZIP CHIP present?
lda ZC_REG_SLOTSPKR
eor #$FF
sta ZC_REG_SLOTSPKR
cmp ZC_REG_SLOTSPKR
bne no_zip
eor #$FF
sta ZC_REG_SLOTSPKR
cmp ZC_REG_SLOTSPKR
bne no_zip
;; Slow on speaker access
lda ZC_REG_SLOTSPKR
ora #%00000001 ; bit 0 = Speaker
sta ZC_REG_SLOTSPKR
;; Lock
lda #kZCLock
sta ZC_REG_LOCK
;; TODO: Include cache size?
jsr log_message
scrcode PRODUCT, " - Configured."
.byte 0
plp
rts
no_zip:
jsr log_message
scrcode PRODUCT, " - Not Found."
.byte 0
plp
rts
.endproc
;;; ************************************************************
.include "../../inc/driver_postamble.inc"
;;; ************************************************************

View File

@ -35,6 +35,7 @@ add_file "selectors/out/bbb.system.SYS" "bbb.system#FF0000" "/$VOLNAME
add_file "selectors/out/buhbye.system.SYS" "buhbye.system#FF0000" "/$VOLNAME"
add_file "selectors/out/bye.system.SYS" "bye.system#FF0000" "/$VOLNAME"
add_file "selectors/out/selector.system.SYS" "selector.system#FF0000" "/$VOLNAME"
add_file "accelerators/zipchip/out/zipchip.system.SYS" "zipchip.system#FF0000" "/$VOLNAME"
add_file "util/out/quit.system.SYS" "quit.system#FF0000" "/$VOLNAME"
add_file "util/out/pause.system.SYS" "pause.system#FF0000" "/$VOLNAME"
add_file "util/out/me.first.system.SYS" "me.first.system#FF0000" "/$VOLNAME"