title KAYPRO II/IV CBIOS for CP/M 2.2. Copyright (C) 1982,1983 By NLS Inc. ;############################################################### ;## KAYPRO II/IV CBIOS for CP/M 2.2 ## ;## ## ;## By G. Ohnysty ## ;## ## ;## Copyright (C) 1982,83 By Non-Linear Systems, Inc. ## ;## No warranty is made, expressed or implied. ## ;############################################################### ;## Last Update: 02/24/83 [02] ## ;############################################################### ; ;History: ; Add disk motor time out. G. Ohnysty ; Add baud rate set by BIOS. ; ; Add # Pad xlate table. J. Nickerson ; Add list status test of TTY: ; Change default IO byte LST: to UL1 ; ; 58K ZCPR3 version 3.1 ; Steven M. Cohen, 06/09/85 ; ; modified in light of a Kaypro IV BIOS disassembly, as well as ; to better configure to ZCPR3 (fixed long time problem where new ; STARTUPs could not be used). ; Michael Broschat, 88/04/08 for Kaypro Campus User Group, Seattle maclib z3base.lib cbrev equ 51 ; BIOS revision number: April 1988 bdos equ ccp+806H ; start of Z80DOS bios equ ccp+1600H ; start of Basic I/O Subsystem (BIOS) cpml equ bios-ccp ; length of CP/M system in bytes (less BIOS) nsects equ cpml/128 ; length of CP/M system in sectors (less BIOS) trksec equ 40 ; sectors/track bitport equ 1CH ; status/control bit mapped port baud equ 0 ; baud rate port baud30 equ 05H ; 300 baud rate iobyte equ 3 ; logical to physical map rom equ 00000H ; base of rom ram equ 0FC00H ; base of scratch ram dmaadr equ ram+14H ; dma address if rcp ne 0 bufferbase equ rcp else equ shstk endif ; bufferbase is the bottom of the ZCPR-added segments. This version of the ; ..BIOS presumes either a minimal ZCPR system (no FCP, NDR, or RCP) or a ; ..full one (including those segments; a "maximum" system would include the ; ..IOP segment as well). The user should be aware that a system somewhere ; ..between these extremes could be developed having only one or two of the ; ..system segments just mentioned. .phase bios jp boot ; arrive here from cold start jp wboot ; arrive here for warm start jp const ; console status return in A FF=ready, 00=not jp conin ; console char in jp conout ; console char out jp list ; listing char out jp punch ; punch char out jp reader ; reader char in jp home ; move to track 0 on selected disk drive jp seldsk ; select disk drive jp settrk ; set track # jp setsec ; set sector # jp setdma ; set DMA address jp read ; read selected sector jp write ; write selected sector jp listst ; list status (Ready to print a char) jp sectran ; sector translate ioconfig: defb 10000001b ; initial value for i/o byte; this configures ; ..for parallel printer: serial gets 00000001 wrtsafe: defb 0 ; write safe flage 0=false vtab: defb 11, 10, 8, 12 ; vector pad xlate table ^k ^j ^h ^l defb '0', '1', '2', '3' defb '4', '5', '6', '7' defb '8', '9', '-', ',' defb 0DH, '.' baudrt: defb baud30 ; baud rate ; Cold boot entry point, set up system pointers and pass control to the CCP ; In the following code, the highest point allowable for non-Kaypro system ; ..code is presumed to be FB00. This, even though the scratch RAM appears ; ..to be at FC00. Tests on a 484 showed that something is using some of the ; ..FB00 block, perhaps as a stack. In effect, this configuration drops the ; ..system 256 bytes lower than perhaps it need be, but the gain is that ; ..all system segments for the 2X/484 series will work interchangably with ; ..this II/IV system. boot: call diskint if rcp ne 0 ld hl,rcp ld de,rcp+1 else ld hl,shstk ld de,shstk+1 endif ld bc,0faffh-bufferbase ; figure out the size of the ZCPR buffer space xor a ld (hl),a ldir ; zero out all buffer space as initialization ld hl,path ld de,expath ld bc,9 ldir ld hl,InitialCommand ld de,z3cl ld bc,0ch ; length of InitialCommand ldir ld hl,z3cl ; this allows the STARTUP file to be altered ld (z3env+24),hl ; ..at will xor a ; clear system disk number ld (4),a cpl ld (z3whl),a ; enable the wheel byte: don't do this if ; ..you want a secure system from boot up ld a,(ioconfig) ; init value for i/o byte ld (iobyte),a ld a,(baudrt) ; set baud rate out (baud),a call print defb 1ah, 0dh, 0ah defb 'Kaypro II/IV ' defb msize/10+'0', msize mod 10+'0' defb 'K Z80DOS vers. ' defb vers/10+'0','.', vers mod 10+'0' defb ' & ZCPR vers. ' defb z3rev/10+'0','.', z3rev mod 10+'0' defb ' w/ BIOS vers. ' defb cbrev/10+'0','.', cbrev mod 10+'0' defb 0dh,0ah defb ' by Campus Kaypro User Group, Seattle',0DH, 0AH, 00H goccp: ld a,0c3h ; set up CP/M jumps to bdos and wboot ld hl,bios+3 ; wboot entry point ld (0000),a ld (0001),hl ld hl,bdos ; entry point to bdos ld (0005),a ld (0006),hl ld a,(0004) ; last logical disk unit used ld c,a ; pass to ccp to select jp ccp ; pass control to ccp ; Warm boot entry point, re-load the CCP and BDOS wboot: call diskint call print defb 0DH, 0AH, 'Warm Boot', 0DH, 0AH, 00H wb0: ld sp,100H ; re-set stack ld c,0 ; select drive A: call seldsk ld bc,0 ; set track call settrk ld hl,ccp ; first memory location to load ld (dmaadr),hl ld bc,nsects*256+1 wb1: push bc ; save sector count and current sector call setsec ; select sector call read pop bc or a jr nz,wb0 ; oops, error on warm boot ld hl,(dmaadr) ; update dma address for next sector ld de,128 ; new dma address add hl,de ld (dmaadr),hl dec b jp z,goccp ; done loading inc c ; bump sector count ld a,trksec ; on to next track? cp c jp nz,wb1 ld c,16 ; first sector on next track push bc ; save counters ld c,1 call settrk ; set track pop bc jr wb1 ; logical devices are con: rdr: pun: and lst: ; physical devices are: ; crt: video and kbd ; tty: serial ; lpt: centronics ; ul1: serial with cts as busy ; pun: same as ul1 ; ;con: tty, crt ;rdr: tty ;pun: tty, pun ;lst: tty, crt, lpt, ul1 ; const: ld hl,count ; turn off disk drive inc (hl) call z,diskoff ld a,(iobyte) ; get i/o byte and 03H ; strip to con bits ld l,rom+33H ; serial status jp z,callrom ld l,rom+2AH ; assume CRT jp callrom conin: call diskoff ld a,(iobyte) and 03H ; check i/o byte ld l,rom+36H ; serial input jp z,callrom ld l,rom+2DH ; assume input from kbd call callrom ; go get char or a ret p ; msb not set and 01fh ; form table index to VTAB ld hl,vtab ld c,a ld b,0 add hl,bc ld a,(hl) ; pick up xlated character ret diskoff: in a,(bitport) ; turn off disk drives and sel leds set 6,a out (bitport),a ret conout: ld a,(iobyte) ; check i/o byte and 03H ld l,rom+39H ; serial output jp z,callrom ld l,rom+45H ; assume video jp callrom reader: ld l, rom+36H ; serial input jp callrom punch: ld l,rom+39h ;serial punch jp callrom list: ld a,(iobyte) and 0C0H ; check i/o byte ld l,rom+39H ; serial jp z,callrom ld l,rom+3FH ; centronics cp 80H jp z,callrom ld l,rom+45H ; video cp 40H jp z,callrom ld l, rom+39h ;ul1: default to serial jp callrom listst: ld a,(iobyte) ; check i/o byte and 0C0H ld l,rom+42H ; serial jp z,callrom ld l,rom+3CH ; centronics cp 80H jp z,callrom xor a ; 0=ready ret diskint: ld l,rom+03H ; re-set disk software sub-system jr callrom home: ld l,rom+0CH ; home disk drive rom routine jr callrom seldsk: ld l,rom+0FH ; select disk drive jr callrom settrk: ld l,rom+12H ; seek track jr callrom setsec: ld l,rom+15H ; set sector number jr callrom setdma: ld l,rom+18H ; set dma address jr callrom read: xor a ; reset disk off count ld (count),a ld l,rom+1BH ; read a logical sector jr callrom write: xor a ; reset disk off count ld (count),a ld l,rom+1EH ; write a logical sector ld a,(wrtsafe) ; write safe flag or a ; true or false jr z,callrom ; normal operation ld c,1 ; directory write code (forces write op) jr callrom sectran: ld l,rom+21H ; xlate logical to physical sector jr callrom callrom: exx ; save cp/m arguments in a,(bitport) ; turn rom on set 7,a out (bitport),a ld (savsp),sp ; save current stack (may be under rom) ld sp,stack ; set a local stack ld de,biosret ; rom to "RET" here push de exx ; restore cp/m arguments and call loc ld h,0 jp (hl) ; to rom routine specified in hl biosret: ex af,af' ; save reg A ld sp,(savsp) ; restore stack in a,(bitport) ; off the rom res 7,a out (bitport),a ex af,af' ; restore reg A ret ; done with rom routine print: ex (sp),hl ; pop return address, points to text to print ld a,(hl) ; get a byte of text, stop on zero byte inc hl ex (sp),hl ; save new return address or a ; is it a zero byte? ret z ld c,a ; no, so print it call conout jr print path: defb 1,15,1,0,'$','$',1,15,0,0,0 InitialCommand: defw z3cl+4 defb z3cls defb 0,'STARTUP',0 count: defb 0 ; disk off counter savsp: defs 2 ; current stack pointer during rom call stack equ $+64 ; A local stack: 64 is OK for ZCPR configurations, ; ..but cannot be used for straight CP/M, where 34 ; ..works fine. .dephase end