]> cloudbase.mooo.com Git - z180-stamp-cpm3.git/blobdiff - cbios/bioskrnl.180
sdio, cfio: factor out common error message print routines
[z180-stamp-cpm3.git] / cbios / bioskrnl.180
index 79dac2c9a73224c46449b0d3c26863cb9ac6a60e..6c8366fe120796d95f2323ef4c0fb5a734436f44 100644 (file)
@@ -51,6 +51,7 @@ ccp   equ     0100h           ; Console Command Processor gets loaded
        extrn @dtbl                     ; table of pointers to XDPHs\r
        public @adrv,@rdrv,@trk,@sect   ; parameters for disk I/O\r
        public @dma,@dbnk,@cnt          ;    ''       ''   ''  ''\r
+       public @xdph,@op\r
 \r
     ; memory control\r
 \r
@@ -67,7 +68,7 @@ ccp   equ     0100h           ; Console Command Processor gets loaded
 \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
@@ -129,6 +130,10 @@ ccp        equ     0100h           ; Console Command Processor gets loaded
        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
@@ -258,13 +263,7 @@ co$next:
        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
-;      jr      z,not$out$ready\r
-;      pop     bc\r
-       push    bc              ; restore and resave the character and device\r
+       push    bc              ; save device num and the character\r
        call    ?co             ; if device selected, print it\r
        pop     bc              ; recover count and character\r
        pop     hl              ; recover the rest of the vector\r
@@ -311,7 +310,7 @@ cos$next:
        push    hl              ; save the vector\r
        push    bc              ; save the count\r
        ld      a,0FFh          ; assume device ready\r
-       call    c,coster        ; check status for this device\r
+       call    c,?cost         ; check status for this device\r
        pop     bc              ; recover count\r
        pop     hl              ; recover bit vector\r
        or      a               ; see if device ready\r
@@ -323,38 +322,6 @@ cos$next:
        or      0FFh            ; all selected were ready, return true\r
        ret\r
 \r
-       ; check for output device ready, including optional\r
-       ;       xon/xoff support\r
-coster:\r
-       ld      l,b\r
-       ld      h,0             ; make device code 16 bits\r
-       push    hl              ; save it in stack\r
-       add     hl,hl\r
-       add     hl,hl\r
-       add     hl,hl           ; create offset into device characteristics tbl\r
-       ld      de,@ctbl+6\r
-       add     hl,de           ; make address of mode byte\r
-       ld      a,(hl)\r
-       and     mb$xon$xoff\r
-       pop     hl              ; recover console number in <HL>\r
-       jp      z,?cost         ; not a xon device, go get output status direct\r
-       ld      de,xofflist\r
-       add     hl,de           ; make pointer to proper xon/xoff flag\r
-       call    cist1           ; see if this keyboard has character\r
-       ld      a,(hl)\r
-       call    nz,ci1          ; get flag or read key if any\r
-       cp      ctlq\r
-       jr      nz,not$q        ; if its a ctl-Q,\r
-       ld      a,0FFh          ;       set the flag ready\r
-not$q:\r
-       cp      ctls\r
-       jr      nz,not$s        ; if its a ctl-S,\r
-       ld      a,00h           ;       clear the flag\r
-not$s:\r
-       ld      (hl),a          ; save the flag\r
-       call    cost1           ; get the actual output status,\r
-       and     (hl)            ; and mask with ctl-Q/ctl-S flag\r
-       ret                     ; return this as the status\r
 \r
 cist1:                         ; get input status with <BC> and <HL> saved\r
        push    bc\r
@@ -365,23 +332,6 @@ cist1:                             ; get input status with <BC> and <HL> saved
        or      a\r
        ret\r
 \r
-cost1:                         ; get output status, saving <BC> & <HL>\r
-       push    bc\r
-       push    hl\r
-       call    ?cost\r
-       pop     hl\r
-       pop     bc\r
-       or      a\r
-       ret\r
-\r
-ci1:                           ; get input, saving <BC> & <HL>\r
-       push    bc\r
-       push    hl\r
-       call    ?ci\r
-       pop     hl\r
-       pop     bc\r
-       ret\r
-\r
 \r
        ; AUXIST\r
        ;       Auxiliary Input Status.  Return true if\r
@@ -404,17 +354,15 @@ const:
 ist$scan:\r
        ld      b,0             ; start with device 0\r
 cis$next:\r
