;-------------------------------------------------------------------------
;
;  This is the Vector 1 Monitor version 2.1C. It performs console I/O
;  through a BITSTREAMER serial port at I/O address 2/3. 
;
;  The CV version of the monitor takes console input from the same 
;  BITSREAMER serial port, but console output is sent to a FLASHWRITER
;  or VDM-1 video board.
;
;  The C monitor puts its stack at CFD0. The CV monitor puts its stack
;  at DFD0. If using MZOS and configuring RAM at DC00-DFFF (as required
;  by the MZOS ROM), the stack should be at DFD0.
;
;  Disassembled by Mike Douglas, 3/18/22
;
;-------------------------------------------------------------------------
;
;  Version 2.1 versus Version 2.0:
;  
;  - Added H command to jump to DOS program at 2A00
;  - Allow command entry in lower case
;  - Allow typing space to force movement to next parameter
;  - Provides auto-selection of the North Star or Micropolis FDC with
;       with the "B"oot command
;  - Changed cassette load abort command to CTRL-X instead of CTRL-C
;  - Change point at which abort request checked for cassette routines
;       and for memory test
;
;-------------------------------------------------------------------------

; VECTOR ONE MONITOR - VERSION 2.1
; R. S. HARP
; OPTION C FOR BITSTREAMER I/O
;
; SYSTEM EQUATES

CONS	EQU	3		;CONSOLE STATUS PORT
COND	EQU	2		;CONSOLE DATA PORT
TBE	EQU	1		;TRANSMIT BUFFER ENTRY
RDA	EQU	2		;RECEIVE DATA AVAILABLE
STPOL	EQU	0		;STATUS POLARITY
CASD	EQU	06FH		;CASSETTE DATA PORT
CASC	EQU	06EH		;CASSETTE STATUS PORT

SPTR	EQU	0CFD0H		;STACK POINTER (RAM AT CC00)
;SPTR	EQU	0DFD0H		;STACK POINTER (RAM AT DC00)

NSBOOT	EQU	0E900H		;DISK BOOT LOADER (NORTHSTAR CONTROLLER)
MICRP1	EQU	0F400H		;DISK BOOT LOADER (MICROPOLIS BOOT TYPICAL)
MICRP2	EQU	0D800H		;DISK BOOT LOADER (MICROPOLIS BOOT ALTERNATE)

DOS	EQU	02028H		;MZOS OR NORTH STAR DOS RESTART
DOSPGM	EQU	02A00H		;MZOS OR NORTH START DOS PROGRAM

;********* COMMAND FORMAT *********
;
;  A SSSS FFFF ASCII DUMP
;  B JUMP TO DISK BOOT LOADER
;  C SSSS FFFF CCCC COMPARE BLOCKS
;  D SSSS FFFF DUMP IN HEX
;  E JUMP TO EXTENSION ROM
;  F SSSS FFFF DD DD TWO BYTE SEARCH
;  G SSSS GO TO AND EXECUTE
;  H JUMP TO DOS PROGRAM (2A00)
;  I PP INPUT FROM I/O PORT
;  J JUMP TO DOS
;  K JUMP TO ZERO
;  L SSSS FFFF LOAD AND GO
;  M SSSS FFFF DDDD MOVE BLOCK
;  N NON DESTRUCTIVE MEMORY TEST
;  O PP DD OUTPUT TO PORT
;  P LLLL PROGRAM MEMORY
;  Q SSSS FFFF COMPUTE CHECKSUM
;  R SSSS FFFF READ CASSETTE
;  S SSSS FFFF DD SEARCH FOR SINGLE BYTE
;  T SSSS FFFF TEST MEMORY
;  U GENERATE TARBELL SYNC
;  V SSSS FFFF VERIFY TAPE
;  W SSSS FFFF WRITE TAPE
;  X SSSS FFFF DDDD EXCHANGE BLOCK
;  Y SSSS FFFF RELOCATING LOADER
;  Z SSSS FFFF DD ZERO OR FILL MEMORY
;
;***********************************
	ORG 	0C000H

MONIT	JMP	INIT
INIT	MVI	A,0CEH		;INIT 8251 UART
	OUT	CONS
	MVI	A,027H
	OUT	CONS
