1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-27 14:08:05 +11:00

blockdev: move the new seek mode logic into the seek command

It wasn't a good idea to complicate all blockdev impls with complicated
seeks. Let's just stay in absolute mode for now.
This commit is contained in:
Virgil Dupras 2019-04-23 08:28:00 -04:00
parent f87cd0485a
commit 07fde3cab5
3 changed files with 27 additions and 27 deletions

View File

@ -132,6 +132,33 @@ blkPutC:
; 4 : Move to the beginning ; 4 : Move to the beginning
; Set position of selected device to the value specified in HL ; Set position of selected device to the value specified in HL
blkSeek: blkSeek:
push de
cp 1
jr z, .forward
cp 2
jr z, .backward
cp 3
jr z, .beginning
cp 4
jr z, .end
; all other modes are considered absolute
jr .seek ; for absolute mode, HL is already correct
.forward:
ex hl, de ; DE has our offset
call blkTell ; HL has our curpos
add hl, de
jr nc, .seek ; no carry? alright!
; we have carry? out of bounds, set to maximum
.backward:
; TODO - subtraction are more complicated...
jr .seek
.beginning:
ld hl, 0
jr .seek
.end:
ld hl, 0xffff
.seek:
pop de
ld iyl, 4 ld iyl, 4
jr _blkCall jr _blkCall

View File

@ -31,7 +31,6 @@ blkSeekCmd:
ld h, a ld h, a
pop af ; bring mode back pop af ; bring mode back
call blkSeek call blkSeek
ld hl, 42
call blkTell call blkTell
ld a, h ld a, h
call printHex call printHex

View File

@ -57,32 +57,6 @@ mmapPutC:
ret ret
mmapSeek: mmapSeek:
cp 1
jr z, .forward
cp 2
jr z, .backward
cp 3
jr z, .beginning
cp 4
jr z, .end
; all other modes are considered absolute
jr .set ; for absolute mode, HL is already correct
.forward:
ld de, (MMAP_PTR)
add hl, de
jr nc, .set
; we have carry? out of bounds, set to maximum
ld hl, 0xffff
jr .set
.backward:
; TODO - subtraction are more complicated...
jr .set
.beginning:
ld hl, 0
jr .set
.end:
ld hl, 0xffff-MMAP_START
.set:
ld (MMAP_PTR), hl ld (MMAP_PTR), hl
ret ret