Parcourir la source

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.
pull/10/head
Virgil Dupras il y a 5 ans
Parent
révision
07fde3cab5
3 fichiers modifiés avec 27 ajouts et 27 suppressions
  1. +27
    -0
      parts/blockdev.asm
  2. +0
    -1
      parts/blockdev_cmds.asm
  3. +0
    -26
      parts/mmap.asm

+ 27
- 0
parts/blockdev.asm Voir le fichier

@@ -132,6 +132,33 @@ blkPutC:
; 4 : Move to the beginning
; Set position of selected device to the value specified in HL
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
jr _blkCall



+ 0
- 1
parts/blockdev_cmds.asm Voir le fichier

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


+ 0
- 26
parts/mmap.asm Voir le fichier

@@ -57,32 +57,6 @@ mmapPutC:
ret

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
ret



Chargement…
Annuler
Enregistrer