Kernal LOAD does not always return an error when failing
Posted: Mon May 29, 2023 7:14 pm
I load files with the following routine in the emulator R43:
LoadFile:
;IN: ZP0, ZP1 = filename
; ZP2, ZP3 = load address,
; ZP4 = RAM or VRAM (0 = load, 1 = verify, 2 = VRAM bank 0, 3 = VRAM bank 1)
; ZP5 = header or not (0 = file contains header, 2 = no header)
jsr GetStringLength ;will return length of filename in .A
ldx ZP0
ldy ZP1
jsr SETNAM
lda #$02
ldx #$08 ;device
ldy ZP5 ;header or not
jsr SETLFS
ldx ZP2 ;load address
ldy ZP3
lda ZP4 ;RAM or VRAM
jsr LOAD ;KERNAL routine
rts
When I try to load a headerless file that doesn't exist (by setting .Y to 2 before calling SETLFS), I get no indication that LOAD has failed. I expect the carry flag to be set and an error number in .A. When loading files with headers, everything works.
I asked about this in a Discord when R41 was the latest KERNAL version. I think Zerobyte created an issue about it but I cannot find any open issue relating to this, and I just realized that the problem is still there.
LoadFile:
;IN: ZP0, ZP1 = filename
; ZP2, ZP3 = load address,
; ZP4 = RAM or VRAM (0 = load, 1 = verify, 2 = VRAM bank 0, 3 = VRAM bank 1)
; ZP5 = header or not (0 = file contains header, 2 = no header)
jsr GetStringLength ;will return length of filename in .A
ldx ZP0
ldy ZP1
jsr SETNAM
lda #$02
ldx #$08 ;device
ldy ZP5 ;header or not
jsr SETLFS
ldx ZP2 ;load address
ldy ZP3
lda ZP4 ;RAM or VRAM
jsr LOAD ;KERNAL routine
rts
When I try to load a headerless file that doesn't exist (by setting .Y to 2 before calling SETLFS), I get no indication that LOAD has failed. I expect the carry flag to be set and an error number in .A. When loading files with headers, everything works.
I asked about this in a Discord when R41 was the latest KERNAL version. I think Zerobyte created an issue about it but I cannot find any open issue relating to this, and I just realized that the problem is still there.