-       add     hl,hl           ; check next bit\r
-       ld      a,0             ; assume device not ready\r
-       call    c,cist1 ; check status for this device\r
-       or      a\r
+       xor     a               ; assume next device not ready\r
+       add     hl,hl           ; check next bit (lets z flag unaffected)\r
+       call    c,cist1         ; check status for this device\r
        ret     nz              ; if any ready, return true\r
        inc     b               ; next device number\r
        ld      a,h\r
        or      l               ; see if any more selected devices\r
-       jr      nz,cis$next\r
-       xor     a               ; all selected were not ready, return false\r
-       ret\r
+       ret     z               ; all selected were not ready, return false\r
+       jr      cis$next\r
 \r
 \r
        ; AUXIN\r
@@ -437,10 +385,9 @@ in$scan:
        push    hl              ; save bit vector\r
        ld      b,0\r
 ci$next:\r
+       xor     a               ; assume next device not ready\r
        add     hl,hl           ; shift out next bit\r
-       ld      a,0             ; insure zero a  (nonexistant device not ready).\r
        call    c,cist1         ; see if the device has a character\r
-       or      a\r
        jr      nz,ci$rdy       ; this device has a character\r
        inc     b               ; else, next device\r
        ld      a,h\r
@@ -471,11 +418,6 @@ bnksel:
        jp      ?bank           ; and go exit through users\r
                                ; physical bank select routine\r
 \r
-\r
-xofflist:\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
        dseg    ; following resides in banked memory\r
 \r
 ;      Disk I/O interface routines\r
@@ -491,7 +433,10 @@ xofflist:
 seldsk:\r
        ld      a,c             ; save drive select code\r
        ld      (@adrv),a\r
-       ld      b,0             ; create index from drive code\r
+       xor     a\r
+       ld      (@op),a\r
+       ld      (@cnt),a\r
+       ld      b,a             ; create index from drive code\r
        ld      hl,@dtbl\r
        add     hl,bc           ; get pointer to dispatch table\r
        add     hl,bc\r
@@ -503,19 +448,21 @@ seldsk:
        or      h\r
        ret     z               ; if no entry in table, no disk\r
 \r
-       ld      a,e             ; examine login bit\r
-       and     1\r
-       ret     nz\r
-\r
-       push    ix\r
-       ld      ix,(@xdph)\r
-       ld      a,(ix-2)\r
-       ld      (@RDRV),a       ; get relative drive\r
-       ld      l,(ix-6)        ; get address of LOGIN routine\r
-       ld      h,(ix-5)\r
-       ex      (sp),ix\r
-       pop     de\r
+       bit     0,e             ; login bit to zero flag\r
+       ex      de,hl\r
+       ld      hl,-2           ; get relative drive\r
+       add     hl,de\r
+       ld      a,(hl)\r
+       ld      (@RDRV),a\r
+       jr      nz,notfirst     ; examine login bit\r
+       ld      hl,-6\r
+       add     hl,de\r
+       ld      a,(hl)\r
+       inc     hl\r
+       ld      h,(hl)\r
+       ld      l,a\r
        call    ipchl           ; call LOGIN\r
+notfirst:\r
        ld      hl,(@xdph)      ; recover DPH pointer\r
        ret\r
 \r
@@ -592,6 +539,8 @@ sectrn:
        ;               extended disk parameter header (XDPH).\r
 \r
 read:\r
+       ld      a,1\r
+       ld      (@op),a\r
        ld      ix,(@xdph)      ; get drive descriptor pointer\r
        ld      l,(ix-8)        ; get read routine entry\r
        ld      h,(ix-7)\r
@@ -604,6 +553,8 @@ read:
        ;               extended disk parameter header (XDPH).\r
 \r
 write:\r
+       ld      a,2\r
+       ld      (@op),a\r
        ld      ix,(@xdph)      ; get drive descriptor pointer\r
        ld      l,(ix-10)       ; get write routine entry\r
        ld      h,(ix- 9)\r
@@ -632,6 +583,7 @@ flush:
 ;     do not change order. sd driver depends on this\r
 \r
 @xdph: ds      2               ; pointer to currently selected drives dph\r
+@op    ds      1               ; current disk operation 0:select, 1:read, 2 write\r
 @adrv: ds      1               ; currently selected disk drive\r
 @rdrv: ds      1               ; controller relative disk drive\r
 @trk:  ds      2               ; current track number\r