1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-24 03:38:05 +11:00

blockdev: protect IX in routines

Sure, it's a bit slower, but it prevents a lot of hard to debug
problems. I don't have to want to remember "don't use IX if you
have any blk* calls". Let's optimize I/O later.
This commit is contained in:
Virgil Dupras 2019-07-14 12:17:13 -04:00
parent 3b0029335a
commit 797cbdcc95

View File

@ -125,7 +125,11 @@ _blkInc:
; Sets Z according to whether read was successful: Set if successful, unset
; if not.
blkGetC:
push ix
ld ix, BLOCKDEV_SEL
call _blkGetC
pop ix
ret
_blkGetC:
push hl
push de
@ -138,7 +142,11 @@ _blkGetC:
; Writes character in A in current position in the selected device. Sets Z
; according to whether the operation was successful.
blkPutC:
push ix
ld ix, BLOCKDEV_SEL
call _blkPutC
pop ix
ret
_blkPutC:
push ix
push hl
@ -155,7 +163,11 @@ _blkPutC:
; Reads B chars from blkGetC and copy them in (HL).
; Sets Z if successful, unset Z if there was an error.
blkRead:
push ix
ld ix, BLOCKDEV_SEL
call _blkRead
pop ix
ret
_blkRead:
push hl
push bc
@ -174,7 +186,11 @@ _blkRead:
; Writes B chars to blkPutC from (HL).
; Sets Z if successful, unset Z if there was an error.
blkWrite:
push ix
ld ix, BLOCKDEV_SEL
call _blkWrite
pop ix
ret
_blkWrite:
push hl
push bc
@ -207,7 +223,11 @@ _blkWrite:
; If the device is "growable", it's possible that seeking to end when calling
; PutC doesn't necessarily result in a failure.
blkSeek:
push ix
ld ix, BLOCKDEV_SEL
call _blkSeek
pop ix
ret
_blkSeek:
cp BLOCKDEV_SEEK_FORWARD
jr z, .forward
@ -275,7 +295,11 @@ _blkSeek:
; Returns the current position of the selected device in HL (low) and DE (high).
blkTell:
push ix
ld ix, BLOCKDEV_SEL
call _blkTell
pop ix
ret
_blkTell:
ld e, (ix+4)
ld d, (ix+5)