Page 1 of 1

Kernal LOAD does not always return an error when failing

Posted: Mon May 29, 2023 7:14 pm
by Johan Kårlin
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.

Re: Kernal LOAD does not always return an error when failing

Posted: Mon May 29, 2023 9:05 pm
by desertfish
If you're running on hostfs, this was an emulator issue that got fixed in https://github.com/X16Community/x16-emulator/pull/109

Re: Kernal LOAD does not always return an error when failing

Posted: Tue May 30, 2023 6:52 am
by Johan Kårlin
Ok, fine. Then it will work in R44 as I understand it.

Re: Kernal LOAD does not always return an error when failing

Posted: Tue May 30, 2023 10:49 am
by desertfish
I think so! In the meantime you can use READST and check the result status to detect a load error even when using headerless load.

Re: Kernal LOAD does not always return an error when failing

Posted: Tue May 30, 2023 2:54 pm
by Johan Kårlin
Thanks for the tip! I didn’t know about that.