; Hyperdrive macro include file
	lst	nprt
;
; 00.01 08/02/82 SBW Created
;
	org	0
hypnum:	ds	1	; Number of table entries
hyptab:	ds	2	; Addr of first table entry
hyplab:	ds	2	; Addr of hyperdrive label
hyprd:	ds	3	; Jump to read from hyperdrive
hypwr:	ds	3	; Jump to write to hyperdrive
hypsdt	equ	$	; Begin SDT patch area
	org	0
hyplen:	ds	2	; Size of the bank
hypadr:	ds	2	; Start addr+size
hypbnk:	ds	1	; Bank byte
hypsiz	equ	$	; Size of table entry
	rog
;
;		No parameters
hyper	mac
[hyptsz	equ	0
hypcnt	equ	0
]
;
;		 Start,Length,Bank byte
hypbank	mac
[	ifc	hyptsz=0
hyptbl:
	endc
	dw	&2>>7		; Size of this bank
	dw	(&1>>7)+(&2>>7)	; Start addr + size of this bank
	db	&3		; Bank byte
hyptsz	equ	hyptsz+(&2>>7)
hypcnt	equ	hypcnt+1
]
;
;		 ID,Hyper read routine,Hyper write routine
hypend	mac
[
	ifc	hyptsz<2048	; Roughly floppy sized?
csz&0	equ	8		; Yes: 1K clusters
	  ifc	hyptsz<1024	;    Smaller than 128K?
den&0	equ	32		;    Yes: 32 directory entries
	  elsec
den&0	equ	64		;    else 64 directory entries
	  endc
	elsec
	  ifc	hyptsz<4096
csz&0	equ	16		; 2K clusters
den&0	equ	64		; 64 directory entries
	  elsec
	    ifc	hyptsz<8192
csz&0	equ	32		; 4K clusters
den&0	equ	128		; 128 directory entries
	    elsec
	      ifc	hyptsz>=8192
csz&0	equ	64		; 8K clusters
den&0	equ	128		; 128 directory entries
	      endc
	    endc
	  endc
	endc
;
ctl&0:
	db	hypcnt!80h	; Count of table entries and init flag
	dw	hyptbl		; First table entry
	dw	lab&0		; Address of label
	jmp	&2		; Hyper read routine
	jmp	&3		; Hyper write routine
;
; SDT size patch:
;
	db	csz&0		; Cluster size
	dw	&1		; DUB pointer
	dw	1		; Dir start (zero is illegal)
	db	den&0		; Directory entries
	db	(den&0/4)/csz&0	; Directory clusters
;
	ent	&1
&1:
	dw	hyptsz+1	; Total blocks (L,H) (plus one for dir start)
	db	0		;              (H2)
	dw	hyptsz+1	; Blocks/surface (plus one for dir start)
	db	128		; Blocks/track
	DB	1		; Flag no single density tracks
	DW	0		; No interleave
	DW	set&0,io&0,spc&0
;
; Canned label for identification on system init.
;
lab&0:
	db	81h,'        ',0,0,0,csz&0,0,0,den&0/4
;
..1:
	ds	(lab&0+1)-$
	db	'&1'		; Patch in the label name
	ds	..1-$
;
	ifc	(den&0/4)>csz&0
	db	0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0	; Two clusters in dir
	elsec
	db	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	; One cluster in dir
	endc
;
	ext	hypset,hypio,hypspc
set&0:
	push	h
	lxi	h,ctl&0
	jmp	hypset
io&0:
	push	h
	lxi	h,ctl&0
	jmp	hypio
spc&0:
	push	h
	lxi	h,ctl&0
	jmp	hypspc
]
;
	lst	prt
