;=====OSBKYBD.ASM======================8301191400===========
;		COPYRIGHT 1983	HOWARD WEINSTEIN
;				SAN DIEGO CA 92128
;		Reproduction in any form for other than
;		personal, non-commercial use is prohibited.
;	
;	Program to replace user-key definitions
;	of Osborne 1 (ROM v1.3 or v1.4) with that
;	set on diskette selected at keyboard.
;
;	CAUTION: The disk system is reset by this 
;	program. Any temporary R/O status will be
;	cancelled.  If R/O is essential to you,
;	either re-establish it or don't use this
;	program.
;
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;
	org 100h
;
; Equates
;
jmp$2$bdos	equ 5
select$dsk	equ 001Bh
select$trk	equ 001Eh
select$sect	equ 0021h
set$dma$adr	equ 0024h
read$sect	equ 0027h
first		equ 300h
second		equ 380h
local$bfr	equ first+006Bh
destination	equ 006Bh
size		equ 0E600h-0E56Bh
ldir		equ 0B0EDh
prnt$strg	equ 9
console$in	equ 1
ret$cur$dsk	equ 25
sel$drive	equ 14
reset$dsk$sys	equ 13
;
; Prepare return to BDOS
;
	lxi h,0
	dad sp
	lxi sp,oldstack
	shld oldstack
;
; Save current disk
;
	mvi c,ret$cur$dsk
	call jmp$2$bdos
	sta cur$dr
;
; Prepare for ROM v1.3 or v1.4
;
	lda 2
	sta a1+2 ! sta a2+2 ! sta a3+2
	sta a4+2 ! sta a5+2 ! sta a6+2
	sta a7+2 ! sta a8+2 ! sta a9+2
;
; Get diskette selection
;
openers	call get$dsk
	db 13,10,10,'Select user keys from drive A or B: ',36
	ds 16
oldstack ds 2
cur$dr  ds 1
; 
get$dsk	pop d
	mvi c,prnt$strg
	call jmp$2$bdos
	mvi c,console$in
	call jmp$2$bdos
	ani 5fh
	cpi 'A'
	jz okay
	cpi 'B'
	jz okay
	jmp openers
okay	sui 41h
	sta a1-1
;
; Make the switch
;
	mvi c,0
a1	call select$dsk
;
	mvi c,2
a2	call select$trk
;
	mvi c,4
a3	call select$sect
;
	lxi b, first
a4	call set$dma$adr
;
a5	call read$sect
;
	mvi c,5
a6	call select$sect
;
	lxi b,second
a7	call set$dma$adr
;
a8	call read$sect
;
; Move the selected user keys into place
;
	lxi h,local$bfr
a9	lxi d,destination
	lxi b,size
	dw ldir
;
; Restore default drive
;
	lda cur$dr
	mov e,a
	mvi c,sel$drive
	call jmp$2$bdos
;
; Reset disk system
;
	mvi c,reset$dsk$sys
	call jmp$2$bdos
;
; Go back to BDOS
;
	lhld oldstack
	sphl
	ret
;
	end 100h
o back to BDOS
;
	lhld oldstack
	sphl
	ret
;
	end 100h