START	LXI	SP,SPTR
	CALL	CRLF
	MVI	A,'*'		;PRINT *
	CALL	PTCN
	CALL	RDCN		;READ KEYBOARD
	ANI	05FH		;LOWER CASE TO UPPER CASE
	PUSH	PSW		;SAVE INPUT
	CALL	SPCE
	POP	PSW		;RESTORE INPUT
	LXI	H,START
	PUSH	H
	CPI	'A'
	RC			;TOO SMALL
	CPI	05BH
	RNC			;TOO LARGE
	LXI	H,CMDTB+07EH
	PUSH	PSW
	ADD	A
	ADD	L
	MOV	L,A
	MOV	E,M
	INX	H
	MOV	D,M
	XCHG
	POP	PSW
	PCHL			;AWAY WE GO

; COMMAND TABLE

CMDTB	DW	DISP		;A SSSS FFFF ASCII DUMP
	DW	DOBOOT		;B JUMP TO DISK BOOT LOADER
	DW	COMPR		;C SSSS FFFF CCCC COMPARE BLOCKS
	DW	DISP		;D SSSS FFFF DUMP IN HEX
	DW	MONIT+0400H	;E JUMP TO EXTENSION ROM
	DW	SRCH		;F SSSS FFFF DD DD TWO BYTE SEARCH
	DW	EXEC		;G SSSS GO TO AND EXECUTE
	DW	DOSPGM		;H JUMP TO DOS PROGRAM AT 2A00
	DW	PINPT		;I PP INPUT FROM I/O PORT
	DW	DODOS		;J JUMP TO DOS
	DW	0		;K JUMP TO ZERO
	DW	CINR		;L SSSS FFFF LOAD AND GO
	DW	MOVEB		;M SSSS FFFF DDDD MOVE BLOCK
	DW	NDMT		;N NON DESTRUCTIVE MEMORY TEST
	DW	POUTP		;O PP DD OUTPUT TO PORT
	DW	PGM		;P LLLL PROGRAM MEMORY
	DW	COUTR		;Q SSSS FFFF COMPUTE CHECKSUM
	DW	CINR		;R SSSS FFFF READ CASSETTE
	DW	SRCH		;S SSSS FFFF DD SEARCH FOR SINGLE BYTE
	DW	TMEM		;T SSSS FFFF TEST MEMORY
	DW	SYNC		;U GENERATE TARBELL SYNC
	DW	CINR		;V SSSS FFFF VERIFY TAPE
	DW	COUTR		;W SSSS FFFF WRITE TAPE
	DW	MOVEB		;X SSSS FFFF DDDD EXCHANGE BLOCK
	DW	RLODR		;Y SSSS FFFF RELOCATING LOADER
	DW	ZEROM		;Z SSSS FFFF DD ZERO OR FILL MEMORY

; EXEC - DXECUTE THE PROGRAM AT THE ADDRESS

EXEC	CALL	AHEX		;READ ADDRESS FROM KEYBOARD
	XCHG
	PCHL

; AHEX - CONVERT UP TO 4 HEX DIGITS TO BINARY

AHEX	MVI	C,4		;COUNT OF 4 DIGITS
AHE0	LXI	H,0		;16 BIT ZERO
AHE1	CALL	RDCN		;READ A BYTE
AHEXNR	CPI	' '
	JMP	HEXPAT		;PATCH TO 2.0 CODE
PATRET	CPI	':'
	CNC	ALPH
	DAD	H
	DAD	H
	DAD	H
	DAD	H
	SUI	'0'		;ASCII BIAS
	CPI	10		;DIGIT 0-10
	JC	ALF
	SUI	7		;ALPHA BIAS
ALF	ADD	L
	MOV	L,A
	DCR	C
	JNZ	AHE1		;KEEP READING
NXTPRM	XCHG
SPCE	MVI	A,' '		;PRINT SPACE
PTCN	PUSH	PSW
PTLOP	IN	CONS
	XRI	STPOL
	ANI	TBE
	JZ	PTLOP
	POP	PSW		;RECOVER A
	OUT	COND		;AND PRINT IT
	RET			;RETURN FROM PTCN
CRLF	MVI	A,0DH		;PRINT A CARRIAGE RETURN
	CALL	PTCN
	MVI	A,0AH		
	JMP	PTCN
ALPH	CPI	'A'
	JC	START
	ANI	05FH
	CPI	'G'
	JNC	START
	RET

; RDCN - READ FROM CONSOLE TO REGISTER A

RDCN	CALL	CNTLC		;GET NEXT CHARACTER
	JZ	RDCN
	CPI	60H		;UPPER CASE?
	JC	PTCN		;YES
	ANI	05FH		;CONVERT LOWER TO UPPER
	JMP	PTCN		;ECHO
