6

On a Commodore 64, I have a custom interrupt routine running in parallel with a main program, and I need to detect if the KERNAL is currently performing a LOAD or SAVE operation via I/O. Unfortunately, I cannot modify the main program's code to signal the start and end of these operations because the main program comes from an external source with a fixed codebase.

I'm looking for a minimum-invasive solution to detect when the LOAD or SAVE routine is active. Specifically, I would like to know:

  1. Is there a Zero Page variable or memory location that indicates the current status of a LOAD/SAVE operation?
  2. I noticed that the status variable at address $90 sets Bit 6 ($40 == EOF) after a LOAD operation completes, but this doesn't help in detecting when a LOAD begins, and its value is $00 after a reset.
  3. I prefer not to hook into the vectors if possible, as I want to keep my solution lightweight and avoid extensive modifications.

Is there a reliable way to detect the active state of the KERNAL I/O routines without modifying the main program?

I am looking preferably for a solution that would also work on other CBM 8bit machines (Commodore Pet, VIC 20, Plus/4, C128, etc.).

2
  • 1
    Have you looked at the kernal code to see what it does?CommentedNov 23, 2024 at 16:10
  • 2
    I would argue that hooking into the vectors is far less invasive than relying on knowledge of internal KERNAL state variables. Also more likely to work on multiple types of machineCommentedNov 23, 2024 at 20:10

1 Answer 1

10

The Kernal's load routine starts at $f49e. Right after running into the vector, it sets the load/verify flag at $93. You could put a sentinel value (e.g. $ff) there and check if the load routine has cleared it.

You can do a similar thing for the save routine that starts at $f5dd. It sets the end address of the blob to save in $ae/$af. Put sentinel values $00/$00 there and check if the save routine has set those.

2
  • 1
    How do you know when it's finished?
    – JeremyP
    CommentedNov 24, 2024 at 17:21
  • For the load routine, as OP wrote, put a sentinel at $90. For the save routine I haven't found a way, sorry.
    – Janka
    CommentedNov 24, 2024 at 23:59

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.