blkdev: make load command stop and the end of the stream
This allows us to reliably and easily load a file until the end of it.
This commit is contained in:
parent
73c3fc7947
commit
95f1a8ddaf
@ -146,16 +146,6 @@ blkGetC:
|
||||
ld ix, (BLOCKDEV_GETC)
|
||||
jr _blkCall
|
||||
|
||||
; Repeatedly call blkGetC until the call is a success.
|
||||
blkGetCW:
|
||||
ld ix, (BLOCKDEV_GETC)
|
||||
.loop:
|
||||
push ix ; fs messes with IX a lot
|
||||
call callIX
|
||||
pop ix
|
||||
jr nz, .loop
|
||||
ret
|
||||
|
||||
; Reads B chars from blkGetC and copy them in (HL).
|
||||
; Sets Z if successful, unset Z if there was an error.
|
||||
blkRead:
|
||||
|
@ -45,9 +45,11 @@ blkSeekCmd:
|
||||
ret
|
||||
|
||||
; Load the specified number of bytes (max 0xff) from IO and write them in the
|
||||
; current memory pointer (which doesn't change). This gets chars from
|
||||
; blkGetCW.
|
||||
; Control is returned to the shell only after all bytes are read.
|
||||
; current memory pointer (which doesn't change). If the 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
|
||||
; call to GetC failed)
|
||||
;
|
||||
; Example: load 42
|
||||
blkLoadCmd:
|
||||
@ -59,11 +61,15 @@ blkLoad:
|
||||
ld a, (hl)
|
||||
ld b, a
|
||||
ld hl, (SHELL_MEM_PTR)
|
||||
.loop: call blkGetCW
|
||||
call blkGetC
|
||||
jr nz, .ioError
|
||||
.loop:
|
||||
ld (hl), a
|
||||
inc hl
|
||||
call blkGetC
|
||||
jr nz, .loopend
|
||||
djnz .loop
|
||||
.loopend:
|
||||
; success
|
||||
xor a
|
||||
jr .end
|
||||
|
Loading…
Reference in New Issue
Block a user