blockdev: reorganize routine pointers
Also, add dummy seek reoutine.
This commit is contained in:
parent
a5addc989c
commit
ce49fc15d0
@ -17,15 +17,13 @@ BLOCKDEV_ERR_OUT_OF_BOUNDS .equ 0x03
|
|||||||
|
|
||||||
; *** VARIABLES ***
|
; *** VARIABLES ***
|
||||||
; A memory pointer to a device table. A device table is a list of addresses
|
; A memory pointer to a device table. A device table is a list of addresses
|
||||||
; pointing to GetC and PutC routines.
|
; pointing to GetC, PutC and Seek routines.
|
||||||
BLOCKDEV_TBL .equ BLOCKDEV_RAMSTART
|
BLOCKDEV_TBL .equ BLOCKDEV_RAMSTART
|
||||||
; Index of the current blockdev selection
|
; Pointer to the selected block device. A block device is a 6 bytes block of
|
||||||
BLOCKDEV_SELIDX .equ BLOCKDEV_TBL+(BLOCKDEV_COUNT*4)
|
; memory with pointers to GetC, PutC and Seek routines, in that order. 0 means
|
||||||
; Address of the current GetC routine
|
; unsupported.
|
||||||
BLOCKDEV_GETC .equ BLOCKDEV_SELIDX+1
|
BLOCKDEV_SEL .equ BLOCKDEV_TBL+(BLOCKDEV_COUNT*2)
|
||||||
; Address of the current PutC routine
|
BLOCKDEV_RAMEND .equ BLOCKDEV_SEL+2
|
||||||
BLOCKDEV_PUTC .equ BLOCKDEV_GETC+2
|
|
||||||
BLOCKDEV_RAMEND .equ BLOCKDEV_PUTC+2
|
|
||||||
|
|
||||||
; *** CODE ***
|
; *** CODE ***
|
||||||
; set DE to point to the table entry at index A.
|
; set DE to point to the table entry at index A.
|
||||||
@ -35,41 +33,29 @@ blkFind:
|
|||||||
ret z ; index is zero? don't loop
|
ret z ; index is zero? don't loop
|
||||||
push bc
|
push bc
|
||||||
ld b, a
|
ld b, a
|
||||||
push af
|
|
||||||
ld a, 4
|
|
||||||
.loop:
|
.loop:
|
||||||
call addDE
|
inc de
|
||||||
|
inc de
|
||||||
djnz .loop
|
djnz .loop
|
||||||
pop af
|
|
||||||
pop bc
|
pop bc
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; Set the GetC pointer of device id A to the value in HL
|
; Set the pointer of device id A to the value in HL
|
||||||
blkSetGetC:
|
blkSet:
|
||||||
call blkFind
|
call blkFind
|
||||||
call writeHLinDE
|
call writeHLinDE
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; Set the GetC pointer of device id A to the value in HL
|
|
||||||
blkSetPutC:
|
|
||||||
call blkFind
|
|
||||||
inc de
|
|
||||||
inc de
|
|
||||||
call writeHLinDE
|
|
||||||
ret
|
|
||||||
|
|
||||||
; Select block index specified in A
|
; Select block index specified in A
|
||||||
blkSel:
|
blkSel:
|
||||||
|
push de
|
||||||
|
push hl
|
||||||
call blkFind
|
call blkFind
|
||||||
ld (BLOCKDEV_SELIDX), a
|
ld hl, BLOCKDEV_SEL
|
||||||
ex hl, de
|
ex hl, de
|
||||||
; now, HL points to the table entry
|
|
||||||
ld de, BLOCKDEV_GETC
|
|
||||||
ldi ; copy (HL) into (BLOCKDEV_GETC)
|
|
||||||
ldi ; .. and into +1
|
|
||||||
ld de, BLOCKDEV_PUTC
|
|
||||||
ldi ; same thing for (BLOCKDEV_PUTC)
|
|
||||||
ldi
|
ldi
|
||||||
|
pop hl
|
||||||
|
pop de
|
||||||
ret
|
ret
|
||||||
|
|
||||||
blkBselCmd:
|
blkBselCmd:
|
||||||
@ -85,12 +71,23 @@ blkBsel:
|
|||||||
ld a, BLOCKDEV_ERR_OUT_OF_BOUNDS
|
ld a, BLOCKDEV_ERR_OUT_OF_BOUNDS
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; Reads one character from blockdev ID specified at A and returns its value
|
; In those routines below, IY is destroyed (we don't push it to the stack). We
|
||||||
; in A. Always returns a character and waits until read if it has to.
|
; seldom use it anyways...
|
||||||
blkGetC:
|
|
||||||
|
; call routine in BLOCKDEV_SEL with offset IYL.
|
||||||
|
_blkCall:
|
||||||
push ix
|
push ix
|
||||||
push de
|
push de
|
||||||
ld de, (BLOCKDEV_GETC)
|
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 ixh, d
|
||||||
ld ixl, e
|
ld ixl, e
|
||||||
pop de
|
pop de
|
||||||
@ -98,13 +95,17 @@ blkGetC:
|
|||||||
pop ix
|
pop ix
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
; Reads one character from blockdev ID specified at A and returns its value
|
||||||
|
; in A. Always returns a character and waits until read if it has to.
|
||||||
|
blkGetC:
|
||||||
|
ld iyl, 0
|
||||||
|
jr _blkCall
|
||||||
|
|
||||||
blkPutC:
|
blkPutC:
|
||||||
push ix
|
ld iyl, 2
|
||||||
push de
|
jr _blkCall
|
||||||
ld de, (BLOCKDEV_PUTC)
|
|
||||||
ld ixh, d
|
blkSeek:
|
||||||
ld ixl, e
|
ld iyl, 4
|
||||||
pop de
|
jr _blkCall
|
||||||
call callIX
|
|
||||||
pop ix
|
|
||||||
ret
|
|
||||||
|
Loading…
Reference in New Issue
Block a user