; Z3OS-OVL.ASM
; Daryl D. Gehlbach
; 05/01/90
;
; This file will generate an overlay used to patch a modified
; Osborne I SYSGEN to allow the Osborne to properly boot with
; ZCPR3. This was written as an alternative to patching via
; Digital Research's DDT.
;
; All patches are based on the standard Osborne I (DD) system. 
; The values of the ORG statements and the BIOS addresses may
; be different if you have tinkered or modified your system in
; any way. In all likelyhood you will need to get a copy of the
; Osborne I technical manual. 
;
;================================================================
;
; We need addresses from Z3BASE.LIB for this file.
;
	MACLIB	Z3BASE
;
BIOS	EQU	CCP+1600H	; bios address
BTOP	EQU	BIOS+0880H	; top of BIOS
BMRAM	EQU	0EA80H		; start of Scratch Ram
;
;
;================================================================
;
; SYSGEN PATCH
;
; #1) This patch bypasses the source prompt for SYSGEN. Since
;     the modified SYSGEN contains the system image, the source
;     prompt is unnecessary.
;
	org 	0144H
	JMP	028DH
;
; #2) This patch changes the signon message to indicate that 
;     the program is patched for ZCPR3n
;
	org	03ADH
	db	'ZCPR 3.0 '
;
;================================================================
;
; CCP PATCH
;
; #3) The Osborne I ROM uses the first three bytes of the CCP
;     to properly place the system in memory. The values of the
;     bytes that Osborne I expects is as follows:
;
;		00 -> C3 (JMP)
;		01 -> 5C (the ROM requires this)
;		02 -> CCP base pase + 3
;
;     If your CCP loads at C300, then byte 02 will be C6. My
;     only guess is that this was a failsafe to prevent the
;     loading of an incompatible system. Apart from the cold
;     boot these bytes serve no other purpose.
;
;     A properly designed ZCPR3 CCP will not place the values
;     the Osborne I expects. This patch allows the Osborne I to
;     boot with the ZCPR3 CCP.
;
	org	0980H
	JMP	CCP+035CH
;
;================================================================
;
; INITIALIZATION PATCHES
;
; These patches are placed in the area normally reserved for the
; function keys. Patches #3 and #4 are for data ZCPR3 needs on a
; cold boot. Patch #5 does the initializing.
;
; #4) This is the data for MAXDRV, MAXUSR, WHEEL and PATH to be
;     placed into low memory.
;
	org	2034H
	DB	06,0FFH,10H	;MAXDRV, WHEEL, MAXUSER
	DB	'$','$'		;Path (11 bytes)
	DB	01,00
	DB	01,15
	DB	00,00
	DB	00,00
	DB	00		;zero terminator
;
;
; #5) This data is placed into the Multiple Command Buffer for
;     program autostart.
;
	org	2042H
	DW	Z3CL+4		;point to first character
	DB	200		;max number of chars allowed
	DB	00
;
	DB	'LDR S.ENV,S.FCP;ST'	;place autst cmd here
	DB	0			;terminator
;
;
;
; #6) The BIOS cold boot routine jumps to this initialization
;     routine, which clears the buffer space, installs low
;     memory values (PATH, WHEEL, etc.) and loads command
;     line buffer with startup command.
;
	org	2059H
	LXI	B,BMRAM-BTOP	;we clear out Z-system area
	LXI	H,BTOP		;top of BIOS to BMRAM
	MVI	M,00
	INX	H
	DCX	B
	MOV	A,B
	ORA	C
	DB	20H,0F8H	;jrnz (to MVI M,00)
;
	LXI	B,14		;move maxdu,wheel and path
	LXI	H,BIOS+0B4H	;to correct spot
	LXI	D,Z3WHL-1
	DB	0EDH,0B0H	;LDIR
;
	LXI	B,23		;move command line
	LXI	H,BIOS+0C2H	;to correct spot
	LXI	D,Z3CL
	DB	0EDH,0B0H	;LDIR
;
	JMP	BIOS+0421H	;returns to boot routine
;
;================================================================
;
; BIOS PATCH
;
; #7) The following patch installs the boot intercept to pass
;     control to the initialization patch, and also bypasses the
;     autostart code, which is no longer needed.
;
	org	02392H
	DB	43H
;
	org	023D4H
	DB	18H,06H
	JMP	BIOS+0D9H
	DB	0,0,0
;
;===============================================================
;
; BDOS PATCH
;
; #8) This patch is needed to compensate for a nasty bug that
;     arises in the ZCPR33 TRANTCCP.SYS file. For some reason 
;     the Z33 version of the Trantor CCP places 01 hex into
;     location 0. Thus a ^C would crash the system. 
;
;     Furthermore, this byte is used by BYE to know when to 
;     hangup. Thus while BYE is running a ^C would force BYE
;     to hangup the phone.
;
;     We intercept ^C and force a C3 back into location 0. In
;     this way we avoid these two problems.
;
;     If using ZCPR30, this patch is not needed. It will not 
;     hurt to leave this in, but you may wish to comment it out
;     under Z30.
;
	org	0143BH
	DW	BIOS-8
;
	org	01F78H
	MVI	A,0C3H
	STA	00
	JMP	BIOS+3
;
;
;===============================================================
;
	END
;
01F78H
	MVI	A,0C3H
	STA	00
	JMP	BIOS+3
;
;
;========================================================