PAUSE	CALL	CNTLC
	CPI	' '
	RNZ
PLOOP	CALL	CNTLC
	CPI	' '
	JNZ	PLOOP
	RET
CNTLC	IN	CONS
	XRI	STPOL
	ANI	RDA
	RZ
	IN	COND
	ANI	07FH
	CPI	018H		;CTRL-X (CAN) ABORTS
	JZ	START
	RET

; COUTR - CASSETTE INTERFACE OUTPUT ROUTINE

COUTR	PUSH	PSW		;SAVE CONTROL
	CALL	TAHEX
	MVI	B,0		;START CHECKSUM = 0
	POP	PSW
	MOV	C,A
	CALL	COUT		;START BYTE OUT
	MVI	A,0E6H		;SEND SYNC BYTE
	CALL	COUT		;TO CASSETTE
COLOP	MOV	A,M		;GET DATA FROM MEMROY
	CALL	COUT		;SEND TO CASSETTE
	ADD	B		;ADD TO CHECKSUM
	MOV	B,A
	CALL	BMP
	JNZ	COLOP		;REPEAT LOOP
	MOV	A,B		;GET CHECKSUM
	CALL	COUT		;OUTPUT IT
	CALL	PT2		;PRINT CHECKSUM
	JMP	START		;GET ANOTHER COMMAND
COUT	PUSH	PSW		;SAVE A AND FLAGS
	MOV	A,C
	CPI	'Q'
	JZ	CHKSM
CLOP	CALL	PAUSE
	IN	CASC		;READ CASSETTE STATUS
	ANI	020H		;LOOK AT BIT 5
	JNZ	CLOP		;TRY AGAIN?
CHKSM	POP	PSW
	OUT	CASD		;SEND DATA TO CASSETTE
	RET

; CINR - CASSETTE INPUT ROUTINE

CINR	PUSH	PSW		;SAVE CONTROL CHARACTER
	MVI	A,010H		;USE BIT 4 IN REGISTER A
	OUT	CASC		;TO RESET CASSETTE INT
	CALL	TAHEX		;READ ADDRESSES
	POP	PSW		;GET CONTROL CHARACTER
	PUSH	H		;SAVE START ADDRESS
	PUSH	PSW		;UNDER CONTROL CHARACTER
	MVI	B,0		;SET CHECKUM = 0
CILOP	CALL	CIN		;READ FROM CASSETTE
	MOV	C,A		;SAVE IT IN REGISTER C
	POP	PSW		;GET CONTROL CHARACTER
	PUSH	PSW		;SAVE IT BACK
	CPI	'V'		;IS IT A V?
	MOV	A,C		;GET BACK DATA BYTE
	JZ	CIN0		;IF V, DON'T STORE
	MOV	M,A		;IF NOT, STORE
CIN0	ADD	B		;ADD TO CHECKSUM
	MOV	B,A
	CALL	BMP
	JNZ	CILOP		;READ MORE
	CALL	CIN		;READ LAST BYTE
	PUSH	PSW
	CALL	PT2		;PRINT CHECKSUM
	CALL	SPCE		;SPACE OVER
	POP	PSW
	CMP	B		;COMPARE TO CHECKSUM
	MVI	A,'E'		;PRINT E FOR ERROR
	JNZ	CERR		;PRINT NOW IF ERROR
	POP	PSW		;RECOVER CONTROL CHARACTER
	CPI	'L'		;IF NOT L
	JNZ	CERR		;DON'T EXECUTE
	POP	H		;OTHERWISE, EXECUTE
	PCHL			;AT STARTING ADDRESS
CERR	CALL	PTCN		;PRINT V, E, OR R
	JMP	START
CIN	CALL	PAUSE
	IN	CASC		;READ STATUS
	ANI	010H		;LOOK AT BIT 4
	JNZ	CIN		;WAIT UNTIL LOW
	IN	CASD		;READ FROM CASSETTE
	RET

; TMEM - MEMORY TEST ROUTINE

TMEM	CALL	TAHEX		;READ ADDRESSES
	LXI	B,05A5AH	;INIT B,C
CYCL	CALL	RNDM
	PUSH	B		;KEEP ALL REGISTERS
	PUSH	H
	PUSH	D
TLOP	CALL	RNDM
	MOV	M,B		;WRITE IN MEMORY
	CALL	BMP
	JNZ	TLOP		;REPEAT LOOP
	POP	D		
	POP	H		;RESTORE ORIGINAL
	POP	B		;VALUES
	PUSH	H
	PUSH	D
