; can be combined to support a particular system\r
; configuration.\r
\r
-cr equ 13\r
-lf equ 10\r
-bell equ 7\r
ctlQ equ 'Q'-'@'\r
ctlS equ 'S'-'@'\r
\r
\r
extrn ?time ; signal time operation\r
\r
- ; general utility routines\r
-\r
- public ?pmsg ; print message\r
- public pr.dec,pr.decl ; print 16 or 32 bit decimal number\r
- public ?pderr ; print BIOS disk error message header\r
- public pr.inln,pr.crlf ; print message inline\r
- public phex4,phex2 ; print 4 digit hex (HL), or 2 digit hex (A)\r
-\r
- extrn div32_16 ; divide 32 bit by 16 bit number\r
-\r
include modebaud.inc ; define mode bits\r
\r
\r
; External names for BIOS entry points\r
\r
- public ?boot,?wboot,?const,?conin,?cono,?list,?auxo,?auxi\r
+ public ?boot,?wboot,boot,?const,?conin,?cono,?list,?auxo,?auxi\r
public ?home,?sldsk,?sttrk,?stsec,?stdma,?read,?write\r
public ?lists,?sctrn\r
public ?conos,?auxis,?auxos,?dvtbl,?devin,?drtbl\r
dseg ; this part can be banked\r
\r
boot:\r
+ ld a,SYS$CBR\r
+ out0 (cbr),a\r
+ ld a,USR$CBAR\r
+ out0 (cbar),a\r
ld sp,bs$stack\r
\r
call hwinit ; first time hardware initialisation\r
or d\r
jr z,d$init$next ; if null, no drive\r
push hl ; save @drv pointer\r
- if 0\r
- ex de,hl ; XDPH address in <HL>\r
- dec hl\r
- dec hl\r
- ld b,(hl) ; get relative drive code\r
- ld (@ADRV),bc ; save absolute and relative drive code\r
- dec hl ; point to init pointer\r
- ld d,(hl)\r
- dec hl\r
- ld e,(hl) ; get init pointer\r
- ex de,hl\r
- call ipchl ; call init routine\r
- else\r
push de\r
- pop ix\r
+ pop ix ; XDPH address in <DE>\r
ld b,(ix-2)\r
ld (@ADRV),bc ; save absolute and relative drive code\r
ld l,(ix-4)\r
ld h,(ix-3) ; get init pointer\r
call ipchl ; call init routine\r
- endif\r
pop hl ; recover @drv pointer\r
d$init$next:\r
pop bc ; recover counter and drive #\r
ret\r
\r
\r
- ds 64\r
+ ds bs$stack$size\r
bs$stack equ $\r
\r
\r
\r
\r
\r
- ; CONOUT\r
- ; Console Output. Send character in <C>\r
- ; to all selected devices\r
-\r
-conout:\r
+ ; LIST\r
+ ; List Output. Send character in <C>\r
+ ; to all selected devices.\r
\r
- ld hl,(@covec) ; fetch console output bit vector\r
+list:\r
+ ld hl,(@lovec) ; fetch list output bit vector\r
jr out$scan\r
\r
\r
jr out$scan\r
\r
\r
- ; LIST\r
- ; List Output. Send character in <C>\r
- ; to all selected devices.\r
+ ; CONOUT\r
+ ; Console Output. Send character in <C>\r
+ ; to all selected devices\r
\r
-list:\r
- ld hl,(@lovec) ; fetch list output bit vector\r
+conout:\r
+\r
+ ld hl,(@covec) ; fetch console output bit vector\r
\r
out$scan:\r
ld b,0 ; start with device 0\r
add hl,hl ; shift out next bit\r
jr nc,not$out$device\r
push hl ; save the vector\r
- push bc ; save the count and character\r
-not$out$ready:\r
- call coster\r
- or a\r
- jp z,not$out$ready\r
- pop bc\r
+; push bc ; save the count and character\r
+;not$out$ready:\r
+; call coster\r
+; or a\r
+; jr z,not$out$ready\r
+; pop bc\r
push bc ; restore and resave the character and device\r
call ?co ; if device selected, print it\r
pop bc ; recover count and character\r
ret\r
\r
\r
- ; CONOST\r
- ; Console Output Status. Return true if\r
- ; all selected console output devices\r
+ ; LISTST\r
+ ; List Output Status. Return true if\r
+ ; all selected list output devices\r
; are ready.\r
\r
-conost:\r
- ld hl,(@covec) ; get console output bit vector\r
+listst:\r
+ ld hl,(@lovec) ; get list output bit vector\r
jr ost$scan\r
\r
\r
jr ost$scan\r
\r
\r
- ; LISTST\r
- ; List Output Status. Return true if\r
- ; all selected list output devices\r
+ ; CONOST\r
+ ; Console Output Status. Return true if\r
+ ; all selected console output devices\r
; are ready.\r
\r
-listst:\r
- ld hl,(@lovec) ; get list output bit vector\r
+conost:\r
+ ld hl,(@covec) ; get console output bit vector\r
\r
ost$scan:\r
ld b,0 ; start with device 0\r
ret\r
\r
\r
- ; CONST\r
- ; Console Input Status. Return true if\r
- ; any selected console input device\r
- ; has an available character.\r
-\r
-const:\r
- ld hl,(@civec) ; get console input bit vector\r
- jr ist$scan\r
-\r
-\r
; AUXIST\r
; Auxiliary Input Status. Return true if\r
; any selected auxiliary input device\r
\r
auxist:\r
ld hl,(@aivec) ; get aux input bit vector\r
+ jr ist$scan\r
+\r
+\r
+ ; CONST\r
+ ; Console Input Status. Return true if\r
+ ; any selected console input device\r
+ ; has an available character.\r
+\r
+const:\r
+ ld hl,(@civec) ; get console input bit vector\r
\r
ist$scan:\r
ld b,0 ; start with device 0\r
ret\r
\r
\r
- ; CONIN\r
- ; Console Input. Return character from first\r
- ; ready console input device.\r
-\r
-conin:\r
- ld hl,(@civec)\r
- jr in$scan\r
-\r
-\r
; AUXIN\r
; Auxiliary Input. Return character from first\r
; ready auxiliary input device.\r
\r
auxin:\r
ld hl,(@aivec)\r
+ jr in$scan\r
+\r
+\r
+ ; CONIN\r
+ ; Console Input. Return character from first\r
+ ; ready console input device.\r
+\r
+conin:\r
+ ld hl,(@civec)\r
\r
in$scan:\r
push hl ; save bit vector\r
jp (hl)\r
\r
\r
-;-------------------------------------------------------------------------------\r
-; print message @<HL> up to a null\r
-; saves <BC> & <DE>\r
-\r
-?pmsg:\r
- push bc\r
- push de\r
-pmsg$loop:\r
- ld a,(hl)\r
- or a\r
- jr z,pmsg$exit\r
- ld c,a\r
- push hl\r
- call ?cono\r
- pop hl\r
- inc hl\r
- jr pmsg$loop\r
-pmsg$exit:\r
- pop de\r
- pop bc\r
- ret\r
-\r
-;-------------------------------------------------------------------------------\r
-; print message inline up to a null\r
-; saves all registers\r
-\r
-pr.inln:\r
- ex (sp),hl\r
- push af\r
- call ?pmsg\r
- pop af\r
- ex (sp),hl\r
- ret\r
-\r
-;-------------------------------------------------------------------------------\r
-; print <CR><LF>\r
-; saves all registers\r
-\r
-pr.crlf:\r
- call pr.inln\r
- db 13,10,0\r
- ret\r
-\r
-;-------------------------------------------------------------------------------\r
-; print hl as a 4 digit hexadecimal number\r
-; saves all registers\r
-\r
-phex4:\r
- ld a,h\r
- call phex2\r
- ld a,l\r
- ; fall thru\r
-\r
-;-------------------------------------------------------------------------------\r
-; print a as a 2 digit hexadecimal number\r
-; saves all registers\r
-\r
-phex2:\r
- push af\r
- rra\r
- rra\r
- rra\r
- rra\r
- call print.digit\r
- pop af\r
-\r
-print.digit:\r
- push hl\r
- push de\r
- push bc\r
- push af\r
- and 00fh\r
- cp 10\r
- jr c,prd_1\r
- add a,007h\r
-prd_1:\r
- add a,'0'\r
-\r
- ld c,a\r
- call ?cono\r
- pop af\r
- pop bc\r
- pop de\r
- pop hl\r
- ret\r
-\r
-\r
- if 0\r
-\r
-;-------------------------------------------------------------------------------\r
-; print 16 bit number from HL\r
-;\r
-\r
-pr.dec:\r
- ex de,hl\r
- ld hl,0\r
- ;fall thru\r
-\r
-pr.decl:\r
- push ix\r
- ld ix,1 ; count chars on stack\r
- push bc\r
- exx\r
- ex (sp),hl\r
-; push de\r
-; push bc\r
- exx\r
-\r
- xor a\r
- push af ; string terminator\r
- inc sp\r
-prd_divloop:\r
- ld bc,10\r
- call div32_16 ; get a digit\r
- ld a,c\r
- add a,'0' ; make it printable\r
- push af\r
- inc sp\r
- inc ix\r
-\r
- ld a,h\r
- or l\r
- or d\r
- or e\r
- jr nz,prd_divloop\r
- exx\r
- push hl\r
- exx\r
- pop bc ;b=filler, c=field width\r
- inc c\r
- push ix\r
- pop de\r
-prd_filloop:\r
- ld a,e\r
- cp c\r
- jr nc,prd_out\r
- push bc\r
- inc sp\r
- inc de\r
- jr prd_filloop\r
-prd_out:\r
- ld hl,0\r
- add hl,sp ;ptr to beginning of number string (hl==0 here)\r
- call ?pmsg\r
- ex de,hl\r
- add hl,sp\r
- ld sp,hl\r
- exx\r
- pop hl\r
- exx\r
- pop ix\r
- ret\r
-\r
- endif\r
-\r
-;-------------------------------------------------------------------------------\r
-; print 16 bit number from HL\r
-;\r
-\r
-pr.dec:\r
- ex de,hl\r
- ld hl,0\r
- ;fall thru\r
-\r
-pr.decl:\r
- push bc ;save width and fillchar\r
- push bc\r
- exx\r
- ex (sp),hl ;save hl', get width and fill\r
- push de ;save de'\r
-\r
- xor a\r
- ld d,a ;clear counter\r
- ld e,a\r
- push af ; string terminator\r
- inc sp\r
-\r
-prd_divloop: ;do\r
- exx ; (main)\r
- ld bc,10 ;\r
- call div32_16 ; get a digit\r
- ld a,c ;\r
- add a,'0' ; make it printable\r
- push af ;\r
-\r
- ld a,h ;\r
- or l ;\r
- or d ;\r
- or e ;\r
- exx ; (alt)\r
- inc sp ;\r
- inc de ;\r
- jr nz,prd_divloop ;\r
-\r
-prd_filloop: ;h=filler, l=field width\r
- ld a,e\r
- cp l\r
- jr nc,prd_out\r
- push hl\r
- inc sp\r
- inc de\r
- jr prd_filloop\r
-prd_out:\r
- ld hl,0\r
- add hl,sp ;ptr to beginning of number string (hl==0 here)\r
- call ?pmsg\r
- ex de,hl\r
- add hl,sp\r
- ld sp,hl\r
- inc sp ;remove string terminator\r
- pop de\r
- pop hl\r
- exx ;(main)\r
- pop bc\r
- ret\r
-\r
-\r
-;-------------------------------------------------------------------------------\r
-;\r
-?pderr:\r
- ld hl,drive$msg\r
- call ?pmsg ; error header\r
- ld a,(@adrv)\r
- add a,'A'\r
- ld c,a\r
- call ?cono ; drive code\r
- ld hl,track$msg\r
- call ?pmsg ; track header\r
- ld c,0\r
- ld hl,(@trk)\r
- call pr.dec ; track number\r
- ld hl,sector$msg\r
- call ?pmsg ; sector header\r
- ld hl,(@sect)\r
- call pr.dec ; sector number\r
- ret\r
-\r
\r
; BNKSEL\r
; Bank Select. Select CPU bank for further execution.\r
db -1,-1,-1,-1,-1,-1,-1,-1 ; ctl-s clears to zero\r
db -1,-1,-1,-1,-1,-1,-1,-1\r
\r
-\r
-\r
dseg ; following resides in banked memory\r
\r
-\r
-\r
; Disk I/O interface routines\r
\r
\r
ret ; return with no error\r
\r
\r
-\r
- ; error message components\r
-drive$msg: db cr,lf,bell,'BIOS Error on ',0\r
-track$msg: db ': T-',0\r
-sector$msg: db ', S-',0\r
-\r
-\r
; disk communication data items\r
; do not change order. sd driver depends on this\r
\r