blockdev: remove a layer of indirection in block routine storage
This will facilitate "copying" blk selection in FS.
This commit is contained in:
parent
ad217c018e
commit
3ba0a707e7
@ -26,8 +26,11 @@ BLOCKDEV_SEEK_END .equ 4
|
|||||||
; Pointer to the selected block device. A block device is a 8 bytes block of
|
; Pointer to the selected block device. A block device is a 8 bytes block of
|
||||||
; memory with pointers to GetC, PutC, Seek and Tell routines, in that order.
|
; memory with pointers to GetC, PutC, Seek and Tell routines, in that order.
|
||||||
; 0 means unsupported.
|
; 0 means unsupported.
|
||||||
BLOCKDEV_SEL .equ BLOCKDEV_RAMSTART
|
BLOCKDEV_GETC .equ BLOCKDEV_RAMSTART
|
||||||
BLOCKDEV_RAMEND .equ BLOCKDEV_SEL+2
|
BLOCKDEV_PUTC .equ BLOCKDEV_GETC+2
|
||||||
|
BLOCKDEV_SEEK .equ BLOCKDEV_PUTC+2
|
||||||
|
BLOCKDEV_TELL .equ BLOCKDEV_SEEK+2
|
||||||
|
BLOCKDEV_RAMEND .equ BLOCKDEV_TELL+2
|
||||||
|
|
||||||
; *** CODE ***
|
; *** CODE ***
|
||||||
; Select block index specified in A
|
; Select block index specified in A
|
||||||
@ -45,36 +48,32 @@ blkSel:
|
|||||||
djnz .loop
|
djnz .loop
|
||||||
pop bc
|
pop bc
|
||||||
.afterloop:
|
.afterloop:
|
||||||
ld (BLOCKDEV_SEL), hl
|
push hl
|
||||||
|
call intoHL
|
||||||
|
ld (BLOCKDEV_GETC), hl
|
||||||
|
pop hl
|
||||||
|
inc hl
|
||||||
|
inc hl
|
||||||
|
push hl
|
||||||
|
call intoHL
|
||||||
|
ld (BLOCKDEV_PUTC), hl
|
||||||
|
pop hl
|
||||||
|
inc hl
|
||||||
|
inc hl
|
||||||
|
push hl
|
||||||
|
call intoHL
|
||||||
|
ld (BLOCKDEV_SEEK), hl
|
||||||
|
pop hl
|
||||||
|
inc hl
|
||||||
|
inc hl
|
||||||
|
call intoHL
|
||||||
|
ld (BLOCKDEV_TELL), hl
|
||||||
pop hl
|
pop hl
|
||||||
pop af
|
pop af
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; In those routines below, IY is destroyed (we don't push it to the stack). We
|
; call IX unless it's zero
|
||||||
; seldom use it anyways...
|
|
||||||
|
|
||||||
; set IX to the address of the routine in BLOCKDEV_SEL with offset IYL.
|
|
||||||
_blkCallAddr:
|
|
||||||
push de
|
|
||||||
ld de, (BLOCKDEV_SEL)
|
|
||||||
; DE now points to the *address table*, not the routine addresses
|
|
||||||
; themselves. One layer of indirection left.
|
|
||||||
; slide by offset
|
|
||||||
push af
|
|
||||||
ld a, iyl
|
|
||||||
call addDE ; slide by offset
|
|
||||||
pop af
|
|
||||||
call intoDE
|
|
||||||
; Alright, now de points to what we want to call
|
|
||||||
ld ixh, d
|
|
||||||
ld ixl, e
|
|
||||||
pop de
|
|
||||||
ret
|
|
||||||
|
|
||||||
; call routine in BLOCKDEV_SEL with offset IYL.
|
|
||||||
_blkCall:
|
_blkCall:
|
||||||
push ix
|
|
||||||
call _blkCallAddr
|
|
||||||
; Before we call... is IX zero? We don't want to call a zero.
|
; Before we call... is IX zero? We don't want to call a zero.
|
||||||
push af
|
push af
|
||||||
xor a
|
xor a
|
||||||
@ -85,25 +84,22 @@ _blkCall:
|
|||||||
.ok:
|
.ok:
|
||||||
pop af
|
pop af
|
||||||
call callIX
|
call callIX
|
||||||
jr .end
|
ret
|
||||||
.error:
|
.error:
|
||||||
pop af
|
pop af
|
||||||
ld a, BLOCKDEV_ERR_UNSUPPORTED
|
ld a, BLOCKDEV_ERR_UNSUPPORTED
|
||||||
.end:
|
|
||||||
pop ix
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; Reads one character from selected device and returns its value in A.
|
; Reads one character from selected device and returns its value in A.
|
||||||
; Sets Z according to whether read was successful: Set if successful, unset
|
; Sets Z according to whether read was successful: Set if successful, unset
|
||||||
; if not.
|
; if not.
|
||||||
blkGetC:
|
blkGetC:
|
||||||
ld iyl, 0
|
ld ix, (BLOCKDEV_GETC)
|
||||||
jr _blkCall
|
jr _blkCall
|
||||||
|
|
||||||
; Repeatedly call blkGetC until the call is a success.
|
; Repeatedly call blkGetC until the call is a success.
|
||||||
blkGetCW:
|
blkGetCW:
|
||||||
ld iyl, 0
|
ld ix, (BLOCKDEV_GETC)
|
||||||
call _blkCallAddr
|
|
||||||
.loop:
|
.loop:
|
||||||
call callIX
|
call callIX
|
||||||
jr nz, .loop
|
jr nz, .loop
|
||||||
@ -127,7 +123,7 @@ blkRead:
|
|||||||
; Writes character in A in current position in the selected device. Sets Z
|
; Writes character in A in current position in the selected device. Sets Z
|
||||||
; according to whether the operation was successful.
|
; according to whether the operation was successful.
|
||||||
blkPutC:
|
blkPutC:
|
||||||
ld iyl, 2
|
ld ix, (BLOCKDEV_PUTC)
|
||||||
jr _blkCall
|
jr _blkCall
|
||||||
|
|
||||||
; Writes B chars to blkPutC from (HL).
|
; Writes B chars to blkPutC from (HL).
|
||||||
@ -180,12 +176,12 @@ blkSeek:
|
|||||||
ld hl, 0xffff
|
ld hl, 0xffff
|
||||||
.seek:
|
.seek:
|
||||||
pop de
|
pop de
|
||||||
ld iyl, 4
|
ld ix, (BLOCKDEV_SEEK)
|
||||||
jr _blkCall
|
jr _blkCall
|
||||||
|
|
||||||
; Returns the current position of the selected device in HL.
|
; Returns the current position of the selected device in HL.
|
||||||
blkTell:
|
blkTell:
|
||||||
ld iyl, 6
|
ld ix, (BLOCKDEV_TELL)
|
||||||
jr _blkCall
|
jr _blkCall
|
||||||
|
|
||||||
; This label is at the end of the file on purpose: the glue file should include
|
; This label is at the end of the file on purpose: the glue file should include
|
||||||
|
Loading…
Reference in New Issue
Block a user