RLOP	CALL	RNDM		;GENERATE NEW SEQUENCE
	MOV	A,M		;READ MEMORY
	CMP	B		;COMPARE MEMORY
	CNZ	ERR		;CALL ERROR ROUTINE
	CALL	BMP
	JNZ	RLOP
	POP	D
	POP	H
	JMP	CYCL

; RNDM - THIS ROUTINE GENERATES RANDOM NUMBERS

RNDM	CALL	PAUSE
	MOV	A,B		;LOOK AT B
	ANI	0B4H		;MASK BITS
	ANA	A		;CLEAR CARRY
	JPE	PEVE		;JUMP IF EVEN
	STC
PEVE	MOV	A,C		;LOOK AT C
	RAL			;ROTATE CARRY IN
	MOV	C,A		;RESTORE C
	MOV	A,B		;LOOK AT B
	RAL			;ROTATE CARRY IN
	MOV	B,A		;RESTORE B
	RET			;RETURN WITH NEW B,C

; PTAD - ERROR PRINT OUT ROUTINE

PTAD	CALL	CRLF		;PRINT CR,LF
	CALL	PAUSE
	MOV	A,H		;PRINT
	CALL	PT2		;ASCII
	MOV	A,L		;CODES
	CALL	PT2		;FOR
	CALL	SPCE		;ADDRESS
	RET
ERR	PUSH	PSW		;SAVE A
	CALL	PTAD		;PRINT ADDRESS
	MOV	A,B		;DATA 
	CALL	PT2		;WRITTEN
	CALL	SPCE
	POP	PSW		;DATA READ
PT2	PUSH	PSW
	CALL	BINH
	POP	PSW
	JMP	BINL
BINH	RAR
	RAR
	RAR
	RAR
BINL	ANI	0FH		;LOW 4 BITS
	ADI	'0'		;ASCII BIAS
	CPI	03AH		;DIGIT 0-9
	JC	PTCN
	ADI	7		;DIGIT A-F
	JMP	PTCN

; DISP - DISPLAY MEMORY CONTENTS

DISP	MOV	B,A		;SAVE CONTROL
	CALL	TAHEX		;READ ADDRESSES
ENT1	MVI	C,16		;16 LOCATIONS PER LINE
	CALL	PTAD
LP2	MOV	A,B
	CPI	'A'		;IS IT "A"?
	MOV	A,M
	JZ	ASCD		;DUMP ASCII
	CALL	PT2		;PRINT OUT
	CALL	SPCE
LP3	CALL	BMP
	RZ
	DCR	C
	JZ	ENT1		;END OF LINE
	JMP	LP2		;CONTINUE LOOP
ASCD	ANI	060H		;MASK FOR CONTROL
	JNZ	NCON
	CALL	SPCE
	JMP	LP3
NCON	MOV	A,M
	ANI	07FH		;MASK FOR ASCII
	CALL	PTCN
	JMP	LP3

; PGM - PROGRAM MEMORY

PGM	CALL	AHEX		;READ ADDRESS
	XCHG
	CALL	CRLF		
PGLP	MOV	A,M		;READ MEMORY
	CALL	PT2		;PRINT 2 DIGITS
	MVI	A,'-'		;LOAD DASH
	CALL	PTCN		;PRINT DASH
CRIG	CALL	RDCN
	CPI	' '		;SPACE
	JZ	CON2		;SKIP IF SPACE
	CPI	0DH		;SKIP IF CR
	JNZ	CON1
	CALL	CRLF		;PRINT CR,LF
	JMP	CRIG		;BACK FOR MORE
CON1	XCHG			;HL->DE
	LXI	H,0		;GET 16 BIT ZERO
	MVI	C,2		;COUNT 2 DIGITS
	CALL	AHEXNR		;CONVERT TO HEX (NO READ)
	MOV	M,E
CON2	INX	H
	JMP	PGLP

; BMP - COMPARE ADDRESS AND INCREMENT H

BMP	MOV	A,E
	SUB	L
	JNZ	GOON
	MOV	A,D
	SBB	H
GOON	INX	H
	RET

; ZEROM - ZERO OR FILL MEMORY WITH A CONSTANT

ZEROM	CALL	TAHEX		;READ ADDRESSES
	PUSH	H		;SAVE H
	MVI	C,2		;2 DIGITS
	CALL	AHE0		;READ 2 DIGITS
	XCHG
	XTHL			;RESTORE HL
	POP	B		
