mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-25 17:38:05 +11:00
blockdev: fix load command over-loading a byte
Calling `load` would always read one more byte than specified. Also, make `0` mean `0x100`.
This commit is contained in:
parent
bd2877e012
commit
8cf9904f33
@ -44,9 +44,10 @@ blkSeekCmd:
|
|||||||
xor a
|
xor a
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; Load the specified number of bytes (max 0xff) from IO and write them in the
|
; Load the specified number of bytes (max 0x100, 0 means 0x100) from IO and
|
||||||
; current memory pointer (which doesn't change). If the blkdev hits end of
|
; write them in the current memory pointer (which doesn't change). If the
|
||||||
; stream before we reach our specified number of bytes, we stop loading.
|
; blkdev hits end of stream before we reach our specified number of bytes, we
|
||||||
|
; stop loading.
|
||||||
;
|
;
|
||||||
; Returns a SHELL_ERR_IO_ERROR only if we couldn't read any byte (if the first
|
; Returns a SHELL_ERR_IO_ERROR only if we couldn't read any byte (if the first
|
||||||
; call to GetC failed)
|
; call to GetC failed)
|
||||||
@ -63,11 +64,13 @@ blkLoad:
|
|||||||
ld hl, (SHELL_MEM_PTR)
|
ld hl, (SHELL_MEM_PTR)
|
||||||
call blkGetC
|
call blkGetC
|
||||||
jr nz, .ioError
|
jr nz, .ioError
|
||||||
|
jr .intoLoop ; properly dec B + check on first iteration.
|
||||||
.loop:
|
.loop:
|
||||||
ld (hl), a
|
ld (hl), a
|
||||||
inc hl
|
inc hl
|
||||||
call blkGetC
|
call blkGetC
|
||||||
jr nz, .loopend
|
jr nz, .loopend
|
||||||
|
.intoLoop:
|
||||||
djnz .loop
|
djnz .loop
|
||||||
.loopend:
|
.loopend:
|
||||||
; success
|
; success
|
||||||
@ -80,9 +83,9 @@ blkLoad:
|
|||||||
pop bc
|
pop bc
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; Load the specified number of bytes (max 0xff) from the current memory pointer
|
; Load the specified number of bytes (max 0x100, 0 means 0x100) from the current
|
||||||
; and write them to I/O. Memory pointer doesn't move. This puts chars to
|
; memory pointer and write them to I/O. Memory pointer doesn't move. This puts
|
||||||
; blkPutC. Raises error if not all bytes could be written.
|
; chars to blkPutC. Raises error if not all bytes could be written.
|
||||||
;
|
;
|
||||||
; Example: save 42
|
; Example: save 42
|
||||||
blkSaveCmd:
|
blkSaveCmd:
|
||||||
|
Loading…
Reference in New Issue
Block a user