title Cold start routines. (C) 1983 By NLS .comment % ######################################################## ## ## ## KAYPRO 10 System ## ## ## ## By G. Ohnysty ## ## ## ## Cold start routine, reset and configure ## ## system for power up condition. ## ## ## ## Copyright (C) 1983 By Non-Linear Systems, Inc ## ## No warranty is made, expressed or implied. ## ## ## ######################################################## ## Date: 04/14/83 [01] ## ######################################################## # # # Modified for proper response to the floppy # # on power-up/reset by M. Sherman on 8-Jun-83 # # # ######################################################### % extrn stack, diskinit, vidinit, devinit, print, dmaadr, dpha extrn home, seldsk, settrk, setsec, setdma, read, write extrn sectran, kbdstat, kbdin, kbdout, ttystat, ttyin, ttyout, TTYOSTAT extrn liststat, list, vidout, diskoff, diskon, thnsd, @dmaadr, adsk extrn sectrk, dmaadr, $home ovlram equ 0EE00H ; load address for overlay hdsel equ 0 ; hard disk is A: flag fsel equ -1 ; floppy is A: flag status equ 10H ; floppy status port (to look for index) .z80 ; ROM master jump table jp start ; start up computer jp diskinit ; disk initialize jp vidinit ; video initialize jp devinit ; device initialize jp home ; home selected disk drive jp seldsk ; select a disk drive jp settrk ; seek a track jp setsec ; set sector number to read jp setdma ; set dma address jp read ; read logical sector jp write ; write logical sector jp sectran ; xlate sector number jp diskon ; turn on disk jp diskoff ; turn off disk jp kbdstat ; KeyBoarD character ready jp kbdin ; input from keyboard jp kbdout ; output to keyboard (used to ring bell) jp ttystat ; status of serial input port jp ttyin ; serial input jp ttyout ; serial output jp liststat ; list output status (Centronics) jp list ; list output JP TTYOSTAT ;TESTSTATUS OF SERIAL OUTPUT jp vidout ; video output jp thnsd ; short delay start: di ; stop interupts while setup ld sp,stack ; rom stack point ld b,20 ; a delay to let the hardware stabilize call thnsd ; 20 milli-seconds worth. call devinit ; init device sub-system call vidinit ; init video sub-system call diskinit ; init disk sub-system jr bootsys ; boot system org 66H ; nmi vector ret ; return from "halt", NMI sequence when in rom page ; boot system, the first sector (1) of the first track (0) ; hold system boot information. It does NOT hold a short boot routine! ; the image is: ; self: jr self ; hang if booted and run ; defw loadpt ; where to load the opsys image ; defw bios ; where to go after booting system ; defw length ; length of image in 128 byte sectors ; (* the rest of the sector is not used *) ; ; This sector image is loaded and inspected at 0FA00H during the boot process crlf equ 0D0AH ; new line codes esc equ 1BH ; ascii esc bell equ 07H ; kbd bell bootsys:call print defb esc,'=',20H+10,20H+31 defb '* KAYPRO 10 v 1.7 * ',0 ; DEFB 'BETA TEST ROM V 1.7a',0 doagain:call check ; is floppy alive? ld a,hdsel ; parms for hard disk ld (adsk),a ld a,68 ld (sectrk),a jr z,loadit ld a,fsel ; parms for floppy ld (adsk),a ld a,40 ld (sectrk),a loadit: call ovload ; load overlay boot: ld c,0 call seldsk ; select disk, set density, do home after diskinit ld bc,0 ; set track call settrk ld c,0 ; read the first sector call setsec ld bc,0FA00H ; header sector to go here call setdma call read ; read sector to FA00 di ; read does EI upon exit or a ; trouble reading? jr nz,doagain ; tell crt ld bc,(0FA02H) ; where to load system image ld a,c ; system image? cp 0E5H jr z,doagain ld (@dmaadr),bc ld (dmaadr),bc ld bc,(0FA04H) ; where to go after loading system push bc ; save for latter use ld bc,(0FA06H) ; length of system in 128 byte sectors ld b,c ; reg B holds # of sectors to load ld c,1 ; initial sector (0 was header sector) cb1: push bc ; save sector count and current sector call setsec ; select sector call read di ; read does EI upon exit pop bc or a jr nz,doagain ; bad read of sector ld hl,(@dmaadr) ; update dma address for next sector ld de,128 ; new dma address add hl,de ld (@dmaadr),hl ld (dmaadr),hl dec b ret z ; done booting goto system inc c ; bump sector count ld a,(sectrk) ; over sectors/track? cp c jr nz,cb1 ; fetch another sector ld c,16 ; first sector to read on next track push bc ; save counts ld bc,1 ; set for next track call settrk pop bc jr cb1 check: call fndidx ; find index pulse ret z ; no index, abort ld b,8 ; delay while waiting for index to go away call thnsd ; 8 MS in a,(status) cpl bit 1,a ; 0=no floppy, 1=floppy ret fndidx: call $home ; home floppy ld hl,9000H lp1: in a,(status) ; index pulse? bit 1,a ret nz ; index is nz, return if true dec hl ; enough tries? ld a,h or l jr nz,lp1 ret ovload: ld a,(adsk) ; is it possible to load overlay? or a ; is not possible if hard disk is drive B: jr z,loadovl ; go load overlay from hard disk filhdr: ld hl,ovlram ; base of overlay, fill with no.op ld b,16 ; *16 [or a, nop, ret] lp2: ld (hl),0B7H ; [or a] inc hl ld (hl),0 ; [nop] inc hl ld (hl),0C9H ; [ret] inc hl djnz lp2 ret loadovl:ld c,1 ; select drive B: call seldsk ld bc,0 ; track = 0 call settrk ld hl,ovlram ; set dma address ld (@dmaadr),hl ld bc,0 ; sector # ldlp: push bc call setsec call read ; read sector pop bc or a jr nz,filhdr ; fault ld hl,(@dmaadr) ; update dma address ld de,128 add hl,de ld (@dmaadr),hl inc c ld a,c cp 16 ; load 2K sec# 0-15 jr nz,ldlp ld a,(ovlram) ; check for a jp inst cp 0C3H jr nz,filhdr ; bad data in ram, fill header with default ret end