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.
Kernal LOAD does not always return an error when failing
-
- Posts: 292
- Joined: Wed Jun 03, 2020 11:33 am
- Location: Kalmar, Sweden
- desertfish
- Posts: 1135
- Joined: Tue Aug 25, 2020 8:27 pm
- Location: Netherlands
Re: Kernal LOAD does not always return an error when failing
If you're running on hostfs, this was an emulator issue that got fixed in https://github.com/X16Community/x16-emulator/pull/109
-
- Posts: 292
- Joined: Wed Jun 03, 2020 11:33 am
- Location: Kalmar, Sweden
Re: Kernal LOAD does not always return an error when failing
Ok, fine. Then it will work in R44 as I understand it.
- desertfish
- Posts: 1135
- Joined: Tue Aug 25, 2020 8:27 pm
- Location: Netherlands
Re: Kernal LOAD does not always return an error when failing
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.
-
- Posts: 292
- Joined: Wed Jun 03, 2020 11:33 am
- Location: Kalmar, Sweden
Re: Kernal LOAD does not always return an error when failing
Thanks for the tip! I didn’t know about that.