Browse Source

ufddos80.asm: reorganize the random access routines to make general

Reorganize the random access routines so that the abstraction layer is
turned around. This allows non-DOS devices to take advantage of the
Q0$ mechanism; if they use DOSFDs then random access, otherwise for
sequential binary access.

XXX: This needs to be properly tested, and proper support added to the
PUN80 ROM.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
H. Peter Anvin 1 year ago
parent
commit
f5400d3477
1 changed files with 38 additions and 49 deletions
  1. 38 49
      rv32/roms/abc80/asmsrc/ufddos80.asm

+ 38 - 49
rv32/roms/abc80/asmsrc/ufddos80.asm

@@ -283,11 +283,11 @@ LINE_BUF        = 0xfe40
 PCODE_BUF       = 0xfeb8
 POKE_BUF        = 0xff80
 
-        .if AUXRAM_UFDDOS_BASE >= 0xe000 && AUXRAM_UFDDOS_BASE < 0xfd00
-STACK_BASE      = AUXRAM_UFDDOS_BASE
-        .else
-STACK_BASE      = _DOSBUF0
-        .endif
+	.if AUXRAM_UFDDOS_BASE >= 0xe000 && AUXRAM_UFDDOS_BASE < 0xfd00
+STACK_BASE	= AUXRAM_UFDDOS_BASE
+	.else
+STACK_BASE	= _DOSBUF0
+	.endif
 
 INIT800:        jp _INIT800             ; 6000 ..d  c3 95 64
 RUNX:           jp _RUNX                ; 6003 ..`  c3 bd 60
@@ -1405,38 +1405,34 @@ do_close:       ;; 6677 <- 6659
 .L6685:         ;; 6685 <- 667e
                 jp CLOSE                ; 6685 .!`  c3 21 60
 do_blkin:       ;; 6688 <- 6662
-                xor a                   ; 6688 .    af
-rd_blk:         ;; 6689 <- 6fbf
-                call posit_blk          ; 6689 ..f  cd a5 66
+                ld b,(ix+12)
                 call READ               ; 668c .-`  cd 2d 60
-                and a                   ; 668f .    a7
-                jr .L669a               ; 6690 ..   18 08
-do_blkut:       ;; 6692 <- 6665
-                xor a                   ; 6692 .    af
-wr_blk:         ;; 6693 <- 6fc2
-                call posit_blk          ; 6693 ..f  cd a5 66
-                call WRITE              ; 6696 .0`  cd 30 60
-                scf                     ; 6699 7    37
-.L669a:         ;; 669a <- 6690
                 ld h,(ix+9)             ; 669a .f.  dd 66 09
                 ld l,3                  ; 669d ..   2e 03
-                ret nc                  ; 669f .    d0
-                ex de,hl                ; 66a0 .    eb
+                ret
+do_blkut:       ;; 6692 <- 6665
+                ld b,(ix+12)
+                call WRITE              ; 6696 .0`  cd 30 60
+                ld d,(ix+9)
+                ld e,3
                 ld a,1                  ; 66a1 >.   3e 01
                 jr .L664a               ; 66a3 ..   18 a5
-                ;; A = 0 or DE = -1 for current block, otherwise DE
-posit_blk:      ;; 66a5 <- 6689 6693
+
+                ;; DE = -1 for current block, otherwise seek to block number
+blk_posit:
                 ld b,(ix+12)            ; 66a5 .F.  dd 46 0c
-                and a                   ; 66a8 .    a7
-                ret z                   ; 66a9 .    c8
+                ld a,b                  ; Lame sanity check for a DOS file
+                and 0x70
+                ret z
+                cp b
+                ret nz
                 ld a,d                  ; 66aa z    7a
                 and e                   ; 66ab .    a3
                 inc a                   ; 66ac <    3c
-                ret z                   ; 66ad .    c8
-                jp POSIT                ; 66ae .*`  c3 2a 60
-                ; Possibly unreachable
-                defb 0x2a               ; 66b1 *    2a
-                ld h,b                  ; 66b2 `    60
+                jp nz,POSIT
+                ret
+
+                .org 0x6b3, 0xff
 _BASERR:        ;; 66b3 <- 6051
                 ld hl,_DOSBUF1+3        ; 66b3 !..  21 03 f6
                 push af                 ; 66b6 .    f5
@@ -1589,7 +1585,7 @@ devdes_rom:     ;; 678a <- 6069 6560
                 defb 0x40 + 46          ; 679a n    6e
                 defb 2                  ; 679b .    02
                 .ascii "SF"             ; 679c SF   53 46
-                defb 37                 ; Nonstandard second hard drive XD_:
+                defb 37			; Nonstandard second hard drive XD_:
                 defb 5
                 .ascii "XD"
                 defb 0x00               ; 67a2 .    00
@@ -2853,23 +2849,25 @@ DOSGEN_HD:      defb 36                 ; 6fb3 $    24
 DOSGEN_XD:      defb 37                 ; 6fb5 %    25
                 defb 1                  ; 6fb6 .    01
                 defb 0                  ; 6fb7 .    00
-_RNDREAD:       ;; 6fb8 <- 6ffc
-                scf                     ; 6fb8 7    37
-                ; ld a,0xb4 -> 6fbb
-                defb 0x3e               ; 6fb9 >    3e
-_RNDWRITE:      ;; 6fba <- 6ffe
-                or h                    ; 6fba .    b4
-                ld ix,(RANDIX)          ; 6fbb .*.. dd 2a 16 fd
-                jp c,rd_blk             ; 6fbf ..f  da 89 66
-                jp wr_blk               ; 6fc2 ..f  c3 93 66
-_RNDSETUP:      ;; 6fc5 <- 6ffa
+_RNDREAD:
+                call rnd_posit
+                jp IX_BLKRD
+_RNDWRITE:
+                call rnd_posit
+                jp IX_BLKWR
+rnd_posit:
+                ld ix,(RANDIX)
+                jp blk_posit
+
+_RNDSETUP:
                 ld hl,0x00be            ; 6fc5 !..  21 be 00
                 push hl                 ; 6fc8 .    e5
                 ld l,h                  ; 6fc9 l    6c
                 push hl                 ; 6fca .    e5
                 add hl,sp               ; 6fcb 9    39
                 push de                 ; 6fcc .    d5
-                call find_q0s           ; 6fcd ..o  cd f0 6f
+                ld bc,Q0S               ; 6ff0 ..Q  01 02 51
+                call S_FNDVARDOS-7
                 pop de                  ; 6fd0 .    d1
                 ld a,e                  ; 6fd1 {    7b
                 call S_FINDOPEN         ; 6fd2 ...  cd 01 09
@@ -2895,15 +2893,6 @@ _RNDSETUP:      ;; 6fc5 <- 6ffa
                 ld (hl),d               ; 6fee r    72
                 ret                     ; 6fef .    c9
 
-;;; Find Q0$ in the BASIC variable list
-;;; The push and load hl could be skipped by jumping to 0x106d
-;;; rather than 0x1074 in BASIC...
-find_q0s:       ;; 6ff0 <- 6fcd
-                ld bc,Q0S               ; 6ff0 ..Q  01 02 51
-                push hl                 ; 6ff3 .    e5
-                ld hl,VARLIST-1         ; 6ff4 !(.  21 28 fe
-                jp S_FNDVARDOS          ; 6ff7 .t.  c3 74 10
-
 ;;;
 ;;; CALL entry points for random access on ABC80
 ;;;