ZLOOP	MOV	M,C		;WRITE INTO MEMORY
	CALL	BMP		;COMPARE ADDRESS, INCREMENT H
	RZ
	JMP	ZLOOP

; MOVEB - MOVE A BLOCK OF MEMORY

MOVEB	MOV	B,A		
	CALL	TAHEX		;READ ADDRESSES
	PUSH	H
	CALL	AHEX
	XCHG
	XTHL			;BACK TO NORMAL
MLOOP	MOV	C,M
	XTHL
	MOV	A,B
	CPI	'M'
	JZ	NEXCH
	MOV	A,M
	XTHL
	MOV	M,A
	XTHL
NEXCH	MOV	M,C
	INX	H
	XTHL
	CALL	BMP
	JZ	START
	JMP	MLOOP

; NDMT - NON DESTRUCTIVE MEMORY TEST

NDMT	LXI	H,0		;START AT ZERO
NDLOP	MOV	C,M
	MVI	B,0FFH
	MOV	M,B
	MOV	A,M
	CMP	B
	JNZ	ERR		;PRINT ERROR
	MVI	B,0
	MOV	M,B
	MOV	A,M
	CMP	B
	JNZ	ERR
	MOV	M,C
	INX	H
	JMP	NDLOP

; COMPR - COMPARE TWO BLOCKS OF MEMORY

COMPR	CALL	TAHEX
	PUSH	H
	CALL	AHEX
	XCHG
VMLOP	MOV	A,M
	INX	H
	XTHL
	CMP	M
	MOV	B,M
	CNZ	ERR
	CALL	BMP
	XTHL
	JNZ	VMLOP
	POP	PSW
	RET

; SRCH - SEARCH FOR SPECIFIC CODES

SRCH	PUSH	PSW
	CALL	TAHEX
	PUSH	H		;SAVE H
	MVI	C,2		;COUNT OF 2
	CALL	AHE0		;READ 2 DIGITS
	XCHG			;H=CODE, D=F
	MOV	B,L		;PUT CODE IN B
	POP	H		;RESTORE H
	POP	PSW
	CPI	'S'
	PUSH	PSW
	JZ	CONT
	PUSH	H
	MVI	C,2
	CALL	AHE0
	XCHG
	MOV	C,L
	POP	H
CONT	MOV	A,M		;READ MEMORY
	CMP	B		;COMPARE TO CODE
	JNZ	SKP		;SKIP IF NO COMPARE
	POP	PSW		;FETCH CONTROL
	CPI	'S'
	PUSH	PSW
	JZ	OBCP
	INX	H
	MOV	A,M
	DCX	H
	CMP	C
	JNZ	SKP
OBCP	INX	H
	MOV	A,M		;READ NEXT BYTE
	DCX	H		;DECR ADDRESS
	CALL	ERR		;PRINT CODES
SKP	CALL	BMP		;CHECK IF DONE
	JNZ	CONT		;BACK FOR MORE
	POP	PSW
	RET

; TAHEX - SHORT ROUTINE TO SAVE CODE

TAHEX	CALL	AHEX
	CALL	AHEX
	RET

; POUTP - OUTPUT DATA TO A PORT

POUTP	MVI	C,2
	CALL	AHE0		;PORT NUMBER IN E
	MVI	C,2
	CALL	AHE0		;PORT TO L, DATA IN E
	MOV	D,L
	LXI	H,SPTR-30H	;FORM OUT NN, RET IN MEMORY AT H
	MVI	M,0C9H		;RET OPCODE
	DCX	H
	MOV	M,D		;OUTPUT PORT FOR OUT INSTRUCTION
	DCX	H
	MVI	M,0D3H		;OUT OPCODE
	MOV	A,E
	PCHL

; PINPT - INPUT DATA FROM A PORT

PINPT	MVI	C,2
	CALL	AHE0		;PORT NUMBER TO E
	LXI	H,SPTR-30H	;FORM IN NN, RET IN MEMORY AT H
	MVI	M,0C9H		;RET OPCODE
	DCX	H
	MOV	M,E		;INPUT PORT OF IN INSTRUCTION
	DCX	H
	MVI	M,0DBH		;IN OPCODE
	CALL	SPTR-32H
	JMP	PT2

; SYNC - OUTPUT TARBELL SYNC

SYNC	MVI	A,0E6H		;SYNC BYTE
	MOV	C,A
	CALL	COUT		;OUTPUT TO CASSETTE
	CALL	CNTLC
	JMP	SYNC

; RLODR - THE VECTOR 1 RELOCATING LOADER

RLODR	MVI	A,10H		;RESET CASS INT.
	OUT	CASC
	CALL	TAHEX
	PUSH	H		;SAVE START ADD.
	MVI	B,0		;ZERO CHECKSUM
PASS1	CALL	CIN		;READ CASS.
	MOV	M,A		;WRITE IN MEMORY
	CMP	M		;CHECK IF THERE
	JNZ	MERR		;MEMORY ERROR
	ADD	B		;ADD TO CHECKSUM
	MOV	B,A		;PUT IT BACK
	CALL	BMP		;ALL DONE?
	JNZ	PASS1		;LOOP IF NOT
	CALL	CIN		;READ LAST BYTE
	CMP	B		;CHECKSUM AGREE?
	JNZ	LDERR
PASS2	MVI	A,10H		;RESET CASS.
	OUT	CASC
	POP	H		;GET START ADD.
	PUSH	H		;SAVE IT BACK
	MVI	B,0		;ZERO CHECKSUM
L2LP	CALL	CIN		;READ CASS.
	PUSH	PSW
	ADD	B		;ADD TO CHECKSUM
	MOV	B,A		;PUT IT BACK
	POP	PSW
	CMP	M
	JZ	OK
	SUB	M
	CPI	017H		;IT IS LSB?
	JNZ	HIBYT		;JUMP IF NOT
	XTHL
	MOV	A,L		;LO BYTE OF START
	XTHL
	ADD	M
	MOV	M,A		;REPLACE NEW ADD.
	JNC	OK		;NO OVERFLOW
	INX	H		;LOOK AT HI BYTE
	INR	M		;BUMP IT
	DCX	H		;RESTORE H
	JMP	OK
HIBYT	XTHL
	MOV	A,H		;HI BYTE OF START
	XTHL
	ADD	M
	MOV	M,A		;REPLACE NEW AD.
OK	CALL	BMP		;CHECK IF DONE
	JNZ	L2LP		;LOOP IF NOT
	CALL	CIN		;READ LAST BYTE
	CMP	B		;CHECKUMP AGREE?
	JNZ	LDERR		;BAD LOAD
GDLD	LXI	H,M3
	JMP	ERMSG
LDERR	LXI	H,M1
	JMP	ERMSG
MERR	LXI	H,M2
ERMSG	POP	PSW		;CLEAR STACK
	MOV	A,M		;READ MESSAGE
	CALL	PTCN
	ANA	A		;SET FLAGS
	INX	H
	JNZ	ERMSG+1
	RET

; MESSAGES

M1	DB	'BAD LOAD',0
M2	DB	'MEMORY ERROR',0
M3	DB	'GOOD LOAD',0

; THE FOLLOWING PATCHES WERE ADDED TO V2.0 AS PART OF THE V2.1 PROM
;
; HEXPAT - PATCH TO AHEX ROUTINE TO ALLOW OPERATOR TO ENTER A SPACE TO
;   FORCE MOVEMENT TO 2ND PARAMETER

HEXPAT	JZ	NXTPRM		;SPACE, MOVE TO NEXT PARAM
	CPI	'0'
	JC	START		;INVALID, ABORT ENTRY
	JMP	PATRET		;BACK INTO CODE

; DOBOOT - PATCH TO BOOT ROUTINE TO AUTOMATICALLY CHOOSE BETWEEN NORTH
;   STAR OR MICROPOLIS FLOPPY CONTROLLER BOOT ROMS

DOBOOT	LDA	NSBOOT		;NORTH STAR FLOPPY?
	CPI	031H		;LOOK FOR LXI SP INSTRUCTION
	JZ	NSBOOT		;YES

	LDA	MICRP1		;MICROPOLIS FLOPPY AT F400?
	CPI	0F3H
	JZ	MICRP1		;YES
	JMP	MICRP2		;ELSE, ASSUME MICROPOLIS AT D800

; DODOS - PATCH TO JUMP TO DOS ENTRY POINT (2028) ONLY IF ITS PRESENCE
;   IS DETECTED. OTHERWISE, JUMP TO 04E7H. NO IDEA WHAT THAT IS.

DODOS	LXI	H,DOS
	MOV	A,M
	CPI	JMP
	JNZ	04E7H
	PCHL

	END
